DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: "Dawid Wesierski" <dawid.wesierski@intel.com>, <dev@dpdk.org>,
	<thomas@monjalon.net>,
	"Marek Kasiewicz" <marek.kasiewicz@intel.com>
Subject: Re: [PATCH v3 1/1] pcapng: add user-supplied timestamp support
Date: Thu, 18 Jun 2026 11:51:21 -0700	[thread overview]
Message-ID: <20260618115121.4b4766f4@phoenix.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F65924@smartserver.smartshare.dk>

On Thu, 18 Jun 2026 18:45:19 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:

> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Thursday, 18 June 2026 17.23
> > 
> > On Thu, 18 Jun 2026 10:38:15 -0400
> > Dawid Wesierski <dawid.wesierski@intel.com> wrote:
> >   
> > > + * @param ts
> > > + *   Packet timestamp in nanoseconds since the Unix epoch. If zero,  
> > the  
> > > + *   current TSC is captured and converted to epoch ns by
> > > + *   rte_pcapng_write_packets() when the packet is written.
> > >   *  
> > 
> > It might help users if a helper rte_tsc_to_epoch() was exposed.  
> 
> +1
> 
> Please note that such a helper would need to compensate for rte_rdtsc() drift.
> 
> Simplified:
> 
> int64_t rte_tsc_to_ns(tsc)
> {
>   struct timespec ts = clock_gettime(CLOCK_REALTIME);
>   int64_t now_ns = ts.tv_sec * NS_PER_S + ts.tv_nsec;
>   int64_t now_tsc = rte_rdtsc();
>   int64_t diff_tsc = tsc - tsc_now;
>   return now_ns + diff_tsc * NS_PER_S / rte_get_tsc_hz();
> }
> 
> A performance optimized version would take "now_ns" and "now_tsc" as parameters.
> And with "now_ns" passed as a parameter, the function also works with other clocks, such as CLOCK_MONOTONIC.
> 
> Also see this discussion on the Grout mailing list:
> https://inbox.dpdk.org/grout/98CBD80474FA8B44BF855DF32C47DC35F6590E@smartserver.smartshare.dk/T/#m465a04ca2e8219612dd9c3efb4198d23d5813422
> 
> 

Inside rte_pcapng is already all the necessary state and setup.
Just not exposed to user. It does it without divide operation

  reply	other threads:[~2026-06-18 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 14:38 [PATCH v3 1/1] pcapng: add user-supplied timestamp support Dawid Wesierski
2026-06-18 15:22 ` Stephen Hemminger
2026-06-18 16:45   ` Morten Brørup
2026-06-18 18:51     ` Stephen Hemminger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-08 16:40 [PATCH 0/7] intel network and pcapng updates Dawid Wesierski
2026-06-18 14:44 ` [PATCH v3 1/1] pcapng: add user-supplied timestamp support Dawid Wesierski
2026-06-18 15:20   ` 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=20260618115121.4b4766f4@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dawid.wesierski@intel.com \
    --cc=dev@dpdk.org \
    --cc=marek.kasiewicz@intel.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /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