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

Hal Rosenstock
Wed Oct 13 11:36:42 PDT 2004


mthca: Implement snoop_mad

Index: include/ib_verbs.h
===================================================================
--- include/ib_verbs.h  (revision 970)
+++ 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);
+        int                       (*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: hw/mthca/mthca_dev.h
===================================================================
--- hw/mthca/mthca_dev.h        (revision 970)
+++ hw/mthca/mthca_dev.h        (working copy)
@@ -352,6 +352,10 @@
 int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16
lid);
 int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16
lid);
 
+int mthca_snoop_mad(struct ib_device *ibdev,
+                   u8 port_num,
+                   u16 slid,
+                   struct ib_mad *mad);
 int mthca_process_mad(struct ib_device *ibdev,
                      int mad_flags,
                      u8 port_num,
Index: hw/mthca/mthca_provider.c
===================================================================
--- hw/mthca/mthca_provider.c   (revision 970)
+++ 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: hw/mthca/mthca_mad.c
===================================================================
--- hw/mthca/mthca_mad.c        (revision 970)
+++ hw/mthca/mthca_mad.c        (working copy)
@@ -69,33 +69,44 @@
        }
 }
 
-int mthca_process_mad(struct ib_device *ibdev,
-                     int mad_flags,
-                     u8 port_num,
-                     u16 slid,
-                     struct ib_mad *in_mad,
-                     struct ib_mad *out_mad)
+int mthca_snoop_mad(struct ib_device *ibdev,
+                   u8 port_num,
+                   u16 slid,
+                   struct ib_mad *mad)
 {
-       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           &&
+       if (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED &&
+           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);
+                       mad->sqpn            = 0;
+                       mad->dlid            = sm_path.sm_lid;
+                       mad->completion_func = NULL;
+#if 0
+                       ib_mad_send(mad);
+#else
+                       printk(KERN_ERR "mthca_snoop_mad:
ib_mad_send\n");
+#endif
                }
 
-               return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
+               return IB_SNOOP_MAD_CONSUMED;
        }
+       return IB_SNOOP_MAD_IGNORED;
+}
 
+int mthca_process_mad(struct ib_device *ibdev,
+                     int mad_flags,
+                     u8 port_num,
+                     u16 slid,
+                     struct ib_mad *in_mad,
+                     struct ib_mad *out_mad)
+{
+       int err;
+       u8 status;
+
        /*
         * Only handle SM gets, sets and trap represses for SM class
         *




More information about the openib-general mailing list