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 874C4A04DD; Thu, 29 Oct 2020 10:29:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B98AC8B0; Thu, 29 Oct 2020 10:28:12 +0100 (CET) Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by dpdk.org (Postfix) with ESMTP id BDD12C884 for ; Thu, 29 Oct 2020 10:28:07 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id DE941972; Thu, 29 Oct 2020 05:28:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 29 Oct 2020 05:28:05 -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=QyZVbia3vs6/U MqiDG5Uw6jan9+5GxOcIEB4g7FcJM8=; b=KaEkSoFmuaw1bE+2NAzcnhg8nfQ8c fAIMkKi7J5zxKJy3n3FBd3Heqds6p4hpG+zCbHFkUI36kHWaHXsu8o88j637GLk4 rPAqMRlNqiz152+RezMxaodD9/Dql75yPVu2cbqOLl+vRUultSIbvxgcnEUWV4R+ C1AVTWlQ6ssuX1XGcL/tdYp0jKwIBRx50Qds5/W8oYgmf2aEvzqGrR8H0lfA+yUN zTQOP2PKdS1Wzhf15D0nTjHEZbA5rUOpGOi4n6RDFdE6ybn2ppP4UEGA8dtGRDAl QUpX0iyyOewzMH3fd+mPNQ5W1HTigv6w5KohQ+l6EkaBMiwBJNPzEVLUw== 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=QyZVbia3vs6/UMqiDG5Uw6jan9+5GxOcIEB4g7FcJM8=; b=XSsbFsZT jdWYnFB2bXG+dpG+EvRltSf3iKOsFDtp/MOSI3BkkxWKQ8gfSyZkCOck9WQnCbMU YOVQmymsDSfr+D/z2XeSvXf9TkuGPduSQzrVn8kybjaEp0TJ7XzNnr1e4W90x1VJ ZtC4qVPPZl+kGnRDB+CiHET35SAEnZpoxsYCsUchnyG8Xav4OqcdRd/1xDAg0KHy ekiETIj6pkE2ERAM8J6mspjqZOdZGUJCZ2vld7v3RDXvSCupkXQKzHQuDP1eVQFF B95Fdz1IUcmo7tWkM0wCo8Zpneu96Cjh/gtO2tAz2BpzcZ4s49cZoy6+yVyO3o6l b9j+19gfv9QwLQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleefgddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho 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 0E4C33280063; Thu, 29 Oct 2020 05:28:02 -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, jerinj@marvell.com, viacheslavo@nvidia.com, Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Matan Azrad , Shahaf Shuler Date: Thu, 29 Oct 2020 10:27:38 +0100 Message-Id: <20201029092751.3837177-4-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029092751.3837177-1-thomas@monjalon.net> References: <20201029092751.3837177-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 03/15] 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" 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 --- app/test-pmd/config.c | 38 ------------------ doc/guides/nics/mlx5.rst | 5 +-- lib/librte_ethdev/rte_ethdev.c | 70 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 9 ++++- lib/librte_mbuf/rte_mbuf_dyn.h | 1 + 5 files changed, 81 insertions(+), 42 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1668ae3238..9a2baf16fe 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3955,44 +3955,6 @@ show_tx_pkt_times(void) void set_tx_pkt_times(unsigned int *tx_times) { - uint16_t port_id; - int offload_found = 0; - int offset; - int flag; - - static const struct rte_mbuf_dynfield desc_offs = { - .name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, - .size = sizeof(uint64_t), - .align = __alignof__(uint64_t), - }; - static const struct rte_mbuf_dynflag desc_flag = { - .name = RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, - }; - - RTE_ETH_FOREACH_DEV(port_id) { - struct rte_eth_dev_info dev_info = { 0 }; - int ret; - - ret = rte_eth_dev_info_get(port_id, &dev_info); - if (ret == 0 && dev_info.tx_offload_capa & - DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) { - offload_found = 1; - break; - } - } - if (!offload_found) { - printf("No device supporting Tx timestamp scheduling found, " - "dynamic flag and field not registered\n"); - return; - } - offset = rte_mbuf_dynfield_register(&desc_offs); - if (offset < 0 && rte_errno != EEXIST) - printf("Dynamic timestamp field registration error: %d", - rte_errno); - flag = rte_mbuf_dynflag_register(&desc_flag); - if (flag < 0 && rte_errno != EEXIST) - printf("Dynamic timestamp flag registration error: %d", - rte_errno); tx_pkt_times_inter = tx_times[0]; tx_pkt_times_intra = tx_times[1]; } diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index afa65a1379..fa8b13dd1b 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -237,9 +237,8 @@ Limitations ``txq_inline_max`` and ``txq_inline_mpw`` devargs keys. - To provide the packet send scheduling on mbuf timestamps the ``tx_pp`` - parameter should be specified, RTE_MBUF_DYNFIELD_TIMESTAMP_NAME and - RTE_MBUF_DYNFLAG_TIMESTAMP_NAME should be registered by application. - When PMD sees the RTE_MBUF_DYNFLAG_TIMESTAMP_NAME set on the packet + parameter should be specified. + When PMD sees the RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME set on the packet being sent it tries to synchronize the time of packet appearing on the wire with the specified packet timestamp. It the specified one is in the past it should be ignored, if one is in the distant future diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b12bb3854d..7c9aadb461 100644 --- 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,59 @@ 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, + }; + static bool done_rx, done_tx; + bool todo_rx, todo_tx; + int offset; + + todo_rx = (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP) != 0 + && !done_rx; + todo_tx = (tx_offloads & DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) != 0 + && !done_tx; + + 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; + } + done_rx = true; + } + 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; + } + done_tx = true; + } + + return 0; +} + /* * Validate offloads that are requested through rte_eth_dev_configure against * the offloads successfully set by the ethernet device. @@ -1481,6 +1535,12 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, goto rollback; } + /* Register mbuf field and flags for timestamp offloads if enabled. */ + ret = eth_dev_timestamp_mbuf_register(dev_conf->rxmode.offloads, + dev_conf->txmode.offloads); + if (ret != 0) + goto rollback; + /* * Setup new number of RX/TX queues and reconfigure device. */ @@ -2088,6 +2148,11 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, return ret; } + /* Register mbuf field and flag for Rx timestamp offload if enabled. */ + ret = eth_dev_timestamp_mbuf_register(local_conf.offloads, 0); + if (ret != 0) + return ret; + ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, socket_id, &local_conf, mp); if (!ret) { @@ -2268,6 +2333,11 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, return -EINVAL; } + /* Register mbuf field and flag for Tx timestamp offload if enabled. */ + ret = eth_dev_timestamp_mbuf_register(0, local_conf.offloads); + if (ret != 0) + return ret; + rte_ethdev_trace_txq_setup(port_id, tx_queue_id, nb_tx_desc, tx_conf); return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc, socket_id, &local_conf)); diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index ba997f16ce..3be0050592 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1344,6 +1344,9 @@ struct rte_eth_conf { #define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400 #define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800 #define DEV_RX_OFFLOAD_SCATTER 0x00002000 +/** + * The mbuf field and flag are registered when the offload is configured. + */ #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000 #define DEV_RX_OFFLOAD_SECURITY 0x00008000 #define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000 @@ -1408,7 +1411,11 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000 /** Device supports outer UDP checksum */ #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000 -/** Device supports send on timestamp */ +/** + * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME + * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags. + * The mbuf field and flag are registered when the offload is configured. + */ #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000 /* * If new Tx offload capabilities are defined, they also must be diff --git a/lib/librte_mbuf/rte_mbuf_dyn.h b/lib/librte_mbuf/rte_mbuf_dyn.h index 5fb85c0610..d4d8f66f77 100644 --- a/lib/librte_mbuf/rte_mbuf_dyn.h +++ b/lib/librte_mbuf/rte_mbuf_dyn.h @@ -260,6 +260,7 @@ void rte_mbuf_dyn_dump(FILE *out); * used by PMD to schedule packet sending. */ #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. -- 2.28.0