Commit 7a5b9459 authored by Luoyouming's avatar Luoyouming Committed by Juan Zhou
Browse files

RDMA/hns: Fix congestions control algorithm type for UD

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I87LV8



--------------------------------------------------------------------------

Due to hardware limitations, UD mode can only configure DCQCN.
Therefore, the default configuration in this mode is set to DCQCN,
and additional validation is applied to user configuration.

Fixes: 09f1b7cb ("RDMA/hns: Support congestion control algorithm configuration at QP granularity")
Signed-off-by: default avatarLuoyouming <luoyouming@huawei.com>
parent 6f3b60e0
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -1114,6 +1114,9 @@ static inline void default_congest_type(struct hns_roce_dev *hr_dev,
{
	struct hns_roce_caps *caps = &hr_dev->caps;

	if (hr_qp->ibqp.qp_type == IB_QPT_UD)
		hr_qp->congest_type = HNS_ROCE_CREATE_QP_FLAGS_DCQCN;
	else
		hr_qp->congest_type = 1 << caps->default_congest_type;
}

@@ -1122,6 +1125,17 @@ static int set_congest_type(struct hns_roce_qp *hr_qp,
{
	int ret = 0;

	if (hr_qp->ibqp.qp_type == IB_QPT_UD &&
	    !(ucmd->congest_type_flags & HNS_ROCE_CREATE_QP_FLAGS_DCQCN)) {
		struct hns_roce_dev *hr_dev = to_hr_dev(hr_qp->ibqp.device);

		ibdev_err_ratelimited(&hr_dev->ib_dev,
			"UD just support DCQCN. unsupported congest type 0x%llx.\n",
			ucmd->congest_type_flags);

		return -EINVAL;
	}

	if (ucmd->congest_type_flags & HNS_ROCE_CREATE_QP_FLAGS_DCQCN)
		hr_qp->congest_type = HNS_ROCE_CREATE_QP_FLAGS_DCQCN;
	else if (ucmd->congest_type_flags & HNS_ROCE_CREATE_QP_FLAGS_LDCP)
@@ -1136,19 +1150,16 @@ static int set_congest_type(struct hns_roce_qp *hr_qp,
	return ret;
}

static void set_congest_param(struct hns_roce_dev *hr_dev,
static int set_congest_param(struct hns_roce_dev *hr_dev,
			      struct hns_roce_qp *hr_qp,
			      struct hns_roce_ib_create_qp *ucmd)
{
	int ret;

	if (ucmd->comp_mask & HNS_ROCE_CREATE_QP_MASK_CONGEST_TYPE) {
		ret = set_congest_type(hr_qp, ucmd);
		if (ret == 0)
			return;
	}
	if (ucmd->comp_mask & HNS_ROCE_CREATE_QP_MASK_CONGEST_TYPE)
		return set_congest_type(hr_qp, ucmd);

	default_congest_type(hr_dev, hr_qp);

	return 0;
}

static void set_qp_notify_param(struct hns_roce_qp *hr_qp,
@@ -1253,7 +1264,10 @@ static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
		ret = set_uqp_create_flag_param(hr_dev, hr_qp, init_attr, ucmd);
		if (ret)
			return ret;
		set_congest_param(hr_dev, hr_qp, ucmd);

		ret = set_congest_param(hr_dev, hr_qp, ucmd);
		if (ret)
			return ret;
	} else {
		if (init_attr->create_flags &
		    IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) {