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 86B84A04E7;
	Tue,  3 Nov 2020 01:17:48 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 6ECB2BC62;
	Tue,  3 Nov 2020 01:14:48 +0100 (CET)
Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com
 [64.147.123.20]) by dpdk.org (Postfix) with ESMTP id 438FFBC5E
 for <dev@dpdk.org>; Tue,  3 Nov 2020 01:14:45 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.west.internal (Postfix) with ESMTP id 0BE0FB6B;
 Mon,  2 Nov 2020 19:14:43 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Mon, 02 Nov 2020 19:14:44 -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=N2rrEYtJMecUA
 DCbGOmnNbzeb9mXaTloBXzlnJneMCs=; b=Fl9ODGMjEhMgw6TWYw1JOpWQfkKe5
 v3bZp/JL3bR+WwoX+W0lT7xKuR97f0RqxJdIBecOC4xkCiQNnqA5iRNF8zalmhb+
 Fcght2FdI1IFeB4bHdMeEdXC2DmKIrzkskO49Xy2iY3rlw1yFqL8/5FFZ5Hrgwvr
 3CNo05LPw995xpTzSybnq8KwCrZ6dLCJ9/4fOOqshf6VibZn3jIsqy33PFyT/1KJ
 DGQ1cBurdAk8Kb/H0+lGoFox9h/BIlZx8toRGtc0YkRJAzcZe9jEoWAZH+GC/mMz
 dq0zS6MsI+UrDxObs1hmjpJBWCuNaQ6m6zC8yqrwW/IvX0ABRC8z9ku9Q==
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=N2rrEYtJMecUADCbGOmnNbzeb9mXaTloBXzlnJneMCs=; b=Cr/wDdyO
 j9GXEwEEYehtbbq1sfAGYklArum1Nlz++3B0cFAANiXA0Myeh/4QNEHAc+E7X801
 Rh95cgzM7FURuCqbCsbrMND83eIMH/EOZbeFDasz27UO+dgsVIkNhevXzYwVEnSf
 K/L8wuWG2GItt/8vy+LkvsIDK9nyynpf4gG1fK1rw1IcyAsZZqoDhW1EtVyxKlLR
 qSyoFXlY12rDyvrBqXDYHZMoYUvNZAqPf8YPVWBS7EaYiVwCxAQkoZrOnPyZF4bo
 aMdJhtmXEUXiLcOTnSg4D2dY1Ubr/cKVMT9q9s2QufHTBTcoARGvxwSU7SjpLUBz
 kvuwSn3fe9c45A==
X-ME-Sender: <xms:86CgX22O3ThLVzS-T2_iWITGgwD4IGdVDH0ezM3QwleNsHL1kDle7A>
 <xme:86CgX5GuvV7CqVCZBrrYS9QVX5PnyzYtLc0ddw4TxX9HlB8dQvmy1qpe1px2-jiQW
 1cLdq8C8j7zpVqMKQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtvddgudejucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre
 dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes
 mhhonhhjrghlohhnrdhnvghtqeenucggtffrrghtthgvrhhnpeelveduleeggeduvdevue
 etueehffegieduveduvdfftdevtedutdehtdeitefgleenucffohhmrghinhepthhsrdht
 vhenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgeptd
 enucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgv
 th
X-ME-Proxy: <xmx:86CgX-7xpWSTBLTTbwcBLa4CCYkbUWLiAmuKQjPRZTwbtCmu4dFWKw>
 <xmx:86CgX31CT6KGb0iebNt6PcVFn0x1Ex8dxAAAhkBwBcd4g4miX6-fPw>
 <xmx:86CgX5Fh-z6vdKr8NhJOAcwkVKQRZ8rDO_mjWrShgudSmnJT2MD-Nw>
 <xmx:86CgXyO7IFSLVEoOhtC0l_nP_KGzaxsMJY9VglYjHrGK6ePVkeX35w>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id 9F2F1306467D;
 Mon,  2 Nov 2020 19:14:42 -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: Tue,  3 Nov 2020 01:14:01 +0100
Message-Id: <20201103001407.2931963-11-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201103001407.2931963-1-thomas@monjalon.net>
References: <20201029092751.3837177-1-thomas@monjalon.net>
 <20201103001407.2931963-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v3 10/16] net/pcap: 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 <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 | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 34e82317b1..4e6d49370e 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -51,6 +51,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 +268,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 +661,15 @@ eth_dev_stop(struct rte_eth_dev *dev)
 static int
 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+	int ret;
+
+	ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
+			&timestamp_rx_dynflag);
+	if (ret != 0) {
+		PMD_LOG(ERR, "Failed to register Rx timestamp field/flag");
+		return -rte_errno;
+	}
+
 	return 0;
 }
 
-- 
2.28.0