All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Washington <joshwash@google.com>
To: Jeroen de Borst <jeroendb@google.com>,
	Joshua Washington <joshwash@google.com>,
	 Xiaoyun Li <xiaoyun.li@intel.com>,
	Junfeng Guo <junfengg@nvidia.com>
Cc: dev@dpdk.org, stable@dpdk.org,
	 "Jasper Tran O'Leary" <jtranoleary@google.com>
Subject: [PATCH v2 3/9] net/gve: copy data to QPL buffer when mbuf read does not
Date: Fri,  3 Jul 2026 06:13:00 -0700	[thread overview]
Message-ID: <20260703131308.2507403-4-joshwash@google.com> (raw)
In-Reply-To: <20260703131308.2507403-1-joshwash@google.com>

The rte_pktmbuf_read method does not guarantee that data will be copied
from an mbuf. If the requested data is all contiguous, the method will
instead return a pointer to the memory location within the buffer that
should be read from, leaving the destination buffer empty.

This is problematic for TSO/multi-segment TX packets which only make use
of two mbufs. If all data in the second mbuf is contiguous, the data
will not be read to QPL memory.

Update the QPL copy logic to copy if the rte_pktmbuf_read does not.

Fixes: a46583cf43c8 ("net/gve: support Rx/Tx")
Cc: stable@dpdk.org
Signed-off-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Jasper Tran O'Leary <jtranoleary@google.com>
---
v2:
  Removed unused declaration and definition of addr

 drivers/net/gve/gve_tx.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/net/gve/gve_tx.c b/drivers/net/gve/gve_tx.c
index 59c82b04ed..d220d5167a 100644
--- a/drivers/net/gve/gve_tx.c
+++ b/drivers/net/gve/gve_tx.c
@@ -255,10 +255,10 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct rte_mbuf **sw_ring = txq->sw_ring;
 	uint16_t mask = txq->nb_tx_desc - 1;
 	uint16_t tx_id = txq->tx_tail & mask;
-	uint64_t ol_flags, addr, fifo_addr;
 	uint32_t tx_tail = txq->tx_tail;
 	struct rte_mbuf *tx_pkt, *first;
 	uint16_t sw_id = txq->sw_tail;
+	uint64_t ol_flags, fifo_addr;
 	uint16_t nb_used, i;
 	uint64_t bytes = 0;
 	uint16_t nb_tx = 0;
@@ -273,6 +273,9 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		gve_tx_clean_swr_qpl(txq);

 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		const void *mbuf_header_addr;
+		void *qpl_write_addr;
+
 		tx_pkt = *tx_pkts++;
 		ol_flags = tx_pkt->ol_flags;

@@ -306,7 +309,6 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			if (!is_fifo_avail(txq, hlen))
 				goto end_of_tx;
 		}
-		addr = (uint64_t)(tx_pkt->buf_addr) + tx_pkt->data_off;
 		fifo_addr = gve_tx_alloc_from_fifo(txq, tx_id, hlen);

 		/* For TSO, check if there's enough fifo space for data first */
@@ -317,26 +319,32 @@ gve_tx_burst_qpl(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 					goto end_of_tx;
 			}
 		}
-		if (tx_pkt->nb_segs == 1 || ol_flags & RTE_MBUF_F_TX_TCP_SEG)
-			rte_memcpy((void *)(size_t)(fifo_addr + txq->fifo_base),
-				   (void *)(size_t)addr, hlen);
-		else
-			rte_pktmbuf_read(tx_pkt, 0, hlen,
-					 (void *)(size_t)(fifo_addr + txq->fifo_base));
+
+		qpl_write_addr = (void *)(size_t)(fifo_addr + txq->fifo_base);
+		mbuf_header_addr = rte_pktmbuf_read(tx_pkt, 0, hlen, qpl_write_addr);
+
+		/* Header data is linear in the mbuf head. Copy directly. */
+		if (mbuf_header_addr != qpl_write_addr)
+			rte_memcpy(qpl_write_addr, mbuf_header_addr, hlen);
+
 		gve_tx_fill_pkt_desc(txd, tx_pkt, nb_used, hlen, fifo_addr);

 		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+			const void *mbuf_payload_addr;
+
 			tx_id = (tx_id + 1) & mask;
 			txd = &txr[tx_id];
-			addr = (uint64_t)(tx_pkt->buf_addr) + tx_pkt->data_off + hlen;
 			fifo_addr = gve_tx_alloc_from_fifo(txq, tx_id, tx_pkt->pkt_len - hlen);
-			if (tx_pkt->nb_segs == 1)
-				rte_memcpy((void *)(size_t)(fifo_addr + txq->fifo_base),
-					   (void *)(size_t)addr,
+			qpl_write_addr = (void *)(txq->fifo_base + fifo_addr);
+			mbuf_payload_addr = rte_pktmbuf_read(tx_pkt, hlen, tx_pkt->pkt_len - hlen,
+							     qpl_write_addr);
+
+			/* Payload data is contiguous. Take the offset from the
+			 * read request and copy from there.
+			 */
+			if (mbuf_payload_addr != qpl_write_addr)
+				rte_memcpy(qpl_write_addr, mbuf_payload_addr,
 					   tx_pkt->pkt_len - hlen);
-			else
-				rte_pktmbuf_read(tx_pkt, hlen, tx_pkt->pkt_len - hlen,
-						 (void *)(size_t)(fifo_addr + txq->fifo_base));

 			gve_tx_fill_seg_desc(txd, ol_flags, tx_offload,
 					     tx_pkt->pkt_len - hlen, fifo_addr);
--
2.55.0.rc0.799.gd6f94ed593-goog


  parent reply	other threads:[~2026-07-03 13:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 13:12 [PATCH v2 0/9] Stability fixes for GVE Joshua Washington
2026-07-03 13:12 ` [PATCH v2 1/9] net/gve: clear out shared memory region for stats report Joshua Washington
2026-07-03 13:12 ` [PATCH v2 2/9] net/gve: delay adding mbuf head to software ring Joshua Washington
2026-07-03 13:13 ` Joshua Washington [this message]
2026-07-03 13:13 ` [PATCH v2 4/9] net/gve: validate buf ID before processing Rx packet Joshua Washington
2026-07-03 13:13 ` [PATCH v2 5/9] net/gve: set mbuf to null in software ring after use Joshua Washington
2026-07-03 13:13 ` [PATCH v2 6/9] net/gve: free ctx mbuf if packet dropped after first segment Joshua Washington
2026-07-03 13:13 ` [PATCH v2 7/9] net/gve: increase range of DMA memzone ids to 64 bits Joshua Washington
2026-07-03 13:13 ` [PATCH v2 8/9] net/gve: don't reset ring size bounds to default on reset Joshua Washington
2026-07-03 13:13 ` [PATCH v2 9/9] net/gve: restrict max ring size in GQ QPL to 2K Joshua Washington
2026-07-03 14:27 ` [PATCH v2 0/9] Stability fixes for GVE Stephen Hemminger
2026-07-07 16:02   ` Joshua Washington
2026-07-07 16:10     ` David Marchand
2026-07-07 16:36       ` Joshua Washington
2026-07-07 16:40     ` Bruce Richardson
2026-07-07 16:40 ` [PATCH v3 " Joshua Washington
2026-07-07 16:40   ` [PATCH v3 1/9] net/gve: clear out shared memory region for stats report Joshua Washington
2026-07-07 16:40   ` [PATCH v3 2/9] net/gve: delay adding mbuf head to software ring Joshua Washington
2026-07-07 16:40   ` [PATCH v3 3/9] net/gve: copy data to QPL buffer when mbuf read does not Joshua Washington
2026-07-07 16:40   ` [PATCH v3 4/9] net/gve: validate buf ID before processing Rx packet Joshua Washington
2026-07-07 16:40   ` [PATCH v3 5/9] net/gve: set mbuf to null in software ring after use Joshua Washington
2026-07-07 16:40   ` [PATCH v3 6/9] net/gve: free ctx mbuf if packet dropped after first segment Joshua Washington
2026-07-07 16:40   ` [PATCH v3 7/9] net/gve: increase range of DMA memzone ids to 64 bits Joshua Washington
2026-07-07 16:40   ` [PATCH v3 8/9] net/gve: don't reset ring size bounds to default on reset Joshua Washington
2026-07-07 16:40   ` [PATCH v3 9/9] net/gve: restrict max ring size in GQ QPL to 2K Joshua Washington
2026-07-07 22:13     ` Joshua Washington

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=20260703131308.2507403-4-joshwash@google.com \
    --to=joshwash@google.com \
    --cc=dev@dpdk.org \
    --cc=jeroendb@google.com \
    --cc=jtranoleary@google.com \
    --cc=junfengg@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=xiaoyun.li@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.