[openib-general] [PATCH] fill in missing parameters for MAD_IFC

Michael S. Tsirkin mst at mellanox.co.il
Sun Jan 16 01:55:37 PST 2005


Hi!
Since sufficient parameters are now passed to process_mad,
all that is left is to pass them down to hardware.
Unfortunately the documentation is wrong for MAD_IFC command:
the parameters are encoded as follows:

input modifier:
bit 0-7 port
bit 16-31 slid

opcode modifer
bit 0 - ignore mkey
bit 1 - ignore bkey
bit 2 - mad extended info enable

The format for mad extended info is correct.
The corrected document will be published soon.

mst

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: hw/mthca/mthca_provider.c
===================================================================
--- hw/mthca/mthca_provider.c	(revision 1537)
+++ hw/mthca/mthca_provider.c	(working copy)
@@ -59,8 +59,8 @@
 	in_mad->method         	   = IB_MGMT_METHOD_GET;
 	in_mad->attr_id   	   = IB_SMP_ATTR_NODE_INFO;
 
-	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
-			    1, in_mad, out_mad,
+	err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+			    1, NULL, NULL, in_mad, out_mad,
 			    &status);
 	if (err)
 		goto out;
@@ -104,8 +104,8 @@
 	in_mad->attr_id   	   = IB_SMP_ATTR_PORT_INFO;
 	in_mad->attr_mod           = cpu_to_be32(port);
 
-	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
-			    port, in_mad, out_mad,
+	err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+			    port, NULL, NULL, in_mad, out_mad,
 			    &status);
 	if (err)
 		goto out;
@@ -189,8 +189,8 @@
 	in_mad->attr_id   	   = IB_SMP_ATTR_PKEY_TABLE;
 	in_mad->attr_mod           = cpu_to_be32(index / 32);
 
-	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
-			    port, in_mad, out_mad,
+	err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+			    port, NULL, NULL, in_mad, out_mad,
 			    &status);
 	if (err)
 		goto out;
@@ -228,8 +228,8 @@
 	in_mad->attr_id   	   = IB_SMP_ATTR_PORT_INFO;
 	in_mad->attr_mod           = cpu_to_be32(port);
 
-	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
-			    port, in_mad, out_mad,
+	err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+			    port, NULL, NULL, in_mad, out_mad,
 			    &status);
 	if (err)
 		goto out;
@@ -248,8 +248,8 @@
 	in_mad->attr_id   	   = IB_SMP_ATTR_GUID_INFO;
 	in_mad->attr_mod           = cpu_to_be32(index / 8);
 
-	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
-			    port, in_mad, out_mad,
+	err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+			    port, NULL, NULL, in_mad, out_mad,
 			    &status);
 	if (err)
 		goto out;
Index: hw/mthca/mthca_mad.c
===================================================================
--- hw/mthca/mthca_mad.c	(revision 1537)
+++ hw/mthca/mthca_mad.c	(working copy)
@@ -231,9 +231,15 @@
 	} else
 		return IB_MAD_RESULT_SUCCESS;
 
+	/* check traps cant be sent unless we have in_wc. */
+
+	if (!in_wc)
+		mad_flags = IB_MAD_IGNORE_ALL;
+
 	err = mthca_MAD_IFC(to_mdev(ibdev),
-			    !!(mad_flags & IB_MAD_IGNORE_MKEY),
-			    port_num, in_mad, out_mad,
+			    mad_flags & IB_MAD_IGNORE_MKEY,
+			    mad_flags & IB_MAD_IGNORE_BKEY,
+			    port_num, in_wc, in_grh, in_mad, out_mad,
 			    &status);
 	if (err) {
 		mthca_err(to_mdev(ibdev), "MAD_IFC failed\n");
Index: hw/mthca/mthca_cmd.c
===================================================================
--- hw/mthca/mthca_cmd.c	(revision 1537)
+++ hw/mthca/mthca_cmd.c	(working copy)
@@ -36,6 +36,7 @@
 #include <linux/pci.h>
 #include <linux/errno.h>
 #include <asm/io.h>
+#include <ib_mad.h>
 
 #include "mthca_dev.h"
 #include "mthca_config_reg.h"
@@ -178,6 +179,17 @@
 	u8                status;
 };
 
+struct mthca_mad_ifc_ext_info {
+	u32 my_qpn;
+	u32 reserved0;
+	u32 rqpn;
+	u16 sl_g_mlpath;
+	u16 rlid;
+	u32 pkey_index;
+	u8  reserved[44];
+	u8  grh[40];
+};
+
 static inline int go_bit(struct mthca_dev *dev)
 {
 	return readl(dev->hcr + HCR_STATUS_OFFSET) &
@@ -1626,25 +1638,67 @@
 			 CMD_TIME_CLASS_B, status);
 }
 
-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port,
-		  void *in_mad, void *response_mad, u8 *status) {
+int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
+		  int port, struct ib_wc* in_wc, struct ib_grh* in_grh,
+		  void *in_mad, void *response_mad, u8 *status)
+{
 	void *box;
 	dma_addr_t dma;
 	int err;
+	struct mthca_mad_ifc_ext_info* info;
+	u16 sl_g_mlpath;
+	u32 in_modifier = port;
+	u32 op_modifier = 0;
 
-#define MAD_IFC_BOX_SIZE 512
+	BUG_ON((!ignore_bkey && !ignore_mkey) && !in_wc);
 
+#define MAD_IFC_BOX_SIZE 1024
+
 	box = pci_alloc_consistent(dev->pdev, MAD_IFC_BOX_SIZE, &dma);
 	if (!box)
 		return -ENOMEM;
 
 	memcpy(box, in_mad, 256);
 
-	err = mthca_cmd_box(dev, dma, dma + 256, port, !!ignore_mkey,
+	if (ignore_mkey)
+		op_modifier |= 0x1;
+
+	if (ignore_bkey)
+		op_modifier |= 0x2;
+	else {
+		memset(box + 256, 0, 256);
+
+		info = box + 256;
+
+		info->my_qpn = cpu_to_be32(in_wc->qp_num);
+		info->rqpn = cpu_to_be32(in_wc->src_qp);
+
+		sl_g_mlpath = in_wc->dlid_path_bits;
+		sl_g_mlpath |= (in_wc->sl << 12);
+		sl_g_mlpath |= (in_wc->wc_flags & IB_WC_GRH) ? 0x80 : 0;
+		info->sl_g_mlpath = cpu_to_be16(sl_g_mlpath);
+
+		info->rlid = cpu_to_be16(in_wc->slid);
+		info->pkey_index = cpu_to_be32(in_wc->pkey_index << 16);
+
+		if (in_grh) {
+			memcpy(&info->grh, in_grh, 40);
+		}
+
+		op_modifier |= 0x10;
+	}
+
+
+	if (in_wc) {
+		in_modifier |= in_wc->slid<<16;
+	}
+
+
+	err = mthca_cmd_box(dev, dma, dma + 512, in_modifier, op_modifier,
 			    CMD_MAD_IFC, CMD_TIME_CLASS_C, status);
 
 	if (!err && !*status)
-		memcpy(response_mad, box + 256, 256);
+		memcpy(response_mad, box + 512, 256);
 
 	pci_free_consistent(dev->pdev, MAD_IFC_BOX_SIZE, box, dma);
 	return err;
Index: hw/mthca/mthca_cmd.h
===================================================================
--- hw/mthca/mthca_cmd.h	(revision 1537)
+++ hw/mthca/mthca_cmd.h	(working copy)
@@ -280,7 +280,8 @@
 		   void *qp_context, u8 *status);
 int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
 			  u8 *status);
-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port,
+int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
+		  int port, struct ib_wc* in_wc, struct ib_grh* in_grh,
 		  void *in_mad, void *response_mad, u8 *status);
 int mthca_READ_MGM(struct mthca_dev *dev, int index, void *mgm,
 		   u8 *status);




More information about the general mailing list