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 2479FA0521 for ; Sat, 27 Jun 2020 05:33:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C0A71BE51; Sat, 27 Jun 2020 05:33:04 +0200 (CEST) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id D9B811BEBA; Sat, 27 Jun 2020 05:33:02 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A28236CCD35D828BE22F; Sat, 27 Jun 2020 11:33:00 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Sat, 27 Jun 2020 11:32:54 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang , Date: Sat, 27 Jun 2020 11:55:46 +0800 Message-ID: <7d949e59e08b619ba4820d59b57fe9e2efb9c12a.1593228634.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [PATCH v1 3/5] net/hinic: fix setting promiscuous mode problem 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" When setting promiscuous or allmulticast mode, increase multi-thread resource protection, because the patch "net/bonding: prefer allmulti to promiscuous for LACP" adds trying to use allmulti when adding a slave, and EVS bond driver also sets promisc with another thread, which may lead to thread reentry and cause failure to set promiscuous mode. Fixes: cb7b6606ebff ("net/hinic: add RSS stats and promiscuous ops") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/hinic_pmd_ethdev.c | 34 ++++++++++++++++++++++++++++++---- drivers/net/hinic/hinic_pmd_ethdev.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index 0c3e1c0..8de9714 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -1271,14 +1271,25 @@ static void hinic_disable_interrupt(struct rte_eth_dev *dev) static int hinic_set_dev_promiscuous(struct hinic_nic_dev *nic_dev, bool enable) { - u32 rx_mode_ctrl = nic_dev->rx_mode_status; + u32 rx_mode_ctrl; + int err; + + err = hinic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode_ctrl = nic_dev->rx_mode_status; if (enable) rx_mode_ctrl |= HINIC_RX_MODE_PROMISC; else rx_mode_ctrl &= (~HINIC_RX_MODE_PROMISC); - return hinic_config_rx_mode(nic_dev, rx_mode_ctrl); + err = hinic_config_rx_mode(nic_dev, rx_mode_ctrl); + + (void)hinic_mutex_unlock(&nic_dev->rx_mode_mutex); + + return err; } /** @@ -1731,14 +1742,25 @@ static void hinic_remove_all_vlanid(struct rte_eth_dev *eth_dev) static int hinic_set_dev_allmulticast(struct hinic_nic_dev *nic_dev, bool enable) { - u32 rx_mode_ctrl = nic_dev->rx_mode_status; + u32 rx_mode_ctrl; + int err; + + err = hinic_mutex_lock(&nic_dev->rx_mode_mutex); + if (err) + return err; + + rx_mode_ctrl = nic_dev->rx_mode_status; if (enable) rx_mode_ctrl |= HINIC_RX_MODE_MC_ALL; else rx_mode_ctrl &= (~HINIC_RX_MODE_MC_ALL); - return hinic_config_rx_mode(nic_dev, rx_mode_ctrl); + err = hinic_config_rx_mode(nic_dev, rx_mode_ctrl); + + (void)hinic_mutex_unlock(&nic_dev->rx_mode_mutex); + + return err; } /** @@ -3130,6 +3152,8 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) } rte_bit_relaxed_set32(HINIC_DEV_INTR_EN, &nic_dev->dev_status); + hinic_mutex_init(&nic_dev->rx_mode_mutex, NULL); + /* initialize filter info */ filter_info = &nic_dev->filter; tcam_info = &nic_dev->tcam; @@ -3204,6 +3228,8 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + hinic_mutex_destroy(&nic_dev->rx_mode_mutex); + hinic_dev_close(dev); dev->dev_ops = NULL; diff --git a/drivers/net/hinic/hinic_pmd_ethdev.h b/drivers/net/hinic/hinic_pmd_ethdev.h index 77b4b91..3f2d51d 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.h +++ b/drivers/net/hinic/hinic_pmd_ethdev.h @@ -329,6 +329,7 @@ struct hinic_nic_dev { unsigned int flags; struct nic_service_cap nic_cap; u32 rx_mode_status; /* promisc or allmulticast */ + pthread_mutex_t rx_mode_mutex; u32 dev_status; char proc_dev_name[HINIC_DEV_NAME_LEN]; -- 1.8.3.1