From patchwork Mon Oct 26 22:20:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 82254 X-Patchwork-Delegate: thomas@monjalon.net 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 8D88AA04DD; Mon, 26 Oct 2020 23:24:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D25358CD; Mon, 26 Oct 2020 23:21:03 +0100 (CET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id C1E692BD0 for ; Mon, 26 Oct 2020 23:20:54 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 726915C00DA; Mon, 26 Oct 2020 18:20:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 26 Oct 2020 18:20:53 -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=QghJ+f9eDw4X6 0gFNigqb9tWEs/gT3YH9380UIq0jaM=; b=C0qrdx0+kE6ohkZi08EZr3nIjRzyr Axwni+4o5i8om4XOj3MeHoV2SMyXo1qv/X1NIPklTSbBZWWOYnv9S3et6iVbKaBi LyOpekaw7qOeiryjvmxLj1YFPCRWWtXOe42zCWU16CXMqwOTsJYx3Hb+dnZeDWVR vBXdiQ06m2iJmYUyOxwY0Ojyb+UyktAe4iDtJlS1o41oKhsVK/GA1mP6rXrUZ5aZ Lsd+GT2VqaVjoYfcM1cyDt9q7BuMLzYk3X1uCjajjNXZBSrjbTEXHZEyolsorI8M fVzpw6pfJOdwQle1f8ZBUx5RaF1D+f1ck9M4Nv/xs798nsRqJ9nCuVmiw== 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=QghJ+f9eDw4X60gFNigqb9tWEs/gT3YH9380UIq0jaM=; b=coGPmQcY ogHksTuwUtYmAX6rVAqeOK9BkRSTLOh5699zK+EPW3cyRKpSaCnYE6ZotRzNwJ+8 uqA44XNUDR6rWCQCtlmLgpKC8xWg5BPz7uumxkaapEjVZMjpSzH7uh8mL3t3eDbp DZ6JOBuI5meOOx2PEaa7lZGBPQ1tWKcGnNDF72JoYY2t6Cp9yhvIK3VBQ30c3ppT s7hGnQJrMGw7H3iJJmaI26dhX9ZHPEjBGYeq7SQROT9HPJTu3KSNFk69g/7GY6so FDAoiIVO/UxzuQwmdxd+3k3s/3Cpb9GHjb7JS759zpgvibZNKH5J126cqjQwnzkr xY69XZ4jjuoIzA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeejgdduvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeduvdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 662953064610; Mon, 26 Oct 2020 18:20:52 -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, John McNamara Date: Mon, 26 Oct 2020 23:20:12 +0100 Message-Id: <20201026222013.2147904-15-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201026222013.2147904-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201026222013.2147904-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 14/15] examples/rxtx_callbacks: switch 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 example used the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64. Signed-off-by: Thomas Monjalon --- doc/guides/sample_app_ug/rxtx_callbacks.rst | 4 ++-- examples/rxtx_callbacks/main.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst b/doc/guides/sample_app_ug/rxtx_callbacks.rst index 62d1f39d7e..56c4293a1a 100644 --- a/doc/guides/sample_app_ug/rxtx_callbacks.rst +++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst @@ -152,7 +152,7 @@ all packets received: uint64_t now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) - pkts[i]->udata64 = now; + TSC_FIELD(pkts[i]) = now; return nb_pkts; } @@ -179,7 +179,7 @@ packets prior to transmission: unsigned i; for (i = 0; i < nb_pkts; i++) - cycles += now - pkts[i]->udata64; + cycles += now - TSC_FIELD(pkts[i]); latency_numbers.total_cycles += cycles; latency_numbers.total_pkts += nb_pkts; diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 6fe39546dd..db3412dafe 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -10,6 +10,7 @@ #include #include #include +#include #define RX_RING_SIZE 1024 #define TX_RING_SIZE 1024 @@ -18,6 +19,11 @@ #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 +static int tsc_dynfield_offset; +#define TSC_FIELD_TYPE uint64_t +#define TSC_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + tsc_dynfield_offset, TSC_FIELD_TYPE *)) + static const char usage[] = "%s EAL_ARGS -- [-t]\n"; @@ -47,7 +53,7 @@ add_timestamps(uint16_t port __rte_unused, uint16_t qidx __rte_unused, uint64_t now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) - pkts[i]->udata64 = now; + TSC_FIELD(pkts[i]) = now; return nb_pkts; } @@ -65,7 +71,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused, rte_eth_read_clock(port, &ticks); for (i = 0; i < nb_pkts; i++) { - cycles += now - pkts[i]->udata64; + cycles += now - TSC_FIELD(pkts[i]); if (hw_timestamping) queue_ticks += ticks - pkts[i]->timestamp; } @@ -261,6 +267,11 @@ main(int argc, char *argv[]) }; int opt, option_index; + static const struct rte_mbuf_dynfield tsc_dynfield_desc = { + .name = "example_bbdev_dynfield_tsc", + .size = sizeof(TSC_FIELD_TYPE), + .align = __alignof__(TSC_FIELD_TYPE), + }; /* init EAL */ int ret = rte_eal_init(argc, argv); @@ -292,6 +303,11 @@ main(int argc, char *argv[]) if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); + tsc_dynfield_offset = + rte_mbuf_dynfield_register(&tsc_dynfield_desc); + if (tsc_dynfield_offset < 0) + rte_exit(EXIT_FAILURE, "Cannot register mbuf field\n"); + /* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0)