From: Martin Spinler <spin...@cesnet.cz>

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

Signed-off-by: Martin Spinler <spin...@cesnet.cz>
---
 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 +----
 4 files changed, 20 insertions(+), 62 deletions(-)

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

Reply via email to