[openib-general] [PATCH] ib_smi: Make port number parameter to SMI DR routines

Hal Rosenstock halr at voltaire.com
Thu Oct 14 06:16:26 PDT 2004


ib_smi: Make port number parameter to SMI DR routines
(in preparation for switch support where port number is not the port of
the receiving MAD agent)

Index: ib_smi.c
===================================================================
--- ib_smi.c	(revision 990)
+++ ib_smi.c	(working copy)
@@ -42,7 +42,8 @@
  * discarded.
  */
 static int smi_handle_dr_smp_send(struct ib_mad_agent *mad_agent,
-				  struct ib_smp *smp)
+				  struct ib_smp *smp,
+				  int port_num)
 {
 	u8 hop_ptr, hop_cnt;
 
@@ -55,7 +56,7 @@
 		if (hop_cnt && hop_ptr == 0) {
 			smp->hop_ptr++;
 			return (smp->initial_path[smp->hop_ptr] == 
-				mad_agent->port_num);
+				port_num);
 		}
 
 		/* C14-9:2 */
@@ -66,7 +67,7 @@
 			/* smp->return_path set when received */
 			smp->hop_ptr++;
 			return (smp->initial_path[smp->hop_ptr] == 
-				mad_agent->port_num);
+				port_num);
 		}
 
 		/* C14-9:3 -- We're at the end of the DR segment of path */
@@ -86,7 +87,7 @@
 		if (hop_cnt && hop_ptr == hop_cnt + 1) {
 			smp->hop_ptr--;
 			return (smp->return_path[smp->hop_ptr] == 
-				mad_agent->port_num);
+				port_num);
 		}
 
 		/* C14-13:2 */
@@ -96,7 +97,7 @@
 
 			smp->hop_ptr--;
 			return (smp->return_path[smp->hop_ptr] == 
-				mad_agent->port_num);
+				port_num);
 		}
 
 		/* C14-13:3 -- at the end of the DR segment of path */
@@ -118,12 +119,13 @@
  * 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)
+			       struct ib_smp *smp,
+			       int port_num)
 {
 	switch (smp->mgmt_class)
 	{
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
-		return smi_handle_dr_smp_send(mad_agent, smp);
+		return smi_handle_dr_smp_send(mad_agent, smp, port_num);
 	default: 	/* LR SM or PerfMgmt classes */
 		return 1;
 	}
@@ -149,6 +151,7 @@
  */
 static int smi_handle_dr_smp_recv(struct ib_mad_agent *mad_agent,
 				  struct ib_smp *smp,
+				  int port_num,
 				  int phys_port_cnt)
 {
 	u8 hop_ptr, hop_cnt;
@@ -175,7 +178,7 @@
 		/* C14-9:3 -- We're at the end of the DR segment of path */
 		if (hop_ptr == hop_cnt) {
 			if (hop_cnt)
-				smp->return_path[hop_ptr] = mad_agent->port_num;
+				smp->return_path[hop_ptr] = port_num;
 			/* smp->hop_ptr updated when sending */
 
 			return (mad_agent->device->node_type == IB_NODE_SWITCH ||
@@ -192,7 +195,7 @@
 		if (hop_cnt && hop_ptr == hop_cnt + 1) {
 			smp->hop_ptr--;
 			return (smp->return_path[smp->hop_ptr] ==
-				mad_agent->port_num);
+				port_num);
 		}
 
 		/* C14-13:2 */
@@ -227,12 +230,14 @@
  */
 static int smi_handle_smp_recv(struct ib_mad_agent *mad_agent,
 			       struct ib_smp *smp,
+			       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, phys_port_cnt);
+		return smi_handle_dr_smp_recv(mad_agent, smp,
+					      port_num, phys_port_cnt);
 	default:	/* LR SM or PerfMgmt classes */
 		return 1;
 	}
@@ -402,7 +407,7 @@
 	struct ib_mad *smp_response;
 	int ret;
 
-	if (!smi_handle_smp_send(mad_agent, smp)) {
+	if (!smi_handle_smp_send(mad_agent, smp, mad_agent->port_num)) {
 		/* SMI failed send */
 		return 0;
 	}
@@ -417,6 +422,7 @@
 		if (ret & IB_MAD_RESULT_SUCCESS) {
 			if (!smi_handle_smp_recv(mad_agent,
 						 (struct ib_smp *)smp_response,
+						 mad_agent->port_num,
 						 phys_port_cnt)) {
 				/* SMI failed receive */
 				kfree(smp_response);
@@ -437,7 +443,8 @@
 		 struct ib_mad_recv_wc *mad_recv_wc,
 		 int phys_port_cnt)
 {
-	if (!smi_handle_smp_recv(mad_agent, smp, phys_port_cnt)) {
+	if (!smi_handle_smp_recv(mad_agent, smp,
+				 mad_agent->port_num, phys_port_cnt)) {
 		/* SMI failed receive */
 		return 0;
 	}






More information about the general mailing list