Skip to content

Commit 7b9bd73

Browse files
Weihang Lijgunthorpe
authored andcommitted
RDMA/hns: Fix wrong assignment of lp_pktn_ini in QPC
The RoCE Engine will schedule to another QP after one has sent (2 ^ lp_pktn_ini) packets. lp_pktn_ini is set in QPC and should be calculated from 2 factors: 1. current MTU as a integer 2. the RoCE Engine's maximum slice length 64KB But the driver use MTU as a enum ib_mtu and the max inline capability, the lp_pktn_ini will be much bigger than expected which may cause traffic of some QPs to never get scheduled. Fixes: b713128 ("RDMA/hns: Adjust lp_pktn_ini dynamically") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c3d6057 commit 7b9bd73

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,6 +3954,15 @@ static int config_qp_sq_buf(struct hns_roce_dev *hr_dev,
39543954
return 0;
39553955
}
39563956

3957+
static inline enum ib_mtu get_mtu(struct ib_qp *ibqp,
3958+
const struct ib_qp_attr *attr)
3959+
{
3960+
if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_UD)
3961+
return IB_MTU_4096;
3962+
3963+
return attr->path_mtu;
3964+
}
3965+
39573966
static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
39583967
const struct ib_qp_attr *attr, int attr_mask,
39593968
struct hns_roce_v2_qp_context *context,
@@ -3965,6 +3974,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
39653974
struct ib_device *ibdev = &hr_dev->ib_dev;
39663975
dma_addr_t trrl_ba;
39673976
dma_addr_t irrl_ba;
3977+
enum ib_mtu mtu;
39683978
u8 port_num;
39693979
u64 *mtts;
39703980
u8 *dmac;
@@ -4062,23 +4072,23 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
40624072
roce_set_field(qpc_mask->byte_52_udpspn_dmac, V2_QPC_BYTE_52_DMAC_M,
40634073
V2_QPC_BYTE_52_DMAC_S, 0);
40644074

4065-
/* mtu*(2^LP_PKTN_INI) should not bigger than 1 message length 64kb */
4075+
mtu = get_mtu(ibqp, attr);
4076+
4077+
if (attr_mask & IB_QP_PATH_MTU) {
4078+
roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_MTU_M,
4079+
V2_QPC_BYTE_24_MTU_S, mtu);
4080+
roce_set_field(qpc_mask->byte_24_mtu_tc, V2_QPC_BYTE_24_MTU_M,
4081+
V2_QPC_BYTE_24_MTU_S, 0);
4082+
}
4083+
4084+
#define MAX_LP_MSG_LEN 65536
4085+
/* MTU*(2^LP_PKTN_INI) shouldn't be bigger than 64kb */
40664086
roce_set_field(context->byte_56_dqpn_err, V2_QPC_BYTE_56_LP_PKTN_INI_M,
40674087
V2_QPC_BYTE_56_LP_PKTN_INI_S,
4068-
ilog2(hr_dev->caps.max_sq_inline / IB_MTU_4096));
4088+
ilog2(MAX_LP_MSG_LEN / ib_mtu_enum_to_int(mtu)));
40694089
roce_set_field(qpc_mask->byte_56_dqpn_err, V2_QPC_BYTE_56_LP_PKTN_INI_M,
40704090
V2_QPC_BYTE_56_LP_PKTN_INI_S, 0);
40714091

4072-
if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_UD)
4073-
roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_MTU_M,
4074-
V2_QPC_BYTE_24_MTU_S, IB_MTU_4096);
4075-
else if (attr_mask & IB_QP_PATH_MTU)
4076-
roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_MTU_M,
4077-
V2_QPC_BYTE_24_MTU_S, attr->path_mtu);
4078-
4079-
roce_set_field(qpc_mask->byte_24_mtu_tc, V2_QPC_BYTE_24_MTU_M,
4080-
V2_QPC_BYTE_24_MTU_S, 0);
4081-
40824092
roce_set_bit(qpc_mask->byte_108_rx_reqepsn,
40834093
V2_QPC_BYTE_108_RX_REQ_PSN_ERR_S, 0);
40844094
roce_set_field(qpc_mask->byte_96_rx_reqmsn, V2_QPC_BYTE_96_RX_REQ_MSN_M,

0 commit comments

Comments
 (0)