From: Ivan Vecera <ivecera@redhat.com>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org,
davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com,
roopa@nvidia.com, nikolay@nvidia.com, amcohen@nvidia.com,
danieller@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com,
Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH net-next 7/9] bridge: switchdev: Notify about VLAN protocol changes
Date: Mon, 30 Nov 2020 16:43:13 +0100 [thread overview]
Message-ID: <20201130164313.535b6efa@ceranb> (raw)
In-Reply-To: <20201129125407.1391557-8-idosch@idosch.org>
On Sun, 29 Nov 2020 14:54:05 +0200
Ido Schimmel <idosch@idosch.org> wrote:
> From: Danielle Ratson <danieller@nvidia.com>
>
> Drivers that support bridge offload need to be notified about changes to
> the bridge's VLAN protocol so that they could react accordingly and
> potentially veto the change.
>
> Add a new switchdev attribute to communicate the change to drivers.
>
> Signed-off-by: Danielle Ratson <danieller@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
> include/net/switchdev.h | 2 ++
> net/bridge/br_vlan.c | 16 ++++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index 53e8b4994296..99cd538d6519 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -38,6 +38,7 @@ enum switchdev_attr_id {
> SWITCHDEV_ATTR_ID_PORT_MROUTER,
> SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
> SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
> + SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL,
> SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
> SWITCHDEV_ATTR_ID_BRIDGE_MROUTER,
> #if IS_ENABLED(CONFIG_BRIDGE_MRP)
> @@ -58,6 +59,7 @@ struct switchdev_attr {
> bool mrouter; /* PORT_MROUTER */
> clock_t ageing_time; /* BRIDGE_AGEING_TIME */
> bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */
> + u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */
> bool mc_disabled; /* MC_DISABLED */
> #if IS_ENABLED(CONFIG_BRIDGE_MRP)
> u8 mrp_port_state; /* MRP_PORT_STATE */
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index 11f54a7c0d1d..d07008678d32 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -854,15 +854,25 @@ EXPORT_SYMBOL_GPL(br_vlan_get_proto);
>
> int __br_vlan_set_proto(struct net_bridge *br, __be16 proto)
> {
> + struct switchdev_attr attr = {
> + .orig_dev = br->dev,
> + .id = SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL,
> + .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
> + .u.vlan_protocol = ntohs(proto),
> + };
> int err = 0;
> struct net_bridge_port *p;
> struct net_bridge_vlan *vlan;
> struct net_bridge_vlan_group *vg;
> - __be16 oldproto;
> + __be16 oldproto = br->vlan_proto;
>
> if (br->vlan_proto == proto)
> return 0;
>
> + err = switchdev_port_attr_set(br->dev, &attr);
> + if (err && err != -EOPNOTSUPP)
> + return err;
> +
> /* Add VLANs for the new proto to the device filter. */
> list_for_each_entry(p, &br->port_list, list) {
> vg = nbp_vlan_group(p);
> @@ -873,7 +883,6 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto)
> }
> }
>
> - oldproto = br->vlan_proto;
> br->vlan_proto = proto;
>
> recalculate_group_addr(br);
> @@ -889,6 +898,9 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto)
> return 0;
>
> err_filt:
> + attr.u.vlan_protocol = ntohs(oldproto);
> + switchdev_port_attr_set(br->dev, &attr);
> +
> list_for_each_entry_continue_reverse(vlan, &vg->vlan_list, vlist)
> vlan_vid_del(p->dev, proto, vlan->vid);
>
Reviewed-by: Ivan Vecera <ivecera@redhat.com>
next prev parent reply other threads:[~2020-11-30 15:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-29 12:53 [PATCH net-next 0/9] mlxsw: Add support for 802.1ad bridging Ido Schimmel
2020-11-29 12:53 ` [PATCH net-next 1/9] mlxsw: reg: Add Switch Port VLAN Classification Register Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 2/9] mlxsw: reg: Add et_vlan field to SPVID register Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 3/9] mlxsw: spectrum: Only treat 802.1q packets as tagged packets Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 4/9] mlxsw: Make EtherType configurable when pushing VLAN at ingress Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 5/9] mlxsw: spectrum_switchdev: Create common functions for VLAN-aware bridge Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 6/9] mlxsw: spectrum_switchdev: Add support of QinQ traffic Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 7/9] bridge: switchdev: Notify about VLAN protocol changes Ido Schimmel
2020-11-30 15:43 ` Ivan Vecera [this message]
2020-11-29 12:54 ` [PATCH net-next 8/9] mlxsw: Add QinQ configuration vetoes Ido Schimmel
2020-11-29 12:54 ` [PATCH net-next 9/9] selftests: forwarding: Add QinQ veto testing Ido Schimmel
2020-12-01 23:40 ` [PATCH net-next 0/9] mlxsw: Add support for 802.1ad bridging patchwork-bot+netdevbpf
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=20201130164313.535b6efa@ceranb \
--to=ivecera@redhat.com \
--cc=amcohen@nvidia.com \
--cc=bridge@lists.linux-foundation.org \
--cc=danieller@nvidia.com \
--cc=davem@davemloft.net \
--cc=idosch@idosch.org \
--cc=idosch@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=petrm@nvidia.com \
--cc=roopa@nvidia.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