[PATCH] app/test: fix data length of each packet segment

2023-03-05 Thread Zhuobin Huang
Assign correct data length to each segments according
to the given pkt_len and nb_pkt_segs, instead of
using pkt_len as the data_len of every packet segment

Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
Cc: cunming.li...@intel.com

Signed-off-by: Zhuobin Huang 
---
 app/test/packet_burst_generator.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 6b42b9b83b..c2e51a3bf1 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -350,6 +350,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
 
+   const uint8_t 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);
if (pkt == NULL) {
@@ -359,7 +361,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
break;
}
 
-   pkt->data_len = pkt_len;
+   pkt->data_len = pkt_seg_data_len;
pkt_seg = pkt;
for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
@@ -369,7 +371,10 @@ generate_packet_burst_proto(struct rte_mempool *mp,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = pkt_len;
+   if(i != nb_pkt_segs - 1)
+   pkt_seg->data_len = pkt_seg_data_len;
+   else
+   pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
}
pkt_seg->next = NULL; /* Last segment of packet. */
 
-- 
2.34.1



[PATCH v2] app/test: fix data length of each packet segment

2023-03-05 Thread Zhuobin Huang
v2: 
* fix code format

Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
Cc: cunming.li...@intel.com

Signed-off-by: Zhuobin Huang 
---
 ...x-data-length-of-each-packet-segment.patch | 54 +++
 app/test/packet_burst_generator.c |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 0001-app-test-fix-data-length-of-each-packet-segment.patch

diff --git a/0001-app-test-fix-data-length-of-each-packet-segment.patch 
b/0001-app-test-fix-data-length-of-each-packet-segment.patch
new file mode 100644
index 00..aa52bb2ae2
--- /dev/null
+++ b/0001-app-test-fix-data-length-of-each-packet-segment.patch
@@ -0,0 +1,54 @@
+From 7b3827259bded81127fb33572868815bd53ad564 Mon Sep 17 00:00:00 2001
+From: Zhuobin Huang 
+Date: Mon, 6 Mar 2023 04:13:20 +0800
+Subject: [PATCH] app/test: fix data length of each packet segment
+
+Assign correct data length to each segments according
+to the given pkt_len and nb_pkt_segs, instead of
+using pkt_len as the data_len of every packet segment
+
+Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
+Cc: cunming.li...@intel.com
+
+Signed-off-by: Zhuobin Huang 
+---
+ app/test/packet_burst_generator.c | 9 +++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
+index 6b42b9b83b..c2e51a3bf1 100644
+--- a/app/test/packet_burst_generator.c
 b/app/test/packet_burst_generator.c
+@@ -350,6 +350,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,
+   struct rte_mbuf *pkt_seg;
+   struct rte_mbuf *pkt;
+ 
++  const uint8_t 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);
+   if (pkt == NULL) {
+@@ -359,7 +361,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
+   break;
+   }
+ 
+-  pkt->data_len = pkt_len;
++  pkt->data_len = pkt_seg_data_len;
+   pkt_seg = pkt;
+   for (i = 1; i < nb_pkt_segs; i++) {
+   pkt_seg->next = rte_pktmbuf_alloc(mp);
+@@ -369,7 +371,10 @@ generate_packet_burst_proto(struct rte_mempool *mp,
+   goto nomore_mbuf;
+   }
+   pkt_seg = pkt_seg->next;
+-  pkt_seg->data_len = pkt_len;
++  if(i != nb_pkt_segs - 1)
++  pkt_seg->data_len = pkt_seg_data_len;
++  else
++  pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
+   }
+   pkt_seg->next = NULL; /* Last segment of packet. */
+ 
+-- 
+2.34.1
+
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index c2e51a3bf1..940f6ddde8 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -371,7 +371,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   if(i != nb_pkt_segs - 1)
+   if (i != nb_pkt_segs - 1)
pkt_seg->data_len = pkt_seg_data_len;
else
pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
-- 
2.34.1



[PATCH] app/test: fix data length of each packet segment

2023-03-05 Thread Zhuobin Huang
Assign correct data length to each segments according
to the given pkt_len and nb_pkt_segs, instead of
using pkt_len as the data_len of every packet segment

Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
Cc: cunming.li...@intel.com

Signed-off-by: Zhuobin Huang 
---
 app/test/packet_burst_generator.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 6b42b9b83b..940f6ddde8 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -350,6 +350,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
 
+   const uint8_t 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);
if (pkt == NULL) {
@@ -359,7 +361,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
break;
}
 
-   pkt->data_len = pkt_len;
+   pkt->data_len = pkt_seg_data_len;
pkt_seg = pkt;
for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
@@ -369,7 +371,10 @@ generate_packet_burst_proto(struct rte_mempool *mp,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = pkt_len;
+   if (i != nb_pkt_segs - 1)
+   pkt_seg->data_len = pkt_seg_data_len;
+   else
+   pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
}
pkt_seg->next = NULL; /* Last segment of packet. */
 
-- 
2.34.1



[PATCH] app/test: fix data length of each packet segment

2023-03-05 Thread Zhuobin Huang
Assign correct data length to each segments according
to the given pkt_len and nb_pkt_segs, instead of
using pkt_len as the data_len of every packet segment

Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
Cc: cunming.li...@intel.com

Signed-off-by: Zhuobin Huang 
---
 .mailmap  | 1 +
 app/test/packet_burst_generator.c | 9 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/.mailmap b/.mailmap
index a9f4f28fba..9128fde9c5 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1576,6 +1576,7 @@ Zhipeng Lu 
 Zhirun Yan 
 Zhiwei He 
 Zhiyong Yang 
+Zhuobin Huang 
 Zi Hu 
 Zijie Pan 
 Ziyang Xuan 
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 6b42b9b83b..940f6ddde8 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -350,6 +350,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
 
+   const uint8_t 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);
if (pkt == NULL) {
@@ -359,7 +361,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
break;
}
 
-   pkt->data_len = pkt_len;
+   pkt->data_len = pkt_seg_data_len;
pkt_seg = pkt;
for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
@@ -369,7 +371,10 @@ generate_packet_burst_proto(struct rte_mempool *mp,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = pkt_len;
+   if (i != nb_pkt_segs - 1)
+   pkt_seg->data_len = pkt_seg_data_len;
+   else
+   pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
}
pkt_seg->next = NULL; /* Last segment of packet. */
 
-- 
2.34.1



[PATCH] app/test: fix data length of each packet segment

2023-03-05 Thread Zhuobin Huang
Assign correct data length to each segments according
to the given pkt_len and nb_pkt_segs, instead of
using pkt_len as the data_len of every packet segment

Fixes: a9c9e9698d5e ("app/test: allow to create packets of different sizes")
Cc: cunming.li...@intel.com

Signed-off-by: Zhuobin Huang 
---
 .mailmap  |  1 +
 app/test/packet_burst_generator.c | 18 ++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/.mailmap b/.mailmap
index a9f4f28fba..9128fde9c5 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1576,6 +1576,7 @@ Zhipeng Lu 
 Zhirun Yan 
 Zhiwei He 
 Zhiyong Yang 
+Zhuobin Huang 
 Zi Hu 
 Zijie Pan 
 Ziyang Xuan 
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 6b42b9b83b..898b717073 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -269,6 +269,8 @@ generate_packet_burst(struct rte_mempool *mp, struct 
rte_mbuf **pkts_burst,
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
 
+   const uint8_t 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);
if (pkt == NULL) {
@@ -278,7 +280,7 @@ generate_packet_burst(struct rte_mempool *mp, struct 
rte_mbuf **pkts_burst,
break;
}
 
-   pkt->data_len = pkt_len;
+   pkt->data_len = pkt_seg_data_len;
pkt_seg = pkt;
for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
@@ -288,7 +290,10 @@ generate_packet_burst(struct rte_mempool *mp, struct 
rte_mbuf **pkts_burst,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = pkt_len;
+   if (i != nb_pkt_segs - 1)
+   pkt_seg->data_len = pkt_seg_data_len;
+   else
+   pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
}
pkt_seg->next = NULL; /* Last segment of packet. */
 
@@ -350,6 +355,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,
struct rte_mbuf *pkt_seg;
struct rte_mbuf *pkt;
 
+   const uint8_t 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);
if (pkt == NULL) {
@@ -359,7 +366,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,
break;
}
 
-   pkt->data_len = pkt_len;
+   pkt->data_len = pkt_seg_data_len;
pkt_seg = pkt;
for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
@@ -369,7 +376,10 @@ generate_packet_burst_proto(struct rte_mempool *mp,
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = pkt_len;
+   if (i != nb_pkt_segs - 1)
+   pkt_seg->data_len = pkt_seg_data_len;
+   else
+   pkt_seg->data_len = pkt_seg_data_len + pkt_len 
% nb_pkt_segs;
}
pkt_seg->next = NULL; /* Last segment of packet. */
 
-- 
2.34.1