drivers/net: do not use ethdev driver
[dpdk.git] / drivers / net / fm10k / fm10k_ethdev.c
index 381c58e..94b4d40 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <rte_ethdev.h>
+#include <rte_ethdev_pci.h>
 #include <rte_malloc.h>
 #include <rte_memzone.h>
 #include <rte_string_fns.h>
@@ -2542,9 +2543,7 @@ error:
  *  void
  */
 static void
-fm10k_dev_interrupt_handler_pf(
-                       struct rte_intr_handle *handle,
-                       void *param)
+fm10k_dev_interrupt_handler_pf(void *param)
 {
        struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -2594,7 +2593,7 @@ fm10k_dev_interrupt_handler_pf(
        FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_AUTOMASK |
                                        FM10K_ITR_MASK_CLEAR);
        /* Re-enable interrupt from host side */
-       rte_intr_enable(handle);
+       rte_intr_enable(dev->intr_handle);
 }
 
 /**
@@ -2609,9 +2608,7 @@ fm10k_dev_interrupt_handler_pf(
  *  void
  */
 static void
-fm10k_dev_interrupt_handler_vf(
-                       struct rte_intr_handle *handle,
-                       void *param)
+fm10k_dev_interrupt_handler_vf(void *param)
 {
        struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -2628,7 +2625,7 @@ fm10k_dev_interrupt_handler_vf(
        FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_AUTOMASK |
                                        FM10K_ITR_MASK_CLEAR);
        /* Re-enable interrupt from host side */
-       rte_intr_enable(handle);
+       rte_intr_enable(dev->intr_handle);
 }
 
 /* Mailbox message handler in VF */
@@ -2772,6 +2769,21 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
        int use_sse = 1;
        uint16_t tx_ftag_en = 0;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+               /* primary process has set the ftag flag and txq_flags */
+               txq = dev->data->tx_queues[0];
+               if (fm10k_tx_vec_condition_check(txq)) {
+                       dev->tx_pkt_burst = fm10k_xmit_pkts;
+                       dev->tx_pkt_prepare = fm10k_prep_pkts;
+                       PMD_INIT_LOG(DEBUG, "Use regular Tx func");
+               } else {
+                       PMD_INIT_LOG(DEBUG, "Use vector Tx func");
+                       dev->tx_pkt_burst = fm10k_xmit_pkts_vec;
+                       dev->tx_pkt_prepare = NULL;
+               }
+               return;
+       }
+
        if (fm10k_check_ftag(dev->device->devargs))
                tx_ftag_en = 1;
 
@@ -2832,6 +2844,9 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)
        else
                PMD_INIT_LOG(DEBUG, "Use regular Rx func");
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return;
+
        for (i = 0; i < dev->data->nb_rx_queues; i++) {
                struct fm10k_rx_queue *rxq = dev->data->rx_queues[i];
 
@@ -2878,9 +2893,15 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
        dev->tx_pkt_burst = &fm10k_xmit_pkts;
        dev->tx_pkt_prepare = &fm10k_prep_pkts;
 
-       /* only initialize in the primary process */
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+       /*
+        * Primary process does the whole initialization, for secondary
+        * processes, we just select the same Rx and Tx function as primary.
+        */
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+               fm10k_set_rx_function(dev);
+               fm10k_set_tx_function(dev);
                return 0;
+       }
 
        rte_eth_copy_pci_info(dev, pdev);
        dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
@@ -3092,6 +3113,18 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
        return 0;
 }
 
+static int eth_fm10k_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+       struct rte_pci_device *pci_dev)
+{
+       return rte_eth_dev_pci_generic_probe(pci_dev,
+               sizeof(struct fm10k_adapter), eth_fm10k_dev_init);
+}
+
+static int eth_fm10k_pci_remove(struct rte_pci_device *pci_dev)
+{
+       return rte_eth_dev_pci_generic_remove(pci_dev, eth_fm10k_dev_uninit);
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -3103,18 +3136,13 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
        { .vendor_id = 0, /* sentinel */ },
 };
 
-static struct eth_driver rte_pmd_fm10k = {
-       .pci_drv = {
-               .id_table = pci_id_fm10k_map,
-               .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-               .probe = rte_eth_dev_pci_probe,
-               .remove = rte_eth_dev_pci_remove,
-       },
-       .eth_dev_init = eth_fm10k_dev_init,
-       .eth_dev_uninit = eth_fm10k_dev_uninit,
-       .dev_private_size = sizeof(struct fm10k_adapter),
+static struct rte_pci_driver rte_pmd_fm10k = {
+       .id_table = pci_id_fm10k_map,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+       .probe = eth_fm10k_pci_probe,
+       .remove = eth_fm10k_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(net_fm10k, rte_pmd_fm10k.pci_drv);
+RTE_PMD_REGISTER_PCI(net_fm10k, rte_pmd_fm10k);
 RTE_PMD_REGISTER_PCI_TABLE(net_fm10k, pci_id_fm10k_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_fm10k, "* igb_uio | uio_pci_generic | vfio");