Skip to content

Commit 0c4a0e2

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Update the data type of immediate data
Because the data structure of hip08 is little endian, it needs to fix the immediate field of wqe and cqe into __le32. Signed-off-by: Lijun Ou <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 73b4e1f commit 0c4a0e2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
272272
switch (wr->opcode) {
273273
case IB_WR_SEND_WITH_IMM:
274274
case IB_WR_RDMA_WRITE_WITH_IMM:
275-
ud_sq_wqe->immtdata = wr->ex.imm_data;
275+
ud_sq_wqe->immtdata =
276+
cpu_to_le32(be32_to_cpu(wr->ex.imm_data));
276277
break;
277278
default:
278279
ud_sq_wqe->immtdata = 0;
@@ -370,7 +371,8 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
370371
switch (wr->opcode) {
371372
case IB_WR_SEND_WITH_IMM:
372373
case IB_WR_RDMA_WRITE_WITH_IMM:
373-
rc_sq_wqe->immtdata = wr->ex.imm_data;
374+
rc_sq_wqe->immtdata =
375+
cpu_to_le32(be32_to_cpu(wr->ex.imm_data));
374376
break;
375377
case IB_WR_SEND_WITH_INV:
376378
rc_sq_wqe->inv_key =
@@ -2178,7 +2180,8 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *hr_cq,
21782180
case HNS_ROCE_V2_OPCODE_RDMA_WRITE_IMM:
21792181
wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
21802182
wc->wc_flags = IB_WC_WITH_IMM;
2181-
wc->ex.imm_data = cqe->immtdata;
2183+
wc->ex.imm_data =
2184+
cpu_to_be32(le32_to_cpu(cqe->immtdata));
21822185
break;
21832186
case HNS_ROCE_V2_OPCODE_SEND:
21842187
wc->opcode = IB_WC_RECV;
@@ -2187,7 +2190,8 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *hr_cq,
21872190
case HNS_ROCE_V2_OPCODE_SEND_WITH_IMM:
21882191
wc->opcode = IB_WC_RECV;
21892192
wc->wc_flags = IB_WC_WITH_IMM;
2190-
wc->ex.imm_data = cqe->immtdata;
2193+
wc->ex.imm_data =
2194+
cpu_to_be32(le32_to_cpu(cqe->immtdata));
21912195
break;
21922196
case HNS_ROCE_V2_OPCODE_SEND_WITH_INV:
21932197
wc->opcode = IB_WC_RECV;

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ struct hns_roce_v2_cqe {
772772
__le32 byte_4;
773773
union {
774774
__le32 rkey;
775-
__be32 immtdata;
775+
__le32 immtdata;
776776
};
777777
__le32 byte_12;
778778
__le32 byte_16;
@@ -930,7 +930,7 @@ struct hns_roce_v2_cq_db {
930930
struct hns_roce_v2_ud_send_wqe {
931931
__le32 byte_4;
932932
__le32 msg_len;
933-
__be32 immtdata;
933+
__le32 immtdata;
934934
__le32 byte_16;
935935
__le32 byte_20;
936936
__le32 byte_24;
@@ -1016,7 +1016,7 @@ struct hns_roce_v2_rc_send_wqe {
10161016
__le32 msg_len;
10171017
union {
10181018
__le32 inv_key;
1019-
__be32 immtdata;
1019+
__le32 immtdata;
10201020
};
10211021
__le32 byte_16;
10221022
__le32 byte_20;

0 commit comments

Comments
 (0)