[openib-general] [RFC] [PATCH] mad: Add RMPP support for additional management classes
Hal Rosenstock
halr at voltaire.com
Thu Mar 16 17:50:52 PST 2006
mad: Add RMPP support for additional management classes which support it
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: include/rdma/ib_mad.h
===================================================================
--- include/rdma/ib_mad.h (revision 5874)
+++ include/rdma/ib_mad.h (working copy)
@@ -55,6 +55,8 @@
#define IB_MGMT_CLASS_DEVICE_MGMT 0x06
#define IB_MGMT_CLASS_CM 0x07
#define IB_MGMT_CLASS_SNMP 0x08
+#define IB_MGMT_CLASS_DEVICE_ADM 0x10
+#define IB_MGMT_CLASS_BIS 0x12
#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
@@ -117,6 +119,8 @@ enum {
IB_MGMT_VENDOR_DATA = 216,
IB_MGMT_SA_HDR = 56,
IB_MGMT_SA_DATA = 200,
+ IB_MGMT_DEVICE_HDR = 64,
+ IB_MGMT_DEVICE_DATA = 192,
};
struct ib_mad_hdr {
@@ -613,6 +617,16 @@ struct ib_mad_send_buf * ib_create_send_
void *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num);
/**
+ * ib_get_rmpp_data_offset - returns the data offset for a given
+ * management class.
+ * @mgmt_class: management class
+ *
+ * This routine returns the data offset in the MAD for the management
+ * class requested.
+ */
+int ib_get_rmpp_data_offset(u8 mgmt_class);
+
+/**
* ib_free_send_mad - Returns data buffers used to send a MAD.
* @send_buf: Previously allocated send data buffer.
*/
Index: core/mad_rmpp.c
===================================================================
--- core/mad_rmpp.c (revision 5874)
+++ core/mad_rmpp.c (working copy)
@@ -100,15 +100,30 @@ void ib_cancel_rmpp_recvs(struct ib_mad_
}
}
-static int data_offset(u8 mgmt_class)
+int ib_get_rmpp_data_offset(u8 mgmt_class)
{
if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
return IB_MGMT_SA_HDR;
+ else if ((mgmt_class == IB_MGMT_CLASS_DEVICE_MGMT) ||
+ (mgmt_class == IB_MGMT_CLASS_DEVICE_ADM) ||
+ (mgmt_class == IB_MGMT_CLASS_BIS))
+ return IB_MGMT_DEVICE_HDR;
else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
(mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
return IB_MGMT_VENDOR_HDR;
else
+ return 0;
+}
+EXPORT_SYMBOL(ib_get_rmpp_data_offset);
+
+static int data_offset(u8 mgmt_class)
+{
+ int offset;
+
+ offset = ib_get_rmpp_data_offset(mgmt_class);
+ if (!offset)
return IB_MGMT_RMPP_HDR;
+ return offset;
}
static void format_ack(struct ib_mad_send_buf *msg,
Index: core/user_mad.c
===================================================================
--- core/user_mad.c (revision 5874)
+++ core/user_mad.c (working copy)
@@ -177,17 +177,6 @@ static int queue_packet(struct ib_umad_f
return ret;
}
-static int data_offset(u8 mgmt_class)
-{
- if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
- return IB_MGMT_SA_HDR;
- else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
- (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
- return IB_MGMT_VENDOR_HDR;
- else
- return IB_MGMT_RMPP_HDR;
-}
-
static void send_handler(struct ib_mad_agent *agent,
struct ib_mad_send_wc *send_wc)
{
@@ -283,7 +272,9 @@ static ssize_t copy_recv_mad(char __user
*/
return -ENOSPC;
}
- offset = data_offset(recv_buf->mad->mad_hdr.mgmt_class);
+ offset = ib_get_rmpp_data_offset(recv_buf->mad->mad_hdr.mgmt_class);
+ if (!offset)
+ offset = IB_MGMT_RMPP_HDR;
max_seg_payload = sizeof (struct ib_mad) - offset;
for (left = packet->length - seg_payload, buf += seg_payload;
@@ -441,14 +432,8 @@ static ssize_t ib_umad_write(struct file
}
rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
- if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
- hdr_len = IB_MGMT_SA_HDR;
- copy_offset = IB_MGMT_RMPP_HDR;
- rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE;
- } else if (rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START &&
- rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END) {
- hdr_len = IB_MGMT_VENDOR_HDR;
+ hdr_len = ib_get_rmpp_data_offset(rmpp_mad->mad_hdr.mgmt_class);
+ if (hdr_len) {
copy_offset = IB_MGMT_RMPP_HDR;
rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
IB_MGMT_RMPP_FLAG_ACTIVE;
More information about the general
mailing list