net/thunderx: add secondary queue set support in stop/close
[dpdk.git] / drivers / net / thunderx / nicvf_ethdev.c
index e141f05..5e5e2f3 100644 (file)
 
 #include "nicvf_ethdev.h"
 #include "nicvf_rxtx.h"
+#include "nicvf_svf.h"
 #include "nicvf_logs.h"
 
 static void nicvf_dev_stop(struct rte_eth_dev *dev);
+static void nicvf_dev_stop_cleanup(struct rte_eth_dev *dev, bool cleanup);
+static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
+                         bool cleanup);
 
 static inline int
 nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
@@ -101,31 +105,40 @@ nicvf_set_eth_link_status(struct nicvf *nic, struct rte_eth_link *link)
 static void
 nicvf_interrupt(void *arg)
 {
-       struct nicvf *nic = arg;
+       struct rte_eth_dev *dev = arg;
+       struct nicvf *nic = nicvf_pmd_priv(dev);
 
        if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
-               if (nic->eth_dev->data->dev_conf.intr_conf.lsc)
-                       nicvf_set_eth_link_status(nic,
-                                       &nic->eth_dev->data->dev_link);
-               _rte_eth_dev_callback_process(nic->eth_dev,
-                               RTE_ETH_EVENT_INTR_LSC);
+               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_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
-                               nicvf_interrupt, nic);
+                               nicvf_interrupt, dev);
+}
+
+static void __rte_unused
+nicvf_vf_interrupt(void *arg)
+{
+       struct nicvf *nic = arg;
+
+       nicvf_reg_poll_interrupts(nic);
+
+       rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
+                               nicvf_vf_interrupt, nic);
 }
 
 static int
-nicvf_periodic_alarm_start(struct nicvf *nic)
+nicvf_periodic_alarm_start(void (fn)(void *), void *arg)
 {
-       return rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
-                                       nicvf_interrupt, nic);
+       return rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, fn, arg);
 }
 
 static int
-nicvf_periodic_alarm_stop(struct nicvf *nic)
+nicvf_periodic_alarm_stop(void (fn)(void *), void *arg)
 {
-       return rte_eal_alarm_cancel(nicvf_interrupt, nic);
+       return rte_eal_alarm_cancel(fn, arg);
 }
 
 /*
@@ -488,14 +501,14 @@ nicvf_dev_rss_hash_update(struct rte_eth_dev *dev,
 }
 
 static int
-nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx,
-                   uint32_t desc_cnt)
+nicvf_qset_cq_alloc(struct rte_eth_dev *dev, struct nicvf *nic,
+                   struct nicvf_rxq *rxq, uint16_t qidx, uint32_t desc_cnt)
 {
        const struct rte_memzone *rz;
        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);
+       rz = rte_eth_dma_zone_reserve(dev, "cq_ring", qidx, ring_size,
+                                     NICVF_CQ_BASE_ALIGN_BYTES, nic->node);
        if (rz == NULL) {
                PMD_INIT_LOG(ERR, "Failed to allocate mem for cq hw ring");
                return -ENOMEM;
@@ -511,13 +524,13 @@ nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx,
 }
 
 static int
-nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq *sq, uint16_t qidx,
-                   uint32_t desc_cnt)
+nicvf_qset_sq_alloc(struct rte_eth_dev *dev, struct nicvf *nic,
+                   struct nicvf_txq *sq, uint16_t qidx, uint32_t desc_cnt)
 {
        const struct rte_memzone *rz;
        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,
+       rz = rte_eth_dma_zone_reserve(dev, "sq", qidx, ring_size,
                                NICVF_SQ_BASE_ALIGN_BYTES, nic->node);
        if (rz == NULL) {
                PMD_INIT_LOG(ERR, "Failed allocate mem for sq hw ring");
@@ -534,7 +547,8 @@ nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq *sq, uint16_t qidx,
 }
 
 static int
-nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
+nicvf_qset_rbdr_alloc(struct rte_eth_dev *dev, struct nicvf *nic,
+                     uint32_t desc_cnt, uint32_t buffsz)
 {
        struct nicvf_rbdr *rbdr;
        const struct rte_memzone *rz;
@@ -549,7 +563,7 @@ nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
        }
 
        ring_size = sizeof(struct rbdr_entry_t) * RBDR_QUEUE_SZ_MAX;
-       rz = rte_eth_dma_zone_reserve(nic->eth_dev, "rbdr", 0, ring_size,
+       rz = rte_eth_dma_zone_reserve(dev, "rbdr", 0, ring_size,
                                   NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
        if (rz == NULL) {
                PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
@@ -574,14 +588,15 @@ nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
 }
 
 static void
-nicvf_rbdr_release_mbuf(struct nicvf *nic, nicvf_phys_addr_t phy)
+nicvf_rbdr_release_mbuf(struct rte_eth_dev *dev, struct nicvf *nic __rte_unused,
+                       nicvf_phys_addr_t phy)
 {
        uint16_t qidx;
        void *obj;
        struct nicvf_rxq *rxq;
 
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
-               rxq = nic->eth_dev->data->rx_queues[qidx];
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
+               rxq = dev->data->rx_queues[qidx];
                if (rxq->precharge_cnt) {
                        obj = (void *)nicvf_mbuff_phy2virt(phy,
                                                           rxq->mbuf_phys_off);
@@ -593,7 +608,7 @@ nicvf_rbdr_release_mbuf(struct nicvf *nic, nicvf_phys_addr_t phy)
 }
 
 static inline void
-nicvf_rbdr_release_mbufs(struct nicvf *nic)
+nicvf_rbdr_release_mbufs(struct rte_eth_dev *dev, struct nicvf *nic)
 {
        uint32_t qlen_mask, head;
        struct rbdr_entry_t *entry;
@@ -603,7 +618,7 @@ nicvf_rbdr_release_mbufs(struct nicvf *nic)
        head = rbdr->head;
        while (head != rbdr->tail) {
                entry = rbdr->desc + head;
-               nicvf_rbdr_release_mbuf(nic, entry->full_addr);
+               nicvf_rbdr_release_mbuf(dev, nic, entry->full_addr);
                head++;
                head = head & qlen_mask;
        }
@@ -663,23 +678,29 @@ config_sq_error:
 }
 
 static inline int
-nicvf_stop_tx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+nicvf_vf_stop_tx_queue(struct rte_eth_dev *dev, struct nicvf *nic,
+                      uint16_t qidx)
 {
        struct nicvf_txq *txq;
        int ret;
 
-       if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+       assert(qidx < MAX_SND_QUEUES_PER_QS);
+
+       if (dev->data->tx_queue_state[nicvf_netdev_qidx(nic, qidx)] ==
+               RTE_ETH_QUEUE_STATE_STOPPED)
                return 0;
 
-       ret = nicvf_qset_sq_reclaim(nicvf_pmd_priv(dev), qidx);
+       ret = nicvf_qset_sq_reclaim(nic, qidx);
        if (ret)
-               PMD_INIT_LOG(ERR, "Failed to reclaim sq %d %d", qidx, ret);
+               PMD_INIT_LOG(ERR, "Failed to reclaim sq VF%d %d %d",
+                            nic->vf_id, qidx, ret);
 
-       txq = dev->data->tx_queues[qidx];
+       txq = dev->data->tx_queues[nicvf_netdev_qidx(nic, qidx)];
        nicvf_tx_queue_release_mbufs(txq);
        nicvf_tx_queue_reset(txq);
 
-       dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+       dev->data->tx_queue_state[nicvf_netdev_qidx(nic, qidx)] =
+               RTE_ETH_QUEUE_STATE_STOPPED;
        return ret;
 }
 
@@ -715,14 +736,13 @@ nicvf_configure_rss(struct rte_eth_dev *dev)
                        dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
        PMD_DRV_LOG(INFO, "mode=%d rx_queues=%d loopback=%d rsshf=0x%" PRIx64,
                    dev->data->dev_conf.rxmode.mq_mode,
-                   nic->eth_dev->data->nb_rx_queues,
-                   nic->eth_dev->data->dev_conf.lpbk_mode, rsshf);
+                   dev->data->nb_rx_queues,
+                   dev->data->dev_conf.lpbk_mode, rsshf);
 
        if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_NONE)
                ret = nicvf_rss_term(nic);
        else if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS)
-               ret = nicvf_rss_config(nic,
-                                      nic->eth_dev->data->nb_rx_queues, rsshf);
+               ret = nicvf_rss_config(nic, dev->data->nb_rx_queues, rsshf);
        if (ret)
                PMD_INIT_LOG(ERR, "Failed to configure RSS %d", ret);
 
@@ -906,7 +926,7 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
                return -ENOMEM;
        }
 
-       if (nicvf_qset_sq_alloc(nic, txq, qidx, nb_desc)) {
+       if (nicvf_qset_sq_alloc(dev, nic, txq, qidx, nb_desc)) {
                PMD_INIT_LOG(ERR, "Failed to allocate mem for sq %d", qidx);
                nicvf_dev_tx_queue_release(txq);
                return -ENOMEM;
@@ -923,12 +943,11 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 }
 
 static inline void
-nicvf_rx_queue_release_mbufs(struct nicvf_rxq *rxq)
+nicvf_rx_queue_release_mbufs(struct rte_eth_dev *dev, struct nicvf_rxq *rxq)
 {
        uint32_t rxq_cnt;
        uint32_t nb_pkts, released_pkts = 0;
        uint32_t refill_cnt = 0;
-       struct rte_eth_dev *dev = rxq->nic->eth_dev;
        struct rte_mbuf *rx_pkts[NICVF_MAX_RX_FREE_THRESH];
 
        if (dev->rx_pkt_burst == NULL)
@@ -993,30 +1012,34 @@ config_rq_error:
 }
 
 static inline int
-nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+nicvf_vf_stop_rx_queue(struct rte_eth_dev *dev, struct nicvf *nic,
+                      uint16_t qidx)
 {
-       struct nicvf *nic = nicvf_pmd_priv(dev);
        struct nicvf_rxq *rxq;
        int ret, other_error;
 
-       if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+       if (dev->data->rx_queue_state[nicvf_netdev_qidx(nic, qidx)] ==
+               RTE_ETH_QUEUE_STATE_STOPPED)
                return 0;
 
        ret = nicvf_qset_rq_reclaim(nic, qidx);
        if (ret)
-               PMD_INIT_LOG(ERR, "Failed to reclaim rq %d %d", qidx, ret);
+               PMD_INIT_LOG(ERR, "Failed to reclaim rq VF%d %d %d",
+                            nic->vf_id, qidx, ret);
 
        other_error = ret;
-       rxq = dev->data->rx_queues[qidx];
-       nicvf_rx_queue_release_mbufs(rxq);
+       rxq = dev->data->rx_queues[nicvf_netdev_qidx(nic, qidx)];
+       nicvf_rx_queue_release_mbufs(dev, rxq);
        nicvf_rx_queue_reset(rxq);
 
        ret = nicvf_qset_cq_reclaim(nic, qidx);
        if (ret)
-               PMD_INIT_LOG(ERR, "Failed to reclaim cq %d %d", qidx, ret);
+               PMD_INIT_LOG(ERR, "Failed to reclaim cq VF%d %d %d",
+                            nic->vf_id, qidx, ret);
 
        other_error |= ret;
-       dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+       dev->data->rx_queue_state[nicvf_netdev_qidx(nic, qidx)] =
+               RTE_ETH_QUEUE_STATE_STOPPED;
        return other_error;
 }
 
@@ -1048,8 +1071,14 @@ static int
 nicvf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
 {
        int ret;
+       struct nicvf *nic = nicvf_pmd_priv(dev);
 
-       ret = nicvf_stop_rx_queue(dev, qidx);
+       if (qidx >= MAX_SND_QUEUES_PER_QS)
+               nic = nic->snicvf[(qidx / MAX_SND_QUEUES_PER_QS - 1)];
+
+       qidx = qidx % MAX_RCV_QUEUES_PER_QS;
+
+       ret = nicvf_vf_stop_rx_queue(dev, nic, qidx);
        ret |= nicvf_configure_cpi(dev);
        ret |= nicvf_configure_rss_reta(dev);
        return ret;
@@ -1064,7 +1093,14 @@ nicvf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
 static int
 nicvf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
 {
-       return nicvf_stop_tx_queue(dev, qidx);
+       struct nicvf *nic = nicvf_pmd_priv(dev);
+
+       if (qidx >= MAX_SND_QUEUES_PER_QS)
+               nic = nic->snicvf[(qidx / MAX_SND_QUEUES_PER_QS - 1)];
+
+       qidx = qidx % MAX_SND_QUEUES_PER_QS;
+
+       return nicvf_vf_stop_tx_queue(dev, nic, qidx);
 }
 
 
@@ -1154,7 +1190,7 @@ nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 
 
        /* Alloc completion queue */
-       if (nicvf_qset_cq_alloc(nic, rxq, rxq->queue_id, nb_desc)) {
+       if (nicvf_qset_cq_alloc(dev, nic, rxq, rxq->queue_id, nb_desc)) {
                PMD_INIT_LOG(ERR, "failed to allocate cq %u", rxq->queue_id);
                nicvf_dev_rx_queue_release(rxq);
                return -ENOMEM;
@@ -1272,7 +1308,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
         */
 
        /* Validate RBDR buff size */
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
                rxq = dev->data->rx_queues[qidx];
                mbp_priv = rte_mempool_get_priv(rxq->pool);
                buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
@@ -1290,7 +1326,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
        }
 
        /* Validate mempool attributes */
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
                rxq = dev->data->rx_queues[qidx];
                rxq->mbuf_phys_off = nicvf_mempool_phy_offset(rxq->pool);
                mbuf = rte_pktmbuf_alloc(rxq->pool);
@@ -1314,12 +1350,12 @@ nicvf_dev_start(struct rte_eth_dev *dev)
 
        /* Check the level of buffers in the pool */
        total_rxq_desc = 0;
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
                rxq = dev->data->rx_queues[qidx];
                /* Count total numbers of rxq descs */
                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;
+               exp_buffs *= dev->data->nb_rx_queues;
                if (rte_mempool_avail_count(rxq->pool) < exp_buffs) {
                        PMD_INIT_LOG(ERR, "Buff shortage in pool=%s (%d/%d)",
                                     rxq->pool->name,
@@ -1345,7 +1381,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
 
        /* Allocate RBDR and RBDR ring desc */
        nb_rbdr_desc = nicvf_qsize_rbdr_roundup(total_rxq_desc);
-       ret = nicvf_qset_rbdr_alloc(nic, nb_rbdr_desc, rbdrsz);
+       ret = nicvf_qset_rbdr_alloc(dev, nic, nb_rbdr_desc, rbdrsz);
        if (ret) {
                PMD_INIT_LOG(ERR, "Failed to allocate memory for rbdr alloc");
                goto qset_reclaim;
@@ -1370,7 +1406,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
                     nic->rbdr->tail, nb_rbdr_desc);
 
        /* Configure RX queues */
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
                ret = nicvf_start_rx_queue(dev, qidx);
                if (ret)
                        goto start_rxq_error;
@@ -1380,7 +1416,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
        nicvf_vlan_hw_strip(nic, dev->data->dev_conf.rxmode.hw_vlan_strip);
 
        /* Configure TX queues */
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_tx_queues; qidx++) {
+       for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++) {
                ret = nicvf_start_tx_queue(dev, qidx);
                if (ret)
                        goto start_txq_error;
@@ -1439,14 +1475,14 @@ nicvf_dev_start(struct rte_eth_dev *dev)
 qset_rss_error:
        nicvf_rss_term(nic);
 start_txq_error:
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_tx_queues; qidx++)
-               nicvf_stop_tx_queue(dev, qidx);
+       for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++)
+               nicvf_vf_stop_tx_queue(dev, nic, qidx);
 start_rxq_error:
-       for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++)
-               nicvf_stop_rx_queue(dev, qidx);
+       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++)
+               nicvf_vf_stop_rx_queue(dev, nic, qidx);
 qset_rbdr_reclaim:
        nicvf_qset_rbdr_reclaim(nic, 0);
-       nicvf_rbdr_release_mbufs(nic);
+       nicvf_rbdr_release_mbufs(dev, nic);
 qset_rbdr_free:
        if (nic->rbdr) {
                rte_free(nic->rbdr);
@@ -1458,32 +1494,74 @@ qset_reclaim:
 }
 
 static void
-nicvf_dev_stop(struct rte_eth_dev *dev)
+nicvf_dev_stop_cleanup(struct rte_eth_dev *dev, bool cleanup)
 {
+       size_t i;
        int ret;
-       uint16_t qidx;
        struct nicvf *nic = nicvf_pmd_priv(dev);
 
        PMD_INIT_FUNC_TRACE();
 
-       /* Let PF make the BGX's RX and TX switches to OFF position */
-       nicvf_mbox_shutdown(nic);
+       /* Teardown secondary vf first */
+       for (i = 0; i < nic->sqs_count; i++) {
+               if (!nic->snicvf[i])
+                       continue;
+
+               nicvf_vf_stop(dev, nic->snicvf[i], cleanup);
+       }
+
+       /* Stop the primary VF now */
+       nicvf_vf_stop(dev, nic, cleanup);
 
        /* Disable loopback */
        ret = nicvf_loopback_config(nic, 0);
        if (ret)
                PMD_INIT_LOG(ERR, "Failed to disable loopback %d", ret);
 
+       /* Reclaim CPI configuration */
+       ret = nicvf_mbox_config_cpi(nic, 0);
+       if (ret)
+               PMD_INIT_LOG(ERR, "Failed to reclaim CPI config %d", ret);
+}
+
+static void
+nicvf_dev_stop(struct rte_eth_dev *dev)
+{
+       PMD_INIT_FUNC_TRACE();
+
+       nicvf_dev_stop_cleanup(dev, false);
+}
+
+static void
+nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, bool cleanup)
+{
+       int ret;
+       uint16_t qidx;
+       uint16_t tx_start, tx_end;
+       uint16_t rx_start, rx_end;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (cleanup) {
+               /* Let PF make the BGX's RX and TX switches to OFF position */
+               nicvf_mbox_shutdown(nic);
+       }
+
        /* Disable VLAN Strip */
        nicvf_vlan_hw_strip(nic, 0);
 
-       /* Reclaim sq */
-       for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++)
-               nicvf_stop_tx_queue(dev, qidx);
+       /* Get queue ranges for this VF */
+       nicvf_tx_range(dev, nic, &tx_start, &tx_end);
+
+       for (qidx = tx_start; qidx <= tx_end; qidx++)
+               nicvf_vf_stop_tx_queue(dev, nic, qidx % MAX_SND_QUEUES_PER_QS);
+
+       /* Get queue ranges for this VF */
+       nicvf_rx_range(dev, nic, &rx_start, &rx_end);
 
        /* Reclaim rq */
-       for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++)
-               nicvf_stop_rx_queue(dev, qidx);
+       for (qidx = rx_start; qidx <= rx_end; qidx++)
+               nicvf_vf_stop_rx_queue(dev, nic, qidx % MAX_RCV_QUEUES_PER_QS);
 
        /* Reclaim RBDR */
        ret = nicvf_qset_rbdr_reclaim(nic, 0);
@@ -1492,17 +1570,10 @@ nicvf_dev_stop(struct rte_eth_dev *dev)
 
        /* Move all charged buffers in RBDR back to pool */
        if (nic->rbdr != NULL)
-               nicvf_rbdr_release_mbufs(nic);
-
-       /* Reclaim CPI configuration */
-       if (!nic->sqs_mode) {
-               ret = nicvf_mbox_config_cpi(nic, 0);
-               if (ret)
-                       PMD_INIT_LOG(ERR, "Failed to reclaim CPI config");
-       }
+               nicvf_rbdr_release_mbufs(dev, nic);
 
        /* Disable qset */
-       ret = nicvf_qset_config(nic);
+       ret = nicvf_qset_reclaim(nic);
        if (ret)
                PMD_INIT_LOG(ERR, "Failed to disable qset %d", ret);
 
@@ -1519,12 +1590,20 @@ nicvf_dev_stop(struct rte_eth_dev *dev)
 static void
 nicvf_dev_close(struct rte_eth_dev *dev)
 {
+       size_t i;
        struct nicvf *nic = nicvf_pmd_priv(dev);
 
        PMD_INIT_FUNC_TRACE();
 
-       nicvf_dev_stop(dev);
-       nicvf_periodic_alarm_stop(nic);
+       nicvf_dev_stop_cleanup(dev, true);
+       nicvf_periodic_alarm_stop(nicvf_interrupt, dev);
+
+       for (i = 0; i < nic->sqs_count; i++) {
+               if (!nic->snicvf[i])
+                       continue;
+
+               nicvf_periodic_alarm_stop(nicvf_vf_interrupt, nic->snicvf[i]);
+       }
 }
 
 static int
@@ -1659,7 +1738,6 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
        nic->vendor_id = pci_dev->id.vendor_id;
        nic->subsystem_device_id = pci_dev->id.subsystem_device_id;
        nic->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
-       nic->eth_dev = eth_dev;
 
        PMD_INIT_LOG(DEBUG, "nicvf: device (%x:%x) %u:%u:%u:%u",
                        pci_dev->id.vendor_id, pci_dev->id.device_id,
@@ -1675,7 +1753,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
 
        nicvf_disable_all_interrupts(nic);
 
-       ret = nicvf_periodic_alarm_start(nic);
+       ret = nicvf_periodic_alarm_start(nicvf_interrupt, eth_dev);
        if (ret) {
                PMD_INIT_LOG(ERR, "Failed to start period alarm");
                goto fail;
@@ -1736,7 +1814,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
 malloc_fail:
        rte_free(eth_dev->data->mac_addrs);
 alarm_fail:
-       nicvf_periodic_alarm_stop(nic);
+       nicvf_periodic_alarm_stop(nicvf_interrupt, eth_dev);
 fail:
        return ret;
 }