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 7BAF4A04E7; Mon, 2 Nov 2020 16:39:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5FEEBC93C; Mon, 2 Nov 2020 16:39:46 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 8151DC92A for ; Mon, 2 Nov 2020 16:39:44 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id 23so1295244wmg.1 for ; Mon, 02 Nov 2020 07:39:44 -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=wNaAJNKN4kcJJBDG8syv+Otox3TP3EezBPmPQBW5sCU=; b=Yuse78QPbw7y/NmNiR8ZVwFkP989Kf7XeWdprMCDXHlEmSoK+DFM7RzF6ssLZRFrRl h0Xrzp4TgsZTloLXreYDWcfHX4necsUbtx0AOgx97ZAtK/ufswaByYwmM1qT04DGeE26 3Tuws1VOUoNo9C4itL+PyY0eCF91V31QryCPnNC08PZ+Knl5lvax0+AmjuCFhekq4pa7 TGyJLLuNy3ewvCLfpFMiLHGg4rwZ8Z83FkWOA/Iff5ulJrW8qzli+pk/mggvvJAOgHgj BiX0qnff/S3PpYWZXuJhNDxVYAAXIXqhojeI7R7TjzDSnneEdMYYfIr7VExMzexLSixo KY3Q== 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=wNaAJNKN4kcJJBDG8syv+Otox3TP3EezBPmPQBW5sCU=; b=kC/0LTZKwHqFiFegiGkdbt2thx01KcXfRpayWijvZfdp0yC7yh5YFJlaw61PRpzYmy 97CeISX41zBakbShgNqkpXCvX8U20vy/4mtl4i0QDbp/MHTVQBQqElpLlNtUWI6dzPk4 sdoeMMpvtLAEM/xgAwkjuH4yqs9loBPyYE0NNUToqBkPJbZLAKa+J/J7LLe4VXkZmwJ+ FX18IqwNThj+vU1VTvJqt5l7huL9oKpqRdlkWmXOz+9Nub4eGQGwIsvJwDIJ0tEeJqPL H6ICuYCxkGBBx2Va8HVaXozngEH9GbNVsmvgSXQYpfyS34G7Tb7ASX3UAs5eYQNBSbWf WKBg== X-Gm-Message-State: AOAM531uyxHLrJvgLYpiVG0WZPkrverB5LYpL7LqiLunrqSdEpTWEvWp yNZLvixTFfcbjq1Ob7ETqRGxPA== X-Google-Smtp-Source: ABdhPJxZZth73h5zfOP0FERXK3gAhgyuG4HVhC61sp3YK+ok7+QjsdmhR0vdFwoNxlBLPvTel9kubA== X-Received: by 2002:a1c:4144:: with SMTP id o65mr661443wma.39.1604331584253; Mon, 02 Nov 2020 07:39:44 -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 f1sm12468752wmj.3.2020.11.02.07.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 07:39:43 -0800 (PST) Date: Mon, 2 Nov 2020 16:39:43 +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, Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Matan Azrad , Shahaf Shuler Message-ID: <20201102153943.GZ1898@platinum> References: <20201029092751.3837177-1-thomas@monjalon.net> <20201101180626.2198868-1-thomas@monjalon.net> <20201101180626.2198868-4-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201101180626.2198868-4-thomas@monjalon.net> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH v2 03/14] ethdev: register mbuf field and flags for timestamp 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 Sun, Nov 01, 2020 at 07:06:15PM +0100, Thomas Monjalon wrote: > During port configure or queue setup, the offload flags > DEV_RX_OFFLOAD_TIMESTAMP and DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP > trigger the registration of the related mbuf field and flags. > > Previously, the Tx timestamp field and flag were registered in testpmd, > as described in mlx5 guide. > For the general usage of Rx and Tx timestamps, > managing registrations inside ethdev is simpler and properly documented. > > Signed-off-by: Thomas Monjalon > Reviewed-by: Andrew Rybchenko <...> > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1232,6 +1233,54 @@ eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size, > return ret; > } > > +static inline int > +eth_dev_timestamp_mbuf_register(uint64_t rx_offloads, uint64_t tx_offloads) > +{ > + 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), > + }; > + static const struct rte_mbuf_dynflag rx_flag_desc = { > + .name = RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, > + }; > + static const struct rte_mbuf_dynflag tx_flag_desc = { > + .name = RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, > + }; > + bool todo_rx, todo_tx; > + int offset; > + > + todo_rx = (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP) != 0; > + todo_tx = (tx_offloads & DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) != 0; > + > + if (todo_rx || todo_tx) { > + offset = rte_mbuf_dynfield_register(&field_desc); > + if (offset < 0) { > + RTE_ETHDEV_LOG(ERR, > + "Failed to register mbuf field for timestamp\n"); > + return -rte_errno; > + } > + } > + if (todo_rx) { > + offset = rte_mbuf_dynflag_register(&rx_flag_desc); > + if (offset < 0) { > + RTE_ETHDEV_LOG(ERR, > + "Failed to register mbuf flag for Rx timestamp\n"); > + return -rte_errno; > + } > + } > + if (todo_tx) { > + offset = rte_mbuf_dynflag_register(&tx_flag_desc); > + if (offset < 0) { > + RTE_ETHDEV_LOG(ERR, > + "Failed to register mbuf flag for Tx timestamp\n"); > + return -rte_errno; > + } > + } > + > + return 0; > +} The code that registers the dynamic fields and flags for timestamp is more or less duplicated several times in the patchset. As discussed privately, it would make sense to have helpers to register them in one operation, without the need to redeclare the structures: int rte_mbuf_dyn_rx_timestamp_register(int *offset, uint64_t *rx_bitnum) int rte_mbuf_dyn_tx_timestamp_register(int *offset, uint64_t *tx_bitnum)