public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: spinler@cesnet.cz
To: dev@dpdk.org
Cc: Martin Spinler <spinler@cesnet.cz>
Subject: [PATCH v4 3/6] net/nfb: update timestamp calculation to meaningful value
Date: Wed, 21 Jan 2026 18:01:17 +0100	[thread overview]
Message-ID: <20260121170120.268553-4-spinler@cesnet.cz> (raw)
In-Reply-To: <20260121170120.268553-1-spinler@cesnet.cz>

From: Martin Spinler <spinler@cesnet.cz>

The resulting timestamp wasn't monotonically increasing value.

Now the timestamp is value in nanoseconds (Unix epoch).

Unfortunately there's currently no safe mechanism in nfb-framework
to get ticks from hardware to implement read_clock function.

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
 doc/guides/nics/nfb.rst  |  6 ++----
 drivers/net/nfb/nfb_rx.h | 13 +++++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/doc/guides/nics/nfb.rst b/doc/guides/nics/nfb.rst
index 96aaf64440..a9b4049654 100644
--- a/doc/guides/nics/nfb.rst
+++ b/doc/guides/nics/nfb.rst
@@ -64,10 +64,8 @@ products). The standard `RTE_ETH_RX_OFFLOAD_TIMESTAMP` flag can be used for this
 When the timestamps are enabled, a timestamp validity flag is set in the MBUFs
 containing received frames and timestamp is inserted into the `rte_mbuf` struct.
 
-The timestamp is an `uint64_t` field. Its lower 32 bits represent *seconds* portion of the timestamp
-(number of seconds elapsed since 1.1.1970 00:00:00 UTC) and its higher 32 bits represent
-*nanosecond* portion of the timestamp (number of nanoseconds elapsed since the beginning of the
-second in the *seconds* portion.
+The timestamp is an `uint64_t` field and holds the number of nanoseconds
+elapsed since 1.1.1970 00:00:00 UTC.
 
 
 Using the NFB PMD
diff --git a/drivers/net/nfb/nfb_rx.h b/drivers/net/nfb/nfb_rx.h
index 12769841ae..67b3b00e2a 100644
--- a/drivers/net/nfb/nfb_rx.h
+++ b/drivers/net/nfb/nfb_rx.h
@@ -13,6 +13,7 @@
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 #include <rte_ethdev.h>
+#include <rte_time.h>
 
 #include "nfb.h"
 
@@ -202,15 +203,15 @@ nfb_eth_ndp_rx(void *queue,
 			if (nfb_timestamp_dynfield_offset >= 0) {
 				rte_mbuf_timestamp_t timestamp;
 
-				/* nanoseconds */
-				timestamp =
-					rte_le_to_cpu_32(*((uint32_t *)
-					(packets[i].header + 4)));
-				timestamp <<= 32;
 				/* seconds */
-				timestamp |=
+				timestamp =
 					rte_le_to_cpu_32(*((uint32_t *)
 					(packets[i].header + 8)));
+				timestamp *= NSEC_PER_SEC;
+				/* nanoseconds */
+				timestamp +=
+					rte_le_to_cpu_32(*((uint32_t *)
+					(packets[i].header + 4)));
 				*nfb_timestamp_dynfield(mbuf) = timestamp;
 				mbuf->ol_flags |= nfb_timestamp_rx_dynflag;
 			}
-- 
2.52.0


  parent reply	other threads:[~2026-01-21 17:02 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 14:01 [PATCH 0/6] spinler
2026-01-15 14:01 ` [PATCH 1/6] net/nfb: use constant values for max Rx/Tx queues count spinler
2026-01-15 14:01 ` [PATCH 2/6] net/nfb: fix bad pointer access in queue stats spinler
2026-01-15 14:01 ` [PATCH 3/6] net/nfb: update timestamp calculation to meaningful value spinler
2026-01-15 14:01 ` [PATCH 4/6] net/nfb: use process private variable for internal data spinler
2026-01-15 14:01 ` [PATCH 5/6] net/nfb: release allocated resources correctly spinler
2026-01-15 14:01 ` [PATCH 6/6] net/nfb: stop only started queues in fail path spinler
2026-01-15 14:40 ` [PATCH v2 0/6] net/nfb: code cleanup spinler
2026-01-15 14:40   ` [PATCH v2 1/6] net/nfb: use constant values for max Rx/Tx queues count spinler
2026-01-15 14:40   ` [PATCH v2 2/6] net/nfb: fix bad pointer access in queue stats spinler
2026-01-15 14:40   ` [PATCH v2 3/6] net/nfb: update timestamp calculation to meaningful value spinler
2026-01-15 14:40   ` [PATCH v2 4/6] net/nfb: use process private variable for internal data spinler
2026-01-15 14:40   ` [PATCH v2 5/6] net/nfb: release allocated resources correctly spinler
2026-01-15 14:40   ` [PATCH v2 6/6] net/nfb: stop only started queues in fail path spinler
2026-01-16  5:48   ` [PATCH v2 0/6] net/nfb: code cleanup Stephen Hemminger
2026-01-16  9:42     ` Martin Spinler
2026-01-16 17:39       ` Stephen Hemminger
2026-01-16 15:20 ` spinler
2026-01-16 15:20   ` [PATCH v3 1/6] net/nfb: use constant values for max Rx/Tx queues count spinler
2026-02-02 17:47     ` Stephen Hemminger
2026-02-02 18:58       ` Martin Špinler
2026-01-16 15:20   ` [PATCH v3 2/6] net/nfb: fix bad pointer access in queue stats spinler
2026-01-16 15:20   ` [PATCH v3 3/6] net/nfb: update timestamp calculation to meaningful value spinler
2026-01-16 15:20   ` [PATCH v3 4/6] net/nfb: use process private variable for internal data spinler
2026-01-20  0:13     ` Stephen Hemminger
2026-01-20 14:13       ` Martin Spinler
2026-01-20 16:11         ` Stephen Hemminger
2026-01-16 15:20   ` [PATCH v3 5/6] net/nfb: release allocated resources correctly spinler
2026-01-20  0:10     ` Stephen Hemminger
2026-01-20 14:14       ` Martin Spinler
2026-01-16 15:20   ` [PATCH v3 6/6] net/nfb: stop only started queues in fail path spinler
2026-01-20  0:09     ` Stephen Hemminger
2026-01-20 14:14       ` Martin Spinler
2026-01-16 15:22 ` [PATCH v3 0/6] net/nfb: code cleanup spinler
2026-01-21  4:57   ` Stephen Hemminger
2026-01-21 17:01 ` [PATCH v4 " spinler
2026-01-21 17:01   ` [PATCH v4 1/6] net/nfb: use constant values for max Rx/Tx queues count spinler
2026-01-21 17:01   ` [PATCH v4 2/6] net/nfb: fix bad pointer access in queue stats spinler
2026-01-21 17:01   ` spinler [this message]
2026-01-21 17:33     ` [PATCH v4 3/6] net/nfb: update timestamp calculation to meaningful value Stephen Hemminger
2026-01-27  8:12       ` Martin Spinler
2026-01-27  0:34     ` Stephen Hemminger
2026-01-27  8:16       ` Martin Spinler
2026-01-21 17:01   ` [PATCH v4 4/6] net/nfb: use process private variable for internal data spinler
2026-01-21 17:01   ` [PATCH v4 5/6] net/nfb: release allocated resources correctly spinler
2026-01-21 17:01   ` [PATCH v4 6/6] net/nfb: stop only started queues in fail path spinler
2026-01-21 17:35   ` [PATCH v4 0/6] net/nfb: code cleanup Stephen Hemminger
2026-02-02 19:33 ` [PATCH v5 " spinler
2026-02-02 19:33   ` [PATCH v5 1/6] net/nfb: use constant values for max Rx/Tx queues count spinler
2026-02-02 19:33   ` [PATCH v5 2/6] net/nfb: fix bad pointer access in queue stats spinler
2026-02-10  0:51     ` Stephen Hemminger
2026-02-02 19:33   ` [PATCH v5 3/6] net/nfb: update timestamp calculation to meaningful value spinler
2026-02-02 19:33   ` [PATCH v5 4/6] net/nfb: use process private variable for internal data spinler
2026-02-02 19:33   ` [PATCH v5 5/6] net/nfb: release allocated resources correctly spinler
2026-02-10  0:52     ` Stephen Hemminger
2026-02-02 19:33   ` [PATCH v5 6/6] net/nfb: stop only started queues in fail path spinler
2026-02-03  1:50   ` [PATCH v5 0/6] net/nfb: code cleanup Stephen Hemminger
2026-02-03  6:36     ` Martin Spinler

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=20260121170120.268553-4-spinler@cesnet.cz \
    --to=spinler@cesnet.cz \
    --cc=dev@dpdk.org \
    /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