VF representor ports are never released.
They have no close callback, so rte_eth_dev_close()
returns -ENOTSUP before releasing the port.
On device removal, eth_ixgbe_pci_remove() looks up
the port by the PCI device name, which always finds
the PF, so the representor branch is dead code.
Each representor leaks its port and private data,
and its MAC address pointer is left pointing into the
per-VF data of the PF, which is freed when the PF is
closed.
Add a close callback for representors, and release them
before the PF on device removal.
As close may also be called from a secondary process,
only clear the shared MAC address pointer in the primary.
Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
Cc: [email protected]
Signed-off-by: Anurag Mandal <[email protected]>
---
drivers/net/intel/ixgbe/ixgbe_ethdev.c | 17 ++++++++---------
drivers/net/intel/ixgbe/ixgbe_vf_representor.c | 5 ++++-
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index cbf8175c56..dabdfd932b 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -1711,17 +1711,16 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv
__rte_unused,
static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
{
struct rte_eth_dev *ethdev;
+ uint16_t port_id;
- ethdev = rte_eth_dev_allocated(pci_dev->device.name);
- if (!ethdev)
- return 0;
+ /* representors point into PF private data, so release them first */
+ RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
+ ethdev = &rte_eth_devices[port_id];
+ if (rte_eth_dev_is_repr(ethdev))
+ rte_eth_dev_destroy(ethdev,
ixgbe_vf_representor_uninit);
+ }
- if (rte_eth_dev_is_repr(ethdev))
- return rte_eth_dev_pci_generic_remove(pci_dev,
- ixgbe_vf_representor_uninit);
- else
- return rte_eth_dev_pci_generic_remove(pci_dev,
- eth_ixgbe_dev_uninit);
+ return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
}
static struct rte_pci_driver rte_ixgbe_pmd = {
diff --git a/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
b/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
index c11983e307..83f8f667a9 100644
--- a/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
+++ b/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
@@ -5,6 +5,7 @@
#include <rte_ethdev.h>
#include <rte_pci.h>
#include <rte_malloc.h>
+#include <rte_eal.h>
#include "ethdev_driver.h"
#include "base/ixgbe_type.h"
@@ -173,6 +174,7 @@ static const struct eth_dev_ops
ixgbe_vf_representor_dev_ops = {
.dev_start = ixgbe_vf_representor_dev_start,
.dev_configure = ixgbe_vf_representor_dev_configure,
.dev_stop = ixgbe_vf_representor_dev_stop,
+ .dev_close = ixgbe_vf_representor_uninit,
.rx_queue_setup = ixgbe_vf_representor_rx_queue_setup,
.tx_queue_setup = ixgbe_vf_representor_tx_queue_setup,
@@ -267,7 +269,8 @@ int
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;
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ ethdev->data->mac_addrs = NULL;
return 0;
}
--
2.25.1