DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/test: fix data length of each packet segment
@ 2023-03-05 21:07 Zhuobin Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Zhuobin Huang @ 2023-03-05 21:07 UTC (permalink / raw)
  To: dev; +Cc: cunming.liang

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.liang@intel.com

Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>
---
 .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 <luzhipeng@cestc.cn>
 Zhirun Yan <zhirun.yan@intel.com>
 Zhiwei He <zhiwei.he@intel.com>
 Zhiyong Yang <zhiyong.yang@intel.com>
+Zhuobin Huang <zobin1999@gmail.com>
 Zi Hu <huzilucky@gmail.com>
 Zijie Pan <zijie.pan@6wind.com>
 Ziyang Xuan <xuanziyang2@huawei.com>
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] app/test: fix data length of each packet segment
  2023-03-16 15:26 ` David Marchand
@ 2023-03-16 15:56   ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2023-03-16 15:56 UTC (permalink / raw)
  To: Zhuobin Huang; +Cc: dev, cunming.liang, Thomas Monjalon

On Thu, Mar 16, 2023 at 4:26 PM David Marchand
<david.marchand@redhat.com> wrote:
> On Mon, Mar 6, 2023 at 7:52 AM Zhuobin Huang <zobin1999@gmail.com> wrote:
> >
> > 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")
> >
> > Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] app/test: fix data length of each packet segment
  2023-03-06  6:51 Zhuobin Huang
@ 2023-03-16 15:26 ` David Marchand
  2023-03-16 15:56   ` David Marchand
  0 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2023-03-16 15:26 UTC (permalink / raw)
  To: Zhuobin Huang; +Cc: dev, cunming.liang, ci, Thomas Monjalon

On Mon, Mar 6, 2023 at 7:52 AM Zhuobin Huang <zobin1999@gmail.com> wrote:
>
> 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.liang@intel.com
>
> Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>

Good catch.
I am curious to know how you noticed the issue since I see no in-tree
code asking for multiseg.


For the record, to check this patch, I compiled with
-DRTE_LIBRTE_MBUF_DEBUG and a small modification:

diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index ff84d251ff..5c670ff165 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -209,7 +209,7 @@ init_traffic(struct rte_mempool *mp,
        return generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr,
                                     0, &pkt_ipv4_hdr, 1,
                                     &pkt_udp_hdr, burst_size,
-                                    PACKET_BURST_GEN_PKT_LEN, 1);
+                                    PACKET_BURST_GEN_PKT_LEN, 2);
 }

 static int


Before the fix:

DPDK_TEST=pmd_perf_autotest ./build-gcc/app/test/dpdk-test --no-huge
-m 2048  --vdev=net_null0 --vdev=net_null1
...
Generate 4096 packets @socket 0
inject 2048 packet to port 0
PANIC in rte_mbuf_sanity_check():
bad pkt_len


Cc: ci@ in general, we should have more tests run with debug/check
options enabled.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] app/test: fix data length of each packet segment
@ 2023-03-06  6:51 Zhuobin Huang
  2023-03-16 15:26 ` David Marchand
  0 siblings, 1 reply; 6+ messages in thread
From: Zhuobin Huang @ 2023-03-06  6:51 UTC (permalink / raw)
  To: dev; +Cc: cunming.liang

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.liang@intel.com

Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>
---
 .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 <luzhipeng@cestc.cn>
 Zhirun Yan <zhirun.yan@intel.com>
 Zhiwei He <zhiwei.he@intel.com>
 Zhiyong Yang <zhiyong.yang@intel.com>
+Zhuobin Huang <zobin1999@gmail.com>
 Zi Hu <huzilucky@gmail.com>
 Zijie Pan <zijie.pan@6wind.com>
 Ziyang Xuan <xuanziyang2@huawei.com>
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] app/test: fix data length of each packet segment
@ 2023-03-05 21:03 Zhuobin Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Zhuobin Huang @ 2023-03-05 21:03 UTC (permalink / raw)
  To: dev; +Cc: cunming.liang

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.liang@intel.com

Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] app/test: fix data length of each packet segment
@ 2023-03-05 20:33 Zhuobin Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Zhuobin Huang @ 2023-03-05 20:33 UTC (permalink / raw)
  To: dev; +Cc: cunming.liang

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.liang@intel.com

Signed-off-by: Zhuobin Huang <zobin1999@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-16 15:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-05 21:07 [PATCH] app/test: fix data length of each packet segment Zhuobin Huang
  -- strict thread matches above, loose matches on Subject: below --
2023-03-06  6:51 Zhuobin Huang
2023-03-16 15:26 ` David Marchand
2023-03-16 15:56   ` David Marchand
2023-03-05 21:03 Zhuobin Huang
2023-03-05 20:33 Zhuobin Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).