ethdev: add device flag to bypass auto-filled queue xstats
[dpdk.git] / drivers / net / e1000 / igb_ethdev.c
index fe0cea8..ac4b8f1 100644 (file)
 
 static int  eth_igb_configure(struct rte_eth_dev *dev);
 static int  eth_igb_start(struct rte_eth_dev *dev);
-static void eth_igb_stop(struct rte_eth_dev *dev);
+static int  eth_igb_stop(struct rte_eth_dev *dev);
 static int  eth_igb_dev_set_link_up(struct rte_eth_dev *dev);
 static int  eth_igb_dev_set_link_down(struct rte_eth_dev *dev);
-static void eth_igb_close(struct rte_eth_dev *dev);
+static int eth_igb_close(struct rte_eth_dev *dev);
 static int eth_igb_reset(struct rte_eth_dev *dev);
 static int  eth_igb_promiscuous_enable(struct rte_eth_dev *dev);
 static int  eth_igb_promiscuous_disable(struct rte_eth_dev *dev);
@@ -154,8 +154,8 @@ static int eth_igb_default_mac_addr_set(struct rte_eth_dev *dev,
 static void igbvf_intr_disable(struct e1000_hw *hw);
 static int igbvf_dev_configure(struct rte_eth_dev *dev);
 static int igbvf_dev_start(struct rte_eth_dev *dev);
-static void igbvf_dev_stop(struct rte_eth_dev *dev);
-static void igbvf_dev_close(struct rte_eth_dev *dev);
+static int igbvf_dev_stop(struct rte_eth_dev *dev);
+static int igbvf_dev_close(struct rte_eth_dev *dev);
 static int igbvf_promiscuous_enable(struct rte_eth_dev *dev);
 static int igbvf_promiscuous_disable(struct rte_eth_dev *dev);
 static int igbvf_allmulticast_enable(struct rte_eth_dev *dev);
@@ -765,6 +765,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
        }
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
+       eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
        hw->hw_addr= (void *)pci_dev->mem_resource[0].addr;
 
@@ -841,11 +842,6 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
        rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.addr,
                        &eth_dev->data->mac_addrs[0]);
 
-       /* Pass the information to the rte_eth_dev_close() that it should also
-        * release the private port resources.
-        */
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
-
        /* initialize the vfta */
        memset(shadow_vfta, 0, sizeof(*shadow_vfta));
 
@@ -964,6 +960,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 
        pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
+       eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
        hw->device_id = pci_dev->id.device_id;
        hw->vendor_id = pci_dev->id.vendor_id;
@@ -997,11 +994,6 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
                return -ENOMEM;
        }
 
-       /* Pass the information to the rte_eth_dev_close() that it should also
-        * release the private port resources.
-        */
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
-
        /* Generate a random MAC address, if none was assigned by PF. */
        if (rte_is_zero_ether_addr(perm_addr)) {
                rte_eth_random_addr(perm_addr->addr_bytes);
@@ -1451,7 +1443,7 @@ error_invalid_config:
  *  global reset on the MAC.
  *
  **********************************************************************/
-static void
+static int
 eth_igb_stop(struct rte_eth_dev *dev)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1462,7 +1454,7 @@ eth_igb_stop(struct rte_eth_dev *dev)
                E1000_DEV_PRIVATE(dev->data->dev_private);
 
        if (adapter->stopped)
-               return;
+               return 0;
 
        eth_igb_rxtx_control(dev, false);
 
@@ -1507,6 +1499,9 @@ eth_igb_stop(struct rte_eth_dev *dev)
        }
 
        adapter->stopped = true;
+       dev->data->dev_started = 0;
+
+       return 0;
 }
 
 static int
@@ -1535,7 +1530,7 @@ eth_igb_dev_set_link_down(struct rte_eth_dev *dev)
        return 0;
 }
 
-static void
+static int
 eth_igb_close(struct rte_eth_dev *dev)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1544,8 +1539,12 @@ eth_igb_close(struct rte_eth_dev *dev)
        struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
        struct e1000_filter_info *filter_info =
                E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
+       int ret;
 
-       eth_igb_stop(dev);
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
+       ret = eth_igb_stop(dev);
 
        e1000_phy_hw_reset(hw);
        igb_release_manageability(hw);
@@ -1571,10 +1570,6 @@ eth_igb_close(struct rte_eth_dev *dev)
        memset(&link, 0, sizeof(link));
        rte_eth_linkstatus_set(dev, &link);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* Reset any pending lock */
        igb_reset_swfw_lock(hw);
 
@@ -1604,6 +1599,8 @@ eth_igb_close(struct rte_eth_dev *dev)
 
        /* clear all the filters list */
        igb_filterlist_flush(dev);
+
+       return ret;
 }
 
 /*
@@ -2920,8 +2917,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,
                             pci_dev->addr.bus,
                             pci_dev->addr.devid,
                             pci_dev->addr.function);
-               _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-                                             NULL);
+               rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
        }
 
        return 0;
@@ -2983,8 +2979,8 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
                /* dummy mbx read to ack pf */
                if (mbx->ops.read(hw, &in_msg, 1, 0))
                        return;
-               _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-                                             NULL);
+               rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
+                                            NULL);
        }
 }
 
@@ -3346,7 +3342,7 @@ igbvf_dev_start(struct rte_eth_dev *dev)
        return 0;
 }
 
-static void
+static int
 igbvf_dev_stop(struct rte_eth_dev *dev)
 {
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -3355,7 +3351,7 @@ igbvf_dev_stop(struct rte_eth_dev *dev)
                E1000_DEV_PRIVATE(dev->data->dev_private);
 
        if (adapter->stopped)
-               return;
+               return 0;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -3380,20 +3376,29 @@ igbvf_dev_stop(struct rte_eth_dev *dev)
        }
 
        adapter->stopped = true;
+       dev->data->dev_started = 0;
+
+       return 0;
 }
 
-static void
+static int
 igbvf_dev_close(struct rte_eth_dev *dev)
 {
        struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_ether_addr addr;
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+       int ret;
 
        PMD_INIT_FUNC_TRACE();
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        e1000_reset_hw(hw);
 
-       igbvf_dev_stop(dev);
+       ret = igbvf_dev_stop(dev);
+       if (ret != 0)
+               return ret;
 
        igb_dev_free_queues(dev);
 
@@ -3406,13 +3411,11 @@ igbvf_dev_close(struct rte_eth_dev *dev)
        memset(&addr, 0, sizeof(addr));
        igbvf_default_mac_addr_set(dev, &addr);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        rte_intr_callback_unregister(&pci_dev->intr_handle,
                                     eth_igbvf_interrupt_handler,
                                     (void *)dev);
+
+       return 0;
 }
 
 static int