[PATCH] Adds SM CHANGE events to mthca and mlx4 drivers

2011-06-01 Thread Michael Heinz
From: Michael Heinz mhe...@qlogic.com

This patch adds events to the handling of SM_LID and SM_SL changes.  When such 
changes occur, a event must be reported and driver stored copies of those 
addresses must be updated so that applications know the new path to the SM/SA.

Signed-off-by: Michael Heinz michael.he...@qlogic.com
---
 drivers/infiniband/hw/mlx4/mad.c|   18 +++---
 drivers/infiniband/hw/mthca/mthca_mad.c |   19 ---
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 57ffa50..e2c65a5 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -119,7 +119,8 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int ignore_mkey, 
int ignore_bkey,
return err;
 }
 
-static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
+static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl,
+u16 *prev_sm_lid, u8 *prev_sm_sl)
 {
struct ib_ah *new_ah;
struct ib_ah_attr ah_attr;
@@ -138,8 +139,12 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 
port_num, u16 lid, u8 sl)
return;
 
spin_lock(dev-sm_lock);
-   if (dev-sm_ah[port_num - 1])
+   if (dev-sm_ah[port_num - 1]) {
+   struct mlx4_ib_ah *ah = to_mah(dev-sm_ah[port_num - 1]);
+   *prev_sm_lid = be16_to_cpu(ah-av.ib.dlid);
+   *prev_sm_sl = be32_to_cpu(ah-av.ib.sl_tclass_flowlabel)  28;
ib_destroy_ah(dev-sm_ah[port_num - 1]);
+   }
dev-sm_ah[port_num - 1] = new_ah;
spin_unlock(dev-sm_lock);
 }
@@ -160,10 +165,13 @@ static void smp_snoop(struct ib_device *ibdev, u8 
port_num, struct ib_mad *mad,
struct ib_port_info *pinfo =
(struct ib_port_info *) ((struct ib_smp *) 
mad)-data;
u16 lid = be16_to_cpu(pinfo-lid);
+   u16 prev_sm_lid = 0;
+   u8 prev_sm_sl = 0;
 
update_sm_ah(to_mdev(ibdev), port_num,
 be16_to_cpu(pinfo-sm_lid),
-pinfo-neighbormtu_mastersmsl  0xf);
+pinfo-neighbormtu_mastersmsl  0xf,
+prev_sm_lid, prev_sm_sl);
 
event.device   = ibdev;
event.element.port_num = port_num;
@@ -171,6 +179,10 @@ static void smp_snoop(struct ib_device *ibdev, u8 
port_num, struct ib_mad *mad,
if (pinfo-clientrereg_resv_subnetto  0x80) {
event.event= IB_EVENT_CLIENT_REREGISTER;
ib_dispatch_event(event);
+   } else if (prev_sm_lid != be16_to_cpu(pinfo-sm_lid)
+   || prev_sm_sl != 
(pinfo-neighbormtu_mastersmsl  0xf)) {
+   event.event= IB_EVENT_SM_CHANGE;
+   ib_dispatch_event(event);
}
 
if (prev_lid != lid) {
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c 
b/drivers/infiniband/hw/mthca/mthca_mad.c
index 03a59534..4566e75 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -72,7 +72,7 @@ out:
 }
 
 static void update_sm_ah(struct mthca_dev *dev,
-u8 port_num, u16 lid, u8 sl)
+u8 port_num, u16 lid, u8 sl, u16 *prev_sm_lid, u8 
*prev_sm_sl)
 {
struct ib_ah *new_ah;
struct ib_ah_attr ah_attr;
@@ -92,8 +92,14 @@ static void update_sm_ah(struct mthca_dev *dev,
return;
 
spin_lock_irqsave(dev-sm_lock, flags);
-   if (dev-sm_ah[port_num - 1])
+   if (dev-sm_ah[port_num - 1]) {
+   struct ib_ah_attr attr;
+   if (! mthca_ah_query(dev-sm_ah[port_num - 1], attr)) {
+   *prev_sm_lid = attr.dlid;
+   *prev_sm_sl = attr.sl;
+   }
ib_destroy_ah(dev-sm_ah[port_num - 1]);
+   }
dev-sm_ah[port_num - 1] = new_ah;
spin_unlock_irqrestore(dev-sm_lock, flags);
 }
@@ -116,11 +122,14 @@ static void smp_snoop(struct ib_device *ibdev,
struct ib_port_info *pinfo =
(struct ib_port_info *) ((struct ib_smp *) 
mad)-data;
u16 lid = be16_to_cpu(pinfo-lid);
+   u16 prev_sm_lid = 0;
+   u8 prev_sm_sl = 0;
 
mthca_update_rate(to_mdev(ibdev), port_num);
update_sm_ah(to_mdev(ibdev), port_num,
 be16_to_cpu(pinfo-sm_lid),
-pinfo-neighbormtu_mastersmsl  0xf);
+

Re: [PATCH] libibmad/[register rpc].c: Fix some bounds checks

2011-06-01 Thread Ira Weiny
On Wed, 1 Jun 2011 06:45:57 -0700
Hal Rosenstock h...@dev.mellanox.co.il wrote:

 
 Signed-off-by: Hal Rosenstock h...@mellanox.com

Thanks, applied,
Ira

 ---
 diff --git a/src/register.c b/src/register.c
 index 0ff8006..1fdb64a 100644
 --- a/src/register.c
 +++ b/src/register.c
 @@ -77,7 +77,7 @@ static int mgmt_class_vers(int mgmt_class)
  
  int mad_class_agent(int mgmt)
  {
 - if (mgmt  1 || mgmt  MAX_CLASS)
 + if (mgmt  1 || mgmt = MAX_CLASS)
   return -1;
   return ibmp-class_agents[mgmt];
  }
 diff --git a/src/rpc.c b/src/rpc.c
 index 88e43e7..d20c321 100644
 --- a/src/rpc.c
 +++ b/src/rpc.c
 @@ -120,7 +120,7 @@ int mad_rpc_portid(struct ibmad_port *srcport)
  
  int mad_rpc_class_agent(struct ibmad_port *port, int class)
  {
 - if (class  1 || class  MAX_CLASS)
 + if (class  1 || class = MAX_CLASS)
   return -1;
   return port-class_agents[class];
  }


-- 
Ira Weiny
Math Programmer/Computer Scientist
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


Re: [PATCH 1v2] opensm: fixed port order configuration in torus routing engine

2011-06-01 Thread Jim Schutt

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


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

Also, while reviewing this I noticed a couple things in the
port-order patch that I should have noticed earlier, but
didn't.  I have a couple of minor fixup patches that go on
top of this one, to send along in a minute.

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


[PATCH 1/2] opensm: fail if configured torus port order references a port not available in all switches

2011-06-01 Thread Jim Schutt

Signed-off-by: Jim Schutt jasc...@sandia.gov
---
 opensm/osm_torus.c |   24 
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c
index 29c1bb4..47654ce 100644
--- a/opensm/osm_torus.c
+++ b/opensm/osm_torus.c
@@ -856,9 +856,6 @@ bool parse_port(unsigned *pnum, const char *parse_sep)
if (!val)
return false;
*pnum = strtoul(val, nextchar, 0);
-   if (*pnum  IB_NODE_NUM_PORTS_MAX) {
-   *pnum = 0;
-   }
return true;
 }
 
@@ -7018,7 +7015,8 @@ static
 bool verify_setup(struct torus *t, struct fabric *f)
 {
struct coord_dirs *o;
-   unsigned n = 0;
+   struct f_switch *sw;
+   unsigned p, s, n = 0;
bool success = false;
bool all_sw_present, need_seed = true;
 
@@ -7044,6 +7042,24 @@ bool verify_setup(struct torus *t, struct fabric *f)
with two QoS levels (have %d need 8)\n,
(int)t-osm-subn.min_data_vls);
/*
+* Be sure all the switches in the torus support the port
+* ordering that might have been configured.
+*/
+   for (s = 0; s  f-switch_cnt; s++) {
+   sw = f-sw[s];
+   for (p = 0; p  sw-port_cnt; p++) {
+   if (t-port_order[p] = sw-port_cnt) {
+   OSM_LOG(t-osm-log, OSM_LOG_ERROR,
+   Error: port_order configured using 
+   port %u, but only %u ports in 
+   switch w/ GUID 0x%04PRIx64\n,
+   t-port_order[p],  sw-port_cnt - 1,
+   cl_ntoh64(sw-n_id));
+   goto out;
+   }
+   }
+   }
+   /*
 * Unfortunately, there is a problem with non-unique topology for any
 * torus dimension which has radix four.  This problem requires extra
 * input, in the form of specifying both the positive and negative
-- 
1.6.2.2


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