[PATCH v9 4/5] test: support larger packet sizes in burst generator
Stephen Hemminger
stephen at networkplumber.org
Thu Jan 29 21:25:30 CET 2026
Widen the parameter types in the packet burst generator functions
to support larger values:
- pkt_len: uint8_t to uint16_t for larger packet sizes
- nb_pkt_segs: uint8_t to uint16_t to match mbuf nb_segs
- nb_pkt_per_burst: int to uint16_t to match tx_burst limit
Remove the incorrect RTE_MAX_SEGS_PER_PKT macro that claimed
nb_segs is 8-bit when it is actually 16-bit.
Add validation to prevent division by zero when nb_pkt_segs is 0.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
app/test/packet_burst_generator.c | 34 ++++++++++++++++++-------------
app/test/packet_burst_generator.h | 4 ++--
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c
index 4c17737739..346c69e6ce 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -205,24 +205,24 @@ initialize_ipv4_header_proto(struct rte_ipv4_hdr *ip_hdr, uint32_t src_addr,
return pkt_len;
}
-/*
- * The maximum number of segments per packet is used when creating
- * scattered transmit packets composed of a list of mbufs.
- */
-#define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */
-
int
generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct rte_ether_hdr *eth_hdr, uint8_t vlan_enabled,
void *ip_hdr, uint8_t ipv4, struct rte_udp_hdr *udp_hdr,
- int nb_pkt_per_burst, uint8_t pkt_len, uint8_t nb_pkt_segs)
+ uint16_t nb_pkt_per_burst, uint16_t pkt_len, uint16_t nb_pkt_segs)
{
- const uint8_t pkt_seg_data_len = pkt_len / nb_pkt_segs;
+ int i, nb_pkt = 0;
+ size_t eth_hdr_size;
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
- size_t eth_hdr_size;
- int i, nb_pkt = 0;
+ uint16_t pkt_seg_data_len;
+
+ if (nb_pkt_segs == 0)
+ return -1;
+
+ /* Calculate per-segment data length */
+ pkt_seg_data_len = pkt_len / nb_pkt_segs;
for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
pkt = rte_pktmbuf_alloc(mp);
@@ -300,13 +300,19 @@ generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf **pkts_burst, struct rte_ether_hdr *eth_hdr,
uint8_t vlan_enabled, void *ip_hdr,
uint8_t ipv4, uint8_t proto, void *proto_hdr,
- int nb_pkt_per_burst, uint8_t pkt_len, uint8_t nb_pkt_segs)
+ uint16_t nb_pkt_per_burst, uint16_t pkt_len, uint16_t nb_pkt_segs)
{
- const uint8_t pkt_seg_data_len = pkt_len / nb_pkt_segs;
+ int i, nb_pkt = 0;
+ size_t eth_hdr_size;
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
- size_t eth_hdr_size;
- int i, nb_pkt = 0;
+ uint16_t pkt_seg_data_len;
+
+ if (nb_pkt_segs == 0)
+ return -1;
+
+ /* Calculate per-segment data length */
+ pkt_seg_data_len = pkt_len / nb_pkt_segs;
for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
pkt = rte_pktmbuf_alloc(mp);
diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h
index cce41bcd0f..bc16764e77 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -62,14 +62,14 @@ int
generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct rte_ether_hdr *eth_hdr, uint8_t vlan_enabled,
void *ip_hdr, uint8_t ipv4, struct rte_udp_hdr *udp_hdr,
- int nb_pkt_per_burst, uint8_t pkt_len, uint8_t nb_pkt_segs);
+ uint16_t nb_pkt_per_burst, uint16_t pkt_len, uint16_t nb_pkt_segs);
int
generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf **pkts_burst, struct rte_ether_hdr *eth_hdr,
uint8_t vlan_enabled, void *ip_hdr,
uint8_t ipv4, uint8_t proto, void *proto_hdr,
- int nb_pkt_per_burst, uint8_t pkt_len, uint8_t nb_pkt_segs);
+ uint16_t nb_pkt_per_burst, uint16_t pkt_len, uint16_t nb_pkt_segs);
#ifdef __cplusplus
}
--
2.51.0
More information about the dev
mailing list