drivers/net/nfb: add timestamp support
Checks
Commit Message
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(+)
Comments
On 6/13/2019 1:05 PM, Rastislav Cernay wrote:
> 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.
Even if this can't be detected on runtime, it should be possible to configure in
runtime with device args so need to compile the PMD again to change the behavior.
In this patch default behavior is no timestamps support, same can be done with
devargs, without any devargs timestamp support disable, but if user provides a
devarg, like "timestamp=1", feature enabled.
What do you think, can it be possible to convert runtime configuration?
On Thu, Jun 27, 2019 at 5:45 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> On 6/13/2019 1:05 PM, Rastislav Cernay wrote:
> > +Timestamping needs to be enabled during compile time, as there is no way
> > +to check whether a timestamping unit is runnig during run time.
>
> Even if this can't be detected on runtime, it should be possible to configure in
> runtime with device args so need to compile the PMD again to change the behavior.
>
> In this patch default behavior is no timestamps support, same can be done with
> devargs, without any devargs timestamp support disable, but if user provides a
> devarg, like "timestamp=1", feature enabled.
>
> What do you think, can it be possible to convert runtime configuration?
This sounds good. We did not explore the devargs option. We will look
into it, and probably rework this patch and send v2.
Thanks,
Jan
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 {