From: Thomas Monjalon Date: Mon, 28 Sep 2020 23:14:27 +0000 (+0200) Subject: net/softnic: release port upon close X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1d6766580775ee02bb2efcc9f5f49d1194c37811;p=dpdk.git net/softnic: release port upon close The flag RTE_ETH_DEV_CLOSE_REMOVE is set so all port resources can be freed by rte_eth_dev_close(). Freeing of private port resources is moved from the ".remove(device)" to the ".dev_close(port)" operation. Nothing is closed in a secondary process. Signed-off-by: Thomas Monjalon Acked-by: Cristian Dumitrescu Acked-by: Stephen Hemminger --- diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 038abd98da..ad9e2aa86d 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -201,9 +201,40 @@ pmd_dev_stop(struct rte_eth_dev *dev) softnic_mtr_free(p); } +static void +pmd_free(struct pmd_internals *p) +{ + if (p == NULL) + return; + + if (p->params.conn_port) + softnic_conn_free(p->conn); + + softnic_thread_free(p); + softnic_pipeline_free(p); + softnic_table_action_profile_free(p); + softnic_port_in_action_profile_free(p); + softnic_tap_free(p); + softnic_tmgr_free(p); + softnic_link_free(p); + softnic_swq_free(p); + softnic_mempool_free(p); + + tm_hierarchy_free(p); + softnic_mtr_free(p); + + rte_free(p); +} + static int -pmd_dev_close(struct rte_eth_dev *dev __rte_unused) +pmd_dev_close(struct rte_eth_dev *dev) { + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + pmd_free(dev->data->dev_private); + dev->data->dev_private = NULL; /* already freed */ + dev->data->mac_addrs = NULL; /* statically allocated */ return 0; } @@ -335,31 +366,6 @@ pmd_init(struct pmd_params *params) return p; } -static void -pmd_free(struct pmd_internals *p) -{ - if (p == NULL) - return; - - if (p->params.conn_port) - softnic_conn_free(p->conn); - - softnic_thread_free(p); - softnic_pipeline_free(p); - softnic_table_action_profile_free(p); - softnic_port_in_action_profile_free(p); - softnic_tap_free(p); - softnic_tmgr_free(p); - softnic_link_free(p); - softnic_swq_free(p); - softnic_mempool_free(p); - - tm_hierarchy_free(p); - softnic_mtr_free(p); - - rte_free(p); -} - static struct rte_ether_addr eth_addr = { .addr_bytes = {0}, }; @@ -384,6 +390,7 @@ pmd_ethdev_register(struct rte_vdev_device *vdev, dev->device = &vdev->device; /* dev->data */ + dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; dev->data->dev_private = dev_private; dev->data->dev_link.link_speed = ETH_SPEED_NUM_100G; dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX; @@ -652,12 +659,9 @@ pmd_remove(struct rte_vdev_device *vdev) /* Find the ethdev entry */ dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev)); if (dev == NULL) - return -ENODEV; + return 0; /* port already released */ - /* Free device data structures*/ - pmd_free(dev->data->dev_private); - dev->data->dev_private = NULL; /* already freed */ - dev->data->mac_addrs = NULL; /* statically allocated */ + pmd_dev_close(dev); rte_eth_dev_release_port(dev); return 0;