[openib-general] [PATCH] mthca: Implement snoop_mad]

Roland Dreier roland at topspin.com
Wed Oct 13 13:23:16 PDT 2004


Thanks.  Your patch was severely whitespace damaged, so I implemented
snoop_mad by hand as below.  Something about your mailer (Evolution?)
or the way you're using it is killing all the tabs and wrapping some
lines.  In any case this should be pretty much the same as your
version.

 - R.

Index: infiniband/include/ib_verbs.h
===================================================================
--- infiniband/include/ib_verbs.h	(revision 948)
+++ infiniband/include/ib_verbs.h	(working copy)
@@ -654,10 +654,14 @@
 enum ib_mad_result {
 	IB_MAD_RESULT_FAILURE  = 0,      /* (!SUCCESS is the important flag) */
 	IB_MAD_RESULT_SUCCESS  = 1 << 0, /* MAD was successfully processed   */
-	IB_MAD_RESULT_REPLY    = 1 << 1, /* Reply packet needs to be sent    */
-	IB_MAD_RESULT_CONSUMED = 1 << 2  /* Packet consumed: stop processing */
+	IB_MAD_RESULT_REPLY    = 1 << 1  /* Reply packet needs to be sent    */
 };
 
+enum ib_snoop_mad_result {
+	IB_SNOOP_MAD_IGNORED,
+	IB_SNOOP_MAD_CONSUMED
+};
+
 #define IB_DEVICE_NAME_MAX 64
 
 struct ib_device {
@@ -771,6 +775,10 @@
 						  u16 source_lid,
 						  struct ib_mad *in_mad,
 						  struct ib_mad *out_mad);
+	enum ib_snoop_mad_result   (*snoop_mad)(struct ib_device *device,
+						u8 port_num,
+						u16 source_lid,
+						struct ib_mad *mad);
 
 	struct class_device          class_dev;
 	struct kobject               ports_parent;
Index: infiniband/core/mad_filter.c
===================================================================
--- infiniband/core/mad_filter.c	(revision 915)
+++ infiniband/core/mad_filter.c	(working copy)
@@ -301,13 +301,6 @@
 			       mad->mad_hdr.mgmt_class,
 			       be16_to_cpu(mad->mad_hdr.attr_id));
 
-	/* If the packet was consumed, we don't want to let anyone else look at it.
-	 * This is a special case for hardware (tavor) which uses the input queue
-	 * to generate traps.
-	 */
-	if (ret & IB_MAD_RESULT_CONSUMED)
-		goto no_response;
-
 	/* Look at incoming MADs to see if they match any filters.
 	 * Outgoing MADs are checked in ib_mad_work_thread().
 	 */
Index: infiniband/hw/mthca/mthca_dev.h
===================================================================
--- infiniband/hw/mthca/mthca_dev.h	(revision 915)
+++ infiniband/hw/mthca/mthca_dev.h	(working copy)
@@ -358,6 +358,10 @@
 		      u16 slid,
 		      struct ib_mad *in_mad,
 		      struct ib_mad *out_mad);
+enum ib_snoop_mad_result mthca_snoop_mad(struct ib_device *ibdev,
+					 u8 port_num,
+					 u16 slid,
+					 struct ib_mad *mad);
 
 static inline struct mthca_dev *to_mdev(struct ib_device *ibdev)
 {
Index: infiniband/hw/mthca/mthca_provider.c
===================================================================
--- infiniband/hw/mthca/mthca_provider.c	(revision 949)
+++ infiniband/hw/mthca/mthca_provider.c	(working copy)
@@ -581,6 +581,7 @@
 	dev->ib_dev.attach_mcast         = mthca_multicast_attach;
 	dev->ib_dev.detach_mcast         = mthca_multicast_detach;
 	dev->ib_dev.process_mad          = mthca_process_mad;
+	dev->ib_dev.snoop_mad            = mthca_snoop_mad;
 
 	ret = ib_register_device(&dev->ib_dev);
 	if (ret)
Index: infiniband/hw/mthca/mthca_mad.c
===================================================================
--- infiniband/hw/mthca/mthca_mad.c	(revision 915)
+++ infiniband/hw/mthca/mthca_mad.c	(working copy)
@@ -79,23 +79,6 @@
 	int err;
 	u8 status;
 
-	/* Forward locally generated traps to the SM */
-	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED &&
-	    in_mad->mad_hdr.method   == IB_MGMT_METHOD_TRAP           &&
-	    slid               == 0) {
-		struct ib_sm_path sm_path;
-
-		ib_cached_sm_path_get(ibdev, port_num, &sm_path);
-		if (sm_path.sm_lid) {
-			in_mad->sqpn            = 0;
-			in_mad->dlid            = sm_path.sm_lid;
-			in_mad->completion_func = NULL;
-			ib_mad_send(in_mad);
-		}
-
-		return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-	}
-
 	/*
 	 * Only handle SM gets, sets and trap represses for SM class
 	 *
@@ -154,6 +137,21 @@
 	return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 }
 
+enum ib_snoop_mad_result mthca_snoop_mad(struct ib_device *ibdev,
+					 u8 port_num,
+					 u16 slid,
+					 struct ib_mad *mad)
+{
+	if (mad->mad_hdr.method     != IB_MGMT_METHOD_TRAP               ||
+	    mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ||
+	    slid                    != 0)
+		return IB_SNOOP_MAD_IGNORED;
+
+	/* XXX: forward locally generated MAD to SM */
+
+	return IB_SNOOP_MAD_CONSUMED;
+}
+
 /*
  * Local Variables:
  * c-file-style: "linux"



More information about the general mailing list