From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B740A0521; Tue, 3 Nov 2020 15:12:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F1D7ECAE0; Tue, 3 Nov 2020 15:10:03 +0100 (CET) Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by dpdk.org (Postfix) with ESMTP id 3091ECACD for ; Tue, 3 Nov 2020 15:10:01 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id CF0FAD30; Tue, 3 Nov 2020 09:09:58 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 03 Nov 2020 09:09:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=Ad3YnWIV8//wa 0/Ps2HuGcyoJx3eHsifS7Fhic4NkI4=; b=wqu3a6d5zG3Aq+quNtHtP7a9dp0pR PI3JJmf1Hv2g3ETLhS+EaPsGg0Y0wE8dXbDJL6bXNYzukJcjkjBuMLp3lC6tmZYL c26VXtvNyH81rKBGqYaYiIfJsHbuOiY+4Y7S2rZrWae1azRah69nLToBPCN2WVVn cW7vrpEzcG91p6bRBZFiF4NNPpIf+xpzk7xk9mJGBF0CU51c6toZO2Q5mk+JsKy3 vXitckq4u5PNGI/evQ49yC6snkMj/kX+c7NLxt9BlmMH91Hj253XDMpkXyeEROA3 jKmEVmdc4CJoQsrVuwtNzX3AvGd8Bqo9aJgXW1yZuXpB0DqXPsJCrHTqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Ad3YnWIV8//wa0/Ps2HuGcyoJx3eHsifS7Fhic4NkI4=; b=WZHVU7x2 2ahMqKOuBv6ADSASxG5J0mlOi7zu9iupGNgkSjgnNv4af6EuG0U1y56DQTIEQAg9 jNt84gcpp0oWN5XzS2Tbw423g8O1b/iiAKlgvfnvul9z4bnla8Ohx0Uoz2ec6ksH 7R1SVuP8RKmUC+nYgGJFqQtF5rxKTxi8+P4j96v218qpEuq61YAbTRKoJEiNVngC 2untQrv/7+nsJDDB/Ik6/0Y2sGuhkQSysh796028Py5FOdap5CnKsN+K0GhW1Sl/ xYzYsD/7BheAMUCY33sv6ZlFQttBQPMsXLwt2rgEx1NEALi/jLUPaMbgAXUUlc2N zol5tb4Jx0Qkpw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtfedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeeknecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 218F63280065; Tue, 3 Nov 2020 09:09:57 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru, jerinj@marvell.com, viacheslavo@nvidia.com, Martin Spinler Date: Tue, 3 Nov 2020 15:09:23 +0100 Message-Id: <20201103140931.488700-9-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103140931.488700-1-thomas@monjalon.net> References: <20201029092751.3837177-1-thomas@monjalon.net> <20201103140931.488700-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 08/16] net/nfb: switch Rx timestamp to dynamic mbuf field X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced. Signed-off-by: Thomas Monjalon Acked-by: David Marchand --- drivers/net/nfb/nfb_rx.c | 15 ++++++++++++++- drivers/net/nfb/nfb_rx.h | 21 +++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfb/nfb_rx.c b/drivers/net/nfb/nfb_rx.c index d97179f818..d6d4ba9663 100644 --- a/drivers/net/nfb/nfb_rx.c +++ b/drivers/net/nfb/nfb_rx.c @@ -9,6 +9,9 @@ #include "nfb_rx.h" #include "nfb.h" +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) @@ -24,6 +27,7 @@ static int nfb_check_timestamp(struct rte_devargs *devargs) { struct rte_kvargs *kvlist; + int ret; if (devargs == NULL) return 0; @@ -38,6 +42,7 @@ nfb_check_timestamp(struct rte_devargs *devargs) } /* Timestamps are enabled when there is * key-value pair: enable_timestamp=1 + * TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP */ if (rte_kvargs_process(kvlist, TIMESTAMP_ARG, timestamp_check_handler, NULL) < 0) { @@ -46,6 +51,14 @@ nfb_check_timestamp(struct rte_devargs *devargs) } 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; } @@ -125,7 +138,7 @@ nfb_eth_rx_queue_setup(struct rte_eth_dev *dev, else rte_free(rxq); - if (nfb_check_timestamp(dev->device->devargs)) + 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 cf3899b2fb..27a2888a75 100644 --- a/drivers/net/nfb/nfb_rx.h +++ b/drivers/net/nfb/nfb_rx.h @@ -15,6 +15,16 @@ #define NFB_TIMESTAMP_FLAG (1 << 0) +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + struct ndp_rx_queue { struct nfb_device *nfb; /* nfb dev structure */ struct ndp_queue *queue; /* rx queue */ @@ -190,16 +200,19 @@ nfb_eth_ndp_rx(void *queue, mbuf->ol_flags = 0; if (timestamping_enabled) { + rte_mbuf_timestamp_t timestamp; + /* nanoseconds */ - mbuf->timestamp = + timestamp = rte_le_to_cpu_32(*((uint32_t *) (packets[i].header + 4))); - mbuf->timestamp <<= 32; + timestamp <<= 32; /* seconds */ - mbuf->timestamp |= + timestamp |= rte_le_to_cpu_32(*((uint32_t *) (packets[i].header + 8))); - mbuf->ol_flags |= PKT_RX_TIMESTAMP; + *nfb_timestamp_dynfield(mbuf) = timestamp; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf; -- 2.28.0