From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1211E100C for ; Wed, 8 Aug 2018 09:00:05 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 00:00:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,456,1526367600"; d="scan'208";a="79500628" Received: from dpdk51.sh.intel.com ([10.67.110.190]) by fmsmga001.fm.intel.com with ESMTP; 08 Aug 2018 00:00:02 -0700 From: Qi Zhang To: thomas@monjalon.net, konstantin.ananyev@intel.com, declan.doherty@intel.com, ferruh.yigit@intel.com Cc: dev@dpdk.org, benjamin.h.shelton@intel.com, narender.vangati@intel.com, beilei.xing@intel.com, wenzhuo.lu@intel.com, 0000-cover-letter.patch, Qi Zhang Date: Wed, 8 Aug 2018 15:00:43 +0800 Message-Id: <20180808070045.13334-2-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180808070045.13334-1-qi.z.zhang@intel.com> References: <20180808070045.13334-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [RFC 2/4] net/i40e: enable async device reset 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: , X-List-Received-Date: Wed, 08 Aug 2018 07:00:06 -0000 Handle device reset in a separate thread and raise RTE_ETH_EVENT_RESET_COMPLETE event when it is done. Signed-off-by: Qi Zhang --- drivers/net/i40e/i40e_ethdev.c | 28 +++++++++++++++++++++++----- drivers/net/i40e/i40e_ethdev_vf.c | 28 +++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 85a6a867f..611570159 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -2439,12 +2439,29 @@ i40e_dev_close(struct rte_eth_dev *dev) I40E_WRITE_FLUSH(hw); } +static void * +do_dev_reset(void *args) +{ + struct rte_eth_dev *dev = args; + int ret; + + ret = eth_i40e_dev_uninit(dev); + if (!ret) + ret = eth_i40e_dev_init(dev, NULL); + + _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_RESET_COMPLETE, + &ret); + return NULL; +} + /* * Reset PF device only to re-initialize resources in PMD layer */ static int i40e_dev_reset(struct rte_eth_dev *dev) { + pthread_t tid; int ret; /* When a DPDK PMD PF begin to reset PF port, it should notify all @@ -2456,11 +2473,12 @@ i40e_dev_reset(struct rte_eth_dev *dev) if (dev->data->sriov.active) return -ENOTSUP; - ret = eth_i40e_dev_uninit(dev); - if (ret) - return ret; - - ret = eth_i40e_dev_init(dev, NULL); + /** + * Since dev_reset should be implemented as async, do + * reset in a separate thread. + */ + ret = rte_ctrl_thread_create(&tid, "i40e_dev_reset", + NULL, do_dev_reset, dev); return ret; } diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 001c301b9..e10e81792 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -2284,19 +2284,37 @@ i40evf_dev_close(struct rte_eth_dev *dev) i40evf_disable_irq0(hw); } +static void * +do_dev_reset(void *args) +{ + struct rte_eth_dev *dev = args; + int ret; + + ret = i40evf_dev_uninit(dev); + if (!ret) + ret = i40evf_dev_init(dev); + + _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_RESET_COMPLETE, + &ret); + return NULL; +} + /* * Reset VF device only to re-initialize resources in PMD layer */ static int i40evf_dev_reset(struct rte_eth_dev *dev) { + pthread_t tid; int ret; - ret = i40evf_dev_uninit(dev); - if (ret) - return ret; - - ret = i40evf_dev_init(dev); + /** + * Since dev_reset should be implemented as async, do + * reset in a separate thread. + */ + ret = rte_ctrl_thread_create(&tid, "i40evf_dev_reset", + NULL, do_dev_reset, dev); return ret; } -- 2.13.6