Commit 593d8957 authored by Chengchang Tang's avatar Chengchang Tang Committed by 岳国风
Browse files

RDMA/hns: Fix missing default values of scc parameters

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



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

Currently, the driver does not actively read the default parameters
of scc, that is, the default parameters are all 0. Therefore, if the
user directly modifies any parameter value without actively reading
the scc default parameters, other parameters will become 0.

This patch will read and save the default value of scc immediately
after the driver registers sysfs to avoid the above problems.

Fixes: 523f34d8 ("RDMA/hns: Support congestion control algorithm parameter configuration")
Signed-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarGuofeng Yue <yueguofeng@h-partners.com>
parent f02739ea
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7388,6 +7388,9 @@ static int hns_roce_v2_query_scc_param(struct hns_roce_dev *hr_dev,
	struct hns_roce_port *pdata;
	int ret;

	if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08)
		return -EOPNOTSUPP;

	if (port_num > hr_dev->caps.num_ports) {
		ibdev_err_ratelimited(&hr_dev->ib_dev,
				      "invalid port num %u.\n", port_num);
+19 −1
Original line number Diff line number Diff line
@@ -26,6 +26,22 @@ static void scc_param_config_work(struct work_struct *work)
				     scc_param->algo_type);
}

static void get_default_scc_param(struct hns_roce_dev *hr_dev,
				  struct hns_roce_port *pdata)
{
	int ret;
	int i;

	for (i = 0; i < HNS_ROCE_SCC_ALGO_TOTAL; i++) {
		pdata->scc_param[i].timestamp = jiffies;
		ret = hr_dev->hw->query_scc_param(hr_dev, pdata->port_num, i);
		if (ret && ret != -EOPNOTSUPP)
			ibdev_warn_ratelimited(&hr_dev->ib_dev,
				"failed to get default parameters of scc algo %d, ret = %d.\n",
				i, ret);
	}
}

static int alloc_scc_param(struct hns_roce_dev *hr_dev,
			   struct hns_roce_port *pdata)
{
@@ -39,7 +55,6 @@ static int alloc_scc_param(struct hns_roce_dev *hr_dev,

	for (i = 0; i < HNS_ROCE_SCC_ALGO_TOTAL; i++) {
		scc_param[i].algo_type = i;
		scc_param[i].timestamp = jiffies;
		scc_param[i].hr_dev = hr_dev;
		scc_param[i].port_num = pdata->port_num;
		INIT_DELAYED_WORK(&scc_param[i].scc_cfg_dwork,
@@ -47,6 +62,9 @@ static int alloc_scc_param(struct hns_roce_dev *hr_dev,
	}

	pdata->scc_param = scc_param;

	get_default_scc_param(hr_dev, pdata);

	return 0;
}