* [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas
@ 2022-01-05 22:11 Vladimir Oltean
2022-01-05 22:11 ` [PATCH net-next 2/2] net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic Vladimir Oltean
2022-01-06 12:40 ` [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-01-05 22:11 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Jakub Kicinski, Andrew Lunn, Vivien Didelot,
Florian Fainelli
This is a cosmetic incremental fixup to commits
7787ff776398 ("net: dsa: merge all bools of struct dsa_switch into a single u32")
bde82f389af1 ("net: dsa: merge all bools of struct dsa_port into a single u8")
The desire to make this change was enunciated after posting these
patches here:
https://patchwork.kernel.org/project/netdevbpf/cover/20220105132141.2648876-1-vladimir.oltean@nxp.com/
but due to a slight timing overlap (message posted at 2:28 p.m. UTC,
merge commit is at 2:46 p.m. UTC), that comment was missed and the
changes were applied as-is.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
include/net/dsa.h | 114 +++++++++++++++++++++++-----------------------
1 file changed, 56 insertions(+), 58 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 5d0fec6db3ae..63c7f553f938 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -265,14 +265,16 @@ struct dsa_port {
u8 stp_state;
- u8 vlan_filtering:1,
- /* Managed by DSA on user ports and by
- * drivers on CPU and DSA ports
- */
- learning:1,
- lag_tx_enabled:1,
- devlink_port_setup:1,
- setup:1;
+ u8 vlan_filtering:1;
+
+ /* Managed by DSA on user ports and by drivers on CPU and DSA ports */
+ u8 learning:1;
+
+ u8 lag_tx_enabled:1;
+
+ u8 devlink_port_setup:1;
+
+ u8 setup:1;
struct device_node *dn;
unsigned int ageing_time;
@@ -331,56 +333,52 @@ struct dsa_switch {
struct dsa_switch_tree *dst;
unsigned int index;
- u32 setup:1,
- /* Disallow bridge core from requesting
- * different VLAN awareness settings on ports
- * if not hardware-supported
- */
- vlan_filtering_is_global:1,
- /* Keep VLAN filtering enabled on ports not
- * offloading any upper
- */
- needs_standalone_vlan_filtering:1,
- /* Pass .port_vlan_add and .port_vlan_del to
- * drivers even for bridges that have
- * vlan_filtering=0. All drivers should ideally
- * set this (and then the option would get
- * removed), but it is unknown whether this
- * would break things or not.
- */
- configure_vlan_while_not_filtering:1,
- /* If the switch driver always programs the CPU
- * port as egress tagged despite the VLAN
- * configuration indicating otherwise, then
- * setting @untag_bridge_pvid will force the
- * DSA receive path to pop the bridge's
- * default_pvid VLAN tagged frames to offer a
- * consistent behavior between a
- * vlan_filtering=0 and vlan_filtering=1 bridge
- * device.
- */
- untag_bridge_pvid:1,
- /* Let DSA manage the FDB entries towards the
- * CPU, based on the software bridge database.
- */
- assisted_learning_on_cpu_port:1,
- /* In case vlan_filtering_is_global is set, the
- * VLAN awareness state should be retrieved
- * from here and not from the per-port
- * settings.
- */
- vlan_filtering:1,
- /* MAC PCS does not provide link state change
- * interrupt, and requires polling. Flag passed
- * on to PHYLINK.
- */
- pcs_poll:1,
- /* For switches that only have the MRU
- * configurable. To ensure the configured MTU
- * is not exceeded, normalization of MRU on all
- * bridged interfaces is needed.
- */
- mtu_enforcement_ingress:1;
+ u32 setup:1;
+
+ /* Disallow bridge core from requesting different VLAN awareness
+ * settings on ports if not hardware-supported
+ */
+ u32 vlan_filtering_is_global:1;
+
+ /* Keep VLAN filtering enabled on ports not offloading any upper */
+ u32 needs_standalone_vlan_filtering:1;
+
+ /* Pass .port_vlan_add and .port_vlan_del to drivers even for bridges
+ * that have vlan_filtering=0. All drivers should ideally set this (and
+ * then the option would get removed), but it is unknown whether this
+ * would break things or not.
+ */
+ u32 configure_vlan_while_not_filtering:1;
+
+ /* If the switch driver always programs the CPU port as egress tagged
+ * despite the VLAN configuration indicating otherwise, then setting
+ * @untag_bridge_pvid will force the DSA receive path to pop the
+ * bridge's default_pvid VLAN tagged frames to offer a consistent
+ * behavior between a vlan_filtering=0 and vlan_filtering=1 bridge
+ * device.
+ */
+ u32 untag_bridge_pvid:1;
+
+ /* Let DSA manage the FDB entries towards the
+ * CPU, based on the software bridge database.
+ */
+ u32 assisted_learning_on_cpu_port:1;
+
+ /* In case vlan_filtering_is_global is set, the VLAN awareness state
+ * should be retrieved from here and not from the per-port settings.
+ */
+ u32 vlan_filtering:1;
+
+ /* MAC PCS does not provide link state change interrupt, and requires
+ * polling. Flag passed on to PHYLINK.
+ */
+ u32 pcs_poll:1;
+
+ /* For switches that only have the MRU configurable. To ensure the
+ * configured MTU is not exceeded, normalization of MRU on all bridged
+ * interfaces is needed.
+ */
+ u32 mtu_enforcement_ingress:1;
/* Listener for switch fabric events */
struct notifier_block nb;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net-next 2/2] net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic
2022-01-05 22:11 [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas Vladimir Oltean
@ 2022-01-05 22:11 ` Vladimir Oltean
2022-01-06 12:40 ` [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-01-05 22:11 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Jakub Kicinski, Andrew Lunn, Vivien Didelot,
Florian Fainelli
As discussed during review here:
https://patchwork.kernel.org/project/netdevbpf/patch/20220105132141.2648876-3-vladimir.oltean@nxp.com/
we should inform developers about pitfalls of concurrent access to the
boolean properties of dsa_switch and dsa_port, now that they've been
converted to bit fields. No other measure than a comment needs to be
taken, since the code paths that update these bit fields are not
concurrent with each other.
Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
include/net/dsa.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 63c7f553f938..57b3e4e7413b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -265,6 +265,10 @@ struct dsa_port {
u8 stp_state;
+ /* Warning: the following bit fields are not atomic, and updating them
+ * can only be done from code paths where concurrency is not possible
+ * (probe time or under rtnl_lock).
+ */
u8 vlan_filtering:1;
/* Managed by DSA on user ports and by drivers on CPU and DSA ports */
@@ -333,6 +337,10 @@ struct dsa_switch {
struct dsa_switch_tree *dst;
unsigned int index;
+ /* Warning: the following bit fields are not atomic, and updating them
+ * can only be done from code paths where concurrency is not possible
+ * (probe time or under rtnl_lock).
+ */
u32 setup:1;
/* Disallow bridge core from requesting different VLAN awareness
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas
2022-01-05 22:11 [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas Vladimir Oltean
2022-01-05 22:11 ` [PATCH net-next 2/2] net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic Vladimir Oltean
@ 2022-01-06 12:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-06 12:40 UTC (permalink / raw)
To: Vladimir Oltean; +Cc: netdev, davem, kuba, andrew, vivien.didelot, f.fainelli
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Thu, 6 Jan 2022 00:11:49 +0200 you wrote:
> This is a cosmetic incremental fixup to commits
> 7787ff776398 ("net: dsa: merge all bools of struct dsa_switch into a single u32")
> bde82f389af1 ("net: dsa: merge all bools of struct dsa_port into a single u8")
>
> The desire to make this change was enunciated after posting these
> patches here:
> https://patchwork.kernel.org/project/netdevbpf/cover/20220105132141.2648876-1-vladimir.oltean@nxp.com/
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas
https://git.kernel.org/netdev/net-next/c/63cfc65753d6
- [net-next,2/2] net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic
https://git.kernel.org/netdev/net-next/c/1b26d364e4e9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-06 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 22:11 [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas Vladimir Oltean
2022-01-05 22:11 ` [PATCH net-next 2/2] net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic Vladimir Oltean
2022-01-06 12:40 ` [PATCH net-next 1/2] net: dsa: don't enumerate dsa_switch and dsa_port bit fields using commas patchwork-bot+netdevbpf
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.