[dpdk-dev] [PATCH] drivers/net/nfb: add timestamp support
Rastislav Cernay
cernay at netcope.com
Thu Jun 13 14:05:09 CEST 2019
From: Rastislav Cernay <cernay at netcope.com>
This patch adds timestamping support to nfb driver.
Signed-off-by: Rastislav Cernay <cernay at netcope.com>
---
config/common_base | 1 +
doc/guides/nics/nfb.rst | 22 ++++++++++++++++++++++
drivers/net/nfb/Makefile | 5 +++++
drivers/net/nfb/meson.build | 4 ++++
drivers/net/nfb/nfb_rx.h | 13 +++++++++++++
5 files changed, 45 insertions(+)
diff --git a/config/common_base b/config/common_base
index 6f19ad5..f533136 100644
--- a/config/common_base
+++ b/config/common_base
@@ -383,6 +383,7 @@ CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
# Compile software PMD backed by NFB device
#
CONFIG_RTE_LIBRTE_NFB_PMD=n
+CONFIG_RTE_LIBRTE_NFB_HW_TIMESTAMP=n
#
# Compile burst-oriented Cavium Thunderx NICVF PMD driver
diff --git a/doc/guides/nics/nfb.rst b/doc/guides/nics/nfb.rst
index 8df76c0..a172f9a 100644
--- a/doc/guides/nics/nfb.rst
+++ b/doc/guides/nics/nfb.rst
@@ -69,6 +69,10 @@ These configuration options can be modified before compilation in the
Value **y** enables compilation of nfb PMD.
+* ``CONFIG_RTE_LIBRTE_NFB_HW_TIMESTAMP`` default value: **n**
+
+ Value **y** enables HW packet timestamping.
+
Using the NFB PMD
----------------------
@@ -142,3 +146,21 @@ Example output:
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX RS bit threshold=0 - TXQ flags=0x0
testpmd>
+
+Timestamp
+----------------
+
+Timestamping needs to be enabled during compile time, as there is no way
+to check whether a timestamping unit is runnig during run time.
+
+While enabled, a validity flag of a timestamp is set and a timestamp data is inserted into a rte_mbuf struct.
+The timestamping unit still needs to be enabled separately according to the documentation of NFB products.
+
+Timestamp is in uint64_t field where upper 32 bits represents nanoseconds and lower 32 bits seconds.
+
+Nanoseconds contains the nanosecond part of the timestamp representing the
+time of frame receipt on physical network interface. It is the number of nanoseconds elapsed
+since the beginning of the second in Timestamp (seconds) field.
+
+Seconds contains the second part of the timestamp representing the time of frame
+receipt on physical network interface.
\ No newline at end of file
diff --git a/drivers/net/nfb/Makefile b/drivers/net/nfb/Makefile
index a84b423..a9c4607 100644
--- a/drivers/net/nfb/Makefile
+++ b/drivers/net/nfb/Makefile
@@ -16,6 +16,11 @@ INCLUDES :=-I$(SRCDIR)
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
CFLAGS += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --cflags netcope-common)
+
+ifeq ($(CONFIG_RTE_LIBRTE_NFB_HW_TIMESTAMP),y)
+ CFLAGS += -DNFB_HW_TIMESTAMP
+endif
+
LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool
LDLIBS += -lrte_ethdev -lrte_net
LDLIBS += -lrte_bus_pci
diff --git a/drivers/net/nfb/meson.build b/drivers/net/nfb/meson.build
index 457955d..c39007a 100644
--- a/drivers/net/nfb/meson.build
+++ b/drivers/net/nfb/meson.build
@@ -13,3 +13,7 @@ ext_deps += dep
ext_deps += nc
sources = files('nfb_rx.c', 'nfb_tx.c', 'nfb_stats.c', 'nfb_ethdev.c', 'nfb_rxmode.c')
+
+if dpdk_conf.has('RTE_LIBRTE_NFB_HW_TIMESTAMP')
+ cflags += [ '-DNFB_HW_TIMESTAMP' ]
+endif
diff --git a/drivers/net/nfb/nfb_rx.h b/drivers/net/nfb/nfb_rx.h
index 88a0307..1178917 100644
--- a/drivers/net/nfb/nfb_rx.h
+++ b/drivers/net/nfb/nfb_rx.h
@@ -181,6 +181,19 @@ struct ndp_rx_queue {
mbuf->pkt_len = packet_size;
mbuf->port = ndp->in_port;
+ mbuf->ol_flags = 0;
+
+#ifdef NFB_HW_TIMESTAMP
+ /* nanoseconds */
+ mbuf->timestamp = rte_le_to_cpu_32(*((uint32_t *)
+ (packets[i].header + 4)));
+ mbuf->timestamp <<= 32;
+ /* seconds */
+ mbuf->timestamp |= rte_le_to_cpu_32(*((uint32_t *)
+ (packets[i].header + 8)));
+ mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+#endif /* NFB_HW_TIMESTAMP */
+
bufs[num_rx++] = mbuf;
num_bytes += packet_size;
} else {
--
1.8.3.1
More information about the dev
mailing list