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 9AC65A04E7; Tue, 3 Nov 2020 01:15:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ED8755A8C; Tue, 3 Nov 2020 01:14:32 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by dpdk.org (Postfix) with ESMTP id 1FB2C592C for ; Tue, 3 Nov 2020 01:14:29 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 3C3C7AD6; Mon, 2 Nov 2020 19:14:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 02 Nov 2020 19:14:27 -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=x9lzp29s3N0EY fnIntSOQ9rtyQhanFz3neI5Pm03g/4=; b=oM+U4KNgBgFeSHpylKMPmD+8HxN6P FlVGJAGk1OoQvW+DXQgkLBwjw0B1jG/ikKcEQIrHarTJStW/jRRXis0xKIqdLvZA rDcl9H8NMluSr6qxOGXsRbY7jVccD91iAqkyhkKzWOXYdY9R26dY5sVoDRV2eK5q HyiLRHHBdYY5Tw7g6Vw0DTFx16oHGSHWEi3Wm9M+Xj1Q5YEocbqT1bAJjjTLEuUE iw74BwcNaZuLDOdR129MECt2GrprbZ5Qi3m0relurj6YgKTDymkDBpZN0aTuEUyG imJRFV8fCtpepE1jEIn0BN4qp1RoWzD+tbJF0Oabip4f1ES2u8O9wkisA== 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=x9lzp29s3N0EYfnIntSOQ9rtyQhanFz3neI5Pm03g/4=; b=abVA8H1K bVpK5ooSvxWJ306T2V08egNVX8HZMAJg1szAn1hxCBDSX1DnJciz0MqXR4jbT9HK iyrQm/cyaoQjWwSzTNFXzyPXpbZy0t+275g174x7Ji3E96VXGhTfLnFY0Jx0nNZC fJXPmlpE3eTx8UADLrpLSxa8Xm1qaEzjqA06onS/IJ55ZTOqQ5eshKKRShKG+Ylp l0ye3xpJeFkphiHQxY8aX+jnKAvKMxxitB5/FrW7MEcjd/ZY4s47ZL34l/SPkkp/ ncWjsn7fS2xOe2ggLWvSSMT7zpPQbaegONiIC6LGn6GLRrF/346idB2TW2FVnsov 4EuqN9FUVMxqxA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtvddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 B2D0C3064680; Mon, 2 Nov 2020 19:14:25 -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, Reshma Pattan Date: Tue, 3 Nov 2020 01:13:54 +0100 Message-Id: <20201103001407.2931963-4-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 03/16] latency: 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 with the dynamic one. Signed-off-by: Thomas Monjalon --- lib/librte_latencystats/rte_latencystats.c | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c index ba2fff3bcb..ab8db7a139 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -31,6 +32,16 @@ latencystat_cycles_per_ns(void) /* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset = -1; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static const char *MZ_RTE_LATENCY_STATS = "rte_latencystats"; static int latency_stats_index; static uint64_t samp_intvl; @@ -128,10 +139,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; - if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) == 0 + if ((pkts[i]->ol_flags & timestamp_dynflag) == 0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |= PKT_RX_TIMESTAMP; + *timestamp_dynfield(pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc = 0; } prev_tsc = now; @@ -161,8 +172,8 @@ calc_latency(uint16_t pid __rte_unused, now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP) - latency[cnt++] = now - pkts[i]->timestamp; + if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield(pkts[i]); } rte_spinlock_lock(&glob_stats->lock); @@ -241,6 +252,15 @@ rte_latencystats_init(uint64_t app_samp_intvl, return -1; } + /* Register mbuf field and flag for Rx timestamp */ + ret = rte_mbuf_dyn_rx_timestamp_register(×tamp_dynfield_offset, + ×tamp_dynflag); + if (ret != 0) { + RTE_LOG(ERR, LATENCY_STATS, + "Cannot register mbuf field/flag for timestamp\n"); + return -rte_errno; + } + /** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; -- 2.28.0