From patchwork Fri Oct 30 17:29:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 82970 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41747A04E6; Fri, 30 Oct 2020 18:34:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 87CA74C6C; Fri, 30 Oct 2020 18:30:43 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id E153F68C3 for ; Fri, 30 Oct 2020 18:30:13 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 975415C01F9; Fri, 30 Oct 2020 13:30:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:30:13 -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=MOdpUSFSnVGb6 VY+6OUa19Wtkh2mtbqEWADJwzRfn/Q=; b=XMr5+RV1hA/D13oqaNFXIdoHpX+be iTBzZcSYjRr81bre40FkjGLCRprQrUTjOsXZbyRo9fUkGzuiqWO6mPs1OShiPJwP kQdloXbpMj7etG1tD3Q8+AgZjfEYKxBiqh3P8rAt7Ik0ToDf9VHOLjxHtuLGP7q3 TrkWZ/NQX08I6x9dgt1IwWEkLZQHwv2yWqdSX/6bOdaHg0urYZDvb5teV6j2YA9C z+VHDc5g2EkMms35DR8kGY4VpL0dJxeRhF7a2ngAQcfvU3GNEQFxOTbSYcXo5pdl rIlLJsaErEPTINtAuCoZ0TSM+Ai1qA9FMmi/6h/KTgySg2UfJ5I7hVq8A== 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=MOdpUSFSnVGb6VY+6OUa19Wtkh2mtbqEWADJwzRfn/Q=; b=NALeuyJR E/Lvv+W/FFWSAC/9cKZZU6i8qeAmGMKQ+h6cZR6F8ZJCMPzUNBLcipoZmtBz7iBM 3cWMuPAv5+b+XMd9i0HiavZ6o1BI7jP6Xua9qetjgL2v2yRaMQSUygo4hdiXa2o4 D+TZ8ddOfZJgTbO/DhNnH/oAmQwMCOFtoWYwLbkSR54PzZWtlsvydN2ltQpX4Xi6 MZR3w0Bb4R3hzxXW0o/TX/INbDi1hxzyVmse+1IAq28kz9WcTCpRK9lfOkICLPC3 qjuzqzsLLi0JoRMJMYBV/Q1UIYPZGThaqvZ0MbLh5srwGVdus6IYyQOwp1LyRroR 87B4szptnfagiw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepuddunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 5D8213064674; Fri, 30 Oct 2020 13:30:12 -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, John McNamara Date: Fri, 30 Oct 2020 18:29:38 +0100 Message-Id: <20201030172940.1073558-14-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 Subject: [dpdk-dev] [PATCH v5 13/15] examples/rxtx_callbacks: switch timestamp to dynamic 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. Signed-off-by: Thomas Monjalon --- examples/rxtx_callbacks/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 1a8e7d47d9..b1869a5ce8 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -19,6 +19,15 @@ #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 +static int hwts_dynfield_offset = -1; + +static inline rte_mbuf_timestamp_t * +hwts_field(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + hwts_dynfield_offset, rte_mbuf_timestamp_t *); +} + typedef uint64_t tsc_t; static int tsc_dynfield_offset = -1; @@ -77,7 +86,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused, for (i = 0; i < nb_pkts; i++) { cycles += now - *tsc_field(pkts[i]); if (hw_timestamping) - queue_ticks += ticks - pkts[i]->timestamp; + queue_ticks += ticks - *hwts_field(pkts[i]); } latency_numbers.total_cycles += cycles; @@ -141,6 +150,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) return -1; } port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TIMESTAMP; + hwts_dynfield_offset = rte_mbuf_dynfield_lookup( + RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); + if (hwts_dynfield_offset < 0) { + printf("ERROR: Failed to lookup timestamp field\n"); + return -rte_errno; + } } retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);