[Fwd: Re: [openib-general] ib_verbs.h ib_device_attr device type]

Roland Dreier roland at topspin.com
Wed Sep 1 14:31:28 PDT 2004


I'm applying this patch to bring my branch up to date.

 - R.

Index: infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- infiniband/ulp/ipoib/ipoib_verbs.c	(revision 714)
+++ infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -301,7 +301,7 @@
 			return;
 		}
 
-		if (device->flags & IB_DEVICE_IS_SWITCH) {
+		if (device->node_type == IB_NODE_SWITCH) {
 			if (try_module_get(device->owner))
 				ipoib_add_port("ib%d", device, 0);
 		} else {
Index: infiniband/include/ib_verbs.h
===================================================================
--- infiniband/include/ib_verbs.h	(revision 714)
+++ infiniband/include/ib_verbs.h	(working copy)
@@ -47,6 +47,12 @@
 	} global;
 };
 
+enum ib_node_type {
+	IB_NODE_CA 	= 1,
+	IB_NODE_SWITCH,
+	IB_NODE_ROUTER
+};
+
 enum ib_device_cap_flags {
 	IB_DEVICE_RESIZE_MAX_WR		= 1, 
 	IB_DEVICE_BAD_PKEY_CNTR		= (1<<1), 
@@ -684,6 +690,8 @@
 	ib_mad_process_func          mad_process;
 
 	struct class_device          class_dev;
+
+	u8                           node_type;
 };
 
 int ib_query_device(struct ib_device *device,
Index: infiniband/include/ts_ib_core_types.h
===================================================================
--- infiniband/include/ts_ib_core_types.h	(revision 714)
+++ infiniband/include/ts_ib_core_types.h	(working copy)
@@ -154,7 +154,6 @@
 /* structures */
 
 enum {
-	IB_DEVICE_IS_SWITCH        = 1 << 0,
 	IB_MAD_NO_HOP_POINTER_INCR = 1 << 1,
 	IB_MAD_LOCAL_USE_QP        = 1 << 2
 };
Index: infiniband/core/mad_main.c
===================================================================
--- infiniband/core/mad_main.c	(revision 714)
+++ infiniband/core/mad_main.c	(working copy)
@@ -181,7 +181,7 @@
 
 	device->mad    = priv;
 	priv->ib_dev   = device;
-	priv->num_port = device->flags & IB_DEVICE_IS_SWITCH ?
+	priv->num_port = device->node_type == IB_NODE_SWITCH ?
 		1 : prop.phys_port_cnt;
 
 	priv->pd = ib_alloc_pd(device);
@@ -235,7 +235,7 @@
 		int start_port, end_port;
 		int p, q, i;
 
-		if (device->flags & IB_DEVICE_IS_SWITCH) {
+		if (device->node_type == IB_NODE_SWITCH) {
 			start_port = end_port = 0;
 		} else {
 			start_port = 1;
Index: infiniband/core/mad_filter.c
===================================================================
--- infiniband/core/mad_filter.c	(revision 714)
+++ infiniband/core/mad_filter.c	(working copy)
@@ -132,7 +132,7 @@
 
 		/* C14-9:2 */
 		if (hop_pointer != 0 && hop_pointer < hop_count) {
-			if (!(device->flags & IB_DEVICE_IS_SWITCH)) {
+			if (device->node_type != IB_NODE_SWITCH) {
 				return 0;   // Drop intermediate hop on non-switch.
 			} else {
 				/* XXX switch */
@@ -148,7 +148,7 @@
 				(TS_IB_MAD_SMP_DR_PAYLOAD(mad))->return_path[hop_pointer] = mad->port;
 			++mad->route.directed.hop_pointer;
 
-			if (device->flags & IB_DEVICE_IS_SWITCH) {
+			if (device->node_type == IB_NODE_SWITCH) {
 				/* XXX switch */
 				TS_REPORT_WARN(MOD_KERNEL_IB, "Need to handle DrMad on switch");
 				return 0;
@@ -198,7 +198,7 @@
 
 		/* C14-13:2 */
 		if (hop_count != 0 && 2 <= hop_pointer && hop_pointer <= hop_count) {
-			if (!(device->flags & IB_DEVICE_IS_SWITCH)) {
+			if (device->node_type != IB_NODE_SWITCH) {
 				return 0;   // Drop intermediate hop on non-switch.
 			} else {
 				/* XXX switch */
@@ -212,7 +212,7 @@
 		if (hop_pointer == 1) {
 			--mad->route.directed.hop_pointer;
 
-			if (device->flags & IB_DEVICE_IS_SWITCH) {
+			if (device->node_type == IB_NODE_SWITCH) {
 				/* XXX switch */
 				TS_REPORT_WARN(MOD_KERNEL_IB, "Need to handle DrMad on switch");
 				return 0;
Index: infiniband/core/core_device.c
===================================================================
--- infiniband/core/core_device.c	(revision 714)
+++ infiniband/core/core_device.c	(working copy)
@@ -162,7 +162,7 @@
 
 	memcpy(priv->node_guid, &prop.node_guid, sizeof (tTS_IB_GUID));
 
-	if (device->flags & IB_DEVICE_IS_SWITCH) {
+	if (device->node_type == IB_NODE_SWITCH) {
 		priv->start_port = priv->end_port = 0;
 	} else {
 		priv->start_port = 1;
@@ -207,7 +207,7 @@
 		goto out_free_cache;
 	}
 
-	ret = ib_proc_setup(device, !!(device->flags & IB_DEVICE_IS_SWITCH));
+	ret = ib_proc_setup(device, device->node_type == IB_NODE_SWITCH);
 	if (ret) {
 		TS_REPORT_WARN(MOD_KERNEL_IB,
 			       "Couldn't create /proc dir for %s",
Index: infiniband/hw/mthca/mthca_provider.c
===================================================================
--- infiniband/hw/mthca/mthca_provider.c	(revision 714)
+++ infiniband/hw/mthca/mthca_provider.c	(working copy)
@@ -517,6 +517,7 @@
 int mthca_register_device(struct mthca_dev *dev)
 {
 	strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
+	dev->ib_dev.node_type            = IB_NODE_CA;
 	dev->ib_dev.owner                = THIS_MODULE;
 	dev->ib_dev.dma_device           = dev->pdev;
 	dev->ib_dev.provider             = "mthca";



More information about the general mailing list