Skip to content

Commit a710df1

Browse files
arndbgregkh
authored andcommitted
net: ethernet: ti-cpsw: fix linking built-in code to modules
[ Upstream commit df75bd5 ] There are six variants of the cpsw driver, sharing various parts of the code: davinci-emac, cpsw, cpsw-switchdev, netcp, netcp_ethss and am65-cpsw-nuss. I noticed that this means some files can be linked into more than one loadable module, or even part of vmlinux but also linked into a loadable module, both of which mess up assumptions of the build system, and causes warnings: scripts/Makefile.build:279: cpsw_ale.o is added to multiple modules: ti-am65-cpsw-nuss ti_cpsw ti_cpsw_new scripts/Makefile.build:279: cpsw_priv.o is added to multiple modules: ti_cpsw ti_cpsw_new scripts/Makefile.build:279: cpsw_sl.o is added to multiple modules: ti-am65-cpsw-nuss ti_cpsw ti_cpsw_new scripts/Makefile.build:279: cpsw_ethtool.o is added to multiple modules: ti_cpsw ti_cpsw_new scripts/Makefile.build:279: davinci_cpdma.o is added to multiple modules: ti_cpsw ti_cpsw_new ti_davinci_emac Change this back to having separate modules for each portion that can be linked standalone, exporting symbols as needed: - ti-cpsw-common.ko now contains both cpsw-common.o and davinci_cpdma.o as they are always used together - ti-cpsw-priv.ko contains cpsw_priv.o, cpsw_sl.o and cpsw_ethtool.o, which are the core of the cpsw and cpsw-new drivers. - ti-cpsw-sl.ko contains the cpsw-sl.o object and is used on ti-am65-cpsw-nuss.ko in addition to the two other cpsw variants. - ti-cpsw-ale.o is the one standalone module that is used by all except davinci_emac. Each of these will be built-in if any of its users are built-in, otherwise it's a loadable module if there is at least one module using it. I did not bring back the separate Kconfig symbols for this, but just handle it using Makefile logic. Note: ideally this is something that Kbuild complains about, but usually we just notice when something using THIS_MODULE misbehaves in a way that a user notices. Fixes: 99f6297 ("net: ethernet: ti: cpsw: drop TI_DAVINCI_CPDMA config option") Link: https://lore.kernel.org/lkml/20240417084400.3034104-1-arnd@kernel.org/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://patch.msgid.link/20260402184726.3746487-2-arnd@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2bbe3d5 commit a710df1

6 files changed

Lines changed: 139 additions & 15 deletions

File tree

drivers/net/ethernet/ti/Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
obj-$(CONFIG_TI_PRUETH) += icssm-prueth.o
77
icssm-prueth-y := icssm/icssm_prueth.o
88

9-
obj-$(CONFIG_TI_CPSW) += cpsw-common.o
10-
obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o
11-
obj-$(CONFIG_TI_CPSW_SWITCHDEV) += cpsw-common.o
9+
ti-cpsw-common-y += cpsw-common.o davinci_cpdma.o
10+
ti-cpsw-priv-y += cpsw_priv.o cpsw_ethtool.o
11+
ti-cpsw-ale-y += cpsw_ale.o
12+
ti-cpsw-sl-y += cpsw_sl.o
1213

1314
obj-$(CONFIG_TLAN) += tlan.o
14-
obj-$(CONFIG_TI_DAVINCI_EMAC) += ti_davinci_emac.o
15-
ti_davinci_emac-y := davinci_emac.o davinci_cpdma.o
15+
obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o ti-cpsw-common.o
1616
obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
1717
obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o
1818
obj-$(CONFIG_TI_CPTS) += cpts.o
19-
obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
20-
ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o cpsw_sl.o cpsw_ethtool.o
21-
obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o
22-
ti_cpsw_new-y := cpsw_switchdev.o cpsw_new.o davinci_cpdma.o cpsw_ale.o cpsw_sl.o cpsw_priv.o cpsw_ethtool.o
19+
obj-$(CONFIG_TI_CPSW) += ti_cpsw.o ti-cpsw-common.o ti-cpsw-priv.o ti-cpsw-ale.o ti-cpsw-sl.o
20+
ti_cpsw-y := cpsw.o
21+
obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o ti-cpsw-common.o ti-cpsw-priv.o ti-cpsw-ale.o ti-cpsw-sl.o
22+
ti_cpsw_new-y := cpsw_switchdev.o cpsw_new.o
2323

24-
obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
25-
keystone_netcp-y := netcp_core.o cpsw_ale.o
26-
obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
27-
keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.o
24+
obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o ti-cpsw-ale.o
25+
keystone_netcp-y := netcp_core.o
26+
obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o ti-cpsw-ale.o
27+
keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o
2828

2929
obj-$(CONFIG_TI_K3_CPPI_DESC_POOL) += k3-cppi-desc-pool.o
3030

31-
obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
32-
ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o
31+
obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o ti-cpsw-sl.o ti-cpsw-ale.o
32+
ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o am65-cpsw-ethtool.o
3333
ti-am65-cpsw-nuss-$(CONFIG_TI_AM65_CPSW_QOS) += am65-cpsw-qos.o
3434
ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
3535
obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
498498
}
499499
return 0;
500500
}
501+
EXPORT_SYMBOL_GPL(cpsw_ale_flush_multicast);
501502

502503
static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry,
503504
int flags, u16 vid)
@@ -535,6 +536,7 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
535536
cpsw_ale_write(ale, idx, ale_entry);
536537
return 0;
537538
}
539+
EXPORT_SYMBOL_GPL(cpsw_ale_add_ucast);
538540

539541
int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
540542
int flags, u16 vid)
@@ -550,6 +552,7 @@ int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
550552
cpsw_ale_write(ale, idx, ale_entry);
551553
return 0;
552554
}
555+
EXPORT_SYMBOL_GPL(cpsw_ale_del_ucast);
553556

554557
int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
555558
int flags, u16 vid, int mcast_state)
@@ -583,6 +586,7 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
583586
cpsw_ale_write(ale, idx, ale_entry);
584587
return 0;
585588
}
589+
EXPORT_SYMBOL_GPL(cpsw_ale_add_mcast);
586590

587591
int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
588592
int flags, u16 vid)
@@ -612,6 +616,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
612616
cpsw_ale_write(ale, idx, ale_entry);
613617
return 0;
614618
}
619+
EXPORT_SYMBOL_GPL(cpsw_ale_del_mcast);
615620

616621
/* ALE NetCP NU switch specific vlan functions */
617622
static void cpsw_ale_set_vlan_mcast(struct cpsw_ale *ale, u32 *ale_entry,
@@ -681,6 +686,7 @@ int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
681686
cpsw_ale_write(ale, idx, ale_entry);
682687
return 0;
683688
}
689+
EXPORT_SYMBOL_GPL(cpsw_ale_add_vlan);
684690

685691
static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale, u32 *ale_entry,
686692
u16 vid, int port_mask)
@@ -738,6 +744,7 @@ int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask)
738744

739745
return 0;
740746
}
747+
EXPORT_SYMBOL_GPL(cpsw_ale_vlan_del_modify);
741748

742749
int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
743750
{
@@ -772,6 +779,7 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
772779

773780
return 0;
774781
}
782+
EXPORT_SYMBOL_GPL(cpsw_ale_del_vlan);
775783

776784
int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
777785
int untag_mask, int reg_mask, int unreg_mask)
@@ -811,6 +819,7 @@ int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
811819

812820
return ret;
813821
}
822+
EXPORT_SYMBOL_GPL(cpsw_ale_vlan_add_modify);
814823

815824
void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
816825
bool add)
@@ -838,6 +847,7 @@ void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
838847
cpsw_ale_write(ale, idx, ale_entry);
839848
}
840849
}
850+
EXPORT_SYMBOL_GPL(cpsw_ale_set_unreg_mcast);
841851

842852
static void cpsw_ale_vlan_set_unreg_mcast(struct cpsw_ale *ale, u32 *ale_entry,
843853
int allmulti)
@@ -903,6 +913,7 @@ void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port)
903913
cpsw_ale_write(ale, idx, ale_entry);
904914
}
905915
}
916+
EXPORT_SYMBOL_GPL(cpsw_ale_set_allmulti);
906917

907918
struct ale_control_info {
908919
const char *name;
@@ -1160,6 +1171,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
11601171

11611172
return 0;
11621173
}
1174+
EXPORT_SYMBOL_GPL(cpsw_ale_control_set);
11631175

11641176
int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
11651177
{
@@ -1183,6 +1195,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
11831195
tmp = readl_relaxed(ale->params.ale_regs + offset) >> shift;
11841196
return tmp & BITMASK(info->bits);
11851197
}
1198+
EXPORT_SYMBOL_GPL(cpsw_ale_control_get);
11861199

11871200
int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)
11881201

@@ -1205,6 +1218,7 @@ int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int rateli
12051218
port, val * ALE_RATE_LIMIT_MIN_PPS);
12061219
return 0;
12071220
}
1221+
EXPORT_SYMBOL_GPL(cpsw_ale_rx_ratelimit_mc);
12081222

12091223
int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)
12101224

@@ -1227,6 +1241,7 @@ int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int rateli
12271241
port, val * ALE_RATE_LIMIT_MIN_PPS);
12281242
return 0;
12291243
}
1244+
EXPORT_SYMBOL_GPL(cpsw_ale_rx_ratelimit_bc);
12301245

12311246
static void cpsw_ale_timer(struct timer_list *t)
12321247
{
@@ -1316,13 +1331,15 @@ void cpsw_ale_start(struct cpsw_ale *ale)
13161331

13171332
cpsw_ale_aging_start(ale);
13181333
}
1334+
EXPORT_SYMBOL_GPL(cpsw_ale_start);
13191335

13201336
void cpsw_ale_stop(struct cpsw_ale *ale)
13211337
{
13221338
cpsw_ale_aging_stop(ale);
13231339
cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
13241340
cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
13251341
}
1342+
EXPORT_SYMBOL_GPL(cpsw_ale_stop);
13261343

13271344
static const struct reg_field ale_fields_cpsw[] = {
13281345
/* CPSW_ALE_IDVER_REG */
@@ -1623,6 +1640,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
16231640
cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
16241641
return ale;
16251642
}
1643+
EXPORT_SYMBOL_GPL(cpsw_ale_create);
16261644

16271645
void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
16281646
{
@@ -1633,6 +1651,7 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
16331651
data += ALE_ENTRY_WORDS;
16341652
}
16351653
}
1654+
EXPORT_SYMBOL_GPL(cpsw_ale_dump);
16361655

16371656
void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
16381657
{
@@ -1643,11 +1662,13 @@ void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
16431662
data += ALE_ENTRY_WORDS;
16441663
}
16451664
}
1665+
EXPORT_SYMBOL_GPL(cpsw_ale_restore);
16461666

16471667
u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale)
16481668
{
16491669
return ale ? ale->params.ale_entries : 0;
16501670
}
1671+
EXPORT_SYMBOL_GPL(cpsw_ale_get_num_entries);
16511672

16521673
/* Reads the specified policer index into ALE POLICER registers */
16531674
static void cpsw_ale_policer_read_idx(struct cpsw_ale *ale, u32 idx)
@@ -1750,3 +1771,7 @@ void cpsw_ale_classifier_setup_default(struct cpsw_ale *ale, int num_rx_ch)
17501771
1);
17511772
}
17521773
}
1774+
EXPORT_SYMBOL_GPL(cpsw_ale_classifier_setup_default);
1775+
1776+
MODULE_LICENSE("GPL");
1777+
MODULE_DESCRIPTION("TI N-Port Ethernet Switch Address Lookup Engine");

0 commit comments

Comments
 (0)