All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	vivien.didelot@savoirfairelinux.com, andrew@lunn.ch,
	jiri@resnulli.us
Subject: Re: [PATCH net-next 3/4] net: switchdev: Add switchdev_port_bridge_getlink_deferred
Date: Mon, 9 Jan 2017 18:11:36 -0200	[thread overview]
Message-ID: <20170109201135.GE3771@localhost.localdomain> (raw)
In-Reply-To: <20170109194503.10713-4-f.fainelli@gmail.com>

On Mon, Jan 09, 2017 at 11:45:02AM -0800, Florian Fainelli wrote:
> Add switchdev_port_bridge_getlink_deferred() which does a deferred
> object dump operation, this is required for e.g: DSA switches which
> typically have sleeping I/O operations which is incompatible with being
> in atomic context obviously.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  include/net/switchdev.h   |  3 ++
>  net/switchdev/switchdev.c | 79 ++++++++++++++++++++++++++++++++++++++---------
>  2 files changed, 67 insertions(+), 15 deletions(-)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index eba80c4fc56f..087761b0df49 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -189,6 +189,9 @@ int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
>  int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
>  				  struct net_device *dev, u32 filter_mask,
>  				  int nlflags);
> +int switchdev_port_bridge_getlink_deferred(struct sk_buff *skb, u32 pid,
> +					   u32 seq, struct net_device *dev,
> +					   u32 filter_mask, int nlflags);
>  int switchdev_port_bridge_setlink(struct net_device *dev,
>  				  struct nlmsghdr *nlh, u16 flags);
>  int switchdev_port_bridge_dellink(struct net_device *dev,
> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
> index 4fa9972d72d2..ab614a9dd872 100644
> --- a/net/switchdev/switchdev.c
> +++ b/net/switchdev/switchdev.c
> @@ -776,12 +776,14 @@ static int switchdev_port_vlan_dump_cb(struct switchdev_obj *obj)
>  	return err;
>  }
>  
> -static int switchdev_port_vlan_fill(struct sk_buff *skb, struct net_device *dev,
> -				    u32 filter_mask)
> +static int __switchdev_port_vlan_fill(struct sk_buff *skb,
> +				      struct net_device *dev,
> +				      u32 filter_mask, u32 obj_flags)
>  {
>  	struct switchdev_vlan_dump dump = {
>  		.vlan.obj.orig_dev = dev,
>  		.vlan.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
> +		.vlan.obj.flags = obj_flags,
>  		.skb = skb,
>  		.filter_mask = filter_mask,
>  	};
> @@ -802,17 +804,27 @@ static int switchdev_port_vlan_fill(struct sk_buff *skb, struct net_device *dev,
>  	return err == -EOPNOTSUPP ? 0 : err;
>  }
>  
> -/**
> - *	switchdev_port_bridge_getlink - Get bridge port attributes
> - *
> - *	@dev: port device
> - *
> - *	Called for SELF on rtnl_bridge_getlink to get bridge port
> - *	attributes.
> - */
> -int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
> -				  struct net_device *dev, u32 filter_mask,
> -				  int nlflags)
> +static int switchdev_port_vlan_fill_deferred(struct sk_buff *skb,
> +					     struct net_device *dev,
> +					     u32 filter_mask)
> +{
> +	return __switchdev_port_vlan_fill(skb, dev, filter_mask,
> +					  SWITCHDEV_F_DEFER);
> +}
> +
> +static int switchdev_port_vlan_fill(struct sk_buff *skb,
> +				    struct net_device *dev,
> +				    u32 filter_mask)
> +{
> +	return __switchdev_port_vlan_fill(skb, dev, filter_mask, 0);
> +}
> +
> +static int __switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid,
> +					   u32 seq, struct net_device *dev,
> +					   u32 filter_mask, int nlflags,
> +					   int (*fill_cb)(struct sk_buff *skb,
> +							  struct net_device *d,
> +							  u32 filter_mask))
>  {
>  	struct switchdev_attr attr = {
>  		.orig_dev = dev,
> @@ -829,12 +841,49 @@ int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
>  	if (err && err != -EOPNOTSUPP)
>  		return err;
>  
> -	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode,
> +	return ndo_dflt_bridge_getlink(skb, pid, seq, d, mode,

Was this s/dev/d/ by mistake?

>  				       attr.u.brport_flags, mask, nlflags,
> -				       filter_mask, switchdev_port_vlan_fill);
> +				       filter_mask, fill_cb);
> +}
> +
> +/**
> + *	switchdev_port_bridge_getlink - Get bridge port attributes
> + *
> + *	@dev: port device
> + *
> + *	Called for SELF on rtnl_bridge_getlink to get bridge port
> + *	attributes.
> + */
> +int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
> +				  struct net_device *dev, u32 filter_mask,
> +				  int nlflags)
> +{
> +	return __switchdev_port_bridge_getlink(skb, pid, seq, dev, filter_mask,
> +					       nlflags,
> +					       switchdev_port_vlan_fill);
>  }
>  EXPORT_SYMBOL_GPL(switchdev_port_bridge_getlink);
>  
> +/**
> + *	switchdev_port_bridge_getlink_deferred - Get bridge port attributes
> + *	(deferred variant)
> + *
> + *	@dev: port device
> + *
> + *	Called for SELF on rtnl_bridge_getlink to get bridge port
> + *	attributes.
> + */
> +int switchdev_port_bridge_getlink_deferred(struct sk_buff *skb, u32 pid,
> +					   u32 seq, struct net_device *dev,
> +					   u32 filter_mask,
> +					   int nlflags)
> +{
> +	return __switchdev_port_bridge_getlink(skb, pid, seq, dev, filter_mask,
> +					       nlflags,
> +					       switchdev_port_vlan_fill_deferred);
> +}
> +EXPORT_SYMBOL_GPL(switchdev_port_bridge_getlink_deferred);
> +
>  static int switchdev_port_br_setflag(struct net_device *dev,
>  				     struct nlattr *nlattr,
>  				     unsigned long brport_flag)
> -- 
> 2.9.3
> 

  reply	other threads:[~2017-01-09 20:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 19:44 [PATCH net-next 0/4] net: switchdev: Avoid sleep in atomic with DSA Florian Fainelli
2017-01-09 19:45 ` [PATCH net-next 1/4] net: switchdev: Prepare for deferred functions modifying objects Florian Fainelli
2017-01-09 19:45 ` [PATCH net-next 2/4] net: switchdev: Add object dump deferred operation Florian Fainelli
2017-01-09 19:45 ` [PATCH net-next 3/4] net: switchdev: Add switchdev_port_bridge_getlink_deferred Florian Fainelli
2017-01-09 20:11   ` Marcelo Ricardo Leitner [this message]
2017-01-09 20:13     ` Florian Fainelli
2017-01-09 20:28       ` Marcelo Ricardo Leitner
2017-01-09 20:29         ` Florian Fainelli
2017-01-10  0:25   ` kbuild test robot
2017-01-09 19:45 ` [PATCH net-next 4/4] net: dsa: Utilize switchdev_port_bridge_getlink_deferred() Florian Fainelli
2017-01-09 20:48 ` [PATCH net-next 0/4] net: switchdev: Avoid sleep in atomic with DSA Ido Schimmel
2017-01-09 20:56   ` Florian Fainelli
2017-01-09 21:14     ` Ido Schimmel
2017-01-09 21:23       ` Andrew Lunn
2017-01-09 21:29         ` Ido Schimmel
2017-01-10 12:08       ` Jiri Pirko
2017-01-10 13:25         ` Ido Schimmel
2017-01-10 14:18           ` Jiri Pirko
2017-01-10 16:08             ` Ido Schimmel
2017-01-10 16:13               ` Jiri Pirko
2017-01-11  1:42               ` Florian Fainelli
2017-01-11 14:59                 ` Andrew Lunn
2017-01-09 21:19     ` Vivien Didelot
2017-01-11  1:26     ` David Miller
2017-01-09 21:05   ` Andrew Lunn

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=20170109201135.GE3771@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.