From patchwork Mon Oct 19 02:20:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yuying" X-Patchwork-Id: 81275 X-Patchwork-Delegate: qi.z.zhang@intel.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 88582A04DC; Mon, 19 Oct 2020 04:25:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D94ABCCE; Mon, 19 Oct 2020 04:25:37 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id EE930BAE2; Mon, 19 Oct 2020 04:25:33 +0200 (CEST) IronPort-SDR: PGW4mQk3oy7yIKWPXuk9LJ1zC/yZzN7jiUEvRZ1EUpV4iKHFDJ02FU+7gYVzjDM9/FtMLiFvQD TrixMLpB30Eg== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="251650924" X-IronPort-AV: E=Sophos;i="5.77,393,1596524400"; d="scan'208";a="251650924" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2020 19:25:31 -0700 IronPort-SDR: +mPnfklNJUzyvqKQz54j+LpcetsVATHM7pK+EwE0cVTfa2jN/pk9d564ts/1pfBfj9w1L72nbZ mzrMJIDQh81g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,393,1596524400"; d="scan'208";a="465354246" Received: from dpdk-yyzhang2.sh.intel.com ([10.67.117.2]) by orsmga004.jf.intel.com with ESMTP; 18 Oct 2020 19:25:30 -0700 From: Yuying Zhang To: dev@dpdk.org, qi.z.zhang@intel.com, beilei.xing@intel.com Cc: Yuying Zhang , stable@dpdk.org Date: Mon, 19 Oct 2020 02:20:25 +0000 Message-Id: <20201019022025.1748497-1-yuying.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200920152813.674261-1-yuying.zhang@intel.com> References: <20200920152813.674261-1-yuying.zhang@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] 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 and multi-thread mode. However, it returns -1 when one process or thread is pending. Add rte_spinlock_trylock() to handle this issue in concurrent scenarios. Fixes: 4861cde46116 ("i40e: new poll mode driver") Cc: stable@dpdk.org Signed-off-by: Yuying Zhang Acked-by: Qi Zhang --- drivers/net/i40e/i40e_ethdev.h | 1 + drivers/net/i40e/i40e_ethdev_vf.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 1466998aa..508a940dc 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -1209,6 +1209,7 @@ struct i40e_vf { 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 */ uint16_t promisc_flags; /* Promiscuous setting */ diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 4d6510d1f..282db4721 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -314,7 +314,7 @@ _atomic_set_cmd(struct i40e_vf *vf, enum virtchnl_ops ops) #define ASQ_DELAY_MS 10 static int -i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) +_i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); @@ -405,6 +405,19 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) return err | vf->cmd_retval; } +static int +i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) +{ + struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + int err; + + while (!rte_spinlock_trylock(&vf->cmd_send_lock)) + rte_delay_us_sleep(50); + err = _i40evf_execute_vf_cmd(dev, args); + rte_spinlock_unlock(&vf->cmd_send_lock); + return err; +} + /* * Check API version with sync wait until version read or fail from admin queue */ @@ -1246,6 +1259,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);