diff mbox series

[net-next,2/4] net/smc: use ib_device_get_netdev() helper to get netdev info

Message ID 20240809083148.1989912-3-liujian56@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Make SMC-R can work with rxe devices | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 33 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-09--15-00 (tests: 705)

Commit Message

liujian (CE) Aug. 9, 2024, 8:31 a.m. UTC
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(-)

Comments

Dust Li Aug. 9, 2024, 2:59 p.m. UTC | #1
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@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;

Why remove this check ?

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
>
liujian (CE) Aug. 12, 2024, 2:07 a.m. UTC | #2
在 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@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;
> 
> 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
>>
Dust Li Aug. 12, 2024, 2:43 a.m. UTC | #3
On 2024-08-12 10:07:42, liujian (CE) wrote:
>
>
>在 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@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;
>> 
>> Why remove this check ?
>> 
>Hi, Dust,
>The same check is already in ib_device_get_netdev().

Oh I see, thanks !

Reviewed-by: Dust Li <dust.li@linux.alibaba.com>

>> 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
>> >
diff mbox series

Patch

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);