From: Maxime Leroy <maxime.le...@6wind.com>

The rte_eth_dev_is_detachable return 0 when the device is detachable.
It not, this one return a negative value or 1.
Such behavior is not logical.

This patch modifies this function to return 1 when the device is detachable
and 0 when is not.

Signed-off-by: Maxime Leroy <maxime.leroy at 6wind.com>
Signed-off-by: David Marchand <david.marchand at 6wind.com>
---
 lib/librte_ether/rte_ethdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 073ffe9..ec1b632 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -510,7 +510,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)

        if (!rte_eth_dev_is_valid_port(port_id)) {
                PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-               return -EINVAL;
+               return 0;
        }

        if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
@@ -521,12 +521,12 @@ rte_eth_dev_is_detachable(uint8_t port_id)
                        break;
                case RTE_KDRV_VFIO:
                default:
-                       return -ENOTSUP;
+                       return 0;
                }
        }

        drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
-       return !(drv_flags & RTE_PCI_DRV_DETACHABLE);
+       return drv_flags & RTE_PCI_DRV_DETACHABLE;
 }

 /* attach the new physical device, then store port_id of the device */
@@ -574,7 +574,7 @@ rte_eth_dev_detach_pdev(uint8_t port_id, struct 
rte_pci_addr *addr)
                goto err;

        /* check whether the driver supports detach feature, or not */
-       if (rte_eth_dev_is_detachable(port_id))
+       if (!rte_eth_dev_is_detachable(port_id))
                goto err;

        /* get pci address by port id */
@@ -651,7 +651,7 @@ rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
                goto err;

        /* check whether the driver supports detach feature, or not */
-       if (rte_eth_dev_is_detachable(port_id))
+       if (!rte_eth_dev_is_detachable(port_id))
                goto err;

        /* get device name by port id */
-- 
1.9.1

Reply via email to