From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E46A8425DC; Thu, 21 Sep 2023 06:24:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9971402EF; Thu, 21 Sep 2023 06:24:07 +0200 (CEST) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by mails.dpdk.org (Postfix) with ESMTP id 52F47402DC for ; Thu, 21 Sep 2023 06:24:04 +0200 (CEST) Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3adba522a5dso349563b6e.2 for ; Wed, 20 Sep 2023 21:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1695270243; x=1695875043; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p0NhDTyyKLT95VSp9/es7oIgnq+8lH/taVTz4Dh8fHU=; b=EprrZGYmHBYX9323Z5S1nZ/dCz59dhHNbFSsyEt6RQv5avYinyxo+Cr3GhqXlIUhIg Dl81k85lFqp5uFa8jfYfPMr3nJn1fkZCzmFw8R4YnaFmsCw3piMM6JM6tZqgnScD7P0K BXY1334E4Jgzd1k5QAF3dGpw39DCzQK03v05UM++y2CUOcR/33FF5P95Rifw7cH/pdH2 Eob1zhrHimozo9geyBzk7PMussvcMoU2NMdB51PCRS7w62T3Ct4klZu5gpYAR7uNgry/ qR5OAJZBYv6gH1D+wU/qxyBAAGLRkJ7FIVZeNycURqLve71zg/PhtLjyRy3sh9wRp03A Zkog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695270243; x=1695875043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p0NhDTyyKLT95VSp9/es7oIgnq+8lH/taVTz4Dh8fHU=; b=pRB7q/YZKWnH4vheUbjvU6Ds1aglvkv4IMmRZ+/DLVwa0KHxmtzUhU7ATqrvJTqaOX 4dJI+8RznzRMXMr8IqNOkjkKOHmr42CzDwlh+3B4IC4UeuBv/BLYwB/G7b+pQX2i3LwV opMujmQ2/A1QW1PgNlQhh2S7ebNN/l5Yg+f/ZpEZa93NJMg7Vszd6dGu1vsA6W4jwAlu 85sDYD2z7RH2nZTDXjUuO2CIgH7UXuRObrcheke66mcWz5Hzu7mbxGAq9NAn5wbhVxgC jPvvSSHApAxAkumJXUmmf9SCd7aopnT3nb8rxQK8xJApiSoqtTyYkIIJG6izw4OEWhGx COig== X-Gm-Message-State: AOJu0YwlxfIckWNqPzlq1Hnewh9icAG+5z8JE3VcypsfLARPenobCw0i LrPErYjUK+dT/xd1R2/jmxSs8ieOZ8l8vjxjHiM= X-Google-Smtp-Source: AGHT+IGRGDos73UNISTCxdURmPpe6ERGJGUMpna5r+vUV0KDxXZQPsNJkWM7XAQFeWvPj6pI1I1CZg== X-Received: by 2002:a05:6808:182:b0:3a7:215c:e37 with SMTP id w2-20020a056808018200b003a7215c0e37mr3989356oic.59.1695270243247; Wed, 20 Sep 2023 21:24:03 -0700 (PDT) Received: from hermes.local (204-195-112-131.wavecable.com. [204.195.112.131]) by smtp.gmail.com with ESMTPSA id u5-20020aa78485000000b00690d1269691sm311946pfn.22.2023.09.20.21.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 21:24:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH 3/4] pcapng: change timestamp argument to write_stats Date: Wed, 20 Sep 2023 21:23:48 -0700 Message-Id: <20230921042349.104150-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921042349.104150-1-stephen@networkplumber.org> References: <20230921042349.104150-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.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 --- 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