Skip to contentSkip to conversation

add device removal event

PATCH Superseded Gaetan Rivet 5 participants 35 messages Mar 3, 2017 – May 2, 2017 Network drivers

lore
Share & tools
lore
#0 lore raw

cover add device removal event

This new event represents the sudden removal of a device from its bus. The underlying resources exposed by the bus are expected not to be available anymore. The application should thus be able to react and possibly clean up related resources that it reserved for the removed device.

This event is different from the current hotplug API available in the DPDK for two reasons:

1. It is a reactive design: the application reacts to a device that has been removed instead of removing a device from its pool.

2. The event itself is going further than the current detaching of a device from a DPDK application. If the bus is a hardware one, it is expected of the underlying resources to not be available anymore.

This series adds a new event type to ethdev and implements it in mlx4. Testpmd is also updated to report all asynchronous ethdev events including this one for testing purposes and as a practical usage example.

This series depends on the series titled
[PATCH 1/2] net/mlx4: split the definitions to the header file

Gaetan Rivet (5):
ethdev: introduce device removal event
net/mlx4: device removal event support
app/testpmd: generic event handler
app/testpmd: request link status interrupt
app/testpmd: request device removal interrupt

 app/test-pmd/parameters.c                       |   8 +
 app/test-pmd/testpmd.c                          | 103 ++++++++++
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/nics/features/default.ini            |   1 +
 doc/guides/nics/features/mlx4.ini               |   1 +
 doc/guides/prog_guide/env_abstraction_layer.rst |  21 +-
 drivers/net/mlx4/mlx4.c                         | 258 ++++++++++++++++++++----
 drivers/net/mlx4/mlx4.h                         |   1 +
 lib/librte_eal/common/include/rte_pci.h         |   2 +
 lib/librte_ether/rte_ethdev.c                   |  13 +-
 lib/librte_ether/rte_ethdev.h                   |   9 +-
 11 files changed, 375 insertions(+), 44 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/5 ethdev: introduce device removal event

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

PMDs implementing support for this notification guarantee that the removal of the underlying device does not incur a risk to the application.

In particular, Rx/Tx bursts and all other functions can still be called (albeit likely returning errors) without triggering a crash, irrespective of an application handling this event.

---
 doc/guides/nics/features/default.ini            |  1 +
 doc/guides/prog_guide/env_abstraction_layer.rst | 21 +++++++++++++++++++--
 lib/librte_eal/common/include/rte_pci.h         |  2 ++
 lib/librte_ether/rte_ethdev.c                   | 13 +++++++++----
 lib/librte_ether/rte_ethdev.h                   |  9 +++++++--
 5 files changed, 38 insertions(+), 8 deletions(-)
doc/guides/nics/features/default.ini +1 -0
index 9e363ff..7bb56ec 100644
@@ -9,6 +9,7 @@
 Speed capabilities   =
 Link status          =
 Link status event    =
+Removal event        =
 Queue status event   =
 Rx interrupt         =
 Queue start/stop     =
doc/guides/prog_guide/env_abstraction_layer.rst +19 -2
index 10a10a8..f72674f 100644
@@ -178,8 +178,8 @@ The EAL also allows timed callbacks to be used in the same way as for NIC interr
 
 .. note::
 
-    In DPDK PMD, the only interrupts handled by the dedicated host thread are those for link status change,
-    i.e. link up and link down notification.
+    In DPDK PMD, the only interrupts handled by the dedicated host thread are those for link status change
+    (link up and link down notification) and for sudden device removal.
 
 
 + RX Interrupt Event
@@ -207,6 +207,23 @@ The eth_dev driver takes responsibility to program the latter mapping.
 The RX interrupt are controlled/enabled/disabled by ethdev APIs - 'rte_eth_dev_rx_intr_*'. They return failure if the PMD
 hasn't support them yet. The intr_conf.rxq flag is used to turn on the capability of RX interrupt per device.
 
++ Device Removal Event
+
+This event is triggered by a device being removed at a bus level. Its
+underlying resources may have been made unavailable (i.e. PCI mappings
+unmapped). The PMD must make sure that on such occurrence, the application can
+still safely use its callbacks.
+
+This event can be subscribed to in the same way one would subscribe to a link
+status change event. The execution context is thus the same, i.e. it is the
+dedicated interrupt host thread.
+
+Considering this, it is likely that an application would want to close a
+device having emitted a Device Removal Event. In such case, calling
+``rte_eth_dev_close()`` can trigger it to unregister its own Device Removal Event
+callback. Care must be taken not to close the device from the interrupt handler
+context. It is necessary to reschedule such closing operation.
+
 Blacklisting
 ~~~~~~~~~~~~
 
lib/librte_eal/common/include/rte_pci.h +2 -0
index 8557e47..4a67883 100644
@@ -216,6 +216,8 @@ struct rte_pci_driver {
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device driver supports link state interrupt */
 #define RTE_PCI_DRV_INTR_LSC	0x0008
+/** Device driver supports device removal interrupt */
+#define RTE_PCI_DRV_INTR_RMV 0x0010
 
 /**
  * A structure describing a PCI mapping.
lib/librte_ether/rte_ethdev.c +9 -4
index 3a52d0a..6c4b796 100644
@@ -848,16 +848,19 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EINVAL;
 	}
 
-	/*
-	 * If link state interrupt is enabled, check that the
-	 * device supports it.
-	 */
+	/* Check that the device supports requested interrupts */
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
 					dev->data->drv_name);
 			return -EINVAL;
 	}
+	if ((dev_conf->intr_conf.rmv == 1) &&
+	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
+		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
+				    dev->data->drv_name);
+		return -EINVAL;
+	}
 
 	/*
 	 * If jumbo frames are enabled, check that the maximum RX packet
@@ -3222,6 +3225,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 	eth_dev->data->dev_flags = 0;
 	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
+		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
lib/librte_ether/rte_ethdev.h +7 -2
index bdad81b..ed99660 100644
@@ -816,9 +816,11 @@ struct rte_eth_udp_tunnel {
  */
 struct rte_intr_conf {
 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
-	uint16_t lsc;
+	uint32_t lsc:1;
 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
-	uint16_t rxq;
+	uint32_t rxq:1;
+	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
+	uint32_t rmv:1;
 };
 
 /**
@@ -1722,6 +1724,8 @@ struct rte_eth_dev_data {
 #define RTE_ETH_DEV_INTR_LSC     0x0002
 /** Device is a bonded slave */
 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
+/** Device supports device removal interrupt */
+#define RTE_ETH_DEV_INTR_RMV     0x0008
 
 /**
  * @internal
@@ -3212,6 +3216,7 @@ enum rte_eth_event_type {
 			/**< reset interrupt event, sent to VF on PF reset */
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
+	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/5 net/mlx4: device removal event support

In reply to Gaetan Rivet

Extend the LSC event handling to support the device removal as well. The Verbs library will send several related events, that can conflict with the LSC event itself.

The event handling has thus been made capable of receiving and signaling several event types at once.

---
 doc/guides/nics/features/mlx4.ini |   1 +
 drivers/net/mlx4/mlx4.c           | 258 ++++++++++++++++++++++++++++++++------
 drivers/net/mlx4/mlx4.h           |   1 +
 3 files changed, 224 insertions(+), 36 deletions(-)
doc/guides/nics/features/mlx4.ini +1 -0
index c9828f7..285f0ec 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Link status event    = Y
+Removal event        = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
drivers/net/mlx4/mlx4.c +222 -36

380 lines not on this page · raw message

drivers/net/mlx4/mlx4.h +1 -0
index e9659eb..063df5f 100644
@@ -356,6 +356,7 @@ struct priv {
 	struct rxq *(*rxqs)[]; /* RX queues. */
 	struct txq *(*txqs)[]; /* TX queues. */
 	struct rte_intr_handle intr_handle; /* Interrupt handler. */
+	struct rte_intr_conf intr_conf; /* Active interrupt configuration. */
 	LIST_HEAD(mlx4_flows, rte_flow) flows;
 	rte_spinlock_t lock; /* Lock for control functions. */
 };
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/5 app/testpmd: generic event handler

In reply to Gaetan Rivet

This is a rather simple handler that prints a message with the name of the current event. It can be used to check PMD callback registration and triggers.

---
 app/test-pmd/testpmd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
app/test-pmd/testpmd.c +47 -0
index b8ec1fe..f2b67d5 100644
@@ -326,6 +326,9 @@ unsigned max_socket = 0;
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port);
 static void check_all_ports_link_status(uint32_t port_mask);
+static void eth_event_callback(uint8_t port_id,
+			       enum rte_eth_event_type type,
+			       void *param);
 
 /*
  * Check if all the ports are started.
@@ -1299,6 +1302,7 @@ start_port(portid_t pid)
 	queueid_t qi;
 	struct rte_port *port;
 	struct ether_addr mac_addr;
+	enum rte_eth_event_type event_type;
 
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return 0;
@@ -1410,6 +1414,21 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
+
+		for (event_type = RTE_ETH_EVENT_UNKNOWN;
+		     event_type < RTE_ETH_EVENT_MAX;
+		     event_type++) {
+			diag = rte_eth_dev_callback_register(pi,
+							event_type,
+							eth_event_callback,
+							NULL);
+			if (diag) {
+				printf("Failed to setup even callback for event %d\n",
+					event_type);
+				return -1;
+			}
+		}
+
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
@@ -1682,6 +1701,34 @@ check_all_ports_link_status(uint32_t port_mask)
 	}
 }
 
+/* This function is used by the interrupt thread */
+static void
+eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
+{
+	static const char * const event_desc[] = {
+		[RTE_ETH_EVENT_UNKNOWN] = "Unknown",
+		[RTE_ETH_EVENT_INTR_LSC] = "LSC",
+		[RTE_ETH_EVENT_QUEUE_STATE] = "Queue state",
+		[RTE_ETH_EVENT_INTR_RESET] = "Interrupt reset",
+		[RTE_ETH_EVENT_VF_MBOX] = "VF Mbox",
+		[RTE_ETH_EVENT_MACSEC] = "MACsec",
+		[RTE_ETH_EVENT_INTR_RMV] = "device removal",
+		[RTE_ETH_EVENT_MAX] = NULL,
+	};
+
+	RTE_SET_USED(param);
+
+	if (type >= RTE_ETH_EVENT_MAX) {
+		fprintf(stderr, "\nPort %" PRIu8 ": %s called upon invalid event %d\n",
+			port_id, __func__, type);
+		fflush(stderr);
+	} else {
+		printf("\nPort %" PRIu8 ": %s event\n", port_id,
+			event_desc[type]);
+		fflush(stdout);
+	}
+}
+
 static int
 set_tx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port)
 {
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/5 app/testpmd: request link status interrupt

In reply to Gaetan Rivet

For drivers supporting the LSC event, enable it.
This allows to test LSC event support.

Add the --no-lsc-interrupt parameter to explicitly disable the link status change interrupt.

---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 13 +++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+)
app/test-pmd/parameters.c +4 -0
index 67d8bf2..89231be 100644
@@ -196,6 +196,7 @@ usage(char* progname)
 		" or total packet length.\n");
 	printf("  --disable-link-check: disable check on link status when "
 	       "starting/stopping ports.\n");
+	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -561,6 +562,7 @@ launch_args_parse(int argc, char** argv)
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
+		{ "no-lsc-interrupt",		0, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -978,6 +980,8 @@ launch_args_parse(int argc, char** argv)
 				no_flush_rx = 1;
 			if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
 				no_link_check = 1;
+			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
+				lsc_interrupt = 0;
 
 			break;
 		case 'h':
app/test-pmd/testpmd.c +13 -0
index f2b67d5..8bd1285 100644
@@ -263,6 +263,11 @@ uint8_t no_flush_rx = 0; /* flush by default */
 uint8_t no_link_check = 0; /* check by default */
 
 /*
+ * Enable link status change notification
+ */
+uint8_t lsc_interrupt = 1; /* enabled by default */
+
+/*
  * NIC bypass mode configuration options.
  */
 #ifdef RTE_NIC_BYPASS
@@ -1698,6 +1703,9 @@ check_all_ports_link_status(uint32_t port_mask)
 		if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
 			print_flag = 1;
 		}
+
+		if (lsc_interrupt)
+			break;
 	}
 }
 
@@ -1892,6 +1900,11 @@ init_port_config(void)
 #ifdef RTE_NIC_BYPASS
 		rte_eth_dev_bypass_init(pid);
 #endif
+
+		if (lsc_interrupt &&
+		    (rte_eth_devices[pid].data->dev_flags &
+		     RTE_ETH_DEV_INTR_LSC))
+			port->dev_conf.intr_conf.lsc = 1;
 	}
 }
 
app/test-pmd/testpmd.h +1 -0
index e1e4939..77fa7ee 100644
@@ -305,6 +305,7 @@ extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
 extern uint8_t  mp_anon; /**< set by "--mp-anon" parameter */
 extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
+extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 
 #ifdef RTE_NIC_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/5 app/testpmd: request device removal interrupt

In reply to Gaetan Rivet

Enable device removal event for PMD supporting it. Add the --no-rmv-interrupt parameter to explicitly disable it.

---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 48 insertions(+)
app/test-pmd/parameters.c +4 -0
index 89231be..792e2e9 100644
@@ -197,6 +197,7 @@ usage(char* progname)
 	printf("  --disable-link-check: disable check on link status when "
 	       "starting/stopping ports.\n");
 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
+	printf("  --no-rmv-interrupt: disable device removal interrupt.");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -563,6 +564,7 @@ launch_args_parse(int argc, char** argv)
 		{ "txpkts",			1, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
 		{ "no-lsc-interrupt",		0, 0, 0 },
+		{ "no-rmv-interrupt",		0, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -982,6 +984,8 @@ launch_args_parse(int argc, char** argv)
 				no_link_check = 1;
 			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
 				lsc_interrupt = 0;
+			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
+				rmv_interrupt = 0;
 
 			break;
 		case 'h':
app/test-pmd/testpmd.c +43 -0

73 lines not on this page · raw message

app/test-pmd/testpmd.h +1 -0
index 77fa7ee..85d3e82 100644
@@ -306,6 +306,7 @@ extern uint8_t  mp_anon; /**< set by "--mp-anon" parameter */
 extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
+extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
 
 #ifdef RTE_NIC_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
Signature · 1 line
2.1.4
#6 lore raw
In reply to Gaetan Rivet

Hi all,

Following the discussion that took place during the tech board meeting, it seems that some clarification and some additional discussion is needed about this series.

As of now, what I plan to do is to:

1. Rebase this series upon the bus framework [1][2][3].
2. Write further documentation to clarify the meaning of this event and further identify the best approach to implement it.

What I expect from this is to spawn a discussion about the best way to achieve a true hot-plug feature in DPDK.

Any thoughts, comments regarding this?
Regards,

[1] http://dpdk.org/ml/archives/dev/2017-January/054165.html
[2] http://dpdk.org/ml/archives/dev/2017-March/059423.html
[3] http://dpdk.org/ml/archives/dev/2017-March/059376.html

Quoted 46 lines · Gaetan Rivet

This new event represents the sudden removal of a device from its bus. The underlying resources exposed by the bus are expected not to be available anymore. The application should thus be able to react and possibly clean up related resources that it reserved for the removed device.

This event is different from the current hotplug API available in the DPDK for two reasons:

1. It is a reactive design: the application reacts to a device that has been removed instead of removing a device from its pool.

2. The event itself is going further than the current detaching of a device from a DPDK application. If the bus is a hardware one, it is expected of the underlying resources to not be available anymore.

This series adds a new event type to ethdev and implements it in mlx4. Testpmd is also updated to report all asynchronous ethdev events including this one for testing purposes and as a practical usage example.

This series depends on the series titled
[PATCH 1/2] net/mlx4: split the definitions to the header file

Gaetan Rivet (5):
ethdev: introduce device removal event
net/mlx4: device removal event support
app/testpmd: generic event handler
app/testpmd: request link status interrupt
app/testpmd: request device removal interrupt

 app/test-pmd/parameters.c                       |   8 +
 app/test-pmd/testpmd.c                          | 103 ++++++++++
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/nics/features/default.ini            |   1 +
 doc/guides/nics/features/mlx4.ini               |   1 +
 doc/guides/prog_guide/env_abstraction_layer.rst |  21 +-
 drivers/net/mlx4/mlx4.c                         | 258 ++++++++++++++++++++----
 drivers/net/mlx4/mlx4.h                         |   1 +
 lib/librte_eal/common/include/rte_pci.h         |   2 +
 lib/librte_ether/rte_ethdev.c                   |  13 +-
 lib/librte_ether/rte_ethdev.h                   |   9 +-
 11 files changed, 375 insertions(+), 44 deletions(-)

--
2.1.4

#7 lore raw

v2 cover add device removal event

In reply to Gaetan Rivet

This new event represents the sudden removal of a device from its bus. The underlying resources exposed by the bus are expected not to be available anymore. The application should thus be able to react and possibly clean up related resources that it reserved for the removed device.

This event is different from the current hotplug API available in the DPDK for two reasons:

1. It is a reactive design: the application reacts to a device that has been removed instead of removing a device from its pool.

2. The event itself is going further than the current detaching of a device from a DPDK application. If the bus is a hardware one, it is expected of the underlying resources to not be available anymore.

This series adds a new event type to ethdev and implements it in mlx4. Testpmd is also updated to report all asynchronous ethdev events including this one for testing purposes and as a practical usage example.

This series depends on the series titled
[PATCH 1/2] net/mlx4: split the definitions to the header file

v1 --> v2:
* integrated the series with the new PCI rte_bus implementation.

I planned on working out a more generic implementation of the RMV event for the v17.05, however while writing it I found that I had to evolve the support of interrupts in the PCI rte_bus, which did not seem wise at this point of the release cycle.

I consider that this event should be generalized along the LSC event, going from pure PCI events to generic rte_bus events, given that they can be relevant to other busses (vdev at least). I would reserve this evolution for future release however, once a real discussion has taken place.

Gaetan Rivet (5):
ethdev: introduce device removal event
net/mlx4: device removal event support
app/testpmd: generic event handler
app/testpmd: request link status interrupt
app/testpmd: request device removal interrupt

 app/test-pmd/parameters.c                       |   8 +
 app/test-pmd/testpmd.c                          | 103 ++++++++++
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/nics/features/default.ini            |   1 +
 doc/guides/nics/features/mlx4.ini               |   1 +
 doc/guides/prog_guide/env_abstraction_layer.rst |  21 +-
 drivers/net/mlx4/mlx4.c                         | 258 ++++++++++++++++++++----
 drivers/net/mlx4/mlx4.h                         |   1 +
 lib/librte_eal/common/include/rte_pci.h         |   2 +
 lib/librte_ether/rte_ethdev.c                   |  11 +-
 lib/librte_ether/rte_ethdev.h                   |   9 +-
 lib/librte_ether/rte_ethdev_pci.h               |   2 +
 12 files changed, 375 insertions(+), 44 deletions(-)
Signature · 1 line
2.1.4
#8 lore raw

PATCH v2 1/5 ethdev: introduce device removal event

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

PMDs implementing support for this notification guarantee that the removal of the underlying device does not incur a risk to the application.

In particular, Rx/Tx bursts and all other functions can still be called (albeit likely returning errors) without triggering a crash, irrespective of an application handling this event.

---
 doc/guides/nics/features/default.ini            |  1 +
 doc/guides/prog_guide/env_abstraction_layer.rst | 21 +++++++++++++++++++--
 lib/librte_eal/common/include/rte_pci.h         |  2 ++
 lib/librte_ether/rte_ethdev.c                   | 11 +++++++----
 lib/librte_ether/rte_ethdev.h                   |  9 +++++++--
 lib/librte_ether/rte_ethdev_pci.h               |  2 ++
 6 files changed, 38 insertions(+), 8 deletions(-)
doc/guides/nics/features/default.ini +1 -0
index b1b9114..cafc6c7 100644
@@ -10,6 +10,7 @@
 Speed capabilities   =
 Link status          =
 Link status event    =
+Removal event        =
 Queue status event   =
 Rx interrupt         =
 Free Tx mbuf on demand =
doc/guides/prog_guide/env_abstraction_layer.rst +19 -2
index 7c39cd2..fff1c06 100644
@@ -178,8 +178,8 @@ The EAL also allows timed callbacks to be used in the same way as for NIC interr
 
 .. note::
 
-    In DPDK PMD, the only interrupts handled by the dedicated host thread are those for link status change,
-    i.e. link up and link down notification.
+    In DPDK PMD, the only interrupts handled by the dedicated host thread are those for link status change
+    (link up and link down notification) and for sudden device removal.
 
 
 + RX Interrupt Event
@@ -207,6 +207,23 @@ The eth_dev driver takes responsibility to program the latter mapping.
 The RX interrupt are controlled/enabled/disabled by ethdev APIs - 'rte_eth_dev_rx_intr_*'. They return failure if the PMD
 hasn't support them yet. The intr_conf.rxq flag is used to turn on the capability of RX interrupt per device.
 
++ Device Removal Event
+
+This event is triggered by a device being removed at a bus level. Its
+underlying resources may have been made unavailable (i.e. PCI mappings
+unmapped). The PMD must make sure that on such occurrence, the application can
+still safely use its callbacks.
+
+This event can be subscribed to in the same way one would subscribe to a link
+status change event. The execution context is thus the same, i.e. it is the
+dedicated interrupt host thread.
+
+Considering this, it is likely that an application would want to close a
+device having emitted a Device Removal Event. In such case, calling
+``rte_eth_dev_close()`` can trigger it to unregister its own Device Removal Event
+callback. Care must be taken not to close the device from the interrupt handler
+context. It is necessary to reschedule such closing operation.
+
 Blacklisting
 ~~~~~~~~~~~~
 
lib/librte_eal/common/include/rte_pci.h +2 -0
index fedb197..6effb7a 100644
@@ -239,6 +239,8 @@ struct rte_pci_bus {
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device driver supports link state interrupt */
 #define RTE_PCI_DRV_INTR_LSC	0x0008
+/** Device driver supports device removal interrupt */
+#define RTE_PCI_DRV_INTR_RMV 0x0010
 
 /**
  * A structure describing a PCI mapping.
lib/librte_ether/rte_ethdev.c +7 -4
index 474188c..ed261c2 100644
@@ -749,16 +749,19 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EINVAL;
 	}
 
-	/*
-	 * If link state interrupt is enabled, check that the
-	 * device supports it.
-	 */
+	/* Check that the device supports requested interrupts */
 	if ((dev_conf->intr_conf.lsc == 1) &&
 		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
 					dev->data->drv_name);
 			return -EINVAL;
 	}
+	if ((dev_conf->intr_conf.rmv == 1) &&
+	    (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
+		RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
+				    dev->data->drv_name);
+		return -EINVAL;
+	}
 
 	/*
 	 * If jumbo frames are enabled, check that the maximum RX packet
lib/librte_ether/rte_ethdev.h +7 -2
index 68a91e2..b8381d6 100644
@@ -815,9 +815,11 @@ struct rte_eth_udp_tunnel {
  */
 struct rte_intr_conf {
 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
-	uint16_t lsc;
+	uint32_t lsc:1;
 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
-	uint16_t rxq;
+	uint32_t rxq:1;
+	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
+	uint32_t rmv:1;
 };
 
 /**
@@ -1737,6 +1739,8 @@ struct rte_eth_dev_data {
 #define RTE_ETH_DEV_INTR_LSC     0x0002
 /** Device is a bonded slave */
 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
+/** Device supports device removal interrupt */
+#define RTE_ETH_DEV_INTR_RMV     0x0008
 
 /**
  * @internal
@@ -3313,6 +3317,7 @@ enum rte_eth_event_type {
 			/**< reset interrupt event, sent to VF on PF reset */
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
+	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
lib/librte_ether/rte_ethdev_pci.h +2 -0
index 2953579..d3bc03c 100644
@@ -64,6 +64,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 	eth_dev->data->dev_flags = 0;
 	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV)
+		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV;
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->device.numa_node;
Signature · 1 line
2.1.4
#9 lore raw

Re: [PATCH v2 1/5] ethdev: introduce device removal event

Quoted 13 lines · Gaetan Rivet

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

PMDs implementing support for this notification guarantee that the removal of the underlying device does not incur a risk to the application.

In particular, Rx/Tx bursts and all other functions can still be called (albeit likely returning errors) without triggering a crash, irrespective of an application handling this event.

<...>

doc/guides/nics/features/default.ini line 16

Quoted 12 lines
doc/guides/nics/features/default.ini +1 -0
index b1b9114..cafc6c7 100644
@@ -10,6 +10,7 @@
 Speed capabilities   =
 Link status          =
 Link status event    =
+Removal event        =
 Queue status event   =
 Rx interrupt         =
 Free Tx mbuf on demand =

This release a few NIC features added, and it is hard to follow them if you are particularly looking for these features.

So do you think does it make sense to put those new PMD features into release notes to make it more visible?

Thanks,
ferruh

#10 lore raw

Re: [PATCH v2 1/5] ethdev: introduce device removal event

Hi Ferruh,

Quoted 33 lines · Ferruh Yigit
Quoted 13 lines · Gaetan Rivet

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

PMDs implementing support for this notification guarantee that the removal of the underlying device does not incur a risk to the application.

In particular, Rx/Tx bursts and all other functions can still be called (albeit likely returning errors) without triggering a crash, irrespective of an application handling this event.

<...>

doc/guides/nics/features/default.ini line 16

Quoted 12 lines
doc/guides/nics/features/default.ini +1 -0
index b1b9114..cafc6c7 100644
@@ -10,6 +10,7 @@
 Speed capabilities   =
 Link status          =
 Link status event    =
+Removal event        =
 Queue status event   =
 Rx interrupt         =
 Free Tx mbuf on demand =

This release a few NIC features added, and it is hard to follow them if you are particularly looking for these features.

Quoted 3 lines

So do you think does it make sense to put those new PMD features into release notes to make it more visible?

Yes it seems like a good idea to announce this evolution. I will send the relevant patch for this soon.

Quoted 2 lines

Thanks,
ferruh

Signature · 2 lines
Gaëtan Rivet
6WIND
#11 lore raw

Re: [PATCH v2 1/5] ethdev: introduce device removal event

Am 25.04.2017 11:06 schrieb "Gaëtan Rivet" <[email protected]>:

Hi Ferruh,

Quoted 7 lines · Ferruh Yigit
Quoted 4 lines · Gaetan Rivet

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

I don't think this belongs into ethdev. If it is bus related we need to expose this from it so that apps can register for the low level device being unplugged.

Jan

Quoted 31 lines
Quoted 10 lines

PMDs implementing support for this notification guarantee that the removal of the underlying device does not incur a risk to the application.

In particular, Rx/Tx bursts and all other functions can still be called (albeit likely returning errors) without triggering a crash, irrespective of an application handling this event.

<...>

(quoted diff) +0 -0

doc/guides/nics/features/default.ini line 16

Quoted 13 lines

b/doc/guides/nics/features/default.ini
index b1b9114..cafc6c7 100644

doc/guides/nics/features/default.ini +1 -0
@@ -10,6 +10,7 @@
 Speed capabilities   =
 Link status          =
 Link status event    =
+Removal event        =
 Queue status event   =
 Rx interrupt         =
 Free Tx mbuf on demand =

This release a few NIC features added, and it is hard to follow them if you are particularly looking for these features.

Quoted 4 lines

So do you think does it make sense to put those new PMD features into release notes to make it more visible?

Yes it seems like a good idea to announce this evolution. I will send the relevant patch for this soon.

Thanks,

Quoted 2 lines

ferruh

Signature · 2 lines
Gaėtan Rivet
6WIND
#12 lore raw

Re: [PATCH v2 1/5] ethdev: introduce device removal event

02/05/2017 09:35, Jan Blunck:

Quoted 9 lines

Am 25.04.2017 11:06 schrieb "Gaëtan Rivet" <[email protected]>:

Hi Ferruh,

Quoted 2 lines · Ferruh Yigit

On 4/18/2017 1:17 PM, Gaetan Rivet wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

I don't think this belongs into ethdev. If it is bus related we need to expose this from it so that apps can register for the low level device being unplugged.

Yes it sounds right.
We could work on device notifications.
We need to find a way of notifying the application that there is a device event and that it affects one or more port at ethdev/cryptodev/eventdev level.

#13 lore raw

Re: [PATCH v2 1/5] ethdev: introduce device removal event

Quoted 19 lines · Thomas Monjalon

02/05/2017 09:35, Jan Blunck:

Quoted 9 lines

Am 25.04.2017 11:06 schrieb "Gaëtan Rivet" <[email protected]>:

Hi Ferruh,

Quoted 2 lines · Ferruh Yigit

On 4/18/2017 1:17 PM, Gaetan Rivet wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

This new API allows reacting to a device removal.
A device removal is the sudden disappearance of a device from its bus.

I don't think this belongs into ethdev. If it is bus related we need to expose this from it so that apps can register for the low level device being unplugged.

Quoted 5 lines

Yes it sounds right.
We could work on device notifications.
We need to find a way of notifying the application that there is a device event and that it affects one or more port at ethdev/cryptodev/eventdev level.

This is interesting.
I developed this event with an easier integration in v17.05 in mind. It needs a proper generic implementation however (as suggested in [1]).

I tried to have this discussion earlier[2], but without much interest.

However, even with a bus-level event framework, we still need a way for drivers to advertize their support for specific events, and we still need to differentiate devices that are ready for specific events from those that do not.

So I agree that it would be interesting to have a generic rte_device level interrupt framework to support generic events accross the whole board, but I'm not sure it would make the dichotomy between the *driver support* flag and the *device enabled* flag disappear.

Regards,
--
[1]: http://dpdk.org/ml/archives/dev/2017-April/064190.html
[2]: http://dpdk.org/ml/archives/dev/2017-March/060998.html

Signature · 2 lines
Gaëtan Rivet
6WIND
#14 lore raw

PATCH v2 2/5 net/mlx4: device removal event support

In reply to Gaetan Rivet

Extend the LSC event handling to support the device removal as well. The Verbs library will send several related events, that can conflict with the LSC event itself.

The event handling has thus been made capable of receiving and signaling several event types at once.

---
 doc/guides/nics/features/mlx4.ini |   1 +
 drivers/net/mlx4/mlx4.c           | 258 ++++++++++++++++++++++++++++++++------
 drivers/net/mlx4/mlx4.h           |   1 +
 3 files changed, 224 insertions(+), 36 deletions(-)
doc/guides/nics/features/mlx4.ini +1 -0
index c9828f7..285f0ec 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Link status event    = Y
+Removal event        = Y
 Queue start/stop     = Y
 MTU update           = Y
 Jumbo frame          = Y
drivers/net/mlx4/mlx4.c +222 -36

379 lines not on this page · raw message

drivers/net/mlx4/mlx4.h +1 -0
index 08af155..9a3bae9 100644
@@ -347,6 +347,7 @@ struct priv {
 	struct rte_intr_handle intr_handle; /* Interrupt handler. */
 	struct rte_flow_drop *flow_drop_queue; /* Flow drop queue. */
 	LIST_HEAD(mlx4_flows, rte_flow) flows;
+	struct rte_intr_conf intr_conf; /* Active interrupt configuration. */
 	rte_spinlock_t lock; /* Lock for control functions. */
 };
 
Signature · 1 line
2.1.4
#15 lore raw

PATCH v2 3/5 app/testpmd: generic event handler

In reply to Gaetan Rivet

This is a rather simple handler that prints a message with the name of the current event. It can be used to check PMD callback registration and triggers.

---
 app/test-pmd/testpmd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
app/test-pmd/testpmd.c +47 -0
index d6bd2b2..221f0e9 100644
@@ -351,6 +351,9 @@ struct rte_stats_bitrates *bitrate_data;
 /* Forward function declarations */
 static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port);
 static void check_all_ports_link_status(uint32_t port_mask);
+static void eth_event_callback(uint8_t port_id,
+			       enum rte_eth_event_type type,
+			       void *param);
 
 /*
  * Check if all the ports are started.
@@ -1347,6 +1350,7 @@ start_port(portid_t pid)
 	queueid_t qi;
 	struct rte_port *port;
 	struct ether_addr mac_addr;
+	enum rte_eth_event_type event_type;
 
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return 0;
@@ -1458,6 +1462,21 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
+
+		for (event_type = RTE_ETH_EVENT_UNKNOWN;
+		     event_type < RTE_ETH_EVENT_MAX;
+		     event_type++) {
+			diag = rte_eth_dev_callback_register(pi,
+							event_type,
+							eth_event_callback,
+							NULL);
+			if (diag) {
+				printf("Failed to setup even callback for event %d\n",
+					event_type);
+				return -1;
+			}
+		}
+
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
@@ -1730,6 +1749,34 @@ check_all_ports_link_status(uint32_t port_mask)
 	}
 }
 
+/* This function is used by the interrupt thread */
+static void
+eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
+{
+	static const char * const event_desc[] = {
+		[RTE_ETH_EVENT_UNKNOWN] = "Unknown",
+		[RTE_ETH_EVENT_INTR_LSC] = "LSC",
+		[RTE_ETH_EVENT_QUEUE_STATE] = "Queue state",
+		[RTE_ETH_EVENT_INTR_RESET] = "Interrupt reset",
+		[RTE_ETH_EVENT_VF_MBOX] = "VF Mbox",
+		[RTE_ETH_EVENT_MACSEC] = "MACsec",
+		[RTE_ETH_EVENT_INTR_RMV] = "device removal",
+		[RTE_ETH_EVENT_MAX] = NULL,
+	};
+
+	RTE_SET_USED(param);
+
+	if (type >= RTE_ETH_EVENT_MAX) {
+		fprintf(stderr, "\nPort %" PRIu8 ": %s called upon invalid event %d\n",
+			port_id, __func__, type);
+		fflush(stderr);
+	} else {
+		printf("\nPort %" PRIu8 ": %s event\n", port_id,
+			event_desc[type]);
+		fflush(stdout);
+	}
+}
+
 static int
 set_tx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port)
 {
Signature · 1 line
2.1.4
#16 lore raw

PATCH v2 4/5 app/testpmd: request link status interrupt

In reply to Gaetan Rivet

For drivers supporting the LSC event, enable it.
This allows to test LSC event support.

Add the --no-lsc-interrupt parameter to explicitly disable the link status change interrupt.

---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 13 +++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+)
app/test-pmd/parameters.c +4 -0
index c36bcf8..c79c349 100644
@@ -200,6 +200,7 @@ usage(char* progname)
 		" or total packet length.\n");
 	printf("  --disable-link-check: disable check on link status when "
 	       "starting/stopping ports.\n");
+	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -568,6 +569,7 @@ launch_args_parse(int argc, char** argv)
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
+		{ "no-lsc-interrupt",		0, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -998,6 +1000,8 @@ launch_args_parse(int argc, char** argv)
 				no_flush_rx = 1;
 			if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
 				no_link_check = 1;
+			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
+				lsc_interrupt = 0;
 
 			break;
 		case 'h':
app/test-pmd/testpmd.c +13 -0
index 221f0e9..5f94393 100644
@@ -271,6 +271,11 @@ uint8_t no_flush_rx = 0; /* flush by default */
 uint8_t no_link_check = 0; /* check by default */
 
 /*
+ * Enable link status change notification
+ */
+uint8_t lsc_interrupt = 1; /* enabled by default */
+
+/*
  * NIC bypass mode configuration options.
  */
 #ifdef RTE_NIC_BYPASS
@@ -1746,6 +1751,9 @@ check_all_ports_link_status(uint32_t port_mask)
 		if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
 			print_flag = 1;
 		}
+
+		if (lsc_interrupt)
+			break;
 	}
 }
 
@@ -1929,6 +1937,11 @@ init_port_config(void)
 #ifdef RTE_NIC_BYPASS
 		rte_eth_dev_bypass_init(pid);
 #endif
+
+		if (lsc_interrupt &&
+		    (rte_eth_devices[pid].data->dev_flags &
+		     RTE_ETH_DEV_INTR_LSC))
+			port->dev_conf.intr_conf.lsc = 1;
 	}
 }
 
app/test-pmd/testpmd.h +1 -0
index 642796e..62f89e6 100644
@@ -305,6 +305,7 @@ extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
 extern uint8_t  mp_anon; /**< set by "--mp-anon" parameter */
 extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
+extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 
 #ifdef RTE_NIC_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
Signature · 1 line
2.1.4
#17 lore raw

Re: [PATCH v2 4/5] app/testpmd: request link status interrupt

Quoted 6 lines · Gaetan Rivet

For drivers supporting the LSC event, enable it.
This allows to test LSC event support.

Add the --no-lsc-interrupt parameter to explicitly disable the link status change interrupt.

Quoted 6 lines
---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 13 +++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+)

Hi Gaetan,

This patch adds new option to testpmd, can you please update testpmd documentation to document new option?

Same is valid for next patch (no-rmv-interrupt option)

Thanks,
ferruh

#18 lore raw

Re: [PATCH v2 4/5] app/testpmd: request link status interrupt

Quoted 14 lines · Ferruh Yigit
Quoted 6 lines · Gaetan Rivet

For drivers supporting the LSC event, enable it.
This allows to test LSC event support.

Add the --no-lsc-interrupt parameter to explicitly disable the link status change interrupt.

Quoted 6 lines
---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 13 +++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+)
Quoted 7 lines

Hi Gaetan,

This patch adds new option to testpmd, can you please update testpmd documentation to document new option?

Same is valid for next patch (no-rmv-interrupt option)

Sure, I will send a patch for this.

Should I send a new version of my previous series or a single patch fixing the documentation for both options as a standalone?

Quoted 3 lines

Thanks,
ferruh

Signature · 2 lines
Gaëtan Rivet
6WIND
#19 lore raw

Re: [PATCH v2 4/5] app/testpmd: request link status interrupt

Quoted 20 lines · Gaëtan Rivet
Quoted 19 lines · Ferruh Yigit
Quoted 6 lines · Gaetan Rivet

For drivers supporting the LSC event, enable it.
This allows to test LSC event support.

Add the --no-lsc-interrupt parameter to explicitly disable the link status change interrupt.

Quoted 6 lines
---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 13 +++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+)

Hi Gaetan,

This patch adds new option to testpmd, can you please update testpmd documentation to document new option?

Quoted 7 lines
Quoted 2 lines

Same is valid for next patch (no-rmv-interrupt option)

Sure, I will send a patch for this.

Should I send a new version of my previous series or a single patch fixing the documentation for both options as a standalone?

Single patch to fix documentation will be do it.

Thanks,
ferruh

#20 lore raw

PATCH 1/3 doc: fix missing backquotes

Fixes ea85e7d711b6 ("ethdev: retrieve xstats by ID")
---
 doc/guides/rel_notes/release_17_05.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/guides/rel_notes/release_17_05.rst +1 -1
index ad20e86..eb5b30f 100644
@@ -454,7 +454,7 @@ API Changes
 
   * Changed set of input parameters for ``rte_eth_xstats_get`` and ``rte_eth_xstats_get_names`` functions.
 
-  * Added new functions ``rte_eth_xstats_get_all`` and ``rte_eth_xstats_get_names_all to provide backward compatibility for
+  * Added new functions ``rte_eth_xstats_get_all`` and ``rte_eth_xstats_get_names_all`` to provide backward compatibility for
     ``rte_eth_xstats_get`` and ``rte_eth_xstats_get_names``
 
   * Added new function ``rte_eth_xstats_get_id_by_name``
Signature · 1 line
2.1.4
#21 lore raw

PATCH 2/3 doc: add device removal event to release note

---
 doc/guides/rel_notes/release_17_05.rst | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_17_05.rst +5 -1
index eb5b30f..293d3fd 100644
@@ -298,6 +298,11 @@ New Features
 
   * DES DOCSIS BPI algorithm.
 
+* **Added Device Removal Interrupt.**
+
+  * Added a new ethdev event ``RTE_ETH_DEV_INTR_RMV`` to signify the sudden removal of a device. This
+    event can be advertized by PCI drivers and enabled accordingly.
+
 
 Resolved Issues
 ---------------
@@ -459,7 +464,6 @@ API Changes
 
   * Added new function ``rte_eth_xstats_get_id_by_name``
 
-
 ABI Changes
 -----------
 
Signature · 1 line
2.1.4
#22 lore raw

PATCH 3/3 doc: add lsc and rmv interrupt to testpmd user guide

In reply to Gaetan Rivet
---
 doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
doc/guides/testpmd_app_ug/run_app.rst +8 -0
index df5a0ee..a72c7e3 100644
@@ -465,3 +465,11 @@ The commandline options are:
 *   ``--disable-link-check``
 
     Disable check on link status when starting/stopping ports.
+
+*  ``--no-lsc-interrupt``
+
+   Disable LSC interrupts for all ports, even those supporting it.
+
+*  ``--no-rmv-interrupt``
+
+  Disable RMV interrupts for all ports, even those supporting it.
Signature · 1 line
2.1.4
#23 lore raw

PATCH v2 1/4 doc: fix missing backquotes

In reply to Gaetan Rivet
Fixes ea85e7d711b6 ("ethdev: retrieve xstats by ID")
---
 doc/guides/rel_notes/release_17_05.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/guides/rel_notes/release_17_05.rst +1 -1
index ad20e86..eb5b30f 100644
@@ -454,7 +454,7 @@ API Changes
 
   * Changed set of input parameters for ``rte_eth_xstats_get`` and ``rte_eth_xstats_get_names`` functions.
 
-  * Added new functions ``rte_eth_xstats_get_all`` and ``rte_eth_xstats_get_names_all to provide backward compatibility for
+  * Added new functions ``rte_eth_xstats_get_all`` and ``rte_eth_xstats_get_names_all`` to provide backward compatibility for
     ``rte_eth_xstats_get`` and ``rte_eth_xstats_get_names``
 
   * Added new function ``rte_eth_xstats_get_id_by_name``
Signature · 1 line
2.1.4
#24 lore raw

PATCH v2 2/4 doc: add device removal event to release note

---
 doc/guides/rel_notes/release_17_05.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_17_05.rst +5 -0
index eb5b30f..602ef8e 100644
@@ -298,6 +298,11 @@ New Features
 
   * DES DOCSIS BPI algorithm.
 
+* **Added Device Removal Interrupt.**
+
+  * Added a new ethdev event ``RTE_ETH_DEV_INTR_RMV`` to signify the sudden removal of a device. This
+    event can be advertized by PCI drivers and enabled accordingly.
+
 
 Resolved Issues
 ---------------
Signature · 1 line
2.1.4
Acked-by on v2 2/4
#25 lore raw

Re: [PATCH v2 2/4] doc: add device removal event to release note

Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Tuesday, April 25, 2017 11:18 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v2 2/4] doc: add device removal event to release note

#26 lore raw

PATCH v2 3/4 doc: add LSC and RMV interrupt to testpmd user guide

In reply to Gaetan Rivet
---
 doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
doc/guides/testpmd_app_ug/run_app.rst +8 -0
index df5a0ee..a72c7e3 100644
@@ -465,3 +465,11 @@ The commandline options are:
 *   ``--disable-link-check``
 
     Disable check on link status when starting/stopping ports.
+
+*  ``--no-lsc-interrupt``
+
+   Disable LSC interrupts for all ports, even those supporting it.
+
+*  ``--no-rmv-interrupt``
+
+  Disable RMV interrupts for all ports, even those supporting it.
Signature · 1 line
2.1.4
Acked-by on v2 3/4
#27 lore raw

Re: [PATCH v2 3/4] doc: add LSC and RMV interrupt to testpmd user guide

Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Tuesday, April 25, 2017 11:18 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v2 3/4] doc: add LSC and RMV interrupt to testpmd user guide

#28 lore raw

PATCH v2 4/4 devtools: add git log checks for rmv

In reply to Gaetan Rivet
---
 devtools/check-git-log.sh | 1 +
 1 file changed, 1 insertion(+)
devtools/check-git-log.sh +1 -0
index 8449d4f..f081ff5 100755
@@ -132,6 +132,7 @@ bad=$(echo "$headlines" | grep -E --color=always \
 	-e ':.*\<numa\>' \
 	-e ':.*\<pci\>' \
 	-e ':.*\<pmd\>' \
+	-e ':.*\<rmv\>' \
 	-e ':.*\<rss\>' \
 	-e ':.*\<tso\>' \
 	-e ':.*\<[Vv]lan\>' \
Signature · 1 line
2.1.4
#30 lore raw

Re: [PATCH v2 4/4] devtools: add git log checks for rmv

In reply to Gaetan Rivet

25/04/2017 12:18, Gaetan Rivet:

Quoted 10 lines
---
 devtools/check-git-log.sh | 1 +
 1 file changed, 1 insertion(+)
devtools/check-git-log.sh +0 -0
index 8449d4f..f081ff5 100755

devtools/check-git-log.sh bad=$(echo "$headlines" | grep -E --color=always \ · line 138

Quoted 7 lines
devtools/check-git-log.sh +1 -0
@@ -132,6 +132,7 @@ bad=$(echo "$headlines" | grep -E --color=always \
 	-e ':.*\<numa\>' \
 	-e ':.*\<pci\>' \
 	-e ':.*\<pmd\>' \
+	-e ':.*\<rmv\>' \
 	-e ':.*\<rss\>' \
 	-e ':.*\<tso\>' \
 	-e ':.*\<[Vv]lan\>' \

rmv is not an acronym. I think there is no need to enforce uppercases.

Acked-by on v2 1/4
#31 lore raw

Re: [PATCH v2 1/4] doc: fix missing backquotes

In reply to Gaetan Rivet
Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Tuesday, April 25, 2017 11:18 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes

Quoted 3 lines
Fixes ea85e7d711b6 ("ethdev: retrieve xstats by ID")

Thanks. Could you also make the V1 patches as "superseded" in patchwork.

#32 lore raw

Re: [PATCH v2 1/4] doc: fix missing backquotes

26/04/2017 16:58, Mcnamara, John:

Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Tuesday, April 25, 2017 11:18 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes

Quoted 7 lines
Quoted 3 lines
Fixes ea85e7d711b6 ("ethdev: retrieve xstats by ID")

Thanks. Could you also make the V1 patches as "superseded" in patchwork.

Series applied, except patch 4/4 which is superfluous.

#33 lore raw

PATCH v2 5/5 app/testpmd: request device removal interrupt

In reply to Gaetan Rivet

Enable device removal event for PMD supporting it. Add the --no-rmv-interrupt parameter to explicitly disable it.

---
 app/test-pmd/parameters.c |  4 ++++
 app/test-pmd/testpmd.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 48 insertions(+)
app/test-pmd/parameters.c +4 -0
index c79c349..7efd718 100644
@@ -201,6 +201,7 @@ usage(char* progname)
 	printf("  --disable-link-check: disable check on link status when "
 	       "starting/stopping ports.\n");
 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
+	printf("  --no-rmv-interrupt: disable device removal interrupt.");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -570,6 +571,7 @@ launch_args_parse(int argc, char** argv)
 		{ "txpkts",			1, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
 		{ "no-lsc-interrupt",		0, 0, 0 },
+		{ "no-rmv-interrupt",		0, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -1002,6 +1004,8 @@ launch_args_parse(int argc, char** argv)
 				no_link_check = 1;
 			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
 				lsc_interrupt = 0;
+			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
+				rmv_interrupt = 0;
 
 			break;
 		case 'h':
app/test-pmd/testpmd.c +43 -0

73 lines not on this page · raw message

app/test-pmd/testpmd.h +1 -0
index 62f89e6..a9ff07e 100644
@@ -306,6 +306,7 @@ extern uint8_t  mp_anon; /**< set by "--mp-anon" parameter */
 extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
+extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
 
 #ifdef RTE_NIC_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
Signature · 1 line
2.1.4
#34 lore raw
In reply to Gaetan Rivet

18/04/2017 14:17, Gaetan Rivet:

Quoted 35 lines

This new event represents the sudden removal of a device from its bus. The underlying resources exposed by the bus are expected not to be available anymore. The application should thus be able to react and possibly clean up related resources that it reserved for the removed device.

This event is different from the current hotplug API available in the DPDK for two reasons:

1. It is a reactive design: the application reacts to a device that has been removed instead of removing a device from its pool.

2. The event itself is going further than the current detaching of a device from a DPDK application. If the bus is a hardware one, it is expected of
the underlying resources to not be available anymore.

This series adds a new event type to ethdev and implements it in mlx4. Testpmd is also updated to report all asynchronous ethdev events including this one for testing purposes and as a practical usage example.

This series depends on the series titled
[PATCH 1/2] net/mlx4: split the definitions to the header file

v1 --> v2:
* integrated the series with the new PCI rte_bus implementation.

I planned on working out a more generic implementation of the RMV event
for the v17.05, however while writing it I found that I had to evolve the support of interrupts in the PCI rte_bus, which did not seem wise at this point of the release cycle.

I consider that this event should be generalized along the LSC event,
going from pure PCI events to generic rte_bus events, given that they can be relevant to other busses (vdev at least). I would reserve this evolution for future release however, once a real discussion has taken place.

Quoted 6 lines

Gaetan Rivet (5):
ethdev: introduce device removal event
net/mlx4: device removal event support
app/testpmd: generic event handler
app/testpmd: request link status interrupt
app/testpmd: request device removal interrupt

Applied, thanks