mad: Add RMPP support for additional management classes which support it

Signed-off-by: Hal Rosenstock <[EMAIL PROTECTED]>

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,16 +100,21 @@ 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 IB_MGMT_RMPP_HDR;
 }
+EXPORT_SYMBOL(ib_get_rmpp_data_offset);
 
 static void format_ack(struct ib_mad_send_buf *msg,
                       struct ib_rmpp_mad *data,
@@ -137,7 +142,7 @@ static void ack_recv(struct mad_rmpp_rec
        struct ib_mad_send_buf *msg;
        int ret, hdr_len;
 
-       hdr_len = data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
+       hdr_len = 
ib_get_rmpp_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
        msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
                                 recv_wc->wc->pkey_index, 1, hdr_len,
                                 0, GFP_KERNEL);
@@ -163,7 +168,7 @@ static struct ib_mad_send_buf *alloc_res
        if (IS_ERR(ah))
                return (void *) ah;
 
-       hdr_len = data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
+       hdr_len = 
ib_get_rmpp_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
        msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
                                 recv_wc->wc->pkey_index, 1,
                                 hdr_len, 0, GFP_KERNEL);
@@ -408,7 +413,7 @@ static inline int get_mad_len(struct mad
 
        rmpp_mad = (struct ib_rmpp_mad *)rmpp_recv->cur_seg_buf->mad;
 
-       hdr_size = data_offset(rmpp_mad->mad_hdr.mgmt_class);
+       hdr_size = ib_get_rmpp_data_offset(rmpp_mad->mad_hdr.mgmt_class);
        data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
        pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
        if (pad > IB_MGMT_RMPP_DATA || pad < 0)
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,7 @@ 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);
                max_seg_payload = sizeof (struct ib_mad) - offset;
 
                for (left = packet->length - seg_payload, buf += seg_payload;
@@ -441,21 +430,15 @@ 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;
-               copy_offset = IB_MGMT_RMPP_HDR;
-               rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
-                             IB_MGMT_RMPP_FLAG_ACTIVE;
-       } else {
+       hdr_len = ib_get_rmpp_data_offset(rmpp_mad->mad_hdr.mgmt_class);
+       if (hdr_len == IB_MGMT_RMPP_HDR) {
                hdr_len = IB_MGMT_MAD_HDR;
                copy_offset = IB_MGMT_MAD_HDR;
                rmpp_active = 0;
+       } else {
+               copy_offset = IB_MGMT_RMPP_HDR;
+               rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+                             IB_MGMT_RMPP_FLAG_ACTIVE;
        }
 
        data_len = count - sizeof (struct ib_user_mad) - hdr_len;



_______________________________________________
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to