Skip to content

Commit 2a93c1a

Browse files
ffainellidavem330
authored andcommitted
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>
1 parent a8168b6 commit 2a93c1a

File tree

8 files changed

+56
-22
lines changed

8 files changed

+56
-22
lines changed

drivers/net/dsa/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ config NET_DSA_MT7530
3333

3434
config NET_DSA_MV88E6060
3535
tristate "Marvell 88E6060 ethernet switch chip support"
36-
depends on NET_DSA
36+
depends on NET_DSA && NET_DSA_LEGACY
3737
select NET_DSA_TAG_TRAILER
3838
---help---
3939
This enables support for the Marvell 88E6060 ethernet switch

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,6 +3755,7 @@ static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
37553755
return chip->info->tag_protocol;
37563756
}
37573757

3758+
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
37583759
static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
37593760
struct device *host_dev, int sw_addr,
37603761
void **priv)
@@ -3802,6 +3803,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
38023803

38033804
return NULL;
38043805
}
3806+
#endif
38053807

38063808
static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
38073809
const struct switchdev_obj_port_mdb *mdb)
@@ -3841,7 +3843,9 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
38413843
}
38423844

38433845
static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
3846+
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
38443847
.probe = mv88e6xxx_drv_probe,
3848+
#endif
38453849
.get_tag_protocol = mv88e6xxx_get_tag_protocol,
38463850
.setup = mv88e6xxx_setup,
38473851
.adjust_link = mv88e6xxx_adjust_link,

include/net/dsa.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,14 @@ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)
321321
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
322322
bool is_static, void *data);
323323
struct dsa_switch_ops {
324+
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
324325
/*
325326
* Legacy probing.
326327
*/
327328
const char *(*probe)(struct device *dsa_dev,
328329
struct device *host_dev, int sw_addr,
329330
void **priv);
331+
#endif
330332

331333
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
332334
int port);
@@ -474,11 +476,20 @@ struct dsa_switch_driver {
474476
const struct dsa_switch_ops *ops;
475477
};
476478

479+
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
477480
/* Legacy driver registration */
478481
void register_switch_driver(struct dsa_switch_driver *type);
479482
void unregister_switch_driver(struct dsa_switch_driver *type);
480483
struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
481484

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
482493
struct net_device *dsa_dev_to_net_device(struct device *dev);
483494

484495
/* Keep inline for faster access in hot path */

net/dsa/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ config NET_DSA
1616

1717
if NET_DSA
1818

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+
1928
# tagging formats
2029
config NET_DSA_TAG_BRCM
2130
bool

net/dsa/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
22
# the core
33
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
56

67
# tagging formats
78
dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o

net/dsa/dsa_priv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,17 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
9797
bool dsa_schedule_work(struct work_struct *work);
9898

9999
/* legacy.c */
100+
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
100101
int dsa_legacy_register(void);
101102
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
102111
int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
103112
struct net_device *dev,
104113
const unsigned char *addr, u16 vid,

net/dsa/legacy.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -718,26 +718,6 @@ static int dsa_resume(struct device *d)
718718
}
719719
#endif
720720

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-
741721
static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);
742722

743723
static const struct of_device_id dsa_of_match_table[] = {

net/dsa/slave.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,26 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
941941
.set_rxnfc = dsa_slave_set_rxnfc,
942942
};
943943

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+
944964
static const struct net_device_ops dsa_slave_netdev_ops = {
945965
.ndo_open = dsa_slave_open,
946966
.ndo_stop = dsa_slave_close,

0 commit comments

Comments
 (0)