DPDK patches and discussions
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
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 <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [RFC 2/4] net/i40e: enable async device reset
Date: Wed,  8 Aug 2018 15:00:43 +0800	[thread overview]
Message-ID: <20180808070045.13334-2-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20180808070045.13334-1-qi.z.zhang@intel.com>

Handle device reset in a separate thread and raise
RTE_ETH_EVENT_RESET_COMPLETE event when it is done.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 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

  reply	other threads:[~2018-08-08  7:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08  7:00 [dpdk-dev] [RFC 1/4] ethdev: claim device reset as async Qi Zhang
2018-08-08  7:00 ` Qi Zhang [this message]
2018-08-08  7:00 ` [dpdk-dev] [RFC 3/4] net/ixgbe: enable async device reset Qi Zhang
2018-08-08  7:00 ` [dpdk-dev] [RFC 4/4] testpmd: " Qi Zhang
2018-08-08 11:15 ` [dpdk-dev] [RFC 1/4] ethdev: claim device reset as async Kevin Traynor
2018-08-15  1:30   ` Zhang, Qi Z
2018-08-08 15:13 ` Stephen Hemminger
2018-08-08 15:22   ` Andrew Rybchenko
2018-08-09  0:41   ` Zhang, Qi Z

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=20180808070045.13334-2-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=benjamin.h.shelton@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=narender.vangati@intel.com \
    --cc=thomas@monjalon.net \
    --cc=wenzhuo.lu@intel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).