From: Martin Spinler <[email protected]> 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 <[email protected]> --- 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

