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 C351FA00C5; Mon, 14 Feb 2022 12:25:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C315D41158; Mon, 14 Feb 2022 12:25:48 +0100 (CET) Received: from office2.cesnet.cz (office2.cesnet.cz [195.113.144.244]) by mails.dpdk.org (Postfix) with ESMTP id 30C2E4114B for ; Mon, 14 Feb 2022 12:25:47 +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 E1BDB400076; Mon, 14 Feb 2022 12:25:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2-2020; t=1644837946; bh=x2nvt6MI7EWgBclVzldVWnpya6vJ7Ie3kvkRezeGpSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FLIvYUZc2ie6lzvOHdkNqKzkKomaqx9Gnl1bsx9ivy9lOti4pOcsWceZy/Odqz577 KsU0iLlU1vyxsS3BTjYzXeVnsvr8R+aVT8eftT9zoUXXZTxLHjMK05CoP2i/AtgKbe cbN1LYRx0gZSK7fuPFUHjEjZgwUlwrCmKVou6Wok7Uz4na5EBSCKhabtHuc3n8iCYs xS/MRo1mc3H2NUIu4o+9v8ggFeXDzcWcJbx8Utc+9aFs5FD8Ww9kx8ceHP/KM3+NMW 6utw7Sr6jsut+1KY5kgLBsaKOuLFsA04YJ41CrnZf+nQEEU5L/2Io5z6t0SyW1psdb X82ShDxKto92Q== From: spinler@cesnet.cz To: dev@dpdk.org Cc: Martin Spinler Subject: [PATCH 4/6] drivers/nfb: use RTE_ETH_RX_OFFLOAD_TIMESTAMP flag Date: Mon, 14 Feb 2022 12:25:39 +0100 Message-Id: <20220214112541.29782-4-spinler@cesnet.cz> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214112541.29782-1-spinler@cesnet.cz> References: <20220214112541.29782-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 --- 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 #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