ethdev: complete closing to free all resources
Subsystems (3)
RFC 1/1 ethdev: complete closing to free all resources
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside the dev_close() driver callback operation.
The last ethdev freeing (dev_private and final release), which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
---
This patch contains only the change in the close function as RFC.
This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-)
lib/librte_ethdev/rte_ethdev.c +5 -0
@@ -1358,6 +1358,7 @@ void rte_eth_dev_close(uint16_t port_id) {struct rte_eth_dev *dev; +struct rte_bus *bus;RTE_ETH_VALID_PORTID_OR_RET (port_id); dev = &rte_eth_devices[port_id];
@@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private); + +rte_eth_dev_release_port (dev); }int
lib/librte_ethdev/rte_ethdev.h +3 -2
@@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. +* If there is no more port associated with the underlying device, +* the driver should free the device resources. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.18.0
Quoted 11 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().
For me, it sounds more logical to kill dev_close and keep detach. IMHO, dev_close is artificial and hardly useful. detach is a local pair to attach.
Anyway it requires update of all drivers as I understand.
Quoted 49 lines
Signed-off-by Thomas Monjalon <[email protected]>---
This patch contains only the change in the close function as RFC.This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +5
-0@@ -1358,6 +1358,7 @@ void rte_eth_dev_close(uint16_t port_id) {struct rte_eth_dev *dev; +struct rte_bus *bus;RTE_ETH_VALID_PORTID_OR_RET (port_id); dev = &rte_eth_devices[port_id];@@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private); + +rte_eth_dev_release_port (dev); }int lib/librte_ethdev/rte_ethdev.h +3
-2@@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. +* If there is no more port associated with the underlying device, +* the driver should free the device resources. * * @param port_id * The port identifier of the Ethernet device.
10/09/2018 10:03, Andrew Rybchenko:
Quoted 10 lines · Thomas Monjalon
Quoted 9 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.
Quoted 6 lines
Quoted 2 lines
The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().For me, it sounds more logical to kill
dev_closeand keep detach. IMHO,dev_closeis artificial and hardly useful. detach is a local pair to attach.
I don't get your point.
In order to free a port, we need close + detach.
We can keep only one.
I choose close because:
1) attach/detach are deprecated
2) probe/close is a more obvious pair
3) we need the driver to free the lower level resources
Quoted 1 line
Anyway it requires update of all drivers as I understand.
Yes if we want to free all resources.
But close operation in drivers can be completed in later steps.
Quoted 16 lines · Thomas Monjalon
10/09/2018 10:03, Andrew Rybchenko:
Quoted 10 lines · Thomas Monjalon
Quoted 9 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.Quoted 5 lines
Quoted 2 lines
The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().For me, it sounds more logical to kill
dev_closeand keep detach. IMHO,dev_closeis artificial and hardly useful. detach is a local pair to attach.
Quoted 8 lines
I don't get your point.
In order to free a port, we need close + detach.
We can keep only one.
I choose close because:
1) attach/detach are deprecated
2) probe/close is a more obvious pair
3) we need the driver to free the lower level resources
Yes, I'm sorry I used bad terminology.
We have probe/remove pair for both PCI and vdev drivers and I mean that remove is a better candidate to be kept (as a pair for probe which allocates all resources).
10/09/2018 10:54, Andrew Rybchenko:
Quoted 26 lines · Thomas Monjalon
Quoted 16 lines
10/09/2018 10:03, Andrew Rybchenko:
Quoted 10 lines · Thomas Monjalon
Quoted 9 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.Quoted 5 lines
Quoted 2 lines
The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().For me, it sounds more logical to kill
dev_closeand keep detach. IMHO,dev_closeis artificial and hardly useful. detach is a local pair to attach.Quoted 8 lines
I don't get your point.
In order to free a port, we need close + detach.
We can keep only one.
I choose close because:
1) attach/detach are deprecated
2) probe/close is a more obvious pair
3) we need the driver to free the lower level resources
Quoted 4 lines
Yes, I'm sorry I used bad terminology.
We have probe/remove pair for both PCI and vdev drivers and I mean that remove is a better candidate to be kept (as a pair for probe which allocates all resources).
OK, yes probe/remove is the pair at EAL level.
But if we want to request removal at ethdev level, rte_eth_dev_close is the function.
Note that there is no function to request creation of an ethdev port. Adding a new port is done only by the PMD during probing (rte_bus level).
Quoted 30 lines · Thomas Monjalon
10/09/2018 10:54, Andrew Rybchenko:
Quoted 25 lines · Thomas Monjalon
Quoted 16 lines
10/09/2018 10:03, Andrew Rybchenko:
Quoted 10 lines · Thomas Monjalon
Quoted 9 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.Quoted 5 lines
Quoted 2 lines
The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().For me, it sounds more logical to kill
dev_closeand keep detach. IMHO,dev_closeis artificial and hardly useful. detach is a local pair to attach.Quoted 8 lines
I don't get your point.
In order to free a port, we need close + detach.
We can keep only one.
I choose close because:
1) attach/detach are deprecated
2) probe/close is a more obvious pair
3) we need the driver to free the lower level resourcesQuoted 4 lines
Yes, I'm sorry I used bad terminology.
We have probe/remove pair for both PCI and vdev drivers and I mean that remove is a better candidate to be kept (as a pair for probe which allocates all resources).
Quoted 6 lines
OK, yes probe/remove is the pair at EAL level.
But if we want to request removal at ethdev level,rte_eth_dev_closeis the function.Note that there is no function to request creation of an ethdev port. Adding a new port is done only by the PMD during probing (
rte_buslevel).
The overall picture is too vague. May be it is simply incomplete looking at the patch only. I understand that restructuring is required looking at rte_eth_dev_destroy() (which is used by i40e and ixgbe drivers only) and rte_eth_dev_pci_release() used by other PCI drivers.
Right now it looks symmetric at least on drivers level which provides init callback to probe to do driver-specific job and uninit callback to remove to free driver-specific resources.
I can't say if the patch is right or wrong direction since final design is unclear.
Quoted 35 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().Signed-off-by Thomas Monjalon <[email protected]>---
This patch contains only the change in the close function as RFC.This idea was presented at Dublin during the "hotplug talk".
--- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +1
-0@@ -1358,6 +1358,7 @@ void rte_eth_dev_close(uint16_t port_id) {struct rte_eth_dev *dev; +struct rte_bus *bus;RTE_ETH_VALID_PORTID_OR_RET (port_id); dev = &rte_eth_devices[port_id];
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1379
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +4
-0@@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private); + +rte_eth_dev_release_port (dev);
These already done in:rte_eth_dev_pci_generic_remove()
rte_eth_dev_pci_release()
Perhaps all content of rte_eth_dev_pci_release(), including above updates, should move to rte_eth_dev_close() and rte_eth_dev_pci_generic_remove() call rte_eth_dev_close() directly.
Just thinking aloud,
driver->probe() called when a new device added.
Application startup can be thought as all devices added one by one. [Perhaps this can be change in the future to add devices only when explicitly stated]
driver->remove() called when device removed.
When application terminated this path not called at all, perhaps we need a way to remove all devices one by one on exit.
eth_dev_close(), when eth_dev removed in ethdev layer but device is not removed in eal level,
I think it make sense for eth_dev_close():
- It does more cleanup, free resources and port_id
- but it may need to do more clean up, like call uninit() and do more driver internal clean up too, and clean up the hw.
- so call stack can be:
driver->remove()
rte_eth_dev_pci_generic_remove()
eth_dev_close()
dev_uninit() [driver unint function ]
Another question, after eth_dev_close() ethdev is not usable and not able to restart it back. So why we need eth_dev_close() in addition to dev remove, why not directly call rte_eth_dev_detach()?
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.c +0
-0}int lib/librte_ethdev/rte_ethdev.h +3
-2@@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. +* If there is no more port associated with the underlying device, +* the driver should free the device resources. * * @param port_id * The port identifier of the Ethernet device.
28/09/2018 14:46, Ferruh Yigit:
Quoted 32 lines · Thomas Monjalon
Quoted 19 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside thedev_close()driver callback operation.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().Signed-off-by Thomas Monjalon <[email protected]>---
This patch contains only the change in the close function as RFC.This idea was presented at Dublin during the "hotplug talk".
---lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1379
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +4
-0@@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private); + +rte_eth_dev_release_port (dev);These already done in:
rte_eth_dev_pci_generic_remove()
rte_eth_dev_pci_release()
Quoted 3 lines
Perhaps all content of
rte_eth_dev_pci_release(), including above updates, should move torte_eth_dev_close()andrte_eth_dev_pci_generic_remove()callrte_eth_dev_close()directly.
Yes I think it is the way to go:
- when removing a rte_device, close all associated ports.
and the reverse can be done in addition:
- when closing the last port of a rte_device, remove it.
Quoted 24 lines
Just thinking aloud,
driver->probe()called when a new device added.
Application startup can be thought as all devices added one by one. [Perhaps this can be change in the future to add devices only when explicitly stated]
driver->remove()called when device removed.
When application terminated this path not called at all, perhaps we need a way to remove all devices one by one on exit.
eth_dev_close(), wheneth_devremoved in ethdev layer but device is not removed in eal level,I think it make sense for
eth_dev_close():
- It does more cleanup, free resources andport_id
- but it may need to do more clean up, like calluninit()and do more driver internal clean up too, and clean up the hw.
- so call stack can be:
driver->remove()
rte_eth_dev_pci_generic_remove()
eth_dev_close()
dev_uninit()[driver unint function ]
Quoted 3 lines
Another question, after
eth_dev_close()ethdev is not usable and not able to restart it back. So why we needeth_dev_close()in addition to dev remove, why not directly callrte_eth_dev_detach()?
rte_eth_dev_detach is assuming a 1:1 mapping between EAL rte_device and rte_eth_dev port.
That's why it is deprecated and going to be removed.
PATCH v2 1/1 ethdev: complete closing of port
In reply to Thomas MonjalonAfter closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing (dev_private and final release), which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
If the driver is trying to free the port again, the function rte_eth_dev_release_port() will abort with -ENODEV error.
--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)
lib/librte_ethdev/rte_ethdev.c +6 -0
@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private); + +rte_eth_dev_release_port (dev); }int
lib/librte_ethdev/rte_ethdev.h +1 -2
@@ -1846,8 +1846,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. +* The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.19.0
Re: [PATCH v2] ethdev: complete closing of port
Quoted 33 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);
It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.
Re: [PATCH v2] ethdev: complete closing of port
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, in rte_eth_dev_pci_generic_remove(), rte_eth_dev_allocated() will return NULL and won't call uninit function.
Re: [PATCH v2] ethdev: complete closing of port
Quoted 42 lines · Thomas Monjalon
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.
Quoted 5 lines
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.
The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)
Re: [PATCH v2] ethdev: complete closing of port
10/10/2018 09:50, Andrew Rybchenko:
Quoted 49 lines · Thomas Monjalon
Quoted 42 lines
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.Quoted 5 lines
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.
Quoted 4 lines
The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)
So far, everything is allowed:
- The application can close a port and remove the rte_device later.
- The application can remove the rte_device and expect the PMD is closing associated ports.
In other words, when rte_device is removed, the ports should be closed by the PMD, except if the application has already closed the ports. It means ethdev port close is optional, but EAL removal is always required. The behaviour is not changed.
If we want to go further, we could change the behaviour of the close op, by asking the PMD to remove the rte_device automatically if all associated ports are closed. It would allow the application to manage only ports at ethdev layer without bothering with low-level EAL management. We can think about it as a planned change for next releases.
Re: [PATCH v2] ethdev: complete closing of port
Quoted 49 lines · Thomas Monjalon
10/10/2018 09:50, Andrew Rybchenko:
Quoted 48 lines · Thomas Monjalon
Quoted 47 lines
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.
Quoted 6 lines
Quoted 4 lines
The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)So far, everything is allowed:
- The application can close a port and remove therte_devicelater.
If the patch is applied, close frees dev_private which is used by uninit. So, uninit must be done first. Who does it?
(it looks like I'm missing something obvious, but still can't find it)
Quoted 15 lines
- The application can remove the
rte_deviceand expect the PMD is closing associated ports.In other words, when
rte_deviceis removed, the ports should be closed by the PMD, except if the application has already closed the ports. It means ethdev port close is optional, but EAL removal is always required. The behaviour is not changed.If we want to go further, we could change the behaviour of the close op, by asking the PMD to remove the
rte_deviceautomatically if all associated ports are closed. It would allow the application to manage only ports at ethdev layer without bothering with low-level EAL management. We can think about it as a planned change for next releases.
Re: [PATCH v2] ethdev: complete closing of port
10/10/2018 17:01, Andrew Rybchenko:
Quoted 58 lines · Thomas Monjalon
Quoted 57 lines
10/10/2018 09:50, Andrew Rybchenko:
Quoted 55 lines · Thomas Monjalon
Quoted 44 lines
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.Quoted 5 lines
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)
Quoted 6 lines
Quoted 2 lines
So far, everything is allowed:
- The application can close a port and remove therte_devicelater.If the patch is applied, close frees
dev_privatewhich is used by uninit. So, uninit must be done first. Who does it?
(it looks like I'm missing something obvious, but still can't find it)
Yes, you missed my explanation above :)
Let me try again:
rte_eth_dev_release_port() does 3 things:
- RTE_ETH_EVENT_DESTROY notification
- state = RTE_ETH_DEV_UNUSED
- memset data to 0
Because of state == RTE_ETH_DEV_UNUSED and data->name == NULL, you should not try to use data->dev_private.
Before calling uninit function, the dev is retrieved by name:
ethdev = rte_eth_dev_allocated(ethdev->data->name);
if (!ethdev)
return -ENODEV;In our case, it will be -ENODEV, which is a good return when trying to release a closed port.
Now I am thinking that PMDs could ignore this -ENODEV error:
it is OK to free the rte_device with ethdev port already closed.
Quoted 13 lines
Quoted 13 lines
- The application can remove the
rte_deviceand expect the PMD is closing associated ports.In other words, when
rte_deviceis removed, the ports should be closed by the PMD, except if the application has already closed the ports. It means ethdev port close is optional, but EAL removal is always required. The behaviour is not changed.If we want to go further, we could change the behaviour of the close op, by asking the PMD to remove the
rte_deviceautomatically if all associated ports are closed. It would allow the application to manage only ports at ethdev layer without bothering with low-level EAL management. We can think about it as a planned change for next releases.
Re: [PATCH v2] ethdev: complete closing of port
Quoted 72 lines · Thomas Monjalon
10/10/2018 17:01, Andrew Rybchenko:
Quoted 54 lines · Thomas Monjalon
Quoted 53 lines
10/10/2018 09:50, Andrew Rybchenko:
Quoted 52 lines · Thomas Monjalon
Quoted 42 lines
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.Quoted 5 lines
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)Quoted 5 lines
Quoted 2 lines
So far, everything is allowed:
- The application can close a port and remove therte_devicelater.If the patch is applied, close frees
dev_privatewhich is used by uninit. So, uninit must be done first. Who does it?
(it looks like I'm missing something obvious, but still can't find it)Yes, you missed my explanation above :)
Let me try again:
rte_eth_dev_release_port()does 3 things:
-RTE_ETH_EVENT_DESTROYnotification
- state =RTE_ETH_DEV_UNUSED
- memset data to 0Because of state ==
RTE_ETH_DEV_UNUSEDanddata->name== NULL, you should not try to usedata->dev_private.
Before calling uninit function, the dev is retrieved by name:
Quoted 6 lines
ethdev = rte_eth_dev_allocated(ethdev->data->name); if (!ethdev) return -ENODEV;In our case, it will be
-ENODEV, which is a good return when trying to release a closed port.
Yes, it replies on the question why dev_uninit is not called upon device removal after close. But it does not reply on the question what does call dev_uninit before/during dev_close.
Quoted 2 lines
Now I am thinking that PMDs could ignore this
-ENODEVerror:
it is OK to free therte_devicewith ethdev port already closed.
I'll apply all 4 patch series tomorrow, add printout to dev_uninit, build, run testpmd, do close and check if printout appears. I hope it will reply on my question. I'll come back when I do and have results.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
- The application can remove the
rte_deviceand expect the PMD is closing associated ports.In other words, when
rte_deviceis removed, the ports should be closed by the PMD, except if the application has already closed the ports. It means ethdev port close is optional, but EAL removal is always required. The behaviour is not changed.If we want to go further, we could change the behaviour of the close op, by asking the PMD to remove the
rte_deviceautomatically if all associated ports are closed. It would allow the application to manage only ports at ethdev layer without bothering with low-level EAL management. We can think about it as a planned change for next releases.
Re: [PATCH v2] ethdev: complete closing of port
10/10/2018 20:01, Andrew Rybchenko:
Quoted 77 lines · Thomas Monjalon
Quoted 76 lines
10/10/2018 17:01, Andrew Rybchenko:
Quoted 54 lines · Thomas Monjalon
Quoted 53 lines
10/10/2018 09:50, Andrew Rybchenko:
Quoted 52 lines · Thomas Monjalon
Quoted 42 lines
10/10/2018 08:15, Andrew Rybchenko:
Quoted 33 lines · Thomas Monjalon
Quoted 32 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing (
dev_privateand final release), which were done byrte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-0@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1447
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues =0 ;rte_free (dev->data->tx_queues); dev->data->tx_queues =NULL ; + +rte_free (dev->data->dev_private);It is used by, for example, PCI device uninit functions.
What does guarantee that uninit is done and we can free the private data.Quoted 5 lines
The state of the port is set to UNUSED and the name is NULL. So nobody should try to use it anymore.
There are already some checks before calling uninit functions. For instance, inrte_eth_dev_pci_generic_remove(),rte_eth_dev_allocated()will return NULL and won't call uninit function.The questions are:
Is application allowed to call the function? When?
Who calls uninit in this case? (What does guarantee that uninit is done before close)Quoted 5 lines
Quoted 2 lines
So far, everything is allowed:
- The application can close a port and remove therte_devicelater.If the patch is applied, close frees
dev_privatewhich is used by uninit. So, uninit must be done first. Who does it?
(it looks like I'm missing something obvious, but still can't find it)Yes, you missed my explanation above :)
Let me try again:
rte_eth_dev_release_port()does 3 things:
-RTE_ETH_EVENT_DESTROYnotification
- state =RTE_ETH_DEV_UNUSED
- memset data to 0Because of state ==
RTE_ETH_DEV_UNUSEDanddata->name== NULL, you should not try to usedata->dev_private.
Before calling uninit function, the dev is retrieved by name:ethdev = rte_eth_dev_allocated(ethdev->data->name); if (!ethdev) return -ENODEV;
Quoted 6 lines
Quoted 2 lines
In our case, it will be
-ENODEV, which is a good return when trying to release a closed port.Yes, it replies on the question why
dev_uninitis not called upon device removal after close. But it does not reply on the question what does calldev_uninitbefore/duringdev_close.
Maybe I don't understand your question correctly. dev_uninit is not called during dev_close.
However, as suggested by Ferruh, it would be cleaner to call dev_close instead of dev_uninit which should do the same thing. Currently, most of the PMDs expect both dev_close and dev_uninit to be called in order to completely free a port.
The call tree to reach dev_uninit is:
[rte_eal_hotplug_remove]
rte_dev_remove
bus.unplug
driver.remove
for port not closed
dev_uninit
free rte_device resources
In a next step, I would suggest to drop dev_uninit, and call dev_close instead.
v3 cover ethdev port freeing
In reply to Thomas MonjalonThe function rte_eth_dev_detach() is freeing a port and its underlying rte_device object. The issue is that we may have several ports associated to the same rte_device.
The right replacement is to free the port, and free the rte_device if no more ports.
At ethdev level, the public function for port freeing is rte_eth_dev_close(). The only miss is rte_eth_dev_release_port() to free all port resources.
Changes in v3:
- free queues, MAC addresses and private structure in rte_eth_dev_release_port.
Thomas Monjalon (2):
ethdev: free all common data when releasing port
ethdev: complete closing of port
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 | 8 ------ 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 | 13 +++------ 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 | 32 +++++++++-------------- lib/librte_ethdev/rte_ethdev.h | 3 +-- lib/librte_ethdev/rte_ethdev_pci.h | 11 -------- 42 files changed, 47 insertions(+), 248 deletions(-)
Signature · 1 line
2.19.0
PATCH v3 1/2 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.
--- 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(-)
drivers/net/af_packet/rte_eth_af_packet.c +0 -2
@@ -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 ;
drivers/net/ark/ark_ethdev.c +0 -1
@@ -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 ; }
drivers/net/avf/avf_ethdev.c +0 -3
@@ -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 ;
drivers/net/avp/avp_ethdev.c +0 -5
@@ -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 ; }
drivers/net/axgbe/axgbe_ethdev.c +0 -3
@@ -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 ;
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -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 ;
drivers/net/bonding/rte_eth_bond_pmd.c +1 -6
@@ -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);
drivers/net/cxgbe/cxgbe_main.c +2 -14
@@ -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 )
drivers/net/cxgbe/cxgbevf_main.c +1 -8
@@ -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; }
drivers/net/dpaa/dpaa_ethdev.c +0 -10
@@ -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 ;
drivers/net/dpaa2/dpaa2_ethdev.c +0 -10
@@ -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 ;
drivers/net/e1000/em_ethdev.c +0 -3
@@ -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,
drivers/net/e1000/igb_ethdev.c +0 -6
@@ -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,
drivers/net/enetc/enetc_ethdev.c +1 -3
@@ -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 ; }
drivers/net/failsafe/failsafe.c +0 -3
@@ -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; }
drivers/net/fm10k/fm10k_ethdev.c +0 -8
@@ -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 ; }
drivers/net/i40e/i40e_ethdev.c +0 -3
@@ -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);
drivers/net/i40e/i40e_ethdev_vf.c +0 -3
@@ -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 ; }
drivers/net/ixgbe/ixgbe_ethdev.c +0 -9
@@ -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);
drivers/net/kni/rte_eth_kni.c +0 -2
@@ -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--;
drivers/net/liquidio/lio_ethdev.c +0 -3
@@ -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 ;
drivers/net/mlx4/mlx4.c +1 -2
@@ -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 ; }/*
drivers/net/mlx5/mlx5.c +1 -4
@@ -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. */
drivers/net/mvneta/mvneta_ethdev.c +5 -11
@@ -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); }
drivers/net/mvpp2/mrvl_ethdev.c +5 -11
@@ -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); }
drivers/net/netvsc/hn_ethdev.c +0 -11
@@ -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 ; }
drivers/net/null/rte_eth_null.c +0 -2
@@ -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 ;
drivers/net/octeontx/octeontx_ethdev.c +11 -18
@@ -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); }
drivers/net/pcap/rte_eth_pcap.c +0 -7
@@ -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 ;
drivers/net/qede/qede_ethdev.c +0 -5
@@ -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 ; }
drivers/net/ring/rte_eth_ring.c +0 -4
@@ -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 ; }
drivers/net/sfc/sfc_ethdev.c +0 -3
@@ -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);
drivers/net/softnic/rte_eth_softnic.c +2 -4
@@ -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 ; }
drivers/net/szedata2/rte_eth_szedata2.c +0 -1
@@ -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);
drivers/net/tap/rte_eth_tap.c +0 -1
@@ -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 ) {
drivers/net/vhost/rte_eth_vhost.c +3 -6
@@ -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 ;
drivers/net/virtio/virtio_ethdev.c +0 -3
@@ -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,
drivers/net/virtio/virtio_user_ethdev.c +0 -3
@@ -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 ;
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -3
@@ -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 ; }
lib/librte_ethdev/rte_ethdev.c +10 -13
@@ -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); }
lib/librte_ethdev/rte_ethdev_pci.h +0 -11
@@ -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 ;
Signature · 1 line
2.19.0
Re: [PATCH v3 1/2] ethdev: free all common data when releasing port
Quoted 8 lines · Thomas Monjalon
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 <[email protected]>
<...>
Quoted 44 lines
drivers/net/cxgbe/cxgbe_main.c +2
-14@@ -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 )drivers/net/cxgbe/cxgbevf_main.c +0
-2@@ -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 )
drivers/net/cxgbe/cxgbevf_main.c int cxgbevf_probe(struct adapter *adapter) · line 288
Quoted 10 lines
drivers/net/cxgbe/cxgbevf_main.c +1
-6-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; }
Above changes looks frightening. I've add cxgbe maintainer in CC.
Quoted 17 lines
drivers/net/softnic/rte_eth_softnic.c +0
-2@@ -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;
drivers/net/softnic/rte_eth_softnic.c pmd_remove(struct rte_vdev_device *vdev) · line 576
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +2
-2/* 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 ; }
The above basically violates approach used everywhere else. It is OK to go, but should be reconsidered.
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_pci.h +0
-3@@ -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); -
lib/librte_ethdev/rte_ethdev_pci.h rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size) · line 139
Quoted 10 lines
lib/librte_ethdev/rte_ethdev_pci.h +0
-8- 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 ;
Not directly related to the patch, but I don't understand why does rte_eth_dev_pci_release () exist? It does nothing PCI specific. May be just for symmetry to rte_eth_dev_pci_allocate(). Why is intr_handle set to NULL above? Is it PCI specific? It does not look so, since failsafe uses it.
In general it looks good, really big work, but ideally it should be acked by cxgbe maintainer as well.
Re: [PATCH v3 1/2] ethdev: free all common data when releasing port
16/10/2018 13:16, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
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.
[...]
Quoted 23 lines
Quoted 23 lines
drivers/net/softnic/rte_eth_softnic.c +2
-4@@ -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);
Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c pmd_remove(struct rte_vdev_device *vdev) · line 576
Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +0
-0return 0 ; }The above basically violates approach used everywhere else. It is OK to go, but should be reconsidered.
Yes, it is because pmd_free does more than freeing just dev_private.
[...]
Quoted 5 lines
Not directly related to the patch, but I don't understand why does
rte_eth_dev_pci_release() exist? It does nothing PCI specific. May be just for symmetry torte_eth_dev_pci_allocate(). Why isintr_handleset to NULL above? Is it PCI specific? It does not look so, since failsafe uses it.
I agree that all these functions must be reconsidered and reworked. We should consider a big cleanup in ethdev for 19.02.
Quoted 2 lines
In general it looks good, really big work, but ideally it should be acked by cxgbe maintainer as well.
Actually, after more thoughts, I think this patch is not correct. It is freeing MAC adresses in ethdev, even if there was no specific allocation done for it in the PMD. Only the PMD can know what are the memory blocks to free.
And it is the same for data->dev_private: are we sure it has been malloc'ed? Are we sure it has not been allocated as part of a bigger block? Historically, ethdev was freeing data->dev_private in some cases. So maybe we can keep this assumption.
Or we can move all data freeing to the PMD?
Re: [PATCH v3 1/2] ethdev: free all common data when releasing port
Quoted 11 lines · Thomas Monjalon
16/10/2018 13:16, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
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.
[...]
Quoted 2 lines
In general it looks good, really big work, but ideally it should be acked by cxgbe maintainer as well.
Quoted 9 lines
Actually, after more thoughts, I think this patch is not correct. It is freeing MAC adresses in ethdev, even if there was no specific allocation done for it in the PMD. Only the PMD can know what are the memory blocks to free.
And it is the same fordata->dev_private: are we sure it has been malloc'ed? Are we sure it has not been allocated as part of a bigger block? Historically, ethdev was freeingdata->dev_privatein some cases. So maybe we can keep this assumption.
Or we can move all data freeing to the PMD?
It is allocated in rte_eth_dev_create(), rte_eth_vdev_allocate(), rte_eth_dev_pci_allocate() and some PMDs. I can't say that I'm happy with it, but it could be really required. May be it should be default behaviour and if PMD wants override it, just free before and set dev_private to NULL.
Re: [PATCH v3 1/2] ethdev: free all common data when releasing port
16/10/2018 14:47, Andrew Rybchenko:
Quoted 22 lines · Thomas Monjalon
Quoted 11 lines
16/10/2018 13:16, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
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.
[...]
Quoted 2 lines
In general it looks good, really big work, but ideally it should be acked by cxgbe maintainer as well.
Quoted 9 lines
Actually, after more thoughts, I think this patch is not correct. It is freeing MAC adresses in ethdev, even if there was no specific allocation done for it in the PMD. Only the PMD can know what are the memory blocks to free.
And it is the same fordata->dev_private: are we sure it has been malloc'ed? Are we sure it has not been allocated as part of a bigger block? Historically, ethdev was freeingdata->dev_privatein some cases. So maybe we can keep this assumption.
Or we can move all data freeing to the PMD?
Quoted 5 lines
It is allocated in
rte_eth_dev_create(),rte_eth_vdev_allocate(),rte_eth_dev_pci_allocate()and some PMDs. I can't say that I'm happy with it, but it could be really required. May be it should be default behaviour and if PMD wants override it, just free before and setdev_privateto NULL.
Yes, you're right!
So freeing is done by default in rte_eth_dev_release_port(), and PMD can avoid it by setting fields to NULL before calling it.
In this case, I just need to double check the MAC freeing, and set NULL in some PMDs which do not allocate MAC separately.
Re: [PATCH v3 1/2] ethdev: free all common data when releasing port
Quoted 27 lines · Thomas Monjalon
16/10/2018 14:47, Andrew Rybchenko:
Quoted 21 lines · Thomas Monjalon
Quoted 11 lines
16/10/2018 13:16, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
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.
[...]
Quoted 2 lines
In general it looks good, really big work, but ideally it should be acked by cxgbe maintainer as well.
Quoted 9 lines
Actually, after more thoughts, I think this patch is not correct. It is freeing MAC adresses in ethdev, even if there was no specific allocation done for it in the PMD. Only the PMD can know what are the memory blocks to free.
And it is the same fordata->dev_private: are we sure it has been malloc'ed? Are we sure it has not been allocated as part of a bigger block? Historically, ethdev was freeingdata->dev_privatein some cases. So maybe we can keep this assumption.
Or we can move all data freeing to the PMD?Quoted 5 lines
It is allocated in
rte_eth_dev_create(),rte_eth_vdev_allocate(),rte_eth_dev_pci_allocate()and some PMDs. I can't say that I'm happy with it, but it could be really required. May be it should be default behaviour and if PMD wants override it, just free before and setdev_privateto NULL.
Quoted 6 lines
Yes, you're right!
So freeing is done by default inrte_eth_dev_release_port(), and PMD can avoid it by setting fields to NULL before calling it.In this case, I just need to double check the MAC freeing, and set NULL in some PMDs which do not allocate MAC separately.
One more thought that we should document it since it is used by all PMDs and we have really a lot already and it looks like every release cycle we have at least plus one.
PATCH v3 2/2 ethdev: complete closing of port
In reply to Thomas MonjalonAfter closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
If the driver is trying to free the port again, the function rte_eth_dev_release_port() will abort with -ENODEV error.
--- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 4 files changed, 4 insertions(+), 16 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)if (bp->dev_stopped ==0 )bnxt_dev_stop_op (eth_dev); -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 ;
drivers/net/vhost/rte_eth_vhost.c +0 -4
@@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++)rte_free (dev->data->tx_queues[i]); -rte_free (dev->data->mac_addrs);free (internal->dev_name);free (internal->iface_name); -rte_free (internal); - - dev->data->dev_private =NULL ; } static int
lib/librte_ethdev/rte_ethdev.c +3 -6
@@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev); - dev->data->nb_rx_queues =0 ; -rte_free (dev->data->rx_queues); - dev->data->rx_queues =NULL ; - dev->data->nb_tx_queues =0 ; -rte_free (dev->data->tx_queues); - dev->data->tx_queues =NULL ; +rte_eth_dev_release_port (dev); }int
lib/librte_ethdev/rte_ethdev.h +1 -2
@@ -1802,8 +1802,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.19.0
Re: [PATCH v3 2/2] ethdev: complete closing of port
Quoted 43 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 4 files changed, 4 insertions(+), 16 deletions(-)drivers/net/bnxt/bnxt_ethdev.c +0
-4@@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)if (bp->dev_stopped ==0 )bnxt_dev_stop_op (eth_dev); -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 ;drivers/net/vhost/rte_eth_vhost.c +0
-0@@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++)rte_free (dev->data->tx_queues[i]);
drivers/net/vhost/rte_eth_vhost.c eth_dev_close(struct rte_eth_dev *dev) · line 1005
Quoted 10 lines
drivers/net/vhost/rte_eth_vhost.c +0
-4-rte_free (dev->data->mac_addrs);free (internal->dev_name);free (internal->iface_name); -rte_free (internal); - - dev->data->dev_private =NULL ; } static int
It looks like above snippets should be a part of previous changeset.
Quoted 17 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev);
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1392
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +1
-6- dev->data->nb_rx_queues =0 ; -rte_free (dev->data->rx_queues); - dev->data->rx_queues =NULL ; - dev->data->nb_tx_queues =0 ; -rte_free (dev->data->tx_queues); - dev->data->tx_queues =NULL ; +rte_eth_dev_release_port (dev); }int
Right now it introduces resource leak for resources which are freed by PCI drivers in uninit.
Re: [PATCH v3 2/2] ethdev: complete closing of port
16/10/2018 13:24, Andrew Rybchenko:
Quoted 53 lines · Thomas Monjalon
Quoted 52 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 4 files changed, 4 insertions(+), 16 deletions(-)drivers/net/bnxt/bnxt_ethdev.c +0
-4@@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)if (bp->dev_stopped ==0 )bnxt_dev_stop_op (eth_dev); -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 ;drivers/net/vhost/rte_eth_vhost.c +0
-4@@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++)rte_free (dev->data->tx_queues[i]); -rte_free (dev->data->mac_addrs);free (internal->dev_name);free (internal->iface_name); -rte_free (internal); - - dev->data->dev_private =NULL ; }
Quoted 3 lines
drivers/net/vhost/rte_eth_vhost.c eth_dev_close(struct rte_eth_dev *dev) · line 1005
Quoted 1 line
drivers/net/vhost/rte_eth_vhost.c +0
-0static intIt looks like above snippets should be a part of previous changeset.
No, this is related to close function.
Quoted 24 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.c +3
-6@@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev); - dev->data->nb_rx_queues =0 ; -rte_free (dev->data->rx_queues); - dev->data->rx_queues =NULL ; - dev->data->nb_tx_queues =0 ; -rte_free (dev->data->tx_queues); - dev->data->tx_queues =NULL ; +rte_eth_dev_release_port (dev); }
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1392
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +0
-0int Right now it introduces resource leak for resources which are freed by PCI drivers in uninit.
No, these resources are freed by rte_eth_dev_release_port.
v3 cover ethdev port freeing
In reply to Thomas MonjalonThe function rte_eth_dev_detach() is freeing a port and its underlying rte_device object. The issue is that we may have several ports associated to the same rte_device.
The right replacement is to free the port, and free the rte_device if no more ports.
At ethdev level, the public function for port freeing is rte_eth_dev_close(). The only miss is rte_eth_dev_release_port() to free all port resources.
This patchset does a cleanup by moving as much ethdev data freeing as possible in an unique function rte_eth_dev_release_port(), and call this function in rte_eth_dev_close().
Changes in v4:
- do not free data fields which are not dynamically allocated blocks
- remove rte_eth_dev_release_port_secondary()
- remove testpmd check to detach without closing
Changes in v3:
- free queues, MAC addresses and private structure in rte_eth_dev_release_port.
Note: this patchset depends on multi-process hotplug series by Qi Zhang, which is accepted but waiting for an unrelated DPAA compilation issue to be fixed, before landing on master tree.
Thomas Monjalon (4):
app/testpmd: allow detaching a port not closed
ethdev: free all common data when releasing port
ethdev: remove release function for secondary process
ethdev: complete closing of port
app/test-pmd/testpmd.c | 22 ++--------- drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++-- 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 | 8 ---- drivers/net/bonding/rte_eth_bond_pmd.c | 9 +---- 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 | 6 ++- drivers/net/failsafe/failsafe_ops.c | 2 + drivers/net/fm10k/fm10k_ethdev.c | 8 ---- drivers/net/i40e/i40e_ethdev.c | 3 -- drivers/net/i40e/i40e_ethdev_vf.c | 3 -- drivers/net/i40e/i40e_vf_representor.c | 5 ++- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ----- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 ++- drivers/net/kni/rte_eth_kni.c | 7 ++-- drivers/net/liquidio/lio_ethdev.c | 3 -- drivers/net/mlx4/mlx4.c | 7 +++- drivers/net/mlx5/mlx5.c | 11 ++++-- drivers/net/mvneta/mvneta_ethdev.c | 16 +++----- drivers/net/mvpp2/mrvl_ethdev.c | 16 +++----- drivers/net/netvsc/hn_ethdev.c | 20 +++------- drivers/net/null/rte_eth_null.c | 7 +--- drivers/net/octeontx/octeontx_ethdev.c | 31 ++++++---------- drivers/net/pcap/rte_eth_pcap.c | 16 ++++---- drivers/net/qede/qede_ethdev.c | 5 --- drivers/net/ring/rte_eth_ring.c | 6 +-- drivers/net/sfc/sfc_ethdev.c | 3 -- drivers/net/softnic/rte_eth_softnic.c | 10 ++--- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 11 +++++- drivers/net/vhost/rte_eth_vhost.c | 15 ++------ 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 | 45 +++++++---------------- lib/librte_ethdev/rte_ethdev.h | 3 +- lib/librte_ethdev/rte_ethdev_driver.h | 25 +++++-------- lib/librte_ethdev/rte_ethdev_pci.h | 17 --------- lib/librte_ethdev/rte_ethdev_version.map | 7 ---- 48 files changed, 129 insertions(+), 323 deletions(-)
Signature · 1 line
2.19.0
PATCH v3 1/4 app/testpmd: allow detaching a port not closed
The testpmd application aim is for testing;
so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
--- app/test-pmd/testpmd.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
app/test-pmd/testpmd.c +4 -18
@@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id)return 1 ; } -static int -port_is_closed (portid_t port_id) -{ -if (port_id_is_invalid (port_id,ENABLED_WARN )) -return 0 ; - -if (ports[port_id].port_status !=RTE_PORT_CLOSED ) -return 0 ; - -return 1 ; -} -int start_port (portid_t pid) {
@@ -2319,14 +2307,12 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" ); -if (!port_is_closed (port_id)) { -printf ("Please close port first\n" ); -return ; +if (ports[port_id].port_status !=RTE_PORT_CLOSED ) { +printf ("Port not closed\n" ); +if (ports[port_id].flow_list) +port_flow_flush (port_id); } -if (ports[port_id].flow_list) -port_flow_flush (port_id); -if (rte_eth_dev_detach (port_id, name)) {TESTPMD_LOG (ERR ,"Failed to detach port %u\n" , port_id);return ;
Signature · 1 line
2.19.0
Re: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed
+Cc Bernard
Note that the function port_is_closed is replaced because a closed port is always seen as invalid after this series:
the state is set to RTE_ETH_DEV_UNUSED by rte_eth_dev_release_port(). I may split this patch and add a release note to make it clear.
17/10/2018 03:54, Thomas Monjalon:
Quoted 55 lines
The testpmd application aim is for testing;
so order of operations should not be enforced.There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Signed-off-by Thomas Monjalon <[email protected]>--- app/test-pmd/testpmd.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)app/test-pmd/testpmd.c +4
-18@@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id)return 1 ; } -static int -port_is_closed (portid_t port_id) -{ -if (port_id_is_invalid (port_id,ENABLED_WARN )) -return 0 ; - -if (ports[port_id].port_status !=RTE_PORT_CLOSED ) -return 0 ; - -return 1 ; -} -int start_port (portid_t pid) {@@ -2319,14 +2307,12 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" ); -if (!port_is_closed (port_id)) { -printf ("Please close port first\n" ); -return ; +if (ports[port_id].port_status !=RTE_PORT_CLOSED ) { +printf ("Port not closed\n" ); +if (ports[port_id].flow_list) +port_flow_flush (port_id); } -if (ports[port_id].flow_list) -port_flow_flush (port_id); -if (rte_eth_dev_detach (port_id, name)) {TESTPMD_LOG (ERR ,"Failed to detach port %u\n" , port_id);return ;
Re: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed
In reply to Thomas MonjalonQuoted 8 lines · Thomas Monjalon
The testpmd application aim is for testing;
so order of operations should not be enforced.There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Signed-off-by Thomas Monjalon <[email protected]>
I'm afraid it could be a problem which the patch, since port close ensures that the port is not used for traffic forwarding. Right now the check is gone and we can detach port which is used for traffic forwarding on separate data cores. So, almost guaranteed crash.
Re: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed
17/10/2018 08:26, Andrew Rybchenko:
Quoted 8 lines · Thomas Monjalon
Quoted 7 lines
The testpmd application aim is for testing;
so order of operations should not be enforced.There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Quoted 7 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'm afraid it could be a problem which the patch, since port close ensures that the port is not used for traffic forwarding. Right now the check is gone and we can detach port which is used for traffic forwarding on separate data cores. So, almost guaranteed crash.
Yes I can duplicate this check in detach_port().
Re: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed
Hi Thomas,
Quoted 20 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Wednesday, October 17, 2018 9:21 AM
To: Andrew Rybchenko <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/4] app/testpmd: allow detaching a port not closed17/10/2018 08:26, Andrew Rybchenko:
Quoted 10 lines · Thomas Monjalon
Quoted 8 lines
The testpmd application aim is for testing; so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Signed-off-by Thomas Monjalon <[email protected]>
Quoted 7 lines
Quoted 5 lines
I'm afraid it could be a problem which the patch, since port close ensures that the port is not used for traffic forwarding. Right now the check is gone and we can detach port which is used for traffic forwarding on separate data cores.
So, almost guaranteed crash.Yes I can duplicate this check in
detach_port().
I agree with Andrew that this will cause a crash.
I don't understand why the sequence is changing here.
The close(), detach() sequence has been in place since the port hot plug work some years ago, user applications may already be using this sequence.
Regards,
Bernard.
Re: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed
17/10/2018 12:30, Iremonger, Bernard:
Quoted 20 lines
Hi Thomas,
From: Thomas Monjalon
Quoted 17 lines
17/10/2018 08:26, Andrew Rybchenko:
Quoted 15 lines · Thomas Monjalon
Quoted 8 lines
The testpmd application aim is for testing; so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Signed-off-by Thomas Monjalon <[email protected]>I'm afraid it could be a problem which the patch, since port close ensures that the port is not used for traffic forwarding. Right now the check is gone and we can detach port which is used for traffic forwarding on separate data cores.
So, almost guaranteed crash.
Quoted 3 lines
Quoted 1 line
Yes I can duplicate this check in
detach_port().I agree with Andrew that this will cause a crash.
As I answered, I will add a check that port is stopped.
Quoted 2 lines
I don't understand why the sequence is changing here.
Theclose(),detach()sequence has been in place since the port hot plug work some years ago, user applications may already be using this sequence.
I explained the reason in the commit log:
Adding too much checks is wrong for a test application. We must be free to call detach without close.
PATCH v3 2/4 ethdev: free all common data when releasing port
In reply to Thomas MonjalonThis 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.
--- drivers/net/af_packet/rte_eth_af_packet.c | 5 ++-- 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 | 6 +++-- drivers/net/fm10k/fm10k_ethdev.c | 8 ------- drivers/net/i40e/i40e_ethdev.c | 3 --- drivers/net/i40e/i40e_ethdev_vf.c | 3 --- drivers/net/i40e/i40e_vf_representor.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ------- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 +++- drivers/net/kni/rte_eth_kni.c | 5 ++-- drivers/net/liquidio/lio_ethdev.c | 3 --- drivers/net/mlx4/mlx4.c | 5 ++-- drivers/net/mlx5/mlx5.c | 9 +++---- drivers/net/mvneta/mvneta_ethdev.c | 16 ++++--------- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++++--------- drivers/net/netvsc/hn_ethdev.c | 15 ++---------- drivers/net/null/rte_eth_null.c | 4 ++-- drivers/net/octeontx/octeontx_ethdev.c | 29 +++++++++-------------- drivers/net/pcap/rte_eth_pcap.c | 8 +++---- drivers/net/qede/qede_ethdev.c | 5 ---- drivers/net/ring/rte_eth_ring.c | 6 ++--- drivers/net/sfc/sfc_ethdev.c | 3 --- drivers/net/softnic/rte_eth_softnic.c | 7 +++--- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 6 ++++- 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 | 21 ++++++++-------- lib/librte_ethdev/rte_ethdev_driver.h | 11 ++++++++- lib/librte_ethdev/rte_ethdev_pci.h | 10 -------- 44 files changed, 92 insertions(+), 231 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
@@ -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 ;
drivers/net/ark/ark_ethdev.c +0 -1
@@ -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 ; }
drivers/net/avf/avf_ethdev.c +0 -3
@@ -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 ;
drivers/net/avp/avp_ethdev.c +0 -5
@@ -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 ; }
drivers/net/axgbe/axgbe_ethdev.c +0 -3
@@ -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 ;
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -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 ;
drivers/net/bonding/rte_eth_bond_pmd.c +1 -6
@@ -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 ; }
@@ -3292,8 +3289,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);
drivers/net/cxgbe/cxgbe_main.c +2 -14
@@ -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 )
drivers/net/cxgbe/cxgbevf_main.c +1 -8
@@ -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; }
drivers/net/dpaa/dpaa_ethdev.c +0 -10
@@ -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 ;
drivers/net/dpaa2/dpaa2_ethdev.c +0 -10
@@ -2062,12 +2062,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) {
@@ -2130,8 +2124,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; }
@@ -2144,8 +2136,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 ;
drivers/net/e1000/em_ethdev.c +0 -3
@@ -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,
drivers/net/e1000/igb_ethdev.c +0 -6
@@ -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,
drivers/net/enetc/enetc_ethdev.c +1 -3
@@ -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 ; }
drivers/net/failsafe/failsafe.c +4 -2
@@ -280,7 +280,8 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) 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; }
drivers/net/fm10k/fm10k_ethdev.c +0 -8
@@ -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 ; }
drivers/net/i40e/i40e_ethdev.c +0 -3
@@ -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);
drivers/net/i40e/i40e_ethdev_vf.c +0 -3
@@ -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 ; }
drivers/net/i40e/i40e_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/ixgbe/ixgbe_ethdev.c +0 -9
@@ -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);
drivers/net/ixgbe/ixgbe_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/kni/rte_eth_kni.c +3 -2
@@ -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--;
drivers/net/liquidio/lio_ethdev.c +0 -3
@@ -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 ;
drivers/net/mlx4/mlx4.c +3 -2
@@ -785,8 +785,9 @@ 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); +/* 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 ; }/*
drivers/net/mlx5/mlx5.c +5 -4
@@ -1226,8 +1226,9 @@ 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); +/* 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 +1448,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. */
drivers/net/mvneta/mvneta_ethdev.c +5 -11
@@ -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); }
drivers/net/mvpp2/mrvl_ethdev.c +5 -11
@@ -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); }
drivers/net/netvsc/hn_ethdev.c +2 -13
@@ -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 ; }
drivers/net/null/rte_eth_null.c +2 -2
@@ -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 ;
drivers/net/octeontx/octeontx_ethdev.c +11 -18
@@ -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; }
@@ -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); }
drivers/net/pcap/rte_eth_pcap.c +3 -5
@@ -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 ;
drivers/net/qede/qede_ethdev.c +0 -5
@@ -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 ; }
drivers/net/ring/rte_eth_ring.c +2 -4
@@ -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 ; }
drivers/net/sfc/sfc_ethdev.c +0 -3
@@ -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);
drivers/net/softnic/rte_eth_softnic.c +3 -4
@@ -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,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 ; }
drivers/net/szedata2/rte_eth_szedata2.c +0 -1
@@ -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);
drivers/net/tap/rte_eth_tap.c +5 -1
@@ -1808,6 +1808,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, 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:
@@ -2076,6 +2078,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);
@@ -2102,7 +2107,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 ) {
drivers/net/vhost/rte_eth_vhost.c +3 -6
@@ -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 ;
drivers/net/virtio/virtio_ethdev.c +0 -3
@@ -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,
drivers/net/virtio/virtio_user_ethdev.c +0 -3
@@ -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 ;
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -3
@@ -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 ; }
lib/librte_ethdev/rte_ethdev.c +10 -11
@@ -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: +probe_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); }
lib/librte_ethdev/rte_ethdev_driver.h +10 -1
@@ -58,7 +58,16 @@ 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 data fields will be freed: +* - rx_queues +* - tx_queues +* - mac_addrs +* - hash_mac_addrs +* - dev_private +* If one of these fields should not be freed, +* it must be reset to NULL by the caller. * * @param eth_dev * Device to be detached.
lib/librte_ethdev/rte_ethdev_pci.h +0 -10
@@ -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 ;
Signature · 1 line
2.19.0
Re: [PATCH v3 2/4] ethdev: free all common data when releasing port
Quoted 8 lines · Thomas Monjalon
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 <[email protected]>
[...]
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0
lib/librte_ethdev/rte_ethdev_driver.h struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); · line 65
Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +5
-1@@ -58,7 +58,16 @@ 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 data fields will be freed: +* - rx_queues +* - tx_queues
I think rx_queues and tx_queues from should not be mentioned here. They are managed by ethdev and there is no options here.
lib/librte_ethdev/rte_ethdev_driver.h struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); · line 70
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +5
-0+* - mac_addrs +* - hash_mac_addrs +* - dev_private +* If one of these fields should not be freed, +* it must be reset to NULL by the caller.
I'm afraid nobody will find it here. Let's add
@see rte_eth_dev_release_port()
to these members description in rte_ethdev_core.h
struct rte_eth_dev_data.
Also I think "by the caller" is misleading here. Let's highlight that it is PMD responsibility, i.e. "by the PMD" may be with
"typically in dev_close method implementation".
Andrew.
Re: [PATCH v3 2/4] ethdev: free all common data when releasing port
17/10/2018 09:13, Andrew Rybchenko:
Quoted 41 lines · Thomas Monjalon
Quoted 8 lines
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 <[email protected]>[...]
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0lib/librte_ethdev/rte_ethdev_driver.h struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); · line 65
Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +5
-1@@ -58,7 +58,16 @@ 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 data fields will be freed: +* - rx_queues +* - tx_queues I think
rx_queuesandtx_queuesfrom should not be mentioned here. They are managed by ethdev and there is no options here.lib/librte_ethdev/rte_ethdev_driver.h struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); · line 70
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +5
-0+* - mac_addrs +* - hash_mac_addrs +* - dev_private +* If one of these fields should not be freed, +* it must be reset to NULL by the caller. I'm afraid nobody will find it here. Let's add
@seerte_eth_dev_release_port()
to these members description inrte_ethdev_core.h
structrte_eth_dev_data.
Quoted 4 lines
Also I think "by the caller" is misleading here. Let's highlight that it is PMD responsibility, i.e. "by the PMD" may be with
"typically indev_closemethod implementation".
OK, thanks for the feedback.
PATCH v3 3/4 ethdev: remove release function for secondary process
In reply to Thomas MonjalonAfter previous changes, the function rte_eth_dev_release_port() can be used for primary or secondary process as well. The only difference with rte_eth_dev_release_port_secondary() is the shared lock used in rte_eth_dev_release_port().
The function rte_eth_dev_release_port_secondary() was recently added in 18.11 cycle.
--- drivers/net/af_packet/rte_eth_af_packet.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- drivers/net/kni/rte_eth_kni.c | 2 +- drivers/net/null/rte_eth_null.c | 3 --- drivers/net/octeontx/octeontx_ethdev.c | 2 +- drivers/net/pcap/rte_eth_pcap.c | 3 --- drivers/net/tap/rte_eth_tap.c | 2 +- drivers/net/vhost/rte_eth_vhost.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 15 --------------- lib/librte_ethdev/rte_ethdev_driver.h | 14 -------------- lib/librte_ethdev/rte_ethdev_pci.h | 7 ------- lib/librte_ethdev/rte_ethdev_version.map | 7 ------- 12 files changed, 6 insertions(+), 55 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
@@ -990,7 +990,7 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;for (q =0 ; q < internals->nb_queues; q++) {
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
@@ -3265,7 +3265,7 @@ bond_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);RTE_ASSERT (eth_dev->device == &dev->device);
drivers/net/kni/rte_eth_kni.c +1 -1
@@ -467,7 +467,7 @@ eth_kni_remove(struct rte_vdev_device *vdev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_kni_dev_stop (eth_dev);
drivers/net/null/rte_eth_null.c +0 -3
@@ -679,9 +679,6 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); -/* 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);
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -1129,7 +1129,7 @@ octeontx_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { -rte_eth_dev_release_port_secondary (eth_dev); +rte_eth_dev_release_port (eth_dev);continue ; }
drivers/net/pcap/rte_eth_pcap.c +0 -3
@@ -1228,9 +1228,6 @@ pmd_pcap_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); - internals = eth_dev->data->dev_private;if (internals !=NULL && internals->phy_mac ==0 )/* not dynamically allocated, must not be freed */
drivers/net/tap/rte_eth_tap.c +1 -1
@@ -2082,7 +2082,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -1433,7 +1433,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_dev_close (eth_dev);
lib/librte_ethdev/rte_ethdev.c +0 -15
@@ -362,18 +362,6 @@ rte_eth_dev_attach_secondary(const char *name)return eth_dev; } -int -rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev) -{ -if (eth_dev ==NULL ) -return -EINVAL ; - -_rte_eth_dev_callback_process (eth_dev,RTE_ETH_EVENT_DESTROY ,NULL ); - eth_dev->state =RTE_ETH_DEV_UNUSED ; - -return 0 ; -} -int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev) {
@@ -3591,9 +3579,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,return ret; } -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (ethdev); -return rte_eth_dev_release_port (ethdev); }
lib/librte_ethdev/rte_ethdev_driver.h +0 -14
@@ -76,20 +76,6 @@ struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);*/ int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev); -/** -* @internal -* Release the specified ethdev port in the local process. -* Only set ethdev state to unused, but not reset shared data since -* it assume other processes is still using it. typically it is -* called by a secondary process. -* -* @param eth_dev -* Device to be detached. -* @return -* - 0 on success, negative on error -*/ -int rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev); -/** * @internal * Release device queues and clear its configuration to force the user
lib/librte_ethdev/rte_ethdev_pci.h +0 -7
@@ -135,13 +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 ) { - eth_dev->device =NULL ; - eth_dev->intr_handle =NULL ; -rte_eth_dev_release_port_secondary (eth_dev); -return ; - } - eth_dev->device =NULL ; eth_dev->intr_handle =NULL ;
lib/librte_ethdev/rte_ethdev_version.map +0 -7
@@ -220,13 +220,6 @@ DPDK_18.08 { } DPDK_18.05; -DPDK_18.11 { - global: - - rte_eth_dev_release_port_secondary; - -} DPDK_18.08; - EXPERIMENTAL { global:
Signature · 1 line
2.19.0
Re: [PATCH v3 3/4] ethdev: remove release function for secondary process
Quoted 9 lines · Thomas Monjalon
After previous changes, the function
rte_eth_dev_release_port()can be used for primary or secondary process as well. The only difference withrte_eth_dev_release_port_secondary()is the shared lock used inrte_eth_dev_release_port().The function
rte_eth_dev_release_port_secondary()was recently added in 18.11 cycle.Signed-off-by Thomas Monjalon <[email protected]>
I really like it. Few notes below.
drivers/net/null/rte_eth_null.c rte_pmd_null_remove(struct rte_vdev_device *dev) · line 683
Quoted 13 lines
drivers/net/null/rte_eth_null.c +0
-3@@ -679,9 +679,6 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); -/* mac_addrs must not be freed alone because part of dev_private */ eth_dev->data->mac_addrs =NULL ;
I think it should be done in primary process only.
Quoted 6 lines
drivers/net/null/rte_eth_null.c +0
-0rte_eth_dev_release_port (eth_dev);drivers/net/pcap/rte_eth_pcap.c +0
-0
drivers/net/pcap/rte_eth_pcap.c pmd_pcap_remove(struct rte_vdev_device *dev) · line 1233
Quoted 9 lines
drivers/net/pcap/rte_eth_pcap.c +0
-3@@ -1228,9 +1228,6 @@ pmd_pcap_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); - internals = eth_dev->data->dev_private;if (internals !=NULL && internals->phy_mac ==0 )/* not dynamically allocated, must not be freed */
Like above I think that assignment (which follows) should be done in the primary process only.
Re: [PATCH v3 3/4] ethdev: remove release function for secondary process
17/10/2018 09:25, Andrew Rybchenko:
Quoted 38 lines · Thomas Monjalon
Quoted 9 lines
After previous changes, the function
rte_eth_dev_release_port()can be used for primary or secondary process as well. The only difference withrte_eth_dev_release_port_secondary()is the shared lock used inrte_eth_dev_release_port().The function
rte_eth_dev_release_port_secondary()was recently added in 18.11 cycle.Signed-off-by Thomas Monjalon <[email protected]>I really like it. Few notes below.
drivers/net/null/rte_eth_null.c rte_pmd_null_remove(struct rte_vdev_device *dev) · line 683
Quoted 13 lines
drivers/net/null/rte_eth_null.c +0
-3@@ -679,9 +679,6 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); -/* mac_addrs must not be freed alone because part of dev_private */ eth_dev->data->mac_addrs =NULL ;I think it should be done in primary process only.
Quoted 9 lines
drivers/net/null/rte_eth_null.c +0
-0rte_eth_dev_release_port (eth_dev);drivers/net/pcap/rte_eth_pcap.c +0
-0@@ -1228,9 +1228,6 @@ pmd_pcap_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ;
Quoted 9 lines
drivers/net/pcap/rte_eth_pcap.c pmd_pcap_remove(struct rte_vdev_device *dev) · line 1233
Quoted 6 lines
drivers/net/pcap/rte_eth_pcap.c +0
-3-if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); - internals = eth_dev->data->dev_private;if (internals !=NULL && internals->phy_mac ==0 )/* not dynamically allocated, must not be freed */ Like above I think that assignment (which follows) should be done in the primary process only.
I am not sure it has a real impact, because all processes are removing the device which should be already stopped.
But OK, I will avoid changing shared data in secondary process.
PATCH v3 4/4 ethdev: complete closing of port
In reply to Thomas MonjalonAfter closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in rte_eth_dev_release_port().
If the driver is trying to free the port again, the function rte_eth_dev_release_port() will abort with -ENODEV error.
--- drivers/net/af_packet/rte_eth_af_packet.c | 4 +++- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/failsafe/failsafe_ops.c | 2 ++ drivers/net/mlx4/mlx4.c | 2 ++ drivers/net/mlx5/mlx5.c | 2 ++ drivers/net/netvsc/hn_ethdev.c | 5 ++++- drivers/net/pcap/rte_eth_pcap.c | 5 +++++ drivers/net/softnic/rte_eth_softnic.c | 3 ++- drivers/net/tap/rte_eth_tap.c | 3 +++ drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 12 files changed, 27 insertions(+), 19 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +3 -1
@@ -362,8 +362,10 @@ eth_stats_reset(struct rte_eth_dev *dev) }static void -eth_dev_close(struct rte_eth_dev *dev __rte_unused) +eth_dev_close (struct rte_eth_dev *dev) { +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)if (bp->dev_stopped ==0 )bnxt_dev_stop_op (eth_dev); -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 ;
drivers/net/failsafe/failsafe_ops.c +2 -0
@@ -331,6 +331,8 @@ fs_dev_close(struct rte_eth_dev *dev) sdev->state =DEV_ACTIVE -1 ; }fs_dev_free_queues (dev); +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ;fs_unlock (dev,0 ); }
drivers/net/mlx4/mlx4.c +2 -0
@@ -218,6 +218,8 @@ mlx4_dev_close(struct rte_eth_dev *dev)assert (priv->ctx ==NULL );mlx4_intr_uninstall (priv);memset (priv,0 ,sizeof (*priv)); +/* mac_addrs must not be freed because part of dev_private */ + dev->data->mac_addrs =NULL ; }static const struct eth_dev_ops mlx4_dev_ops = {
drivers/net/mlx5/mlx5.c +2 -0
@@ -337,6 +337,8 @@ mlx5_dev_close(struct rte_eth_dev *dev) }memset (priv,0 ,sizeof (*priv)); priv->domain_id =RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID ; +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; }const struct eth_dev_ops mlx5_dev_ops = {
drivers/net/netvsc/hn_ethdev.c +4 -1
@@ -630,11 +630,14 @@ hn_dev_stop(struct rte_eth_dev *dev) }static void -hn_dev_close(struct rte_eth_dev *dev __rte_unused) +hn_dev_close (struct rte_eth_dev *dev) {PMD_INIT_LOG (DEBUG ,"close" );hn_vf_close (dev); + +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; }static const struct eth_dev_ops hn_eth_dev_ops = {
drivers/net/pcap/rte_eth_pcap.c +5 -0
@@ -623,6 +623,11 @@ eth_stats_reset(struct rte_eth_dev *dev)static void eth_dev_close(struct rte_eth_dev *dev __rte_unused) { +struct pmd_internals *internals = dev->data->dev_private; + +if (internals !=NULL && internals->phy_mac ==0 ) +/* not dynamically allocated, must not be freed */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/softnic/rte_eth_softnic.c +2 -1
@@ -194,8 +194,9 @@ pmd_dev_stop(struct rte_eth_dev *dev) }static void -pmd_dev_close(struct rte_eth_dev *dev __rte_unused) +pmd_dev_close (struct rte_eth_dev *dev) { + dev->data->mac_addrs =NULL ;/* statically allocated */ return ; }
drivers/net/tap/rte_eth_tap.c +3 -0
@@ -1000,6 +1000,9 @@ tap_dev_close(struct rte_eth_dev *dev)* Since TUN device has no more opened file descriptors * it will be removed from kernel */ + +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/vhost/rte_eth_vhost.c +0 -4
@@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++)rte_free (dev->data->tx_queues[i]); -rte_free (dev->data->mac_addrs);free (internal->dev_name);free (internal->iface_name); -rte_free (internal); - - dev->data->dev_private =NULL ; } static int
lib/librte_ethdev/rte_ethdev.c +3 -6
@@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev); - dev->data->nb_rx_queues =0 ; -rte_free (dev->data->rx_queues); - dev->data->rx_queues =NULL ; - dev->data->nb_tx_queues =0 ; -rte_free (dev->data->tx_queues); - dev->data->tx_queues =NULL ; +rte_eth_dev_release_port (dev); }int
lib/librte_ethdev/rte_ethdev.h +1 -2
@@ -1802,8 +1802,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.19.0
Re: [PATCH v3 4/4] ethdev: complete closing of port
17/10/2018 03:54, Thomas Monjalon:
Quoted 9 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().
[...]
Quoted 5 lines
/**
* Close a stopped Ethernet device. The device cannot be restarted!
- * The function frees all resources except for needed by the
- * closed state. To free these resources, callrte_eth_dev_detach().
+ * The function frees all port resources.
[...]
lib/librte_ethdev/rte_ethdev.c rte_eth_dev_close(uint16_t port_id) · line 1386
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +1
-0@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) +rte_eth_dev_release_port (dev);
After more thoughts, I think I should add a release note to explain that a closed port has its data freed and its state to RTE_ETH_DEV_UNUSED.
Re: [PATCH v3 0/4] ethdev port freeing
In reply to Thomas MonjalonQuoted 1 line · Thomas Monjalon
[...]
Quoted 5 lines
Note: this patchset depends on multi-process hotplug series by Qi Zhang, which is accepted but waiting for an unrelated DPAA compilation issue to be fixed, before landing on master tree.
Can you please point me to which DPAA compilation issue is being referred here?
Is that [1]? (which is DPAA2 and patch already sent)
[1] https://mails.dpdk.org/archives/test-report/2018-October/066840.html
Re: [PATCH v3 0/4] ethdev port freeing
17/10/2018 12:24, Shreyansh Jain:
Quoted 6 lines · Thomas Monjalon
Quoted 4 lines
Note: this patchset depends on multi-process hotplug series by Qi Zhang, which is accepted but waiting for an unrelated DPAA compilation issue to be fixed, before landing on master tree.
Quoted 6 lines
Can you please point me to which DPAA compilation issue is being referred here?
Is that [1]? (which is DPAA2 and patch already sent)
[1] https://mails.dpdk.org/archives/test-report/2018-October/066840.html
Yes, you fixed it.
So multi-process hotplug series is now on master branch.
v5 cover ethdev port freeing
In reply to Thomas MonjalonThe function rte_eth_dev_detach() is freeing a port and its underlying rte_device object. The issue is that we may have several ports associated to the same rte_device.
The right replacement is to free the port, and free the rte_device if no more ports.
At ethdev level, the public function for port freeing is rte_eth_dev_close(). The only miss is rte_eth_dev_release_port() to free all port resources.
This patchset does a cleanup by moving as much ethdev data freeing as possible in an unique function rte_eth_dev_release_port(), and call this function in rte_eth_dev_close().
Changes in v5:
- fix testpmd for detaching multi-ports device
- fix testpmd for detaching only stopped ports
- add a release note about closed port freeing and state
- fix some doxygen comments in rte_eth_dev_data
- improve doxygen of rte_eth_dev_release_port()
- fix data freeing in some drivers
Changes in v4:
- do not free data fields which are not dynamically allocated blocks
- remove rte_eth_dev_release_port_secondary()
- remove testpmd check to detach without closing
Changes in v3:
- free queues, MAC addresses and private structure in rte_eth_dev_release_port.
Thomas Monjalon (5):
app/testpmd: allow detaching a port not closed
ethdev: fix doxygen comments of shared data fields
ethdev: free all common data when releasing port
ethdev: remove release function for secondary process
ethdev: complete closing of port
Wisam Jaddo (1):
app/testpmd: fix ports list after removing several at once
app/test-pmd/testpmd.c | 64 +++++++++++++---------- doc/guides/rel_notes/release_18_11.rst | 4 ++ drivers/net/af_packet/rte_eth_af_packet.c | 11 ++-- 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 | 8 --- drivers/net/bonding/rte_eth_bond_pmd.c | 11 ++-- 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 | 6 ++- drivers/net/failsafe/failsafe_ops.c | 2 + drivers/net/fm10k/fm10k_ethdev.c | 8 --- drivers/net/i40e/i40e_ethdev.c | 3 -- drivers/net/i40e/i40e_ethdev_vf.c | 3 -- drivers/net/i40e/i40e_vf_representor.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ---- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 +- drivers/net/kni/rte_eth_kni.c | 7 +-- drivers/net/liquidio/lio_ethdev.c | 3 -- drivers/net/mlx4/mlx4.c | 9 +++- drivers/net/mlx5/mlx5.c | 13 +++-- drivers/net/mvneta/mvneta_ethdev.c | 16 ++---- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++---- drivers/net/netvsc/hn_ethdev.c | 20 +++---- drivers/net/null/rte_eth_null.c | 7 ++- drivers/net/octeontx/octeontx_ethdev.c | 31 +++++------ drivers/net/pcap/rte_eth_pcap.c | 19 ++++--- drivers/net/qede/qede_ethdev.c | 5 -- drivers/net/ring/rte_eth_ring.c | 6 +-- drivers/net/sfc/sfc_ethdev.c | 3 -- drivers/net/softnic/rte_eth_softnic.c | 10 ++-- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 11 +++- drivers/net/vhost/rte_eth_vhost.c | 15 ++---- 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 | 45 +++++----------- lib/librte_ethdev/rte_ethdev.h | 3 +- lib/librte_ethdev/rte_ethdev_core.h | 38 ++++++++------ lib/librte_ethdev/rte_ethdev_driver.h | 23 +++----- lib/librte_ethdev/rte_ethdev_pci.h | 17 ------ lib/librte_ethdev/rte_ethdev_version.map | 7 --- 50 files changed, 196 insertions(+), 347 deletions(-)
Signature · 1 line
2.19.0
PATCH v5 1/6 app/testpmd: fix ports list after removing several at once
From: Wisam Jaddo <[email protected]>
When detaching a port, the full rte_device is removed. If the rte_device was hosting several ports,
the testpmd list of ports must be updated for multiple removals.
--- app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
app/test-pmd/testpmd.c +25 -11
@@ -2186,6 +2186,30 @@ stop_port(portid_t pid)printf ("Done\n" ); } +static void +remove_unused_fwd_ports (void ) +{ +int i; +int last_port_idx = nb_ports -1 ; + +for (i =0 ; i < last_port_idx +1 ; i++) {/* iterate in ports_ids */ +if (rte_eth_devices[ports_ids[i]].state ==RTE_ETH_DEV_UNUSED ) { +/* skip unused ports at the end */ +while (rte_eth_devices[ports_ids[last_port_idx]].state + ==RTE_ETH_DEV_UNUSED && i <= last_port_idx) + last_port_idx--; +if (last_port_idx < i) +break ; +/* overwrite unused port with last valid port */ + ports_ids[i] = ports_ids[last_port_idx]; +/* decrease ports count */ + last_port_idx--; + } + } + nb_ports =rte_eth_dev_count_avail (); +update_fwd_ports (RTE_MAX_ETHPORTS ); +} +void close_port (portid_t pid) {
@@ -2315,7 +2339,6 @@ void detach_port(portid_t port_id) {char name[RTE_ETH_NAME_MAX_LEN ]; -uint16_t i;printf ("Detaching a port...\n" );
@@ -2332,16 +2355,7 @@ detach_port(portid_t port_id)return ; } -for (i =0 ; i < nb_ports; i++) { -if (ports_ids[i] == port_id) { - ports_ids[i] = ports_ids[nb_ports-1 ]; - ports_ids[nb_ports-1 ] =0 ; -break ; - } - } - nb_ports =rte_eth_dev_count_avail (); - -update_fwd_ports (RTE_MAX_ETHPORTS ); +remove_unused_fwd_ports ();printf ("Port %u is detached. Now total ports is %d\n" , port_id, nb_ports);
Signature · 1 line
2.19.0
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Hi Wisam,
Quoted 10 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, October 18, 2018 2:24 AM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Iremonger, Bernard <[email protected]>; [email protected]; Wisam Jaddo <[email protected]>
Subject: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Quoted 5 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed.
If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh -1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at once
Quoted 10 lines
Signed-off-by Wisam Jaddo <[email protected]>--- app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
5dbbf783f..c4109417a100644
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2195
Quoted 10 lines
app/test-pmd/testpmd.c +7
-0@@ -2186,6 +2186,30 @@ stop_port(portid_t pid)printf ("Done\n" ); } +static void +remove_unused_fwd_ports (void ) +{ +int i; +int last_port_idx = nb_ports -1 ; + +for (i =0 ; i < last_port_idx +1 ; i++) {/* iterate in ports_ids */
Why not use " i <= last_port_index" instead of adding back 1
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2201
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+if (rte_eth_devices[ports_ids[i]].state ==RTE_ETH_DEV_UNUSED ) { +/* skip unused ports at the end */ +while (rte_eth_devices[ports_ids[last_port_idx]].state + ==RTE_ETH_DEV_UNUSED && i <= last_port_idx)
WARNING:LONG_LINE: line over 80 characters
#48: FILE: app/test-pmd/testpmd.c:2199:
+ == RTE_ETH_DEV_UNUSED && i <= last_port_idx)
Quoted 43 lines
app/test-pmd/testpmd.c +13
-0+ last_port_idx--; +if (last_port_idx < i) +break ; +/* overwrite unused port with last valid port */ + ports_ids[i] = ports_ids[last_port_idx]; +/* decrease ports count */ + last_port_idx--; + } + } + nb_ports =rte_eth_dev_count_avail (); +update_fwd_ports (RTE_MAX_ETHPORTS ); +} +void
close_port(portid_t pid)
{app/test-pmd/testpmd.c +1
-12@@ -2315,7 +2339,6 @@ void detach_port(portid_t port_id) {char name[RTE_ETH_NAME_MAX_LEN ]; -uint16_t i;printf ("Detaching a port...\n" );@@ -2332,16 +2355,7 @@ detach_port(portid_t port_id)return ; } -for (i =0 ; i < nb_ports; i++) { -if (ports_ids[i] == port_id) { - ports_ids[i] = ports_ids[nb_ports-1 ]; - ports_ids[nb_ports-1 ] =0 ; -break ; - } - } - nb_ports =rte_eth_dev_count_avail (); - -update_fwd_ports (RTE_MAX_ETHPORTS ); +remove_unused_fwd_ports ();printf ("Port %u is detached. Now total ports is %d\n" , port_id, nb_ports); --
Quoted 1 line
2.19.0
Regards,
Bernard.
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
18/10/2018 12:40, Iremonger, Bernard:
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed.
If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at once
I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.
Quoted 13 lines
Quoted 13 lines
Signed-off-by Wisam Jaddo <[email protected]>--- app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
5dbbf783f..c4109417a100644app/test-pmd/testpmd.c +0
-0@@ -2186,6 +2186,30 @@ stop_port(portid_t pid)printf ("Done\n" ); }
Quoted 9 lines
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2195
Quoted 7 lines
app/test-pmd/testpmd.c +7
-0+static void +remove_unused_fwd_ports (void ) +{ +int i; +int last_port_idx = nb_ports -1 ; + +for (i =0 ; i < last_port_idx +1 ; i++) {/* iterate in ports_ids */ Why not use " i <=
last_port_index" instead of adding back 1
If Wisam agrees, I can fix it in v6.
Quoted 10 lines
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2201
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+if (rte_eth_devices[ports_ids[i]].state ==RTE_ETH_DEV_UNUSED ) { +/* skip unused ports at the end */ +while (rte_eth_devices[ports_ids[last_port_idx]].state + ==RTE_ETH_DEV_UNUSED && i <= last_port_idx)WARNING:LONG_LINE: line over 80 characters
#48: FILE:app/test-pmd/testpmd.c:2199:
+ ==RTE_ETH_DEV_UNUSED&& i <=last_port_idx)
Will fix it.
Anyway, we should reverse the order of this check in order to avoid accessing ports_ids[-1].
Quoted 1 line
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+ last_port_idx--;
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Hi Thomas
Quoted 19 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, October 18, 2018 12:29 PM
To: Iremonger, Bernard <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; Wisam Jaddo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once18/10/2018 12:40, Iremonger, Bernard:
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed. If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
Quoted 7 lines
Quoted 3 lines
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at onceI think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.
If "fix" is removed from the commit message then the fixes line will not be needed. However if it is a real fix, then I think fixes line should be added .
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Wisam Jaddo <[email protected]>
<snip>
Regards,
Bernard.
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
18/10/2018 13:41, Iremonger, Bernard:
Quoted 16 lines
Hi Thomas
From: Thomas Monjalon [mailto:[email protected]]
Quoted 13 lines
18/10/2018 12:40, Iremonger, Bernard:
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed. If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at once
Quoted 6 lines
Quoted 3 lines
I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.If "fix" is removed from the commit message then the fixes line will not be needed. However if it is a real fix, then I think fixes line should be added .
I know, I am the one implementing this check :-)
If I add a Fixes: line, it will warn about a lack of Cc:stable. But we don't need to backport this.
That's why I think we can ignore this warning.
Reminder: it is just warning, not a mandatory requirement.
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Hi Thomas,
Quoted 33 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, October 18, 2018 3:21 PM
To: Iremonger, Bernard <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; Wisam Jaddo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once18/10/2018 13:41, Iremonger, Bernard:
Quoted 16 lines
Hi Thomas
From: Thomas Monjalon [mailto:[email protected]]
Quoted 13 lines
18/10/2018 12:40, Iremonger, Bernard:
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed. If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at onceQuoted 5 lines
Quoted 3 lines
I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.If "fix" is removed from the commit message then the fixes line will not be
needed.
Quoted 10 lines
Quoted 1 line
However if it is a real fix, then I think fixes line should be added .
I know, I am the one implementing this check :-) If I add a Fixes: line, it will warn about a lack of Cc:stable.
But we don't need to backport this.
That's why I think we can ignore this warning.Reminder: it is just warning, not a mandatory requirement.
As this does not seem to be a normal "fix", how about replacing "fix" with something like "update", then there will be no warning to ignore. Better not have warnings.
Regards,
Bernard.
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
18/10/2018 18:42, Iremonger, Bernard:
Quoted 33 lines
Hi Thomas,
From: Thomas Monjalon [mailto:[email protected]]
Quoted 30 lines
18/10/2018 13:41, Iremonger, Bernard:
Quoted 16 lines
Hi Thomas
From: Thomas Monjalon [mailto:[email protected]]
Quoted 13 lines
18/10/2018 12:40, Iremonger, Bernard:
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed. If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at onceQuoted 5 lines
Quoted 3 lines
I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.If "fix" is removed from the commit message then the fixes line will not be
needed.
Quoted 1 line
However if it is a real fix, then I think fixes line should be added .
I know, I am the one implementing this check :-) If I add a Fixes: line, it will warn about a lack of Cc:stable.
But we don't need to backport this.
That's why I think we can ignore this warning.
Quoted 5 lines
Quoted 3 lines
Reminder: it is just warning, not a mandatory requirement.
As this does not seem to be a normal "fix", how about replacing "fix" with something like "update", then there will be no warning to ignore. Better not have warnings.
Yes, I thought about it and felt that "update" would not have the same meaning. If nobody has a better idea, I will replace with "update" instead of "fix".
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
In reply to Thomas MonjalonAre we saving cycles by set it to be <= instead of < _ +1?
BRs,
Wisam Jaddo
From: Thomas Monjalon<mailto:[email protected]>
Sent: Thursday, October 18, 2018 2:29 PM
To: Iremonger, Bernard<mailto:[email protected]>
Cc: [email protected]<mailto:[email protected]>; Yigit, Ferruh<mailto:[email protected]>; [email protected]<mailto:[email protected]>; Ophir Munk<mailto:[email protected]>; [email protected]<mailto:[email protected]>; Wisam Monther<mailto:[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
18/10/2018 12:40, Iremonger, Bernard:
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed.
If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.
./devtools/check-git-log.sh-1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at once
I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.
Quoted 13 lines
Quoted 13 lines
Signed-off-by Wisam Jaddo <[email protected]>--- app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
5dbbf783f..c4109417a100644app/test-pmd/testpmd.c +0
-0@@ -2186,6 +2186,30 @@ stop_port(portid_t pid)printf ("Done\n" ); }
Quoted 9 lines
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2195
Quoted 7 lines
app/test-pmd/testpmd.c +7
-0+static void +remove_unused_fwd_ports (void ) +{ +int i; +int last_port_idx = nb_ports -1 ; + +for (i =0 ; i < last_port_idx +1 ; i++) {/* iterate in ports_ids */ Why not use " i <=
last_port_index" instead of adding back 1
If Wisam agrees, I can fix it in v6.
Quoted 10 lines
app/test-pmd/testpmd.c stop_port(portid_t pid) · line 2201
Quoted 6 lines
app/test-pmd/testpmd.c +4
-0+if (rte_eth_devices[ports_ids[i]].state ==RTE_ETH_DEV_UNUSED ) { +/* skip unused ports at the end */ +while (rte_eth_devices[ports_ids[last_port_idx]].state + ==RTE_ETH_DEV_UNUSED && i <= last_port_idx)WARNING:LONG_LINE: line over 80 characters
#48: FILE:app/test-pmd/testpmd.c:2199:
+ ==RTE_ETH_DEV_UNUSED&& i <=last_port_idx)
Will fix it.
Anyway, we should reverse the order of this check in order to avoid accessing ports_ids[-1].
Quoted 1 line
Quoted 1 line
app/test-pmd/testpmd.c +1
-0+ last_port_idx--;
Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Hi Wisam,
From: Wisam Monther [mailto:[email protected]]
Sent: Thursday, October 18, 2018 12:49 PM
To: Thomas Monjalon <[email protected]>; Iremonger, Bernard <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Ophir Munk <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Are we saving cycles by set it to be <= instead of < _ +1?
No idea, just looks cleaner to me.
BRs,
Wisam Jaddo
<snip>
Regards,
Bernard.
PATCH v5 2/6 app/testpmd: allow detaching a port not closed
In reply to Thomas MonjalonThe testpmd application aim is for testing;
so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
--- app/test-pmd/testpmd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +7 -5
@@ -2343,13 +2343,15 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" );if (!port_is_closed (port_id)) { -printf ("Please close port first\n" ); -return ; +if (ports[port_id].port_status !=RTE_PORT_STOPPED ) { +printf ("Port not stopped\n" ); +return ; + } +printf ("Port was not closed\n" ); +if (ports[port_id].flow_list) +port_flow_flush (port_id); } -if (ports[port_id].flow_list) -port_flow_flush (port_id); -if (rte_eth_dev_detach (port_id, name)) {TESTPMD_LOG (ERR ,"Failed to detach port %u\n" , port_id);return ;
Signature · 1 line
2.19.0
Re: [PATCH v5 2/6] app/testpmd: allow detaching a port not closed
Quoted 6 lines · Thomas Monjalon
The testpmd application aim is for testing;
so order of operations should not be enforced.There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Yes. In the case of net/sfc it requires a patch to call sfc_dev_close() from uninit. I think network PMD maintainers should be notified to double-check drivers.
Quoted 2 lines
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
I thought that it is sufficient to stop traffic and the port may be stopped automatically by PMD. Not sure about it, just would like to clarify my previous notes.
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>
[...]
Re: [PATCH v5 2/6] app/testpmd: allow detaching a port not closed
Hi Thomas,
Quoted 23 lines
-----Original Message-----
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Thursday, October 18, 2018 8:45 AM
To: Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Iremonger, Bernard <[email protected]>; [email protected]
Subject: Re: [PATCH v5 2/6] app/testpmd: allow detaching a port not closedQuoted 6 lines · Thomas Monjalon
The testpmd application aim is for testing; so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Yes. In the case of net/sfc it requires a patch to call
sfc_dev_close()from uninit. I think network PMD maintainers should be notified to double-check drivers.Quoted 2 lines
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
Quoted 7 lines
I thought that it is sufficient to stop traffic and the port may be stopped automatically by PMD. Not sure about it, just would like to clarify my previous notes.
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>[...]
This patch seems too risky as it may impact some of the PMD's.
Regards,
Bernard.
Re: [PATCH v5 2/6] app/testpmd: allow detaching a port not closed
18/10/2018 12:51, Iremonger, Bernard:
Quoted 19 lines
From: Andrew Rybchenko [mailto:[email protected]]
Quoted 18 lines · Thomas Monjalon
Quoted 6 lines
The testpmd application aim is for testing; so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
Yes. In the case of net/sfc it requires a patch to call
sfc_dev_close()from uninit. I think network PMD maintainers should be notified to double-check drivers.Quoted 2 lines
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
I thought that it is sufficient to stop traffic and the port may be stopped automatically by PMD. Not sure about it, just would like to clarify my previous notes.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>[...]
This patch seems too risky as it may impact some of the PMD's.
Yes, it will not work for all PMDs.
If we want to allow this scenario, we'll need to improve some PMDs. This patch is just allowing to test the scenario.
It will help PMD developers, so I think it is more helpful than risky.
PATCH v5 3/6 ethdev: fix doxygen comments of shared data fields
In reply to Thomas MonjalonSome doxygen comments were wrongly associated to the next field because of syntax /** instead of /**<
Some other cleanups (like alignment) are done.
--- lib/librte_ethdev/rte_ethdev_core.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
lib/librte_ethdev/rte_ethdev_core.h +13 -15
@@ -581,22 +581,20 @@ struct rte_eth_dev_data {void *dev_private;/**< PMD-specific private data */ -struct rte_eth_link dev_link; -/**< Link-level information & status */ - +struct rte_eth_link dev_link;/**< Link-level information & status. */ struct rte_eth_conf dev_conf;/**< Configuration applied to device. */ uint16_t mtu;/**< Maximum Transmission Unit. */ -uint32_t min_rx_buf_size; -/**< Common rx buffer size handled by all queues */ +/**< 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. */ uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR ]; -/** bitmap array of associating Ethernet MAC addresses to pools */ -struct ether_addr * hash_mac_addrs; -/** Device Ethernet MAC addresses of hash filtering. */ +/**< Bitmap associating MAC addresses to pools. */ +struct ether_addr *hash_mac_addrs; +/**< Device Ethernet MAC addresses of hash filtering. */ uint16_t port_id;/**< Device [external] port identifier. */ + __extension__ uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */ scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
@@ -604,14 +602,14 @@ struct rte_eth_dev_data { dev_started :1 ,/**< Device state: STARTED(1) / STOPPED(0). */ lro : 1; /**< RX LRO is ON(1) / OFF(0) */uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT ]; -/** Queues state: STARTED(1) / STOPPED(0) */ +/**< Queues state: STARTED(1) / STOPPED(0). */ uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT ]; -/** Queues state: STARTED(1) / STOPPED(0) */ -uint32_t dev_flags;/**< Capabilities */ -enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ -int numa_node;/**< NUMA node connection */ +/**< Queues state: STARTED(1) / STOPPED(0). */ +uint32_t dev_flags;/**< Capabilities. */ +enum rte_kernel_driver kdrv;/**< Kernel driver passthrough. */ +int numa_node;/**< NUMA node connection. */ struct rte_vlan_filter_conf vlan_filter_conf; -/**< VLAN filter configuration. */ +/**< VLAN filter configuration. */ struct rte_eth_dev_owner owner;/**< The port owner. */ } __rte_cache_aligned;
Signature · 1 line
2.19.0
Re: [PATCH v5 3/6] ethdev: fix doxygen comments of shared data fields
Quoted 6 lines · Thomas Monjalon
Some doxygen comments were wrongly associated to the next field because of syntax /** instead of /**<
Some other cleanups (like alignment) are done.
Signed-off-by Thomas Monjalon <[email protected]>
Yesterday I made similar patch, but moving corresponding comments before its structure members to make doxygen usage correct. It looks also good when post-comments are indented as you do.
PATCH v5 4/6 ethdev: free all common data when releasing port
In reply to Thomas MonjalonThis 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.
--- drivers/net/af_packet/rte_eth_af_packet.c | 5 ++-- 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 | 9 +++---- 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 | 6 +++-- drivers/net/fm10k/fm10k_ethdev.c | 8 ------- drivers/net/i40e/i40e_ethdev.c | 3 --- drivers/net/i40e/i40e_ethdev_vf.c | 3 --- drivers/net/i40e/i40e_vf_representor.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ------- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 +++- drivers/net/kni/rte_eth_kni.c | 5 ++-- drivers/net/liquidio/lio_ethdev.c | 3 --- drivers/net/mlx4/mlx4.c | 7 +++++- drivers/net/mlx5/mlx5.c | 11 ++++++--- drivers/net/mvneta/mvneta_ethdev.c | 16 ++++--------- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++++--------- drivers/net/netvsc/hn_ethdev.c | 15 ++---------- drivers/net/null/rte_eth_null.c | 4 ++-- drivers/net/octeontx/octeontx_ethdev.c | 29 +++++++++-------------- drivers/net/pcap/rte_eth_pcap.c | 8 +++---- drivers/net/qede/qede_ethdev.c | 5 ---- drivers/net/ring/rte_eth_ring.c | 6 ++--- drivers/net/sfc/sfc_ethdev.c | 3 --- drivers/net/softnic/rte_eth_softnic.c | 7 +++--- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 6 ++++- 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 | 21 ++++++++-------- lib/librte_ethdev/rte_ethdev_core.h | 14 ++++++++--- lib/librte_ethdev/rte_ethdev_driver.h | 9 ++++++- lib/librte_ethdev/rte_ethdev_pci.h | 10 -------- 45 files changed, 109 insertions(+), 232 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
@@ -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 ;
drivers/net/ark/ark_ethdev.c +0 -1
@@ -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 ; }
drivers/net/avf/avf_ethdev.c +0 -3
@@ -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 ;
drivers/net/avp/avp_ethdev.c +0 -5
@@ -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 ; }
drivers/net/axgbe/axgbe_ethdev.c +0 -3
@@ -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 ;
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -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 ;
drivers/net/bonding/rte_eth_bond_pmd.c +3 -6
@@ -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);
drivers/net/cxgbe/cxgbe_main.c +2 -14
@@ -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 )
drivers/net/cxgbe/cxgbevf_main.c +1 -8
@@ -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; }
drivers/net/dpaa/dpaa_ethdev.c +0 -10
@@ -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 ;
drivers/net/dpaa2/dpaa2_ethdev.c +0 -10
@@ -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 ;
drivers/net/e1000/em_ethdev.c +0 -3
@@ -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,
drivers/net/e1000/igb_ethdev.c +0 -6
@@ -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,
drivers/net/enetc/enetc_ethdev.c +1 -3
@@ -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 ; }
drivers/net/failsafe/failsafe.c +4 -2
@@ -280,7 +280,8 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) 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; }
drivers/net/fm10k/fm10k_ethdev.c +0 -8
@@ -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 ; }
drivers/net/i40e/i40e_ethdev.c +0 -3
@@ -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);
drivers/net/i40e/i40e_ethdev_vf.c +0 -3
@@ -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 ; }
drivers/net/i40e/i40e_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/ixgbe/ixgbe_ethdev.c +0 -9
@@ -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);
drivers/net/ixgbe/ixgbe_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/kni/rte_eth_kni.c +3 -2
@@ -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--;
drivers/net/liquidio/lio_ethdev.c +0 -3
@@ -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 ;
drivers/net/mlx4/mlx4.c +6 -1
@@ -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 ; }/*
drivers/net/mlx5/mlx5.c +8 -3
@@ -1223,11 +1223,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,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. */
drivers/net/mvneta/mvneta_ethdev.c +5 -11
@@ -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); }
drivers/net/mvpp2/mrvl_ethdev.c +5 -11
@@ -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); }
drivers/net/netvsc/hn_ethdev.c +2 -13
@@ -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 ; }
drivers/net/null/rte_eth_null.c +2 -2
@@ -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 ;
drivers/net/octeontx/octeontx_ethdev.c +11 -18
@@ -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; }
@@ -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); }
drivers/net/pcap/rte_eth_pcap.c +3 -5
@@ -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 ;
drivers/net/qede/qede_ethdev.c +0 -5
@@ -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 ; }
drivers/net/ring/rte_eth_ring.c +2 -4
@@ -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 ; }
drivers/net/sfc/sfc_ethdev.c +0 -3
@@ -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);
drivers/net/softnic/rte_eth_softnic.c +3 -4
@@ -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,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 ; }
drivers/net/szedata2/rte_eth_szedata2.c +0 -1
@@ -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);
drivers/net/tap/rte_eth_tap.c +5 -1
@@ -1808,6 +1808,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, 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:
@@ -2076,6 +2078,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);
@@ -2102,7 +2107,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 ) {
drivers/net/vhost/rte_eth_vhost.c +3 -6
@@ -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 ;
drivers/net/virtio/virtio_ethdev.c +0 -3
@@ -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,
drivers/net/virtio/virtio_user_ethdev.c +0 -3
@@ -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 ;
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -3
@@ -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 ; }
lib/librte_ethdev/rte_ethdev.c +10 -11
@@ -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: +probe_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); }
lib/librte_ethdev/rte_ethdev_core.h +11 -3
@@ -579,7 +579,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. */
@@ -588,11 +591,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__
lib/librte_ethdev/rte_ethdev_driver.h +8 -1
@@ -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.
lib/librte_ethdev/rte_ethdev_pci.h +0 -10
@@ -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 ;
Signature · 1 line
2.19.0
Re: [PATCH v5 4/6] ethdev: free all common data when releasing port
Quoted 8 lines · Thomas Monjalon
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 <[email protected]>
PATCH v5 5/6 ethdev: remove release function for secondary process
In reply to Thomas MonjalonAfter previous changes, the function rte_eth_dev_release_port() can be used for primary or secondary process as well. The only difference with rte_eth_dev_release_port_secondary() is the shared lock used in rte_eth_dev_release_port().
The function rte_eth_dev_release_port_secondary() was recently added in 18.11 cycle.
--- drivers/net/af_packet/rte_eth_af_packet.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- drivers/net/kni/rte_eth_kni.c | 2 +- drivers/net/null/rte_eth_null.c | 7 +++---- drivers/net/octeontx/octeontx_ethdev.c | 2 +- drivers/net/pcap/rte_eth_pcap.c | 12 ++++++------ drivers/net/tap/rte_eth_tap.c | 2 +- drivers/net/vhost/rte_eth_vhost.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 15 --------------- lib/librte_ethdev/rte_ethdev_driver.h | 14 -------------- lib/librte_ethdev/rte_ethdev_pci.h | 7 ------- lib/librte_ethdev/rte_ethdev_version.map | 7 ------- 12 files changed, 15 insertions(+), 59 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
@@ -990,7 +990,7 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;for (q =0 ; q < internals->nb_queues; q++) {
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
@@ -3267,7 +3267,7 @@ bond_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);RTE_ASSERT (eth_dev->device == &dev->device);
drivers/net/kni/rte_eth_kni.c +1 -1
@@ -467,7 +467,7 @@ eth_kni_remove(struct rte_vdev_device *vdev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_kni_dev_stop (eth_dev);
drivers/net/null/rte_eth_null.c +3 -4
@@ -679,11 +679,10 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +/* mac_addrs must not be freed alone because part of dev_private */ + eth_dev->data->mac_addrs =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);return 0 ;
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -1129,7 +1129,7 @@ octeontx_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { -rte_eth_dev_release_port_secondary (eth_dev); +rte_eth_dev_release_port (eth_dev);continue ; }
drivers/net/pcap/rte_eth_pcap.c +6 -6
@@ -1228,13 +1228,13 @@ pmd_pcap_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + internals = 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 ; + } - internals = 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 ;
drivers/net/tap/rte_eth_tap.c +1 -1
@@ -2082,7 +2082,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -1433,7 +1433,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_dev_close (eth_dev);
lib/librte_ethdev/rte_ethdev.c +0 -15
@@ -362,18 +362,6 @@ rte_eth_dev_attach_secondary(const char *name)return eth_dev; } -int -rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev) -{ -if (eth_dev ==NULL ) -return -EINVAL ; - -_rte_eth_dev_callback_process (eth_dev,RTE_ETH_EVENT_DESTROY ,NULL ); - eth_dev->state =RTE_ETH_DEV_UNUSED ; - -return 0 ; -} -int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev) {
@@ -3591,9 +3579,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,return ret; } -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (ethdev); -return rte_eth_dev_release_port (ethdev); }
lib/librte_ethdev/rte_ethdev_driver.h +0 -14
@@ -74,20 +74,6 @@ struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);*/ int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev); -/** -* @internal -* Release the specified ethdev port in the local process. -* Only set ethdev state to unused, but not reset shared data since -* it assume other processes is still using it. typically it is -* called by a secondary process. -* -* @param eth_dev -* Device to be detached. -* @return -* - 0 on success, negative on error -*/ -int rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev); -/** * @internal * Release device queues and clear its configuration to force the user
lib/librte_ethdev/rte_ethdev_pci.h +0 -7
@@ -135,13 +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 ) { - eth_dev->device =NULL ; - eth_dev->intr_handle =NULL ; -rte_eth_dev_release_port_secondary (eth_dev); -return ; - } - eth_dev->device =NULL ; eth_dev->intr_handle =NULL ;
lib/librte_ethdev/rte_ethdev_version.map +0 -7
@@ -220,13 +220,6 @@ DPDK_18.08 { } DPDK_18.05; -DPDK_18.11 { - global: - - rte_eth_dev_release_port_secondary; - -} DPDK_18.08; - EXPERIMENTAL { global:
Signature · 1 line
2.19.0
Re: [PATCH v5 5/6] ethdev: remove release function for secondary process
Quoted 9 lines · Thomas Monjalon
After previous changes, the function
rte_eth_dev_release_port()can be used for primary or secondary process as well. The only difference withrte_eth_dev_release_port_secondary()is the shared lock used inrte_eth_dev_release_port().The function
rte_eth_dev_release_port_secondary()was recently added in 18.11 cycle.Signed-off-by Thomas Monjalon <[email protected]>
PATCH v5 6/6 ethdev: complete closing of port
In reply to Thomas MonjalonAfter closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in rte_eth_dev_release_port().
A closed port will have the state RTE_ETH_DEV_UNUSED which is considered as invalid by rte_eth_dev_is_valid_port(). So validity is not checked anymore for closed ports in testpmd.
If the driver is trying to free the port again, the function rte_eth_dev_release_port() will abort with -ENODEV error.
--- app/test-pmd/testpmd.c | 16 +++------------- doc/guides/rel_notes/release_18_11.rst | 4 ++++ drivers/net/af_packet/rte_eth_af_packet.c | 4 +++- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/failsafe/failsafe_ops.c | 2 ++ drivers/net/mlx4/mlx4.c | 2 ++ drivers/net/mlx5/mlx5.c | 2 ++ drivers/net/netvsc/hn_ethdev.c | 5 ++++- drivers/net/pcap/rte_eth_pcap.c | 5 +++++ drivers/net/softnic/rte_eth_softnic.c | 3 ++- drivers/net/tap/rte_eth_tap.c | 3 +++ drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 14 files changed, 34 insertions(+), 32 deletions(-)
app/test-pmd/testpmd.c +3 -13
@@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id)return 1 ; } -static int -port_is_closed (portid_t port_id) -{ -if (port_id_is_invalid (port_id,ENABLED_WARN )) -return 0 ; - -if (ports[port_id].port_status !=RTE_PORT_CLOSED ) -return 0 ; - -return 1 ; -} -int start_port (portid_t pid) {
@@ -2252,6 +2240,8 @@ close_port(portid_t pid)port_flow_flush (pi);rte_eth_dev_close (pi); +remove_unused_fwd_ports (); +if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_HANDLING ,RTE_PORT_CLOSED ) ==0 )printf ("Port %d cannot be set to closed\n" , pi);
@@ -2342,7 +2332,7 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" ); -if (!port_is_closed (port_id)) { +if (ports[port_id].port_status !=RTE_PORT_CLOSED ) {if (ports[port_id].port_status !=RTE_PORT_STOPPED ) {printf ("Port not stopped\n" );return ;
doc/guides/rel_notes/release_18_11.rst +4 -0
@@ -215,6 +215,10 @@ API Changes functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. +* ethdev: A call to ``rte_eth_dev_release_port()`` has been added in + ``rte_eth_dev_close()``. As a consequence, a closed port is freed + and seen as invalid because of its state ``RTE_ETH_DEV_UNUSED``. + * A new device flag, RTE_ETH_DEV_NOLIVE_MAC_ADDR, changes the order of actions inside rte_eth_dev_start regarding MAC set. Some NICs do not support MAC changes once the port has started and with this new device
drivers/net/af_packet/rte_eth_af_packet.c +3 -1
@@ -362,8 +362,10 @@ eth_stats_reset(struct rte_eth_dev *dev) }static void -eth_dev_close(struct rte_eth_dev *dev __rte_unused) +eth_dev_close (struct rte_eth_dev *dev) { +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)if (bp->dev_stopped ==0 )bnxt_dev_stop_op (eth_dev); -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 ;
drivers/net/failsafe/failsafe_ops.c +2 -0
@@ -331,6 +331,8 @@ fs_dev_close(struct rte_eth_dev *dev) sdev->state =DEV_ACTIVE -1 ; }fs_dev_free_queues (dev); +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ;fs_unlock (dev,0 ); }
drivers/net/mlx4/mlx4.c +2 -0
@@ -209,6 +209,8 @@ mlx4_dev_close(struct rte_eth_dev *dev)mlx4_rx_queue_release (dev->data->rx_queues[i]);for (i =0 ; i != dev->data->nb_tx_queues; ++i)mlx4_tx_queue_release (dev->data->tx_queues[i]); +/* mac_addrs must not be freed because part of dev_private */ + dev->data->mac_addrs =NULL ;mlx4_mr_release (dev);if (priv->pd !=NULL ) {assert (priv->ctx !=NULL );
drivers/net/mlx5/mlx5.c +2 -0
@@ -337,6 +337,8 @@ mlx5_dev_close(struct rte_eth_dev *dev) }memset (priv,0 ,sizeof (*priv)); priv->domain_id =RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID ; +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; }const struct eth_dev_ops mlx5_dev_ops = {
drivers/net/netvsc/hn_ethdev.c +4 -1
@@ -630,11 +630,14 @@ hn_dev_stop(struct rte_eth_dev *dev) }static void -hn_dev_close(struct rte_eth_dev *dev __rte_unused) +hn_dev_close (struct rte_eth_dev *dev) {PMD_INIT_LOG (DEBUG ,"close" );hn_vf_close (dev); + +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; }static const struct eth_dev_ops hn_eth_dev_ops = {
drivers/net/pcap/rte_eth_pcap.c +5 -0
@@ -623,6 +623,11 @@ eth_stats_reset(struct rte_eth_dev *dev)static void eth_dev_close(struct rte_eth_dev *dev __rte_unused) { +struct pmd_internals *internals = dev->data->dev_private; + +if (internals !=NULL && internals->phy_mac ==0 ) +/* not dynamically allocated, must not be freed */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/softnic/rte_eth_softnic.c +2 -1
@@ -194,8 +194,9 @@ pmd_dev_stop(struct rte_eth_dev *dev) }static void -pmd_dev_close(struct rte_eth_dev *dev __rte_unused) +pmd_dev_close (struct rte_eth_dev *dev) { + dev->data->mac_addrs =NULL ;/* statically allocated */ return ; }
drivers/net/tap/rte_eth_tap.c +3 -0
@@ -1000,6 +1000,9 @@ tap_dev_close(struct rte_eth_dev *dev)* Since TUN device has no more opened file descriptors * it will be removed from kernel */ + +/* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs =NULL ; } static void
drivers/net/vhost/rte_eth_vhost.c +0 -4
@@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++)rte_free (dev->data->tx_queues[i]); -rte_free (dev->data->mac_addrs);free (internal->dev_name);free (internal->iface_name); -rte_free (internal); - - dev->data->dev_private =NULL ; } static int
lib/librte_ethdev/rte_ethdev.c +3 -6
@@ -367,6 +367,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) {if (eth_dev ==NULL )return -EINVAL ; +if (eth_dev->state ==RTE_ETH_DEV_UNUSED ) +return -ENODEV ;rte_eth_dev_shared_data_prepare ();
@@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev); - dev->data->nb_rx_queues =0 ; -rte_free (dev->data->rx_queues); - dev->data->rx_queues =NULL ; - dev->data->nb_tx_queues =0 ; -rte_free (dev->data->tx_queues); - dev->data->tx_queues =NULL ; +rte_eth_dev_release_port (dev); }int
lib/librte_ethdev/rte_ethdev.h +1 -2
@@ -1802,8 +1802,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.19.0
Re: [PATCH v5 6/6] ethdev: complete closing of port
Quoted 14 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in
rte_eth_dev_release_port().
Quoted 8 lines
A closed port will have the state
RTE_ETH_DEV_UNUSEDwhich is considered as invalid byrte_eth_dev_is_valid_port(). So validity is not checked anymore for closed ports in testpmd.If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>
I've tested the patch series together with [1].
As I expected it makes problems and resource leaks if rte_eth_dev_close() is used.
Everything is OK if I do port stop and detach (with net/sfc patch which does close from uninit).
If I do port stop, close and detach, the last one returns error since the device already released and net/sfc uninit is never called.
Basically it should be one function which is called in both
cases: dev_close or pci_device remove. Similar changes should be done in many PCI drivers.
If I drop the patch, everything seems to be work fine from the first sight.
May be it should be removed from the patchset and considered separately.
Re: [PATCH v5 6/6] ethdev: complete closing of port
18/10/2018 10:33, Andrew Rybchenko:
Quoted 19 lines · Thomas Monjalon
Quoted 18 lines
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close().Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in
rte_eth_dev_release_port().A closed port will have the state
RTE_ETH_DEV_UNUSEDwhich is considered as invalid byrte_eth_dev_is_valid_port(). So validity is not checked anymore for closed ports in testpmd.
Quoted 6 lines
Quoted 4 lines
If the driver is trying to free the port again, the function
rte_eth_dev_release_port()will abort with-ENODEVerror.Signed-off-by Thomas Monjalon <[email protected]>I've tested the patch series together with [1].
There are 2 use cases to consider:
1/ rte_eth_dev_close + rte_dev_remove
2/ rte_dev_remove without prior close
Quoted 5 lines
As I expected it makes problems and resource leaks if
rte_eth_dev_close()is used.Everything is OK if I do port stop and detach (with net/sfc patch which does close from uninit).
This is the case #2.
It requires some PMD updates to avoid the leaks.
It was buggy in previous releases too, because it was not managing devices with multiple ports.
I think we should continue recommending the use case #1 in 18.11, and let time for PMDs to be fixed for use case #2.
It PMDs can be fixed in 18.11, it is even better.
Quoted 3 lines
If I do port stop, close and detach, the last one returns error since the device already released and net/sfc uninit is never called.
This is the case #1.
The bug is assuming that the port is not freed when removing the device. We should just skip closed ports without any error.
I can fix it in a v6.
Quoted 3 lines
Basically it should be one function which is called in both
cases:dev_closeorpci_deviceremove. Similar changes should be done in many PCI drivers.
Yes, dev_close must be called for all non-closed ports of a PCI device to remove.
Usually, PMDs have an implementation of dev_close which is different of the uninit function called with rte_eth_dev_pci_generic_remove() or rte_eth_dev_destroy(). They have no good reason to be different:
typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev); typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
Quoted 4 lines
If I drop the patch, everything seems to be work fine from the first sight.
May be it should be removed from the patchset and considered separately.
No, I think I should just fix the use case #1,
and let PMDs fixing the use case #2 when they have a chance. In my opinion, the use case #2 was never advertised before, so it is just opening the way for the support of this use case.
Quoted 1 line
v6 cover ethdev port freeing
In reply to Thomas MonjalonThe function rte_eth_dev_detach() is freeing a port and its underlying rte_device object. The issue is that we may have several ports associated to the same rte_device.
The right replacement is to free the port, and free the rte_device if no more ports.
At ethdev level, the public function for port freeing is rte_eth_dev_close(). The only miss is rte_eth_dev_release_port() to free all port resources.
This patchset does a cleanup by moving as much ethdev data freeing as possible in an unique function rte_eth_dev_release_port(), and call this function in rte_eth_dev_close().
The port is released on close only if the driver supports it.
Changes in v6:
- fix testpmd ports list iteration
- keep old behaviour
- add flag RTE_ETH_DEV_CLOSE_REMOVE to enable new behaviour (port release)
Changes in v5:
- fix testpmd for detaching multi-ports device
- fix testpmd for detaching only stopped ports
- add a release note about closed port freeing and state
- fix some doxygen comments in rte_eth_dev_data
- improve doxygen of rte_eth_dev_release_port()
- fix data freeing in some drivers
Changes in v4:
- do not free data fields which are not dynamically allocated blocks
- remove rte_eth_dev_release_port_secondary()
- remove testpmd check to detach without closing
Changes in v3:
- free queues, MAC addresses and private structure in rte_eth_dev_release_port.
Thomas Monjalon (5):
app/testpmd: allow detaching a port not closed
ethdev: fix doxygen comments of shared data fields
ethdev: free all common data when releasing port
ethdev: remove release function for secondary process
ethdev: complete closing of port
Wisam Jaddo (1):
app/testpmd: update port list for multiple removals
app/test-pmd/testpmd.c | 65 +++++++++++++---------- doc/guides/rel_notes/release_18_11.rst | 5 ++ drivers/net/af_packet/rte_eth_af_packet.c | 7 +-- 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 | 11 ++-- 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 | 6 ++- drivers/net/fm10k/fm10k_ethdev.c | 8 --- drivers/net/i40e/i40e_ethdev.c | 3 -- drivers/net/i40e/i40e_ethdev_vf.c | 3 -- drivers/net/i40e/i40e_vf_representor.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ---- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 +- drivers/net/kni/rte_eth_kni.c | 7 +-- drivers/net/liquidio/lio_ethdev.c | 3 -- drivers/net/mlx4/mlx4.c | 7 ++- drivers/net/mlx5/mlx5.c | 11 ++-- drivers/net/mvneta/mvneta_ethdev.c | 16 ++---- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++---- drivers/net/netvsc/hn_ethdev.c | 15 +----- drivers/net/null/rte_eth_null.c | 7 ++- drivers/net/octeontx/octeontx_ethdev.c | 31 +++++------ drivers/net/pcap/rte_eth_pcap.c | 14 +++-- drivers/net/qede/qede_ethdev.c | 5 -- drivers/net/ring/rte_eth_ring.c | 6 +-- drivers/net/sfc/sfc_ethdev.c | 3 -- drivers/net/softnic/rte_eth_softnic.c | 7 ++- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 8 ++- drivers/net/vhost/rte_eth_vhost.c | 11 ++-- 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 | 46 +++++++--------- lib/librte_ethdev/rte_ethdev.h | 9 +++- lib/librte_ethdev/rte_ethdev_core.h | 38 +++++++------ lib/librte_ethdev/rte_ethdev_driver.h | 23 +++----- lib/librte_ethdev/rte_ethdev_pci.h | 17 ------ lib/librte_ethdev/rte_ethdev_version.map | 7 --- 49 files changed, 188 insertions(+), 330 deletions(-)
Signature · 1 line
2.19.0
PATCH v6 1/6 app/testpmd: update port list for multiple removals
From: Wisam Jaddo <[email protected]>
When detaching a port, the full rte_device is removed. If the rte_device was hosting several ports,
the testpmd list of ports must be updated for multiple removals.
--- app/test-pmd/testpmd.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
app/test-pmd/testpmd.c +26 -11
@@ -2186,6 +2186,31 @@ stop_port(portid_t pid)printf ("Done\n" ); } +static void +remove_unused_fwd_ports (void ) +{ +int i; +int last_port_idx = nb_ports -1 ; + +for (i =0 ; i <= last_port_idx; i++) {/* iterate in ports_ids */ +if (rte_eth_devices[ports_ids[i]].state !=RTE_ETH_DEV_UNUSED ) +continue ; +/* skip unused ports at the end */ +while (i <= last_port_idx && + rte_eth_devices[ports_ids[last_port_idx]].state + ==RTE_ETH_DEV_UNUSED ) + last_port_idx--; +if (last_port_idx < i) +break ; +/* overwrite unused port with last valid port */ + ports_ids[i] = ports_ids[last_port_idx]; +/* decrease ports count */ + last_port_idx--; + } + nb_ports =rte_eth_dev_count_avail (); +update_fwd_ports (RTE_MAX_ETHPORTS ); +} +void close_port (portid_t pid) {
@@ -2315,7 +2340,6 @@ void detach_port(portid_t port_id) {char name[RTE_ETH_NAME_MAX_LEN ]; -uint16_t i;printf ("Detaching a port...\n" );
@@ -2332,16 +2356,7 @@ detach_port(portid_t port_id)return ; } -for (i =0 ; i < nb_ports; i++) { -if (ports_ids[i] == port_id) { - ports_ids[i] = ports_ids[nb_ports-1 ]; - ports_ids[nb_ports-1 ] =0 ; -break ; - } - } - nb_ports =rte_eth_dev_count_avail (); - -update_fwd_ports (RTE_MAX_ETHPORTS ); +remove_unused_fwd_ports ();printf ("Port %u is detached. Now total ports is %d\n" , port_id, nb_ports);
Signature · 1 line
2.19.0
Re: [PATCH v6 1/6] app/testpmd: update port list for multiple removals
Quoted 9 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, October 19, 2018 3:08 AM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Iremonger, Bernard <[email protected]>; [email protected]; Wisam Jaddo <[email protected]>
Subject: [PATCH v6 1/6] app/testpmd: update port list for multiple removals
Quoted 7 lines
From: Wisam Jaddo <[email protected]>
When detaching a port, the full
rte_deviceis removed.
If therte_devicewas hosting several ports, the testpmd list of ports must be updated for multiple removals.Signed-off-by Wisam Jaddo <[email protected]>
PATCH v6 2/6 app/testpmd: allow detaching a port not closed
In reply to Thomas MonjalonThe testpmd application aim is for testing;
so order of operations should not be enforced.
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
--- app/test-pmd/testpmd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
app/test-pmd/testpmd.c +7 -5
@@ -2344,13 +2344,15 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" );if (!port_is_closed (port_id)) { -printf ("Please close port first\n" ); -return ; +if (ports[port_id].port_status !=RTE_PORT_STOPPED ) { +printf ("Port not stopped\n" ); +return ; + } +printf ("Port was not closed\n" ); +if (ports[port_id].flow_list) +port_flow_flush (port_id); } -if (ports[port_id].flow_list) -port_flow_flush (port_id); -if (rte_eth_dev_detach (port_id, name)) {TESTPMD_LOG (ERR ,"Failed to detach port %u\n" , port_id);return ;
Signature · 1 line
2.19.0
Re: [PATCH v6 2/6] app/testpmd: allow detaching a port not closed
Quoted 11 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, October 19, 2018 3:08 AM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Iremonger, Bernard <[email protected]>; [email protected]
Subject: [PATCH v6 2/6] app/testpmd: allow detaching a port not closedThe testpmd application aim is for testing; so order of operations should not be enforced.
Quoted 8 lines
There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching.
in order to avoid a crash, it is checked that the port must be stopped before detaching (as for closing).
Signed-off-by Thomas Monjalon <[email protected]>
PATCH v6 3/6 ethdev: fix doxygen comments of shared data fields
In reply to Thomas MonjalonSome doxygen comments were wrongly associated to the next field because of syntax /** instead of /**<
Some other cleanups (like alignment) are done.
--- lib/librte_ethdev/rte_ethdev_core.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
lib/librte_ethdev/rte_ethdev_core.h +13 -15
@@ -581,22 +581,20 @@ struct rte_eth_dev_data {void *dev_private;/**< PMD-specific private data */ -struct rte_eth_link dev_link; -/**< Link-level information & status */ - +struct rte_eth_link dev_link;/**< Link-level information & status. */ struct rte_eth_conf dev_conf;/**< Configuration applied to device. */ uint16_t mtu;/**< Maximum Transmission Unit. */ -uint32_t min_rx_buf_size; -/**< Common rx buffer size handled by all queues */ +/**< 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. */ uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR ]; -/** bitmap array of associating Ethernet MAC addresses to pools */ -struct ether_addr * hash_mac_addrs; -/** Device Ethernet MAC addresses of hash filtering. */ +/**< Bitmap associating MAC addresses to pools. */ +struct ether_addr *hash_mac_addrs; +/**< Device Ethernet MAC addresses of hash filtering. */ uint16_t port_id;/**< Device [external] port identifier. */ + __extension__ uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */ scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
@@ -604,14 +602,14 @@ struct rte_eth_dev_data { dev_started :1 ,/**< Device state: STARTED(1) / STOPPED(0). */ lro : 1; /**< RX LRO is ON(1) / OFF(0) */uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT ]; -/** Queues state: STARTED(1) / STOPPED(0) */ +/**< Queues state: STARTED(1) / STOPPED(0). */ uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT ]; -/** Queues state: STARTED(1) / STOPPED(0) */ -uint32_t dev_flags;/**< Capabilities */ -enum rte_kernel_driver kdrv;/**< Kernel driver passthrough */ -int numa_node;/**< NUMA node connection */ +/**< Queues state: STARTED(1) / STOPPED(0). */ +uint32_t dev_flags;/**< Capabilities. */ +enum rte_kernel_driver kdrv;/**< Kernel driver passthrough. */ +int numa_node;/**< NUMA node connection. */ struct rte_vlan_filter_conf vlan_filter_conf; -/**< VLAN filter configuration. */ +/**< VLAN filter configuration. */ struct rte_eth_dev_owner owner;/**< The port owner. */ } __rte_cache_aligned;
Signature · 1 line
2.19.0
PATCH v6 4/6 ethdev: free all common data when releasing port
In reply to Thomas MonjalonThis 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.
--- drivers/net/af_packet/rte_eth_af_packet.c | 5 ++-- 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 | 9 +++---- 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 | 6 +++-- drivers/net/fm10k/fm10k_ethdev.c | 8 ------- drivers/net/i40e/i40e_ethdev.c | 3 --- drivers/net/i40e/i40e_ethdev_vf.c | 3 --- drivers/net/i40e/i40e_vf_representor.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 9 ------- drivers/net/ixgbe/ixgbe_vf_representor.c | 5 +++- drivers/net/kni/rte_eth_kni.c | 5 ++-- drivers/net/liquidio/lio_ethdev.c | 3 --- drivers/net/mlx4/mlx4.c | 7 +++++- drivers/net/mlx5/mlx5.c | 11 ++++++--- drivers/net/mvneta/mvneta_ethdev.c | 16 ++++--------- drivers/net/mvpp2/mrvl_ethdev.c | 16 ++++--------- drivers/net/netvsc/hn_ethdev.c | 15 ++---------- drivers/net/null/rte_eth_null.c | 4 ++-- drivers/net/octeontx/octeontx_ethdev.c | 29 +++++++++-------------- drivers/net/pcap/rte_eth_pcap.c | 8 +++---- drivers/net/qede/qede_ethdev.c | 5 ---- drivers/net/ring/rte_eth_ring.c | 6 ++--- drivers/net/sfc/sfc_ethdev.c | 3 --- drivers/net/softnic/rte_eth_softnic.c | 7 +++--- drivers/net/szedata2/rte_eth_szedata2.c | 1 - drivers/net/tap/rte_eth_tap.c | 6 ++++- 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 | 21 ++++++++-------- lib/librte_ethdev/rte_ethdev_core.h | 14 ++++++++--- lib/librte_ethdev/rte_ethdev_driver.h | 9 ++++++- lib/librte_ethdev/rte_ethdev_pci.h | 10 -------- 45 files changed, 109 insertions(+), 232 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
@@ -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 ;
drivers/net/ark/ark_ethdev.c +0 -1
@@ -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 ; }
drivers/net/avf/avf_ethdev.c +0 -3
@@ -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 ;
drivers/net/avp/avp_ethdev.c +0 -5
@@ -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 ; }
drivers/net/axgbe/axgbe_ethdev.c +0 -3
@@ -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 ;
drivers/net/bnxt/bnxt_ethdev.c +0 -4
@@ -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 ;
drivers/net/bonding/rte_eth_bond_pmd.c +3 -6
@@ -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);
drivers/net/cxgbe/cxgbe_main.c +2 -14
@@ -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 )
drivers/net/cxgbe/cxgbevf_main.c +1 -8
@@ -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; }
drivers/net/dpaa/dpaa_ethdev.c +0 -10
@@ -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 ;
drivers/net/dpaa2/dpaa2_ethdev.c +0 -10
@@ -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 ;
drivers/net/e1000/em_ethdev.c +0 -3
@@ -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,
drivers/net/e1000/igb_ethdev.c +0 -6
@@ -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,
drivers/net/enetc/enetc_ethdev.c +1 -3
@@ -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 ; }
drivers/net/failsafe/failsafe.c +4 -2
@@ -280,7 +280,8 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) 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; }
drivers/net/fm10k/fm10k_ethdev.c +0 -8
@@ -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 ; }
drivers/net/i40e/i40e_ethdev.c +0 -3
@@ -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);
drivers/net/i40e/i40e_ethdev_vf.c +0 -3
@@ -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 ; }
drivers/net/i40e/i40e_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/ixgbe/ixgbe_ethdev.c +0 -9
@@ -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);
drivers/net/ixgbe/ixgbe_vf_representor.c +4 -1
@@ -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 ; }
drivers/net/kni/rte_eth_kni.c +3 -2
@@ -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--;
drivers/net/liquidio/lio_ethdev.c +0 -3
@@ -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 ;
drivers/net/mlx4/mlx4.c +6 -1
@@ -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 ; }/*
drivers/net/mlx5/mlx5.c +8 -3
@@ -1223,11 +1223,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,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. */
drivers/net/mvneta/mvneta_ethdev.c +5 -11
@@ -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); }
drivers/net/mvpp2/mrvl_ethdev.c +5 -11
@@ -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); }
drivers/net/netvsc/hn_ethdev.c +2 -13
@@ -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 ; }
drivers/net/null/rte_eth_null.c +2 -2
@@ -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 ;
drivers/net/octeontx/octeontx_ethdev.c +11 -18
@@ -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; }
@@ -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); }
drivers/net/pcap/rte_eth_pcap.c +3 -5
@@ -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 ;
drivers/net/qede/qede_ethdev.c +0 -5
@@ -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 ; }
drivers/net/ring/rte_eth_ring.c +2 -4
@@ -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 ; }
drivers/net/sfc/sfc_ethdev.c +0 -3
@@ -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);
drivers/net/softnic/rte_eth_softnic.c +3 -4
@@ -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,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 ; }
drivers/net/szedata2/rte_eth_szedata2.c +0 -1
@@ -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);
drivers/net/tap/rte_eth_tap.c +5 -1
@@ -1808,6 +1808,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, 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:
@@ -2076,6 +2078,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);
@@ -2102,7 +2107,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 ) {
drivers/net/vhost/rte_eth_vhost.c +3 -6
@@ -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 ;
drivers/net/virtio/virtio_ethdev.c +0 -3
@@ -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,
drivers/net/virtio/virtio_user_ethdev.c +0 -3
@@ -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 ;
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -3
@@ -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 ; }
lib/librte_ethdev/rte_ethdev.c +10 -11
@@ -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: +probe_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); }
lib/librte_ethdev/rte_ethdev_core.h +11 -3
@@ -579,7 +579,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. */
@@ -588,11 +591,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__
lib/librte_ethdev/rte_ethdev_driver.h +8 -1
@@ -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.
lib/librte_ethdev/rte_ethdev_pci.h +0 -10
@@ -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 ;
Signature · 1 line
2.19.0
PATCH v6 5/6 ethdev: remove release function for secondary process
In reply to Thomas MonjalonAfter previous changes, the function rte_eth_dev_release_port() can be used for primary or secondary process as well. The only difference with rte_eth_dev_release_port_secondary() is the shared lock used in rte_eth_dev_release_port().
The function rte_eth_dev_release_port_secondary() was recently added in 18.11 cycle.
--- drivers/net/af_packet/rte_eth_af_packet.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 2 +- drivers/net/kni/rte_eth_kni.c | 2 +- drivers/net/null/rte_eth_null.c | 7 +++---- drivers/net/octeontx/octeontx_ethdev.c | 2 +- drivers/net/pcap/rte_eth_pcap.c | 12 ++++++------ drivers/net/tap/rte_eth_tap.c | 2 +- drivers/net/vhost/rte_eth_vhost.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 15 --------------- lib/librte_ethdev/rte_ethdev_driver.h | 14 -------------- lib/librte_ethdev/rte_ethdev_pci.h | 7 ------- lib/librte_ethdev/rte_ethdev_version.map | 7 ------- 12 files changed, 15 insertions(+), 59 deletions(-)
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
@@ -990,7 +990,7 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;for (q =0 ; q < internals->nb_queues; q++) {
drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
@@ -3267,7 +3267,7 @@ bond_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);RTE_ASSERT (eth_dev->device == &dev->device);
drivers/net/kni/rte_eth_kni.c +1 -1
@@ -467,7 +467,7 @@ eth_kni_remove(struct rte_vdev_device *vdev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_kni_dev_stop (eth_dev);
drivers/net/null/rte_eth_null.c +3 -4
@@ -679,11 +679,10 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +/* mac_addrs must not be freed alone because part of dev_private */ + eth_dev->data->mac_addrs =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);return 0 ;
drivers/net/octeontx/octeontx_ethdev.c +1 -1
@@ -1129,7 +1129,7 @@ octeontx_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { -rte_eth_dev_release_port_secondary (eth_dev); +rte_eth_dev_release_port (eth_dev);continue ; }
drivers/net/pcap/rte_eth_pcap.c +6 -6
@@ -1228,13 +1228,13 @@ pmd_pcap_remove(struct rte_vdev_device *dev)if (eth_dev ==NULL )return -1 ; -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + internals = 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 ; + } - internals = 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 ;
drivers/net/tap/rte_eth_tap.c +1 -1
@@ -2082,7 +2082,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev); internals = eth_dev->data->dev_private;
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -1433,7 +1433,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)return -ENODEV ;if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (eth_dev); +return rte_eth_dev_release_port (eth_dev);eth_dev_close (eth_dev);
lib/librte_ethdev/rte_ethdev.c +0 -15
@@ -362,18 +362,6 @@ rte_eth_dev_attach_secondary(const char *name)return eth_dev; } -int -rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev) -{ -if (eth_dev ==NULL ) -return -EINVAL ; - -_rte_eth_dev_callback_process (eth_dev,RTE_ETH_EVENT_DESTROY ,NULL ); - eth_dev->state =RTE_ETH_DEV_UNUSED ; - -return 0 ; -} -int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev) {
@@ -3591,9 +3579,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,return ret; } -if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) -return rte_eth_dev_release_port_secondary (ethdev); -return rte_eth_dev_release_port (ethdev); }
lib/librte_ethdev/rte_ethdev_driver.h +0 -14
@@ -74,20 +74,6 @@ struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);*/ int rte_eth_dev_release_port (struct rte_eth_dev *eth_dev); -/** -* @internal -* Release the specified ethdev port in the local process. -* Only set ethdev state to unused, but not reset shared data since -* it assume other processes is still using it. typically it is -* called by a secondary process. -* -* @param eth_dev -* Device to be detached. -* @return -* - 0 on success, negative on error -*/ -int rte_eth_dev_release_port_secondary (struct rte_eth_dev *eth_dev); -/** * @internal * Release device queues and clear its configuration to force the user
lib/librte_ethdev/rte_ethdev_pci.h +0 -7
@@ -135,13 +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 ) { - eth_dev->device =NULL ; - eth_dev->intr_handle =NULL ; -rte_eth_dev_release_port_secondary (eth_dev); -return ; - } - eth_dev->device =NULL ; eth_dev->intr_handle =NULL ;
lib/librte_ethdev/rte_ethdev_version.map +0 -7
@@ -220,13 +220,6 @@ DPDK_18.08 { } DPDK_18.05; -DPDK_18.11 { - global: - - rte_eth_dev_release_port_secondary; - -} DPDK_18.08; - EXPERIMENTAL { global:
Signature · 1 line
2.19.0
PATCH v6 6/6 ethdev: complete closing of port
In reply to Thomas MonjalonAfter closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated. Instead of blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close() if the driver supports the flag RTE_ETH_DEV_CLOSE_REMOVE.
There will be a transition period for PMDs to enable this new flag and migrate to the new behaviour.
When enabling RTE_ETH_DEV_CLOSE_REMOVE, the PMD must free all its private resources for the port, in its dev_close function. It is advised to call the dev_close function in the remove function in order to support removing a device without closing its ports.
Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in rte_eth_dev_release_port().
A closed port will have the state RTE_ETH_DEV_UNUSED which is considered as invalid by rte_eth_dev_is_valid_port(). So validity is not checked anymore for closed ports in testpmd.
--- app/test-pmd/testpmd.c | 16 +++------------- doc/guides/rel_notes/release_18_11.rst | 5 +++++ lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ lib/librte_ethdev/rte_ethdev.h | 9 +++++++-- 4 files changed, 25 insertions(+), 15 deletions(-)
app/test-pmd/testpmd.c +3 -13
@@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id)return 1 ; } -static int -port_is_closed (portid_t port_id) -{ -if (port_id_is_invalid (port_id,ENABLED_WARN )) -return 0 ; - -if (ports[port_id].port_status !=RTE_PORT_CLOSED ) -return 0 ; - -return 1 ; -} -int start_port (portid_t pid) {
@@ -2253,6 +2241,8 @@ close_port(portid_t pid)port_flow_flush (pi);rte_eth_dev_close (pi); +remove_unused_fwd_ports (); +if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_HANDLING ,RTE_PORT_CLOSED ) ==0 )printf ("Port %d cannot be set to closed\n" , pi);
@@ -2343,7 +2333,7 @@ detach_port(portid_t port_id)printf ("Detaching a port...\n" ); -if (!port_is_closed (port_id)) { +if (ports[port_id].port_status !=RTE_PORT_CLOSED ) {if (ports[port_id].port_status !=RTE_PORT_STOPPED ) {printf ("Port not stopped\n" );return ;
doc/guides/rel_notes/release_18_11.rst +5 -0
@@ -235,6 +235,11 @@ API Changes functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. +* ethdev: A call to ``rte_eth_dev_release_port()`` has been added in + ``rte_eth_dev_close()``. As a consequence, a closed port is freed + and seen as invalid because of its state ``RTE_ETH_DEV_UNUSED``. + This new behaviour is enabled per driver for a migration period. + * A new device flag, RTE_ETH_DEV_NOLIVE_MAC_ADDR, changes the order of actions inside rte_eth_dev_start regarding MAC set. Some NICs do not support MAC changes once the port has started and with this new device
lib/librte_ethdev/rte_ethdev.c +10 -0
@@ -1384,6 +1384,16 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started =0 ; (*dev->dev_ops->dev_close)(dev); +/* check behaviour flag - temporary for PMD migration */ +if ((dev->data->dev_flags &RTE_ETH_DEV_CLOSE_REMOVE ) !=0 ) { +/* new behaviour: send event + reset state + free all data */ +rte_eth_dev_release_port (dev); +return ; + } +RTE_ETHDEV_LOG (DEBUG ,"Port closing is using an old behaviour.\n" +"The driver %s should migrate to the new behaviour.\n" , + dev->device->driver->name); +/* old behaviour: only free queue arrays */ dev->data->nb_rx_queues =0 ;rte_free (dev->data->rx_queues); dev->data->rx_queues =NULL ;
lib/librte_ethdev/rte_ethdev.h +7 -2
@@ -1259,6 +1259,11 @@ struct rte_eth_dev_owner {char name[RTE_ETH_MAX_OWNER_NAME_LEN ];/**< The owner name. */ }; +/** +* Port is released (i.e. totally freed and data erased) on close. +* Temporary flag for PMD migration to new rte_eth_dev_close() behaviour. +*/ +#define RTE_ETH_DEV_CLOSE_REMOVE 0x0001/** Device supports link state interrupt */ #define RTE_ETH_DEV_INTR_LSC 0x0002/** Device is a bonded slave */
@@ -1802,8 +1807,8 @@ int rte_eth_dev_set_link_down(uint16_t port_id);/** * Close a stopped Ethernet device. The device cannot be restarted! -* The function frees all resources except for needed by the -* closed state. To free these resources, call rte_eth_dev_detach(). +* The function frees all port resources if the driver supports +* the flag RTE_ETH_DEV_CLOSE_REMOVE. * * @param port_id * The port identifier of the Ethernet device.
Signature · 1 line
2.19.0
Re: [PATCH v6 6/6] ethdev: complete closing of port
Quoted 21 lines · Thomas Monjalon
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.The last step was done with
rte_eth_dev_detach()which is deprecated. Instead of blindly removing the associatedrte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device.The last ethdev freeing which were done by
rte_eth_dev_detach(), are now done at the end ofrte_eth_dev_close()if the driver supports the flagRTE_ETH_DEV_CLOSE_REMOVE.
There will be a transition period for PMDs to enable this new flag and migrate to the new behaviour.
When enablingRTE_ETH_DEV_CLOSE_REMOVE, the PMD must free all its private resources for the port, in itsdev_closefunction. It is advised to call thedev_closefunction in the remove function in order to support removing a device without closing its ports.Some drivers does not allocate MAC addresses dynamically or separately. In those cases, the pointer is set to NULL, in order to avoid wrongly freeing them in
rte_eth_dev_release_port().
Quoted 5 lines
A closed port will have the state
RTE_ETH_DEV_UNUSEDwhich is considered as invalid byrte_eth_dev_is_valid_port(). So validity is not checked anymore for closed ports in testpmd.Signed-off-by Thomas Monjalon <[email protected]>
I really like the idea with RTE_ETH_DEV_CLOSE_REMOVE.
As I understand it should applied to dpdk-next-net, but right now there are conflicts in net/tap (patch 4).
Re: [PATCH v6 0/6] ethdev port freeing
In reply to Thomas MonjalonQuoted 45 lines · Thomas Monjalon
The function
rte_eth_dev_detach()is freeing a port and its underlyingrte_deviceobject. The issue is that we may have several ports associated to the samerte_device.The right replacement is to free the port, and free the
rte_deviceif no more ports.
At ethdev level, the public function for port freeing isrte_eth_dev_close(). The only miss isrte_eth_dev_release_port()to free all port resources.This patchset does a cleanup by moving as much ethdev data freeing as possible in an unique function
rte_eth_dev_release_port(), and call this function inrte_eth_dev_close().
The port is released on close only if the driver supports it.Changes in v6:
- fix testpmd ports list iteration
- keep old behaviour
- add flagRTE_ETH_DEV_CLOSE_REMOVEto enable new behaviour (port release)Changes in v5:
- fix testpmd for detaching multi-ports device
- fix testpmd for detaching only stopped ports
- add a release note about closed port freeing and state
- fix some doxygen comments inrte_eth_dev_data
- improve doxygen ofrte_eth_dev_release_port()
- fix data freeing in some driversChanges in v4:
- do not free data fields which are not dynamically allocated blocks
- removerte_eth_dev_release_port_secondary()
- remove testpmd check to detach without closingChanges in v3:
- free queues, MAC addresses and private structure inrte_eth_dev_release_port.Thomas Monjalon (5):
app/testpmd: allow detaching a port not closed
ethdev: fix doxygen comments of shared data fields
ethdev: free all common data when releasing port
ethdev: remove release function for secondary process
ethdev: complete closing of port
Quoted 2 lines
Wisam Jaddo (1):
app/testpmd: update port list for multiple removals
Series applied to dpdk-next-net/master, thanks.