From patchwork Tue Apr 7 22:26:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 67914 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2FD9BA0588; Wed, 8 Apr 2020 00:27:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 825981BFD4; Wed, 8 Apr 2020 00:26:57 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id BBD361BFC6 for ; Wed, 8 Apr 2020 00:26:56 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 561975C01BD; Tue, 7 Apr 2020 18:26:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 07 Apr 2020 18:26:56 -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=mesmtp; bh=MwSgVm7eYQ Xt+xuSPj5JKTYtPlAj0T0drqZZ5+PqQbk=; b=RGnUF2TWMQJo+2ZoDckexIt6fD vP5ldrQd5PqWCJia/WrM5iacLFqfC/Y2EdflmCDMEUZ4n+o4V/A5r2gVYDW++S9Q Zx+eca7JCCf8XJAyfpw4svb6M7ZhRLw9KpRlYnnA8scUFYh1sNHWopLqjzHpRQc4 i6l4PZj2FP1lov5Qo= 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= fm2; bh=MwSgVm7eYQXt+xuSPj5JKTYtPlAj0T0drqZZ5+PqQbk=; b=guQQ/tVL ufaK8pCTHmRK9GRZgQcU19v+YNETkocHJ7/BQTNyQRxu3BDFR9iCuThceFuGBJDS aLVAdB3KYqNwLW+/IqD3TapQ9JupFFgQzdlkRKwt9WCrkAcuvFE9VU1gODYOxo6B uP3FFwFuzPPPYhl8hyvdkjRJHwz3DG3nv0fHU1N6OVqUVuphcilWV0pfkjvUJ/+s BY8jO525IQdFr6t0pQc2FbLk+EmadNPycakGhHqQcRRNPVs2ZhpYvA2M/g3JNRHU fizklwqeNPb2qQt/OfxDvQmTnhfytLoAKYgrpWyNt4mDurNhCz/T6Y5PLKL5B3t8 9s7bJyBfvETzSg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeigddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth 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 3404E3280059; Tue, 7 Apr 2020 18:26:55 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: Ferruh Yigit , Andrew Rybchenko Date: Wed, 8 Apr 2020 00:26:36 +0200 Message-Id: <20200407222637.55289-2-thomas@monjalon.net> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407222637.55289-1-thomas@monjalon.net> References: <98CBD80474FA8B44BF855DF32C47DC35C60F3C@smartserver.smartshare.dk> <20200407222637.55289-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos 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" There are two function to retrieve link informations. The only small difference is a boolean timeout parameter. Adding a new static function, with an additional parameter, removes the code redundancy. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 52 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 0854ef8832..0df39dff97 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2332,44 +2332,36 @@ rte_eth_allmulticast_get(uint16_t port_id) return dev->data->all_multicast; } +static int +get_link_infos(uint16_t port_id, struct rte_eth_link *eth_link, int wait) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (dev->data->dev_conf.intr_conf.lsc && + dev->data->dev_started) + rte_eth_linkstatus_get(dev, eth_link); + else { + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP); + (*dev->dev_ops->link_update)(dev, wait); + *eth_link = dev->data->dev_link; + } + + return 0; +} + int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link) { - struct rte_eth_dev *dev; - - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - dev = &rte_eth_devices[port_id]; - - if (dev->data->dev_conf.intr_conf.lsc && - dev->data->dev_started) - rte_eth_linkstatus_get(dev, eth_link); - else { - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP); - (*dev->dev_ops->link_update)(dev, 1); - *eth_link = dev->data->dev_link; - } - - return 0; + return get_link_infos(port_id, eth_link, 1); } int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) { - struct rte_eth_dev *dev; - - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - dev = &rte_eth_devices[port_id]; - - if (dev->data->dev_conf.intr_conf.lsc && - dev->data->dev_started) - rte_eth_linkstatus_get(dev, eth_link); - else { - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP); - (*dev->dev_ops->link_update)(dev, 0); - *eth_link = dev->data->dev_link; - } - - return 0; + return get_link_infos(port_id, eth_link, 0); } int From patchwork Tue Apr 7 22:26:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 67915 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED1DFA0588; Wed, 8 Apr 2020 00:27:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 629481C023; Wed, 8 Apr 2020 00:27:08 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id A43B31BF9D for ; Wed, 8 Apr 2020 00:27:06 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 579C35C01BF; Tue, 7 Apr 2020 18:27:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 07 Apr 2020 18:27: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-type:content-transfer-encoding; s=mesmtp; bh=N/VmChbwUSycaxMZYOHtcWF5DE7MQaAJnEBWy5twlk0=; b=V+7t1HSMooFl tVn+/pqe/hN8K/ZXSbQH8ieEPnU/XKCxFfuZ19O+oyX/NZxcP3GvFKxxzqZH0Z4z XYZ+36Ycg1A5w61axdO3vcNhdmZmqNGfccwBVeKNeuqNF2dfpMWSxn8y1+hvKifH RNo8/XCJWE61s3X19EYbglSAIQ/BlTs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :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=fm2; bh=N/VmChbwUSycaxMZYOHtcWF5DE7MQaAJnEBWy5twl k0=; b=k2SM6lss/R9t/3wG1P3dG7sZ24up9E2decfL+R/SEIxRuPocq+JBsAGjb 2FhKgM/gn1+00CSq+y7UbMEuc9CJwM1Av88Cr2Dvq06WOQIq/VU/L9fzPVL84sin MArw6BkJdXfUvYqIkDTK4jtkzeMYHJZnBX616r45+F5W+uLP3ekjqJXCPWqIiHYE ni+u8br1SJ35kCkVeYnCQQ+Zjtl7eoQvQYpLM8LVJB3G7tPyX5NuEE6u6VffifTD BnKpgc6qWCWBHJ3ZvAivk4woEXsbZ4EEybURcdEKcoJWefpoyvuNoosZTXN0NT87 3tdNU6Iggu+fhxOLVCSbugTU4cXug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeigddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukf hppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght 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 E6E573280067; Tue, 7 Apr 2020 18:27:03 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: =?utf-8?q?Morten_Br=C3=B8rup?= , Benoit Ganne , Ferruh Yigit , Andrew Rybchenko Date: Wed, 8 Apr 2020 00:26:37 +0200 Message-Id: <20200407222637.55289-3-thomas@monjalon.net> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407222637.55289-1-thomas@monjalon.net> References: <98CBD80474FA8B44BF855DF32C47DC35C60F3C@smartserver.smartshare.dk> <20200407222637.55289-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/2] ethdev: allow unknown link speed 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" When querying the link informations, the link status is a mandatory major information. Other boolean values are supposed to be accurate: - duplex mode (half/full) - negotiation (auto/fixed) This API update is making explicit that the link speed information is optional. The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases: - speed is not known by the driver - device is virtual Suggested-by: Morten Brørup Suggested-by: Benoit Ganne Signed-off-by: Thomas Monjalon --- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d1a593ad11..2d51fd3444 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -300,6 +300,7 @@ struct rte_eth_stats { #define ETH_SPEED_NUM_50G 50000 /**< 50 Gbps */ #define ETH_SPEED_NUM_56G 56000 /**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000 /**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port. @@ -2245,15 +2246,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id); int rte_eth_allmulticast_get(uint16_t port_id); /** - * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX - * or FULL-DUPLEX) of the physical link of an Ethernet device. It might need - * to wait up to 9 seconds in it. + * Retrieve the link status (up/down), the duplex mode (half/full), + * the negotiation (auto/fixed), and if available, the speed (Mbps). + * + * It might need to wait up to 9 seconds. + * @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link - * A pointer to an *rte_eth_link* structure to be filled with - * the status, the speed and the mode of the Ethernet device link. + * Link informations written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver. @@ -2262,15 +2264,13 @@ int rte_eth_allmulticast_get(uint16_t port_id); int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); /** - * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX - * or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait - * version of rte_eth_link_get(). + * Retrieve the link status (up/down), the duplex mode (half/full), + * the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link - * A pointer to an *rte_eth_link* structure to be filled with - * the status, the speed and the mode of the Ethernet device link. + * Link informations written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.