[PATCH net-next v4 07/10] net: stmmac: qcom-ethqos: share common GMAC4 address table
From: Mohd Ayaan Anwar
Date: Tue Nov 17 2026 - 03:47:25 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 | 74 +++++++---------------
1 file changed, 23 insertions(+), 51 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 192788e00dfa..bc443793539b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -100,7 +100,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;
/* Fixed PTP reference clock rate, used on SCMI platforms where
* firmware does not implement the clock protocol allowing linux to
@@ -262,6 +262,23 @@ static const struct ethqos_emac_driver_data emac_v2_1_0_data = {
.setup = ethqos_hlos_setup,
};
+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 },
@@ -276,22 +293,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,
.setup = ethqos_hlos_setup,
};
@@ -312,22 +314,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,
.setup = ethqos_hlos_setup,
};
@@ -336,22 +323,7 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_scmi_data = {
.needs_sgmii_loopback = true,
.dma_addr_width = 36,
.ptp_clk_rate = 230400000,
- .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,
.setup = ethqos_scmi_setup,
};
@@ -999,8 +971,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
plat_dat->bsp_priv = ethqos;
plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config;
plat_dat->core_type = DWMAC_CORE_GMAC4;
- if (data->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