From: Xiaoyun wang <cloud.wangxiaoyun@huawei.com> To: <dev@dpdk.org> Cc: <ferruh.yigit@intel.com>, <bluca@debian.org>, <luoxianjun@huawei.com>, <luoxingyu@huawei.com>, <zhouguoyang@huawei.com>, <yin.yinshi@huawei.com>, <david.yangxiaoliang@huawei.com>, <zhaohui8@huawei.com>, <zhengjingzhou@huawei.com>, Xiaoyun wang <cloud.wangxiaoyun@huawei.com>, <stable@dpdk.org> Subject: [dpdk-dev] [PATCH v1 3/5] net/hinic: fix setting promiscuous mode problem Date: Sat, 27 Jun 2020 11:55:46 +0800 Message-ID: <7d949e59e08b619ba4820d59b57fe9e2efb9c12a.1593228634.git.cloud.wangxiaoyun@huawei.com> (raw) In-Reply-To: <cover.1593228634.git.cloud.wangxiaoyun@huawei.com> 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 <cloud.wangxiaoyun@huawei.com> --- 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
next prev parent reply other threads:[~2020-06-27 3:33 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-27 3:55 [dpdk-dev] [PATCH v1 0/5] fix promisc and tcam problem Xiaoyun wang 2020-06-27 3:55 ` [dpdk-dev] [PATCH v1 1/5] net/hinic/base: add out parameter for mgmt sync channel Xiaoyun wang 2020-06-27 3:55 ` [dpdk-dev] [PATCH v1 2/5] net/hinic/base: remove unused parameter Xiaoyun wang 2020-06-27 3:55 ` Xiaoyun wang [this message] 2020-06-27 3:55 ` [dpdk-dev] [PATCH v1 4/5] net/hinic: add tcam filter switch for FDIR Xiaoyun wang 2020-06-27 3:55 ` [dpdk-dev] [PATCH v1 5/5] net/hinic/base: modify return errors Xiaoyun wang 2020-07-07 19:42 ` Ferruh Yigit 2020-07-03 16:22 ` [dpdk-dev] [PATCH v1 0/5] fix promisc and tcam problem Ferruh Yigit
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=7d949e59e08b619ba4820d59b57fe9e2efb9c12a.1593228634.git.cloud.wangxiaoyun@huawei.com \ --to=cloud.wangxiaoyun@huawei.com \ --cc=bluca@debian.org \ --cc=david.yangxiaoliang@huawei.com \ --cc=dev@dpdk.org \ --cc=ferruh.yigit@intel.com \ --cc=luoxianjun@huawei.com \ --cc=luoxingyu@huawei.com \ --cc=stable@dpdk.org \ --cc=yin.yinshi@huawei.com \ --cc=zhaohui8@huawei.com \ --cc=zhengjingzhou@huawei.com \ --cc=zhouguoyang@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git