net/dpaa2: fix duplicate calling of dpaa2 dev close
PATCH 1/3 net/dpaa2: fix duplicate calling of dpaa2 dev close
When rte_eth_dev_close() is called, it performs the following actions:
Calls dev->dev_ops->dev_close(), which in this case is dpaa2_dev_close(). Then calls rte_eth_dev_release_port(), which releases all device data and sets dev->data to NULL.
Later, when rte_dev_remove() is called, the FSLMC bus invokes dev->remove() — that is, rte_dpaa2_remove().
However, rte_dpaa2_remove() calls dpaa2_dev_close() again. Since dev->data was already set to NULL by the previous call, this second invocation causes a crash.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +6 -3
@@ -3347,14 +3347,17 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); +if (eth_dev->data) { + ret =dpaa2_dev_close (eth_dev); +if (!ret) + ret =rte_eth_dev_release_port (eth_dev); + } dpaa2_valid_dev--;if (!dpaa2_valid_dev)rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev);return ret; }
Signature · 1 line
2.25.1
PATCH 2/3 net/dpaa2: clear active VDQ state when freeing Rx queues
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Each queue_storage_info_t also stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_id
Before issuing a new pull command, dpaa2_dev_prefetch_rx() checks for an active entry and spins on qbman_check_command_complete() until the corresponding VDQCR completes.
On port close / hotplug remove, dpaa2_free_rx_tx_queues() frees all per-lcore queue_storage_info_t structures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb, dq->dq.tok stays 0 and dpaa2_dev_prefetch_rx() loops in:
while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;
Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if qs->active_dqs is non-NULL, call clear_swp_active_dqs(qs->active_dpio_id) and set qs->active_dqs to NULL. Then dpaa2_queue_storage_free() can safely free q_storage and dq_storage[].
After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:
grcli interface add port dpni.1 devargs fslmc:dpni.1
grcli interface del dpni.1
grcli interface add port dpni.1 devargs fslmc:dpni.1
-> Rx was stuck in qbman_check_command_complete(), now works. - testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normall
--- .mailmap | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
.mailmap +1 -0
@@ -1036,6 +1036,7 @@ Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
drivers/net/dpaa2/dpaa2_ethdev.c +19 -0
@@ -631,6 +631,24 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; + +if (!qs) +continue ; + +if (qs->active_dqs) { +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +static void dpaa2_free_rx_tx_queues (struct rte_eth_dev *dev) {
@@ -645,6 +663,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)/* cleaning up queue storage */ for (i =0 ; i < priv->nb_rx_queues; i++) { dpaa2_q = priv->rx_vq[i]; +dpaa2_clear_queue_active_dps (dpaa2_q,RTE_MAX_LCORE );dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); }
Signature · 1 line
2.25.1
Re: [PATCH 2/3] net/dpaa2: clear active VDQ state when freeing Rx queues
Quoted 8 lines · On Thu, 6 Nov 2025 22:08:06 +0530 Hemant Agrawal <[email protected]>…
drivers/net/dpaa2/dpaa2_ethdev.c +8
-0+static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; +
drivers/net/dpaa2/dpaa2_ethdev.c dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) · line 651
Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +10
-0+if (!qs) +continue ; + +if (qs->active_dqs) { +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +
Why not use RTE_LCORE_FOREACH() here?
Re: [PATCH 2/3] net/dpaa2: clear active VDQ state when freeing Rx queues
Quoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Thu, 6 Nov 2025 22:08:06 +0530 Hemant Agrawal <[email protected]>…
drivers/net/dpaa2/dpaa2_ethdev.c +12
-0+static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; + +if (!qs) +continue ; + +if (qs->active_dqs) {
Quoted 9 lines
drivers/net/dpaa2/dpaa2_ethdev.c dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) · line 651
Quoted 6 lines
drivers/net/dpaa2/dpaa2_ethdev.c +6
-0+clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +Why not use
RTE_LCORE_FOREACH()here?
For the loop, I did it the same way as in dpaa2_queue_storage_alloc(), to stay aligned with the rest of the driver instead of using RTE_LCORE_FOREACH().
Thanks Hemant for upstreaming my patch. However, you added my email in .mailmap as a new entry — it should instead be added as a second email under the existing Maxime Leroy entry.
Quoted 1 line
RE: [PATCH 2/3] net/dpaa2: clear active VDQ state when freeing Rx queues
Le jeu. 6 nov. 2025, 20:29, Stephen Hemminger <[email protected]<mailto:[email protected]>> a écrit :
Quoted 8 lines · On Thu, 6 Nov 2025 22:08:06 +0530 Hemant Agrawal…
drivers/net/dpaa2/dpaa2_ethdev.c +8
-0+static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; +
drivers/net/dpaa2/dpaa2_ethdev.c dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) · line 651
Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +10
-0+if (!qs) +continue ; + +if (qs->active_dqs) { +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +
Why not use RTE_LCORE_FOREACH() here?
For the loop, I did it the same way as in dpaa2_queue_storage_alloc(), to stay aligned with the rest of the driver instead of using RTE_LCORE_FOREACH().
Thanks Hemant for upstreaming my patch. However, you added my email in .mailmap as a new entry — it should instead be added as a second email under the existing Maxime Leroy entry. [Hemant]
Will send v2
Re: [PATCH 2/3] net/dpaa2: clear active VDQ state when freeing Rx queues
In reply to Hemant Agrawal.mailmap Mauro Annarumma <[email protected]> · line 1039
Quoted 9 lines · Hemant Agrawal
.mailmap +1
-0@@ -1036,6 +1036,7 @@ Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]>
On a single line please:
Maxime Leroy <[email protected]> <[email protected]>
Quoted 3 lines
.mailmap +0
-0Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
Signature · 1 line
David Marchand
PATCH 3/3 bus/fslmc: add support for hotplug of dpni
In reply to Hemant AgrawalThis patch implements the plug and unplug function to support attach/detach of dpni interfaces.
--- drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +50 -6
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void) }static int -fslmc_bus_plug(struct rte_device *dev __rte_unused) +fslmc_bus_plug (struct rte_device *rte_dev) { -/* No operation is performed while plugging the device */ -return 0 ; +int ret =0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv; + + TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + ret =rte_fslmc_match (drv, dev); +if (ret) +continue ; + +if (!drv->probe) +continue ; + +if (rte_dev_is_probed (&dev->device)) +continue ; + +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , + dev->device.name); +continue ; + } + + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; +DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); + } +break ; + } + +return ret; }static int -fslmc_bus_unplug(struct rte_device *dev __rte_unused) +fslmc_bus_unplug (struct rte_device *rte_dev) { -/* No operation is performed while unplugging the device */ -return 0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv = dev->driver; + +if (drv && drv->remove) { + drv->remove (dev); + dev->driver =NULL ; + dev->device.driver =NULL ; +DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name); +return 0 ; + } + +return -ENODEV ; } static void *
Signature · 1 line
2.25.1
Hello,
Quoted 27 lines · Hemant Agrawal
When
rte_eth_dev_close()is called, it performs the following actions:Calls
dev->dev_ops->dev_close(), which in this case isdpaa2_dev_close(). Then callsrte_eth_dev_release_port(), which releases all device data and setsdev->datato NULL.Later, when
rte_dev_remove()is called, the FSLMC bus invokesdev->remove()— that is,rte_dpaa2_remove().
However,rte_dpaa2_remove()callsdpaa2_dev_close()again. Sincedev->datawas already set to NULL by the previous call, this second invocation causes a crash.Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +0
-0
drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3352
Quoted 7 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1@@ -3347,14 +3347,17 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; eth_dev = dpaa2_dev->eth_dev;
Having a back reference of the "class" object in a "device" object seems wrong to me (and there is a dev_priv->eth_dev too...). It breaks the separation that was introduced with rte_device years ago.
I did not look in detail, but it seems strange that after closing a first time, there would still remain a reference of the eth_dev object in the dpaa2 device object.
At least, it would be worth double checking that the dpaa2_dev->eth_dev is cleared in dpaa2_dev_close.
drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3356
Quoted 5 lines
drivers/net/dpaa2/dpaa2_ethdev.c +4
-1-dpaa2_dev_close (eth_dev); +if (eth_dev->data) { + ret =dpaa2_dev_close (eth_dev); +if (!ret) + ret =rte_eth_dev_release_port (eth_dev);
I don't see why you would need to decrement dpaa2_valid_dev again below. Maybe a missing return here?
drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3363
Quoted 8 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1+ } dpaa2_valid_dev--;if (!dpaa2_valid_dev)rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev);return ret; }
Taking a step back, the issue this patch wants to fix is a pattern that is resolved by other drivers by checking if a eth_dev is allocated for a rte_device.
A simpler (untested) fix seems to be:
drivers/net/dpaa2/dpaa2_ethdev.c +4 -1
@@ -3349,7 +3349,10 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)struct rte_eth_dev *eth_dev;int ret; - eth_dev = dpaa2_dev->eth_dev; + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (!eth_dev) +return 0 ; +dpaa2_dev_close (eth_dev); dpaa2_valid_dev--;if (!dpaa2_valid_dev)
Signature · 1 line
David Marchand
Quoted 11 lines · David Marchand
Quoted 11 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1@@ -3347,14 +3347,17 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ;
Quoted 5 lines
drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3352
Quoted 1 line
drivers/net/dpaa2/dpaa2_ethdev.c +0
-0eth_dev = dpaa2_dev->eth_dev;Having a back reference of the "class" object in a "device" object seems wrong to me (and there is a
dev_priv->eth_devtoo...). It breaks the separation that was introduced withrte_deviceyears ago.
I went and had a try:
https://patchwork.dpdk.org/project/dpdk/list/?series=36627
No promise it works, but it is cleaner this way.
Signature · 1 line
David Marchand
Quoted 12 lines · On Thu, 6 Nov 2025 22:08:05 +0530 Hemant Agrawal <[email protected]>…
When
rte_eth_dev_close()is called, it performs the following actions:Calls
dev->dev_ops->dev_close(), which in this case isdpaa2_dev_close(). Then callsrte_eth_dev_release_port(), which releases all device data and setsdev->datato NULL.Later, when
rte_dev_remove()is called, the FSLMC bus invokesdev->remove()— that is,rte_dpaa2_remove().
However,rte_dpaa2_remove()callsdpaa2_dev_close()again. Sincedev->datawas already set to NULL by the previous call, this second invocation causes a crash.
Quoted 5 lines
Signed-off-by Hemant Agrawal <[email protected]>
Not merging this now, because of the feedback about how this driver is interacting with bus. Either need an ACK or new version.
PATCH v2 1/5 net/dpaa2: fix duplicate calling of dpaa2 dev close
In reply to Hemant AgrawalWhen rte_eth_dev_close() is called, it performs the following actions:
Calls dev->dev_ops->dev_close(), which in this case is dpaa2_dev_close(). Then calls rte_eth_dev_release_port(), which releases all device data and sets dev->data to NULL.
Later, when rte_dev_remove() is called, the FSLMC bus invokes dev->remove() — that is, rte_dpaa2_remove().
However, rte_dpaa2_remove() calls dpaa2_dev_close() again. Since dev->data was already set to NULL by the previous call, this second invocation causes a crash.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +10 -5
@@ -3347,14 +3347,19 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { +dpaa2_dev_close (eth_dev); + ret =rte_eth_dev_release_port (eth_dev); + } - eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); dpaa2_valid_dev--; -if (!dpaa2_valid_dev) +if (!dpaa2_valid_dev) {rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev); + dpaa2_tx_sg_pool =NULL ; + }return ret; }
Signature · 1 line
2.25.1
PATCH v2 2/5 net/dpaa2: clear active VDQ state when freeing Rx queues
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Each queue_storage_info_t also stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_id
Before issuing a new pull command, dpaa2_dev_prefetch_rx() checks for an active entry and spins on qbman_check_command_complete() until the corresponding VDQCR completes.
On port close / hotplug remove, dpaa2_free_rx_tx_queues() frees all per-lcore queue_storage_info_t structures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb, dq->dq.tok stays 0 and dpaa2_dev_prefetch_rx() loops in:
while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;
Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if qs->active_dqs is non-NULL, call clear_swp_active_dqs(qs->active_dpio_id) and set qs->active_dqs to NULL. Then dpaa2_queue_storage_free() can safely free q_storage and dq_storage[].
After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:
grcli interface add port dpni.1 devargs fslmc:dpni.1
grcli interface del dpni.1
grcli interface add port dpni.1 devargs fslmc:dpni.1
-> Rx was stuck in qbman_check_command_complete(), now works. - testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normal
--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
drivers/net/dpaa2/dpaa2_ethdev.c +22 -0
@@ -631,6 +631,27 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q) +{ +int lcore_id; + +RTE_LCORE_FOREACH (lcore_id) { +struct queue_storage_info_t *qs = q->q_storage[lcore_id]; + +if (!qs) +continue ; + +if (qs->active_dqs) { +while (!qbman_check_command_complete (qs->active_dqs)) +/* wait */ ; + +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +static void dpaa2_free_rx_tx_queues (struct rte_eth_dev *dev) {
@@ -645,6 +666,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)/* cleaning up queue storage */ for (i =0 ; i < priv->nb_rx_queues; i++) { dpaa2_q = priv->rx_vq[i]; +dpaa2_clear_queue_active_dps (dpaa2_q);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); }
Signature · 1 line
2.25.1
PATCH v2 3/5 net/dpaa2: fix queue free cleanup
In reply to Hemant AgrawalThe RX error queue was not being free.
Also, set the free queues pointers to NULL.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +8 -0
@@ -669,11 +669,13 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)dpaa2_clear_queue_active_dps (dpaa2_q);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->rx_vq[i] =NULL ; }/* cleanup tx queue cscn */ for (i =0 ; i < priv->nb_tx_queues; i++) { dpaa2_q = priv->tx_vq[i];rte_free (dpaa2_q->cscn); + priv->tx_vq[i] =NULL ; }if (priv->flags &DPAA2_TX_CONF_ENABLE ) {/* cleanup tx conf queue storage */
@@ -681,8 +683,14 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) dpaa2_q = priv->tx_conf_vq[i];dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->tx_conf_vq[i] =NULL ; } } +if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { + dpaa2_q = priv->rx_err_vq; +dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + } +/*free memory for all queues (RX+TX) */ rte_free (priv->rx_vq[0 ]); priv->rx_vq[0 ] =NULL ;
Signature · 1 line
2.25.1
PATCH v2 4/5 net/dpaa2: bifurcate close into close and deinit
In reply to Hemant AgrawalThe close function was overloaded to be also used as deinit function. This can cause issues when using functions like hotplug.
This patch cleans up the code and implement separate close and deinit
--- drivers/net/dpaa2/dpaa2_ethdev.c | 92 ++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 41 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +51 -41
@@ -1524,53 +1524,14 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)static int dpaa2_dev_close (struct rte_eth_dev *dev) { -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int i, ret; -struct rte_eth_link link; -PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; -if (!dpni) { -DPAA2_PMD_WARN ("Already closed or not started" ); -return -EINVAL ; - } -dpaa2_tm_deinit (dev);dpaa2_flow_clean (dev); -/* Clean the device first */ - ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); -return ret; - } - -memset (&link,0 ,sizeof (link)); -rte_eth_linkstatus_set (dev, &link); - -/* Free private queues memory */ -dpaa2_free_rx_tx_queues (dev); -/* Close the device at underlying layer*/ - ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , - ret); - } - -/* Free the allocated memory for ethernet private data and dpni*/ - priv->hw =NULL ; - dev->process_private =NULL ; -rte_free (dpni); -for (i =0 ; i <MAX_TCS ; i++) -rte_free (priv->extract.tc_extract_param[i]); - -rte_free (priv->extract.qos_extract_param); - -DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name);return 0 ; }
@@ -2891,6 +2852,55 @@ dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)return 1 ; } +static int +dpaa2_dev_deinit (struct rte_eth_dev *dev) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +int i, ret; +struct rte_eth_link link; + +PMD_INIT_FUNC_TRACE (); + +if (!dpni) { +DPAA2_PMD_WARN ("Already closed or not started" ); +return -EINVAL ; + } + +/* Clean the device first */ + ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); +return ret; + } + +memset (&link,0 ,sizeof (link)); +rte_eth_linkstatus_set (dev, &link); + +/* Free private queues memory */ +dpaa2_free_rx_tx_queues (dev); +/* Close the device at underlying layer*/ + ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , + ret); + } + +/* Free the allocated memory for ethernet private data and dpni*/ + priv->hw =NULL ; + dev->process_private =NULL ; +rte_free (dpni); + +for (i =0 ; i <MAX_TCS ; i++) +rte_free (priv->extract.tc_extract_param[i]); + +rte_free (priv->extract.qos_extract_param); + +DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name); +return 0 ; +} + +static int dpaa2_dev_init (struct rte_eth_dev *eth_dev) {
@@ -3177,7 +3187,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; init_err: -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev);return ret; }
@@ -3381,7 +3391,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name);if (eth_dev) { -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev); ret =rte_eth_dev_release_port (eth_dev); }
Signature · 1 line
2.25.1
Re: [PATCH v2 4/5] net/dpaa2: bifurcate close into close and deinit
Hi Hemant,
Quoted 135 lines · Hemant Agrawal
The close function was overloaded to be also used as deinit function. This can cause issues when using functions like hotplug.
This patch cleans up the code and implement separate close and deinit
Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 92 ++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 41 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +50
-40@@ -1524,53 +1524,14 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)static int dpaa2_dev_close (struct rte_eth_dev *dev) { -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int i, ret; -struct rte_eth_link link; -PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; -if (!dpni) { -DPAA2_PMD_WARN ("Already closed or not started" ); -return -EINVAL ; - } -dpaa2_tm_deinit (dev);dpaa2_flow_clean (dev); -/* Clean the device first */ - ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); -return ret; - } - -memset (&link,0 ,sizeof (link)); -rte_eth_linkstatus_set (dev, &link); - -/* Free private queues memory */ -dpaa2_free_rx_tx_queues (dev); -/* Close the device at underlying layer*/ - ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , - ret); - } - -/* Free the allocated memory for ethernet private data and dpni*/ - priv->hw =NULL ; - dev->process_private =NULL ; -rte_free (dpni); -for (i =0 ; i <MAX_TCS ; i++) -rte_free (priv->extract.tc_extract_param[i]); - -rte_free (priv->extract.qos_extract_param); - -DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name);return 0 ; }@@ -2891,6 +2852,55 @@ dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)return 1 ; } +static int +dpaa2_dev_deinit (struct rte_eth_dev *dev) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +int i, ret; +struct rte_eth_link link; + +PMD_INIT_FUNC_TRACE (); + +if (!dpni) { +DPAA2_PMD_WARN ("Already closed or not started" ); +return -EINVAL ; + } + +/* Clean the device first */ + ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); +return ret; + } + +memset (&link,0 ,sizeof (link)); +rte_eth_linkstatus_set (dev, &link); + +/* Free private queues memory */ +dpaa2_free_rx_tx_queues (dev); +/* Close the device at underlying layer*/ + ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , + ret); + } + +/* Free the allocated memory for ethernet private data and dpni*/ + priv->hw =NULL ; + dev->process_private =NULL ; +rte_free (dpni); + +for (i =0 ; i <MAX_TCS ; i++) +rte_free (priv->extract.tc_extract_param[i]); + +rte_free (priv->extract.qos_extract_param); + +DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name); +return 0 ; +} + +static int dpaa2_dev_init (struct rte_eth_dev *eth_dev) {@@ -3177,7 +3187,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; init_err: -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev);return ret; }
drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3397
Quoted 8 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1@@ -3381,7 +3391,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name);if (eth_dev) { -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev); ret =rte_eth_dev_release_port (eth_dev); }
When a DPDK application stops, dpaa2_dev_close is no longer called. This happens because eal_cleanup() invokes rte_fslmc_close(), which then calls the remove function (rte_dpaa2_remove) for each DPAA2 Ethernet driver. As a result, dpaa2_tm_deinit() and dpaa2_flow_clean() are no longer executed.
Another issue is that dpaa2_dev_deinit is now called in secondary process, which was not the case before this commit.
For comparison, other drivers like ixgbe call their close method from the bus’s remove callback. I don’t see any issue doing the same here—calling close during remove if the Ethernet device is still allocated.
As far as I know, there is no counterpart to rte_eth_dev_close() in the DPDK API (there could have been an rte_eth_dev_open()). The open path is always triggered by the bus’s probe callback. Because of this, it is expected that dpaa2_dev_init is called from the plug/probe path, while the corresponding deinit logic is handled in the close callback.
One more point: why isn’t dpaa2_tx_sg_pool_init() done directly in dpaa2_dev_init(), with its corresponding cleanup performed in dpaa2_dev_close()?
Maxime Leroy
Re: [PATCH v2 4/5] net/dpaa2: bifurcate close into close and deinit
In reply to Hemant AgrawalHi Hemant,
Quoted 135 lines · Hemant Agrawal
The close function was overloaded to be also used as deinit function. This can cause issues when using functions like hotplug.
This patch cleans up the code and implement separate close and deinit
Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 92 ++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 41 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +50
-40@@ -1524,53 +1524,14 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)static int dpaa2_dev_close (struct rte_eth_dev *dev) { -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int i, ret; -struct rte_eth_link link; -PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; -if (!dpni) { -DPAA2_PMD_WARN ("Already closed or not started" ); -return -EINVAL ; - } -dpaa2_tm_deinit (dev);dpaa2_flow_clean (dev); -/* Clean the device first */ - ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); -return ret; - } - -memset (&link,0 ,sizeof (link)); -rte_eth_linkstatus_set (dev, &link); - -/* Free private queues memory */ -dpaa2_free_rx_tx_queues (dev); -/* Close the device at underlying layer*/ - ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , - ret); - } - -/* Free the allocated memory for ethernet private data and dpni*/ - priv->hw =NULL ; - dev->process_private =NULL ; -rte_free (dpni); -for (i =0 ; i <MAX_TCS ; i++) -rte_free (priv->extract.tc_extract_param[i]); - -rte_free (priv->extract.qos_extract_param); - -DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name);return 0 ; }@@ -2891,6 +2852,55 @@ dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)return 1 ; } +static int +dpaa2_dev_deinit (struct rte_eth_dev *dev) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +int i, ret; +struct rte_eth_link link; + +PMD_INIT_FUNC_TRACE (); + +if (!dpni) { +DPAA2_PMD_WARN ("Already closed or not started" ); +return -EINVAL ; + } + +/* Clean the device first */ + ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); +return ret; + } + +memset (&link,0 ,sizeof (link)); +rte_eth_linkstatus_set (dev, &link); + +/* Free private queues memory */ +dpaa2_free_rx_tx_queues (dev); +/* Close the device at underlying layer*/ + ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , + ret); + } + +/* Free the allocated memory for ethernet private data and dpni*/ + priv->hw =NULL ; + dev->process_private =NULL ; +rte_free (dpni); + +for (i =0 ; i <MAX_TCS ; i++) +rte_free (priv->extract.tc_extract_param[i]); + +rte_free (priv->extract.qos_extract_param); + +DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name); +return 0 ; +} + +static int dpaa2_dev_init (struct rte_eth_dev *eth_dev) {@@ -3177,7 +3187,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; init_err: -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev);return ret; }
drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3396
Quoted 7 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1@@ -3381,7 +3391,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name);if (eth_dev) { -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev); ret =rte_eth_dev_release_port (eth_dev); }
When a DPDK application stops, dpaa2_dev_close is no longer called. This happens because eal_cleanup() invokes rte_fslmc_close(), which then calls the remove function (rte_dpaa2_remove) for each DPAA2 Ethernet driver. As a result, dpaa2_tm_deinit() and dpaa2_flow_clean() are no longer executed.
Another issue is that dpaa2_dev_deinit is now called in secondary process, which was not the case before this commit.
For comparison, other drivers like ixgbe call their close method from the bus’s remove callback. I don’t see any issue doing the same here—calling close during remove if the Ethernet device is still allocated.
As far as I know, there is no counterpart to rte_eth_dev_close() in the DPDK API (there could have been an rte_eth_dev_open()). The open path is always triggered by the bus’s probe callback. Because of this, it is expected that dpaa2_dev_init is called from the plug/probe path, while the corresponding deinit logic is handled in the close callback.
One more point: why isn’t dpaa2_tx_sg_pool_init() done directly in dpaa2_dev_init(), with its corresponding cleanup performed in dpaa2_dev_close()?
Maxime Leroy
Re: [PATCH v2 4/5] net/dpaa2: bifurcate close into close and deinit
Quoted 160 lines · Maxime Leroy
[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Hi Hemant,
Quoted 134 lines · Hemant Agrawal
The close function was overloaded to be also used as deinit function. This can cause issues when using functions like hotplug.
This patch cleans up the code and implement separate close and deinit
Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 92 ++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 41 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +50
-40@@ -1524,53 +1524,14 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)static int dpaa2_dev_close (struct rte_eth_dev *dev) { -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int i, ret; -struct rte_eth_link link; -PMD_INIT_FUNC_TRACE ();if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return 0 ; -if (!dpni) { -DPAA2_PMD_WARN ("Already closed or not started" ); -return -EINVAL ; - } -dpaa2_tm_deinit (dev);dpaa2_flow_clean (dev); -/* Clean the device first */ - ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); -return ret; - } - -memset (&link,0 ,sizeof (link)); -rte_eth_linkstatus_set (dev, &link); - -/* Free private queues memory */ -dpaa2_free_rx_tx_queues (dev); -/* Close the device at underlying layer*/ - ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , - ret); - } - -/* Free the allocated memory for ethernet private data and dpni*/ - priv->hw =NULL ; - dev->process_private =NULL ; -rte_free (dpni); -for (i =0 ; i <MAX_TCS ; i++) -rte_free (priv->extract.tc_extract_param[i]); - -rte_free (priv->extract.qos_extract_param); - -DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name);return 0 ; }@@ -2891,6 +2852,55 @@ dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)return 1 ; } +static int +dpaa2_dev_deinit (struct rte_eth_dev *dev) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +int i, ret; +struct rte_eth_link link; + +PMD_INIT_FUNC_TRACE (); + +if (!dpni) { +DPAA2_PMD_WARN ("Already closed or not started" ); +return -EINVAL ; + } + +/* Clean the device first */ + ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure cleaning dpni device: err=%d" , ret); +return ret; + } + +memset (&link,0 ,sizeof (link)); +rte_eth_linkstatus_set (dev, &link); + +/* Free private queues memory */ +dpaa2_free_rx_tx_queues (dev); +/* Close the device at underlying layer*/ + ret =dpni_close (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Failure closing dpni device with err code %d" , + ret); + } + +/* Free the allocated memory for ethernet private data and dpni*/ + priv->hw =NULL ; + dev->process_private =NULL ; +rte_free (dpni); + +for (i =0 ; i <MAX_TCS ; i++) +rte_free (priv->extract.tc_extract_param[i]); + +rte_free (priv->extract.qos_extract_param); + +DPAA2_PMD_INFO ("%s: netdev deleted" , dev->data->name); +return 0 ; +} + +static int dpaa2_dev_init (struct rte_eth_dev *eth_dev) {@@ -3177,7 +3187,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)return 0 ; init_err: -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev);return ret; }drivers/net/dpaa2/dpaa2_ethdev.c rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) · line 3396
Quoted 7 lines
drivers/net/dpaa2/dpaa2_ethdev.c +1
-1@@ -3381,7 +3391,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name);if (eth_dev) { -dpaa2_dev_close (eth_dev); +dpaa2_dev_deinit (eth_dev); ret =rte_eth_dev_release_port (eth_dev); }When a DPDK application stops,
dpaa2_dev_closeis no longer called. This happens becauseeal_cleanup()invokesrte_fslmc_close(), which then calls the remove function (rte_dpaa2_remove) for each DPAA2 Ethernet driver. As a result,dpaa2_tm_deinit()anddpaa2_flow_clean()are no longer executed.Another issue is that
dpaa2_dev_deinitis now called in secondary process, which was not the case before this commit.For comparison, other drivers like ixgbe call their close method from the bus’s remove callback. I don’t see any issue doing the same here—calling close during remove if the Ethernet device is still allocated.
Quoted 6 lines
As far as I know, there is no counterpart to
rte_eth_dev_close()in the DPDK API (there could have been anrte_eth_dev_open()). The open path is always triggered by the bus’s probe callback. Because of this, it is expected thatdpaa2_dev_initis called from the plug/probe path, while the corresponding deinit logic is handled in the close callback.
ok, it looks like best approach is to drop this patch.
Quoted 4 lines
One more point: why isn’t
dpaa2_tx_sg_pool_init()done directly indpaa2_dev_init(), with its corresponding cleanup performed indpaa2_dev_close()?
dpaa2_tx_sg_pool is a global resource across devices; which is being tracked with dpaa2_valid_dev
we will be revamping this logic in next major release.
Quoted 2 lines
Maxime Leroy
PATCH v2 5/5 bus/fslmc: add support for hotplug of dpni
In reply to Hemant AgrawalThis patch implements the plug and unplug function to support attach/detach of dpni interfaces.
--- drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +50 -6
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void) }static int -fslmc_bus_plug(struct rte_device *dev __rte_unused) +fslmc_bus_plug (struct rte_device *rte_dev) { -/* No operation is performed while plugging the device */ -return 0 ; +int ret =0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv; + + TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + ret =rte_fslmc_match (drv, dev); +if (ret) +continue ; + +if (!drv->probe) +continue ; + +if (rte_dev_is_probed (&dev->device)) +continue ; + +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , + dev->device.name); +continue ; + } + + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; +DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); + } +break ; + } + +return ret; }static int -fslmc_bus_unplug(struct rte_device *dev __rte_unused) +fslmc_bus_unplug (struct rte_device *rte_dev) { -/* No operation is performed while unplugging the device */ -return 0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv = dev->driver; + +if (drv && drv->remove) { + drv->remove (dev); + dev->driver =NULL ; + dev->device.driver =NULL ; +DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name); +return 0 ; + } + +return -ENODEV ; } static void *
Signature · 1 line
2.25.1
PATCH v3 1/4 net/dpaa2: fix duplicate calling of dpaa2 dev close
In reply to Hemant AgrawalWhen rte_eth_dev_close() is called, it performs the following actions:
Calls dev->dev_ops->dev_close(), which in this case is dpaa2_dev_close(). Then calls rte_eth_dev_release_port(), which releases all device data and sets dev->data to NULL.
Later, when rte_dev_remove() is called, the FSLMC bus invokes dev->remove() — that is, rte_dpaa2_remove().
However, rte_dpaa2_remove() calls dpaa2_dev_close() again. Since dev->data was already set to NULL by the previous call, this second invocation causes a crash.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +10 -5
@@ -3347,14 +3347,19 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { +dpaa2_dev_close (eth_dev); + ret =rte_eth_dev_release_port (eth_dev); + } - eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); dpaa2_valid_dev--; -if (!dpaa2_valid_dev) +if (!dpaa2_valid_dev) {rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev); + dpaa2_tx_sg_pool =NULL ; + }return ret; }
Signature · 1 line
2.25.1
PATCH v3 2/4 net/dpaa2: clear active VDQ state when freeing Rx queues
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Each queue_storage_info_t also stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_id
Before issuing a new pull command, dpaa2_dev_prefetch_rx() checks for an active entry and spins on qbman_check_command_complete() until the corresponding VDQCR completes.
On port close / hotplug remove, dpaa2_free_rx_tx_queues() frees all per-lcore queue_storage_info_t structures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb, dq->dq.tok stays 0 and dpaa2_dev_prefetch_rx() loops in:
while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;
Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if qs->active_dqs is non-NULL, call clear_swp_active_dqs(qs->active_dpio_id) and set qs->active_dqs to NULL. Then dpaa2_queue_storage_free() can safely free q_storage and dq_storage[].
After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:
grcli interface add port dpni.1 devargs fslmc:dpni.1
grcli interface del dpni.1
grcli interface add port dpni.1 devargs fslmc:dpni.1
-> Rx was stuck in qbman_check_command_complete(), now works. - testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normal
--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
drivers/net/dpaa2/dpaa2_ethdev.c +22 -0
@@ -631,6 +631,27 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q) +{ +int lcore_id; + +RTE_LCORE_FOREACH (lcore_id) { +struct queue_storage_info_t *qs = q->q_storage[lcore_id]; + +if (!qs) +continue ; + +if (qs->active_dqs) { +while (!qbman_check_command_complete (qs->active_dqs)) +/* wait */ ; + +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +static void dpaa2_free_rx_tx_queues (struct rte_eth_dev *dev) {
@@ -645,6 +666,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)/* cleaning up queue storage */ for (i =0 ; i < priv->nb_rx_queues; i++) { dpaa2_q = priv->rx_vq[i]; +dpaa2_clear_queue_active_dps (dpaa2_q);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); }
Signature · 1 line
2.25.1
Re: [PATCH v3 2/4] net/dpaa2: clear active VDQ state when freeing Rx queues
Hi Hemant,
Quoted 84 lines · Hemant Agrawal
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (
dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Eachqueue_storage_info_talso stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_idBefore issuing a new pull command,
dpaa2_dev_prefetch_rx()checks for an active entry and spins onqbman_check_command_complete()until the corresponding VDQCR completes.On port close / hotplug remove,
dpaa2_free_rx_tx_queues()frees all per-lcorequeue_storage_info_tstructures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb,dq->dq.tokstays 0 anddpaa2_dev_prefetch_rx()loops in:while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if
qs->active_dqsis non-NULL, callclear_swp_active_dqs(qs->active_dpio_id)and setqs->active_dqsto NULL. Thendpaa2_queue_storage_free()can safely freeq_storageand dq_storage[].After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:grcli interface add port dpni.1 devargs fslmc:dpni.1 grcli interface del dpni.1 grcli interface add port dpni.1 devargs fslmc:dpni.1 -> Rx was stuck in qbman_check_command_complete(), now works.- testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normalFixes 12d98eceb8ac ("bus/fslmc: enhance QBMAN DQ storage logic")Signed-off-by Maxime Leroy <[email protected]>--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-).mailmap +1
-1@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>drivers/net/dpaa2/dpaa2_ethdev.c +0
-0
drivers/net/dpaa2/dpaa2_ethdev.c dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) · line 639
Quoted 9 lines
drivers/net/dpaa2/dpaa2_ethdev.c +6
-0@@ -631,6 +631,27 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q) +{ +int lcore_id; + +RTE_LCORE_FOREACH (lcore_id) {
RTE_LCORE_FOREACH does not iterate over NON-EAL threads. However, Grout creates NON-EAL threads using the pthread library to poll the RX queue.
As a result, using RTE_LCORE_FOREACH breaks the fix. We should revert to the previous version of the fix.
Thanks,
Maxime Leroy
PATCH v3 3/4 net/dpaa2: fix queue free cleanup
In reply to Hemant AgrawalThe RX error queue was not being free.
Also, set the free queues pointers to NULL.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +8 -0
@@ -669,11 +669,13 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)dpaa2_clear_queue_active_dps (dpaa2_q);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->rx_vq[i] =NULL ; }/* cleanup tx queue cscn */ for (i =0 ; i < priv->nb_tx_queues; i++) { dpaa2_q = priv->tx_vq[i];rte_free (dpaa2_q->cscn); + priv->tx_vq[i] =NULL ; }if (priv->flags &DPAA2_TX_CONF_ENABLE ) {/* cleanup tx conf queue storage */
@@ -681,8 +683,14 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) dpaa2_q = priv->tx_conf_vq[i];dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->tx_conf_vq[i] =NULL ; } } +if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { + dpaa2_q = priv->rx_err_vq; +dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + } +/*free memory for all queues (RX+TX) */ rte_free (priv->rx_vq[0 ]); priv->rx_vq[0 ] =NULL ;
Signature · 1 line
2.25.1
PATCH v3 4/4 bus/fslmc: add support for hotplug of dpni
In reply to Hemant AgrawalThis patch implements the plug and unplug function to support attach/detach of dpni interfaces.
--- drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +50 -6
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void) }static int -fslmc_bus_plug(struct rte_device *dev __rte_unused) +fslmc_bus_plug (struct rte_device *rte_dev) { -/* No operation is performed while plugging the device */ -return 0 ; +int ret =0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv; + + TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + ret =rte_fslmc_match (drv, dev); +if (ret) +continue ; + +if (!drv->probe) +continue ; + +if (rte_dev_is_probed (&dev->device)) +continue ; + +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , + dev->device.name); +continue ; + } + + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; +DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); + } +break ; + } + +return ret; }static int -fslmc_bus_unplug(struct rte_device *dev __rte_unused) +fslmc_bus_unplug (struct rte_device *rte_dev) { -/* No operation is performed while unplugging the device */ -return 0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv = dev->driver; + +if (drv && drv->remove) { + drv->remove (dev); + dev->driver =NULL ; + dev->device.driver =NULL ; +DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name); +return 0 ; + } + +return -ENODEV ; } static void *
Signature · 1 line
2.25.1
PATCH v4 1/4 net/dpaa2: fix duplicate calling of dpaa2 dev close
In reply to Hemant AgrawalWhen rte_eth_dev_close() is called, it performs the following actions:
Calls dev->dev_ops->dev_close(), which in this case is dpaa2_dev_close(). Then calls rte_eth_dev_release_port(), which releases all device data and sets dev->data to NULL.
Later, when rte_dev_remove() is called, the FSLMC bus invokes dev->remove() — that is, rte_dpaa2_remove().
However, rte_dpaa2_remove() calls dpaa2_dev_close() again. Since dev->data was already set to NULL by the previous call, this second invocation causes a crash.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +10 -5
@@ -3347,14 +3347,19 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { +dpaa2_dev_close (eth_dev); + ret =rte_eth_dev_release_port (eth_dev); + } - eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); dpaa2_valid_dev--; -if (!dpaa2_valid_dev) +if (!dpaa2_valid_dev) {rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev); + dpaa2_tx_sg_pool =NULL ; + }return ret; }
Signature · 1 line
2.25.1
PATCH v4 2/4 net/dpaa2: clear active VDQ state when freeing Rx queues
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Each queue_storage_info_t also stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_id
Before issuing a new pull command, dpaa2_dev_prefetch_rx() checks for an active entry and spins on qbman_check_command_complete() until the corresponding VDQCR completes.
On port close / hotplug remove, dpaa2_free_rx_tx_queues() frees all per-lcore queue_storage_info_t structures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb, dq->dq.tok stays 0 and dpaa2_dev_prefetch_rx() loops in:
while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;
Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if qs->active_dqs is non-NULL, call clear_swp_active_dqs(qs->active_dpio_id) and set qs->active_dqs to NULL. Then dpaa2_queue_storage_free() can safely free q_storage and dq_storage[].
After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:
grcli interface add port dpni.1 devargs fslmc:dpni.1
grcli interface del dpni.1
grcli interface add port dpni.1 devargs fslmc:dpni.1
-> Rx was stuck in qbman_check_command_complete(), now works. - testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normal
--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
drivers/net/dpaa2/dpaa2_ethdev.c +23 -0
@@ -631,6 +631,27 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; + +if (!qs) +continue ; + +if (qs->active_dqs) { +while (!qbman_check_command_complete (qs->active_dqs)) +/* wait */ ; + +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +static void dpaa2_free_rx_tx_queues (struct rte_eth_dev *dev) {
@@ -645,6 +666,8 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)/* cleaning up queue storage */ for (i =0 ; i < priv->nb_rx_queues; i++) { dpaa2_q = priv->rx_vq[i]; +dpaa2_clear_queue_active_dps (dpaa2_q, +RTE_MAX_LCORE );dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); }
Signature · 1 line
2.25.1
PATCH v4 3/4 net/dpaa2: fix queue free cleanup
In reply to Hemant AgrawalThe RX error queue was not being free.
Also, set the free queues pointers to NULL.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +8 -0
@@ -670,11 +670,13 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) RTE_MAX_LCORE);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->rx_vq[i] =NULL ; }/* cleanup tx queue cscn */ for (i =0 ; i < priv->nb_tx_queues; i++) { dpaa2_q = priv->tx_vq[i];rte_free (dpaa2_q->cscn); + priv->tx_vq[i] =NULL ; }if (priv->flags &DPAA2_TX_CONF_ENABLE ) {/* cleanup tx conf queue storage */
@@ -682,8 +684,14 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) dpaa2_q = priv->tx_conf_vq[i];dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->tx_conf_vq[i] =NULL ; } } +if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { + dpaa2_q = priv->rx_err_vq; +dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + } +/*free memory for all queues (RX+TX) */ rte_free (priv->rx_vq[0 ]); priv->rx_vq[0 ] =NULL ;
Signature · 1 line
2.25.1
PATCH v4 4/4 bus/fslmc: add support for hotplug of dpni
In reply to Hemant AgrawalThis patch implements the plug and unplug function to support attach/detach of dpni interfaces.
--- drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +50 -6
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void) }static int -fslmc_bus_plug(struct rte_device *dev __rte_unused) +fslmc_bus_plug (struct rte_device *rte_dev) { -/* No operation is performed while plugging the device */ -return 0 ; +int ret =0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv; + + TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + ret =rte_fslmc_match (drv, dev); +if (ret) +continue ; + +if (!drv->probe) +continue ; + +if (rte_dev_is_probed (&dev->device)) +continue ; + +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , + dev->device.name); +continue ; + } + + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; +DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); + } +break ; + } + +return ret; }static int -fslmc_bus_unplug(struct rte_device *dev __rte_unused) +fslmc_bus_unplug (struct rte_device *rte_dev) { -/* No operation is performed while unplugging the device */ -return 0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv = dev->driver; + +if (drv && drv->remove) { + drv->remove (dev); + dev->driver =NULL ; + dev->device.driver =NULL ; +DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name); +return 0 ; + } + +return -ENODEV ; } static void *
Signature · 1 line
2.25.1
Hi Hemant,
Quoted 28 lines · Hemant Agrawal
When
rte_eth_dev_close()is called, it performs the following actions:Calls
dev->dev_ops->dev_close(), which in this case isdpaa2_dev_close(). Then callsrte_eth_dev_release_port(), which releases all device data and setsdev->datato NULL.Later, when
rte_dev_remove()is called, the FSLMC bus invokesdev->remove()— that is,rte_dpaa2_remove().
However,rte_dpaa2_remove()callsdpaa2_dev_close()again. Sincedev->datawas already set to NULL by the previous call, this second invocation causes a crash.Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +0
-0@@ -3347,14 +3347,19 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3356
Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +7
-1{struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { +dpaa2_dev_close (eth_dev); + ret =rte_eth_dev_release_port (eth_dev); + }
dpaa2_dev_close() returns a status code, but it isn’t being checked here.
For comparison, in rte_eth_dev_pci_generic_remove(), if dev_uninit (i.e. the device close callback) fails, rte_eth_dev_release_port() is not called.
How should the dpaa2 driver handle this kind of error case?
By the way, if it makes sense for you, feel free to add a Tested-by tag from me, since I’ve validated the series on my side with Grout.
Regards,
Maxime Leroy
Hi Maxime,
Quoted 47 lines
-----Original Message-----
From: Maxime Leroy <[email protected]>
Hi Hemant,Le jeu. 13 nov. 2025 à 12:44, Hemant Agrawal <[email protected]> a écrit :
Quoted 28 lines
When
rte_eth_dev_close()is called, it performs the following actions:Calls
dev->dev_ops->dev_close(), which in this case isdpaa2_dev_close(). Then callsrte_eth_dev_release_port(), which releases all device data and setsdev->datato NULL.Later, when
rte_dev_remove()is called, the FSLMC bus invokesdev->remove()— that is,rte_dpaa2_remove().
However,rte_dpaa2_remove()callsdpaa2_dev_close()again. Sincedev->datawas already set to NULL by the previous call, this second invocation causes a crash.Signed-off-by Hemant Agrawal <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +0
-0drivers/net/dpaa2/dpaa2_ethdev.c static int · line 3355
Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +7
-1@@ -3347,14 +3347,19 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { +dpaa2_dev_close (eth_dev); + ret =rte_eth_dev_release_port (eth_dev); + }
dpaa2_dev_close()returns a status code, but it isn’t being checked here.
Quoted 4 lines
For comparison, in
rte_eth_dev_pci_generic_remove(), ifdev_uninit(i.e. the device close callback) fails,rte_eth_dev_release_port()is not called. How should the dpaa2 driver handle this kind of error case?
[Hemant] The current framework can only record the error.
Quoted 2 lines
By the way, if it makes sense for you, feel free to add a Tested-by tag from me, since I’ve validated the series on my side with Grout.
[Hemant] sure
Quoted 4 lines
Regards,
Maxime Leroy
PATCH v5 1/4 net/dpaa2: fix duplicate calling of dpaa2 dev close
In reply to Hemant AgrawalWhen rte_eth_dev_close() is called, it performs the following actions:
Calls dev->dev_ops->dev_close(), which in this case is dpaa2_dev_close(). Then calls rte_eth_dev_release_port(), which releases all device data and sets dev->data to NULL.
Later, when rte_dev_remove() is called, the FSLMC bus invokes dev->remove() — that is, rte_dpaa2_remove().
However, rte_dpaa2_remove() calls dpaa2_dev_close() again. Since dev->data was already set to NULL by the previous call, this second invocation causes a crash.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +13 -5
@@ -3347,14 +3347,22 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { + ret =dpaa2_dev_close (eth_dev); +if (ret) +DPAA2_PMD_ERR ("dpaa2_dev_close ret= %d" , ret); + + ret =rte_eth_dev_release_port (eth_dev); + } - eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); dpaa2_valid_dev--; -if (!dpaa2_valid_dev) +if (!dpaa2_valid_dev) {rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev); + dpaa2_tx_sg_pool =NULL ; + }return ret; }
Signature · 1 line
2.25.1
PATCH v5 2/4 net/dpaa2: clear active VDQ state when freeing Rx queues
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Each queue_storage_info_t also stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_id
Before issuing a new pull command, dpaa2_dev_prefetch_rx() checks for an active entry and spins on qbman_check_command_complete() until the corresponding VDQCR completes.
On port close / hotplug remove, dpaa2_free_rx_tx_queues() frees all per-lcore queue_storage_info_t structures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb, dq->dq.tok stays 0 and dpaa2_dev_prefetch_rx() loops in:
while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;
Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if qs->active_dqs is non-NULL, call clear_swp_active_dqs(qs->active_dpio_id) and set qs->active_dqs to NULL. Then dpaa2_queue_storage_free() can safely free q_storage and dq_storage[].
After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:
grcli interface add port dpni.1 devargs fslmc:dpni.1
grcli interface del dpni.1
grcli interface add port dpni.1 devargs fslmc:dpni.1
-> Rx was stuck in qbman_check_command_complete(), now works. - testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normal
--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]> Md Fahad Iqbal Polash <[email protected]> Megha Ajmera <[email protected]> Meijuan Zhao <[email protected]>
drivers/net/dpaa2/dpaa2_ethdev.c +23 -0
@@ -631,6 +631,27 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)return ret; } +static void +dpaa2_clear_queue_active_dps (struct dpaa2_queue *q,int num_lcores) +{ +int i; + +for (i =0 ; i < num_lcores; i++) { +struct queue_storage_info_t *qs = q->q_storage[i]; + +if (!qs) +continue ; + +if (qs->active_dqs) { +while (!qbman_check_command_complete (qs->active_dqs)) +/* wait */ ; + +clear_swp_active_dqs (qs->active_dpio_id); + qs->active_dqs =NULL ; + } + } +} +static void dpaa2_free_rx_tx_queues (struct rte_eth_dev *dev) {
@@ -645,6 +666,8 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)/* cleaning up queue storage */ for (i =0 ; i < priv->nb_rx_queues; i++) { dpaa2_q = priv->rx_vq[i]; +dpaa2_clear_queue_active_dps (dpaa2_q, +RTE_MAX_LCORE );dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); }
Signature · 1 line
2.25.1
Re: [PATCH v5 2/4] net/dpaa2: clear active VDQ state when freeing Rx queues
Hi Hemant,
Quoted 72 lines · Hemant Agrawal
From: Maxime Leroy <[email protected]>
When using the prefetch Rx path (
dpaa2_dev_prefetch_rx), the driver keeps track of one outstanding VDQCR command per DPIO portal in the global rte_global_active_dqs_list[] array. Eachqueue_storage_info_talso stores the active result buffer and portal index:
qs->active_dqs
qs->active_dpio_idBefore issuing a new pull command,
dpaa2_dev_prefetch_rx()checks for an active entry and spins onqbman_check_command_complete()until the corresponding VDQCR completes.On port close / hotplug remove,
dpaa2_free_rx_tx_queues()frees all per-lcorequeue_storage_info_tstructures and their dq_storage[] buffers, but never clears the global rte_global_active_dqs_list[] entries. After a detach/attach sequence (or "del/add" in grout), the prefetch Rx path still sees an active entry for the portal and spins forever on a stale dq buffer that has been freed and will never be completed by hardware. In gdb,dq->dq.tokstays 0 anddpaa2_dev_prefetch_rx()loops in:while (!qbman_check_command_complete(get_swp_active_dqs(idx)))
;Fix this by clearing the active VDQ state before freeing queue storage. For each Rx queue and lcore, if
qs->active_dqsis non-NULL, callclear_swp_active_dqs(qs->active_dpio_id)and setqs->active_dqsto NULL. Thendpaa2_queue_storage_free()can safely freeq_storageand dq_storage[].After this change, a DPNI detach/attach sequence no longer leaves stale entries in rte_global_active_dqs_list[], and the prefetch Rx loop does not hang waiting for a completion from a previous device instance.
Reproduction:
- grout:grcli interface add port dpni.1 devargs fslmc:dpni.1 grcli interface del dpni.1 grcli interface add port dpni.1 devargs fslmc:dpni.1 -> Rx was stuck in qbman_check_command_complete(), now works.- testpmd:
dpdk-testpmd -n1 -a fslmc:dpni.65535 -- -i --forward-mode=rxonly testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
testpmd> stop
testpmd> port stop all
testpmd> port detach 0
testpmd> port attach fslmc:dpni.1
testpmd> port start all
testpmd> start
-> Rx was hanging, now runs normalFixes 12d98eceb8ac ("bus/fslmc: enhance QBMAN DQ storage logic")Signed-off-by Maxime Leroy <[email protected]>Acked-by Hemant Agrawal <[email protected]>--- .mailmap | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-).mailmap +0
-0
.mailmap Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti · line 1038
Quoted 5 lines
.mailmap +1
-1@@ -1035,7 +1035,7 @@ Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti Mauro Annarumma <[email protected]> Maxime Coquelin <[email protected]> Maxime Gouin <[email protected]> -Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]>
The order is incorrect. My new email address is [email protected], and it should appear first in the list.
Thank you,
Maxime Leroy
RE: [PATCH v5 2/4] net/dpaa2: clear active VDQ state when freeing Rx queues
Quoted 6 lines
.mailmap Mauricio Vasquez B
Quoted 5 lines
.mailmap +0
-0@@ -1035,7 +1035,7 @@ Mauricio Vasquez B
Quoted 8 lines
Quoted 3 lines
<mauricio.vasquezbernal@studenti Mauro Annarumma
<[email protected]> Maxime Coquelin
<[email protected]> Maxime Gouin.mailmap Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti · line 1038
Quoted 2 lines
.mailmap +1
-1-Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]>The order is incorrect. My new email address is [email protected], and it should appear first in the list.
Hi @[email protected] will you please take care of it in merge, or I should send new version?
Regards
Hemant
Quoted 4 lines
Thank you,
Maxime Leroy
Re: [PATCH v5 2/4] net/dpaa2: clear active VDQ state when freeing Rx queues
Quoted 15 lines · On Mon, 17 Nov 2025 09:44:40 +0000 Hemant Agrawal <[email protected]>…
Quoted 6 lines
.mailmap Mauricio Vasquez B
Quoted 5 lines
.mailmap +0
-0@@ -1035,7 +1035,7 @@ Mauricio Vasquez BQuoted 8 lines
Quoted 3 lines
<mauricio.vasquezbernal@studenti Mauro Annarumma
<[email protected]> Maxime Coquelin
<[email protected]> Maxime Gouin.mailmap Mauricio Vasquez B <[email protected]> <mauricio.vasquezbernal@studenti · line 1038
Quoted 2 lines
.mailmap +1
-1-Maxime Leroy <[email protected]> +Maxime Leroy <[email protected]> <[email protected]>The order is incorrect. My new email address is [email protected], and it should appear first in the list.
Quoted 9 lines
Hi @[email protected] will you please take care of it in merge, or I should send new version?
Regards
HemantQuoted 4 lines
Thank you,
Maxime Leroy
Fixed the .mailmap and checkpatch warning about indentation when committing to next-net.
### [PATCH] net/dpaa2: clear active VDQ state when freeing Rx queues
WARNING:SUSPECT_CODE_INDENT: suspect code indent for conditional statements (24, 42) #99: FILE: drivers/net/dpaa2/dpaa2_ethdev.c:646:
+ while (!qbman_check_command_complete(qs->active_dqs))
+ /* wait */;
total: 0 errors, 1 warnings, 0 checks, 43 lines checked
PATCH v5 3/4 net/dpaa2: fix queue free cleanup
In reply to Hemant AgrawalThe RX error queue was not being free.
Also, set the free queues pointers to NULL.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +8 -0
@@ -670,11 +670,13 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) RTE_MAX_LCORE);dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->rx_vq[i] =NULL ; }/* cleanup tx queue cscn */ for (i =0 ; i < priv->nb_tx_queues; i++) { dpaa2_q = priv->tx_vq[i];rte_free (dpaa2_q->cscn); + priv->tx_vq[i] =NULL ; }if (priv->flags &DPAA2_TX_CONF_ENABLE ) {/* cleanup tx conf queue storage */
@@ -682,8 +684,14 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) dpaa2_q = priv->tx_conf_vq[i];dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + priv->tx_conf_vq[i] =NULL ; } } +if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { + dpaa2_q = priv->rx_err_vq; +dpaa2_queue_storage_free (dpaa2_q,RTE_MAX_LCORE ); + } +/*free memory for all queues (RX+TX) */ rte_free (priv->rx_vq[0 ]); priv->rx_vq[0 ] =NULL ;
Signature · 1 line
2.25.1
PATCH v5 4/4 bus/fslmc: add support for hotplug of dpni
In reply to Hemant AgrawalThis patch implements the plug and unplug function to support attach/detach of dpni interfaces.
--- drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +50 -6
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void) }static int -fslmc_bus_plug(struct rte_device *dev __rte_unused) +fslmc_bus_plug (struct rte_device *rte_dev) { -/* No operation is performed while plugging the device */ -return 0 ; +int ret =0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv; + + TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) { + ret =rte_fslmc_match (drv, dev); +if (ret) +continue ; + +if (!drv->probe) +continue ; + +if (rte_dev_is_probed (&dev->device)) +continue ; + +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , + dev->device.name); +continue ; + } + + ret = drv->probe (drv, dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to probe" ); + }else { + dev->driver = drv; + dev->device.driver = &drv->driver; +DPAA2_BUS_INFO ("%s Plugged" , dev->device.name); + } +break ; + } + +return ret; }static int -fslmc_bus_unplug(struct rte_device *dev __rte_unused) +fslmc_bus_unplug (struct rte_device *rte_dev) { -/* No operation is performed while unplugging the device */ -return 0 ; +struct rte_dpaa2_device *dev =container_of (rte_dev, + struct rte_dpaa2_device, device); +struct rte_dpaa2_driver *drv = dev->driver; + +if (drv && drv->remove) { + drv->remove (dev); + dev->driver =NULL ; + dev->device.driver =NULL ; +DPAA2_BUS_INFO ("%s Un-Plugged" , dev->device.name); +return 0 ; + } + +return -ENODEV ; } static void *
Signature · 1 line
2.25.1
Hi Stephen and Hemant,
It would be great if this series could be merged for rc3. I’ve tested it successfully with Grout on my side, and it allows us to support the DPAA2 Ethernet driver without any ugly workarounds. I’ve also reviewed all the patches, and everything looks good with no major risks.
Regards,
Maxime Leroy
Le ven. 14 nov. 2025, 07:25, Hemant Agrawal <[email protected]> a écrit :
Quoted 59 lines
When
rte_eth_dev_close()is called, it performs the following actions:Calls
dev->dev_ops->dev_close(), which in this case isdpaa2_dev_close(). Then callsrte_eth_dev_release_port(), which releases all device data and setsdev->datato NULL.Later, when
rte_dev_remove()is called, the FSLMC bus invokesdev->remove()— that is,rte_dpaa2_remove().
However,rte_dpaa2_remove()callsdpaa2_dev_close()again. Sincedev->datawas already set to NULL by the previous call, this second invocation causes a crash.Signed-off-by Hemant Agrawal <[email protected]>Tested-by Maxime Leroy <[email protected]>--- drivers/net/dpaa2/dpaa2_ethdev.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)drivers/net/dpaa2/dpaa2_ethdev.c +13
-6@@ -3347,14 +3347,22 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) {struct rte_eth_dev *eth_dev; -int ret; +int ret =0 ; + + eth_dev =rte_eth_dev_allocated (dpaa2_dev->device.name); +if (eth_dev) { + ret =dpaa2_dev_close (eth_dev); +if (ret) +DPAA2_PMD_ERR ("dpaa2_dev_close ret= %d" , ret); + + ret =rte_eth_dev_release_port (eth_dev); + } - eth_dev = dpaa2_dev->eth_dev; -dpaa2_dev_close (eth_dev); dpaa2_valid_dev--; -if (!dpaa2_valid_dev) +if (!dpaa2_valid_dev) {rte_mempool_free (dpaa2_tx_sg_pool); - ret =rte_eth_dev_release_port (eth_dev); + dpaa2_tx_sg_pool =NULL ; + }return ret; } --2.25.1
Quoted 6 lines · On Fri, 14 Nov 2025 17:53:38 +0100 Maxime Leroy <[email protected]> wrote:
Hi Stephen and Hemant,
It would be great if this series could be merged for rc3. I’ve tested it successfully with Grout on my side, and it allows us to support the DPAA2 Ethernet driver without any ugly workarounds. I’ve also reviewed all the patches, and everything looks good with no major risks.
Just waiting for discussion to settle out.