From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 236A51150 for ; Mon, 15 Oct 2018 01:20:36 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B1CEC21EAB; Sun, 14 Oct 2018 19:20:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 19:20:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=3Mn2nmxYHL ZZ95ltvsKYSc1M7jhDiqG+FlGydjprkkc=; b=eVF1LtuVvHEY5FtVDLDrh+WuFX a+hqbStP33n66iHZa6WNfNV/EEAt8kRhVEcm2PTyzmm7Q7/QHaGI6lhzLCZ9jIB2 toaU7EHEy3BiHxecGgBKKpQOW+E8vZUYMZpz4RLX4gab+eAmF0s0Hgt8JQSiLA8a s5etar1tTF3DePZtg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=3Mn2nmxYHLZZ95ltvsKYSc1M7jhDiqG+FlGydjprkkc=; b=hA+Mj9rI k5ukAjl4RHJ4/NW4hsV1Ey9SfXcCvjQFEvRuXNjqO5+4wSPx/rFkHuM4gAXNJZk2 5yYsCN9F1oMFdRSBi4U1639JprOLyEnSyhIDa+zBszoIUh0BeV0Exi98XSY+1ZTl UCN02UMilOIKpoG3hTAFUoN5ZA6yKJ7AzQlOS9TdvzkmAFPCQhUOPHpIrdRx3/uD z+kji2w/sJegVsZgp6JR3Yd/qx1yxhO+tpJah073UG2Eaddg+CFM39FLrLho1f4k 3Cb08l6Ts+wrJy5+araJk0C4IMIMPCveOPb9MuhdMJ6UM5VDiWtel/u5DXCdN39l DAejGLG8VU6ktA== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 81B3CE4532; Sun, 14 Oct 2018 19:20:34 -0400 (EDT) From: Thomas Monjalon To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, ophirmu@mellanox.com Date: Mon, 15 Oct 2018 01:20:19 +0200 Message-Id: <20181014232020.12114-2-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014232020.12114-1-thomas@monjalon.net> References: <20180907233929.21950-1-thomas@monjalon.net> <20181014232020.12114-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/2] ethdev: free all common data when releasing port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Oct 2018 23:20:36 -0000 This is a clean-up of common ethdev data freeing. All data freeing are moved to rte_eth_dev_release_port() and done only in case of primary process. It is probably fixing some memory leaks for PMDs which were not freeing all data. Signed-off-by: Thomas Monjalon --- drivers/net/af_packet/rte_eth_af_packet.c | 2 -- drivers/net/ark/ark_ethdev.c | 1 - drivers/net/avf/avf_ethdev.c | 3 --- drivers/net/avp/avp_ethdev.c | 5 ---- drivers/net/axgbe/axgbe_ethdev.c | 3 --- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/bonding/rte_eth_bond_pmd.c | 7 +----- drivers/net/cxgbe/cxgbe_main.c | 16 ++----------- drivers/net/cxgbe/cxgbevf_main.c | 9 +------ drivers/net/dpaa/dpaa_ethdev.c | 10 -------- drivers/net/dpaa2/dpaa2_ethdev.c | 10 -------- drivers/net/e1000/em_ethdev.c | 3 --- drivers/net/e1000/igb_ethdev.c | 6 ----- drivers/net/enetc/enetc_ethdev.c | 4 +--- drivers/net/failsafe/failsafe.c | 3 --- drivers/net/fm10k/fm10k_ethdev.c | 8 ------- drivers/net/i40e/i40e_ethdev.c | 3 --- drivers/net/i40e/i40e_ethdev_vf.c | 3 --- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ------- drivers/net/kni/rte_eth_kni.c | 2 -- drivers/net/liquidio/lio_ethdev.c | 3 --- drivers/net/mlx4/mlx4.c | 3 +-- drivers/net/mlx5/mlx5.c | 5 +--- drivers/net/mvneta/mvneta_ethdev.c | 16 ++++--------- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++++--------- drivers/net/netvsc/hn_ethdev.c | 11 --------- drivers/net/null/rte_eth_null.c | 2 -- drivers/net/octeontx/octeontx_ethdev.c | 29 +++++++++-------------- drivers/net/pcap/rte_eth_pcap.c | 7 ------ drivers/net/qede/qede_ethdev.c | 5 ---- drivers/net/ring/rte_eth_ring.c | 4 ---- drivers/net/sfc/sfc_ethdev.c | 3 --- drivers/net/softnic/rte_eth_softnic.c | 6 ++--- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 1 - drivers/net/vhost/rte_eth_vhost.c | 9 +++---- drivers/net/virtio/virtio_ethdev.c | 3 --- drivers/net/virtio/virtio_user_ethdev.c | 3 --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 23 ++++++++---------- lib/librte_ethdev/rte_ethdev_pci.h | 11 --------- 41 files changed, 43 insertions(+), 232 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index bc7daed5e..74073ecf6 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -994,8 +994,6 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) } free(internals->if_name); - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 552ca01a6..70d62ec7f 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -506,7 +506,6 @@ eth_ark_dev_uninit(struct rte_eth_dev *dev) dev->dev_ops = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; - rte_free(dev->data->mac_addrs); return 0; } diff --git a/drivers/net/avf/avf_ethdev.c b/drivers/net/avf/avf_ethdev.c index e56d57c43..13eec1b45 100644 --- a/drivers/net/avf/avf_ethdev.c +++ b/drivers/net/avf/avf_ethdev.c @@ -1303,9 +1303,6 @@ avf_dev_uninit(struct rte_eth_dev *dev) rte_free(vf->aq_resp); vf->aq_resp = NULL; - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - if (vf->rss_lut) { rte_free(vf->rss_lut); vf->rss_lut = NULL; diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index 0f8ccb954..09388d05f 100644 --- a/drivers/net/avp/avp_ethdev.c +++ b/drivers/net/avp/avp_ethdev.c @@ -1036,11 +1036,6 @@ eth_avp_dev_uninit(struct rte_eth_dev *eth_dev) return ret; } - if (eth_dev->data->mac_addrs != NULL) { - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - } - return 0; } diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 4b84b50c0..e89c0ec2c 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -718,9 +718,6 @@ eth_axgbe_dev_uninit(struct rte_eth_dev *eth_dev) return 0; pci_dev = RTE_DEV_TO_PCI(eth_dev->device); - /*Free macaddres*/ - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 858e65d00..ff41cb0fa 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3501,10 +3501,6 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) bnxt_disable_int(bp); bnxt_free_int(bp); bnxt_free_mem(bp); - if (eth_dev->data->mac_addrs != NULL) { - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - } if (bp->grp_info != NULL) { rte_free(bp->grp_info); bp->grp_info = NULL; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 31c83a286..73da41862 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -3128,10 +3128,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode) err: rte_free(internals); - if (eth_dev != NULL) { - rte_free(eth_dev->data->mac_addrs); - rte_eth_dev_release_port(eth_dev); - } + rte_eth_dev_release_port(eth_dev); return -1; } @@ -3290,8 +3287,6 @@ bond_remove(struct rte_vdev_device *dev) rte_mempool_free(internals->mode6.mempool); rte_bitmap_free(internals->vlan_filter_bmp); rte_free(internals->vlan_filter_bmpmem); - rte_free(eth_dev->data->dev_private); - rte_free(eth_dev->data->mac_addrs); rte_eth_dev_release_port(eth_dev); diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index a135df9c7..88dc851f8 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1710,12 +1710,7 @@ void cxgbe_close(struct adapter *adapter) if (pi->viid != 0) t4_free_vi(adapter, adapter->mbox, adapter->pf, 0, pi->viid); - rte_free(pi->eth_dev->data->mac_addrs); - /* Skip first port since it'll be freed by DPDK stack */ - if (i) { - rte_free(pi->eth_dev->data->dev_private); - rte_eth_dev_release_port(pi->eth_dev); - } + rte_eth_dev_release_port(pi->eth_dev); } adapter->flags &= ~FULL_INIT_DONE; } @@ -1918,14 +1913,7 @@ int cxgbe_probe(struct adapter *adapter) if (pi->viid != 0) t4_free_vi(adapter, adapter->mbox, adapter->pf, 0, pi->viid); - /* Skip first port since it'll be de-allocated by DPDK */ - if (i == 0) - continue; - if (pi->eth_dev) { - if (pi->eth_dev->data->dev_private) - rte_free(pi->eth_dev->data->dev_private); - rte_eth_dev_release_port(pi->eth_dev); - } + rte_eth_dev_release_port(pi->eth_dev); } if (adapter->flags & FW_OK) diff --git a/drivers/net/cxgbe/cxgbevf_main.c b/drivers/net/cxgbe/cxgbevf_main.c index 4214d0312..6223e1250 100644 --- a/drivers/net/cxgbe/cxgbevf_main.c +++ b/drivers/net/cxgbe/cxgbevf_main.c @@ -282,14 +282,7 @@ int cxgbevf_probe(struct adapter *adapter) if (pi->viid != 0) t4_free_vi(adapter, adapter->mbox, adapter->pf, 0, pi->viid); - /* Skip first port since it'll be de-allocated by DPDK */ - if (i == 0) - continue; - if (pi->eth_dev) { - if (pi->eth_dev->data->dev_private) - rte_free(pi->eth_dev->data->dev_private); - rte_eth_dev_release_port(pi->eth_dev); - } + rte_eth_dev_release_port(pi->eth_dev); } return -err; } diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 5c743c3c8..d0572b3d9 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1439,10 +1439,6 @@ dpaa_dev_uninit(struct rte_eth_dev *dev) rte_free(dpaa_intf->tx_queues); dpaa_intf->tx_queues = NULL; - /* free memory for storing MAC addresses */ - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - dev->dev_ops = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; @@ -1544,9 +1540,6 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, return 0; } - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return diag; } @@ -1561,9 +1554,6 @@ rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev) eth_dev = dpaa_dev->eth_dev; dpaa_dev_uninit(eth_dev); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 880034fcf..3c986ea19 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1953,12 +1953,6 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev) priv->rx_vq[0] = NULL; } - /* free memory for storing MAC addresses */ - if (eth_dev->data->mac_addrs) { - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - } - /* Close the device at underlying layer*/ ret = dpni_close(dpni, CMD_PRI_LOW, priv->token); if (ret) { @@ -2021,8 +2015,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv, return 0; } - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); return diag; } @@ -2035,8 +2027,6 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) eth_dev = dpaa2_dev->eth_dev; dpaa2_dev_uninit(eth_dev); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index 28c153512..8230824e7 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -329,9 +329,6 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - /* disable uio intr before callback unregister */ rte_intr_disable(intr_handle); rte_intr_callback_unregister(intr_handle, diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index e542ef572..d9d29d22f 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -917,9 +917,6 @@ eth_igb_dev_uninit(struct rte_eth_dev *eth_dev) /* Reset any pending lock */ igb_reset_swfw_lock(hw); - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - /* uninitialize PF if max_vfs not zero */ igb_pf_host_uninit(eth_dev); @@ -1073,9 +1070,6 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - /* disable uio intr before callback unregister */ rte_intr_disable(&pci_dev->intr_handle); rte_intr_callback_unregister(&pci_dev->intr_handle, diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 3ee7bb446..023fe7517 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -108,11 +108,9 @@ enetc_dev_init(struct rte_eth_dev *eth_dev) } static int -enetc_dev_uninit(struct rte_eth_dev *eth_dev) +enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) { PMD_INIT_FUNC_TRACE(); - rte_free(eth_dev->data->mac_addrs); - return 0; } diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index c3999f026..04c9f1f71 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -280,7 +280,6 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) free_subs: fs_sub_device_free(dev); free_dev: - rte_free(PRIV(dev)); rte_eth_dev_release_port(dev); return -1; } @@ -304,8 +303,6 @@ fs_rte_eth_free(const char *name) ret = pthread_mutex_destroy(&PRIV(dev)->hotplug_mutex); if (ret) ERROR("Error while destroying hotplug mutex"); - rte_free(PRIV(dev)->mcast_addrs); - rte_free(PRIV(dev)); rte_eth_dev_release_port(dev); return ret; } diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 46983e5df..bb7b906a9 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -3234,14 +3234,6 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev) fm10k_dev_interrupt_handler_vf, (void *)dev); } - /* free mac memory */ - if (dev->data->mac_addrs) { - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - } - - memset(hw, 0, sizeof(*hw)); - return 0; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index f7a685c8c..8a5c3c8fb 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1728,9 +1728,6 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev) /* uninitialize pf host driver */ i40e_pf_host_uninit(dev); - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - /* disable uio intr before callback unregister */ rte_intr_disable(intr_handle); diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index baa6cc58f..ed2fc1310 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1483,9 +1483,6 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev) return -1; } - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - return 0; } diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c458bffc0..269595b73 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1337,12 +1337,6 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) /* uninitialize PF if max_vfs not zero */ ixgbe_pf_host_uninit(eth_dev); - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - - rte_free(eth_dev->data->hash_mac_addrs); - eth_dev->data->hash_mac_addrs = NULL; - /* remove all the fdir filters & hash */ ixgbe_fdir_filter_uninit(eth_dev); @@ -1722,9 +1716,6 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev) /* Disable the interrupts for VF */ ixgbevf_intr_disable(eth_dev); - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - rte_intr_disable(intr_handle); rte_intr_callback_unregister(intr_handle, ixgbevf_dev_interrupt_handler, eth_dev); diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 8a7015a0b..af395ac17 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -469,8 +469,6 @@ eth_kni_remove(struct rte_vdev_device *vdev) internals = eth_dev->data->dev_private; rte_kni_release(internals->kni); - rte_free(internals); - rte_eth_dev_release_port(eth_dev); is_kni_initialized--; diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 93e89007a..6755585d9 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -2043,9 +2043,6 @@ lio_eth_dev_uninit(struct rte_eth_dev *eth_dev) /* lio_free_sc_buffer_pool */ lio_free_sc_buffer_pool(lio_dev); - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 3de7bc53e..857b43fd8 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -785,8 +785,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) claim_zero(mlx4_glue->dealloc_pd(pd)); if (ctx) claim_zero(mlx4_glue->close_device(ctx)); - if (eth_dev) - rte_eth_dev_release_port(eth_dev); + rte_eth_dev_release_port(eth_dev); break; } /* diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 8cbfee1ba..3c5cf78e4 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1226,8 +1226,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } if (pd) claim_zero(mlx5_glue->dealloc_pd(pd)); - if (eth_dev) - rte_eth_dev_release_port(eth_dev); + rte_eth_dev_release_port(eth_dev); if (ctx) claim_zero(mlx5_glue->close_device(ctx)); assert(err > 0); @@ -1447,8 +1446,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (!list[i].eth_dev) continue; mlx5_dev_close(list[i].eth_dev); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(list[i].eth_dev->data->dev_private); claim_zero(rte_eth_dev_release_port(list[i].eth_dev)); } /* Restore original error. */ diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index f7071bc2e..2d7666454 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -787,8 +787,9 @@ mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) priv = rte_zmalloc_socket(name, sizeof(*priv), 0, rte_socket_id()); if (!priv) { ret = -ENOMEM; - goto out_free_dev; + goto out_free; } + eth_dev->data->dev_private = priv; eth_dev->data->mac_addrs = rte_zmalloc("mac_addrs", @@ -796,20 +797,19 @@ mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) if (!eth_dev->data->mac_addrs) { MVNETA_LOG(ERR, "Failed to allocate space for eth addrs"); ret = -ENOMEM; - goto out_free_priv; + goto out_free; } memset(&req, 0, sizeof(req)); strcpy(req.ifr_name, name); ret = ioctl(fd, SIOCGIFHWADDR, &req); if (ret) - goto out_free_mac; + goto out_free; memcpy(eth_dev->data->mac_addrs[0].addr_bytes, req.ifr_addr.sa_data, ETHER_ADDR_LEN); eth_dev->data->kdrv = RTE_KDRV_NONE; - eth_dev->data->dev_private = priv; eth_dev->device = &vdev->device; eth_dev->rx_pkt_burst = mvneta_rx_pkt_burst; mvneta_set_tx_function(eth_dev); @@ -817,11 +817,7 @@ mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) rte_eth_dev_probing_finish(eth_dev); return 0; -out_free_mac: - rte_free(eth_dev->data->mac_addrs); -out_free_priv: - rte_free(priv); -out_free_dev: +out_free: rte_eth_dev_release_port(eth_dev); return ret; @@ -836,8 +832,6 @@ mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) static void mvneta_eth_dev_destroy(struct rte_eth_dev *eth_dev) { - rte_free(eth_dev->data->dev_private); - rte_free(eth_dev->data->mac_addrs); rte_eth_dev_release_port(eth_dev); } diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 0682c635a..ab4c14e51 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -2780,8 +2780,9 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) priv = mrvl_priv_create(name); if (!priv) { ret = -ENOMEM; - goto out_free_dev; + goto out_free; } + eth_dev->data->dev_private = priv; eth_dev->data->mac_addrs = rte_zmalloc("mac_addrs", @@ -2789,20 +2790,19 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) if (!eth_dev->data->mac_addrs) { MRVL_LOG(ERR, "Failed to allocate space for eth addrs"); ret = -ENOMEM; - goto out_free_priv; + goto out_free; } memset(&req, 0, sizeof(req)); strcpy(req.ifr_name, name); ret = ioctl(fd, SIOCGIFHWADDR, &req); if (ret) - goto out_free_mac; + goto out_free; memcpy(eth_dev->data->mac_addrs[0].addr_bytes, req.ifr_addr.sa_data, ETHER_ADDR_LEN); eth_dev->data->kdrv = RTE_KDRV_NONE; - eth_dev->data->dev_private = priv; eth_dev->device = &vdev->device; eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst; mrvl_set_tx_function(eth_dev); @@ -2810,12 +2810,8 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) rte_eth_dev_probing_finish(eth_dev); return 0; -out_free_mac: - rte_free(eth_dev->data->mac_addrs); -out_free_dev: +out_free: rte_eth_dev_release_port(eth_dev); -out_free_priv: - rte_free(priv); return ret; } @@ -2839,8 +2835,6 @@ mrvl_eth_dev_destroy(const char *name) priv = eth_dev->data->dev_private; pp2_bpool_deinit(priv->bpool); used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit); - rte_free(priv); - rte_free(eth_dev->data->mac_addrs); rte_eth_dev_release_port(eth_dev); } diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 8e728d639..323bc1262 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -121,17 +121,6 @@ eth_dev_vmbus_release(struct rte_eth_dev *eth_dev) /* free ether device */ rte_eth_dev_release_port(eth_dev); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); - - eth_dev->data->dev_private = NULL; - - /* - * Secondary process will check the name to attach. - * Clear this field to avoid attaching a released ports. - */ - eth_dev->data->name[0] = '\0'; - eth_dev->device = NULL; eth_dev->intr_handle = NULL; } diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index de10b5bdf..3c51810ff 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -680,8 +680,6 @@ rte_pmd_null_remove(struct rte_vdev_device *dev) if (eth_dev == NULL) return -1; - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 71843c63a..e0619296f 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -1015,12 +1015,22 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, return 0; } + /* Reserve an ethdev entry */ + eth_dev = rte_eth_dev_allocate(octtx_name); + if (eth_dev == NULL) { + octeontx_log_err("failed to allocate rte_eth_dev"); + res = -ENOMEM; + goto err; + } + data = eth_dev->data; + nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id); if (nic == NULL) { octeontx_log_err("failed to allocate nic structure"); res = -ENOMEM; goto err; } + data->dev_private = nic; nic->port_id = port; nic->evdev = evdev; @@ -1037,21 +1047,11 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, goto err; } - /* Reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocate(octtx_name); - if (eth_dev == NULL) { - octeontx_log_err("failed to allocate rte_eth_dev"); - res = -ENOMEM; - goto err; - } - eth_dev->device = &dev->device; eth_dev->intr_handle = NULL; eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->numa_node = dev->device.numa_node; - data = eth_dev->data; - data->dev_private = nic; data->port_id = eth_dev->data->port_id; nic->ev_queues = 1; @@ -1103,12 +1103,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, if (nic) octeontx_port_close(nic); - if (eth_dev != NULL) { - rte_free(eth_dev->data->mac_addrs); - rte_free(data); - rte_free(nic); - rte_eth_dev_release_port(eth_dev); - } + rte_eth_dev_release_port(eth_dev); return res; } @@ -1137,8 +1132,6 @@ octeontx_remove(struct rte_vdev_device *dev) rte_event_dev_stop(nic->evdev); PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name); - rte_free(eth_dev->data->mac_addrs); - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); rte_event_dev_close(nic->evdev); } diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 51d405116..8347ac2cf 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -1215,7 +1215,6 @@ pmd_pcap_probe(struct rte_vdev_device *dev) static int pmd_pcap_remove(struct rte_vdev_device *dev) { - struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; PMD_LOG(INFO, "Closing pcap ethdev on numa socket %d", @@ -1229,12 +1228,6 @@ pmd_pcap_remove(struct rte_vdev_device *dev) if (eth_dev == NULL) return -1; - internals = eth_dev->data->dev_private; - if (internals && internals->phy_mac) - rte_free(eth_dev->data->mac_addrs); - - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index 18d244a93..404859426 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -2666,11 +2666,6 @@ static int qede_dev_common_uninit(struct rte_eth_dev *eth_dev) eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; - if (eth_dev->data->mac_addrs) - rte_free(eth_dev->data->mac_addrs); - - eth_dev->data->mac_addrs = NULL; - return 0; } diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index bfe2f1780..383fb782b 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -666,10 +666,6 @@ rte_pmd_ring_remove(struct rte_vdev_device *dev) } } - rte_free(eth_dev->data->rx_queues); - rte_free(eth_dev->data->tx_queues); - rte_free(eth_dev->data->dev_private); - rte_eth_dev_release_port(eth_dev); return 0; } diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index b2e17f26e..3886daf7a 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2035,9 +2035,6 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev) sfc_detach(sa); sfc_unprobe(sa); - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - sfc_kvargs_cleanup(sa); sfc_adapter_unlock(sa); diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 0fd264e25..f01ed36b6 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -556,7 +556,6 @@ static int pmd_remove(struct rte_vdev_device *vdev) { struct rte_eth_dev *dev = NULL; - struct pmd_internals *p; if (!vdev) return -EINVAL; @@ -567,12 +566,11 @@ pmd_remove(struct rte_vdev_device *vdev) dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev)); if (dev == NULL) return -ENODEV; - p = dev->data->dev_private; /* Free device data structures*/ - rte_free(dev->data); + pmd_free(dev->data->dev_private); + dev->data->dev_private = NULL; rte_eth_dev_release_port(dev); - pmd_free(p); return 0; } diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index 4e5e01cf1..88448eff6 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1544,7 +1544,6 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); free(internals->sze_dev_path); - rte_free(dev->data->mac_addrs); PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized", RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data->name); diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index ad5ae988b..902a60847 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -2100,7 +2100,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) } close(internals->ioctl_sock); - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); if (internals->ka_fd != -1) { diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index aa6052221..986bf9633 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1220,10 +1220,12 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name, eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal)); if (eth_dev == NULL) goto error; + data = eth_dev->data; eth_addr = rte_zmalloc_socket(name, sizeof(*eth_addr), 0, numa_node); if (eth_addr == NULL) goto error; + data->mac_addrs = eth_addr; *eth_addr = base_eth_addr; eth_addr->addr_bytes[5] = eth_dev->data->port_id; @@ -1253,13 +1255,11 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name, rte_spinlock_init(&vring_state->lock); vring_states[eth_dev->data->port_id] = vring_state; - data = eth_dev->data; data->nb_rx_queues = queues; data->nb_tx_queues = queues; internal->max_queues = queues; internal->vid = -1; data->dev_link = pmd_link; - data->mac_addrs = eth_addr; data->dev_flags = RTE_ETH_DEV_INTR_LSC; eth_dev->dev_ops = &ops; @@ -1291,10 +1291,7 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name, free(internal->dev_name); } rte_free(vring_state); - rte_free(eth_addr); - if (eth_dev) - rte_eth_dev_release_port(eth_dev); - rte_free(internal); + rte_eth_dev_release_port(eth_dev); rte_free(list); return -1; diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b81df0a99..3b1bec9ba 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1706,9 +1706,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = NULL; eth_dev->rx_pkt_burst = NULL; - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - /* reset interrupt callback */ if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) rte_intr_callback_unregister(eth_dev->intr_handle, diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 525d16cab..420364b7a 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -422,7 +422,6 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev) if (!dev) { PMD_INIT_LOG(ERR, "malloc virtio_user_dev failed"); rte_eth_dev_release_port(eth_dev); - rte_free(hw); return NULL; } @@ -449,7 +448,6 @@ virtio_user_eth_dev_free(struct rte_eth_dev *eth_dev) struct virtio_hw *hw = data->dev_private; rte_free(hw->virtio_user_dev); - rte_free(hw); rte_eth_dev_release_port(eth_dev); } @@ -662,7 +660,6 @@ virtio_user_pmd_remove(struct rte_vdev_device *vdev) dev = hw->virtio_user_dev; virtio_user_dev_uninit(dev); - rte_free(eth_dev->data->dev_private); rte_eth_dev_release_port(eth_dev); return 0; diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 78e5b7680..41bcd450a 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -368,9 +368,6 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = NULL; eth_dev->tx_pkt_prepare = NULL; - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - return 0; } diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 14fc7e328..178800a5b 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -376,7 +376,14 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) eth_dev->state = RTE_ETH_DEV_UNUSED; - memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data)); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + rte_free(eth_dev->data->rx_queues); + rte_free(eth_dev->data->tx_queues); + rte_free(eth_dev->data->mac_addrs); + rte_free(eth_dev->data->hash_mac_addrs); + rte_free(eth_dev->data->dev_private); + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data)); + } rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); @@ -3517,7 +3524,7 @@ rte_eth_dev_create(struct rte_device *device, const char *name, if (!ethdev->data->dev_private) { RTE_LOG(ERR, EAL, "failed to allocate private data"); retval = -ENOMEM; - goto data_alloc_failed; + goto probe_failed; } } } else { @@ -3549,14 +3556,9 @@ rte_eth_dev_create(struct rte_device *device, const char *name, rte_eth_dev_probing_finish(ethdev); return retval; -probe_failed: - /* free ports private data if primary process */ - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(ethdev->data->dev_private); -data_alloc_failed: +probe_failed: rte_eth_dev_release_port(ethdev); - return retval; } @@ -3577,11 +3579,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev, return ret; } - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(ethdev->data->dev_private); - - ethdev->data->dev_private = NULL; - return rte_eth_dev_release_port(ethdev); } diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h index f652596f4..23257e986 100644 --- a/lib/librte_ethdev/rte_ethdev_pci.h +++ b/lib/librte_ethdev/rte_ethdev_pci.h @@ -135,17 +135,6 @@ rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size) static inline void rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev) { - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - rte_free(eth_dev->data->dev_private); - - eth_dev->data->dev_private = NULL; - - /* - * Secondary process will check the name to attach. - * Clear this field to avoid attaching a released ports. - */ - eth_dev->data->name[0] = '\0'; - eth_dev->device = NULL; eth_dev->intr_handle = NULL; -- 2.19.0