[openib-general] [PATCH] GSI: GRH support for normal MADs

Hal Rosenstock halr at voltaire.com
Tue Aug 10 14:54:10 PDT 2004


Added GRH support for normal MADs

Index: access/TODO
===================================================================
--- access/TODO	(revision 605)
+++ access/TODO	(working copy)
@@ -1,11 +1,12 @@
-8/9/04
+8/10/04
 
-Add support for (at least) responses to requests with GRH
 Remove #if 0/1 with suitable preprocessor symbols
 Replace ib_reg_mr with ib_reg_phys_mr
 Eliminate static limit on numbers of ports/HCAs
 Makefile needs to use standard kbuild 
 Migrate from /proc to /sysfs
+Obtain proper SGID index for GRH support (low priority)
+Add GRH support for RMPP (low priority)
 Static rate handling (low priority)
 
 Update API to proposed openib GSI interface
Index: access/gsi_main.c
===================================================================
--- access/gsi_main.c	(revision 622)
+++ access/gsi_main.c	(working copy)
@@ -1680,6 +1680,7 @@
 			dtgrm_priv->path_bits = wc->dlid_path_bits;
 			dtgrm_priv->sl = wc->sl;
 			dtgrm_priv->pkey_index = wc->pkey_index;
+			dtgrm_priv->grh_flag = wc->grh_flag;
 
 			mad_swap_header(mad);
 			if (gsi_post_send_plm_reply_mad
@@ -1700,6 +1701,7 @@
 	dtgrm_priv->path_bits = wc->dlid_path_bits;
 	dtgrm_priv->sl = wc->sl;
 	dtgrm_priv->pkey_index = wc->pkey_index;
+	dtgrm_priv->grh_flag = wc->grh_flag;
 
 	printk(KERN_DEBUG \
 		 "Received datagram - remote QP num-%d, LID-%d, path bits- %d, SL - %d\n",
@@ -1749,6 +1751,7 @@
 	struct ib_class_port_info_t class_port_info;
 	int redirect = FALSE;
 	struct gsi_redirect_info_st *redirect_info;
+	struct ib_grh *grh;
 	GSI_REDIR_LIST_LOCK_VAR;
 
 	if (!dtgrm_priv->mad.hdr.m.ms.r) {
@@ -1768,10 +1771,8 @@
 		GSI_REDIR_LIST_UNLOCK(class_info);
 	}
 
-	addr_vec->grh_flag = 0;
-	memset((char *) &addr_vec->grh.dgid, 0, sizeof (addr_vec->grh.dgid));
+	addr_vec->grh_flag = dtgrm_priv->grh_flag;
 	addr_vec->grh.sgid_index = 0;
-	addr_vec->grh.hop_limit = GSI_HOP_LIMIT;
 	addr_vec->static_rate = GSI_MAX_STATIC_RATE;
 	addr_vec->src_path_bits = GSI_SOURCE_PATH_BIT;
 	addr_vec->port = class_info->hca->port;
@@ -1782,8 +1783,10 @@
 			 class_port_info.redirect_qp,
 			 class_port_info.redirect_q_key);
 
+		memcpy(&addr_vec->grh.dgid, &class_port_info.redirect_gid,  sizeof (addr_vec->grh.dgid)); 
 		addr_vec->dlid = class_port_info.redirect_lid;
 		addr_vec->sl = class_port_info.redirect_sl;
+		addr_vec->grh.hop_limit = GSI_HOP_LIMIT;
 		addr_vec->grh.traffic_class = class_port_info.redirect_tc;
 		addr_vec->grh.flow_label = class_port_info.redirect_fl;
 		dtgrm_priv->rqp = class_port_info.redirect_qp;
@@ -1791,8 +1794,18 @@
 	} else {
 		addr_vec->dlid = dtgrm_priv->rlid;
 		addr_vec->sl = GSI_SL;
-		addr_vec->grh.traffic_class = GSI_TRAFIC_CLASS;
-		addr_vec->grh.flow_label = GSI_FLOW_LABEL;
+		if (addr_vec->grh_flag) {
+			grh = (struct ib_grh *)dtgrm_priv->grh;
+			memcpy(&addr_vec->grh.dgid, &grh->destination_gid, sizeof(addr_vec->grh.dgid));
+			addr_vec->grh.hop_limit = grh->hop_limit;
+			addr_vec->grh.traffic_class = grh->traffic_class;
+			addr_vec->grh.flow_label = grh->flow_label;	
+		} else {
+			memset((char *) &addr_vec->grh.dgid, 0, sizeof (addr_vec->grh.dgid));
+			addr_vec->grh.hop_limit = GSI_HOP_LIMIT;
+			addr_vec->grh.traffic_class = GSI_TRAFIC_CLASS;
+			addr_vec->grh.flow_label = GSI_FLOW_LABEL;
+		}
 		dtgrm_priv->rqp = 1;
 		dtgrm_priv->r_q_key = GSI_QP1_WELL_KNOWN_Q_KEY;
 	}
@@ -1822,20 +1835,19 @@
 	mad->hdr.class_ver = class_info->version;
 #if 0
 	mad->hdr.m.ms.method-- - Set by caller
-	    mad->hdr.m.ms.r-- - Response bit - set by caller
+	mad->hdr.m.ms.r-- - Response bit - set by caller
 #endif
-	    /*
-	     * For response - the client ID is taken from the request datagram.
-	     * It is may be set by the caller or the same received datagram is used
-	     * for response.
-	     */
-	    if (!mad->hdr.m.ms.r) {
+	/*
+	 * For response - the client ID is taken from the request datagram.
+	 * It is may be set by the caller or the same received datagram
+	 * is used for response.
+	 */
+	if (!mad->hdr.m.ms.r) {
 		/*
-		 * For Microsoft CM compatability:
+		 * For Microsoft CM compatibility:
 		 * they require the same transaction id in CM negotiation,
-		 * although response bit is not set in Send() methods.
-		 * Caller may set transaction id or
-		 * set zero and let gsi to do it.
+		 * although response bit is not set in Send() method.
+		 * Caller may set transaction id or set zero and let gsi do it.
 		 */
 		if (!mad->hdr.transact_id) {
 			((struct gsi_tid_st *) &mad->hdr.transact_id)->
@@ -2013,19 +2025,28 @@
 	int ret = 0;
 	struct gsi_dtgrm_priv_st *dtgrm_priv =
 	    (struct gsi_dtgrm_priv_st *) dtgrm;
+	struct ib_grh *grh;
 
-	addr_vec.grh_flag = 0;
-	memset((char *) &addr_vec.grh.dgid, 0, sizeof (addr_vec.grh.dgid));
+	addr_vec.grh_flag = dtgrm_priv->grh_flag;
 	addr_vec.grh.sgid_index = 0;
-	addr_vec.grh.hop_limit = GSI_HOP_LIMIT;
 	addr_vec.static_rate = GSI_MAX_STATIC_RATE;
 	addr_vec.src_path_bits = GSI_SOURCE_PATH_BIT;
 	addr_vec.port = hca->port;
 
 	addr_vec.dlid = dtgrm_priv->rlid;
 	addr_vec.sl = GSI_SL;
-	addr_vec.grh.traffic_class = GSI_TRAFIC_CLASS;
-	addr_vec.grh.flow_label = GSI_FLOW_LABEL;
+	if (addr_vec.grh_flag) {
+		grh = (struct ib_grh *)dtgrm_priv->grh;
+		memcpy(&addr_vec.grh.dgid, &grh->source_gid, sizeof(addr_vec.grh.dgid));
+		addr_vec.grh.hop_limit = grh->hop_limit;
+		addr_vec.grh.traffic_class = grh->traffic_class;
+		addr_vec.grh.flow_label = grh->flow_label;	
+	} else {
+		memset((char *) &addr_vec.grh.dgid, 0, sizeof (addr_vec.grh.dgid));
+		addr_vec.grh.hop_limit = GSI_HOP_LIMIT;
+		addr_vec.grh.traffic_class = GSI_TRAFIC_CLASS;
+		addr_vec.grh.flow_label = GSI_FLOW_LABEL;
+	}
 	dtgrm_priv->rqp = 1;
 	dtgrm_priv->r_q_key = GSI_QP1_WELL_KNOWN_Q_KEY;
 
@@ -2117,7 +2138,7 @@
 
 	rmpp_mad->dir_switch_needed = dtgrm_priv->rmpp_dir_switch_needed;
 
-	/* NOTE: GRH not supported yet! */
+	/* NOTE: GRH not supported yet for RMPP! */
 	rmpp_mad->grh_valid = FALSE;
 
 	rmpp_mad->pkey_index = dtgrm_priv->pkey_index;
@@ -2139,7 +2160,7 @@
 	rmpp_mad->pkey_index = dtgrm_priv->pkey_index;
 
 	rmpp_mad->dir_switch_needed = dtgrm_priv->rmpp_dir_switch_needed;
-	/* NOTE: GRH not supported yet! */
+	/* NOTE: GRH not supported yet for RMPP! */
 	rmpp_mad->grh_valid = FALSE;
 
 	rmpp_mad->context = dtgrm_priv;
Index: access/gsi.h
===================================================================
--- access/gsi.h	(revision 599)
+++ access/gsi.h	(working copy)
@@ -110,6 +110,7 @@
 	u16 rlid;
 	u16 pkey_index;
 	u8 sl;
+	int grh_flag:1;
 
 	u64 guid;
 	u8 path_bits;
Index: access/gsi_priv.h
===================================================================
--- access/gsi_priv.h	(revision 596)
+++ access/gsi_priv.h	(working copy)
@@ -145,6 +145,7 @@
 	u16 rlid;
 	u16 pkey_index;
 	u8 sl;
+	int grh_flag:1;
 
 	u64 guid;
 	u8 path_bits;
Index: include/ib_core_types.h
===================================================================
--- include/ib_core_types.h	(revision 562)
+++ include/ib_core_types.h	(working copy)
@@ -34,4 +34,15 @@
 			  struct ib_device * device, int event);
 	struct list_head list;
 };
+
+struct ib_grh {
+	u8 ip_version;
+	u8 traffic_class;
+	u32 flow_label;
+	u16 next_header;
+	u8 hop_limit;
+	union ib_gid source_gid;
+	union ib_gid destination_gid;
+};
+
 #endif				/* _IB_CORE_TYPES_H */




More information about the general mailing list