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 188A1A04E6; Fri, 30 Oct 2020 18:30:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D843567C; Fri, 30 Oct 2020 18:29:58 +0100 (CET) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id DEA584C6C for ; Fri, 30 Oct 2020 18:29:53 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 943B2580650; Fri, 30 Oct 2020 13:29:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:29:52 -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=a1vfCLFKGlHPvieIIEHFY68HSNonv skEF+PR7LASUEFSqjs0RVRk/XQj9oCXVvEgi0yRRPFL66hL5A4677DmUQndVAteD SZa7Yd/IFgswh9F+yeQAiRv1qvYkj91Y1votjMJEAqAIjJm6BC68YcZZVM3EqEDf ESbOspYBsuDRyymjOf0kP6muQImjdg4ffhVRpEdkiC6snL2w1hdaSybaORTFi0Dr MTL1v7lIm3SsuDveZ4tPZkP/6Xt4bKk5KG9H0zm+S/fFW/hn6MI1AZgQyzvo8ECf DPZQu4w0dAcehoQeHti/gyxpremaPJmoJwxj4slgT6Be2RhsTr7nRQwyw== 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=bysDvjSp HsGyOjWGFbGoziDZUFCi5O4OUOF0/rpAae+VQH7rOr3Er0nUQscLto+h8TxRVLXK +y/fK9vx9NaXawrvbJVkHbJtqZx0R+5lLkUSM0CqumnIO3IO0CnCCbG11CuO3spu 0PgM3k7abHDbXT3DJ5ceBhTw8+1GO5nNyNTc30XVjr8Lvj504m5qJlGD5icNJPTC NdvR4sCkeYxf3QCrVS7+rcca1g459He2yl0DunXJylW484dAml+cU2cCFpdpG7F0 17HZu7fW1CjIS3ITUl96NkqNbc7oNh0FAhcbEVPruibsv++rIvbastVYwGq8C35X ZA32MJO9Uuy2gg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdeliecutefuodetggdotefrodftvf 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 E1099306467D; Fri, 30 Oct 2020 13:29:50 -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, Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Date: Fri, 30 Oct 2020 18:29:28 +0100 Message-Id: <20201030172940.1073558-4-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 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