On Thu, Feb 21, 2019 at 09:46:18AM -0800, Jakub Kicinski wrote: > Instead of iterating over all devlink ports add a NDO which > will return the devlink instance from the driver. > > Suggested-by: Jiri Pirko <[email protected]> > Signed-off-by: Jakub Kicinski <[email protected]> > --- > include/linux/netdevice.h | 6 ++++ > net/core/devlink.c | 62 +++++++++++++-------------------------- > 2 files changed, 26 insertions(+), 42 deletions(-) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index aab4d9f6613d..eebcef6b8191 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -940,6 +940,8 @@ struct dev_ifalias { > char ifalias[]; > }; > > +struct devlink; > + > /* > * This structure defines the management hooks for network devices. > * The following hooks can be defined; unless noted otherwise, they are > @@ -1248,6 +1250,9 @@ struct dev_ifalias { > * that got dropped are freed/returned via xdp_return_frame(). > * Returns negative number, means general error invoking ndo, meaning > * no frames were xmit'ed and core-caller will free all frames. > + * struct devlink *(*ndo_get_devlink)(struct net_device *dev); > + * Get devlink instance associated with a given netdev. > + * Called with a reference on the device only, rtnl_lock is not held.
The formulation is a bit ambiguous. Do I understand correctly that what it says is that device reference is sufficient and rtnl_lock is not necessary (but there is no harm if caller holds rtnl_lock)? Michal
