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 09/15] net: stmmac: add helper to set receive buffer size
Date: Wed, 11 Mar 2026 09:52:50 +0000 [thread overview]
Message-ID: <E1w0GFG-0000000CiTP-1EJi@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <abE7LWj04-JNxgS2@shell.armlinux.org.uk>
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
next prev parent reply other threads:[~2026-03-11 9:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 9:51 [PATCH net-next 00/15] net: stmmac: clean up descriptor handling part 1 Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 01/15] net: stmmac: rearrange stmmac_tx_info members to pack better Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 02/15] net: stmmac: helpers for filling tx_q->tx_skbuff_dma Russell King (Oracle)
2026-03-11 14:57 ` Andrew Lunn
2026-03-11 14:59 ` Russell King (Oracle)
2026-03-12 8:54 ` Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 03/15] net: stmmac: clean up stmmac_clear_rx_descriptors() Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 04/15] net: stmmac: add helper to get hardware receive descriptor Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 05/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 06/15] net: stmmac: add helper to set receive tail pointer Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 07/15] net: stmmac: remove rx_tail_addr Russell King (Oracle)
2026-03-11 9:52 ` [PATCH net-next 08/15] net: stmmac: use consistent tests for receive buffer size Russell King (Oracle)
2026-03-11 9:52 ` Russell King (Oracle) [this message]
2026-03-11 9:52 ` [PATCH net-next 10/15] net: stmmac: simplify stmmac_set_queue_rx_buf_size() Russell King (Oracle)
2026-03-11 9:53 ` [PATCH net-next 11/15] net: stmmac: add helper to get hardware transmit descriptor Russell King (Oracle)
2026-03-11 9:53 ` [PATCH net-next 12/15] net: stmmac: add helper to get size of a " Russell King (Oracle)
2026-03-11 9:53 ` [PATCH net-next 13/15] net: stmmac: add helper to set transmit tail pointer Russell King (Oracle)
2026-03-11 9:53 ` [PATCH net-next 14/15] net: stmmac: remove tx_tail_addr Russell King (Oracle)
2026-03-11 9:53 ` [PATCH net-next 15/15] net: stmmac: use queue rather than ->queue_index Russell King (Oracle)
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=E1w0GFG-0000000CiTP-1EJi@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