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: 523f34d81ea7 ("RDMA/hns: Support congestion control algorithm parameter configuration") Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +++ drivers/infiniband/hw/hns/hns_roce_sysfs.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 00a13b36ce2d..5df6a07cc8f7 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7382,6 +7382,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); diff --git a/drivers/infiniband/hw/hns/hns_roce_sysfs.c b/drivers/infiniband/hw/hns/hns_roce_sysfs.c index a51423b94dc1..f92e5c13ab92 100644 --- a/drivers/infiniband/hw/hns/hns_roce_sysfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_sysfs.c @@ -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; }