]> err.no Git - linux-2.6/commitdiff
[IB] Add MAD data field size definitions
authorSean Hefty <sean.hefty@intel.com>
Wed, 21 Sep 2005 19:31:26 +0000 (12:31 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 21 Sep 2005 19:31:26 +0000 (12:31 -0700)
Clean up code by using enums instead of hard-coded magic numbers.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/mad_rmpp.c
include/rdma/ib_mad.h

index 2bd8b1cc57c4c925fe8db42ecfb6c8a82797dc14..8f7cef0812f6a4836853dd72a6125ced6a559aba 100644 (file)
@@ -583,6 +583,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
 {
        struct ib_rmpp_mad *rmpp_mad;
        int timeout;
+       u32 paylen;
 
        rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr;
        ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
@@ -590,11 +591,9 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
 
        if (mad_send_wr->seg_num == 1) {
                rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST;
-               rmpp_mad->rmpp_hdr.paylen_newwin =
-                       cpu_to_be32(mad_send_wr->total_seg *
-                                   (sizeof(struct ib_rmpp_mad) -
-                                      offsetof(struct ib_rmpp_mad, data)) -
-                                   mad_send_wr->pad);
+               paylen = mad_send_wr->total_seg * IB_MGMT_RMPP_DATA -
+                        mad_send_wr->pad;
+               rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
                mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad);
        } else {
                mad_send_wr->send_wr.num_sge = 2;
@@ -608,10 +607,8 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
 
        if (mad_send_wr->seg_num == mad_send_wr->total_seg) {
                rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST;
-               rmpp_mad->rmpp_hdr.paylen_newwin =
-                       cpu_to_be32(sizeof(struct ib_rmpp_mad) -
-                                   offsetof(struct ib_rmpp_mad, data) -
-                                   mad_send_wr->pad);
+               paylen = IB_MGMT_RMPP_DATA - mad_send_wr->pad;
+               rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
        }
 
        /* 2 seconds for an ACK until we can find the packet lifetime */
index 53184a38fdf64c5cee649dc482ab2fc656a936cf..0e293fe733b0e2924bfc6ca23c2e33fc044de9f4 100644 (file)
 #define IB_QP1_QKEY    0x80010000
 #define IB_QP_SET_QKEY 0x80000000
 
+enum {
+       IB_MGMT_MAD_DATA = 232,
+       IB_MGMT_RMPP_DATA = 220,
+       IB_MGMT_VENDOR_DATA = 216,
+       IB_MGMT_SA_DATA = 200
+};
+
 struct ib_mad_hdr {
        u8      base_version;
        u8      mgmt_class;
@@ -149,20 +156,20 @@ struct ib_sa_hdr {
 
 struct ib_mad {
        struct ib_mad_hdr       mad_hdr;
-       u8                      data[232];
+       u8                      data[IB_MGMT_MAD_DATA];
 };
 
 struct ib_rmpp_mad {
        struct ib_mad_hdr       mad_hdr;
        struct ib_rmpp_hdr      rmpp_hdr;
-       u8                      data[220];
+       u8                      data[IB_MGMT_RMPP_DATA];
 };
 
 struct ib_sa_mad {
        struct ib_mad_hdr       mad_hdr;
        struct ib_rmpp_hdr      rmpp_hdr;
        struct ib_sa_hdr        sa_hdr;
-       u8                      data[200];
+       u8                      data[IB_MGMT_SA_DATA];
 } __attribute__ ((packed));
 
 struct ib_vendor_mad {
@@ -170,7 +177,7 @@ struct ib_vendor_mad {
        struct ib_rmpp_hdr      rmpp_hdr;
        u8                      reserved;
        u8                      oui[3];
-       u8                      data[216];
+       u8                      data[IB_MGMT_VENDOR_DATA];
 };
 
 struct ib_class_port_info