From patchwork Mon Mar 9 09:32:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 66404 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E7DA3A052E; Mon, 9 Mar 2020 10:34:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C6DC51C0C4; Mon, 9 Mar 2020 10:33:30 +0100 (CET) Received: from incedge.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 9E4191C021 for ; Mon, 9 Mar 2020 10:33:23 +0100 (CET) X-ASG-Debug-ID: 1583746368-0a3dd1404a03530006-TfluYd Received: from mail.chinasoftinc.com (inccas001.ito.icss [10.168.0.51]) by incedge.chinasoftinc.com with ESMTP id 6yQph95g9umiSDWV (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 09 Mar 2020 17:32:51 +0800 (CST) X-Barracuda-Envelope-From: huwei013@chinasoftinc.com X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.51 X-ASG-Whitelist: Client Received: from localhost.localdomain (114.119.4.74) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Mon, 9 Mar 2020 17:32:50 +0800 From: "Wei Hu (Xavier)" X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.60 To: Date: Mon, 9 Mar 2020 17:32:43 +0800 X-ASG-Orig-Subj: [PATCH v2 5/5] net/hns3: fix promiscuous mode for PF Message-ID: <20200309093243.63204-6-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200309093243.63204-1-huwei013@chinasoftinc.com> References: <20200309093243.63204-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 X-Originating-IP: [114.119.4.74] X-Barracuda-Connect: inccas001.ito.icss[10.168.0.51] X-Barracuda-Start-Time: 1583746370 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://incspam.chinasofti.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at chinasoftinc.com X-Barracuda-Scan-Msg-Size: 4480 Subject: [dpdk-dev] [PATCH v2 5/5] net/hns3: fix promiscuous mode for PF 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: Chengchang Tang Currently, when promiscuous mode is enabled, it is just allowed to accept all the unicast and broadcast packets in hns3 PF PMD driver. It should also be able to receive multicast packets. Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index f6495623e..58aaed47a 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -3649,7 +3649,7 @@ hns3_cmd_set_promisc_mode(struct hns3_hw *hw, struct hns3_promisc_param *param) ret = hns3_cmd_send(hw, &desc, 1); if (ret) - PMD_INIT_LOG(ERR, "Set promisc mode fail, status is %d", ret); + PMD_INIT_LOG(ERR, "Set promisc mode fail, ret = %d", ret); return ret; } @@ -3702,14 +3702,14 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; int ret; rte_spinlock_lock(&hw->lock); - ret = hns3_set_promisc_mode(hw, true, en_mc_pmc); + ret = hns3_set_promisc_mode(hw, true, true); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to enable promiscuous mode: %d", ret); + hns3_err(hw, "Failed to enable promiscuous mode, ret = %d", + ret); return ret; } @@ -3717,17 +3717,18 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) static int hns3_dev_promiscuous_disable(struct rte_eth_dev *dev) { + bool allmulti = dev->data->all_multicast ? true : false; struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; int ret; /* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock(&hw->lock); - ret = hns3_set_promisc_mode(hw, false, en_mc_pmc); + ret = hns3_set_promisc_mode(hw, false, allmulti); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to disable promiscuous mode: %d", ret); + hns3_err(hw, "Failed to disable promiscuous mode, ret = %d", + ret); return ret; } @@ -3737,14 +3738,17 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; int ret; + if (dev->data->promiscuous) + return 0; + rte_spinlock_lock(&hw->lock); - ret = hns3_set_promisc_mode(hw, en_uc_pmc, true); + ret = hns3_set_promisc_mode(hw, false, true); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to enable allmulticast mode: %d", ret); + hns3_err(hw, "Failed to enable allmulticast mode, ret = %d", + ret); return ret; } @@ -3754,18 +3758,18 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; int ret; /* If now in promiscuous mode, must remain in all_multicast mode. */ - if (dev->data->promiscuous == 1) + if (dev->data->promiscuous) return 0; rte_spinlock_lock(&hw->lock); - ret = hns3_set_promisc_mode(hw, en_uc_pmc, false); + ret = hns3_set_promisc_mode(hw, false, false); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to disable allmulticast mode: %d", ret); + hns3_err(hw, "Failed to disable allmulticast mode, ret = %d", + ret); return ret; } @@ -3774,13 +3778,12 @@ static int hns3_dev_promisc_restore(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; - bool en_mc_pmc; - bool en_uc_pmc; + bool allmulti = hw->data->all_multicast ? true : false; - en_uc_pmc = (hw->data->promiscuous == 1) ? true : false; - en_mc_pmc = (hw->data->all_multicast == 1) ? true : false; + if (hw->data->promiscuous) + return hns3_set_promisc_mode(hw, true, true); - return hns3_set_promisc_mode(hw, en_uc_pmc, en_mc_pmc); + return hns3_set_promisc_mode(hw, false, allmulti); } static int