ethdev: decouple from PCI device
[dpdk.git] / drivers / net / thunderx / nicvf_ethdev.c
index 8bafc78..1060319 100644 (file)
@@ -111,7 +111,7 @@ nicvf_interrupt(void *arg)
        if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
                if (dev->data->dev_conf.intr_conf.lsc)
                        nicvf_set_eth_link_status(nic, &dev->data->dev_link);
-               _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
+               _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
        }
 
        rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
@@ -1335,9 +1335,12 @@ static void
 nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct nicvf *nic = nicvf_pmd_priv(dev);
+       struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
        PMD_INIT_FUNC_TRACE();
 
+       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
+
        dev_info->min_rx_bufsize = ETHER_MIN_MTU;
        dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
        dev_info->max_rx_queues =
@@ -1345,7 +1348,7 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->max_tx_queues =
                        (uint16_t)MAX_SND_QUEUES_PER_QS * (MAX_SQS_PER_VF + 1);
        dev_info->max_mac_addrs = 1;
-       dev_info->max_vfs = dev->pci_dev->max_vfs;
+       dev_info->max_vfs = pci_dev->max_vfs;
 
        dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;
        dev_info->tx_offload_capa =
@@ -1527,6 +1530,16 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
        /* Configure VLAN Strip */
        nicvf_vlan_hw_strip(nic, dev->data->dev_conf.rxmode.hw_vlan_strip);
 
+       /* Based on the packet type(IPv4 or IPv6), the nicvf HW aligns L3 data
+        * to the 64bit memory address.
+        * The alignment creates a hole in mbuf(between the end of headroom and
+        * packet data start). The new revision of the HW provides an option to
+        * disable the L3 alignment feature and make mbuf layout looks
+        * more like other NICs. For better application compatibility, disabling
+        * l3 alignment feature on the hardware revisions it supports
+        */
+       nicvf_apad_config(nic, false);
+
        /* Get queue ranges for this VF */
        nicvf_tx_range(dev, nic, &tx_start, &tx_end);
 
@@ -1965,7 +1978,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
                }
        }
 
-       pci_dev = eth_dev->pci_dev;
+       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
        nic->device_id = pci_dev->id.device_id;
@@ -2086,6 +2099,13 @@ static const struct rte_pci_id pci_id_nicvf_map[] = {
                .subsystem_vendor_id = PCI_VENDOR_ID_CAVIUM,
                .subsystem_device_id = PCI_SUB_DEVICE_ID_CN81XX_NICVF,
        },
+       {
+               .class_id = RTE_CLASS_ANY_ID,
+               .vendor_id = PCI_VENDOR_ID_CAVIUM,
+               .device_id = PCI_DEVICE_ID_THUNDERX_NICVF,
+               .subsystem_vendor_id = PCI_VENDOR_ID_CAVIUM,
+               .subsystem_device_id = PCI_SUB_DEVICE_ID_CN83XX_NICVF,
+       },
        {
                .vendor_id = 0,
        },
@@ -2104,3 +2124,4 @@ static struct eth_driver rte_nicvf_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_thunderx, rte_nicvf_pmd.pci_drv);
 RTE_PMD_REGISTER_PCI_TABLE(net_thunderx, pci_id_nicvf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_thunderx, "* igb_uio | uio_pci_generic | vfio");