All of lore.kernel.org
 help / color / mirror / Atom feed
From: roopa <roopa@cumulusnetworks.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: sfeldma@gmail.com, jhs@mojatatu.com, bcrl@kvack.org,
	tgraf@suug.ch, john.fastabend@gmail.com,
	stephen@networkplumber.org, vyasevic@redhat.com,
	ronen.arad@intel.com, netdev@vger.kernel.org,
	davem@davemloft.net, shm@cumulusnetworks.com,
	gospo@cumulusnetworks.com
Subject: Re: [PATCH net-next v3 2/5] swdevice: add new api to set and del bridge port attributes
Date: Fri, 23 Jan 2015 07:58:57 -0800	[thread overview]
Message-ID: <54C26FC1.70605@cumulusnetworks.com> (raw)
In-Reply-To: <20150123104127.GC2065@nanopsycho.orion>

On 1/23/15, 2:41 AM, Jiri Pirko wrote:

<snip..>
>
> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
> index d162b21..bf0be98 100644
> --- a/net/switchdev/switchdev.c
> +++ b/net/switchdev/switchdev.c
> @@ -50,3 +50,73 @@ int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
> 	return ops->ndo_switch_port_stp_update(dev, state);
> }
> EXPORT_SYMBOL(netdev_switch_port_stp_update);
> +
> +/**
> + *	netdev_switch_port_bridge_setlink - Notify switch device port of bridge
> + *	port attributes
> + *
> + *	@dev: port device
> + *	@nlh: netlink msg with bridge port attributes
> + *
> + *	Notify switch device port of bridge port attributes
> + */
> +int netdev_switch_port_bridge_setlink(struct net_device *dev,
> +				      struct nlmsghdr *nlh, u16 flags)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +	struct net_device *lower_dev;
> +	struct list_head *iter;
> +	int ret = 0, err = 0;
> +
> +	if (!(dev->features & NETIF_F_HW_NETFUNC_OFFLOAD))
> +		return err;
> +
> +	if (ops->ndo_bridge_setlink) {
> +		WARN_ON(!ops->ndo_switch_parent_id_get);
> +		return ops->ndo_bridge_setlink(dev, nlh, flags);
> +	}
> +
> +	netdev_for_each_lower_dev(dev, lower_dev, iter) {
> +		err = netdev_switch_port_bridge_setlink(lower_dev, nlh, flags);
> +		if (err)
> +			ret = err;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(netdev_switch_port_bridge_setlink);
> +
> +/**
> + *	netdev_switch_port_bridge_dellink - Notify switch device port of bridge
> + *	attribute delete
> + *
> + *	@dev: port device
> + *	@nlh: netlink msg with bridge port attributes
> + *
> + *	Notify switch device port of bridge port attribute delete
> + */
> +int netdev_switch_port_bridge_dellink(struct net_device *dev,
> +				      struct nlmsghdr *nlh, u16 flags)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +	struct net_device *lower_dev;
> +	struct list_head *iter;
> +	int ret = 0, err = 0;
> +
> +	if (!(dev->features & NETIF_F_HW_NETFUNC_OFFLOAD))
> +		return err;
> +
> +	if (ops->ndo_bridge_dellink) {
> +		WARN_ON(!ops->ndo_switch_parent_id_get);
> +		return ops->ndo_bridge_dellink(dev, nlh, flags);
> +	}
> +
> +	netdev_for_each_lower_dev(dev, lower_dev, iter) {
> +		err = netdev_switch_port_bridge_dellink(lower_dev, nlh, flags);
> +		if (err)
> +			ret = err;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(netdev_switch_port_bridge_dellink);
> -- 
> 1.7.10.4
>
> Is there any other place, other than bridge code, this functions are
> suppored to be called from?
No other place today. Its usually the master that implements 
ndo_bridge_setlink/dellink.

> If not, which I consider likely, it would
> make more sense to me to:
>
> - move netdev_for_each_lower_dev iterations directly to bridge code
> - let the masters (bond, team, ..) implement ndo_bridge_*link and do
>    the traversing there (can be in a form of pre-prepared default
>    ndo callback (ndo_dflt_netdev_switch_port_bridge_*link)
But, i am still not understanding why i would modify bond, team and 
other slaves
to offload bridge attributes. They could independently do so in the 
future if they
want to do something more than what this default api provides.
The api's setlink/dellink provided by this patch are the default api's.
The drivers can override them if needed in the future (which aligns with 
what you want as well).

Thanks,
Roopa

  reply	other threads:[~2015-01-23 15:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23  4:33 [PATCH net-next v3 2/5] swdevice: add new api to set and del bridge port attributes roopa
2015-01-23 10:41 ` Jiri Pirko
2015-01-23 15:58   ` roopa [this message]
2015-01-23 16:06     ` Jiri Pirko
2015-01-23 22:45       ` roopa
2015-01-23 23:10         ` roopa
2015-01-24 11:26           ` Jiri Pirko
2015-01-25  1:03             ` roopa
2015-01-23 11:24 ` Rosen, Rami

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=54C26FC1.70605@cumulusnetworks.com \
    --to=roopa@cumulusnetworks.com \
    --cc=bcrl@kvack.org \
    --cc=davem@davemloft.net \
    --cc=gospo@cumulusnetworks.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=ronen.arad@intel.com \
    --cc=sfeldma@gmail.com \
    --cc=shm@cumulusnetworks.com \
    --cc=stephen@networkplumber.org \
    --cc=tgraf@suug.ch \
    --cc=vyasevic@redhat.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.