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 12/15] net: stmmac: add helper to get size of a transmit descriptor
Date: Sat, 14 Mar 2026 09:43:21 +0000 [thread overview]
Message-ID: <E1w1LWj-0000000DGSp-0lhO@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <abUtGH9KB03PH5Ne@shell.armlinux.org.uk>
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
next prev parent reply other threads:[~2026-03-14 9:49 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 ` [PATCH net-next v4 06/15] net: stmmac: add helper to set receive tail pointer Russell King (Oracle)
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 ` Russell King (Oracle) [this message]
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=E1w1LWj-0000000DGSp-0lhO@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