From: Vladimir Oltean <vladimir.oltean@nxp.com> To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net> Cc: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vivien Didelot <vivien.didelot@gmail.com>, Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@idosch.org>, Tobias Waldekranz <tobias@waldekranz.com>, Roopa Prabhu <roopa@nvidia.com>, Nikolay Aleksandrov <nikolay@nvidia.com>, Stephen Hemminger <stephen@networkplumber.org>, bridge@lists.linux-foundation.org, Alexander Duyck <alexander.duyck@gmail.com> Subject: [RFC PATCH v2 net-next 07/10] net: dsa: track the number of switches in a tree Date: Sat, 3 Jul 2021 14:57:02 +0300 [thread overview] Message-ID: <20210703115705.1034112-8-vladimir.oltean@nxp.com> (raw) In-Reply-To: <20210703115705.1034112-1-vladimir.oltean@nxp.com> In preparation of supporting data plane forwarding on behalf of a software bridge, some drivers might need to view bridges as virtual switches behind the CPU port in a cross-chip topology. Give them some help and let them know how many physical switches there are in the tree, so that they can count the virtual switches starting from that number on. Note that the first dsa_switch_ops method where this information is reliably available is .setup(). This is because of how DSA works: in a tree with 3 switches, each calling dsa_register_switch(), the first 2 will advance until dsa_tree_setup() -> dsa_tree_setup_routing_table() and exit with error code 0 because the topology is not complete. Since probing is parallel at this point, one switch does not know about the existence of the other. Then the third switch comes, and for it, dsa_tree_setup_routing_table() returns complete = true. This switch goes ahead and calls dsa_tree_setup_switches() for everybody else, calling their .setup() methods too. This acts as the synchronization point. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> --- include/net/dsa.h | 3 +++ net/dsa/dsa2.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 33f40c1ec379..89626eab92b9 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -159,6 +159,9 @@ struct dsa_switch_tree { */ struct net_device **lags; unsigned int lags_len; + + /* Track the largest switch index within a tree */ + unsigned int last_switch; }; #define dsa_lags_foreach_id(_id, _dst) \ diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 185629f27f80..de5e93ba2a9d 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1265,6 +1265,9 @@ static int dsa_switch_parse_member_of(struct dsa_switch *ds, return -EEXIST; } + if (ds->dst->last_switch < ds->index) + ds->dst->last_switch = ds->index; + return 0; } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Oltean <vladimir.oltean@nxp.com> To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net> Cc: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Jiri Pirko <jiri@resnulli.us>, bridge@lists.linux-foundation.org, Alexander Duyck <alexander.duyck@gmail.com>, Ido Schimmel <idosch@idosch.org>, Nikolay Aleksandrov <nikolay@nvidia.com>, Roopa Prabhu <roopa@nvidia.com>, Vivien Didelot <vivien.didelot@gmail.com>, Tobias Waldekranz <tobias@waldekranz.com> Subject: [Bridge] [RFC PATCH v2 net-next 07/10] net: dsa: track the number of switches in a tree Date: Sat, 3 Jul 2021 14:57:02 +0300 [thread overview] Message-ID: <20210703115705.1034112-8-vladimir.oltean@nxp.com> (raw) In-Reply-To: <20210703115705.1034112-1-vladimir.oltean@nxp.com> In preparation of supporting data plane forwarding on behalf of a software bridge, some drivers might need to view bridges as virtual switches behind the CPU port in a cross-chip topology. Give them some help and let them know how many physical switches there are in the tree, so that they can count the virtual switches starting from that number on. Note that the first dsa_switch_ops method where this information is reliably available is .setup(). This is because of how DSA works: in a tree with 3 switches, each calling dsa_register_switch(), the first 2 will advance until dsa_tree_setup() -> dsa_tree_setup_routing_table() and exit with error code 0 because the topology is not complete. Since probing is parallel at this point, one switch does not know about the existence of the other. Then the third switch comes, and for it, dsa_tree_setup_routing_table() returns complete = true. This switch goes ahead and calls dsa_tree_setup_switches() for everybody else, calling their .setup() methods too. This acts as the synchronization point. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> --- include/net/dsa.h | 3 +++ net/dsa/dsa2.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 33f40c1ec379..89626eab92b9 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -159,6 +159,9 @@ struct dsa_switch_tree { */ struct net_device **lags; unsigned int lags_len; + + /* Track the largest switch index within a tree */ + unsigned int last_switch; }; #define dsa_lags_foreach_id(_id, _dst) \ diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 185629f27f80..de5e93ba2a9d 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1265,6 +1265,9 @@ static int dsa_switch_parse_member_of(struct dsa_switch *ds, return -EEXIST; } + if (ds->dst->last_switch < ds->index) + ds->dst->last_switch = ds->index; + return 0; } -- 2.25.1
next prev parent reply other threads:[~2021-07-03 11:58 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-03 11:56 [RFC PATCH v2 net-next 00/10] Allow forwarding for the software bridge data path to be offloaded to capable devices Vladimir Oltean 2021-07-03 11:56 ` [Bridge] " Vladimir Oltean 2021-07-03 11:56 ` [RFC PATCH v2 net-next 01/10] net: dfwd: constrain existing users to macvlan subordinates Vladimir Oltean 2021-07-03 11:56 ` [Bridge] " Vladimir Oltean 2021-07-03 11:56 ` [RFC PATCH v2 net-next 02/10] net: bridge: disambiguate offload_fwd_mark Vladimir Oltean 2021-07-03 11:56 ` [Bridge] " Vladimir Oltean 2021-07-09 13:23 ` Grygorii Strashko 2021-07-03 11:56 ` [RFC PATCH v2 net-next 03/10] net: bridge: switchdev: recycle unused hwdoms Vladimir Oltean 2021-07-03 11:56 ` [Bridge] " Vladimir Oltean 2021-07-03 11:56 ` [RFC PATCH v2 net-next 04/10] net: bridge: switchdev: allow the data plane forwarding to be offloaded Vladimir Oltean 2021-07-03 11:56 ` [Bridge] " Vladimir Oltean 2021-07-09 13:16 ` Grygorii Strashko 2021-07-09 14:09 ` Vladimir Oltean 2021-07-09 14:09 ` [Bridge] " Vladimir Oltean 2021-07-12 12:28 ` Tobias Waldekranz 2021-07-12 12:28 ` [Bridge] " Tobias Waldekranz 2021-07-12 13:03 ` Vladimir Oltean 2021-07-12 13:03 ` [Bridge] " Vladimir Oltean 2021-07-03 11:57 ` [RFC PATCH v2 net-next 05/10] net: extract helpers for binding a subordinate device to TX queues Vladimir Oltean 2021-07-03 11:57 ` [Bridge] " Vladimir Oltean 2021-07-03 11:57 ` [RFC PATCH v2 net-next 06/10] net: allow ndo_select_queue to go beyond dev->num_real_tx_queues Vladimir Oltean 2021-07-03 11:57 ` [Bridge] " Vladimir Oltean 2021-07-03 11:57 ` Vladimir Oltean [this message] 2021-07-03 11:57 ` [Bridge] [RFC PATCH v2 net-next 07/10] net: dsa: track the number of switches in a tree Vladimir Oltean 2021-07-03 11:57 ` [RFC PATCH v2 net-next 08/10] net: dsa: add support for bridge forwarding offload Vladimir Oltean 2021-07-03 11:57 ` [Bridge] " Vladimir Oltean 2021-07-03 11:57 ` [RFC PATCH v2 net-next 09/10] net: dsa: mv88e6xxx: map virtual bridges with forwarding offload in the PVT Vladimir Oltean 2021-07-03 11:57 ` [Bridge] " Vladimir Oltean 2021-07-03 11:57 ` [RFC PATCH v2 net-next 10/10] net: dsa: tag_dsa: offload the bridge forwarding process Vladimir Oltean 2021-07-03 11:57 ` [Bridge] " Vladimir Oltean 2021-07-03 22:04 ` [RFC PATCH v2 net-next 00/10] Allow forwarding for the software bridge data path to be offloaded to capable devices Tobias Waldekranz 2021-07-03 22:04 ` [Bridge] " Tobias Waldekranz 2021-07-04 8:11 ` Vladimir Oltean 2021-07-04 8:11 ` [Bridge] " Vladimir Oltean 2021-07-05 8:09 ` Tobias Waldekranz 2021-07-05 8:09 ` [Bridge] " Tobias Waldekranz 2021-07-05 8:54 ` Vladimir Oltean 2021-07-05 8:54 ` [Bridge] " Vladimir Oltean 2021-07-05 4:20 ` DENG Qingfang 2021-07-05 4:20 ` [Bridge] " DENG Qingfang 2021-07-05 8:32 ` Tobias Waldekranz 2021-07-05 8:32 ` [Bridge] " Tobias Waldekranz 2021-07-05 9:57 ` Vladimir Oltean 2021-07-05 9:57 ` [Bridge] " 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=20210703115705.1034112-8-vladimir.oltean@nxp.com \ --to=vladimir.oltean@nxp.com \ --cc=alexander.duyck@gmail.com \ --cc=andrew@lunn.ch \ --cc=bridge@lists.linux-foundation.org \ --cc=davem@davemloft.net \ --cc=f.fainelli@gmail.com \ --cc=idosch@idosch.org \ --cc=jiri@resnulli.us \ --cc=kuba@kernel.org \ --cc=netdev@vger.kernel.org \ --cc=nikolay@nvidia.com \ --cc=roopa@nvidia.com \ --cc=stephen@networkplumber.org \ --cc=tobias@waldekranz.com \ --cc=vivien.didelot@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: linkBe 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.