RDMA/hns: Updates for 5.14
Subsystems (2)
cover RDMA/hns: Updates for 5.14
As usual, this series collects some miscellaneous fixes and cleanups at the end of 5.14 for the hns driver:
* #1 ~ #5 are fixes.
* #6 ~ #10 are some small cleanups.
Lang Cheng (2):
RDMA/hns: Force rewrite inline flag of WQE
RDMA/hns: Fix spelling mistakes of original
Wenpeng Liang (1):
RDMA/hns: Encapsulate flushing CQE as a function
Xi Wang (1):
RDMA/hns: Clean definitions of EQC structure
Yangyang Li (3):
RDMA/hns: Add member assignments for qp_init_attr RDMA/hns: Delete unnecessary branch of hns_roce_v2_query_qp RDMA/hns: Modify function return value type
Yixing Liu (3):
RDMA/hns: Fix uninitialized variable
RDMA/hns: Fix some print issues
RDMA/hns: Simplify the judgment in hns_roce_v2_post_send()
drivers/infiniband/hw/hns/hns_roce_device.h | 5 ++- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 60 ++++++++--------------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 19 ++------- drivers/infiniband/hw/hns/hns_roce_main.c | 8 +--- drivers/infiniband/hw/hns/hns_roce_mr.c | 4 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 27 +++++++++---- 6 files changed, 44 insertions(+), 79 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/10 RDMA/hns: Force rewrite inline flag of WQE
From: Lang Cheng <[email protected]>
When a non-inline WR reuses a WQE that was used for inline last time, the remaining inline flag should be cleared.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -2
@@ -274,8 +274,6 @@ static int set_rc_inl(struct hns_roce_qp *qp, const struct ib_send_wr *wr, dseg +=sizeof (struct hns_roce_v2_rc_send_wqe ); -roce_set_bit (rc_sq_wqe->byte_4,V2_RC_SEND_WQE_BYTE_4_INLINE_S ,1 ); -if (msg_len <=HNS_ROCE_V2_MAX_RC_INL_INN_SZ ) {roce_set_bit (rc_sq_wqe->byte_20,V2_RC_SEND_WQE_BYTE_20_INL_TYPE_S ,0 );
@@ -320,6 +318,8 @@ static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S , (*sge_ind) & (qp->sge.sge_cnt - 1)); +roce_set_bit (rc_sq_wqe->byte_4,V2_RC_SEND_WQE_BYTE_4_INLINE_S , + !!(wr->send_flags &IB_SEND_INLINE ));if (wr->send_flags &IB_SEND_INLINE )return set_rc_inl (qp, wr, rc_sq_wqe, sge_ind);
Signature · 1 line
2.7.4
PATCH 2/10 RDMA/hns: Fix uninitialized variable
In reply to Weihang LiFrom: Yixing Liu <[email protected]>
A random value will be returned if the condition below is not met, so it needs to be initialized.
--- drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_mr.c +1 -1
@@ -776,7 +776,7 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,struct ib_device *ibdev = &hr_dev->ib_dev;struct hns_roce_buf_region *r;unsigned int i, mapped_cnt; -int ret; +int ret =0 ;/* * Only use the first page address as root ba when hopnum is 0, this
Signature · 1 line
2.7.4
PATCH 3/10 RDMA/hns: Fix some print issues
In reply to Weihang LiFrom: Yixing Liu <[email protected]>
Remove redundant print and fix a character type mismatch.
--- drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_mr.c +1 -1
@@ -992,7 +992,7 @@ int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr, &buf_page_shift, udata ? user_addr & ~PAGE_MASK : 0);if (buf_page_cnt <1 || buf_page_shift <HNS_HW_PAGE_SHIFT ) { -ibdev_err (ibdev,"failed to init mtr cfg, count %d shift %d.\n" , +ibdev_err (ibdev,"failed to init mtr cfg, count %d shift %u.\n" , buf_page_cnt, buf_page_shift);return -EINVAL ; }
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -3
@@ -648,9 +648,7 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,if (!cap->max_send_wr || cap->max_send_wr > hr_dev->caps.max_wqes || cap->max_send_sge > hr_dev->caps.max_sq_sg) { -ibdev_err (ibdev, -"failed to check SQ WR or SGE num, ret = %d.\n" , - -EINVAL ); +ibdev_err (ibdev,"failed to check SQ WR or SGE num.\n" );return -EINVAL ; }
Signature · 1 line
2.7.4
PATCH 4/10 RDMA/hns: Add member assignments for qp_init_attr
In reply to Weihang LiFrom: Yangyang Li <[email protected]>
Some kernel ULPs need to use the return value of qp_init_attr, so add member assignments for qp_init_attr.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +5 -0
@@ -5411,6 +5411,11 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->cap.max_send_sge =0 ; } + qp_init_attr->qp_context = ibqp->qp_context; + qp_init_attr->qp_type = ibqp->qp_type; + qp_init_attr->recv_cq = ibqp->recv_cq; + qp_init_attr->send_cq = ibqp->send_cq; + qp_init_attr->srq = ibqp->srq; qp_init_attr->cap = qp_attr->cap; qp_init_attr->sq_sig_type = hr_qp->sq_signal_bits;
Signature · 1 line
2.7.4
PATCH 5/10 RDMA/hns: Delete unnecessary branch of hns_roce_v2_query_qp
In reply to Weihang LiFrom: Yangyang Li <[email protected]>
When query_qp is called by userspace, max_send_wr and max_send_sge are set to 0 by the kernel driver. However, the userspace does not use these two return values from the kernel driver, but uses its own calculated values. So there is no need for special treatment.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -7
@@ -5403,13 +5403,8 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->cap.max_recv_sge = hr_qp->rq.max_gs - hr_qp->rq.rsv_sge; qp_attr->cap.max_inline_data = hr_qp->max_inline_data; -if (!ibqp->uobject) { - qp_attr->cap.max_send_wr = hr_qp->sq.wqe_cnt; - qp_attr->cap.max_send_sge = hr_qp->sq.max_gs; - }else { - qp_attr->cap.max_send_wr =0 ; - qp_attr->cap.max_send_sge =0 ; - } + qp_attr->cap.max_send_wr = hr_qp->sq.wqe_cnt; + qp_attr->cap.max_send_sge = hr_qp->sq.max_gs; qp_init_attr->qp_context = ibqp->qp_context; qp_init_attr->qp_type = ibqp->qp_type;
Signature · 1 line
2.7.4
PATCH 6/10 RDMA/hns: Clean definitions of EQC structure
In reply to Weihang LiFrom: Xi Wang <[email protected]>
Remove unused members in EQ context structure.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +4 -15
@@ -1729,21 +1729,6 @@ struct hns_roce_v2_priv {struct hns_roce_link_table ext_llm; }; -struct hns_roce_eq_context { -__le32 byte_4; -__le32 byte_8; -__le32 byte_12; -__le32 eqe_report_timer; -__le32 eqe_ba0; -__le32 eqe_ba1; -__le32 byte_28; -__le32 byte_32; -__le32 byte_36; -__le32 byte_40; -__le32 byte_44; -__le32 rsv[5 ]; -}; -struct hns_roce_dip {u8 dgid[GID_LEN_V2 ];u8 dip_idx;
@@ -1805,6 +1790,10 @@ struct hns_roce_dip {#define HNS_ROCE_V2_VF_ABN_INT_CFG_M GENMASK(2, 0)#define HNS_ROCE_V2_VF_EVENT_INT_EN_M GENMASK(0, 0) +struct hns_roce_eq_context { +__le32 data[16 ]; +}; +#define EQC_FIELD_LOC (h, l) FIELD_LOC(struct hns_roce_eq_context, h, l)#define EQC_EQ_ST EQC_FIELD_LOC(1, 0)
Signature · 1 line
2.7.4
PATCH 7/10 RDMA/hns: Modify function return value type
In reply to Weihang LiFrom: Yangyang Li <[email protected]>
hns_roce_init_qp_table() will only return 0, because this function does not need to return a value, so it is modified to void type.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- drivers/infiniband/hw/hns/hns_roce_main.c | 8 +------- drivers/infiniband/hw/hns/hns_roce_qp.c | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -1
@@ -1144,7 +1144,7 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,int hns_roce_init_pd_table (struct hns_roce_dev *hr_dev);int hns_roce_init_mr_table (struct hns_roce_dev *hr_dev);void hns_roce_init_cq_table (struct hns_roce_dev *hr_dev); -int hns_roce_init_qp_table (struct hns_roce_dev *hr_dev); +void hns_roce_init_qp_table (struct hns_roce_dev *hr_dev);int hns_roce_init_srq_table (struct hns_roce_dev *hr_dev);int hns_roce_init_xrcd_table (struct hns_roce_dev *hr_dev);
drivers/infiniband/hw/hns/hns_roce_main.c +1 -7
@@ -771,11 +771,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)hns_roce_init_cq_table (hr_dev); - ret =hns_roce_init_qp_table (hr_dev); -if (ret) { -dev_err (dev,"Failed to init queue pair table.\n" ); - goto err_cq_table_free; - } +hns_roce_init_qp_table (hr_dev);if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_SRQ ) { ret =hns_roce_init_srq_table (hr_dev);
@@ -790,8 +786,6 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) err_qp_table_free:hns_roce_cleanup_qp_table (hr_dev); - -err_cq_table_free:hns_roce_cleanup_cq_table (hr_dev);hns_roce_cleanup_mr_table (hr_dev);
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -3
@@ -1414,7 +1414,7 @@ bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, u32 nreq,return cur + nreq >= hr_wq->wqe_cnt; } -int hns_roce_init_qp_table (struct hns_roce_dev *hr_dev) +void hns_roce_init_qp_table (struct hns_roce_dev *hr_dev) {struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;unsigned int reserved_from_bot;
@@ -1437,8 +1437,6 @@ int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev)HNS_ROCE_QP_BANK_NUM -1 ; hr_dev->qp_table.bank[i].next = hr_dev->qp_table.bank[i].min; } - -return 0 ; }void hns_roce_cleanup_qp_table (struct hns_roce_dev *hr_dev)
Signature · 1 line
2.7.4
PATCH 8/10 RDMA/hns: Encapsulate flushing CQE as a function
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
The process of flushing CQE can be encapsultated into a function, which can reduce duplicate code.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 1 + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 36 +++-------------------------- drivers/infiniband/hw/hns/hns_roce_qp.c | 19 +++++++++++++-- 3 files changed, 21 insertions(+), 35 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -0
@@ -1259,6 +1259,7 @@ void hns_roce_free_db(struct hns_roce_dev *hr_dev, struct hns_roce_db *db);void hns_roce_cq_completion (struct hns_roce_dev *hr_dev,u32 cqn);void hns_roce_cq_event (struct hns_roce_dev *hr_dev,u32 cqn,int event_type); +void flush_cqe (struct hns_roce_dev *dev,struct hns_roce_qp *qp);void hns_roce_qp_event (struct hns_roce_dev *hr_dev,u32 qpn,int event_type);void hns_roce_srq_event (struct hns_roce_dev *hr_dev,u32 srqn,int event_type);u8 hns_get_gid_index (struct hns_roce_dev *hr_dev,u32 port,int gid_index);
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -33
@@ -629,18 +629,8 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,static inline void update_sq_db (struct hns_roce_dev *hr_dev,struct hns_roce_qp *qp) { -/* -* Hip08 hardware cannot flush the WQEs in SQ if the QP state -* gets into errored mode. Hence, as a workaround to this -* hardware limitation, driver needs to assist in flushing. But -* the flushing operation uses mailbox to convey the QP state to -* the hardware and which can sleep due to the mutex protection -* around the mailbox calls. Hence, use the deferred flush for -* now. -*/ if (unlikely (qp->state ==IB_QPS_ERR )) { -if (!test_and_set_bit (HNS_ROCE_FLUSH_FLAG , &qp->flush_flag)) -init_flush_work (hr_dev, qp); +flush_cqe (hr_dev, qp); }else {struct hns_roce_v2_db sq_db = {};
@@ -663,18 +653,8 @@ static inline void update_sq_db(struct hns_roce_dev *hr_dev,static inline void update_rq_db (struct hns_roce_dev *hr_dev,struct hns_roce_qp *qp) { -/* -* Hip08 hardware cannot flush the WQEs in RQ if the QP state -* gets into errored mode. Hence, as a workaround to this -* hardware limitation, driver needs to assist in flushing. But -* the flushing operation uses mailbox to convey the QP state to -* the hardware and which can sleep due to the mutex protection -* around the mailbox calls. Hence, use the deferred flush for -* now. -*/ if (unlikely (qp->state ==IB_QPS_ERR )) { -if (!test_and_set_bit (HNS_ROCE_FLUSH_FLAG , &qp->flush_flag)) -init_flush_work (hr_dev, qp); +flush_cqe (hr_dev, qp); }else {if (likely (qp->en_flags &HNS_ROCE_QP_CAP_RQ_RECORD_DB )) { *qp->rdb.db_record =
@@ -3514,17 +3494,7 @@ static void get_cqe_status(struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp,if (cqe_status ==HNS_ROCE_CQE_V2_GENERAL_ERR )return ; -/* -* Hip08 hardware cannot flush the WQEs in SQ/RQ if the QP state gets -* into errored mode. Hence, as a workaround to this hardware -* limitation, driver needs to assist in flushing. But the flushing -* operation uses mailbox to convey the QP state to the hardware and -* which can sleep due to the mutex protection around the mailbox calls. -* Hence, use the deferred flush for now. Once wc error detected, the -* flushing operation is needed. -*/ -if (!test_and_set_bit (HNS_ROCE_FLUSH_FLAG , &qp->flush_flag)) -init_flush_work (hr_dev, qp); +flush_cqe (hr_dev, qp); } static int get_cur_qp(struct hns_roce_cq *hr_cq, struct hns_roce_v2_cqe *cqe,
drivers/infiniband/hw/hns/hns_roce_qp.c +17 -2
@@ -79,6 +79,21 @@ void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)queue_work (hr_dev->irq_workq, &flush_work->work); } +void flush_cqe (struct hns_roce_dev *dev,struct hns_roce_qp *qp) +{ +/* +* Hip08 hardware cannot flush the WQEs in SQ/RQ if the QP state +* gets into errored mode. Hence, as a workaround to this +* hardware limitation, driver needs to assist in flushing. But +* the flushing operation uses mailbox to convey the QP state to +* the hardware and which can sleep due to the mutex protection +* around the mailbox calls. Hence, use the deferred flush for +* now. +*/ +if (!test_and_set_bit (HNS_ROCE_FLUSH_FLAG , &qp->flush_flag)) +init_flush_work (dev, qp); +} +void hns_roce_qp_event (struct hns_roce_dev *hr_dev,u32 qpn,int event_type) {struct device *dev = hr_dev->dev;
@@ -102,8 +117,8 @@ void hns_roce_qp_event(struct hns_roce_dev *hr_dev, u32 qpn, int event_type) event_type == HNS_ROCE_EVENT_TYPE_XRCD_VIOLATION || event_type == HNS_ROCE_EVENT_TYPE_INVALID_XRCETH)) { qp->state =IB_QPS_ERR ; -if (!test_and_set_bit (HNS_ROCE_FLUSH_FLAG , &qp->flush_flag)) -init_flush_work (hr_dev, qp); + +flush_cqe (hr_dev, qp); } qp->event (qp, (enum hns_roce_event )event_type);
Signature · 1 line
2.7.4
PATCH 9/10 RDMA/hns: Simplify the judgment in hns_roce_v2_post_send()
In reply to Weihang LiFrom: Yixing Liu <[email protected]>
The QP type has been checked in check_send_valid(), if it's not RC, it will process the UD/GSI branch.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -3
@@ -755,10 +755,10 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, ~(((qp->sq.head + nreq) >>ilog2 (qp->sq.wqe_cnt)) &0x1 );/* Corresponding to the QP type, wqe process separately */ -if (ibqp->qp_type ==IB_QPT_GSI || ibqp->qp_type ==IB_QPT_UD ) - ret =set_ud_wqe (qp, wr, wqe, &sge_idx, owner_bit); -else if (ibqp->qp_type ==IB_QPT_RC ) +if (ibqp->qp_type ==IB_QPT_RC ) ret =set_rc_wqe (qp, wr, wqe, &sge_idx, owner_bit); +else + ret =set_ud_wqe (qp, wr, wqe, &sge_idx, owner_bit);if (unlikely (ret)) { *bad_wr = wr;
Signature · 1 line
2.7.4
PATCH 10/10 RDMA/hns: Fix spelling mistakes of original
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
'orignal' should be 'original'.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -1
@@ -336,7 +336,7 @@ struct hns_roce_mw {struct hns_roce_mr {struct ib_mr ibmr; -u64 iova;/* MR's virtual orignal addr */ +u64 iova;/* MR's virtual original addr */ u64 size;/* Address range of MR */ u32 key;/* Key of MR */ u32 pd;/* PD num of MR */
Signature · 1 line
2.7.4
Quoted 20 lines · Weihang Li
As usual, this series collects some miscellaneous fixes and cleanups at the end of 5.14 for the hns driver:
* #1 ~ #5 are fixes.
* #6 ~ #10 are some small cleanups.Lang Cheng (2):
RDMA/hns: Force rewrite inline flag of WQE
RDMA/hns: Fix spelling mistakes of originalWenpeng Liang (1):
RDMA/hns: Encapsulate flushing CQE as a functionXi Wang (1):
RDMA/hns: Clean definitions of EQC structureYangyang Li (3):
RDMA/hns: Add member assignments forqp_init_attrRDMA/hns: Delete unnecessary branch ofhns_roce_v2_query_qpRDMA/hns: Modify function return value type
Quoted 4 lines
Yixing Liu (3):
RDMA/hns: Fix uninitialized variable
RDMA/hns: Fix some print issues
RDMA/hns: Simplify the judgment inhns_roce_v2_post_send()
Applied to for-next, thanks
Jason