drivers: use PCI registration macro
[dpdk.git] / drivers / net / thunderx / nicvf_ethdev.c
index d534312..9ccf59e 100644 (file)
@@ -188,20 +188,17 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
        return 0;
 }
 
-static int
-nicvf_dev_get_reg_length(struct rte_eth_dev *dev  __rte_unused)
-{
-       return nicvf_reg_get_count();
-}
-
 static int
 nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs)
 {
        uint64_t *data = regs->data;
        struct nicvf *nic = nicvf_pmd_priv(dev);
 
-       if (data == NULL)
-               return -EINVAL;
+       if (data == NULL) {
+               regs->length = nicvf_reg_get_count();
+               regs->width = THUNDERX_REG_BYTES;
+               return 0;
+       }
 
        /* Support only full register dump */
        if ((regs->length == 0) ||
@@ -495,7 +492,7 @@ nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx,
                    uint32_t desc_cnt)
 {
        const struct rte_memzone *rz;
-       uint32_t ring_size = desc_cnt * sizeof(union cq_entry_t);
+       uint32_t ring_size = CMP_QUEUE_SZ_MAX * sizeof(union cq_entry_t);
 
        rz = rte_eth_dma_zone_reserve(nic->eth_dev, "cq_ring", qidx, ring_size,
                                        NICVF_CQ_BASE_ALIGN_BYTES, nic->node);
@@ -518,7 +515,7 @@ nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq *sq, uint16_t qidx,
                    uint32_t desc_cnt)
 {
        const struct rte_memzone *rz;
-       uint32_t ring_size = desc_cnt * sizeof(union sq_entry_t);
+       uint32_t ring_size = SND_QUEUE_SZ_MAX * sizeof(union sq_entry_t);
 
        rz = rte_eth_dma_zone_reserve(nic->eth_dev, "sq", qidx, ring_size,
                                NICVF_SQ_BASE_ALIGN_BYTES, nic->node);
@@ -551,7 +548,7 @@ nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
                return -ENOMEM;
        }
 
-       ring_size = sizeof(struct rbdr_entry_t) * desc_cnt;
+       ring_size = sizeof(struct rbdr_entry_t) * RBDR_QUEUE_SZ_MAX;
        rz = rte_eth_dma_zone_reserve(nic->eth_dev, "rbdr", 0, ring_size,
                                   NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
        if (rz == NULL) {
@@ -1158,7 +1155,7 @@ nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 
        PMD_RX_LOG(DEBUG, "[%d] rxq=%p pool=%s nb_desc=(%d/%d) phy=%" PRIx64,
                        qidx, rxq, mp->name, nb_desc,
-                       rte_mempool_count(mp), rxq->phys);
+                       rte_mempool_avail_count(mp), rxq->phys);
 
        dev->data->rx_queues[qidx] = rxq;
        dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
@@ -1313,10 +1310,10 @@ nicvf_dev_start(struct rte_eth_dev *dev)
                total_rxq_desc += rxq->qlen_mask + 1;
                exp_buffs = RTE_MEMPOOL_CACHE_MAX_SIZE + rxq->rx_free_thresh;
                exp_buffs *= nic->eth_dev->data->nb_rx_queues;
-               if (rte_mempool_count(rxq->pool) < exp_buffs) {
+               if (rte_mempool_avail_count(rxq->pool) < exp_buffs) {
                        PMD_INIT_LOG(ERR, "Buff shortage in pool=%s (%d/%d)",
                                     rxq->pool->name,
-                                    rte_mempool_count(rxq->pool),
+                                    rte_mempool_avail_count(rxq->pool),
                                     exp_buffs);
                        return -ENOENT;
                }
@@ -1623,7 +1620,6 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
        .rx_queue_count           = nicvf_dev_rx_queue_count,
        .tx_queue_setup           = nicvf_dev_tx_queue_setup,
        .tx_queue_release         = nicvf_dev_tx_queue_release,
-       .get_reg_length           = nicvf_dev_get_reg_length,
        .get_reg                  = nicvf_dev_get_regs,
 };
 
@@ -1766,26 +1762,12 @@ static struct eth_driver rte_nicvf_pmd = {
                .name = "rte_nicvf_pmd",
                .id_table = pci_id_nicvf_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 = nicvf_eth_dev_init,
        .dev_private_size = sizeof(struct nicvf),
 };
 
-static int
-rte_nicvf_pmd_init(const char *name __rte_unused, const char *para __rte_unused)
-{
-       PMD_INIT_FUNC_TRACE();
-       PMD_INIT_LOG(INFO, "librte_pmd_thunderx nicvf version %s",
-                       THUNDERX_NICVF_PMD_VERSION);
-
-       rte_eth_driver_register(&rte_nicvf_pmd);
-       return 0;
-}
-
-static struct rte_driver rte_nicvf_driver = {
-       .name = "nicvf_driver",
-       .type = PMD_PDEV,
-       .init = rte_nicvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nicvf_driver);
+DRIVER_REGISTER_PCI(net_thunderx, rte_nicvf_pmd.pci_drv);
+DRIVER_REGISTER_PCI_TABLE(net_thunderx, pci_id_nicvf_map);