All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@mellanox.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:STAGING SUBSYSTEM" <devel@driverdev.osuosl.org>,
	"moderated list:ETHERNET BRIDGE"
	<bridge@lists.linux-foundation.org>,
	Jiri Pirko <jiri@mellanox.com>, "andrew@lunn.ch" <andrew@lunn.ch>,
	"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>
Subject: Re: [PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET
Date: Sat, 23 Feb 2019 10:33:48 +0000	[thread overview]
Message-ID: <20190223103330.GB13070@splinter> (raw)
In-Reply-To: <20190222235927.10295-2-f.fainelli@gmail.com>

On Fri, Feb 22, 2019 at 03:59:19PM -0800, Florian Fainelli wrote:
> In preparation for allowing switchdev enabled drivers to veto specific
> attribute settings from within the context of the caller, introduce a
> new switchdev notifier type for port attributes.
> 
> Suggested-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  include/net/switchdev.h   | 27 +++++++++++++++++++++
>  net/switchdev/switchdev.c | 51 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 78 insertions(+)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index 45310ddf2d7e..ca56b7487540 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -136,6 +136,7 @@ enum switchdev_notifier_type {
>  
>  	SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
>  	SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
> +	SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */

See my comment on 7/8. IIUC, this is always blocking, so comment needs to
be changed.

>  
>  	SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
>  	SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
> @@ -164,6 +165,13 @@ struct switchdev_notifier_port_obj_info {
>  	bool handled;
>  };
>  
> +struct switchdev_notifier_port_attr_info {
> +	struct switchdev_notifier_info info; /* must be first */
> +	const struct switchdev_attr *attr;
> +	struct switchdev_trans *trans;
> +	bool handled;
> +};
> +
>  static inline struct net_device *
>  switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
>  {
> @@ -216,7 +224,15 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
>  			int (*del_cb)(struct net_device *dev,
>  				      const struct switchdev_obj *obj));
>  
> +int switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans));
> +
>  #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
> +
>  #else
>  
>  static inline void switchdev_deferred_process(void)
> @@ -303,6 +319,17 @@ switchdev_handle_port_obj_del(struct net_device *dev,
>  	return 0;
>  }
>  
> +static inline int
> +switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	return 0;
> +}
> +
>  #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
>  
>  #endif
> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
> index 7e1357db33d7..94400f5b8e07 100644
> --- a/net/switchdev/switchdev.c
> +++ b/net/switchdev/switchdev.c
> @@ -697,3 +697,54 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
>  	return err;
>  }
>  EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del);
> +
> +static int __switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	struct net_device *lower_dev;
> +	struct list_head *iter;
> +	int err = -EOPNOTSUPP;
> +
> +	if (check_cb(dev)) {
> +		port_attr_info->handled = true;
> +		return set_cb(dev, port_attr_info->attr,
> +			      port_attr_info->trans);
> +	}
> +
> +	/* Switch ports might be stacked under e.g. a LAG. Ignore the
> +	 * unsupported devices, another driver might be able to handle them. But
> +	 * propagate to the callers any hard errors.
> +	 *
> +	 * If the driver does its own bookkeeping of stacked ports, it's not
> +	 * necessary to go through this helper.
> +	 */
> +	netdev_for_each_lower_dev(dev, lower_dev, iter) {
> +		err = __switchdev_handle_port_attr_set(lower_dev, port_attr_info,
> +						       check_cb, set_cb);
> +		if (err && err != -EOPNOTSUPP)
> +			return err;
> +	}
> +
> +	return err;
> +}
> +
> +int switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	int err;
> +
> +	err = __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb,
> +					       set_cb);
> +	if (err == -EOPNOTSUPP)
> +		err = 0;
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(switchdev_handle_port_attr_set);
> -- 
> 2.17.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Ido Schimmel <idosch@mellanox.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "open list:STAGING SUBSYSTEM" <devel@driverdev.osuosl.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"moderated list:ETHERNET BRIDGE"
	<bridge@lists.linux-foundation.org>,
	open list <linux-kernel@vger.kernel.org>,
	"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>,
	Jiri Pirko <jiri@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Bridge] [PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET
Date: Sat, 23 Feb 2019 10:33:48 +0000	[thread overview]
Message-ID: <20190223103330.GB13070@splinter> (raw)
In-Reply-To: <20190222235927.10295-2-f.fainelli@gmail.com>

On Fri, Feb 22, 2019 at 03:59:19PM -0800, Florian Fainelli wrote:
> In preparation for allowing switchdev enabled drivers to veto specific
> attribute settings from within the context of the caller, introduce a
> new switchdev notifier type for port attributes.
> 
> Suggested-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  include/net/switchdev.h   | 27 +++++++++++++++++++++
>  net/switchdev/switchdev.c | 51 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 78 insertions(+)
> 
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index 45310ddf2d7e..ca56b7487540 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -136,6 +136,7 @@ enum switchdev_notifier_type {
>  
>  	SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
>  	SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
> +	SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */

See my comment on 7/8. IIUC, this is always blocking, so comment needs to
be changed.

>  
>  	SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
>  	SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
> @@ -164,6 +165,13 @@ struct switchdev_notifier_port_obj_info {
>  	bool handled;
>  };
>  
> +struct switchdev_notifier_port_attr_info {
> +	struct switchdev_notifier_info info; /* must be first */
> +	const struct switchdev_attr *attr;
> +	struct switchdev_trans *trans;
> +	bool handled;
> +};
> +
>  static inline struct net_device *
>  switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
>  {
> @@ -216,7 +224,15 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
>  			int (*del_cb)(struct net_device *dev,
>  				      const struct switchdev_obj *obj));
>  
> +int switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans));
> +
>  #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
> +
>  #else
>  
>  static inline void switchdev_deferred_process(void)
> @@ -303,6 +319,17 @@ switchdev_handle_port_obj_del(struct net_device *dev,
>  	return 0;
>  }
>  
> +static inline int
> +switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	return 0;
> +}
> +
>  #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
>  
>  #endif
> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
> index 7e1357db33d7..94400f5b8e07 100644
> --- a/net/switchdev/switchdev.c
> +++ b/net/switchdev/switchdev.c
> @@ -697,3 +697,54 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
>  	return err;
>  }
>  EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del);
> +
> +static int __switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	struct net_device *lower_dev;
> +	struct list_head *iter;
> +	int err = -EOPNOTSUPP;
> +
> +	if (check_cb(dev)) {
> +		port_attr_info->handled = true;
> +		return set_cb(dev, port_attr_info->attr,
> +			      port_attr_info->trans);
> +	}
> +
> +	/* Switch ports might be stacked under e.g. a LAG. Ignore the
> +	 * unsupported devices, another driver might be able to handle them. But
> +	 * propagate to the callers any hard errors.
> +	 *
> +	 * If the driver does its own bookkeeping of stacked ports, it's not
> +	 * necessary to go through this helper.
> +	 */
> +	netdev_for_each_lower_dev(dev, lower_dev, iter) {
> +		err = __switchdev_handle_port_attr_set(lower_dev, port_attr_info,
> +						       check_cb, set_cb);
> +		if (err && err != -EOPNOTSUPP)
> +			return err;
> +	}
> +
> +	return err;
> +}
> +
> +int switchdev_handle_port_attr_set(struct net_device *dev,
> +			struct switchdev_notifier_port_attr_info *port_attr_info,
> +			bool (*check_cb)(const struct net_device *dev),
> +			int (*set_cb)(struct net_device *dev,
> +				      const struct switchdev_attr *attr,
> +				      struct switchdev_trans *trans))
> +{
> +	int err;
> +
> +	err = __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb,
> +					       set_cb);
> +	if (err == -EOPNOTSUPP)
> +		err = 0;
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(switchdev_handle_port_attr_set);
> -- 
> 2.17.1
> 

  reply	other threads:[~2019-02-23 10:33 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 23:59 [PATCH net-next 0/8] net: Remove switchdev_ops Florian Fainelli
2019-02-22 23:59 ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-23 10:33   ` Ido Schimmel [this message]
2019-02-23 10:33     ` Ido Schimmel
2019-02-22 23:59 ` [PATCH net-next 2/8] rocker: Handle SWITCHDEV_PORT_ATTR_SET Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH net-next 3/8] net: dsa: " Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH net-next 4/8] mlxsw: spectrum_switchdev: " Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-23 10:36   ` Ido Schimmel
2019-02-23 10:36     ` [Bridge] " Ido Schimmel
2019-02-22 23:59 ` [PATCH net-next 5/8] net: mscc: ocelot: " Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH net-next 6/8] staging: fsl-dpaa2: ethsw: " Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH net-next 7/8] net: switchdev: Replace port attr set SDO with a notification Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-23 10:32   ` Ido Schimmel
2019-02-23 10:32     ` [Bridge] " Ido Schimmel
2019-02-24 16:47     ` Florian Fainelli
2019-02-24 16:47       ` [Bridge] " Florian Fainelli
2019-02-25  9:49       ` Ido Schimmel
2019-02-25  9:49         ` [Bridge] " Ido Schimmel
2019-02-25 19:47         ` Florian Fainelli
2019-02-25 19:47           ` [Bridge] " Florian Fainelli
2019-02-27 12:32           ` Ido Schimmel
2019-02-27 12:32             ` [Bridge] " Ido Schimmel
2019-02-22 23:59 ` [PATCH net-next 8/8] net: Remove switchdev_ops Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli
2019-02-22 23:59 ` [PATCH 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET Florian Fainelli
2019-02-22 23:59   ` [Bridge] " Florian Fainelli

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=20190223103330.GB13070@splinter \
    --to=idosch@mellanox.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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.