[PATCH 15/18] net: dpaa2: fix mixed module-builtin object
From: Alexander Lobakin
Date: Sat Nov 19 2022 - 18:10:16 EST
With CONFIG_FSL_DPAA2_ETH=m and CONFIG_FSL_DPAA2_SWITCH=y (or vice
versa), dpaa2-mac.o and dpmac.o are linked to a module and also to
vmlinux even though the expected CFLAGS are different between
builtins and modules.
This is the same situation as fixed by
commit 637a642f5ca5 ("zstd: Fixing mixed module-builtin objects").
There's also no need to duplicate relatively big piece of object
code into two modules.
Introduce the new module, fsl-dpaa2-mac, to provide the common
functions to both fsl-dpaa2-eth and fsl-dpaa2-switch.
Misc: constify and shrink @dpaa2_mac_ethtool_stats while at it.
Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Suggested-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
Signed-off-by: Alexander Lobakin <alobakin@xxxxx>
---
drivers/net/ethernet/freescale/dpaa2/Kconfig | 6 ++++++
drivers/net/ethernet/freescale/dpaa2/Makefile | 6 ++++--
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 ++
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 15 ++++++++++++++-
.../net/ethernet/freescale/dpaa2/dpaa2-switch.c | 2 ++
5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/Kconfig b/drivers/net/ethernet/freescale/dpaa2/Kconfig
index d029b69c3f18..54c388f25c43 100644
--- a/drivers/net/ethernet/freescale/dpaa2/Kconfig
+++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig
@@ -1,7 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+config FSL_DPAA2_MAC
+ tristate
+
config FSL_DPAA2_ETH
tristate "Freescale DPAA2 Ethernet"
depends on FSL_MC_BUS && FSL_MC_DPIO
+ select FSL_DPAA2_MAC
select PHYLINK
select PCS_LYNX
select FSL_XGMAC_MDIO
@@ -34,6 +39,7 @@ config FSL_DPAA2_SWITCH
tristate "Freescale DPAA2 Ethernet Switch"
depends on BRIDGE || BRIDGE=n
depends on NET_SWITCHDEV
+ select FSL_DPAA2_MAC
help
Driver for Freescale DPAA2 Ethernet Switch. This driver manages
switch objects discovered on the Freeescale MC bus.
diff --git a/drivers/net/ethernet/freescale/dpaa2/Makefile b/drivers/net/ethernet/freescale/dpaa2/Makefile
index 3d9842af7f10..9dbe2273c9a1 100644
--- a/drivers/net/ethernet/freescale/dpaa2/Makefile
+++ b/drivers/net/ethernet/freescale/dpaa2/Makefile
@@ -4,14 +4,16 @@
#
obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o
+obj-$(CONFIG_FSL_DPAA2_MAC) += fsl-dpaa2-mac.o
obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += fsl-dpaa2-ptp.o
obj-$(CONFIG_FSL_DPAA2_SWITCH) += fsl-dpaa2-switch.o
-fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-mac.o dpmac.o dpaa2-eth-devlink.o
+fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-eth-devlink.o
fsl-dpaa2-eth-${CONFIG_FSL_DPAA2_ETH_DCB} += dpaa2-eth-dcb.o
fsl-dpaa2-eth-${CONFIG_DEBUG_FS} += dpaa2-eth-debugfs.o
+fsl-dpaa2-mac-objs := dpaa2-mac.o dpmac.o
fsl-dpaa2-ptp-objs := dpaa2-ptp.o dprtc.o
-fsl-dpaa2-switch-objs := dpaa2-switch.o dpaa2-switch-ethtool.o dpsw.o dpaa2-switch-flower.o dpaa2-mac.o dpmac.o
+fsl-dpaa2-switch-objs := dpaa2-switch.o dpaa2-switch-ethtool.o dpsw.o dpaa2-switch-flower.o
# Needed by the tracing framework
CFLAGS_dpaa2-eth.o := -I$(src)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 8d029addddad..876c3ed6e2c5 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -28,6 +28,8 @@
#define CREATE_TRACE_POINTS
#include "dpaa2-eth-trace.h"
+MODULE_IMPORT_NS(FSL_DPAA2_MAC);
+
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Freescale Semiconductor, Inc");
MODULE_DESCRIPTION("Freescale DPAA2 Ethernet Driver");
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 49ff85633783..dc2c7cde5435 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -339,12 +339,14 @@ void dpaa2_mac_start(struct dpaa2_mac *mac)
if (mac->serdes_phy)
phy_power_on(mac->serdes_phy);
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_start, FSL_DPAA2_MAC);
void dpaa2_mac_stop(struct dpaa2_mac *mac)
{
if (mac->serdes_phy)
phy_power_off(mac->serdes_phy);
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_stop, FSL_DPAA2_MAC);
int dpaa2_mac_connect(struct dpaa2_mac *mac)
{
@@ -435,6 +437,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
return err;
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_connect, FSL_DPAA2_MAC);
void dpaa2_mac_disconnect(struct dpaa2_mac *mac)
{
@@ -447,6 +450,7 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac)
of_phy_put(mac->serdes_phy);
mac->serdes_phy = NULL;
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_disconnect, FSL_DPAA2_MAC);
int dpaa2_mac_open(struct dpaa2_mac *mac)
{
@@ -495,6 +499,7 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
return err;
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_open, FSL_DPAA2_MAC);
void dpaa2_mac_close(struct dpaa2_mac *mac)
{
@@ -504,8 +509,9 @@ void dpaa2_mac_close(struct dpaa2_mac *mac)
if (mac->fw_node)
fwnode_handle_put(mac->fw_node);
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_close, FSL_DPAA2_MAC);
-static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = {
+static const char * const dpaa2_mac_ethtool_stats[] = {
[DPMAC_CNT_ING_ALL_FRAME] = "[mac] rx all frames",
[DPMAC_CNT_ING_GOOD_FRAME] = "[mac] rx frames ok",
[DPMAC_CNT_ING_ERR_FRAME] = "[mac] rx frame errors",
@@ -542,6 +548,7 @@ int dpaa2_mac_get_sset_count(void)
{
return DPAA2_MAC_NUM_STATS;
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_sset_count, FSL_DPAA2_MAC);
void dpaa2_mac_get_strings(u8 *data)
{
@@ -553,6 +560,7 @@ void dpaa2_mac_get_strings(u8 *data)
p += ETH_GSTRING_LEN;
}
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_strings, FSL_DPAA2_MAC);
void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data)
{
@@ -572,3 +580,8 @@ void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data)
*(data + i) = value;
}
}
+EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_ethtool_stats, FSL_DPAA2_MAC);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Freescale Semiconductor, Inc");
+MODULE_DESCRIPTION("Freescale DPAA2 MAC Driver");
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 2b5909fa93cf..fccbaf75b512 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -3534,5 +3534,7 @@ static void __exit dpaa2_switch_driver_exit(void)
module_init(dpaa2_switch_driver_init);
module_exit(dpaa2_switch_driver_exit);
+MODULE_IMPORT_NS(FSL_DPAA2_MAC);
+
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("DPAA2 Ethernet Switch Driver");
--
2.38.1