Skip to content

Commit d20a7cf

Browse files
Luoyoumingrleon
authored andcommitted
RDMA/hns: Fix mis-modifying default congestion control algorithm
Commit 27c5fd2 ("RDMA/hns: The UD mode can only be configured with DCQCN") adds a check of congest control alorithm for UD. But that patch causes a problem: hr_dev->caps.congest_type is global, used by all QPs, so modifying this field to DCQCN for UD QPs causes other QPs unable to use any other algorithm except DCQCN. Revert the modification in commit 27c5fd2 ("RDMA/hns: The UD mode can only be configured with DCQCN"). Add a new field cong_type to struct hns_roce_qp and configure DCQCN for UD QPs. Fixes: 27c5fd2 ("RDMA/hns: The UD mode can only be configured with DCQCN") Fixes: f91696f ("RDMA/hns: Support congestion control type selection according to the FW") Signed-off-by: Luoyouming <[email protected]> Signed-off-by: Junxian Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent aafe4cc commit d20a7cf

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,13 @@ struct hns_roce_work {
594594
u32 queue_num;
595595
};
596596

597+
enum hns_roce_cong_type {
598+
CONG_TYPE_DCQCN,
599+
CONG_TYPE_LDCP,
600+
CONG_TYPE_HC3,
601+
CONG_TYPE_DIP,
602+
};
603+
597604
struct hns_roce_qp {
598605
struct ib_qp ibqp;
599606
struct hns_roce_wq rq;
@@ -637,6 +644,7 @@ struct hns_roce_qp {
637644
struct list_head sq_node; /* all send qps are on a list */
638645
struct hns_user_mmap_entry *dwqe_mmap_entry;
639646
u32 config;
647+
enum hns_roce_cong_type cong_type;
640648
};
641649

642650
struct hns_roce_ib_iboe {
@@ -708,13 +716,6 @@ struct hns_roce_eq_table {
708716
struct hns_roce_eq *eq;
709717
};
710718

711-
enum cong_type {
712-
CONG_TYPE_DCQCN,
713-
CONG_TYPE_LDCP,
714-
CONG_TYPE_HC3,
715-
CONG_TYPE_DIP,
716-
};
717-
718719
struct hns_roce_caps {
719720
u64 fw_ver;
720721
u8 num_ports;
@@ -844,7 +845,7 @@ struct hns_roce_caps {
844845
u16 default_aeq_period;
845846
u16 default_aeq_arm_st;
846847
u16 default_ceq_arm_st;
847-
enum cong_type cong_type;
848+
enum hns_roce_cong_type cong_type;
848849
};
849850

850851
enum hns_roce_device_state {

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4738,12 +4738,15 @@ static int check_cong_type(struct ib_qp *ibqp,
47384738
struct hns_roce_congestion_algorithm *cong_alg)
47394739
{
47404740
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
4741+
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
47414742

4742-
if (ibqp->qp_type == IB_QPT_UD)
4743-
hr_dev->caps.cong_type = CONG_TYPE_DCQCN;
4743+
if (ibqp->qp_type == IB_QPT_UD || ibqp->qp_type == IB_QPT_GSI)
4744+
hr_qp->cong_type = CONG_TYPE_DCQCN;
4745+
else
4746+
hr_qp->cong_type = hr_dev->caps.cong_type;
47444747

47454748
/* different congestion types match different configurations */
4746-
switch (hr_dev->caps.cong_type) {
4749+
switch (hr_qp->cong_type) {
47474750
case CONG_TYPE_DCQCN:
47484751
cong_alg->alg_sel = CONG_DCQCN;
47494752
cong_alg->alg_sub_sel = UNSUPPORT_CONG_LEVEL;
@@ -4771,8 +4774,8 @@ static int check_cong_type(struct ib_qp *ibqp,
47714774
default:
47724775
ibdev_warn(&hr_dev->ib_dev,
47734776
"invalid type(%u) for congestion selection.\n",
4774-
hr_dev->caps.cong_type);
4775-
hr_dev->caps.cong_type = CONG_TYPE_DCQCN;
4777+
hr_qp->cong_type);
4778+
hr_qp->cong_type = CONG_TYPE_DCQCN;
47764779
cong_alg->alg_sel = CONG_DCQCN;
47774780
cong_alg->alg_sub_sel = UNSUPPORT_CONG_LEVEL;
47784781
cong_alg->dip_vld = DIP_INVALID;
@@ -4791,6 +4794,7 @@ static int fill_cong_field(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
47914794
struct hns_roce_congestion_algorithm cong_field;
47924795
struct ib_device *ibdev = ibqp->device;
47934796
struct hns_roce_dev *hr_dev = to_hr_dev(ibdev);
4797+
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
47944798
u32 dip_idx = 0;
47954799
int ret;
47964800

@@ -4803,7 +4807,7 @@ static int fill_cong_field(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
48034807
return ret;
48044808

48054809
hr_reg_write(context, QPC_CONG_ALGO_TMPL_ID, hr_dev->cong_algo_tmpl_id +
4806-
hr_dev->caps.cong_type * HNS_ROCE_CONG_SIZE);
4810+
hr_qp->cong_type * HNS_ROCE_CONG_SIZE);
48074811
hr_reg_clear(qpc_mask, QPC_CONG_ALGO_TMPL_ID);
48084812
hr_reg_write(&context->ext, QPCEX_CONG_ALG_SEL, cong_field.alg_sel);
48094813
hr_reg_clear(&qpc_mask->ext, QPCEX_CONG_ALG_SEL);

0 commit comments

Comments
 (0)