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, Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [RFC v2 2/2] testpmd: enable async device reset
Date: Mon, 10 Sep 2018 21:51:07 +0800 [thread overview]
Message-ID: <20180910135107.6286-3-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20180910135107.6286-1-qi.z.zhang@intel.com>
rte_eth_dev_reset is claimed as an async API, so re-work
on the device reset handling.
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
app/test-pmd/testpmd.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index ee48db2a3..8d4d7b4f9 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1918,6 +1918,54 @@ close_port(portid_t pid)
printf("Done\n");
}
+static int reset_ret;
+static int reset_done;
+
+static int
+on_reset_complete(__rte_unused uint16_t port_id,
+ __rte_unused enum rte_eth_event_type event,
+ __rte_unused void *cb_arg,
+ void *ret_param)
+{
+ RTE_ASSERT(event == RTE_ETH_EVENT_RESET_COMPLETE);
+
+ reset_ret = *(int *)ret_param;
+ reset_done = 1;
+ return 0;
+}
+
+static int
+do_dev_reset_sync(portid_t pid)
+{
+ int ret;
+
+ ret = rte_eth_dev_callback_register(pid,
+ RTE_ETH_EVENT_RESET_COMPLETE,
+ on_reset_complete, NULL);
+
+ if (ret) {
+ printf("Fail to reigster callback function\n");
+ return ret;
+ }
+
+ reset_done = 0;
+ ret = rte_eth_dev_reset(pid);
+ if (ret)
+ goto finish;
+
+ while (!reset_done)
+ rte_delay_ms(10);
+
+ ret = reset_ret;
+
+finish:
+ rte_eth_dev_callback_unregister(pid,
+ RTE_ETH_EVENT_RESET_COMPLETE,
+ on_reset_complete, NULL);
+
+ return ret;
+}
+
void
reset_port(portid_t pid)
{
@@ -1946,7 +1994,7 @@ reset_port(portid_t pid)
continue;
}
- diag = rte_eth_dev_reset(pi);
+ diag = do_dev_reset_sync(pi);
if (diag == 0) {
port = &ports[pi];
port->need_reconfig = 1;
--
2.13.6
prev parent reply other threads:[~2018-09-10 13:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 13:51 [dpdk-dev] [RFC v2 0/2] ethdev: claim device reset as async Qi Zhang
2018-09-10 13:51 ` [dpdk-dev] [RFC v2 1/2] " Qi Zhang
2018-09-10 13:51 ` Qi Zhang [this message]
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=20180910135107.6286-3-qi.z.zhang@intel.com \
--to=qi.z.zhang@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 \
/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).