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 DF7E5A04B7; Sun, 20 Sep 2020 17:31:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 628C91D9F3; Sun, 20 Sep 2020 17:31:53 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 321011D9D5; Sun, 20 Sep 2020 17:31:52 +0200 (CEST) IronPort-SDR: Gmt7kSjfIZhEdolyc8kByfk17fo68sg4XfiKuU5UlKCSKfv4b2DIDP5hkW3zIAHSCvqscxRGzP OmjKcojdGT+g== X-IronPort-AV: E=McAfee;i="6000,8403,9750"; a="245078767" X-IronPort-AV: E=Sophos;i="5.77,283,1596524400"; d="scan'208";a="245078767" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 08:31:51 -0700 IronPort-SDR: yh1CFsrPD6SVhg+jL0ocaC9br7hc+XKDZnZbkfg2szoLvMvvwIt/kVpSGllSnM0fO7CMJOksQ/ t2WZZSVRTn5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,283,1596524400"; d="scan'208";a="333820177" Received: from dpdk-yyzhang2.sh.intel.com ([10.67.117.2]) by fmsmga004.fm.intel.com with ESMTP; 20 Sep 2020 08:31:50 -0700 From: Yuying Zhang To: dev@dpdk.org, qi.z.zhang@intel.com, beilei.xing@intel.com Cc: Yuying Zhang , stable@dpdk.org Date: Sun, 20 Sep 2020 15:28:13 +0000 Message-Id: <20200920152813.674261-1-yuying.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] net/i40e: fix virtual channel confiliction issue 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" i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual channel commands safely in multi-process mode. However, it returns -1 when one process is pending. Add a spinlock to wait for the virtual channel will handle this issue in concurrent scenarios. Fixes: 4861cde46116 ("i40e: new poll mode driver") Cc: stable@dpdk.org Signed-off-by: Yuying Zhang --- drivers/net/i40e/i40e_ethdev.h | 1 + drivers/net/i40e/i40e_ethdev_vf.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 19f821829..514c0988b 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -1199,6 +1199,7 @@ struct i40e_vf { uint16_t max_pkt_len; /* Maximum packet length */ bool promisc_unicast_enabled; bool promisc_multicast_enabled; + rte_spinlock_t cmd_send_lock; uint32_t version_major; /* Major version number */ uint32_t version_minor; /* Minor version number */ diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 69cab8e73..7fdc58649 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -326,8 +326,11 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) enum i40evf_aq_result ret; int err, i = 0; - if (_atomic_set_cmd(vf, args->ops)) + rte_spinlock_lock(&vf->cmd_send_lock); + if (_atomic_set_cmd(vf, args->ops)) { + rte_spinlock_unlock(&vf->cmd_send_lock); return -1; + } info.msg = args->out_buffer; info.buf_len = args->out_size; @@ -339,6 +342,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) if (err) { PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops); _clear_cmd(vf); + rte_spinlock_unlock(&vf->cmd_send_lock); return err; } @@ -406,6 +410,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) break; } + rte_spinlock_unlock(&vf->cmd_send_lock); return err | vf->cmd_retval; } @@ -1249,6 +1254,7 @@ i40evf_init_vf(struct rte_eth_dev *dev) vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); vf->dev_data = dev->data; + rte_spinlock_init(&vf->cmd_send_lock); err = i40e_set_mac_type(hw); if (err) { PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err); -- 2.25.1