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 28E56A04E6; Fri, 30 Oct 2020 18:49:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 765492BFF; Fri, 30 Oct 2020 18:45:43 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 9690A5946 for ; Fri, 30 Oct 2020 18:45:16 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 4A04A5C0226; Fri, 30 Oct 2020 13:45:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:45:16 -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=tiaM3Au73WwaT RdFqBkQJUsMMBTubovz+d2J0K8CACE=; b=lxWZufSviUJGwmcPsw+XXyOkHx7bB k5sYEol8Nn8O5LxFij0PzfaZ6d3dIjUi34XZtLZXvjVAvRpYekPlCh4mSMmgQH7w bY9DeSGA/1dQx879QyB8gXJGqt9MTWvwwGGWcafBEIZBNSnRi4WSwzYHqWiN5ik4 SP0YJNchqxtK+jvkaenzyxoJkMJZo6c3JcGdzF4tS79IPfTX+NOXZ5//oj778pyM RGWPvoBi5L5zcS/1Rkjae0PgJa/74P41FfHtqS0N43FQd6r4DKC4ohqAc928QNn1 HR7UN3Qw2nRVT1VvJkjapMHaqhFyeG7A7C4zh/WTsQodwHOD18e8yjDHQ== 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=tiaM3Au73WwaTRdFqBkQJUsMMBTubovz+d2J0K8CACE=; b=WnEmioXz ecg9US1oloFHZdS66HL94r3kY1K8EWUn34vt54kg6/01dues7iG0/3q9hrBGqeps S9AwucatAyJz1M4QnvjnESCiV6psHiH1KXXt+ek/nPD/2P3CYOPykuKQal4rEQLa lSBqZpMiNzssq+bwPccfWFbpKtt9p8qpQShvuXru42gg2zdoMLzqTrizj4asIh3d WwnIj/+2rwe91WY2faXznUlh0u9teoqD4EAnb59URdfQ6UL5N+e3hD3ZjTwNWzjW RQROls3KsrE15awzgelDaIlbBN39aIawWYVPkgVpnDzqqcjb2u5wt5MDbVPX5kNa bKTA9I4WzhIPvA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdellecutefuodetggdotefrodftvf 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 39FF43064674; Fri, 30 Oct 2020 13:45:15 -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:44:40 +0100 Message-Id: <20201030174441.1076264-15-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030174441.1076264-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201030174441.1076264-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 14/15] examples/rxtx_callbacks: switch TSC 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 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 | 24 +++++++++++++++++++-- 2 files changed, 24 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..344446290b 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..1a8e7d47d9 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,15 @@ #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 +typedef uint64_t tsc_t; +static int tsc_dynfield_offset = -1; + +static inline tsc_t * +tsc_field(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, tsc_dynfield_offset, tsc_t *); +} + static const char usage[] = "%s EAL_ARGS -- [-t]\n"; @@ -47,7 +57,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 +75,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 +271,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 +307,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