port_flow_flush(portid_t port_id)
{
struct rte_flow_error error;
- struct rte_port *port;
+ struct rte_port *port = &ports[port_id];
int ret = 0;
+ if (port->flow_list == NULL)
+ return ret;
+
/* Poisoning to make sure PMDs update it in case of error. */
memset(&error, 0x44, sizeof(error));
if (rte_flow_flush(port_id, &error)) {
port_id == (portid_t)RTE_PORT_ALL)
return ret;
}
- port = &ports[port_id];
+
while (port->flow_list) {
struct port_flow *pf = port->flow_list->next;
continue;
}
- if (port->flow_list)
- port_flow_flush(pi);
+ port_flow_flush(pi);
rte_eth_dev_close(pi);
}
printf("Removing a device...\n");
- if (rte_dev_remove(dev) < 0) {
- TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name);
- return;
- }
RTE_ETH_FOREACH_DEV_OF(sibling, dev) {
if (ports[sibling].port_status != RTE_PORT_CLOSED) {
+ if (ports[sibling].port_status != RTE_PORT_STOPPED) {
+ printf("Port %u not stopped\n", sibling);
+ return;
+ }
+ port_flow_flush(sibling);
}
}
+ if (rte_dev_remove(dev) < 0) {
+ TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name);
+ return;
+ }
remove_invalid_ports();
printf("Device is detached\n");
return;
}
printf("Port was not closed\n");
- if (ports[port_id].flow_list)
- port_flow_flush(port_id);
}
detach_device(rte_eth_devices[port_id].device);
rte_eth_iterator_cleanup(&iterator);
return;
}
-
- if (ports[port_id].flow_list)
- port_flow_flush(port_id);
+ port_flow_flush(port_id);
}
}