[openib-general] [PATCH] define SMP attributes in ib_smi.h
Sean Hefty
mshefty at ichips.intel.com
Mon Dec 13 15:37:11 PST 2004
This patch defines SMP attribute values in ib_smi.h. (I use these in madeye.)
It removes/replaces the SMP attribute enums from mthca. There is also a minor
change from using cpu_to_be32 to __constant_htonl to allow using #define's in
switch statements.
- Sean
Index: include/ib_mad.h
===================================================================
--- include/ib_mad.h (revision 1324)
+++ include/ib_mad.h (working copy)
@@ -60,7 +60,7 @@
#define IB_MGMT_MAX_METHODS 128
#define IB_QP0 0
-#define IB_QP1 cpu_to_be32(1)
+#define IB_QP1 __constant_htonl(1)
#define IB_QP1_QKEY 0x80010000
struct ib_grh {
Index: include/ib_smi.h
===================================================================
--- include/ib_smi.h (revision 1324)
+++ include/ib_smi.h (working copy)
@@ -56,7 +56,25 @@
u8 return_path[IB_SMP_MAX_PATH_HOPS];
} __attribute__ ((packed));
-#define IB_SMP_DIRECTION cpu_to_be16(0x8000)
+#define IB_SMP_DIRECTION __constant_htons(0x8000)
+
+/* Subnet management attributes */
+#define IB_SMP_ATTR_NOTICE __constant_htons(0x0002)
+#define IB_SMP_ATTR_NODE_DESC __constant_htons(0x0010)
+#define IB_SMP_ATTR_NODE_INFO __constant_htons(0x0011)
+#define IB_SMP_ATTR_SWITCH_INFO __constant_htons(0x0012)
+#define IB_SMP_ATTR_GUID_INFO __constant_htons(0x0014)
+#define IB_SMP_ATTR_PORT_INFO __constant_htons(0x0015)
+#define IB_SMP_ATTR_PKEY_TABLE __constant_htons(0x0016)
+#define IB_SMP_ATTR_SL_TO_VL_TABLE __constant_htons(0x0017)
+#define IB_SMP_ATTR_VL_ARB_TABLE __constant_htons(0x0018)
+#define IB_SMP_ATTR_LINEAR_FORWARD_TABLE __constant_htons(0x0019)
+#define IB_SMP_ATTR_RANDOM_FORWARD_TABLE __constant_htons(0x001A)
+#define IB_SMP_ATTR_MCAST_FORWARD_TABLE __constant_htons(0x001B)
+#define IB_SMP_ATTR_SM_INFO __constant_htons(0x0020)
+#define IB_SMP_ATTR_VENDOR_DIAG __constant_htons(0x0030)
+#define IB_SMP_ATTR_LED_INFO __constant_htons(0x0031)
+#define IB_SMP_ATTR_VENDOR_MASK __constant_htons(0xFF00)
static inline u8
ib_get_smp_direction(struct ib_smp *smp)
Index: hw/mthca/mthca_provider.c
===================================================================
--- hw/mthca/mthca_provider.c (revision 1324)
+++ hw/mthca/mthca_provider.c (working copy)
@@ -22,18 +22,11 @@
*/
#include <ib_mad.h>
+#include <ib_smi.h>
#include "mthca_dev.h"
#include "mthca_cmd.h"
-/* Temporary until we get core support straightened out */
-enum {
- IB_SMP_ATTRIB_NODE_INFO = 0x0011,
- IB_SMP_ATTRIB_GUID_INFO = 0x0014,
- IB_SMP_ATTRIB_PORT_INFO = 0x0015,
- IB_SMP_ATTRIB_PKEY_TABLE = 0x0016
-};
-
static int mthca_query_device(struct ib_device *ibdev,
struct ib_device_attr *props)
{
@@ -54,7 +47,7 @@
in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->mad_hdr.class_version = 1;
in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- in_mad->mad_hdr.attr_id = cpu_to_be16(IB_SMP_ATTRIB_NODE_INFO);
+ in_mad->mad_hdr.attr_id = IB_SMP_ATTR_NODE_INFO;
err = mthca_MAD_IFC(to_mdev(ibdev), 1,
1, in_mad, out_mad,
@@ -98,7 +91,7 @@
in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->mad_hdr.class_version = 1;
in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- in_mad->mad_hdr.attr_id = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
+ in_mad->mad_hdr.attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->mad_hdr.attr_mod = cpu_to_be32(port);
err = mthca_MAD_IFC(to_mdev(ibdev), 1,
@@ -152,7 +145,7 @@
in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->mad_hdr.class_version = 1;
in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- in_mad->mad_hdr.attr_id = cpu_to_be16(IB_SMP_ATTRIB_PKEY_TABLE);
+ in_mad->mad_hdr.attr_id = IB_SMP_ATTR_PKEY_TABLE;
in_mad->mad_hdr.attr_mod = cpu_to_be32(index / 32);
err = mthca_MAD_IFC(to_mdev(ibdev), 1,
@@ -191,7 +184,7 @@
in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->mad_hdr.class_version = 1;
in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- in_mad->mad_hdr.attr_id = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
+ in_mad->mad_hdr.attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->mad_hdr.attr_mod = cpu_to_be32(port);
err = mthca_MAD_IFC(to_mdev(ibdev), 1,
@@ -211,7 +204,7 @@
in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->mad_hdr.class_version = 1;
in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- in_mad->mad_hdr.attr_id = cpu_to_be16(IB_SMP_ATTRIB_GUID_INFO);
+ in_mad->mad_hdr.attr_id = IB_SMP_ATTR_GUID_INFO;
in_mad->mad_hdr.attr_mod = cpu_to_be32(index / 8);
err = mthca_MAD_IFC(to_mdev(ibdev), 1,
Index: hw/mthca/mthca_mad.c
===================================================================
--- hw/mthca/mthca_mad.c (revision 1324)
+++ hw/mthca/mthca_mad.c (working copy)
@@ -23,18 +23,12 @@
#include <ib_verbs.h>
#include <ib_mad.h>
+#include <ib_smi.h>
#include "mthca_dev.h"
#include "mthca_cmd.h"
enum {
- IB_SM_PORT_INFO = 0x0015,
- IB_SM_PKEY_TABLE = 0x0016,
- IB_SM_SM_INFO = 0x0020,
- IB_SM_VENDOR_START = 0xff00
-};
-
-enum {
MTHCA_VENDOR_CLASS1 = 0x9,
MTHCA_VENDOR_CLASS2 = 0xa
};
@@ -84,7 +78,7 @@
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 == cpu_to_be16(IB_SM_PORT_INFO)) {
+ if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {
update_sm_ah(to_mdev(ibdev), port_num,
be16_to_cpup((__be16 *) (mad->data + 58)),
(*(u8 *) (mad->data + 76)) & 0xf);
@@ -95,7 +89,7 @@
ib_dispatch_event(&event);
}
- if (mad->mad_hdr.attr_id == cpu_to_be16(IB_SM_PKEY_TABLE)) {
+ 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;
@@ -211,8 +205,9 @@
* Don't process SMInfo queries or vendor-specific
* MADs -- the SMA can't handle them.
*/
- if (be16_to_cpu(in_mad->mad_hdr.attr_id) == IB_SM_SM_INFO ||
- be16_to_cpu(in_mad->mad_hdr.attr_id) >= IB_SM_VENDOR_START)
+ 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 == MTHCA_VENDOR_CLASS1 ||
More information about the general
mailing list