DPDK patches and discussions
 help / color / mirror / Atom feed
From: spinler@cesnet.cz
To: dev@dpdk.org
Cc: Martin Spinler <spinler@cesnet.cz>
Subject: [PATCH v2 3/5] net/nfb: use RTE_ETH_RX_OFFLOAD_TIMESTAMP flag
Date: Tue, 15 Feb 2022 13:55:41 +0100	[thread overview]
Message-ID: <20220215125543.142108-4-spinler@cesnet.cz> (raw)
In-Reply-To: <20220215125543.142108-1-spinler@cesnet.cz>

From: Martin Spinler <spinler@cesnet.cz>

Rewrite the RX timestamp setup code to use standard offload flag.

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
 doc/guides/nics/nfb.rst      |  8 ++----
 drivers/net/nfb/nfb.h        |  3 +-
 drivers/net/nfb/nfb_ethdev.c | 19 ++++++++++++-
 drivers/net/nfb/nfb_rx.c     | 53 ------------------------------------
 drivers/net/nfb/nfb_rx.h     |  7 +----
 5 files changed, 22 insertions(+), 68 deletions(-)

diff --git a/doc/guides/nics/nfb.rst b/doc/guides/nics/nfb.rst
index 14560d38e4..96aaf64440 100644
--- a/doc/guides/nics/nfb.rst
+++ b/doc/guides/nics/nfb.rst
@@ -59,13 +59,9 @@ Timestamps
 
 The PMD supports hardware timestamps of frame receipt on physical network interface. In order to use
 the timestamps, the hardware timestamping unit must be enabled (follow the documentation of the NFB
-products) and the device argument `timestamp=1` must be used.
+products). The standard `RTE_ETH_RX_OFFLOAD_TIMESTAMP` flag can be used for this feature.
 
-.. code-block:: console
-
-    ./<build_dir>/app/dpdk-testpmd -a b3:00.0,timestamp=1 <other EAL params> -- <testpmd params>
-
-When the timestamps are enabled with the *devarg*, a timestamp validity flag is set in the MBUFs
+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
diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index 59d3ab4986..4de9006ac0 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -37,8 +37,7 @@
 #define RTE_NFB_DRIVER_NAME net_nfb
 
 /* Device arguments */
-#define TIMESTAMP_ARG  "timestamp"
-static const char * const VALID_KEYS[] = {TIMESTAMP_ARG, NULL};
+static const char * const VALID_KEYS[] = {NULL};
 
 struct pmd_internals {
 	uint16_t         max_rxmac;
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 0b27fe78cc..53a98642b3 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -183,6 +183,22 @@ nfb_eth_dev_stop(struct rte_eth_dev *dev)
 static int
 nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+	int ret;
+	struct pmd_internals *internals = dev->data->dev_private;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+
+	if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+		ret = rte_mbuf_dyn_rx_timestamp_register
+				(&nfb_timestamp_dynfield_offset,
+				&nfb_timestamp_rx_dynflag);
+		if (ret != 0) {
+			RTE_LOG(ERR, PMD, "Cannot register Rx timestamp"
+					" field/flag %d\n", ret);
+			nfb_close(internals->nfb);
+			return -rte_errno;
+		}
+	}
+
 	return 0;
 }
 
@@ -203,6 +219,8 @@ nfb_eth_dev_info(struct rte_eth_dev *dev,
 	dev_info->max_rx_queues = dev->data->nb_rx_queues;
 	dev_info->max_tx_queues = dev->data->nb_tx_queues;
 	dev_info->speed_capa = RTE_ETH_LINK_SPEED_100G;
+	dev_info->rx_offload_capa =
+		RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
 	return 0;
 }
@@ -609,4 +627,3 @@ static struct rte_pci_driver nfb_eth_driver = {
 RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_NFB_DRIVER_NAME, "* nfb");
-RTE_PMD_REGISTER_PARAM_STRING(RTE_NFB_DRIVER_NAME, TIMESTAMP_ARG "=<0|1>");
diff --git a/drivers/net/nfb/nfb_rx.c b/drivers/net/nfb/nfb_rx.c
index f76e2ba646..8a9b232305 100644
--- a/drivers/net/nfb/nfb_rx.c
+++ b/drivers/net/nfb/nfb_rx.c
@@ -12,56 +12,6 @@
 uint64_t nfb_timestamp_rx_dynflag;
 int nfb_timestamp_dynfield_offset = -1;
 
-static int
-timestamp_check_handler(__rte_unused const char *key,
-	const char *value, __rte_unused void *opaque)
-{
-	if (strcmp(value, "1"))
-		return -1;
-
-	return 0;
-}
-
-
-static int
-nfb_check_timestamp(struct rte_devargs *devargs)
-{
-	struct rte_kvargs *kvlist;
-	int ret;
-
-	if (devargs == NULL)
-		return 0;
-
-	kvlist = rte_kvargs_parse(devargs->args, NULL);
-	if (kvlist == NULL)
-		return 0;
-
-	if (!rte_kvargs_count(kvlist, TIMESTAMP_ARG)) {
-		rte_kvargs_free(kvlist);
-		return 0;
-	}
-	/* Timestamps are enabled when there is
-	 * key-value pair: enable_timestamp=1
-	 * TODO: timestamp should be enabled with RTE_ETH_RX_OFFLOAD_TIMESTAMP
-	 */
-	if (rte_kvargs_process(kvlist, TIMESTAMP_ARG,
-		timestamp_check_handler, NULL) < 0) {
-		rte_kvargs_free(kvlist);
-		return 0;
-	}
-	rte_kvargs_free(kvlist);
-
-	ret = rte_mbuf_dyn_rx_timestamp_register(
-			&nfb_timestamp_dynfield_offset,
-			&nfb_timestamp_rx_dynflag);
-	if (ret != 0) {
-		RTE_LOG(ERR, PMD, "Cannot register Rx timestamp field/flag\n");
-		return -rte_errno;
-	}
-
-	return 1;
-}
-
 int
 nfb_eth_rx_queue_start(struct rte_eth_dev *dev, uint16_t rxq_id)
 {
@@ -138,9 +88,6 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev,
 	else
 		rte_free(rxq);
 
-	if (nfb_check_timestamp(dev->device->devargs) > 0)
-		rxq->flags |= NFB_TIMESTAMP_FLAG;
-
 	return ret;
 }
 
diff --git a/drivers/net/nfb/nfb_rx.h b/drivers/net/nfb/nfb_rx.h
index 638205d53c..b618682e13 100644
--- a/drivers/net/nfb/nfb_rx.h
+++ b/drivers/net/nfb/nfb_rx.h
@@ -14,8 +14,6 @@
 #include <rte_mbuf_dyn.h>
 #include <rte_ethdev.h>
 
-#define NFB_TIMESTAMP_FLAG (1 << 0)
-
 extern uint64_t nfb_timestamp_rx_dynflag;
 extern int nfb_timestamp_dynfield_offset;
 
@@ -145,7 +143,6 @@ nfb_eth_ndp_rx(void *queue,
 	uint16_t nb_pkts)
 {
 	struct ndp_rx_queue *ndp = queue;
-	uint8_t timestamping_enabled;
 	uint16_t packet_size;
 	uint64_t num_bytes = 0;
 	uint16_t num_rx;
@@ -163,8 +160,6 @@ nfb_eth_ndp_rx(void *queue,
 		return 0;
 	}
 
-	timestamping_enabled = ndp->flags & NFB_TIMESTAMP_FLAG;
-
 	/* returns either all or nothing */
 	i = rte_pktmbuf_alloc_bulk(ndp->mb_pool, mbufs, nb_pkts);
 	if (unlikely(i != 0))
@@ -202,7 +197,7 @@ nfb_eth_ndp_rx(void *queue,
 			mbuf->port = ndp->in_port;
 			mbuf->ol_flags = 0;
 
-			if (timestamping_enabled) {
+			if (nfb_timestamp_dynfield_offset >= 0) {
 				rte_mbuf_timestamp_t timestamp;
 
 				/* nanoseconds */
-- 
2.35.1


  parent reply	other threads:[~2022-02-15 12:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 11:25 [PATCH 1/6] net/nfb: add missing libfdt dependency for build spinler
2022-02-14 11:25 ` [PATCH 2/6] drivers/nfb: fix array indexes in deinit functions spinler
2022-02-14 13:34   ` Ferruh Yigit
2022-02-14 16:52     ` Martin Spinler
2022-02-14 11:25 ` [PATCH 3/6] drivers/nfb: do not report zero-sized TX burst spinler
2022-02-14 13:35   ` Ferruh Yigit
2022-02-14 16:53     ` Martin Spinler
2022-02-14 17:34       ` Ferruh Yigit
2022-02-14 11:25 ` [PATCH 4/6] drivers/nfb: use RTE_ETH_RX_OFFLOAD_TIMESTAMP flag spinler
2022-02-14 11:25 ` [PATCH 5/6] drivers/nfb: fix multicast/promiscuous mode switching spinler
2022-02-14 13:36   ` Ferruh Yigit
2022-02-14 16:53     ` Martin Spinler
2022-02-14 11:25 ` [PATCH 6/6] drivers/nfb: add support for more MAC addresses spinler
2022-02-14 13:37   ` Ferruh Yigit
2022-02-14 16:53     ` Martin Spinler
2022-02-14 17:54       ` Ferruh Yigit
2022-02-15 13:02         ` Martin Spinler
2022-02-14 13:36 ` [PATCH 1/6] net/nfb: add missing libfdt dependency for build Ferruh Yigit
2022-02-14 16:53   ` Martin Spinler
2022-02-15 12:55 ` [PATCH v2 0/5] " spinler
2022-02-15 12:55   ` [PATCH v2 1/5] net/nfb: fix array indexes in deinit functions spinler
2022-02-15 12:55   ` [PATCH v2 2/5] net/nfb: do not report zero-sized TX burst spinler
2022-02-15 12:55   ` spinler [this message]
2022-02-15 12:55   ` [PATCH v2 4/5] net/nfb: fix multicast/promiscuous mode switching spinler
2022-02-15 12:55   ` [PATCH v2 5/5] net/nfb: add support for more MAC addresses spinler
2022-02-15 13:55   ` [PATCH v2 0/5] net/nfb: add missing libfdt dependency for build Ferruh Yigit
2022-02-15 13:57     ` 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=20220215125543.142108-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;
as well as URLs for NNTP newsgroup(s).