DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rastislav Cernay <cernay@netcope.com>
To: dev@dpdk.org
Cc: cernay@netcope.com, remes@netcope.com
Subject: [dpdk-dev] [PATCH] drivers/net/nfb: add timestamp support
Date: Thu, 13 Jun 2019 14:05:09 +0200	[thread overview]
Message-ID: <1560427509-56164-1-git-send-email-cernay@netcope.com> (raw)

From: Rastislav Cernay <cernay@netcope.com>

This patch adds timestamping support to nfb driver.

Signed-off-by: Rastislav Cernay <cernay@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


             reply	other threads:[~2019-06-13 12:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 12:05 Rastislav Cernay [this message]
2019-06-27 15:45 ` Ferruh Yigit
2019-06-28 14:12   ` Jan Remeš
2019-07-02 10:32 ` [dpdk-dev] [PATCH v2] " Rastislav Cernay
2019-07-03 11:55   ` Ferruh Yigit
2019-07-15 12:03 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
2019-07-15 13:08   ` Ferruh Yigit

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=1560427509-56164-1-git-send-email-cernay@netcope.com \
    --to=cernay@netcope.com \
    --cc=dev@dpdk.org \
    --cc=remes@netcope.com \
    /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;
as well as URLs for NNTP newsgroup(s).