RDMA/hns: Fix init failure of RoCE VF and HIP08
authorJunxian Huang <huangjunxian6@hisilicon.com>
Tue, 17 Oct 2023 12:52:39 +0000 (20:52 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 19 Oct 2023 06:49:40 +0000 (09:49 +0300)
commit07f06e0e5cd99555c861e874716d9e2627655fd5
treef0943c513b4c90abfff3b54761644a1475ada443
parentb4a797b894dc91a541ea230db6fa00cc74683bfd
RDMA/hns: Fix init failure of RoCE VF and HIP08

During device init, a struct for HW stats will be allocated. As HW
stats are not supported for VF and HIP08, currently
hns_roce_alloc_hw_port_stats() returns NULL in this case. However,
ib-core considers the returned NULL pointer as memory allocation
failure and returns ENOMEM, eventually leading to the failure of VF
and HIP08 init.

In the case where the driver does not support the .alloc_hw_port_stats()
ops, ib-core will return EOPNOTSUPP and ignore this error code in the
upper layer function. So for VF and HIP08, just don't set the HW stats
ops to ib-core.

Fixes: 5a87279591a1 ("RDMA/hns: Support hns HW stats")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20231017125239.164455-8-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_main.c