Vhost-User: Fix bind sockaddr length
[vpp.git] / vnet / vnet / devices / dpdk / vhost_user.c
index 5ab4c22..0df9f0b 100644 (file)
@@ -12,6 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <assert.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/stat.h>
 #define DBG_SOCK(args...)
 #endif
 
+#if DPDK_VHOST_USER
+
+static const char *vhost_message_str[] __attribute__((unused)) = {
+    [VHOST_USER_NONE] = "VHOST_USER_NONE",
+    [VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES",
+    [VHOST_USER_SET_FEATURES] = "VHOST_USER_SET_FEATURES",
+    [VHOST_USER_SET_OWNER] = "VHOST_USER_SET_OWNER",
+    [VHOST_USER_RESET_OWNER] = "VHOST_USER_RESET_OWNER",
+    [VHOST_USER_SET_MEM_TABLE] = "VHOST_USER_SET_MEM_TABLE",
+    [VHOST_USER_SET_LOG_BASE] = "VHOST_USER_SET_LOG_BASE",
+    [VHOST_USER_SET_LOG_FD] = "VHOST_USER_SET_LOG_FD",
+    [VHOST_USER_SET_VRING_NUM] = "VHOST_USER_SET_VRING_NUM",
+    [VHOST_USER_SET_VRING_ADDR] = "VHOST_USER_SET_VRING_ADDR",
+    [VHOST_USER_SET_VRING_BASE] = "VHOST_USER_SET_VRING_BASE",
+    [VHOST_USER_GET_VRING_BASE] = "VHOST_USER_GET_VRING_BASE",
+    [VHOST_USER_SET_VRING_KICK] = "VHOST_USER_SET_VRING_KICK",
+    [VHOST_USER_SET_VRING_CALL] = "VHOST_USER_SET_VRING_CALL",
+    [VHOST_USER_SET_VRING_ERR]  = "VHOST_USER_SET_VRING_ERR",
+    [VHOST_USER_GET_PROTOCOL_FEATURES]  = "VHOST_USER_GET_PROTOCOL_FEATURES",
+    [VHOST_USER_SET_PROTOCOL_FEATURES]  = "VHOST_USER_SET_PROTOCOL_FEATURES",
+    [VHOST_USER_GET_QUEUE_NUM]  = "VHOST_USER_GET_QUEUE_NUM",
+    [VHOST_USER_SET_VRING_ENABLE]  = "VHOST_USER_SET_VRING_ENABLE",
+};
+
+static int dpdk_vhost_user_set_vring_enable(u32 hw_if_index,
+    u8 idx, int enable);
+
 /*
  * DPDK vhost-user functions 
  */
  */
 
 
-static uint64_t
-qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)
+static uword
+qva_to_vva(struct virtio_net *dev, uword qemu_va)
 {
   struct virtio_memory_regions *region;
-  uint64_t vhost_va = 0;
+  uword vhost_va = 0;
   uint32_t regionidx = 0;
 
   /* Find the region where the address lives. */
@@ -122,7 +150,25 @@ dpdk_vhost_user_device_from_sw_if_index(u32 sw_if_index)
   return dpdk_vhost_user_device_from_hw_if_index(sw->hw_if_index);
 }
 
-static inline void * map_guest_mem(dpdk_device_t * xd, u64 addr)
+static void stop_processing_packets(u32 hw_if_index, u8 idx)
+{
+  dpdk_device_t *xd =
+    dpdk_vhost_user_device_from_hw_if_index(hw_if_index);
+  assert(xd);
+  xd->vu_vhost_dev.virtqueue[idx]->enabled = 0;
+}
+
+static void disable_interface(dpdk_device_t * xd)
+{
+  u8 idx;
+  int numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+  for (idx = 0;  idx < numqs; idx++)
+    xd->vu_vhost_dev.virtqueue[idx]->enabled = 0;
+
+  xd->vu_is_running = 0;
+}
+
+static inline void * map_guest_mem(dpdk_device_t * xd, uword addr)
 {
   dpdk_vu_intf_t * vui = xd->vu_intf;
   struct virtio_memory * mem = xd->vu_vhost_dev.mem;
@@ -130,15 +176,15 @@ static inline void * map_guest_mem(dpdk_device_t * xd, u64 addr)
   for (i=0; i<mem->nregions; i++) {
     if ((mem->regions[i].guest_phys_address <= addr) &&
        ((mem->regions[i].guest_phys_address + mem->regions[i].memory_size) > addr)) {
-         return (void *) (vui->region_addr[i] + addr - mem->regions[i].guest_phys_address);
+         return (void *) ((uword)vui->region_addr[i] + addr - (uword)mem->regions[i].guest_phys_address);
        }
   }
-  DBG_SOCK("failed to map guest mem addr %llx", addr);
+  DBG_SOCK("failed to map guest mem addr %lx", addr);
   return 0;
 }
 
 static clib_error_t *
-dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
+dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 *hwaddr)
 {
   dpdk_main_t * dm = &dpdk_main;
   vlib_main_t * vm = vlib_get_main();
@@ -146,6 +192,10 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
   vnet_sw_interface_t * sw;
   clib_error_t * error;
   dpdk_device_and_queue_t * dq;
+  int num_qpairs = 1;
+  dpdk_vu_intf_t *vui = NULL;
+
+  num_qpairs = dm->use_rss < 1 ? 1 : tm->n_vlib_mains;
 
   dpdk_device_t * xd = NULL;
   u8 addr[6];
@@ -179,12 +229,19 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
           xd->vu_if_id = if_id;
 
       // reset virtqueues
-      for (j = 0; j < VIRTIO_QNUM; j++)
-        {
+      vui = xd->vu_intf;
+      for (j = 0; j < num_qpairs * VIRTIO_QNUM; j++) {
           memset(xd->vu_vhost_dev.virtqueue[j], 0, sizeof(struct vhost_virtqueue));
-        }
+          xd->vu_vhost_dev.virtqueue[j]->kickfd = -1; 
+          xd->vu_vhost_dev.virtqueue[j]->callfd = -1; 
+          xd->vu_vhost_dev.virtqueue[j]->backend = -1; 
+          vui->vrings[j].packets = 0;
+          vui->vrings[j].bytes = 0;
+       }
+
       // reset lockp
-      memset ((void *) xd->lockp, 0, CLIB_CACHE_LINE_BYTES);
+      dpdk_device_lock_free(xd);
+      dpdk_device_lock_init(xd);
 
       // reset tx vectors
       for (j = 0; j < tm->n_vlib_mains; j++)
@@ -205,7 +262,10 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
       // vui was not retrieved from inactive ifaces - create new
       vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES);
       xd->dev_type = VNET_DPDK_DEV_VHOST_USER;
-      xd->rx_q_used = 1;
+      xd->rx_q_used = num_qpairs;
+      xd->tx_q_used = num_qpairs;
+      xd->vu_vhost_dev.virt_qp_nb = num_qpairs;
+
       vec_validate_aligned (xd->rx_vectors, xd->rx_q_used, CLIB_CACHE_LINE_BYTES);
 
       if (if_id == (u32)~0)
@@ -215,21 +275,34 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
 
       xd->device_index = xd - dm->devices;
       xd->per_interface_next_index = ~0;
-      xd->vu_intf = NULL;
+      xd->vu_intf = clib_mem_alloc (sizeof(*(xd->vu_intf)));
 
       xd->vu_vhost_dev.mem = clib_mem_alloc (sizeof(struct virtio_memory) +
                                              VHOST_MEMORY_MAX_NREGIONS *
                                              sizeof(struct virtio_memory_regions));
 
-      for (j = 0; j < VIRTIO_QNUM; j++)
-        {
+      /* Will be set when guest sends VHOST_USER_SET_MEM_TABLE cmd */
+      xd->vu_vhost_dev.mem->nregions = 0;
+
+      /* 
+       * New virtqueue structure is an array of VHOST_MAX_QUEUE_PAIRS * 2
+       * We need to allocate numq pairs.
+       */
+      vui = xd->vu_intf;
+      for (j = 0; j < num_qpairs * VIRTIO_QNUM; j++) {
           xd->vu_vhost_dev.virtqueue[j] = clib_mem_alloc (sizeof(struct vhost_virtqueue));
           memset(xd->vu_vhost_dev.virtqueue[j], 0, sizeof(struct vhost_virtqueue));
-        }
+          xd->vu_vhost_dev.virtqueue[j]->kickfd = -1; 
+          xd->vu_vhost_dev.virtqueue[j]->callfd = -1; 
+          xd->vu_vhost_dev.virtqueue[j]->backend = -1; 
+          vui->vrings[j].packets = 0;
+          vui->vrings[j].bytes = 0;
+      }
+
+      dpdk_device_lock_init(xd);
 
-      xd->lockp = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,
-                                          CLIB_CACHE_LINE_BYTES);
-      memset ((void *) xd->lockp, 0, CLIB_CACHE_LINE_BYTES);
+      DBG_SOCK("tm->n_vlib_mains: %d. TX %d, RX: %d, num_qpairs: %d, Lock: %p",
+        tm->n_vlib_mains, xd->tx_q_used, xd->rx_q_used, num_qpairs, xd->lockp);
 
       vec_validate_aligned (xd->tx_vectors, tm->n_vlib_mains,
                             CLIB_CACHE_LINE_BYTES);
@@ -253,13 +326,18 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
                             CLIB_CACHE_LINE_BYTES);
 
   }
-  {
+  /*
+   * Generate random MAC address for the interface
+   */
+  if (hwaddr) {
+    clib_memcpy(addr, hwaddr, sizeof(addr));
+  } else {
     f64 now = vlib_time_now(vm);
     u32 rnd;
     rnd = (u32) (now * 1e6);
     rnd = random_u32 (&rnd);
 
-    memcpy (addr+2, &rnd, sizeof(rnd));
+    clib_memcpy (addr+2, &rnd, sizeof(rnd));
     addr[0] = 2;
     addr[1] = 0xfe;
   }
@@ -278,39 +356,80 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
   sw = vnet_get_hw_sw_interface (dm->vnet_main, xd->vlib_hw_if_index);
   xd->vlib_sw_if_index = sw->sw_if_index;
 
-  if (!xd->vu_intf)
-      xd->vu_intf = clib_mem_alloc (sizeof(*(xd->vu_intf)));
-
   *hw_if_index = xd->vlib_hw_if_index;
 
-  int cpu = (xd->device_index % dm->input_cpu_count) +
-            dm->input_cpu_first_index;
+  DBG_SOCK("xd->device_index: %d, dm->input_cpu_count: %d, "
+    "dm->input_cpu_first_index: %d\n", xd->device_index,
+    dm->input_cpu_count, dm->input_cpu_first_index);
 
-  vec_add2(dm->devices_by_cpu[cpu], dq, 1);
-  dq->device = xd->device_index;
-  dq->queue_id = 0;
+  int q, next_cpu = 0;
+  for (q = 0; q < num_qpairs; q++) {
+      int cpu = dm->input_cpu_first_index +
+        (next_cpu % dm->input_cpu_count);
 
-  // start polling if it was not started yet (because of no phys ifaces)
-  if (tm->n_vlib_mains == 1 && dpdk_input_node.state != VLIB_NODE_STATE_POLLING)
-    vlib_node_set_state (vm, dpdk_input_node.index, VLIB_NODE_STATE_POLLING);
+      unsigned lcore = vlib_worker_threads[cpu].dpdk_lcore_id;
+      vec_validate(xd->cpu_socket_id_by_queue, q);
+      xd->cpu_socket_id_by_queue[q] = rte_lcore_to_socket_id(lcore);
 
-  if (tm->n_vlib_mains > 1 && tm->main_thread_is_io_node)
-    vlib_node_set_state (vm, dpdk_io_input_node.index, VLIB_NODE_STATE_POLLING);
+      vec_add2(dm->devices_by_cpu[cpu], dq, 1);
+      dq->device = xd->device_index;
+      dq->queue_id = q;
+      DBG_SOCK("CPU for %d = %d. QID: %d", *hw_if_index, cpu, dq->queue_id);
 
-  if (tm->n_vlib_mains > 1 && !tm->main_thread_is_io_node)
-    vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
-                         VLIB_NODE_STATE_POLLING);
+      // start polling if it was not started yet (because of no phys ifaces)
+      if (tm->n_vlib_mains == 1 && dpdk_input_node.state != VLIB_NODE_STATE_POLLING)
+        vlib_node_set_state (vm, dpdk_input_node.index, VLIB_NODE_STATE_POLLING);
+
+      if (tm->n_vlib_mains > 1)
+        vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
+                             VLIB_NODE_STATE_POLLING);
+      next_cpu++;
+  }
 
   vlib_worker_thread_barrier_release (vm);
   return 0;
 }
 
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
+static long get_huge_page_size(int fd)
+{
+  struct statfs s;
+  fstatfs(fd, &s);
+  return s.f_bsize;
+}
+#endif
+
+static clib_error_t *
+dpdk_vhost_user_set_protocol_features(u32 hw_if_index, u64 prot_features)
+{
+  dpdk_device_t * xd;
+  xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_index);
+  assert(xd);
+  xd->vu_vhost_dev.protocol_features = prot_features;
+  return 0;
+}
+
 static clib_error_t *
 dpdk_vhost_user_get_features(u32 hw_if_index, u64 * features)
 {
   *features = rte_vhost_feature_get();
 
-  DBG_SOCK("supported features: 0x%x", *features);
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
+#define OFFLOAD_FEATURES ((1ULL << VIRTIO_NET_F_HOST_TSO4) | \
+               (1ULL << VIRTIO_NET_F_HOST_TSO6) | \
+               (1ULL << VIRTIO_NET_F_CSUM)    | \
+               (1ULL << VIRTIO_NET_F_GUEST_CSUM) | \
+               (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
+               (1ULL << VIRTIO_NET_F_GUEST_TSO6))
+
+  /* These are not suppoted as bridging/tunneling VHOST
+   * interfaces with hardware interfaces/drivers that does
+   * not support offloading breaks L4 traffic.
+   */
+  *features &= (~OFFLOAD_FEATURES);
+#endif
+
+  DBG_SOCK("supported features: 0x%lx", *features);
   return 0;
 }
 
@@ -331,10 +450,22 @@ dpdk_vhost_user_set_features(u32 hw_if_index, u64 features)
   if (xd->vu_vhost_dev.features & (1 << VIRTIO_NET_F_MRG_RXBUF))
     hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
 
-  xd->vu_vhost_dev.virtqueue[VIRTIO_RXQ]->vhost_hlen = hdr_len;
-  xd->vu_vhost_dev.virtqueue[VIRTIO_TXQ]->vhost_hlen = hdr_len;
-
-  xd->vu_is_running = 0;
+  int numqs = VIRTIO_QNUM;
+  u8 idx;
+  int prot_feature = features &
+        (1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
+  numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+  for (idx = 0; idx < numqs; idx++) {
+      xd->vu_vhost_dev.virtqueue[idx]->vhost_hlen = hdr_len;
+      /*
+       * Spec says, if F_PROTOCOL_FEATURE is not set by the
+       * slave, then all the vrings should start off as
+       * enabled. If slave negotiates F_PROTOCOL_FEATURE, then
+       * slave is responsible to enable it.
+       */
+      if (! prot_feature)
+          dpdk_vhost_user_set_vring_enable(hw_if_index, idx, 1);
+  }
 
   return 0;
 }
@@ -367,9 +498,9 @@ dpdk_vhost_user_set_mem_table(u32 hw_if_index, vhost_user_memory_t * vum, int fd
     mem->regions[i].userspace_address      = vum->regions[i].userspace_addr;
 
     mapped_size = mem->regions[i].memory_size + vum->regions[i].mmap_offset;
-    mapped_address = (uint64_t)(uintptr_t)mmap(NULL, mapped_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd[i], 0);
+    mapped_address = pointer_to_uword(mmap(NULL, mapped_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd[i], 0));
 
-    if ((void *)mapped_address == MAP_FAILED)
+    if (uword_to_pointer(mapped_address, void*) == MAP_FAILED)
     {
       clib_warning("mmap error");
       return 0;
@@ -378,17 +509,19 @@ dpdk_vhost_user_set_mem_table(u32 hw_if_index, vhost_user_memory_t * vum, int fd
     mapped_address +=  vum->regions[i].mmap_offset;
     vui->region_addr[i] = mapped_address;
     vui->region_fd[i] = fd[i];
+    vui->region_offset[i] = vum->regions[i].mmap_offset;
     mem->regions[i].address_offset = mapped_address - mem->regions[i].guest_phys_address;
 
+    DBG_SOCK("map memory region %d addr 0x%lx off 0x%lx len 0x%lx",
+      i, vui->region_addr[i], vui->region_offset[i], mapped_size);
+
     if (vum->regions[i].guest_phys_addr == 0) {
       mem->base_address = vum->regions[i].userspace_addr;
       mem->mapped_address = mem->regions[i].address_offset;
     }
   }
 
-  xd->vu_is_running = 0;
-
-  DBG_SOCK("done");
+  disable_interface(xd);
   return 0;
 }
 
@@ -407,18 +540,20 @@ dpdk_vhost_user_set_vring_num(u32 hw_if_index, u8 idx, u32 num)
   vq = xd->vu_vhost_dev.virtqueue[idx];
   vq->size = num;
 
-  xd->vu_is_running = 0;
+  stop_processing_packets(hw_if_index, idx);
 
   return 0;
 }
 
 static clib_error_t *
-dpdk_vhost_user_set_vring_addr(u32 hw_if_index, u8 idx, u64 desc, u64 used, u64 avail)
+dpdk_vhost_user_set_vring_addr(u32 hw_if_index, u8 idx, uword desc, \
+    uword used, uword avail, uword log)
 {
   dpdk_device_t * xd;
   struct vhost_virtqueue *vq;
 
-  DBG_SOCK("idx %u desc 0x%x used 0x%x avail 0x%x", idx, desc, used, avail);
+  DBG_SOCK("idx %u desc 0x%lx used 0x%lx avail 0x%lx log 0x%lx",
+    idx, desc, used, avail, log);
 
   if (!(xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_index))) {
     clib_warning("not a vhost-user interface");
@@ -429,12 +564,32 @@ dpdk_vhost_user_set_vring_addr(u32 hw_if_index, u8 idx, u64 desc, u64 used, u64
   vq->desc = (struct vring_desc *) qva_to_vva(&xd->vu_vhost_dev, desc);
   vq->used = (struct vring_used *) qva_to_vva(&xd->vu_vhost_dev, used);
   vq->avail = (struct vring_avail *) qva_to_vva(&xd->vu_vhost_dev, avail);
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
+  vq->log_guest_addr = log;
+#endif
 
   if (!(vq->desc && vq->used && vq->avail)) {
     clib_warning("falied to set vring addr");
   }
 
-  xd->vu_is_running = 0;
+  if (vq->last_used_idx != vq->used->idx) {
+    clib_warning("last_used_idx (%u) and vq->used->idx (%u) mismatches; "
+                 "some packets maybe resent for Tx and dropped for Rx",
+                 vq->last_used_idx, vq->used->idx);
+      vq->last_used_idx     = vq->used->idx;
+      vq->last_used_idx_res = vq->used->idx;
+  }
+
+  /*
+   * Inform the guest that there is no need to inform (kick) the
+   * host when it adds buffers. kick results in vmexit and will
+   * incur performance degradation.
+   *
+   * The below function sets a flag in used table. Therefore,
+   * should be initialized after initializing vq->used.
+   */
+  rte_vhost_enable_guest_notification(&xd->vu_vhost_dev, idx, 0);
+  stop_processing_packets(hw_if_index, idx);
 
   return 0;
 }
@@ -453,7 +608,38 @@ dpdk_vhost_user_get_vring_base(u32 hw_if_index, u8 idx, u32 * num)
   vq = xd->vu_vhost_dev.virtqueue[idx];
   *num = vq->last_used_idx;
 
-  DBG_SOCK("idx %u num %u", idx, *num);
+/*
+ * From spec:
+ * Client must start ring upon receiving a kick
+ * (that is, detecting that file descriptor is readable)
+ * on the descriptor specified by VHOST_USER_SET_VRING_KICK,
+ * and stop ring upon receiving VHOST_USER_GET_VRING_BASE.
+ */
+  DBG_SOCK("Stopping vring Q %u of device %d", idx, hw_if_index);
+  dpdk_vu_intf_t *vui = xd->vu_intf;
+  vui->vrings[idx].enabled = 0; /* Reset local copy */
+  vui->vrings[idx].callfd = -1; /* Reset FD */
+  vq->enabled = 0;
+  vq->desc = NULL;
+  vq->used = NULL;
+  vq->avail = NULL;
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
+  vq->log_guest_addr = 0;
+#endif
+
+  /* Check if all Qs are disabled */
+  int numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+  for (idx = 0;  idx < numqs; idx++) {
+    if (xd->vu_vhost_dev.virtqueue[idx]->enabled)
+        break;
+  }
+
+  /* If all vrings are disabed then disable device */
+  if (idx == numqs)  {
+      DBG_SOCK("Device %d disabled", hw_if_index);
+      xd->vu_is_running = 0;
+  }
+
   return 0;
 }
 
@@ -474,7 +660,7 @@ dpdk_vhost_user_set_vring_base(u32 hw_if_index, u8 idx, u32 num)
   vq->last_used_idx = num;
   vq->last_used_idx_res = num;
 
-  xd->vu_is_running = 0;
+  stop_processing_packets(hw_if_index, idx);
 
   return 0;
 }
@@ -484,9 +670,9 @@ dpdk_vhost_user_set_vring_kick(u32 hw_if_index, u8 idx, int fd)
 {
   dpdk_main_t * dm = &dpdk_main;
   dpdk_device_t * xd;
-  struct vhost_virtqueue *vq, *vq0, *vq1;
-
-  DBG_SOCK("idx %u fd %d", idx, fd);
+  dpdk_vu_vring *vring;
+  struct vhost_virtqueue *vq0, *vq1, *vq;
+  int index, vu_is_running = 0;
 
   if (!(xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_index))) {
     clib_warning("not a vhost-user interface");
@@ -496,38 +682,115 @@ dpdk_vhost_user_set_vring_kick(u32 hw_if_index, u8 idx, int fd)
   vq = xd->vu_vhost_dev.virtqueue[idx];
   vq->kickfd = fd;
 
-  vq0 = xd->vu_vhost_dev.virtqueue[0];
-  vq1 = xd->vu_vhost_dev.virtqueue[1];
+  vring = &xd->vu_intf->vrings[idx];
+  vq->enabled = (vq->desc && vq->avail && vq->used && vring->enabled) ? 1 : 0;
+
+  /*
+   * Set xd->vu_is_running if at least one pair of
+   * RX/TX queues are enabled.
+   */
+  int numqs = VIRTIO_QNUM;
+  numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
 
-  if (vq0->desc && vq0->avail && vq0->used &&
-      vq1->desc && vq1->avail && vq1->used) {
-    xd->vu_is_running = 1;
-    if (xd->admin_up)
-      vnet_hw_interface_set_flags (dm->vnet_main, xd->vlib_hw_if_index,
-                           VNET_HW_INTERFACE_FLAG_LINK_UP |
-                           ETH_LINK_FULL_DUPLEX );
+  for (index = 0; index < numqs; index += 2) {
+    vq0 = xd->vu_vhost_dev.virtqueue[index]; /* RX */
+    vq1 = xd->vu_vhost_dev.virtqueue[index + 1]; /* TX */
+    if (vq0->enabled && vq1->enabled)
+    {
+        vu_is_running = 1;
+        break;
+    }
+  }
+  DBG_SOCK("SET_VRING_KICK - idx %d, running %d, fd: %d",
+    idx, vu_is_running, fd);
+
+  xd->vu_is_running = vu_is_running;
+  if (xd->vu_is_running && xd->admin_up) {
+    vnet_hw_interface_set_flags (dm->vnet_main,
+      xd->vlib_hw_if_index, VNET_HW_INTERFACE_FLAG_LINK_UP |
+      ETH_LINK_FULL_DUPLEX );
   }
 
   return 0;
 }
 
+static int
+dpdk_vhost_user_set_vring_enable(u32 hw_if_index, u8 idx, int enable)
+{
+  dpdk_device_t * xd;
+  struct vhost_virtqueue *vq;
+  dpdk_vu_intf_t *vui;
+
+  if (!(xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_index))) {
+    clib_warning("not a vhost-user interface");
+    return 0;
+  }
+
+  vui = xd->vu_intf;
+  /*
+   * Guest vhost driver wrongly enables queue before
+   * setting the vring address. Therefore, save a
+   * local copy. Reflect it in vq structure if addresses
+   * are set. If not, vq will be enabled when vring
+   * is kicked.
+   */
+  vui->vrings[idx].enabled = enable; /* Save local copy */
+
+  int numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+  while (numqs--) {
+    if (! vui->vrings[numqs].enabled)
+        break;
+  }
+
+  if (numqs == -1) /* All Qs are enabled */
+    xd->need_txlock = 0;
+  else
+    xd->need_txlock = 1;
+
+  vq = xd->vu_vhost_dev.virtqueue[idx];
+  if (vq->desc && vq->avail && vq->used)
+    xd->vu_vhost_dev.virtqueue[idx]->enabled = enable;
+
+  return 0;
+}
+
+static clib_error_t * dpdk_vhost_user_callfd_read_ready (unix_file_t * uf)
+{
+  __attribute__((unused)) int n;
+  u8 buff[8];
+  n = read(uf->file_descriptor, ((char*)&buff), 8);
+  return 0;
+}
 
 static clib_error_t *
 dpdk_vhost_user_set_vring_call(u32 hw_if_index, u8 idx, int fd)
 {
   dpdk_device_t * xd;
   struct vhost_virtqueue *vq;
+  unix_file_t template = {0};
 
-  DBG_SOCK("idx %u fd %d", idx, fd);
+  DBG_SOCK("SET_VRING_CALL - idx %d, fd %d", idx, fd);
 
   if (!(xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_index))) {
     clib_warning("not a vhost-user interface");
     return 0;
   }
 
+  dpdk_vu_intf_t *vui = xd->vu_intf;
+
+  /* if there is old fd, delete it */
+  if (vui->vrings[idx].callfd > 0) {
+    unix_file_t * uf = pool_elt_at_index (unix_main.file_pool,
+      vui->vrings[idx].callfd_idx);
+    unix_file_del (&unix_main, uf);
+  }
+  vui->vrings[idx].callfd = fd;
+  template.read_function = dpdk_vhost_user_callfd_read_ready;
+  template.file_descriptor = fd;
+  vui->vrings[idx].callfd_idx = unix_file_add (&unix_main, &template);
+
   vq = xd->vu_vhost_dev.virtqueue[idx];
-  /* reset callfd to force no interrupts */
-  vq->callfd = -1;
+  vq->callfd = -1; /* We use locally saved vring->callfd; */
 
   return 0;
 }
@@ -563,12 +826,9 @@ dpdk_vhost_user_send_interrupt(vlib_main_t * vm, dpdk_device_t * xd, int idx)
 
     /* if vm is interested in interrupts */
     if((vring->callfd > 0) && !(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) {
-        u64 x = 1;
-        int rv __attribute__((unused));
-        /* $$$$ pay attention to rv */
-        rv = write(vring->callfd, &x, sizeof(x));
+        eventfd_write(vring->callfd, (eventfd_t)1);
         vring->n_since_last_int = 0;
-        vring->int_deadline = vlib_time_now(vm) + dm->vhost_coalesce_time;
+        vring->int_deadline = vlib_time_now(vm) + dm->conf->vhost_coalesce_time;
     }
 }
 
@@ -588,7 +848,8 @@ dpdk_vhost_user_vui_init(vnet_main_t * vnm,
   memset(vui, 0, sizeof(*vui));
 
   vui->unix_fd = sockfd;
-  vui->num_vrings = 2;
+  vui->num_vrings = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+  DBG_SOCK("dpdk_vhost_user_vui_init VRINGS: %d", vui->num_vrings);
   vui->sock_is_server = is_server;
   strncpy(vui->sock_filename, sock_filename, ARRAY_LEN(vui->sock_filename)-1);
   vui->sock_errno = 0;
@@ -614,12 +875,44 @@ dpdk_vhost_user_vui_register(vlib_main_t * vm, dpdk_device_t *xd)
             xd->vlib_sw_if_index);
 }
 
+static void dpdk_unmap_all_mem_regions(dpdk_device_t * xd)
+{
+  int i, r;
+  dpdk_vu_intf_t *vui = xd->vu_intf;
+  struct virtio_memory * mem = xd->vu_vhost_dev.mem;
+
+  for (i=0; i<mem->nregions; i++) {
+    if (vui->region_addr[i] != -1) {
+
+      long page_sz = get_huge_page_size(vui->region_fd[i]);
+
+      ssize_t map_sz = (mem->regions[i].memory_size +
+        vui->region_offset[i] + page_sz) & ~(page_sz - 1);
+
+      r = munmap((void *)(vui->region_addr[i] - vui->region_offset[i]), map_sz);
+
+      DBG_SOCK("unmap memory region %d addr 0x%lx off 0x%lx len 0x%lx page_sz 0x%x",
+        i, vui->region_addr[i], vui->region_offset[i], map_sz, page_sz);
+
+      vui->region_addr[i]= -1;
+
+      if (r == -1) {
+        clib_unix_warning("failed to unmap memory region");
+      }
+      close(vui->region_fd[i]);
+    }
+  }
+  mem->nregions = 0;
+}
+
 static inline void
 dpdk_vhost_user_if_disconnect(dpdk_device_t * xd)
 {
     dpdk_vu_intf_t *vui = xd->vu_intf;
     vnet_main_t * vnm = vnet_get_main();
     dpdk_main_t * dm = &dpdk_main;
+    struct vhost_virtqueue *vq;
+    int q;
 
     xd->admin_up = 0;
     vnet_hw_interface_set_flags (vnm, xd->vlib_hw_if_index,  0);
@@ -635,15 +928,22 @@ dpdk_vhost_user_if_disconnect(dpdk_device_t * xd)
     vui->unix_fd = -1;
     vui->is_up = 0;
 
-    DBG_SOCK("interface ifindex %d disconnected", xd->vlib_sw_if_index);
-}
+    for (q = 0; q < vui->num_vrings; q++) {
+        vq = xd->vu_vhost_dev.virtqueue[q];
+        vui->vrings[q].enabled = 0; /* Reset local copy */
+        vui->vrings[q].callfd = -1; /* Reset FD */
+        vq->enabled = 0;
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
+        vq->log_guest_addr = 0;
+#endif
+        vq->desc = NULL;
+        vq->used = NULL;
+        vq->avail = NULL;
+    }
+    xd->vu_is_running = 0;
 
-static clib_error_t * dpdk_vhost_user_callfd_read_ready (unix_file_t * uf)
-{
-  __attribute__((unused)) int n;
-  u8 buff[8];
-  n = read(uf->file_descriptor, ((char*)&buff), 8);
-  return 0;
+    dpdk_unmap_all_mem_regions(xd);
+    DBG_SOCK("interface ifindex %d disconnected", xd->vlib_sw_if_index);
 }
 
 static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
@@ -660,7 +960,6 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
   struct cmsghdr *cmsg;
   uword * p;
   u8 q;
-  unix_file_t template = {0};
   vnet_main_t * vnm = vnet_get_main();
 
   p = hash_get (dm->vu_sw_if_index_by_sock_fd, uf->file_descriptor);
@@ -704,7 +1003,7 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       (cmsg->cmsg_type == SCM_RIGHTS) &&
       (cmsg->cmsg_len - CMSG_LEN(0) <= VHOST_MEMORY_MAX_NREGIONS * sizeof(int))) {
         number_of_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int);
-        memcpy(fds, CMSG_DATA(cmsg), number_of_fds * sizeof(int));
+        clib_memcpy(fds, CMSG_DATA(cmsg), number_of_fds * sizeof(int));
   }
 
   /* version 1, no reply bit set*/
@@ -719,12 +1018,13 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       rv = read(uf->file_descriptor, ((char*)&msg) + n, msg.size);
   }
 
+  DBG_SOCK("VPP VHOST message %s", vhost_message_str[msg.request]);
   switch (msg.request) {
     case VHOST_USER_GET_FEATURES:
       DBG_SOCK("if %d msg VHOST_USER_GET_FEATURES",
         xd->vlib_hw_if_index);
 
-      msg.flags |= 4;
+      msg.flags |= VHOST_USER_REPLY_MASK;
 
       dpdk_vhost_user_get_features(xd->vlib_hw_if_index, &msg.u64);
       msg.u64 &= vui->feature_mask;
@@ -732,7 +1032,7 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       break;
 
     case VHOST_USER_SET_FEATURES:
-      DBG_SOCK("if %d msg VHOST_USER_SET_FEATURES features 0x%016llx",
+      DBG_SOCK("if %d msg VHOST_USER_SET_FEATURES features 0x%016lx",
         xd->vlib_hw_if_index, msg.u64);
 
       dpdk_vhost_user_set_features(xd->vlib_hw_if_index, msg.u64);
@@ -778,7 +1078,8 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       dpdk_vhost_user_set_vring_addr(xd->vlib_hw_if_index, msg.state.index,
                                     msg.addr.desc_user_addr,
                                     msg.addr.used_user_addr,
-                                    msg.addr.avail_user_addr);
+                                    msg.addr.avail_user_addr,
+                                    msg.addr.log_guest_addr);
       break;
 
     case VHOST_USER_SET_OWNER:
@@ -792,39 +1093,30 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       break;
 
     case VHOST_USER_SET_VRING_CALL:
-      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_CALL u64 %d",
-        xd->vlib_hw_if_index, msg.u64);
-
       q = (u8) (msg.u64 & 0xFF);
 
+      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_CALL u64 %lx, idx: %d",
+        xd->vlib_hw_if_index, msg.u64, q);
+
       if (!(msg.u64 & 0x100))
       {
         if (number_of_fds != 1)
           goto close_socket;
-
-        /* if there is old fd, delete it */
-        if (vui->vrings[q].callfd) {
-          unix_file_t * uf = pool_elt_at_index (unix_main.file_pool,
-            vui->vrings[q].callfd_idx);
-          unix_file_del (&unix_main, uf);
-        }
-        vui->vrings[q].callfd = fds[0];
-        template.read_function = dpdk_vhost_user_callfd_read_ready;
-        template.file_descriptor = fds[0];
-        vui->vrings[q].callfd_idx = unix_file_add (&unix_main, &template);
+        fd = fds[0];
+      } else {
+        fd = -1;
       }
-      else
-        vui->vrings[q].callfd = -1;
+      dpdk_vhost_user_set_vring_call(xd->vlib_hw_if_index, q, fd);
 
-      dpdk_vhost_user_set_vring_call(xd->vlib_hw_if_index, q, vui->vrings[q].callfd);
       break;
 
     case VHOST_USER_SET_VRING_KICK:
-      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_KICK u64 %d",
-        xd->vlib_hw_if_index, msg.u64);
 
       q = (u8) (msg.u64 & 0xFF);
 
+      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_KICK u64 %lx, idx: %d",
+        xd->vlib_hw_if_index, msg.u64, q);
+
       if (!(msg.u64 & 0x100))
       {
         if (number_of_fds != 1)
@@ -839,11 +1131,12 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       break;
 
     case VHOST_USER_SET_VRING_ERR:
-      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_ERR u64 %d",
-        xd->vlib_hw_if_index, msg.u64);
 
       q = (u8) (msg.u64 & 0xFF);
 
+      DBG_SOCK("if %d msg VHOST_USER_SET_VRING_ERR u64 %lx, idx: %d",
+        xd->vlib_hw_if_index, msg.u64, q);
+
       if (!(msg.u64 & 0x100))
       {
         if (number_of_fds != 1)
@@ -868,7 +1161,7 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       DBG_SOCK("if %d msg VHOST_USER_GET_VRING_BASE idx %d num %d",
         xd->vlib_hw_if_index, msg.state.index, msg.state.num);
 
-      msg.flags |= 4;
+      msg.flags |= VHOST_USER_REPLY_MASK;
       msg.size = sizeof(msg.state);
 
       dpdk_vhost_user_get_vring_base(xd->vlib_hw_if_index, msg.state.index, &msg.state.num);
@@ -880,8 +1173,45 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
       break;
 
     case VHOST_USER_SET_LOG_BASE:
+#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
       DBG_SOCK("if %d msg VHOST_USER_SET_LOG_BASE",
         xd->vlib_hw_if_index);
+
+      if (msg.size != sizeof(msg.log)) {
+        DBG_SOCK("invalid msg size for VHOST_USER_SET_LOG_BASE: %u instead of %lu",
+                 msg.size, sizeof(msg.log));
+        goto close_socket;
+      }
+
+      if (!(xd->vu_vhost_dev.protocol_features & (1 << VHOST_USER_PROTOCOL_F_LOG_SHMFD))) {
+        DBG_SOCK("VHOST_USER_PROTOCOL_F_LOG_SHMFD not set but VHOST_USER_SET_LOG_BASE received");
+        goto close_socket;
+      }
+
+      fd = fds[0];
+      /* align size to 2M page */
+      long page_sz = get_huge_page_size(fd);
+      ssize_t map_sz = (msg.log.size + msg.log.offset + page_sz) & ~(page_sz - 1);
+
+      void *addr = mmap(0, map_sz, PROT_READ | PROT_WRITE,
+                                MAP_SHARED, fd, 0);
+
+      DBG_SOCK("map log region addr 0 len 0x%lx off 0x%lx fd %d mapped %p",
+               map_sz, msg.log.offset, fd, addr);
+
+      if (addr == MAP_FAILED) {
+        clib_warning("failed to map memory. errno is %d", errno);
+        goto close_socket;
+      }
+
+      xd->vu_vhost_dev.log_base += pointer_to_uword(addr) + msg.log.offset;
+      xd->vu_vhost_dev.log_size = msg.log.size;
+      msg.flags |= VHOST_USER_REPLY_MASK;
+      msg.size = sizeof(msg.u64);
+#else
+      DBG_SOCK("if %d msg VHOST_USER_SET_LOG_BASE Not-Implemented",
+        xd->vlib_hw_if_index);
+#endif
       break;
 
     case VHOST_USER_SET_LOG_FD:
@@ -889,6 +1219,42 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
         xd->vlib_hw_if_index);
       break;
 
+    case VHOST_USER_GET_PROTOCOL_FEATURES:
+      DBG_SOCK("if %d msg VHOST_USER_GET_PROTOCOL_FEATURES",
+        xd->vlib_hw_if_index);
+
+      msg.flags |= VHOST_USER_REPLY_MASK;
+      msg.u64 = VHOST_USER_PROTOCOL_FEATURES;
+      DBG_SOCK("VHOST_USER_PROTOCOL_FEATURES: %llx", VHOST_USER_PROTOCOL_FEATURES);
+      msg.size = sizeof(msg.u64);
+      break;
+
+    case VHOST_USER_SET_PROTOCOL_FEATURES:
+      DBG_SOCK("if %d msg VHOST_USER_SET_PROTOCOL_FEATURES",
+        xd->vlib_hw_if_index);
+
+      DBG_SOCK("VHOST_USER_SET_PROTOCOL_FEATURES: 0x%lx",
+        msg.u64);
+      dpdk_vhost_user_set_protocol_features(xd->vlib_hw_if_index,
+        msg.u64);
+      break;
+
+    case VHOST_USER_SET_VRING_ENABLE:
+      DBG_SOCK("%d VPP VHOST_USER_SET_VRING_ENABLE IDX: %d, Enable: %d",
+        xd->vlib_hw_if_index, msg.state.index, msg.state.num);
+      dpdk_vhost_user_set_vring_enable
+        (xd->vlib_hw_if_index, msg.state.index, msg.state.num);
+      break;
+
+    case VHOST_USER_GET_QUEUE_NUM:
+      DBG_SOCK("if %d msg VHOST_USER_GET_QUEUE_NUM:",
+        xd->vlib_hw_if_index);
+
+      msg.flags |= VHOST_USER_REPLY_MASK;
+      msg.u64 = xd->vu_vhost_dev.virt_qp_nb;
+      msg.size = sizeof(msg.u64);
+      break;
+
     default:
       DBG_SOCK("unknown vhost-user message %d received. closing socket",
         msg.request);
@@ -904,10 +1270,11 @@ static clib_error_t * dpdk_vhost_user_socket_read (unix_file_t * uf)
 
       vnet_hw_interface_set_flags (vnm, xd->vlib_hw_if_index,  VNET_HW_INTERFACE_FLAG_LINK_UP);
       vui->is_up = 1;
+      xd->admin_up = 1;
   }
 
   /* if we need to reply */
-  if (msg.flags & 4)
+  if (msg.flags & VHOST_USER_REPLY_MASK)
   {
       n = send(uf->file_descriptor, &msg, VHOST_USER_MSG_HDR_SZ + msg.size, 0);
       if (n != (msg.size + VHOST_USER_MSG_HDR_SZ))
@@ -986,8 +1353,8 @@ static clib_error_t * dpdk_vhost_user_socksvr_accept_ready (unix_file_t * uf)
 // init server socket on specified sock_filename
 static int dpdk_vhost_user_init_server_sock(const char * sock_filename, int *sockfd)
 {
-  int rv = 0, len;
-  struct sockaddr_un un;
+  int rv = 0;
+  struct sockaddr_un un = {};
   int fd;
   /* create listening socket */
   fd = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -1002,9 +1369,7 @@ static int dpdk_vhost_user_init_server_sock(const char * sock_filename, int *soc
   /* remove if exists */
   unlink( (char *) sock_filename);
 
-  len = strlen((char *) un.sun_path) + strlen((char *) sock_filename);
-
-  if (bind(fd, (struct sockaddr *) &un, len) == -1) {
+  if (bind(fd, (struct sockaddr *) &un, sizeof(un)) == -1) {
     rv = VNET_API_ERROR_SYSCALL_ERROR_2;
     goto error;
   }
@@ -1035,7 +1400,8 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm,
                               u8 is_server,
                               u32 * sw_if_index,
                               u64 feature_mask,
-                              u8 renumber, u32 custom_dev_instance)
+                              u8 renumber, u32 custom_dev_instance,
+                              u8 *hwaddr)
 {
   dpdk_main_t * dm = &dpdk_main;
   dpdk_device_t *xd;
@@ -1044,9 +1410,9 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm,
   int rv = 0;
 
   // using virtio vhost user?
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
       return vhost_user_create_if(vnm, vm, sock_filename, is_server,
-              sw_if_index, feature_mask, renumber, custom_dev_instance);
+              sw_if_index, feature_mask, renumber, custom_dev_instance, hwaddr);
   }
 
   if (is_server) {
@@ -1060,9 +1426,9 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm,
       if (custom_dev_instance >= dm->next_vu_if_id)
           dm->next_vu_if_id = custom_dev_instance + 1;
 
-    dpdk_create_vhost_user_if_internal(&hw_if_idx, custom_dev_instance);
+    dpdk_create_vhost_user_if_internal(&hw_if_idx, custom_dev_instance, hwaddr);
   } else 
-    dpdk_create_vhost_user_if_internal(&hw_if_idx, (u32)~0);
+    dpdk_create_vhost_user_if_internal(&hw_if_idx, (u32)~0, hwaddr);
   DBG_SOCK("dpdk vhost-user interface created hw_if_index %d", hw_if_idx);
 
   xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_idx);
@@ -1090,7 +1456,7 @@ int dpdk_vhost_user_modify_if(vnet_main_t * vnm, vlib_main_t * vm,
   int rv = 0;
 
   // using virtio vhost user?
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
       return vhost_user_modify_if(vnm, vm, sock_filename, is_server,
               sw_if_index, feature_mask, renumber, custom_dev_instance);
   }
@@ -1134,7 +1500,7 @@ int dpdk_vhost_user_delete_if(vnet_main_t * vnm, vlib_main_t * vm,
   int rv = 0;
 
   // using virtio vhost user?
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
       return vhost_user_delete_if(vnm, vm, sw_if_index);
   }
 
@@ -1176,7 +1542,7 @@ int dpdk_vhost_user_dump_ifs(vnet_main_t * vnm, vlib_main_t * vm, vhost_user_int
         return -1;
 
     // using virtio vhost user?
-    if (dm->use_virtio_vhost) {
+    if (dm->conf->use_virtio_vhost) {
         return vhost_user_dump_ifs(vnm, vm, out_vuids);
     }
 
@@ -1308,8 +1674,10 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
   u64 feature_mask = (u64)~0;
   u8 renumber = 0;
   u32 custom_dev_instance = ~0;
+  u8 hwaddr[6];
+  u8 *hw = NULL;
 
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
       return vhost_user_connect_command_fn(vm, input, cmd);
   }
 
@@ -1324,6 +1692,8 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
       is_server = 1;
     else if (unformat (line_input, "feature-mask 0x%llx", &feature_mask))
       ;
+    else if (unformat (line_input, "hwaddr %U", unformat_ethernet_address, hwaddr))
+      hw = hwaddr;
     else if (unformat (line_input, "renumber %d", &custom_dev_instance)) {
         renumber = 1;
     }
@@ -1339,9 +1709,10 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
 
   dpdk_vhost_user_create_if(vnm, vm, (char *)sock_filename,
                             is_server, &sw_if_index, feature_mask,
-                            renumber, custom_dev_instance);
+                            renumber, custom_dev_instance, hw);
 
   vec_free(sock_filename);
+  vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
   return 0;
 }
 
@@ -1361,7 +1732,7 @@ dpdk_vhost_user_delete_command_fn (vlib_main_t * vm,
   unformat_input_t _line_input, * line_input = &_line_input;
   u32 sw_if_index = ~0;
 
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
       return vhost_user_delete_command_fn(vm, input, cmd);
   }
 
@@ -1428,7 +1799,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
   { .str = NULL }
   };
 
-  if (dm->use_virtio_vhost) {
+  if (dm->conf->use_virtio_vhost) {
     return show_vhost_user_command_fn(vm, input, cmd);
   }
 
@@ -1454,7 +1825,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
 
   vlib_cli_output (vm, "DPDK vhost-user interfaces");
   vlib_cli_output (vm, "Global:\n  coalesce frames %d time %e\n\n",
-                   dm->vhost_coalesce_frames, dm->vhost_coalesce_time);
+                   dm->conf->vhost_coalesce_frames, dm->conf->vhost_coalesce_time);
 
   for (i = 0; i < vec_len (hw_if_indices); i++) {
     hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
@@ -1470,7 +1841,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
     u32 virtio_net_hdr_sz = (vui->num_vrings > 0 ?
             vhost_dev->virtqueue[0]->vhost_hlen : 0);
 
-    vlib_cli_output (vm, "Interface: %s (ifindex %d)",
+    vlib_cli_output (vm, "Interface: %v (ifindex %d)",
                          hi->name, hw_if_indices[i]);
 
     vlib_cli_output (vm, "virtio_net_hdr_sz %d\n features (0x%llx): \n",
@@ -1506,8 +1877,9 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
     }
     for (q = 0; q < vui->num_vrings; q++) {
       struct vhost_virtqueue *vq = vhost_dev->virtqueue[q];
+      const char *qtype = (q & 1) ? "TX" : "RX";
 
-      vlib_cli_output(vm, "\n Virtqueue %d\n", q);
+      vlib_cli_output(vm, "\n Virtqueue %d (%s)\n", q/2, qtype);
 
       vlib_cli_output(vm, "  qsz %d last_used_idx %d last_used_idx_res %d\n",
               vq->size, vq->last_used_idx, vq->last_used_idx_res);
@@ -1516,12 +1888,10 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
         vlib_cli_output(vm, "  avail.flags %x avail.idx %d used.flags %x used.idx %d\n",
           vq->avail->flags, vq->avail->idx, vq->used->flags, vq->used->idx);
 
-      vlib_cli_output(vm, "  kickfd %d callfd %d errfd %d\n",
-        vui->vrings[q].kickfd,
-        vui->vrings[q].callfd,
-        vui->vrings[q].errfd);
+      vlib_cli_output(vm, "  kickfd %d callfd %d errfd %d enabled %d\n",
+        vq->kickfd, vq->callfd, vui->vrings[q].errfd, vq->enabled);
 
-      if (show_descr) {
+      if (show_descr && vq->enabled) {
         vlib_cli_output(vm, "\n  descriptor table:\n");
         vlib_cli_output(vm, "   id          addr         len  flags  next      user_addr\n");
         vlib_cli_output(vm, "  ===== ================== ===== ====== ===== ==================\n");
@@ -1532,7 +1902,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
             vq->desc[j].len,
             vq->desc[j].flags,
             vq->desc[j].next,
-            (u64) map_guest_mem(xd, vq->desc[j].addr));}
+            pointer_to_uword(map_guest_mem(xd, vq->desc[j].addr)));}
       }
     }
     vlib_cli_output (vm, "\n");
@@ -1547,4 +1917,4 @@ VLIB_CLI_COMMAND (show_vhost_user_command, static) = {
     .short_help = "show vhost-user interface",
     .function = show_dpdk_vhost_user_command_fn,
 };
-
+#endif