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

net: build all switchdev drivers as modules when the bridge is a module

Currently, all drivers depend on the bool CONFIG_NET_SWITCHDEV, but only
the drivers that call some sort of function exported by the bridge, like
br_vlan_enabled() or whatever, have an extra dependency on CONFIG_BRIDGE.

Since the blamed commit, all switchdev drivers have a functional
dependency upon switchdev_bridge_port_{,un}offload(), which is a pair of
functions exported by the bridge module and not by the bridge-independent
part of CONFIG_NET_SWITCHDEV.

Problems appear when we have:

CONFIG_BRIDGE=m
CONFIG_NET_SWITCHDEV=y
CONFIG_TI_CPSW_SWITCHDEV=y

because cpsw, am65_cpsw and sparx5 will then be built-in but they will
call a symbol exported by a loadable module. This is not possible and
will result in the following build error:

drivers/net/ethernet/ti/cpsw_new.o: in function `cpsw_netdevice_event':
drivers/net/ethernet/ti/cpsw_new.c:1520: undefined reference to
`switchdev_bridge_port_offload'
drivers/net/ethernet/ti/cpsw_new.c:1537: undefined reference to
`switchdev_bridge_port_unoffload'

As mentioned, the other switchdev drivers don't suffer from this because
switchdev_bridge_port_offload() is not the first symbol exported by the
bridge that they are calling, so they already needed to deal with this
in the same way.

Fixes: 2f5dc00f7a3e ("net: bridge: switchdev: let drivers inform which bridge ports are offloaded")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
b0e81817 9b29a161

+3
+1
drivers/net/ethernet/microchip/sparx5/Kconfig
··· 1 1 config SPARX5_SWITCH 2 2 tristate "Sparx5 switch driver" 3 + depends on BRIDGE || BRIDGE=n 3 4 depends on NET_SWITCHDEV 4 5 depends on HAS_IOMEM 5 6 depends on OF
+2
drivers/net/ethernet/ti/Kconfig
··· 64 64 config TI_CPSW_SWITCHDEV 65 65 tristate "TI CPSW Switch Support with switchdev" 66 66 depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST 67 + depends on BRIDGE || BRIDGE=n 67 68 depends on NET_SWITCHDEV 68 69 depends on TI_CPTS || !TI_CPTS 69 70 select PAGE_POOL ··· 110 109 config TI_K3_AM65_CPSW_SWITCHDEV 111 110 bool "TI K3 AM654x/J721E CPSW Switch mode support" 112 111 depends on TI_K3_AM65_CPSW_NUSS 112 + depends on BRIDGE || BRIDGE=n 113 113 depends on NET_SWITCHDEV 114 114 help 115 115 This enables switchdev support for TI K3 CPSWxG Ethernet