[openib-general] [PATCH] GSI: Remove hard coded PKey Index

Hal Rosenstock halr at voltaire.com
Fri Aug 6 09:15:18 PDT 2004


Support PKey index rather than hardcoding in GSI

Index: access/TODO
===================================================================
--- access/TODO	(revision 586)
+++ access/TODO	(working copy)
@@ -1,7 +1,6 @@
-8/4/04
+8/6/04
 
-Consumer needs to be able to set PKey index (currently hardcoded)
-Add support for at least responses to requests with GRH
+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
Index: access/make.rules
===================================================================
--- access/make.rules	(revision 561)
+++ access/make.rules	(working copy)
@@ -68,8 +68,8 @@
 CC=gcc
 LD=ld
 LDFLAGS=-m elf_i386 -r
-#CFLAGS += -DCPU_BE=0 -DCPU_LE=1 -mpreferred-stack-boundary=2 -fno-common -I/usr/src/linux/include/asm/mach-default
-CFLAGS += -mpreferred-stack-boundary=2 -fno-common -I/usr/src/linux/include/asm/mach-default
+#CFLAGS += -DCPU_BE=0 -DCPU_LE=1 -mpreferred-stack-boundary=2 -fno-common -I/usr/src/linux-$(shell uname -r)/include/asm-i386/mach-default
+CFLAGS += -mpreferred-stack-boundary=2 -fno-common -I/usr/src/linux-$(shell uname -r)/include/asm-i386/mach-default
 endif
 endif
 endif
Index: access/gsi_main.c
===================================================================
--- access/gsi_main.c	(revision 586)
+++ access/gsi_main.c	(working copy)
@@ -81,7 +81,6 @@
 #define GSI_MAX_STATIC_RATE  0
 #define GSI_SOURCE_PATH_BIT  0
 #define GSI_SEND_Q_PSN       0
-#define GSI_P_KEY_INDEX      0
 #define GSI_SL               0
 #define GSI_TRAFIC_CLASS     0
 #define GSI_HOP_LIMIT       63
@@ -243,7 +242,11 @@
 	}
 
 	attr->qp_state = IB_QPS_INIT;
-	attr->pkey_index = GSI_P_KEY_INDEX;
+	/*
+	 * PKey index for QP1 is irrelevant but one is needed for 
+	 * Reset to Init transition.
+	 */
+	attr->pkey_index = 0;
 	attr->port = port;
 	attr->qkey = GSI_QP1_WELL_KNOWN_Q_KEY;
 	attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT | IB_QP_QKEY;
@@ -1663,6 +1666,7 @@
 			dtgrm_priv->rlid = wc->slid;
 			dtgrm_priv->path_bits = wc->dlid_path_bits;
 			dtgrm_priv->sl = wc->sl;
+			dtgrm_priv->pkey_index = wc->pkey_index;
 
 			mad_swap_header(mad);
 			if (gsi_post_send_plm_reply_mad
@@ -1682,6 +1686,7 @@
 	dtgrm_priv->rlid = wc->slid;
 	dtgrm_priv->path_bits = wc->dlid_path_bits;
 	dtgrm_priv->sl = wc->sl;
+	dtgrm_priv->pkey_index = wc->pkey_index;
 
 	printk(KERN_DEBUG \
 		 "Received datagram - remote QP num-%d, LID-%d, path bits- %d, SL - %d\n",
@@ -1696,10 +1701,7 @@
 		goto out1;
 	}
 
-	/*
-	 * If the received MAD is for RMPP - 
-	 * handle it properly.
-	 */
+	/* If the received MAD is for RMPP - handle it properly. */ 
 	if (gsi_is_rmpp_mad(class_info, (struct gsi_dtgrm_t *) dtgrm_priv)) {
 		gsi_rmpp_recv(class_info, dtgrm_priv);
 		goto out1;
@@ -1901,7 +1903,7 @@
 	/* QP1_WELL_KNOWN_Q_KEY = 0x80010000 */
 	wr.wr.ud.remote_qkey = dtgrm_priv->r_q_key;
 	wr.wr.ud.ah = addr_hndl;
-	wr.wr.ud.pkey_index = GSI_P_KEY_INDEX;
+	wr.wr.ud.pkey_index = dtgrm_priv->pkey_index;
 	wr.send_flags = IB_SEND_SIGNALED;
 
 	mad_swap_header(mad);
@@ -2041,7 +2043,7 @@
 	/* QP1_WELL_KNOWN_Q_KEY = 0x80010000 */
 	wr.wr.ud.remote_qkey = dtgrm_priv->r_q_key;
 	wr.wr.ud.ah = addr_hndl;
-	wr.wr.ud.pkey_index = GSI_P_KEY_INDEX;
+	wr.wr.ud.pkey_index = dtgrm_priv->pkey_index;
 	wr.send_flags = IB_SEND_SIGNALED;
 
 	mad_swap_header(mad);
@@ -2095,7 +2097,7 @@
 	/* NOTE: GRH not supported yet! */
 	rmpp_mad->grh_valid = FALSE;
 
-	rmpp_mad->pkey_index = GSI_P_KEY_INDEX;
+	rmpp_mad->pkey_index = dtgrm_priv->pkey_index;
 }
 
 static void
@@ -2111,7 +2113,7 @@
 	rmpp_mad->remote_sl = dtgrm_priv->sl;
 	rmpp_mad->remote_qp = dtgrm_priv->rqp;
 	rmpp_mad->path_bits = dtgrm_priv->path_bits;
-	rmpp_mad->pkey_index = GSI_P_KEY_INDEX;
+	rmpp_mad->pkey_index = dtgrm_priv->pkey_index;
 
 	rmpp_mad->dir_switch_needed = dtgrm_priv->rmpp_dir_switch_needed;
 	/* NOTE: GRH not supported yet! */
@@ -2603,11 +2605,11 @@
 
 	lock_kernel();
 
-#if 1				/* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
+#if 0				/* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
 	sprintf(current->comm, "gsi-%-6s-%-2d", hca->handle->name, hca->port);
 	daemonize();
 #else
-	daemonize("gsi-%-6s-%-2d", hca->handle->name, hca_port);
+	daemonize("gsi-%-6s-%-2d", hca->handle->name, hca->port);
 #endif
 
 	unlock_kernel();
Index: access/gsi.h
===================================================================
--- access/gsi.h	(revision 561)
+++ access/gsi.h	(working copy)
@@ -109,6 +109,7 @@
 	u32 rqp;
 	u32 rqk;
 	u16 rlid;
+	u16 pkey_index;
 	u8 sl;
 
 	u64 guid;
Index: access/gsi_priv.h
===================================================================
--- access/gsi_priv.h	(revision 561)
+++ access/gsi_priv.h	(working copy)
@@ -144,6 +144,7 @@
 	u32 rqp;
 	u32 r_q_key;
 	u16 rlid;
+	u16 pkey_index;
 	u8 sl;
 
 	u64 guid;






More information about the general mailing list