ethdev: free all common data when releasing port

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 <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
Thomas Monjalon 2018-10-19 04:07:55 +02:00 committed by Ferruh Yigit
parent f6a12685a5
commit e16adf08e5
45 changed files with 109 additions and 232 deletions

View File

@ -986,6 +986,9 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev)
if (eth_dev == NULL)
return -1;
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port_secondary(eth_dev);
@ -996,8 +999,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;

View File

@ -509,7 +509,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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -3128,10 +3128,9 @@ 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);
}
if (eth_dev != NULL)
eth_dev->data->dev_private = NULL;
rte_eth_dev_release_port(eth_dev);
return -1;
}
@ -3292,8 +3291,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);

View File

@ -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 @@ out_free:
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)

View File

@ -282,14 +282,7 @@ out_free:
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;
}

View File

@ -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;

View File

@ -2065,12 +2065,6 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
dpaa2_free_rx_tx_queues(eth_dev);
/* 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) {
@ -2133,8 +2127,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;
}
@ -2147,8 +2139,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;

View File

@ -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,

View File

@ -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,

View File

@ -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;
}

View File

@ -280,7 +280,8 @@ free_args:
free_subs:
fs_sub_device_free(dev);
free_dev:
rte_free(PRIV(dev));
/* mac_addrs must not be freed alone because part of dev_private */
dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(dev);
return -1;
}
@ -305,7 +306,8 @@ fs_rte_eth_free(const char *name)
if (ret)
ERROR("Error while destroying hotplug mutex");
rte_free(PRIV(dev)->mcast_addrs);
rte_free(PRIV(dev));
/* mac_addrs must not be freed alone because part of dev_private */
dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(dev);
return ret;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -523,7 +523,10 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
}
int
i40e_vf_representor_uninit(struct rte_eth_dev *ethdev __rte_unused)
i40e_vf_representor_uninit(struct rte_eth_dev *ethdev)
{
/* mac_addrs must not be freed because part of i40e_pf_vf */
ethdev->data->mac_addrs = NULL;
return 0;
}

View File

@ -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);

View File

@ -225,7 +225,10 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
}
int
ixgbe_vf_representor_uninit(struct rte_eth_dev *ethdev __rte_unused)
ixgbe_vf_representor_uninit(struct rte_eth_dev *ethdev)
{
/* mac_addrs must not be freed because part of ixgbe_vf_info */
ethdev->data->mac_addrs = NULL;
return 0;
}

View File

@ -463,6 +463,9 @@ eth_kni_remove(struct rte_vdev_device *vdev)
if (eth_dev == NULL)
return -1;
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port_secondary(eth_dev);
@ -471,8 +474,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--;

View File

@ -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;

View File

@ -781,12 +781,17 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
continue;
port_error:
rte_free(priv);
if (eth_dev != NULL)
eth_dev->data->dev_private = NULL;
if (pd)
claim_zero(mlx4_glue->dealloc_pd(pd));
if (ctx)
claim_zero(mlx4_glue->close_device(ctx));
if (eth_dev)
if (eth_dev != NULL) {
/* mac_addrs must not be freed because part of dev_private */
eth_dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(eth_dev);
}
break;
}
/*

View File

@ -1223,11 +1223,16 @@ error:
if (own_domain_id)
claim_zero(rte_eth_switch_domain_free(priv->domain_id));
rte_free(priv);
if (eth_dev != NULL)
eth_dev->data->dev_private = NULL;
}
if (pd)
claim_zero(mlx5_glue->dealloc_pd(pd));
if (eth_dev)
if (eth_dev != NULL) {
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(eth_dev);
}
if (ctx)
claim_zero(mlx5_glue->close_device(ctx));
assert(err > 0);
@ -1447,8 +1452,8 @@ 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);
/* mac_addrs must not be freed because in dev_private */
list[i].eth_dev->data->mac_addrs = NULL;
claim_zero(rte_eth_dev_release_port(list[i].eth_dev));
}
/* Restore original error. */

View File

@ -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 @@ out_free_dev:
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);
}

View File

@ -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);
}

View File

@ -118,20 +118,11 @@ eth_dev_vmbus_allocate(struct rte_vmbus_device *dev, size_t private_data_size)
static void
eth_dev_vmbus_release(struct rte_eth_dev *eth_dev)
{
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
/* 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;
}
@ -829,8 +820,6 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
rte_free(hv->primary);
rte_eth_dev_owner_delete(hv->owner.id);
eth_dev->data->mac_addrs = NULL;
return 0;
}

View File

@ -682,8 +682,8 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port_secondary(eth_dev);
rte_free(eth_dev->data->dev_private);
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(eth_dev);
return 0;

View File

@ -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 @@ err:
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;
}
@ -1142,8 +1137,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);
}

View File

@ -1232,11 +1232,9 @@ pmd_pcap_remove(struct rte_vdev_device *dev)
return rte_eth_dev_release_port_secondary(eth_dev);
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);
if (internals != NULL && internals->phy_mac == 0)
/* not dynamically allocated, must not be freed */
eth_dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(eth_dev);
return 0;

View File

@ -2659,11 +2659,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;
}

View File

@ -666,10 +666,8 @@ 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);
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(eth_dev);
return 0;
}

View File

@ -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);

View File

@ -557,7 +557,6 @@ static int
pmd_remove(struct rte_vdev_device *vdev)
{
struct rte_eth_dev *dev = NULL;
struct pmd_internals *p;
if (!vdev)
return -EINVAL;
@ -568,12 +567,12 @@ 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; /* already freed */
dev->data->mac_addrs = NULL; /* statically allocated */
rte_eth_dev_release_port(dev);
pmd_free(p);
return 0;
}

View File

@ -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);

View File

@ -1858,6 +1858,8 @@ error_remote:
error_exit:
if (pmd->ioctl_sock > 0)
close(pmd->ioctl_sock);
/* mac_addrs must not be freed alone because part of dev_private */
dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(dev);
error_exit_nodev:
@ -2259,6 +2261,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
if (!eth_dev)
return -ENODEV;
/* mac_addrs must not be freed alone because part of dev_private */
eth_dev->data->mac_addrs = NULL;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port_secondary(eth_dev);
@ -2286,7 +2291,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
}
close(internals->ioctl_sock);
rte_free(eth_dev->data->dev_private);
rte_free(eth_dev->process_private);
if (tap_devices_count == 1)
rte_mp_action_unregister(TAP_MP_KEY);

View File

@ -1222,10 +1222,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;
@ -1255,13 +1257,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;
@ -1293,10 +1293,7 @@ error:
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;

View File

@ -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,

View File

@ -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;

View File

@ -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;
}

View File

@ -388,7 +388,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);
@ -3529,7 +3536,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 {
@ -3561,14 +3568,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:
rte_eth_dev_release_port(ethdev);
return retval;
}
@ -3592,9 +3594,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port_secondary(ethdev);
rte_free(ethdev->data->dev_private);
ethdev->data->dev_private = NULL;
return rte_eth_dev_release_port(ethdev);
}

View File

@ -585,7 +585,10 @@ struct rte_eth_dev_data {
struct rte_eth_dev_sriov sriov; /**< SRIOV data */
void *dev_private; /**< PMD-specific private data */
void *dev_private;
/**< PMD-specific private data.
* @see rte_eth_dev_release_port()
*/
struct rte_eth_link dev_link; /**< Link-level information & status. */
struct rte_eth_conf dev_conf; /**< Configuration applied to device. */
@ -594,11 +597,16 @@ struct rte_eth_dev_data {
/**< Common RX buffer size handled by all queues. */
uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
struct ether_addr *mac_addrs; /**< Device Ethernet link address. */
struct ether_addr *mac_addrs;
/**< Device Ethernet link address.
* @see rte_eth_dev_release_port()
*/
uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
/**< Bitmap associating MAC addresses to pools. */
struct ether_addr *hash_mac_addrs;
/**< Device Ethernet MAC addresses of hash filtering. */
/**< Device Ethernet MAC addresses of hash filtering.
* @see rte_eth_dev_release_port()
*/
uint16_t port_id; /**< Device [external] port identifier. */
__extension__

View File

@ -58,7 +58,14 @@ struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
/**
* @internal
* Release the specified ethdev port.
* Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
*
* The following PMD-managed data fields will be freed:
* - dev_private
* - mac_addrs
* - hash_mac_addrs
* If one of these fields should not be freed,
* it must be reset to NULL by the PMD, typically in dev_close method.
*
* @param eth_dev
* Device to be detached.

View File

@ -142,16 +142,6 @@ rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
return;
}
/* primary process */
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;