mlx4/mthca: define common vendor mgmt class
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 12 May 2009 17:23:03 +0000 (17:23 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 12 May 2009 17:23:03 +0000 (17:23 +0000)
Replace the separate MLX4 and MTHCA vendor MAD classes with common
MLX vendor classes.  This more easily allows us to determine if a vendor
defined management class should be routed to the HCA driver or dispatched
to a MAD client.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2172 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/ib/mad.c
hw/mthca/kernel/mthca_mad.c
inc/iba/ib_types.h

index 4a055d9..09f6869 100644 (file)
-/*
- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
- *
- * 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 from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * 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.
- */
-
-#include <mlx4_debug.h>
-#include "mlx4_ib.h"
-#include <ib_mad.h>
-#include <ib_smi.h>
-#include "cmd.h"
-
-#if defined(EVENT_TRACING)
-#ifdef offsetof
-#undef offsetof
-#endif
-#include "mad.tmh"
-#endif
-
-
-enum {
-       MLX4_IB_VENDOR_CLASS1 = 0x9,
-       MLX4_IB_VENDOR_CLASS2 = 0xa
-};
-
-int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int ignore_mkey, int ignore_bkey,
-                int port, ib_wc_t *in_wc, struct ib_grh *in_grh,
-                void *in_mad, void *response_mad)
-{
-       struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
-       u8 *inbox;
-       int err;
-       u32 in_modifier = port;
-       u8 op_modifier = 0;
-
-       inmailbox = mlx4_alloc_cmd_mailbox(dev->dev);
-       if (IS_ERR(inmailbox))
-               return PTR_ERR(inmailbox);
-       inbox = inmailbox->buf;
-
-       outmailbox = mlx4_alloc_cmd_mailbox(dev->dev);
-       if (IS_ERR(outmailbox)) {
-               mlx4_free_cmd_mailbox(dev->dev, inmailbox);
-               return PTR_ERR(outmailbox);
-       }
-
-       memcpy(inbox, in_mad, 256);
-
-       /*
-        * Key check traps can't be generated unless we have in_wc to
-        * tell us where to send the trap.
-        */
-       if (ignore_mkey || !in_wc)
-               op_modifier |= 0x1;
-       if (ignore_bkey || !in_wc)
-               op_modifier |= 0x2;
-
-       if (in_wc) {
-               struct {
-                       __be32          my_qpn;
-                       u32             reserved1;
-                       __be32          rqpn;
-                       u8              sl;
-                       u8              g_path;
-                       u16             reserved2[2];
-                       __be16          pkey;
-                       u32             reserved3[11];
-                       u8              grh[40];
-               } *ext_info;
-
-               memset(inbox + 256, 0, 256);
-               ext_info = (void*)(inbox + 256);
-
-               ext_info->rqpn   = in_wc->recv.ud.remote_qp;
-               ext_info->sl     = in_wc->recv.ud.remote_sl << 4;
-               ext_info->g_path = in_wc->recv.ud.path_bits |
-                       (in_wc->recv.ud.recv_opt & IB_RECV_OPT_GRH_VALID ? 0x80 : 0);
-               ext_info->pkey   = cpu_to_be16(in_wc->recv.ud.pkey_index);
-
-               if (in_grh)
-                       memcpy(ext_info->grh, in_grh, 40);
-
-               op_modifier |= 0x4;
-
-               in_modifier |= be16_to_cpu(in_wc->recv.ud.remote_lid) << 16;
-       }
-
-       err = mlx4_cmd_box(dev->dev, inmailbox->dma.da, outmailbox->dma.da,
-                          in_modifier, op_modifier,
-                          MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);
-
-       if (!err)
-               memcpy(response_mad, outmailbox->buf, 256);
-
-//     mlx4_dbg( dev->dev, "[MLX4_BUS] mlx4_MAD_IFC : port %d, err %d \n", port, err );
-
-       mlx4_free_cmd_mailbox(dev->dev, inmailbox);
-       mlx4_free_cmd_mailbox(dev->dev, outmailbox);
-
-       return err;
-}
-
-static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
-{
-       struct ib_ah *new_ah;
-       struct ib_ah_attr ah_attr;
-
-       if (!dev->send_agent[port_num - 1][0])
-               return;
-
-       memset(&ah_attr, 0, sizeof ah_attr);
-       ah_attr.dlid     = lid;
-       ah_attr.sl       = sl;
-       ah_attr.port_num = port_num;
-
-       new_ah = ib_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
-                             &ah_attr);
-       if (IS_ERR(new_ah))
-               return;
-
-       spin_lock(&dev->sm_lock);
-       if (dev->sm_ah[port_num - 1])
-               ib_destroy_ah(dev->sm_ah[port_num - 1]);
-       dev->sm_ah[port_num - 1] = new_ah;
-       spin_unlock(&dev->sm_lock);
-}
-
-/*
- * Snoop SM MADs for port info and P_Key table sets, so we can
- * synthesize LID change and P_Key change events.
- */
-static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad)
-{
-       struct ib_event event;
-
-       if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-            mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
-           mad->mad_hdr.method == IB_MGMT_METHOD_SET) {
-               if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {
-                       struct ib_port_info *pinfo =
-                               (struct ib_port_info *) ((struct ib_smp *) mad)->data;
-
-                       update_sm_ah(to_mdev(ibdev), port_num,
-                                    be16_to_cpu(pinfo->sm_lid),
-                                    pinfo->neighbormtu_mastersmsl & 0xf);
-
-                       event.device           = ibdev;
-                       event.element.port_num = port_num;
-
-                       if(pinfo->clientrereg_resv_subnetto & 0x80)
-                               event.event    = IB_EVENT_CLIENT_REREGISTER;
-                       else
-                               event.event    = IB_EVENT_LID_CHANGE;
-
-                       ib_dispatch_event(&event);
-               }
-
-               if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PKEY_TABLE) {
-                       event.device           = ibdev;
-                       event.event            = IB_EVENT_PKEY_CHANGE;
-                       event.element.port_num = port_num;
-                       ib_dispatch_event(&event);
-               }
-       }
-}
-
-static void node_desc_override(struct ib_device *dev,
-                              struct ib_mad *mad)
-{
-       if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-            mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
-           mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
-           mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
-               spin_lock(&to_mdev(dev)->sm_lock);
-               memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
-               spin_unlock(&to_mdev(dev)->sm_lock);
-       }
-}
-
-int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags,        u8 port_num,
-                       ib_wc_t *in_wc, struct ib_grh *in_grh,
-                       struct ib_mad *in_mad, struct ib_mad *out_mad)
-{
-       u16 slid;
-       int err;
-
-       if (mlx4_is_barred(ibdev->dma_device))
-               return -EFAULT;
-
-       slid = in_wc ? be16_to_cpu(in_wc->recv.ud.remote_lid) : be16_to_cpu(XIB_LID_PERMISSIVE);
-
-       if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0) {
-               // we never comes here !
-               ASSERT(0);
-               MLX4_PRINT( TRACE_LEVEL_ERROR ,MLX4_DBG_MAD ,
-                       (" Received a trap from HCA, which is unexpected here !\n" ));
-               // forward_trap(to_mdev(ibdev), port_num, in_mad);
-               return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-       }
-
-       if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-           in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-               if (in_mad->mad_hdr.method   != IB_MGMT_METHOD_GET &&
-                   in_mad->mad_hdr.method   != IB_MGMT_METHOD_SET &&
-                   in_mad->mad_hdr.method   != IB_MGMT_METHOD_TRAP_REPRESS)
-                       return IB_MAD_RESULT_SUCCESS;
-
-               /*
-                * Don't process SMInfo queries or vendor-specific
-                * MADs -- the SMA can't handle them.
-                */
-               if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
-                   ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
-                    IB_SMP_ATTR_VENDOR_MASK))
-                       return IB_MAD_RESULT_SUCCESS;
-       } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
-                  in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1   ||
-                  in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS2) {
-               if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&
-                   in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET)
-                       return IB_MAD_RESULT_SUCCESS;
-       } else
-               return IB_MAD_RESULT_SUCCESS;
-
-       err = mlx4_MAD_IFC(to_mdev(ibdev),
-                          mad_flags & IB_MAD_IGNORE_MKEY,
-                          mad_flags & IB_MAD_IGNORE_BKEY,
-                          port_num, in_wc, in_grh, in_mad, out_mad);
-       if (err)
-               return IB_MAD_RESULT_FAILURE;
-
-       if (!out_mad->mad_hdr.status) {
-               smp_snoop(ibdev, port_num, in_mad);
-               node_desc_override(ibdev, out_mad);
-       }
-
-       /* set return bit in status of directed route responses */
-       if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
-               out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
-
-       if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
-               /* no response for trap repress */
-               return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-
-       return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
-}
+/*\r
+ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.\r
+ *\r
+ * This software is available to you under a choice of one of two\r
+ * licenses.  You may choose to be licensed under the terms of the GNU\r
+ * General Public License (GPL) Version 2, available from the file\r
+ * COPYING in the main directory of this source tree, or the\r
+ * OpenIB.org BSD license below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include <mlx4_debug.h>\r
+#include "mlx4_ib.h"\r
+#include <ib_mad.h>\r
+#include <ib_smi.h>\r
+#include "cmd.h"\r
+\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "mad.tmh"\r
+#endif\r
+\r
+\r
+int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int ignore_mkey, int ignore_bkey,\r
+                int port, ib_wc_t *in_wc, struct ib_grh *in_grh,\r
+                void *in_mad, void *response_mad)\r
+{\r
+       struct mlx4_cmd_mailbox *inmailbox, *outmailbox;\r
+       u8 *inbox;\r
+       int err;\r
+       u32 in_modifier = port;\r
+       u8 op_modifier = 0;\r
+\r
+       inmailbox = mlx4_alloc_cmd_mailbox(dev->dev);\r
+       if (IS_ERR(inmailbox))\r
+               return PTR_ERR(inmailbox);\r
+       inbox = inmailbox->buf;\r
+\r
+       outmailbox = mlx4_alloc_cmd_mailbox(dev->dev);\r
+       if (IS_ERR(outmailbox)) {\r
+               mlx4_free_cmd_mailbox(dev->dev, inmailbox);\r
+               return PTR_ERR(outmailbox);\r
+       }\r
+\r
+       memcpy(inbox, in_mad, 256);\r
+\r
+       /*\r
+        * Key check traps can't be generated unless we have in_wc to\r
+        * tell us where to send the trap.\r
+        */\r
+       if (ignore_mkey || !in_wc)\r
+               op_modifier |= 0x1;\r
+       if (ignore_bkey || !in_wc)\r
+               op_modifier |= 0x2;\r
+\r
+       if (in_wc) {\r
+               struct {\r
+                       __be32          my_qpn;\r
+                       u32             reserved1;\r
+                       __be32          rqpn;\r
+                       u8              sl;\r
+                       u8              g_path;\r
+                       u16             reserved2[2];\r
+                       __be16          pkey;\r
+                       u32             reserved3[11];\r
+                       u8              grh[40];\r
+               } *ext_info;\r
+\r
+               memset(inbox + 256, 0, 256);\r
+               ext_info = (void*)(inbox + 256);\r
+\r
+               ext_info->rqpn   = in_wc->recv.ud.remote_qp;\r
+               ext_info->sl     = in_wc->recv.ud.remote_sl << 4;\r
+               ext_info->g_path = in_wc->recv.ud.path_bits |\r
+                       (in_wc->recv.ud.recv_opt & IB_RECV_OPT_GRH_VALID ? 0x80 : 0);\r
+               ext_info->pkey   = cpu_to_be16(in_wc->recv.ud.pkey_index);\r
+\r
+               if (in_grh)\r
+                       memcpy(ext_info->grh, in_grh, 40);\r
+\r
+               op_modifier |= 0x4;\r
+\r
+               in_modifier |= be16_to_cpu(in_wc->recv.ud.remote_lid) << 16;\r
+       }\r
+\r
+       err = mlx4_cmd_box(dev->dev, inmailbox->dma.da, outmailbox->dma.da,\r
+                          in_modifier, op_modifier,\r
+                          MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);\r
+\r
+       if (!err)\r
+               memcpy(response_mad, outmailbox->buf, 256);\r
+\r
+//     mlx4_dbg( dev->dev, "[MLX4_BUS] mlx4_MAD_IFC : port %d, err %d \n", port, err );\r
+\r
+       mlx4_free_cmd_mailbox(dev->dev, inmailbox);\r
+       mlx4_free_cmd_mailbox(dev->dev, outmailbox);\r
+\r
+       return err;\r
+}\r
+\r
+static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)\r
+{\r
+       struct ib_ah *new_ah;\r
+       struct ib_ah_attr ah_attr;\r
+\r
+       if (!dev->send_agent[port_num - 1][0])\r
+               return;\r
+\r
+       memset(&ah_attr, 0, sizeof ah_attr);\r
+       ah_attr.dlid     = lid;\r
+       ah_attr.sl       = sl;\r
+       ah_attr.port_num = port_num;\r
+\r
+       new_ah = ib_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,\r
+                             &ah_attr);\r
+       if (IS_ERR(new_ah))\r
+               return;\r
+\r
+       spin_lock(&dev->sm_lock);\r
+       if (dev->sm_ah[port_num - 1])\r
+               ib_destroy_ah(dev->sm_ah[port_num - 1]);\r
+       dev->sm_ah[port_num - 1] = new_ah;\r
+       spin_unlock(&dev->sm_lock);\r
+}\r
+\r
+/*\r
+ * Snoop SM MADs for port info and P_Key table sets, so we can\r
+ * synthesize LID change and P_Key change events.\r
+ */\r
+static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad)\r
+{\r
+       struct ib_event event;\r
+\r
+       if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||\r
+            mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&\r
+           mad->mad_hdr.method == IB_MGMT_METHOD_SET) {\r
+               if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {\r
+                       struct ib_port_info *pinfo =\r
+                               (struct ib_port_info *) ((struct ib_smp *) mad)->data;\r
+\r
+                       update_sm_ah(to_mdev(ibdev), port_num,\r
+                                    be16_to_cpu(pinfo->sm_lid),\r
+                                    pinfo->neighbormtu_mastersmsl & 0xf);\r
+\r
+                       event.device           = ibdev;\r
+                       event.element.port_num = port_num;\r
+\r
+                       if(pinfo->clientrereg_resv_subnetto & 0x80)\r
+                               event.event    = IB_EVENT_CLIENT_REREGISTER;\r
+                       else\r
+                               event.event    = IB_EVENT_LID_CHANGE;\r
+\r
+                       ib_dispatch_event(&event);\r
+               }\r
+\r
+               if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PKEY_TABLE) {\r
+                       event.device           = ibdev;\r
+                       event.event            = IB_EVENT_PKEY_CHANGE;\r
+                       event.element.port_num = port_num;\r
+                       ib_dispatch_event(&event);\r
+               }\r
+       }\r
+}\r
+\r
+static void node_desc_override(struct ib_device *dev,\r
+                              struct ib_mad *mad)\r
+{\r
+       if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||\r
+            mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&\r
+           mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&\r
+           mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {\r
+               spin_lock(&to_mdev(dev)->sm_lock);\r
+               memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);\r
+               spin_unlock(&to_mdev(dev)->sm_lock);\r
+       }\r
+}\r
+\r
+int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags,        u8 port_num,\r
+                       ib_wc_t *in_wc, struct ib_grh *in_grh,\r
+                       struct ib_mad *in_mad, struct ib_mad *out_mad)\r
+{\r
+       u16 slid;\r
+       int err;\r
+\r
+       if (mlx4_is_barred(ibdev->dma_device))\r
+               return -EFAULT;\r
+\r
+       slid = in_wc ? be16_to_cpu(in_wc->recv.ud.remote_lid) : be16_to_cpu(XIB_LID_PERMISSIVE);\r
+\r
+       if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0) {\r
+               // we never comes here !\r
+               ASSERT(0);\r
+               MLX4_PRINT( TRACE_LEVEL_ERROR ,MLX4_DBG_MAD ,\r
+                       (" Received a trap from HCA, which is unexpected here !\n" ));\r
+               // forward_trap(to_mdev(ibdev), port_num, in_mad);\r
+               return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;\r
+       }\r
+\r
+       if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||\r
+           in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {\r
+               if (in_mad->mad_hdr.method   != IB_MGMT_METHOD_GET &&\r
+                   in_mad->mad_hdr.method   != IB_MGMT_METHOD_SET &&\r
+                   in_mad->mad_hdr.method   != IB_MGMT_METHOD_TRAP_REPRESS)\r
+                       return IB_MAD_RESULT_SUCCESS;\r
+\r
+               /*\r
+                * Don't process SMInfo queries or vendor-specific\r
+                * MADs -- the SMA can't handle them.\r
+                */\r
+               if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||\r
+                   ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==\r
+                    IB_SMP_ATTR_VENDOR_MASK))\r
+                       return IB_MAD_RESULT_SUCCESS;\r
+       } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||\r
+                  in_mad->mad_hdr.mgmt_class == IB_MLX_VENDOR_CLASS1   ||\r
+                  in_mad->mad_hdr.mgmt_class == IB_MLX_VENDOR_CLASS2) {\r
+               if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&\r
+                   in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET)\r
+                       return IB_MAD_RESULT_SUCCESS;\r
+       } else\r
+               return IB_MAD_RESULT_SUCCESS;\r
+\r
+       err = mlx4_MAD_IFC(to_mdev(ibdev),\r
+                          mad_flags & IB_MAD_IGNORE_MKEY,\r
+                          mad_flags & IB_MAD_IGNORE_BKEY,\r
+                          port_num, in_wc, in_grh, in_mad, out_mad);\r
+       if (err)\r
+               return IB_MAD_RESULT_FAILURE;\r
+\r
+       if (!out_mad->mad_hdr.status) {\r
+               smp_snoop(ibdev, port_num, in_mad);\r
+               node_desc_override(ibdev, out_mad);\r
+       }\r
+\r
+       /* set return bit in status of directed route responses */\r
+       if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)\r
+               out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);\r
+\r
+       if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)\r
+               /* no response for trap repress */\r
+               return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;\r
+\r
+       return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;\r
+}\r
index f001805..6c6c0e6 100644 (file)
 #endif\r
 #include "mthca_cmd.h"\r
 \r
-enum {\r
-       MTHCA_VENDOR_CLASS1 = 0x9,\r
-       MTHCA_VENDOR_CLASS2 = 0xa\r
-};\r
-\r
 struct mthca_trap_mad {\r
        struct scatterlist sg;\r
 };\r
@@ -231,8 +226,8 @@ int mthca_process_mad(struct ib_device *ibdev,
        } \r
        else {\r
                if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||\r
-                  in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1     ||\r
-                  in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {\r
+                  in_mad->mad_hdr.mgmt_class == IB_MLX_VENDOR_CLASS1     ||\r
+                  in_mad->mad_hdr.mgmt_class == IB_MLX_VENDOR_CLASS2) {\r
 \r
                        if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&\r
                            in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET) {\r
index 6d61ff6..390d3b2 100644 (file)
@@ -534,6 +534,9 @@ extern "C"
 #define IB_MCLASS_VENDOR_LOW_RANGE_MAX 0x0f\r
 /**********/\r
 \r
+#define IB_MLX_VENDOR_CLASS1 0x9\r
+#define IB_MLX_VENDOR_CLASS2 0xA\r
+\r
 /****d* IBA Base: Constants/IB_MCLASS_DEV_ADM\r
 * NAME\r
 *      IB_MCLASS_DEV_ADM\r