From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH v3 6/7] test: increase gap in pcapng test
Date: Sun, 11 Jan 2026 20:50:19 -0800 [thread overview]
Message-ID: <20260112045359.142999-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20260112045359.142999-1-stephen@networkplumber.org>
Want to make sure that test takes long enough that 32 bit
counter wraps around.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_pcapng.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 6e3df17525..f93bbb26ac 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -27,7 +27,6 @@
#define TOTAL_PACKETS 4096
#define MAX_BURST 64
-#define MAX_GAP_US 100000
#define DUMMY_MBUF_NUM 2
static struct rte_mempool *mp;
@@ -175,7 +174,7 @@ test_setup(void)
}
static int
-fill_pcapng_file(rte_pcapng_t *pcapng, unsigned int num_packets)
+fill_pcapng_file(rte_pcapng_t *pcapng)
{
struct dummy_mbuf mbfs;
struct rte_mbuf *orig;
@@ -190,11 +189,18 @@ fill_pcapng_file(rte_pcapng_t *pcapng, unsigned int num_packets)
"Please collect your free cache miss.",
"Lockless and fearless - that’s how we roll in userspace."
};
+ /* How many microseconds does it take TSC to wrap around 32 bits */
+ const unsigned wrap_us
+ = (US_PER_S * (uint64_t)UINT32_MAX) / rte_get_tsc_hz();
+
+ /* Want overall test to take to wraparound at least twice. */
+ const unsigned int avg_gap = (2 * wrap_us)
+ / (TOTAL_PACKETS / (MAX_BURST / 2));
mbuf1_prepare(&mbfs);
orig = &mbfs.mb[0];
- for (count = 0; count < num_packets; count += burst_size) {
+ for (count = 0; count < TOTAL_PACKETS; count += burst_size) {
struct rte_mbuf *clones[MAX_BURST];
unsigned int i;
@@ -230,8 +236,7 @@ fill_pcapng_file(rte_pcapng_t *pcapng, unsigned int num_packets)
return -1;
}
- /* Leave a small gap between packets to test for time wrap */
- usleep(rte_rand_max(MAX_GAP_US));
+ rte_delay_us_block(rte_rand_max(2 * avg_gap));
}
return count;
@@ -468,7 +473,7 @@ test_write_packets(void)
goto fail;
}
- count = fill_pcapng_file(pcapng, TOTAL_PACKETS);
+ count = fill_pcapng_file(pcapng);
if (count < 0)
goto fail;
--
2.51.0
next prev parent reply other threads:[~2026-01-12 4:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 5:12 [RFC] pcapng: improve performance of timestamping Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 0/6] pcapng: timestamping and comment fixes Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 1/6] pcapng: use alloca instead of fixed buffer Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 2/6] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 3/6] test: add more tests for comments in pcapng Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 4/6] test: vary size of packets in pcapng test Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 5/6] test: increase gap " Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 6/6] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 0/7] pcapng: fixes and improvements Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 1/7] pcapng: add length checks to string arguments Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 2/7] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 3/7] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 4/7] test: add more tests for comments in pcapng Stephen Hemminger
2026-01-12 4:50 ` [PATCH v3 5/7] test: vary size of packets in pcapng test Stephen Hemminger
2026-01-12 4:50 ` Stephen Hemminger [this message]
2026-01-12 4:50 ` [PATCH v3 7/7] pcapng: improve performance of timestamping Stephen Hemminger
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=20260112045359.142999-7-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=reshma.pattan@intel.com \
/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).