Skip to content

Commit d9581bf

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Bugfix for atomic operation
The atomic operation not supported inline. Besides, the standard atomic operation only support a sge and the sge is placed in the wqe. Fix: 384f881("RDMA/hns: Add atomic support") Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent caf3e40 commit d9581bf

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,18 +467,14 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
467467
rc_sq_wqe->rkey =
468468
cpu_to_le32(atomic_wr(wr)->rkey);
469469
rc_sq_wqe->va =
470-
cpu_to_le32(atomic_wr(wr)->remote_addr);
471-
wqe += sizeof(struct hns_roce_v2_wqe_data_seg);
472-
set_atomic_seg(wqe, atomic_wr(wr));
470+
cpu_to_le64(atomic_wr(wr)->remote_addr);
473471
break;
474472
case IB_WR_ATOMIC_FETCH_AND_ADD:
475473
hr_op = HNS_ROCE_V2_WQE_OP_ATOM_FETCH_AND_ADD;
476474
rc_sq_wqe->rkey =
477475
cpu_to_le32(atomic_wr(wr)->rkey);
478476
rc_sq_wqe->va =
479-
cpu_to_le32(atomic_wr(wr)->remote_addr);
480-
wqe += sizeof(struct hns_roce_v2_wqe_data_seg);
481-
set_atomic_seg(wqe, atomic_wr(wr));
477+
cpu_to_le64(atomic_wr(wr)->remote_addr);
482478
break;
483479
case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
484480
hr_op =
@@ -497,10 +493,25 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
497493
V2_RC_SEND_WQE_BYTE_4_OPCODE_M,
498494
V2_RC_SEND_WQE_BYTE_4_OPCODE_S, hr_op);
499495

500-
ret = set_rwqe_data_seg(ibqp, wr, rc_sq_wqe, wqe,
501-
&sge_ind, bad_wr);
502-
if (ret)
503-
goto out;
496+
if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
497+
wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
498+
struct hns_roce_v2_wqe_data_seg *dseg;
499+
500+
dseg = wqe;
501+
set_data_seg_v2(dseg, wr->sg_list);
502+
wqe += sizeof(struct hns_roce_v2_wqe_data_seg);
503+
set_atomic_seg(wqe, atomic_wr(wr));
504+
roce_set_field(rc_sq_wqe->byte_16,
505+
V2_RC_SEND_WQE_BYTE_16_SGE_NUM_M,
506+
V2_RC_SEND_WQE_BYTE_16_SGE_NUM_S,
507+
wr->num_sge);
508+
} else {
509+
ret = set_rwqe_data_seg(ibqp, wr, rc_sq_wqe,
510+
wqe, &sge_ind, bad_wr);
511+
if (ret)
512+
goto out;
513+
}
514+
504515
ind++;
505516
} else {
506517
dev_err(dev, "Illegal qp_type(0x%x)\n", ibqp->qp_type);

0 commit comments

Comments
 (0)