From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1CD3DA034C; Tue, 15 Feb 2022 13:56:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71BE041172; Tue, 15 Feb 2022 13:56:06 +0100 (CET) Received: from office2.cesnet.cz (office2.cesnet.cz [195.113.144.244]) by mails.dpdk.org (Postfix) with ESMTP id C24634115E for ; Tue, 15 Feb 2022 13:56:03 +0100 (CET) Received: from emil.fit.vutbr.cz (unknown [IPv6:2001:67c:1220:80c:eb:e00e:9e81:ff5f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 9A41B40006C; Tue, 15 Feb 2022 13:56:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2-2020; t=1644929763; bh=ondvkInt1DMQr1MwfZCBpb3szd0warx3iEiFyb2+6V4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fXddHQc5n3cdh/uIpnNRITAgrGJiptrMOFXjU5f/TmNVlaoonxXcN2ku88OHF3sWs EeHjKa42St+cwT3zc4hfK/VEzVQqjg5dSqOnMf77w7eD8jel4F5CtrHJXlUmgeA/Gd R+SKlseaA7Mgb7q6qLMtq5Yh93sxddE64bYaPR4HMhf9WIVs/YElvwMRsSYhQdcS/Q ZVuHHiM544SLKt8MORxQGnGu90pWx5MyhsfqN7wXcmJPYyr5PQx9mePJ9L4lOF6Mo+ Pg1C/N4jQzHd8Pcohpp1CpJNoMWEjdtTlegnTNy+jBQ/rDh/pTQyFRKTIhTWqTBE8q gy+PSgZqkk9uQ== From: spinler@cesnet.cz To: dev@dpdk.org Cc: Martin Spinler Subject: [PATCH v2 3/5] net/nfb: use RTE_ETH_RX_OFFLOAD_TIMESTAMP flag Date: Tue, 15 Feb 2022 13:55:41 +0100 Message-Id: <20220215125543.142108-4-spinler@cesnet.cz> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220215125543.142108-1-spinler@cesnet.cz> References: <20220214112541.29782-1-spinler@cesnet.cz> <20220215125543.142108-1-spinler@cesnet.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Martin Spinler Rewrite the RX timestamp setup code to use standard offload flag. Signed-off-by: Martin Spinler --- 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 - - .//app/dpdk-testpmd -a b3:00.0,timestamp=1 -- - -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 #include -#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