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 EA2CEA0093 for ; Tue, 19 May 2020 15:09:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD0931D6A4; Tue, 19 May 2020 15:09:58 +0200 (CEST) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 0658E1D6D0 for ; Tue, 19 May 2020 15:09:58 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id u1so2220258wmn.3 for ; Tue, 19 May 2020 06:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7DKt4rU8wznTLNJSucAM0KvF5y2GiDV9UsAIiFqRVE=; b=GtWbYdJUsX1UarVT6G+znk4Pab2AMCukhEgPp2pyMa4jiImgxM3R6XRh0XsxmqEDWi 06dMPLCFNZTod08EDMcCmuwY8V5t+30odnIoPSHQM8erKJcBrtIGYzb5HtEXrrI1Rr72 8/eYwOuVb+/k9K19TIqK73wrszL3vDrYkvd3yajTTCkOVTgBJQoMdq3PPjJb86TE76y3 y842WUt3GJwx8lmcBg7qmTIm6p+kj50mWY1uiVf3QIm0PPgyYdr9RKuULLacGQ+IL4ac pMpqWPdP46o9pI19KWHLQBgTaTFLY2TZCorQo8aPz1mZxGTC8lYYCkVCp68EJi4omF3O WWDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A7DKt4rU8wznTLNJSucAM0KvF5y2GiDV9UsAIiFqRVE=; b=PElmzCw6P0EYO/DgZExTGuBAHHbM03GL91UT9ls6KYFlNUJqgXqIo5hoY56vcHR4Ce ZZnL46BklRLg84Ck/l3O0Qgr/GC+2WbBSRHfExRqJV1cd4TDAEjDN6s7+7b7Ddl94qkd rT8oADo0/HdvQGRdncHH3DNCJJwrq5llN1nSveaxT72q23qEc4ojKBk1Ln221Dp9fq+d xp+ldeGPFPyc/iwwVciO+YDWciAR+ZKksZHRwtPB+nYG9rNRy63YAM3QYZxrJvtckxGZ suL2DrYvpZvo2tk1qj/FvT8Y17fEAzPDkzlSov1DInxs5Cd+rmJGHm0xmA77ovMxBLl/ SQMQ== X-Gm-Message-State: AOAM531FXNeGwnapjgTAU1cNjf/Puq9RGfrW3X3OzXXyi5ZpucYsYr+K a15tS2xLa4HZbLwyVA8GE1DrIC68V8Ff0XzM X-Google-Smtp-Source: ABdhPJyA39B4+ni9dRyf9x22zgDPP21VH/CJXS4R6WQ2aTpYUBnhzBZVbHXD9Gu0qQeJaaH0+eQNxA== X-Received: by 2002:a1c:6287:: with SMTP id w129mr5623242wmb.151.1589893797717; Tue, 19 May 2020 06:09:57 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id n128sm3908872wmb.47.2020.05.19.06.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:09:57 -0700 (PDT) From: luca.boccassi@gmail.com To: Chengchang Tang Cc: Wei Hu , dpdk stable Date: Tue, 19 May 2020 14:03:33 +0100 Message-Id: <20200519130549.112823-78-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: fix VLAN filter when setting promisucous mode' has been queued to stable release 19.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From be0d36b087b7ba1b9342d0c3a12e637245179b4b Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Fri, 10 Apr 2020 19:09:30 +0800 Subject: [PATCH] net/hns3: fix VLAN filter when setting promisucous mode [ upstream commit 40b5448d045573d4d99c866665cd1a9350390f6c ] Currently, when upper level application call the API function named rte_eth_dev_set_vlan_offload to configure the hardware vlan filter offload and call the rte_eth_promiscuous_enable API to enable promiscuous mode based on hns3 PF device, driver can't receive the packets with a vlan tag which has not been added by calling the API function named rte_eth_dev_vlan_filter. This patch fixes it by disabling the vlan filter when setting the promiscuous mode and enabling the vlan filter again after the promiscuous mode are disabled. Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations") Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 119 +++++++++++++++++++++++++-------- 1 file changed, 91 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index b6fac3e378..378774396f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -599,16 +599,19 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask) rxmode = &dev->data->dev_conf.rxmode; tmp_mask = (unsigned int)mask; if (tmp_mask & ETH_VLAN_FILTER_MASK) { - /* Enable or disable VLAN filter */ - enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? - true : false; + /* ignore vlan filter configuration during promiscuous mode */ + if (!dev->data->promiscuous) { + /* Enable or disable VLAN filter */ + enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? + true : false; - ret = hns3_enable_vlan_filter(hns, enable); - if (ret) { - rte_spinlock_unlock(&hw->lock); - hns3_err(hw, "failed to %s rx filter, ret = %d", - enable ? "enable" : "disable", ret); - return ret; + ret = hns3_enable_vlan_filter(hns, enable); + if (ret) { + rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "failed to %s rx filter, ret = %d", + enable ? "enable" : "disable", ret); + return ret; + } } } @@ -994,14 +997,16 @@ hns3_restore_vlan_conf(struct hns3_adapter *hns) bool enable; int ret; - /* restore vlan filter states */ - offloads = hw->data->dev_conf.rxmode.offloads; - enable = offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? true : false; - ret = hns3_enable_vlan_filter(hns, enable); - if (ret) { - hns3_err(hw, "failed to restore vlan rx filter conf, ret = %d", - ret); - return ret; + if (!hw->data->promiscuous) { + /* restore vlan filter states */ + offloads = hw->data->dev_conf.rxmode.offloads; + enable = offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? true : false; + ret = hns3_enable_vlan_filter(hns, enable); + if (ret) { + hns3_err(hw, "failed to restore vlan rx filter conf, " + "ret = %d", ret); + return ret; + } } ret = hns3_set_vlan_rx_offload_cfg(hns, &pf->vtag_config.rx_vcfg); @@ -3628,16 +3633,43 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) static int hns3_dev_promiscuous_enable(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; + uint64_t offloads; + int err; int ret = 0; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, true, true); - rte_spinlock_unlock(&hw->lock); - if (ret) - hns3_err(hw, "Failed to enable promiscuous mode, ret = %d", + if (ret) { + rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "failed to enable promiscuous mode, ret = %d", ret); + return ret; + } + + /* + * When promiscuous mode was enabled, disable the vlan filter to let + * all packets coming in in the receiving direction. + */ + offloads = dev->data->dev_conf.rxmode.offloads; + if (offloads & DEV_RX_OFFLOAD_VLAN_FILTER) { + ret = hns3_enable_vlan_filter(hns, false); + if (ret) { + hns3_err(hw, "failed to enable promiscuous mode due to " + "failure to disable vlan filter, ret = %d", + ret); + err = hns3_set_promisc_mode(hw, false, allmulti); + if (err) + hns3_err(hw, "failed to restore promiscuous " + "status after disable vlan filter " + "failed during enabling promiscuous " + "mode, ret = %d", ret); + } + } + + rte_spinlock_unlock(&hw->lock); return ret; } @@ -3648,15 +3680,36 @@ 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; + uint64_t offloads; + int err; int ret = 0; /* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, false, allmulti); - rte_spinlock_unlock(&hw->lock); - if (ret) - hns3_err(hw, "Failed to disable promiscuous mode, ret = %d", + if (ret) { + rte_spinlock_unlock(&hw->lock); + hns3_err(hw, "failed to disable promiscuous mode, ret = %d", ret); + return ret; + } + /* when promiscuous mode was disabled, restore the vlan filter status */ + offloads = dev->data->dev_conf.rxmode.offloads; + if (offloads & DEV_RX_OFFLOAD_VLAN_FILTER) { + ret = hns3_enable_vlan_filter(hns, true); + if (ret) { + hns3_err(hw, "failed to disable promiscuous mode due to" + " failure to restore vlan filter, ret = %d", + ret); + err = hns3_set_promisc_mode(hw, true, true); + if (err) + hns3_err(hw, "failed to restore promiscuous " + "status after enabling vlan filter " + "failed during disabling promiscuous " + "mode, ret = %d", ret); + } + } + rte_spinlock_unlock(&hw->lock); return ret; } @@ -3675,7 +3728,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) ret = hns3_set_promisc_mode(hw, false, true); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to enable allmulticast mode, ret = %d", + hns3_err(hw, "failed to enable allmulticast mode, ret = %d", ret); return ret; @@ -3696,7 +3749,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) ret = hns3_set_promisc_mode(hw, false, false); rte_spinlock_unlock(&hw->lock); if (ret) - hns3_err(hw, "Failed to disable allmulticast mode, ret = %d", + hns3_err(hw, "failed to disable allmulticast mode, ret = %d", ret); return ret; @@ -3707,11 +3760,21 @@ hns3_dev_promisc_restore(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; bool allmulti = hw->data->all_multicast ? true : false; + int ret; - if (hw->data->promiscuous) - return hns3_set_promisc_mode(hw, true, true); + if (hw->data->promiscuous) { + ret = hns3_set_promisc_mode(hw, true, true); + if (ret) + hns3_err(hw, "failed to restore promiscuous mode, " + "ret = %d", ret); + return ret; + } - return hns3_set_promisc_mode(hw, false, allmulti); + ret = hns3_set_promisc_mode(hw, false, allmulti); + if (ret) + hns3_err(hw, "failed to restore allmulticast mode, ret = %d", + ret); + return ret; } static int -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:47.640519973 +0100 +++ 0078-net-hns3-fix-VLAN-filter-when-setting-promisucous-mo.patch 2020-05-19 14:04:44.248648953 +0100 @@ -1,8 +1,10 @@ -From 40b5448d045573d4d99c866665cd1a9350390f6c Mon Sep 17 00:00:00 2001 +From be0d36b087b7ba1b9342d0c3a12e637245179b4b Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Fri, 10 Apr 2020 19:09:30 +0800 Subject: [PATCH] net/hns3: fix VLAN filter when setting promisucous mode +[ upstream commit 40b5448d045573d4d99c866665cd1a9350390f6c ] + Currently, when upper level application call the API function named rte_eth_dev_set_vlan_offload to configure the hardware vlan filter offload and call the rte_eth_promiscuous_enable API to enable @@ -15,7 +17,6 @@ promiscuous mode are disabled. 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) @@ -24,10 +25,10 @@ 1 file changed, 91 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bab4312b39..3e3a8c5f4e 100644 +index b6fac3e378..378774396f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c -@@ -607,16 +607,19 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask) +@@ -599,16 +599,19 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask) rxmode = &dev->data->dev_conf.rxmode; tmp_mask = (unsigned int)mask; if (tmp_mask & ETH_VLAN_FILTER_MASK) { @@ -56,7 +57,7 @@ } } -@@ -1002,14 +1005,16 @@ hns3_restore_vlan_conf(struct hns3_adapter *hns) +@@ -994,14 +997,16 @@ hns3_restore_vlan_conf(struct hns3_adapter *hns) bool enable; int ret; @@ -81,7 +82,7 @@ } ret = hns3_set_vlan_rx_offload_cfg(hns, &pf->vtag_config.rx_vcfg); -@@ -3830,16 +3835,43 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) +@@ -3628,16 +3633,43 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) static int hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) { @@ -90,7 +91,7 @@ struct hns3_hw *hw = &hns->hw; + uint64_t offloads; + int err; - int ret; + int ret = 0; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, true, true); @@ -128,13 +129,13 @@ return ret; } -@@ -3850,15 +3882,36 @@ hns3_dev_promiscuous_disable(struct rte_eth_dev *dev) +@@ -3648,15 +3680,36 @@ 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; + uint64_t offloads; + int err; - int ret; + int ret = 0; /* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock(&hw->lock); @@ -168,7 +169,7 @@ return ret; } -@@ -3877,7 +3930,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) +@@ -3675,7 +3728,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) ret = hns3_set_promisc_mode(hw, false, true); rte_spinlock_unlock(&hw->lock); if (ret) @@ -177,7 +178,7 @@ ret); return ret; -@@ -3898,7 +3951,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) +@@ -3696,7 +3749,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) ret = hns3_set_promisc_mode(hw, false, false); rte_spinlock_unlock(&hw->lock); if (ret) @@ -186,7 +187,7 @@ ret); return ret; -@@ -3909,11 +3962,21 @@ hns3_dev_promisc_restore(struct hns3_adapter *hns) +@@ -3707,11 +3760,21 @@ hns3_dev_promisc_restore(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; bool allmulti = hw->data->all_multicast ? true : false;