From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8DJVZ
--------------------------------------------------------------------------
As HW stats are not supported for VF and HIP08, just don't set the HW stats ops to ib-core in these cases.
Fixes: 8681236b9ca9 ("Revert "RDMA/hns: Add dfx cnt stats"") Fixes: 05491dda8e9b ("RDMA/hns: Support hns HW stats") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 88db61fc3b9d..8641cb38cd07 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -819,10 +819,6 @@ static struct rdma_hw_stats *hns_roce_alloc_hw_port_stats(struct ib_device *devi { struct hns_roce_dev *hr_dev = to_hr_dev(device);
- if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 || - hr_dev->is_vf) - return NULL; - if (port_num > hr_dev->caps.num_ports) { ibdev_err(device, "invalid port num.\n"); return NULL; @@ -847,10 +843,6 @@ static int hns_roce_get_hw_stats(struct ib_device *device, if (port > hr_dev->caps.num_ports) return -EINVAL;
- if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 || - hr_dev->is_vf) - return -EOPNOTSUPP; - ret = hr_dev->hw->query_hw_counter(hr_dev, stats->value, port, &num_counters); if (ret) { @@ -941,8 +933,6 @@ static const struct ib_device_ops hns_roce_dev_ops = { .query_pkey = hns_roce_query_pkey, .query_port = hns_roce_query_port, .reg_user_mr = hns_roce_reg_user_mr, - .alloc_hw_stats = hns_roce_alloc_hw_port_stats, - .get_hw_stats = hns_roce_get_hw_stats, .init_port = hns_roce_create_port_files,
INIT_RDMA_OBJ_SIZE(ib_ah, hns_roce_ah, ibah), @@ -951,6 +941,11 @@ static const struct ib_device_ops hns_roce_dev_ops = { INIT_RDMA_OBJ_SIZE(ib_ucontext, hns_roce_ucontext, ibucontext), };
+static const struct ib_device_ops hns_roce_dev_hw_stats_ops = { + .alloc_hw_stats = hns_roce_alloc_hw_port_stats, + .get_hw_stats = hns_roce_get_hw_stats, +}; + static const struct ib_device_ops hns_roce_dev_mr_ops = { .rereg_user_mr = hns_roce_rereg_user_mr, }; @@ -1073,6 +1068,10 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ib_set_device_ops(ib_dev, &hns_roce_dev_xrcd_ops); }
+ if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09 && + !hr_dev->is_vf) + ib_set_device_ops(ib_dev, &hns_roce_dev_hw_stats_ops); + ib_set_device_ops(ib_dev, hr_dev->hw->hns_roce_dev_ops); ib_set_device_ops(ib_dev, &hns_roce_dev_ops); ib_set_device_ops(ib_dev, &hns_roce_dev_restrack_ops);