net: stmmac: add helper to set receive tail pointer

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>
Link: https://patch.msgid.link/E1w1LWE-0000000DGSF-2Hbs@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Russell King (Oracle) 2026-03-14 09:42:50 +00:00 committed by Jakub Kicinski
parent 4f6280c450
commit e9d0cafa9d

View File

@ -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 */
@ -5023,9 +5032,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);
}
@ -5405,9 +5412,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;
@ -6975,10 +6980,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);
@ -7129,11 +7132,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);