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 D6782A04DD; Wed, 28 Oct 2020 11:31:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 30CA8CA90; Wed, 28 Oct 2020 11:27:46 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id EB025CA37 for ; Wed, 28 Oct 2020 11:27:29 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id A25FC5C01A3; Wed, 28 Oct 2020 06:27:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Oct 2020 06:27:29 -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=4yZj+8b1nOxb6 ehMxfOUTqIE3F/4Ed8jzYXpIR+VKNk=; b=dn3oNt53fRvWVC2c3G+Bmb6eYRQmm JY89+hgmWcj0K2GgPLmLlaQiOsjlqvf3P+EORxUrY9+dKzH4fuJZqTK/DpuBXvNw pdRfOEgUlFo7KMaUuG5ibH1nTUSVBWGnJJ3/m9WPWTjd1LRJghUYuTSPRV1P66vs 4jsuCuJAfccJqadsEaDeXklvY6/avpMXnhw7S0c7Y5k4kLh9JyiMP4k6UNh/FZha u9LWyekngkjGl7q7Cw9LyChyQfO/8qGF0rdUDBRtxz+C5EtLkZ0eNtTMAljyGgaW bm0gSYX7Mmj5VR/aKsDZUo0AiGUOdq4S+BiuitdrglMNmIjC2h07PupIA== 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=4yZj+8b1nOxb6ehMxfOUTqIE3F/4Ed8jzYXpIR+VKNk=; b=DeMwK5Mt nMZezv1aObd1a4aMvw8IKmq/gSt2mkccjHSnBvVkwcOqX+cQ64hlbDZi5C9/+rGI roy3yezNGOxSGSbyH+Z5Cw70wDPxKVlX81qQG5OiLjVyGzrymLy4VJqt070u+lol V7IFD6vQwYeveLD83NjVjbCKYKTeAsy3tU8XE934PuXpo/SExs4nRBS+aZxt0EvZ hsOxzdUo0jJ7pd8+7+ALoVfL2q3GgXVjdSjI7B4j+vE9Gy8lEMCdfJ3NdQ8Z3fBp cx8yNIf4+5agm8TJfjliBjWzZ5wkIZ8cShgAhbOay6UYpSY8I20OHExOE+olspLz MPC5qXGvyI/IaQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrledugdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepleenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 8DC473280060; Wed, 28 Oct 2020 06:27:28 -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: Wed, 28 Oct 2020 11:26:39 +0100 Message-Id: <20201028102640.3191964-15-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201028102640.3191964-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201028102640.3191964-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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..b9a98ceddc 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 +typedef uint64_t tsc_t; +static int tsc_dynfield_offset = -1; +#define TSC_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + tsc_dynfield_offset, tsc_t *)) + 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_t), + .align = __alignof__(tsc_t), + }; /* 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) -- 2.28.0