[v10,14/19] net/pcap: enable hotplug on secondary process
Checks
Commit Message
Attach port from secondary should ignore devargs since the private
device is not necessary to support. Also previously, detach port on
a secondary process will mess primary process and cause the same
device can't be attached back again. A secondary process should use
rte_eth_release_port_private to release a port.
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/net/pcap/rte_eth_pcap.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
@@ -916,8 +916,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
start_cycles = rte_get_timer_cycles();
hz = rte_get_timer_hz();
- if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
- strlen(rte_vdev_device_args(dev)) == 0) {
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
eth_dev = rte_eth_dev_attach_secondary(name);
if (!eth_dev) {
PMD_LOG(ERR, "Failed to probe %s", name);
@@ -925,6 +924,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
}
/* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &ops;
+ eth_dev->device = &dev->device;
rte_eth_dev_probing_finish(eth_dev);
return 0;
}
@@ -1016,6 +1016,7 @@ static int
pmd_pcap_remove(struct rte_vdev_device *dev)
{
struct rte_eth_dev *eth_dev = NULL;
+ const char *name;
PMD_LOG(INFO, "Closing pcap ethdev on numa socket %d",
rte_socket_id());
@@ -1023,11 +1024,15 @@ pmd_pcap_remove(struct rte_vdev_device *dev)
if (!dev)
return -1;
+ name = rte_vdev_device_name(dev);
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
+ eth_dev = rte_eth_dev_allocated(name);
if (eth_dev == NULL)
return -1;
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return rte_eth_dev_release_port_private(eth_dev);
+
rte_free(eth_dev->data->dev_private);
rte_eth_dev_release_port(eth_dev);