From: Sachin Saxena Date: Mon, 28 Sep 2020 23:14:16 +0000 (+0200) Subject: net/dpaa: release port upon close X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2defb1143842f30b6f6d6329241a82009d2ae7a4;p=dpdk.git net/dpaa: release port upon close With removal of old close behavior, the private port resources must be released in the .dev_close callback. Freeing of port private resources is moved from the ".remove(device)" to the ".dev_close(port)" operation Signed-off-by: Sachin Saxena Acked-by: Hemant Agrawal Acked-by: Stephen Hemminger --- diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 7fe06e1830..8f986683e2 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -376,9 +376,25 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) struct rte_device *rdev = dev->device; struct rte_dpaa_device *dpaa_dev; struct rte_intr_handle *intr_handle; + struct dpaa_if *dpaa_intf = dev->data->dev_private; + int loop; PMD_INIT_FUNC_TRACE(); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + if (!dpaa_intf) { + DPAA_PMD_WARN("Already closed or not started"); + return -1; + } + + /* DPAA FM deconfig */ + if (!(default_q || fmc_q)) { + if (dpaa_fm_deconfig(dpaa_intf, dev->process_private)) + DPAA_PMD_WARN("DPAA FM deconfig failed\n"); + } + dpaa_dev = container_of(rdev, struct rte_dpaa_device, device); intr_handle = &dpaa_dev->intr_handle; __fif = container_of(fif, struct __fman_if, __if); @@ -393,6 +409,42 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev) (void *)dev); } + /* release configuration memory */ + if (dpaa_intf->fc_conf) + rte_free(dpaa_intf->fc_conf); + + /* Release RX congestion Groups */ + if (dpaa_intf->cgr_rx) { + for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++) + qman_delete_cgr(&dpaa_intf->cgr_rx[loop]); + + qman_release_cgrid_range(dpaa_intf->cgr_rx[loop].cgrid, + dpaa_intf->nb_rx_queues); + } + + rte_free(dpaa_intf->cgr_rx); + dpaa_intf->cgr_rx = NULL; + /* Release TX congestion Groups */ + if (dpaa_intf->cgr_tx) { + for (loop = 0; loop < MAX_DPAA_CORES; loop++) + qman_delete_cgr(&dpaa_intf->cgr_tx[loop]); + + qman_release_cgrid_range(dpaa_intf->cgr_tx[loop].cgrid, + MAX_DPAA_CORES); + rte_free(dpaa_intf->cgr_tx); + dpaa_intf->cgr_tx = NULL; + } + + rte_free(dpaa_intf->rx_queues); + dpaa_intf->rx_queues = NULL; + + rte_free(dpaa_intf->tx_queues); + dpaa_intf->tx_queues = NULL; + + dev->dev_ops = NULL; + dev->rx_pkt_burst = NULL; + dev->tx_pkt_burst = NULL; + return 0; } @@ -1977,70 +2029,6 @@ free_rx: return ret; } -static int -dpaa_dev_uninit(struct rte_eth_dev *dev) -{ - struct dpaa_if *dpaa_intf = dev->data->dev_private; - int loop; - - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return -EPERM; - - if (!dpaa_intf) { - DPAA_PMD_WARN("Already closed or not started"); - return -1; - } - - /* DPAA FM deconfig */ - if (!(default_q || fmc_q)) { - if (dpaa_fm_deconfig(dpaa_intf, dev->process_private)) - DPAA_PMD_WARN("DPAA FM deconfig failed\n"); - } - - dpaa_eth_dev_close(dev); - - /* release configuration memory */ - if (dpaa_intf->fc_conf) - rte_free(dpaa_intf->fc_conf); - - /* Release RX congestion Groups */ - if (dpaa_intf->cgr_rx) { - for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++) - qman_delete_cgr(&dpaa_intf->cgr_rx[loop]); - - qman_release_cgrid_range(dpaa_intf->cgr_rx[loop].cgrid, - dpaa_intf->nb_rx_queues); - } - - rte_free(dpaa_intf->cgr_rx); - dpaa_intf->cgr_rx = NULL; - - /* Release TX congestion Groups */ - if (dpaa_intf->cgr_tx) { - for (loop = 0; loop < MAX_DPAA_CORES; loop++) - qman_delete_cgr(&dpaa_intf->cgr_tx[loop]); - - qman_release_cgrid_range(dpaa_intf->cgr_tx[loop].cgrid, - MAX_DPAA_CORES); - rte_free(dpaa_intf->cgr_tx); - dpaa_intf->cgr_tx = NULL; - } - - rte_free(dpaa_intf->rx_queues); - dpaa_intf->rx_queues = NULL; - - rte_free(dpaa_intf->tx_queues); - dpaa_intf->tx_queues = NULL; - - dev->dev_ops = NULL; - dev->rx_pkt_burst = NULL; - dev->tx_pkt_burst = NULL; - - return 0; -} - static int rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, struct rte_dpaa_device *dpaa_dev) @@ -2139,6 +2127,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, qman_ern_register_cb(dpaa_free_mbuf); + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; if (dpaa_drv->drv_flags & RTE_DPAA_DRV_INTR_LSC) eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; @@ -2157,15 +2146,15 @@ static int rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev) { struct rte_eth_dev *eth_dev; + int ret; PMD_INIT_FUNC_TRACE(); eth_dev = dpaa_dev->eth_dev; - dpaa_dev_uninit(eth_dev); + dpaa_eth_dev_close(eth_dev); + ret = rte_eth_dev_release_port(eth_dev); - rte_eth_dev_release_port(eth_dev); - - return 0; + return ret; } static void __attribute__((destructor(102))) dpaa_finish(void)