[openib-general] Re: [PATCH] [CM] 2/2 Fix CM redirection in SRP

John Kingman kingman at storagegear.com
Thu Sep 8 20:44:01 PDT 2005


SRP part of updated redirection change.

Any chance of inclusion as an interim fix?

Signed-off-by: John Kingman <kingman <at> storagegear.com>

Index: ib_srp.h
===================================================================
--- ib_srp.h	(revision 3344)
+++ ib_srp.h	(working copy)
@@ -49,6 +49,7 @@
 
 enum {
 	SRP_PORT_REDIRECT	= 1,
+	SRP_PORT_REDIRECT	= 2,
 
 	SRP_MAX_IU_LEN		= 256,
 
@@ -316,4 +317,24 @@ struct srp_rsp {
 	u8	data[0];
 };
 
+struct class_port_info
+{
+	u8      base_version;
+	u8      class_version;
+	__be16  capability_mask;
+	__be32  resp_time_value;
+	u8      redirect_gid[16];
+	__be32  redirect_tcslfl;
+	__be16  redirect_lid;
+	__be16  redirect_p_key;
+	__be32  redirect_qp;
+	__be32  redirect_q_key;
+	u8      trap_gid[16];
+	__be32  trap_tcslfl;
+	__be16  trap_lid;
+	__be16  trap_p_key;
+	__be32  trap_hlqp;
+	__be32  trap_q_key;
+};
+
 #endif /* IB_SRP_H */

Index: ib_srp.c
===================================================================
--- ib_srp.c	(revision 3344)
+++ ib_srp.c	(working copy)
@@ -875,6 +875,7 @@ static int srp_cm_handler(struct ib_cm_i
 {
 	struct srp_target_port *target = cm_id->context;
 	struct ib_qp_attr *qp_attr = NULL;
+	struct class_port_info *cpi;
 	int attr_mask = 0;
 	int comp = 0;
 	int ret = 0;
@@ -944,17 +945,34 @@ static int srp_cm_handler(struct ib_cm_i
 	case IB_CM_REJ_RECEIVED:
 		printk(KERN_DEBUG PFX "REJ received\n");
 		comp = 1;
+		cpi = (struct class_port_info *)event->param.rej_rcvd.ari;
 
 		if (event->param.rej_rcvd.reason == IB_CM_REJ_PORT_CM_REDIRECT) {
-			/*
-			 * Additional Reject Info contains
-			 * ClassPortInfo, which has the RedirectGID
-			 * field at an offset of 8 bytes.
+			/* 
+			 * Additional Reject Info contains ClassPortInfo, of which
+			 * we need the RedirectGID, RedirectLID, RedirectP_Key, and 
+			 * the RedirectQP fields.
 			 */
-			memcpy(target->path.dgid.raw,
-			       event->param.rej_rcvd.ari + 8, 16);
+			target->path.dlid = cpi->redirect_lid;
+			target->path.pkey = cpi->redirect_p_key;
+			cm_id->qpn = be32_to_cpu(cpi->redirect_qp) & 0x00ffffff;
+			if (target->path.dlid) {
+				/* 
+				 * If RedirectLID is non-zero, it is the DLID a 
+				 * requester shall use to access the class services.
+				 */
+				target->status = SRP_DLID_REDIRECT;
+			} else {
+				/*
+				 * If the RedirectLID value is zero, the redirect 
+				 * requires the requester to use the supplied 
+				 * RedirectGID to request further path resolution 
+				 * from subnet administration.  
+				 */
+				memcpy(target->path.dgid.raw, cpi->redirect_gid, 16);
 
-			target->status = SRP_PORT_REDIRECT;
+				target->status = SRP_PORT_REDIRECT;
+			}
 		} else if (topspin_workarounds &&
 			   !memcmp(&target->ioc_guid, topspin_oui, 3) &&
 			   event->param.rej_rcvd.reason == IB_CM_REJ_PORT_REDIRECT) {
@@ -963,8 +981,7 @@ static int srp_cm_handler(struct ib_cm_i
 			 * reject reason code 25 when they mean 24
 			 * (port redirect).
 			 */
-			memcpy(target->path.dgid.raw,
-			       event->param.rej_rcvd.ari + 0, 16);
+			memcpy(target->path.dgid.raw, cpi->redirect_gid, 16);
 
 			printk(KERN_DEBUG PFX "Topspin/Cisco redirect to target port GID %016llx%016llx\n",
 			       (unsigned long long) be64_to_cpu(target->path.dgid.global.subnet_prefix),
@@ -1333,6 +1350,7 @@ retry_path:
 		goto err;
 	}
 
+retry_send:
 	init_completion(&target->done);
 	ret = srp_send_req(target);
 	if (ret)
@@ -1341,10 +1359,13 @@ retry_path:
 
 	/*
 	 * The CM event handling code will set status to
-	 * SRP_PORT_REDIRECT if we get a port redirect REJ back.
+	 * SRP_PORT_REDIRECT if we get a port redirect REJ back,
+	 * or SRP_DLID_REDIRECT if we get a lid/qp redirect REJ back.
 	 */
 	if (target->status == SRP_PORT_REDIRECT)
 		goto retry_path;
+	else if (target->status == SRP_DLID_REDIRECT)
+		goto retry_send;
 	else if (target->status < 0) {
 		printk(KERN_ERR PFX "Connection failed\n");
 		ret = target->status;




More information about the general mailing list