path: root/drivers
diff options
authorOphir Munk <>2018-10-23 18:26:04 +0000
committerFerruh Yigit <>2018-10-26 22:14:06 +0200
commit42603bbdb58ea57091c40304e65a2e9fef99e9d0 (patch)
tree9a44bbe23d32d965196e770497007f3bb305e6fa /drivers
parent206254b7dc4283e0073373b88d451081bd0801b7 (diff)
net/mlx5: release port on close
With the introduction of representors several eth devices are using the same rte device (e.g. a PCI bus). It is therefore required to release the eth device resources during an eth device close operation rather than during an rte device removal (detach) operation. In current version many PMDs are still releasing the eth device as part of the rte device removal. In order to allow a smooth transition for all PMDs to behave correctly an ethdev flag RTE_ETH_DEV_CLOSE_REMOVE is used. When this flag is set it indicates to rte_eth_dev_close() to call rte_eth_dev_release_port(), so the port is freed during the close operation. Signed-off-by: Ophir Munk <> Acked-by: Shahaf Shuler <>
Diffstat (limited to 'drivers')
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 1e976d7..be7d8f5 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -337,6 +337,17 @@ mlx5_dev_close(struct rte_eth_dev *dev)
memset(priv, 0, sizeof(*priv));
+ /*
+ * flag to rte_eth_dev_close() that it should release the port resources
+ * (calling rte_eth_dev_release_port()) in addition to closing it.
+ */
+ dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+ /*
+ * Reset mac_addrs to NULL such that it is not freed as part of
+ * rte_eth_dev_release_port(). mac_addrs is part of dev_private so
+ * it is freed when dev_private is freed.
+ */
+ dev->data->mac_addrs = NULL;
const struct eth_dev_ops mlx5_dev_ops = {