Commit 2223966b authored by Junxian Huang's avatar Junxian Huang Committed by Juan Zhou
Browse files

RDMA/hns: Don't set the HW stats ops for VF and HIP08

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: 05491dda ("RDMA/hns: Support hns HW stats")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
parent 5e7ecc38
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -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);