From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CF9C4740A for ; Mon, 9 Sep 2019 11:59:24 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 3CADA218DE for ; Mon, 9 Sep 2019 11:59:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CADA218DE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=solarflare.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 67B551EC96; Mon, 9 Sep 2019 13:59:13 +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 92D9E2C08 for ; Mon, 9 Sep 2019 13:59:06 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 58219B4005A; Mon, 9 Sep 2019 11:59:04 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 9 Sep 2019 04:59:01 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Mon, 9 Sep 2019 04:59:00 -0700 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 x89BwwnB027693; Mon, 9 Sep 2019 12:58:58 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id BBDEC1613D1; Mon, 9 Sep 2019 12:58:58 +0100 (BST) From: Andrew Rybchenko To: Neil Horman , John McNamara , Marko Kovacevic , Bernard Iremonger , Ori Kam , Bruce Richardson , "Pablo de Lara" , Radu Nicolau , Akhil Goyal , Tomasz Kantecki , Harry van Haaren , Xiaoyun Li , Thomas Monjalon , Ferruh Yigit CC: , Ivan Ilchenko Date: Mon, 9 Sep 2019 12:58:38 +0100 Message-ID: <1568030331-16526-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568030331-16526-1-git-send-email-arybchenko@solarflare.com> References: <1567699852-31693-1-git-send-email-arybchenko@solarflare.com> <1568030331-16526-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.5.1010-24898.005 X-TM-AS-Result: No-2.288400-4.000000-10 X-TMASE-MatchedRID: lHuKSapP4PBWSqhPlGB83yAI8aJmq0jw8boZEVitthhWm0JlHAu9AR/1 64dzHy5ihHMkSqTHaFfOJ0IyxDDCgcigY/XF8iwS2fov7TwhL8lj8vb8BkkBZIukmjWUj0k9cij MZrr2iZ2t2gtuWr1LmmiZWLI3MgipUAcCqG4Nmd4cLuEDP+gqckkQGNGmCuF4np9KgXcu34yNnB T9+Dm7M4sEQGUHUZ8zrQrECMFmvg+KhA2hG2DTq26HurDH4PpP3V4UShoTXacgcEd8uJSjxBUCx /X5xkUnv4pvasvMugApwItBoCVXY587xECPSepOOEqbf6/UkFDKIqAq0jIHiubnFWpNX1DBZd0G RVurhXF7gzb4fJeegNCMjbCUMvtzXT2tkBhml87N+qWlu2ZxaH/0yDqj7AyLAjg7CsbRHPgvLDE fPXW+FOLzNWBegCW2wgn7iDBesS3fd+P6wwCt8wml69OKUTCQgNh9Aqq8mQETSkX5P+hlBMtyVX zd7P3KG4KIk94HKscb3B+pHEXaMMOIlL8NSDkab5mWzgd0DmsuhSAji7sUVbzBU9kf8zyJ8Oycc FNBL2TKhETi2//sjuP9Cb59K8ACZrS+A8PszW+YV38c4KFOjw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--2.288400-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568030345-c0jUDAtMeBNj Subject: [dpdk-dev] [PATCH v2 01/13] ethdev: change promiscuous mode controllers to return errors 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_promiscuous_enable()/rte_eth_promiscuous_disable() return value from void to int and return negative errno values in case of error conditions. Modify usage of these functions across the ethdev according to new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_19_11.rst | 4 ++ doc/guides/sample_app_ug/flow_classify.rst | 6 ++- doc/guides/sample_app_ug/flow_filtering.rst | 15 +++++- doc/guides/sample_app_ug/rxtx_callbacks.rst | 5 +- doc/guides/sample_app_ug/skeleton.rst | 6 ++- lib/librte_ethdev/rte_ethdev.c | 52 ++++++++++++++++----- lib/librte_ethdev/rte_ethdev.h | 14 +++++- 8 files changed, 80 insertions(+), 23 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index cbb4c34efd..b2e0a1fc7c 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -88,7 +88,6 @@ Deprecation Notices negative errno values to indicate various error conditions (e.g. invalid port ID, unsupported operation, failed operation): - - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable`` - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable`` - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait`` - ``rte_eth_dev_stop`` diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 152f120197..5299157df7 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -97,6 +97,10 @@ API Changes * ethdev: changed ``rte_eth_dev_infos_get`` return value from ``void`` to ``int`` to provide a way to report various error conditions. +* ethdev: changed ``rte_eth_promiscuous_enable`` and + ``rte_eth_promiscuous_disable`` return value from ``void`` to ``int`` to + provide a way to report various error conditions. + ABI Changes ----------- diff --git a/doc/guides/sample_app_ug/flow_classify.rst b/doc/guides/sample_app_ug/flow_classify.rst index 96a5c66d0f..7c2b6dcf83 100644 --- a/doc/guides/sample_app_ug/flow_classify.rst +++ b/doc/guides/sample_app_ug/flow_classify.rst @@ -315,7 +315,9 @@ Forwarding application is shown below: addr.addr_bytes[4], addr.addr_bytes[5]); /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; } @@ -343,7 +345,7 @@ Finally the RX port is set in promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); The Add Rules function ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/sample_app_ug/flow_filtering.rst b/doc/guides/sample_app_ug/flow_filtering.rst index 02fc675506..de3e4ab0b6 100644 --- a/doc/guides/sample_app_ug/flow_filtering.rst +++ b/doc/guides/sample_app_ug/flow_filtering.rst @@ -193,7 +193,13 @@ application is shown below: } } - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + rte_exit(EXIT_FAILURE, + ":: cannot enable promiscuous mode: err=%d, port=%u\n", + ret, port_id); + } + ret = rte_eth_dev_start(port_id); if (ret < 0) { rte_exit(EXIT_FAILURE, @@ -278,7 +284,12 @@ We are setting the RX port to promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + rte_exit(EXIT_FAILURE, + ":: cannot enable promiscuous mode: err=%d, port=%u\n", + ret, port_id); + } The last step is to start the port. diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst b/doc/guides/sample_app_ug/rxtx_callbacks.rst index 32c120992f..0a69ec71ab 100644 --- a/doc/guides/sample_app_ug/rxtx_callbacks.rst +++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst @@ -117,8 +117,9 @@ comments: return retval; /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); - + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; /* Add the callbacks for RX and TX.*/ rte_eth_add_rx_callback(port, 0, add_timestamps, NULL); diff --git a/doc/guides/sample_app_ug/skeleton.rst b/doc/guides/sample_app_ug/skeleton.rst index 59ca511d33..1d0a2760d4 100644 --- a/doc/guides/sample_app_ug/skeleton.rst +++ b/doc/guides/sample_app_ug/skeleton.rst @@ -149,7 +149,9 @@ Forwarding application is shown below: return retval; /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; } @@ -177,7 +179,7 @@ Finally the RX port is set in promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); The Lcores Main diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 30b0c7803f..b97dd8aa85 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1381,24 +1381,41 @@ rte_eth_dev_mac_restore(struct rte_eth_dev *dev, } } -static void +static int rte_eth_dev_config_restore(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info, uint16_t port_id) { + int ret; + if (!(*dev_info->dev_flags & RTE_ETH_DEV_NOLIVE_MAC_ADDR)) rte_eth_dev_mac_restore(dev, dev_info); /* replay promiscuous configuration */ - if (rte_eth_promiscuous_get(port_id) == 1) - rte_eth_promiscuous_enable(port_id); - else if (rte_eth_promiscuous_get(port_id) == 0) - rte_eth_promiscuous_disable(port_id); + if (rte_eth_promiscuous_get(port_id) == 1) { + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0 && ret != -ENOTSUP) { + RTE_ETHDEV_LOG(ERR, + "Failed to enable promiscuous mode for device (port %u): %s\n", + port_id, rte_strerror(-ret)); + return ret; + } + } else if (rte_eth_promiscuous_get(port_id) == 0) { + ret = rte_eth_promiscuous_disable(port_id); + if (ret != 0 && ret != -ENOTSUP) { + RTE_ETHDEV_LOG(ERR, + "Failed to disable promiscuous mode for device (port %u): %s\n", + port_id, rte_strerror(-ret)); + return ret; + } + } /* replay all multicast configuration */ if (rte_eth_allmulticast_get(port_id) == 1) rte_eth_allmulticast_enable(port_id); else if (rte_eth_allmulticast_get(port_id) == 0) rte_eth_allmulticast_disable(port_id); + + return 0; } int @@ -1436,7 +1453,14 @@ rte_eth_dev_start(uint16_t port_id) else return eth_err(port_id, diag); - rte_eth_dev_config_restore(dev, &dev_info, port_id); + ret = rte_eth_dev_config_restore(dev, &dev_info, port_id); + if (ret != 0) { + 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); + return ret; + } if (dev->data->dev_conf.intr_conf.lsc == 0) { RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP); @@ -1864,30 +1888,34 @@ rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt) return eth_err(port_id, ret); } -void +int rte_eth_promiscuous_enable(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->promiscuous_enable); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_enable, -ENOTSUP); (*dev->dev_ops->promiscuous_enable)(dev); dev->data->promiscuous = 1; + + return 0; } -void +int rte_eth_promiscuous_disable(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->promiscuous_disable); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_disable, -ENOTSUP); dev->data->promiscuous = 0; (*dev->dev_ops->promiscuous_disable)(dev); + + return 0; } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 475dbdae17..f07a829b29 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2022,16 +2022,26 @@ int rte_eth_dev_reset(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_enable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_enable(uint16_t port_id); +int rte_eth_promiscuous_enable(uint16_t port_id); /** * Disable receipt in promiscuous mode for an Ethernet device. * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_disable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_disable(uint16_t port_id); +int rte_eth_promiscuous_disable(uint16_t port_id); /** * Return the value of promiscuous mode for an Ethernet device. -- 2.17.1