RDMA/hns: Updates for kernel v5.8
Subsystems (2)
cover RDMA/hns: Updates for kernel v5.8
These are some miscellaneous changes of hns driver. #1 ~ #5 are cleanups and #6 ~ #7 are small fixes.
Lang Cheng (4):
RDMA/hns: Remove redundant hardware opcode definitions RDMA/hns: Remove support for HIP08A
RDMA/hns: Delete unnecessary memset when allocating VF resource RDMA/hns: Fix error during modify qp RTS2RTS
Weihang Li (2):
RDMA/hns: Refactor hns_roce_v2_set_hem() RDMA/hns: Remove redundant parameters in set_rc_wqe()
Xi Wang (1):
RDMA/hns: Fix the unneeded process when getting a general type of CQE
error
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 209 +++++++++++++++-------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 19 +-- drivers/infiniband/hw/hns/hns_roce_qp.c | 10 -- 3 files changed, 113 insertions(+), 125 deletions(-)
Signature · 1 line
2.8.1
PATCH 1/7 RDMA/hns: Remove redundant hardware opcode definitions
From: Lang Cheng <[email protected]>
HNS_ROCE_SQ_OPCODE_XXXs and HNS_ROCE_V2_WQE_OP_XXXs have same values, so remove a set of redundant definitions. In addition, remove the suffix of HNS_ROCE_V2_WQE_OP_BIND_MW_TYPE.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 26 +++++++++++++------------- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 18 +----------------- 2 files changed, 14 insertions(+), 30 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +13 -13
@@ -3169,51 +3169,51 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *hr_cq,/* SQ corresponding to CQE */ switch (roce_get_field (cqe->byte_4,V2_CQE_BYTE_4_OPCODE_M ,V2_CQE_BYTE_4_OPCODE_S ) &0x1f ) { -case HNS_ROCE_SQ_OPCODE_SEND : +case HNS_ROCE_V2_WQE_OP_SEND : wc->opcode =IB_WC_SEND ;break ; -case HNS_ROCE_SQ_OPCODE_SEND_WITH_INV : +case HNS_ROCE_V2_WQE_OP_SEND_WITH_INV : wc->opcode =IB_WC_SEND ;break ; -case HNS_ROCE_SQ_OPCODE_SEND_WITH_IMM : +case HNS_ROCE_V2_WQE_OP_SEND_WITH_IMM : wc->opcode =IB_WC_SEND ; wc->wc_flags |=IB_WC_WITH_IMM ;break ; -case HNS_ROCE_SQ_OPCODE_RDMA_READ : +case HNS_ROCE_V2_WQE_OP_RDMA_READ : wc->opcode =IB_WC_RDMA_READ ; wc->byte_len =le32_to_cpu (cqe->byte_cnt);break ; -case HNS_ROCE_SQ_OPCODE_RDMA_WRITE : +case HNS_ROCE_V2_WQE_OP_RDMA_WRITE : wc->opcode =IB_WC_RDMA_WRITE ;break ; -case HNS_ROCE_SQ_OPCODE_RDMA_WRITE_WITH_IMM : +case HNS_ROCE_V2_WQE_OP_RDMA_WRITE_WITH_IMM : wc->opcode =IB_WC_RDMA_WRITE ; wc->wc_flags |=IB_WC_WITH_IMM ;break ; -case HNS_ROCE_SQ_OPCODE_LOCAL_INV : +case HNS_ROCE_V2_WQE_OP_LOCAL_INV : wc->opcode =IB_WC_LOCAL_INV ; wc->wc_flags |=IB_WC_WITH_INVALIDATE ;break ; -case HNS_ROCE_SQ_OPCODE_ATOMIC_COMP_AND_SWAP : +case HNS_ROCE_V2_WQE_OP_ATOM_CMP_AND_SWAP : wc->opcode =IB_WC_COMP_SWAP ; wc->byte_len =8 ;break ; -case HNS_ROCE_SQ_OPCODE_ATOMIC_FETCH_AND_ADD : +case HNS_ROCE_V2_WQE_OP_ATOM_FETCH_AND_ADD : wc->opcode =IB_WC_FETCH_ADD ; wc->byte_len =8 ;break ; -case HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_COMP_AND_SWAP : +case HNS_ROCE_V2_WQE_OP_ATOM_MSK_CMP_AND_SWAP : wc->opcode =IB_WC_MASKED_COMP_SWAP ; wc->byte_len =8 ;break ; -case HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_FETCH_AND_ADD : +case HNS_ROCE_V2_WQE_OP_ATOM_MSK_FETCH_AND_ADD : wc->opcode =IB_WC_MASKED_FETCH_ADD ; wc->byte_len =8 ;break ; -case HNS_ROCE_SQ_OPCODE_FAST_REG_WR : +case HNS_ROCE_V2_WQE_OP_FAST_REG_PMR : wc->opcode =IB_WC_REG_MR ;break ; -case HNS_ROCE_SQ_OPCODE_BIND_MW : +case HNS_ROCE_V2_WQE_OP_BIND_MW : wc->opcode =IB_WC_REG_MR ;break ;default :
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +1 -17
@@ -179,27 +179,11 @@ enum {HNS_ROCE_V2_WQE_OP_ATOM_MSK_FETCH_AND_ADD =0x9 ,HNS_ROCE_V2_WQE_OP_FAST_REG_PMR =0xa ,HNS_ROCE_V2_WQE_OP_LOCAL_INV =0xb , -HNS_ROCE_V2_WQE_OP_BIND_MW_TYPE =0xc , +HNS_ROCE_V2_WQE_OP_BIND_MW =0xc , HNS_ROCE_V2_WQE_OP_MASK = 0x1f, };enum { -HNS_ROCE_SQ_OPCODE_SEND =0x0 , -HNS_ROCE_SQ_OPCODE_SEND_WITH_INV =0x1 , -HNS_ROCE_SQ_OPCODE_SEND_WITH_IMM =0x2 , -HNS_ROCE_SQ_OPCODE_RDMA_WRITE =0x3 , -HNS_ROCE_SQ_OPCODE_RDMA_WRITE_WITH_IMM =0x4 , -HNS_ROCE_SQ_OPCODE_RDMA_READ =0x5 , -HNS_ROCE_SQ_OPCODE_ATOMIC_COMP_AND_SWAP =0x6 , -HNS_ROCE_SQ_OPCODE_ATOMIC_FETCH_AND_ADD =0x7 , -HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_COMP_AND_SWAP =0x8 , -HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_FETCH_AND_ADD =0x9 , -HNS_ROCE_SQ_OPCODE_FAST_REG_WR =0xa , -HNS_ROCE_SQ_OPCODE_LOCAL_INV =0xb , -HNS_ROCE_SQ_OPCODE_BIND_MW =0xc , -}; - -enum {/* rq operations */ HNS_ROCE_V2_OPCODE_RDMA_WRITE_IMM =0x0 , HNS_ROCE_V2_OPCODE_SEND = 0x1,
Signature · 1 line
2.8.1
PATCH 2/7 RDMA/hns: Refactor hns_roce_v2_set_hem()
In reply to Weihang LiThe parts about preparing and sending mailbox to hardware is not strongly related to other codes in hns_roce_v2_set_hem(), and can be encapsulated into a separate function.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 45 +++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +26 -19
@@ -3373,11 +3373,33 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,return op + step_idx; } +static int set_hem_to_hw (struct hns_roce_dev *hr_dev,int obj,u64 bt_ba, +u32 hem_type,int step_idx) +{ +struct hns_roce_cmd_mailbox *mailbox; +int ret; +int op; + + op =get_op_for_set_hem (hr_dev, hem_type, step_idx); +if (op == -EINVAL ) +return 0 ; + + mailbox =hns_roce_alloc_cmd_mailbox (hr_dev); +if (IS_ERR (mailbox)) +return PTR_ERR (mailbox); + + ret =hns_roce_cmd_mbox (hr_dev, bt_ba, mailbox->dma, obj, +0 , op,HNS_ROCE_CMD_TIMEOUT_MSECS ); + +hns_roce_free_cmd_mailbox (hr_dev, mailbox); + +return ret; +} +static int hns_roce_v2_set_hem (struct hns_roce_dev *hr_dev,struct hns_roce_hem_table *table,int obj,int step_idx) { -struct hns_roce_cmd_mailbox *mailbox;struct hns_roce_hem_iter iter;struct hns_roce_hem_mhop mhop;struct hns_roce_hem *hem;
@@ -3389,7 +3411,6 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,u64 bt_ba =0 ;u32 chunk_ba_num;u32 hop_num; -int op;if (!hns_roce_check_whether_mhop (hr_dev, table->type))return 0 ;
@@ -3411,14 +3432,6 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, hem_idx = i; } - op =get_op_for_set_hem (hr_dev, table->type, step_idx); -if (op == -EINVAL ) -return 0 ; - - mailbox =hns_roce_alloc_cmd_mailbox (hr_dev); -if (IS_ERR (mailbox)) -return PTR_ERR (mailbox); -if (table->type ==HEM_TYPE_SCCC ) obj = mhop.l0_idx;
@@ -3427,11 +3440,8 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,for (hns_roce_hem_first (hem, &iter); !hns_roce_hem_last (&iter);hns_roce_hem_next (&iter)) { bt_ba =hns_roce_hem_addr (&iter); - -/* configure the ba, tag, and op */ - ret =hns_roce_cmd_mbox (hr_dev, bt_ba, mailbox->dma, - obj,0 , op, -HNS_ROCE_CMD_TIMEOUT_MSECS ); + ret =set_hem_to_hw (hr_dev, obj, bt_ba, table->type, + step_idx); } }else {if (step_idx ==0 )
@@ -3439,12 +3449,9 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,else if (step_idx ==1 && hop_num ==2 ) bt_ba = table->bt_l1_dma_addr[l1_idx]; -/* configure the ba, tag, and op */ - ret =hns_roce_cmd_mbox (hr_dev, bt_ba, mailbox->dma, obj, -0 , op,HNS_ROCE_CMD_TIMEOUT_MSECS ); + ret =set_hem_to_hw (hr_dev, obj, bt_ba, table->type, step_idx); } -hns_roce_free_cmd_mailbox (hr_dev, mailbox);return ret; }
Signature · 1 line
2.8.1
Re: [PATCH for-next 2/7] RDMA/hns: Refactor hns_roce_v2_set_hem()
Quoted 17 lines · Weihang Li
The parts about preparing and sending mailbox to hardware is not strongly related to other codes in
hns_roce_v2_set_hem(), and can be encapsulated into a separate function.Signed-off-by Weihang Li <[email protected]>--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 45 +++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-)drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0
-0@@ -3373,11 +3373,33 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,return op + step_idx; }
drivers/infiniband/hw/hns/hns_roce_hw_v2.c static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, · line 3385
Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10
-0+static int set_hem_to_hw (struct hns_roce_dev *hr_dev,int obj,u64 bt_ba, +u32 hem_type,int step_idx) +{ +struct hns_roce_cmd_mailbox *mailbox; +int ret; +int op; + + op =get_op_for_set_hem (hr_dev, hem_type, step_idx); +if (op == -EINVAL ) +return 0 ;
It is not how we write error checks "if (op < 0) return 0;"
Thanks
Re: [PATCH for-next 2/7] RDMA/hns: Refactor hns_roce_v2_set_hem()
Quoted 31 lines · Leon Romanovsky
Quoted 17 lines · Weihang Li
The parts about preparing and sending mailbox to hardware is not strongly related to other codes in
hns_roce_v2_set_hem(), and can be encapsulated into a separate function.Signed-off-by Weihang Li <[email protected]>--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 45 +++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-)drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0
-0@@ -3373,11 +3373,33 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,return op + step_idx; }drivers/infiniband/hw/hns/hns_roce_hw_v2.c static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, · line 3385
Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10
-0+static int set_hem_to_hw (struct hns_roce_dev *hr_dev,int obj,u64 bt_ba, +u32 hem_type,int step_idx) +{ +struct hns_roce_cmd_mailbox *mailbox; +int ret; +int op; + + op =get_op_for_set_hem (hr_dev, hem_type, step_idx); +if (op == -EINVAL ) +return 0 ;It is not how we write error checks "if (op < 0) return 0;"
Quoted 2 lines
Thanks
Thanks for your comments, will modify it.
Weihang
PATCH 3/7 RDMA/hns: Remove support for HIP08A
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
HIP08_A is an engineering sample, and all of them have been already replaced by HIP08_B. So remove the relevant code.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 97 ++++++++++++++---------------- drivers/infiniband/hw/hns/hns_roce_qp.c | 10 --- 2 files changed, 45 insertions(+), 62 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +45 -52
@@ -1744,27 +1744,25 @@ static void set_default_caps(struct hns_roce_dev *hr_dev) caps->max_srq_wrs =HNS_ROCE_V2_MAX_SRQ_WR ; caps->max_srq_sges =HNS_ROCE_V2_MAX_SRQ_SGE ; -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP08_B ) { - caps->flags |=HNS_ROCE_CAP_FLAG_ATOMIC |HNS_ROCE_CAP_FLAG_MW | -HNS_ROCE_CAP_FLAG_SRQ |HNS_ROCE_CAP_FLAG_FRMR | -HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL ; - - caps->num_qpc_timer =HNS_ROCE_V2_MAX_QPC_TIMER_NUM ; - caps->qpc_timer_entry_sz =HNS_ROCE_V2_QPC_TIMER_ENTRY_SZ ; - caps->qpc_timer_ba_pg_sz =0 ; - caps->qpc_timer_buf_pg_sz =0 ; - caps->qpc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; - caps->num_cqc_timer =HNS_ROCE_V2_MAX_CQC_TIMER_NUM ; - caps->cqc_timer_entry_sz =HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ ; - caps->cqc_timer_ba_pg_sz =0 ; - caps->cqc_timer_buf_pg_sz =0 ; - caps->cqc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; - - caps->sccc_entry_sz =HNS_ROCE_V2_SCCC_ENTRY_SZ ; - caps->sccc_ba_pg_sz =0 ; - caps->sccc_buf_pg_sz =0 ; - caps->sccc_hop_num =HNS_ROCE_SCCC_HOP_NUM ; - } + caps->flags |=HNS_ROCE_CAP_FLAG_ATOMIC |HNS_ROCE_CAP_FLAG_MW | +HNS_ROCE_CAP_FLAG_SRQ |HNS_ROCE_CAP_FLAG_FRMR | +HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL ; + + caps->num_qpc_timer =HNS_ROCE_V2_MAX_QPC_TIMER_NUM ; + caps->qpc_timer_entry_sz =HNS_ROCE_V2_QPC_TIMER_ENTRY_SZ ; + caps->qpc_timer_ba_pg_sz =0 ; + caps->qpc_timer_buf_pg_sz =0 ; + caps->qpc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; + caps->num_cqc_timer =HNS_ROCE_V2_MAX_CQC_TIMER_NUM ; + caps->cqc_timer_entry_sz =HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ ; + caps->cqc_timer_ba_pg_sz =0 ; + caps->cqc_timer_buf_pg_sz =0 ; + caps->cqc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; + + caps->sccc_entry_sz =HNS_ROCE_V2_SCCC_ENTRY_SZ ; + caps->sccc_ba_pg_sz =0 ; + caps->sccc_buf_pg_sz =0 ; + caps->sccc_hop_num =HNS_ROCE_SCCC_HOP_NUM ; } static void calc_pg_sz(int obj_num, int obj_size, int hop_num, int ctx_bt_num,
@@ -1995,20 +1993,18 @@ static int hns_roce_query_pf_caps(struct hns_roce_dev *hr_dev) caps->srqc_bt_num, &caps->srqc_buf_pg_sz, &caps->srqc_ba_pg_sz, HEM_TYPE_SRQC); -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP08_B ) { - caps->sccc_hop_num = ctx_hop_num; - caps->qpc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; - caps->cqc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; + caps->sccc_hop_num = ctx_hop_num; + caps->qpc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; + caps->cqc_timer_hop_num =HNS_ROCE_HOP_NUM_0 ; -calc_pg_sz (caps->num_qps, caps->sccc_entry_sz, - caps->sccc_hop_num, caps->sccc_bt_num, - &caps->sccc_buf_pg_sz, &caps->sccc_ba_pg_sz, -HEM_TYPE_SCCC ); -calc_pg_sz (caps->num_cqc_timer, caps->cqc_timer_entry_sz, - caps->cqc_timer_hop_num, caps->cqc_timer_bt_num, - &caps->cqc_timer_buf_pg_sz, - &caps->cqc_timer_ba_pg_sz,HEM_TYPE_CQC_TIMER ); - } +calc_pg_sz (caps->num_qps, caps->sccc_entry_sz, + caps->sccc_hop_num, caps->sccc_bt_num, + &caps->sccc_buf_pg_sz, &caps->sccc_ba_pg_sz, +HEM_TYPE_SCCC ); +calc_pg_sz (caps->num_cqc_timer, caps->cqc_timer_entry_sz, + caps->cqc_timer_hop_num, caps->cqc_timer_bt_num, + &caps->cqc_timer_buf_pg_sz, + &caps->cqc_timer_ba_pg_sz,HEM_TYPE_CQC_TIMER );calc_pg_sz (caps->num_cqe_segs, caps->mtt_entry_sz, caps->cqe_hop_num,1 , &caps->cqe_buf_pg_sz, &caps->cqe_ba_pg_sz,HEM_TYPE_CQE );
@@ -2055,22 +2051,19 @@ static int hns_roce_v2_profile(struct hns_roce_dev *hr_dev)return ret; } -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP08_B ) { - ret =hns_roce_query_pf_timer_resource (hr_dev); -if (ret) { -dev_err (hr_dev->dev, -"Query pf timer resource fail, ret = %d.\n" , - ret); -return ret; - } + ret =hns_roce_query_pf_timer_resource (hr_dev); +if (ret) { +dev_err (hr_dev->dev, +"failed to query pf timer resource, ret = %d.\n" , ret); +return ret; + } - ret =hns_roce_set_vf_switch_param (hr_dev,0 ); -if (ret) { -dev_err (hr_dev->dev, -"Set function switch param fail, ret = %d.\n" , - ret); -return ret; - } + ret =hns_roce_set_vf_switch_param (hr_dev,0 ); +if (ret) { +dev_err (hr_dev->dev, +"failed to set function switch param, ret = %d.\n" , + ret); +return ret; } hr_dev->vendor_part_id = hr_dev->pci_dev->device;
@@ -2336,8 +2329,7 @@ static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev) {struct hns_roce_v2_priv *priv = hr_dev->priv; -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP08_B ) -hns_roce_function_clear (hr_dev); +hns_roce_function_clear (hr_dev);hns_roce_free_link_table (hr_dev, &priv->tpq);hns_roce_free_link_table (hr_dev, &priv->tsq);
@@ -4231,12 +4223,13 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,roce_set_field (qpc_mask->byte_24_mtu_tc,V2_QPC_BYTE_24_HOP_LIMIT_M ,V2_QPC_BYTE_24_HOP_LIMIT_S ,0 ); -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP08_B && is_udp) +if (is_udp)roce_set_field (context->byte_24_mtu_tc,V2_QPC_BYTE_24_TC_M ,V2_QPC_BYTE_24_TC_S , grh->traffic_class >>2 );else roce_set_field (context->byte_24_mtu_tc,V2_QPC_BYTE_24_TC_M ,V2_QPC_BYTE_24_TC_S , grh->traffic_class); +roce_set_field (qpc_mask->byte_24_mtu_tc,V2_QPC_BYTE_24_TC_M ,V2_QPC_BYTE_24_TC_S ,0 ); roce_set_field(context->byte_28_at_fl, V2_QPC_BYTE_28_FL_M,
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -10
@@ -411,7 +411,6 @@ static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,struct hns_roce_qp *hr_qp, struct ib_qp_cap *cap) { - struct ib_device *ibdev = &hr_dev->ib_dev; u32 cnt; cnt =max (1U , cap->max_send_sge);
@@ -431,15 +430,6 @@ static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt, }else if (hr_qp->sq.max_gs >HNS_ROCE_SGE_IN_WQE ) { cnt =roundup_pow_of_two (sq_wqe_cnt * (hr_qp->sq.max_gs -HNS_ROCE_SGE_IN_WQE )); - -if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08_A ) { -if (cnt > hr_dev->caps.max_extend_sg) { -ibdev_err (ibdev, -"failed to check exSGE num, exSGE num = %d.\n" , - cnt); -return -EINVAL ; - } - } }else { cnt =0 ; }
Signature · 1 line
2.8.1
PATCH 4/7 RDMA/hns: Remove redundant parameters in set_rc_wqe()
In reply to Weihang LiThere are some functions called by set_rc_wqe() use two parameters:
"void *wqe" and "struct hns_roce_v2_rc_send_wqe *rc_sq_wqe", but the first one can be got from the second one. So remove the redundant wqe from related functions.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +17 -13
@@ -91,10 +91,11 @@ static u32 to_hr_opcode(u32 ib_opcode) }static void set_frmr_seg (struct hns_roce_v2_rc_send_wqe *rc_sq_wqe, -void *wqe,const struct ib_reg_wr *wr) +const struct ib_reg_wr *wr) { +struct hns_roce_wqe_frmr_seg *fseg = + (void *)rc_sq_wqe +sizeof (struct hns_roce_v2_rc_send_wqe );struct hns_roce_mr *mr =to_hr_mr (wr->mr); -struct hns_roce_wqe_frmr_seg *fseg = wqe;u64 pbl_ba;/* use ib_access_flags */
@@ -128,14 +129,16 @@ static void set_frmr_seg(struct hns_roce_v2_rc_send_wqe *rc_sq_wqe, V2_RC_FRMR_WQE_BYTE_40_BLK_MODE_S, 0); } -static void set_atomic_seg (const struct ib_send_wr *wr,void *wqe, +static void set_atomic_seg (const struct ib_send_wr *wr,struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,unsigned int valid_num_sge) { -struct hns_roce_wqe_atomic_seg *aseg; +struct hns_roce_v2_wqe_data_seg *dseg = + (void *)rc_sq_wqe +sizeof (struct hns_roce_v2_rc_send_wqe ); +struct hns_roce_wqe_atomic_seg *aseg = + (void *)dseg +sizeof (struct hns_roce_v2_wqe_data_seg ); -set_data_seg_v2 (wqe, wr->sg_list); - aseg = wqe +sizeof (struct hns_roce_v2_wqe_data_seg ); +set_data_seg_v2 (dseg, wr->sg_list);if (wr->opcode ==IB_WR_ATOMIC_CMP_AND_SWP ) { aseg->fetchadd_swap_data =cpu_to_le64 (atomic_wr (wr)->swap);
@@ -143,7 +146,7 @@ static void set_atomic_seg(const struct ib_send_wr *wr, void *wqe, }else { aseg->fetchadd_swap_data =cpu_to_le64 (atomic_wr (wr)->compare_add); - aseg->cmp_data =0 ; + aseg->cmp_data =0 ; } roce_set_field(rc_sq_wqe->byte_16, V2_RC_SEND_WQE_BYTE_16_SGE_NUM_M,
@@ -176,13 +179,15 @@ static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,static int set_rwqe_data_seg (struct ib_qp *ibqp,const struct ib_send_wr *wr,struct hns_roce_v2_rc_send_wqe *rc_sq_wqe, -void *wqe,unsigned int *sge_ind, +unsigned int *sge_ind,unsigned int valid_num_sge) {struct hns_roce_dev *hr_dev =to_hr_dev (ibqp->device); -struct hns_roce_v2_wqe_data_seg *dseg = wqe; +struct hns_roce_v2_wqe_data_seg *dseg = + (void *)rc_sq_wqe +sizeof (struct hns_roce_v2_rc_send_wqe );struct ib_device *ibdev = &hr_dev->ib_dev;struct hns_roce_qp *qp =to_hr_qp (ibqp); +void *wqe = dseg;int j =0 ;int i;
@@ -438,7 +443,6 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,roce_set_bit (rc_sq_wqe->byte_4,V2_RC_SEND_WQE_BYTE_4_OWNER_S , owner_bit); - wqe +=sizeof (struct hns_roce_v2_rc_send_wqe );switch (wr->opcode) {case IB_WR_RDMA_READ :case IB_WR_RDMA_WRITE :
@@ -451,7 +455,7 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp, rc_sq_wqe->inv_key =cpu_to_le32 (wr->ex.invalidate_rkey);break ;case IB_WR_REG_MR : -set_frmr_seg (rc_sq_wqe, wqe,reg_wr (wr)); +set_frmr_seg (rc_sq_wqe,reg_wr (wr));break ;case IB_WR_ATOMIC_CMP_AND_SWP :case IB_WR_ATOMIC_FETCH_AND_ADD :
@@ -468,10 +472,10 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,if (wr->opcode ==IB_WR_ATOMIC_CMP_AND_SWP || wr->opcode ==IB_WR_ATOMIC_FETCH_AND_ADD ) -set_atomic_seg (wr, wqe, rc_sq_wqe, valid_num_sge); +set_atomic_seg (wr, rc_sq_wqe, valid_num_sge);else if (wr->opcode !=IB_WR_REG_MR ) ret =set_rwqe_data_seg (&qp->ibqp, wr, rc_sq_wqe, - wqe, &curr_idx, valid_num_sge); + &curr_idx, valid_num_sge); *sge_idx = curr_idx;
Signature · 1 line
2.8.1
PATCH 5/7 RDMA/hns: Delete unnecessary memset when allocating VF resource
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
The hns_roce_cmq_setup_basic_desc() can clear the whole desc, so removes these redundant memset operations.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -2
@@ -1514,8 +1514,6 @@ static int hns_roce_alloc_vf_resource(struct hns_roce_dev *hr_dev) req_a = (struct hns_roce_vf_res_a *)desc[0 ].data; req_b = (struct hns_roce_vf_res_b *)desc[1 ].data; -memset (req_a,0 ,sizeof (*req_a)); -memset (req_b,0 ,sizeof (*req_b));for (i =0 ; i <2 ; i++) {hns_roce_cmq_setup_basic_desc (&desc[i],HNS_ROCE_OPC_ALLOC_VF_RES , false);
Signature · 1 line
2.8.1
PATCH 6/7 RDMA/hns: Fix error during modify qp RTS2RTS
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
One qp state migrations legal configuration was deleted mistakenly.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -1
@@ -4262,7 +4262,9 @@ static bool check_qp_state(enum ib_qp_state cur_state, [IB_QPS_RTR ] = { [IB_QPS_RESET ] = true, [IB_QPS_RTS ] = true, [IB_QPS_ERR] = true }, - [IB_QPS_RTS] = { [IB_QPS_RESET] = true, [IB_QPS_ERR] = true }, + [IB_QPS_RTS ] = { [IB_QPS_RESET ] = true, + [IB_QPS_RTS ] = true, + [IB_QPS_ERR] = true }, [IB_QPS_SQD] = {}, [IB_QPS_SQE] = {}, [IB_QPS_ERR ] = { [IB_QPS_RESET ] = true, [IB_QPS_ERR ] = true }
Signature · 1 line
2.8.1
PATCH 7/7 RDMA/hns: Fix the unneeded process when getting a general type of CQE error
In reply to Weihang LiFrom: Xi Wang <[email protected]>
If the hns ROCEE reports a general error CQE (types not specified by the IB General Specifications), it's no need to change the QP state to error, and the driver should just skip it.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 9 +++++++++ drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 + 2 files changed, 10 insertions(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +9 -0
@@ -3046,6 +3046,7 @@ static void get_cqe_status(struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp, IB_WC_RETRY_EXC_ERR }, { HNS_ROCE_CQE_V2_RNR_RETRY_EXC_ERR, IB_WC_RNR_RETRY_EXC_ERR }, { HNS_ROCE_CQE_V2_REMOTE_ABORT_ERR, IB_WC_REM_ABORT_ERR }, + { HNS_ROCE_CQE_V2_GENERAL_ERR, IB_WC_GENERAL_ERR} }; u32 cqe_status = roce_get_field(cqe->byte_4, V2_CQE_BYTE_4_STATUS_M,
@@ -3068,6 +3069,14 @@ static void get_cqe_status(struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp, sizeof(*cqe), false);/* +* For hns ROCEE, GENERAL_ERR is an error type that is not defined in +* the standard protocol, the driver must ignore it and needn't to set +* the QP to an error state. +*/ +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
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +1 -0
@@ -214,6 +214,7 @@ enum {HNS_ROCE_CQE_V2_TRANSPORT_RETRY_EXC_ERR =0x15 ,HNS_ROCE_CQE_V2_RNR_RETRY_EXC_ERR =0x16 ,HNS_ROCE_CQE_V2_REMOTE_ABORT_ERR =0x22 , +HNS_ROCE_CQE_V2_GENERAL_ERR =0x23 , HNS_ROCE_V2_CQE_STATUS_MASK = 0xff, };
Signature · 1 line
2.8.1