DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH v6 1/2] eal: add uevent monitor for hot plug
@ 2017-12-13 11:34 Mordechay Haimovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Mordechay Haimovsky @ 2017-12-13 11:34 UTC (permalink / raw)
  To: jia.guo; +Cc: dev

Hello Jeff,

 I've failed to apply the patch on latest DPDK (git://dpdk.org/dpdk), 
Due to missing eal_common_vdev.c file
What am I doing wrong  ?

Moti

$ patch -p1 < dpdk-dev-v6-1-2-eal-add-uevent-monitor-for-hot-plug.patch                            
patching file drivers/bus/pci/bsd/pci.c
Hunk #1 succeeded at 126 (offset -1 lines).
patching file drivers/bus/pci/linux/pci.c
patching file drivers/bus/pci/linux/pci_init.h
patching file drivers/bus/pci/pci_common.c
Hunk #1 succeeded at 282 (offset -1 lines).
Hunk #2 succeeded at 482 (offset -1 lines).
Hunk #3 succeeded at 504 (offset -1 lines).
Hunk #4 succeeded at 568 (offset -1 lines).
patching file drivers/bus/pci/pci_common_uio.c
patching file drivers/bus/pci/private.h
patching file drivers/bus/pci/rte_bus_pci.h
patching file lib/librte_eal/bsdapp/eal/eal_dev.c
patching file lib/librte_eal/bsdapp/eal/include/exec-env/rte_dev.h
patching file lib/librte_eal/common/eal_common_bus.c
patching file lib/librte_eal/common/eal_common_dev.c
Hunk #2 succeeded at 258 (offset -10 lines).
can't find file to patch at input line 746
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
|index f7e547a..2ad517c 100644
|--- a/lib/librte_eal/common/eal_common_vdev.c
|+++ b/lib/librte_eal/common/eal_common_vdev.c
--------------------------
File to patch: ^C

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v5 2/2] app/testpmd: use uevent to monitor hot removal
@ 2017-09-20  4:12 Jeff Guo
  2017-11-01 20:16 ` [dpdk-dev] [PATCH v6 0/2] add uevent monitor for hot plug Jeff Guo
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Guo @ 2017-09-20  4:12 UTC (permalink / raw)
  To: stephen, bruce.richardson, ferruh.yigit, gaetan.rivet
  Cc: konstantin.ananyev, jblunck, shreyansh.jain, jingjing.wu, dev,
	jia.guo, thomas, helin.zhang

use testpmd for example, to show app how to request and use
uevent monitoring to handle the hot removal event and the
hot insertion event.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v5->v4:
add new callback to process hot insertion 
---
 app/test-pmd/testpmd.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e097ee0..df2bb48 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -393,6 +393,9 @@ static void check_all_ports_link_status(uint32_t port_mask);
 static int eth_event_callback(uint8_t port_id,
 			      enum rte_eth_event_type type,
 			      void *param, void *ret_param);
+static int eth_uevent_callback(enum rte_eal_dev_event_type type,
+			      void *param, void *ret_param);
+
 
 /*
  * Check if all the ports are started.
@@ -1413,6 +1416,7 @@ start_port(portid_t pid)
 	struct rte_port *port;
 	struct ether_addr mac_addr;
 	enum rte_eth_event_type event_type;
+	enum rte_eal_dev_event_type dev_event_type;
 
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return 0;
@@ -1547,6 +1551,21 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
+		rte_eal_dev_monitor_enable();
+
+		for (dev_event_type = RTE_EAL_DEV_EVENT_UNKNOWN;
+		     dev_event_type < RTE_EAL_DEV_EVENT_MAX;
+		     dev_event_type++) {
+			diag = rte_dev_callback_register(dev_event_type,
+					eth_uevent_callback,
+					&pi);
+			if (diag) {
+				printf("Failed to setup uevent callback for"
+					" device event %d\n",
+					dev_event_type);
+				return -1;
+			}
+		}
 
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
@@ -1883,6 +1902,35 @@ rmv_event_callback(void *arg)
 			dev->device->name);
 }
 
+static void
+rmv_uevent_callback(void *arg)
+{
+	char name[RTE_ETH_NAME_MAX_LEN];
+
+	uint8_t port_id = *(uint8_t *)arg;
+
+	printf("removing device port_id:%u\n", port_id);
+
+	if (rte_eth_dev_detach(port_id, name)) {
+		RTE_LOG(ERR, USER1, "Failed to detach port '%s'\n", name);
+		return;
+	}
+
+	nb_ports = rte_eth_dev_count();
+
+	printf("Port '%s' is detached. Now total ports is %d\n",
+			name, nb_ports);
+}
+
+static void
+add_uevent_callback(void *arg)
+{
+	char *dev_name = (char *)arg;
+
+	printf("adding device %s\n", dev_name);
+	attach_port(dev_name);
+}
+
 /* This function is used by the interrupt thread */
 static int
 eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param,
@@ -1924,6 +1972,48 @@ eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param,
 	return 0;
 }
 
+/* This function is used by the interrupt thread */
+static int
+eth_uevent_callback(enum rte_eal_dev_event_type type, void *arg,
+		  void *ret_param)
+{
+	static const char * const event_desc[] = {
+		[RTE_EAL_DEV_EVENT_UNKNOWN] = "Unknown",
+		[RTE_EAL_DEV_EVENT_ADD] = "add",
+		[RTE_EAL_DEV_EVENT_REMOVE] = "remove",
+	};
+
+	RTE_SET_USED(ret_param);
+
+	if (type >= RTE_EAL_DEV_EVENT_MAX) {
+		fprintf(stderr, "%s called upon invalid event %d\n",
+			__func__, type);
+		fflush(stderr);
+	} else if (event_print_mask & (UINT32_C(1) << type)) {
+		printf("%s event\n",
+			event_desc[type]);
+		fflush(stdout);
+	}
+
+	switch (type) {
+	case RTE_EAL_DEV_EVENT_ADD:
+		if (rte_eal_alarm_set(2000000,
+			add_uevent_callback, (void *)arg))
+			fprintf(stderr, "Could not set up deferred "
+				"device removal\n");
+		break;
+	case RTE_EAL_DEV_EVENT_REMOVE:
+		if (rte_eal_alarm_set(100000,
+			rmv_uevent_callback, (void *)arg))
+			fprintf(stderr, "Could not set up deferred "
+				"device removal\n");
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
 static int
 set_tx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port)
 {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-02  9:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 11:34 [dpdk-dev] [PATCH v6 1/2] eal: add uevent monitor for hot plug Mordechay Haimovsky
  -- strict thread matches above, loose matches on Subject: below --
2017-09-20  4:12 [dpdk-dev] [PATCH v5 2/2] app/testpmd: use uevent to monitor hot removal Jeff Guo
2017-11-01 20:16 ` [dpdk-dev] [PATCH v6 0/2] add uevent monitor for hot plug Jeff Guo
2017-11-01 20:16   ` [dpdk-dev] [PATCH v6 1/2] eal: " Jeff Guo
2017-11-01 21:36     ` Stephen Hemminger
2017-11-01 21:41     ` Stephen Hemminger
2017-11-08  5:39       ` Guo, Jia
2017-12-25  8:30       ` Guo, Jia
2017-12-25 18:06     ` Stephen Hemminger
2018-01-02  9:40       ` Guo, Jia

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).