[openib-general] [PATCH] ib_smi: Add GRH support for PMA

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


ib_smi: Add GRH support for PMA

Index: ib_smi.c
===================================================================
--- ib_smi.c	(revision 1017)
+++ ib_smi.c	(working copy)
@@ -307,6 +307,7 @@
 
 void agent_mad_send(struct ib_mad_agent *mad_agent,
 		    struct ib_mad *mad,
+		    struct ib_grh *grh,
 		    struct ib_mad_recv_wc *mad_recv_wc)
 {
 	struct ib_agent_port_private *entry, *port_priv = NULL;
@@ -359,9 +360,24 @@
 	ah_attr.dlid = mad_recv_wc->wc->slid;
 	ah_attr.port_num = mad_agent->port_num;
 	ah_attr.src_path_bits = mad_recv_wc->wc->dlid_path_bits;
-	ah_attr.ah_flags = 0; /* No GRH */
 	ah_attr.sl = mad_recv_wc->wc->sl;
 	ah_attr.static_rate = 0;
+	if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
+		if (mad_recv_wc->wc->wc_flags & IB_WC_GRH) {
+			ah_attr.ah_flags = IB_AH_GRH;
+			ah_attr.grh.sgid_index = 0; /* Should sgid be looked up
+? */
+			ah_attr.grh.hop_limit = grh->hop_limit;
+			ah_attr.grh.flow_label = be32_to_cpup(&grh->version_tclass_flow) &
0xfffff; 
+			ah_attr.grh.traffic_class = (be32_to_cpup(&grh->version_tclass_flow)
>> 20) & 0xff;
+			memcpy(ah_attr.grh.dgid.raw, grh->sgid.raw, sizeof(struct ib_grh));
+		} else {
+			ah_attr.ah_flags = 0; /* No GRH */
+		}
+	} else {
+		/* Directed route or LID routed SM class */
+		ah_attr.ah_flags = 0; /* No GRH */
+	}
 
 	ah = ib_create_ah(mad_agent->qp->pd, &ah_attr);
 	if (IS_ERR(ah)) {
@@ -428,7 +444,8 @@
 				kfree(smp_response);
 				return 0;
 			}
-			agent_mad_send(mad_agent, smp_response, mad_recv_wc);
+			agent_mad_send(mad_agent, smp_response,
+				       NULL, mad_recv_wc);
 		} else
 			kfree(smp_response);
 		return 1;
@@ -438,12 +455,13 @@
 	return 1;
 }
 
-int mad_response(struct ib_mad_agent *mad_agent,
-		 struct ib_mad *mad,
-		 struct ib_mad_recv_wc *mad_recv_wc,
-		 u16 slid)
+int agent_mad_response(struct ib_mad_agent *mad_agent,
+		       struct ib_mad *mad,
+		       struct ib_mad_recv_wc *mad_recv_wc,
+		       u16 slid)
 {
 	struct ib_mad *response;
+	struct ib_grh *grh;
 	int ret;
 
 	response = kmalloc(sizeof(struct ib_mad), GFP_KERNEL);
@@ -452,7 +470,8 @@
 
 	ret = mad_process_local(mad_agent, mad, response, slid);
 	if (ret & IB_MAD_RESULT_SUCCESS) {
-		agent_mad_send(mad_agent, response, mad_recv_wc);
+		grh = (void *)mad - sizeof(struct ib_grh);
+		agent_mad_send(mad_agent, response, grh, mad_recv_wc);
 	} else
 		kfree(response);
 	return 1;
@@ -483,8 +502,8 @@
 	} else {
 		/* PerfMgmt class */
 		if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
-			mad_response(mad_agent, mad, mad_recv_wc,
-				     mad_recv_wc->wc->slid);
+			agent_mad_response(mad_agent, mad, mad_recv_wc,
+					   mad_recv_wc->wc->slid);
 		} else {
 			printk(KERN_ERR "agent_recv_mad: Unexpected mgmt class 0x%x
received\n", mad->mad_hdr.mgmt_class);
 		}






More information about the general mailing list