* [PATCH net-next 01/13] net: ethernet: mtk_eth_soc: reset PDMA TX completion index on ring setup
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 02/13] net: ethernet: mtk_eth_soc: move PDMA TX ring registers to the register map Ho Jie Feng
` (12 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
mtk_poll_tx_pdma() resumes from ring->cpu_idx, and that field is only
ever written by the poll function itself. mtk_tx_alloc() resets the
hardware CPU and DMA indices of a new PDMA ring, but leaves the software
cursor at the value it had when the previous ring was torn down.
Start the software cursor at descriptor zero together with the hardware
indices.
Fixes: 296c9120752b ("net: ethernet: mediatek: Add MT7628/88 SoC support")
Link: https://github.com/dormancygrace/net-next/commit/c865cc487e7008aabd7a6616be5515b7541a657d
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 21abeccfe0..e4b703a79d 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2749,6 +2749,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
if (mtk_is_netsys_v2_or_greater(eth))
mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate + 4);
} else {
+ ring->cpu_idx = 0;
mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0);
mtk_w32(eth, ring_size, MT7628_TX_MAX_CNT0);
mtk_w32(eth, 0, MT7628_TX_CTX_IDX0);
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 02/13] net: ethernet: mtk_eth_soc: move PDMA TX ring registers to the register map
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 01/13] net: ethernet: mtk_eth_soc: reset PDMA TX completion index on ring setup Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 03/13] net: ethernet: mtk_eth_soc: add a per-SoC TX done interrupt mask Ho Jie Feng
` (11 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
Prepare for RT3883, where the PDMA registers are at other offsets.
Add the TX ring registers to the pdma part of struct mtk_reg_map, next
to the RX ones, and use them instead. No functional change.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 18 +++++++++++-------
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 6 +++++-
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index e4b703a79d..20f6566a84 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -98,6 +98,10 @@ static const struct mtk_reg_map mt7628_reg_map = {
.tx_irq_mask = 0x0a28,
.tx_irq_status = 0x0a20,
.pdma = {
+ .tx_ptr = MT7628_TX_BASE_PTR0,
+ .tx_cnt_cfg = MT7628_TX_MAX_CNT0,
+ .pctx_ptr = MT7628_TX_CTX_IDX0,
+ .pdtx_ptr = MT7628_TX_DTX_IDX0,
.rx_ptr = 0x0900,
.rx_cnt_cfg = 0x0904,
.pcrx_ptr = 0x0908,
@@ -1709,7 +1713,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->tx.desc_size),
ring->dma_size);
- mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0);
+ mtk_w32(eth, next_idx, soc->reg_map->pdma.pctx_ptr);
}
return 0;
@@ -2083,7 +2087,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf,
idx = txd_to_idx(ring, txd, soc->tx.desc_size);
mtk_w32(eth, NEXT_DESP_IDX(idx, ring->dma_size),
- MT7628_TX_CTX_IDX0);
+ soc->reg_map->pdma.pctx_ptr);
}
spin_unlock(ð->page_lock);
@@ -2527,7 +2531,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget,
u32 cpu, dma;
cpu = ring->cpu_idx;
- dma = mtk_r32(eth, MT7628_TX_DTX_IDX0);
+ dma = mtk_r32(eth, eth->soc->reg_map->pdma.pdtx_ptr);
xdp_frame_bulk_init(&bq);
while ((cpu != dma) && budget) {
@@ -2750,10 +2754,10 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate + 4);
} else {
ring->cpu_idx = 0;
- mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0);
- mtk_w32(eth, ring_size, MT7628_TX_MAX_CNT0);
- mtk_w32(eth, 0, MT7628_TX_CTX_IDX0);
- mtk_w32(eth, MT7628_PST_DTX_IDX0, soc->reg_map->pdma.rst_idx);
+ mtk_w32(eth, ring->phys_pdma, soc->reg_map->pdma.tx_ptr);
+ mtk_w32(eth, ring_size, soc->reg_map->pdma.tx_cnt_cfg);
+ mtk_w32(eth, 0, soc->reg_map->pdma.pctx_ptr);
+ mtk_w32(eth, MTK_PST_DTX_IDX0, soc->reg_map->pdma.rst_idx);
}
return 0;
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 88a9b3b23b..1291c324a8 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -203,6 +203,7 @@
#define MTK_RX_CFG_SDL_OFFSET 16
/* PDMA Reset Index Register */
+#define MTK_PST_DTX_IDX0 BIT(0)
#define MTK_PST_DRX_IDX0 BIT(16)
#define MTK_PST_DRX_IDX_CFG(x) (MTK_PST_DRX_IDX0 << (x))
@@ -621,7 +622,6 @@
#define MT7628_TX_MAX_CNT0 (MT7628_PDMA_OFFSET + 0x04)
#define MT7628_TX_CTX_IDX0 (MT7628_PDMA_OFFSET + 0x08)
#define MT7628_TX_DTX_IDX0 (MT7628_PDMA_OFFSET + 0x0c)
-#define MT7628_PST_DTX_IDX0 BIT(0)
#define MT7628_SDM_MAC_ADRL (MT7628_SDM_OFFSET + 0x0c)
#define MT7628_SDM_MAC_ADRH (MT7628_SDM_OFFSET + 0x10)
@@ -1145,6 +1145,10 @@ struct mtk_reg_map {
u32 tx_irq_mask;
u32 tx_irq_status;
struct {
+ u32 tx_ptr; /* tx base pointer */
+ u32 tx_cnt_cfg; /* tx max count configuration */
+ u32 pctx_ptr; /* tx cpu pointer */
+ u32 pdtx_ptr; /* tx dma pointer */
u32 rx_ptr; /* rx base pointer */
u32 rx_cnt_cfg; /* rx max count configuration */
u32 pcrx_ptr; /* rx cpu pointer */
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 03/13] net: ethernet: mtk_eth_soc: add a per-SoC TX done interrupt mask
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 01/13] net: ethernet: mtk_eth_soc: reset PDMA TX completion index on ring setup Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 02/13] net: ethernet: mtk_eth_soc: move PDMA TX ring registers to the register map Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 04/13] net: ethernet: mtk_eth_soc: complete PDMA TX on the right MAC Ho Jie Feng
` (10 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
Prepare for RT3883, where the TX done interrupt is on another bit.
Add tx.irq_done_mask to struct mtk_soc_data, set it to MTK_TX_DONE_INT
for all SoCs and use it instead. No functional change.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 35 ++++++++++++++-------
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 +-
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 20f6566a84..a52f6a57ee 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2603,7 +2603,7 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
mtk_handle_status_irq(eth);
- mtk_w32(eth, MTK_TX_DONE_INT, reg_map->tx_irq_status);
+ mtk_w32(eth, eth->soc->tx.irq_done_mask, reg_map->tx_irq_status);
tx_done = mtk_poll_tx(eth, budget);
if (unlikely(netif_msg_intr(eth))) {
@@ -2616,11 +2616,11 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget)
if (tx_done == budget)
return budget;
- if (mtk_r32(eth, reg_map->tx_irq_status) & MTK_TX_DONE_INT)
+ if (mtk_r32(eth, reg_map->tx_irq_status) & eth->soc->tx.irq_done_mask)
return budget;
if (napi_complete_done(napi, tx_done))
- mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_enable(eth, eth->soc->tx.irq_done_mask);
return tx_done;
}
@@ -3438,7 +3438,7 @@ static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth)
eth->tx_events++;
if (likely(napi_schedule_prep(ð->tx_napi))) {
- mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_disable(eth, eth->soc->tx.irq_done_mask);
__napi_schedule(ð->tx_napi);
}
@@ -3456,8 +3456,10 @@ static irqreturn_t mtk_handle_irq(int irq, void *_eth)
eth->soc->rx.irq_done_mask)
mtk_handle_irq_rx(irq, _eth);
}
- if (mtk_r32(eth, reg_map->tx_irq_mask) & MTK_TX_DONE_INT) {
- if (mtk_r32(eth, reg_map->tx_irq_status) & MTK_TX_DONE_INT)
+ if (mtk_r32(eth, reg_map->tx_irq_mask) &
+ eth->soc->tx.irq_done_mask) {
+ if (mtk_r32(eth, reg_map->tx_irq_status) &
+ eth->soc->tx.irq_done_mask)
mtk_handle_irq_tx(irq, _eth);
}
@@ -3470,10 +3472,10 @@ static void mtk_poll_controller(struct net_device *dev)
struct mtk_mac *mac = netdev_priv(dev);
struct mtk_eth *eth = mac->hw;
- mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_disable(eth, eth->soc->tx.irq_done_mask);
mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask);
mtk_handle_irq_rx(eth->irq[MTK_FE_IRQ_RX], eth);
- mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_enable(eth, eth->soc->tx.irq_done_mask);
mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask);
}
#endif
@@ -3662,7 +3664,7 @@ static int mtk_open(struct net_device *dev)
napi_enable(ð->tx_napi);
napi_enable(ð->rx_napi);
- mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_enable(eth, soc->tx.irq_done_mask);
mtk_rx_irq_enable(eth, soc->rx.irq_done_mask);
refcount_set(ð->dma_refcnt, 1);
} else {
@@ -3747,7 +3749,7 @@ static int mtk_stop(struct net_device *dev)
for (i = 0; i < MTK_MAX_DEVS; i++)
mtk_gdm_config(eth, i, MTK_GDMA_DROP_ALL);
- mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
+ mtk_tx_irq_disable(eth, eth->soc->tx.irq_done_mask);
mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask);
napi_disable(ð->tx_napi);
napi_disable(ð->rx_napi);
@@ -4236,9 +4238,9 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
mtk_rx_irq_disable(eth, ~0);
/* FE int grouping */
- mtk_w32(eth, MTK_TX_DONE_INT, reg_map->pdma.int_grp);
+ mtk_w32(eth, eth->soc->tx.irq_done_mask, reg_map->pdma.int_grp);
mtk_w32(eth, eth->soc->rx.irq_done_mask, reg_map->pdma.int_grp + 4);
- mtk_w32(eth, MTK_TX_DONE_INT, reg_map->qdma.int_grp);
+ mtk_w32(eth, eth->soc->tx.irq_done_mask, reg_map->qdma.int_grp);
mtk_w32(eth, eth->soc->rx.irq_done_mask, reg_map->qdma.int_grp + 4);
mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP);
@@ -5440,6 +5442,7 @@ static const struct mtk_soc_data mt2701_data = {
.version = 1,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5468,6 +5471,7 @@ static const struct mtk_soc_data mt7621_data = {
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5498,6 +5502,7 @@ static const struct mtk_soc_data mt7622_data = {
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5527,6 +5532,7 @@ static const struct mtk_soc_data mt7623_data = {
.disable_pll_modes = true,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5553,6 +5559,7 @@ static const struct mtk_soc_data mt7629_data = {
.version = 1,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5583,6 +5590,7 @@ static const struct mtk_soc_data mt7981_data = {
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma_v2),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
.dma_len_offset = 8,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5613,6 +5621,7 @@ static const struct mtk_soc_data mt7986_data = {
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma_v2),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
.dma_len_offset = 8,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5643,6 +5652,7 @@ static const struct mtk_soc_data mt7988_data = {
.foe_entry_size = MTK_FOE_ENTRY_V3_SIZE,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma_v2),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
.dma_len_offset = 8,
.dma_size = MTK_DMA_SIZE(2K),
@@ -5667,6 +5677,7 @@ static const struct mtk_soc_data rt5350_data = {
.version = 1,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = MTK_TX_DONE_INT,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
.dma_size = MTK_DMA_SIZE(2K),
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 1291c324a8..9b20b39eae 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -1207,7 +1207,7 @@ struct mtk_reg_map {
* @has_accounting Bool indicating support for accounting of
* offloaded flows.
* @desc_size Tx/Rx DMA descriptor size.
- * @irq_done_mask Rx irq done register mask.
+ * @irq_done_mask Tx/Rx irq done register mask.
* @dma_l4_valid Rx DMA valid register mask.
* @dma_max_len Max DMA tx/rx buffer length.
* @dma_len_offset Tx/Rx DMA length field offset.
@@ -1228,6 +1228,7 @@ struct mtk_soc_data {
bool disable_pll_modes;
struct {
u32 desc_size;
+ u32 irq_done_mask;
u32 dma_max_len;
u32 dma_len_offset;
u32 dma_size;
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 04/13] net: ethernet: mtk_eth_soc: complete PDMA TX on the right MAC
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (2 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 03/13] net: ethernet: mtk_eth_soc: add a per-SoC TX done interrupt mask Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 05/13] dt-bindings: net: mediatek,net: fix the ralink,rt5350-eth constraints Ho Jie Feng
` (9 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
Prepare for RT3883, which has two MACs. mtk_poll_tx_pdma() completes
every skb on MAC 0, which is only right on MT7628, as it has a single
MAC.
Use the MAC id stored in the TX buffer, as the QDMA path does.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index a52f6a57ee..4099d7c426 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2541,7 +2541,8 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget,
if (tx_buf->data != (void *)MTK_DMA_DUMMY_DESC) {
if (tx_buf->type == MTK_TYPE_SKB)
- mtk_poll_tx_done(eth, state, 0, tx_buf->data);
+ mtk_poll_tx_done(eth, state, tx_buf->mac_id,
+ tx_buf->data);
budget--;
}
mtk_tx_unmap(eth, tx_buf, &bq, true);
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 05/13] dt-bindings: net: mediatek,net: fix the ralink,rt5350-eth constraints
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (3 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 04/13] net: ethernet: mtk_eth_soc: complete PDMA TX on the right MAC Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 06/13] dt-bindings: net: mediatek,net: add ralink,rt3883-eth Ho Jie Feng
` (8 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
RT5350/MT7628, under ralink,rt5350-eth, have no ethsys syscon and no
WED, and fewer clocks and resets. The binding still requires
mediatek,ethsys and at least two clocks and three resets, and allows
mediatek,wed.
Only require these for the MediaTek SoCs, and disallow mediatek,ethsys
and mediatek,wed for ralink,rt5350-eth.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
.../devicetree/bindings/net/mediatek,net.yaml | 29 +++++++++++++++----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/mediatek,net.yaml b/Documentation/devicetree/bindings/net/mediatek,net.yaml
index 6bbd83c6aa..a7291852bf 100644
--- a/Documentation/devicetree/bindings/net/mediatek,net.yaml
+++ b/Documentation/devicetree/bindings/net/mediatek,net.yaml
@@ -31,11 +31,11 @@ properties:
maxItems: 1
clocks:
- minItems: 2
+ minItems: 1
maxItems: 24
clock-names:
- minItems: 2
+ minItems: 1
maxItems: 24
interrupts:
@@ -58,9 +58,11 @@ properties:
maxItems: 1
resets:
+ minItems: 1
maxItems: 3
reset-names:
+ minItems: 1
items:
- const: fe
- const: gmac
@@ -442,12 +444,30 @@ allOf:
properties:
compatible:
contains:
- const: ralink,rt5350-eth
+ enum:
+ - ralink,rt5350-eth
then:
properties:
- mediatek,wed:
+ mediatek,ethsys: false
+
+ mediatek,wed: false
+ else:
+ properties:
+ clocks:
minItems: 2
+ clock-names:
+ minItems: 2
+
+ resets:
+ minItems: 3
+
+ reset-names:
+ minItems: 3
+
+ required:
+ - mediatek,ethsys
+
patternProperties:
"^mac@[0-2]$":
type: object
@@ -473,7 +493,6 @@ required:
- interrupts
- clocks
- clock-names
- - mediatek,ethsys
unevaluatedProperties: false
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 06/13] dt-bindings: net: mediatek,net: add ralink,rt3883-eth
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (4 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 05/13] dt-bindings: net: mediatek,net: fix the ralink,rt5350-eth constraints Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 07/13] net: ethernet: mtk_eth_soc: use BIT_ULL() for the required clocks Ho Jie Feng
` (7 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
The RT3883 frame engine is the older Ralink one. It has a single
interrupt, clock and reset, and like the rt5350 one, no ethsys syscon
and no WED.
Add ralink,rt3883-eth to the Ralink compatibles, with these limits.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
.../devicetree/bindings/net/mediatek,net.yaml | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/mediatek,net.yaml b/Documentation/devicetree/bindings/net/mediatek,net.yaml
index a7291852bf..5c3ec3b3a4 100644
--- a/Documentation/devicetree/bindings/net/mediatek,net.yaml
+++ b/Documentation/devicetree/bindings/net/mediatek,net.yaml
@@ -25,6 +25,7 @@ properties:
- mediatek,mt7981-eth
- mediatek,mt7986-eth
- mediatek,mt7988-eth
+ - ralink,rt3883-eth
- ralink,rt5350-eth
reg:
@@ -440,11 +441,41 @@ allOf:
mediatek,wed:
minItems: 2
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: ralink,rt3883-eth
+ then:
+ properties:
+ interrupts:
+ maxItems: 1
+
+ interrupt-names:
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+ clock-names:
+ items:
+ - const: fe
+
+ resets:
+ maxItems: 1
+
+ reset-names:
+ maxItems: 1
+
+ required:
+ - resets
+
- if:
properties:
compatible:
contains:
enum:
+ - ralink,rt3883-eth
- ralink,rt5350-eth
then:
properties:
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 07/13] net: ethernet: mtk_eth_soc: use BIT_ULL() for the required clocks
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (5 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 06/13] dt-bindings: net: mediatek,net: add ralink,rt3883-eth Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 08/13] net: ethernet: mtk_eth_soc: add RT3883 support Ho Jie Feng
` (6 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
Prepare for RT3883, which requires the fe clock.
required_clks is a u64, but mtk_probe() tests it with BIT().
With fe (11) required, along with top_netsys_warp_sel (43),
the probe fails.
Use BIT_ULL().
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 4099d7c426..83a829bfa0 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -5266,7 +5266,7 @@ static int mtk_probe(struct platform_device *pdev)
err = -EPROBE_DEFER;
goto err_wed_exit;
}
- if (eth->soc->required_clks & BIT(i)) {
+ if (eth->soc->required_clks & BIT_ULL(i)) {
dev_err(&pdev->dev, "clock %s not found\n",
mtk_clks_source_name[i]);
err = -EINVAL;
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 08/13] net: ethernet: mtk_eth_soc: add RT3883 support
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (6 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 07/13] net: ethernet: mtk_eth_soc: use BIT_ULL() for the required clocks Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 09/13] net: ethernet: mtk_eth_soc: allow building for RT5350 Ho Jie Feng
` (5 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
The RT3883 frame engine is PDMA only like RT5350/MT7628, but it is the
older one, shared with RT2880 and RT305x:
- different register offsets
- the descriptors carry the GDMA port in txd4/rxd4
- the GMAC link is forced through MDIO_CFG
RT3883 also has two RGMII GMACs.
Add support for this RT2880 family, the way MT7628 is supported.
Tested on an ASUS RT-N56U (RT3883).
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/Kconfig | 3 +-
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 255 +++++++++++++++++---
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 57 +++++
3 files changed, 285 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
index 2ba361f8ce..0f9fd3659b 100644
--- a/drivers/net/ethernet/mediatek/Kconfig
+++ b/drivers/net/ethernet/mediatek/Kconfig
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only
config NET_VENDOR_MEDIATEK
bool "MediaTek devices"
- depends on ARCH_MEDIATEK || ARCH_AIROHA || SOC_MT7621 || SOC_MT7620 || COMPILE_TEST
+ depends on ARCH_MEDIATEK || ARCH_AIROHA || SOC_MT7621 || SOC_MT7620 || \
+ SOC_RT3883 || COMPILE_TEST
help
If you have a Mediatek SoC with ethernet, say Y.
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 83a829bfa0..33750f6b54 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -29,6 +29,7 @@
#include <net/netdev_lock.h>
#include <net/page_pool/helpers.h>
#include <linux/genalloc.h>
+#include <linux/units.h>
#include "mtk_eth_soc.h"
#include "mtk_wed.h"
@@ -218,6 +219,26 @@ static const struct mtk_reg_map mt7988_reg_map = {
.pse_oq_sta = 0x01a0,
};
+static const struct mtk_reg_map rt2880_reg_map = {
+ .tx_irq_mask = 0x0014,
+ .tx_irq_status = 0x0010,
+ .pdma = {
+ .tx_ptr = 0x0110,
+ .tx_cnt_cfg = 0x0114,
+ .pctx_ptr = 0x0118,
+ .pdtx_ptr = 0x011c,
+ .rx_ptr = 0x0130,
+ .rx_cnt_cfg = 0x0134,
+ .pcrx_ptr = 0x0138,
+ .glo_cfg = 0x0100,
+ .rst_idx = 0x0104,
+ .delay_irq = 0x010c,
+ .irq_status = 0x0010,
+ .irq_mask = 0x0014,
+ },
+ .gdm1_cnt = 0x0700,
+};
+
/* strings used by ethtool */
static const struct mtk_ethtool_stats {
char str[ETH_GSTRING_LEN];
@@ -983,6 +1004,59 @@ static const struct phylink_mac_ops rt5350_phylink_ops = {
.mac_link_up = rt5350_mac_link_up,
};
+static void rt2880_mac_link_down(struct phylink_config *config,
+ unsigned int mode, phy_interface_t interface)
+{
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
+ phylink_config);
+
+ mtk_m32(mac->hw, 0, RT_MDIO_LNK_DWN, RT_MDIO_CFG(mac->id));
+}
+
+static void rt2880_mac_link_up(struct phylink_config *config,
+ struct phy_device *phy,
+ unsigned int mode, phy_interface_t interface,
+ int speed, int duplex, bool tx_pause, bool rx_pause)
+{
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
+ phylink_config);
+ u32 val;
+
+ /* 200 ps RGMII clock skew, as set by the OpenWrt driver */
+ val = RT_MDIO_FRC_EN | FIELD_PREP(RT_MDIO_RX_SKEW, 1) |
+ FIELD_PREP(RT_MDIO_TX_SKEW, 1);
+
+ switch (speed) {
+ case SPEED_1000:
+ val |= FIELD_PREP(RT_MDIO_SPEED, RT_MDIO_SPEED_1000);
+ break;
+ case SPEED_100:
+ val |= FIELD_PREP(RT_MDIO_SPEED, RT_MDIO_SPEED_100);
+ break;
+ default:
+ val |= FIELD_PREP(RT_MDIO_SPEED, RT_MDIO_SPEED_10);
+ break;
+ }
+
+ if (duplex == DUPLEX_FULL)
+ val |= RT_MDIO_DUPLEX;
+ if (tx_pause)
+ val |= RT_MDIO_FC_TX;
+ if (rx_pause)
+ val |= RT_MDIO_FC_RX;
+
+ mtk_m32(mac->hw, RT_MDIO_FRC_EN | RT_MDIO_SPEED | RT_MDIO_DUPLEX |
+ RT_MDIO_FC_TX | RT_MDIO_FC_RX | RT_MDIO_LNK_DWN |
+ RT_MDIO_RX_SKEW | RT_MDIO_TX_SKEW, val, RT_MDIO_CFG(mac->id));
+}
+
+/* RT2880 family GMACs force the link through MDIO_CFG */
+static const struct phylink_mac_ops rt2880_phylink_ops = {
+ .mac_config = rt5350_mac_config,
+ .mac_link_down = rt2880_mac_link_down,
+ .mac_link_up = rt2880_mac_link_up,
+};
+
static void mtk_mdio_config(struct mtk_eth *eth)
{
u32 val;
@@ -1104,6 +1178,7 @@ static int mtk_set_mac_address(struct net_device *dev, void *p)
struct mtk_mac *mac = netdev_priv(dev);
struct mtk_eth *eth = mac->hw;
const char *macaddr = dev->dev_addr;
+ u32 adrh, adrl;
if (ret)
return ret;
@@ -1111,20 +1186,21 @@ static int mtk_set_mac_address(struct net_device *dev, void *p)
if (unlikely(test_bit(MTK_RESETTING, &mac->hw->state)))
return -EBUSY;
- spin_lock_bh(&mac->hw->page_lock);
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
- mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1],
- MT7628_SDM_MAC_ADRH);
- mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) |
- (macaddr[4] << 8) | macaddr[5],
- MT7628_SDM_MAC_ADRL);
+ adrh = MT7628_SDM_MAC_ADRH;
+ adrl = MT7628_SDM_MAC_ADRL;
+ } else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ adrh = RT_GDMA_MAC_ADRH(mac->id);
+ adrl = RT_GDMA_MAC_ADRL(mac->id);
} else {
- mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1],
- MTK_GDMA_MAC_ADRH(mac->id));
- mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) |
- (macaddr[4] << 8) | macaddr[5],
- MTK_GDMA_MAC_ADRL(mac->id));
+ adrh = MTK_GDMA_MAC_ADRH(mac->id);
+ adrl = MTK_GDMA_MAC_ADRL(mac->id);
}
+
+ spin_lock_bh(&mac->hw->page_lock);
+ mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1], adrh);
+ mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) |
+ (macaddr[4] << 8) | macaddr[5], adrl);
spin_unlock_bh(&mac->hw->page_lock);
return 0;
@@ -1144,6 +1220,23 @@ void mtk_stats_update_mac(struct mtk_mac *mac)
hw_stats->rx_bytes += mtk_r32(mac->hw, MT7628_SDM_RBCNT);
hw_stats->rx_checksum_errors +=
mtk_r32(mac->hw, MT7628_SDM_CS_ERR);
+ } else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ u32 base = eth->soc->reg_map->gdm1_cnt + hw_stats->reg_offset;
+
+ hw_stats->tx_bytes += mtk_r32(mac->hw, base);
+ hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x04);
+ hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x08);
+ hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x0c);
+ hw_stats->rx_bytes += mtk_r32(mac->hw, base + 0x20);
+ hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x24);
+ hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x28);
+ hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x2c);
+ hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x30);
+ hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x34);
+ hw_stats->rx_checksum_errors +=
+ mtk_r32(mac->hw, base + 0x38);
+ hw_stats->rx_flow_control_packets +=
+ mtk_r32(mac->hw, base + 0x3c);
} else {
const struct mtk_reg_map *reg_map = eth->soc->reg_map;
unsigned int offs = hw_stats->reg_offset;
@@ -1480,6 +1573,11 @@ static void setup_tx_buf(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
tx_buf->data = (void *)MTK_DMA_DUMMY_DESC;
txd->txd1 = mapped_addr;
txd->txd2 = TX_DMA_PLEN0(size);
+ /* GDMA port, on queue 3 like the vendor driver */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ txd->txd4 = FIELD_PREP(RT_TX_DMA_QN, 3) |
+ FIELD_PREP(RT_TX_DMA_PN,
+ tx_buf->mac_id + 1);
dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr);
dma_unmap_len_set(tx_buf, dma_len0, size);
}
@@ -1628,6 +1726,8 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
itx_buf->mac_id = mac->id;
setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size,
k++);
+ if (MTK_HAS_CAPS(soc->caps, MTK_SOC_RT2880) && txd_info.csum)
+ itxd_pdma->txd4 |= TX_DMA_CHKSUM;
/* TX SG offload */
txd = itxd;
@@ -1795,6 +1895,11 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
goto dropped;
}
+ /* RT2880 family pads to 60 bytes including the VLAN tag */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880) &&
+ eth_type_vlan(skb->protocol) && skb_put_padto(skb, VLAN_ETH_ZLEN))
+ goto dropped;
+
/* normally we can rely on the stack not calling this more than once,
* however we have 2 queues running on the same ring so we need to lock
* the ring access
@@ -2249,6 +2354,8 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
default:
break;
}
+ } else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ mac = (int)FIELD_GET(RT_RX_DMA_SPORT, trxd.rxd4) - 1;
} else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
!(trxd.rxd4 & RX_DMA_SPECIAL_TAG)) {
mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1;
@@ -2403,7 +2510,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
addr64 = RX_DMA_PREP_ADDR64(dma_addr);
}
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ if (mtk_is_ralink(eth))
rxd->rxd2 = RX_DMA_LSO;
else
rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size) | addr64;
@@ -2874,7 +2981,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
rxd->rxd1 = (unsigned int)dma_addr;
ring->data[i] = data;
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ if (mtk_is_ralink(eth))
rxd->rxd2 = RX_DMA_LSO;
else
rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size);
@@ -3205,6 +3312,22 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev,
return 0;
}
+static netdev_features_t mtk_features_check(struct sk_buff *skb,
+ struct net_device *dev,
+ netdev_features_t features)
+{
+ struct mtk_mac *mac = netdev_priv(dev);
+ __be16 proto = skb_vlan_tag_present(skb) ? skb->vlan_proto :
+ skb->protocol;
+
+ /* the RT2880 family checksum offload can't parse DSA or 802.1ad tags */
+ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SOC_RT2880) &&
+ (netdev_uses_dsa(dev) || proto == htons(ETH_P_8021AD)))
+ features &= ~NETIF_F_CSUM_MASK;
+
+ return vlan_features_check(skb, features);
+}
+
static netdev_features_t mtk_fix_features(struct net_device *dev,
netdev_features_t features)
{
@@ -3349,7 +3472,13 @@ static void mtk_dma_free(struct mtk_eth *eth)
static bool mtk_hw_reset_check(struct mtk_eth *eth)
{
- u32 val = mtk_r32(eth, MTK_INT_STATUS2);
+ u32 val;
+
+ /* no INT_STATUS2 and no reset recovery on the RT2880 family */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ return false;
+
+ val = mtk_r32(eth, MTK_INT_STATUS2);
return (val & MTK_FE_INT_FQ_EMPTY) || (val & MTK_FE_INT_RFIFO_UF) ||
(val & MTK_FE_INT_RFIFO_OV) || (val & MTK_FE_INT_TSO_FAIL) ||
@@ -3512,9 +3641,11 @@ static int mtk_start_dma(struct mtk_eth *eth)
MTK_RX_BT_32DWORDS | MTK_MULTI_EN,
reg_map->pdma.glo_cfg);
} else {
- mtk_w32(eth, MTK_TX_WB_DDONE | MTK_TX_DMA_EN | MTK_RX_DMA_EN |
- MTK_MULTI_EN | MTK_PDMA_SIZE_8DWORDS,
- reg_map->pdma.glo_cfg);
+ val = MTK_TX_WB_DDONE | MTK_TX_DMA_EN | MTK_RX_DMA_EN |
+ MTK_PDMA_SIZE_8DWORDS;
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ val |= MTK_MULTI_EN;
+ mtk_w32(eth, val, reg_map->pdma.glo_cfg);
}
return 0;
@@ -3522,25 +3653,41 @@ static int mtk_start_dma(struct mtk_eth *eth)
static void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
{
- u32 val;
+ u32 reg, val;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
return;
- val = mtk_r32(eth, MTK_GDMA_FWD_CFG(id));
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ /* not every GDMA exists, only touch those with a MAC */
+ if (!eth->netdev[id])
+ return;
+ reg = RT_GDMA_FWD_CFG(id);
+ } else {
+ reg = MTK_GDMA_FWD_CFG(id);
+ }
+
+ val = mtk_r32(eth, reg);
/* default setup the forward port to send frame to PDMA */
val &= ~0xffff;
+ /* take frames up to 2 KB, the RX buffer size */
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ val &= ~RT_GDMA_JMB_LEN;
+ val |= RT_GDMA_JMB_EN | FIELD_PREP(RT_GDMA_JMB_LEN, 2);
+ }
+
/* Enable RX checksum */
val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
val |= config;
- if (eth->netdev[id] && netdev_uses_dsa(eth->netdev[id]))
+ if (eth->netdev[id] && netdev_uses_dsa(eth->netdev[id]) &&
+ !MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
val |= MTK_GDMA_SPECIAL_TAG;
- mtk_w32(eth, val, MTK_GDMA_FWD_CFG(id));
+ mtk_w32(eth, val, reg);
}
@@ -3675,7 +3822,8 @@ static int mtk_open(struct net_device *dev)
phylink_start(mac->phylink);
netif_tx_start_all_queues(dev);
- if (mtk_is_netsys_v2_or_greater(eth))
+ if (mtk_is_netsys_v2_or_greater(eth) ||
+ MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
return 0;
if (mtk_uses_dsa(dev) && !eth->prog) {
@@ -3928,7 +4076,7 @@ static void mtk_set_mcr_max_rx(struct mtk_mac *mac, u32 val)
struct mtk_eth *eth = mac->hw;
u32 mcr_cur, mcr_new;
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ if (mtk_is_ralink(eth))
return;
mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
@@ -4048,7 +4196,7 @@ static bool mtk_hw_check_dma_hang(struct mtk_eth *eth)
bool qfsm_hang, qfwd_hang;
bool ret = false;
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ if (mtk_is_ralink(eth))
return false;
/* WDMA sanity checks */
@@ -4134,6 +4282,23 @@ static void mtk_hw_reset_monitor_work(struct work_struct *work)
MTK_DMA_MONITOR_TIMEOUT);
}
+static void rt2880_hw_init(struct mtk_eth *eth)
+{
+ struct clk *clk = eth->clks[MTK_CLK_FE];
+
+ mtk_m32(eth, RT_US_CYC_CNT,
+ FIELD_PREP(RT_US_CYC_CNT, clk_get_rate(clk) / HZ_PER_MHZ),
+ RT_FE_GLO_CFG);
+
+ mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG);
+
+ mtk_m32(eth, 0, RT_CSG_ICS_GEN_EN | RT_CSG_UCS_GEN_EN |
+ RT_CSG_TCS_GEN_EN, RT_CDMA_CSG_CFG);
+
+ mtk_w32(eth, RT_PSE_RESET, RT_FE_RST_GL);
+ mtk_w32(eth, 0, RT_FE_RST_GL);
+}
+
static int mtk_hw_init(struct mtk_eth *eth, bool reset)
{
u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA |
@@ -4157,13 +4322,16 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
regmap_update_bits(eth->ethsys, ETHSYS_DMA_AG_MAP, dma_mask,
of_dma_is_coherent(eth->dma_dev->of_node) * dma_mask);
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
+ if (mtk_is_ralink(eth)) {
ret = device_reset(eth->dev);
if (ret) {
dev_err(eth->dev, "MAC reset failed!\n");
goto err_disable_pm;
}
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ rt2880_hw_init(eth);
+
/* set interrupt delays based on current Net DIM sample */
mtk_dim_rx(ð->rx_dim.work);
mtk_dim_tx(ð->tx_dim.work);
@@ -4815,6 +4983,7 @@ static const struct net_device_ops mtk_netdev_ops = {
.ndo_open = mtk_open,
.ndo_stop = mtk_stop,
.ndo_start_xmit = mtk_start_xmit,
+ .ndo_features_check = mtk_features_check,
.ndo_set_mac_address = mtk_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = mtk_do_ioctl,
@@ -4969,6 +5138,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
mac_ops = &rt5350_phylink_ops;
+ else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ mac_ops = &rt2880_phylink_ops;
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
id == MTK_GMAC2_ID)
@@ -5137,7 +5308,7 @@ static int mtk_probe(struct platform_device *pdev)
if (IS_ERR(eth->base))
return PTR_ERR(eth->base);
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ if (mtk_is_ralink(eth))
eth->ip_align = NET_IP_ALIGN;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA)) {
@@ -5163,7 +5334,7 @@ static int mtk_probe(struct platform_device *pdev)
eth->tx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
INIT_WORK(ð->tx_dim.work, mtk_dim_tx);
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
+ if (!mtk_is_ralink(eth)) {
eth->ethsys = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
"mediatek,ethsys");
if (IS_ERR(eth->ethsys)) {
@@ -5318,8 +5489,8 @@ static int mtk_probe(struct platform_device *pdev)
if (err)
goto err_free_dev;
- /* No MT7628/88 support yet */
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
+ /* No MT7628/88 or RT2880 family support yet */
+ if (!mtk_is_ralink(eth)) {
err = mtk_mdio_init(eth);
if (err)
goto err_free_dev;
@@ -5669,6 +5840,31 @@ static const struct mtk_soc_data mt7988_data = {
},
};
+static const struct mtk_soc_data rt3883_data = {
+ .reg_map = &rt2880_reg_map,
+ .caps = RT3883_CAPS,
+ .hw_features = MTK_HW_FEATURES_RT3883,
+ .required_clks = RT3883_CLKS_BITMAP,
+ .required_pctl = false,
+ .pse_fq_cfg = RT3883_PSE_FQ_256Q,
+ .version = 1,
+ .tx = {
+ .desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = RT_INT_TX_DLY,
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+ .rx = {
+ .desc_size = sizeof(struct mtk_rx_dma),
+ .irq_done_mask = RT_INT_RX_DLY,
+ .dma_l4_valid = RX_DMA_L4_VALID_PDMA,
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+};
+
static const struct mtk_soc_data rt5350_data = {
.reg_map = &mt7628_reg_map,
.caps = MT7628_CAPS,
@@ -5702,6 +5898,7 @@ const struct of_device_id of_mtk_match[] = {
{ .compatible = "mediatek,mt7981-eth", .data = &mt7981_data },
{ .compatible = "mediatek,mt7986-eth", .data = &mt7986_data },
{ .compatible = "mediatek,mt7988-eth", .data = &mt7988_data },
+ { .compatible = "ralink,rt3883-eth", .data = &rt3883_data },
{ .compatible = "ralink,rt5350-eth", .data = &rt5350_data },
{},
};
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 9b20b39eae..72d0a9566e 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -54,6 +54,7 @@
NETIF_F_IPV6_CSUM |\
NETIF_F_HW_TC)
#define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM)
+#define MTK_HW_FEATURES_RT3883 (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM)
#define NEXT_DESP_IDX(X, Y) (((X) + 1) & ((Y) - 1))
#define MTK_PP_HEADROOM XDP_PACKET_HEADROOM
@@ -633,6 +634,48 @@
#define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c)
#define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110)
+/* RT2880 family (RT2880, RT305x, RT3883) specific stuff */
+#define RT_MDIO_CFG(x) ((x) ? 0x18 : 0x04)
+#define RT_MDIO_FRC_EN BIT(15)
+#define RT_MDIO_SPEED GENMASK(14, 13)
+#define RT_MDIO_SPEED_10 0
+#define RT_MDIO_SPEED_100 1
+#define RT_MDIO_SPEED_1000 2
+#define RT_MDIO_DUPLEX BIT(12)
+#define RT_MDIO_FC_TX BIT(11)
+#define RT_MDIO_FC_RX BIT(10)
+#define RT_MDIO_LNK_DWN BIT(9)
+#define RT_MDIO_RX_SKEW GENMASK(3, 2)
+#define RT_MDIO_TX_SKEW GENMASK(1, 0)
+
+#define RT_FE_GLO_CFG 0x08
+#define RT_US_CYC_CNT GENMASK(15, 8)
+
+#define RT_FE_RST_GL 0x0c
+#define RT_PSE_RESET BIT(0)
+
+#define RT_INT_TX_DLY BIT(1)
+#define RT_INT_RX_DLY BIT(0)
+
+#define RT_GDMA_FWD_CFG(x) (0x20 + (x) * 0x40)
+#define RT_GDMA_JMB_EN BIT(19)
+#define RT_GDMA_JMB_LEN GENMASK(31, 28)
+#define RT_GDMA_MAC_ADRL(x) (0x2c + (x) * 0x40)
+#define RT_GDMA_MAC_ADRH(x) (0x30 + (x) * 0x40)
+
+#define RT_PSE_FQ_CFG 0x40
+#define RT3883_PSE_FQ_256Q 0xff908000
+
+#define RT_CDMA_CSG_CFG 0x80
+#define RT_CSG_ICS_GEN_EN BIT(2)
+#define RT_CSG_UCS_GEN_EN BIT(1)
+#define RT_CSG_TCS_GEN_EN BIT(0)
+
+/* PDMA descriptor fields */
+#define RT_TX_DMA_PN GENMASK(26, 24)
+#define RT_TX_DMA_QN GENMASK(18, 16)
+#define RT_RX_DMA_SPORT GENMASK(26, 24)
+
#define MTK_FE_CDM1_FSM 0x220
#define MTK_FE_CDM2_FSM 0x224
#define MTK_FE_CDM3_FSM 0x238
@@ -857,6 +900,7 @@ enum mtk_clks_map {
BIT_ULL(MTK_CLK_TOP_NETSYS_SYNC_250M_SEL) | \
BIT_ULL(MTK_CLK_TOP_NETSYS_PPEFB_250M_SEL) | \
BIT_ULL(MTK_CLK_TOP_NETSYS_WARP_SEL))
+#define RT3883_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE))
enum mtk_dev_state {
MTK_HW_INIT,
@@ -995,6 +1039,7 @@ enum mkt_eth_capabilities {
MTK_SRAM_BIT,
MTK_36BIT_DMA_BIT,
MTK_GMAC_EEE_BIT,
+ MTK_SOC_RT2880_BIT,
/* MUX BITS*/
MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT,
@@ -1036,6 +1081,7 @@ enum mkt_eth_capabilities {
#define MTK_SRAM BIT_ULL(MTK_SRAM_BIT)
#define MTK_36BIT_DMA BIT_ULL(MTK_36BIT_DMA_BIT)
#define MTK_GMAC_EEE BIT_ULL(MTK_GMAC_EEE_BIT)
+#define MTK_SOC_RT2880 BIT_ULL(MTK_SOC_RT2880_BIT)
#define MTK_ETH_MUX_GDM1_TO_GMAC1_ESW \
BIT_ULL(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT)
@@ -1129,6 +1175,8 @@ enum mkt_eth_capabilities {
MTK_MUX_GMAC2_TO_2P5GPHY | MTK_QDMA | MTK_RSTCTRL_PPE1 | \
MTK_RSTCTRL_PPE2 | MTK_SRAM)
+#define RT3883_CAPS (MTK_RGMII | MTK_SHARED_INT | MTK_SOC_RT2880)
+
struct mtk_tx_dma_desc_info {
dma_addr_t addr;
u32 size;
@@ -1206,6 +1254,7 @@ struct mtk_reg_map {
* @foe_entry_size Foe table entry size.
* @has_accounting Bool indicating support for accounting of
* offloaded flows.
+ * @pse_fq_cfg PSE free queue config of the RT2880 family.
* @desc_size Tx/Rx DMA descriptor size.
* @irq_done_mask Tx/Rx irq done register mask.
* @dma_l4_valid Rx DMA valid register mask.
@@ -1226,6 +1275,7 @@ struct mtk_soc_data {
netdev_features_t hw_features;
bool has_accounting;
bool disable_pll_modes;
+ u32 pse_fq_cfg;
struct {
u32 desc_size;
u32 irq_done_mask;
@@ -1390,6 +1440,13 @@ struct mtk_mac {
/* the struct describing the SoC. these are declared in the soc_xyz.c files */
extern const struct of_device_id of_mtk_match[];
+/* Ralink frame engine: PDMA only, no NETSYS MAC or MDIO */
+static inline bool mtk_is_ralink(struct mtk_eth *eth)
+{
+ return MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) ||
+ MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880);
+}
+
static inline bool mtk_is_netsys_v1(struct mtk_eth *eth)
{
return eth->soc->version == 1;
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 09/13] net: ethernet: mtk_eth_soc: allow building for RT5350
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (7 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 08/13] net: ethernet: mtk_eth_soc: add RT3883 support Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 10/13] dt-bindings: net: mediatek,net: add ralink,rt2880-eth Ho Jie Feng
` (4 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
The driver supports the RT5350 frame engine through ralink,rt5350-eth,
but NET_VENDOR_MEDIATEK can't be enabled for RT5350, which is under
SOC_RT305X, so the support is only reachable on MT7628.
Allow SOC_RT305X.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
index 0f9fd3659b..15a6468c57 100644
--- a/drivers/net/ethernet/mediatek/Kconfig
+++ b/drivers/net/ethernet/mediatek/Kconfig
@@ -2,7 +2,7 @@
config NET_VENDOR_MEDIATEK
bool "MediaTek devices"
depends on ARCH_MEDIATEK || ARCH_AIROHA || SOC_MT7621 || SOC_MT7620 || \
- SOC_RT3883 || COMPILE_TEST
+ SOC_RT3883 || SOC_RT305X || COMPILE_TEST
help
If you have a Mediatek SoC with ethernet, say Y.
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 10/13] dt-bindings: net: mediatek,net: add ralink,rt2880-eth
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (8 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 09/13] net: ethernet: mtk_eth_soc: allow building for RT5350 Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 11/13] net: ethernet: mtk_eth_soc: add RT2880 support Ho Jie Feng
` (3 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
The RT2880 frame engine is the one RT3883 has, with a single GMAC. It
also has a single interrupt, clock and reset, and no ethsys syscon or
WED.
Add ralink,rt2880-eth with the RT3883 limits.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
Documentation/devicetree/bindings/net/mediatek,net.yaml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/mediatek,net.yaml b/Documentation/devicetree/bindings/net/mediatek,net.yaml
index 5c3ec3b3a4..97eb4229de 100644
--- a/Documentation/devicetree/bindings/net/mediatek,net.yaml
+++ b/Documentation/devicetree/bindings/net/mediatek,net.yaml
@@ -25,6 +25,7 @@ properties:
- mediatek,mt7981-eth
- mediatek,mt7986-eth
- mediatek,mt7988-eth
+ - ralink,rt2880-eth
- ralink,rt3883-eth
- ralink,rt5350-eth
@@ -445,7 +446,9 @@ allOf:
properties:
compatible:
contains:
- const: ralink,rt3883-eth
+ enum:
+ - ralink,rt2880-eth
+ - ralink,rt3883-eth
then:
properties:
interrupts:
@@ -475,6 +478,7 @@ allOf:
compatible:
contains:
enum:
+ - ralink,rt2880-eth
- ralink,rt3883-eth
- ralink,rt5350-eth
then:
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 11/13] net: ethernet: mtk_eth_soc: add RT2880 support
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (9 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 10/13] dt-bindings: net: mediatek,net: add ralink,rt2880-eth Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 12/13] dt-bindings: net: mediatek,net: add ralink,rt3050-eth Ho Jie Feng
` (2 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
The RT2880 frame engine is the one RT3883 has, with a single RGMII
GMAC. Its checksum offload should work according to the datasheet, but
the OpenWrt driver found that it doesn't, so leave it off.
Add support for RT2880.
Build tested only, as no RT2880 hardware was available.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/Kconfig | 2 +-
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 38 ++++++++++++++++++---
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 ++
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
index 15a6468c57..48e9f72dc3 100644
--- a/drivers/net/ethernet/mediatek/Kconfig
+++ b/drivers/net/ethernet/mediatek/Kconfig
@@ -2,7 +2,7 @@
config NET_VENDOR_MEDIATEK
bool "MediaTek devices"
depends on ARCH_MEDIATEK || ARCH_AIROHA || SOC_MT7621 || SOC_MT7620 || \
- SOC_RT3883 || SOC_RT305X || COMPILE_TEST
+ SOC_RT3883 || SOC_RT305X || SOC_RT288X || COMPILE_TEST
help
If you have a Mediatek SoC with ethernet, say Y.
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 33750f6b54..d442c33ee8 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3678,8 +3678,11 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
val |= RT_GDMA_JMB_EN | FIELD_PREP(RT_GDMA_JMB_LEN, 2);
}
- /* Enable RX checksum */
- val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
+ /* Enable RX checksum, else clear the checks that are on by default */
+ if (eth->soc->hw_features & NETIF_F_RXCSUM)
+ val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
+ else
+ val &= ~(MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN);
val |= config;
@@ -4292,8 +4295,9 @@ static void rt2880_hw_init(struct mtk_eth *eth)
mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG);
- mtk_m32(eth, 0, RT_CSG_ICS_GEN_EN | RT_CSG_UCS_GEN_EN |
- RT_CSG_TCS_GEN_EN, RT_CDMA_CSG_CFG);
+ if (eth->soc->hw_features & NETIF_F_IP_CSUM)
+ mtk_m32(eth, 0, RT_CSG_ICS_GEN_EN | RT_CSG_UCS_GEN_EN |
+ RT_CSG_TCS_GEN_EN, RT_CDMA_CSG_CFG);
mtk_w32(eth, RT_PSE_RESET, RT_FE_RST_GL);
mtk_w32(eth, 0, RT_FE_RST_GL);
@@ -5840,6 +5844,31 @@ static const struct mtk_soc_data mt7988_data = {
},
};
+static const struct mtk_soc_data rt2880_data = {
+ .reg_map = &rt2880_reg_map,
+ .caps = RT3883_CAPS,
+ .hw_features = MTK_HW_FEATURES_RT2880,
+ .required_clks = RT3883_CLKS_BITMAP,
+ .required_pctl = false,
+ .pse_fq_cfg = RT2880_PSE_FQ_128Q,
+ .version = 1,
+ .tx = {
+ .desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = RT_INT_TX_DLY,
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+ .rx = {
+ .desc_size = sizeof(struct mtk_rx_dma),
+ .irq_done_mask = RT_INT_RX_DLY,
+ /* no .dma_l4_valid, the GDMA doesn't check the checksums */
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+};
+
static const struct mtk_soc_data rt3883_data = {
.reg_map = &rt2880_reg_map,
.caps = RT3883_CAPS,
@@ -5898,6 +5927,7 @@ const struct of_device_id of_mtk_match[] = {
{ .compatible = "mediatek,mt7981-eth", .data = &mt7981_data },
{ .compatible = "mediatek,mt7986-eth", .data = &mt7986_data },
{ .compatible = "mediatek,mt7988-eth", .data = &mt7988_data },
+ { .compatible = "ralink,rt2880-eth", .data = &rt2880_data },
{ .compatible = "ralink,rt3883-eth", .data = &rt3883_data },
{ .compatible = "ralink,rt5350-eth", .data = &rt5350_data },
{},
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 72d0a9566e..fbcdcbd849 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -55,6 +55,8 @@
NETIF_F_HW_TC)
#define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM)
#define MTK_HW_FEATURES_RT3883 (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM)
+/* checksum offload doesn't work on RT2880 */
+#define MTK_HW_FEATURES_RT2880 (NETIF_F_SG)
#define NEXT_DESP_IDX(X, Y) (((X) + 1) & ((Y) - 1))
#define MTK_PP_HEADROOM XDP_PACKET_HEADROOM
@@ -665,6 +667,7 @@
#define RT_PSE_FQ_CFG 0x40
#define RT3883_PSE_FQ_256Q 0xff908000
+#define RT2880_PSE_FQ_128Q 0x80504000
#define RT_CDMA_CSG_CFG 0x80
#define RT_CSG_ICS_GEN_EN BIT(2)
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 12/13] dt-bindings: net: mediatek,net: add ralink,rt3050-eth
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (10 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 11/13] net: ethernet: mtk_eth_soc: add RT2880 support Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:21 ` [PATCH net-next 13/13] net: ethernet: mtk_eth_soc: add RT305x support Ho Jie Feng
2026-12-05 17:28 ` [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs netdev-bot+sinfo
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
RT3050, RT3052, RT3350 and RT3352 have the RT3883 frame engine with a
single GMAC, which is wired to the embedded switch. Like RT3883, it has
a single interrupt, clock and reset, and no ethsys syscon or WED.
Add ralink,rt3050-eth.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
Documentation/devicetree/bindings/net/mediatek,net.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/mediatek,net.yaml b/Documentation/devicetree/bindings/net/mediatek,net.yaml
index 97eb4229de..ff228da558 100644
--- a/Documentation/devicetree/bindings/net/mediatek,net.yaml
+++ b/Documentation/devicetree/bindings/net/mediatek,net.yaml
@@ -26,6 +26,7 @@ properties:
- mediatek,mt7986-eth
- mediatek,mt7988-eth
- ralink,rt2880-eth
+ - ralink,rt3050-eth
- ralink,rt3883-eth
- ralink,rt5350-eth
@@ -448,6 +449,7 @@ allOf:
contains:
enum:
- ralink,rt2880-eth
+ - ralink,rt3050-eth
- ralink,rt3883-eth
then:
properties:
@@ -479,6 +481,7 @@ allOf:
contains:
enum:
- ralink,rt2880-eth
+ - ralink,rt3050-eth
- ralink,rt3883-eth
- ralink,rt5350-eth
then:
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH net-next 13/13] net: ethernet: mtk_eth_soc: add RT305x support
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (11 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 12/13] dt-bindings: net: mediatek,net: add ralink,rt3050-eth Ho Jie Feng
@ 2026-12-05 17:21 ` Ho Jie Feng
2026-12-05 17:28 ` [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs netdev-bot+sinfo
13 siblings, 0 replies; 16+ messages in thread
From: Ho Jie Feng @ 2026-12-05 17:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King
Cc: netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Gleb Pesin, Ho Jie Feng
RT3050, RT3052, RT3350 and RT3352 have the RT3883 frame engine with a
single GMAC, which is wired to port 6 of the embedded switch. It has no
MDIO_CFG to force the link with, so use the MAC operations of MT7628.
Add support for the RT305x SoCs.
Build tested only, as no RT305x hardware was available.
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 45 +++++++++++++++++----
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++-
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index d442c33ee8..e71607feed 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -997,7 +997,7 @@ static void rt5350_mac_link_up(struct phylink_config *config,
{
}
-/* MT76x8 (rt5350-eth) does not expose any MAC control registers */
+/* RT305x and MT76x8 (rt5350-eth) do not expose any MAC control registers */
static const struct phylink_mac_ops rt5350_phylink_ops = {
.mac_config = rt5350_mac_config,
.mac_link_down = rt5350_mac_link_down,
@@ -1050,7 +1050,7 @@ static void rt2880_mac_link_up(struct phylink_config *config,
RT_MDIO_RX_SKEW | RT_MDIO_TX_SKEW, val, RT_MDIO_CFG(mac->id));
}
-/* RT2880 family GMACs force the link through MDIO_CFG */
+/* RT2880 family RGMII GMACs force the link through MDIO_CFG */
static const struct phylink_mac_ops rt2880_phylink_ops = {
.mac_config = rt5350_mac_config,
.mac_link_down = rt2880_mac_link_down,
@@ -3673,7 +3673,7 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
val &= ~0xffff;
/* take frames up to 2 KB, the RX buffer size */
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880)) {
+ if (eth->soc->rt_jumbo) {
val &= ~RT_GDMA_JMB_LEN;
val |= RT_GDMA_JMB_EN | FIELD_PREP(RT_GDMA_JMB_LEN, 2);
}
@@ -4293,7 +4293,8 @@ static void rt2880_hw_init(struct mtk_eth *eth)
FIELD_PREP(RT_US_CYC_CNT, clk_get_rate(clk) / HZ_PER_MHZ),
RT_FE_GLO_CFG);
- mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG);
+ if (eth->soc->pse_fq_cfg)
+ mtk_w32(eth, eth->soc->pse_fq_cfg, RT_PSE_FQ_CFG);
if (eth->soc->hw_features & NETIF_F_IP_CSUM)
mtk_m32(eth, 0, RT_CSG_ICS_GEN_EN | RT_CSG_UCS_GEN_EN |
@@ -5140,10 +5141,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
mac->phylink_config.supported_interfaces);
}
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
- mac_ops = &rt5350_phylink_ops;
- else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880))
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880 | MTK_RGMII))
mac_ops = &rt2880_phylink_ops;
+ else if (mtk_is_ralink(eth))
+ mac_ops = &rt5350_phylink_ops;
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
id == MTK_GMAC2_ID)
@@ -5191,6 +5192,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH - MTK_RX_ETH_HLEN;
+ else if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_RT2880) &&
+ !eth->soc->rt_jumbo)
+ eth->netdev[id]->max_mtu = ETH_DATA_LEN;
else
eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN;
@@ -5851,6 +5855,7 @@ static const struct mtk_soc_data rt2880_data = {
.required_clks = RT3883_CLKS_BITMAP,
.required_pctl = false,
.pse_fq_cfg = RT2880_PSE_FQ_128Q,
+ .rt_jumbo = true,
.version = 1,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
@@ -5869,6 +5874,30 @@ static const struct mtk_soc_data rt2880_data = {
},
};
+static const struct mtk_soc_data rt3050_data = {
+ .reg_map = &rt2880_reg_map,
+ .caps = RT305X_CAPS,
+ .hw_features = MTK_HW_FEATURES_RT3883,
+ .required_clks = RT3883_CLKS_BITMAP,
+ .required_pctl = false,
+ .version = 1,
+ .tx = {
+ .desc_size = sizeof(struct mtk_tx_dma),
+ .irq_done_mask = RT_INT_TX_DLY,
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+ .rx = {
+ .desc_size = sizeof(struct mtk_rx_dma),
+ .irq_done_mask = RT_INT_RX_DLY,
+ .dma_l4_valid = RX_DMA_L4_VALID_PDMA,
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
+ .dma_len_offset = 16,
+ .dma_size = MTK_DMA_SIZE(2K),
+ },
+};
+
static const struct mtk_soc_data rt3883_data = {
.reg_map = &rt2880_reg_map,
.caps = RT3883_CAPS,
@@ -5876,6 +5905,7 @@ static const struct mtk_soc_data rt3883_data = {
.required_clks = RT3883_CLKS_BITMAP,
.required_pctl = false,
.pse_fq_cfg = RT3883_PSE_FQ_256Q,
+ .rt_jumbo = true,
.version = 1,
.tx = {
.desc_size = sizeof(struct mtk_tx_dma),
@@ -5928,6 +5958,7 @@ const struct of_device_id of_mtk_match[] = {
{ .compatible = "mediatek,mt7986-eth", .data = &mt7986_data },
{ .compatible = "mediatek,mt7988-eth", .data = &mt7988_data },
{ .compatible = "ralink,rt2880-eth", .data = &rt2880_data },
+ { .compatible = "ralink,rt3050-eth", .data = &rt3050_data },
{ .compatible = "ralink,rt3883-eth", .data = &rt3883_data },
{ .compatible = "ralink,rt5350-eth", .data = &rt5350_data },
{},
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index fbcdcbd849..716dac1536 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -1180,6 +1180,8 @@ enum mkt_eth_capabilities {
#define RT3883_CAPS (MTK_RGMII | MTK_SHARED_INT | MTK_SOC_RT2880)
+#define RT305X_CAPS (MTK_SHARED_INT | MTK_SOC_RT2880)
+
struct mtk_tx_dma_desc_info {
dma_addr_t addr;
u32 size;
@@ -1257,7 +1259,10 @@ struct mtk_reg_map {
* @foe_entry_size Foe table entry size.
* @has_accounting Bool indicating support for accounting of
* offloaded flows.
- * @pse_fq_cfg PSE free queue config of the RT2880 family.
+ * @pse_fq_cfg PSE free queue config of the RT2880 family,
+ * 0 keeps the reset value.
+ * @rt_jumbo Bool indicating that the RT2880 family GDMA
+ * has a jumbo frame limit.
* @desc_size Tx/Rx DMA descriptor size.
* @irq_done_mask Tx/Rx irq done register mask.
* @dma_l4_valid Rx DMA valid register mask.
@@ -1279,6 +1284,7 @@ struct mtk_soc_data {
bool has_accounting;
bool disable_pll_modes;
u32 pse_fq_cfg;
+ bool rt_jumbo;
struct {
u32 desc_size;
u32 irq_done_mask;
--
2.53.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs
2026-12-05 17:21 [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs Ho Jie Feng
` (12 preceding siblings ...)
2026-12-05 17:21 ` [PATCH net-next 13/13] net: ethernet: mtk_eth_soc: add RT305x support Ho Jie Feng
@ 2026-12-05 17:28 ` netdev-bot+sinfo
2026-12-05 17:49 ` Jie Feng
13 siblings, 1 reply; 16+ messages in thread
From: netdev-bot+sinfo @ 2026-12-05 17:28 UTC (permalink / raw)
To: Ho Jie Feng
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek, Gleb Pesin
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs
2026-12-05 17:28 ` [PATCH net-next 00/13] net: ethernet: mtk_eth_soc: add support for RT3883 and related SoCs netdev-bot+sinfo
@ 2026-12-05 17:49 ` Jie Feng
0 siblings, 0 replies; 16+ messages in thread
From: Jie Feng @ 2026-12-05 17:49 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Felix Fietkau, Lorenzo Bianconi, Matthias Brugger,
AngeloGioacchino Del Regno, Russell King, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek, Gleb Pesin
On Sun, 6 Dec 2026 at 01:28, <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
Only the first commit is a fix, and is obtained from the github link.
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
Other patches do not seem to affect existing chip support, only the
new RT3883 added here.
^ permalink raw reply [flat|nested] 16+ messages in thread