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 2830AA0521; Tue, 3 Nov 2020 10:34:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9B345C82C; Tue, 3 Nov 2020 10:33:59 +0100 (CET) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id 13D57C820 for ; Tue, 3 Nov 2020 10:33:57 +0100 (CET) Received: by mail-wm1-f67.google.com with SMTP id e2so12064968wme.1 for ; Tue, 03 Nov 2020 01:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/tNgqc5TuHa6Iv6Zift1Sd8xYpQQRz7SsV2BgXLcse4=; b=Sa3jBR6ja+S5hQy1neD578481J9Xw0DDF5+w8luIIho/AOuTRZ7bjtLPKKNSoP/9hU LSWKtzeNzI1H2qvh6Lx3sU6tK21UtQsbicu4f4KqjnPZVZClVfkLei6xRdI/ohd6K/rh m6NAZEw6dPy3aSr9wsYYKSqq7DEistpE6VDHijexAwcPlgUm4wDEiGH3gEKWD+nSA9/z 7cNF4dK31tghOT/fJLqehWK8M3Q3uBDuIS/xxIurb7FdTrfvJUUS0d0zfa3tMoEUhm7g c3/IlbBJ7P7syZhhnsrui+N7evc2eHM/iJzSrRQk28m86XNYRIGl17+fN3ZUNhF8CEom Gddg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/tNgqc5TuHa6Iv6Zift1Sd8xYpQQRz7SsV2BgXLcse4=; b=TyR877MhC+bTfV+XXVKjgoAM1ZDyt7C7MznGIzTIGaqzLVQzGoc9/oCOJniVBk4sIJ MDDgnASEAnPQRBfB4B+D10SqO3emm7Yhvwzz5tUDhW4c4Md4YmM6vgOA5cPEmqEhpl0P 7fh2pGuWyvOLypLOYLHbARbqM60iwNKRI3S4iniaEYLmkUOKI4oPXS57i5NZY9fB5xn+ WWLR6mTV8hLEdMgDCpNJ1ppG6FnccoodkHKCnFU1xcg4VnCHdYOHOYU6MY84a9X5z76m zXWhACcEjiP+OqEZua79LEwpCzFH/ozZHZiWLnaA9QEen8Cy1w+WV7sKLe2fOUlI7e4S 4Ebg== X-Gm-Message-State: AOAM5321QKf1QhJG3HuikCqg79hF1BDUXRIWMU9H3gjuGxfMqfm+UcYz UDnmAw9fyAjsdpLeXhDNBsZnKg== X-Google-Smtp-Source: ABdhPJw6B+evNLAwkM8L56FvgKoUesOlzn3iv89+6lTDQVQlfbGLQEM4AXt4tb+x3kWPLoUjyNyrSA== X-Received: by 2002:a1c:ed06:: with SMTP id l6mr2543528wmh.67.1604396036685; Tue, 03 Nov 2020 01:33:56 -0800 (PST) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id n4sm2258072wmi.32.2020.11.03.01.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 01:33:55 -0800 (PST) Date: Tue, 3 Nov 2020 10:33:55 +0100 From: Olivier Matz To: Thomas Monjalon Cc: dev@dpdk.org, ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, andrew.rybchenko@oktetlabs.ru, jerinj@marvell.com, viacheslavo@nvidia.com, Ray Kinsella , Neil Horman Message-ID: <20201103093355.GB1898@platinum> References: <20201029092751.3837177-1-thomas@monjalon.net> <20201103001407.2931963-1-thomas@monjalon.net> <20201103001407.2931963-3-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103001407.2931963-3-thomas@monjalon.net> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH v3 02/16] mbuf: add Rx timestamp flag and helpers 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" Hi Thomas, On Tue, Nov 03, 2020 at 01:13:53AM +0100, Thomas Monjalon wrote: > There is already a dynamic field for timestamp, > used only for Tx scheduling with the dedicated Tx offload flag. > The same field can be used for Rx timestamp filled by drivers. > > A new dynamic flag is defined for Rx usage. > A new function wraps the registration of both field and Rx flag. > The type rte_mbuf_timestamp_t is defined for the API users. > > After migrating all Rx timestamp usages, it will be possible > to remove the deprecated timestamp field. > > Signed-off-by: Thomas Monjalon > --- > lib/librte_mbuf/rte_mbuf_dyn.c | 43 ++++++++++++++++++++++++++++++++++ > lib/librte_mbuf/rte_mbuf_dyn.h | 33 ++++++++++++++++++++++---- > lib/librte_mbuf/version.map | 1 + > 3 files changed, 72 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c > index 538a43f695..e279b23aea 100644 > --- a/lib/librte_mbuf/rte_mbuf_dyn.c > +++ b/lib/librte_mbuf/rte_mbuf_dyn.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -569,3 +570,45 @@ void rte_mbuf_dyn_dump(FILE *out) > > rte_mcfg_tailq_write_unlock(); > } > + > +static int > +rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag, > + const char *direction, const char *flag_name) > +{ > + static const struct rte_mbuf_dynfield field_desc = { > + .name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, > + .size = sizeof(rte_mbuf_timestamp_t), > + .align = __alignof__(rte_mbuf_timestamp_t), > + }; > + struct rte_mbuf_dynflag flag_desc; > + int offset; > + > + offset = rte_mbuf_dynfield_register(&field_desc); > + if (offset < 0) { > + RTE_LOG(ERR, MBUF, > + "Failed to register mbuf field for timestamp\n"); > + return -1; > + } > + if (field_offset != NULL) > + *field_offset = offset; > + > + strlcpy(flag_desc.name, flag_name, sizeof flag_desc.name); The rest of the flag_desc structure is not initialized to 0 (the "flags" field). I suggest to do it at declaration: struct rte_mbuf_dynflag flag_desc = { 0 }; > + offset = rte_mbuf_dynflag_register(&flag_desc); > + if (offset < 0) { > + RTE_LOG(ERR, MBUF, > + "Failed to register mbuf flag for %s timestamp\n", > + direction); > + return -1; > + } > + if (flag != NULL) > + *flag = RTE_BIT64(offset); > + > + return 0; > +} > + > +int > +rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag) > +{ > + return rte_mbuf_dyn_timestamp_register(field_offset, rx_flag, > + "Rx", RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME); > +} > diff --git a/lib/librte_mbuf/rte_mbuf_dyn.h b/lib/librte_mbuf/rte_mbuf_dyn.h > index 0ebac88b83..2e729ddaca 100644 > --- a/lib/librte_mbuf/rte_mbuf_dyn.h > +++ b/lib/librte_mbuf/rte_mbuf_dyn.h > @@ -258,13 +258,36 @@ void rte_mbuf_dyn_dump(FILE *out); > * timestamp. The dynamic Tx timestamp flag tells whether the field contains > * actual timestamp value for the packets being sent, this value can be > * used by PMD to schedule packet sending. > - * > - * After PKT_RX_TIMESTAMP flag and fixed timestamp field deprecation > - * and obsoleting, the dedicated Rx timestamp flag is supposed to be > - * introduced and the shared dynamic timestamp field will be used > - * to handle the timestamps on receiving datapath as well. > */ > #define RTE_MBUF_DYNFIELD_TIMESTAMP_NAME "rte_dynfield_timestamp" > +typedef uint64_t rte_mbuf_timestamp_t; > + > +/** > + * Indicate that the timestamp field in the mbuf was filled by the driver. > + */ > +#define RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME "rte_dynflag_rx_timestamp" > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Register dynamic mbuf field and flag for Rx timestamp. > + * > + * @param field_offset > + * Pointer to the offset of the registered mbuf field, can be NULL. > + * The same field is shared for Rx and Tx timestamp. > + * @param rx_flag > + * Pointer to the mask of the registered offload flag, can be NULL. > + * @return > + * 0 on success, -1 otherwise. > + * Possible values for rte_errno: > + * - EEXIST: already registered with different parameters. > + * - EPERM: called from a secondary process. > + * - ENOENT: no more field or flag available. > + * - ENOMEM: allocation failure. > + */ > +__rte_experimental > +int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag); > > /** > * When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME flag set on the > diff --git a/lib/librte_mbuf/version.map b/lib/librte_mbuf/version.map > index a011aaead3..0b66668bff 100644 > --- a/lib/librte_mbuf/version.map > +++ b/lib/librte_mbuf/version.map > @@ -42,6 +42,7 @@ EXPERIMENTAL { > rte_mbuf_dynflag_register; > rte_mbuf_dynflag_register_bitnum; > rte_mbuf_dyn_dump; > + rte_mbuf_dyn_rx_timestamp_register; > rte_pktmbuf_copy; > rte_pktmbuf_free_bulk; > rte_pktmbuf_pool_create_extbuf; > -- > 2.28.0 >