From: Nikolay Aleksandrov <nikolay@nvidia.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Roopa Prabhu <roopa@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
Ido Schimmel <idosch@nvidia.com>,
Rafael Richter <rafael.richter@gin.de>,
Daniel Klauer <daniel.klauer@gin.de>,
Tobias Waldekranz <tobias@waldekranz.com>
Subject: Re: [PATCH v2 net-next 1/8] net: bridge: vlan: notify switchdev only when something changed
Date: Tue, 15 Feb 2022 17:44:52 +0200 [thread overview]
Message-ID: <49709ba6-7f4f-493d-88c9-553d7c300397@nvidia.com> (raw)
In-Reply-To: <20220215153803.hlibqjxa4b5x2kup@skbuf>
On 15/02/2022 17:38, Vladimir Oltean wrote:
> Hi Nikolay,
>
> On Tue, Feb 15, 2022 at 01:08:13PM +0200, Nikolay Aleksandrov wrote:
>> +static bool __vlan_add_flags(struct net_bridge_vlan *v, u16 flags, bool commit)
>> {
>> struct net_bridge_vlan_group *vg;
>> - u16 old_flags = v->flags;
>> - bool ret;
>> + bool change;
>>
>> if (br_vlan_is_master(v))
>> vg = br_vlan_group(v->br);
>> else
>> vg = nbp_vlan_group(v->port);
>>
>> + /* check if anything would be changed on commit */
>> + change = (!!(flags & BRIDGE_VLAN_INFO_PVID) == !!(vg->pvid != v->vid) ||
>> + ((flags ^ v->flags) & BRIDGE_VLAN_INFO_UNTAGGED));
>> +
>> + if (!commit)
>> + goto out;
>> +
>> if (flags & BRIDGE_VLAN_INFO_PVID)
>> - ret = __vlan_add_pvid(vg, v);
>> + __vlan_add_pvid(vg, v);
>> else
>> - ret = __vlan_delete_pvid(vg, v->vid);
>> + __vlan_delete_pvid(vg, v->vid);
>>
>> if (flags & BRIDGE_VLAN_INFO_UNTAGGED)
>> v->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
>> else
>> v->flags &= ~BRIDGE_VLAN_INFO_UNTAGGED;
>>
>> - return ret || !!(old_flags ^ v->flags);
>> +out:
>> + return change;
>> +}
>
> I'm really sorry that I keep insisting, but could you please clarify
> something for me.
>
> Here you change the behavior of __vlan_add_flags(): yes, it only changes
> BRIDGE_VLAN_INFO_UNTAGGED and BRIDGE_VLAN_INFO_PVID, but it used to
> return true if other flags changed as well, like BRIDGE_VLAN_INFO_BRENTRY.
> Now it does not, since you've explicitly made it so, and for good
> reason: make the function do what it says on the box.
>
> However, this forces me to add extra logic in br_vlan_add_existing()
> such that a transition of master vlan flags from !BRENTRY -> BRENTRY is
> still notified to switchdev.
>
> Which begs the question, why exactly do we even bother to notify to
> switchdev master VLANs that aren't brentries?! All drivers that I could
> find just ignore VLANs that aren't brentries.
>
> I can suppress the switchdev notification of these private bridge data
> structures like this, and nothing else seems to be affected:
>
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index 6fc2e366f13a..4607689c4e6a 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -300,10 +300,12 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
> }
> br_multicast_port_ctx_init(p, v, &v->port_mcast_ctx);
> } else {
> - err = br_switchdev_port_vlan_add(dev, v->vid, flags, false, 0,
> - extack);
> - if (err && err != -EOPNOTSUPP)
> - goto out;
> + if (br_vlan_should_use(v)) {
> + err = br_switchdev_port_vlan_add(dev, v->vid, flags,
> + false, 0, extack);
> + if (err && err != -EOPNOTSUPP)
> + goto out;
> + }
> br_multicast_ctx_init(br, v, &v->br_mcast_ctx);
> v->priv_flags |= BR_VLFLAG_GLOBAL_MCAST_ENABLED;
> }
>
> Would you mind if I added an extra patch that also does this (it would
> also remove the need for this check in drivers, plus it would change the
> definition of "changed" to something IMO more reasonable, i.e. a master
> VLAN that isn't brentry doesn't really exist, so even though the
> !BRENTRY->BRENTRY is a flag change, it isn't a change of a switchdev
> VLAN object that anybody offloads), or is there some reason I'm missing?
I agree, patch looks good to me. I see that everyone already filters the
!BRENTRY case anyway.
Thanks,
Nik
next prev parent reply other threads:[~2022-02-15 15:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 23:31 [PATCH v2 net-next 0/8] Replay and offload host VLAN entries in DSA Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 1/8] net: bridge: vlan: notify switchdev only when something changed Vladimir Oltean
2022-02-15 0:05 ` Vladimir Oltean
2022-02-15 8:54 ` Nikolay Aleksandrov
2022-02-15 9:54 ` Vladimir Oltean
2022-02-15 10:10 ` Vladimir Oltean
2022-02-15 10:15 ` Nikolay Aleksandrov
2022-02-15 10:12 ` Nikolay Aleksandrov
2022-02-15 10:30 ` Vladimir Oltean
2022-02-15 11:08 ` Nikolay Aleksandrov
2022-02-15 11:10 ` Nikolay Aleksandrov
2022-02-15 14:36 ` Vladimir Oltean
2022-02-15 15:38 ` Vladimir Oltean
2022-02-15 15:44 ` Nikolay Aleksandrov [this message]
2022-02-15 15:52 ` Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 2/8] net: bridge: switchdev: differentiate new VLANs from changed ones Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 3/8] net: bridge: make nbp_switchdev_unsync_objs() follow reverse order of sync() Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 4/8] net: bridge: switchdev: replay all VLAN groups Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 5/8] net: switchdev: rename switchdev_lower_dev_find to switchdev_lower_dev_find_rcu Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 6/8] net: switchdev: introduce switchdev_handle_port_obj_{add,del} for foreign interfaces Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 7/8] net: dsa: add explicit support for host bridge VLANs Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 8/8] net: dsa: offload bridge port VLANs on foreign interfaces Vladimir Oltean
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=49709ba6-7f4f-493d-88c9-553d7c300397@nvidia.com \
--to=nikolay@nvidia.com \
--cc=andrew@lunn.ch \
--cc=daniel.klauer@gin.de \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=idosch@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=rafael.richter@gin.de \
--cc=roopa@nvidia.com \
--cc=tobias@waldekranz.com \
--cc=vivien.didelot@gmail.com \
--cc=vladimir.oltean@nxp.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