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 EA105A04B5; Thu, 29 Oct 2020 11:20:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4DADBC916; Thu, 29 Oct 2020 11:20:10 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by dpdk.org (Postfix) with ESMTP id 77D8CC864 for ; Thu, 29 Oct 2020 11:20:08 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 1C89F7F548; Thu, 29 Oct 2020 13:20:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1C89F7F548 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1603966807; bh=aWbXC5S/8vRQ2Pxrhov1w6aGzd6V/4Zh+bS5CRr7Ty4=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=dhxWUbZgbNc0yxNIj6QSKTiVtx+A7eHCXOqLq8qOiPkU4oXjiAJGL716Dz/jA5Sxq 0UWkkKjN1WejwrDZBSvr8JKCrhNDuSisZJnKUf2aV0trrIv59q7GKmGsnwALnuCk92 /VergU+QfSA90mSKg7OQNj16z6l9AEJWGnurCN50= To: Thomas Monjalon , dev@dpdk.org Cc: ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, olivier.matz@6wind.com, jerinj@marvell.com, viacheslavo@nvidia.com, Wenzhuo Lu , Beilei Xing , Bernard Iremonger References: <20201029092751.3837177-1-thomas@monjalon.net> <20201029092751.3837177-13-thomas@monjalon.net> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: Date: Thu, 29 Oct 2020 13:20:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201029092751.3837177-13-thomas@monjalon.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 12/15] app/testpmd: 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" On 10/29/20 12:27 PM, Thomas Monjalon wrote: > 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. > > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/util.c | 39 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) > > diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c > index 781a813759..eebb5166ad 100644 > --- a/app/test-pmd/util.c > +++ b/app/test-pmd/util.c > @@ -5,6 +5,7 @@ > > #include > > +#include > #include > #include > #include > @@ -22,6 +23,40 @@ print_ether_addr(const char *what, const struct rte_ether_addr *eth_addr) > printf("%s%s", what, buf); > } > > +static inline bool > +is_timestamp_enabled(const struct rte_mbuf *mbuf) > +{ > + static uint64_t timestamp_rx_dynflag; > + > + int timestamp_rx_dynflag_offset; > + > + if (timestamp_rx_dynflag == 0) { > + timestamp_rx_dynflag_offset = rte_mbuf_dynflag_lookup( > + RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, NULL); If the flag is not registered, it will try to lookup on every call. I'm not sure that it is good. > + if (timestamp_rx_dynflag_offset < 0) > + return false; > + timestamp_rx_dynflag = RTE_BIT64(timestamp_rx_dynflag_offset); > + } > + > + return (mbuf->ol_flags & timestamp_rx_dynflag) != 0; > +} > + > +static inline rte_mbuf_timestamp_t > +get_timestamp(const struct rte_mbuf *mbuf) > +{ > + static int timestamp_dynfield_offset = -1; > + > + if (timestamp_dynfield_offset < 0) { > + timestamp_dynfield_offset = rte_mbuf_dynfield_lookup( > + RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); same here > + if (timestamp_dynfield_offset < 0) > + return 0; > + } > + > + return *RTE_MBUF_DYNFIELD(mbuf, > + timestamp_dynfield_offset, rte_mbuf_timestamp_t *); > +} > + > static inline void > dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], > uint16_t nb_pkts, int is_rx) > @@ -107,8 +142,8 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], > printf("hash=0x%x ID=0x%x ", > mb->hash.fdir.hash, mb->hash.fdir.id); > } > - if (ol_flags & PKT_RX_TIMESTAMP) > - printf(" - timestamp %"PRIu64" ", mb->timestamp); > + if (is_timestamp_enabled(mb)) > + printf(" - timestamp %"PRIu64" ", get_timestamp(mb)); > if (ol_flags & PKT_RX_QINQ) > printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x", > mb->vlan_tci, mb->vlan_tci_outer); >