net/vdev_netvsc: Prevent alarm lost on failed device probe
PATCH 1/1 net/vdev_netvsc: Prevent alarm lost on failed device probe
From: Long Li <[email protected]>
If a device probe fails, the alarm is canceled and will no longer work for previously probed devices.
Fix this by introducing a flag to track if alarm has been set. Because it's possible that an alarm is triggered while probing is in progress that may modify vdev_netvsc_ctx_list, introduce a lock to protect it.
--- drivers/net/vdev_netvsc/vdev_netvsc.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-)
drivers/net/vdev_netvsc/vdev_netvsc.c +30 -11
@@ -76,6 +76,11 @@ struct vdev_netvsc_ctx {/** Context list is common to all driver instances. */ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =LIST_HEAD_INITIALIZER (vdev_netvsc_ctx_list); +/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ +static rte_rwlock_t vdev_netvsc_ctx_list_lock; + +/* Flag to track if alarm has been set */ +static int vdev_netvsc_alarm_set;/** Number of entries in context list. */ static unsigned int vdev_netvsc_ctx_count;
@@ -454,19 +459,26 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =struct vdev_netvsc_ctx *ctx;int ret; +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock); LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { ret =vdev_netvsc_foreach_iface (vdev_netvsc_device_probe,0 , ctx);if (ret <0 )break ; } -if (!vdev_netvsc_ctx_count) +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + +if (!vdev_netvsc_ctx_count) { + vdev_netvsc_alarm_set =0 ;return ; + } + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL );if (ret <0 ) {DRV_LOG (ERR ,"unable to reschedule alarm callback: %s" ,rte_strerror (-ret)); + vdev_netvsc_alarm_set =0 ; } }
@@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = " device."); goto error; } -rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); + +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock);/* Gather interfaces. */ ret =vdev_netvsc_foreach_iface (vdev_netvsc_netvsc_probe,1 , name, kvargs, specified, &matched);if (ret <0 ) - goto error; + goto error_unlock;if (specified && matched < specified) {if (!force) {DRV_LOG (ERR ,"Cannot find the specified netvsc device" ); - goto error; + goto error_unlock; }/* Try to force probing on non-netvsc specified device. */ if (vdev_netvsc_foreach_iface (vdev_netvsc_netvsc_probe,0 , name, kvargs, specified, &matched) <0 ) - goto error; + goto error_unlock;if (matched < specified) {DRV_LOG (ERR ,"Cannot find the specified device" ); - goto error; + goto error_unlock; }DRV_LOG (WARNING ,"non-netvsc device was probed as netvsc" ); } - ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , +if (!vdev_netvsc_alarm_set) { + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL ); -if (ret <0 ) { -DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , -rte_strerror (-ret)); - goto error; +if (ret <0 ) +DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , +rte_strerror (-ret)); +else + vdev_netvsc_alarm_set =1 ; } + +error_unlock: +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + error:if (kvargs)rte_kvargs_free (kvargs);
Signature · 1 line
1.8.3.1
From: Long Li
Quoted 103 lines
If a device probe fails, the alarm is canceled and will no longer work for previously probed devices.
Fix this by introducing a flag to track if alarm has been set. Because it's possible that an alarm is triggered while probing is in progress that may modify
vdev_netvsc_ctx_list, introduce a lock to protect it.Signed-off-by Long Li <[email protected]>--- drivers/net/vdev_netvsc/vdev_netvsc.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-)drivers/net/vdev_netvsc/vdev_netvsc.c +0
-0@@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { /** Context list is common to all driver instances. */ static LIST_HEAD(,
vdev_netvsc_ctx)vdev_netvsc_ctx_list=LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list);drivers/net/vdev_netvsc/vdev_netvsc.c +5
-0+/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ +static rte_rwlock_t vdev_netvsc_ctx_list_lock; + +/* Flag to track if alarm has been set */ static int +vdev_netvsc_alarm_set; /** Number of entries in context list. */ static unsigned int
vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ staticLIST_HEAD(, vdev_netvsc_ctx)vdev_netvsc_ctx_list=struct vdev_netvsc_ctx *ctx; int ret;drivers/net/vdev_netvsc/vdev_netvsc.c +8
-1+rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock); LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { ret =vdev_netvsc_foreach_iface (vdev_netvsc_device_probe,0 , ctx);if (ret <0 )break ; } -if (!vdev_netvsc_ctx_count) +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + +if (!vdev_netvsc_ctx_count) { + vdev_netvsc_alarm_set =0 ;return ; + } + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL );if (ret <0 ) {DRV_LOG (ERR ,"unable to reschedule alarm callback: %s" ,rte_strerror (-ret)); + vdev_netvsc_alarm_set =0 ; } }@@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx)
vdev_netvsc_ctx_list=" device."); goto error; }drivers/net/vdev_netvsc/vdev_netvsc.c +12
-10-rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); + +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock);/* Gather interfaces. */ ret =vdev_netvsc_foreach_iface (vdev_netvsc_netvsc_probe,1 , name, kvargs, specified, &matched);if (ret <0 ) - goto error; + goto error_unlock;if (specified && matched < specified) {if (!force) {DRV_LOG (ERR ,"Cannot find the specified netvsc device" ); - goto error; + goto error_unlock; }/* Try to force probing on non-netvsc specified device. */ if (vdev_netvsc_foreach_iface (vdev_netvsc_netvsc_probe,0 , name, kvargs, specified, &matched) <0 ) - goto error; + goto error_unlock;if (matched < specified) {DRV_LOG (ERR ,"Cannot find the specified device" ); - goto error; + goto error_unlock; }DRV_LOG (WARNING ,"non-netvsc device was probed as netvsc" ); } - ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , +if (!vdev_netvsc_alarm_set) { + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL ); -if (ret <0 ) { -DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , -rte_strerror (-ret)); - goto error; +if (ret <0 ) +DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , +rte_strerror (-ret)); +else
drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 10 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +5
-1+ vdev_netvsc_alarm_set =1 ; } + +error_unlock: +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + error:if (kvargs)rte_kvargs_free (kvargs); --
Hi
Nice direction.
As I understand from your patch it looks like you want to add support for the vdev_netvsc driver itself to be hot-plug aware - so it can be probed\removed in run-time (even after EAL initialization). So I think the title and commit log should be converted to this: net/vdev_netvsc: support driver instance hot-plug
...
More things:
Look on convention of the file - blank line only after variables declarations inside the blocks.
Need to adjust also vdev_netvsc_vdev_remove to the feature.
Matan
Quoted 125 lines
Subject: RE: [PATCH]
net/vdev_netvsc: Prevent alarm lost on failed device probeFrom: Long Li
Quoted 65 lines
If a device probe fails, the alarm is canceled and will no longer work for previously probed devices.
Fix this by introducing a flag to track if alarm has been set. Because it's possible that an alarm is triggered while probing is in progress that may modify
vdev_netvsc_ctx_list, introduce a lock to protect it.Signed-off-by Long Li <[email protected]>--- drivers/net/vdev_netvsc/vdev_netvsc.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-)drivers/net/vdev_netvsc/vdev_netvsc.c +0
-0@@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { /** Context list is common to all driver instances. */ static LIST_HEAD(,
vdev_netvsc_ctx)vdev_netvsc_ctx_list=LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list);drivers/net/vdev_netvsc/vdev_netvsc.c +5
-0+/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ +static rte_rwlock_t vdev_netvsc_ctx_list_lock; + +/* Flag to track if alarm has been set */ static int +vdev_netvsc_alarm_set; /** Number of entries in context list. */ static unsigned int
vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ staticLIST_HEAD(, vdev_netvsc_ctx)vdev_netvsc_ctx_list=struct vdev_netvsc_ctx *ctx; int ret;drivers/net/vdev_netvsc/vdev_netvsc.c +8
-1+rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock); LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { ret =vdev_netvsc_foreach_iface (vdev_netvsc_device_probe,0 , ctx);if (ret <0 )break ; } -if (!vdev_netvsc_ctx_count) +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + +if (!vdev_netvsc_ctx_count) { + vdev_netvsc_alarm_set =0 ;return ; + } + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL );if (ret <0 ) {DRV_LOG (ERR ,"unable to reschedule alarm callback: %s" ,rte_strerror (-ret)); + vdev_netvsc_alarm_set =0 ; } }@@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx)
vdev_netvsc_ctx_list=" device."); goto error; }drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 5 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +2
-1-rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); + +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock);/* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 1,name,
drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 12 lines
kvargs, specified, &matched); if (ret < 0)drivers/net/vdev_netvsc/vdev_netvsc.c +2
-2- goto error; + goto error_unlock;if (specified && matched < specified) {if (!force) {DRV_LOG (ERR ,"Cannot find the specified netvsc device" ); - goto error; + goto error_unlock; }/* Try to force probing on non-netvsc specified device. */ if (vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 0,name,
Quoted 22 lines
kvargs, specified, &matched) < 0)
drivers/net/vdev_netvsc/vdev_netvsc.c +8
-7- goto error; + goto error_unlock;if (matched < specified) {DRV_LOG (ERR ,"Cannot find the specified device" ); - goto error; + goto error_unlock; }DRV_LOG (WARNING ,"non-netvsc device was probed as netvsc" ); } - ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , +if (!vdev_netvsc_alarm_set) { + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL ); -if (ret <0 ) { -DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , -rte_strerror (-ret)); - goto error; +if (ret <0 ) +DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , +rte_strerror (-ret)); +else drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 10 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +5
-1+ vdev_netvsc_alarm_set =1 ; } + +error_unlock: +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + error:if (kvargs)rte_kvargs_free (kvargs); --Hi
Quoted 7 lines
Nice direction.
As I understand from your patch it looks like you want to add support for the
vdev_netvscdriver itself to be hot-plug aware - so it can be probed\removed in run-time (even after EAL initialization).
So I think the title and commit log should be converted to this:net/vdev_netvsc: support driver instance hot-plug ...
Hi Matan,
Actually I was not trying to add support for hot-plug (although it made half way there).
The problem I'm trying to solve is on a system with multiple vdev_netvsc interfaces. For example, if the system has eth1, eth2 .. eth10. What if the probing on eth1 to eth9 succeed, but on eth10 fails? Current behavior is that we can still have DPDK run on eth1 to eth9, but without any alarms. Because the alarm is canceled while trying to probing eth10. Then once eth1 to eth9 lost VF, they won't get VF back because we don't have any alarms.
Long
Quoted 8 lines
More things:
Look on convention of the file - blank line only after variables declarations inside the blocks.Need to adjust also
vdev_netvsc_vdev_removeto the feature.Matan
From: Long Li
Quoted 141 lines
Quoted 5 lines
Subject: RE: [PATCH]
net/vdev_netvsc: Prevent alarm lost on failed device probeQuoted 7 lines
From: Long Li
Quoted 6 lines
If a device probe fails, the alarm is canceled and will no longer work for previously probed devices.
Fix this by introducing a flag to track if alarm has been set. Because it's possible that an alarm is triggered while probing is in progress that may modify
vdev_netvsc_ctx_list, introduce a lock toprotect it.
Quoted 78 lines
Quoted 59 lines
Signed-off-by Long Li <[email protected]>--- drivers/net/vdev_netvsc/vdev_netvsc.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-)drivers/net/vdev_netvsc/vdev_netvsc.c +0
-0@@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { /** Context list is common to all driver instances. */ static LIST_HEAD(,
vdev_netvsc_ctx)vdev_netvsc_ctx_list=LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list);drivers/net/vdev_netvsc/vdev_netvsc.c +5
-0+/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ +static rte_rwlock_t vdev_netvsc_ctx_list_lock; + +/* Flag to track if alarm has been set */ static int +vdev_netvsc_alarm_set; /** Number of entries in context list. */ static unsigned int
vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ staticLIST_HEAD(, vdev_netvsc_ctx)vdev_netvsc_ctx_list=struct vdev_netvsc_ctx *ctx; int ret;drivers/net/vdev_netvsc/vdev_netvsc.c +8
-1+rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock); LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { ret =vdev_netvsc_foreach_iface (vdev_netvsc_device_probe,0 , ctx);if (ret <0 )break ; } -if (!vdev_netvsc_ctx_count) +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + +if (!vdev_netvsc_ctx_count) { + vdev_netvsc_alarm_set =0 ;return ; + } + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL );if (ret <0 ) {DRV_LOG (ERR ,"unable to reschedule alarm callback: %s" ,rte_strerror (-ret)); + vdev_netvsc_alarm_set =0 ; } }@@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx)
vdev_netvsc_ctx_list=" device."); goto error; }drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 5 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +2
-1-rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); + +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock);/* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 1,name,
Quoted 12 lines
kvargs, specified, &matched); if (ret < 0)drivers/net/vdev_netvsc/vdev_netvsc.c +2
-2- goto error; + goto error_unlock;if (specified && matched < specified) {if (!force) {DRV_LOG (ERR ,"Cannot find the specified netvsc device" ); - goto error; + goto error_unlock; }/* Try to force probing on non-netvsc specified device. */ ifQuoted 1 line
(vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 0,
Quoted 10 lines
name,
Quoted 9 lines
kvargs, specified, &matched) < 0)
drivers/net/vdev_netvsc/vdev_netvsc.c +2
-2- goto error; + goto error_unlock;if (matched < specified) {DRV_LOG (ERR ,"Cannot find the specified device" ); - goto error; + goto error_unlock; } DRV_LOG(WARNING, "non-netvsc device was probed asnetvsc");
Quoted 26 lines
Quoted 13 lines
}drivers/net/vdev_netvsc/vdev_netvsc.c +6
-5- ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , +if (!vdev_netvsc_alarm_set) { + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL ); -if (ret <0 ) { -DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , -rte_strerror (-ret)); - goto error; +if (ret <0 ) +DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , +rte_strerror (-ret)); +else drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 10 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +5
-1+ vdev_netvsc_alarm_set =1 ; } + +error_unlock: +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + error:if (kvargs)rte_kvargs_free (kvargs); --Hi
Quoted 7 lines
Nice direction.
As I understand from your patch it looks like you want to add support for the
vdev_netvscdriver itself to be hot-plug aware - so it can be probed\removed in run-time (even after EAL initialization). So I think the title and commit log should be converted to this:net/vdev_netvsc: support driver instance hot-plug ...Hi Matan,
Actually I was not trying to add support for hot-plug (although it made half way there).
Quoted 8 lines
The problem I'm trying to solve is on a system with multiple
vdev_netvscinterfaces. For example, if the system has eth1, eth2 .. eth10. What if the probing on eth1 to eth9 succeed, but on eth10 fails? Current behavior is that we can still have DPDK run on eth1 to eth9, but without any alarms. Because the alarm is canceled while trying to probing eth10. Then once eth1 to eth9 lost VF, they won't get VF back because we don't have any alarms.Long
Ok, got you.
So, why to manage critical sections in the code, better, to stop alarm before adding a new device, and apply it back if the list of devices is not empty. It will make it simpler, no?
Quoted 8 lines
Quoted 8 lines
More things:
Look on convention of the file - blank line only after variables declarations inside the blocks.Need to adjust also
vdev_netvsc_vdev_removeto the feature.Matan
Quoted 159 lines
Subject: RE: [PATCH]
net/vdev_netvsc: Prevent alarm lost on failed device probeFrom: Long Li
Quoted 44 lines
Quoted 5 lines
Subject: RE: [PATCH]
net/vdev_netvsc: Prevent alarm lost on failed device probeQuoted 8 lines
From: Long Li
Quoted 7 lines
If a device probe fails, the alarm is canceled and will no longer work for previously probed devices.
Fix this by introducing a flag to track if alarm has been set. Because it's possible that an alarm is triggered while probing is in progress that may modify
vdev_netvsc_ctx_list, introduce a lock toprotect it.
Quoted 30 lines
Quoted 30 lines
Signed-off-by Long Li <[email protected]>--- drivers/net/vdev_netvsc/vdev_netvsc.c | 41 +++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-)drivers/net/vdev_netvsc/vdev_netvsc.c +0
-0@@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { /** Context list is common to all driver instances. */ static LIST_HEAD(,
vdev_netvsc_ctx)vdev_netvsc_ctx_list=LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list);drivers/net/vdev_netvsc/vdev_netvsc.c +5
-0+/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ +static rte_rwlock_t vdev_netvsc_ctx_list_lock; + +/* Flag to track if alarm has been set */ static int +vdev_netvsc_alarm_set; /** Number of entries in context list. */ static unsigned int
vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ staticLIST_HEAD(, vdev_netvsc_ctx)vdev_netvsc_ctx_list=struct vdev_netvsc_ctx *ctx; int ret;Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
+
rte_rwlock_write_lock(&vdev_netvsc_ctx_list_lock);
LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry){
ret = vdev_netvsc_foreach_iface(vdev_netvsc_device_probe,0,
Quoted 97 lines
Quoted 46 lines
Quoted 31 lines
ctx); if (ret < 0) break; }drivers/net/vdev_netvsc/vdev_netvsc.c +7
-1-if (!vdev_netvsc_ctx_count) +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + +if (!vdev_netvsc_ctx_count) { + vdev_netvsc_alarm_set =0 ;return ; + } + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , vdev_netvsc_alarm,NULL );if (ret <0 ) {DRV_LOG (ERR ,"unable to reschedule alarm callback: %s" ,rte_strerror (-ret)); + vdev_netvsc_alarm_set =0 ; } }@@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx)
vdev_netvsc_ctx_list=" device."); goto error; }drivers/net/vdev_netvsc/vdev_netvsc.c +2
-1-rte_eal_alarm_cancel (vdev_netvsc_alarm,NULL ); + +rte_rwlock_write_lock (&vdev_netvsc_ctx_list_lock);/* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe,Quoted 1 line
1,
name,
Quoted 12 lines
kvargs, specified, &matched); if (ret < 0)drivers/net/vdev_netvsc/vdev_netvsc.c +2
-2- goto error; + goto error_unlock;if (specified && matched < specified) {if (!force) {DRV_LOG (ERR ,"Cannot find the specified netvsc device" ); - goto error; + goto error_unlock; }/* Try to force probing on non-netvsc specified device. */ ifQuoted 1 line
(vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 0,
Quoted 10 lines
name,
Quoted 9 lines
kvargs, specified, &matched) < 0)
drivers/net/vdev_netvsc/vdev_netvsc.c +2
-2- goto error; + goto error_unlock;if (matched < specified) {DRV_LOG (ERR ,"Cannot find the specified device" ); - goto error; + goto error_unlock; } DRV_LOG(WARNING, "non-netvsc device was probed asnetvsc");
Quoted 27 lines
Quoted 14 lines
}drivers/net/vdev_netvsc/vdev_netvsc.c +7
-5- ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS *1000 , +if (!vdev_netvsc_alarm_set) { + ret =rte_eal_alarm_set (VDEV_NETVSC_PROBE_MS * +1000 , vdev_netvsc_alarm,NULL ); -if (ret <0 ) { -DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , -rte_strerror (-ret)); - goto error; +if (ret <0 ) +DRV_LOG (ERR ,"unable to schedule alarm callback: %s" , +rte_strerror (-ret)); +else drivers/net/vdev_netvsc/vdev_netvsc.c static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
Quoted 10 lines
drivers/net/vdev_netvsc/vdev_netvsc.c +5
-1+ vdev_netvsc_alarm_set =1 ; } + +error_unlock: +rte_rwlock_write_unlock (&vdev_netvsc_ctx_list_lock); + error:if (kvargs)rte_kvargs_free (kvargs); --Hi
Quoted 7 lines
Nice direction.
As I understand from your patch it looks like you want to add support for the
vdev_netvscdriver itself to be hot-plug aware - so it can be probed\removed in run-time (even after EAL initialization). So I think the title and commit log should be converted to this:net/vdev_netvsc: support driver instance hot-plug ...Hi Matan,
Actually I was not trying to add support for hot-plug (although it made half way there).
Quoted 6 lines
The problem I'm trying to solve is on a system with multiple
vdev_netvscinterfaces. For example, if the system has eth1, eth2 .. eth10. What if the probing on eth1 to eth9 succeed, but on eth10 fails? Current behavior is that we can still have DPDK run on eth1 to eth9, but without any alarms. Because the alarm is canceled while trying to probing eth10. Then once eth1 to eth9 lost VF, they won't get VFback because we don't have any alarms.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Long
Ok, got you.
So, why to manage critical sections in the code, better, to stop alarm before adding a new device, and apply it back if the list of devices is not empty. It will make it simpler, no?
Okay, I will send v2 based on your suggestion. Thanks.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
More things:
Look on convention of the file - blank line only after variables declarations inside the blocks.Need to adjust also
vdev_netvsc_vdev_removeto the feature.Matan