From patchwork Mon Oct 26 05:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 82159 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 D167AA04B5; Mon, 26 Oct 2020 06:26:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A2EF55937; Mon, 26 Oct 2020 06:22:01 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 129BD4CA7 for ; Mon, 26 Oct 2020 06:21:52 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id B7BB85C0100; Mon, 26 Oct 2020 01:21:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 26 Oct 2020 01:21:51 -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=57+dhfkTTLluy vKGDU99KoyPvQVw3E+pbdGvWjTxhko=; b=RQC1pEw1OO+AkyI8ZYAgEtW/MwlPv 0EIrpkA5hObe62DEhCXVMYZzSaXTqervdSTDGC1zpeX/xCe/BuYRnjqxc170C9mi CbeXPKOy+zE2Pq+UhsK0wZwZbqWnWt3mEF6/PbEpBLvwdlu5Z+ItwSluDP0y8dFS lNK0pMnzcDGFE/DWROB8HCqONAMBS5p3Gj/mjPf2U1K0Pi5QEl4fpaOYrNhCa+RW ZvaKC3Vh0n/U58scBLI88PgLb3PTp4Tzn9HYvhUXU8bm5zedG6JbKdsjeerMggEm PqGrq0suyjTjqd/vvKrDgCI32zyndlEAQ2DrFaOkujDvmbfYq7OqsBg8w== 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=57+dhfkTTLluyvKGDU99KoyPvQVw3E+pbdGvWjTxhko=; b=q36XawO3 fJlyF3i2i2Kak3ifR6IJi23boDcmlp/4DifprEgv93oKwyQ2psUS+vURvqcwTi+e IAwFgkC75uPodChzcp+gaC913MgX2KZV23I6r95kWa5BU8V1Herr8NpWcK2vXCEW hFyZh0Et9wNWjP0dJ3ef4F1yerU0tX7D0aVz+OXCbZgvXyWEASawTkb1+UjOeBzy DYqPc3IsdWjF7DcXzvwLVHiL5k03jDIhd0CX1trKunE1ajwZ8a2ywQ7t8wf3XRPy TxnNlGP5RxtxJbO9zD0JT6T7MNSriSgywyps35BhaGPYFCAkIjXLJJIL6aAQmLCA NNu1e7nnUgnS9g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeehgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepuddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 789B13064674; Mon, 26 Oct 2020 01:21:50 -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 06:21:04 +0100 Message-Id: <20201026052105.1561859-15-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201026052105.1561859-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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. Note: RTE_MBUF_DYNFIELD_TIMESTAMP_NAME is an existing mbuf field name. Signed-off-by: Thomas Monjalon --- doc/guides/sample_app_ug/rxtx_callbacks.rst | 4 ++-- examples/rxtx_callbacks/main.c | 19 +++++++++++++++++-- 2 files changed, 19 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..8c3b49ae62 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; + TIMESTAMP_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 - TIMESTAMP_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..8f9852bf6f 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,10 @@ #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 +static int timestamp_dynfield_offset; +#define TIMESTAMP_FIELD(mbuf) \ + (*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset, uint64_t *)) + static const char usage[] = "%s EAL_ARGS -- [-t]\n"; @@ -47,7 +52,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; + TIMESTAMP_FIELD(pkts[i]) = now; return nb_pkts; } @@ -65,7 +70,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 - TIMESTAMP_FIELD(pkts[i]); if (hw_timestamping) queue_ticks += ticks - pkts[i]->timestamp; } @@ -261,6 +266,11 @@ main(int argc, char *argv[]) }; int opt, option_index; + static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, + .size = sizeof(uint64_t), + .align = __alignof__(uint64_t), + }; /* init EAL */ int ret = rte_eal_init(argc, argv); @@ -292,6 +302,11 @@ main(int argc, char *argv[]) if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); + timestamp_dynfield_offset = + rte_mbuf_dynfield_register(×tamp_dynfield_desc); + if (timestamp_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)