Message ID | 20240809083148.1989912-3-liujian56@huawei.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | Make SMC-R can work with rxe devices | expand |
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 >
在 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 >>
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 --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);
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(-)