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 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 Content-Transfer-Encoding: 8bit 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 --- 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 -- 2.26.0