Skip to contentSkip to conversation

app/test-pmd: use burst IO for IEEE1588 forwarding

PATCH Superseded Bruce Richardson 2 participants 6 messages Nov 18 – Nov 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/test-pmd: use burst IO for IEEE1588 forwarding

The IEEE1588 forwarder in test-pmd read a single packet at a time rather than using the burst size configuration parameter. This meant that it cannot be used with vector driver paths which require a minimum burst size for calling the Rx function.

Make the forwarding function respect the configured burst size and only process packets one at a time, not Rx them one-at-a-time.

Fixes af75078fece3 ("first public release")
---
 app/test-pmd/ieee1588fwd.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)
app/test-pmd/ieee1588fwd.c +19 -12
index afea7735c7..5b97ddc41b 100644
@@ -34,10 +34,10 @@ struct ptpv2_msg {
 /*
  * Forwarding of IEEE1588 Precise Time Protocol (PTP) packets.
  *
- * In this mode, packets are received one by one and are expected to be
- * PTP V2 L2 Ethernet frames (with the specific Ethernet type "0x88F7")
- * containing PTP "sync" messages (version 2 at offset 1, and message ID
- * 0 at offset 0).
+ * In this mode, packets are received in bursts and processed one by one.
+ * They are expected to be PTP V2 L2 Ethernet frames (with the specific
+ * Ethernet type "0x88F7") containing PTP "sync" messages (version 2 at
+ * offset 1, and message ID 0 at offset 0).
  *
  * Check that each received packet is a IEEE1588 PTP V2 packet of type
  * PTP_SYNC_MESSAGE, and that it has been identified and timestamped
@@ -90,21 +90,14 @@ port_ieee1588_tx_timestamp_check(portid_t pi)
 }
 
 static bool
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_process_packet(struct fwd_stream *fs, struct rte_mbuf *mb)
 {
-	struct rte_mbuf  *mb;
 	struct rte_ether_hdr *eth_hdr;
 	struct rte_ether_addr addr;
 	struct ptpv2_msg *ptp_hdr;
 	uint16_t eth_type;
 	uint32_t timesync_index;
 
-	/*
-	 * Receive 1 packet at a time.
-	 */
-	if (common_fwd_stream_receive(fs, &mb, 1) == 0)
-		return false;
-
 	/*
 	 * Check that the received packet is a PTP packet that was detected
 	 * by the hardware.
@@ -194,6 +187,20 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	return true;
 }
 
+static bool
+ieee1588_packet_fwd(struct fwd_stream *fs)
+{
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+	bool fwd = false;
+
+	const uint16_t nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
+	for (uint16_t i = 0; i < nb_rx; i++)
+		if (ieee1588_process_packet(fs, pkts_burst[i]))
+			fwd = true;
+
+	return fwd;
+}
+
 static int
 port_ieee1588_fwd_begin(portid_t pi)
 {
Signature · 1 line
2.55.0
#1 lore raw
Quoted 5 lines · On Wed, 18 Nov 2026 15:11:55 +0000 Bruce Richardson…

The IEEE1588 forwarder in test-pmd read a single packet at a time rather than using the burst size configuration parameter. This meant that it cannot be used with vector driver paths which require a minimum burst size for calling the Rx function.

Quoted 8 lines

Make the forwarding function respect the configured burst size and only process packets one at a time, not Rx them one-at-a-time.

Fixes af75078fece3 ("first public release")

---

More detailed AI review had pre-existing observation.

Subject: Re: [PATCH] app/test-pmd: use burst IO for IEEE1588 forwarding

Applies cleanly to main. Rx path change is correct; Tx drop path still frees the mbuf via common_fwd_stream_transmit().

Info

ieee1588_packet_fwd() returns true only if at least one packet was forwarded. Other engines (macfwd, iofwd) return true whenever nb_rx > 0, so busy-cycle accounting counts a burst of rejected packets as idle here. This matches the old single-packet behaviour, but with bursts it is simpler to follow the other engines:

	nb_rx = common_fwd_stream_receive(fs, pkts_burst,
					  nb_pkt_per_burst);
	for (i = 0; i < nb_rx; i++)
		ieee1588_process_packet(fs, pkts_burst[i]);

	return nb_rx > 0;

ieee1588_process_packet() could then return void.

#2 lore raw

PATCH v2 1/1 app/testpmd: use burst IO for IEEE1588 forwarding

In reply to Bruce Richardson

The IEEE1588 forwarder in test-pmd read a single packet at a time rather than using the burst size configuration parameter. This meant that it cannot be used with vector driver paths which require a minimum burst size for calling the Rx function.

Make the forwarding function respect the configured burst size and only process packets one at a time, not Rx them one-at-a-time.

Fixes af75078fece3 ("first public release")

---
V2: align return value from ieee_packet_fwd() with other fwd fns.

---
 app/test-pmd/ieee1588fwd.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)
app/test-pmd/ieee1588fwd.c +17 -12
index afea7735c7..57c426e819 100644
@@ -34,10 +34,10 @@ struct ptpv2_msg {
 /*
  * Forwarding of IEEE1588 Precise Time Protocol (PTP) packets.
  *
- * In this mode, packets are received one by one and are expected to be
- * PTP V2 L2 Ethernet frames (with the specific Ethernet type "0x88F7")
- * containing PTP "sync" messages (version 2 at offset 1, and message ID
- * 0 at offset 0).
+ * In this mode, packets are received in bursts and processed one by one.
+ * They are expected to be PTP V2 L2 Ethernet frames (with the specific
+ * Ethernet type "0x88F7") containing PTP "sync" messages (version 2 at
+ * offset 1, and message ID 0 at offset 0).
  *
  * Check that each received packet is a IEEE1588 PTP V2 packet of type
  * PTP_SYNC_MESSAGE, and that it has been identified and timestamped
@@ -90,21 +90,14 @@ port_ieee1588_tx_timestamp_check(portid_t pi)
 }
 
 static bool
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_process_packet(struct fwd_stream *fs, struct rte_mbuf *mb)
 {
-	struct rte_mbuf  *mb;
 	struct rte_ether_hdr *eth_hdr;
 	struct rte_ether_addr addr;
 	struct ptpv2_msg *ptp_hdr;
 	uint16_t eth_type;
 	uint32_t timesync_index;
 
-	/*
-	 * Receive 1 packet at a time.
-	 */
-	if (common_fwd_stream_receive(fs, &mb, 1) == 0)
-		return false;
-
 	/*
 	 * Check that the received packet is a PTP packet that was detected
 	 * by the hardware.
@@ -194,6 +187,18 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 	return true;
 }
 
+static bool
+ieee1588_packet_fwd(struct fwd_stream *fs)
+{
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+
+	const uint16_t nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
+	for (uint16_t i = 0; i < nb_rx; i++)
+		(void)ieee1588_process_packet(fs, pkts_burst[i]);
+
+	return nb_rx > 0;
+}
+
 static int
 port_ieee1588_fwd_begin(portid_t pi)
 {
Signature · 1 line
2.55.0
#3 lore raw

Re: [PATCH v2] app/testpmd: use burst IO for IEEE1588 forwarding

On Mon, 23 Nov 2026 12:26:26 +0000
Bruce Richardson <[email protected]> wrote:

Since only called here:

app/test-pmd/ieee1588fwd.c port_ieee1588_tx_timestamp_check(portid_t pi) · line 94

Quoted 4 lines

static bool

app/test-pmd/ieee1588fwd.c +1 -1
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_process_packet(struct fwd_stream *fs, struct rte_mbuf *mb)
 {

Make it void not bool

and drop the cast.

Quoted 8 lines
app/test-pmd/ieee1588fwd.c +8 -0
+static bool
+ieee1588_packet_fwd(struct fwd_stream *fs)
+{
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+
+	const uint16_t nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
+	for (uint16_t i = 0; i < nb_rx; i++)
+		(void)ieee1588_process_packet(fs, pkts_burst[i]);
#4 lore raw

Re: [PATCH v2] app/testpmd: use burst IO for IEEE1588 forwarding

Quoted 4 lines · Stephen Hemminger

On Mon, 23 Nov 2026 12:26:26 +0000
Bruce Richardson <[email protected]> wrote:

Since only called here:

Quoted 9 lines

app/test-pmd/ieee1588fwd.c port_ieee1588_tx_timestamp_check(portid_t pi) · line 94

Quoted 4 lines

static bool

app/test-pmd/ieee1588fwd.c +1 -1
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_process_packet(struct fwd_stream *fs, struct rte_mbuf *mb)
 {

Make it void not bool

and drop the cast.

I thought about that, and thought it best to leave it as bool to allow for any future error checking we might need. The cast can be safely dropped, but I think some form of return value might be useful from this.

Quoted 8 lines
Quoted 8 lines
app/test-pmd/ieee1588fwd.c +8 -0
+static bool
+ieee1588_packet_fwd(struct fwd_stream *fs)
+{
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+
+	const uint16_t nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);
+	for (uint16_t i = 0; i < nb_rx; i++)
+		(void)ieee1588_process_packet(fs, pkts_burst[i]);
#5 lore raw

Re: [PATCH v2] app/testpmd: use burst IO for IEEE1588 forwarding

Quoted 8 lines · On Mon, 23 Nov 2026 16:53:38 +0000 Bruce Richardson…
Quoted 8 lines

Since only called here:

app/test-pmd/ieee1588fwd.c port_ieee1588_tx_timestamp_check(portid_t pi) · line 94

Quoted 4 lines

static bool

app/test-pmd/ieee1588fwd.c +1 -1
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_process_packet(struct fwd_stream *fs, struct rte_mbuf *mb)
 {  

Make it void not bool

Quoted 6 lines
Quoted 2 lines

and drop the cast.

I thought about that, and thought it best to leave it as bool to allow for any future error checking we might need. The cast can be safely dropped, but I think some form of return value might be useful from this.

YAGNI

Since it is internal to the file, you can change API at will later to return an int or whatever suits.