net: add rte prefix to ether structures
[dpdk.git] / drivers / net / avp / avp_ethdev.c
index b3daa15..69a70d2 100644 (file)
@@ -1,33 +1,5 @@
-/*
- *   BSD LICENSE
- *
- * Copyright (c) 2013-2017, Wind River Systems, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1) Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2) Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * 3) Neither the name of Wind River Systems nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2013-2017 Wind River Systems, Inc.
  */
 
 #include <stdint.h>
 #include <errno.h>
 #include <unistd.h>
 
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
+#include <rte_ethdev_pci.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
-#include <rte_memzone.h>
 #include <rte_malloc.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
 #include <rte_ether.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
+#include <rte_spinlock.h>
 #include <rte_byteorder.h>
 #include <rte_dev.h>
 #include <rte_memory.h>
 
 #include "avp_logs.h"
 
+int avp_logtype_driver;
 
+static int avp_dev_create(struct rte_pci_device *pci_dev,
+                         struct rte_eth_dev *eth_dev);
 
 static int avp_dev_configure(struct rte_eth_dev *dev);
+static int avp_dev_start(struct rte_eth_dev *dev);
+static void avp_dev_stop(struct rte_eth_dev *dev);
+static void avp_dev_close(struct rte_eth_dev *dev);
 static void avp_dev_info_get(struct rte_eth_dev *dev,
                             struct rte_eth_dev_info *dev_info);
-static void avp_vlan_offload_set(struct rte_eth_dev *dev, int mask);
-static int avp_dev_link_update(struct rte_eth_dev *dev,
-                              __rte_unused int wait_to_complete);
+static int avp_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+static int avp_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete);
+static void avp_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static void avp_dev_promiscuous_disable(struct rte_eth_dev *dev);
+
 static int avp_dev_rx_queue_setup(struct rte_eth_dev *dev,
                                  uint16_t rx_queue_id,
                                  uint16_t nb_rx_desc,
@@ -86,12 +68,25 @@ static uint16_t avp_recv_scattered_pkts(void *rx_queue,
 static uint16_t avp_recv_pkts(void *rx_queue,
                              struct rte_mbuf **rx_pkts,
                              uint16_t nb_pkts);
+
+static uint16_t avp_xmit_scattered_pkts(void *tx_queue,
+                                       struct rte_mbuf **tx_pkts,
+                                       uint16_t nb_pkts);
+
+static uint16_t avp_xmit_pkts(void *tx_queue,
+                             struct rte_mbuf **tx_pkts,
+                             uint16_t nb_pkts);
+
 static void avp_dev_rx_queue_release(void *rxq);
 static void avp_dev_tx_queue_release(void *txq);
-#define AVP_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device)
+
+static int avp_dev_stats_get(struct rte_eth_dev *dev,
+                             struct rte_eth_stats *stats);
+static void avp_dev_stats_reset(struct rte_eth_dev *dev);
 
 
 #define AVP_MAX_RX_BURST 64
+#define AVP_MAX_TX_BURST 64
 #define AVP_MAX_MAC_ADDRS 1
 #define AVP_MIN_RX_BUFSIZE ETHER_MIN_LEN
 
@@ -131,9 +126,16 @@ static const struct rte_pci_id pci_id_avp_map[] = {
  */
 static const struct eth_dev_ops avp_eth_dev_ops = {
        .dev_configure       = avp_dev_configure,
+       .dev_start           = avp_dev_start,
+       .dev_stop            = avp_dev_stop,
+       .dev_close           = avp_dev_close,
        .dev_infos_get       = avp_dev_info_get,
        .vlan_offload_set    = avp_vlan_offload_set,
+       .stats_get           = avp_dev_stats_get,
+       .stats_reset         = avp_dev_stats_reset,
        .link_update         = avp_dev_link_update,
+       .promiscuous_enable  = avp_dev_promiscuous_enable,
+       .promiscuous_disable = avp_dev_promiscuous_disable,
        .rx_queue_setup      = avp_dev_rx_queue_setup,
        .rx_queue_release    = avp_dev_rx_queue_release,
        .tx_queue_setup      = avp_dev_tx_queue_setup,
@@ -144,6 +146,7 @@ static const struct eth_dev_ops avp_eth_dev_ops = {
 #define AVP_F_PROMISC (1 << 1)
 #define AVP_F_CONFIGURED (1 << 2)
 #define AVP_F_LINKUP (1 << 3)
+#define AVP_F_DETACHED (1 << 4)
 /**@} */
 
 /* Ethernet device validation marker */
@@ -156,11 +159,11 @@ static const struct eth_dev_ops avp_eth_dev_ops = {
 struct avp_dev {
        uint32_t magic; /**< Memory validation marker */
        uint64_t device_id; /**< Unique system identifier */
-       struct ether_addr ethaddr; /**< Host specified MAC address */
+       struct rte_ether_addr ethaddr; /**< Host specified MAC address */
        struct rte_eth_dev_data *dev_data;
        /**< Back pointer to ethernet device data */
        volatile uint32_t flags; /**< Device operational flags */
-       uint8_t port_id; /**< Ethernet port identifier */
+       uint16_t port_id; /**< Ethernet port identifier */
        struct rte_mempool *pool; /**< pkt mbuf mempool */
        unsigned int guest_mbuf_size; /**< local pool mbuf size */
        unsigned int host_mbuf_size; /**< host mbuf size */
@@ -179,6 +182,9 @@ struct avp_dev {
        struct rte_avp_fifo *free_q[RTE_AVP_MAX_QUEUES];
        /**< To be freed mbufs queue */
 
+       /* mutual exclusion over the 'flag' and 'resp_q/req_q' fields */
+       rte_spinlock_t lock;
+
        /* For request & response */
        struct rte_avp_fifo *req_q; /**< Request queue */
        struct rte_avp_fifo *resp_q; /**< Response queue */
@@ -291,6 +297,23 @@ done:
        return ret;
 }
 
+static int
+avp_dev_ctrl_set_link_state(struct rte_eth_dev *eth_dev, unsigned int state)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       struct rte_avp_request request;
+       int ret;
+
+       /* setup a link state change request */
+       memset(&request, 0, sizeof(request));
+       request.req_id = RTE_AVP_REQ_CFG_NETWORK_IF;
+       request.if_up = state;
+
+       ret = avp_dev_process_request(avp, &request);
+
+       return ret == 0 ? request.result : ret;
+}
+
 static int
 avp_dev_ctrl_set_config(struct rte_eth_dev *eth_dev,
                        struct rte_avp_device_config *config)
@@ -309,6 +332,22 @@ avp_dev_ctrl_set_config(struct rte_eth_dev *eth_dev,
        return ret == 0 ? request.result : ret;
 }
 
+static int
+avp_dev_ctrl_shutdown(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       struct rte_avp_request request;
+       int ret;
+
+       /* setup a shutdown request */
+       memset(&request, 0, sizeof(request));
+       request.req_id = RTE_AVP_REQ_SHUTDOWN_DEVICE;
+
+       ret = avp_dev_process_request(avp, &request);
+
+       return ret == 0 ? request.result : ret;
+}
+
 /* translate from host mbuf virtual address to guest virtual address */
 static inline void *
 avp_dev_translate_buffer(struct avp_dev *avp, void *host_mbuf_address)
@@ -321,9 +360,9 @@ avp_dev_translate_buffer(struct avp_dev *avp, void *host_mbuf_address)
 /* translate from host physical address to guest virtual address */
 static void *
 avp_dev_translate_address(struct rte_eth_dev *eth_dev,
-                         phys_addr_t host_phys_addr)
+                         rte_iova_t host_phys_addr)
 {
-       struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        struct rte_mem_resource *resource;
        struct rte_avp_memmap_info *info;
        struct rte_avp_memmap *map;
@@ -344,7 +383,7 @@ avp_dev_translate_address(struct rte_eth_dev *eth_dev,
                        (host_phys_addr < (map->phys_addr + map->length))) {
                        /* address is within this segment */
                        offset += (host_phys_addr - map->phys_addr);
-                       addr = RTE_PTR_ADD(addr, offset);
+                       addr = RTE_PTR_ADD(addr, (uintptr_t)offset);
 
                        PMD_DRV_LOG(DEBUG, "Translating host physical 0x%" PRIx64 " to guest virtual 0x%p\n",
                                    host_phys_addr, addr);
@@ -376,7 +415,7 @@ avp_dev_version_check(uint32_t version)
 static int
 avp_dev_check_regions(struct rte_eth_dev *eth_dev)
 {
-       struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        struct rte_avp_memmap_info *memmap;
        struct rte_avp_device_info *info;
        struct rte_mem_resource *resource;
@@ -433,6 +472,46 @@ avp_dev_check_regions(struct rte_eth_dev *eth_dev)
        return 0;
 }
 
+static int
+avp_dev_detach(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       int ret;
+
+       PMD_DRV_LOG(NOTICE, "Detaching port %u from AVP device 0x%" PRIx64 "\n",
+                   eth_dev->data->port_id, avp->device_id);
+
+       rte_spinlock_lock(&avp->lock);
+
+       if (avp->flags & AVP_F_DETACHED) {
+               PMD_DRV_LOG(NOTICE, "port %u already detached\n",
+                           eth_dev->data->port_id);
+               ret = 0;
+               goto unlock;
+       }
+
+       /* shutdown the device first so the host stops sending us packets. */
+       ret = avp_dev_ctrl_shutdown(eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to send/recv shutdown to host, ret=%d\n",
+                           ret);
+               avp->flags &= ~AVP_F_DETACHED;
+               goto unlock;
+       }
+
+       avp->flags |= AVP_F_DETACHED;
+       rte_wmb();
+
+       /* wait for queues to acknowledge the presence of the detach flag */
+       rte_delay_ms(1);
+
+       ret = 0;
+
+unlock:
+       rte_spinlock_unlock(&avp->lock);
+       return ret;
+}
+
 static void
 _avp_set_rx_queue_mappings(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id)
 {
@@ -472,7 +551,7 @@ _avp_set_rx_queue_mappings(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id)
 static void
 _avp_set_queue_counts(struct rte_eth_dev *eth_dev)
 {
-       struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
        struct rte_avp_device_info *host_info;
        void *addr;
@@ -501,6 +580,239 @@ _avp_set_queue_counts(struct rte_eth_dev *eth_dev)
                    avp->num_tx_queues, avp->num_rx_queues);
 }
 
+static int
+avp_dev_attach(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       struct rte_avp_device_config config;
+       unsigned int i;
+       int ret;
+
+       PMD_DRV_LOG(NOTICE, "Attaching port %u to AVP device 0x%" PRIx64 "\n",
+                   eth_dev->data->port_id, avp->device_id);
+
+       rte_spinlock_lock(&avp->lock);
+
+       if (!(avp->flags & AVP_F_DETACHED)) {
+               PMD_DRV_LOG(NOTICE, "port %u already attached\n",
+                           eth_dev->data->port_id);
+               ret = 0;
+               goto unlock;
+       }
+
+       /*
+        * make sure that the detached flag is set prior to reconfiguring the
+        * queues.
+        */
+       avp->flags |= AVP_F_DETACHED;
+       rte_wmb();
+
+       /*
+        * re-run the device create utility which will parse the new host info
+        * and setup the AVP device queue pointers.
+        */
+       ret = avp_dev_create(RTE_ETH_DEV_TO_PCI(eth_dev), eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to re-create AVP device, ret=%d\n",
+                           ret);
+               goto unlock;
+       }
+
+       if (avp->flags & AVP_F_CONFIGURED) {
+               /*
+                * Update the receive queue mapping to handle cases where the
+                * source and destination hosts have different queue
+                * requirements.  As long as the DETACHED flag is asserted the
+                * queue table should not be referenced so it should be safe to
+                * update it.
+                */
+               _avp_set_queue_counts(eth_dev);
+               for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+                       _avp_set_rx_queue_mappings(eth_dev, i);
+
+               /*
+                * Update the host with our config details so that it knows the
+                * device is active.
+                */
+               memset(&config, 0, sizeof(config));
+               config.device_id = avp->device_id;
+               config.driver_type = RTE_AVP_DRIVER_TYPE_DPDK;
+               config.driver_version = AVP_DPDK_DRIVER_VERSION;
+               config.features = avp->features;
+               config.num_tx_queues = avp->num_tx_queues;
+               config.num_rx_queues = avp->num_rx_queues;
+               config.if_up = !!(avp->flags & AVP_F_LINKUP);
+
+               ret = avp_dev_ctrl_set_config(eth_dev, &config);
+               if (ret < 0) {
+                       PMD_DRV_LOG(ERR, "Config request failed by host, ret=%d\n",
+                                   ret);
+                       goto unlock;
+               }
+       }
+
+       rte_wmb();
+       avp->flags &= ~AVP_F_DETACHED;
+
+       ret = 0;
+
+unlock:
+       rte_spinlock_unlock(&avp->lock);
+       return ret;
+}
+
+static void
+avp_dev_interrupt_handler(void *data)
+{
+       struct rte_eth_dev *eth_dev = data;
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+       void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr;
+       uint32_t status, value;
+       int ret;
+
+       if (registers == NULL)
+               rte_panic("no mapped MMIO register space\n");
+
+       /* read the interrupt status register
+        * note: this register clears on read so all raised interrupts must be
+        *    handled or remembered for later processing
+        */
+       status = AVP_READ32(
+               RTE_PTR_ADD(registers,
+                           RTE_AVP_INTERRUPT_STATUS_OFFSET));
+
+       if (status & RTE_AVP_MIGRATION_INTERRUPT_MASK) {
+               /* handle interrupt based on current status */
+               value = AVP_READ32(
+                       RTE_PTR_ADD(registers,
+                                   RTE_AVP_MIGRATION_STATUS_OFFSET));
+               switch (value) {
+               case RTE_AVP_MIGRATION_DETACHED:
+                       ret = avp_dev_detach(eth_dev);
+                       break;
+               case RTE_AVP_MIGRATION_ATTACHED:
+                       ret = avp_dev_attach(eth_dev);
+                       break;
+               default:
+                       PMD_DRV_LOG(ERR, "unexpected migration status, status=%u\n",
+                                   value);
+                       ret = -EINVAL;
+               }
+
+               /* acknowledge the request by writing out our current status */
+               value = (ret == 0 ? value : RTE_AVP_MIGRATION_ERROR);
+               AVP_WRITE32(value,
+                           RTE_PTR_ADD(registers,
+                                       RTE_AVP_MIGRATION_ACK_OFFSET));
+
+               PMD_DRV_LOG(NOTICE, "AVP migration interrupt handled\n");
+       }
+
+       if (status & ~RTE_AVP_MIGRATION_INTERRUPT_MASK)
+               PMD_DRV_LOG(WARNING, "AVP unexpected interrupt, status=0x%08x\n",
+                           status);
+
+       /* re-enable UIO interrupt handling */
+       ret = rte_intr_enable(&pci_dev->intr_handle);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to re-enable UIO interrupts, ret=%d\n",
+                           ret);
+               /* continue */
+       }
+}
+
+static int
+avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev)
+{
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+       void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr;
+       int ret;
+
+       if (registers == NULL)
+               return -EINVAL;
+
+       /* enable UIO interrupt handling */
+       ret = rte_intr_enable(&pci_dev->intr_handle);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to enable UIO interrupts, ret=%d\n",
+                           ret);
+               return ret;
+       }
+
+       /* inform the device that all interrupts are enabled */
+       AVP_WRITE32(RTE_AVP_APP_INTERRUPTS_MASK,
+                   RTE_PTR_ADD(registers, RTE_AVP_INTERRUPT_MASK_OFFSET));
+
+       return 0;
+}
+
+static int
+avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev)
+{
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+       void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr;
+       int ret;
+
+       if (registers == NULL)
+               return 0;
+
+       /* inform the device that all interrupts are disabled */
+       AVP_WRITE32(RTE_AVP_NO_INTERRUPTS_MASK,
+                   RTE_PTR_ADD(registers, RTE_AVP_INTERRUPT_MASK_OFFSET));
+
+       /* enable UIO interrupt handling */
+       ret = rte_intr_disable(&pci_dev->intr_handle);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to disable UIO interrupts, ret=%d\n",
+                           ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+static int
+avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev)
+{
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+       int ret;
+
+       /* register a callback handler with UIO for interrupt notifications */
+       ret = rte_intr_callback_register(&pci_dev->intr_handle,
+                                        avp_dev_interrupt_handler,
+                                        (void *)eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to register UIO interrupt callback, ret=%d\n",
+                           ret);
+               return ret;
+       }
+
+       /* enable interrupt processing */
+       return avp_dev_enable_interrupts(eth_dev);
+}
+
+static int
+avp_dev_migration_pending(struct rte_eth_dev *eth_dev)
+{
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+       void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr;
+       uint32_t value;
+
+       if (registers == NULL)
+               return 0;
+
+       value = AVP_READ32(RTE_PTR_ADD(registers,
+                                      RTE_AVP_MIGRATION_STATUS_OFFSET));
+       if (value == RTE_AVP_MIGRATION_DETACHED) {
+               /* migration is in progress; ack it if we have not already */
+               AVP_WRITE32(value,
+                           RTE_PTR_ADD(registers,
+                                       RTE_AVP_MIGRATION_ACK_OFFSET));
+               return 1;
+       }
+       return 0;
+}
+
 /*
  * create a AVP device using the supplied device info by first translating it
  * to guest address space(s).
@@ -553,6 +865,7 @@ avp_dev_create(struct rte_pci_device *pci_dev,
                avp->port_id = eth_dev->data->port_id;
                avp->host_mbuf_size = host_info->mbuf_size;
                avp->host_features = host_info->features;
+               rte_spinlock_init(&avp->lock);
                memcpy(&avp->ethaddr.addr_bytes[0],
                       host_info->ethaddr, ETHER_ADDR_LEN);
                /* adjust max values to not exceed our max */
@@ -642,9 +955,10 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev)
        struct rte_pci_device *pci_dev;
        int ret;
 
-       pci_dev = AVP_DEV_TO_PCI(eth_dev);
+       pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        eth_dev->dev_ops = &avp_eth_dev_ops;
        eth_dev->rx_pkt_burst = &avp_recv_pkts;
+       eth_dev->tx_pkt_burst = &avp_xmit_pkts;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
                /*
@@ -656,13 +970,18 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev)
                if (eth_dev->data->scattered_rx) {
                        PMD_DRV_LOG(NOTICE, "AVP device configured for chained mbufs\n");
                        eth_dev->rx_pkt_burst = avp_recv_scattered_pkts;
+                       eth_dev->tx_pkt_burst = avp_xmit_scattered_pkts;
                }
                return 0;
        }
 
        rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
+       /* Check current migration status */
+       if (avp_dev_migration_pending(eth_dev)) {
+               PMD_DRV_LOG(ERR, "VM live migration operation in progress\n");
+               return -EBUSY;
+       }
 
        /* Check BAR resources */
        ret = avp_dev_check_regions(eth_dev);
@@ -672,6 +991,13 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev)
                return ret;
        }
 
+       /* Enable interrupts */
+       ret = avp_dev_setup_interrupts(eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to enable interrupts, ret=%d\n", ret);
+               return ret;
+       }
+
        /* Handle each subtype */
        ret = avp_dev_create(pci_dev, eth_dev);
        if (ret < 0) {
@@ -696,31 +1022,43 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev)
 static int
 eth_avp_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+       int ret;
+
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return -EPERM;
 
        if (eth_dev->data == NULL)
                return 0;
 
-       if (eth_dev->data->mac_addrs != NULL) {
-               rte_free(eth_dev->data->mac_addrs);
-               eth_dev->data->mac_addrs = NULL;
+       ret = avp_dev_disable_interrupts(eth_dev);
+       if (ret != 0) {
+               PMD_DRV_LOG(ERR, "Failed to disable interrupts, ret=%d\n", ret);
+               return ret;
        }
 
        return 0;
 }
 
+static int
+eth_avp_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 avp_adapter),
+                       eth_avp_dev_init);
+}
 
-static struct eth_driver rte_avp_pmd = {
-       {
-               .id_table = pci_id_avp_map,
-               .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
-               .probe = rte_eth_dev_pci_probe,
-               .remove = rte_eth_dev_pci_remove,
-       },
-       .eth_dev_init = eth_avp_dev_init,
-       .eth_dev_uninit = eth_avp_dev_uninit,
-       .dev_private_size = sizeof(struct avp_adapter),
+static int
+eth_avp_pci_remove(struct rte_pci_device *pci_dev)
+{
+       return rte_eth_dev_pci_generic_remove(pci_dev,
+                                             eth_avp_dev_uninit);
+}
+
+static struct rte_pci_driver rte_avp_pmd = {
+       .id_table = pci_id_avp_map,
+       .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+       .probe = eth_avp_pci_probe,
+       .remove = eth_avp_pci_remove,
 };
 
 static int
@@ -786,6 +1124,7 @@ avp_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
                        PMD_DRV_LOG(NOTICE, "AVP device configured for chained mbufs\n");
                        eth_dev->data->scattered_rx = 1;
                        eth_dev->rx_pkt_burst = avp_recv_scattered_pkts;
+                       eth_dev->tx_pkt_burst = avp_xmit_scattered_pkts;
                }
        }
 
@@ -860,7 +1199,7 @@ avp_dev_tx_queue_setup(struct rte_eth_dev *eth_dev,
 }
 
 static inline int
-_avp_cmp_ether_addr(struct ether_addr *a, struct ether_addr *b)
+_avp_cmp_ether_addr(struct rte_ether_addr *a, struct rte_ether_addr *b)
 {
        uint16_t *_a = (uint16_t *)&a->addr_bytes[0];
        uint16_t *_b = (uint16_t *)&b->addr_bytes[0];
@@ -870,7 +1209,7 @@ _avp_cmp_ether_addr(struct ether_addr *a, struct ether_addr *b)
 static inline int
 _avp_mac_filter(struct avp_dev *avp, struct rte_mbuf *m)
 {
-       struct ether_hdr *eth = rte_pktmbuf_mtod(m, struct ether_hdr *);
+       struct rte_ether_hdr *eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
 
        if (likely(_avp_cmp_ether_addr(&avp->ethaddr, &eth->d_addr) == 0)) {
                /* allow all packets destined to our address */
@@ -977,7 +1316,7 @@ avp_dev_copy_from_buffers(struct avp_dev *avp,
        src_offset = 0;
 
        if (pkt_buf->ol_flags & RTE_AVP_RX_VLAN_PKT) {
-               ol_flags = PKT_RX_VLAN_PKT;
+               ol_flags = PKT_RX_VLAN;
                vlan_tci = pkt_buf->vlan_tci;
        } else {
                ol_flags = 0;
@@ -1062,6 +1401,11 @@ avp_recv_scattered_pkts(void *rx_queue,
        unsigned int port_id;
        unsigned int i;
 
+       if (unlikely(avp->flags & AVP_F_DETACHED)) {
+               /* VM live migration in progress */
+               return 0;
+       }
+
        guest_mbuf_size = avp->guest_mbuf_size;
        port_id = avp->port_id;
        rx_q = avp->rx_q[rxq->queue_id];
@@ -1156,6 +1500,11 @@ avp_recv_pkts(void *rx_queue,
        char *pkt_data;
        unsigned int i;
 
+       if (unlikely(avp->flags & AVP_F_DETACHED)) {
+               /* VM live migration in progress */
+               return 0;
+       }
+
        rx_q = avp->rx_q[rxq->queue_id];
        free_q = avp->free_q[rxq->queue_id];
 
@@ -1225,7 +1574,7 @@ avp_recv_pkts(void *rx_queue,
                m->port = avp->port_id;
 
                if (pkt_buf->ol_flags & RTE_AVP_RX_VLAN_PKT) {
-                       m->ol_flags = PKT_RX_VLAN_PKT;
+                       m->ol_flags = PKT_RX_VLAN;
                        m->vlan_tci = pkt_buf->vlan_tci;
                }
 
@@ -1248,6 +1597,340 @@ avp_recv_pkts(void *rx_queue,
        return count;
 }
 
+/*
+ * Copy a chained mbuf to a set of host buffers.  This function assumes that
+ * there are sufficient destination buffers to contain the entire source
+ * packet.
+ */
+static inline uint16_t
+avp_dev_copy_to_buffers(struct avp_dev *avp,
+                       struct rte_mbuf *mbuf,
+                       struct rte_avp_desc **buffers,
+                       unsigned int count)
+{
+       struct rte_avp_desc *previous_buf = NULL;
+       struct rte_avp_desc *first_buf = NULL;
+       struct rte_avp_desc *pkt_buf;
+       struct rte_avp_desc *buf;
+       size_t total_length;
+       struct rte_mbuf *m;
+       size_t copy_length;
+       size_t src_offset;
+       char *pkt_data;
+       unsigned int i;
+
+       __rte_mbuf_sanity_check(mbuf, 1);
+
+       m = mbuf;
+       src_offset = 0;
+       total_length = rte_pktmbuf_pkt_len(m);
+       for (i = 0; (i < count) && (m != NULL); i++) {
+               /* fill each destination buffer */
+               buf = buffers[i];
+
+               if (i < count - 1) {
+                       /* prefetch next entry while processing this one */
+                       pkt_buf = avp_dev_translate_buffer(avp, buffers[i + 1]);
+                       rte_prefetch0(pkt_buf);
+               }
+
+               /* Adjust pointers for guest addressing */
+               pkt_buf = avp_dev_translate_buffer(avp, buf);
+               pkt_data = avp_dev_translate_buffer(avp, pkt_buf->data);
+
+               /* setup the buffer chain */
+               if (previous_buf != NULL)
+                       previous_buf->next = buf;
+               else
+                       first_buf = pkt_buf;
+
+               previous_buf = pkt_buf;
+
+               do {
+                       /*
+                        * copy as many source mbuf segments as will fit in the
+                        * destination buffer.
+                        */
+                       copy_length = RTE_MIN((avp->host_mbuf_size -
+                                              pkt_buf->data_len),
+                                             (rte_pktmbuf_data_len(m) -
+                                              src_offset));
+                       rte_memcpy(RTE_PTR_ADD(pkt_data, pkt_buf->data_len),
+                                  RTE_PTR_ADD(rte_pktmbuf_mtod(m, void *),
+                                              src_offset),
+                                  copy_length);
+                       pkt_buf->data_len += copy_length;
+                       src_offset += copy_length;
+
+                       if (likely(src_offset == rte_pktmbuf_data_len(m))) {
+                               /* need a new source buffer */
+                               m = m->next;
+                               src_offset = 0;
+                       }
+
+                       if (unlikely(pkt_buf->data_len ==
+                                    avp->host_mbuf_size)) {
+                               /* need a new destination buffer */
+                               break;
+                       }
+
+               } while (m != NULL);
+       }
+
+       first_buf->nb_segs = count;
+       first_buf->pkt_len = total_length;
+
+       if (mbuf->ol_flags & PKT_TX_VLAN_PKT) {
+               first_buf->ol_flags |= RTE_AVP_TX_VLAN_PKT;
+               first_buf->vlan_tci = mbuf->vlan_tci;
+       }
+
+       avp_dev_buffer_sanity_check(avp, buffers[0]);
+
+       return total_length;
+}
+
+
+static uint16_t
+avp_xmit_scattered_pkts(void *tx_queue,
+                       struct rte_mbuf **tx_pkts,
+                       uint16_t nb_pkts)
+{
+       struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
+                                      RTE_AVP_MAX_MBUF_SEGMENTS)];
+       struct avp_queue *txq = (struct avp_queue *)tx_queue;
+       struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];
+       struct avp_dev *avp = txq->avp;
+       struct rte_avp_fifo *alloc_q;
+       struct rte_avp_fifo *tx_q;
+       unsigned int count, avail, n;
+       unsigned int orig_nb_pkts;
+       struct rte_mbuf *m;
+       unsigned int required;
+       unsigned int segments;
+       unsigned int tx_bytes;
+       unsigned int i;
+
+       orig_nb_pkts = nb_pkts;
+       if (unlikely(avp->flags & AVP_F_DETACHED)) {
+               /* VM live migration in progress */
+               /* TODO ... buffer for X packets then drop? */
+               txq->errors += nb_pkts;
+               return 0;
+       }
+
+       tx_q = avp->tx_q[txq->queue_id];
+       alloc_q = avp->alloc_q[txq->queue_id];
+
+       /* limit the number of transmitted packets to the max burst size */
+       if (unlikely(nb_pkts > AVP_MAX_TX_BURST))
+               nb_pkts = AVP_MAX_TX_BURST;
+
+       /* determine how many buffers are available to copy into */
+       avail = avp_fifo_count(alloc_q);
+       if (unlikely(avail > (AVP_MAX_TX_BURST *
+                             RTE_AVP_MAX_MBUF_SEGMENTS)))
+               avail = AVP_MAX_TX_BURST * RTE_AVP_MAX_MBUF_SEGMENTS;
+
+       /* determine how many slots are available in the transmit queue */
+       count = avp_fifo_free_count(tx_q);
+
+       /* determine how many packets can be sent */
+       nb_pkts = RTE_MIN(count, nb_pkts);
+
+       /* determine how many packets will fit in the available buffers */
+       count = 0;
+       segments = 0;
+       for (i = 0; i < nb_pkts; i++) {
+               m = tx_pkts[i];
+               if (likely(i < (unsigned int)nb_pkts - 1)) {
+                       /* prefetch next entry while processing this one */
+                       rte_prefetch0(tx_pkts[i + 1]);
+               }
+               required = (rte_pktmbuf_pkt_len(m) + avp->host_mbuf_size - 1) /
+                       avp->host_mbuf_size;
+
+               if (unlikely((required == 0) ||
+                            (required > RTE_AVP_MAX_MBUF_SEGMENTS)))
+                       break;
+               else if (unlikely(required + segments > avail))
+                       break;
+               segments += required;
+               count++;
+       }
+       nb_pkts = count;
+
+       if (unlikely(nb_pkts == 0)) {
+               /* no available buffers, or no space on the tx queue */
+               txq->errors += orig_nb_pkts;
+               return 0;
+       }
+
+       PMD_TX_LOG(DEBUG, "Sending %u packets on Tx queue at %p\n",
+                  nb_pkts, tx_q);
+
+       /* retrieve sufficient send buffers */
+       n = avp_fifo_get(alloc_q, (void **)&avp_bufs, segments);
+       if (unlikely(n != segments)) {
+               PMD_TX_LOG(DEBUG, "Failed to allocate buffers "
+                          "n=%u, segments=%u, orig=%u\n",
+                          n, segments, orig_nb_pkts);
+               txq->errors += orig_nb_pkts;
+               return 0;
+       }
+
+       tx_bytes = 0;
+       count = 0;
+       for (i = 0; i < nb_pkts; i++) {
+               /* process each packet to be transmitted */
+               m = tx_pkts[i];
+
+               /* determine how many buffers are required for this packet */
+               required = (rte_pktmbuf_pkt_len(m) + avp->host_mbuf_size - 1) /
+                       avp->host_mbuf_size;
+
+               tx_bytes += avp_dev_copy_to_buffers(avp, m,
+                                                   &avp_bufs[count], required);
+               tx_bufs[i] = avp_bufs[count];
+               count += required;
+
+               /* free the original mbuf */
+               rte_pktmbuf_free(m);
+       }
+
+       txq->packets += nb_pkts;
+       txq->bytes += tx_bytes;
+
+#ifdef RTE_LIBRTE_AVP_DEBUG_BUFFERS
+       for (i = 0; i < nb_pkts; i++)
+               avp_dev_buffer_sanity_check(avp, tx_bufs[i]);
+#endif
+
+       /* send the packets */
+       n = avp_fifo_put(tx_q, (void **)&tx_bufs[0], nb_pkts);
+       if (unlikely(n != orig_nb_pkts))
+               txq->errors += (orig_nb_pkts - n);
+
+       return n;
+}
+
+
+static uint16_t
+avp_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+       struct avp_queue *txq = (struct avp_queue *)tx_queue;
+       struct rte_avp_desc *avp_bufs[AVP_MAX_TX_BURST];
+       struct avp_dev *avp = txq->avp;
+       struct rte_avp_desc *pkt_buf;
+       struct rte_avp_fifo *alloc_q;
+       struct rte_avp_fifo *tx_q;
+       unsigned int count, avail, n;
+       struct rte_mbuf *m;
+       unsigned int pkt_len;
+       unsigned int tx_bytes;
+       char *pkt_data;
+       unsigned int i;
+
+       if (unlikely(avp->flags & AVP_F_DETACHED)) {
+               /* VM live migration in progress */
+               /* TODO ... buffer for X packets then drop?! */
+               txq->errors++;
+               return 0;
+       }
+
+       tx_q = avp->tx_q[txq->queue_id];
+       alloc_q = avp->alloc_q[txq->queue_id];
+
+       /* limit the number of transmitted packets to the max burst size */
+       if (unlikely(nb_pkts > AVP_MAX_TX_BURST))
+               nb_pkts = AVP_MAX_TX_BURST;
+
+       /* determine how many buffers are available to copy into */
+       avail = avp_fifo_count(alloc_q);
+
+       /* determine how many slots are available in the transmit queue */
+       count = avp_fifo_free_count(tx_q);
+
+       /* determine how many packets can be sent */
+       count = RTE_MIN(count, avail);
+       count = RTE_MIN(count, nb_pkts);
+
+       if (unlikely(count == 0)) {
+               /* no available buffers, or no space on the tx queue */
+               txq->errors += nb_pkts;
+               return 0;
+       }
+
+       PMD_TX_LOG(DEBUG, "Sending %u packets on Tx queue at %p\n",
+                  count, tx_q);
+
+       /* retrieve sufficient send buffers */
+       n = avp_fifo_get(alloc_q, (void **)&avp_bufs, count);
+       if (unlikely(n != count)) {
+               txq->errors++;
+               return 0;
+       }
+
+       tx_bytes = 0;
+       for (i = 0; i < count; i++) {
+               /* prefetch next entry while processing the current one */
+               if (i < count - 1) {
+                       pkt_buf = avp_dev_translate_buffer(avp,
+                                                          avp_bufs[i + 1]);
+                       rte_prefetch0(pkt_buf);
+               }
+
+               /* process each packet to be transmitted */
+               m = tx_pkts[i];
+
+               /* Adjust pointers for guest addressing */
+               pkt_buf = avp_dev_translate_buffer(avp, avp_bufs[i]);
+               pkt_data = avp_dev_translate_buffer(avp, pkt_buf->data);
+               pkt_len = rte_pktmbuf_pkt_len(m);
+
+               if (unlikely((pkt_len > avp->guest_mbuf_size) ||
+                                        (pkt_len > avp->host_mbuf_size))) {
+                       /*
+                        * application should be using the scattered transmit
+                        * function; send it truncated to avoid the performance
+                        * hit of having to manage returning the already
+                        * allocated buffer to the free list.  This should not
+                        * happen since the application should have set the
+                        * max_rx_pkt_len based on its MTU and it should be
+                        * policing its own packet sizes.
+                        */
+                       txq->errors++;
+                       pkt_len = RTE_MIN(avp->guest_mbuf_size,
+                                         avp->host_mbuf_size);
+               }
+
+               /* copy data out of our mbuf and into the AVP buffer */
+               rte_memcpy(pkt_data, rte_pktmbuf_mtod(m, void *), pkt_len);
+               pkt_buf->pkt_len = pkt_len;
+               pkt_buf->data_len = pkt_len;
+               pkt_buf->nb_segs = 1;
+               pkt_buf->next = NULL;
+
+               if (m->ol_flags & PKT_TX_VLAN_PKT) {
+                       pkt_buf->ol_flags |= RTE_AVP_TX_VLAN_PKT;
+                       pkt_buf->vlan_tci = m->vlan_tci;
+               }
+
+               tx_bytes += pkt_len;
+
+               /* free the original mbuf */
+               rte_pktmbuf_free(m);
+       }
+
+       txq->packets += count;
+       txq->bytes += tx_bytes;
+
+       /* send the packets */
+       n = avp_fifo_put(tx_q, (void **)&avp_bufs[0], count);
+
+       return n;
+}
+
 static void
 avp_dev_rx_queue_release(void *rx_queue)
 {
@@ -1279,7 +1962,7 @@ avp_dev_tx_queue_release(void *tx_queue)
 static int
 avp_dev_configure(struct rte_eth_dev *eth_dev)
 {
-       struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
        struct rte_avp_device_info *host_info;
        struct rte_avp_device_config config;
@@ -1287,6 +1970,13 @@ avp_dev_configure(struct rte_eth_dev *eth_dev)
        void *addr;
        int ret;
 
+       rte_spinlock_lock(&avp->lock);
+       if (avp->flags & AVP_F_DETACHED) {
+               PMD_DRV_LOG(ERR, "Operation not supported during VM live migration\n");
+               ret = -ENOTSUP;
+               goto unlock;
+       }
+
        addr = pci_dev->mem_resource[RTE_AVP_PCI_DEVICE_BAR].addr;
        host_info = (struct rte_avp_device_info *)addr;
 
@@ -1296,7 +1986,12 @@ avp_dev_configure(struct rte_eth_dev *eth_dev)
        mask = (ETH_VLAN_STRIP_MASK |
                ETH_VLAN_FILTER_MASK |
                ETH_VLAN_EXTEND_MASK);
-       avp_vlan_offload_set(eth_dev, mask);
+       ret = avp_vlan_offload_set(eth_dev, mask);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "VLAN offload set failed by host, ret=%d\n",
+                           ret);
+               goto unlock;
+       }
 
        /* update device config */
        memset(&config, 0, sizeof(config));
@@ -1318,9 +2013,100 @@ avp_dev_configure(struct rte_eth_dev *eth_dev)
        ret = 0;
 
 unlock:
+       rte_spinlock_unlock(&avp->lock);
        return ret;
 }
 
+static int
+avp_dev_start(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       int ret;
+
+       rte_spinlock_lock(&avp->lock);
+       if (avp->flags & AVP_F_DETACHED) {
+               PMD_DRV_LOG(ERR, "Operation not supported during VM live migration\n");
+               ret = -ENOTSUP;
+               goto unlock;
+       }
+
+       /* update link state */
+       ret = avp_dev_ctrl_set_link_state(eth_dev, 1);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Link state change failed by host, ret=%d\n",
+                           ret);
+               goto unlock;
+       }
+
+       /* remember current link state */
+       avp->flags |= AVP_F_LINKUP;
+
+       ret = 0;
+
+unlock:
+       rte_spinlock_unlock(&avp->lock);
+       return ret;
+}
+
+static void
+avp_dev_stop(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       int ret;
+
+       rte_spinlock_lock(&avp->lock);
+       if (avp->flags & AVP_F_DETACHED) {
+               PMD_DRV_LOG(ERR, "Operation not supported during VM live migration\n");
+               goto unlock;
+       }
+
+       /* remember current link state */
+       avp->flags &= ~AVP_F_LINKUP;
+
+       /* update link state */
+       ret = avp_dev_ctrl_set_link_state(eth_dev, 0);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Link state change failed by host, ret=%d\n",
+                           ret);
+       }
+
+unlock:
+       rte_spinlock_unlock(&avp->lock);
+}
+
+static void
+avp_dev_close(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       int ret;
+
+       rte_spinlock_lock(&avp->lock);
+       if (avp->flags & AVP_F_DETACHED) {
+               PMD_DRV_LOG(ERR, "Operation not supported during VM live migration\n");
+               goto unlock;
+       }
+
+       /* remember current link state */
+       avp->flags &= ~AVP_F_LINKUP;
+       avp->flags &= ~AVP_F_CONFIGURED;
+
+       ret = avp_dev_disable_interrupts(eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Failed to disable interrupts\n");
+               /* continue */
+       }
+
+       /* update device state */
+       ret = avp_dev_ctrl_shutdown(eth_dev);
+       if (ret < 0) {
+               PMD_DRV_LOG(ERR, "Device shutdown failed by host, ret=%d\n",
+                           ret);
+               /* continue */
+       }
+
+unlock:
+       rte_spinlock_unlock(&avp->lock);
+}
 
 static int
 avp_dev_link_update(struct rte_eth_dev *eth_dev,
@@ -1336,6 +2122,33 @@ avp_dev_link_update(struct rte_eth_dev *eth_dev,
        return -1;
 }
 
+static void
+avp_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+       rte_spinlock_lock(&avp->lock);
+       if ((avp->flags & AVP_F_PROMISC) == 0) {
+               avp->flags |= AVP_F_PROMISC;
+               PMD_DRV_LOG(DEBUG, "Promiscuous mode enabled on %u\n",
+                           eth_dev->data->port_id);
+       }
+       rte_spinlock_unlock(&avp->lock);
+}
+
+static void
+avp_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+       rte_spinlock_lock(&avp->lock);
+       if ((avp->flags & AVP_F_PROMISC) != 0) {
+               avp->flags &= ~AVP_F_PROMISC;
+               PMD_DRV_LOG(DEBUG, "Promiscuous mode disabled on %u\n",
+                           eth_dev->data->port_id);
+       }
+       rte_spinlock_unlock(&avp->lock);
+}
 
 static void
 avp_dev_info_get(struct rte_eth_dev *eth_dev,
@@ -1343,8 +2156,6 @@ avp_dev_info_get(struct rte_eth_dev *eth_dev,
 {
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-       dev_info->driver_name = "rte_avp_pmd";
-       dev_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
        dev_info->max_rx_queues = avp->max_rx_queues;
        dev_info->max_tx_queues = avp->max_tx_queues;
        dev_info->min_rx_bufsize = AVP_MIN_RX_BUFSIZE;
@@ -1356,14 +2167,16 @@ avp_dev_info_get(struct rte_eth_dev *eth_dev,
        }
 }
 
-static void
+static int
 avp_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 {
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       struct rte_eth_conf *dev_conf = &eth_dev->data->dev_conf;
+       uint64_t offloads = dev_conf->rxmode.offloads;
 
        if (mask & ETH_VLAN_STRIP_MASK) {
                if (avp->host_features & RTE_AVP_FEATURE_VLAN_OFFLOAD) {
-                       if (eth_dev->data->dev_conf.rxmode.hw_vlan_strip)
+                       if (offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
                                avp->features |= RTE_AVP_FEATURE_VLAN_OFFLOAD;
                        else
                                avp->features &= ~RTE_AVP_FEATURE_VLAN_OFFLOAD;
@@ -1373,15 +2186,88 @@ avp_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
        }
 
        if (mask & ETH_VLAN_FILTER_MASK) {
-               if (eth_dev->data->dev_conf.rxmode.hw_vlan_filter)
+               if (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
                        PMD_DRV_LOG(ERR, "VLAN filter offload not supported\n");
        }
 
        if (mask & ETH_VLAN_EXTEND_MASK) {
-               if (eth_dev->data->dev_conf.rxmode.hw_vlan_extend)
+               if (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)
                        PMD_DRV_LOG(ERR, "VLAN extend offload not supported\n");
        }
+
+       return 0;
 }
 
-RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd.pci_drv);
+static int
+avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       unsigned int i;
+
+       for (i = 0; i < avp->num_rx_queues; i++) {
+               struct avp_queue *rxq = avp->dev_data->rx_queues[i];
+
+               if (rxq) {
+                       stats->ipackets += rxq->packets;
+                       stats->ibytes += rxq->bytes;
+                       stats->ierrors += rxq->errors;
+
+                       stats->q_ipackets[i] += rxq->packets;
+                       stats->q_ibytes[i] += rxq->bytes;
+                       stats->q_errors[i] += rxq->errors;
+               }
+       }
+
+       for (i = 0; i < avp->num_tx_queues; i++) {
+               struct avp_queue *txq = avp->dev_data->tx_queues[i];
+
+               if (txq) {
+                       stats->opackets += txq->packets;
+                       stats->obytes += txq->bytes;
+                       stats->oerrors += txq->errors;
+
+                       stats->q_opackets[i] += txq->packets;
+                       stats->q_obytes[i] += txq->bytes;
+                       stats->q_errors[i] += txq->errors;
+               }
+       }
+
+       return 0;
+}
+
+static void
+avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       unsigned int i;
+
+       for (i = 0; i < avp->num_rx_queues; i++) {
+               struct avp_queue *rxq = avp->dev_data->rx_queues[i];
+
+               if (rxq) {
+                       rxq->bytes = 0;
+                       rxq->packets = 0;
+                       rxq->errors = 0;
+               }
+       }
+
+       for (i = 0; i < avp->num_tx_queues; i++) {
+               struct avp_queue *txq = avp->dev_data->tx_queues[i];
+
+               if (txq) {
+                       txq->bytes = 0;
+                       txq->packets = 0;
+                       txq->errors = 0;
+               }
+       }
+}
+
+RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
+
+RTE_INIT(avp_init_log)
+{
+       avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
+       if (avp_logtype_driver >= 0)
+               rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
+}