[PATCH] opensm/osm_ucast_mgr.c: Fix some issues found by Coverity

2011-05-31 Thread Hal Rosenstock

Signed-off-by: Hal Rosenstock h...@mellanox.com
---
diff --git a/opensm/osm_ucast_mgr.c b/opensm/osm_ucast_mgr.c
index 211d6e0..600bb10 100644
--- a/opensm/osm_ucast_mgr.c
+++ b/opensm/osm_ucast_mgr.c
@@ -529,6 +529,7 @@ static int set_dimn_ports(void *ctx, uint64_t guid, char *p)
if (!ports) {
OSM_LOG(p_subn-p_osm-log, OSM_LOG_ERROR,
ERR 3A08: cannot allocate memory for ports\n);
+   free(dimn_ports);
return -1;
}
memset(ports, 0, words*sizeof(*ports));
@@ -794,6 +795,8 @@ static void add_sw_endports_to_order_list(osm_switch_t * sw,
port = osm_get_port_by_guid(m-p_subn,
p-p_remote_physp-
port_guid);
+   if (!port)
+   continue;
cl_qlist_insert_tail(m-port_order_list,
 port-list_item);
port-flag = 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] opensm: Added cleanup of SA cache after handover

2011-05-31 Thread Alex Netes
Previously, when SM becomes STANDBY after being MASTER it preserved
the SA cache. When the SM will become MASTER again, its' SA cache
might be inconsitent. The solution is to clean the SA cache each
time the SM becomes STANDBY after a handover.

Signed-off-by: Hal Rosenstock h...@dev.mellanox.co.il
Signed-off-by: Alex Netes ale...@mellanox.com
---
 include/opensm/osm_subnet.h |9 -
 opensm/osm_sm_state_mgr.c   |1 +
 opensm/osm_state_mgr.c  |   82 +++
 3 files changed, 91 insertions(+), 1 deletions(-)

diff --git a/include/opensm/osm_subnet.h b/include/opensm/osm_subnet.h
index 83ef77e..41f2546 100644
--- a/include/opensm/osm_subnet.h
+++ b/include/opensm/osm_subnet.h
@@ -552,6 +552,7 @@ typedef struct osm_subn {
boolean_t first_time_master_sweep;
boolean_t coming_out_of_standby;
boolean_t sweeping_enabled;
+   boolean_t clean_sa;
unsigned need_update;
cl_fmap_t mgrp_mgid_tbl;
void *mboxes[IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO + 1];
@@ -669,13 +670,19 @@ typedef struct osm_subn {
 *  TRUE on the first sweep after the SM was in standby.
 *  Used for nulling any cache of LID and Routing.
 *  The flag is set true if the SM state was standby and now
-*  changed to MASTER it is reset at the end of the sweep.
+*  changed to MASTER. It is reset at the end of the sweep.
 *
 *  sweeping_enabled
 *  FALSE - sweeping is administratively disabled, all
 *  sweeping is inhibited, TRUE - sweeping is done
 *  normally
 *
+*  clean_sa
+*  TRUE on the first sweep after SM is in standby after handover.
+*  Used for nulling the SA cache. the flag is set true if the SM
+*  state was master and now changed to standby. The flag is reset
+*  at the end of the SA cleanup.
+*
 *  need_update
 *  This flag should be on during first non-master heavy
 *  (including pre-master discovery stage)
diff --git a/opensm/osm_sm_state_mgr.c b/opensm/osm_sm_state_mgr.c
index a568267..99ab4d2 100644
--- a/opensm/osm_sm_state_mgr.c
+++ b/opensm/osm_sm_state_mgr.c
@@ -414,6 +414,7 @@ ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm,
 */
sm-p_subn-sm_state = IB_SMINFO_STATE_STANDBY;
osm_report_sm_state(sm);
+   sm-p_subn-clean_sa = TRUE;
sm_state_mgr_start_polling(sm);
break;
case OSM_SM_SIGNAL_WAIT_FOR_HANDOVER:
diff --git a/opensm/osm_state_mgr.c b/opensm/osm_state_mgr.c
index dd308f2..0061238 100644
--- a/opensm/osm_state_mgr.c
+++ b/opensm/osm_state_mgr.c
@@ -63,6 +63,7 @@
 #include opensm/osm_port.h
 #include vendor/osm_vendor_api.h
 #include opensm/osm_inform.h
+#include opensm/osm_service.h
 #include opensm/osm_opensm.h
 
 extern void osm_drop_mgr_process(IN osm_sm_t * sm);
@@ -275,6 +276,78 @@ static ib_api_status_t state_mgr_clean_known_lids(IN 
osm_sm_t * sm)
 }
 
 /**
+ Clear SA cache
+**/
+static ib_api_status_t state_mgr_sa_clean(IN osm_sm_t * sm)
+{
+   ib_api_status_t status = IB_SUCCESS;
+   osm_assigned_guids_t *p_assigned_guids;
+   osm_alias_guid_t *p_alias_guid;
+   cl_qmap_t *p_port_guid_tbl;
+   osm_mcm_port_t *mcm_port;
+   cl_map_item_t *item;
+   osm_subn_t * p_subn;
+   osm_port_t *p_port;
+   osm_switch_t *p_sw;
+   osm_infr_t *p_infr;
+   osm_svcr_t *p_svcr;
+
+   OSM_LOG_ENTER(sm-p_log);
+
+   /* we need a lock here! */
+   CL_PLOCK_ACQUIRE(sm-p_lock);
+
+   p_subn = sm-p_subn;
+   /* Clean MGID table */
+   cl_fmap_remove_all(p_subn-mgrp_mgid_tbl);
+
+   /* Clean Multicast member list on each port */
+   p_port_guid_tbl = p_subn-port_guid_tbl;
+   for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
+p_port = (osm_port_t *) cl_qmap_next(p_port-map_item)) {
+   while (!cl_is_qlist_empty(p_port-mcm_list)) {
+   mcm_port = cl_item_obj(cl_qlist_head(p_port-mcm_list),
+  mcm_port, list_item);
+   osm_mgrp_delete_port(p_subn, sm-p_log, mcm_port-mgrp,
+p_port);
+   }
+   }
+
+   /* Clean InformInfo records */
+   p_infr = (osm_infr_t *) cl_qlist_remove_head(p_subn-sa_infr_list);
+   while (p_infr !=
+  (osm_infr_t *) cl_qlist_end(p_subn-sa_infr_list)) {
+   osm_infr_delete(p_infr);
+   p_infr = (osm_infr_t *) 
cl_qlist_remove_head(p_subn-sa_infr_list);
+   }
+
+   /* Clean 

Re: opensm: fixed port order configuration in torus routing engine

2011-05-31 Thread Jim Schutt

Hi Alex,

Alex Netes wrote:

Commit 1c2a298b295eba7e24205519abc24e47106d15df broke port order
configuration for torus routing engine. order was incorrectly initiated,
causing setting LFTs to fail.

Signed-off-by: Alex Netes ale...@mellanox.com
---
 opensm/osm_torus.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c
index cd3d490..75724d2 100644
--- a/opensm/osm_torus.c
+++ b/opensm/osm_torus.c
@@ -8484,7 +8484,7 @@ bool torus_lft(struct torus *t, struct t_switch *sw)
struct port_grp *pgrp;
struct t_switch *dsw;
osm_switch_t *osm_sw;
-   unsigned order[IB_NODE_NUM_PORTS_MAX+1];
+   unsigned char order[IB_NODE_NUM_PORTS_MAX+1];
 
 	if (!(sw-osm_switch  sw-osm_switch-priv == sw)) {

OSM_LOG(t-osm-log, OSM_LOG_ERROR,
@@ -8506,7 +8506,7 @@ bool torus_lft(struct torus *t, struct t_switch *sw)
 
 		for (p = 0; p  ARRAY_SIZE(order); p++) {
 
-			unsigned px = order[t-port_order[p]];

+   unsigned char px = order[t-port_order[p]];
 
 			if (px == IB_INVALID_PORT_NUM)

continue;


I guess the memset(order, IB_INVALID_PORT_NUM, sizeof(order))
a few lines up does the wrong thing without your fix,
since we compare here with IB_INVALID_PORT_NUM?

Nice catch - I'm sorry I missed it.

FWIW, ib_types.h uses uint8_t for ports - maybe should do
that here as well rather than unsigned char?

Acked-by: Jim Schutt jasc...@sandia.gov

-- 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


RE: [PATCH] infiniband, ipath: convert old cpumask api into new one

2011-05-31 Thread Mike Marciniszyn
 Subject: [PATCH] infiniband, ipath: convert old cpumask api into new
 one

 Adapt new api. we plan to remove old one later. Almost change are
 trivial. but there is one real fix. following code is unsafe.

   int ncpus = num_online_cpus()
   for (i = 0; i  ncpus; i++) {
   ..
   }


Thanks for the patch!

Acked-by: Mike Marciniszyn mike.marcinis...@qlogic.com

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


RE: [PATCH] infiniband, qib: convert old cpumask api into new one.

2011-05-31 Thread Mike Marciniszyn

 Adapt new APIs. we plan to remove old one later and plan to
 change current-cpus_allowed implementation.

 No functional change.

Thanks for the patch!

Acked-by: Mike Marciniszyn mike.marcinis...@qlogic.com

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