From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1E0C1A04E7;
	Sun,  1 Nov 2020 19:09:58 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id B77C3697A;
	Sun,  1 Nov 2020 19:07:09 +0100 (CET)
Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com
 [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id BDB3D5AA6
 for <dev@dpdk.org>; Sun,  1 Nov 2020 19:07:06 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailnew.nyi.internal (Postfix) with ESMTP id 74D355800F5;
 Sun,  1 Nov 2020 13:07:06 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Sun, 01 Nov 2020 13:07:06 -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=DOn1l1u2vwZ2n
 GbtpoeDWnpnD0GrfJWR9l+cCrsJ/Ds=; b=C/vqNoOYw09Fyt3w61PTum2P2Mcmm
 6+Sk/mPc2k1j7zzBRDh1FLODibSpbntvPJ5mZIJxIYVsKRDym2LM5gVC0Q1kGy9R
 rblL9mEWNvvhrG2iRUC3+3SPFrLfbpCOMeBLhdiw70J6TXDwOZaeZHropU/3RDT8
 bUERACwIfR+q7jz4LwhK5rnmZv51cVb9zg1Hp3PTRDuapeEVpDlvraWnppx8fYI4
 7KJYGi1qdbEaEqEtgLzJqWAUYdvA4YP5o6UI5keo7Jv6qElJgPNZqzuZWk7hbu7M
 KZv+ieGebqySEhGUHmUy72r8vv3FHDNraL7ZbArjHn+Rt7F70/ixER6gg==
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=DOn1l1u2vwZ2nGbtpoeDWnpnD0GrfJWR9l+cCrsJ/Ds=; b=QCbBXVD0
 tNzZioLRLiqGklM+/CRPC5chBEYBieI+7+GH2RsPov98RMmD/LWLXagSOOI3PUsz
 fieVJKTFdSbL5LxAr6hiFxsdKcgC6JrZcCZMfjWZeqQiqIir9YL8FKSh9CUuqeUY
 cCy5YbSBJRq1lRzVOxcd5VxZoOQEubMl6F/jLwNEjbUDW4LzdpFUCo+DxIhrNykO
 Yef6PAJqu8M5NwhghuwMp5UYuNrkZL6yg5CInXFuFFGaeZdR2ZzcLDj9adFNdszb
 cx1JlFT6CLQM3WM4pOmH2pHYZU5XW1BU7y6Yi7tNdwgL6uK+cX1uz1P+VcYdEE3y
 FTIa0xw10eLTAw==
X-ME-Sender: <xms:SfmeX4aGbVb938tRziDvxfzdeiY8FVkBn81DcpTnxKzQzuOJHPYwMA>
 <xme:SfmeXzbH_LLmtK7VEX8iJrkNp-Z6kFGJDMaaFc8wOByo-CpMgrElg9SSTM0mfwq0g
 FmJeCZoN9n0Z4EiYQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleelgdduuddvucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr
 shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg
 ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg
 uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf
 hiiigvpedutdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr
 lhhonhdrnhgvth
X-ME-Proxy: <xmx:SfmeXy-uw8E5kUuJn2YaRD4CbOuZ02vGTRijuU2_nzUZlmMtgkdr0A>
 <xmx:SfmeXyrQBumaEr1u5eOzQvtYtdNxhdmKHlAJ1aCZtFnAs_9nQ_Ta9A>
 <xmx:SfmeXzoi6OV5eqvkTazjVRXcW23qGwtbOaZKAPQ8_9Wg7ORsA_pL3w>
 <xmx:SvmeX21PeGjZ6byemTVrdrDKCds0nW1Lwpe_5Fufcs1zoXKoioLLNw>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id A04633280065;
 Sun,  1 Nov 2020 13:07:04 -0500 (EST)
From: Thomas Monjalon <thomas@monjalon.net>
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,
 Nithin Dabilpuram <ndabilpuram@marvell.com>,
 Kiran Kumar K <kirankumark@marvell.com>, Ray Kinsella <mdr@ashroe.eu>,
 Neil Horman <nhorman@tuxdriver.com>
Date: Sun,  1 Nov 2020 19:06:22 +0100
Message-Id: <20201101180626.2198868-11-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201101180626.2198868-1-thomas@monjalon.net>
References: <20201029092751.3837177-1-thomas@monjalon.net>
 <20201101180626.2198868-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2 10/14] net/octeontx2: 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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 <thomas@monjalon.net>
---
 drivers/net/octeontx2/otx2_ethdev.c | 33 +++++++++++++++++++++++++++++
 drivers/net/octeontx2/otx2_rx.h     | 19 ++++++++++++++---
 drivers/net/octeontx2/version.map   |  7 ++++++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index cfb733a4b5..ad95219438 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -4,6 +4,7 @@
 
 #include <inttypes.h>
 
+#include <rte_bitops.h>
 #include <rte_ethdev_pci.h>
 #include <rte_io.h>
 #include <rte_malloc.h>
@@ -14,6 +15,35 @@
 #include "otx2_ethdev.h"
 #include "otx2_ethdev_sec.h"
 
+uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;
+int rte_pmd_octeontx2_timestamp_dynfield_offset = -1;
+
+static int
+otx2_rx_timestamp_setup(uint16_t flags)
+{
+	int timestamp_rx_dynflag_offset;
+
+	if ((flags & NIX_RX_OFFLOAD_TSTAMP_F) == 0)
+		return 0;
+
+	rte_pmd_octeontx2_timestamp_dynfield_offset = rte_mbuf_dynfield_lookup(
+			RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL);
+	if (rte_pmd_octeontx2_timestamp_dynfield_offset < 0) {
+		otx2_err("Failed to lookup timestamp field");
+		return -rte_errno;
+	}
+	timestamp_rx_dynflag_offset = rte_mbuf_dynflag_lookup(
+			RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, NULL);
+	if (timestamp_rx_dynflag_offset < 0) {
+		otx2_err("Failed to lookup Rx timestamp flag");
+		return -rte_errno;
+	}
+	rte_pmd_octeontx2_timestamp_rx_dynflag =
+			RTE_BIT64(timestamp_rx_dynflag_offset);
+
+	return 0;
+}
+
 static inline uint64_t
 nix_get_rx_offload_capa(struct otx2_eth_dev *dev)
 {
@@ -1874,6 +1904,9 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
 	dev->tx_offload_flags |= nix_tx_offload_flags(eth_dev);
 	dev->rss_info.rss_grps = NIX_RSS_GRPS;
 
+	if (otx2_rx_timestamp_setup(dev->rx_offload_flags) != 0)
+		goto fail_offloads;
+
 	nb_rxq = RTE_MAX(data->nb_rx_queues, 1);
 	nb_txq = RTE_MAX(data->nb_tx_queues, 1);
 
diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h
index 61a5c436dd..6981edce82 100644
--- a/drivers/net/octeontx2/otx2_rx.h
+++ b/drivers/net/octeontx2/otx2_rx.h
@@ -63,6 +63,18 @@ union mbuf_initializer {
 	uint64_t value;
 };
 
+/* variables are exported because this file is included in other drivers */
+extern uint64_t rte_pmd_octeontx2_timestamp_rx_dynflag;
+extern int rte_pmd_octeontx2_timestamp_dynfield_offset;
+
+static inline rte_mbuf_timestamp_t *
+otx2_timestamp_dynfield(struct rte_mbuf *mbuf)
+{
+	return RTE_MBUF_DYNFIELD(mbuf,
+		rte_pmd_octeontx2_timestamp_dynfield_offset,
+		rte_mbuf_timestamp_t *);
+}
+
 static __rte_always_inline void
 otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
 			struct otx2_timesync_info *tstamp, const uint16_t flag,
@@ -77,15 +89,16 @@ otx2_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf,
 		/* Reading the rx timestamp inserted by CGX, viz at
 		 * starting of the packet data.
 		 */
-		mbuf->timestamp = rte_be_to_cpu_64(*tstamp_ptr);
+		*otx2_timestamp_dynfield(mbuf) = rte_be_to_cpu_64(*tstamp_ptr);
 		/* PKT_RX_IEEE1588_TMST flag needs to be set only in case
 		 * PTP packets are received.
 		 */
 		if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
-			tstamp->rx_tstamp = mbuf->timestamp;
+			tstamp->rx_tstamp = *otx2_timestamp_dynfield(mbuf);
 			tstamp->rx_ready = 1;
 			mbuf->ol_flags |= PKT_RX_IEEE1588_PTP |
-				PKT_RX_IEEE1588_TMST | PKT_RX_TIMESTAMP;
+				PKT_RX_IEEE1588_TMST |
+				rte_pmd_octeontx2_timestamp_rx_dynflag;
 		}
 	}
 }
diff --git a/drivers/net/octeontx2/version.map b/drivers/net/octeontx2/version.map
index 4a76d1d52d..d4f4784bcd 100644
--- a/drivers/net/octeontx2/version.map
+++ b/drivers/net/octeontx2/version.map
@@ -1,3 +1,10 @@
 DPDK_21 {
 	local: *;
 };
+
+INTERNAL {
+	global:
+
+	rte_pmd_octeontx2_timestamp_dynfield_offset;
+	rte_pmd_octeontx2_timestamp_rx_dynflag;
+};
-- 
2.28.0