Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: modularize DSA_TAG_PROTO_NONE

There is no reason that I can see why the no-op tagging protocol should
be registered manually, so make it a module and make all drivers which
have any sort of reference to DSA_TAG_PROTO_NONE select it.

Note that I don't know if ksz_get_tag_protocol() really needs this,
or if it's just the logic which is poorly written. All switches seem to
have their own tagging protocol, and DSA_TAG_PROTO_NONE is just a
fallback that never gets used.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
d2be3204 c5fb8ead

+41 -22
+2
drivers/net/dsa/Kconfig
··· 18 18 19 19 config NET_DSA_LOOP 20 20 tristate "DSA mock-up Ethernet switch chip support" 21 + select NET_DSA_TAG_NONE 21 22 select FIXED_PHY 22 23 help 23 24 This enables support for a fake mock-up switch chip which ··· 100 99 101 100 config NET_DSA_VITESSE_VSC73XX 102 101 tristate 102 + select NET_DSA_TAG_NONE 103 103 select FIXED_PHY 104 104 select VITESSE_PHY 105 105 select GPIOLIB
+1
drivers/net/dsa/b53/Kconfig
··· 2 2 menuconfig B53 3 3 tristate "Broadcom BCM53xx managed switch support" 4 4 depends on NET_DSA 5 + select NET_DSA_TAG_NONE 5 6 select NET_DSA_TAG_BRCM 6 7 select NET_DSA_TAG_BRCM_LEGACY 7 8 select NET_DSA_TAG_BRCM_PREPEND
+1
drivers/net/dsa/microchip/Kconfig
··· 3 3 tristate "Microchip KSZ8795/KSZ9477/LAN937x series switch support" 4 4 depends on NET_DSA 5 5 select NET_DSA_TAG_KSZ 6 + select NET_DSA_TAG_NONE 6 7 help 7 8 This driver adds support for Microchip KSZ9477 series switch and 8 9 KSZ8795/KSZ88x3 switch chips.
+6
net/dsa/Kconfig
··· 18 18 19 19 # Drivers must select the appropriate tagging format(s) 20 20 21 + config NET_DSA_TAG_NONE 22 + tristate "No-op tag driver" 23 + help 24 + Say Y or M if you want to enable support for switches which don't tag 25 + frames over the CPU port. 26 + 21 27 config NET_DSA_TAG_AR9331 22 28 tristate "Tag driver for Atheros AR9331 SoC with built-in switch" 23 29 help
+1
net/dsa/Makefile
··· 20 20 obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o 21 21 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o 22 22 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o 23 + obj-$(CONFIG_NET_DSA_TAG_NONE) += tag_none.o 23 24 obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o 24 25 obj-$(CONFIG_NET_DSA_TAG_OCELOT_8021Q) += tag_ocelot_8021q.o 25 26 obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
-21
net/dsa/dsa.c
··· 18 18 static LIST_HEAD(dsa_tag_drivers_list); 19 19 static DEFINE_MUTEX(dsa_tag_drivers_lock); 20 20 21 - static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, 22 - struct net_device *dev) 23 - { 24 - /* Just return the original SKB */ 25 - return skb; 26 - } 27 - 28 - static const struct dsa_device_ops none_ops = { 29 - .name = "none", 30 - .proto = DSA_TAG_PROTO_NONE, 31 - .xmit = dsa_slave_notag_xmit, 32 - .rcv = NULL, 33 - }; 34 - 35 - DSA_TAG_DRIVER(none_ops); 36 - 37 21 static void dsa_tag_driver_register(struct dsa_tag_driver *dsa_tag_driver, 38 22 struct module *owner) 39 23 { ··· 535 551 536 552 dev_add_pack(&dsa_pack_type); 537 553 538 - dsa_tag_driver_register(&DSA_TAG_DRIVER_NAME(none_ops), 539 - THIS_MODULE); 540 - 541 554 rc = rtnl_link_register(&dsa_link_ops); 542 555 if (rc) 543 556 goto netlink_register_fail; ··· 542 561 return 0; 543 562 544 563 netlink_register_fail: 545 - dsa_tag_driver_unregister(&DSA_TAG_DRIVER_NAME(none_ops)); 546 564 dsa_slave_unregister_notifier(); 547 565 dev_remove_pack(&dsa_pack_type); 548 566 register_notifier_fail: ··· 554 574 static void __exit dsa_cleanup_module(void) 555 575 { 556 576 rtnl_link_unregister(&dsa_link_ops); 557 - dsa_tag_driver_unregister(&DSA_TAG_DRIVER_NAME(none_ops)); 558 577 559 578 dsa_slave_unregister_notifier(); 560 579 dev_remove_pack(&dsa_pack_type);
-1
net/dsa/dsa_priv.h
··· 384 384 struct netlink_ext_ack *extack); 385 385 386 386 /* slave.c */ 387 - extern const struct dsa_device_ops notag_netdev_ops; 388 387 extern struct notifier_block dsa_slave_switchdev_notifier; 389 388 extern struct notifier_block dsa_slave_switchdev_blocking_notifier; 390 389
+30
net/dsa/tag_none.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * net/dsa/tag_none.c - Traffic handling for switches with no tag 4 + * Copyright (c) 2008-2009 Marvell Semiconductor 5 + * Copyright (c) 2013 Florian Fainelli <florian@openwrt.org> 6 + * 7 + * WARNING: do not use this for new switches. In case of no hardware 8 + * tagging support, look at tag_8021q.c instead. 9 + */ 10 + 11 + #include "dsa_priv.h" 12 + 13 + #define NONE_NAME "none" 14 + 15 + static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, 16 + struct net_device *dev) 17 + { 18 + /* Just return the original SKB */ 19 + return skb; 20 + } 21 + 22 + static const struct dsa_device_ops none_ops = { 23 + .name = NONE_NAME, 24 + .proto = DSA_TAG_PROTO_NONE, 25 + .xmit = dsa_slave_notag_xmit, 26 + }; 27 + 28 + module_dsa_tag_driver(none_ops); 29 + MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_NONE, NONE_NAME); 30 + MODULE_LICENSE("GPL");