DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhuobin Huang <zobin1999@gmail.com>
To: dev@dpdk.org
Cc: cunming.liang@intel.com
Subject: [PATCH] app/test: fix data length of each packet segment
Date: Mon,  6 Mar 2023 14:51:56 +0800	[thread overview]
Message-ID: <20230306065156.3759-1-zobin1999@gmail.com> (raw)

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


             reply	other threads:[~2023-03-06  6:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  6:51 Zhuobin Huang [this message]
2023-03-16 15:26 ` David Marchand
2023-03-16 15:56   ` David Marchand
  -- strict thread matches above, loose matches on Subject: below --
2023-03-05 21:07 Zhuobin Huang
2023-03-05 21:03 Zhuobin Huang
2023-03-05 20:33 Zhuobin Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230306065156.3759-1-zobin1999@gmail.com \
    --to=zobin1999@gmail.com \
    --cc=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).