* [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1
@ 2026-03-12 10:07 Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
` (14 more replies)
0 siblings, 15 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:07 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Hi,
Part 1 of cleaning up the stmmac descriptor handling. Rearrange the
struct stmmac_tx_info to pack better, and introduce helpers for
duplicated code handing the transmit and receive descriptors. Remove
unnecessary struct members that are only transitorily used.
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 8 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 458 +++++++++------------
3 files changed, 195 insertions(+), 273 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v2 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
@ 2026-03-12 10:08 ` Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma Russell King (Oracle)
` (13 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:08 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Rearrange the struct stmmac_tx_info members to pack better, essentially
by sorting by type size:
xsk_meta embeds only a pointer - 32 or 64 bit
buf dma address, 32 or 64 bit
len normally 32 bit
buf_type dependent on arch
map_as_page normally 8 bit
last_segment normally 8 bit
is_jumbo normally 8 bit
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index bba9bb9c95bf..b096a9e090e3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -47,13 +47,13 @@ enum stmmac_txbuf_type {
};
struct stmmac_tx_info {
+ struct xsk_tx_metadata_compl xsk_meta;
dma_addr_t buf;
- bool map_as_page;
unsigned len;
+ enum stmmac_txbuf_type buf_type;
+ bool map_as_page;
bool last_segment;
bool is_jumbo;
- enum stmmac_txbuf_type buf_type;
- struct xsk_tx_metadata_compl xsk_meta;
};
#define STMMAC_TBS_AVAIL BIT(0)
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
@ 2026-03-12 10:08 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors() Russell King (Oracle)
` (12 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:08 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Add helpers to fill in the transmit queue metadata to ensure that all
entries are initialised when preparing to transmit. This avoids clean
up code running into surprises.
For example, stmmac_clean_desc3() (which calls clean_desc3() in
chain_mode.c or ring_mode.c) looks at the .last_segment, and in the
latter case, .is_jumbo members.
AI believes that there is a missing .buf_type assignment in
stmmac_tso_xmit(), but this is a mis-analysis. AI believes that
stmmac_tso_allocator() which would increment tx_q->cur_tx will be
called within the loop when nfrags is zero, but it's failing to
realise that none of the code within the for() loop will be
executed. In any case, at the point where the loop exits,
tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type has been correctly set
via the call to stmmac_set_tx_skb_dma_entry() - either the one
before the loop, or the one at the end of the loop block.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 96 +++++++++++--------
1 file changed, 54 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 11150bddd872..0dcf4a31e314 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1925,6 +1925,34 @@ static int init_dma_rx_desc_rings(struct net_device *dev,
return ret;
}
+static void stmmac_set_tx_dma_entry(struct stmmac_tx_queue *tx_q,
+ unsigned int entry,
+ enum stmmac_txbuf_type type,
+ dma_addr_t addr, size_t len,
+ bool map_as_page)
+{
+ tx_q->tx_skbuff_dma[entry].buf = addr;
+ tx_q->tx_skbuff_dma[entry].len = len;
+ tx_q->tx_skbuff_dma[entry].buf_type = type;
+ tx_q->tx_skbuff_dma[entry].map_as_page = map_as_page;
+ tx_q->tx_skbuff_dma[entry].last_segment = false;
+ tx_q->tx_skbuff_dma[entry].is_jumbo = false;
+}
+
+static void stmmac_set_tx_skb_dma_entry(struct stmmac_tx_queue *tx_q,
+ unsigned int entry, dma_addr_t addr,
+ size_t len, bool map_as_page)
+{
+ stmmac_set_tx_dma_entry(tx_q, entry, STMMAC_TXBUF_T_SKB, addr, len,
+ map_as_page);
+}
+
+static void stmmac_set_tx_dma_last_segment(struct stmmac_tx_queue *tx_q,
+ unsigned int entry)
+{
+ tx_q->tx_skbuff_dma[entry].last_segment = true;
+}
+
/**
* __init_dma_tx_desc_rings - init the TX descriptor ring (per queue)
* @priv: driver private structure
@@ -1970,11 +1998,8 @@ static int __init_dma_tx_desc_rings(struct stmmac_priv *priv,
p = tx_q->dma_tx + i;
stmmac_clear_desc(priv, p);
+ stmmac_set_tx_skb_dma_entry(tx_q, i, 0, 0, false);
- tx_q->tx_skbuff_dma[i].buf = 0;
- tx_q->tx_skbuff_dma[i].map_as_page = false;
- tx_q->tx_skbuff_dma[i].len = 0;
- tx_q->tx_skbuff_dma[i].last_segment = false;
tx_q->tx_skbuff[i] = NULL;
}
@@ -2695,19 +2720,15 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
- tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XSK_TX;
-
/* To return XDP buffer to XSK pool, we simple call
* xsk_tx_completed(), so we don't need to fill up
* 'buf' and 'xdpf'.
*/
- tx_q->tx_skbuff_dma[entry].buf = 0;
- tx_q->xdpf[entry] = NULL;
+ stmmac_set_tx_dma_entry(tx_q, entry, STMMAC_TXBUF_T_XSK_TX,
+ 0, xdp_desc.len, false);
+ stmmac_set_tx_dma_last_segment(tx_q, entry);
- tx_q->tx_skbuff_dma[entry].map_as_page = false;
- tx_q->tx_skbuff_dma[entry].len = xdp_desc.len;
- tx_q->tx_skbuff_dma[entry].last_segment = true;
- tx_q->tx_skbuff_dma[entry].is_jumbo = false;
+ tx_q->xdpf[entry] = NULL;
stmmac_set_desc_addr(priv, tx_desc, dma_addr);
@@ -2882,6 +2903,9 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
tx_q->tx_skbuff_dma[entry].map_as_page = false;
}
+ /* This looks at tx_q->tx_skbuff_dma[tx_q->dirty_tx].is_jumbo
+ * and tx_q->tx_skbuff_dma[tx_q->dirty_tx].last_segment
+ */
stmmac_clean_desc3(priv, tx_q, p);
tx_q->tx_skbuff_dma[entry].last_segment = false;
@@ -4471,10 +4495,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
* this DMA buffer right after the DMA engine completely finishes the
* full buffer transmission.
*/
- tx_q->tx_skbuff_dma[tx_q->cur_tx].buf = des;
- tx_q->tx_skbuff_dma[tx_q->cur_tx].len = skb_headlen(skb);
- tx_q->tx_skbuff_dma[tx_q->cur_tx].map_as_page = false;
- tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = STMMAC_TXBUF_T_SKB;
+ stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des, skb_headlen(skb),
+ false);
/* Prepare fragments */
for (i = 0; i < nfrags; i++) {
@@ -4489,17 +4511,14 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
stmmac_tso_allocator(priv, des, skb_frag_size(frag),
(i == nfrags - 1), queue);
- tx_q->tx_skbuff_dma[tx_q->cur_tx].buf = des;
- tx_q->tx_skbuff_dma[tx_q->cur_tx].len = skb_frag_size(frag);
- tx_q->tx_skbuff_dma[tx_q->cur_tx].map_as_page = true;
- tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = STMMAC_TXBUF_T_SKB;
+ stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des,
+ skb_frag_size(frag), true);
}
- tx_q->tx_skbuff_dma[tx_q->cur_tx].last_segment = true;
+ stmmac_set_tx_dma_last_segment(tx_q, tx_q->cur_tx);
/* Only the last descriptor gets to point to the skb. */
tx_q->tx_skbuff[tx_q->cur_tx] = skb;
- tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = STMMAC_TXBUF_T_SKB;
/* Manage tx mitigation */
tx_packets = CIRC_CNT(tx_q->cur_tx + 1, first_tx,
@@ -4758,23 +4777,18 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
if (dma_mapping_error(priv->device, des))
goto dma_map_err; /* should reuse desc w/o issues */
- tx_q->tx_skbuff_dma[entry].buf = des;
-
+ stmmac_set_tx_skb_dma_entry(tx_q, entry, des, len, true);
stmmac_set_desc_addr(priv, desc, des);
- tx_q->tx_skbuff_dma[entry].map_as_page = true;
- tx_q->tx_skbuff_dma[entry].len = len;
- tx_q->tx_skbuff_dma[entry].last_segment = last_segment;
- tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_SKB;
-
/* Prepare the descriptor and set the own bit too */
stmmac_prepare_tx_desc(priv, desc, 0, len, csum_insertion,
priv->mode, 1, last_segment, skb->len);
}
+ stmmac_set_tx_dma_last_segment(tx_q, entry);
+
/* Only the last descriptor gets to point to the skb. */
tx_q->tx_skbuff[entry] = skb;
- tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_SKB;
/* According to the coalesce parameter the IC bit for the latest
* segment is reset and the timer re-started to clean the tx status.
@@ -4853,14 +4867,13 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
if (dma_mapping_error(priv->device, des))
goto dma_map_err;
- tx_q->tx_skbuff_dma[first_entry].buf = des;
- tx_q->tx_skbuff_dma[first_entry].buf_type = STMMAC_TXBUF_T_SKB;
- tx_q->tx_skbuff_dma[first_entry].map_as_page = false;
+ stmmac_set_tx_skb_dma_entry(tx_q, first_entry, des, nopaged_len,
+ false);
stmmac_set_desc_addr(priv, first, des);
- tx_q->tx_skbuff_dma[first_entry].len = nopaged_len;
- tx_q->tx_skbuff_dma[first_entry].last_segment = last_segment;
+ if (last_segment)
+ stmmac_set_tx_dma_last_segment(tx_q, first_entry);
if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
priv->hwts_tx_en)) {
@@ -5062,6 +5075,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
bool csum = !priv->plat->tx_queues_cfg[queue].coe_unsupported;
unsigned int entry = tx_q->cur_tx;
+ enum stmmac_txbuf_type buf_type;
struct dma_desc *tx_desc;
dma_addr_t dma_addr;
bool set_ic;
@@ -5089,7 +5103,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
if (dma_mapping_error(priv->device, dma_addr))
return STMMAC_XDP_CONSUMED;
- tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XDP_NDO;
+ buf_type = STMMAC_TXBUF_T_XDP_NDO;
} else {
struct page *page = virt_to_page(xdpf->data);
@@ -5098,14 +5112,12 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
dma_sync_single_for_device(priv->device, dma_addr,
xdpf->len, DMA_BIDIRECTIONAL);
- tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XDP_TX;
+ buf_type = STMMAC_TXBUF_T_XDP_TX;
}
- tx_q->tx_skbuff_dma[entry].buf = dma_addr;
- tx_q->tx_skbuff_dma[entry].map_as_page = false;
- tx_q->tx_skbuff_dma[entry].len = xdpf->len;
- tx_q->tx_skbuff_dma[entry].last_segment = true;
- tx_q->tx_skbuff_dma[entry].is_jumbo = false;
+ stmmac_set_tx_dma_entry(tx_q, entry, buf_type, dma_addr, xdpf->len,
+ false);
+ stmmac_set_tx_dma_last_segment(tx_q, entry);
tx_q->xdpf[entry] = xdpf;
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors()
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 04/15] net: stmmac: add helper to get hardware receive descriptor Russell King (Oracle)
` (11 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
The two paths calling stmmac_init_rx_desc() are identical apart from
the way the pointer to the descriptor is fetched. Split this out.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0dcf4a31e314..765b168df50d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1514,20 +1514,20 @@ static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv,
u32 queue)
{
struct stmmac_rx_queue *rx_q = &dma_conf->rx_queue[queue];
+ struct dma_desc *desc;
int i;
/* Clear the RX descriptors */
- for (i = 0; i < dma_conf->dma_rx_size; i++)
+ for (i = 0; i < dma_conf->dma_rx_size; i++) {
if (priv->extend_desc)
- stmmac_init_rx_desc(priv, &rx_q->dma_erx[i].basic,
- priv->use_riwt, priv->mode,
- (i == dma_conf->dma_rx_size - 1),
- dma_conf->dma_buf_sz);
+ desc = &rx_q->dma_erx[i].basic;
else
- stmmac_init_rx_desc(priv, &rx_q->dma_rx[i],
- priv->use_riwt, priv->mode,
- (i == dma_conf->dma_rx_size - 1),
- dma_conf->dma_buf_sz);
+ desc = &rx_q->dma_rx[i];
+
+ stmmac_init_rx_desc(priv, desc, priv->use_riwt, priv->mode,
+ (i == dma_conf->dma_rx_size - 1),
+ dma_conf->dma_buf_sz);
+ }
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 04/15] net: stmmac: add helper to get hardware receive descriptor
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (2 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors() Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 05/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
` (10 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Provide a helper to get a hardware receive descriptor that takes
account of whether extended format is being used, but returning the
base struct dma_desc pointer. This avoids multiple instances where
this is open coded.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 76 +++++++------------
1 file changed, 26 insertions(+), 50 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 765b168df50d..a3dfd3501604 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -362,6 +362,16 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv, u32 queue)
priv->dma_conf.dma_tx_size);
}
+static struct dma_desc *stmmac_get_rx_desc(struct stmmac_priv *priv,
+ struct stmmac_rx_queue *rx_q,
+ unsigned int index)
+{
+ if (priv->extend_desc)
+ return &rx_q->dma_erx[index].basic;
+ else
+ return &rx_q->dma_rx[index];
+}
+
/**
* stmmac_rx_dirty - Get RX queue dirty
* @priv: driver private structure
@@ -1421,13 +1431,11 @@ static void stmmac_display_rx_rings(struct stmmac_priv *priv,
pr_info("\tRX Queue %u rings\n", queue);
- if (priv->extend_desc) {
- head_rx = (void *)rx_q->dma_erx;
+ head_rx = stmmac_get_rx_desc(priv, rx_q, 0);
+ if (priv->extend_desc)
desc_size = sizeof(struct dma_extended_desc);
- } else {
- head_rx = (void *)rx_q->dma_rx;
+ else
desc_size = sizeof(struct dma_desc);
- }
/* Display RX ring */
stmmac_display_ring(priv, head_rx, dma_conf->dma_rx_size, true,
@@ -1519,10 +1527,7 @@ static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv,
/* Clear the RX descriptors */
for (i = 0; i < dma_conf->dma_rx_size; i++) {
- if (priv->extend_desc)
- desc = &rx_q->dma_erx[i].basic;
- else
- desc = &rx_q->dma_rx[i];
+ desc = stmmac_get_rx_desc(priv, rx_q, i);
stmmac_init_rx_desc(priv, desc, priv->use_riwt, priv->mode,
(i == dma_conf->dma_rx_size - 1),
@@ -1731,10 +1736,7 @@ static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv,
struct dma_desc *p;
int ret;
- if (priv->extend_desc)
- p = &((rx_q->dma_erx + i)->basic);
- else
- p = rx_q->dma_rx + i;
+ p = stmmac_get_rx_desc(priv, rx_q, i);
ret = stmmac_init_rx_buffers(priv, dma_conf, p, i, flags,
queue);
@@ -1789,10 +1791,7 @@ static int stmmac_alloc_rx_buffers_zc(struct stmmac_priv *priv,
dma_addr_t dma_addr;
struct dma_desc *p;
- if (priv->extend_desc)
- p = (struct dma_desc *)(rx_q->dma_erx + i);
- else
- p = rx_q->dma_rx + i;
+ p = stmmac_get_rx_desc(priv, rx_q, i);
buf = &rx_q->buf_pool[i];
@@ -4954,10 +4953,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
struct dma_desc *p;
bool use_rx_wd;
- if (priv->extend_desc)
- p = (struct dma_desc *)(rx_q->dma_erx + entry);
- else
- p = rx_q->dma_rx + entry;
+ p = stmmac_get_rx_desc(priv, rx_q, entry);
if (!buf->page) {
buf->page = page_pool_alloc_pages(rx_q->page_pool, gfp);
@@ -5355,10 +5351,7 @@ static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
}
}
- if (priv->extend_desc)
- rx_desc = (struct dma_desc *)(rx_q->dma_erx + entry);
- else
- rx_desc = rx_q->dma_rx + entry;
+ rx_desc = stmmac_get_rx_desc(priv, rx_q, entry);
dma_addr = xsk_buff_xdp_get_dma(buf->xdp);
stmmac_set_desc_addr(priv, rx_desc, dma_addr);
@@ -5416,14 +5409,12 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
int status = 0;
if (netif_msg_rx_status(priv)) {
- void *rx_head;
+ void *rx_head = stmmac_get_rx_desc(priv, rx_q, 0);
netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__);
if (priv->extend_desc) {
- rx_head = (void *)rx_q->dma_erx;
desc_size = sizeof(struct dma_extended_desc);
} else {
- rx_head = (void *)rx_q->dma_rx;
desc_size = sizeof(struct dma_desc);
}
@@ -5461,10 +5452,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
dirty = 0;
}
- if (priv->extend_desc)
- p = (struct dma_desc *)(rx_q->dma_erx + entry);
- else
- p = rx_q->dma_rx + entry;
+ p = stmmac_get_rx_desc(priv, rx_q, entry);
/* read the status of the incoming frame */
status = stmmac_rx_status(priv, &priv->xstats, p);
@@ -5477,10 +5465,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
priv->dma_conf.dma_rx_size);
next_entry = rx_q->cur_rx;
- if (priv->extend_desc)
- np = (struct dma_desc *)(rx_q->dma_erx + next_entry);
- else
- np = rx_q->dma_rx + next_entry;
+ np = stmmac_get_rx_desc(priv, rx_q, next_entry);
prefetch(np);
@@ -5616,16 +5601,13 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
limit = min(priv->dma_conf.dma_rx_size - 1, (unsigned int)limit);
if (netif_msg_rx_status(priv)) {
- void *rx_head;
+ void *rx_head = stmmac_get_rx_desc(priv, rx_q, 0);
netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__);
- if (priv->extend_desc) {
- rx_head = (void *)rx_q->dma_erx;
+ if (priv->extend_desc)
desc_size = sizeof(struct dma_extended_desc);
- } else {
- rx_head = (void *)rx_q->dma_rx;
+ else
desc_size = sizeof(struct dma_desc);
- }
stmmac_display_ring(priv, rx_head, priv->dma_conf.dma_rx_size, true,
rx_q->dma_rx_phy, desc_size);
@@ -5658,10 +5640,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
entry = next_entry;
buf = &rx_q->buf_pool[entry];
- if (priv->extend_desc)
- p = (struct dma_desc *)(rx_q->dma_erx + entry);
- else
- p = rx_q->dma_rx + entry;
+ p = stmmac_get_rx_desc(priv, rx_q, entry);
/* read the status of the incoming frame */
status = stmmac_rx_status(priv, &priv->xstats, p);
@@ -5673,10 +5652,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
priv->dma_conf.dma_rx_size);
next_entry = rx_q->cur_rx;
- if (priv->extend_desc)
- np = (struct dma_desc *)(rx_q->dma_erx + next_entry);
- else
- np = rx_q->dma_rx + next_entry;
+ np = stmmac_get_rx_desc(priv, rx_q, next_entry);
prefetch(np);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 05/15] net: stmmac: add helper to get size of a receive descriptor
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (3 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 04/15] net: stmmac: add helper to get hardware receive descriptor Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 06/15] net: stmmac: add helper to set receive tail pointer Russell King (Oracle)
` (9 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Add and use a helper to get the size of the hardware receive
descriptor.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++----------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a3dfd3501604..dca62e7b259a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -362,6 +362,14 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv, u32 queue)
priv->dma_conf.dma_tx_size);
}
+static size_t stmmac_get_rx_desc_size(struct stmmac_priv *priv)
+{
+ if (priv->extend_desc)
+ return sizeof(struct dma_extended_desc);
+ else
+ return sizeof(struct dma_desc);
+}
+
static struct dma_desc *stmmac_get_rx_desc(struct stmmac_priv *priv,
struct stmmac_rx_queue *rx_q,
unsigned int index)
@@ -1432,10 +1440,7 @@ static void stmmac_display_rx_rings(struct stmmac_priv *priv,
pr_info("\tRX Queue %u rings\n", queue);
head_rx = stmmac_get_rx_desc(priv, rx_q, 0);
- if (priv->extend_desc)
- desc_size = sizeof(struct dma_extended_desc);
- else
- desc_size = sizeof(struct dma_desc);
+ desc_size = stmmac_get_rx_desc_size(priv);
/* Display RX ring */
stmmac_display_ring(priv, head_rx, dma_conf->dma_rx_size, true,
@@ -5412,11 +5417,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
void *rx_head = stmmac_get_rx_desc(priv, rx_q, 0);
netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__);
- if (priv->extend_desc) {
- desc_size = sizeof(struct dma_extended_desc);
- } else {
- desc_size = sizeof(struct dma_desc);
- }
+ desc_size = stmmac_get_rx_desc_size(priv);
stmmac_display_ring(priv, rx_head, priv->dma_conf.dma_rx_size, true,
rx_q->dma_rx_phy, desc_size);
@@ -5604,10 +5605,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
void *rx_head = stmmac_get_rx_desc(priv, rx_q, 0);
netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__);
- if (priv->extend_desc)
- desc_size = sizeof(struct dma_extended_desc);
- else
- desc_size = sizeof(struct dma_desc);
+ desc_size = stmmac_get_rx_desc_size(priv);
stmmac_display_ring(priv, rx_head, priv->dma_conf.dma_rx_size, true,
rx_q->dma_rx_phy, desc_size);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 06/15] net: stmmac: add helper to set receive tail pointer
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (4 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 05/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 07/15] net: stmmac: remove rx_tail_addr Russell King (Oracle)
` (8 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Setting the queue receive tail pointer follows a common pattern:
calculate the DMA address, and then call stmmac_set_rx_tail_ptr().
The only difference between all the call sites is the index used.
Factor this out into a static function, and add a comment about why
it only uses the normal descriptor size.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index dca62e7b259a..8823f8f5b053 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -380,6 +380,18 @@ static struct dma_desc *stmmac_get_rx_desc(struct stmmac_priv *priv,
return &rx_q->dma_rx[index];
}
+static void stmmac_set_queue_rx_tail_ptr(struct stmmac_priv *priv,
+ struct stmmac_rx_queue *rx_q,
+ unsigned int chan, unsigned int index)
+{
+ /* This only needs to deal with normal descriptors as enhanced
+ * descriptiors are only supported with dwmac1000 (<v4.0) which
+ * does not implement .set_rx_tail_ptr
+ */
+ rx_q->rx_tail_addr = rx_q->dma_rx_phy + index * sizeof(struct dma_desc);
+ stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, chan);
+}
+
/**
* stmmac_rx_dirty - Get RX queue dirty
* @priv: driver private structure
@@ -3302,11 +3314,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
rx_q->dma_rx_phy, chan);
- rx_q->rx_tail_addr = rx_q->dma_rx_phy +
- (rx_q->buf_alloc_num *
- sizeof(struct dma_desc));
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr,
- rx_q->rx_tail_addr, chan);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, chan,
+ rx_q->buf_alloc_num);
}
/* DMA TX Channel Configuration */
@@ -4999,9 +5008,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_rx_size);
}
rx_q->dirty_rx = entry;
- rx_q->rx_tail_addr = rx_q->dma_rx_phy +
- (rx_q->dirty_rx * sizeof(struct dma_desc));
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, queue);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->dirty_rx);
/* Wake up Rx DMA from the suspend state if required */
stmmac_enable_dma_reception(priv, priv->ioaddr, queue);
}
@@ -5381,9 +5388,7 @@ static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
if (rx_desc) {
rx_q->dirty_rx = entry;
- rx_q->rx_tail_addr = rx_q->dma_rx_phy +
- (rx_q->dirty_rx * sizeof(struct dma_desc));
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, queue);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->dirty_rx);
}
return ret;
@@ -6951,10 +6956,8 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
rx_q->dma_rx_phy, rx_q->queue_index);
- rx_q->rx_tail_addr = rx_q->dma_rx_phy + (rx_q->buf_alloc_num *
- sizeof(struct dma_desc));
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr,
- rx_q->rx_tail_addr, rx_q->queue_index);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, rx_q->queue_index,
+ rx_q->buf_alloc_num);
if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
@@ -7105,11 +7108,8 @@ int stmmac_xdp_open(struct net_device *dev)
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
rx_q->dma_rx_phy, chan);
- rx_q->rx_tail_addr = rx_q->dma_rx_phy +
- (rx_q->buf_alloc_num *
- sizeof(struct dma_desc));
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr,
- rx_q->rx_tail_addr, chan);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, chan,
+ rx_q->buf_alloc_num);
if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 07/15] net: stmmac: remove rx_tail_addr
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (5 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 06/15] net: stmmac: add helper to set receive tail pointer Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 08/15] net: stmmac: use consistent tests for receive buffer size Russell King (Oracle)
` (7 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
There is only one place where rx_q->rx_tail_addr is used - the new
stmmac_set_queue_rx_tail_ptr(). Make this a local variable and remove
it from struct stmmac_rx_queue.
This commit does not change the semantics - the hardware relies upon
the descriptor ring not crossing a 4GiB boundary as the high address
bits are programmed into a separate register via stmmac_init_rx_chan().
Hence, truncating the DMA address to 32-bit is fine as the register it
will be programmed into is 32-bit, and the high bits are handled
elsewhere.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 -
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index b096a9e090e3..d1f8383d1c04 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -131,7 +131,6 @@ struct stmmac_rx_queue {
unsigned int buf_alloc_num;
unsigned int napi_skb_frag_size;
dma_addr_t dma_rx_phy;
- u32 rx_tail_addr;
unsigned int state_saved;
struct {
struct sk_buff *skb;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8823f8f5b053..1d40168ec68d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -388,8 +388,9 @@ static void stmmac_set_queue_rx_tail_ptr(struct stmmac_priv *priv,
* descriptiors are only supported with dwmac1000 (<v4.0) which
* does not implement .set_rx_tail_ptr
*/
- rx_q->rx_tail_addr = rx_q->dma_rx_phy + index * sizeof(struct dma_desc);
- stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, chan);
+ u32 rx_tail_addr = rx_q->dma_rx_phy + index * sizeof(struct dma_desc);
+
+ stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_tail_addr, chan);
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 08/15] net: stmmac: use consistent tests for receive buffer size
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (6 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 07/15] net: stmmac: remove rx_tail_addr Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 09/15] net: stmmac: add helper to set " Russell King (Oracle)
` (6 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Two out of the three sites that set the receive buffer size (via
stmmac_set_dma_bfsize()) check for rx_q->xsk_pool &&
rx_q->buf_alloc_num. One uses just rx_q->xsk_pool.
Discussing with Yoong Siang Song, the conclusion is that
stmmac_dma_operation_mode() is missing the rx_q->buf_alloc_num
check. Add this check.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1d40168ec68d..787b02c2607a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2612,7 +2612,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
stmmac_dma_rx_mode(priv, priv->ioaddr, rxmode, chan,
rxfifosz, qmode);
- if (rx_q->xsk_pool) {
+ if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
stmmac_set_dma_bfsize(priv, priv->ioaddr,
buf_size,
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 09/15] net: stmmac: add helper to set receive buffer size
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (7 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 08/15] net: stmmac: use consistent tests for receive buffer size Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size() Russell King (Oracle)
` (5 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
There are three sites that configure the hardware for the receive
buffer size using the same logic to determine the buffer size.
Add a helper so there is only one copy of this code.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 54 ++++++++-----------
1 file changed, 21 insertions(+), 33 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 787b02c2607a..47b536c15c0e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -393,6 +393,24 @@ static void stmmac_set_queue_rx_tail_ptr(struct stmmac_priv *priv,
stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_tail_addr, chan);
}
+static void stmmac_set_queue_rx_buf_size(struct stmmac_priv *priv,
+ struct stmmac_rx_queue *rx_q,
+ unsigned int chan)
+{
+ u32 buf_size;
+
+ if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
+ buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
+ stmmac_set_dma_bfsize(priv, priv->ioaddr,
+ buf_size,
+ rx_q->queue_index);
+ } else {
+ stmmac_set_dma_bfsize(priv, priv->ioaddr,
+ priv->dma_conf.dma_buf_sz,
+ rx_q->queue_index);
+ }
+}
+
/**
* stmmac_rx_dirty - Get RX queue dirty
* @priv: driver private structure
@@ -2605,23 +2623,13 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
/* configure all channels */
for (chan = 0; chan < rx_channels_count; chan++) {
struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[chan];
- u32 buf_size;
qmode = priv->plat->rx_queues_cfg[chan].mode_to_use;
stmmac_dma_rx_mode(priv, priv->ioaddr, rxmode, chan,
rxfifosz, qmode);
- if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
- buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- buf_size,
- chan);
- } else {
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- priv->dma_conf.dma_buf_sz,
- chan);
- }
+ stmmac_set_queue_rx_buf_size(priv, rx_q, chan);
}
for (chan = 0; chan < tx_channels_count; chan++) {
@@ -6935,7 +6943,6 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
struct stmmac_rx_queue *rx_q = &priv->dma_conf.rx_queue[queue];
struct stmmac_channel *ch = &priv->channel[queue];
unsigned long flags;
- u32 buf_size;
int ret;
ret = __alloc_dma_rx_desc_resources(priv, &priv->dma_conf, queue);
@@ -6960,16 +6967,7 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
stmmac_set_queue_rx_tail_ptr(priv, rx_q, rx_q->queue_index,
rx_q->buf_alloc_num);
- if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
- buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- buf_size,
- rx_q->queue_index);
- } else {
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- priv->dma_conf.dma_buf_sz,
- rx_q->queue_index);
- }
+ stmmac_set_queue_rx_buf_size(priv, rx_q, rx_q->queue_index);
stmmac_start_rx_dma(priv, queue);
@@ -7072,7 +7070,6 @@ int stmmac_xdp_open(struct net_device *dev)
u8 dma_csr_ch = max(rx_cnt, tx_cnt);
struct stmmac_rx_queue *rx_q;
struct stmmac_tx_queue *tx_q;
- u32 buf_size;
bool sph_en;
u8 chan;
int ret;
@@ -7112,16 +7109,7 @@ int stmmac_xdp_open(struct net_device *dev)
stmmac_set_queue_rx_tail_ptr(priv, rx_q, chan,
rx_q->buf_alloc_num);
- if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
- buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- buf_size,
- rx_q->queue_index);
- } else {
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- priv->dma_conf.dma_buf_sz,
- rx_q->queue_index);
- }
+ stmmac_set_queue_rx_buf_size(priv, rx_q, chan);
stmmac_enable_sph(priv, priv->ioaddr, sph_en, chan);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size()
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (8 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 09/15] net: stmmac: add helper to set " Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 11/15] net: stmmac: add helper to get hardware transmit descriptor Russell King (Oracle)
` (4 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Clean up the new stmmac_set_queue_rx_buf_size() to simplify the code.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 47b536c15c0e..032ef9fba8b4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -399,16 +399,12 @@ static void stmmac_set_queue_rx_buf_size(struct stmmac_priv *priv,
{
u32 buf_size;
- if (rx_q->xsk_pool && rx_q->buf_alloc_num) {
+ if (rx_q->xsk_pool && rx_q->buf_alloc_num)
buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool);
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- buf_size,
- rx_q->queue_index);
- } else {
- stmmac_set_dma_bfsize(priv, priv->ioaddr,
- priv->dma_conf.dma_buf_sz,
- rx_q->queue_index);
- }
+ else
+ buf_size = priv->dma_conf.dma_buf_sz;
+
+ stmmac_set_dma_bfsize(priv, priv->ioaddr, buf_size, rx_q->queue_index);
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 11/15] net: stmmac: add helper to get hardware transmit descriptor
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (9 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size() Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 12/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
` (3 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Provide a helper to get the hardware transmit descriptor that takes
account of whether extended format and TBS are being used, returning
the base struct dma_desc pointer. This avoids multiple instances where
these tests are open coded.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 87 ++++++-------------
1 file changed, 25 insertions(+), 62 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 032ef9fba8b4..76e4dcf8f697 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -362,6 +362,18 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv, u32 queue)
priv->dma_conf.dma_tx_size);
}
+static struct dma_desc *stmmac_get_tx_desc(struct stmmac_priv *priv,
+ struct stmmac_tx_queue *tx_q,
+ unsigned int index)
+{
+ if (priv->extend_desc)
+ return &tx_q->dma_etx[index].basic;
+ else if (tx_q->tbs & STMMAC_TBS_AVAIL)
+ return &tx_q->dma_entx[index].basic;
+ else
+ return &tx_q->dma_tx[index];
+}
+
static size_t stmmac_get_rx_desc_size(struct stmmac_priv *priv)
{
if (priv->extend_desc)
@@ -1489,16 +1501,14 @@ static void stmmac_display_tx_rings(struct stmmac_priv *priv,
pr_info("\tTX Queue %d rings\n", queue);
- if (priv->extend_desc) {
- head_tx = (void *)tx_q->dma_etx;
+ if (priv->extend_desc)
desc_size = sizeof(struct dma_extended_desc);
- } else if (tx_q->tbs & STMMAC_TBS_AVAIL) {
- head_tx = (void *)tx_q->dma_entx;
+ else if (tx_q->tbs & STMMAC_TBS_AVAIL)
desc_size = sizeof(struct dma_edesc);
- } else {
- head_tx = (void *)tx_q->dma_tx;
+ else
desc_size = sizeof(struct dma_desc);
- }
+
+ head_tx = stmmac_get_tx_desc(priv, tx_q, 0);
stmmac_display_ring(priv, head_tx, dma_conf->dma_tx_size, false,
tx_q->dma_tx_phy, desc_size);
@@ -1587,13 +1597,7 @@ static void stmmac_clear_tx_descriptors(struct stmmac_priv *priv,
int last = (i == (dma_conf->dma_tx_size - 1));
struct dma_desc *p;
- if (priv->extend_desc)
- p = &tx_q->dma_etx[i].basic;
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- p = &tx_q->dma_entx[i].basic;
- else
- p = &tx_q->dma_tx[i];
-
+ p = stmmac_get_tx_desc(priv, tx_q, i);
stmmac_init_tx_desc(priv, p, priv->mode, last);
}
}
@@ -2021,13 +2025,7 @@ static int __init_dma_tx_desc_rings(struct stmmac_priv *priv,
for (i = 0; i < dma_conf->dma_tx_size; i++) {
struct dma_desc *p;
- if (priv->extend_desc)
- p = &((tx_q->dma_etx + i)->basic);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- p = &((tx_q->dma_entx + i)->basic);
- else
- p = tx_q->dma_tx + i;
-
+ p = stmmac_get_tx_desc(priv, tx_q, i);
stmmac_clear_desc(priv, p);
stmmac_set_tx_skb_dma_entry(tx_q, i, 0, 0, false);
@@ -2730,13 +2728,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
continue;
}
- if (likely(priv->extend_desc))
- tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- tx_desc = &tx_q->dma_entx[entry].basic;
- else
- tx_desc = tx_q->dma_tx + entry;
-
+ tx_desc = stmmac_get_tx_desc(priv, tx_q, entry);
dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
@@ -2863,13 +2855,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
skb = NULL;
}
- if (priv->extend_desc)
- p = (struct dma_desc *)(tx_q->dma_etx + entry);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- p = &tx_q->dma_entx[entry].basic;
- else
- p = tx_q->dma_tx + entry;
-
+ p = stmmac_get_tx_desc(priv, tx_q, entry);
status = stmmac_tx_status(priv, &priv->xstats, p, priv->ioaddr);
/* Check if the descriptor is owned by the DMA */
if (unlikely(status & tx_dma_own))
@@ -4752,13 +4738,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
csum_insertion = !csum_insertion;
}
- if (likely(priv->extend_desc))
- desc = (struct dma_desc *)(tx_q->dma_etx + entry);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- desc = &tx_q->dma_entx[entry].basic;
- else
- desc = tx_q->dma_tx + entry;
-
+ desc = stmmac_get_tx_desc(priv, tx_q, entry);
first = desc;
if (has_vlan)
@@ -4783,12 +4763,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
WARN_ON(tx_q->tx_skbuff[entry]);
- if (likely(priv->extend_desc))
- desc = (struct dma_desc *)(tx_q->dma_etx + entry);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- desc = &tx_q->dma_entx[entry].basic;
- else
- desc = tx_q->dma_tx + entry;
+ desc = stmmac_get_tx_desc(priv, tx_q, entry);
des = skb_frag_dma_map(priv->device, frag, 0, len,
DMA_TO_DEVICE);
@@ -4829,13 +4804,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
set_ic = false;
if (set_ic) {
- if (likely(priv->extend_desc))
- desc = &tx_q->dma_etx[entry].basic;
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- desc = &tx_q->dma_entx[entry].basic;
- else
- desc = &tx_q->dma_tx[entry];
-
+ desc = stmmac_get_tx_desc(priv, tx_q, entry);
tx_q->tx_count_frames = 0;
stmmac_set_tx_ic(priv, desc);
}
@@ -5103,13 +5072,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
return STMMAC_XDP_CONSUMED;
}
- if (likely(priv->extend_desc))
- tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- tx_desc = &tx_q->dma_entx[entry].basic;
- else
- tx_desc = tx_q->dma_tx + entry;
-
+ tx_desc = stmmac_get_tx_desc(priv, tx_q, entry);
if (dma_map) {
dma_addr = dma_map_single(priv->device, xdpf->data,
xdpf->len, DMA_TO_DEVICE);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 12/15] net: stmmac: add helper to get size of a transmit descriptor
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (10 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 11/15] net: stmmac: add helper to get hardware transmit descriptor Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
` (2 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Add and use a helper to get the size of the hardware transmit
descriptor.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 +++++++------------
1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 76e4dcf8f697..da1726b887f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -362,6 +362,17 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv, u32 queue)
priv->dma_conf.dma_tx_size);
}
+static size_t stmmac_get_tx_desc_size(struct stmmac_priv *priv,
+ struct stmmac_tx_queue *tx_q)
+{
+ if (priv->extend_desc)
+ return sizeof(struct dma_extended_desc);
+ else if (tx_q->tbs & STMMAC_TBS_AVAIL)
+ return sizeof(struct dma_edesc);
+ else
+ return sizeof(struct dma_desc);
+}
+
static struct dma_desc *stmmac_get_tx_desc(struct stmmac_priv *priv,
struct stmmac_tx_queue *tx_q,
unsigned int index)
@@ -1501,14 +1512,8 @@ static void stmmac_display_tx_rings(struct stmmac_priv *priv,
pr_info("\tTX Queue %d rings\n", queue);
- if (priv->extend_desc)
- desc_size = sizeof(struct dma_extended_desc);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- desc_size = sizeof(struct dma_edesc);
- else
- desc_size = sizeof(struct dma_desc);
-
head_tx = stmmac_get_tx_desc(priv, tx_q, 0);
+ desc_size = stmmac_get_tx_desc_size(priv, tx_q);
stmmac_display_ring(priv, head_tx, dma_conf->dma_tx_size, false,
tx_q->dma_tx_phy, desc_size);
@@ -2186,17 +2191,14 @@ static void __free_dma_tx_desc_resources(struct stmmac_priv *priv,
dma_free_tx_skbufs(priv, dma_conf, queue);
if (priv->extend_desc) {
- size = sizeof(struct dma_extended_desc);
addr = tx_q->dma_etx;
} else if (tx_q->tbs & STMMAC_TBS_AVAIL) {
- size = sizeof(struct dma_edesc);
addr = tx_q->dma_entx;
} else {
- size = sizeof(struct dma_desc);
addr = tx_q->dma_tx;
}
- size *= dma_conf->dma_tx_size;
+ size = stmmac_get_tx_desc_size(priv, tx_q) * dma_conf->dma_tx_size;
dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy);
@@ -2358,14 +2360,7 @@ static int __alloc_dma_tx_desc_resources(struct stmmac_priv *priv,
if (!tx_q->tx_skbuff)
return -ENOMEM;
- if (priv->extend_desc)
- size = sizeof(struct dma_extended_desc);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- size = sizeof(struct dma_edesc);
- else
- size = sizeof(struct dma_desc);
-
- size *= dma_conf->dma_tx_size;
+ size = stmmac_get_tx_desc_size(priv, tx_q) * dma_conf->dma_tx_size;
addr = dma_alloc_coherent(priv->device, size,
&tx_q->dma_tx_phy, GFP_KERNEL);
@@ -4333,12 +4328,7 @@ static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue)
struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
int desc_size;
- if (likely(priv->extend_desc))
- desc_size = sizeof(struct dma_extended_desc);
- else if (tx_q->tbs & STMMAC_TBS_AVAIL)
- desc_size = sizeof(struct dma_edesc);
- else
- desc_size = sizeof(struct dma_desc);
+ desc_size = stmmac_get_tx_desc_size(priv, tx_q);
/* The own bit must be the latest setting done when prepare the
* descriptor and then barrier is needed to make sure that
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (11 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 12/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 12:34 ` Russell King (Oracle)
` (2 more replies)
2026-03-12 10:09 ` [PATCH net-next v2 14/15] net: stmmac: remove tx_tail_addr Russell King (Oracle)
2026-03-12 10:10 ` [PATCH net-next v2 15/15] net: stmmac: use queue rather than ->queue_index Russell King (Oracle)
14 siblings, 3 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Setting the queue transmit tail pointer follows a common pattern:
calculate the DMA address, and then call stmmac_set_tx_tail_ptr().
The only difference between all the call sites is the index used.
Factor this out into a static function.
We need to update dwmac4_display_ring() to cope the passed head
pointer always pointing at the struct dma_desc by using
dma_desc_to_edesc() to convert it to struct dma_edesc. This is the
only stmmac_display_ring() implementation that this affects.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../ethernet/stmicro/stmmac/dwmac4_descs.c | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 30 ++++++++++---------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index 1bbf02504dad..d5c003f3fbbc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -427,7 +427,7 @@ static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
extp++;
}
} else if (desc_size == sizeof(struct dma_edesc)) {
- struct dma_edesc *ep = (struct dma_edesc *)head;
+ struct dma_edesc *ep = dma_desc_to_edesc(head);
for (i = 0; i < size; i++) {
dma_addr = dma_rx_phy + i * sizeof(*ep);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index da1726b887f3..4521469c5e1d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -385,6 +385,18 @@ static struct dma_desc *stmmac_get_tx_desc(struct stmmac_priv *priv,
return &tx_q->dma_tx[index];
}
+static void stmmac_set_queue_tx_tail_ptr(struct stmmac_priv *priv,
+ struct stmmac_tx_queue *tx_q,
+ unsigned int chan, unsigned int index)
+{
+ int desc_size;
+
+ desc_size = stmmac_get_tx_desc_size(priv, tx_q);
+
+ tx_q->tx_tail_addr = tx_q->dma_tx_phy + index * desc_size;
+ stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, chan);
+}
+
static size_t stmmac_get_rx_desc_size(struct stmmac_priv *priv)
{
if (priv->extend_desc)
@@ -3311,9 +3323,7 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
tx_q->dma_tx_phy, chan);
- tx_q->tx_tail_addr = tx_q->dma_tx_phy;
- stmmac_set_tx_tail_ptr(priv, priv->ioaddr,
- tx_q->tx_tail_addr, chan);
+ stmmac_set_queue_tx_tail_ptr(priv, tx_q, chan, 0);
}
return ret;
@@ -4326,9 +4336,6 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des,
static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue)
{
struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
- int desc_size;
-
- desc_size = stmmac_get_tx_desc_size(priv, tx_q);
/* The own bit must be the latest setting done when prepare the
* descriptor and then barrier is needed to make sure that
@@ -4336,8 +4343,7 @@ static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue)
*/
wmb();
- tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size);
- stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
+ stmmac_set_queue_tx_tail_ptr(priv, tx_q, queue, tx_q->cur_tx);
}
/**
@@ -6967,9 +6973,7 @@ void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue)
if (tx_q->tbs & STMMAC_TBS_AVAIL)
stmmac_enable_tbs(priv, priv->ioaddr, 1, tx_q->queue_index);
- tx_q->tx_tail_addr = tx_q->dma_tx_phy;
- stmmac_set_tx_tail_ptr(priv, priv->ioaddr,
- tx_q->tx_tail_addr, tx_q->queue_index);
+ stmmac_set_queue_tx_tail_ptr(priv, tx_q, tx_q->queue_index, 0);
stmmac_start_tx_dma(priv, queue);
@@ -7070,9 +7074,7 @@ int stmmac_xdp_open(struct net_device *dev)
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
tx_q->dma_tx_phy, chan);
- tx_q->tx_tail_addr = tx_q->dma_tx_phy;
- stmmac_set_tx_tail_ptr(priv, priv->ioaddr,
- tx_q->tx_tail_addr, chan);
+ stmmac_set_queue_tx_tail_ptr(priv, tx_q, chan, 0);
hrtimer_setup(&tx_q->txtimer, stmmac_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 14/15] net: stmmac: remove tx_tail_addr
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (12 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
@ 2026-03-12 10:09 ` Russell King (Oracle)
2026-03-12 10:10 ` [PATCH net-next v2 15/15] net: stmmac: use queue rather than ->queue_index Russell King (Oracle)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
There is only one place where tx_q->tx_tail_addr is used - the new
stmmac_set_queue_tx_tail_ptr(). Make this a local variable and remove
it from struct stmmac_tx_queue.
This commit does not change the semantics - the hardware relies upon
the descriptor ring not crossing a 4GiB boundary as the high address
bits are programmed into a separate register via stmmac_init_tx_chan().
Hence, truncating the DMA address to 32-bit is fine as the register it
will be programmed into is 32-bit, and the high bits are handled
elsewhere.
Also change the type of desc_size to size_t, as this variable is
initialised from sizeof().
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 -
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index d1f8383d1c04..7cc5967aecd7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -79,7 +79,6 @@ struct stmmac_tx_queue {
unsigned int cur_tx;
unsigned int dirty_tx;
dma_addr_t dma_tx_phy;
- dma_addr_t tx_tail_addr;
u32 mss;
};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 4521469c5e1d..55b79e9e637f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -389,12 +389,13 @@ static void stmmac_set_queue_tx_tail_ptr(struct stmmac_priv *priv,
struct stmmac_tx_queue *tx_q,
unsigned int chan, unsigned int index)
{
- int desc_size;
+ size_t desc_size;
+ u32 tx_tail_addr;
desc_size = stmmac_get_tx_desc_size(priv, tx_q);
- tx_q->tx_tail_addr = tx_q->dma_tx_phy + index * desc_size;
- stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, chan);
+ tx_tail_addr = tx_q->dma_tx_phy + index * desc_size;
+ stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_tail_addr, chan);
}
static size_t stmmac_get_rx_desc_size(struct stmmac_priv *priv)
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net-next v2 15/15] net: stmmac: use queue rather than ->queue_index
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
` (13 preceding siblings ...)
2026-03-12 10:09 ` [PATCH net-next v2 14/15] net: stmmac: remove tx_tail_addr Russell King (Oracle)
@ 2026-03-12 10:10 ` Russell King (Oracle)
14 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 10:10 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
We use a lot of ->queue_index where we already have the queue / channel
index (which are actually the same index), which has been used to get
the queue struct. Since queue and queue_index are identical in
priv->(tx|rx)_queue[queue]->queue_index there is no point using the
queue_index where we already have queue.
Use queue rather than queue_index.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++++-----------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 55b79e9e637f..8393cbd0875e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -440,7 +440,7 @@ static void stmmac_set_queue_rx_buf_size(struct stmmac_priv *priv,
else
buf_size = priv->dma_conf.dma_buf_sz;
- stmmac_set_dma_bfsize(priv, priv->ioaddr, buf_size, rx_q->queue_index);
+ stmmac_set_dma_bfsize(priv, priv->ioaddr, buf_size, chan);
}
/**
@@ -1902,7 +1902,7 @@ static int __init_dma_rx_desc_rings(struct stmmac_priv *priv,
NULL));
netdev_info(priv->dev,
"Register MEM_TYPE_XSK_BUFF_POOL RxQ-%d\n",
- rx_q->queue_index);
+ queue);
xsk_pool_set_rxq_info(rx_q->xsk_pool, &rx_q->xdp_rxq);
} else {
WARN_ON(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq,
@@ -1910,7 +1910,7 @@ static int __init_dma_rx_desc_rings(struct stmmac_priv *priv,
rx_q->page_pool));
netdev_info(priv->dev,
"Register MEM_TYPE_PAGE_POOL RxQ-%d\n",
- rx_q->queue_index);
+ queue);
}
if (rx_q->xsk_pool) {
@@ -2310,9 +2310,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv,
else
napi_id = ch->rx_napi.napi_id;
- ret = xdp_rxq_info_reg(&rx_q->xdp_rxq, priv->dev,
- rx_q->queue_index,
- napi_id);
+ ret = xdp_rxq_info_reg(&rx_q->xdp_rxq, priv->dev, queue, napi_id);
if (ret) {
netdev_err(priv->dev, "Failed to register xdp rxq info\n");
return -EINVAL;
@@ -3340,7 +3338,7 @@ static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue)
if (!tx_coal_timer)
return;
- ch = &priv->channel[tx_q->queue_index];
+ ch = &priv->channel[queue];
napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi;
/* Arm timer only if napi is not already scheduled.
@@ -6918,12 +6916,11 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
stmmac_clear_rx_descriptors(priv, &priv->dma_conf, queue);
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
- rx_q->dma_rx_phy, rx_q->queue_index);
+ rx_q->dma_rx_phy, queue);
- stmmac_set_queue_rx_tail_ptr(priv, rx_q, rx_q->queue_index,
- rx_q->buf_alloc_num);
+ stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->buf_alloc_num);
- stmmac_set_queue_rx_buf_size(priv, rx_q, rx_q->queue_index);
+ stmmac_set_queue_rx_buf_size(priv, rx_q, queue);
stmmac_start_rx_dma(priv, queue);
@@ -6969,12 +6966,12 @@ void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue)
stmmac_clear_tx_descriptors(priv, &priv->dma_conf, queue);
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
- tx_q->dma_tx_phy, tx_q->queue_index);
+ tx_q->dma_tx_phy, queue);
if (tx_q->tbs & STMMAC_TBS_AVAIL)
- stmmac_enable_tbs(priv, priv->ioaddr, 1, tx_q->queue_index);
+ stmmac_enable_tbs(priv, priv->ioaddr, 1, queue);
- stmmac_set_queue_tx_tail_ptr(priv, tx_q, tx_q->queue_index, 0);
+ stmmac_set_queue_tx_tail_ptr(priv, tx_q, queue, 0);
stmmac_start_tx_dma(priv, queue);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
@ 2026-03-12 12:34 ` Russell King (Oracle)
2026-03-13 19:50 ` kernel test robot
2026-03-13 20:10 ` kernel test robot
2 siblings, 0 replies; 19+ messages in thread
From: Russell King (Oracle) @ 2026-03-12 12:34 UTC (permalink / raw)
To: Andrew Lunn
Cc: Alexandre Torgue, Alexei Starovoitov, Andrew Lunn, bpf,
Daniel Borkmann, David S. Miller, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
On Thu, Mar 12, 2026 at 10:09:54AM +0000, Russell King (Oracle) wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index 1bbf02504dad..d5c003f3fbbc 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -427,7 +427,7 @@ static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
> extp++;
> }
> } else if (desc_size == sizeof(struct dma_edesc)) {
> - struct dma_edesc *ep = (struct dma_edesc *)head;
> + struct dma_edesc *ep = dma_desc_to_edesc(head);
Too-many-outstanding-patches-itis strikes again (I have more than 100
outstnading patches at the moment.) dma_desc_to_edesc() is in a later
patch that isn't part of this series.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
2026-03-12 12:34 ` Russell King (Oracle)
@ 2026-03-13 19:50 ` kernel test robot
2026-03-13 20:10 ` kernel test robot
2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2026-03-13 19:50 UTC (permalink / raw)
To: Russell King (Oracle), Andrew Lunn
Cc: llvm, oe-kbuild-all, Alexandre Torgue, Alexei Starovoitov, bpf,
Daniel Borkmann, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Hi Russell,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Russell-King-Oracle/net-stmmac-rearrange-stmmac_tx_info-members-to-pack-better/20260313-225823
base: net-next/main
patch link: https://lore.kernel.org/r/E1w0czK-0000000CzH7-19Fb%40rmk-PC.armlinux.org.uk
patch subject: [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260313/202603132053.N3kL3UZZ-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260313/202603132053.N3kL3UZZ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603132053.N3kL3UZZ-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:430:26: error: call to undeclared function 'dma_desc_to_edesc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
430 | struct dma_edesc *ep = dma_desc_to_edesc(head);
| ^
>> drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:430:21: error: incompatible integer to pointer conversion initializing 'struct dma_edesc *' with an expression of type 'int' [-Wint-conversion]
430 | struct dma_edesc *ep = dma_desc_to_edesc(head);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
vim +/dma_desc_to_edesc +430 drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
396
397 static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
398 dma_addr_t dma_rx_phy, unsigned int desc_size)
399 {
400 dma_addr_t dma_addr;
401 int i;
402
403 pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
404
405 if (desc_size == sizeof(struct dma_desc)) {
406 struct dma_desc *p = (struct dma_desc *)head;
407
408 for (i = 0; i < size; i++) {
409 dma_addr = dma_rx_phy + i * sizeof(*p);
410 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
411 i, &dma_addr,
412 le32_to_cpu(p->des0), le32_to_cpu(p->des1),
413 le32_to_cpu(p->des2), le32_to_cpu(p->des3));
414 p++;
415 }
416 } else if (desc_size == sizeof(struct dma_extended_desc)) {
417 struct dma_extended_desc *extp = (struct dma_extended_desc *)head;
418
419 for (i = 0; i < size; i++) {
420 dma_addr = dma_rx_phy + i * sizeof(*extp);
421 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
422 i, &dma_addr,
423 le32_to_cpu(extp->basic.des0), le32_to_cpu(extp->basic.des1),
424 le32_to_cpu(extp->basic.des2), le32_to_cpu(extp->basic.des3),
425 le32_to_cpu(extp->des4), le32_to_cpu(extp->des5),
426 le32_to_cpu(extp->des6), le32_to_cpu(extp->des7));
427 extp++;
428 }
429 } else if (desc_size == sizeof(struct dma_edesc)) {
> 430 struct dma_edesc *ep = dma_desc_to_edesc(head);
431
432 for (i = 0; i < size; i++) {
433 dma_addr = dma_rx_phy + i * sizeof(*ep);
434 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
435 i, &dma_addr,
436 le32_to_cpu(ep->des4), le32_to_cpu(ep->des5),
437 le32_to_cpu(ep->des6), le32_to_cpu(ep->des7),
438 le32_to_cpu(ep->basic.des0), le32_to_cpu(ep->basic.des1),
439 le32_to_cpu(ep->basic.des2), le32_to_cpu(ep->basic.des3));
440 ep++;
441 }
442 } else {
443 pr_err("unsupported descriptor!");
444 }
445 }
446
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
2026-03-12 12:34 ` Russell King (Oracle)
2026-03-13 19:50 ` kernel test robot
@ 2026-03-13 20:10 ` kernel test robot
2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2026-03-13 20:10 UTC (permalink / raw)
To: Russell King (Oracle), Andrew Lunn
Cc: oe-kbuild-all, Alexandre Torgue, Alexei Starovoitov, bpf,
Daniel Borkmann, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, linux-arm-kernel, linux-stm32, netdev,
Paolo Abeni, Stanislav Fomichev
Hi Russell,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Russell-King-Oracle/net-stmmac-rearrange-stmmac_tx_info-members-to-pack-better/20260313-225823
base: net-next/main
patch link: https://lore.kernel.org/r/E1w0czK-0000000CzH7-19Fb%40rmk-PC.armlinux.org.uk
patch subject: [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260313/202603132104.OVIsnpBk-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260313/202603132104.OVIsnpBk-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603132104.OVIsnpBk-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c: In function 'dwmac4_display_ring':
>> drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:430:40: error: implicit declaration of function 'dma_desc_to_edesc' [-Wimplicit-function-declaration]
430 | struct dma_edesc *ep = dma_desc_to_edesc(head);
| ^~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:430:40: error: initialization of 'struct dma_edesc *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
vim +/dma_desc_to_edesc +430 drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
396
397 static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
398 dma_addr_t dma_rx_phy, unsigned int desc_size)
399 {
400 dma_addr_t dma_addr;
401 int i;
402
403 pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
404
405 if (desc_size == sizeof(struct dma_desc)) {
406 struct dma_desc *p = (struct dma_desc *)head;
407
408 for (i = 0; i < size; i++) {
409 dma_addr = dma_rx_phy + i * sizeof(*p);
410 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
411 i, &dma_addr,
412 le32_to_cpu(p->des0), le32_to_cpu(p->des1),
413 le32_to_cpu(p->des2), le32_to_cpu(p->des3));
414 p++;
415 }
416 } else if (desc_size == sizeof(struct dma_extended_desc)) {
417 struct dma_extended_desc *extp = (struct dma_extended_desc *)head;
418
419 for (i = 0; i < size; i++) {
420 dma_addr = dma_rx_phy + i * sizeof(*extp);
421 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
422 i, &dma_addr,
423 le32_to_cpu(extp->basic.des0), le32_to_cpu(extp->basic.des1),
424 le32_to_cpu(extp->basic.des2), le32_to_cpu(extp->basic.des3),
425 le32_to_cpu(extp->des4), le32_to_cpu(extp->des5),
426 le32_to_cpu(extp->des6), le32_to_cpu(extp->des7));
427 extp++;
428 }
429 } else if (desc_size == sizeof(struct dma_edesc)) {
> 430 struct dma_edesc *ep = dma_desc_to_edesc(head);
431
432 for (i = 0; i < size; i++) {
433 dma_addr = dma_rx_phy + i * sizeof(*ep);
434 pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
435 i, &dma_addr,
436 le32_to_cpu(ep->des4), le32_to_cpu(ep->des5),
437 le32_to_cpu(ep->des6), le32_to_cpu(ep->des7),
438 le32_to_cpu(ep->basic.des0), le32_to_cpu(ep->basic.des1),
439 le32_to_cpu(ep->basic.des2), le32_to_cpu(ep->basic.des3));
440 ep++;
441 }
442 } else {
443 pr_err("unsupported descriptor!");
444 }
445 }
446
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-03-13 20:11 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 10:07 [PATCH net-next v2 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
2026-03-12 10:08 ` [PATCH net-next v2 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors() Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 04/15] net: stmmac: add helper to get hardware receive descriptor Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 05/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 06/15] net: stmmac: add helper to set receive tail pointer Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 07/15] net: stmmac: remove rx_tail_addr Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 08/15] net: stmmac: use consistent tests for receive buffer size Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 09/15] net: stmmac: add helper to set " Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size() Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 11/15] net: stmmac: add helper to get hardware transmit descriptor Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 12/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-12 10:09 ` [PATCH net-next v2 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
2026-03-12 12:34 ` Russell King (Oracle)
2026-03-13 19:50 ` kernel test robot
2026-03-13 20:10 ` kernel test robot
2026-03-12 10:09 ` [PATCH net-next v2 14/15] net: stmmac: remove tx_tail_addr Russell King (Oracle)
2026-03-12 10:10 ` [PATCH net-next v2 15/15] net: stmmac: use queue rather than ->queue_index Russell King (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox