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 9F6CEA0471 for ; Mon, 9 Sep 2019 14:14:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF8491ECD2; Mon, 9 Sep 2019 14:13:36 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 6C76D1EC7D for ; Mon, 9 Sep 2019 14:13:23 +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-us5.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 64CA358005F; Mon, 9 Sep 2019 12:13:22 +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 05:13:19 -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 05:13:19 -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 x89CDIBO012212; Mon, 9 Sep 2019 13:13:18 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id A3EE51613D2; Mon, 9 Sep 2019 13:13:18 +0100 (BST) From: Andrew Rybchenko To: Thomas Monjalon , Ferruh Yigit CC: Date: Mon, 9 Sep 2019 13:13:07 +0100 Message-ID: <1568031190-16510-6-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568031190-16510-1-git-send-email-arybchenko@solarflare.com> References: <1568031190-16510-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-1.076600-4.000000-10 X-TMASE-MatchedRID: n8dyCgqCzuubX4K/DqV0NeIfK/Jd5eHmF81qHybtKI3HoLp1yJ83GOBw lzWEEXt2iguYsX+1nsZ2DSY8jnCpzqiOHwlYzcGcxi///JpaHQO2McZY43zJ4zE5FmPR2MmR1AP JYMpZ2b7/NpanhgvTJzxkTRNTP3S5W8T6xyvT3jk/ApMPW/xhXkyQ5fRSh265wJ0nWKO7EQTQDj kgBdHEzcwoZ4h95QFe7Dt8kTj2UaeKhA2hG2DTq0rM69p7lDSsfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtpmd/ehreR4VQk4qj+40OixfyMKhfle7WNFOlTs3jb6+XJV+tIhIaW2it1SnxUaIimAzl xOPyEjmCtYR+lKC3uu/Z3qwv3rbrzEK3GrMGeoTaQLtLC8aUqEPBvsmCWGHWUWQ7Bol0IqAY5tv H9Ry2Nw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.076600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568031203-akvcmlQaye9Z Subject: [dpdk-dev] [PATCH 5/7] ethdev: do nothing if all-multicast mode is applied again 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" Since driver callbacks return status code now, there is no necessity to enable or disable all-multicast mode once again if it is already successfully enabled or disabled. Configuration restore at startup tries to ensure that configured all-multicast mode is applied and start will return error if it fails. Also it avoids theoretical cases when already configured all-multicast mode is applied once again and fails. In this cases it is unclear which value should be reported on get (configured or opposite). Signed-off-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 40 ++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 8115226c91..e1921e8225 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1416,16 +1416,22 @@ rte_eth_dev_config_restore(struct rte_eth_dev *dev, } /* replay all multicast configuration */ - if (rte_eth_allmulticast_get(port_id) == 1) { - ret = rte_eth_allmulticast_enable(port_id); + /* + * use callbacks directly since we don't need port_id check and + * would like to bypass the same value set + */ + if (rte_eth_allmulticast_get(port_id) == 1 && + *dev->dev_ops->allmulticast_enable != NULL) { + ret = (*dev->dev_ops->allmulticast_enable)(dev); if (ret != 0 && ret != -ENOTSUP) { RTE_ETHDEV_LOG(ERR, "Failed to enable allmulticast mode for device (port %u): %s\n", port_id, rte_strerror(-ret)); return ret; } - } else if (rte_eth_allmulticast_get(port_id) == 0) { - ret = rte_eth_allmulticast_disable(port_id); + } else if (rte_eth_allmulticast_get(port_id) == 0 && + *dev->dev_ops->allmulticast_disable != NULL) { + ret = (*dev->dev_ops->allmulticast_disable)(dev); if (ret != 0 && ret != -ENOTSUP) { RTE_ETHDEV_LOG(ERR, "Failed to disable allmulticast mode for device (port %u): %s\n", @@ -1962,16 +1968,17 @@ int rte_eth_allmulticast_enable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_allmulticast; - int diag; + int diag = 0; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_enable, -ENOTSUP); - old_allmulticast = dev->data->all_multicast; - diag = (*dev->dev_ops->allmulticast_enable)(dev); - dev->data->all_multicast = (diag == 0) ? 1 : old_allmulticast; + + if (dev->data->all_multicast == 0) { + diag = (*dev->dev_ops->allmulticast_enable)(dev); + dev->data->all_multicast = (diag == 0) ? 1 : 0; + } return eth_err(port_id, diag); } @@ -1980,18 +1987,19 @@ int rte_eth_allmulticast_disable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_allmulticast; - int diag; + int diag = 0; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_disable, -ENOTSUP); - old_allmulticast = dev->data->all_multicast; - dev->data->all_multicast = 0; - diag = (*dev->dev_ops->allmulticast_disable)(dev); - if (diag != 0) - dev->data->all_multicast = old_allmulticast; + + if (dev->data->all_multicast == 1) { + dev->data->all_multicast = 0; + diag = (*dev->dev_ops->allmulticast_disable)(dev); + if (diag != 0) + dev->data->all_multicast = 1; + } return eth_err(port_id, diag); } -- 2.17.1