[v10,8/8] testpmd: use hotplug failure handle mechanism

Message ID 1534502916-31636-10-git-send-email-jia.guo@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series hotplug failure handle mechanism |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Guo, Jia Aug. 17, 2018, 10:48 a.m. UTC
  This patch use testpmd for example to show how to use failure handle
mechanism for hotplug in app.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v10->v9:
use new APIs to manage hotplug handling.
---
 app/test-pmd/testpmd.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index ee48db2..12fc497 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2098,14 +2098,22 @@  pmd_test_exit(void)
 
 	if (hot_plug) {
 		ret = rte_dev_event_monitor_stop();
-		if (ret)
+		if (ret) {
 			RTE_LOG(ERR, EAL,
 				"fail to stop device event monitor.");
+			return;
+		}
 
 		ret = eth_dev_event_callback_unregister();
 		if (ret)
+			return;
+
+		ret = rte_dev_hotplug_handle_disable();
+		if (ret) {
 			RTE_LOG(ERR, EAL,
-				"fail to unregister all event callbacks.");
+				"fail to disable hotplug handling.");
+			return;
+		}
 	}
 
 	printf("\nBye...\n");
@@ -2784,14 +2792,23 @@  main(int argc, char** argv)
 	init_config();
 
 	if (hot_plug) {
-		/* enable hot plug monitoring */
+		ret = rte_dev_hotplug_handle_enable();
+		if (ret) {
+			RTE_LOG(ERR, EAL,
+				"fail to enable hotplug handling.");
+			return -1;
+		}
+
 		ret = rte_dev_event_monitor_start();
 		if (ret) {
-			rte_errno = EINVAL;
+			RTE_LOG(ERR, EAL,
+				"fail to start device event monitoring.");
 			return -1;
 		}
-		eth_dev_event_callback_register();
 
+		ret = eth_dev_event_callback_register();
+		if (ret)
+			return -1;
 	}
 
 	if (start_port(RTE_PORT_ALL) != 0)