fix typos using codespell utility
[dpdk.git] / drivers / net / thunderx / nicvf_ethdev.c
index b0b9c3b..471cc16 100644 (file)
@@ -258,7 +258,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        /* Reading per RX ring stats */
        for (qidx = rx_start; qidx <= rx_end; qidx++) {
-               if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+               if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                        break;
 
                nicvf_hw_get_rx_qstats(nic, &rx_qstats, qidx);
@@ -271,7 +271,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        /* Reading per TX ring stats */
        for (qidx = tx_start; qidx <= tx_end; qidx++) {
-               if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+               if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                        break;
 
                nicvf_hw_get_tx_qstats(nic, &tx_qstats, qidx);
@@ -290,7 +290,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
                /* Reading per RX ring stats */
                for (qidx = rx_start; qidx <= rx_end; qidx++) {
-                       if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+                       if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                                break;
 
                        nicvf_hw_get_rx_qstats(snic, &rx_qstats,
@@ -303,7 +303,7 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                nicvf_tx_range(dev, snic, &tx_start, &tx_end);
                /* Reading per TX ring stats */
                for (qidx = tx_start; qidx <= tx_end; qidx++) {
-                       if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+                       if (qidx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
                                break;
 
                        nicvf_hw_get_tx_qstats(snic, &tx_qstats,
@@ -1232,6 +1232,30 @@ nicvf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
        return nicvf_vf_stop_tx_queue(dev, nic, qidx);
 }
 
+static inline void
+nicvf_rxq_mbuf_setup(struct nicvf_rxq *rxq)
+{
+       uintptr_t p;
+       struct rte_mbuf mb_def;
+
+       RTE_BUILD_BUG_ON(sizeof(union mbuf_initializer) != 8);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) % 8 != 0);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) -
+                               offsetof(struct rte_mbuf, data_off) != 2);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) -
+                               offsetof(struct rte_mbuf, data_off) != 4);
+       RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) -
+                               offsetof(struct rte_mbuf, data_off) != 6);
+       mb_def.nb_segs = 1;
+       mb_def.data_off = RTE_PKTMBUF_HEADROOM;
+       mb_def.port = rxq->port_id;
+       rte_mbuf_refcnt_set(&mb_def, 1);
+
+       /* Prevent compiler reordering: rearm_data covers previous fields */
+       rte_compiler_barrier();
+       p = (uintptr_t)&mb_def.rearm_data;
+       rxq->mbuf_initializer.value = *(uint64_t *)p;
+}
 
 static int
 nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
@@ -1324,6 +1348,7 @@ nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
        else
                rxq->rbptr_offset = NICVF_CQE_RBPTR_WORD;
 
+       nicvf_rxq_mbuf_setup(rxq);
 
        /* Alloc completion queue */
        if (nicvf_qset_cq_alloc(dev, nic, rxq, rxq->queue_id, nb_desc)) {
@@ -1348,11 +1373,11 @@ 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);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 
        PMD_INIT_FUNC_TRACE();
 
-       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
+       dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 
        dev_info->min_rx_bufsize = ETHER_MIN_MTU;
        dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
@@ -1999,7 +2024,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
                }
        }
 
-       pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
+       pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
        nic->device_id = pci_dev->id.device_id;
@@ -2061,7 +2086,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
                        goto fail;
                }
 
-               /* Detach port by returning postive error number */
+               /* Detach port by returning positive error number */
                return ENOTSUP;
        }
 
@@ -2146,11 +2171,12 @@ static int nicvf_eth_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_nicvf_pmd = {
        .id_table = pci_id_nicvf_map,
-       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_KEEP_MAPPED_RES |
+                       RTE_PCI_DRV_INTR_LSC,
        .probe = nicvf_eth_pci_probe,
        .remove = nicvf_eth_pci_remove,
 };
 
 RTE_PMD_REGISTER_PCI(net_thunderx, rte_nicvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_thunderx, pci_id_nicvf_map);
-RTE_PMD_REGISTER_KMOD_DEP(net_thunderx, "* igb_uio | uio_pci_generic | vfio");
+RTE_PMD_REGISTER_KMOD_DEP(net_thunderx, "* igb_uio | uio_pci_generic | vfio-pci");