[PATCH net-next v3 7/9] net: stmmac: qcom-ethqos: share common GMAC4 address table
From: Mohd Ayaan Anwar
Date: Sat Oct 17 2026 - 05:46:45 EST
Several ETHQOS versions use identical GMAC4 DMA and MTL address offsets.
Store the descriptor once and let per-compatible data reference it.
Use its presence, rather than has_emac_ge_3, when passing it to stmmac
core. This keeps address-table ownership independent of the feature
flag.
No functional change intended.
Suggested-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxxxxxxxxxxxx>
Signed-off-by: Mohd Ayaan Anwar <mohd.anwar@xxxxxxxxxxxxxxxx>
---
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 57 +++++++++-------------
1 file changed, 22 insertions(+), 35 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 2471871562ed9915398614d5c88d1c6673829db8..370eb05caabc00a20d887ac88c1ffa4473bc4021 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -96,7 +96,7 @@ struct ethqos_emac_driver_data {
bool has_emac_ge_3;
u8 dma_addr_width;
const char *link_clk_name;
- struct dwmac4_addrs dwmac4_addrs;
+ const struct dwmac4_addrs *dwmac4_addrs;
bool needs_sgmii_loopback;
};
@@ -247,6 +247,23 @@ static const struct ethqos_emac_driver_data emac_v2_1_0_data = {
.has_emac_ge_3 = false,
};
+static const struct dwmac4_addrs ethqos_dwmac4_addrs = {
+ .dma_chan = 0x00008100,
+ .dma_chan_offset = 0x1000,
+ .mtl_chan = 0x00008000,
+ .mtl_chan_offset = 0x1000,
+ .mtl_ets_ctrl = 0x00008010,
+ .mtl_ets_ctrl_offset = 0x1000,
+ .mtl_txq_weight = 0x00008018,
+ .mtl_txq_weight_offset = 0x1000,
+ .mtl_send_slp_cred = 0x0000801c,
+ .mtl_send_slp_cred_offset = 0x1000,
+ .mtl_high_cred = 0x00008020,
+ .mtl_high_cred_offset = 0x1000,
+ .mtl_low_cred = 0x00008024,
+ .mtl_low_cred_offset = 0x1000,
+};
+
static const struct ethqos_emac_por emac_v3_0_0_por[] = {
{ .offset = RGMII_IO_MACRO_CONFIG, .value = 0x40c01343 },
{ .offset = SDCC_HC_REG_DLL_CONFIG, .value = 0x2004642c },
@@ -261,22 +278,7 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = {
.num_rgmii_por = ARRAY_SIZE(emac_v3_0_0_por),
.rgmii_config_loopback_en = false,
.has_emac_ge_3 = true,
- .dwmac4_addrs = {
- .dma_chan = 0x00008100,
- .dma_chan_offset = 0x1000,
- .mtl_chan = 0x00008000,
- .mtl_chan_offset = 0x1000,
- .mtl_ets_ctrl = 0x00008010,
- .mtl_ets_ctrl_offset = 0x1000,
- .mtl_txq_weight = 0x00008018,
- .mtl_txq_weight_offset = 0x1000,
- .mtl_send_slp_cred = 0x0000801c,
- .mtl_send_slp_cred_offset = 0x1000,
- .mtl_high_cred = 0x00008020,
- .mtl_high_cred_offset = 0x1000,
- .mtl_low_cred = 0x00008024,
- .mtl_low_cred_offset = 0x1000,
- },
+ .dwmac4_addrs = ðqos_dwmac4_addrs,
};
static const struct ethqos_emac_por emac_v4_0_0_por[] = {
@@ -296,22 +298,7 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = {
.link_clk_name = "phyaux",
.needs_sgmii_loopback = true,
.dma_addr_width = 36,
- .dwmac4_addrs = {
- .dma_chan = 0x00008100,
- .dma_chan_offset = 0x1000,
- .mtl_chan = 0x00008000,
- .mtl_chan_offset = 0x1000,
- .mtl_ets_ctrl = 0x00008010,
- .mtl_ets_ctrl_offset = 0x1000,
- .mtl_txq_weight = 0x00008018,
- .mtl_txq_weight_offset = 0x1000,
- .mtl_send_slp_cred = 0x0000801c,
- .mtl_send_slp_cred_offset = 0x1000,
- .mtl_high_cred = 0x00008020,
- .mtl_high_cred_offset = 0x1000,
- .mtl_low_cred = 0x00008024,
- .mtl_low_cred_offset = 0x1000,
- },
+ .dwmac4_addrs = ðqos_dwmac4_addrs,
};
static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
@@ -830,8 +817,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
plat_dat->dump_debug_regs = rgmii_dump;
plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config;
plat_dat->core_type = DWMAC_CORE_GMAC4;
- if (ethqos->has_emac_ge_3)
- plat_dat->dwmac4_addrs = &data->dwmac4_addrs;
+ if (data->dwmac4_addrs)
+ plat_dat->dwmac4_addrs = data->dwmac4_addrs;
plat_dat->pmt = true;
if (of_property_read_bool(np, "snps,tso"))
plat_dat->flags |= STMMAC_FLAG_TSO_EN;
--
2.34.1