在 2024/8/9 22:59, Dust Li 写道:
On 2024-08-09 16:31:46, Liu Jian wrote:
Currently, in the SMC protocol, network devices are obtained by calling
ib_device_ops.get_netdev(). But for some drivers, this callback function
is not implemented separately. Therefore, here I modified to use
ib_device_get_netdev() to get net_device.
For rdma devices that do not implement ib_device_ops.get_netdev(), one of
the issues addressed is as follows:
before:
smcr device
Net-Dev IB-Dev IB-P IB-State Type Crit #Links PNET-ID
rxee 1 ACTIVE 0 No 0
after:
smcr device
Net-Dev IB-Dev IB-P IB-State Type Crit #Links PNET-ID
enp1s0f1 rxee 1 ACTIVE 0 No 0
Signed-off-by: Liu Jian <liujian56@xxxxxxxxxx>
---
net/smc/smc_ib.c | 8 +++-----
net/smc/smc_pnet.c | 6 +-----
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 9297dc20bfe2..382351ac9434 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -899,9 +899,7 @@ static void smc_copy_netdev_ifindex(struct smc_ib_device *smcibdev, int port)
struct ib_device *ibdev = smcibdev->ibdev;
struct net_device *ndev;
- if (!ibdev->ops.get_netdev)
- return;
- ndev = ibdev->ops.get_netdev(ibdev, port + 1);
+ ndev = ib_device_get_netdev(ibdev, port + 1);
if (ndev) {
smcibdev->ndev_ifidx[port] = ndev->ifindex;
dev_put(ndev);
@@ -921,9 +919,9 @@ void smc_ib_ndev_change(struct net_device *ndev, unsigned long event)
port_cnt = smcibdev->ibdev->phys_port_cnt;
for (i = 0; i < min_t(size_t, port_cnt, SMC_MAX_PORTS); i++) {
libdev = smcibdev->ibdev;
- if (!libdev->ops.get_netdev)
+ lndev = ib_device_get_netdev(libdev, i + 1);
+ if (!lndev)
continue;
- lndev = libdev->ops.get_netdev(libdev, i + 1);
dev_put(lndev);
if (lndev != ndev)
continue;
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index 2adb92b8c469..a55a697a48de 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -1055,11 +1055,7 @@ static void smc_pnet_find_rdma_dev(struct net_device *netdev,
continue;
for (i = 1; i <= SMC_MAX_PORTS; i++) {
- if (!rdma_is_port_valid(ibdev->ibdev, i))
- continue;
Why remove this check ?
Hi, Dust,
The same check is already in ib_device_get_netdev().
Best regard,
Dust
- if (!ibdev->ibdev->ops.get_netdev)
- continue;
- ndev = ibdev->ibdev->ops.get_netdev(ibdev->ibdev, i);
+ ndev = ib_device_get_netdev(ibdev->ibdev, i);
if (!ndev)
continue;
dev_put(ndev);
--
2.34.1