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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:21 +0000 (11:59 +0100)
commitcd294f7c6024580f883c7bec7a5ef23683fec8f7
treecbab4844edf8ca9061c6c98402ce71827ebc5e87
parent1210137c7f82beb0dd7506a4befb05753c0979b7
RDMA/hns: Fix init failure of RoCE VF and HIP08

[ Upstream commit 07f06e0e5cd99555c861e874716d9e2627655fd5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/hns/hns_roce_main.c