diff options
author | Eli Cohen <eli@mellanox.co.il> | 2010-02-08 06:40:37 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-02-24 17:54:10 -0500 |
commit | 920d706c892e8f8cfff95f46aeb95fc6344f0bd5 (patch) | |
tree | a4219e9b0bc285bb080b4239107cf9e391017c66 /drivers/infiniband | |
parent | ccbe9f0b11b137c9453771a7ca3bf417dc7ce152 (diff) |
IB/core: Fix and clean up ib_ud_header_init()
ib_ud_header_init() first clears header and then fills up the various
fields. Later on, it tests header->immediate_present, which it has
already cleared, so the condition is always false. Fix this by adding
an immediate_present parameter and setting header->immediate_present
as is done with grh_present. Also remove unused calculation of
header_len.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/ud_header.c | 14 | ||||
-rw-r--r-- | drivers/infiniband/hw/mlx4/qp.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 2 |
3 files changed, 6 insertions, 12 deletions
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c index 8ec7876bedc..650b501eb14 100644 --- a/drivers/infiniband/core/ud_header.c +++ b/drivers/infiniband/core/ud_header.c | |||
@@ -181,6 +181,7 @@ static const struct ib_field deth_table[] = { | |||
181 | * ib_ud_header_init - Initialize UD header structure | 181 | * ib_ud_header_init - Initialize UD header structure |
182 | * @payload_bytes:Length of packet payload | 182 | * @payload_bytes:Length of packet payload |
183 | * @grh_present:GRH flag (if non-zero, GRH will be included) | 183 | * @grh_present:GRH flag (if non-zero, GRH will be included) |
184 | * @immediate_present: specify if immediate data should be used | ||
184 | * @header:Structure to initialize | 185 | * @header:Structure to initialize |
185 | * | 186 | * |
186 | * ib_ud_header_init() initializes the lrh.link_version, lrh.link_next_header, | 187 | * ib_ud_header_init() initializes the lrh.link_version, lrh.link_next_header, |
@@ -191,21 +192,13 @@ static const struct ib_field deth_table[] = { | |||
191 | */ | 192 | */ |
192 | void ib_ud_header_init(int payload_bytes, | 193 | void ib_ud_header_init(int payload_bytes, |
193 | int grh_present, | 194 | int grh_present, |
195 | int immediate_present, | ||
194 | struct ib_ud_header *header) | 196 | struct ib_ud_header *header) |
195 | { | 197 | { |
196 | int header_len; | ||
197 | u16 packet_length; | 198 | u16 packet_length; |
198 | 199 | ||
199 | memset(header, 0, sizeof *header); | 200 | memset(header, 0, sizeof *header); |
200 | 201 | ||
201 | header_len = | ||
202 | IB_LRH_BYTES + | ||
203 | IB_BTH_BYTES + | ||
204 | IB_DETH_BYTES; | ||
205 | if (grh_present) { | ||
206 | header_len += IB_GRH_BYTES; | ||
207 | } | ||
208 | |||
209 | header->lrh.link_version = 0; | 202 | header->lrh.link_version = 0; |
210 | header->lrh.link_next_header = | 203 | header->lrh.link_next_header = |
211 | grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL; | 204 | grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL; |
@@ -231,7 +224,8 @@ void ib_ud_header_init(int payload_bytes, | |||
231 | 224 | ||
232 | header->lrh.packet_length = cpu_to_be16(packet_length); | 225 | header->lrh.packet_length = cpu_to_be16(packet_length); |
233 | 226 | ||
234 | if (header->immediate_present) | 227 | header->immediate_present = immediate_present; |
228 | if (immediate_present) | ||
235 | header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; | 229 | header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; |
236 | else | 230 | else |
237 | header->bth.opcode = IB_OPCODE_UD_SEND_ONLY; | 231 | header->bth.opcode = IB_OPCODE_UD_SEND_ONLY; |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 2a97c964b9e..a1823523d7a 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
@@ -1228,7 +1228,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr, | |||
1228 | for (i = 0; i < wr->num_sge; ++i) | 1228 | for (i = 0; i < wr->num_sge; ++i) |
1229 | send_size += wr->sg_list[i].length; | 1229 | send_size += wr->sg_list[i].length; |
1230 | 1230 | ||
1231 | ib_ud_header_init(send_size, mlx4_ib_ah_grh_present(ah), &sqp->ud_header); | 1231 | ib_ud_header_init(send_size, mlx4_ib_ah_grh_present(ah), 0, &sqp->ud_header); |
1232 | 1232 | ||
1233 | sqp->ud_header.lrh.service_level = | 1233 | sqp->ud_header.lrh.service_level = |
1234 | be32_to_cpu(ah->av.sl_tclass_flowlabel) >> 28; | 1234 | be32_to_cpu(ah->av.sl_tclass_flowlabel) >> 28; |
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index c10576fa60c..d2d172e6289 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -1494,7 +1494,7 @@ static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp, | |||
1494 | u16 pkey; | 1494 | u16 pkey; |
1495 | 1495 | ||
1496 | ib_ud_header_init(256, /* assume a MAD */ | 1496 | ib_ud_header_init(256, /* assume a MAD */ |
1497 | mthca_ah_grh_present(to_mah(wr->wr.ud.ah)), | 1497 | mthca_ah_grh_present(to_mah(wr->wr.ud.ah)), 0, |
1498 | &sqp->ud_header); | 1498 | &sqp->ud_header); |
1499 | 1499 | ||
1500 | err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header); | 1500 | err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header); |