[PATCH] [TRIVIAL] opensm/osm_log.h: fix function documentation

2012-09-20 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 include/opensm/osm_log.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/opensm/osm_log.h b/include/opensm/osm_log.h
index 3247296..61ba750 100644
--- a/include/opensm/osm_log.h
+++ b/include/opensm/osm_log.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -427,7 +427,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
 *  [in] New level to set.
 *
 * RETURN VALUES
-*  Returns the current log level.
+*  This function does not return a value.
 *
 * NOTES
 *
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/8] opensm/complib: define if statements with branch prediction hints

2012-09-11 Thread Yevgeny Kliteynik
 
 I would not abstract the 'if' statement.  If CL_PREDICT_FALSE/TRUE are not 
 readable, then shorten those.
 
 if (PF(...))
 
 is just as readable as
 
 if_PF(...)

OK, agree.
I'll issue a v2 shortly - the only difference would be
change in this macro and rebase to the updated trunk.

-- YK

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8 v2] opensm/complib: define macros for for if statements with branch prediction hints

2012-09-11 Thread Yevgeny Kliteynik
Defined PT and PF for predict true
and predict false respectively.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 include/complib/cl_types_osd.h | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/complib/cl_types_osd.h b/include/complib/cl_types_osd.h
index ce1a452..2538913 100644
--- a/include/complib/cl_types_osd.h
+++ b/include/complib/cl_types_osd.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -64,6 +64,18 @@ BEGIN_C_DECLS
 #include inttypes.h
 #include assert.h
 #include string.h
+
+/*
+ * Branch prediction hints
+ */
+#if defined(HAVE_BUILTIN_EXPECT)
+#define PT(exp)__builtin_expect( ((uintptr_t)(exp)), 1 )
+#define PF(exp)__builtin_expect( ((uintptr_t)(exp)), 0 )
+#else
+#define PT(exp)(exp)
+#define PF(exp)(exp)
+#endif
+
 #if defined (_DEBUG_)
 #define CL_ASSERT  assert
 #else  /* _DEBUG_ */
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/8 v2] opensm/libvendor/osm_vendor_ibumad_sa.c: use wrapper function instead of direct access

2012-09-11 Thread Yevgeny Kliteynik
Use existing wrapper function to get to context instead of direct access.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 libvendor/osm_vendor_ibumad_sa.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad_sa.c b/libvendor/osm_vendor_ibumad_sa.c
index 1d482c0..f715cf6 100644
--- a/libvendor/osm_vendor_ibumad_sa.c
+++ b/libvendor/osm_vendor_ibumad_sa.c
@@ -84,9 +84,8 @@ __osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
}

/* obtain the sent context since we store it during send in the ni_ctx 
*/
-   p_query_req_copy =
-   (osmv_query_req_t *) (uintptr_t)(p_req_madw-context.ni_context.
-   node_guid);
+   p_query_req_copy = (osmv_query_req_t *)
+(uintptr_t)(osm_madw_get_ni_context_ptr(p_req_madw)-node_guid);

/* provide the context of the original request in the result */
query_res.query_context = p_query_req_copy-query_context;
@@ -180,9 +179,8 @@ static void __osmv_sa_mad_err_cb(IN void *bind_context, IN 
osm_madw_t * p_madw)
OSM_LOG_ENTER(p_bind-p_log);

/* Obtain the sent context etc */
-   p_query_req_copy =
-   (osmv_query_req_t *) (uintptr_t)(p_madw-context.ni_context.
-   node_guid);
+   p_query_req_copy = (osmv_query_req_t *)
+(uintptr_t)(osm_madw_get_ni_context_ptr(p_madw)-node_guid);

/* provide the context of the original request in the result */
query_res.query_context = p_query_req_copy-query_context;
@@ -433,7 +431,7 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
goto Exit;
}
*p_query_req_copy = *p_query_req;
-   p_madw-context.ni_context.node_guid =
+   osm_madw_get_ni_context_ptr(p_madw)-node_guid =
(ib_net64_t) (uintptr_t)p_query_req_copy;

/* we can support async as well as sync calls */
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/8 v2] opensm/libvendor/osm_vendor_ibumad.c:rename mad to p_mad to indicate pointer

2012-09-11 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 libvendor/osm_vendor_ibumad.c | 44 +--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index b068443..e0c9f90 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -288,7 +288,7 @@ static void *umad_receiver(void *p_ptr)
osm_umad_bind_info_t *p_bind;
osm_mad_addr_t osm_addr;
osm_madw_t *p_madw, *p_req_madw;
-   ib_mad_t *mad;
+   ib_mad_t *p_mad;
void *umad = 0;
int mad_agent, length;

@@ -340,11 +340,11 @@ static void *umad_receiver(void *p_ptr)
continue;
}

-   mad = (ib_mad_t *) umad_get_mad(umad);
+   p_mad = (ib_mad_t *) umad_get_mad(umad);

ib_mad_addr_conv(umad, osm_addr,
-mad-mgmt_class == IB_MCLASS_SUBN_LID ||
-mad-mgmt_class == IB_MCLASS_SUBN_DIR);
+p_mad-mgmt_class == IB_MCLASS_SUBN_LID ||
+p_mad-mgmt_class == IB_MCLASS_SUBN_DIR);

if (!(p_madw = osm_mad_pool_get(p_bind-p_mad_pool,
(osm_bind_handle_t) p_bind,
@@ -367,15 +367,15 @@ static void *umad_receiver(void *p_ptr)

/* if status != 0 then we are handling recv timeout on send */
if (umad_status(p_madw-vend_wrap.umad)) {
-   if (!(p_req_madw = get_madw(p_vend, mad-trans_id,
-   mad-mgmt_class))) {
+   if (!(p_req_madw = get_madw(p_vend, p_mad-trans_id,
+   p_mad-mgmt_class))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
ERR 5412: 
Failed to obtain request madw for 
timed out MAD
 (class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   mad-mgmt_class, mad-method,
-   cl_ntoh16(mad-attr_id),
-   cl_ntoh64(mad-trans_id));
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
} else {
p_req_madw-status = IB_TIMEOUT;
log_send_error(p_vend, p_req_madw);
@@ -394,30 +394,30 @@ static void *umad_receiver(void *p_ptr)
}

p_req_madw = 0;
-   if (ib_mad_is_response(mad) 
-   !(p_req_madw = get_madw(p_vend, mad-trans_id,
-   mad-mgmt_class))) {
+   if (ib_mad_is_response(p_mad) 
+   !(p_req_madw = get_madw(p_vend, p_mad-trans_id,
+   p_mad-mgmt_class))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5413: 
Failed to obtain request madw for received MAD
 (class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   mad-mgmt_class, mad-method,
-   cl_ntoh16((mad)-attr_id),
-   cl_ntoh64(mad-trans_id));
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
continue;
}
 #ifndef VENDOR_RMPP_SUPPORT
-   if ((mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
-   (mad-mgmt_class != IB_MCLASS_SUBN_LID) 
-   (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) mad,
+   if ((p_mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
+   (p_mad-mgmt_class != IB_MCLASS_SUBN_LID) 
+   (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_mad,
 IB_RMPP_FLAG_ACTIVE))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5414: 
class 0x%x method 0x%x RMPP version %d type 
%d flags 0x%x received -- dropping\n,
-   mad-mgmt_class, mad-method,
-   ((ib_rmpp_mad_t *) mad)-rmpp_version,
-   ((ib_rmpp_mad_t *) mad)-rmpp_type,
-   ((ib_rmpp_mad_t *) mad)-rmpp_flags);
+   p_mad-mgmt_class, p_mad-method

[PATCH 6/8 v2] opensm/libvendor/osm_vendor_ibumad.c: validate response MAD properties

2012-09-11 Thread Yevgeny Kliteynik
Check that attribute ID, attribute modifier and
transaction ID are the same in request and response.

Note that just by checking these we cover a very wide
range of possible bugs in SMAs. Attribute modifier is
used in PortInfo, LFT, MFT, and others.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 libvendor/osm_vendor_ibumad.c | 57 ++-
 1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index e0c9f90..ca320a6 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -288,7 +288,7 @@ static void *umad_receiver(void *p_ptr)
osm_umad_bind_info_t *p_bind;
osm_mad_addr_t osm_addr;
osm_madw_t *p_madw, *p_req_madw;
-   ib_mad_t *p_mad;
+   ib_mad_t *p_mad, *p_req_mad;
void *umad = 0;
int mad_agent, length;

@@ -394,18 +394,51 @@ static void *umad_receiver(void *p_ptr)
}

p_req_madw = 0;
-   if (ib_mad_is_response(p_mad) 
-   !(p_req_madw = get_madw(p_vend, p_mad-trans_id,
-   p_mad-mgmt_class))) {
-   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5413: 
-   Failed to obtain request madw for received MAD
-(class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   p_mad-mgmt_class, p_mad-method,
-   cl_ntoh16(p_mad-attr_id),
-   cl_ntoh64(p_mad-trans_id));
-   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
-   continue;
+   if (ib_mad_is_response(p_mad)) {
+   p_req_madw = get_madw(p_vend, p_mad-trans_id,
+ p_mad-mgmt_class);
+   if (PF(!p_req_madw)) {
+   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
+   ERR 5413: Failed to obtain request 
+   madw for received MAD 
+   (class=0x%X method=0x%X attr=0x%X 
+   tid=0x%PRIx64) -- dropping\n,
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
+   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
+   continue;
+   }
+
+   /*
+* Check that request MAD was really a request,
+* and make sure that attribute ID, attribute
+* modifier and transaction ID are the same in
+* request and response.
+*/
+   p_req_mad = osm_madw_get_mad_ptr(p_req_madw);
+   if (PF(ib_mad_is_response(p_req_mad) ||
+  p_mad-attr_id != p_req_mad-attr_id ||
+  p_mad-attr_mod != p_req_mad-attr_mod ||
+  p_mad-trans_id != p_req_mad-trans_id)) {
+   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
+   ERR 541A: 
+   Response MAD validation failed 
+   (request attr=0x%X modif=0x%X 
+   tid=0x%PRIx64, 
+   response attr=0x%X modif=0x%X 
+   tid=0x%PRIx64) -- dropping\n,
+   cl_ntoh16(p_req_mad-attr_id),
+   cl_ntoh32(p_req_mad-attr_mod),
+   cl_ntoh64(p_req_mad-trans_id),
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh32(p_mad-attr_mod),
+   cl_ntoh64(p_mad-trans_id));
+   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
+   continue;
+   }
}
+
 #ifndef VENDOR_RMPP_SUPPORT
if ((p_mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
(p_mad-mgmt_class != IB_MCLASS_SUBN_LID) 
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8 v2] opensm/osm_port_info_rcv.c: check received local_port_num

2012-09-11 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osm_port_info_rcv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/opensm/osm_port_info_rcv.c b/opensm/osm_port_info_rcv.c
index c3bc66c..442bc3f 100644
--- a/opensm/osm_port_info_rcv.c
+++ b/opensm/osm_port_info_rcv.c
@@ -505,6 +505,11 @@ void osm_pi_rcv_process(IN void *context, IN void *data)

CL_ASSERT(p_smp-attr_id == IB_MAD_ATTR_PORT_INFO);

+   /*
+* Attribute modifier has already been validated upon MAD receive,
+* which means that port_num has to be valid - it originated from
+* the request attribute modifier.
+*/
port_num = (uint8_t) cl_ntoh32(p_smp-attr_mod);

port_guid = p_context-port_guid;
@@ -554,6 +559,17 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
p_node = p_port-p_node;
CL_ASSERT(p_node);

+   if (p_pi-local_port_num  p_node-node_info.num_ports) {
+   CL_PLOCK_RELEASE(sm-p_lock);
+   OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F15: 
+   Received PortInfo for port GUID 0x% PRIx64  is 
+   non-compliant and is being ignored since the 
+   local port num %u  num ports %u\n,
+   cl_ntoh64(port_guid), p_pi-local_port_num,
+   p_node-node_info.num_ports);
+   goto Exit;
+   }
+
/*
   If we were setting the PortInfo, then receiving
   this attribute was not part of sweeping the subnet.
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8 v2] opensm/osm_port_info_rcv.c: use PF() hint on fatal conditions

2012-09-11 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osm_port_info_rcv.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/opensm/osm_port_info_rcv.c b/opensm/osm_port_info_rcv.c
index 442bc3f..2a6d037 100644
--- a/opensm/osm_port_info_rcv.c
+++ b/opensm/osm_port_info_rcv.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
@@ -69,7 +69,7 @@
 static void pi_rcv_check_and_fix_lid(osm_log_t * log, ib_port_info_t * pi,
 osm_physp_t * p)
 {
-   if (cl_ntoh16(pi-base_lid)  IB_LID_UCAST_END_HO) {
+   if (PF(cl_ntoh16(pi-base_lid)  IB_LID_UCAST_END_HO)) {
OSM_LOG(log, OSM_LOG_ERROR, ERR 0F04: 
Got invalid base LID %u from the network. 
Corrected to %u\n, cl_ntoh16(pi-base_lid),
@@ -545,7 +545,7 @@ void osm_pi_rcv_process(IN void *context, IN void *data)

CL_PLOCK_EXCL_ACQUIRE(sm-p_lock);
p_port = osm_get_port_by_guid(sm-p_subn, port_guid);
-   if (!p_port) {
+   if (PF(!p_port)) {
CL_PLOCK_RELEASE(sm-p_lock);
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F06: 
No port object for port with GUID 0x% PRIx64
@@ -559,7 +559,7 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
p_node = p_port-p_node;
CL_ASSERT(p_node);

-   if (p_pi-local_port_num  p_node-node_info.num_ports) {
+   if (PF(p_pi-local_port_num  p_node-node_info.num_ports)) {
CL_PLOCK_RELEASE(sm-p_lock);
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F15: 
Received PortInfo for port GUID 0x% PRIx64  is 
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/8] opensm/complib: define if statements with branch prediction hints

2012-08-26 Thread Yevgeny Kliteynik
On 8/26/2012 4:43 PM, Yevgeny Kliteynik wrote:
 
 If you are typing these so often (ie more than in some datastructure
 kernels) that the length is a problem then you really should be using
 profile guided optimization instead...
 
 I'm trying to optimize all the 'if' conditions in the SM.

Obviously, what I meant is that I'm *not* trying to optimize
all the 'if' conditions in the SM...  :)

-- YK

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/8] opensm/configure.in: check that compiler supports __builtin_expect()

2012-08-14 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 configure.in | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/configure.in b/configure.in
index e48c066..eb252ff 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,17 @@ AC_HEADER_TIME
 AC_STRUCT_TM
 AC_C_VOLATILE

+dnl See if we have __builtin_expect
+AC_MSG_CHECKING([if the compiler supports __builtin_expect])
+AC_TRY_COMPILE(, [ return __builtin_expect(1, 1) ? 1 : 0],
+[ have_builtin_expect=yes
+  AC_MSG_RESULT([yes]) ],
+[ have_builtin_expect=no
+  AC_MSG_RESULT([no])  ])
+if test x_$have_builtin_expect = x_yes ; then
+   AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler 
supports __builtin_expect.])
+fi
+
 dnl We use --version-script with ld if possible
 AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
 if test -n `$LD --help  /dev/null 2/dev/null | grep version-script`; then
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] opensm/complib: define if statements with branch prediction hints

2012-08-14 Thread Yevgeny Kliteynik
Defined if_PT and if_PF for predict true
and predict false respectively.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 include/complib/cl_types_osd.h | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/complib/cl_types_osd.h b/include/complib/cl_types_osd.h
index ce1a452..f9abb28 100644
--- a/include/complib/cl_types_osd.h
+++ b/include/complib/cl_types_osd.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -64,6 +64,21 @@ BEGIN_C_DECLS
 #include inttypes.h
 #include assert.h
 #include string.h
+
+/*
+ * Branch prediction hints
+ */
+#if defined(HAVE_BUILTIN_EXPECT)
+#define CL_PREDICT_TRUE(exp)   __builtin_expect( ((uintptr_t)(exp)), 1 )
+#define CL_PREDICT_FALSE(exp)  __builtin_expect( ((uintptr_t)(exp)), 0 )
+#else
+#define CL_PREDICT_TRUE(exp)   (exp)
+#define CL_PREDICT_FALSE(exp)  (exp)
+#endif
+
+#define if_PF(cond)if(CL_PREDICT_FALSE(cond))
+#define if_PT(cond)if(CL_PREDICT_TRUE(cond))
+
 #if defined (_DEBUG_)
 #define CL_ASSERT  assert
 #else  /* _DEBUG_ */
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] opensm/libvendor/osm_vendor_ibumad.c: validate response MAD properties

2012-08-14 Thread Yevgeny Kliteynik
Check that attribute ID, attribute modifier and
transaction ID are the same in request and response.

Note that just by checking these we cover a very wide range
of possible bugs in SMAs. Attribute modifier is used in
PortInfo, LFT, MFT, and others.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 libvendor/osm_vendor_ibumad.c | 57 ++-
 1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index 4d33758..27f7373 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -285,7 +285,7 @@ static void *umad_receiver(void *p_ptr)
osm_umad_bind_info_t *p_bind;
osm_mad_addr_t osm_addr;
osm_madw_t *p_madw, *p_req_madw;
-   ib_mad_t *p_mad;
+   ib_mad_t *p_mad, *p_req_mad;
void *umad = 0;
int mad_agent, length;

@@ -391,18 +391,51 @@ static void *umad_receiver(void *p_ptr)
}

p_req_madw = 0;
-   if (ib_mad_is_response(p_mad) 
-   !(p_req_madw = get_madw(p_vend, p_mad-trans_id,
-   p_mad-mgmt_class))) {
-   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5413: 
-   Failed to obtain request madw for received MAD
-(class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   p_mad-mgmt_class, p_mad-method,
-   cl_ntoh16(p_mad-attr_id),
-   cl_ntoh64(p_mad-trans_id));
-   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
-   continue;
+   if (ib_mad_is_response(p_mad)) {
+   p_req_madw = get_madw(p_vend, p_mad-trans_id,
+ p_mad-mgmt_class);
+   if_PF (!p_req_madw) {
+   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
+   ERR 5413: Failed to obtain request 
+   madw for received MAD 
+   (class=0x%X method=0x%X attr=0x%X 
+   tid=0x%PRIx64) -- dropping\n,
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
+   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
+   continue;
+   }
+
+   /*
+* Check that request MAD was really a request,
+* and make sure that attribute ID, attribute
+* modifier and transaction ID are the same in
+* request and response.
+*/
+   p_req_mad = osm_madw_get_mad_ptr(p_req_madw);
+   if_PF (ib_mad_is_response(p_req_mad) ||
+  p_mad-attr_id != p_req_mad-attr_id ||
+  p_mad-attr_mod != p_req_mad-attr_mod ||
+  p_mad-trans_id != p_req_mad-trans_id) {
+   OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
+   ERR 541A: 
+   Response MAD validation failed 
+   (request attr=0x%X modif=0x%X 
+   tid=0x%PRIx64, 
+   response attr=0x%X modif=0x%X 
+   tid=0x%PRIx64) -- dropping\n,
+   cl_ntoh16(p_req_mad-attr_id),
+   cl_ntoh32(p_req_mad-attr_mod),
+   cl_ntoh64(p_req_mad-trans_id),
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh32(p_mad-attr_mod),
+   cl_ntoh64(p_mad-trans_id));
+   osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
+   continue;
+   }
}
+
 #ifndef VENDOR_RMPP_SUPPORT
if ((p_mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
(p_mad-mgmt_class != IB_MCLASS_SUBN_LID) 
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8] opensm/osm_node_info_rcv.c: using if_PF for all the fatal conditions

2012-08-14 Thread Yevgeny Kliteynik
This is just the first file - similar optimization will be done
on other MADs receivers.

Note that this patch doesn't mess with all the non-fatal cases.
The goal was not to help SM to perform better with all the
validations that it does, but to make sure that the fatal
cases will never be predicted wrong, so any fatal check (existing
or a newely added one) won't affect the SM performance.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 opensm/osm_node_info_rcv.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/opensm/osm_node_info_rcv.c b/opensm/osm_node_info_rcv.c
index 36d8046..2f2aa6d 100644
--- a/opensm/osm_node_info_rcv.c
+++ b/opensm/osm_node_info_rcv.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
@@ -153,7 +153,7 @@ static void ni_rcv_set_links(IN osm_sm_t * sm, osm_node_t * 
p_node,

p_neighbor_node = osm_get_node_by_guid(sm-p_subn,
   p_ni_context-node_guid);
-   if (!p_neighbor_node) {
+   if_PF (!p_neighbor_node) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D10: 
Unexpected removal of neighbor node 0x% PRIx64 \n,
cl_ntoh64(p_ni_context-node_guid));
@@ -430,7 +430,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,
osm_node_init_physp(p_node, port_num, p_madw);

p_port = osm_port_new(p_ni, p_node);
-   if (p_port == NULL) {
+   if_PF (p_port == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D04: 
Unable to create new port object\n);
goto Exit;
@@ -443,7 +443,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,
(osm_port_t *) cl_qmap_insert(sm-p_subn-port_guid_tbl,
  p_ni-port_guid,
  p_port-map_item);
-   if (p_port_check != p_port) {
+   if_PF (p_port_check != p_port) {
/*
   We should never be here!
   Somehow, this port GUID already exists in the table.
@@ -458,7 +458,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,

p_alias_guid = osm_alias_guid_new(p_ni-port_guid,
  p_port);
-   if (!p_alias_guid) {
+   if_PF (!p_alias_guid) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D11: 
alias guid memory allocation failed
 for port GUID 0x% PRIx64 \n,
@@ -495,7 +495,7 @@ alias_done:
} else {
osm_physp_t *p_physp = osm_node_get_physp_ptr(p_node, port_num);

-   if (p_physp == NULL) {
+   if_PF (p_physp == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D1C: 
No physical port found for node GUID 0x%
PRIx64  port %u. Might be duplicate port 
GUID\n,
@@ -639,7 +639,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
ib_get_node_type_str(p_ni-node_type),
cl_ntoh64(p_ni-node_guid), cl_ntoh64(p_smp-trans_id));

-   if (port_num  p_ni-num_ports) {
+   if_PF (port_num  p_ni-num_ports) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D0A: 
New %s node GUID 0x% PRIx64 is non-compliant and 
is being ignored since the 
@@ -651,7 +651,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
}

p_node = osm_node_new(p_madw);
-   if (p_node == NULL) {
+   if_PF (p_node == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D07: 
Unable to create new node object\n);
goto Exit;
@@ -662,7 +662,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
   ports in the port table.
 */
p_port = osm_port_new(p_ni, p_node);
-   if (p_port == NULL) {
+   if_PF (p_port == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D14: 
Unable to create new port object\n);
osm_node_delete(p_node);
@@ -675,7 +675,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
p_port_check =
(osm_port_t *) cl_qmap_insert(sm-p_subn-port_guid_tbl

[PATCH 5/8] opensm/libvendor/osm_vendor_ibumad.c: rename mad to p_mad to indicate pointer

2012-08-14 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 libvendor/osm_vendor_ibumad.c | 44 +--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index d9ed13a..4d33758 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -285,7 +285,7 @@ static void *umad_receiver(void *p_ptr)
osm_umad_bind_info_t *p_bind;
osm_mad_addr_t osm_addr;
osm_madw_t *p_madw, *p_req_madw;
-   ib_mad_t *mad;
+   ib_mad_t *p_mad;
void *umad = 0;
int mad_agent, length;

@@ -337,11 +337,11 @@ static void *umad_receiver(void *p_ptr)
continue;
}

-   mad = (ib_mad_t *) umad_get_mad(umad);
+   p_mad = (ib_mad_t *) umad_get_mad(umad);

ib_mad_addr_conv(umad, osm_addr,
-mad-mgmt_class == IB_MCLASS_SUBN_LID ||
-mad-mgmt_class == IB_MCLASS_SUBN_DIR);
+p_mad-mgmt_class == IB_MCLASS_SUBN_LID ||
+p_mad-mgmt_class == IB_MCLASS_SUBN_DIR);

if (!(p_madw = osm_mad_pool_get(p_bind-p_mad_pool,
(osm_bind_handle_t) p_bind,
@@ -364,15 +364,15 @@ static void *umad_receiver(void *p_ptr)

/* if status != 0 then we are handling recv timeout on send */
if (umad_status(p_madw-vend_wrap.umad)) {
-   if (!(p_req_madw = get_madw(p_vend, mad-trans_id,
-   mad-mgmt_class))) {
+   if (!(p_req_madw = get_madw(p_vend, p_mad-trans_id,
+   p_mad-mgmt_class))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR,
ERR 5412: 
Failed to obtain request madw for 
timed out MAD
 (class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   mad-mgmt_class, mad-method,
-   cl_ntoh16(mad-attr_id),
-   cl_ntoh64(mad-trans_id));
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
} else {
p_req_madw-status = IB_TIMEOUT;
log_send_error(p_vend, p_req_madw);
@@ -391,30 +391,30 @@ static void *umad_receiver(void *p_ptr)
}

p_req_madw = 0;
-   if (ib_mad_is_response(mad) 
-   !(p_req_madw = get_madw(p_vend, mad-trans_id,
-   mad-mgmt_class))) {
+   if (ib_mad_is_response(p_mad) 
+   !(p_req_madw = get_madw(p_vend, p_mad-trans_id,
+   p_mad-mgmt_class))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5413: 
Failed to obtain request madw for received MAD
 (class=0x%X method=0x%X attr=0x%X 
tid=0x%PRIx64) -- dropping\n,
-   mad-mgmt_class, mad-method,
-   cl_ntoh16((mad)-attr_id),
-   cl_ntoh64(mad-trans_id));
+   p_mad-mgmt_class, p_mad-method,
+   cl_ntoh16(p_mad-attr_id),
+   cl_ntoh64(p_mad-trans_id));
osm_mad_pool_put(p_bind-p_mad_pool, p_madw);
continue;
}
 #ifndef VENDOR_RMPP_SUPPORT
-   if ((mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
-   (mad-mgmt_class != IB_MCLASS_SUBN_LID) 
-   (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) mad,
+   if ((p_mad-mgmt_class != IB_MCLASS_SUBN_DIR) 
+   (p_mad-mgmt_class != IB_MCLASS_SUBN_LID) 
+   (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_mad,
 IB_RMPP_FLAG_ACTIVE))) {
OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5414: 
class 0x%x method 0x%x RMPP version %d type 
%d flags 0x%x received -- dropping\n,
-   mad-mgmt_class, mad-method,
-   ((ib_rmpp_mad_t *) mad)-rmpp_version,
-   ((ib_rmpp_mad_t *) mad)-rmpp_type,
-   ((ib_rmpp_mad_t *) mad)-rmpp_flags);
+   p_mad-mgmt_class, p_mad-method

[PATCH 7/8] opensm/osm_port_info_rcv.c: check received local_port_num

2012-08-14 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osm_port_info_rcv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/opensm/osm_port_info_rcv.c b/opensm/osm_port_info_rcv.c
index c3bc66c..442bc3f 100644
--- a/opensm/osm_port_info_rcv.c
+++ b/opensm/osm_port_info_rcv.c
@@ -505,6 +505,11 @@ void osm_pi_rcv_process(IN void *context, IN void *data)

CL_ASSERT(p_smp-attr_id == IB_MAD_ATTR_PORT_INFO);

+   /*
+* Attribute modifier has already been validated upon MAD receive,
+* which means that port_num has to be valid - it originated from
+* the request attribute modifier.
+*/
port_num = (uint8_t) cl_ntoh32(p_smp-attr_mod);

port_guid = p_context-port_guid;
@@ -554,6 +559,17 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
p_node = p_port-p_node;
CL_ASSERT(p_node);

+   if (p_pi-local_port_num  p_node-node_info.num_ports) {
+   CL_PLOCK_RELEASE(sm-p_lock);
+   OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F15: 
+   Received PortInfo for port GUID 0x% PRIx64  is 
+   non-compliant and is being ignored since the 
+   local port num %u  num ports %u\n,
+   cl_ntoh64(port_guid), p_pi-local_port_num,
+   p_node-node_info.num_ports);
+   goto Exit;
+   }
+
/*
   If we were setting the PortInfo, then receiving
   this attribute was not part of sweeping the subnet.
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8] opensm/osm_port_info_rcv.c: use if_PF() on fatal conditions

2012-08-14 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osm_port_info_rcv.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/opensm/osm_port_info_rcv.c b/opensm/osm_port_info_rcv.c
index 442bc3f..829628f 100644
--- a/opensm/osm_port_info_rcv.c
+++ b/opensm/osm_port_info_rcv.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
@@ -69,7 +69,7 @@
 static void pi_rcv_check_and_fix_lid(osm_log_t * log, ib_port_info_t * pi,
 osm_physp_t * p)
 {
-   if (cl_ntoh16(pi-base_lid)  IB_LID_UCAST_END_HO) {
+   if_PF (cl_ntoh16(pi-base_lid)  IB_LID_UCAST_END_HO) {
OSM_LOG(log, OSM_LOG_ERROR, ERR 0F04: 
Got invalid base LID %u from the network. 
Corrected to %u\n, cl_ntoh16(pi-base_lid),
@@ -545,7 +545,7 @@ void osm_pi_rcv_process(IN void *context, IN void *data)

CL_PLOCK_EXCL_ACQUIRE(sm-p_lock);
p_port = osm_get_port_by_guid(sm-p_subn, port_guid);
-   if (!p_port) {
+   if_PF (!p_port) {
CL_PLOCK_RELEASE(sm-p_lock);
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F06: 
No port object for port with GUID 0x% PRIx64
@@ -559,7 +559,7 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
p_node = p_port-p_node;
CL_ASSERT(p_node);

-   if (p_pi-local_port_num  p_node-node_info.num_ports) {
+   if_PF (p_pi-local_port_num  p_node-node_info.num_ports) {
CL_PLOCK_RELEASE(sm-p_lock);
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0F15: 
Received PortInfo for port GUID 0x% PRIx64  is 
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] configure.in: check that compiler supports __builtin_expect()

2012-07-22 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 configure.in | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/configure.in b/configure.in
index b2d07bc..0a56da6 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,17 @@ AC_HEADER_TIME
 AC_STRUCT_TM
 AC_C_VOLATILE

+dnl See if we have __builtin_expect
+AC_MSG_CHECKING([if the compiler supports __builtin_expect])
+AC_TRY_COMPILE(, [ return __builtin_expect(1, 1) ? 1 : 0],
+[ have_builtin_expect=yes
+  AC_MSG_RESULT([yes]) ],
+[ have_builtin_expect=no
+  AC_MSG_RESULT([no])  ])
+if test x_$have_builtin_expect = x_yes ; then
+   AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler 
supports __builtin_expect.])
+fi
+
 dnl We use --version-script with ld if possible
 AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
 if test -n `$LD --help  /dev/null 2/dev/null | grep version-script`; then
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] configure.in: check that compiler supports __builtin_expect()

2012-07-22 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 configure.in | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/configure.in b/configure.in
index b2d07bc..0a56da6 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,17 @@ AC_HEADER_TIME
 AC_STRUCT_TM
 AC_C_VOLATILE

+dnl See if we have __builtin_expect
+AC_MSG_CHECKING([if the compiler supports __builtin_expect])
+AC_TRY_COMPILE(, [ return __builtin_expect(1, 1) ? 1 : 0],
+[ have_builtin_expect=yes
+  AC_MSG_RESULT([yes]) ],
+[ have_builtin_expect=no
+  AC_MSG_RESULT([no])  ])
+if test x_$have_builtin_expect = x_yes ; then
+   AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler 
supports __builtin_expect.])
+fi
+
 dnl We use --version-script with ld if possible
 AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
 if test -n `$LD --help  /dev/null 2/dev/null | grep version-script`; then
-- 
1.7.11.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] complib: define if statements with branch prediction hints

2012-07-22 Thread Yevgeny Kliteynik
Similar to likely and unlikely that are used in kernel,
defined if_PT and if_PF for predict true and predict
false respectively.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 include/complib/cl_types_osd.h | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/complib/cl_types_osd.h b/include/complib/cl_types_osd.h
index ce1a452..f9abb28 100644
--- a/include/complib/cl_types_osd.h
+++ b/include/complib/cl_types_osd.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -64,6 +64,21 @@ BEGIN_C_DECLS
 #include inttypes.h
 #include assert.h
 #include string.h
+
+/*
+ * Branch prediction hints
+ */
+#if defined(HAVE_BUILTIN_EXPECT)
+#define CL_PREDICT_TRUE(exp)   __builtin_expect( ((uintptr_t)(exp)), 1 )
+#define CL_PREDICT_FALSE(exp)  __builtin_expect( ((uintptr_t)(exp)), 0 )
+#else
+#define CL_PREDICT_TRUE(exp)   (exp)
+#define CL_PREDICT_FALSE(exp)  (exp)
+#endif
+
+#define if_PF(cond)if(CL_PREDICT_FALSE(cond))
+#define if_PT(cond)if(CL_PREDICT_TRUE(cond))
+
 #if defined (_DEBUG_)
 #define CL_ASSERT  assert
 #else  /* _DEBUG_ */
-- 
1.7.11.1


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] opensm/osm_node_info_rcv.c: using if_PF for all the fatal conditions

2012-07-22 Thread Yevgeny Kliteynik

This is just the first file - similar optimization will be done
on other MADs receivers.

Note that this patch doesn't mess with all the non-fatal cases.
The goal was not to help SM to perform better with all the
validations that it does (which, of course, can be addressed in
a separate patch), but to make sure that the fatal cases will
never be predicted wrong, so any fatal check won't affect the
SM performance.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 opensm/osm_node_info_rcv.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/opensm/osm_node_info_rcv.c b/opensm/osm_node_info_rcv.c
index 58c92b9..10055ef 100644
--- a/opensm/osm_node_info_rcv.c
+++ b/opensm/osm_node_info_rcv.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
@@ -152,7 +152,7 @@ static void ni_rcv_set_links(IN osm_sm_t * sm, osm_node_t * 
p_node,

p_neighbor_node = osm_get_node_by_guid(sm-p_subn,
   p_ni_context-node_guid);
-   if (!p_neighbor_node) {
+   if_PF (!p_neighbor_node) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D10: 
Unexpected removal of neighbor node 0x% PRIx64 \n,
cl_ntoh64(p_ni_context-node_guid));
@@ -415,7 +415,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,
osm_node_init_physp(p_node, port_num, p_madw);

p_port = osm_port_new(p_ni, p_node);
-   if (p_port == NULL) {
+   if_PF (p_port == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D04: 
Unable to create new port object\n);
goto Exit;
@@ -428,7 +428,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,
(osm_port_t *) cl_qmap_insert(sm-p_subn-port_guid_tbl,
  p_ni-port_guid,
  p_port-map_item);
-   if (p_port_check != p_port) {
+   if_PF (p_port_check != p_port) {
/*
   We should never be here!
   Somehow, this port GUID already exists in the table.
@@ -443,7 +443,7 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,

p_alias_guid = osm_alias_guid_new(p_ni-port_guid,
  p_port);
-   if (!p_alias_guid) {
+   if_PF (!p_alias_guid) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D11: 
alias guid memory allocation failed
 for port GUID 0x% PRIx64 \n,
@@ -615,7 +615,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
cl_ntoh64(p_ni-node_guid), cl_ntoh64(p_smp-trans_id));

p_node = osm_node_new(p_madw);
-   if (p_node == NULL) {
+   if_PF (p_node == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D07: 
Unable to create new node object\n);
goto Exit;
@@ -626,7 +626,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
   ports in the port table.
 */
p_port = osm_port_new(p_ni, p_node);
-   if (p_port == NULL) {
+   if_PF (p_port == NULL) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D14: 
Unable to create new port object\n);
osm_node_delete(p_node);
@@ -639,7 +639,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)
p_port_check =
(osm_port_t *) cl_qmap_insert(sm-p_subn-port_guid_tbl,
  p_ni-port_guid, p_port-map_item);
-   if (p_port_check != p_port) {
+   if_PF (p_port_check != p_port) {
/*
   We should never be here!
   Somehow, this port GUID already exists in the table.
@@ -662,7 +662,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const 
osm_madw_t * p_madw)

p_alias_guid = osm_alias_guid_new(p_ni-port_guid,
  p_port);
-   if (!p_alias_guid) {
+   if_PF (!p_alias_guid) {
OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 0D18: 
alias guid memory allocation failed
 for port GUID 0x% PRIx64 \n,
@@ -697,7 +697,7 @@ alias_done2:
/* If there were RouterInfo or other router attribute,
   this would

Re: [OMPI users] Problems when running open-MPI on OFED

2012-01-03 Thread Yevgeny Kliteynik
On 29-Dec-11 7:10 PM, Venkateswara Rao Dokku wrote:
 Yes, Previously we could run those tests, but after adding some changes we 
 see those errors,,...
 can you please suggest why those errors will occur?

I would strongly suggest to have the usual IB tests running
before even trying to run OMPI - these tests are going to be
way more easy to debug. OMPI have lots of components and layers,
and debugging driver with OMPI won't be pretty.

Please address your questions to Linux RDMA mailing 
list:linux-rdma@vger.kernel.org
You can find all the relevant experts there.

-- YK

 On Thu, Dec 29, 2011 at 4:06 PM, Yevgeny Kliteynik 
 klit...@dev.mellanox.co.il mailto:klit...@dev.mellanox.co.il wrote:
 
 Hi,
 
 Does OMPI with IMP work OK on the official OFED release?
 Do the usual ibv performance tests (ibv_rc_*) work on your customized 
 OFED?
 
 -- YK
 
 On 29-Dec-11 9:34 AM, Venkateswara Rao Dokku wrote:
   Hi,
We tried running the Intel Benchmarks(IMB_3.2) on the customized 
 OFED(that was build by us).. While executing the tests we are getting the 
 following errors
   1.
   
 --
   The OpenFabrics stack has reported a network error event.  Open MPI
   will try to continue, but your job may end up failing.
  
  Local host:localhost.localdomain
  MPI process PID:   5259
  Error number:  2 (IBV_EVENT_QP_REQ_ERR)
  
   This error may indicate connectivity problems within the fabric;
   please contact your system administrator.
   
 --
   2.
   While executing the Reduce_scatter benchmark..
   [localhost.localdomain:04437] *** An error occurred in 
 MPI_Reduce_scatter
   [localhost.localdomain:04437] *** on communicator MPI COMMUNICATOR 3 
 SPLIT FROM 0
   [localhost.localdomain:04437] *** MPI_ERR_TRUNCATE: message truncated
   [localhost.localdomain:04437] *** MPI_ERRORS_ARE_FATAL (your MPI job 
 will now abort)
   
 --
  
  
  
   What is the root cause for those errors??, and any suggestions on how 
 to remove those errors..!!!
  
   Thanks for your reply..
  
  
   --
   Thanks  Regards,
   D.Venkateswara Rao,
  
  
  
  
   ___
   users mailing list
   us...@open-mpi.org mailto:us...@open-mpi.org
   http://www.open-mpi.org/mailman/listinfo.cgi/users
 
 
 
 
 -- 
 Thanks  Regards,
 D.Venkateswara Rao,
 Software Engineer,One Convergence Devices Pvt Ltd.,
 Jubille Hills,Hyderabad.
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: OpenSM plugin patch request

2011-10-13 Thread Yevgeny Kliteynik

Hi Karl,


The idea in that if the received event is = OSM_EVENT_ID_MAX,

then the plug-in knows that something went wrong (wrong version,

something changed in API, etc).


Also, you might want to know about more stuff if you're pulling
topology/routing info from SM, such as when SM became stand-by
and when it became master, and when re-route was done.

Please see this patch for reference:


http://www.mail-archive.com/linux-rdma@vger.kernel.org/msg02206.html


It wasn't applied as is back then, but you might want it now.


-- YK



On 13-Oct-11 4:50 AM, Karl Schulz wrote:


Thanks Ira,

My apologies for not following the conventional standard.  Should I generate a 
new patch?

-k

On Oct 12, 2011, at 5:13 PM, Ira Weiny wrote:


I think this is a reasonable idea.

Comment on the patch.

-   OSM_EVENT_ID_MAX
+   OSM_EVENT_ID_MAX,
+   OSM_EVENT_ID_LIGHT_SWEEP_START, 
+   OSM_EVENT_ID_LIGHT_SWEEP_DONE,  

Traditionally the MAX value in the enum is kept at the end.

Ira


On Wed, 12 Oct 2011 14:31:07 -0700
Karl Schulzk...@tacc.utexas.edu  wrote:


Hello,

Would it be possible to consider exposing light-sweep events to the current 
OpenSM plugin interface?  Something along the lines of the attached patch is 
what we are using locally against opensm-3.3.9.

The motivation is to support a plugin module we have written to expose topology 
information to a query service which can be used by MPI stacks (in user-space) 
for topology-aware optimization and for topology-aware scheduling via batch 
systems.

Thanks for the consideration,

Karl



--
Ira Weiny
Member of Technical Staff
Lawrence Livermore National Lab
925-423-8008
wei...@llnl.gov

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


OSM doesn't send notice on traps 129, 130 and 131

2011-03-13 Thread Yevgeny Kliteynik
It appears that SM is not sending notice on receiving traps 129, 130 and 131. 

From osm_trap_rcv.c: 

547  /* If we reached here due to trap 129/130/131 - do not need to do 
548 the notice report. Just goto exit. We know this is the case 
549 if physp_change_trap is TRUE. */ 
550 if (physp_change_trap == TRUE) 
551goto Exit; 

Does anybody knows why? Spec doesn't say that SM shouldn't send notice on these 
traps. Is this a bug?

-- YK
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pensm/osm_qos_parser: QOS parser doesn't work after syntax error

2011-03-07 Thread Yevgeny Kliteynik
If there was a syntax error in the QoS policy file,
any subsequent parsing fails, even if the error is fixed.
The reason is that the parser doesn't clean its buffer -
need to clean it explicitly when exiting parsing.

Signed-off-by: Aviad Yehezkel avia...@mellanox.co.il
Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_qos_parser_l.l |4 
 opensm/opensm/osm_qos_parser_y.y |4 
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_qos_parser_l.l b/opensm/opensm/osm_qos_parser_l.l
index 4633e0e..559974b 100644
--- a/opensm/opensm/osm_qos_parser_l.l
+++ b/opensm/opensm/osm_qos_parser_l.l
@@ -355,6 +355,10 @@ QUOTED_TEXT \[^\]*\

 .   { SAVE_POS; yylval = strdup(yytext); return TK_TEXT;}

+EOF {
+YY_NEW_FILE;
+yyterminate();
+}
 %%


diff --git a/opensm/opensm/osm_qos_parser_y.y b/opensm/opensm/osm_qos_parser_y.y
index 7118b79..51f72e3 100644
--- a/opensm/opensm/osm_qos_parser_y.y
+++ b/opensm/opensm/osm_qos_parser_y.y
@@ -149,6 +149,7 @@ extern char * yytext;
 extern int yylex (void);
 extern FILE * yyin;
 extern int errno;
+extern void yyrestart(FILE *input_file);
 int yyparse();

 #define RESET_BUFFER  __parser_tmp_struct_reset()
@@ -2354,7 +2355,10 @@ int osm_qos_parse_policy_file(IN osm_subn_t * p_subn)

   Exit:
 if (yyin)
+{
+yyrestart(yyin);
 fclose(yyin);
+}
 OSM_LOG_EXIT(p_qos_parser_osm_log);
 return res;
 }
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: ibdiagpath broken with TCL 8.5

2011-03-03 Thread Yevgeny Kliteynik
 IBDIAGPATH from: /usr/lib64/ibdiagpath1.5.6
 -W- Topology file is not specified.
  Reports regarding cluster links will use direct routes.
 Loading IBDM from: /usr/lib64/ibdm1.5.6
 -I- Using port 1 as the local port.

 -I---
 -I- Traversing the path from local to source
 -I---

 -I---
 -I- Traversing the path from source to destination
 -I---
 -I- From: lid=0x0001 guid=0x00117578aca6 dev=29474 ifs004/P1
 -I- To:   lid=0x0003 guid=0x00066a01e5000108 dev=29472 Port=8

 -I- From: lid=0x0003 guid=0x00066a01e5000108 dev=29472 Port=8
 -I- To:   lid=0x0001 guid=0x00117578aca6 dev=29474 ifs004/P1

 can't read PATH(1): no such element in array
 [root@ifs004 1]#


 The problem appears to be occurring in this code fragment:

  if {[info exists NODE]} {
  for {set i 0} {$i  [llength [array names NODE
 *,PortGUID]]} {incr i} {
  set portGuid $NODE($i,PortGUID)
  set nodeGuid $G(data:NodeGuid.$portGuid)
  if {$i % 2} {
  set portNum $NODE($i,EntryPort)
  } else {
  set portNum [lindex [split $PATH([expr $i + 1]) ,]
 end]  -- Bug here. Line 2381, ibdebug_if.tcl
  }
  lappend CSV_ERRORS
 $CSV_scope,$nodeGuid,$portGuid,$portNum,$desc,$msgBody,$CSV_severity,$e
 xid,$err_type
  }
  } else {
  lappend CSV_ERRORS
 $CSV_scope,$nodeGuid,$portGuid,$portNum,$desc,$msgBody,$CSV_severity,$e
 xid,$err_type
  }
  }

 I don't know if it matters, but I'm testing with a one-port HCA. I
 added a puts in the offending code and got this:

 MHEINZ: i = 0. PATH(0) = 1
 can't read PATH(1): no such element in array

 Please let me know if there are any tests I can run for you.

 -Original Message-
 From: Mike Heinz
 Sent: Monday, February 21, 2011 10:40 AM
 To: 'klit...@dev.mellanox.co.il'; John Jolly
 Cc: e...@lists.openfabrics.org; Linux RDMA; Todd Rimmer; Eli Dorfman
 (Voltaire)
 Subject: RE: Patch breaks OFED 1.5.3: [ewg] [PATCH] ibdiagpath:
 Properly index VlArbTable during QoS test

 Yevgeny,

 It did occur to me that this is a version issue; I tested with TCL 8.4,
 which is the version included in RHEL5 and SLES10. The newest version
 appears to be 8.5, skimming through the release notes I didn't see
 anything about languages changes, but if it's working for you then
 obviously the language has been changed.

 The thing is, I also noticed that John's original complaint - about an
 extra item in the array - did not seem to be true on the RHEL 5.x boxes
 I tried, which is why I suggested that the entire change should be
 rolled back.

 I'm building RC4 on a Red Hat 6 box now, I'll see if it makes a
 difference.

 -Original Message-
 From: Yevgeny Kliteynik [mailto:klit...@dev.mellanox.co.il]
 Sent: Sunday, February 20, 2011 9:05 AM
 To: Mike Heinz; John Jolly
 Cc: e...@lists.openfabrics.org; Linux RDMA; Todd Rimmer; Eli Dorfman
 (Voltaire)
 Subject: Re: Patch breaks OFED 1.5.3: [ewg] [PATCH] ibdiagpath:
 Properly index VlArbTable during QoS test

 Mike,

 This looks like a different tcl versions/implementation issue.

 I certainly can replace $i+1 with [expr $i+1], but I'm not
 sure about reverting the patch.

 John,

 What tcl version have you used?

 -- YK



 On 07-Feb-11 6:44 PM, Mike Heinz wrote:
 The version of  ibdiagpath included with OFED 1.5.3-rc3 contains
 syntax errors which prevent it from executing on the systems I've
 tested (using TCL 8.4).  Attempts to use ibdiagpath fail with an error
 message:

 -I---
 -I- QoS on Path Check
 -I---
 bad index 0+1: must be integer or end?-integer?

 After doing some research and debugging, I traced the problem to a
 patch applied back in October:

 commit f3cf1f7c15ca24598fdf68b9ba71788b386b2f14
 Author: John Jollyjjo...@novell.com
 Date:   Wed Oct 6 17:29:48 2010 +0200

   ibdiagpath: Properly index VlArbTable during QoS test

   Description: ibdiagpath: Properly index VlArbTable during QoS
 test
   Symptom: Error 'invalid bareword vl_entry' during QoS on
Path Check
   Problem: The 'dump' command within the smVlArbTableMad
 command
appends '-vl_entry' to the beginning of the array.
The ibdebug.tcl script does not properly handle
 this
extra element at the beginning of the array.
   Solution:Offset the index value by one when referencing the
array.

   Signed-off-by: John Jollyjjo...@novell.com
   Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il

 Unfortunately, this patch isn't valid TCL code (at least not in TCL
 8.4) and does not appear

Re: Patch breaks OFED 1.5.3: [ewg] [PATCH] ibdiagpath: Properly index VlArbTable during QoS test

2011-02-20 Thread Yevgeny Kliteynik
Mike,

This looks like a different tcl versions/implementation issue.

I certainly can replace $i+1 with [expr $i+1], but I'm not
sure about reverting the patch.

John,

What tcl version have you used?

-- YK



On 07-Feb-11 6:44 PM, Mike Heinz wrote:
 The version of  ibdiagpath included with OFED 1.5.3-rc3 contains syntax 
 errors which prevent it from executing on the systems I've tested (using TCL 
 8.4).  Attempts to use ibdiagpath fail with an error message:
 
 -I---
 -I- QoS on Path Check
 -I---
 bad index 0+1: must be integer or end?-integer?
 
 After doing some research and debugging, I traced the problem to a patch 
 applied back in October:
 
 commit f3cf1f7c15ca24598fdf68b9ba71788b386b2f14
 Author: John Jollyjjo...@novell.com
 Date:   Wed Oct 6 17:29:48 2010 +0200
 
  ibdiagpath: Properly index VlArbTable during QoS test
 
  Description: ibdiagpath: Properly index VlArbTable during QoS test
  Symptom: Error 'invalid bareword vl_entry' during QoS on
   Path Check
  Problem: The 'dump' command within the smVlArbTableMad command
   appends '-vl_entry' to the beginning of the array.
   The ibdebug.tcl script does not properly handle this
   extra element at the beginning of the array.
  Solution:Offset the index value by one when referencing the
   array.
 
  Signed-off-by: John Jollyjjo...@novell.com
  Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 
 Unfortunately, this patch isn't valid TCL code (at least not in TCL 8.4) and 
 does not appear to be needed at all.
 
 For example:
 
 set entry [lindex $values $i+1]
 
 Is not syntactically correct TCL.  In order for it to be correct it would 
 have to be
 
 set entry [lindex $values [expr $i+1]]
 
 However, the patch does not appear to be needed at all. Reverting the patch, 
 allows ibdiagpath to complete successfully:
 
 -I---
 -I- QoS on Path Check
 -I---
 -W- Blocked VLs:3 4 5 at node:homer lid=0x0002 guid=0x00066a00a000707f 
 dev=25208  port:1
 -W- SLs:3 4 5 6 7 8 9 10 11 12 13 14 15 are blocked due to VLArb node:homer
  lid=0x0002 guid=0x00066a00a000707f dev=25208 in-port:0 out-port:1
 -W- Blocked VLs:3 4 5 at node: lid=0x0001 guid=0x00066a00d9000275 dev=47396
  port:21
 -W- SLs:3 4 5 6 7 8 9 10 11 12 13 14 15 mapped to VL  5 at node: lid=0x0001
  guid=0x00066a00d9000275 dev=47396 in-port:14 out-port:21
 -I- The following SLs can be used:0 1 2
 
 This message and any attached documents contain information from QLogic 
 Corporation or its wholly-owned subsidiaries that may be confidential. If you 
 are not the intended recipient, you may not read, copy, distribute, or use 
 this information. If you have received this transmission in error, please 
 notify the sender immediately by reply e-mail and then delete this message.
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] fix rpmbuild with and w/o ibmgtsim build

2011-01-05 Thread Yevgeny Kliteynik
On 06-Jan-11 2:57 AM, Ira Weiny wrote:
 
 [PATCH] fix rpmbuild with and w/o ibmgtsim build
 
 
 Signed-off-by: Ira Weinywei...@hype137.llnl.gov
 ---

Thanks, applied.

-- Yevgeny
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ibutils:Update requirements for building and installing

2011-01-05 Thread Yevgeny Kliteynik
On 06-Jan-11 3:34 AM, Ira Weiny wrote:
 
 [PATCH] Update requirements for building and installing
 
 
 Signed-off-by: Ira Weinywei...@hype137.llnl.gov


Thanks, applied.

-- Yevgeny
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Subnet management on non pure fat-tree network‏

2010-11-29 Thread Yevgeny Kliteynik
On 29-Nov-10 12:18 AM, Reid O wrote:
 
 Hello,
We have an Infiniband cluster in a fat tree configuration with 8 core 
 switches and
 12 leaf switches.  The compute nodes are all in enclosures connected to the 12
 leaf switches.  However, we have a number of non-compute nodes (admin,
 login and storage nodes) that we have connected directly to the core
 switches.  Initially, we were getting credit-loop issues so we switched
 from Min Hop to UPDN routing.  However, now 90% of our IB traffic seems
 to be routed through a single core switch.  I have tried adding a root
 guid file with the -a option, but that results in us getting this error:
 
 Nov
 28 16:47:19 319442 [45007960] 0x01 -  __osm_pr_rcv_get_path_parms:
 ERR 1F07: Dead end on path to LID 0x6F from switch for GUID
 0x00066a00d9000ac8
 Nov 28 16:47:22 319469 [43C05960] 0x01 -
 __osm_pr_rcv_get_path_parms: ERR 1F07: Dead end on path to LID 0x6F
 from switch for GUID 0x00066a00d9000ac8
 
 Is there any way we can handle this hardware config via subnet management?

I'm only guessing, but here's what I understand from your description:
You have 8 spine switches, and 12 leaf switches.
ANY of the spine switches is connected to ALL the leaf switches.
You have compute nodes connected to ALL the leaf switches.
You have some management/IO nodes connected to SEVERAL spine switches.

Am I right so far?

You get credit loops because of the traffic between management/IO nodes.
Up/Down routing with root nodes list doesn't solve you problem - it
prevents credit loops, but this is only because it doesn't connect
those management/IO nodes (hence the error that you see in the OSM log).

The real solution would be changing the topology.

If it's not an option, you can select a SINGLE leaf switch as a root
node, and run Up/Down routing with root guid list with this leaf switch
as a root. This is bad for BW, but it will solve the problem.

-- Yevgeny

 Thanks,
 
 Reid O.   
   
 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [opensm] RFC: new routing options

2010-10-12 Thread Yevgeny Kliteynik
Hi Al,

This looks really great!
One question: have you tried benchmarking the BW with up/down
routing using the guid_routing_order_file option w/o your new
features?

-- YK

On 08-Oct-10 7:40 PM, Albert Chu wrote:
 Hey Sasha,
 
 We recently got a new cluster and I've been experimenting with some
 routing changes to improve the average bandwidth of the cluster.  They
 are attached as patches with description of the routing goals below.
 
 We're using mpiGraph (http://sourceforge.net/projects/mpigraph/) to
 measure min, peak, and average send/recv bandwidth across the cluster.
 What we found with the original updn routing was an average of around
 420 MB/s send bandwidth and 508 MB/s recv bandwidth.  The following two
 patches were able to get the average send bandwidth up to 1045 MB/s and
 recv bandwidth up to 1228 MB/s.
 
 I'm sure this is only round 1 of the patches and I'm looking for
 comments.  Many areas could be cleaned up w/ some rearchitecture or
 struct changes, but I simply implemented the most non-invasive
 implementation first.  I'm also open to name changes on the options.
 
 BTW, b/c of the old management tree on the git server, the following
 patches were developed on an internal LLNL tree.  I'll rebase after the
 up2date tree is on the openfabrics server.
 
 1) Port Shifting
 
 This is similar to what was done with some of the LMC  0 code.
 Congestion would occur due to alignment of routes w/ common traffic
 patterns.  However, we found that it was also necessary for LMC=0 and
 only for used-ports.  For example, lets say there are 4 ports (called A,
 B, C, D) and we are routing lids 1-9 through them.  Suppose only routing
 through A, B, and C will reach lids 1-9.
 
 The LFT would normally be:
 
 A: 1 4 7
 B: 2 5 8
 C: 3 6 9
 D:
 
 The Port Shifting would make this:
 
 A: 1 6 8
 B: 2 4 9
 C: 3 5 7
 D:
 
 This option by itself improved the mpiGraph average send/recv bandwidth
 from 420 MB/s and 508 MB/s to to 991 MB/s and 1172 MB/s.
 
 2) Remote Guid Sorting
 
 Most core/spine switches we've seen have had line boards connected to
 spine boards in a consistent pattern.  However, we recently got some
 Qlogic switches that connect from line/leaf boards to spine boards in a
 (to the casual observer) random pattern.  I'm sure there was a good
 electrical/board reason for this design, but it does hurt routing b/c
 some of the opensm routing algorithms didn't account for this
 assumption.  Here's an output from iblinkinfo as an example.
 
 Switch 0x00066a00ec0029b8 ibcore1 L123:
   1801[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  254   19[  ] 
 ibsw55 ( )
   1802[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  253   19[  ] 
 ibsw56 ( )
   1803[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  258   19[  ] 
 ibsw57 ( )
   1804[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  257   19[  ] 
 ibsw58 ( )
   1805[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  256   19[  ] 
 ibsw59 ( )
   1806[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  255   19[  ] 
 ibsw60 ( )
   1807[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  261   19[  ] 
 ibsw61 ( )
   1808[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  262   19[  ] 
 ibsw62 ( )
   1809[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  260   19[  ] 
 ibsw63 ( )
   180   10[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  259   19[  ] 
 ibsw64 ( )
   180   11[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  284   19[  ] 
 ibsw65 ( )
   180   12[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  285   19[  ] 
 ibsw66 ( )
   180   13[  ] ==( 4X 10.0 Gbps Active/  LinkUp)== 2227   19[  ] 
 ibsw67 ( )
   180   14[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  283   19[  ] 
 ibsw68 ( )
   180   15[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  267   19[  ] 
 ibsw69 ( )
   180   16[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  270   19[  ] 
 ibsw70 ( )
   180   17[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  269   19[  ] 
 ibsw71 ( )
   180   18[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  268   19[  ] 
 ibsw72 ( )
   180   19[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  222   17[  ] 
 ibcore1 S117B ( )
   180   20[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  209   19[  ] 
 ibcore1 S211B ( )
   180   21[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  218   21[  ] 
 ibcore1 S117A ( )
   180   22[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  192   23[  ] 
 ibcore1 S215B ( )
   180   23[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==   85   15[  ] 
 ibcore1 S209A ( )
   180   24[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  182   13[  ] 
 ibcore1 S215A ( )
   180   25[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  200   11[  ] 
 ibcore1 S115B ( )
   180   26[  ] ==( 4X 10.0 Gbps Active/  LinkUp)==  129   25[  ] 
 ibcore1 S209B ( )
   180   27[  ] ==( 4X 10.0 Gbps 

osm_vl15intf.c: fixing use-after-free coredump

2010-10-11 Thread Yevgeny Kliteynik
p_madw is freed if responce is not expected.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_vl15intf.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_vl15intf.c b/opensm/opensm/osm_vl15intf.c
index bb2c0c6..c845597 100644
--- a/opensm/opensm/osm_vl15intf.c
+++ b/opensm/opensm/osm_vl15intf.c
@@ -57,13 +57,14 @@
 static void vl15_send_mad(osm_vl15_t * p_vl, osm_madw_t * p_madw)
 {
ib_api_status_t status;
+   boolean_t resp_expected = p_madw-resp_expected;

/*
   Non-response-expected mads are not throttled on the wire
   since we can have no confirmation that they arrived
   at their destination.
 */
-   if (p_madw-resp_expected == TRUE)
+   if (resp_expected)
/*
   Note that other threads may not see the response MAD
   arrive before send() even returns.
@@ -103,7 +104,7 @@ static void vl15_send_mad(osm_vl15_t * p_vl, osm_madw_t * 
p_madw)
   qp0_mads_outstanding will be decremented by send error callback
   (called by osm_vendor_send() */
cl_atomic_dec(p_vl-p_stats-qp0_mads_sent);
-   if (!p_madw-resp_expected)
+   if (!resp_expected)
cl_atomic_dec(p_vl-p_stats-qp0_unicasts_sent);
 }

-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [ewg] [PATCH] ibdiagpath: Properly index VlArbTable during QoS test

2010-10-06 Thread Yevgeny Kliteynik
On 14-Sep-10 5:34 PM, John Jolly wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Description: ibdiagpath: Properly index VlArbTable during QoS test
 Symptom: Error 'invalid bareword vl_entry' during QoS on
   Path Check
 Problem: The 'dump' command within the smVlArbTableMad command
   appends '-vl_entry' to the beginning of the array.
   The ibdebug.tcl script does not properly handle this
   extra element at the beginning of the array.
 Solution:Offset the index value by one when referencing the
   array.
 Problem-ID:  629166
 - ---

Thanks, applied.

-- YK
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] umad.{c,h}: moving stdlib.h include from C to H file

2010-10-04 Thread Yevgeny Kliteynik
umad.h uses size_t type, which requires stdlib.h

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 libibumad/include/infiniband/umad.h |1 +
 libibumad/src/umad.c|1 -
 2 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libibumad/include/infiniband/umad.h 
b/libibumad/include/infiniband/umad.h
index 7ad5e4a..23abf0d 100644
--- a/libibumad/include/infiniband/umad.h
+++ b/libibumad/include/infiniband/umad.h
@@ -34,6 +34,7 @@
 #define _UMAD_H

 #include stdint.h
+#include stdlib.h

 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern C {
diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
index d16e750..45a9423 100644
--- a/libibumad/src/umad.c
+++ b/libibumad/src/umad.c
@@ -46,7 +46,6 @@
 #include sys/ioctl.h
 #include netinet/in.h
 #include dirent.h
-#include stdlib.h
 #include ctype.h

 #include umad.h
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ibstat.c: fix core dump if wrong port phys state is reported

2010-10-04 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 infiniband-diags/src/ibstat.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/infiniband-diags/src/ibstat.c b/infiniband-diags/src/ibstat.c
index f655a13..f51d17b 100644
--- a/infiniband-diags/src/ibstat.c
+++ b/infiniband-diags/src/ibstat.c
@@ -114,7 +114,7 @@ static int port_dump(umad_port_t * port, int alone)
   (unsigned)port-state =
   4 ? port_state_str[port-state] : ???);
printf(%sPhysical state: %s\n, pre,
-  (unsigned)port-state =
+  (unsigned)port-phys_state =
   7 ? port_phy_state_str[port-phys_state] : ???);
printf(%sRate: %d\n, pre, port-rate);
printf(%sBase lid: %d\n, pre, port-base_lid);
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/sa: simplify osm_mcmr_rcv_find_or_create_new_mgrp() function call

2010-09-21 Thread Yevgeny Kliteynik
On 07-Sep-10 11:55 PM, Sasha Khapyorsky wrote:
 
 Simplify osm_mcmr_rcv_find_or_create_new_mgrp() function call so that it
 will return the pointer to created of found MC group.

Looks good.

-- Yevgeny

 Signed-off-by: Sasha Khapyorskysas...@voltaire.com
 ---
   opensm/include/opensm/osm_sa.h |   15 +++
   opensm/opensm/osm_prtn.c   |   20 ++--
   opensm/opensm/osm_sa.c |8 
   opensm/opensm/osm_sa_mcmember_record.c |   21 ++---
   4 files changed, 31 insertions(+), 33 deletions(-)
 
 diff --git a/opensm/include/opensm/osm_sa.h b/opensm/include/opensm/osm_sa.h
 index d516310..7c1061d 100644
 --- a/opensm/include/opensm/osm_sa.h
 +++ b/opensm/include/opensm/osm_sa.h
 @@ -472,22 +472,21 @@ int osm_sa_db_file_load(struct osm_opensm *p_osm);
   * SYNOPSIS
   */
 
 -ib_api_status_t
 -osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, IN ib_net64_t 
 comp_mask,
 -  IN ib_member_rec_t * p_recvd_mcmember_rec,
 -  OUT osm_mgrp_t ** pp_mgrp);
 +osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
 +  IN ib_net64_t comp_mask,
 +  IN ib_member_rec_t *
 +  p_recvd_mcmember_rec);
   /*
   * PARAMETERS
   *   p_sa
   *   [in] Pointer to an osm_sa_t object.
 +*comp_mask
 +*[in] SA query component mask
   *   p_recvd_mcmember_rec
   *   [in] Received Multicast member record
   *
 -*pp_mgrp
 -*[out] pointer the osm_mgrp_t object
 -*
   * RETURN VALUES
 -*IB_SUCCESS, IB_ERROR
 +*The pointer to MC group object found or created, NULL in case of errors
   *
   */
 
 diff --git a/opensm/opensm/osm_prtn.c b/opensm/opensm/osm_prtn.c
 index 4b087a4..6a23c76 100644
 --- a/opensm/opensm/osm_prtn.c
 +++ b/opensm/opensm/osm_prtn.c
 @@ -174,9 +174,8 @@ ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, 
 osm_subn_t * p_subn,
   ib_member_rec_t mc_rec;
   ib_net64_t comp_mask;
   ib_net16_t pkey;
 - osm_mgrp_t *p_mgrp = NULL;
 + osm_mgrp_t *mgrp;
   osm_sa_t *p_sa =p_subn-p_osm-sa;
 - ib_api_status_t status = IB_SUCCESS;
   uint8_t hop_limit;
 
   pkey = p-pkey | cl_hton16(0x8000);
 @@ -197,24 +196,25 @@ ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, 
 osm_subn_t * p_subn,
   mc_rec.pkt_life = p_subn-opt.subnet_timeout;
   mc_rec.sl_flow_hop = ib_member_set_sl_flow_hop(p-sl, 0, hop_limit);
   /* Scope in MCMemberRecord (if present) needs to be consistent with 
 MGID */
 - mc_rec.scope_state = ib_member_set_scope_state(scope, 
 IB_MC_REC_STATE_FULL_MEMBER);
 + mc_rec.scope_state =
 + ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER);
   ib_mgid_set_scope(mc_rec.mgid, scope);
 
   /* don't update rate, mtu */
   comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL |
   IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
 - status = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask,mc_rec,
 - p_mgrp);
 - if (!p_mgrp || status != IB_SUCCESS)
 + mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask,mc_rec);
 + if (!mgrp) {
   OSM_LOG(p_log, OSM_LOG_ERROR,
   Failed to create MC group with pkey 0x%04x\n,
   cl_ntoh16(pkey));
 - if (p_mgrp) {
 - p_mgrp-well_known = TRUE;
 - p-mgrp = p_mgrp;
 + return IB_ERROR;
   }
 
 - return status;
 + mgrp-well_known = TRUE;
 + p-mgrp = mgrp;
 +
 + return IB_SUCCESS;
   }
 
   static uint16_t generate_pkey(osm_subn_t * p_subn)
 diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c
 index ef9872d..812e435 100644
 --- a/opensm/opensm/osm_sa.c
 +++ b/opensm/opensm/osm_sa.c
 @@ -741,10 +741,10 @@ static osm_mgrp_t *load_mcgroup(osm_opensm_t * p_osm, 
 ib_net16_t mlid,
 
   comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL
   | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
 - if (osm_mcmr_rcv_find_or_create_new_mgrp(p_osm-sa,
 -  comp_mask, p_mcm_rec,
 - p_mgrp) != IB_SUCCESS ||
 - !p_mgrp || p_mgrp-mlid != mlid) {
 + if (!(p_mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(p_osm-sa,
 + comp_mask,
 + p_mcm_rec)) ||
 + p_mgrp-mlid != mlid) {
   OSM_LOG(p_osm-log, OSM_LOG_ERROR,
   cannot create MC group with mlid 0x%04x and mgid 
   0x%016 PRIx64 :0x%016 PRIx64 \n, cl_ntoh16(mlid),
 diff --git a/opensm/opensm/osm_sa_mcmember_record.c 
 

Re: [PATCH] opensm/osm_db_files.c: remove bad free() call

2010-09-12 Thread Yevgeny Kliteynik
On 07-Sep-10 10:51 PM, Sasha Khapyorsky wrote:
 On 17:52 Tue 07 Sep , Yevgeny Kliteynik wrote:
 p_key is a parameter, and it is char[].
 It shouldn't be freed here.
 
 I don't see this. st_delete() call:
 
  if (st_delete(p_domain_imp-p_hash,
   (void *)p_key, (void *)p_prev_val)) {
   ...
   free(p_key);
   ...
   }
 
 overwrites those value by pointers to key values stored in the hash
 table (then 1 is returned).

Oh, you're right. I was following the function
parameter itself and missed this part.

-- Yevgeny


 Sasha
 

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_db_files.c |1 -
   1 files changed, 0 insertions(+), 1 deletions(-)

 diff --git a/opensm/opensm/osm_db_files.c b/opensm/opensm/osm_db_files.c
 index dd9f772..c475004 100644
 --- a/opensm/opensm/osm_db_files.c
 +++ b/opensm/opensm/osm_db_files.c
 @@ -582,7 +582,6 @@ int osm_db_delete(IN osm_db_domain_t * p_domain, IN char 
 *p_key)
  p_key, p_domain_imp-file_name, p_prev_val);
  res = 1;
  } else {
 -free(p_key);
  free(p_prev_val);
  res = 0;
  }
 -- 
 1.6.2.4

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/osm_helper.c: fix potential overrun of the array

2010-09-12 Thread Yevgeny Kliteynik
On 09-Sep-10 5:36 PM, Sasha Khapyorsky wrote:
 On 18:02 Tue 07 Sep , Yevgeny Kliteynik wrote:
 Max index of the ib_sm_method_str[] static array
 is 0x20. Fixing OSM_SM_METHOD_STR_UNKNOWN_VAL to
 match this value.

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_helper.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
 index 196d5aa..0233e70 100644
 --- a/opensm/opensm/osm_helper.c
 +++ b/opensm/opensm/osm_helper.c
 @@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
  UNKNOWN   /* 20 */
   };

 -#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
 +#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20
 
 BTW, wouldn't it be better to use ARR_SIZE macro for those defines:
 
 #define OSM_SM_METHOD_STR_UNKNOWN_VAL ARR_SIZE(ib_sm_method_str)

Good idea, with a small fix:

#define OSM_SM_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_method_str) - 1)

-- Yevgeny

 
 , where:
 
 #define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
 ?
 
 Sasha
 

   static const char *ib_sm_attr_str[] = {
  RESERVED, /* 0 */
 -- 
 1.6.2.4

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_helper.c: use ARR_SIZE macro instead of hardcoded values

2010-09-12 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_helper.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index 58bc86b..2597e50 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -84,7 +84,7 @@ static const char *ib_sa_method_str[] = {
UNKNOWN   /* 16 */
 };

-#define OSM_SA_METHOD_STR_UNKNOWN_VAL 0x16
+#define OSM_SA_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_method_str) - 1)

 static const char *ib_sa_resp_method_str[] = {
RESERVED, /* 80 */
@@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
UNKNOWN   /* 20 */
 };

-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_method_str) - 1)

 static const char *ib_sm_attr_str[] = {
RESERVED, /* 0 */
@@ -187,7 +187,7 @@ static const char *ib_sm_attr_str[] = {
UNKNOWN   /* 21 - always highest value */
 };

-#define OSM_SM_ATTR_STR_UNKNOWN_VAL 0x21
+#define OSM_SM_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_attr_str) - 1)

 static const char *ib_sa_attr_str[] = {
RESERVED, /* 0 */
@@ -437,7 +437,7 @@ static const char *ib_sa_attr_str[] = {
UNKNOWN   /* F4 - always highest value */
 };

-#define OSM_SA_ATTR_STR_UNKNOWN_VAL 0xF4
+#define OSM_SA_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_attr_str) - 1)

 static int sprint_uint8_arr(char *buf, size_t size,
const uint8_t * arr, size_t len)
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/osm_trap_rcv.c: fix possible core dump

2010-09-12 Thread Yevgeny Kliteynik
On 07-Sep-10 10:58 PM, Sasha Khapyorsky wrote:
 On 17:53 Tue 07 Sep , Yevgeny Kliteynik wrote:
 Handle the case when source physical port
 for trap 145 wasn't found.

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_trap_rcv.c |   14 ++
   1 files changed, 10 insertions(+), 4 deletions(-)

 diff --git a/opensm/opensm/osm_trap_rcv.c b/opensm/opensm/osm_trap_rcv.c
 index 500632c..9f39644 100644
 --- a/opensm/opensm/osm_trap_rcv.c
 +++ b/opensm/opensm/osm_trap_rcv.c
 @@ -510,10 +510,16 @@ static void trap_rcv_process_request(IN osm_sm_t * sm,
  ERR 3812: No physical port found for 
  trap 144: \node description update\\n);
  goto check_sweep;
 -} else if (cl_ntoh16(p_ntci-g_or_v.generic.trap_num) == 145)
 -/* this assumes that trap 145 content is not broken? */
 -p_physp-p_node-node_info.sys_guid =
 -p_ntci-data_details.ntc_145.new_sys_guid;
 +} else if (cl_ntoh16(p_ntci-g_or_v.generic.trap_num) == 145) {
 +if (p_physp)
 +/* this assumes that trap 145 content is not broken? */
 +p_physp-p_node-node_info.sys_guid =
 +p_ntci-data_details.ntc_145.new_sys_guid;
 +else
 +OSM_LOG(sm-p_log, OSM_LOG_ERROR,
 +ERR 3813: No physical port found for 
 +trap 145: \SystemImageGUID update\\n);
 +}
 
 Wouldn't it be better to make such check for all traps and not
 separately for selected values?

Such check exists:

   407  if (p_physp)
   408  p_smp-m_key = p_physp-port_info.m_key;
   409  else
   410  OSM_LOG(sm-p_log, OSM_LOG_ERROR, ERR 3809: 
   411  Failed to find source physical port for 
trap\n);

However, even if p_physp wasn't found, the function continues,
and for each trap it is doing something else. For instance,
p_physp can be absent, but trap 144 will still cause heavy sweep.

-- Yevgeny

 Sasha
 

   check_sweep:
  /* do a sweep if we received a trap */
 -- 
 1.6.2.4

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_db_files.c: remove bad free() call

2010-09-07 Thread Yevgeny Kliteynik
p_key is a parameter, and it is char[].
It shouldn't be freed here.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_db_files.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_db_files.c b/opensm/opensm/osm_db_files.c
index dd9f772..c475004 100644
--- a/opensm/opensm/osm_db_files.c
+++ b/opensm/opensm/osm_db_files.c
@@ -582,7 +582,6 @@ int osm_db_delete(IN osm_db_domain_t * p_domain, IN char 
*p_key)
p_key, p_domain_imp-file_name, p_prev_val);
res = 1;
} else {
-   free(p_key);
free(p_prev_val);
res = 0;
}
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_mtree.c: removing useless 'if' statement

2010-09-07 Thread Yevgeny Kliteynik
p_mtn-max_children is an array - no point checking if it is NULL.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_mtree.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/opensm/opensm/osm_mtree.c b/opensm/opensm/osm_mtree.c
index b5ce73b..693d0d5 100644
--- a/opensm/opensm/osm_mtree.c
+++ b/opensm/opensm/osm_mtree.c
@@ -73,11 +73,10 @@ void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn)
if (p_mtn == NULL)
return;

-   if (p_mtn-child_array != NULL)
-   for (i = 0; i  p_mtn-max_children; i++)
-   if ((p_mtn-child_array[i] != NULL) 
-   (p_mtn-child_array[i] != OSM_MTREE_LEAF))
-   osm_mtree_destroy(p_mtn-child_array[i]);
+   for (i = 0; i  p_mtn-max_children; i++)
+   if ((p_mtn-child_array[i] != NULL) 
+   (p_mtn-child_array[i] != OSM_MTREE_LEAF))
+   osm_mtree_destroy(p_mtn-child_array[i]);

free(p_mtn);
 }
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_ucast_cache.c: fix potential seg fault

2010-09-07 Thread Yevgeny Kliteynik
Fix potential seg fault when NULL is returned

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_ucast_cache.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_ucast_cache.c b/opensm/opensm/osm_ucast_cache.c
index c611c38..be15508 100644
--- a/opensm/opensm/osm_ucast_cache.c
+++ b/opensm/opensm/osm_ucast_cache.c
@@ -931,6 +931,14 @@ void osm_ucast_cache_add_node(osm_ucast_mgr_t * p_mgr, 
osm_node_t * p_node)

p_cache_sw = cache_get_sw(p_mgr, lid_ho);
CL_ASSERT(p_cache_sw);
+   if (!p_cache_sw) {
+   /* something is wrong - forget about cache */
+   OSM_LOG(p_mgr-p_log, OSM_LOG_ERROR,
+   ERR AD04: no cached switch with lid %u - 
+   clearing cache\n, lid_ho);
+   osm_ucast_cache_invalidate(p_mgr);
+   goto Exit;
+   }

if (!cache_sw_is_leaf(p_cache_sw)) {
OSM_LOG(p_mgr-p_log, OSM_LOG_DEBUG,
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_pkey.c: removing unused function

2010-09-07 Thread Yevgeny Kliteynik
Removing unused (and, may I add, buggy) function.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_pkey.c |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/opensm/opensm/osm_pkey.c b/opensm/opensm/osm_pkey.c
index aa7b690..4c5a852 100644
--- a/opensm/opensm/osm_pkey.c
+++ b/opensm/opensm/osm_pkey.c
@@ -104,16 +104,6 @@ void osm_pkey_tbl_init_new_blocks(IN const osm_pkey_tbl_t 
* p_pkey_tbl)
memset(p_block, 0, sizeof(*p_block));
 }

-void osm_pkey_tbl_cleanup_pending(IN osm_pkey_tbl_t * p_pkey_tbl)
-{
-   cl_list_item_t *p_item;
-
-   p_item = cl_qlist_remove_head(p_pkey_tbl-pending);
-   while (p_item != cl_qlist_end(p_pkey_tbl-pending)) {
-   free((osm_pending_pkey_t *) p_item);
-   }
-}
-
 ib_api_status_t osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
 IN uint16_t block, IN ib_pkey_table_t * p_tbl)
 {
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_sminfo_rcv.c: removing unused variable

2010-09-07 Thread Yevgeny Kliteynik
Removing variable that was never used outside
CL_ASSERT() statement.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_sminfo_rcv.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/opensm/opensm/osm_sminfo_rcv.c b/opensm/opensm/osm_sminfo_rcv.c
index e9394d7..b6bc558 100644
--- a/opensm/opensm/osm_sminfo_rcv.c
+++ b/opensm/opensm/osm_sminfo_rcv.c
@@ -78,7 +78,6 @@ static void smi_rcv_process_get_request(IN osm_sm_t * sm,
IN const osm_madw_t * p_madw)
 {
uint8_t payload[IB_SMP_DATA_SIZE];
-   ib_smp_t *p_smp;
ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
ib_api_status_t status;
ib_sm_info_t *p_remote_smi;
@@ -90,9 +89,7 @@ static void smi_rcv_process_get_request(IN osm_sm_t * sm,
/* No real need to grab the lock for this function. */
memset(payload, 0, sizeof(payload));

-   p_smp = osm_madw_get_smp_ptr(p_madw);
-
-   CL_ASSERT(p_smp-method == IB_MAD_METHOD_GET);
+   CL_ASSERT(osm_madw_get_smp_ptr(p_madw)-method == IB_MAD_METHOD_GET);

p_smi-guid = sm-p_subn-sm_port_guid;
p_smi-act_count = cl_hton32(sm-p_subn-p_osm-stats.qp0_mads_sent);
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_sa_pkey_record.c: removing unused variable

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_sa_pkey_record.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_sa_pkey_record.c 
b/opensm/opensm/osm_sa_pkey_record.c
index 5b1c794..e4930d0 100644
--- a/opensm/opensm/osm_sa_pkey_record.c
+++ b/opensm/opensm/osm_sa_pkey_record.c
@@ -210,7 +210,6 @@ void osm_pkey_rec_rcv_process(IN void *ctx, IN void *data)
const ib_sa_mad_t *p_rcvd_mad;
const ib_pkey_table_record_t *p_rcvd_rec;
const osm_port_t *p_port = NULL;
-   const ib_pkey_table_t *p_pkey;
cl_qlist_t rec_list;
osm_pkey_search_ctxt_t context;
ib_net64_t comp_mask;
@@ -264,8 +263,6 @@ void osm_pkey_rec_rcv_process(IN void *ctx, IN void *data)
goto Exit;
}

-   p_pkey = ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
cl_qlist_init(rec_list);

context.p_rcvd_rec = p_rcvd_rec;
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_node_info_rcv.c: remove useless code line

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_node_info_rcv.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_node_info_rcv.c 
b/opensm/opensm/osm_node_info_rcv.c
index d24e757..1041e42 100644
--- a/opensm/opensm/osm_node_info_rcv.c
+++ b/opensm/opensm/osm_node_info_rcv.c
@@ -436,7 +436,6 @@ static void ni_rcv_process_existing_ca_or_router(IN 
osm_sm_t * sm,
if (sm-p_subn-sm_state == IB_SMINFO_STATE_MASTER)
p_port-is_new = 1;

-   p_physp = osm_node_get_physp_ptr(p_node, port_num);
} else {
p_physp = osm_node_get_physp_ptr(p_node, port_num);
/*
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_sa_vlarb_record.c: removed unused variable

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_sa_vlarb_record.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_sa_vlarb_record.c 
b/opensm/opensm/osm_sa_vlarb_record.c
index 36cbac1..d32fdb1 100644
--- a/opensm/opensm/osm_sa_vlarb_record.c
+++ b/opensm/opensm/osm_sa_vlarb_record.c
@@ -212,7 +212,6 @@ void osm_vlarb_rec_rcv_process(IN void *ctx, IN void *data)
const ib_sa_mad_t *sad_mad;
const ib_vl_arb_table_record_t *p_rcvd_rec;
const osm_port_t *p_port = NULL;
-   const ib_vl_arb_table_t *p_vl_arb;
cl_qlist_t rec_list;
osm_vl_arb_search_ctxt_t context;
ib_api_status_t status = IB_SUCCESS;
@@ -252,8 +251,6 @@ void osm_vlarb_rec_rcv_process(IN void *ctx, IN void *data)
goto Exit;
}

-   p_vl_arb = (ib_vl_arb_table_t *) ib_sa_mad_get_payload_ptr(sad_mad);
-
cl_qlist_init(rec_list);

context.p_rcvd_rec = p_rcvd_rec;
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_mesh.c: fixing a bug in compare_switches()

2010-09-07 Thread Yevgeny Kliteynik
I'm pretty sure that ; at the end of if statement
is not supposed to be there (not sure how it worked till
now though).
Also, making this condition a bit more readable.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_mesh.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_mesh.c b/opensm/opensm/osm_mesh.c
index 9d1082a..d156b7a 100644
--- a/opensm/opensm/osm_mesh.c
+++ b/opensm/opensm/osm_mesh.c
@@ -1385,7 +1385,8 @@ static int compare_switches(const void *p1, const void 
*p2)

for (i = 0; i  ctx-mesh-dimension; i++) {
j = ctx-mesh-dim_order[i];
-   if ((ret = s1-node-coord[j] - s2-node-coord[j]));
+   ret = s1-node-coord[j] - s2-node-coord[j];
+   if (ret)
return ret;
}

-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] osmtest/osmtest.c: handle timeouts in PR stress test

2010-09-07 Thread Yevgeny Kliteynik
There was some preparation code for handling
PathRecord timeouts in SA stress codes: variable
num_timeouts exists, and it's value is checked.
What was missing is actually increasing the
num_timeouts value when timeout happens.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osmtest/osmtest.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/opensm/osmtest/osmtest.c b/opensm/osmtest/osmtest.c
index 7412ce7..b2ec3fa 100644
--- a/opensm/osmtest/osmtest.c
+++ b/opensm/osmtest/osmtest.c
@@ -2753,7 +2753,11 @@ static ib_api_status_t osmtest_stress_small_rmpp(IN 
osmtest_t * const p_osmt)

status = osmtest_stress_port_recs_small(p_osmt, delta_recs,
delta_queries);
-   if (status != IB_SUCCESS)
+   if (status == IB_TIMEOUT) {
+   num_timeouts++;
+   continue;
+   }
+   else if (status != IB_SUCCESS)
goto Exit;

num_recs += delta_recs;
@@ -2889,7 +2893,11 @@ static ib_api_status_t osmtest_stress_get_pr(IN 
osmtest_t * const p_osmt)
status = osmtest_stress_path_recs_by_lid(p_osmt,
 delta_recs,
 delta_queries);
-   if (status != IB_SUCCESS)
+   if (status == IB_TIMEOUT) {
+   num_timeouts++;
+   continue;
+   }
+   else if (status != IB_SUCCESS)
goto Exit;

num_recs += delta_recs;
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_helper.c: fix potential overrun of the array

2010-09-07 Thread Yevgeny Kliteynik
Max index of the ib_sm_method_str[] static array
is 0x20. Fixing OSM_SM_METHOD_STR_UNKNOWN_VAL to
match this value.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_helper.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index 196d5aa..0233e70 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -148,7 +148,7 @@ static const char *ib_sm_method_str[] = {
UNKNOWN   /* 20 */
 };

-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x20

 static const char *ib_sm_attr_str[] = {
RESERVED, /* 0 */
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_helper.c: cosmetics - move define closer to the relevant code

2010-09-07 Thread Yevgeny Kliteynik
OSM_SA_METHOD_STR_UNKNOWN_VAL refers to ib_sa_method_str[].
Moving it closer to the array.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_helper.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index 0233e70..58bc86b 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -84,6 +84,8 @@ static const char *ib_sa_method_str[] = {
UNKNOWN   /* 16 */
 };

+#define OSM_SA_METHOD_STR_UNKNOWN_VAL 0x16
+
 static const char *ib_sa_resp_method_str[] = {
RESERVED, /* 80 */
SubnAdmGetResp,   /* 81 */
@@ -110,8 +112,6 @@ static const char *ib_sa_resp_method_str[] = {
UNKNOWN
 };

-#define OSM_SA_METHOD_STR_UNKNOWN_VAL 0x16
-
 static const char *ib_sm_method_str[] = {
RESERVED0,/* 0 */
SubnGet,  /* 1 */
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_subnet.c: fixing small bug in error path

2010-09-07 Thread Yevgeny Kliteynik
Closing file on failure

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_subnet.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index d5c5ab2..149ab85 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -1163,8 +1163,10 @@ int osm_subn_parse_conf_file(char *file_name, 
osm_subn_opt_t * p_opts)
cl_log_event(OpenSM, CL_LOG_INFO, line, NULL, 0);

p_opts-config_file = file_name;
-   if (!p_opts-file_opts  !(p_opts-file_opts = 
malloc(sizeof(*p_opts
+   if (!p_opts-file_opts  !(p_opts-file_opts = 
malloc(sizeof(*p_opts {
+   fclose(opts_file);
return -1;
+   }
memcpy(p_opts-file_opts, p_opts, sizeof(*p_opts));

while (fgets(line, 1023, opts_file) != NULL) {
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_db_files.c: fix small memory leak

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_db_files.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_db_files.c b/opensm/opensm/osm_db_files.c
index c475004..603bcf2 100644
--- a/opensm/opensm/osm_db_files.c
+++ b/opensm/opensm/osm_db_files.c
@@ -175,6 +175,7 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log)
OSM_LOG(p_log, OSM_LOG_ERROR, ERR 6101: 
Failed to create the db directory:%s\n,
p_db_imp-db_dir_name);
+   free(p_db_imp);
OSM_LOG_EXIT(p_log);
return 1;
}
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] osmtest/osmt_slvl_vl_arb.c: handling fopen() failure

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osmtest/osmt_slvl_vl_arb.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/opensm/osmtest/osmt_slvl_vl_arb.c 
b/opensm/osmtest/osmt_slvl_vl_arb.c
index d3919fb..d4a08ff 100644
--- a/opensm/osmtest/osmt_slvl_vl_arb.c
+++ b/opensm/osmtest/osmt_slvl_vl_arb.c
@@ -489,6 +489,12 @@ osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const 
p_osmt)
OSM_LOG_ENTER(p_osmt-log);

fh = fopen(qos.txt, w);
+   if (!fh) {
+   OSM_LOG(p_osmt-log, OSM_LOG_ERROR, ERR 0474: 
+   Failed to open file qos.txt for writing\n);
+   status = IB_ERROR;
+   goto Exit;
+   }

/* go over all ports in the subnet */
status = osmt_query_all_ports_vl_arb(p_osmt, fh);
@@ -520,7 +526,8 @@ osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const 
p_osmt)
}

 Exit:
-   fclose(fh);
+   if (fh)
+   fclose(fh);
OSM_LOG_EXIT(p_osmt-log);
return status;
 }
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_ucast_ftree.c: fix small memory leak in error path

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_ucast_ftree.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c
index 88ea344..fb46d0f 100644
--- a/opensm/opensm/osm_ucast_ftree.c
+++ b/opensm/opensm/osm_ucast_ftree.c
@@ -791,8 +791,10 @@ static ftree_hca_t *hca_create(IN osm_node_t * p_osm_node)
p_hca-up_port_groups = (ftree_port_group_t **)
malloc(osm_node_get_num_physp(p_hca-p_osm_node) *
   sizeof(ftree_port_group_t *));
-   if (!p_hca-up_port_groups)
+   if (!p_hca-up_port_groups) {
+   free(p_hca);
return NULL;
+   }
p_hca-up_port_groups_num = 0;
return p_hca;
 }
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_console.c: fix memory and file descriptor leaks

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_console.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index bc7bea3..29a6c83 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1302,12 +1302,13 @@ static void dump_portguid_parse(char **p_last, 
osm_opensm_t * p_osm, FILE * out)
/* Check we have at least one expression to match */
if (p_head_regexp == NULL) {
fprintf(out, No valid expression provided. Aborting\n);
+   goto Exit;
return;
}

if (p_osm-sm.p_subn-need_update != 0) {
fprintf(out, Subnet is not ready yet. Try again later\n);
-   return;
+   goto Free_and_exit;
}

/* Subnet doesn't need to be updated so we can carry on */
@@ -1333,14 +1334,16 @@ static void dump_portguid_parse(char **p_last, 
osm_opensm_t * p_osm, FILE * out)
}

CL_PLOCK_RELEASE(p_osm-sm.p_lock);
-   if (output != out)
-   fclose(output);

+Free_and_exit:
for (; p_head_regexp; p_head_regexp = p_regexp) {
p_regexp = p_head_regexp-next;
regfree(p_head_regexp-exp);
free(p_head_regexp);
}
+Exit:
+   if (output != out)
+   fclose(output);
 }

 static void help_dump_portguid(FILE * out, int detail)
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_ucast_lash.c: small bug in calculating allocated size

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_ucast_lash.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index 4669946..2081296 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -726,7 +726,7 @@ static int init_lash_structures(lash_t * p_lash)
for (j = 0; j  num_switches; j++) {
p_lash-cdg_vertex_matrix[i][j] =
(cdg_vertex_t **) malloc(num_switches *
-sizeof(cdg_vertex_t **));
+sizeof(cdg_vertex_t *));
if (p_lash-cdg_vertex_matrix[i][j] == NULL)
goto Exit_Mem_Error;

-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_pkey_mgr.c: fixing small memory leak

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_pkey_mgr.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_pkey_mgr.c b/opensm/opensm/osm_pkey_mgr.c
index 1e98c82..612130c 100644
--- a/opensm/opensm/osm_pkey_mgr.c
+++ b/opensm/opensm/osm_pkey_mgr.c
@@ -118,6 +118,7 @@ pkey_mgr_process_physical_port(IN osm_log_t * p_log,
cl_ntoh16(ib_pkey_get_base(pkey)),
cl_ntoh64(osm_node_get_node_guid(p_node)),
osm_physp_get_port_num(p_physp));
+   free(p_pending);
return;
}
cl_qlist_insert_head(p_pkey_tbl-pending,
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_ucast_file.c: closing file descriptor in error path

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_ucast_file.c |   38 ++
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/opensm/opensm/osm_ucast_file.c b/opensm/opensm/osm_ucast_file.c
index 8cb3cb6..fef77a2 100644
--- a/opensm/opensm/osm_ucast_file.c
+++ b/opensm/opensm/osm_ucast_file.c
@@ -130,6 +130,7 @@ static int do_ucast_file_load(void *context)
uint16_t lid;
uint8_t port_num;
unsigned lineno;
+   int status = -1;

file_name = p_osm-subn.opt.lfts_file;
if (!file_name) {
@@ -143,7 +144,7 @@ static int do_ucast_file_load(void *context)
if (!file) {
OSM_LOG(p_osm-log, OSM_LOG_ERROR | OSM_LOG_SYS, ERR 6302: 
Can't open ucast dump file \'%s\': %m\n, file_name);
-   return -1;
+   goto Exit;
}

lineno = 0;
@@ -173,7 +174,7 @@ static int do_ucast_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse switch definition\n,
file_name, lineno);
-   return -1;
+   goto Exit;
}
p = q + 8;
sw_guid = strtoull(p, q, 16);
@@ -182,7 +183,7 @@ static int do_ucast_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse switch guid: \'%s\'\n,
file_name, lineno, p);
-   return -1;
+   goto Exit;
}
sw_guid = cl_hton64(sw_guid);

@@ -202,7 +203,7 @@ static int do_ucast_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse lid: \'%s\'\n,
file_name, lineno, p);
-   return -1;
+   goto Exit;
}
p = q;
while (isspace(*p))
@@ -213,7 +214,7 @@ static int do_ucast_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse port: \'%s\'\n,
file_name, lineno, p);
-   return -1;
+   goto Exit;
}
p = q;
/* additionally try to extract guid */
@@ -241,9 +242,11 @@ static int do_ucast_file_load(void *context)
add_path(p_osm, p_sw, lid, port_num, port_guid);
}
}
-
-   fclose(file);
-   return 0;
+   status = 0;
+Exit:
+   if (file)
+   fclose(file);
+   return status;
 }

 static int do_lid_matrix_file_load(void *context)
@@ -257,6 +260,7 @@ static int do_lid_matrix_file_load(void *context)
osm_switch_t *p_sw;
unsigned lineno;
uint16_t lid;
+   int status = -1;

file_name = p_osm-subn.opt.lid_matrix_dump_file;
if (!file_name) {
@@ -270,7 +274,7 @@ static int do_lid_matrix_file_load(void *context)
if (!file) {
OSM_LOG(p_osm-log, OSM_LOG_ERROR | OSM_LOG_SYS, ERR 6305: 
Can't open lid matrix file \'%s\': %m\n, file_name);
-   return -1;
+   goto Exit;
}

lineno = 0;
@@ -294,7 +298,7 @@ static int do_lid_matrix_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse switch definition\n,
file_name, lineno);
-   return -1;
+   goto Exit;
}
p = q + 8;
guid = strtoull(p, q, 16);
@@ -303,7 +307,7 @@ static int do_lid_matrix_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse switch guid: \'%s\'\n,
file_name, lineno, p);
-   return -1;
+   goto Exit;
}
guid = cl_hton64(guid);

@@ -328,7 +332,7 @@ static int do_lid_matrix_file_load(void *context)
PARSE ERROR: %s:%u: 
cannot parse lid: \'%s\'\n,
file_name, lineno, p);
-   return -1;
+   goto Exit;
}
/* Just checked the range

Re: [PATCH] opensm/osm_console.c: fix memory and file descriptor leaks

2010-09-07 Thread Yevgeny Kliteynik
On 07-Sep-10 6:20 PM, Ira Weiny wrote:
 Hi Yevgeny,
 
 On Tue, 7 Sep 2010 08:12:58 -0700
 Yevgeny Kliteynikklit...@mellanox.co.il  wrote:
 

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_console.c |9 ++---
   1 files changed, 6 insertions(+), 3 deletions(-)

 diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
 index bc7bea3..29a6c83 100644
 --- a/opensm/opensm/osm_console.c
 +++ b/opensm/opensm/osm_console.c
 @@ -1302,12 +1302,13 @@ static void dump_portguid_parse(char **p_last, 
 osm_opensm_t * p_osm, FILE * out)
  /* Check we have at least one expression to match */
  if (p_head_regexp == NULL) {
  fprintf(out, No valid expression provided. Aborting\n);
 +goto Exit;
  return;
 
 While you are at it, shouldn't you remove the return here as well?

Yep :)

-- Yevgeny
 
 Ira
 
  }

  if (p_osm-sm.p_subn-need_update != 0) {
  fprintf(out, Subnet is not ready yet. Try again later\n);
 -return;
 +goto Free_and_exit;
  }

  /* Subnet doesn't need to be updated so we can carry on */
 @@ -1333,14 +1334,16 @@ static void dump_portguid_parse(char **p_last, 
 osm_opensm_t * p_osm, FILE * out)
  }

  CL_PLOCK_RELEASE(p_osm-sm.p_lock);
 -if (output != out)
 -fclose(output);

 +Free_and_exit:
  for (; p_head_regexp; p_head_regexp = p_regexp) {
  p_regexp = p_head_regexp-next;
  regfree(p_head_regexp-exp);
  free(p_head_regexp);
  }
 +Exit:
 +if (output != out)
 +fclose(output);
   }

   static void help_dump_portguid(FILE * out, int detail)
 -- 
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://*vger.kernel.org/majordomo-info.html

 
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] libvendor/osm_vendor_ibumad_sa.c: remove useless if statement

2010-09-07 Thread Yevgeny Kliteynik
On 07-Sep-10 8:47 PM, Hal Rosenstock wrote:
 On Tue, Sep 7, 2010 at 11:13 AM, Yevgeny Kliteynik
 klit...@mellanox.co.il  wrote:
 Content of p_query_req_copy is used in the function,
 so no point checking if it's NULL before the free().

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/libvendor/osm_vendor_ibumad_sa.c |3 +--
 
 Same change could be done for osm_vendor_mlx_sa.c too.

Sure, thanks.

-- Yevgeny
 
 -- Hal
 
   1 files changed, 1 insertions(+), 2 deletions(-)

 diff --git a/opensm/libvendor/osm_vendor_ibumad_sa.c 
 b/opensm/libvendor/osm_vendor_ibumad_sa.c
 index 75bc303..1fdcc47 100644
 --- a/opensm/libvendor/osm_vendor_ibumad_sa.c
 +++ b/opensm/libvendor/osm_vendor_ibumad_sa.c
 @@ -199,8 +199,7 @@ static void __osmv_sa_mad_err_cb(IN void *bind_context, 
 IN osm_madw_t * p_madw)
 if ((p_query_req_copy-flags  OSM_SA_FLAGS_SYNC) == 
 OSM_SA_FLAGS_SYNC)
 cl_event_signal(p_bind-sync_event);

 -   if (p_query_req_copy)
 -   free(p_query_req_copy);
 +   free(p_query_req_copy);
 OSM_LOG_EXIT(p_bind-p_log);
   }

 --
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] opensm/osm_console.c: fix memory and file descriptor leaks

2010-09-07 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

V2: removed unneeded 'return'

 opensm/opensm/osm_console.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index bc7bea3..5407e9a 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1302,12 +1302,12 @@ static void dump_portguid_parse(char **p_last, 
osm_opensm_t * p_osm, FILE * out)
/* Check we have at least one expression to match */
if (p_head_regexp == NULL) {
fprintf(out, No valid expression provided. Aborting\n);
-   return;
+   goto Exit;
}

if (p_osm-sm.p_subn-need_update != 0) {
fprintf(out, Subnet is not ready yet. Try again later\n);
-   return;
+   goto Free_and_exit;
}

/* Subnet doesn't need to be updated so we can carry on */
@@ -1333,14 +1333,16 @@ static void dump_portguid_parse(char **p_last, 
osm_opensm_t * p_osm, FILE * out)
}

CL_PLOCK_RELEASE(p_osm-sm.p_lock);
-   if (output != out)
-   fclose(output);

+Free_and_exit:
for (; p_head_regexp; p_head_regexp = p_regexp) {
p_regexp = p_head_regexp-next;
regfree(p_head_regexp-exp);
free(p_head_regexp);
}
+Exit:
+   if (output != out)
+   fclose(output);
 }

 static void help_dump_portguid(FILE * out, int detail)
-- 
1.6.2.4


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libvendor/osm_vendor_mlx_sa.c: remove useless if statement

2010-09-07 Thread Yevgeny Kliteynik
Content of p_query_req_copy is used in the function,
so no point checking if it's NULL before the free()

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/libvendor/osm_vendor_mlx_sa.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/opensm/libvendor/osm_vendor_mlx_sa.c 
b/opensm/libvendor/osm_vendor_mlx_sa.c
index 0cc3f19..9050af8 100644
--- a/opensm/libvendor/osm_vendor_mlx_sa.c
+++ b/opensm/libvendor/osm_vendor_mlx_sa.c
@@ -210,8 +210,7 @@ void __osmv_sa_mad_err_cb(IN void *bind_context, IN 
osm_madw_t * p_madw)
if ((p_query_req_copy-flags  OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
cl_event_signal(p_bind-sync_event);

-   if (p_query_req_copy)
-   free(p_query_req_copy);
+   free(p_query_req_copy);
OSM_LOG_EXIT(p_bind-p_log);
 }

-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/osm_qos_policy.c: fix SL for TS-precreated mcast group

2010-09-06 Thread Yevgeny Kliteynik
On 06-Sep-10 7:56 PM, Sasha Khapyorsky wrote:
 On 13:01 Sun 05 Sep , Yevgeny Kliteynik wrote:
 Assuming we still need to support TopSpin's non-compliant join
 compmask for IPoIB v4 multicast group ff12:401b:pkey::1
 
 Wouldn't it be better to understand an use case of this group? It is
 probably obsolete and such addition is not needed.

Sure, I'd trade this patch for another patch
that removes the mcast group pre-creation.

If no one objects, I'll remove that TS hack.

-- Yevgeny

 Sasha
 

 The group is pre-defined and maintained as a well-known
 multicast group, hence it's SL needs to be fixed too in
 accordance with QoS policy configuration, same as for
 ff12:401b:pkey::: MGID.

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_qos_policy.c |   35 +++
   1 files changed, 35 insertions(+), 0 deletions(-)

 diff --git a/opensm/opensm/osm_qos_policy.c b/opensm/opensm/osm_qos_policy.c
 index ac49ab3..bdd27d0 100644
 --- a/opensm/opensm/osm_qos_policy.c
 +++ b/opensm/opensm/osm_qos_policy.c
 @@ -764,6 +764,20 @@ static osm_qos_port_group_t 
 *__qos_policy_get_port_group_by_name(

   /***
***/
 +/*
 + * HACK: Until TS resolves their noncompliant join compmask,
 + * we have to fix SL for this pre-defined the MGID too
 + */
 +static const ib_gid_t osm_ts_ipoib_mgid = {
 +{
 + 0xff,  /*  multicast field */
 + 0x12,  /*  non-permanent bit, link local scope */
 + 0x40, 0x1b,/*  IPv4 signature */
 + 0xff, 0xff,/*  16 bits of P_Key (to be filled in) */
 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,/*  48 bits of zeros */
 + 0x00, 0x00, 0x00, 0x01,/*  32 bit IPv4 broadcast address */
 + },
 +};

   static void __qos_policy_validate_pkey(
  osm_qos_policy_t * p_qos_policy,
 @@ -773,6 +787,9 @@ static void __qos_policy_validate_pkey(
  uint8_t sl;
  uint32_t flow;
  uint8_t hop;
 +ib_gid_t mgid;
 +ib_net16_t pkey;
 +osm_mgrp_t * mgrp;
  char gid_str[INET6_ADDRSTRLEN];

  if (!p_qos_policy || !p_qos_match_rule || !p_prtn)
 @@ -810,6 +827,24 @@ static void __qos_policy_validate_pkey(
  p_prtn-mgrp-mcmember_rec.sl_flow_hop =
  ib_member_set_sl_flow_hop(p_prtn-sl, flow, hop);
  }
 +
 +/* workaround for TS */
 +/* FIXME: remove this upon TS fixes */
 +mgid = osm_ts_ipoib_mgid;
 +pkey = p_prtn-pkey | cl_hton16(0x8000);
 +memcpy(mgid.raw[4],pkey, sizeof(pkey));
 +mgrp = osm_get_mgrp_by_mgid(p_qos_policy-p_subn,mgid);
 +if (mgrp) {
 +OSM_LOG(p_qos_policy-p_subn-p_osm-log, OSM_LOG_DEBUG,
 +TS workaround: Updating MCGroup (MGID %s) SL to 
 +match partition SL (%u)\n,
 +inet_ntop(AF_INET6, mgid.raw, gid_str, sizeof gid_str),
 +p_prtn-sl);
 +ib_member_get_sl_flow_hop(mgrp-mcmember_rec.sl_flow_hop,
 +sl,flow,hop);
 +mgrp-mcmember_rec.sl_flow_hop =
 +ib_member_set_sl_flow_hop(p_prtn-sl, flow, hop);
 +}
   }

   /***
 -- 
 1.6.2.4

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Multicast group pre-creation for TopSpin old stack

2010-09-05 Thread Yevgeny Kliteynik
Sasha,

There's a hack in the SM to deal with TopSpin's non-compliant
join compmask for IPoIB v4 multicast group ff12:401b:pkey::1
The group is pre-defined and maintained as a well-known multicast
group.

opensm/osm_prtn.c:

   232  /* workaround for TS */
   233  /* FIXME: remove this upon TS fixes */
   234  mc_rec.mgid = osm_ts_ipoib_mgid;
   235  memcpy(mc_rec.mgid.raw[4], pkey, sizeof(pkey));
   236  /* Scope in MCMemberRecord (if present) needs to be consistent 
with MGID */
   237  mc_rec.scope_state = ib_member_set_scope_state(scope, 
IB_MC_REC_STATE_FULL_MEMBER);
   238  ib_mgid_set_scope(mc_rec.mgid, scope);
   239
   240  status = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, 
mc_rec,
   241p_mgrp);
   242  if (p_mgrp) {
   243  p_mgrp-well_known = TRUE;
   244  if (!p-mgrp)
   245  p-mgrp = p_mgrp;
   246  }

As far as I can tell, this was added before git history.
Any idea if it's still needed?

-- Yevgeny
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_qos_policy.c: change a log message

2010-09-05 Thread Yevgeny Kliteynik
Pring multicast group GID rather than LID -
MGID is more relevant than MLID in this context.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_qos_policy.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_qos_policy.c b/opensm/opensm/osm_qos_policy.c
index 72df6c8..ac49ab3 100644
--- a/opensm/opensm/osm_qos_policy.c
+++ b/opensm/opensm/osm_qos_policy.c
@@ -48,6 +48,7 @@
 #include stdlib.h
 #include string.h
 #include ctype.h
+#include arpa/inet.h
 #include opensm/osm_log.h
 #include opensm/osm_node.h
 #include opensm/osm_port.h
@@ -772,6 +773,7 @@ static void __qos_policy_validate_pkey(
uint8_t sl;
uint32_t flow;
uint8_t hop;
+   char gid_str[INET6_ADDRSTRLEN];

if (!p_qos_policy || !p_qos_match_rule || !p_prtn)
return;
@@ -801,9 +803,9 @@ static void __qos_policy_validate_pkey(
  sl, flow, hop);
if (sl != p_prtn-sl) {
OSM_LOG(p_qos_policy-p_subn-p_osm-log, OSM_LOG_DEBUG,
-   Updating MCGroup (MLID 0x%04x) SL to 
+   Updating MCGroup (MGID %s) SL to 
match partition SL (%u)\n,
-   cl_hton16(p_prtn-mgrp-mcmember_rec.mlid),
+   inet_ntop(AF_INET6, mgid.raw, gid_str, sizeof gid_str),
p_prtn-sl);
p_prtn-mgrp-mcmember_rec.sl_flow_hop =
ib_member_set_sl_flow_hop(p_prtn-sl, flow, hop);
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_qos_policy.c: fix SL for TS-precreated mcast group

2010-09-05 Thread Yevgeny Kliteynik
Assuming we still need to support TopSpin's non-compliant join
compmask for IPoIB v4 multicast group ff12:401b:pkey::1

The group is pre-defined and maintained as a well-known
multicast group, hence it's SL needs to be fixed too in
accordance with QoS policy configuration, same as for
ff12:401b:pkey::: MGID.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_qos_policy.c |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_qos_policy.c b/opensm/opensm/osm_qos_policy.c
index ac49ab3..bdd27d0 100644
--- a/opensm/opensm/osm_qos_policy.c
+++ b/opensm/opensm/osm_qos_policy.c
@@ -764,6 +764,20 @@ static osm_qos_port_group_t 
*__qos_policy_get_port_group_by_name(

 /***
  ***/
+/*
+ * HACK: Until TS resolves their noncompliant join compmask,
+ * we have to fix SL for this pre-defined the MGID too
+ */
+static const ib_gid_t osm_ts_ipoib_mgid = {
+   {
+0xff,  /*  multicast field */
+0x12,  /*  non-permanent bit, link local scope */
+0x40, 0x1b,/*  IPv4 signature */
+0xff, 0xff,/*  16 bits of P_Key (to be filled in) */
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00,/*  48 bits of zeros */
+0x00, 0x00, 0x00, 0x01,/*  32 bit IPv4 broadcast address */
+},
+};

 static void __qos_policy_validate_pkey(
osm_qos_policy_t * p_qos_policy,
@@ -773,6 +787,9 @@ static void __qos_policy_validate_pkey(
uint8_t sl;
uint32_t flow;
uint8_t hop;
+   ib_gid_t mgid;
+   ib_net16_t pkey;
+   osm_mgrp_t * mgrp;
char gid_str[INET6_ADDRSTRLEN];

if (!p_qos_policy || !p_qos_match_rule || !p_prtn)
@@ -810,6 +827,24 @@ static void __qos_policy_validate_pkey(
p_prtn-mgrp-mcmember_rec.sl_flow_hop =
ib_member_set_sl_flow_hop(p_prtn-sl, flow, hop);
}
+
+   /* workaround for TS */
+   /* FIXME: remove this upon TS fixes */
+   mgid = osm_ts_ipoib_mgid;
+   pkey = p_prtn-pkey | cl_hton16(0x8000);
+   memcpy(mgid.raw[4], pkey, sizeof(pkey));
+   mgrp = osm_get_mgrp_by_mgid(p_qos_policy-p_subn, mgid);
+   if (mgrp) {
+   OSM_LOG(p_qos_policy-p_subn-p_osm-log, OSM_LOG_DEBUG,
+   TS workaround: Updating MCGroup (MGID %s) SL to 
+   match partition SL (%u)\n,
+   inet_ntop(AF_INET6, mgid.raw, gid_str, sizeof gid_str),
+   p_prtn-sl);
+   ib_member_get_sl_flow_hop(mgrp-mcmember_rec.sl_flow_hop,
+ sl, flow, hop);
+   mgrp-mcmember_rec.sl_flow_hop =
+   ib_member_set_sl_flow_hop(p_prtn-sl, flow, hop);
+   }
 }

 /***
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] complib/cl_timer.c: fixing cl_timer calculation

2010-08-25 Thread Yevgeny Kliteynik
On 25-Aug-10 7:07 PM, Sasha Khapyorsky wrote:
 On 15:01 Tue 24 Aug , Yevgeny Kliteynik wrote:

 BTW, any idea what are the (obviously historical)
 reasons for these lines in the code?

 323: /* do not do 0 wait ! */
 324: /* if (delta_time  1000.0) {delta_time = 1000;} */
 
 Have no idea. This is from day zero of git history.

Well, it's not there any more.

-- Yevgeny

 Sasha
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] complib/cl_timer.c: fixing cl_timer calculation

2010-08-24 Thread Yevgeny Kliteynik
On 23-Aug-10 9:55 PM, Sasha Khapyorsky wrote:
 On 17:38 Mon 23 Aug , Yevgeny Kliteynik wrote:
 When calculating p_timer-timeout.tv_sec and p_timer-timeout.tv_nsec,
 the carry was ignored, resulting in wrong value in p_timer-timeout.tv_sec,
 and value  10^9 in p_timer-timeout.tv_nsec (illegal value).
 
 Nice catch. And I also see a similar issue in cl_timer_trim().
 
 See a comments about the patch below.
 

 Signed-off-by:  Yevgeny Kliteynikklit...@dev.mellanox.co.il

 ---
   opensm/complib/cl_timer.c |8 +---
   1 files changed, 5 insertions(+), 3 deletions(-)

 diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c
 index 2acdb51..09a5584 100644
 --- a/opensm/complib/cl_timer.c
 +++ b/opensm/complib/cl_timer.c
 @@ -299,7 +299,8 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
   {
  struct timeval curtime;
  cl_list_item_t *p_list_item;
 -uint32_t delta_time = time_ms;
 +uint32_t delta_time_sec = time_ms / 1000;
 +uint32_t delta_time_usec = (time_ms % 1000) * 1000;
 
 In order to prevent compatibility and porting issues would it be better
 to use struct timeval's types here:
 
   time_t delta_time_sec;
   suseconds_t delta_time_usec_t delta_time_usec;
 
 , instead of fixed size integers?
 

  CL_ASSERT(p_timer);
  CL_ASSERT(p_timer-state == CL_INITIALIZED);
 @@ -324,9 +325,10 @@ cl_status_t cl_timer_start(IN cl_timer_t * const 
 p_timer,
  /* if (delta_time  1000.0) {delta_time = 1000;} */

  /* Calculate the timeout. */
 -p_timer-timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
 +p_timer-timeout.tv_sec = curtime.tv_sec + delta_time_sec +
 +((curtime.tv_usec + delta_time_usec) / 100);
  p_timer-timeout.tv_nsec =
 -(curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
 +((curtime.tv_usec + delta_time_usec) % 100) * 1000;
 
 Or even something like this:
 
   strcut timeval curtime, deltatime;
 
   gettimeofday(curtime, NULL);
 
   addtime.tv_sec = time_ms / 1000;
   addtime.tv_usec = (time_ms % 1000) * 1000;
 
   timeradd(curtime,addtime,timer-timeout);
 
 ?

Sure, why not. It won't be that clean, because p_timer-timeout
and curtime/deltatime are different types, but I get the idea.

-- Yevgeny
 
 Sasha
 

  /* Add the timer to the queue. */
  if (cl_is_qlist_empty(gp_timer_prov-queue)) {
 -- 
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] complib/cl_timer.c: fixing cl_timer calculation

2010-08-24 Thread Yevgeny Kliteynik
On 24-Aug-10 2:55 PM, Yevgeny Kliteynik wrote:
 On 23-Aug-10 9:55 PM, Sasha Khapyorsky wrote:
 On 17:38 Mon 23 Aug , Yevgeny Kliteynik wrote:
 When calculating p_timer-timeout.tv_sec and p_timer-timeout.tv_nsec,
 the carry was ignored, resulting in wrong value in p_timer-timeout.tv_sec,
 and value   10^9 in p_timer-timeout.tv_nsec (illegal value).

 Nice catch. And I also see a similar issue in cl_timer_trim().

BTW, any idea what are the (obviously historical)
reasons for these lines in the code?

323:/* do not do 0 wait ! */
324:/* if (delta_time  1000.0) {delta_time = 1000;} */

-- Yevgeny

 See a comments about the patch below.


 Signed-off-by:  Yevgeny Kliteynikklit...@dev.mellanox.co.il

 ---
opensm/complib/cl_timer.c |8 +---
1 files changed, 5 insertions(+), 3 deletions(-)

 diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c
 index 2acdb51..09a5584 100644
 --- a/opensm/complib/cl_timer.c
 +++ b/opensm/complib/cl_timer.c
 @@ -299,7 +299,8 @@ cl_status_t cl_timer_start(IN cl_timer_t * const 
 p_timer,
{
 struct timeval curtime;
 cl_list_item_t *p_list_item;
 -   uint32_t delta_time = time_ms;
 +   uint32_t delta_time_sec = time_ms / 1000;
 +   uint32_t delta_time_usec = (time_ms % 1000) * 1000;

 In order to prevent compatibility and porting issues would it be better
 to use struct timeval's types here:

  time_t delta_time_sec;
  suseconds_t delta_time_usec_t delta_time_usec;

 , instead of fixed size integers?


 CL_ASSERT(p_timer);
 CL_ASSERT(p_timer-state == CL_INITIALIZED);
 @@ -324,9 +325,10 @@ cl_status_t cl_timer_start(IN cl_timer_t * const 
 p_timer,
 /* if (delta_time   1000.0) {delta_time = 1000;} */

 /* Calculate the timeout. */
 -   p_timer-timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
 +   p_timer-timeout.tv_sec = curtime.tv_sec + delta_time_sec +
 +   ((curtime.tv_usec + delta_time_usec) / 100);
 p_timer-timeout.tv_nsec =
 -   (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
 +   ((curtime.tv_usec + delta_time_usec) % 100) * 1000;

 Or even something like this:

  strcut timeval curtime, deltatime;

  gettimeofday(curtime, NULL);

  addtime.tv_sec = time_ms / 1000;
  addtime.tv_usec = (time_ms % 1000) * 1000;

  timeradd(curtime,addtime,timer-timeout);

 ?
 
 Sure, why not. It won't be that clean, because p_timer-timeout
 and curtime/deltatime are different types, but I get the idea.
 
 -- Yevgeny
 
 Sasha


 /* Add the timer to the queue. */
 if (cl_is_qlist_empty(gp_timer_prov-queue)) {
 -- 
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


 
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] complib/cl_timer.c: fixing cl_timer calculation

2010-08-24 Thread Yevgeny Kliteynik
When calculating p_timer-timeout.tv_sec and p_timer-timeout.tv_nsec,
the carry was ignored, resulting in wrong value in p_timer-timeout.tv_sec,
and value  10^9 in p_timer-timeout.tv_nsec (illegal value).

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

V2: - using macros instead of int types
- fixed the same problem in cl_timer_trim()

 opensm/complib/cl_timer.c |   48 ++--
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c
index 2acdb51..3b3c7b0 100644
--- a/opensm/complib/cl_timer.c
+++ b/opensm/complib/cl_timer.c
@@ -294,12 +294,32 @@ static cl_status_t __cl_timer_find(IN const 
cl_list_item_t * const p_list_item,
return (CL_NOT_FOUND);
 }

+/*
+ * Calculate 'struct timespec' value that is the
+ * current time plus the 'time_ms' milliseconds.
+ */
+static __inline void __cl_timer_calculate(IN const uint32_t time_ms,
+ OUT struct timespec * const p_timer)
+{
+   struct timeval curtime, deltatime, endtime;
+
+#ifndef timerclear
+#define timerclear(tvp)  (tvp)-tv_sec = (time_t)0, (tvp)-tv_usec = 0L
+#endif
+   timerclear(curtime);
+   gettimeofday(curtime, NULL);
+
+   deltatime.tv_sec = time_ms / 1000;
+   deltatime.tv_usec = (time_ms % 1000) * 1000;
+   timeradd(curtime, deltatime, endtime);
+   p_timer-tv_sec = endtime.tv_sec;
+   p_timer-tv_nsec = endtime.tv_usec * 1000;
+}
+
 cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
   IN const uint32_t time_ms)
 {
-   struct timeval curtime;
cl_list_item_t *p_list_item;
-   uint32_t delta_time = time_ms;

CL_ASSERT(p_timer);
CL_ASSERT(p_timer-state == CL_INITIALIZED);
@@ -313,20 +333,7 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
cl_qlist_remove_item(gp_timer_prov-queue,
 p_timer-list_item);

-   /* Get the current time */
-#ifndef timerclear
-#definetimerclear(tvp) (tvp)-tv_sec = (time_t)0, 
(tvp)-tv_usec = 0L
-#endif
-   timerclear(curtime);
-   gettimeofday(curtime, NULL);
-
-   /* do not do 0 wait ! */
-   /* if (delta_time  1000.0) {delta_time = 1000;} */
-
-   /* Calculate the timeout. */
-   p_timer-timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
-   p_timer-timeout.tv_nsec =
-   (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
+   __cl_timer_calculate(time_ms, p_timer-timeout);

/* Add the timer to the queue. */
if (cl_is_qlist_empty(gp_timer_prov-queue)) {
@@ -385,7 +392,6 @@ void cl_timer_stop(IN cl_timer_t * const p_timer)
 cl_status_t cl_timer_trim(IN cl_timer_t * const p_timer,
  IN const uint32_t time_ms)
 {
-   struct timeval curtime;
struct timespec newtime;
cl_status_t status;

@@ -394,13 +400,7 @@ cl_status_t cl_timer_trim(IN cl_timer_t * const p_timer,

pthread_mutex_lock(gp_timer_prov-mutex);

-   /* Get the current time */
-   timerclear(curtime);
-   gettimeofday(curtime, NULL);
-
-   /* Calculate the timeout. */
-   newtime.tv_sec = curtime.tv_sec + (time_ms / 1000);
-   newtime.tv_nsec = (curtime.tv_usec + ((time_ms % 1000) * 1000)) * 1000;
+   __cl_timer_calculate(time_ms, newtime);

if (p_timer-timer_state == CL_TIMER_QUEUED) {
/* If the old time is earlier, do not trim it.  Just return. */
-- 
1.6.2.4


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] complib/cl_timer.c: fixing cl_timer calculation

2010-08-23 Thread Yevgeny Kliteynik
When calculating p_timer-timeout.tv_sec and p_timer-timeout.tv_nsec,
the carry was ignored, resulting in wrong value in p_timer-timeout.tv_sec,
and value  10^9 in p_timer-timeout.tv_nsec (illegal value).

Signed-off-by:  Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 opensm/complib/cl_timer.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c
index 2acdb51..09a5584 100644
--- a/opensm/complib/cl_timer.c
+++ b/opensm/complib/cl_timer.c
@@ -299,7 +299,8 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
 {
struct timeval curtime;
cl_list_item_t *p_list_item;
-   uint32_t delta_time = time_ms;
+   uint32_t delta_time_sec = time_ms / 1000;
+   uint32_t delta_time_usec = (time_ms % 1000) * 1000;

CL_ASSERT(p_timer);
CL_ASSERT(p_timer-state == CL_INITIALIZED);
@@ -324,9 +325,10 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
/* if (delta_time  1000.0) {delta_time = 1000;} */

/* Calculate the timeout. */
-   p_timer-timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
+   p_timer-timeout.tv_sec = curtime.tv_sec + delta_time_sec +
+   ((curtime.tv_usec + delta_time_usec) / 100);
p_timer-timeout.tv_nsec =
-   (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
+   ((curtime.tv_usec + delta_time_usec) % 100) * 1000;

/* Add the timer to the queue. */
if (cl_is_qlist_empty(gp_timer_prov-queue)) {
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: opensm/osm_opensm.c: no report when SM is exiting

2010-08-19 Thread Yevgeny Kliteynik
On 19-Aug-10 3:59 AM, Ira Weiny wrote:
 On Wed, 18 Aug 2010 14:58:44 -0700
 Yevgeny Kliteynikklit...@gmail.com  wrote:
 
 On 18-Aug-10 7:06 PM, Ira Weiny wrote:
 On Wed, 18 Aug 2010 06:38:14 -0700
 Yevgeny Kliteynikklit...@dev.mellanox.co.il   wrote:

 Don't bother reporting events to plug-ins while SM is exiting.

 Does this fix a bug?

 Don't think so (at least not that I'm aware of it).
 For me, the issue here is optimization.
 
 Does this delay exit?  Is that the optimization.

Yes.
When SM catches SIGTERM, it marks osm_exit_flag.
However, it doesn't mean that SM will stop doing
whatever it's doing and start exiting - if SM is
in the middle of calling plug-ins, it will
continue calling them.

 
 I wonder if plugins would want to know the SM is shutting down.  But there is
 a delete function... ?

The delete function allows plug-ins to know when
SM is exiting (if they want to know it).

-- Yevgeny 
 
 Ira
 

 -- Yevgeny

 Ira


 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
opensm/opensm/osm_opensm.c |2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
 index d3dc02e..50e8763 100644
 --- a/opensm/opensm/osm_opensm.c
 +++ b/opensm/opensm/osm_opensm.c
 @@ -475,7 +475,7 @@ void osm_opensm_report_event(osm_opensm_t *osm, 
 osm_epi_event_id_t event_id,
cl_list_item_t *item;

for (item = cl_qlist_head(osm-plugin_list);
 -   item != cl_qlist_end(osm-plugin_list);
 +   (!osm_exit_flag)   (item != cl_qlist_end(osm-plugin_list));
 item = cl_qlist_next(item)) {
osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
if (p-impl-report)
 -- 
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://**vger.kernel.org/majordomo-info.html





 
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


opensm/osm_opensm.c: no report when SM is exiting

2010-08-18 Thread Yevgeny Kliteynik
Don't bother reporting events to plug-ins while SM is exiting.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_opensm.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index d3dc02e..50e8763 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -475,7 +475,7 @@ void osm_opensm_report_event(osm_opensm_t *osm, 
osm_epi_event_id_t event_id,
cl_list_item_t *item;

for (item = cl_qlist_head(osm-plugin_list);
-item != cl_qlist_end(osm-plugin_list);
+(!osm_exit_flag)  (item != cl_qlist_end(osm-plugin_list));
 item = cl_qlist_next(item)) {
osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
if (p-impl-report)
-- 
1.6.2.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: opensm/osm_opensm.c: no report when SM is exiting

2010-08-18 Thread Yevgeny Kliteynik
On 18-Aug-10 7:06 PM, Ira Weiny wrote:
 On Wed, 18 Aug 2010 06:38:14 -0700
 Yevgeny Kliteynikklit...@dev.mellanox.co.il  wrote:
 
 Don't bother reporting events to plug-ins while SM is exiting.
 
 Does this fix a bug?

Don't think so (at least not that I'm aware of it).
For me, the issue here is optimization.

-- Yevgeny
 
 Ira
 

 Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
 ---
   opensm/opensm/osm_opensm.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
 index d3dc02e..50e8763 100644
 --- a/opensm/opensm/osm_opensm.c
 +++ b/opensm/opensm/osm_opensm.c
 @@ -475,7 +475,7 @@ void osm_opensm_report_event(osm_opensm_t *osm, 
 osm_epi_event_id_t event_id,
  cl_list_item_t *item;

  for (item = cl_qlist_head(osm-plugin_list);
 - item != cl_qlist_end(osm-plugin_list);
 + (!osm_exit_flag)  (item != cl_qlist_end(osm-plugin_list));
   item = cl_qlist_next(item)) {
  osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
  if (p-impl-report)
 -- 
 1.6.2.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-rdma in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://*vger.kernel.org/majordomo-info.html

 
 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm: event plig-in API fixed to compile with g++

2010-07-06 Thread Yevgeny Kliteynik

On 07-Jul-10 12:03 AM, Ira Weiny wrote:

On Mon, 5 Jul 2010 11:41:44 -0700
Sasha Khapyorskysas...@voltaire.com  wrote:


On 14:30 Mon 05 Jul , Hal Rosenstock wrote:

On Mon, Jul 5, 2010 at 2:11 PM, Sasha Khapyorskysas...@voltaire.com  wrote:

On 11:10 Thu 24 Jun , Yevgeny Kliteynik wrote:

Event API should have been able to be used by libraries
written both in C and C++.


I don't know about such requirement.


Are you saying it isn't a valid requirement to allow OpenSM plugins to
be C++ based ? If so, why not ?


I'm saying that there is no requirement for plugin API to support C++ -
obviously (following method names) plugin API was never developed for
using it in C++.


Actually IMO this is not correct.  The use of delete was introduced
by commit a5963f93fa3d4514cc526e4ad029b036724b8167.  I was at fault to
not have objected back then.  The use of extern C in all of the header
files below implies a desire to support C++.


Couldn't agree more.

-- Yevgeny


10:28:14  pwd; grep BEGIN_C_DECLS extern *
/home/weiny2/OpenIB/git-trees/management/opensm/include/opensm
osm_attrib_req.h:#  define BEGIN_C_DECLS extern C {
osm_base.h:#  define BEGIN_C_DECLS extern C {
osm_console.h:#  define BEGIN_C_DECLS extern C {
osm_console_io.h:#  define BEGIN_C_DECLS extern C {
osm_db.h:#  define BEGIN_C_DECLS extern C {
osm_db_pack.h:#  define BEGIN_C_DECLS extern C {
osm_event_plugin.h:#  define BEGIN_C_DECLS extern C {
osm_helper.h:#  define BEGIN_C_DECLS extern C {
osm_inform.h:#  define BEGIN_C_DECLS extern C {
osm_lid_mgr.h:#  define BEGIN_C_DECLS extern C {
osm_log.h:#  define BEGIN_C_DECLS extern C {
osm_mad_pool.h:#  define BEGIN_C_DECLS extern C {
osm_madw.h:#  define BEGIN_C_DECLS extern C {
osm_mcast_tbl.h:#  define BEGIN_C_DECLS extern C {
osm_mcm_port.h:#  define BEGIN_C_DECLS extern C {
osm_msgdef.h:#  define BEGIN_C_DECLS extern C {
osm_mtree.h:#  define BEGIN_C_DECLS extern C {
osm_multicast.h:#  define BEGIN_C_DECLS extern C {
osm_node.h:#  define BEGIN_C_DECLS extern C {
osm_opensm.h:#  define BEGIN_C_DECLS extern C {
osm_partition.h:#  define BEGIN_C_DECLS extern C {
osm_path.h:#  define BEGIN_C_DECLS extern C {
osm_perfmgr_db.h:#  define BEGIN_C_DECLS extern C {
osm_pkey.h:#  define BEGIN_C_DECLS extern C {
osm_port.h:#  define BEGIN_C_DECLS extern C {
osm_port_profile.h:#  define BEGIN_C_DECLS extern C {
osm_prefix_route.h:#  define BEGIN_C_DECLS extern C {
osm_remote_sm.h:#  define BEGIN_C_DECLS extern C {
osm_router.h:#  define BEGIN_C_DECLS extern C {
osm_sa.h:#  define BEGIN_C_DECLS extern C {
osm_sa_mad_ctrl.h:#  define BEGIN_C_DECLS extern C {
osm_service.h:#  define BEGIN_C_DECLS extern C {
osm_sm.h:#  define BEGIN_C_DECLS extern C {
osm_sm.h.orig:#  define BEGIN_C_DECLS extern C {
osm_sm_mad_ctrl.h:#  define BEGIN_C_DECLS extern C {
osm_stats.h:#  define BEGIN_C_DECLS extern C {
osm_subnet.h:#  define BEGIN_C_DECLS extern C {
osm_subnet.h.orig:#  define BEGIN_C_DECLS extern C {
osm_switch.h:#  define BEGIN_C_DECLS extern C {
osm_ucast_cache.h:#  define BEGIN_C_DECLS extern C {
osm_ucast_mgr.h:#  define BEGIN_C_DECLS extern C {
osm_vl15intf.h:#  define BEGIN_C_DECLS extern C {
st.h:#  define BEGIN_C_DECLS extern C {

Ira



Why not is another question - for instance in order to not deal with
C/C++ compatibility issues (such as castings, function names limitation,
linking mess, etc.)

Sasha
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://*vger.kernel.org/majordomo-info.html





--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6] opensm/osmeventplugin: added new events to monitor SM

2010-06-30 Thread Yevgeny Kliteynik
Adding new events that allow event plug-in to see
when SM starts/finishes heavy sweep and routing
configuration, when it updates dump files, when it
is no longer master, when SM port is down, and when
SA DB is actually dumped at the end of light sweep:

  OSM_EVENT_ID_HEAVY_SWEEP_START
  OSM_EVENT_ID_HEAVY_SWEEP_DONE
  OSM_EVENT_ID_UCAST_ROUTING_DONE
  OSM_EVENT_ID_STATE_CHANGE
  OSM_EVENT_ID_SA_DB_DUMPED

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

Changes since v5:
 - Added OSM_EVENT_ID_HEAVY_SWEEP_START event.

Changes since v4:
 - OSM_EVENT_ID_SA_DB_DUMPED was still reported during
   heavy sweep - removed.

Changes since v3:
 - OSM_EVENT_ID_ENTERING_STANDBY and OSM_EVENT_ID_SM_PORT_DOWN
   replaced by OSM_EVENT_STATE_CHANGE
 - OSM_EVENT_ID_SA_DB_DUMPED is not reported during
   heavy sweep, but only if SA DB was actually dumped
   at the end of light sweep
 - fixed bug with OSM_EVENT_ID_MAX

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/include/opensm/osm_event_plugin.h   |5 +
 opensm/opensm/osm_state_mgr.c  |   20 ++--
 opensm/osmeventplugin/src/osmeventplugin.c |   15 +++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 33d1920..6a99ed9 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -72,6 +72,11 @@ typedef enum {
OSM_EVENT_ID_PORT_SELECT,
OSM_EVENT_ID_TRAP,
OSM_EVENT_ID_SUBNET_UP,
+   OSM_EVENT_ID_HEAVY_SWEEP_START,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE,
+   OSM_EVENT_ID_STATE_CHANGE,
+   OSM_EVENT_ID_SA_DB_DUMPED,
OSM_EVENT_ID_MAX
 } osm_epi_event_id_t;

diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 81c8f54..e7bff46 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1107,8 +1107,10 @@ static void do_sweep(osm_sm_t * sm)
if (wait_for_pending_transactions(sm-p_subn-p_osm-stats))
return;
if (!sm-p_subn-force_heavy_sweep) {
-   if (sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (sm-p_subn-opt.sa_db_dump 
+   !osm_sa_db_file_dump(sm-p_subn-p_osm))
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SA_DB_DUMPED, NULL);
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
LIGHT SWEEP COMPLETE);
return;
@@ -1151,10 +1153,15 @@ static void do_sweep(osm_sm_t * sm)
if (!sm-p_subn-subnet_initialization_error) {
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
REROUTE COMPLETE);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);
return;
}
}

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_START, NULL);
+
/* go to heavy sweep */
 repeat_discovery:

@@ -1185,6 +1192,8 @@ repeat_discovery:

/* Move to DISCOVERING state */
osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1205,6 +1214,8 @@ repeat_discovery:
ENTERING STANDBY STATE);
/* notify master SM about us */
osm_send_trap144(sm, 0);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1212,6 +1223,9 @@ repeat_discovery:
if (sm-p_subn-force_heavy_sweep)
goto repeat_discovery;

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE, HEAVY SWEEP COMPLETE);

/* If we are MASTER - get the highest remote_sm, and
@@ -1314,6 +1328,8 @@ repeat_discovery:

OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
SWITCHES CONFIGURED FOR UNICAST);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);

if (!sm-p_subn-opt.disable_multicast) {
osm_mcast_mgr_process(sm);
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c 
b/opensm/osmeventplugin/src/osmeventplugin.c
index b4d9ce9..9caf184 100644
--- a/opensm/osmeventplugin/src/osmeventplugin.c
+++ b/opensm

[PATCH] opensm: event plig-in API fixed to compile with g++

2010-06-24 Thread Yevgeny Kliteynik
Event API should have been able to be used by libraries
written both in C and C++. The problem is, one of the
fields in struct osm_event_plugin is called delete.
Changing it to destroy and promoting the API version.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/include/opensm/osm_event_plugin.h|2 +-
 opensm/opensm/osm_event_plugin.c|4 ++--
 opensm/osmeventplugin/libosmeventplugin.ver |2 +-
 opensm/osmeventplugin/src/osmeventplugin.c  |2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 0b3464e..aa3fed4 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -145,7 +145,7 @@ typedef struct osm_api_ps_event {
 typedef struct osm_event_plugin {
const char *osm_version;
void *(*create) (struct osm_opensm *osm);
-   void (*delete) (void *plugin_data);
+   void (*destroy) (void *plugin_data);
void (*report) (void *plugin_data, osm_epi_event_id_t event_id,
void *event_data);
 } osm_event_plugin_t;
diff --git a/opensm/opensm/osm_event_plugin.c b/opensm/opensm/osm_event_plugin.c
index 2d67065..7f61960 100644
--- a/opensm/opensm/osm_event_plugin.c
+++ b/opensm/opensm/osm_event_plugin.c
@@ -141,8 +141,8 @@ DLOPENFAIL:
 void osm_epi_destroy(osm_epi_plugin_t * plugin)
 {
if (plugin) {
-   if (plugin-impl-delete)
-   plugin-impl-delete(plugin-plugin_data);
+   if (plugin-impl-destroy)
+   plugin-impl-destroy(plugin-plugin_data);
dlclose(plugin-handle);
free(plugin-plugin_name);
free(plugin);
diff --git a/opensm/osmeventplugin/libosmeventplugin.ver 
b/opensm/osmeventplugin/libosmeventplugin.ver
index f755ff6..0c3a85b 100644
--- a/opensm/osmeventplugin/libosmeventplugin.ver
+++ b/opensm/osmeventplugin/libosmeventplugin.ver
@@ -6,4 +6,4 @@
 # API_REV - advance on any added API
 # RUNNING_REV - advance any change to the vendor files
 # AGE - number of backward versions the API still supports
-LIBVERSION=1:0:0
+LIBVERSION=2:0:0
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c 
b/opensm/osmeventplugin/src/osmeventplugin.c
index f40f7fe..a82be07 100644
--- a/opensm/osmeventplugin/src/osmeventplugin.c
+++ b/opensm/osmeventplugin/src/osmeventplugin.c
@@ -207,6 +207,6 @@ static void report(void *_log, osm_epi_event_id_t event_id, 
void *event_data)
 osm_event_plugin_t osm_event_plugin = {
   osm_version:OSM_VERSION,
   create:construct,
-  delete:destroy,
+  destroy:destroy,
   report:report
 };
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] opensm/osmeventplugin: added new events to monitor SM

2010-06-20 Thread Yevgeny Kliteynik

On 20-Jun-10 12:31 PM, Yevgeny Kliteynik wrote:

Adding new events that allow event plug-in to see
when SM finishes heavy sweep and routing configuration,
when it updates dump files, when it is no longer master,
when SM port is down, and when SA DB is actually dumped
at the end of light sweep:

   OSM_EVENT_ID_HEAVY_SWEEP_DONE
   OSM_EVENT_ID_UCAST_ROUTING_DONE
   OSM_EVENT_ID_STATE_CHANGE
   OSM_EVENT_ID_SA_DB_DUMPED

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---

Changes since v3:
  - OSM_EVENT_ID_ENTERING_STANDBY and OSM_EVENT_ID_SM_PORT_DOWN
replaced by OSM_EVENT_STATE_CHANGE
  - OSM_EVENT_ID_SA_DB_DUMPED is not reported during
heavy sweep, but only if SA DB was actually dumped


Nope, still reported during heavy sweep. V5 is on its way...

-- Yevgeny


at the end of light sweep
  - fixed bug with OSM_EVENT_ID_MAX

  opensm/include/opensm/osm_event_plugin.h   |4 
  opensm/opensm/osm_state_mgr.c  |   22 +++---
  opensm/osmeventplugin/src/osmeventplugin.c |   14 ++
  3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 33d1920..0b3464e 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -72,6 +72,10 @@ typedef enum {
OSM_EVENT_ID_PORT_SELECT,
OSM_EVENT_ID_TRAP,
OSM_EVENT_ID_SUBNET_UP,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE,
+   OSM_EVENT_ID_STATE_CHANGE,
+   OSM_EVENT_ID_SA_DB_DUMPED,
OSM_EVENT_ID_MAX
  } osm_epi_event_id_t;

diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 81c8f54..be6e67d 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1107,8 +1107,10 @@ static void do_sweep(osm_sm_t * sm)
if (wait_for_pending_transactions(sm-p_subn-p_osm-stats))
return;
if (!sm-p_subn-force_heavy_sweep) {
-   if (sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (sm-p_subn-opt.sa_db_dump
+   !osm_sa_db_file_dump(sm-p_subn-p_osm))
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SA_DB_DUMPED, NULL);
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
LIGHT SWEEP COMPLETE);
return;
@@ -1151,6 +1153,8 @@ static void do_sweep(osm_sm_t * sm)
if (!sm-p_subn-subnet_initialization_error) {
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
REROUTE COMPLETE);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);
return;
}
}
@@ -1185,6 +1189,8 @@ repeat_discovery:

/* Move to DISCOVERING state */
osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1205,6 +1211,8 @@ repeat_discovery:
ENTERING STANDBY STATE);
/* notify master SM about us */
osm_send_trap144(sm, 0);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1212,6 +1220,9 @@ repeat_discovery:
if (sm-p_subn-force_heavy_sweep)
goto repeat_discovery;

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE, HEAVY SWEEP COMPLETE);

/* If we are MASTER - get the highest remote_sm, and
@@ -1314,6 +1325,8 @@ repeat_discovery:

OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
SWITCHES CONFIGURED FOR UNICAST);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);

if (!sm-p_subn-opt.disable_multicast) {
osm_mcast_mgr_process(sm);
@@ -1375,7 +1388,10 @@ repeat_discovery:

if (osm_log_is_active(sm-p_log, OSM_LOG_VERBOSE) ||
sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (!osm_sa_db_file_dump(sm-p_subn-p_osm))
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SA_DB_DUMPED, NULL);
+
}

/*
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c 
b/opensm/osmeventplugin/src

[PATCH v5] opensm/osmeventplugin: added new events to monitor SM

2010-06-20 Thread Yevgeny Kliteynik
Adding new events that allow event plug-in to see
when SM finishes heavy sweep and routing configuration,
when it updates dump files, when it is no longer master,
when SM port is down, and when SA DB is actually dumped
at the end of light sweep:

  OSM_EVENT_ID_HEAVY_SWEEP_DONE
  OSM_EVENT_ID_UCAST_ROUTING_DONE
  OSM_EVENT_ID_STATE_CHANGE
  OSM_EVENT_ID_SA_DB_DUMPED

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

Changes since v4:
 - OSM_EVENT_ID_SA_DB_DUMPED was still reported during
   heavy sweep - removed.

Changes since v3:
 - OSM_EVENT_ID_ENTERING_STANDBY and OSM_EVENT_ID_SM_PORT_DOWN
   replaced by OSM_EVENT_STATE_CHANGE
 - OSM_EVENT_ID_SA_DB_DUMPED is not reported during
   heavy sweep, but only if SA DB was actually dumped
   at the end of light sweep
 - fixed bug with OSM_EVENT_ID_MAX

 opensm/include/opensm/osm_event_plugin.h   |4 
 opensm/opensm/osm_state_mgr.c  |   17 +++--
 opensm/osmeventplugin/src/osmeventplugin.c |   12 
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 33d1920..0b3464e 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -72,6 +72,10 @@ typedef enum {
OSM_EVENT_ID_PORT_SELECT,
OSM_EVENT_ID_TRAP,
OSM_EVENT_ID_SUBNET_UP,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE,
+   OSM_EVENT_ID_STATE_CHANGE,
+   OSM_EVENT_ID_SA_DB_DUMPED,
OSM_EVENT_ID_MAX
 } osm_epi_event_id_t;

diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 81c8f54..299514b 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1107,8 +1107,10 @@ static void do_sweep(osm_sm_t * sm)
if (wait_for_pending_transactions(sm-p_subn-p_osm-stats))
return;
if (!sm-p_subn-force_heavy_sweep) {
-   if (sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (sm-p_subn-opt.sa_db_dump 
+   !osm_sa_db_file_dump(sm-p_subn-p_osm))
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SA_DB_DUMPED, NULL);
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
LIGHT SWEEP COMPLETE);
return;
@@ -1151,6 +1153,8 @@ static void do_sweep(osm_sm_t * sm)
if (!sm-p_subn-subnet_initialization_error) {
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
REROUTE COMPLETE);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);
return;
}
}
@@ -1185,6 +1189,8 @@ repeat_discovery:

/* Move to DISCOVERING state */
osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1205,6 +1211,8 @@ repeat_discovery:
ENTERING STANDBY STATE);
/* notify master SM about us */
osm_send_trap144(sm, 0);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_STATE_CHANGE, NULL);
return;
}

@@ -1212,6 +1220,9 @@ repeat_discovery:
if (sm-p_subn-force_heavy_sweep)
goto repeat_discovery;

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE, HEAVY SWEEP COMPLETE);

/* If we are MASTER - get the highest remote_sm, and
@@ -1314,6 +1325,8 @@ repeat_discovery:

OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
SWITCHES CONFIGURED FOR UNICAST);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);

if (!sm-p_subn-opt.disable_multicast) {
osm_mcast_mgr_process(sm);
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c 
b/opensm/osmeventplugin/src/osmeventplugin.c
index b4d9ce9..f40f7fe 100644
--- a/opensm/osmeventplugin/src/osmeventplugin.c
+++ b/opensm/osmeventplugin/src/osmeventplugin.c
@@ -176,6 +176,18 @@ static void report(void *_log, osm_epi_event_id_t 
event_id, void *event_data)
case OSM_EVENT_ID_SUBNET_UP:
fprintf(log-log_file, Subnet up reported\n);
break;
+   case OSM_EVENT_ID_HEAVY_SWEEP_DONE:
+   fprintf(log-log_file, Heavy sweep completed\n);
+   break;
+   case

Re: [PATCH v3] opensm/osmeventplugin: added new events to monitor SM

2010-06-17 Thread Yevgeny Kliteynik

Hi Sasha,

On 17-Jun-10 5:18 PM, Sasha Khapyorsky wrote:

On 14:41 Thu 10 Jun , Yevgeny Kliteynik wrote:

Hi Sasha,

Adding new events that allow event plug-in to see
when SM finishes heavy sweep and routing configuration,
when it updates dump files, when it is no longer master,
and when SM port is down:

   OSM_EVENT_ID_HEAVY_SWEEP_DONE
   OSM_EVENT_ID_UCAST_ROUTING_DONE


What is wrong with using Subnet Up event for those purposes?


There is a big difference between SWEEP_DONE  and SUBNET_UP
events. The former happens before all the managers (drop
manager, QoS, unicast and multicast routing, etc), so there
is a long period between two events.
Moreover, after SWEEP_DONE there is a lot of information
that is later cleared.

As for ROUTING_DONE, if OSM is doing re-route only, then
routing might change, and we don't get SUBNET_UP event.
Furthermore, when torus2QoS routing will be included in
the SM, the re-route will also cause QoS configuration
to change.
 

   OSM_EVENT_ID_ENTERING_STANDBY
   OSM_EVENT_ID_SM_PORT_DOWN


Instead I would suggest to make state change event.


OK
 

   OSM_EVENT_ID_SA_DB_DUMPED


Again, Subnet Up indicates that all sweep stuff is done (including
dump files).


This is true. In fact, the way I posed it, there is no
point adding this event. However, this event should also
be sent when SA DB is dumped at the end of light sweep,
and then SUBNET_UP cannot replace it.



The last event is reported when SA DB is actually dumped.

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---

Changes from V2:
   - reduced number of events that are reported
   - rebased to latest master

---
  opensm/include/opensm/osm_event_plugin.h   |7 ++-
  opensm/opensm/osm_state_mgr.c  |   16 +++-
  opensm/osmeventplugin/src/osmeventplugin.c |   15 +++
  3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 33d1920..a565123 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -72,7 +72,12 @@ typedef enum {
OSM_EVENT_ID_PORT_SELECT,
OSM_EVENT_ID_TRAP,
OSM_EVENT_ID_SUBNET_UP,
-   OSM_EVENT_ID_MAX
+   OSM_EVENT_ID_MAX,


Likely you wanted to move OSM_EVENT_ID_MAX to be last in the list.


Oops...

-- Yevgeny


Sasha


+   OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE,
+   OSM_EVENT_ID_ENTERING_STANDBY,
+   OSM_EVENT_ID_SM_PORT_DOWN,
+   OSM_EVENT_ID_SA_DB_DUMPED
  } osm_epi_event_id_t;

  typedef struct osm_epi_port_id {
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 81c8f54..3231ae9 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1151,6 +1151,8 @@ static void do_sweep(osm_sm_t * sm)
if (!sm-p_subn-subnet_initialization_error) {
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
REROUTE COMPLETE);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);
return;
}
}
@@ -1185,6 +1187,8 @@ repeat_discovery:

/* Move to DISCOVERING state */
osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SM_PORT_DOWN, NULL);
return;
}

@@ -1205,6 +1209,8 @@ repeat_discovery:
ENTERING STANDBY STATE);
/* notify master SM about us */
osm_send_trap144(sm, 0);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_ENTERING_STANDBY, NULL);
return;
}

@@ -1212,6 +1218,9 @@ repeat_discovery:
if (sm-p_subn-force_heavy_sweep)
goto repeat_discovery;

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE, HEAVY SWEEP COMPLETE);

/* If we are MASTER - get the highest remote_sm, and
@@ -1314,6 +1323,8 @@ repeat_discovery:

OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
SWITCHES CONFIGURED FOR UNICAST);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);

if (!sm-p_subn-opt.disable_multicast) {
osm_mcast_mgr_process(sm);
@@ -1375,7 +1386,10 @@ repeat_discovery:

if (osm_log_is_active(sm-p_log, OSM_LOG_VERBOSE) ||
sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (!osm_sa_db_file_dump(sm-p_subn-p_osm

Re: [PATCH v2] opensm: Modify connect_roots to allow connectivity between all switches

2010-06-15 Thread Yevgeny Kliteynik

On 15-Jun-10 10:09 AM, Eli Dorfman (Voltaire) wrote:

Yevgeny Kliteynik wrote:

Eli,

On 13-Jun-10 6:10 PM, Eli Dorfman (Voltaire) wrote:

After a second thought and in order not to break current configuration,
I send this modified patch that does not change connect_roots option but
changes its functionality in up-down (I think that in fat-tree it is
already implemented)

Modify connect_roots option to allow connectivity between
all switches in up-down routing algorithm and in this way be
fully IBA compliant

Signed-off-by: Eli Dorfmane...@voltaire.com
---
   opensm/man/opensm.8.in |2 +-
   opensm/opensm/main.c   |2 +-
   opensm/opensm/osm_ucast_updn.c |4 +---
   3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/opensm/man/opensm.8.in b/opensm/man/opensm.8.in
index 9053611..c67126e 100644
--- a/opensm/man/opensm.8.in
+++ b/opensm/man/opensm.8.in
@@ -174,7 +174,7 @@ the host comes back online.
   .TP
   \fB\-z\fR, \fB\-\-connect_roots\fR
   This option enforces routing engines (up/down and
-fat-tree) to make connectivity between root switches and in
+fat-tree) to make connectivity between all switches and in
   this way to be fully IBA complaint. In many cases this can
   violate pure deadlock free algorithm, so use it carefully.
   .TP
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 0093aa7..82ca78f 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -187,7 +187,7 @@ static void show_usage(void)
Sets the SL to use to communicate with the
SM/SA. Defaults to 0.\n\n);
   printf(--connect_roots, -z\n
This option enforces routing engines (up/down
and \n
- fat-tree) to make connectivity between root
switches\n
+ fat-tree) to make connectivity between all
switches\n
and in this way be IBA compliant. In many
cases,\n
this can violate \pure\ deadlock free
algorithm, so\n
use it carefully.\n\n);
diff --git a/opensm/opensm/osm_ucast_updn.c
b/opensm/opensm/osm_ucast_updn.c
index 164c6f4..f44ca24 100644
--- a/opensm/opensm/osm_ucast_updn.c
+++ b/opensm/opensm/osm_ucast_updn.c
@@ -314,9 +314,7 @@ static int updn_set_min_hop_table(IN updn_t * p_updn)
item = cl_qmap_next(item)) {
   p_sw = (osm_switch_t *)item;
   /* Clear Min Hop Table */
-if (p_subn-opt.connect_roots)
-updn_clear_non_root_hops(p_updn, p_sw);
-else
+if (!p_subn-opt.connect_roots)
   osm_switch_clear_hops(p_sw);
   }



What kind of testing was done for this?
I have a strong feeling that it will break up/down.
If the connect_roots option is on, you will not clear
the lid matrix at all, and it will contain also the
down/up routes.


that is the idea.
instead of leaving only up/dpwn routes we want to keep routes between all 
switches.
the routes between host nodes will still be up/down.


Lid matrix might contain down/up routes between many
kinds of switches, not only between roots. This means
that you might have down/up paths between leaf switches,
even though you could have found up/down path for them.
This also means that you might end up with down/up routes
between HCAs that are connected to these leafs.

-- Yevgeny


Eli



-- Yevgeny


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osmtest.c: fix bug in getting attr offset

2010-06-15 Thread Yevgeny Kliteynik
Fix bug that was introduced by commit 4fd4ca306f93376963725285f3bf7c87a76055b0

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/osmtest/osmtest.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/osmtest/osmtest.c b/opensm/osmtest/osmtest.c
index abdfa7e..7412ce7 100644
--- a/opensm/osmtest/osmtest.c
+++ b/opensm/osmtest/osmtest.c
@@ -563,7 +563,7 @@ osmtest_get_all_recs(IN osmtest_t * const p_osmt,

p_context-p_osmt = p_osmt;
user.attr_id = attr_id;
-   user.attr_offset = ib_get_attr_offset((uint16_t) (attr_size  3));
+   user.attr_offset = ib_get_attr_offset((uint16_t) attr_size);

req.query_type = OSMV_QUERY_USER_DEFINED;
req.timeout_ms = p_osmt-opt.transaction_timeout;
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] opensm: Modify connect_roots to allow connectivity between all switches

2010-06-14 Thread Yevgeny Kliteynik

Eli,

On 13-Jun-10 6:10 PM, Eli Dorfman (Voltaire) wrote:

After a second thought and in order not to break current configuration,
I send this modified patch that does not change connect_roots option but
changes its functionality in up-down (I think that in fat-tree it is already 
implemented)

Modify connect_roots option to allow connectivity between
all switches in up-down routing algorithm and in this way be
fully IBA compliant

Signed-off-by: Eli Dorfmane...@voltaire.com
---
  opensm/man/opensm.8.in |2 +-
  opensm/opensm/main.c   |2 +-
  opensm/opensm/osm_ucast_updn.c |4 +---
  3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/opensm/man/opensm.8.in b/opensm/man/opensm.8.in
index 9053611..c67126e 100644
--- a/opensm/man/opensm.8.in
+++ b/opensm/man/opensm.8.in
@@ -174,7 +174,7 @@ the host comes back online.
  .TP
  \fB\-z\fR, \fB\-\-connect_roots\fR
  This option enforces routing engines (up/down and
-fat-tree) to make connectivity between root switches and in
+fat-tree) to make connectivity between all switches and in
  this way to be fully IBA complaint. In many cases this can
  violate pure deadlock free algorithm, so use it carefully.
  .TP
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 0093aa7..82ca78f 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -187,7 +187,7 @@ static void show_usage(void)
 Sets the SL to use to communicate with the SM/SA. Defaults 
to 0.\n\n);
printf(--connect_roots, -z\n
 This option enforces routing engines (up/down and \n
-fat-tree) to make connectivity between root 
switches\n
+fat-tree) to make connectivity between all switches\n
 and in this way be IBA compliant. In many cases,\n
 this can violate \pure\ deadlock free algorithm, 
so\n
 use it carefully.\n\n);
diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c
index 164c6f4..f44ca24 100644
--- a/opensm/opensm/osm_ucast_updn.c
+++ b/opensm/opensm/osm_ucast_updn.c
@@ -314,9 +314,7 @@ static int updn_set_min_hop_table(IN updn_t * p_updn)
 item = cl_qmap_next(item)) {
p_sw = (osm_switch_t *)item;
/* Clear Min Hop Table */
-   if (p_subn-opt.connect_roots)
-   updn_clear_non_root_hops(p_updn, p_sw);
-   else
+   if (!p_subn-opt.connect_roots)
osm_switch_clear_hops(p_sw);
}



What kind of testing was done for this?
I have a strong feeling that it will break up/down.
If the connect_roots option is on, you will not clear
the lid matrix at all, and it will contain also the
down/up routes.

-- Yevgeny
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] opensm/osmeventplugin: added new events to monitor SM

2010-06-10 Thread Yevgeny Kliteynik
Hi Sasha,

Adding new events that allow event plug-in to see
when SM finishes heavy sweep and routing configuration,
when it updates dump files, when it is no longer master,
and when SM port is down:

  OSM_EVENT_ID_HEAVY_SWEEP_DONE
  OSM_EVENT_ID_UCAST_ROUTING_DONE
  OSM_EVENT_ID_ENTERING_STANDBY
  OSM_EVENT_ID_SM_PORT_DOWN
  OSM_EVENT_ID_SA_DB_DUMPED

The last event is reported when SA DB is actually dumped.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

Changes from V2:
  - reduced number of events that are reported
  - rebased to latest master

---
 opensm/include/opensm/osm_event_plugin.h   |7 ++-
 opensm/opensm/osm_state_mgr.c  |   16 +++-
 opensm/osmeventplugin/src/osmeventplugin.c |   15 +++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index 33d1920..a565123 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -72,7 +72,12 @@ typedef enum {
OSM_EVENT_ID_PORT_SELECT,
OSM_EVENT_ID_TRAP,
OSM_EVENT_ID_SUBNET_UP,
-   OSM_EVENT_ID_MAX
+   OSM_EVENT_ID_MAX,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE,
+   OSM_EVENT_ID_ENTERING_STANDBY,
+   OSM_EVENT_ID_SM_PORT_DOWN,
+   OSM_EVENT_ID_SA_DB_DUMPED
 } osm_epi_event_id_t;

 typedef struct osm_epi_port_id {
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 81c8f54..3231ae9 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1151,6 +1151,8 @@ static void do_sweep(osm_sm_t * sm)
if (!sm-p_subn-subnet_initialization_error) {
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
REROUTE COMPLETE);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);
return;
}
}
@@ -1185,6 +1187,8 @@ repeat_discovery:

/* Move to DISCOVERING state */
osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SM_PORT_DOWN, NULL);
return;
}

@@ -1205,6 +1209,8 @@ repeat_discovery:
ENTERING STANDBY STATE);
/* notify master SM about us */
osm_send_trap144(sm, 0);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_ENTERING_STANDBY, NULL);
return;
}

@@ -1212,6 +1218,9 @@ repeat_discovery:
if (sm-p_subn-force_heavy_sweep)
goto repeat_discovery;

+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE, HEAVY SWEEP COMPLETE);

/* If we are MASTER - get the highest remote_sm, and
@@ -1314,6 +1323,8 @@ repeat_discovery:

OSM_LOG_MSG_BOX(sm-p_log, OSM_LOG_VERBOSE,
SWITCHES CONFIGURED FOR UNICAST);
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_UCAST_ROUTING_DONE, NULL);

if (!sm-p_subn-opt.disable_multicast) {
osm_mcast_mgr_process(sm);
@@ -1375,7 +1386,10 @@ repeat_discovery:

if (osm_log_is_active(sm-p_log, OSM_LOG_VERBOSE) ||
sm-p_subn-opt.sa_db_dump)
-   osm_sa_db_file_dump(sm-p_subn-p_osm);
+   if (!osm_sa_db_file_dump(sm-p_subn-p_osm))
+   osm_opensm_report_event(sm-p_subn-p_osm,
+   OSM_EVENT_ID_SA_DB_DUMPED, NULL);
+
}

/*
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c 
b/opensm/osmeventplugin/src/osmeventplugin.c
index b4d9ce9..af68a5c 100644
--- a/opensm/osmeventplugin/src/osmeventplugin.c
+++ b/opensm/osmeventplugin/src/osmeventplugin.c
@@ -176,6 +176,21 @@ static void report(void *_log, osm_epi_event_id_t 
event_id, void *event_data)
case OSM_EVENT_ID_SUBNET_UP:
fprintf(log-log_file, Subnet up reported\n);
break;
+   case OSM_EVENT_ID_HEAVY_SWEEP_DONE:
+   fprintf(log-log_file, Heavy sweep completed\n);
+   break;
+   case OSM_EVENT_ID_UCAST_ROUTING_DONE:
+   fprintf(log-log_file, Unicast routing completed\n);
+   break;
+   case OSM_EVENT_ID_ENTERING_STANDBY:
+   fprintf(log-log_file, Entering stand-by state\n);
+   break;
+   case OSM_EVENT_ID_SM_PORT_DOWN:
+   fprintf(log-log_file, SM port is down\n);
+   break;
+   case OSM_EVENT_ID_SA_DB_DUMPED:
+   fprintf(log-log_file, SA

[Patch v2] opensm/main.c: force stdout to be line-buffered

2010-06-10 Thread Yevgeny Kliteynik
When stdout is assigned to a terminal, it is line-buffered.
But when opensm's stdout is redirected to a file, stdout
becomes block-buffered, which means that '\n' won't cause
the buffer to be flushed.

Forcing stdout to always be line-buffered and to have a
more predictable behavior when used as opensm  some_file.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---

Changes since V1:
  - replacing setlinebuf() with an ANSI C compliant setvbuf()
  - Note: similar patch for ibv_asyncwatch was accepted by Roland:

  http://www.mail-archive.com/linux-rdma@vger.kernel.org/msg04161.html

 opensm/opensm/main.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 0093aa7..6e6c733 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -618,6 +618,9 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}  /* Required at the end of the array */
};

+   /* force stdout to be line-buffered */
+   setvbuf(stdout, NULL, _IOLBF, 0);
+
/* Make sure that the opensm and complib were compiled using
   same modes (debug/free) */
if (osm_is_debug() != cl_is_debug()) {
-- 
1.5.1.4


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resend] opensm/osm_sa_path_record.c: adding wrapper for pr_rcv_get_path_parms()

2010-06-10 Thread Yevgeny Kliteynik
Adding non-static wrapper function for pr_rcv_get_path_parms()
function to enable calling path record calculation function from
outside this file.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il

---
 opensm/opensm/osm_sa_path_record.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_sa_path_record.c 
b/opensm/opensm/osm_sa_path_record.c
index f0d7ca2..2897c7b 100644
--- a/opensm/opensm/osm_sa_path_record.c
+++ b/opensm/opensm/osm_sa_path_record.c
@@ -764,6 +764,18 @@ Exit:
return status;
 }

+ib_api_status_t osm_get_path_params(IN osm_sa_t * sa,
+   IN const osm_port_t * p_src_port,
+   IN const osm_port_t * p_dest_port,
+   IN const uint16_t dlid_ho,
+   OUT osm_path_parms_t * p_parms)
+{
+   ib_path_rec_t pr;
+   memset(pr, 0, sizeof(ib_path_rec_t));
+   return pr_rcv_get_path_parms(sa, pr,
+   p_src_port, p_dest_port, dlid_ho, 0, p_parms);
+}
+
 static void pr_rcv_build_pr(IN osm_sa_t * sa, IN const osm_port_t * p_src_port,
IN const osm_port_t * p_dest_port,
IN const ib_gid_t * p_dgid,
-- 
1.5.1.4


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm: fixing compilation issues in some header files

2010-06-01 Thread Yevgeny Kliteynik

Sasha,

On 24-Mar-10 5:50 PM, Yevgeny Kliteynik wrote:

All the compilation issues refer to implicit casting
from void* to some_struct_t*


This was detected when compiling a code that includes these
headers with g++ compiler. The headers should be able to compile
by g++ (they have 'extern C'). But the problem is not only
with g++ - it is with typing in general. I may be wrong, but I
feel that every new gcc version is more strongly typed.
Moreover, it appears that it would be more strongly typed in the
future, as GCC folks themselves are starting to compile GCC
with G++:

http://gcc.gnu.org/ml/gcc/2010-05/msg00705.html

-- Yevgeny

 

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---
  opensm/include/opensm/osm_pkey.h   |8 +---
  opensm/include/opensm/osm_port.h   |4 ++--
  opensm/include/opensm/osm_subnet.h |2 +-
  3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/opensm/include/opensm/osm_pkey.h b/opensm/include/opensm/osm_pkey.h
index d10479d..53e9657 100644
--- a/opensm/include/opensm/osm_pkey.h
+++ b/opensm/include/opensm/osm_pkey.h
@@ -252,7 +252,8 @@ static inline ib_pkey_table_t *osm_pkey_tbl_block_get(const 
osm_pkey_tbl_t *
  uint16_t block)
  {
return ((block  cl_ptr_vector_get_size(p_pkey_tbl-blocks)) ?
-   cl_ptr_vector_get(p_pkey_tbl-blocks, block) : NULL);
+   (ib_pkey_table_t *)cl_ptr_vector_get(
+   p_pkey_tbl-blocks, block) : NULL);
  };

  /*
@@ -282,8 +283,9 @@ static inline ib_pkey_table_t 
*osm_pkey_tbl_new_block_get(const osm_pkey_tbl_t *
  p_pkey_tbl,
  uint16_t block)
  {
-   return (block  cl_ptr_vector_get_size(p_pkey_tbl-new_blocks)) ?
-   cl_ptr_vector_get(p_pkey_tbl-new_blocks, block) : NULL;
+   return ((block  cl_ptr_vector_get_size(p_pkey_tbl-new_blocks)) ?
+   (ib_pkey_table_t *)cl_ptr_vector_get(
+   p_pkey_tbl-new_blocks, block) : NULL);
  };

  /f* OpenSM: osm_pkey_tbl_set_new_entry
diff --git a/opensm/include/opensm/osm_port.h b/opensm/include/opensm/osm_port.h
index ff0a178..8c68c99 100644
--- a/opensm/include/opensm/osm_port.h
+++ b/opensm/include/opensm/osm_port.h
@@ -549,7 +549,7 @@ static inline void osm_physp_set_slvl_tbl(IN osm_physp_t * 
p_physp,

CL_ASSERT(p_slvl_tbl);
CL_ASSERT(osm_physp_is_valid(p_physp));
-   p_tbl = cl_ptr_vector_get(p_physp-slvl_by_port, in_port_num);
+   p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(p_physp-slvl_by_port, 
in_port_num);
*p_tbl = *p_slvl_tbl;
  }

@@ -590,7 +590,7 @@ static inline ib_slvl_table_t *osm_physp_get_slvl_tbl(IN 
const osm_physp_t *
ib_slvl_table_t *p_tbl;

CL_ASSERT(osm_physp_is_valid(p_physp));
-   p_tbl = cl_ptr_vector_get(p_physp-slvl_by_port, in_port_num);
+   p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(p_physp-slvl_by_port, 
in_port_num);
return p_tbl;
  }

diff --git a/opensm/include/opensm/osm_subnet.h 
b/opensm/include/opensm/osm_subnet.h
index 3970e98..2eef9c7 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -1015,7 +1015,7 @@ struct osm_mgrp *osm_get_mgrp_by_mgid(IN osm_subn_t * 
subn, IN ib_gid_t * mgid);
  */
  static inline struct osm_mgrp_box *osm_get_mbox_by_mlid(osm_subn_t const 
*p_subn, ib_net16_t mlid)
  {
-   return p_subn-mboxes[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+   return (struct osm_mgrp_box *)p_subn-mboxes[cl_ntoh16(mlid) - 
IB_LID_MCAST_START_HO];
  }
  /*
  * PARAMETERS


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm: fixing compilation issues in some header files

2010-06-01 Thread Yevgeny Kliteynik

On 01-Jun-10 10:22 PM, Sasha Khapyorsky wrote:

Hi Yevgeny,

On 14:58 Tue 01 Jun , Yevgeny Kliteynik wrote:


On 24-Mar-10 5:50 PM, Yevgeny Kliteynik wrote:

All the compilation issues refer to implicit casting
from void* to some_struct_t*


This was detected when compiling a code that includes these
headers with g++ compiler. The headers should be able to compile
by g++ (they have 'extern C').


Well let's apply the patch since we have 'extern C'.

But this raises another question. All affected header files are OpenSM
internals and OpenSM is written in C (not C++). So why 'extern C'
should be here at all? Do you know?


But the problem is not only
with g++ - it is with typing in general. I may be wrong, but I
feel that every new gcc version is more strongly typed.


AFAIR (anytype *) to (void *) casting is not needed (doing implicitly)
in C and this is already part of some basic standards.


True, but the problem is not (anytype *) to (void *) casting.
It's the other way around: (void *) to (anytype *) casting.

-- Yevgeny
 

Sasha



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/osm_log.h: osm_log_is_active should return true for syslog

2010-05-17 Thread Yevgeny Kliteynik

On 11-May-10 9:20 PM, Yevgeny Kliteynik wrote:

On 11-May-10 7:21 PM, Sasha Khapyorsky wrote:

On 12:06 Tue 11 May , Yevgeny Kliteynik wrote:


osm_log() always logs messages that came with OSM_LOG_SYS level,
so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be
printed with OSM_LOG macro, instead of using osm_log() directly.

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---
opensm/include/opensm/osm_log.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/include/opensm/osm_log.h
b/opensm/include/opensm/osm_log.h
index b2f105a..a494bc3 100644
--- a/opensm/include/opensm/osm_log.h
+++ b/opensm/include/opensm/osm_log.h
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t
* p_log,
static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
IN osm_log_level_t level)
{
- return ((p_log-level level) != 0);
+ return (((OSM_LOG_SYS | p_log-level) level) != 0);
}


What about to set OSM_LOG_SYS bits in p_log-level at stage of
initialization and to remove all subsequent explicit checks? Like this
(against master):

diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 54c2f36..bd4a200 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN
osm_log_level_t verbosity,
#endif /* __WIN__ */

/* If this is a call to syslog - always print it */
- if (!(verbosity (OSM_LOG_SYS | p_log-level)))
+ if (!(verbosity p_log-level))
return;

va_start(args, p_str);
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t *
p_log, IN boolean_t flush,
IN unsigned long max_size,
IN boolean_t accum_log_file)
{
- p_log-level = log_flags;
+ p_log-level = log_flags | OSM_LOG_SYS;


Sure, that should do the trick too.
Want me to send a patch, or will you do it?


OK, no answer, never mind.
I'll post the patch shortly.

-- Yevgeny
 

-- Yevgeny


p_log-flush = flush;
p_log-count = 0;
p_log-max_size = max_size 20; /* convert size in MB to bytes */


Sasha



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_log.c: add OSM_LOG_SYS to default flags

2010-05-17 Thread Yevgeny Kliteynik
As suggested by Sasha, instead of checking OSM_LOG_SYS in
osm_log_is_active(), just adding OSM_LOG_SYS to default flags.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_log.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 54c2f36..bd4a200 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t 
verbosity,
 #endif /* __WIN__ */

/* If this is a call to syslog - always print it */
-   if (!(verbosity  (OSM_LOG_SYS | p_log-level)))
+   if (!(verbosity  p_log-level))
return;

va_start(args, p_str);
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN 
boolean_t flush,
IN unsigned long max_size,
IN boolean_t accum_log_file)
 {
-   p_log-level = log_flags;
+   p_log-level = log_flags | OSM_LOG_SYS;
p_log-flush = flush;
p_log-count = 0;
p_log-max_size = max_size  20; /* convert size in MB to bytes */
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_log.h: osm_log_is_active should return true for syslog

2010-05-11 Thread Yevgeny Kliteynik

osm_log() always logs messages that came with OSM_LOG_SYS level,
so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be
printed with OSM_LOG macro, instead of using osm_log() directly.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/include/opensm/osm_log.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/include/opensm/osm_log.h b/opensm/include/opensm/osm_log.h
index b2f105a..a494bc3 100644
--- a/opensm/include/opensm/osm_log.h
+++ b/opensm/include/opensm/osm_log.h
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
 static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
  IN osm_log_level_t level)
 {
-   return ((p_log-level  level) != 0);
+   return (((OSM_LOG_SYS | p_log-level)  level) != 0);
 }

 /*
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] opensm/osm_log.h: osm_log_is_active should return true for syslog

2010-05-11 Thread Yevgeny Kliteynik

On 11-May-10 7:21 PM, Sasha Khapyorsky wrote:

On 12:06 Tue 11 May , Yevgeny Kliteynik wrote:


osm_log() always logs messages that came with OSM_LOG_SYS level,
so osm_log_is_active() should concur with this.
As a by-product of this fix, OSM_LOG_SYS messages can now be
printed with OSM_LOG macro, instead of using osm_log() directly.

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---
  opensm/include/opensm/osm_log.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/opensm/include/opensm/osm_log.h b/opensm/include/opensm/osm_log.h
index b2f105a..a494bc3 100644
--- a/opensm/include/opensm/osm_log.h
+++ b/opensm/include/opensm/osm_log.h
@@ -355,7 +355,7 @@ static inline void osm_log_set_level(IN osm_log_t * p_log,
  static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
  IN osm_log_level_t level)
  {
-   return ((p_log-level  level) != 0);
+   return (((OSM_LOG_SYS | p_log-level)  level) != 0);
  }


What about to set OSM_LOG_SYS bits in p_log-level at stage of
initialization and to remove all subsequent explicit checks? Like this
(against master):

diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 54c2f36..bd4a200 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -119,7 +119,7 @@ void osm_log(IN osm_log_t * p_log, IN osm_log_level_t 
verbosity,
  #endif/* __WIN__ */

/* If this is a call to syslog - always print it */
-   if (!(verbosity  (OSM_LOG_SYS | p_log-level)))
+   if (!(verbosity  p_log-level))
return;

va_start(args, p_str);
@@ -306,7 +306,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN 
boolean_t flush,
IN unsigned long max_size,
IN boolean_t accum_log_file)
  {
-   p_log-level = log_flags;
+   p_log-level = log_flags | OSM_LOG_SYS;


Sure, that should do the trick too.
Want me to send a patch, or will you do it?

-- Yevgeny


p_log-flush = flush;
p_log-count = 0;
p_log-max_size = max_size  20; /* convert size in MB to bytes */


Sasha



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: opensm with multiple IB subnets

2010-04-22 Thread Yevgeny Kliteynik

On 4/22/2010 5:23 PM, Justin Clift wrote:

We should really put this on the wiki. :)


Good idea :)

-- Yevgeny
 


On 04/22/2010 12:56 AM, Yevgeny Kliteynik wrote:
snip

OpenSM dumps various files to /var/log and /var/cache/opensm folders.
When you have more than one OpenSM process, they will all dump the
same files, which is probably not a good idea.

To change the output directories, set the OSM_TMP_DIR and
OSM_CACHE_DIR env. variables to some other place.
In addition, you need to make sure that each SM instance
prints its log in a different place. You need to do
something like this:

foreach guid in guid_list
export OSM_TMP_DIR=/tmp/osm_dump_dir${guid}
export OSM_CACHE_DIR=/tmp/osm_dump_dir${guid}
opensm --log_file /tmp/osm_dump_dir${guid}/osm.log -g ${guid} [your
other options]

-- Yevgeny

snip



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: opensm with multiple IB subnets

2010-04-21 Thread Yevgeny Kliteynik

Ken,

On 4/21/2010 3:07 AM, Ken Teague wrote:

On Tue, Apr 20, 2010 at 2:13 PM, Ken Teaguektea...@pobox.com  wrote:

I have a 17-node cluster and each node has a single IB card that has
2x IB ports (ib0 and ib1).


After doing a little more research, I confirmed that my understanding
of the manual page is correct.  To run opensm for each GUID, I
modified my init script to run a for loop based on the information
returned from ibstat -p.


I added this near the beginning of the script where the other
environment variables are located:
snip
OFA_HOME=/usr/local/sbin
IBSTAT_BIN=${OFA_HOME}/ibstat
IBSTAT_ARG=-p
OPENSM_BIN=${OFA_HOME}/opensm
OPENSM_ARG=-B -g
snip


I replaced the single line which started opensm with this for loop:
for i in `${IBSTAT_BIN} ${IBSTAT_ARG}`
do
 ${OPENSM_BIN} ${OPENSM_ARG} ${i}
done
snip

If anyone has a more elegant way to handle this, I'm open to
suggestions.  Many thanks.


OpenSM dumps various files to /var/log and /var/cache/opensm folders.
When you have more than one OpenSM process, they will all dump the
same files, which is probably not a good idea.

To change the output directories, set the OSM_TMP_DIR and
OSM_CACHE_DIR env. variables to some other place.
In addition, you need to make sure that each SM instance
prints its log in a different place. You need to do
something like this:

foreach guid in guid_list
export OSM_TMP_DIR=/tmp/osm_dump_dir${guid}
export OSM_CACHE_DIR=/tmp/osm_dump_dir${guid}
opensm --log_file /tmp/osm_dump_dir${guid}/osm.log -g ${guid} [your 
other options]

-- Yevgeny


Ken
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] opensm: added function that dumps PathRecords

2010-04-15 Thread Yevgeny Kliteynik

Hi Jim,

On 15/Apr/10 01:16, Jim Schutt wrote:

Hi Yevgeny,

On Thu, 2010-04-08 at 07:29 -0600, Yevgeny Kliteynik wrote:

Dumping SL, MTU and Rate for all the
non-switch-2-non-switch paths in the subnet.

PRs that are dumped:

   for every non-switch source port
   for every non-switch target LID in the subnet
   dump PR between source port and target LID

This way number of sources is equal to number of physical
non-switch ports in the subnet, and only number of targets
depends on LMC that is used.

Signed-off-by: Yevgeny Kliteynikklit...@dev.mellanox.co.il
---


[snip]
 

+   p_node = p_src_port-p_node;
+   if (p_node-node_info.node_type == IB_NODE_TYPE_SWITCH)
+   return;


-   return;
+   continue;

Otherwise we stop dumping at the first switch we encounter?


Correct, thanks :)

-- Yevgeny


-- Jim



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_subnet.c: fixing some options to not hot-swappable

2010-04-13 Thread Yevgeny Kliteynik
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Return-Path: klit...@dev.mellanox.co.il
X-OriginalArrivalTime: 13 Apr 2010 10:40:45.0762 (UTC) 
FILETIME=[C6063A20:01CADAF5]

The following options are not hot-swappable:

  transaction_timeout
  transaction_retries
  use_ucast_cache

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_subnet.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index 9132c82..3f5f0f3 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -299,8 +299,8 @@ static const opt_rec_t opt_tbl[] = {
{ max_wire_smps, OPT_OFFSET(max_wire_smps), opts_parse_uint32, NULL, 
1 },
{ console, OPT_OFFSET(console), opts_parse_charp, NULL, 0 },
{ console_port, OPT_OFFSET(console_port), opts_parse_uint16, NULL, 0 
},
-   { transaction_timeout, OPT_OFFSET(transaction_timeout), 
opts_parse_uint32, NULL, 1 },
-   { transaction_retries, OPT_OFFSET(transaction_retries), 
opts_parse_uint32, NULL, 1 },
+   { transaction_timeout, OPT_OFFSET(transaction_timeout), 
opts_parse_uint32, NULL, 0 },
+   { transaction_retries, OPT_OFFSET(transaction_retries), 
opts_parse_uint32, NULL, 0 },
{ max_msg_fifo_timeout, OPT_OFFSET(max_msg_fifo_timeout), 
opts_parse_uint32, NULL, 1 },
{ sm_priority, OPT_OFFSET(sm_priority), opts_parse_uint8, 
opts_setup_sm_priority, 1 },
{ lmc, OPT_OFFSET(lmc), opts_parse_uint8, NULL, 1 },
@@ -328,7 +328,7 @@ static const opt_rec_t opt_tbl[] = {
{ sweep_on_trap, OPT_OFFSET(sweep_on_trap), opts_parse_boolean, NULL, 
1 },
{ routing_engine, OPT_OFFSET(routing_engine_names), opts_parse_charp, 
NULL, 0 },
{ connect_roots, OPT_OFFSET(connect_roots), opts_parse_boolean, NULL, 
1 },
-   { use_ucast_cache, OPT_OFFSET(use_ucast_cache), opts_parse_boolean, 
NULL, 1 },
+   { use_ucast_cache, OPT_OFFSET(use_ucast_cache), opts_parse_boolean, 
NULL, 0 },
{ log_file, OPT_OFFSET(log_file), opts_parse_charp, NULL, 0 },
{ log_max_size, OPT_OFFSET(log_max_size), opts_parse_uint32, 
opts_setup_log_max_size, 1 },
{ log_flags, OPT_OFFSET(log_flags), opts_parse_uint8, 
opts_setup_log_flags, 1 },
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] opensm/osm_sa.c: enhance opensm_dump_to_file() to accept full path file name

2010-04-08 Thread Yevgeny Kliteynik
Hi Sasha,

Small patch that enhances opensm_dump_to_file() function
and allows it to accept full path file names as argument.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/opensm/osm_sa.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c
index 3473e4c..8aab548 100644
--- a/opensm/opensm/osm_sa.c
+++ b/opensm/opensm/osm_sa.c
@@ -510,8 +510,13 @@ opensm_dump_to_file(osm_opensm_t * p_osm, const char 
*file_name,
char path[1024];
FILE *file;

-   snprintf(path, sizeof(path), %s/%s,
-p_osm-subn.opt.dump_files_dir, file_name);
+   if (*file_name == '/')
+   /* file name was provided as an absolute path */
+   snprintf(path, sizeof(path), %s, file_name);
+   else
+   /* file name is relative to dump_files_dir */
+   snprintf(path, sizeof(path), %s/%s,
+p_osm-subn.opt.dump_files_dir, file_name);

file = fopen(path, w);
if (!file) {
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] opensm: added function that dumps PathRecords

2010-04-08 Thread Yevgeny Kliteynik

Dumping SL, MTU and Rate for all the
non-switch-2-non-switch paths in the subnet.

PRs that are dumped:

  for every non-switch source port
  for every non-switch target LID in the subnet
  dump PR between source port and target LID

This way number of sources is equal to number of physical
non-switch ports in the subnet, and only number of targets
depends on LMC that is used.

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/include/opensm/osm_sa.h |   21 +
 opensm/opensm/osm_sa.c |   81 
 opensm/opensm/osm_sa_path_record.c |   12 +
 3 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/opensm/include/opensm/osm_sa.h b/opensm/include/opensm/osm_sa.h
index d516310..40622ff 100644
--- a/opensm/include/opensm/osm_sa.h
+++ b/opensm/include/opensm/osm_sa.h
@@ -462,6 +462,27 @@ int osm_sa_db_file_load(struct osm_opensm *p_osm);
 *
 */

+/f* OpenSM: SA/osm_sa_path_records_file_dump
+* NAME
+*  osm_sa_path_records_file_dump
+*
+* DESCRIPTION
+*  Dumps the SA Path Records to the dump file.
+*
+* SYNOPSIS
+*/
+int osm_sa_path_records_file_dump(struct osm_opensm *p_osm);
+/*
+* PARAMETERS
+*  p_osm
+*  [in] Pointer to an osm_opensm_t object.
+*
+* RETURN VALUES
+*   0 on success
+*  !0 if some error occurred.
+*
+*/
+
 /f* OpenSM: MC Member Record Receiver/osm_mcmr_rcv_find_or_create_new_mgrp
 * NAME
 *  osm_mcmr_rcv_find_or_create_new_mgrp
diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c
index 8aab548..83da258 100644
--- a/opensm/opensm/osm_sa.c
+++ b/opensm/opensm/osm_sa.c
@@ -718,6 +718,87 @@ int osm_sa_db_file_dump(osm_opensm_t * p_osm)
return res;
 }

+typedef struct _path_parms {
+   ib_net16_t pkey;
+   uint8_t mtu;
+   uint8_t rate;
+   uint8_t sl;
+   uint8_t pkt_life;
+   boolean_t reversible;
+} path_parms_t;
+
+extern ib_api_status_t osm_get_path_params(IN osm_sa_t * sa,
+   IN const osm_port_t * p_src_port,
+   IN const osm_port_t * p_dest_port,
+   IN const uint16_t dlid_ho,
+   OUT path_parms_t * p_parms);
+
+static void sa_dump_path_records(osm_opensm_t * p_osm, FILE * file)
+{
+   osm_port_t *p_src_port;
+   osm_port_t *p_dest_port;
+   osm_node_t *p_node;
+   uint16_t dlid_ho;
+   uint32_t vector_size;
+   osm_physp_t *p_physp;
+   path_parms_t path_parms;
+   ib_api_status_t status;
+
+   vector_size = cl_ptr_vector_get_size(p_osm-subn.port_lid_tbl);
+   for (p_src_port = (osm_port_t *) 
cl_qmap_head(p_osm-subn.port_guid_tbl);
+p_src_port != (osm_port_t *) 
cl_qmap_end(p_osm-subn.port_guid_tbl);
+p_src_port = (osm_port_t *) cl_qmap_next(p_src_port-map_item)) {
+
+   p_node = p_src_port-p_node;
+   if (p_node-node_info.node_type == IB_NODE_TYPE_SWITCH)
+   return;
+
+   p_physp = p_src_port-p_physp;
+   CL_ASSERT(p_physp-p_remote_physp);
+
+   fprintf(file, %s 0x%016 PRIx64 , base LID %d, 
+   \%s\, port %d\n# LID  : SL : MTU : RATE\n,
+   ib_get_node_type_str(p_node-node_info.node_type),
+   cl_ntoh64(p_src_port-guid),
+   cl_ntoh16(osm_port_get_base_lid(p_src_port)),
+   p_node-print_desc, p_physp-port_num);
+
+   memset(path_parms, 0, sizeof(path_parms_t));
+
+   for (dlid_ho = 1; dlid_ho  vector_size; dlid_ho++) {
+
+   p_dest_port = (osm_port_t *) cl_ptr_vector_get(
+   p_osm-subn.port_lid_tbl, dlid_ho);
+
+   if (!p_dest_port || !p_dest_port-p_node ||
+   p_dest_port-p_node-node_info.node_type ==
+   IB_NODE_TYPE_SWITCH)
+   continue;
+
+   status = osm_get_path_params(p_osm-sa,
+   p_src_port, p_dest_port, dlid_ho,
+   (void*)path_parms);
+
+   if (!status)
+   fprintf(file, 0x%04X : %-2d : %-3d : %-4d\n,
+   dlid_ho, path_parms.sl,
+   path_parms.mtu, path_parms.rate);
+   else
+   fprintf(file, 0x%04X : UNREACHABLE\n,
+   dlid_ho);
+   }
+   fprintf(file, \n);
+   }
+}
+
+
+int osm_sa_path_records_file_dump(osm_opensm_t * p_osm)
+{
+   return opensm_dump_to_file(p_osm, p_osm-subn.opt.path_rec_file ?
+   p_osm-subn.opt.path_rec_file : opensm-path-records.dump,
+   sa_dump_path_records);
+}
+
 /*
  *  SA DB Loader
  */
diff

[PATCH 2/4] opensm: added 2 options: dump PRs and filename

2010-04-08 Thread Yevgeny Kliteynik

Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il
---
 opensm/include/opensm/osm_subnet.h |   10 ++
 opensm/opensm/osm_subnet.c |   14 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/opensm/include/opensm/osm_subnet.h 
b/opensm/include/opensm/osm_subnet.h
index 3970e98..8d7182b 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -201,6 +201,8 @@ typedef struct osm_subn_opt {
char *guid_routing_order_file;
char *sa_db_file;
boolean_t sa_db_dump;
+   boolean_t path_rec_dump;
+   char *path_rec_file;
boolean_t do_mesh_analysis;
boolean_t exit_on_fatal;
boolean_t honor_guid2lid_file;
@@ -418,6 +420,14 @@ typedef struct osm_subn_opt {
 *  When TRUE causes OpenSM to dump SA DB at the end of every
 *  light sweep regardless the current verbosity level.
 *
+*  path_rec_file
+*  Name of the PathRecords dump file.
+*
+*  path_rec_dump
+*  When TRUE causes OpenSM to dump PathRecords for all the
+*  CA-2-CA paths at the end of every heavy sweep, regardless
+*  of the verbosity level.
+*
 *  exit_on_fatal
 *  If TRUE (default) - SM will exit on fatal subnet initialization
 *  issues.
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index e4126bc..c87ed2a 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -757,6 +757,8 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt)
p_opt-guid_routing_order_file = NULL;
p_opt-sa_db_file = NULL;
p_opt-sa_db_dump = FALSE;
+   p_opt-path_rec_file = NULL;
+   p_opt-path_rec_dump = FALSE;
p_opt-do_mesh_analysis = FALSE;
p_opt-exit_on_fatal = TRUE;
p_opt-enable_quirks = FALSE;
@@ -1464,6 +1466,18 @@ int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * 
p_opts)
p_opts-sa_db_dump ? TRUE : FALSE);

fprintf(out,
+   # PathRecords dump file name\n
+   path_rec_file %s\n\n,
+   p_opts-path_rec_file ? p_opts-path_rec_file : null_str);
+
+   fprintf(out,
+   # If TRUE causes OpenSM to dump PathRecords for all the\n
+   # CA-2-CA paths at the end of every heavy sweep, regardless\n
+   # of the verbosity level\n
+   path_rec_dump %s\n\n,
+   p_opts-path_rec_dump ? TRUE : FALSE);
+
+   fprintf(out,
#\n# HANDOVER - MULTIPLE SMs OPTIONS\n#\n
# SM priority used for deciding who is the master\n
# Range goes from 0 (lowest priority) to 15 (highest).\n
-- 
1.5.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >