diff options
author | Sean Hefty <sean.hefty@intel.com> | 2005-09-21 15:31:26 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-09-21 15:31:26 -0400 |
commit | 972d512a17c1bb7c4b784a9da2ca75745fcc6989 (patch) | |
tree | 91eb1a1a0c1affe19e23b15069b6a5fd86d3ca72 | |
parent | 2fe9f798ba3cf7c939e638b78f46975e79039978 (diff) |
[IB] Add MAD data field size definitions
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>
-rw-r--r-- | drivers/infiniband/core/mad_rmpp.c | 15 | ||||
-rw-r--r-- | include/rdma/ib_mad.h | 15 |
2 files changed, 17 insertions, 13 deletions
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 2bd8b1cc57c4..8f7cef0812f6 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c | |||
@@ -583,6 +583,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) | |||
583 | { | 583 | { |
584 | struct ib_rmpp_mad *rmpp_mad; | 584 | struct ib_rmpp_mad *rmpp_mad; |
585 | int timeout; | 585 | int timeout; |
586 | u32 paylen; | ||
586 | 587 | ||
587 | rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; | 588 | rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; |
588 | ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE); | 589 | 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) | |||
590 | 591 | ||
591 | if (mad_send_wr->seg_num == 1) { | 592 | if (mad_send_wr->seg_num == 1) { |
592 | rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST; | 593 | rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST; |
593 | rmpp_mad->rmpp_hdr.paylen_newwin = | 594 | paylen = mad_send_wr->total_seg * IB_MGMT_RMPP_DATA - |
594 | cpu_to_be32(mad_send_wr->total_seg * | 595 | mad_send_wr->pad; |
595 | (sizeof(struct ib_rmpp_mad) - | 596 | rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen); |
596 | offsetof(struct ib_rmpp_mad, data)) - | ||
597 | mad_send_wr->pad); | ||
598 | mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); | 597 | mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); |
599 | } else { | 598 | } else { |
600 | mad_send_wr->send_wr.num_sge = 2; | 599 | 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) | |||
608 | 607 | ||
609 | if (mad_send_wr->seg_num == mad_send_wr->total_seg) { | 608 | if (mad_send_wr->seg_num == mad_send_wr->total_seg) { |
610 | rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST; | 609 | rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST; |
611 | rmpp_mad->rmpp_hdr.paylen_newwin = | 610 | paylen = IB_MGMT_RMPP_DATA - mad_send_wr->pad; |
612 | cpu_to_be32(sizeof(struct ib_rmpp_mad) - | 611 | rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen); |
613 | offsetof(struct ib_rmpp_mad, data) - | ||
614 | mad_send_wr->pad); | ||
615 | } | 612 | } |
616 | 613 | ||
617 | /* 2 seconds for an ACK until we can find the packet lifetime */ | 614 | /* 2 seconds for an ACK until we can find the packet lifetime */ |
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h index 53184a38fdf6..0e293fe733b0 100644 --- a/include/rdma/ib_mad.h +++ b/include/rdma/ib_mad.h | |||
@@ -108,6 +108,13 @@ | |||
108 | #define IB_QP1_QKEY 0x80010000 | 108 | #define IB_QP1_QKEY 0x80010000 |
109 | #define IB_QP_SET_QKEY 0x80000000 | 109 | #define IB_QP_SET_QKEY 0x80000000 |
110 | 110 | ||
111 | enum { | ||
112 | IB_MGMT_MAD_DATA = 232, | ||
113 | IB_MGMT_RMPP_DATA = 220, | ||
114 | IB_MGMT_VENDOR_DATA = 216, | ||
115 | IB_MGMT_SA_DATA = 200 | ||
116 | }; | ||
117 | |||
111 | struct ib_mad_hdr { | 118 | struct ib_mad_hdr { |
112 | u8 base_version; | 119 | u8 base_version; |
113 | u8 mgmt_class; | 120 | u8 mgmt_class; |
@@ -149,20 +156,20 @@ struct ib_sa_hdr { | |||
149 | 156 | ||
150 | struct ib_mad { | 157 | struct ib_mad { |
151 | struct ib_mad_hdr mad_hdr; | 158 | struct ib_mad_hdr mad_hdr; |
152 | u8 data[232]; | 159 | u8 data[IB_MGMT_MAD_DATA]; |
153 | }; | 160 | }; |
154 | 161 | ||
155 | struct ib_rmpp_mad { | 162 | struct ib_rmpp_mad { |
156 | struct ib_mad_hdr mad_hdr; | 163 | struct ib_mad_hdr mad_hdr; |
157 | struct ib_rmpp_hdr rmpp_hdr; | 164 | struct ib_rmpp_hdr rmpp_hdr; |
158 | u8 data[220]; | 165 | u8 data[IB_MGMT_RMPP_DATA]; |
159 | }; | 166 | }; |
160 | 167 | ||
161 | struct ib_sa_mad { | 168 | struct ib_sa_mad { |
162 | struct ib_mad_hdr mad_hdr; | 169 | struct ib_mad_hdr mad_hdr; |
163 | struct ib_rmpp_hdr rmpp_hdr; | 170 | struct ib_rmpp_hdr rmpp_hdr; |
164 | struct ib_sa_hdr sa_hdr; | 171 | struct ib_sa_hdr sa_hdr; |
165 | u8 data[200]; | 172 | u8 data[IB_MGMT_SA_DATA]; |
166 | } __attribute__ ((packed)); | 173 | } __attribute__ ((packed)); |
167 | 174 | ||
168 | struct ib_vendor_mad { | 175 | struct ib_vendor_mad { |
@@ -170,7 +177,7 @@ struct ib_vendor_mad { | |||
170 | struct ib_rmpp_hdr rmpp_hdr; | 177 | struct ib_rmpp_hdr rmpp_hdr; |
171 | u8 reserved; | 178 | u8 reserved; |
172 | u8 oui[3]; | 179 | u8 oui[3]; |
173 | u8 data[216]; | 180 | u8 data[IB_MGMT_VENDOR_DATA]; |
174 | }; | 181 | }; |
175 | 182 | ||
176 | struct ib_class_port_info | 183 | struct ib_class_port_info |