@@ -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)
@@ -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");
@@ -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));
@@ -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);