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 27ADEA04E7;
	Sun,  1 Nov 2020 19:10:15 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 46B484CBD;
	Sun,  1 Nov 2020 19:07:11 +0100 (CET)
Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com
 [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 45279697A
 for <dev@dpdk.org>; Sun,  1 Nov 2020 19:07:08 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id EFF845C008C;
 Sun,  1 Nov 2020 13:07:07 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Sun, 01 Nov 2020 13:07:07 -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=zreLXuW/VQbq1
 G/2toaLV/kjXG9nHBevfn/tWKO5IWE=; b=PGLWojj9vrhEo2Lk2PL96RptCzJT9
 9WzwOpmrlA47GYZp9plbxwMsNstF44/WR5MNAnGX+zyQ3VC8awgRgqxzxs5ptzI/
 z2p/Sg1CjLbMmXjVSrM0E8OxdEJENvP+0OP/QiEbIZUI4R7u2jKe0hNk53GZ7k9R
 vCvR9rf/zFyQeZToQpBM3NDgQZk1MrUtAAe4xr6xPTfrUUtLgCy9aH+xVg4FF9cH
 nVabSYBO8s32XkD68AebSOLvHMcEakS13P3TITTv2QZsR6hfXiqqAi1LjCyVYIQ7
 ueR0fDe3Ocxoh8WEgqbM3p7kufvyrA0IsXwR1uvd9Q/8FwfoSYvC4/usA==
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=zreLXuW/VQbq1G/2toaLV/kjXG9nHBevfn/tWKO5IWE=; b=KeofXpA9
 3yKpzl4ysjW0q/RmVEtUCpmSue//v61BrkrfMtsMi9II5YITuLTl7W31GA5vDEyn
 4pFZZdJptxwbuXUrhGSMmMjU+vTiWvmUez1Qbl9F6lAXi277uSbhseEMj7doVoye
 7aedE8/eDttv6etsv6afEVmPi3jjeNQGsrscpiztqaN6pm2huQGbT/yTgfdmipYm
 /TsqGsxMr1oFDEbWv015xVnHFtbUgmTzoYM1pmFoNaM0CQ9or4x54BP1GPvwRspP
 2GdmNWGSK178xWg1JPKCxkQjbRsh2xwOOFAI68ziyee9gamWJ8npTizhmJrpB3+6
 h5Q+l5MDdX+8xg==
X-ME-Sender: <xms:S_meX7PXnGOVt7JZ-bpGcKeIWZuG_Y9dsM8lFPU7DlACYFyBaaTjFw>
 <xme:S_meX1_FjK7Ben0qSPTUcxq7hpHTSHqg633DcoFqzP09XFzHV2rKKdexvJX2NmXug
 cZIUzhzdfgBhXKatg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleelgdduuddvucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre
 dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes
 mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpeelveduleeggeduvdevue
 etueehffegieduveduvdfftdevtedutdehtdeitefgleenucffohhmrghinhepthhsrdht
 vhenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgeptd
 enucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgv
 th
X-ME-Proxy: <xmx:S_meX6S7Nxh30lvh9LhsB6YvNThcN5MxT7EQMYFd1fYeJ-UdYsyHaQ>
 <xmx:S_meX_uoY9pjVvX24hWJLu1yduZrq_sQJxJeiK6ObjwqqCQOIijmVg>
 <xmx:S_meXzc56DPYSPiEnT8X7jGtaOzzUAnrlI7Xm2MVkM0FPOe5FrjwZg>
 <xmx:S_meX0G53p5sTbATQ1Kbm7mm1x0RRmh7_JpxDwGHAQZU1HMl0h2UdQ>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id E01D93280064;
 Sun,  1 Nov 2020 13:07:06 -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
Date: Sun,  1 Nov 2020 19:06:23 +0100
Message-Id: <20201101180626.2198868-12-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 11/14] net/pcap: 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/pcap/rte_eth_pcap.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 34e82317b1..b4b7a1839b 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -18,6 +18,7 @@
 
 #include <pcap.h>
 
+#include <rte_bitops.h>
 #include <rte_cycles.h>
 #include <rte_ethdev_driver.h>
 #include <rte_ethdev_vdev.h>
@@ -51,6 +52,9 @@ static uint64_t start_cycles;
 static uint64_t hz;
 static uint8_t iface_idx;
 
+static uint64_t timestamp_rx_dynflag;
+static int timestamp_dynfield_offset = -1;
+
 struct queue_stat {
 	volatile unsigned long pkts;
 	volatile unsigned long bytes;
@@ -265,9 +269,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		}
 
 		mbuf->pkt_len = (uint16_t)header.caplen;
-		mbuf->timestamp = (uint64_t)header.ts.tv_sec * 1000000
-							+ header.ts.tv_usec;
-		mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+		*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset,
+			rte_mbuf_timestamp_t *) =
+				(uint64_t)header.ts.tv_sec * 1000000 +
+				header.ts.tv_usec;
+		mbuf->ol_flags |= timestamp_rx_dynflag;
 		mbuf->port = pcap_q->port_id;
 		bufs[num_rx] = mbuf;
 		num_rx++;
@@ -656,6 +662,23 @@ eth_dev_stop(struct rte_eth_dev *dev)
 static int
 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+	int timestamp_rx_dynflag_offset;
+
+	timestamp_dynfield_offset = rte_mbuf_dynfield_lookup(
+			RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL);
+	if (timestamp_dynfield_offset < 0) {
+		PMD_LOG(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) {
+		PMD_LOG(ERR, "Failed lookup Rx timestamp flag");
+		return -rte_errno;
+	}
+	timestamp_rx_dynflag =
+		RTE_BIT64(timestamp_rx_dynflag_offset);
+
 	return 0;
 }
 
-- 
2.28.0