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 v2 7/8] net: macb: make tx path skb agnostic
Date: Mon, 23 Feb 2026 19:26:31 +0100 [thread overview]
Message-ID: <20260223182632.1681809-8-pvalerio@redhat.com> (raw)
In-Reply-To: <20260223182632.1681809-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 4e3cc0e9ea87..67fef88af2c6 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 f65f976123fd..50646ee90672 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -967,7 +967,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)
@@ -979,9 +980,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;
}
}
@@ -1068,7 +1069,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 */
@@ -1076,7 +1077,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
@@ -1204,7 +1205,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) {
@@ -2170,7 +2173,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;
@@ -2198,7 +2202,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;
@@ -2216,7 +2221,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
@@ -5136,8 +5142,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)) {
@@ -5229,9 +5236,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-02-23 18:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 18:26 [PATCH net-next v2 0/8] net: macb: Add XDP support and page pool integration Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 1/8] net: macb: move Rx buffers alloc from link up to open Paolo Valerio
2026-02-24 0:08 ` [net-next,v2,1/8] " Jakub Kicinski
2026-02-25 18:29 ` Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 2/8] net: macb: rename rx_skbuff into rx_buff Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 3/8] net: macb: Add page pool support handle multi-descriptor frame rx Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 4/8] net: macb: use the current queue number for stats Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 5/8] net: macb: add XDP support for gem Paolo Valerio
2026-02-23 23:23 ` kernel test robot
2026-02-24 0:08 ` [net-next,v2,5/8] " Jakub Kicinski
2026-02-25 18:30 ` Paolo Valerio
2026-02-27 10:52 ` Théo Lebrun
2026-02-28 13:49 ` Claudiu Beznea
2026-02-23 18:26 ` [PATCH net-next v2 6/8] net: macb: make macb_tx_skb generic Paolo Valerio
2026-02-24 0:08 ` [net-next,v2,6/8] " Jakub Kicinski
2026-02-23 18:26 ` Paolo Valerio [this message]
2026-02-24 0:09 ` [net-next,v2,7/8] net: macb: make tx path skb agnostic Jakub Kicinski
2026-02-25 18:36 ` Paolo Valerio
2026-02-23 18:26 ` [PATCH net-next v2 8/8] net: macb: introduce xmit support Paolo Valerio
2026-02-24 0:09 ` [net-next,v2,8/8] " Jakub Kicinski
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=20260223182632.1681809-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