ethdev: fix hotplug attach
[dpdk.git] / lib / librte_ether / rte_ethdev.c
index cc2f921..24029f0 100644 (file)
@@ -275,7 +275,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
                return 0;
 
        RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
-                       pci_drv->name,
+                       pci_drv->driver.name,
                        (unsigned) pci_dev->id.vendor_id,
                        (unsigned) pci_dev->id.device_id);
        if (rte_eal_process_type() == RTE_PROC_PRIMARY)
@@ -421,7 +421,7 @@ int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
        int ret = -1;
-       int current = eth_dev_last_created_port;
+       int current = rte_eth_dev_count();
        char *name = NULL;
        char *args = NULL;
 
@@ -438,9 +438,9 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
        if (ret < 0)
                goto err;
 
-       /* no point looking at eth_dev_last_created_port if no port exists */
-       if (!nb_ports) {
-               RTE_LOG(ERR, EAL, "No ports found for device (%s)\n", name);
+       /* no point looking at the port count if no port exists */
+       if (!rte_eth_dev_count()) {
+               RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name);
                ret = -1;
                goto err;
        }
@@ -448,7 +448,7 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
        /* if nothing happened, there is a bug here, since some driver told us
         * it did attach a device, but did not create a port.
         */
-       if (current == eth_dev_last_created_port) {
+       if (current == rte_eth_dev_count()) {
                ret = -1;
                goto err;
        }
@@ -2568,7 +2568,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
        const struct rte_memzone *mz;
 
        snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                dev->driver->pci_drv.name, ring_name,
+                dev->driver->pci_drv.driver.name, ring_name,
                 dev->data->port_id, queue_id);
 
        mz = rte_memzone_lookup(z_name);
@@ -3209,8 +3209,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
                eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        eth_dev->data->kdrv = pci_dev->kdrv;
-       eth_dev->data->numa_node = pci_dev->numa_node;
-       eth_dev->data->drv_name = pci_dev->driver->name;
+       eth_dev->data->numa_node = pci_dev->device.numa_node;
+       eth_dev->data->drv_name = pci_dev->driver->driver.name;
 }
 
 int