bus/ifpga: add fpga bus cleanup
PATCH 1/1 bus/ifpga: add fpga bus cleanup
In this patch, cleanup method is implemented for FPGA bus which will be called during eal_bus_cleanup().
--- drivers/bus/ifpga/ifpga_bus.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/bus/ifpga/ifpga_bus.c +36 -0
@@ -360,6 +360,41 @@ struct rte_afu_device *return ret; } +/* +* Cleanup the content of the Intel FPGA bus, and call the remove() function +* for all registered devices. +*/ +static int +ifpga_cleanup (void ) +{ +struct rte_afu_device *afu_dev, *tmp_dev; +int error =0 ; + + RTE_TAILQ_FOREACH_SAFE(afu_dev, &ifpga_afu_dev_list, next, tmp_dev) { +struct rte_afu_driver *drv = afu_dev->driver; +int ret =0 ; + +if (drv ==NULL || drv->remove ==NULL ) + goto free; + + ret = drv->remove (afu_dev); +if (ret <0 ) { + rte_errno = errno; + error =-1 ; + } + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + +free: +TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); +rte_devargs_remove (afu_dev->device.devargs); +rte_intr_instance_free (afu_dev->intr_handle); +free (afu_dev); + } + +return error; +} +static int ifpga_plug (struct rte_device *dev) {
@@ -470,6 +505,7 @@ struct rte_afu_device *static struct rte_bus rte_ifpga_bus = { .scan = ifpga_scan, .probe = ifpga_probe, + .cleanup = ifpga_cleanup, .find_device = ifpga_find_device, .plug = ifpga_plug, .unplug = ifpga_unplug,
Signature · 1 line
1.8.3.1
Hi,
Quoted 75 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Friday, March 17, 2023 4:45 AM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Zhang, Qi Z <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH v1] bus/ifpga: add fpga bus cleanupIn this patch, cleanup method is implemented for FPGA bus which will be called during
eal_bus_cleanup().Signed-off-by Wei Huang <[email protected]>--- drivers/bus/ifpga/ifpga_bus.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)drivers/bus/ifpga/ifpga_bus.c +37
-1@@ -360,6 +360,41 @@ struct rte_afu_device *return ret; } +/* +* Cleanup the content of the Intel FPGA bus, and call the remove() +function +* for all registered devices. +*/ +static int +ifpga_cleanup (void ) +{ +struct rte_afu_device *afu_dev, *tmp_dev; +int error =0 ; + +RTE_TAILQ_FOREACH_SAFE (afu_dev, &ifpga_afu_dev_list, next, tmp_dev) { +struct rte_afu_driver *drv = afu_dev->driver; +int ret =0 ; + +if (drv ==NULL || drv->remove ==NULL ) + goto free; + + ret = drv->remove (afu_dev); +if (ret <0 ) { + rte_errno = errno; + error =-1 ; + } + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + +free: +TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); +rte_devargs_remove (afu_dev->device.devargs); +rte_intr_instance_free (afu_dev->intr_handle); +free (afu_dev); + } + +return error; +} +static int ifpga_plug (struct rte_device *dev) {@@ -470,6 +505,7 @@ struct rte_afu_device * static struct rte_bus rte_ifpga_bus = { .scan = ifpga_scan, .probe = ifpga_probe, + .cleanup = ifpga_cleanup, .find_device = ifpga_find_device, .plug = ifpga_plug, .unplug = ifpga_unplug, --
Quoted 1 line
1.8.3.1
Quoted 6 lines
Quoted 4 lines
In this patch, cleanup method is implemented for FPGA bus which will be called during
eal_bus_cleanup().Signed-off-by Wei Huang <[email protected]>Acked-by Rosen Xu <[email protected]>
It looks to be simple enough to go in -rc3.
Applied, thanks.
Quoted 75 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Friday, March 17, 2023 4:45 AM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Zhang, Qi Z <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH v1] bus/ifpga: add fpga bus cleanupIn this patch, cleanup method is implemented for FPGA bus which will be called during
eal_bus_cleanup().Signed-off-by Wei Huang <[email protected]>--- drivers/bus/ifpga/ifpga_bus.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)drivers/bus/ifpga/ifpga_bus.c index renamed from drivers/bus/ifpga/ifpga_bus.c +0
-007e316b..ffb0c61 100644
drivers/bus/ifpga/ifpga_bus.c +37
-1@@ -360,6 +360,41 @@ struct rte_afu_device *return ret; } +/* +* Cleanup the content of the Intel FPGA bus, and call the remove() +function +* for all registered devices. +*/ +static int +ifpga_cleanup (void ) +{ +struct rte_afu_device *afu_dev, *tmp_dev; +int error =0 ; + + RTE_TAILQ_FOREACH_SAFE(afu_dev, &ifpga_afu_dev_list, next, tmp_dev) { +struct rte_afu_driver *drv = afu_dev->driver; +int ret =0 ; + +if (drv ==NULL || drv->remove ==NULL ) + goto free; + + ret = drv->remove (afu_dev); +if (ret <0 ) { + rte_errno = errno; + error =-1 ; + } + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + +free: +TAILQ_REMOVE (&ifpga_afu_dev_list, afu_dev, next); +rte_devargs_remove (afu_dev->device.devargs); +rte_intr_instance_free (afu_dev->intr_handle); +free (afu_dev); + } + +return error; +} +static int ifpga_plug (struct rte_device *dev) {@@ -470,6 +505,7 @@ struct rte_afu_device * static struct rte_bus rte_ifpga_bus = { .scan = ifpga_scan, .probe = ifpga_probe, + .cleanup = ifpga_cleanup, .find_device = ifpga_find_device, .plug = ifpga_plug, .unplug = ifpga_unplug, --
Quoted 1 line
1.8.3.1
This patch is based on EAL cleanup devices for shutdown.
https://github.com/DPDK/dpdk/commit/1cab1a40ea9b858821aaf4655486e31ca1b52456
It looks good for me,