ethdev: fix extended statistics name index
[dpdk.git] / lib / librte_ether / rte_ethdev.c
index 9f60ff3..9dea1f1 100644 (file)
@@ -261,7 +261,8 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
                if (eth_dev->data->dev_private == NULL)
                        rte_panic("Cannot allocate memzone for private port data\n");
        }
-       eth_dev->pci_dev = pci_dev;
+       eth_dev->device = &pci_dev->device;
+       eth_dev->intr_handle = &pci_dev->intr_handle;
        eth_dev->driver = eth_drv;
 
        /* Invoke PMD device initialization function */
@@ -312,7 +313,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
        if (rte_eal_process_type() == RTE_PROC_PRIMARY)
                rte_free(eth_dev->data->dev_private);
 
-       eth_dev->pci_dev = NULL;
+       eth_dev->device = NULL;
        eth_dev->driver = NULL;
        eth_dev->data = NULL;
 
@@ -1526,8 +1527,11 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
                }
        }
 
-       for (i = 0; i < count + xcount; i++)
+       for (i = 0; i < count; i++)
                xstats[i].id = i;
+       /* add an offset to driver-specific stats */
+       for ( ; i < count + xcount; i++)
+               xstats[i].id += count;
 
        return count + xcount;
 }
@@ -1603,7 +1607,6 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
        (*dev->dev_ops->dev_infos_get)(dev, dev_info);
-       dev_info->pci_dev = dev->pci_dev;
        dev_info->driver_name = dev->data->drv_name;
        dev_info->nb_rx_queues = dev->data->nb_rx_queues;
        dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2591,7 +2594,13 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
        dev = &rte_eth_devices[port_id];
-       intr_handle = &dev->pci_dev->intr_handle;
+
+       if (!dev->intr_handle) {
+               RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+               return -ENOTSUP;
+       }
+
+       intr_handle = dev->intr_handle;
        if (!intr_handle->intr_vec) {
                RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
                return -EPERM;
@@ -2619,7 +2628,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.driver.name, ring_name,
+                dev->data->drv_name, ring_name,
                 dev->data->port_id, queue_id);
 
        mz = rte_memzone_lookup(z_name);
@@ -2651,7 +2660,12 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
                return -EINVAL;
        }
 
-       intr_handle = &dev->pci_dev->intr_handle;
+       if (!dev->intr_handle) {
+               RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+               return -ENOTSUP;
+       }
+
+       intr_handle = dev->intr_handle;
        if (!intr_handle->intr_vec) {
                RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
                return -EPERM;
@@ -3253,6 +3267,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
                return;
        }
 
+       eth_dev->intr_handle = &pci_dev->intr_handle;
+
        eth_dev->data->dev_flags = 0;
        if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
                eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;