[openib-general] [PATCH] ib_smi: More minor change to DR SMI code for port number

Hal Rosenstock halr at voltaire.com
Mon Oct 18 10:52:57 PDT 2004


ib_smi: More minor changes to DR SMI code for port number

Index: ib_smi.c
===================================================================
--- ib_smi.c	(revision 1018)
+++ ib_smi.c	(working copy)
@@ -41,8 +41,8 @@
  * Fixup a directed route SMP for sending.  Return 0 if the SMP should
be
  * discarded.
  */
-static int smi_handle_dr_smp_send(struct ib_mad_agent *mad_agent,
-				  struct ib_smp *smp,
+static int smi_handle_dr_smp_send(struct ib_smp *smp,
+				  u8 node_type,
 				  int port_num)
 {
 	u8 hop_ptr, hop_cnt;
@@ -61,7 +61,7 @@
 
 		/* C14-9:2 */
 		if (hop_ptr && hop_ptr < hop_cnt) {
-			if (mad_agent->device->node_type != IB_NODE_SWITCH)
+			if (node_type != IB_NODE_SWITCH)
 				return 0;
 			
 			/* smp->return_path set when received */
@@ -74,7 +74,7 @@
 		if (hop_ptr == hop_cnt) {
 			/* smp->return_path set when received */
 			smp->hop_ptr++;
-			return (mad_agent->device->node_type == IB_NODE_SWITCH ||
+			return (node_type == IB_NODE_SWITCH ||
 				smp->dr_dlid == IB_LID_PERMISSIVE);
 		}
 
@@ -92,7 +92,7 @@
 
 		/* C14-13:2 */
 		if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
-			if (mad_agent->device->node_type != IB_NODE_SWITCH)
+			if (node_type != IB_NODE_SWITCH)
 				return 0;
 
 			smp->hop_ptr--;
@@ -104,7 +104,7 @@
 		if (hop_ptr == 1) {
 			smp->hop_ptr--;
 			/* C14-13:3 -- SMPs destined for SM shouldn't be here */
-			return (mad_agent->device->node_type == IB_NODE_SWITCH ||
+			return (node_type == IB_NODE_SWITCH ||
 				smp->dr_slid == IB_LID_PERMISSIVE);
 		}
 
@@ -118,14 +118,14 @@
  * Sender side handling of outgoing SMPs.  Fixup the SMP as required by
  * the spec.  Return 0 if the SMP should be dropped.
  */
-static int smi_handle_smp_send(struct ib_mad_agent *mad_agent,
-			       struct ib_smp *smp,
+static int smi_handle_smp_send(struct ib_smp *smp,
+			       u8 node_type,
 			       int port_num)
 {
 	switch (smp->mgmt_class)
 	{
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
-		return smi_handle_dr_smp_send(mad_agent, smp, port_num);
+		return smi_handle_dr_smp_send(smp, node_type, port_num);
 	default: 	/* LR SM class */
 		return 1;
 	}
@@ -149,8 +149,8 @@
  * Adjust information for a received SMP.  Return 0 if the SMP should
be
  * dropped.
  */
-static int smi_handle_dr_smp_recv(struct ib_mad_agent *mad_agent,
-				  struct ib_smp *smp,
+static int smi_handle_dr_smp_recv(struct ib_smp *smp,
+				  u8 node_type,
 				  int port_num,
 				  int phys_port_cnt)
 {
@@ -167,10 +167,10 @@
 
 		/* C14-9:2 -- intermediate hop */
 		if (hop_ptr && hop_ptr < hop_cnt) {
-			if (mad_agent->device->node_type != IB_NODE_SWITCH)
+			if (node_type != IB_NODE_SWITCH)
 				return 0;
 
-			smp->return_path[hop_ptr] = mad_agent->port_num;
+			smp->return_path[hop_ptr] = port_num;
 			/* smp->hop_ptr updated when sending */
 			return (smp->initial_path[hop_ptr+1] <= phys_port_cnt);
 		}
@@ -181,7 +181,7 @@
 				smp->return_path[hop_ptr] = port_num;
 			/* smp->hop_ptr updated when sending */
 
-			return (mad_agent->device->node_type == IB_NODE_SWITCH ||
+			return (node_type == IB_NODE_SWITCH ||
 				smp->dr_dlid == IB_LID_PERMISSIVE);
 		}
 		
@@ -200,7 +200,7 @@
 
 		/* C14-13:2 */
 		if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
-			if (mad_agent->device->node_type != IB_NODE_SWITCH)
+			if (node_type != IB_NODE_SWITCH)
 				return 0;
 
 			/* smp->hop_ptr updated when sending */
@@ -215,7 +215,7 @@
 				return 1;
 			}
 			/* smp->hop_ptr updated when sending */
-			return (mad_agent->device->node_type == IB_NODE_SWITCH);
+			return (node_type == IB_NODE_SWITCH);
 		}
 
 		/* C14-13:4 -- hop_ptr = 0 -> give to SM. */
@@ -228,15 +228,15 @@
  * Receive side handling SMPs.  Save receive information as required by
  * the spec.  Return 0 if the SMP should be dropped.
  */
-static int smi_handle_smp_recv(struct ib_mad_agent *mad_agent,
-			       struct ib_smp *smp,
+static int smi_handle_smp_recv(struct ib_smp *smp,
+			       u8 node_type,
 			       int port_num,
 			       int phys_port_cnt)
 {
 	switch (smp->mgmt_class)
 	{
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
-		return smi_handle_dr_smp_recv(mad_agent, smp,
+		return smi_handle_dr_smp_recv(smp, node_type,
 					      port_num, phys_port_cnt);
 	default:	/* LR SM class */
 		return 1;
@@ -247,8 +247,7 @@
  * Return 1 if the received DR SMP should be forwarded to the send
queue.
  * Return 0 if the SMP should be completed up the stack.
  */
-static int smi_check_forward_dr_smp(struct ib_mad_agent *mad_agent,
-				    struct ib_smp *smp)
+static int smi_check_forward_dr_smp(struct ib_smp *smp)
 {
 	u8 hop_ptr, hop_cnt;
 
@@ -283,13 +282,12 @@
  * Return 1 if the received SMP should be forwarded to the send queue.
  * Return 0 if the SMP should be completed up the stack.
  */
-static int smi_check_forward_smp(struct ib_mad_agent *mad_agent,
-				 struct ib_smp *smp)
+static int smi_check_forward_smp(struct ib_smp *smp)
 {
 	switch (smp->mgmt_class)
 	{
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
-		return smi_check_forward_dr_smp(mad_agent, smp);
+		return smi_check_forward_dr_smp(smp);
 	default:	/* LR SM class */
 		return 1;
 	}
@@ -423,7 +421,8 @@
 	struct ib_mad *smp_response;
 	int ret;
 
-	if (!smi_handle_smp_send(mad_agent, smp, mad_agent->port_num)) {
+	if (!smi_handle_smp_send(smp, mad_agent->device->node_type,
+				 mad_agent->port_num)) {
 		/* SMI failed send */
 		return 0;
 	}
@@ -436,8 +435,8 @@
 		ret = mad_process_local(mad_agent, (struct ib_mad *)smp,
 					smp_response, slid);
 		if (ret & IB_MAD_RESULT_SUCCESS) {
-			if (!smi_handle_smp_recv(mad_agent,
-						 (struct ib_smp *)smp_response,
+			if (!smi_handle_smp_recv((struct ib_smp *)smp_response,
+						 mad_agent->device->node_type,
 						 mad_agent->port_num,
 						 phys_port_cnt)) {
 				/* SMI failed receive */
@@ -485,14 +484,16 @@
 	/* SM Directed Route or LID Routed class */
 	if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ||
 	    mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) {
-		if (!smi_handle_smp_recv(mad_agent, (struct ib_smp *)mad,
+		if (!smi_handle_smp_recv((struct ib_smp *)mad,
+					 mad_agent->device->node_type,
 					 mad_agent->port_num, phys_port_cnt)) {
 			/* SMI failed receive */
 			return 0;
 		}
 
-		if (smi_check_forward_smp(mad_agent, (struct ib_smp *)mad)) {
-			smi_send_smp(mad_agent, (struct ib_smp *)mad,
+		if (smi_check_forward_smp((struct ib_smp *)mad)) {
+			smi_send_smp(mad_agent,
+				    (struct ib_smp *)mad,
 				     mad_recv_wc,
 				     mad_recv_wc->wc->slid,
 				     phys_port_cnt);






More information about the general mailing list