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 2E9F5A04DB; Thu, 15 Oct 2020 15:34:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 00FB91E975; Thu, 15 Oct 2020 15:31:35 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id B49291E945 for ; Thu, 15 Oct 2020 15:31:21 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.61]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 41E60600F3; Thu, 15 Oct 2020 13:31:20 +0000 (UTC) Received: from us4-mdac16-27.ut7.mdlocal (unknown [10.7.66.59]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 3E6C8800A4; Thu, 15 Oct 2020 13:31:20 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.174]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id BA0908006C; Thu, 15 Oct 2020 13:31:19 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 04C3E1C0098; Thu, 15 Oct 2020 13:31:19 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Oct 2020 14:31:13 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 15 Oct 2020 14:31:13 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09FDV9HY025271; Thu, 15 Oct 2020 14:31:13 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 4A2DC1613A9; Thu, 15 Oct 2020 14:31:09 +0100 (BST) From: Andrew Rybchenko To: Ray Kinsella , Neil Horman , "Thomas Monjalon" , Ferruh Yigit , Andrew Rybchenko CC: , Ivan Ilchenko Date: Thu, 15 Oct 2020 14:30:35 +0100 Message-ID: <1602768646-13142-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602768646-13142-1-git-send-email-arybchenko@solarflare.com> References: <1602682146-4722-1-git-send-email-arybchenko@solarflare.com> <1602768646-13142-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25726.003 X-TM-AS-Result: No-0.338000-8.000000-10 X-TMASE-MatchedRID: gX8VrEpETz5WSqhPlGB83xz2MDiYujy50mSc1YzbC53iYlKox3ryNARj Z4/TzBlyZcz/Uu/FtYOn93rCC6a9lnT3K3VineCfuwdUMMznEA8LKPaBHScRdT2mEJylgvfBcij MZrr2iZ2t2gtuWr1LmmiZWLI3MgipUAcCqG4Nmd4cLuEDP+gqckkQGNGmCuF4rdf6qWXIexlx1B wqk2Gx7fzWsjh29VQ4/StNdQuGxIdLn0r+bsqYxf3HILfxLV/9+wkHrk36xsxtw+n+iKWyyGrjw a8vt1tRVWY5roQd3og1I8VhEP37+ylNwXDXu2Rw/1dEgwtQ6NAwjY20D2quYpDgR3nlxgB62myG rIZlTgbi8zVgXoAltsIJ+4gwXrEtKsmEtKMlFWZdmxWUtUuClzjhqDosM+jps1auOy7gq//vt9k amZA7OdLkR472EQBKJ81bjJGEEobvXIi4jkOIlEEGfgQmZbw/X70xODkzZVa9Tbikt9AWZ0CBSG S7bIBtA1B/p1SzcogrKiD/U8b7SaNbPJBuvLaLnqg/VrSZEiM= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.338000-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25726.003 X-MDID: 1602768680-pEWZl0xYODFv X-PPE-DISP: 1602768680;pEWZl0xYODFv Subject: [dpdk-dev] [PATCH v2 01/11] ethdev: change eth dev stop function to return int 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" From: Ivan Ilchenko Change rte_eth_dev_stop() return value from void to int and return negative errno values in case of error conditions. Also update the usage of the function in ethdev according to the new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Acked-by: Thomas Monjalon --- doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_20_11.rst | 3 +++ lib/librte_ethdev/rte_ethdev.c | 27 +++++++++++++++++++------- lib/librte_ethdev/rte_ethdev.h | 5 ++++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index d1f5ed39db..2e04e24374 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -127,7 +127,6 @@ Deprecation Notices negative errno values to indicate various error conditions (e.g. invalid port ID, unsupported operation, failed operation): - - ``rte_eth_dev_stop`` - ``rte_eth_dev_close`` * ethdev: New offload flags ``DEV_RX_OFFLOAD_FLOW_MARK`` will be added in 19.11. diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index f8686a50db..c8c30937fa 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -355,6 +355,9 @@ API Changes * vhost: Add a new function ``rte_vhost_crypto_driver_start`` to be called instead of ``rte_vhost_driver_start`` by crypto applications. +* ethdev: changed ``rte_eth_dev_stop`` return value from ``void`` to + ``int`` to provide a way to report various error conditions. + ABI Changes ----------- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d9b82df073..b8cf04ef4d 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1661,7 +1661,7 @@ rte_eth_dev_start(uint16_t port_id) struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; int diag; - int ret; + int ret, ret_stop; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); @@ -1695,7 +1695,13 @@ rte_eth_dev_start(uint16_t port_id) RTE_ETHDEV_LOG(ERR, "Error during restoring configuration for device (port %u): %s\n", port_id, rte_strerror(-ret)); - rte_eth_dev_stop(port_id); + ret_stop = rte_eth_dev_stop(port_id); + if (ret_stop != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to stop device (port %u): %s\n", + port_id, rte_strerror(-ret_stop)); + } + return ret; } @@ -1708,26 +1714,28 @@ rte_eth_dev_start(uint16_t port_id) return 0; } -void +int rte_eth_dev_stop(uint16_t port_id) { struct rte_eth_dev *dev; - RTE_ETH_VALID_PORTID_OR_RET(port_id); + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; - RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -ENOTSUP); if (dev->data->dev_started == 0) { RTE_ETHDEV_LOG(INFO, "Device with port_id=%"PRIu16" already stopped\n", port_id); - return; + return 0; } dev->data->dev_started = 0; (*dev->dev_ops->dev_stop)(dev); rte_ethdev_trace_stop(port_id); + + return 0; } int @@ -1783,7 +1791,12 @@ rte_eth_dev_reset(uint16_t port_id) RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP); - rte_eth_dev_stop(port_id); + ret = rte_eth_dev_stop(port_id); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to stop device (port %u) before reset: %s - ignore\n", + port_id, rte_strerror(-ret)); + } ret = dev->dev_ops->dev_reset(dev); return eth_err(port_id, ret); diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index a61ca115a0..b85861cf2b 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2277,8 +2277,11 @@ int rte_eth_dev_start(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - 0: Success, Ethernet device stopped. + * - <0: Error code of the driver device stop function. */ -void rte_eth_dev_stop(uint16_t port_id); +int rte_eth_dev_stop(uint16_t port_id); /** * Link up an Ethernet device. -- 2.17.1