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 9E0CFA04E6; Fri, 30 Oct 2020 18:31:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 59C985916; Fri, 30 Oct 2020 18:30:08 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 9195F4C90 for ; Fri, 30 Oct 2020 18:29:55 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 44CA15C01FE; Fri, 30 Oct 2020 13:29:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:29:54 -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=/6iLpZ0x9cJlH 39sGii0tG4BQkFef1nNSvqD5l2mg5k=; b=WHucPcvVBSQN+qDUab3GO+oWuUaW1 5u91oEg+dTVjgzV0zSkJCblTUE3CkQL9cHifOFZ6SgKuY9Dp2bmaG2gXFmsyB/jd /4cCcR0Io2QM0NqfkU9xH5F+FTrJLBC+ktSgVp3N3VMdL9/hHEWwwq5pb/HzrMw2 9M8sYWUjaHc4M4Z3KTICdLN2t5a4gdScJqvF5V6qg8grwA44j5SXUoPHQjFiOeis jqTuQe0dyYtckBg3pE0UsgV927ZKXxHawese6tgc7n1O/XdZc5RSYxlAEWwRf3A5 xYQfyYVHxkYuQK/YB0pMi51zL8Bkm0PJZrFKyH2Wg7j11gmIqErFQwexA== 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=/6iLpZ0x9cJlH39sGii0tG4BQkFef1nNSvqD5l2mg5k=; b=Eie3Rjj0 1zfsiZ0PgqIybP9SJmsqZJEeLc+cgDRa1jIzecH6SKRdBN4XJKC4dDc2xxj2USkk GOqPzoY9KLonmveH4ITE7OLO7aM3M2LkQ2XdS00ll2T3unbUdcahedup5lLYjgNa 98J2aWGfrDerdGnrYUmRwNhCstrzz0H9VhbCTL5tiJNv6nI1wWjSp0h+qcMr8pn+ 8lFhnNgxA5JWWNxSHsm6enrpxGYT/CqgNMpXCKKw5cKVbVonf4CVJKy7HeS7/8Kd uPSrW92nV/B1N4SAu0/8vpWp3w7ghCdMWYaUeLMiCpfaDerczpZV1+hQJrdeLEsv HGN2KyhEX0ot5Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho 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 2495D306467E; Fri, 30 Oct 2020 13:29:53 -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, Reshma Pattan Date: Fri, 30 Oct 2020 18:29:29 +0100 Message-Id: <20201030172940.1073558-5-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 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 04/15] latency: switch timestamp 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 mbuf timestamp is moved to a dynamic field in order to allow removal of the deprecated static field. The related mbuf flag is also replaced with the dynamic one. Signed-off-by: Thomas Monjalon --- lib/librte_latencystats/rte_latencystats.c | 48 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c index ba2fff3bcb..a21f6239d9 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -8,7 +8,9 @@ #include #include +#include #include +#include #include #include #include @@ -31,6 +33,16 @@ latencystat_cycles_per_ns(void) /* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +static uint64_t timestamp_dynflag; +static int timestamp_dynfield_offset = -1; + +static inline rte_mbuf_timestamp_t * +timestamp_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + static const char *MZ_RTE_LATENCY_STATS = "rte_latencystats"; static int latency_stats_index; static uint64_t samp_intvl; @@ -128,10 +140,10 @@ add_time_stamps(uint16_t pid __rte_unused, diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; - if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) == 0 + if ((pkts[i]->ol_flags & timestamp_dynflag) == 0 && (timer_tsc >= samp_intvl)) { - pkts[i]->timestamp = now; - pkts[i]->ol_flags |= PKT_RX_TIMESTAMP; + *timestamp_dynfield(pkts[i]) = now; + pkts[i]->ol_flags |= timestamp_dynflag; timer_tsc = 0; } prev_tsc = now; @@ -161,8 +173,8 @@ calc_latency(uint16_t pid __rte_unused, now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP) - latency[cnt++] = now - pkts[i]->timestamp; + if (pkts[i]->ol_flags & timestamp_dynflag) + latency[cnt++] = now - *timestamp_dynfield(pkts[i]); } rte_spinlock_lock(&glob_stats->lock); @@ -204,6 +216,14 @@ int rte_latencystats_init(uint64_t app_samp_intvl, rte_latency_stats_flow_type_fn user_cb) { + static const struct rte_mbuf_dynfield timestamp_dynfield_desc = { + .name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, + .size = sizeof(rte_mbuf_timestamp_t), + .align = __alignof__(rte_mbuf_timestamp_t), + }; + static const struct rte_mbuf_dynflag timestamp_dynflag_desc = { + .name = RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, + }; unsigned int i; uint16_t pid; uint16_t qid; @@ -211,6 +231,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, const char *ptr_strings[NUM_LATENCY_STATS] = {0}; const struct rte_memzone *mz = NULL; const unsigned int flags = 0; + int timestamp_dynflag_offset; int ret; if (rte_memzone_lookup(MZ_RTE_LATENCY_STATS)) @@ -241,6 +262,23 @@ rte_latencystats_init(uint64_t app_samp_intvl, return -1; } + /* Register mbuf field and flag for Rx timestamp */ + timestamp_dynfield_offset = + rte_mbuf_dynfield_register(×tamp_dynfield_desc); + if (timestamp_dynfield_offset < 0) { + RTE_LOG(ERR, LATENCY_STATS, + "Cannot register mbuf field for timestamp\n"); + return -rte_errno; + } + timestamp_dynflag_offset = + rte_mbuf_dynflag_register(×tamp_dynflag_desc); + if (timestamp_dynflag_offset < 0) { + RTE_LOG(ERR, LATENCY_STATS, + "Cannot register mbuf field for timestamp\n"); + return -rte_errno; + } + timestamp_dynflag = RTE_BIT64(timestamp_dynflag_offset); + /** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; -- 2.28.0