diff mbox series

[ovs-dev] netdev-dpdk: Update device attach status if success.

Message ID 20250508035027.485361-1-changliang.wu@smartx.com
State New
Delegated to: Kevin Traynor
Headers show
Series [ovs-dev] netdev-dpdk: Update device attach status if success. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/cirrus-robot success cirrus build: passed
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Changliang Wu May 8, 2025, 3:50 a.m. UTC
The ovs op hangs when performing:
1. Create a DPDK bridge (datapath_type=netdev) with bind-ed DPDK port
2. Restart OVS service (systemctl restart openvswitch)
3. Delete the bridge (ovs-vsctl del-br)
4. Recreate bridge and re-add DPDK port

Root cause:
During OVS service restart, ovs-vswitchd reloads all ports from OVSDB via:
dpdk_init() -> dpdk_init__() -> rte_eal_init() -> ... -> rte_eth_dev_probing_finish()
This leaves port in DPDK's global rte_eth_devices array with dev->state=RTE_ETH_DEV_ATTACHED

When recreating port:
netdev_dpdk_process_devargs() calls rte_eth_dev_is_valid_port(port_id)
Since port_id is valid, skips rte_dev_probe() and does not set netdev->attached=true

During bridge/port deletion:
netdev_dpdk_destruct() checks if(dev->attached)
and fail to execute cleanup logic for attached devices
Leave a device in rte_eth_devices with RTE_ETH_DEV_ATTACHED

Subsequent port addition:
rte_eth_dev_is_valid_port() still returns true,
critical PCI initialization (rte_dev_probe()) was skip,
the following configurations hang due to uninitialized device state

Fix implementation:
Modify netdev_dpdk_process_devargs() to set netdev->attached=true explicitly,
when port_id is not DPDK_ETH_PORT_ID_INVALID.

Signed-off-by: Changliang Wu <changliang.wu@smartx.com>
---
 lib/netdev-dpdk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e2708a8a5..a551b204e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2129,7 +2129,6 @@  netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
                 new_port_id = netdev_dpdk_get_port_by_devargs(devargs);
                 if (rte_eth_dev_is_valid_port(new_port_id)) {
                     /* Attach successful */
-                    dev->attached = true;
                     VLOG_INFO("Device '%s' attached to DPDK", devargs);
                 } else {
                     /* Attach unsuccessful */
@@ -2141,6 +2140,8 @@  netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
 
     if (new_port_id == DPDK_ETH_PORT_ID_INVALID) {
         VLOG_WARN_BUF(errp, "Error attaching device '%s' to DPDK", devargs);
+    } else {
+        dev->attached = true;
     }
 
     return new_port_id;