Skip to content

Commit aba457c

Browse files
larrchjgunthorpe
authored andcommitted
RDMA/hns: Support owner mode doorbell
The doorbell needs to store PI information into QPC, so the RoCEE should wait for the results of storing, that is, it needs two bus operations to complete a doorbell. When ROCEE is in SDI mode, multiple doorbells may be interlocked because the RoCEE can only handle bus operations serially. So a flag to mark if HIP09 is working in SDI mode is added. When the SDI flag is set, the ROCEE will ignore the PI information of the doorbell, continue to fetch wqe and verify its validity by it's owner_bit. Link: https://lore.kernel.org/r/1603195493-22741-1-git-send-email-liweihang@huawei.com Signed-off-by: Lang Cheng <chenglang@huawei.com> Signed-off-by: Weihang Li <liweihang@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent dae7a75 commit aba457c

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎drivers/infiniband/hw/hns/hns_roce_device.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ enum {
129129
SERV_TYPE_UD,
130130
};
131131

132-
enum {
132+
enum hns_roce_qp_caps {
133133
HNS_ROCE_QP_CAP_RQ_RECORD_DB = BIT(0),
134134
HNS_ROCE_QP_CAP_SQ_RECORD_DB = BIT(1),
135+
HNS_ROCE_QP_CAP_OWNER_DB = BIT(2),
135136
};
136137

137138
enum hns_roce_cq_flags {
@@ -221,6 +222,7 @@ enum {
221222
HNS_ROCE_CAP_FLAG_FRMR = BIT(8),
222223
HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL = BIT(9),
223224
HNS_ROCE_CAP_FLAG_ATOMIC = BIT(10),
225+
HNS_ROCE_CAP_FLAG_SDI_MODE = BIT(14),
224226
};
225227

226228
#define HNS_ROCE_DB_TYPE_COUNT 2

‎drivers/infiniband/hw/hns/hns_roce_hw_v2.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,6 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
474474
roce_set_bit(ud_sq_wqe->byte_4, V2_UD_SEND_WQE_BYTE_4_SE_S,
475475
(wr->send_flags & IB_SEND_SOLICITED) ? 1 : 0);
476476

477-
roce_set_bit(ud_sq_wqe->byte_4, V2_UD_SEND_WQE_BYTE_4_OWNER_S,
478-
owner_bit);
479-
480477
roce_set_field(ud_sq_wqe->byte_16, V2_UD_SEND_WQE_BYTE_16_PD_M,
481478
V2_UD_SEND_WQE_BYTE_16_PD_S, to_hr_pd(qp->ibqp.pd)->pdn);
482479

@@ -517,7 +514,18 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
517514

518515
set_extend_sge(qp, wr, &curr_idx, valid_num_sge);
519516

517+
/*
518+
* The pipeline can sequentially post all valid WQEs into WQ buffer,
519+
* including new WQEs waiting for the doorbell to update the PI again.
520+
* Therefore, the owner bit of WQE MUST be updated after all fields
521+
* and extSGEs have been written into DDR instead of cache.
522+
*/
523+
if (qp->en_flags & HNS_ROCE_QP_CAP_OWNER_DB)
524+
dma_wmb();
525+
520526
*sge_idx = curr_idx;
527+
roce_set_bit(ud_sq_wqe->byte_4, V2_UD_SEND_WQE_BYTE_4_OWNER_S,
528+
owner_bit);
521529

522530
return 0;
523531
}
@@ -591,17 +599,25 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
591599
roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_CQE_S,
592600
(wr->send_flags & IB_SEND_SIGNALED) ? 1 : 0);
593601

594-
roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_OWNER_S,
595-
owner_bit);
596-
597602
if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
598603
wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD)
599604
set_atomic_seg(wr, rc_sq_wqe, valid_num_sge);
600605
else if (wr->opcode != IB_WR_REG_MR)
601606
ret = set_rwqe_data_seg(&qp->ibqp, wr, rc_sq_wqe,
602607
&curr_idx, valid_num_sge);
603608

609+
/*
610+
* The pipeline can sequentially post all valid WQEs into WQ buffer,
611+
* including new WQEs waiting for the doorbell to update the PI again.
612+
* Therefore, the owner bit of WQE MUST be updated after all fields
613+
* and extSGEs have been written into DDR instead of cache.
614+
*/
615+
if (qp->en_flags & HNS_ROCE_QP_CAP_OWNER_DB)
616+
dma_wmb();
617+
604618
*sge_idx = curr_idx;
619+
roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_OWNER_S,
620+
owner_bit);
605621

606622
return ret;
607623
}

‎drivers/infiniband/hw/hns/hns_roce_qp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,9 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
725725
struct ib_device *ibdev = &hr_dev->ib_dev;
726726
int ret;
727727

728+
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SDI_MODE)
729+
hr_qp->en_flags |= HNS_ROCE_QP_CAP_OWNER_DB;
730+
728731
if (udata) {
729732
if (user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd)) {
730733
ret = hns_roce_db_map_user(uctx, udata, ucmd->sdb_addr,

0 commit comments

Comments
 (0)