examples/ipsec-secgw: fix session mempool initialisation
[dpdk.git] / drivers / net / atlantic / atl_ethdev.c
index 540b106..b071677 100644 (file)
 #include "hw_atl/hw_atl_b0_internal.h"
 
 static int eth_atl_dev_init(struct rte_eth_dev *eth_dev);
-static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
-
 static int  atl_dev_configure(struct rte_eth_dev *dev);
 static int  atl_dev_start(struct rte_eth_dev *dev);
-static void atl_dev_stop(struct rte_eth_dev *dev);
+static int atl_dev_stop(struct rte_eth_dev *dev);
 static int  atl_dev_set_link_up(struct rte_eth_dev *dev);
 static int  atl_dev_set_link_down(struct rte_eth_dev *dev);
-static void atl_dev_close(struct rte_eth_dev *dev);
+static int  atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
 static int  atl_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int  atl_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -382,6 +380,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
+       eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
        /* Vendor and Device ID need to be set before init of shared code */
        hw->device_id = pci_dev->id.device_id;
        hw->vendor_id = pci_dev->id.vendor_id;
@@ -442,40 +442,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
        return err;
 }
 
-static int
-eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
-{
-       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
-       struct aq_hw_s *hw;
-
-       PMD_INIT_FUNC_TRACE();
-
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return -EPERM;
-
-       hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-
-       if (hw->adapter_stopped == 0)
-               atl_dev_close(eth_dev);
-
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-
-       /* disable uio intr before callback unregister */
-       rte_intr_disable(intr_handle);
-       rte_intr_callback_unregister(intr_handle,
-                                    atl_dev_interrupt_handler, eth_dev);
-
-       rte_free(eth_dev->data->mac_addrs);
-       eth_dev->data->mac_addrs = NULL;
-
-       pthread_mutex_destroy(&hw->mbox_mutex);
-
-       return 0;
-}
-
 static int
 eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
        struct rte_pci_device *pci_dev)
@@ -487,7 +453,7 @@ eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 static int
 eth_atl_pci_remove(struct rte_pci_device *pci_dev)
 {
-       return rte_eth_dev_pci_generic_remove(pci_dev, eth_atl_dev_uninit);
+       return rte_eth_dev_pci_generic_remove(pci_dev, atl_dev_close);
 }
 
 static int
@@ -635,7 +601,7 @@ error:
 /*
  * Stop device: disable rx and tx functions to allow for reconfiguring.
  */
-static void
+static int
 atl_dev_stop(struct rte_eth_dev *dev)
 {
        struct rte_eth_link link;
@@ -645,6 +611,7 @@ atl_dev_stop(struct rte_eth_dev *dev)
        struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
        PMD_INIT_FUNC_TRACE();
+       dev->data->dev_started = 0;
 
        /* disable interrupts */
        atl_disable_intr(hw);
@@ -675,6 +642,8 @@ atl_dev_stop(struct rte_eth_dev *dev)
                rte_free(intr_handle->intr_vec);
                intr_handle->intr_vec = NULL;
        }
+
+       return 0;
 }
 
 /*
@@ -719,14 +688,33 @@ atl_dev_set_link_down(struct rte_eth_dev *dev)
 /*
  * Reset and stop device.
  */
-static void
+static int
 atl_dev_close(struct rte_eth_dev *dev)
 {
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct aq_hw_s *hw;
+       int ret;
+
        PMD_INIT_FUNC_TRACE();
 
-       atl_dev_stop(dev);
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
+       hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+       ret = atl_dev_stop(dev);
 
        atl_free_queues(dev);
+
+       /* disable uio intr before callback unregister */
+       rte_intr_disable(intr_handle);
+       rte_intr_callback_unregister(intr_handle,
+                                    atl_dev_interrupt_handler, dev);
+
+       pthread_mutex_destroy(&hw->mbox_mutex);
+
+       return ret;
 }
 
 static int
@@ -734,7 +722,7 @@ atl_dev_reset(struct rte_eth_dev *dev)
 {
        int ret;
 
-       ret = eth_atl_dev_uninit(dev);
+       ret = atl_dev_close(dev);
        if (ret)
                return ret;
 
@@ -1395,8 +1383,7 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev,
        /* Notify userapp if link status changed */
        if (!atl_dev_link_update(dev, 0)) {
                atl_dev_link_status_print(dev);
-               _rte_eth_dev_callback_process(dev,
-                       RTE_ETH_EVENT_INTR_LSC, NULL);
+               rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
        } else {
                if (hw->aq_fw_ops->send_macsec_req == NULL)
                        goto done;
@@ -1422,7 +1409,7 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev,
                    resp.stats.egress_expired ||
                    resp.stats.ingress_expired) {
                        PMD_DRV_LOG(INFO, "RTE_ETH_EVENT_MACSEC");
-                       _rte_eth_dev_callback_process(dev,
+                       rte_eth_dev_callback_process(dev,
                                RTE_ETH_EVENT_MACSEC, NULL);
                }
        }