From: Liu Jian <liujian56@huawei.com>
To: <linux-rdma@vger.kernel.org>, <linux-s390@vger.kernel.org>,
<netdev@vger.kernel.org>
Cc: <jgg@ziepe.ca>, <leon@kernel.org>, <zyjzyj2000@gmail.com>,
<wenjia@linux.ibm.com>, <jaka@linux.ibm.com>,
<alibuda@linux.alibaba.com>, <tonylu@linux.alibaba.com>,
<guwen@linux.alibaba.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<liujian56@huawei.com>
Subject: [PATCH net-next 2/4] net/smc: use ib_device_get_netdev() helper to get netdev info
Date: Fri, 9 Aug 2024 16:31:46 +0800 [thread overview]
Message-ID: <20240809083148.1989912-3-liujian56@huawei.com> (raw)
In-Reply-To: <20240809083148.1989912-1-liujian56@huawei.com>
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@huawei.com>
---
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;
- 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
next prev parent reply other threads:[~2024-08-09 8:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 8:31 [PATCH net-next 0/4] Make SMC-R can work with rxe devices Liu Jian
2024-08-09 8:31 ` [PATCH net-next 1/4] rdma/device: export ib_device_get_netdev() Liu Jian
2024-08-09 8:31 ` Liu Jian [this message]
2024-08-09 14:59 ` [PATCH net-next 2/4] net/smc: use ib_device_get_netdev() helper to get netdev info Dust Li
2024-08-12 2:07 ` liujian (CE)
2024-08-12 2:43 ` Dust Li
2024-08-09 8:31 ` [PATCH net-next 3/4] net/smc: fix one NULL pointer dereference in smc_ib_is_sg_need_sync() Liu Jian
2024-08-09 10:01 ` Wen Gu
2024-08-09 14:59 ` Dust Li
2024-08-12 3:30 ` D. Wythe
2024-08-09 8:31 ` [PATCH net-next 4/4] RDMA/rxe: Set queue pair cur_qp_state when being queried Liu Jian
2024-08-09 11:06 ` Zhu Yanjun
2024-08-11 8:31 ` Leon Romanovsky
[not found] ` <bb0a5de8-f2d3-4276-ada4-f788f574b798@linux.dev>
2024-08-11 10:24 ` Zhu Yanjun
2024-08-11 6:05 ` [PATCH net-next 0/4] Make SMC-R can work with rxe devices Jan Karcher
2024-08-20 13:16 ` Jan Karcher
2024-08-21 1:03 ` Dust Li
2024-08-24 10:04 ` liujian (CE)
2024-08-26 19:04 ` Jan Karcher
2024-08-28 10:29 ` liujian (CE)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240809083148.1989912-3-liujian56@huawei.com \
--to=liujian56@huawei.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=jaka@linux.ibm.com \
--cc=jgg@ziepe.ca \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tonylu@linux.alibaba.com \
--cc=wenjia@linux.ibm.com \
--cc=zyjzyj2000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).