RDMA/hns: Misc updates for 5.13
Subsystems (2)
cover RDMA/hns: Misc updates for 5.13
There are some cleanups for the -next branch as usual:
- #1, #2 fix issues about inline.
- #3 ~ #6 remove some dead code and redunant check.
- #7 ~ #9 are miscellaneous changes.
Lang Cheng (1):
RDMA/hns: Prevent le32 from being implicitly converted to u32
Weihang Li (2):
RDMA/hns: Avoid enabling RQ inline on UD RDMA/hns: Fix missing assignment of max_inline_data
Wenpeng Liang (3):
RDMA/hns: Delete redundant abnormal interrupt status RDMA/hns: Remove unsupported QP types RDMA/hns: Add XRC subtype in QPC and XRC type in SRQC
Yangyang Li (2):
RDMA/hns: Delete redundant condition judgment related to eq RDMA/hns: Delete unused members in the structure hns_roce_hw
Yixing Liu (1):
RDMA/hns: Simplify the function config_eqc()
drivers/infiniband/hw/hns/hns_roce_common.h | 15 +- drivers/infiniband/hw/hns/hns_roce_device.h | 16 -- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 9 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 220 ++++++++-------------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 116 ++++----------- drivers/infiniband/hw/hns/hns_roce_qp.c | 6 +- 6 files changed, 105 insertions(+), 277 deletions(-)
Signature · 1 line
2.8.1
PATCH 1/9 RDMA/hns: Avoid enabling RQ inline on UD
RQ inline is not supported on UD/GSI QP, it should be disabled in QPC.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 +++++-- drivers/infiniband/hw/hns/hns_roce_qp.c | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +5 -2
@@ -4106,8 +4106,11 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp, ((u32)hr_qp->rdb.dma) >> 1); context->rq_db_record_addr =cpu_to_le32 (hr_qp->rdb.dma >>32 ); -roce_set_bit (context->byte_76_srqn_op_en,V2_QPC_BYTE_76_RQIE_S , - (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_RQ_INLINE ) ?1 :0 ); +if (ibqp->qp_type !=IB_QPT_UD && ibqp->qp_type !=IB_QPT_GSI ) +roce_set_bit (context->byte_76_srqn_op_en, +V2_QPC_BYTE_76_RQIE_S , + !!(hr_dev->caps.flags & +HNS_ROCE_CAP_FLAG_RQ_INLINE ));roce_set_field (context->byte_80_rnr_rx_cqn,V2_QPC_BYTE_80_RX_CQN_M ,V2_QPC_BYTE_80_RX_CQN_S ,get_cqn (ibqp->recv_cq));
drivers/infiniband/hw/hns/hns_roce_qp.c +3 -1
@@ -487,7 +487,9 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap, hr_qp->rq.max_gs); hr_qp->rq.wqe_cnt = cnt; -if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_RQ_INLINE ) +if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_RQ_INLINE && + hr_qp->ibqp.qp_type !=IB_QPT_UD && + hr_qp->ibqp.qp_type !=IB_QPT_GSI ) hr_qp->rq_inl_buf.wqe_cnt = cnt;else hr_qp->rq_inl_buf.wqe_cnt =0 ;
Signature · 1 line
2.8.1
PATCH 2/9 RDMA/hns: Fix missing assignment of max_inline_data
In reply to Weihang LiWhen querying QP, the ULPs should be informed of the max length of inline data supported by the hardware.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -0
@@ -5376,6 +5376,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->cur_qp_state = qp_attr->qp_state; qp_attr->cap.max_recv_wr = hr_qp->rq.wqe_cnt; 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;
Signature · 1 line
2.8.1
PATCH 3/9 RDMA/hns: Delete redundant condition judgment related to eq
In reply to Weihang LiFrom: Yangyang Li <[email protected]>
The register value related to the eq interrupt depends only on enable_flag, so the redundant condition judgment is deleted.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +6 -21
@@ -6058,31 +6058,16 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id) }static void hns_roce_v2_int_mask_enable (struct hns_roce_dev *hr_dev, -int eq_num,int enable_flag) +int eq_num,u32 enable_flag) {int i; -if (enable_flag ==EQ_ENABLE ) { -for (i =0 ; i < eq_num; i++) -roce_write (hr_dev,ROCEE_VF_EVENT_INT_EN_REG + - i *EQ_REG_OFFSET , -HNS_ROCE_V2_VF_EVENT_INT_EN_M ); - -roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , -HNS_ROCE_V2_VF_ABN_INT_EN_M ); -roce_write (hr_dev,ROCEE_VF_ABN_INT_CFG_REG , -HNS_ROCE_V2_VF_ABN_INT_CFG_M ); - }else { -for (i =0 ; i < eq_num; i++) -roce_write (hr_dev,ROCEE_VF_EVENT_INT_EN_REG + - i *EQ_REG_OFFSET , -HNS_ROCE_V2_VF_EVENT_INT_EN_M &0x0 ); +for (i =0 ; i < eq_num; i++) +roce_write (hr_dev,ROCEE_VF_EVENT_INT_EN_REG + + i *EQ_REG_OFFSET , enable_flag); -roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , -HNS_ROCE_V2_VF_ABN_INT_EN_M &0x0 ); -roce_write (hr_dev,ROCEE_VF_ABN_INT_CFG_REG , -HNS_ROCE_V2_VF_ABN_INT_CFG_M &0x0 ); - } +roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , enable_flag); +roce_write (hr_dev,ROCEE_VF_ABN_INT_CFG_REG , enable_flag); }static void hns_roce_v2_destroy_eqc (struct hns_roce_dev *hr_dev,int eqn)
Signature · 1 line
2.8.1
PATCH 4/9 RDMA/hns: Delete redundant abnormal interrupt status
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
The hardware supports only two types of abnormal interrupts.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 19 +++++-------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 3 +-- 2 files changed, 6 insertions(+), 16 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +5 -14
@@ -6031,28 +6031,19 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , int_en); int_work =1 ; - }else if (int_st &BIT (HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S )) { -dev_err (dev,"BUS ERR!\n" ); + }else if (int_st &BIT (HNS_ROCE_V2_VF_INT_ST_RAS_INT_S )) { +dev_err (dev,"RAS interrupt!\n" ); - int_st |=1 <<HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S ; + int_st |=1 <<HNS_ROCE_V2_VF_INT_ST_RAS_INT_S ;roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , int_st); int_en |=1 <<HNS_ROCE_V2_VF_ABN_INT_EN_S ;roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , int_en); int_work =1 ; - }else if (int_st &BIT (HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S )) { -dev_err (dev,"OTHER ERR!\n" ); - - int_st |=1 <<HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S ; -roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , int_st); - - int_en |=1 <<HNS_ROCE_V2_VF_ABN_INT_EN_S ; -roce_write (hr_dev,ROCEE_VF_ABN_INT_EN_REG , int_en); - - int_work =1 ; - }else + }else {dev_err (dev,"There is no abnormal irq found!\n" ); + }return IRQ_RETVAL (int_work); }
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +1 -2
@@ -1956,8 +1956,7 @@ struct hns_roce_dip {#define HNS_ROCE_V2_ASYNC_EQE_NUM 0x1000#define HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S 0 -#define HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S 1 -#define HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S 2 +#define HNS_ROCE_V2_VF_INT_ST_RAS_INT_S 1#define HNS_ROCE_EQ_DB_CMD_AEQ 0x0#define HNS_ROCE_EQ_DB_CMD_AEQ_ARMED 0x1
Signature · 1 line
2.8.1
PATCH 5/9 RDMA/hns: Delete unused members in the structure hns_roce_hw
In reply to Weihang LiFrom: Yangyang Li <[email protected]>
Some structure members in hns_roce_hw have never been used and need to be deleted.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 16 ---------------- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 6 ------ drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 10 ---------- 3 files changed, 32 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +0 -16
@@ -914,33 +914,17 @@ struct hns_roce_hw {int (*clear_hem)(struct hns_roce_dev *hr_dev,struct hns_roce_hem_table *table,int obj,int step_idx); -int (*query_qp)(struct ib_qp *ibqp,struct ib_qp_attr *qp_attr, -int qp_attr_mask,struct ib_qp_init_attr *qp_init_attr);int (*modify_qp)(struct ib_qp *ibqp,const struct ib_qp_attr *attr,int attr_mask,enum ib_qp_state cur_state,enum ib_qp_state new_state); -int (*destroy_qp)(struct ib_qp *ibqp,struct ib_udata *udata);int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev,struct hns_roce_qp *hr_qp); -int (*post_send)(struct ib_qp *ibqp,const struct ib_send_wr *wr, -const struct ib_send_wr **bad_wr); -int (*post_recv)(struct ib_qp *qp,const struct ib_recv_wr *recv_wr, -const struct ib_recv_wr **bad_recv_wr); -int (*req_notify_cq)(struct ib_cq *ibcq,enum ib_cq_notify_flags flags); -int (*poll_cq)(struct ib_cq *ibcq,int num_entries,struct ib_wc *wc);int (*dereg_mr)(struct hns_roce_dev *hr_dev,struct hns_roce_mr *mr,struct ib_udata *udata);int (*destroy_cq)(struct ib_cq *ibcq,struct ib_udata *udata); -int (*modify_cq)(struct ib_cq *cq,u16 cq_count,u16 cq_period);int (*init_eq)(struct hns_roce_dev *hr_dev);void (*cleanup_eq)(struct hns_roce_dev *hr_dev);int (*write_srqc)(struct hns_roce_srq *srq,void *mb_buf); -int (*modify_srq)(struct ib_srq *ibsrq,struct ib_srq_attr *srq_attr, -enum ib_srq_attr_mask srq_attr_mask, -struct ib_udata *udata); -int (*query_srq)(struct ib_srq *ibsrq,struct ib_srq_attr *attr); -int (*post_srq_recv)(struct ib_srq *ibsrq,const struct ib_recv_wr *wr, -const struct ib_recv_wr **bad_wr);const struct ib_device_ops *hns_roce_dev_ops;const struct ib_device_ops *hns_roce_dev_srq_ops; };
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +0 -6
@@ -4357,12 +4357,6 @@ static const struct hns_roce_hw hns_roce_hw_v1 = { .write_cqc = hns_roce_v1_write_cqc, .clear_hem = hns_roce_v1_clear_hem, .modify_qp = hns_roce_v1_modify_qp, - .query_qp = hns_roce_v1_query_qp, - .destroy_qp = hns_roce_v1_destroy_qp, - .post_send = hns_roce_v1_post_send, - .post_recv = hns_roce_v1_post_recv, - .req_notify_cq = hns_roce_v1_req_notify_cq, - .poll_cq = hns_roce_v1_poll_cq, .dereg_mr = hns_roce_v1_dereg_mr, .destroy_cq = hns_roce_v1_destroy_cq, .init_eq = hns_roce_v1_init_eq_table,
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -10
@@ -6514,20 +6514,10 @@ static const struct hns_roce_hw hns_roce_hw_v2 = { .set_hem = hns_roce_v2_set_hem, .clear_hem = hns_roce_v2_clear_hem, .modify_qp = hns_roce_v2_modify_qp, - .query_qp = hns_roce_v2_query_qp, - .destroy_qp = hns_roce_v2_destroy_qp, .qp_flow_control_init = hns_roce_v2_qp_flow_control_init, - .modify_cq = hns_roce_v2_modify_cq, - .post_send = hns_roce_v2_post_send, - .post_recv = hns_roce_v2_post_recv, - .req_notify_cq = hns_roce_v2_req_notify_cq, - .poll_cq = hns_roce_v2_poll_cq, .init_eq = hns_roce_v2_init_eq_table, .cleanup_eq = hns_roce_v2_cleanup_eq_table, .write_srqc = hns_roce_v2_write_srqc, - .modify_srq = hns_roce_v2_modify_srq, - .query_srq = hns_roce_v2_query_srq, - .post_srq_recv = hns_roce_v2_post_srq_recv, .hns_roce_dev_ops = &hns_roce_v2_dev_ops, .hns_roce_dev_srq_ops = &hns_roce_v2_dev_srq_ops, };
Signature · 1 line
2.8.1
PATCH 6/9 RDMA/hns: Remove unsupported QP types
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
The hns ROCEE does not support UC QP currently.
--- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 3 +-- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 - drivers/infiniband/hw/hns/hns_roce_qp.c | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +1 -2
@@ -3449,8 +3449,7 @@ static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, ((roce_get_bit (context->qpc_bytes_4,QP_CONTEXT_QPC_BYTE_4_ATOMIC_OPERATION_ENABLE_S )) <<3 ); -if (hr_qp->ibqp.qp_type ==IB_QPT_RC || - hr_qp->ibqp.qp_type ==IB_QPT_UC ) { +if (hr_qp->ibqp.qp_type ==IB_QPT_RC ) {struct ib_global_route *grh =rdma_ah_retrieve_grh (&qp_attr->ah_attr);
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -1
@@ -5324,7 +5324,6 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, V2_QPC_BYTE_76_ATE_S)) << V2_QP_ATE_S);if (hr_qp->ibqp.qp_type ==IB_QPT_RC || - hr_qp->ibqp.qp_type ==IB_QPT_UC || hr_qp->ibqp.qp_type ==IB_QPT_XRC_INI || hr_qp->ibqp.qp_type ==IB_QPT_XRC_TGT ) { struct ib_global_route *grh =
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -2
@@ -1189,8 +1189,6 @@ int to_hr_qp_type(int qp_type)switch (qp_type) {case IB_QPT_RC :return SERV_TYPE_RC ; -case IB_QPT_UC : -return SERV_TYPE_UC ;case IB_QPT_UD :case IB_QPT_GSI :return SERV_TYPE_UD ;
Signature · 1 line
2.8.1
PATCH 7/9 RDMA/hns: Add XRC subtype in QPC and XRC type in SRQC
In reply to Weihang LiFrom: Wenpeng Liang <[email protected]>
A field to distuiguish basic SRQ from XRC SRQ in SRQC and a field in QPC to determine whether a QP is XRC TGT QP or XRC INI QP are missing.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 13 +++++++------ drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 5 ++++- 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +7 -6
@@ -4093,9 +4093,13 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,roce_set_field (context->byte_24_mtu_tc,V2_QPC_BYTE_24_VLAN_ID_M ,V2_QPC_BYTE_24_VLAN_ID_S ,0xfff ); -if (ibqp->qp_type ==IB_QPT_XRC_TGT ) +if (ibqp->qp_type ==IB_QPT_XRC_TGT ) { context->qkey_xrcd =cpu_to_le32 (hr_qp->xrcdn); +roce_set_bit (context->byte_80_rnr_rx_cqn, +V2_QPC_BYTE_80_XRC_QP_TYPE_S ,1 ); + } +if (hr_qp->en_flags &HNS_ROCE_QP_CAP_RQ_RECORD_DB )roce_set_bit (context->byte_68_rq_db,V2_QPC_BYTE_68_RQ_RECORD_EN_S ,1 );
@@ -4153,11 +4157,6 @@ static void modify_qp_init_to_init(struct ib_qp *ibqp,roce_set_field (qpc_mask->byte_4_sqpn_tst,V2_QPC_BYTE_4_TST_M ,V2_QPC_BYTE_4_TST_S ,0 ); -if (ibqp->qp_type ==IB_QPT_XRC_TGT ) { - context->qkey_xrcd =cpu_to_le32 (hr_qp->xrcdn); - qpc_mask->qkey_xrcd =0 ; - } -roce_set_field (context->byte_16_buf_ba_pg_sz,V2_QPC_BYTE_16_PD_M ,V2_QPC_BYTE_16_PD_S ,get_pdn (ibqp->pd));
@@ -5590,6 +5589,8 @@ static int hns_roce_v2_write_srqc(struct hns_roce_srq *srq, void *mb_buf) }hr_reg_write (ctx,SRQC_SRQ_ST ,1 ); +hr_reg_write (ctx,SRQC_SRQ_TYPE , + !!(srq->ibsrq.srq_type ==IB_SRQT_XRC ));hr_reg_write (ctx,SRQC_PD ,to_hr_pd (srq->ibsrq.pd)->pdn);hr_reg_write (ctx,SRQC_SRQN , srq->srqn);hr_reg_write (ctx,SRQC_XRCD , srq->xrcdn);
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +4 -1
@@ -404,7 +404,8 @@ struct hns_roce_srq_context {#define SRQC_CONSUMER_IDX SRQC_FIELD_LOC(127, 112)#define SRQC_WQE_BT_BA_L SRQC_FIELD_LOC(159, 128)#define SRQC_WQE_BT_BA_H SRQC_FIELD_LOC(188, 160) -#define SRQC_RSV2 SRQC_FIELD_LOC(191, 189) +#define SRQC_RSV2 SRQC_FIELD_LOC(190, 189) +#define SRQC_SRQ_TYPE SRQC_FIELD_LOC(191, 191)#define SRQC_PD SRQC_FIELD_LOC(215, 192)#define SRQC_RQWS SRQC_FIELD_LOC(219, 216)#define SRQC_RSV3 SRQC_FIELD_LOC(223, 220)
@@ -704,6 +705,8 @@ struct hns_roce_v2_qp_context {#define V2_QPC_BYTE_80_RX_CQN_S 0#define V2_QPC_BYTE_80_RX_CQN_M GENMASK(23, 0) +#define V2_QPC_BYTE_80_XRC_QP_TYPE_S 24 +#define V2_QPC_BYTE_80_MIN_RNR_TIME_S 27#define V2_QPC_BYTE_80_MIN_RNR_TIME_M GENMASK(31, 27)
Signature · 1 line
2.8.1
PATCH 8/9 RDMA/hns: Simplify the function config_eqc()
In reply to Weihang LiFrom: Yixing Liu <[email protected]>
Use "hr_reg_write" replace "roce_set_filed".
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 142 ++++++++--------------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 108 ++++++---------------- 2 files changed, 65 insertions(+), 185 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +39 -103
@@ -6083,6 +6083,16 @@ static void free_eq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)hns_roce_mtr_destroy (hr_dev, &eq->mtr); } +static void init_eq_config (struct hns_roce_dev *hr_dev,struct hns_roce_eq *eq) +{ + eq->db_reg = hr_dev->reg_base +ROCEE_VF_EQ_DB_CFG0_REG ; + eq->cons_index =0 ; + eq->over_ignore =HNS_ROCE_V2_EQ_OVER_IGNORE_0 ; + eq->coalesce =HNS_ROCE_V2_EQ_COALESCE_0 ; + eq->arm_st =HNS_ROCE_V2_EQ_ALWAYS_ARMED ; + eq->shift =ilog2 ((unsigned int )eq->entries); +} +static int config_eqc (struct hns_roce_dev *hr_dev,struct hns_roce_eq *eq,void *mb_buf) {
@@ -6094,13 +6104,7 @@ static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq, eqc = mb_buf;memset (eqc,0 ,sizeof (struct hns_roce_eq_context )); -/* init eqc */ - eq->db_reg = hr_dev->reg_base +ROCEE_VF_EQ_DB_CFG0_REG ; - eq->cons_index =0 ; - eq->over_ignore =HNS_ROCE_V2_EQ_OVER_IGNORE_0 ; - eq->coalesce =HNS_ROCE_V2_EQ_COALESCE_0 ; - eq->arm_st =HNS_ROCE_V2_EQ_ALWAYS_ARMED ; - eq->shift =ilog2 ((unsigned int )eq->entries); +init_eq_config (hr_dev, eq);/* if not multi-hop, eqe buffer only use one trunk */ count = hns_roce_mtr_find(hr_dev, &eq->mtr, 0, eqe_ba, MTT_MIN_COUNT,
@@ -6110,102 +6114,34 @@ static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq,return -ENOBUFS ; } -/* set eqc state */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_EQ_ST_M ,HNS_ROCE_EQC_EQ_ST_S , -HNS_ROCE_V2_EQ_STATE_VALID ); - -/* set eqe hop num */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_HOP_NUM_M , -HNS_ROCE_EQC_HOP_NUM_S , eq->hop_num); - -/* set eqc over_ignore */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_OVER_IGNORE_M , -HNS_ROCE_EQC_OVER_IGNORE_S , eq->over_ignore); - -/* set eqc coalesce */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_COALESCE_M , -HNS_ROCE_EQC_COALESCE_S , eq->coalesce); - -/* set eqc arm_state */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_ARM_ST_M , -HNS_ROCE_EQC_ARM_ST_S , eq->arm_st); - -/* set eqn */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_EQN_M ,HNS_ROCE_EQC_EQN_S , - eq->eqn); - -/* set eqe_cnt */ -roce_set_field (eqc->byte_4,HNS_ROCE_EQC_EQE_CNT_M , -HNS_ROCE_EQC_EQE_CNT_S ,HNS_ROCE_EQ_INIT_EQE_CNT ); - -/* set eqe_ba_pg_sz */ -roce_set_field (eqc->byte_8,HNS_ROCE_EQC_BA_PG_SZ_M , -HNS_ROCE_EQC_BA_PG_SZ_S , -to_hr_hw_page_shift (eq->mtr.hem_cfg.ba_pg_shift)); - -/* set eqe_buf_pg_sz */ -roce_set_field (eqc->byte_8,HNS_ROCE_EQC_BUF_PG_SZ_M , -HNS_ROCE_EQC_BUF_PG_SZ_S , -to_hr_hw_page_shift (eq->mtr.hem_cfg.buf_pg_shift)); - -/* set eq_producer_idx */ -roce_set_field (eqc->byte_8,HNS_ROCE_EQC_PROD_INDX_M , -HNS_ROCE_EQC_PROD_INDX_S ,HNS_ROCE_EQ_INIT_PROD_IDX ); - -/* set eq_max_cnt */ -roce_set_field (eqc->byte_12,HNS_ROCE_EQC_MAX_CNT_M , -HNS_ROCE_EQC_MAX_CNT_S , eq->eq_max_cnt); - -/* set eq_period */ -roce_set_field (eqc->byte_12,HNS_ROCE_EQC_PERIOD_M , -HNS_ROCE_EQC_PERIOD_S , eq->eq_period); - -/* set eqe_report_timer */ -roce_set_field (eqc->eqe_report_timer,HNS_ROCE_EQC_REPORT_TIMER_M , -HNS_ROCE_EQC_REPORT_TIMER_S , -HNS_ROCE_EQ_INIT_REPORT_TIMER ); - -/* set bt_ba [34:3] */ -roce_set_field (eqc->eqe_ba0,HNS_ROCE_EQC_EQE_BA_L_M , -HNS_ROCE_EQC_EQE_BA_L_S , bt_ba >>3 ); - -/* set bt_ba [64:35] */ -roce_set_field (eqc->eqe_ba1,HNS_ROCE_EQC_EQE_BA_H_M , -HNS_ROCE_EQC_EQE_BA_H_S , bt_ba >>35 ); - -/* set eq shift */ -roce_set_field (eqc->byte_28,HNS_ROCE_EQC_SHIFT_M ,HNS_ROCE_EQC_SHIFT_S , - eq->shift); - -/* set eq MSI_IDX */ -roce_set_field (eqc->byte_28,HNS_ROCE_EQC_MSI_INDX_M , -HNS_ROCE_EQC_MSI_INDX_S ,HNS_ROCE_EQ_INIT_MSI_IDX ); - -/* set cur_eqe_ba [27:12] */ -roce_set_field (eqc->byte_28,HNS_ROCE_EQC_CUR_EQE_BA_L_M , -HNS_ROCE_EQC_CUR_EQE_BA_L_S , eqe_ba[0 ] >>12 ); - -/* set cur_eqe_ba [59:28] */ -roce_set_field (eqc->byte_32,HNS_ROCE_EQC_CUR_EQE_BA_M_M , -HNS_ROCE_EQC_CUR_EQE_BA_M_S , eqe_ba[0 ] >>28 ); - -/* set cur_eqe_ba [63:60] */ -roce_set_field (eqc->byte_36,HNS_ROCE_EQC_CUR_EQE_BA_H_M , -HNS_ROCE_EQC_CUR_EQE_BA_H_S , eqe_ba[0 ] >>60 ); - -/* set eq consumer idx */ -roce_set_field (eqc->byte_36,HNS_ROCE_EQC_CONS_INDX_M , -HNS_ROCE_EQC_CONS_INDX_S ,HNS_ROCE_EQ_INIT_CONS_IDX ); - -roce_set_field (eqc->byte_40,HNS_ROCE_EQC_NXT_EQE_BA_L_M , -HNS_ROCE_EQC_NXT_EQE_BA_L_S , eqe_ba[1 ] >>12 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_NXT_EQE_BA_H_M , -HNS_ROCE_EQC_NXT_EQE_BA_H_S , eqe_ba[1 ] >>44 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_EQE_SIZE_M , -HNS_ROCE_EQC_EQE_SIZE_S , - eq->eqe_size ==HNS_ROCE_V3_EQE_SIZE ?1 :0 ); +hr_reg_write (eqc,EQC_EQ_ST ,HNS_ROCE_V2_EQ_STATE_VALID ); +hr_reg_write (eqc,EQC_EQE_HOP_NUM , eq->hop_num); +hr_reg_write (eqc,EQC_OVER_IGNORE , eq->over_ignore); +hr_reg_write (eqc,EQC_COALESCE , eq->coalesce); +hr_reg_write (eqc,EQC_ARM_ST , eq->arm_st); +hr_reg_write (eqc,EQC_EQN , eq->eqn); +hr_reg_write (eqc,EQC_EQE_CNT ,HNS_ROCE_EQ_INIT_EQE_CNT ); +hr_reg_write (eqc,EQC_EQE_BA_PG_SZ , +to_hr_hw_page_shift (eq->mtr.hem_cfg.ba_pg_shift)); +hr_reg_write (eqc,EQC_EQE_BUF_PG_SZ , +to_hr_hw_page_shift (eq->mtr.hem_cfg.buf_pg_shift)); +hr_reg_write (eqc,EQC_EQ_PROD_INDX ,HNS_ROCE_EQ_INIT_PROD_IDX ); +hr_reg_write (eqc,EQC_EQ_MAX_CNT , eq->eq_max_cnt); + +hr_reg_write (eqc,EQC_EQ_PERIOD , eq->eq_period); +hr_reg_write (eqc,EQC_EQE_REPORT_TIMER ,HNS_ROCE_EQ_INIT_REPORT_TIMER ); +hr_reg_write (eqc,EQC_EQE_BA_L , bt_ba >>3 ); +hr_reg_write (eqc,EQC_EQE_BA_H , bt_ba >>35 ); +hr_reg_write (eqc,EQC_SHIFT , eq->shift); +hr_reg_write (eqc,EQC_MSI_INDX ,HNS_ROCE_EQ_INIT_MSI_IDX ); +hr_reg_write (eqc,EQC_CUR_EQE_BA_L , eqe_ba[0 ] >>12 ); +hr_reg_write (eqc,EQC_CUR_EQE_BA_M , eqe_ba[0 ] >>28 ); +hr_reg_write (eqc,EQC_CUR_EQE_BA_H , eqe_ba[0 ] >>60 ); +hr_reg_write (eqc,EQC_EQ_CONS_INDX ,HNS_ROCE_EQ_INIT_CONS_IDX ); +hr_reg_write (eqc,EQC_NEX_EQE_BA_L , eqe_ba[1 ] >>12 ); +hr_reg_write (eqc,EQC_NEX_EQE_BA_H , eqe_ba[1 ] >>44 ); +hr_reg_write (eqc,EQC_EQE_SIZE , + !!(eq->eqe_size ==HNS_ROCE_V3_EQE_SIZE ));return 0 ; }
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +26 -82
114 lines not on this page · raw message
Signature · 1 line
2.8.1
Jason Gunthorpe
maintainerRe: [PATCH for-next 8/9] RDMA/hns: Simplify the function config_eqc()
drivers/infiniband/hw/hns/hns_roce_hw_v2.c static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq, · line 6120
Quoted 13 lines · Weihang Li
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +4
-9-roce_set_field (eqc->byte_40,HNS_ROCE_EQC_NXT_EQE_BA_L_M , -HNS_ROCE_EQC_NXT_EQE_BA_L_S , eqe_ba[1 ] >>12 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_NXT_EQE_BA_H_M , -HNS_ROCE_EQC_NXT_EQE_BA_H_S , eqe_ba[1 ] >>44 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_EQE_SIZE_M , -HNS_ROCE_EQC_EQE_SIZE_S , - eq->eqe_size ==HNS_ROCE_V3_EQE_SIZE ?1 :0 ); +hr_reg_write (eqc,EQC_EQ_ST ,HNS_ROCE_V2_EQ_STATE_VALID ); +hr_reg_write (eqc,EQC_EQE_HOP_NUM , eq->hop_num); +hr_reg_write (eqc,EQC_OVER_IGNORE , eq->over_ignore); +hr_reg_write (eqc,EQC_COALESCE , eq->coalesce);
This really is a lot better like this, isn't it?
Jason
Re: [PATCH for-next 8/9] RDMA/hns: Simplify the function config_eqc()
Quoted 17 lines · Jason Gunthorpe
drivers/infiniband/hw/hns/hns_roce_hw_v2.c static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq, · line 6120
Quoted 13 lines · Weihang Li
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +4
-9-roce_set_field (eqc->byte_40,HNS_ROCE_EQC_NXT_EQE_BA_L_M , -HNS_ROCE_EQC_NXT_EQE_BA_L_S , eqe_ba[1 ] >>12 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_NXT_EQE_BA_H_M , -HNS_ROCE_EQC_NXT_EQE_BA_H_S , eqe_ba[1 ] >>44 ); - -roce_set_field (eqc->byte_44,HNS_ROCE_EQC_EQE_SIZE_M , -HNS_ROCE_EQC_EQE_SIZE_S , - eq->eqe_size ==HNS_ROCE_V3_EQE_SIZE ?1 :0 ); +hr_reg_write (eqc,EQC_EQ_ST ,HNS_ROCE_V2_EQ_STATE_VALID ); +hr_reg_write (eqc,EQC_EQE_HOP_NUM , eq->hop_num); +hr_reg_write (eqc,EQC_OVER_IGNORE , eq->over_ignore); +hr_reg_write (eqc,EQC_COALESCE , eq->coalesce);This really is a lot better like this, isn't it?
Quoted 2 lines
Jason
Yes, thank you for your previous advice :)
Weihang
PATCH 9/9 RDMA/hns: Prevent le32 from being implicitly converted to u32
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
Replace BUILD_BUG_ON_ZERO() with BUILD_BUG_ON() to avoid sparse complaining "restricted __le32 degrades to integer".
--- drivers/infiniband/hw/hns/hns_roce_common.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/infiniband/hw/hns/hns_roce_common.h +7 -8
@@ -48,7 +48,8 @@#define roce_set_field (origin, mask, shift, val) \ do { \ (origin) &= ~cpu_to_le32(mask); \ - (origin) |= cpu_to_le32(((u32)(val) << (u32)(shift)) & (mask)); \ + (origin) |= \ + cpu_to_le32(((u32)(val) << (u32)(shift)) & (mask)); \ } while (0)#define roce_set_bit (origin, shift, val) \
@@ -59,9 +60,9 @@#define _hr_reg_enable (ptr, field_type, field_h, field_l) \ ({ \ const field_type *_ptr = ptr; \ - *((__le32 *)_ptr + (field_h) / 32) |= \ - cpu_to_le32(BIT((field_l) % 32)) + \ - BUILD_BUG_ON_ZERO((field_h) != (field_l)); \ + *((__le32 *)_ptr + (field_h) / 32) |= cpu_to_le32( \ + BIT((field_l) % 32) + \ + BUILD_BUG_ON_ZERO((field_h) != (field_l))); \ })#define hr_reg_enable (ptr, field) _hr_reg_enable(ptr, field)
@@ -69,11 +70,9 @@#define _hr_reg_clear (ptr, field_type, field_h, field_l) \ ({ \ const field_type *_ptr = ptr; \ + BUILD_BUG_ON(((field_h) / 32) != ((field_l) / 32)); \ *((__le32 *)_ptr + (field_h) / 32) &= \ - cpu_to_le32( \ - ~GENMASK((field_h) % 32, (field_l) % 32)) + \ - BUILD_BUG_ON_ZERO(((field_h) / 32) != \ - ((field_l) / 32)); \ + ~cpu_to_le32(GENMASK((field_h) % 32, (field_l) % 32)); \ })#define hr_reg_clear (ptr, field) _hr_reg_clear(ptr, field)
Signature · 1 line
2.8.1
Quoted 17 lines · Weihang Li
There are some cleanups for the -next branch as usual:
- #1, #2 fix issues about inline.
- #3 ~ #6 remove some dead code and redunant check.
- #7 ~ #9 are miscellaneous changes.Lang Cheng (1):
RDMA/hns: Prevent le32 from being implicitly converted to u32Weihang Li (2):
RDMA/hns: Avoid enabling RQ inline on UD RDMA/hns: Fix missing assignment ofmax_inline_dataWenpeng Liang (3):
RDMA/hns: Delete redundant abnormal interrupt status RDMA/hns: Remove unsupported QP types RDMA/hns: Add XRC subtype in QPC and XRC type in SRQC
Quoted 6 lines
Yangyang Li (2):
RDMA/hns: Delete redundant condition judgment related to eq RDMA/hns: Delete unused members in the structurehns_roce_hwYixing Liu (1):
RDMA/hns: Simplify the functionconfig_eqc()
Applied to for-next, thanks
Jason