[openib-general] [PATCH] beginnings of SMI

Sean Hefty mshefty at ichips.intel.com
Wed Sep 15 09:45:10 PDT 2004


On Tue, 14 Sep 2004 15:18:39 -0700
Sean Hefty <mshefty at ichips.intel.com> wrote:

> This patch begins to add in functionality needed by the SMI implementation.

Let's try this again.  Moved SMI specific code from ib_mad.h to ib_smi.h.  Updated printk from previous patch.  And replaced the Makefile.  (Feel free to ignore the Makefile changes or to replace it with yours.  The current one didn't seem out of date.)

- Sean

Index: access/ib_mad_priv.h
===================================================================
--- access/ib_mad_priv.h	(revision 841)
+++ access/ib_mad_priv.h	(working copy)
@@ -58,7 +58,8 @@
 
 #include <linux/pci.h>
 #include <linux/kthread.h>
-
+#include <ib_mad.h>
+#include <ib_smi.h>
 
 #define IB_MAD_QPS_CORE		2 /* Always QP0 and QP1 as a minimum */
 #define IB_MAD_QPS_SUPPORTED	2
@@ -93,6 +94,7 @@
 	union {
 		struct ib_mad mad;
 		struct ib_rmpp_mad rmpp_mad;
+		struct ib_smp smp;
 	} mad;
 } __attribute__ ((packed));
 
Index: access/ib_smi.c
===================================================================
--- access/ib_smi.c	(revision 0)
+++ access/ib_smi.c	(revision 0)
@@ -0,0 +1,125 @@
+/*
+  This software is available to you under a choice of one of two
+  licenses.  You may choose to be licensed under the terms of the GNU
+  General Public License (GPL) Version 2, available at
+  <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
+  license, available in the LICENSE.TXT file accompanying this
+  software.  These details are also available at
+  <http://openib.org/license.html>.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+
+  Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
+  Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
+  Copyright (c) 2004 Intel Corporation.  All rights reserved.
+  Copyright (c) 2004 Topspin Corporation.  All rights reserved.
+  Copyright (c) 2004 Voltaire Corporation.  All rights reserved.
+*/
+
+#include <ib_smi.h>
+#include "ib_mad_priv.h"
+
+int smi_process_dr_smp(struct ib_mad_port_private *port_priv,
+		       struct ib_smp *smp)
+{
+	u8 hop_ptr, hop_cnt;
+
+	hop_ptr = smp->hop_ptr;
+	hop_cnt = smp->hop_cnt;
+
+	/*
+	 * Outgoing MAD processing.  "Outgoing" means from initiator to responder.
+	 * Section 14.2.2.2, Vol 1 IB spec
+	 */
+	if (!ib_get_smp_direction(smp)) {
+		/* C14-9:1 */
+		if (hop_ptr == 0 && hop_cnt)
+			return 0;
+
+		/* C14-9:2 */
+		if (hop_ptr && hop_ptr < hop_cnt) {
+			if (port_priv->device->node_type == IB_NODE_SWITCH) {
+				printk(KERN_NOTICE
+					"Need to handle DR Mad on switch\n");
+			}
+			return 0;
+		}
+
+		/* C14-9:3 -- We're at the end of the DR segment of path */
+		if (hop_ptr == hop_cnt) {
+			if (hop_cnt)
+				smp->return_path[hop_ptr] = port_priv->port;
+			smp->hop_ptr++;
+
+			if (port_priv->device->node_type == IB_NODE_SWITCH) {
+				printk(KERN_NOTICE
+					"Need to handle DR Mad on switch\n");
+				return 0;
+			} else if (smp->dr_dlid != IB_LID_PERMISSIVE) {
+					return 0;
+			}
+
+			return 1;
+		}
+
+		/* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM. */
+		if (hop_ptr == hop_cnt + 1)
+			return 1;
+
+		/* C14-9:5 -- Check for unreasonable hop pointer. */
+		if (hop_ptr > hop_cnt + 1)
+			return 0;
+
+		/* There should be no way of getting here, since one of the if
+		 * statements above should have matched, and should have
+		 * returned a value.
+		 */
+		printk(KERN_ERR "Unhandled Outgoing DR MAD case\n");
+		return 0;
+	} else {  /* Returning MAD (From responder to initiator) */
+
+		/* C14-13:1 */
+		if (hop_cnt && hop_ptr == hop_cnt + 1)
+			return 0;
+
+		/* C14-13:2 */
+		if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
+			if (port_priv->device->node_type == IB_NODE_SWITCH) {
+				printk(KERN_NOTICE
+					"Need to handle DR Mad on switch\n");
+			}
+			return 0;
+		}
+
+		/* C14-13:3 -- We're at the end of the DR segment of path */
+		if (hop_ptr == 1) {
+			smp->hop_ptr--;
+
+			if (port_priv->device->node_type == IB_NODE_SWITCH) {
+				printk(KERN_NOTICE
+					"Need to handle DR Mad on switch\n");
+				return 0;
+			} else if (smp->dr_dlid != IB_LID_PERMISSIVE) {
+				return 0;
+			}
+
+			return 1;
+		}
+
+		/* C14-13:4 -- Hop Pointer = 0 -> give to SM. */
+		if (hop_ptr == 0)
+			return 1;
+
+		/* C14-13:5 -- Check for unreasonable hop pointer. */
+		if (hop_ptr > hop_cnt + 1)
+			return 0;
+	}
+	return 1;
+}
Index: access/Makefile
===================================================================
--- access/Makefile	(revision 841)
+++ access/Makefile	(working copy)
@@ -1,27 +1,9 @@
-# Makefile for the kernel module
+EXTRA_CFLAGS += -Idrivers/infiniband/include 
 
-INCDIRS := -I. -I../include -I/lib/modules/$(shell uname -r)/build/include
-#INCDIRS := -I. -I../include -I/lib/modules/$(shell uname -r)/build/include -I../../include 
+obj-$(CONFIG_INFINIBAND) += ib_access.o
 
-MODULE := gsi
-OBJS   := gsi_main.o
+ib_access-objs := \
+    ib_verbs.o \
+    ib_mad.o \
+    ib_smi.o
 
-#For RMPP support:
-OBJS   += gsi_rmpp_vendal.o rmpp/rmpp_module.o
-
-#CFLAGS := -W -O2 -DVD_MODULE_NAME=GSI -DVD_TRACE_LEVEL=6 -DVD_ENTERLEAVE_LEVEL=3 -DMODULE -D__KERNEL__ -DKBUILD_BASENAME=$(MODULE) -DKBUILD_MODNAME=$(MODULE) $(INCDIRS) 
-CFLAGS := -W -O2 -DVD_MODULE_NAME=GSI -DMODULE -D__KERNEL__ -DKBUILD_BASENAME=$(MODULE) -DKBUILD_MODNAME=$(MODULE) -DGSI_RMPP_SUPPORT $(INCDIRS)
-
-all: gsi.o
-
-rmpp/rmpp_module.o:
-	make -C rmpp
-
-gsi.o: $(OBJS)
-	$(LD) $(LDFLAGS) -o $@ $(OBJS)
-
-include ./make.rules
-CFLAGS := ${CFLAGS:-W=}
-CFLAGS := ${CFLAGS:-Wshadow=}
-
-# DO NOT DELETE
Index: include/ib_smi.h
===================================================================
--- include/ib_smi.h	(revision 0)
+++ include/ib_smi.h	(revision 0)
@@ -0,0 +1,66 @@
+/*
+  This software is available to you under a choice of one of two
+  licenses.  You may choose to be licensed under the terms of the GNU
+  General Public License (GPL) Version 2, available at
+  <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
+  license, available in the LICENSE.TXT file accompanying this
+  software.  These details are also available at
+  <http://openib.org/license.html>.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+
+  Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
+  Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
+  Copyright (c) 2004 Intel Corporation.  All rights reserved.
+  Copyright (c) 2004 Topspin Corporation.  All rights reserved.
+  Copyright (c) 2004 Voltaire Corporation.  All rights reserved.
+*/
+
+#if !defined( IB_SMI_H )
+#define IB_SMI_H
+
+#include <ib_mad.h>
+
+#define IB_LID_PERMISSIVE			0xFFFF
+
+#define IB_SMP_DATA_SIZE			64
+#define IB_SMP_MAX_PATH_HOPS			64
+
+struct ib_smp {
+	u8	base_version;
+	u8	mgmt_class;
+	u8	class_version;
+	u8	method;
+	u16	status;
+	u8	hop_ptr;
+	u8	hop_cnt;
+	u64	tid;
+	u16	attr_id;
+	u16	resv;
+	u32	attr_mod;
+	u64	mkey;
+	u16	dr_slid;
+	u16	dr_dlid;
+	u8	reserved[28];
+	u8	data[IB_SMP_DATA_SIZE];
+	u8	initial_path[IB_SMP_MAX_PATH_HOPS];
+	u8	return_path[IB_SMP_MAX_PATH_HOPS];
+} __attribute__ ((packed));
+
+#define IB_SMP_DIRECTION	cpu_to_be16(0x8000)
+
+static inline u8
+ib_get_smp_direction(struct ib_smp *smp)
+{
+	return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
+}
+
+
+#endif /* IB_SMI_H */



More information about the general mailing list