netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: davem@davemloft.net, jiri@resnulli.us, andrew@lunn.ch,
	f.fainelli@gmail.com, netdev@vger.kernel.org,
	oss-drivers@netronome.com
Subject: Re: [PATCH net-next 3/5] devlink: create a special NDO for getting the devlink instance
Date: Fri, 22 Feb 2019 08:56:30 -0800	[thread overview]
Message-ID: <20190222085630.6e9e764c@cakuba.netronome.com> (raw)
In-Reply-To: <20190222095131.GQ23151@unicorn.suse.cz>

On Fri, 22 Feb 2019 10:51:31 +0100, Michal Kubecek wrote:
> 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 <jiri@resnulli.us>
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > ---
> >  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)?

Yes, only reference is held, the expectation is that drivers free
netdevs before they unregister devlink.  The devlink vs rtnl ordering
gets a bit tricky, drivers should definitely not expect rtnl to be held
in this NDO.  If the caller comes from rtnl path (like ethtool) it will
likely have to release rtnl before taking devlink->lock.

  reply	other threads:[~2019-02-22 16:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 17:46 [PATCH net-next 0/5] devlink: make ethtool compat reliable Jakub Kicinski
2019-02-21 17:46 ` [PATCH net-next 1/5] net: devlink: turn devlink into a built-in Jakub Kicinski
2019-02-21 17:46 ` [PATCH net-next 2/5] ethtool: hold a reference to the netdevice around devlink compat Jakub Kicinski
2019-02-21 17:46 ` [PATCH net-next 3/5] devlink: create a special NDO for getting the devlink instance Jakub Kicinski
2019-02-22  9:51   ` Michal Kubecek
2019-02-22 16:56     ` Jakub Kicinski [this message]
2019-02-21 17:46 ` [PATCH net-next 4/5] nfp: add .ndo_get_devlink Jakub Kicinski
2019-02-22 10:04   ` Michal Kubecek
2019-02-22 17:02     ` Jakub Kicinski
2019-02-22 17:27       ` Michal Kubecek
2019-02-22 18:53         ` Jakub Kicinski
2019-02-21 17:46 ` [PATCH net-next 5/5] nfp: remove ethtool flashing fallback Jakub Kicinski

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=20190222085630.6e9e764c@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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).