diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-12-06 18:03:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-07 14:14:54 -0500 |
commit | 2a93c1a3651fb41b580676c849887b68af6da02b (patch) | |
tree | 15a29c4aa5f0688f75b335e611b1dfd18ee3bb95 | |
parent | a8168b6cee6e9334dfebb4b9108e8d73794f6088 (diff) |
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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/Kconfig | 2 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx/chip.c | 4 | ||||
-rw-r--r-- | include/net/dsa.h | 11 | ||||
-rw-r--r-- | net/dsa/Kconfig | 9 | ||||
-rw-r--r-- | net/dsa/Makefile | 3 | ||||
-rw-r--r-- | net/dsa/dsa_priv.h | 9 | ||||
-rw-r--r-- | net/dsa/legacy.c | 20 | ||||
-rw-r--r-- | net/dsa/slave.c | 20 |
8 files changed, 56 insertions, 22 deletions
diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index 83a9bc892a3b..2b81b97e994f 100644 --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig | |||
@@ -33,7 +33,7 @@ config NET_DSA_MT7530 | |||
33 | 33 | ||
34 | config NET_DSA_MV88E6060 | 34 | config NET_DSA_MV88E6060 |
35 | tristate "Marvell 88E6060 ethernet switch chip support" | 35 | tristate "Marvell 88E6060 ethernet switch chip support" |
36 | depends on NET_DSA | 36 | depends on NET_DSA && NET_DSA_LEGACY |
37 | select NET_DSA_TAG_TRAILER | 37 | select NET_DSA_TAG_TRAILER |
38 | ---help--- | 38 | ---help--- |
39 | This enables support for the Marvell 88E6060 ethernet switch | 39 | This enables support for the Marvell 88E6060 ethernet switch |
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 29b79d6d2925..24e5d98f15a1 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c | |||
@@ -3755,6 +3755,7 @@ static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds, | |||
3755 | return chip->info->tag_protocol; | 3755 | return chip->info->tag_protocol; |
3756 | } | 3756 | } |
3757 | 3757 | ||
3758 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) | ||
3758 | static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, | 3759 | static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, |
3759 | struct device *host_dev, int sw_addr, | 3760 | struct device *host_dev, int sw_addr, |
3760 | void **priv) | 3761 | void **priv) |
@@ -3802,6 +3803,7 @@ free: | |||
3802 | 3803 | ||
3803 | return NULL; | 3804 | return NULL; |
3804 | } | 3805 | } |
3806 | #endif | ||
3805 | 3807 | ||
3806 | static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port, | 3808 | static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port, |
3807 | const struct switchdev_obj_port_mdb *mdb) | 3809 | const struct switchdev_obj_port_mdb *mdb) |
@@ -3841,7 +3843,9 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, | |||
3841 | } | 3843 | } |
3842 | 3844 | ||
3843 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { | 3845 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
3846 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) | ||
3844 | .probe = mv88e6xxx_drv_probe, | 3847 | .probe = mv88e6xxx_drv_probe, |
3848 | #endif | ||
3845 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, | 3849 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
3846 | .setup = mv88e6xxx_setup, | 3850 | .setup = mv88e6xxx_setup, |
3847 | .adjust_link = mv88e6xxx_adjust_link, | 3851 | .adjust_link = mv88e6xxx_adjust_link, |
diff --git a/include/net/dsa.h b/include/net/dsa.h index d29feccaefab..6cb602dd970c 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -321,12 +321,14 @@ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) | |||
321 | typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, | 321 | typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, |
322 | bool is_static, void *data); | 322 | bool is_static, void *data); |
323 | struct dsa_switch_ops { | 323 | struct dsa_switch_ops { |
324 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) | ||
324 | /* | 325 | /* |
325 | * Legacy probing. | 326 | * Legacy probing. |
326 | */ | 327 | */ |
327 | const char *(*probe)(struct device *dsa_dev, | 328 | const char *(*probe)(struct device *dsa_dev, |
328 | struct device *host_dev, int sw_addr, | 329 | struct device *host_dev, int sw_addr, |
329 | void **priv); | 330 | void **priv); |
331 | #endif | ||
330 | 332 | ||
331 | enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds, | 333 | enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds, |
332 | int port); | 334 | int port); |
@@ -474,11 +476,20 @@ struct dsa_switch_driver { | |||
474 | const struct dsa_switch_ops *ops; | 476 | const struct dsa_switch_ops *ops; |
475 | }; | 477 | }; |
476 | 478 | ||
479 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) | ||
477 | /* Legacy driver registration */ | 480 | /* Legacy driver registration */ |
478 | void register_switch_driver(struct dsa_switch_driver *type); | 481 | void register_switch_driver(struct dsa_switch_driver *type); |
479 | void unregister_switch_driver(struct dsa_switch_driver *type); | 482 | void unregister_switch_driver(struct dsa_switch_driver *type); |
480 | struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); | 483 | struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); |
481 | 484 | ||
485 | #else | ||
486 | static inline void register_switch_driver(struct dsa_switch_driver *type) { } | ||
487 | static inline void unregister_switch_driver(struct dsa_switch_driver *type) { } | ||
488 | static inline struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev) | ||
489 | { | ||
490 | return NULL; | ||
491 | } | ||
492 | #endif | ||
482 | struct net_device *dsa_dev_to_net_device(struct device *dev); | 493 | struct net_device *dsa_dev_to_net_device(struct device *dev); |
483 | 494 | ||
484 | /* Keep inline for faster access in hot path */ | 495 | /* Keep inline for faster access in hot path */ |
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 03c3bdf25468..bbf2c82cf7b2 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig | |||
@@ -16,6 +16,15 @@ config NET_DSA | |||
16 | 16 | ||
17 | if NET_DSA | 17 | if NET_DSA |
18 | 18 | ||
19 | config NET_DSA_LEGACY | ||
20 | bool "Support for older platform device and Device Tree registration" | ||
21 | default y | ||
22 | ---help--- | ||
23 | Say Y if you want to enable support for the older platform device and | ||
24 | deprecated Device Tree binding registration. | ||
25 | |||
26 | This feature is scheduled for removal in 4.17. | ||
27 | |||
19 | # tagging formats | 28 | # tagging formats |
20 | config NET_DSA_TAG_BRCM | 29 | config NET_DSA_TAG_BRCM |
21 | bool | 30 | bool |
diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 0e13c1f95d13..9e4d3536f977 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # the core | 2 | # the core |
3 | obj-$(CONFIG_NET_DSA) += dsa_core.o | 3 | obj-$(CONFIG_NET_DSA) += dsa_core.o |
4 | dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o | 4 | dsa_core-y += dsa.o dsa2.o master.o port.o slave.o switch.o |
5 | dsa_core-$(CONFIG_NET_DSA_LEGACY) += legacy.o | ||
5 | 6 | ||
6 | # tagging formats | 7 | # tagging formats |
7 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o | 8 | dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o |
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 7d036696e8c4..b03665e8fb4e 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h | |||
@@ -97,8 +97,17 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol); | |||
97 | bool dsa_schedule_work(struct work_struct *work); | 97 | bool dsa_schedule_work(struct work_struct *work); |
98 | 98 | ||
99 | /* legacy.c */ | 99 | /* legacy.c */ |
100 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) | ||
100 | int dsa_legacy_register(void); | 101 | int dsa_legacy_register(void); |
101 | void dsa_legacy_unregister(void); | 102 | void dsa_legacy_unregister(void); |
103 | #else | ||
104 | static inline int dsa_legacy_register(void) | ||
105 | { | ||
106 | return -ENODEV; | ||
107 | } | ||
108 | |||
109 | static inline void dsa_legacy_unregister(void) { } | ||
110 | #endif | ||
102 | int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], | 111 | int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], |
103 | struct net_device *dev, | 112 | struct net_device *dev, |
104 | const unsigned char *addr, u16 vid, | 113 | const unsigned char *addr, u16 vid, |
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c index 84611d7fcfa2..aa56d3fb5da4 100644 --- a/net/dsa/legacy.c +++ b/net/dsa/legacy.c | |||
@@ -718,26 +718,6 @@ static int dsa_resume(struct device *d) | |||
718 | } | 718 | } |
719 | #endif | 719 | #endif |
720 | 720 | ||
721 | /* legacy way, bypassing the bridge *****************************************/ | ||
722 | int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], | ||
723 | struct net_device *dev, | ||
724 | const unsigned char *addr, u16 vid, | ||
725 | u16 flags) | ||
726 | { | ||
727 | struct dsa_port *dp = dsa_slave_to_port(dev); | ||
728 | |||
729 | return dsa_port_fdb_add(dp, addr, vid); | ||
730 | } | ||
731 | |||
732 | int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], | ||
733 | struct net_device *dev, | ||
734 | const unsigned char *addr, u16 vid) | ||
735 | { | ||
736 | struct dsa_port *dp = dsa_slave_to_port(dev); | ||
737 | |||
738 | return dsa_port_fdb_del(dp, addr, vid); | ||
739 | } | ||
740 | |||
741 | static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume); | 721 | static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume); |
742 | 722 | ||
743 | static const struct of_device_id dsa_of_match_table[] = { | 723 | static const struct of_device_id dsa_of_match_table[] = { |
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 895db05d8c82..5d6475a6cc5d 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -941,6 +941,26 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { | |||
941 | .set_rxnfc = dsa_slave_set_rxnfc, | 941 | .set_rxnfc = dsa_slave_set_rxnfc, |
942 | }; | 942 | }; |
943 | 943 | ||
944 | /* legacy way, bypassing the bridge *****************************************/ | ||
945 | int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], | ||
946 | struct net_device *dev, | ||
947 | const unsigned char *addr, u16 vid, | ||
948 | u16 flags) | ||
949 | { | ||
950 | struct dsa_port *dp = dsa_slave_to_port(dev); | ||
951 | |||
952 | return dsa_port_fdb_add(dp, addr, vid); | ||
953 | } | ||
954 | |||
955 | int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], | ||
956 | struct net_device *dev, | ||
957 | const unsigned char *addr, u16 vid) | ||
958 | { | ||
959 | struct dsa_port *dp = dsa_slave_to_port(dev); | ||
960 | |||
961 | return dsa_port_fdb_del(dp, addr, vid); | ||
962 | } | ||
963 | |||
944 | static const struct net_device_ops dsa_slave_netdev_ops = { | 964 | static const struct net_device_ops dsa_slave_netdev_ops = { |
945 | .ndo_open = dsa_slave_open, | 965 | .ndo_open = dsa_slave_open, |
946 | .ndo_stop = dsa_slave_close, | 966 | .ndo_stop = dsa_slave_close, |