Auto enable hotplug with netvsc devices
cover Auto enable hotplug with netvsc devices
In Azure, hotplug is a requirement for a working application. Yet most applications don't enable it because DPDK hotplug support is opt-in.
There are three options:
1. Blame the application (this seems to be the DPDK default)
2. Fix the design mistake (too risky at this time)
3. Automatically enable hotplug if necessary (that is what this patchset does).
Stephen Hemminger (3):
eal/hotplug: allow monitor to be setup by multiple places net/vdev_netvsc: automatically enable hotplug support net/netvsc: automatically enable hotplug support
drivers/net/netvsc/hn_ethdev.c | 5 ++++- drivers/net/vdev_netvsc/vdev_netvsc.c | 4 ++++ lib/librte_eal/linux/eal_dev.c | 15 +++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
RFC 1/3 eal/hotplug: allow monitor to be setup by multiple places
In some cases, a device or infrastructure may want to enable hotplug but application may also try and start hotplug as well. Therefore change the monitor_started from a boolean into a reference count.
--- lib/librte_eal/linux/eal_dev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
lib/librte_eal/linux/eal_dev.c +7 -8
@@ -23,8 +23,11 @@#include "eal_private.h" -static struct rte_intr_handle intr_handle = {.fd =-1 }; -static bool monitor_started; +static struct rte_intr_handle intr_handle = { + .type =RTE_INTR_HANDLE_DEV_EVENT , + .fd =-1 , +}; +static uint32_t monitor_refcount;static bool hotplug_handle;#define EAL_UEV_MSG_LEN 4096
@@ -290,7 +293,7 @@ rte_dev_event_monitor_start(void) {int ret; -if (monitor_started) +if (__atomic_fetch_add (&monitor_refcount,1 , __ATOMIC_RELAXED))return 0 ; ret =dev_uev_socket_fd_create ();
@@ -299,7 +302,6 @@ rte_dev_event_monitor_start(void)return -1 ; } - intr_handle.type =RTE_INTR_HANDLE_DEV_EVENT ; ret =rte_intr_callback_register (&intr_handle, dev_uev_handler,NULL );if (ret) {
@@ -307,8 +309,6 @@ rte_dev_event_monitor_start(void)return -1 ; } - monitor_started = true; -return 0 ; }
@@ -317,7 +317,7 @@ rte_dev_event_monitor_stop(void) {int ret; -if (!monitor_started) +if (__atomic_sub_fetch (&monitor_refcount,1 , __ATOMIC_RELAXED))return 0 ; ret = rte_intr_callback_unregister(&intr_handle, dev_uev_handler,
@@ -329,7 +329,6 @@ rte_dev_event_monitor_stop(void)close (intr_handle.fd); intr_handle.fd =-1 ; - monitor_started = false;return 0 ; }
Signature · 1 line
2.20.1
RFC 2/3 net/vdev_netvsc: automatically enable hotplug support
In reply to Stephen HemmingerIn Hyper-V/Azure with accelerated networking the VF device maybe added or removed at anytime. Automatically enable hotplug support (in case application has forgot to).
--- drivers/net/vdev_netvsc/vdev_netvsc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/vdev_netvsc/vdev_netvsc.c +4 -0
@@ -729,6 +729,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)if (kvargs)rte_kvargs_free (kvargs); ++vdev_netvsc_ctx_inst; +rte_dev_event_monitor_start ();return 0 ; }
@@ -749,7 +750,10 @@ vdev_netvsc_vdev_remove(__rte_unused struct rte_vdev_device *dev) {if (--vdev_netvsc_ctx_inst)return 0 ; +rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); +rte_dev_event_monitor_stop (); +while (!LIST_EMPTY (&vdev_netvsc_ctx_list)) {struct vdev_netvsc_ctx *ctx =LIST_FIRST (&vdev_netvsc_ctx_list);
Signature · 1 line
2.20.1
RFC 3/3 net/netvsc: automatically enable hotplug support
In reply to Stephen HemmingerIn Hyper-V/Azure with accelerated networking the VF device maybe added or removed at anytime. Automatically enable hotplug support (in case application has forgot to).
--- drivers/net/netvsc/hn_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/netvsc/hn_ethdev.c +4 -1
@@ -1074,8 +1074,10 @@ static int eth_hn_probe(struct rte_vmbus_driver *drv __rte_unused, ret =eth_hn_dev_init (eth_dev);if (ret)eth_dev_vmbus_release (eth_dev); -else +else {rte_eth_dev_probing_finish (eth_dev); +rte_dev_event_monitor_stop (); + }return ret; }
@@ -1096,6 +1098,7 @@ static int eth_hn_remove(struct rte_vmbus_device *dev)return ret;eth_dev_vmbus_release (eth_dev); +rte_dev_event_monitor_stop ();return 0 ; }
Signature · 1 line
2.20.1