netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roopa Prabhu <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, linville@tuxdriver.com,
	vyasevic@redhat.com, netdev@vger.kernel.org, davem@davemloft.net,
	shm@cumulusnetworks.com, gospo@cumulusnetworks.com
Subject: Re: [PATCH net-next v2 2/4] swdevice: add new api to set and del bridge port attributes
Date: Thu, 11 Dec 2014 09:59:15 -0800	[thread overview]
Message-ID: <5489DB73.1080808@cumulusnetworks.com> (raw)
In-Reply-To: <20141211171145.GG1912@nanopsycho.orion>

On 12/11/14, 9:11 AM, Jiri Pirko wrote:
> Thu, Dec 11, 2014 at 05:52:10PM CET, roopa@cumulusnetworks.com wrote:
>> On 12/10/14, 1:37 AM, Jiri Pirko wrote:
>>> Wed, Dec 10, 2014 at 10:05:18AM CET, roopa@cumulusnetworks.com wrote:
>>>> From: Roopa Prabhu <roopa@cumulusnetworks.com>
>>>>
>>>> This patch adds two new api's netdev_switch_port_bridge_setlink
>>>> and netdev_switch_port_bridge_dellink to offload bridge port attributes
>>>> to switch asic
>>>>
>>>> (The names of the apis look odd with 'switch_port_bridge',
>>>> but am more inclined to change the prefix of the api to something else.
>>>> Will take any suggestions).
>>>>
>>>> The api's look at the NETIF_F_HW_NETFUNC_OFFLOAD feature flag to
>>>> pass bridge port attributes to the port device.
>>>>
>>>> If the device has the NETIF_F_HW_NETFUNC_OFFLOAD, but does not support
>>>> the bridge port attribute offload ndo, call bridge port attribute ndo's on
>>>> the lowerdevs if supported. This is one way to pass bridge port attributes
>>>> through stacked netdevs (example when bridge port is a bond and bond slaves
>>>> are switch ports).
>>>>
>>>> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
>>>> ---
>>>> include/net/switchdev.h   |    5 +++-
>>>> net/switchdev/switchdev.c |   70 +++++++++++++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 74 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
>>>> index 8a6d164..22676b6 100644
>>>> --- a/include/net/switchdev.h
>>>> +++ b/include/net/switchdev.h
>>>> @@ -17,7 +17,10 @@
>>>> int netdev_switch_parent_id_get(struct net_device *dev,
>>>> 				struct netdev_phys_item_id *psid);
>>>> int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
>>>> -
>>>> +int netdev_switch_port_bridge_setlink(struct net_device *dev,
>>>> +				struct nlmsghdr *nlh, u16 flags);
>>>> +int netdev_switch_port_bridge_dellink(struct net_device *dev,
>>>> +				struct nlmsghdr *nlh, u16 flags);
>>>> #else
>>>>
>>>> static inline int netdev_switch_parent_id_get(struct net_device *dev,
>>>> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
>>>> index d162b21..62317e1 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);
>>> 	You have to change ndo_bridge_setlink in netdevice.h first.
>>> 	Otherwise when only this patch is applied (during bisection)
>>> 	this won't compile.
>> ack, will fix it and keep that in mind next time.
>>>> +	}
>>>> +
>>>> +	netdev_for_each_lower_dev(dev, lower_dev, iter) {
>>> 	I do not understand why to iterate over lower devices. At this
>>> 	stage we don't know a thing about this upper or its lowers. Let
>>> 	the uppers (/masters) to decide if this needs to be propagated
>>> 	or not.
>> Jiri, In the stacked devices case, there is no way to propagate the bridge
>> port attributes to switch device driver today (vlan and other bridge port
>> attributes). Can you tell me if there is a way ?. no, ndo_vlan* ndo's are not
>> useful here. Nor we should go and implement ndo_bridge_setlink* in all
>> devices that can be bridge ports.
>
> Hmm. I just think that is cleaner to implement ndo_bridge_setlink in
> bonding for example and let it propagate the the call to slaves.
No, that will require bridge attribute support in all drivers. And that 
is no good.
> Let every "upper" to handle ndo_bridge_setlink their way. Sometimes it
> might not make sense to propagate to "lowers".

This does not really propagate to lowers. It is just trying to get to a 
switch port and from there to the switch driver.
Example, bond driver does not need to care if its a bridge port. It will 
simply pass the call to its slave which
might be a switch port.

bond driver does not care if its a bridge port. But the switch driver 
cares,  because it knows that the bond was created with switch ports.


>
>> And this allows a switch driver to receive these callbacks if it has marked
>> the switch port with an offload flag. Your way of using the switch port to
>> get to the switch driver does not help in these cases.
> I do not follow how this is related to this case (stacked layout).
>
>> The other option is to use the 'switch device (not port)' to get to the
>> switch driver.
>
> That would not help this case (stacked layout) I believe.
>
>
>> This patch shows that you can still do this with the ndo ops.
>>>> +		err = netdev_switch_port_bridge_setlink(lower_dev, nlh, flags);
>>>> +		if (err)
>>>> +			ret = err;
>>>> +    }
>>>   ^^^^^ Indent is off. This should be catched by scripts/checkpatch.pl.
>>>
>>>> +
>>>> +	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
>>>>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-12-11 17:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10  9:05 [PATCH net-next v2 2/4] swdevice: add new api to set and del bridge port attributes roopa
2014-12-10  9:37 ` Jiri Pirko
2014-12-11 16:52   ` Roopa Prabhu
2014-12-11 17:11     ` Jiri Pirko
2014-12-11 17:59       ` Roopa Prabhu [this message]
2014-12-11 18:07         ` Jiri Pirko
2014-12-11 18:27           ` Roopa Prabhu
2014-12-11 22:25             ` Jiri Pirko
2014-12-14 14:13               ` Roopa Prabhu
2014-12-14 15:35                 ` Jiri Pirko
2014-12-14 19:41                   ` Roopa Prabhu
2014-12-15 15:26                     ` Jamal Hadi Salim
2014-12-15 17:20                       ` Roopa Prabhu
2014-12-15 18:03                         ` Benjamin LaHaise
2014-12-15 17:25                       ` Arad, Ronen
2014-12-15 17:57                         ` Benjamin LaHaise
2014-12-15 17:57                         ` John Fastabend
2014-12-15 18:36                           ` Arad, Ronen
2014-12-15 23:27                             ` Jamal Hadi Salim
2014-12-16  0:58                               ` Arad, Ronen
2014-12-16  1:20                                 ` Roopa Prabhu
2014-12-16 11:01                                   ` Arad, Ronen
2014-12-16 15:54                                     ` Samudrala, Sridhar
2014-12-16 16:41                                     ` John Fastabend
2014-12-16 17:29                                       ` Arad, Ronen
2014-12-16 19:23                                         ` B Viswanath
2014-12-16 20:52                                           ` Arad, Ronen
2014-12-16 21:51                                             ` B Viswanath
2014-12-16 22:46                                               ` Arad, Ronen
2014-12-16 19:25                                         ` Roopa Prabhu
2014-12-16 19:20                                     ` Roopa Prabhu

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=5489DB73.1080808@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=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --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 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).