From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, idosch@mellanox.com,
eladr@mellanox.com, sfeldma@gmail.com, f.fainelli@gmail.com,
linux@roeck-us.net, andrew@lunn.ch, john.fastabend@gmail.com,
David.Laight@ACULAB.COM
Subject: Re: [patch net-next] bridge: try switchdev op first in __vlan_vid_add/del
Date: Fri, 9 Oct 2015 18:44:06 -0400 [thread overview]
Message-ID: <20151009224405.GA25393@ketchup.mtl.sfl> (raw)
In-Reply-To: <1444391651-13775-1-git-send-email-jiri@resnulli.us>
Hi Jiri,
On Oct. Friday 09 (41) 01:54 PM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Some drivers need to implement both switchdev vlan ops and
> vid_add/kill ndos. For that to work in bridge code, we need to try
> switchdev op first when adding/deleting vlan id.
Just curious, when would a driver need to have both operations?
I kinda have the same question regarding ndo_fdb_{add,del} and the
bridge_{get,set}link equivalent, which is a bit confusing to me.
>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> ---
> net/bridge/br_vlan.c | 58 ++++++++++++++++++++--------------------------------
> 1 file changed, 22 insertions(+), 36 deletions(-)
>
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index eae07ee..975deb9 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -72,28 +72,20 @@ static void __vlan_add_flags(struct net_bridge_vlan *v, u16 flags)
> static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
> u16 vid, u16 flags)
> {
> - const struct net_device_ops *ops = dev->netdev_ops;
> + struct switchdev_obj_port_vlan v = {
> + .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
> + .flags = flags,
> + .vid_begin = vid,
> + .vid_end = vid,
> + };
> int err;
>
> - /* If driver uses VLAN ndo ops, use 8021q to install vid
> - * on device, otherwise try switchdev ops to install vid.
> + /* Try switchdev op first. In case it is not supported, fallback to
> + * 8021q add.
> */
> -
> - if (ops->ndo_vlan_rx_add_vid) {
> - err = vlan_vid_add(dev, br->vlan_proto, vid);
> - } else {
> - struct switchdev_obj_port_vlan v = {
> - .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
> - .flags = flags,
> - .vid_begin = vid,
> - .vid_end = vid,
> - };
> -
> - err = switchdev_port_obj_add(dev, &v.obj);
> - if (err == -EOPNOTSUPP)
> - err = 0;
> - }
> -
> + err = switchdev_port_obj_add(dev, &v.obj);
> + if (err == -EOPNOTSUPP)
> + return vlan_vid_add(dev, br->vlan_proto, vid);
err = vlan_vid_add(dev, br->vlan_proto, vid);
Just being picky: the above line would have been preferred to keep a
single return path, but this does not justify a v2 though.
> return err;
> }
Thanks,
-v
next prev parent reply other threads:[~2015-10-09 22:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 11:54 [patch net-next] bridge: try switchdev op first in __vlan_vid_add/del Jiri Pirko
2015-10-09 22:44 ` Vivien Didelot [this message]
2015-10-10 3:20 ` Scott Feldman
2015-10-10 7:01 ` Jiri Pirko
2015-10-10 18:16 ` Florian Fainelli
2015-10-10 16:03 ` Vivien Didelot
2015-10-12 4:20 ` Scott Feldman
2015-10-10 3:12 ` Scott Feldman
2015-10-13 2:35 ` David Miller
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=20151009224405.GA25393@ketchup.mtl.sfl \
--to=vivien.didelot@savoirfairelinux.com \
--cc=David.Laight@ACULAB.COM \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=eladr@mellanox.com \
--cc=f.fainelli@gmail.com \
--cc=idosch@mellanox.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=sfeldma@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 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).