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 BAEBCA2EEB for ; Sat, 14 Sep 2019 13:37:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C3AF1EABE; Sat, 14 Sep 2019 13:37:54 +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 D01D11D161 for ; Sat, 14 Sep 2019 13:37:50 +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 E8B2E4C005B; Sat, 14 Sep 2019 11:37:49 +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; Sat, 14 Sep 2019 04:37:45 -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; Sat, 14 Sep 2019 04:37:44 -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 x8EBbhoL015398; Sat, 14 Sep 2019 12:37:43 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 618B31613D2; Sat, 14 Sep 2019 12:37:43 +0100 (BST) From: Andrew Rybchenko To: Gaetan Rivet CC: , Ivan Ilchenko Date: Sat, 14 Sep 2019 12:37:22 +0100 Message-ID: <1568461055-16472-3-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568461055-16472-1-git-send-email-arybchenko@solarflare.com> References: <1567699852-31693-1-git-send-email-arybchenko@solarflare.com> <1568461055-16472-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-24910.005 X-TM-AS-Result: No-0.883400-4.000000-10 X-TMASE-MatchedRID: Y4ICLEyyxIvbS0m47m6fSn84FZpy/6JVAPiR4btCEeYd0WOKRkwsh7v6 vrbswMDMxarRl7NbtIiTeJoP42XqZOO3C1C2ZcTl/1dEgwtQ6NA/pOSL72dTfwdkFovAReUovqn FtM6Nq/JgJHW0v6veR29yZj3aufb5HxPMjOKY7A8LbigRnpKlKZvjAepGmdoO7FCTfXWLOkFE82 jP3+66QcD0xnPXFoGxpyLryVMC8Rs6js504/amlbgeQl6EYJiSIYQZ6ksp367suDKdG3HNUQ0nx wgFLqQ25APDq2B3cAxn2JWP8qFf9FKehBzm9vnO5B2Qzud0EsLj5cAllduzaw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.883400-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24910.005 X-MDID: 1568461070-ifKhm2-aOew6 Subject: [dpdk-dev] [PATCH v3 02/13] net/failsafe: check code of promiscuous mode switch 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 rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return value was changed from void to int, so this patch modify usage of these functions across net/failsafe according to new return type. Try to keep promiscuous mode consistent across all active devices in the case of failure. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Acked-by: Gaetan Rivet --- drivers/net/failsafe/failsafe_ether.c | 8 +++-- drivers/net/failsafe/failsafe_ops.c | 44 ++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 504c76edb..bd38f1c1e 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -126,9 +126,13 @@ fs_eth_dev_conf_apply(struct rte_eth_dev *dev, if (dev->data->promiscuous != edev->data->promiscuous) { DEBUG("Configuring promiscuous"); if (dev->data->promiscuous) - rte_eth_promiscuous_enable(PORT_ID(sdev)); + ret = rte_eth_promiscuous_enable(PORT_ID(sdev)); else - rte_eth_promiscuous_disable(PORT_ID(sdev)); + ret = rte_eth_promiscuous_disable(PORT_ID(sdev)); + if (ret != 0) { + ERROR("Failed to apply promiscuous mode"); + return ret; + } } else { DEBUG("promiscuous already set"); } diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 2683b8fe5..af2c216f3 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -659,10 +659,28 @@ fs_promiscuous_enable(struct rte_eth_dev *dev) { struct sub_device *sdev; uint8_t i; + int ret = 0; fs_lock(dev, 0); - FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) - rte_eth_promiscuous_enable(PORT_ID(sdev)); + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_promiscuous_enable(PORT_ID(sdev)); + ret = fs_err(sdev, ret); + if (ret != 0) { + ERROR("Promiscuous mode enable failed for subdevice %d", + PORT_ID(sdev)); + break; + } + } + if (ret != 0) { + /* Rollback in the case of failure */ + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_promiscuous_disable(PORT_ID(sdev)); + ret = fs_err(sdev, ret); + if (ret != 0) + ERROR("Promiscuous mode disable during rollback failed for subdevice %d", + PORT_ID(sdev)); + } + } fs_unlock(dev, 0); } @@ -671,10 +689,28 @@ fs_promiscuous_disable(struct rte_eth_dev *dev) { struct sub_device *sdev; uint8_t i; + int ret = 0; fs_lock(dev, 0); - FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) - rte_eth_promiscuous_disable(PORT_ID(sdev)); + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_promiscuous_disable(PORT_ID(sdev)); + ret = fs_err(sdev, ret); + if (ret != 0) { + ERROR("Promiscuous mode disable failed for subdevice %d", + PORT_ID(sdev)); + break; + } + } + if (ret != 0) { + /* Rollback in the case of failure */ + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_promiscuous_enable(PORT_ID(sdev)); + ret = fs_err(sdev, ret); + if (ret != 0) + ERROR("Promiscuous mode enable during rollback failed for subdevice %d", + PORT_ID(sdev)); + } + } fs_unlock(dev, 0); } -- 2.17.1