]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: dsa: sja1105: break dependency between dsa_port_is_sja1105 and switch driver
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 22 Sep 2021 14:37:26 +0000 (17:37 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Sep 2021 11:45:07 +0000 (12:45 +0100)
It's nice to be able to test a tagging protocol with dsa_loop, but not
at the cost of losing the ability of building the tagging protocol and
switch driver as modules, because as things stand, there is a circular
dependency between the two. Tagging protocol drivers cannot depend on
switch drivers, that is a hard fact.

The reasoning behind the blamed patch was that accessing dp->priv should
first make sure that the structure behind that pointer is what we really
think it is.

Currently the "sja1105" and "sja1110" tagging protocols only operate
with the sja1105 switch driver, just like any other tagging protocol and
switch combination. The only way to mix and match them is by modifying
the code, and this applies to dsa_loop as well (by default that uses
DSA_TAG_PROTO_NONE). So while in principle there is an issue, in
practice there isn't one.

Until we extend dsa_loop to allow user space configuration, treat the
problem as a non-issue and just say that DSA ports found by tag_sja1105
are always sja1105 ports, which is in fact true. But keep the
dsa_port_is_sja1105 function so that it's easy to patch it during
testing, and rely on dead code elimination.

Fixes: 994d2cbb08ca ("net: dsa: tag_sja1105: be dsa_loop-safe")
Link: https://lore.kernel.org/netdev/20210908220834.d7gmtnwrorhharna@skbuf/
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c
include/linux/dsa/sja1105.h
net/dsa/Kconfig

index 7ce69dc07800ac85097e3c6f3461363c48a02eee..d5f8166b73b1540f6cd49bebc9975107620f29ae 100644 (file)
@@ -3116,7 +3116,7 @@ static void sja1105_teardown(struct dsa_switch *ds)
        sja1105_static_config_free(&priv->static_config);
 }
 
-const struct dsa_switch_ops sja1105_switch_ops = {
+static const struct dsa_switch_ops sja1105_switch_ops = {
        .get_tag_protocol       = sja1105_get_tag_protocol,
        .setup                  = sja1105_setup,
        .teardown               = sja1105_teardown,
@@ -3165,7 +3165,6 @@ const struct dsa_switch_ops sja1105_switch_ops = {
        .port_bridge_tx_fwd_offload = dsa_tag_8021q_bridge_tx_fwd_offload,
        .port_bridge_tx_fwd_unoffload = dsa_tag_8021q_bridge_tx_fwd_unoffload,
 };
-EXPORT_SYMBOL_GPL(sja1105_switch_ops);
 
 static const struct of_device_id sja1105_dt_ids[];
 
index 9d5a1053b2766303204abc391610ed63ae4a9997..e6c78be40bde71c76e792c01e92315ae7568d0fd 100644 (file)
@@ -87,22 +87,9 @@ static inline s64 sja1105_ticks_to_ns(s64 ticks)
        return ticks * SJA1105_TICK_NS;
 }
 
-#if IS_ENABLED(CONFIG_NET_DSA_SJA1105)
-
-extern const struct dsa_switch_ops sja1105_switch_ops;
-
-static inline bool dsa_port_is_sja1105(struct dsa_port *dp)
-{
-       return dp->ds->ops == &sja1105_switch_ops;
-}
-
-#else
-
 static inline bool dsa_port_is_sja1105(struct dsa_port *dp)
 {
-       return false;
+       return true;
 }
 
-#endif
-
 #endif /* _NET_DSA_SJA1105_H */
index 54828553975236d8d1d04582220ba701a03b9032..bca1b5d66df2297507ab3f8bb2c9f99d2a06a80e 100644 (file)
@@ -138,7 +138,6 @@ config NET_DSA_TAG_LAN9303
 
 config NET_DSA_TAG_SJA1105
        tristate "Tag driver for NXP SJA1105 switches"
-       depends on NET_DSA_SJA1105 || !NET_DSA_SJA1105
        select PACKING
        help
          Say Y or M if you want to enable support for tagging frames with the