net: dsa: Allow compiling out legacy support
Subsystems (3)
PATCH 1/1 net: dsa: Allow compiling out legacy support
Introduce a configuration option: CONFIG_NET_DSA_LEGACY allowing to compile out support for the old platform device and Device Tree binding registration. Support for these configurations is scheduled to be removed in 4.17.
--- include/net/dsa.h | 9 +++++++++ net/dsa/Kconfig | 8 ++++++++ net/dsa/Makefile | 3 ++- net/dsa/dsa_priv.h | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-)
include/net/dsa.h +9 -0
@@ -472,11 +472,20 @@ struct dsa_switch_driver {const struct dsa_switch_ops *ops; }; +#if IS_ENABLED (CONFIG_NET_DSA_LEGACY )/* Legacy driver registration */ void register_switch_driver (struct dsa_switch_driver *type);void unregister_switch_driver (struct dsa_switch_driver *type);struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev); +#else +static inline void register_switch_driver (struct dsa_switch_driver *type) { } +static inline void unregister_switch_driver (struct dsa_switch_driver *type) { } +static inline struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev) +{ +return NULL ; +} +#endif struct net_device *dsa_dev_to_net_device (struct device *dev);/* Keep inline for faster access in hot path */
net/dsa/Kconfig +8 -0
@@ -16,6 +16,14 @@ config NET_DSA if NET_DSA +config NET_DSA_LEGACY + bool "Support for older platform device and Device Tree registration" + ---help--- + Say Y if you want to enable support for the older platform device and + deprectaed Device Tree binding registration. + + This feature is scheduled for removal in 4.17. + # tagging formats config NET_DSA_TAG_BRCM bool
net/dsa/Makefile +2 -1
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # the core obj-$(CONFIG_NET_DSA) += dsa_core.o -dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o +dsa_core-y += dsa.o dsa2.o master.o port.o slave.o switch.o +dsa_core-$(CONFIG_NET_DSA_LEGACY) += legacy.o # tagging formats dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
net/dsa/dsa_priv.h +23 -0
@@ -97,6 +97,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);bool dsa_schedule_work (struct work_struct *work);/* legacy.c */ +#if IS_ENABLED (CONFIG_NET_DSA_LEGACY )int dsa_legacy_register (void );void dsa_legacy_unregister (void ); int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
@@ -106,6 +107,28 @@ int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],int dsa_legacy_fdb_del (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid); +#else +static inline int dsa_legacy_register (void ) +{ +return -ENODEV ; +} + +static inline void dsa_legacy_unregister (void ) { } +static inline int dsa_legacy_fdb_add (struct ndmsg *ndm,struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr,u16 vid, +u16 flags) +{ +return 0 ; +} + +static inline int dsa_legacy_fdb_del (struct ndmsg *ndm,struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr,u16 vid) +{ +return 0 ; +} +#endif /* master.c */ int dsa_master_setup (struct net_device *dev,struct dsa_port *cpu_dp);
Signature · 1 line
2.14.1
Hi Florian,
Quoted 4 lines · Florian Fainelli
include/net/dsa.h +1
-0+#if IS_ENABLED (CONFIG_NET_DSA_LEGACY )/* Legacy driver registration */ void register_switch_driver (struct dsa_switch_driver *type);void unregister_switch_driver (struct dsa_switch_driver *type);
include/net/dsa.h struct dsa_switch_driver { · line 488
Quoted 10 lines
include/net/dsa.h +8
-0struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev); +#else +static inline void register_switch_driver (struct dsa_switch_driver *type) { } +static inline void unregister_switch_driver (struct dsa_switch_driver *type) { } +static inline struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev) +{ +return NULL ; +} +#endif
The .probe dsa_switch_ops is part of the legacy code, we may want to wrap it in a CONFIG_NET_DSA_LEGACY check as well.
net/dsa/Kconfig config NET_DSA · line 19
Quoted 12 lines
struct
net_device*dsa_dev_to_net_device(struct device *dev);/* Keep inline for faster access in hot path */
net/dsa/Kconfig +1
-0@@ -16,6 +16,14 @@ config NET_DSA if NET_DSA +config NET_DSA_LEGACY
We need to have it enabled by default, otherwise we'll miss errors when touching the code shared by both legacy and new bindings.
net/dsa/Kconfig config NET_DSA · line 23
Quoted 4 lines
net/dsa/Kconfig +4
-0+ bool "Support for older platform device and Device Tree registration" + ---help--- + Say Y if you want to enable support for the older platform device and + deprectaed Device Tree binding registration.
deprecated*
net/dsa/Kconfig int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], · line 109
Quoted 12 lines
net/dsa/Kconfig +4
-0+ + This feature is scheduled for removal in 4.17. + /* legacy.c */ +#if IS_ENABLED(CONFIG_NET_DSA_LEGACY) int dsa_legacy_register(void); void dsa_legacy_unregister(void); int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],@@ -106,6 +107,28 @@ int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid);
the dsa_legacy_fdb_{add,del} routines are "legacy" in terms of FDB handling, not in terms of DSA bindings, we must keep them.
Quoted 12 lines
net/dsa/Kconfig +12
-0+#else +static inline int dsa_legacy_register(void) +{ + return -ENODEV; +} + +static inline void dsa_legacy_unregister(void) { } +static inline int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], + struct net_device *dev, + const unsigned char *addr, u16 vid, + u16 flags) +{
net/dsa/Kconfig int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], · line 131
Quoted 10 lines
net/dsa/Kconfig +10
-0+ return 0; +} + +static inline int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], + struct net_device *dev, + const unsigned char *addr, u16 vid) +{ + return 0; +} +#endif
Thanks,
Vivien
Quoted 10 lines · Vivien Didelot
Hi Florian,
Quoted 6 lines · Florian Fainelli
+#if
IS_ENABLED(CONFIG_NET_DSA_LEGACY)
/* Legacy driver registration */
voidregister_switch_driver(struct dsa_switch_driver *type); voidunregister_switch_driver(struct dsa_switch_driver *type); structmii_bus*dsa_host_dev_to_mii_bus(struct device *dev);
Quoted 11 lines
include/net/dsa.h struct dsa_switch_driver { · line 488
Quoted 8 lines
include/net/dsa.h +8
-0+#else +static inline void register_switch_driver (struct dsa_switch_driver *type) { } +static inline void unregister_switch_driver (struct dsa_switch_driver *type) { } +static inline struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev) +{ +return NULL ; +} +#endif The .probe
dsa_switch_opsis part of the legacy code, we may want to wrap it in aCONFIG_NET_DSA_LEGACYcheck as well.
Fixed, also made 88e6060 dependent on CONFIG_NET_DSA_LEGACY as a result.
Quoted 10 lines
Quoted 10 lines
struct
net_device*dsa_dev_to_net_device(struct device *dev);/* Keep inline for faster access in hot path */
net/dsa/Kconfig +0
-0@@ -16,6 +16,14 @@ config NET_DSA
Quoted 6 lines
net/dsa/Kconfig config NET_DSA · line 19
Quoted 3 lines
net/dsa/Kconfig +1
-0if NET_DSA +config NET_DSA_LEGACYWe need to have it enabled by default, otherwise we'll miss errors when touching the code shared by both legacy and new bindings.
Fixed.
Quoted 8 lines
net/dsa/Kconfig config NET_DSA · line 23
Quoted 5 lines
net/dsa/Kconfig +4
-0+ bool "Support for older platform device and Device Tree registration" + ---help--- + Say Y if you want to enable support for the older platform device and + deprectaed Device Tree binding registration.deprecated*
Quoted 15 lines
net/dsa/Kconfig int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], · line 109
Quoted 12 lines
net/dsa/Kconfig +4
-0+ + This feature is scheduled for removal in 4.17. + /* legacy.c */ +#if IS_ENABLED(CONFIG_NET_DSA_LEGACY) int dsa_legacy_register(void); void dsa_legacy_unregister(void); int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],@@ -106,6 +107,28 @@ int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid);the dsa_legacy_fdb_{add,del} routines are "legacy" in terms of FDB handling, not in terms of DSA bindings, we must keep them.
Oh, right. This should probably be moved somewhere else then, right? The whole idea was to compile out net/dsa/legacy.c
Signature · 1 line
Florian