From: Paolo Valerio <pvalerio@redhat.com>
To: netdev@vger.kernel.org
Cc: "Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Lorenzo Bianconi" <lorenzo@kernel.org>,
"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH net-next 7/8] cadence: macb: make tx path skb agnostic
Date: Thu, 15 Jan 2026 23:25:30 +0100 [thread overview]
Message-ID: <20260115222531.313002-8-pvalerio@redhat.com> (raw)
In-Reply-To: <20260115222531.313002-1-pvalerio@redhat.com>
Rename macb_tx_buff member skb to ptr and introduce macb_tx_buff_type
to identify the buffer type macb_tx_buff represents.
This is the last preparatory step for xdp xmit support.
Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
---
drivers/net/ethernet/cadence/macb.h | 23 +++++++++++-----
drivers/net/ethernet/cadence/macb_main.c | 35 ++++++++++++++----------
2 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 970ad3f945fb..c17e894dfcdb 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -959,19 +959,28 @@ struct macb_dma_desc_ptp {
/* Scaled PPM fraction */
#define PPM_FRACTION 16
-/* struct macb_tx_buff - data about an skb which is being transmitted
- * @skb: skb currently being transmitted, only set for the last buffer
- * of the frame
+enum macb_tx_buff_type {
+ MACB_TYPE_SKB,
+ MACB_TYPE_XDP_TX,
+ MACB_TYPE_XDP_NDO,
+};
+
+/* struct macb_tx_buff - data about an skb or xdp frame which is being
+ * transmitted.
+ * @ptr: pointer to skb or xdp frame being transmitted, only set
+ * for the last buffer for sk_buff
* @mapping: DMA address of the skb's fragment buffer
* @size: size of the DMA mapped buffer
* @mapped_as_page: true when buffer was mapped with skb_frag_dma_map(),
* false when buffer was mapped with dma_map_single()
+ * @type: type of buffer (MACB_TYPE_SKB, MACB_TYPE_XDP_TX, MACB_TYPE_XDP_NDO)
*/
struct macb_tx_buff {
- void *skb;
- dma_addr_t mapping;
- size_t size;
- bool mapped_as_page;
+ void *ptr;
+ dma_addr_t mapping;
+ size_t size;
+ bool mapped_as_page;
+ enum macb_tx_buff_type type;
};
/* Hardware-collected statistics. Used when updating the network
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 26af371b3b1e..afd8c0f2d895 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -969,7 +969,8 @@ static int macb_halt_tx(struct macb *bp)
bp, TSR);
}
-static void macb_tx_unmap(struct macb *bp, struct macb_tx_buff *tx_buff, int budget)
+static void macb_tx_unmap(struct macb *bp, struct macb_tx_buff *tx_buff,
+ int budget)
{
if (tx_buff->mapping) {
if (tx_buff->mapped_as_page)
@@ -981,9 +982,9 @@ static void macb_tx_unmap(struct macb *bp, struct macb_tx_buff *tx_buff, int bud
tx_buff->mapping = 0;
}
- if (tx_buff->skb) {
- napi_consume_skb(tx_buff->skb, budget);
- tx_buff->skb = NULL;
+ if (tx_buff->ptr) {
+ napi_consume_skb(tx_buff->ptr, budget);
+ tx_buff->ptr = NULL;
}
}
@@ -1070,7 +1071,7 @@ static void macb_tx_error_task(struct work_struct *work)
desc = macb_tx_desc(queue, tail);
ctrl = desc->ctrl;
tx_buff = macb_tx_buff(queue, tail);
- skb = tx_buff->skb;
+ skb = tx_buff->ptr;
if (ctrl & MACB_BIT(TX_USED)) {
/* skb is set for the last buffer of the frame */
@@ -1078,7 +1079,7 @@ static void macb_tx_error_task(struct work_struct *work)
macb_tx_unmap(bp, tx_buff, 0);
tail++;
tx_buff = macb_tx_buff(queue, tail);
- skb = tx_buff->skb;
+ skb = tx_buff->ptr;
}
/* ctrl still refers to the first buffer descriptor
@@ -1206,7 +1207,9 @@ static int macb_tx_complete(struct macb_queue *queue, int budget)
/* Process all buffers of the current transmitted frame */
for (;; tail++) {
tx_buff = macb_tx_buff(queue, tail);
- skb = tx_buff->skb;
+
+ if (tx_buff->type == MACB_TYPE_SKB)
+ skb = tx_buff->ptr;
/* First, update TX stats if needed */
if (skb) {
@@ -2163,7 +2166,8 @@ static unsigned int macb_tx_map(struct macb *bp,
goto dma_error;
/* Save info to properly release resources */
- tx_buff->skb = NULL;
+ tx_buff->ptr = NULL;
+ tx_buff->type = MACB_TYPE_SKB;
tx_buff->mapping = mapping;
tx_buff->size = size;
tx_buff->mapped_as_page = false;
@@ -2191,7 +2195,8 @@ static unsigned int macb_tx_map(struct macb *bp,
goto dma_error;
/* Save info to properly release resources */
- tx_buff->skb = NULL;
+ tx_buff->ptr = NULL;
+ tx_buff->type = MACB_TYPE_SKB;
tx_buff->mapping = mapping;
tx_buff->size = size;
tx_buff->mapped_as_page = true;
@@ -2209,7 +2214,8 @@ static unsigned int macb_tx_map(struct macb *bp,
}
/* This is the last buffer of the frame: save socket buffer */
- tx_buff->skb = skb;
+ tx_buff->ptr = skb;
+ tx_buff->type = MACB_TYPE_SKB;
/* Update TX ring: update buffer descriptors in reverse order
* to avoid race condition
@@ -5096,8 +5102,9 @@ static netdev_tx_t at91ether_start_xmit(struct sk_buff *skb,
netif_stop_queue(dev);
/* Store packet information (to free when Tx completed) */
- lp->rm9200_txq[desc].skb = skb;
+ lp->rm9200_txq[desc].ptr = skb;
lp->rm9200_txq[desc].size = skb->len;
+ lp->rm9200_txq[desc].type = MACB_TYPE_SKB;
lp->rm9200_txq[desc].mapping = dma_map_single(&lp->pdev->dev, skb->data,
skb->len, DMA_TO_DEVICE);
if (dma_mapping_error(&lp->pdev->dev, lp->rm9200_txq[desc].mapping)) {
@@ -5189,9 +5196,9 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
dev->stats.tx_errors++;
desc = 0;
- if (lp->rm9200_txq[desc].skb) {
- dev_consume_skb_irq(lp->rm9200_txq[desc].skb);
- lp->rm9200_txq[desc].skb = NULL;
+ if (lp->rm9200_txq[desc].ptr) {
+ dev_consume_skb_irq(lp->rm9200_txq[desc].ptr);
+ lp->rm9200_txq[desc].ptr = NULL;
dma_unmap_single(&lp->pdev->dev, lp->rm9200_txq[desc].mapping,
lp->rm9200_txq[desc].size, DMA_TO_DEVICE);
dev->stats.tx_packets++;
--
2.52.0
next prev parent reply other threads:[~2026-01-15 22:26 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 22:25 [PATCH net-next 0/8] net: macb: Add XDP support and page pool integration Paolo Valerio
2026-01-15 22:25 ` [PATCH net-next 1/8] net: macb: move Rx buffers alloc from link up to open Paolo Valerio
2026-01-15 22:25 ` [PATCH net-next 2/8] net: macb: rename rx_skbuff into rx_buff Paolo Valerio
2026-01-15 22:25 ` [PATCH net-next 3/8] cadence: macb: Add page pool support handle multi-descriptor frame rx Paolo Valerio
2026-01-16 17:16 ` Andrew Lunn
2026-01-19 18:58 ` Paolo Valerio
2026-01-22 22:24 ` Paolo Valerio
2026-01-22 23:04 ` Andrew Lunn
2026-01-25 19:02 ` Paolo Valerio
2026-01-26 14:29 ` Andrew Lunn
2026-01-26 18:45 ` Théo Lebrun
2026-01-26 23:51 ` Paolo Valerio
2026-01-27 15:48 ` Théo Lebrun
2026-01-26 23:34 ` Paolo Valerio
2026-01-19 19:36 ` [net-next,3/8] " Jakub Kicinski
2026-01-22 14:39 ` Théo Lebrun
2026-01-22 15:16 ` Jakub Kicinski
2026-01-26 14:55 ` [PATCH net-next 3/8] " Théo Lebrun
2026-02-20 15:45 ` Théo Lebrun
2026-01-15 22:25 ` [PATCH net-next 4/8] cadence: macb: use the current queue number for stats Paolo Valerio
2026-01-15 22:25 ` [PATCH net-next 5/8] cadence: macb: add XDP support for gem Paolo Valerio
2026-01-19 19:36 ` [net-next,5/8] " Jakub Kicinski
2026-01-15 22:25 ` [PATCH net-next 6/8] cadence: macb: make macb_tx_skb generic Paolo Valerio
2026-01-15 22:25 ` Paolo Valerio [this message]
2026-01-15 22:25 ` [PATCH net-next 8/8] cadence: macb: introduce xmit support Paolo Valerio
2026-01-19 19:36 ` [net-next,8/8] " Jakub Kicinski
2026-02-02 16:31 ` [PATCH net-next 0/8] net: macb: Add XDP support and page pool integration Théo Lebrun
2026-02-13 16:57 ` [PATCH 1/6] net: macb: rename release_buff() -> macb_tx_release_buff() Théo Lebrun
2026-02-13 16:57 ` [PATCH 2/6] net: macb: drop two labels in gem_rx() Théo Lebrun
2026-02-13 16:57 ` [PATCH 3/6] net: macb: always use DMA_BIDIRECTIONAL on page pool buffers Théo Lebrun
2026-02-13 16:57 ` [PATCH 4/6] net: macb: account for stats in Rx XDP codepaths Théo Lebrun
2026-02-13 16:57 ` [PATCH 5/6] net: macb: improve Rx refill error message Théo Lebrun
2026-02-13 16:57 ` [PATCH 6/6] net: macb: rework macb_tx_complete() processing loop Théo Lebrun
2026-02-13 16:57 ` [PATCH net-next 0/8] net: macb: Add XDP support and page pool integration Théo Lebrun
2026-02-13 17:02 ` Théo Lebrun
2026-02-14 15:37 ` Paolo Valerio
2026-02-16 9:17 ` Théo Lebrun
2026-02-19 18:05 ` Paolo Valerio
2026-02-20 15:58 ` Théo Lebrun
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=20260115222531.313002-8-pvalerio@redhat.com \
--to=pvalerio@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=theo.lebrun@bootlin.com \
/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