From patchwork Tue Sep 24 12:56:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 59667 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3B5453977; Tue, 24 Sep 2019 14:56:46 +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 00EF52C23 for ; Tue, 24 Sep 2019 14:56:29 +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-us2.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 9F5101C009C; Tue, 24 Sep 2019 12:56:27 +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; Tue, 24 Sep 2019 05:56:24 -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; Tue, 24 Sep 2019 05:56:24 -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 x8OCuN6A029777; Tue, 24 Sep 2019 13:56:23 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 63BF51613D2; Tue, 24 Sep 2019 13:56:23 +0100 (BST) From: Andrew Rybchenko To: Thomas Monjalon , Ferruh Yigit CC: Date: Tue, 24 Sep 2019 13:56:11 +0100 Message-ID: <1569329773-10185-6-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569329773-10185-1-git-send-email-arybchenko@solarflare.com> References: <1568031190-16510-1-git-send-email-arybchenko@solarflare.co MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24930.005 X-TM-AS-Result: No-1.645700-4.000000-10 X-TMASE-MatchedRID: NGDYxnKYxb2UVb9JKXTEDv3HILfxLV/9B4Id7CiQcz9Qrt/FJPUIWLLX y+lnwmMxblGexigQYN80OFaYkO1Eq3tQf2I7ph75Zj7E6vHnuNbKIqAq0jIHii8zQZ2rR/OpSa4 vavKbRAH43M0eHKdCU+tCCat9VMiO3dpCt+02H6zxQg/1zqqUm0tc8DbogbSE31GU/N5W5BDwLT aOpnI6M6Tj0eKb2CFz57jS/hsxRY/580/MbwPUZoph1hAtvKZNxO20cNGQz3WbKItl61J/yZ+in TK0bC9eKrauXd3MZDWy7JL1d4u7cnROR33V+xt4XT+NhHpXhfxk/k4G0K383HuLDLfMqIsZG2jh IuBeGtXmeSUepmWRre9Y0nOidTlsODdwuTq7dIDOLX7TEpsRmjigZBQJvBjlD6DuZ3COjrnoW0N kKZgEncpMvD+U2DDy X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.645700-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24930.005 X-MDID: 1569329788-2JihJKiIdPPu Subject: [dpdk-dev] [PATCH v2 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" m> <1569329773-10185-1-git-send-email-arybchenko@solarflare.com> 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 | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 3f360c9e6..68e886a45 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1416,16 +1416,24 @@ 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 = eth_err(port_id, + (*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 = eth_err(port_id, + (*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 +1970,17 @@ int rte_eth_allmulticast_enable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_allmulticast; int diag; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->all_multicast == 1) + return 0; + 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; + dev->data->all_multicast = (diag == 0) ? 1 : 0; return eth_err(port_id, diag); } @@ -1980,18 +1989,19 @@ int rte_eth_allmulticast_disable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_allmulticast; int diag; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->all_multicast == 0) + return 0; + 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; + dev->data->all_multicast = 1; return eth_err(port_id, diag); }