[PATCH v10 06/19] net/pcap: use bulk free

Stephen Hemminger
2026-01-30T01:14:33Z

Using function rte_pktmbuf_free_bulk is marginally faster here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/pcap/pcap_ethdev.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 806451dc99..61ba50e356 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -423,8 +423,8 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)

num_tx++;
tx_bytes += caplen;
- rte_pktmbuf_free(mbuf);
}
+ rte_pktmbuf_free_bulk(bufs, nb_pkts);

/*
* Since there's no place to hook a callback when the forwarding
@@ -449,13 +449,10 @@ eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
uint32_t tx_bytes = 0;
struct pcap_tx_queue *tx_queue = queue;

- if (unlikely(nb_pkts == 0))
- return 0;
-
- for (i = 0; i < nb_pkts; i++) {
+ for (i = 0; i < nb_pkts; i++)
tx_bytes += bufs[i]->pkt_len;
- rte_pktmbuf_free(bufs[i]);
- }
+
+ rte_pktmbuf_free_bulk(bufs, nb_pkts);

tx_queue->tx_stat.pkts += nb_pkts;
tx_queue->tx_stat.bytes += tx_bytes;
@@ -494,7 +491,6 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
PMD_LOG(ERR,
"Dropping multi segment PCAP packet. Size (%zd) > max size (%zd).",
len, sizeof(temp_data));
- rte_pktmbuf_free(mbuf);
continue;
}

@@ -508,9 +504,10 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
break;
num_tx++;
tx_bytes += len;
- rte_pktmbuf_free(mbuf);
}

+ rte_pktmbuf_free_bulk(bufs, nb_pkts);
+
tx_queue->tx_stat.pkts += num_tx;
tx_queue->tx_stat.bytes += tx_bytes;
tx_queue->tx_stat.err_pkts += i - num_tx;
--
2.51.0