[openib-general] [PATCH] ib_smi: Support LID routed Gets and Sets in SMA

Hal Rosenstock halr at voltaire.com
Thu Oct 7 14:54:37 PDT 2004


ib_smi: Support LID routed Gets and Sets in SMA

Index: ib_smi.c
===================================================================
--- ib_smi.c	(revision 955)
+++ ib_smi.c	(working copy)
@@ -125,7 +125,7 @@
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
 		return smi_handle_dr_smp_send(mad_agent, smp);
 	default:
-		return 0; /* write me... */
+		return 1;
 	}
 }
 
@@ -137,9 +137,10 @@
 {
 	/* C14-9:3 -- We're at the end of the DR segment of path */
 	/* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM. */
-	return (mad_agent->device->process_mad &&
+	return ((smp->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
+		(mad_agent->device->process_mad &&
 		!ib_get_smp_direction(smp) &&
-		(smp->hop_ptr == smp->hop_cnt + 1));
+		(smp->hop_ptr == smp->hop_cnt + 1)));
 }
 
 /*
@@ -230,7 +231,7 @@
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
 		return smi_handle_dr_smp_recv(mad_agent, smp);
 	default:
-		return 0; /* write me... */
+		return 1;
 	}
 }
 
@@ -282,7 +283,7 @@
 	case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
 		return smi_check_forward_dr_smp(mad_agent, smp);
 	default:
-		return 0; /* write me... */
+		return 1;
 	}
 }
 
@@ -312,7 +313,8 @@
 	/* Find matching MAD agent */
 	spin_lock_irqsave(&ib_smi_port_list_lock, flags);
 	list_for_each_entry(entry, &ib_smi_port_list, port_list) {
-		if (entry->mad_agent == mad_agent) {
+		if ((entry->mad_agent == mad_agent) ||
+		    (entry->mad_agent2 == mad_agent)) { 
 			port_priv = entry;
 			break;
 		}
@@ -403,8 +405,11 @@
 		ret = smi_process_local(mad_agent, (struct ib_mad *)smp,
 					smp_response, slid);
 		if (ret & IB_MAD_RESULT_SUCCESS) {
-			/* Workaround !!! */
-			((struct ib_smp *)smp_response)->hop_ptr--;
+			if (smp_response->mad_hdr.mgmt_class ==
+			      IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+				/* Workaround !!! */
+				((struct ib_smp *)smp_response)->hop_ptr--;
+			}
 			smp_send(mad_agent, smp_response, mad_recv_wc);
 		} else
 			kfree(smp_response);
@@ -445,7 +450,8 @@
 	/* Find matching MAD agent */
 	spin_lock_irqsave(&ib_smi_port_list_lock, flags);
 	list_for_each_entry(entry, &ib_smi_port_list, port_list) {
-		if (entry->mad_agent == mad_agent) {
+		if ((entry->mad_agent == mad_agent) ||
+		    (entry->mad_agent2 == mad_agent)) {
 			port_priv = entry;
 			break;
 		}
@@ -539,6 +545,7 @@
 	spin_lock_init(&port_priv->send_list_lock);
 	INIT_LIST_HEAD(&port_priv->send_posted_smp_list);
 
+	/* Obtain MAD agent for directed route SM class */
 	reg_req.mgmt_class = IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE;
 	reg_req.mgmt_class_version = 1;
 
@@ -556,17 +563,32 @@
 						    &smi_recv_handler,
 						     NULL);
 	if (IS_ERR(port_priv->mad_agent)) {
-		port_priv->mad_agent = NULL;
 		ret = PTR_ERR(port_priv->mad_agent);
 		kfree(port_priv);
 		return ret;
 	}
 
+	/* Obtain MAD agent for LID routed SM class */
+	reg_req.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	port_priv->mad_agent2 = ib_register_mad_agent(device, port_num,
+						      IB_QPT_SMI,
+						     &reg_req, 0,
+						     &smi_send_handler,
+						     &smi_recv_handler,
+						      NULL);
+	if (IS_ERR(port_priv->mad_agent2)) {
+		ret = PTR_ERR(port_priv->mad_agent2);
+		ib_unregister_mad_agent(port_priv->mad_agent);
+		kfree(port_priv);
+		return ret;
+	}
+
 	port_priv->mr = ib_reg_phys_mr(port_priv->mad_agent->qp->pd,
 				      &buf_list, 1,
 				       IB_ACCESS_LOCAL_WRITE, &iova);
 	if (IS_ERR(port_priv->mr)) {
 		printk(KERN_ERR "Couldn't register MR\n");
+		ib_unregister_mad_agent(port_priv->mad_agent2);
 		ib_unregister_mad_agent(port_priv->mad_agent);	
 		ret = PTR_ERR(port_priv->mr);
 		kfree(port_priv);
@@ -604,6 +626,7 @@
 	spin_unlock_irqrestore(&ib_smi_port_list_lock, flags);
 
 	ib_dereg_mr(port_priv->mr);
+	ib_unregister_mad_agent(port_priv->mad_agent2);
 	ib_unregister_mad_agent(port_priv->mad_agent);
         kfree(port_priv);
 
Index: ib_smi_priv.h
===================================================================
--- ib_smi_priv.h	(revision 947)
+++ ib_smi_priv.h	(working copy)
@@ -39,7 +39,8 @@
 	struct list_head send_posted_smp_list;
 	spinlock_t send_list_lock;
 	int port_num;
-	struct ib_mad_agent *mad_agent;
+	struct ib_mad_agent *mad_agent; /* DR */
+	struct ib_mad_agent *mad_agent2; /* LR */
 	struct ib_mr *mr;
 	u64 wr_id;
 };
Index: TODO
===================================================================
--- TODO	(revision 947)
+++ TODO	(working copy)
@@ -5,8 +5,7 @@
 Short Term
 Send timeout support
 Treat send overruns as timeouts for now (once timeout support
implemented) ?
-LR SMP 
-GMP with GRH testing
+Test GMPs with GRH 
 
 Revisit
 ib_mad.h structure packing
@@ -18,7 +17,7 @@
 RMPP support
 Redirection support
 PMA support
-SMI support for switches
+Test SMI support for switches
 sysfs support for MAD layer (statistics, debug support, etc.)
 Replace locking with RCU
 






More information about the general mailing list