Add DPDK 16.07 support (rc3 based)
[vpp.git] / vnet / vnet / devices / dpdk / device.c
index c53d22b..66d4b6d 100644 (file)
@@ -355,6 +355,7 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
               n_retry = (rv == DPDK_TX_RING_SIZE - tx_tail) ? 1 : 0;
             }
         } 
+#if DPDK_VHOST_USER
       else if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER)
         {
           u32 offset = 0;
@@ -362,7 +363,6 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
             queue_id = 0;
             while (__sync_lock_test_and_set (xd->lockp[queue_id], 1));
           }
-#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
           else {
               dpdk_device_and_queue_t * dq;
               vec_foreach (dq, dm->devices_by_cpu[vm->cpu_index])
@@ -373,7 +373,6 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
               assert (dq);
               offset = dq->queue_id * VIRTIO_QNUM;
           }
-#endif
           if (PREDICT_TRUE(tx_head > tx_tail)) 
             {
               int i; u32 bytes = 0;
@@ -399,7 +398,7 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
 
                     f64 now = vlib_time_now (vm);
                     if (vring->int_deadline < now ||
-                        vring->n_since_last_int > dm->vhost_coalesce_frames)
+                        vring->n_since_last_int > dm->conf->vhost_coalesce_frames)
                       dpdk_vhost_user_send_interrupt(vm, xd, offset + VIRTIO_RXQ);
                   }
 
@@ -437,7 +436,7 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
 
                     f64 now = vlib_time_now (vm);
                     if (vring->int_deadline < now ||
-                        vring->n_since_last_int > dm->vhost_coalesce_frames)
+                        vring->n_since_last_int > dm->conf->vhost_coalesce_frames)
                       dpdk_vhost_user_send_interrupt(vm, xd, offset + VIRTIO_RXQ);
                   }
 
@@ -452,6 +451,7 @@ u32 tx_burst_vector_internal (vlib_main_t * vm,
           if (xd->need_txlock)
             *xd->lockp[queue_id] = 0;
         }
+#endif
 #if RTE_LIBRTE_KNI
       else if (xd->dev_type == VNET_DPDK_DEV_KNI)
         {
@@ -672,10 +672,12 @@ dpdk_interface_tx (vlib_main_t * vm,
       mb0 = rte_mbuf_from_vlib_buffer(b0);
       mb1 = rte_mbuf_from_vlib_buffer(b1);
 
-      any_clone = b0->clone_count | b1->clone_count;
+      any_clone = (b0->flags & VLIB_BUFFER_RECYCLE)
+          | (b1->flags & VLIB_BUFFER_RECYCLE);
       if (PREDICT_FALSE(any_clone != 0))
         {
-          if (PREDICT_FALSE(b0->clone_count != 0))
+            if (PREDICT_FALSE
+                ((b0->flags & VLIB_BUFFER_RECYCLE) != 0))
            {
              struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0);
              if (PREDICT_FALSE(mb0_new == 0))
@@ -688,7 +690,8 @@ dpdk_interface_tx (vlib_main_t * vm,
                mb0 = mb0_new;
              vec_add1 (dm->recycle[my_cpu], bi0);
            }
-          if (PREDICT_FALSE(b1->clone_count != 0))
+          if (PREDICT_FALSE
+              ((b1->flags & VLIB_BUFFER_RECYCLE) != 0))
            {
              struct rte_mbuf * mb1_new = dpdk_replicate_packet_mb (b1);
              if (PREDICT_FALSE(mb1_new == 0))
@@ -772,7 +775,7 @@ dpdk_interface_tx (vlib_main_t * vm,
       b0 = vlib_get_buffer (vm, bi0);
 
       mb0 = rte_mbuf_from_vlib_buffer(b0);
-      if (PREDICT_FALSE(b0->clone_count != 0))
+      if (PREDICT_FALSE((b0->flags & VLIB_BUFFER_RECYCLE) != 0))
        {
          struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0);
          if (PREDICT_FALSE(mb0_new == 0))
@@ -877,6 +880,7 @@ dpdk_interface_tx (vlib_main_t * vm,
 static int dpdk_device_renumber (vnet_hw_interface_t * hi,
                                  u32 new_dev_instance)
 {
+#if DPDK_VHOST_USER
   dpdk_main_t * dm = &dpdk_main;
   dpdk_device_t * xd = vec_elt_at_index (dm->devices, hi->dev_instance);
 
@@ -887,6 +891,7 @@ static int dpdk_device_renumber (vnet_hw_interface_t * hi,
   }
 
   xd->vu_if_id = new_dev_instance;
+#endif
   return 0;
 }
 
@@ -925,6 +930,7 @@ static void dpdk_clear_hw_interface_counters (u32 instance)
       memset (&xd->last_stats, 0, sizeof (xd->last_stats));
     }
 
+#if DPDK_VHOST_USER
   if (PREDICT_FALSE(xd->dev_type == VNET_DPDK_DEV_VHOST_USER)) {
     int i;
     for (i = 0; i < xd->rx_q_used * VIRTIO_QNUM; i++) {
@@ -932,6 +938,7 @@ static void dpdk_clear_hw_interface_counters (u32 instance)
       xd->vu_intf->vrings[i].bytes = 0;
     }
   }
+#endif
 }
 
 #ifdef RTE_LIBRTE_KNI
@@ -1026,6 +1033,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
       return 0;
   }
 #endif
+#if DPDK_VHOST_USER
   if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER)
     {
       if (is_up)
@@ -1044,6 +1052,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
 
       return 0;
     }
+#endif
 
 
   if (is_up)
@@ -1093,6 +1102,18 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
        */
       if (xd->pmd != VNET_DPDK_PMD_VMXNET3)
          rte_eth_dev_stop (xd->device_index);
+
+      /* For bonded interface, stop slave links */
+      if (xd->pmd == VNET_DPDK_PMD_BOND) 
+        {
+         u8  slink[16];
+         int nlink = rte_eth_bond_slaves_get(xd->device_index, slink, 16);
+         while (nlink >=1) 
+           {
+             u8 dpdk_port = slink[--nlink];
+             rte_eth_dev_stop (dpdk_port);
+           }
+        }
     }
 
   if (rv < 0)
@@ -1136,7 +1157,10 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
   dpdk_device_t * xd = vec_elt_at_index (xm->devices, hw->dev_instance);
   vnet_sw_interface_t * t = (vnet_sw_interface_t *) st;
   int r, vlan_offload;
+  u32 prev_subifs = xd->vlan_subifs;
 
+  if (is_add) xd->vlan_subifs++;
+  else if (xd->vlan_subifs) xd->vlan_subifs--;
 
   if (xd->dev_type != VNET_DPDK_DEV_ETH)
         return 0;
@@ -1149,21 +1173,26 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
   if (t->sub.eth.flags.no_tags == 1)
         return 0;
 
-  if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1 ))
+  if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1 )) {
+        xd->vlan_subifs = prev_subifs;
         return clib_error_return (0, "unsupported VLAN setup");
-
+  }
 
   vlan_offload = rte_eth_dev_get_vlan_offload(xd->device_index);
   vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
 
-  if ((r = rte_eth_dev_set_vlan_offload(xd->device_index, vlan_offload)))
+  if ((r = rte_eth_dev_set_vlan_offload(xd->device_index, vlan_offload))) {
+        xd->vlan_subifs = prev_subifs;
         return clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
                                   xd->device_index, r);
+  }
 
 
-  if ((r = rte_eth_dev_vlan_filter(xd->device_index, t->sub.eth.outer_vlan_id, is_add)))
+  if ((r = rte_eth_dev_vlan_filter(xd->device_index, t->sub.eth.outer_vlan_id, is_add))) {
+        xd->vlan_subifs = prev_subifs;
         return clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
                                  xd->device_index, r);
+  }
 
   return 0;
 }
@@ -1297,17 +1326,7 @@ u32 dpdk_num_mbufs (void)
 {
   dpdk_main_t * dm = &dpdk_main;
 
-  return dm->num_mbufs;
-}
-
-/*
- * Return the io_thread_release
- */
-int dpdk_io_thread_release (void)
-{
-  dpdk_main_t * dm = &dpdk_main;
-
-  return dm->io_thread_release;
+  return dm->conf->num_mbufs;
 }
 
 /*