[v3,08/23] net/i40e: enable port detach on secondary process
Checks
Commit Message
Previously, detach port on secondary process will mess primary
process and cause same device can't be attached again, by take
advantage of rte_eth_release_port_private, we can support this
with minor change.
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 2 ++
drivers/net/i40e/i40e_ethdev_vf.c | 9 +++++++++
2 files changed, 11 insertions(+)
Comments
On 06/25/2018 10:17 AM, Qi Zhang wrote:
> Previously, detach port on secondary process will mess primary
> process and cause same device can't be attached again, by take
> advantage of rte_eth_release_port_private, we can support this
> with minor change.
>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
> drivers/net/i40e/i40e_ethdev.c | 2 ++
> drivers/net/i40e/i40e_ethdev_vf.c | 9 +++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 13c5d3296..7d1f98422 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -678,6 +678,8 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
> if (!ethdev)
> return -ENODEV;
>
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return rte_eth_dev_release_port_private(ethdev);
>
> if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
> return rte_eth_dev_destroy(ethdev, i40e_vf_representor_uninit);
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index 804e44530..fc6f079d5 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1500,6 +1500,15 @@ static int eth_i40evf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>
> static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev)
> {
> + struct rte_eth_dev *ethdev;
> + ethdev = rte_eth_dev_allocated(pci_dev->device.name);
Above two lines looks strange. Is alignment incorrect?
> +
> + if (!ethdev)
> + return -ENODEV;
> +
> + if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> + return rte_eth_dev_release_port_private(ethdev);
> +
These 9 lines are duplicated in 5 changeset (this one and 4 following).
Shouldn't it be done in rte_eth_dev_pci_generic_remove()?
> return rte_eth_dev_pci_generic_remove(pci_dev, i40evf_dev_uninit);
> }
@@ -678,6 +678,8 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
if (!ethdev)
return -ENODEV;
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return rte_eth_dev_release_port_private(ethdev);
if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
return rte_eth_dev_destroy(ethdev, i40e_vf_representor_uninit);
@@ -1500,6 +1500,15 @@ static int eth_i40evf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev)
{
+ struct rte_eth_dev *ethdev;
+ ethdev = rte_eth_dev_allocated(pci_dev->device.name);
+
+ if (!ethdev)
+ return -ENODEV;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return rte_eth_dev_release_port_private(ethdev);
+
return rte_eth_dev_pci_generic_remove(pci_dev, i40evf_dev_uninit);
}