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 4AA74A04E6; Fri, 30 Oct 2020 18:33:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C52546A16; Fri, 30 Oct 2020 18:30:16 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 334BF5916 for ; Fri, 30 Oct 2020 18:30:06 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id DE55E5C01F9; Fri, 30 Oct 2020 13:30:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:30:05 -0400 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=gBQ3EENVoHp7n Z+5f/s4THoJvHHh3lJew6ghBdkyeM8=; b=pj8oA1eCjcprl23cFMkWHtgqsyXyQ t4PcXwMX1RHz5klCBCS2y0ASkTfEopY1lNxIbkcGj5EqhVCUMfH1fRwPk5MuUW0R wSFAs/Q2enr0CJcGBMEq7lyVxvUrVWrdAGldpnRYc7OUcspluwJwI2/3i8YKiJDV WPGFaLLN2dJ/RUNOaqYd3EbunJeb58EihuvCnw8kRtXN1soGOHqCEoggv6XpDI8/ BrKEdTO9HioFaXkdU0mhftAv93EMqHZNYYeCHZJ5UPDpKVI6yenDi8OsmecS+c8H ICR2OgcbF/sgx0C8VcJSoMCxmrWNMPSjnWco2m4Twfqhvhzrn5mD9uuaA== 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=gBQ3EENVoHp7nZ+5f/s4THoJvHHh3lJew6ghBdkyeM8=; b=FfRMaFQD UZfd05F74RZWPnDHa3a95Ql7fOmb+9FnfOYRENg+zNIg3p3NYdjUAHZccWBxosEw iz7YW6iETWAfKXe1QOLGSGz2ejrroPZ8SzW/FlznAilSZqCAPH++959ngfubJFdD yLKF2+J6aAC3vN6QROKHqsFe4UQYv9EuSNfKlE+5Wk95s8weVV7s+Zy8q5+03M94 ZH2kXAmgWOyy0eoUW/tMuMSOLw1h3OGQwiiY9KT2hy1LFmi1d0y/IbDEla5Q4R8O pkNaRPDWFprzKcEo1wLhoajbhAnMawd9UTuw4LvggAa6tb/ECZG6vSsBg/qzp3Ty KgJUOAZPXq9Icg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepjeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 584F63064610; Fri, 30 Oct 2020 13:30:04 -0400 (EDT) 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, akhil.goyal@nxp.com, jerinj@marvell.com, Martin Spinler Date: Fri, 30 Oct 2020 18:29:34 +0100 Message-Id: <20201030172940.1073558-10-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030172940.1073558-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201030172940.1073558-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 09/15] net/nfb: switch 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 --- drivers/net/nfb/nfb_rx.c | 23 ++++++++++++++++++++++- drivers/net/nfb/nfb_rx.h | 18 ++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfb/nfb_rx.c b/drivers/net/nfb/nfb_rx.c index d97179f818..1f90357522 100644 --- a/drivers/net/nfb/nfb_rx.c +++ b/drivers/net/nfb/nfb_rx.c @@ -5,10 +5,14 @@ */ #include +#include #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) @@ -23,6 +27,7 @@ timestamp_check_handler(__rte_unused const char *key, static int nfb_check_timestamp(struct rte_devargs *devargs) { + int timestamp_rx_dynflag_offset; struct rte_kvargs *kvlist; if (devargs == NULL) @@ -38,6 +43,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 +52,21 @@ nfb_check_timestamp(struct rte_devargs *devargs) } rte_kvargs_free(kvlist); + nfb_timestamp_dynfield_offset = rte_mbuf_dynfield_lookup( + RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); + if (nfb_timestamp_dynfield_offset < 0) { + RTE_LOG(ERR, PMD, "Cannot lookup timestamp field\n"); + return -rte_errno; + } + timestamp_rx_dynflag_offset = rte_mbuf_dynflag_lookup( + RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, NULL); + if (timestamp_rx_dynflag_offset < 0) { + RTE_LOG(ERR, PMD, "Cannot lookup Rx timestamp flag\n"); + return -rte_errno; + } + nfb_timestamp_rx_dynflag = + RTE_BIT64(timestamp_rx_dynflag_offset); + return 1; } @@ -125,7 +146,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..e548226e0f 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 */ @@ -191,15 +201,15 @@ nfb_eth_ndp_rx(void *queue, if (timestamping_enabled) { /* nanoseconds */ - mbuf->timestamp = + *nfb_timestamp_dynfield(mbuf) = rte_le_to_cpu_32(*((uint32_t *) (packets[i].header + 4))); - mbuf->timestamp <<= 32; + *nfb_timestamp_dynfield(mbuf) <<= 32; /* seconds */ - mbuf->timestamp |= + *nfb_timestamp_dynfield(mbuf) |= rte_le_to_cpu_32(*((uint32_t *) (packets[i].header + 8))); - mbuf->ol_flags |= PKT_RX_TIMESTAMP; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; } bufs[num_rx++] = mbuf; -- 2.28.0