From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Alexei Starovoitov <ast@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
bpf@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org,
Paolo Abeni <pabeni@redhat.com>,
Stanislav Fomichev <sdf@fomichev.me>
Subject: [PATCH net-next v4 06/15] net: stmmac: add helper to set receive tail pointer
Date: Sat, 14 Mar 2026 09:42:50 +0000 [thread overview]
Message-ID: <E1w1LWE-0000000DGSF-2Hbs@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <abUtGH9KB03PH5Ne@shell.armlinux.org.uk>
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
next prev parent reply other threads:[~2026-03-14 9:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 9:40 [PATCH net-next v4 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
2026-03-14 9:42 ` [PATCH net-next v4 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
2026-03-14 9:42 ` [PATCH net-next v4 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma Russell King (Oracle)
2026-03-14 9:42 ` [PATCH net-next v4 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors() Russell King (Oracle)
2026-03-14 9:42 ` [PATCH net-next v4 04/15] net: stmmac: add helper to get hardware receive descriptor Russell King (Oracle)
2026-03-14 9:42 ` [PATCH net-next v4 05/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-14 9:42 ` Russell King (Oracle) [this message]
2026-03-14 9:42 ` [PATCH net-next v4 07/15] net: stmmac: remove rx_tail_addr Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 08/15] net: stmmac: use consistent tests for receive buffer size Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 09/15] net: stmmac: add helper to set " Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size() Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 11/15] net: stmmac: add helper to get hardware transmit descriptor Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 12/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 14/15] net: stmmac: remove tx_tail_addr Russell King (Oracle)
2026-03-14 9:43 ` [PATCH net-next v4 15/15] net: stmmac: use queue rather than ->queue_index Russell King (Oracle)
2026-03-18 3:40 ` [PATCH net-next v4 00/15] net: stmmac: clean up descriptor handling part 1 patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1w1LWE-0000000DGSF-2Hbs@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox