From patchwork Mon Sep 9 11:58:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 58997 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 B031C1ECB9; Mon, 9 Sep 2019 13:59:19 +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 A3ED61E962 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 6E93AB40057; Mon, 9 Sep 2019 11:59:05 +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:02 -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:01 -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 x89Bx0JH027730; Mon, 9 Sep 2019 12:59:00 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id C8ADF1613D3; Mon, 9 Sep 2019 12:59:00 +0100 (BST) From: Andrew Rybchenko To: Thomas Monjalon , Ferruh Yigit CC: Date: Mon, 9 Sep 2019 12:58:42 +0100 Message-ID: <1568030331-16526-6-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 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24898.005 X-TM-AS-Result: No-0.014400-4.000000-10 X-TMASE-MatchedRID: HRm6PbbemxebX4K/DqV0NeIfK/Jd5eHmF81qHybtKI3HoLp1yJ83GOBw lzWEEXt2iguYsX+1nsZ2DSY8jnCpzqiOHwlYzcGcxi///JpaHQO2McZY43zJ4zE5FmPR2MmR1AP JYMpZ2b7/NpanhgvTJzxkTRNTP3S5W8T6xyvT3jk/ApMPW/xhXkyQ5fRSh2654uxAgOavdLl9aW vTi9VKSjBk64Y1DPkbYSeig+PVibOqPTUWVYFp2vgo8BKl9ae5L1eX+z9B1Qxa3t7REXGYi6PFj JEFr+olwXCBO/GKkVqOhzOa6g8KrQ8hMxcnQBmrD3pnqIdcsN5c27Vrbi/rOJbodOaAzRjSqTgy Q8zv3Doxw9CtXFFopfIp8BBuXpQTgB5neGrMSyl7HTewQD3Dt4XXmHr+iJs1sqxYnjga4QY83Fq 7f38GK0XAdmaT51YyUOfq31Q4JR+UTGVAhB5EbQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.014400-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568030346-riw2OiLUIOnw Subject: [dpdk-dev] [PATCH v2 05/13] ethdev: do nothing if promiscuous 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 promiscuous mode once again if it is already successfully enabled or disabled. Configuration restore at startup tries to ensure that configured promiscuous mode is applied and start will return error if it fails. Also it avoids theoretical cases when already configured promiscuous 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 f2e6b4c83b..98fe533c5a 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1391,16 +1391,22 @@ rte_eth_dev_config_restore(struct rte_eth_dev *dev, rte_eth_dev_mac_restore(dev, dev_info); /* replay promiscuous configuration */ - if (rte_eth_promiscuous_get(port_id) == 1) { - ret = rte_eth_promiscuous_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_promiscuous_get(port_id) == 1 && + *dev->dev_ops->promiscuous_enable != NULL) { + ret = (*dev->dev_ops->promiscuous_enable)(dev); 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); + } else if (rte_eth_promiscuous_get(port_id) == 0 && + *dev->dev_ops->promiscuous_disable != NULL) { + ret = (*dev->dev_ops->promiscuous_disable)(dev); if (ret != 0 && ret != -ENOTSUP) { RTE_ETHDEV_LOG(ERR, "Failed to disable promiscuous mode for device (port %u): %s\n", @@ -1892,16 +1898,17 @@ int rte_eth_promiscuous_enable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_promiscuous; - 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->promiscuous_enable, -ENOTSUP); - old_promiscuous = dev->data->promiscuous; - diag = (*dev->dev_ops->promiscuous_enable)(dev); - dev->data->promiscuous = (diag == 0) ? 1 : old_promiscuous; + + if (dev->data->promiscuous == 0) { + diag = (*dev->dev_ops->promiscuous_enable)(dev); + dev->data->promiscuous = (diag == 0) ? 1 : 0; + } return eth_err(port_id, diag); } @@ -1910,18 +1917,19 @@ int rte_eth_promiscuous_disable(uint16_t port_id) { struct rte_eth_dev *dev; - uint8_t old_promiscuous; - 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->promiscuous_disable, -ENOTSUP); - old_promiscuous = dev->data->promiscuous; - dev->data->promiscuous = 0; - diag = (*dev->dev_ops->promiscuous_disable)(dev); - if (diag != 0) - dev->data->promiscuous = old_promiscuous; + + if (dev->data->promiscuous == 1) { + dev->data->promiscuous = 0; + diag = (*dev->dev_ops->promiscuous_disable)(dev); + if (diag != 0) + dev->data->promiscuous = 1; + } return eth_err(port_id, diag); }