DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH 3/4] pcapng: change timestamp argument to write_stats
Date: Wed, 20 Sep 2023 21:23:48 -0700	[thread overview]
Message-ID: <20230921042349.104150-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20230921042349.104150-1-stephen@networkplumber.org>

In order to cleanup the management of time base calculation,
later patch will move the calculation from pcapng to the pdump
library. One of the changes necessary is to move the timestamp
calculation in the write_stats call from the pcapng library
into the caller. Since dumpcap already does this for other timestamps
the change is rather small.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c      | 3 ++-
 app/test/test_pcapng.c  | 4 ++--
 lib/pcapng/rte_pcapng.c | 8 +++-----
 lib/pcapng/rte_pcapng.h | 5 ++++-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 37754fd06f4f..8f6ab3396cef 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -577,6 +577,7 @@ report_packet_stats(dumpcap_out_t out)
 	struct rte_pdump_stats pdump_stats;
 	struct interface *intf;
 	uint64_t ifrecv, ifdrop;
+	uint64_t timestamp = create_timestamp();
 	double percent;
 
 	fputc('\n', stderr);
@@ -590,7 +591,7 @@ report_packet_stats(dumpcap_out_t out)
 
 		if (use_pcapng)
 			rte_pcapng_write_stats(out.pcapng, intf->port, NULL,
-					       start_time, end_time,
+					       timestamp, start_time, end_time,
 					       ifrecv, ifdrop);
 
 		if (ifrecv == 0)
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index b8429a02f160..55aa2cf93666 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -173,8 +173,8 @@ test_write_stats(void)
 	ssize_t len;
 
 	/* write a statistics block */
-	len = rte_pcapng_write_stats(pcapng, port_id,
-				     NULL, 0, 0,
+	len = rte_pcapng_write_stats(pcapng, port_id, NULL,
+				     0, 0, 0,
 				     NUM_PACKETS, 0);
 	if (len <= 0) {
 		fprintf(stderr, "Write of statistics failed\n");
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 3c91fc77644a..ddce7bc87141 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -368,7 +368,7 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,
  */
 ssize_t
 rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id,
-		       const char *comment,
+		       const char *comment, uint64_t sample_time,
 		       uint64_t start_time, uint64_t end_time,
 		       uint64_t ifrecv, uint64_t ifdrop)
 {
@@ -376,7 +376,6 @@ rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id,
 	struct pcapng_option *opt;
 	uint32_t optlen, len;
 	uint8_t *buf;
-	uint64_t ns;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -425,9 +424,8 @@ rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id,
 	hdr->block_length = len;
 	hdr->interface_id = self->port_index[port_id];
 
-	ns = pcapng_tsc_to_ns(rte_get_tsc_cycles());
-	hdr->timestamp_hi = ns >> 32;
-	hdr->timestamp_lo = (uint32_t)ns;
+	hdr->timestamp_hi = sample_time >> 32;
+	hdr->timestamp_lo = (uint32_t)sample_time;
 
 	/* clone block_length after option */
 	memcpy(opt, &len, sizeof(uint32_t));
diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
index d93cc9f73ad5..1225ed5536ff 100644
--- a/lib/pcapng/rte_pcapng.h
+++ b/lib/pcapng/rte_pcapng.h
@@ -189,7 +189,9 @@ rte_pcapng_write_packets(rte_pcapng_t *self,
  * @param port
  *  The Ethernet port to report stats on.
  * @param comment
- *   Optional comment to add to statistics.
+ *  Optional comment to add to statistics.
+ * @param timestamp
+ *  Time this statistic sample refers to in nanoseconds.
  * @param start_time
  *  The time when packet capture was started in nanoseconds.
  *  Optional: can be zero if not known.
@@ -209,6 +211,7 @@ __rte_experimental
 ssize_t
 rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port,
 		       const char *comment,
+		       uint64_t timestamp,
 		       uint64_t start_time, uint64_t end_time,
 		       uint64_t ifrecv, uint64_t ifdrop);
 
-- 
2.39.2


  parent reply	other threads:[~2023-09-21  4:24 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  4:23 [PATCH 0/4] pcapng fixes Stephen Hemminger
2023-09-21  4:23 ` [PATCH 1/4] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-09-21  4:23 ` [PATCH 2/4] dumpcap: allow multiple invocations Stephen Hemminger
2023-09-21  6:22   ` Morten Brørup
2023-09-21  7:10     ` Isaac Boukris
2023-11-07  2:34     ` Stephen Hemminger
2023-09-21  4:23 ` Stephen Hemminger [this message]
2023-09-21  4:23 ` [PATCH 4/4] pcapng: move timestamp calculation into pdump Stephen Hemminger
2023-10-02  8:15   ` David Marchand
2023-10-04 17:13     ` Stephen Hemminger
2023-10-06  9:10       ` David Marchand
2023-10-06 14:59         ` Kevin Traynor
2023-10-05 23:06 ` [PATCH v2 0/4] dumpcap and pcapng fixes Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 1/4] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 2/4] dumpcap: allow multiple invocations Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 3/4] pcapng: modify timestamp calculation Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 4/4] test: cleanups to pcapng test Stephen Hemminger
2023-11-08 18:35 ` [PATCH v3 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-08 18:35   ` [PATCH v3 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09  7:34     ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09  7:50     ` Morten Brørup
2023-11-09 15:40       ` Stephen Hemminger
2023-11-09 16:00         ` Morten Brørup
2023-11-09 17:16       ` Stephen Hemminger
2023-11-09 18:22         ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-09  7:57     ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09  8:21     ` Morten Brørup
2023-11-09 15:44       ` Stephen Hemminger
2023-11-09 16:25         ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-09 17:34 ` [PATCH v4 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09 18:30     ` Morten Brørup
2023-11-09 17:34   ` [PATCH v4 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-09 19:45 ` [PATCH v5 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09 20:09     ` Morten Brørup
2023-11-09 19:45   ` [PATCH v5 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-12 14:22     ` Thomas Monjalon
2023-11-09 19:45   ` [PATCH v5 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-13 16:15 ` [PATCH v6 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-17 16:35 ` [PATCH v7 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-22 22:42   ` [PATCH v7 0/5] dumpcap and pcapng fixes Thomas Monjalon

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=20230921042349.104150-4-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).