On Wed, Oct 19, 2022 at 09:08:14AM +0000, yanjun.zhu@xxxxxxxxx wrote: > October 18, 2022 4:24 PM, "Leon Romanovsky" <leon@xxxxxxxxxx> wrote: > > > On Sun, Oct 16, 2022 at 02:19:25AM -0400, Zhu Yanjun wrote: > > > >> From: Zhu Yanjun <yanjun.zhu@xxxxxxxxx> > >> > >> Before mlx5 ib device is registered, the function ib_device_set_netdev > >> is not called to map the mlx5 ib device with the related net device. > >> > >> As such, when the function ib_device_get_by_netdev is called to get ib > >> device, NULL is returned. > >> > >> Other ib devices, such as irdma, rxe and so on, the function > >> ib_device_get_by_netdev can get ib device from the related net device. > > > > Ohh, you opened Pandora box, everything around it looks half-backed. > > > > mlx4 and mlx5 don't call to ib_device_set_netdev(), because they have > > .get_netdev() callback. This callback is not an easy task to eliminate > > and many internal attempts failed to eliminate them. > > > > This caused to very questionable ksmbd_rdma_capable_netdev() > > implementation where ksmbd first checked internal ib_dev callback > > and tried to use ib_device_get_by_netdev(). And to smc_ib, which > > didn't even bother to use ib_device_get_by_netdev(). > > Thanks. > > I read the function ksmbd_rdma_capable_netdev carefully. > Mlx5 and mlx4 do not call ib_device_set_netdev to map net device and ib devices. > This brings a lot of problems. ULPs are not allowed to use these interfaces, they are for driver implementations. It is an error that ksmbd_rdma_capable_netdev() calls it in the first place. Jason