vhost-user: Interface state updates
[vpp.git] / src / vnet / devices / virtio / vhost_user_output.c
index f400f18..f4d1c2c 100644 (file)
@@ -223,11 +223,9 @@ vhost_user_tx_copy (vhost_user_intf_t * vui, vhost_copy_t * cpy,
   return 0;
 }
 
-
-uword
-CLIB_MULTIARCH_FN (vhost_user_tx) (vlib_main_t * vm,
-                                  vlib_node_runtime_t * node,
-                                  vlib_frame_t * frame)
+VNET_DEVICE_CLASS_TX_FN (vhost_user_device_class) (vlib_main_t * vm,
+                                                  vlib_node_runtime_t *
+                                                  node, vlib_frame_t * frame)
 {
   u32 *buffers = vlib_frame_args (frame);
   u32 n_left = frame->n_vectors;
@@ -238,7 +236,7 @@ CLIB_MULTIARCH_FN (vhost_user_tx) (vlib_main_t * vm,
   u32 qid = ~0;
   vhost_user_vring_t *rxvq;
   u8 error;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 map_hint = 0;
   u8 retry = 8;
   u16 copy_len;
@@ -250,7 +248,7 @@ CLIB_MULTIARCH_FN (vhost_user_tx) (vlib_main_t * vm,
       goto done3;
     }
 
-  if (PREDICT_FALSE (!vui->is_up))
+  if (PREDICT_FALSE (!vui->is_ready))
     {
       error = VHOST_USER_TX_FUNC_ERROR_NOT_READY;
       goto done3;
@@ -623,20 +621,24 @@ vhost_user_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
   vhost_user_main_t *vum = &vhost_user_main;
   vhost_user_intf_t *vui =
     pool_elt_at_index (vum->vhost_user_interfaces, hif->dev_instance);
-  u32 hw_flags = 0;
+  u8 link_old, link_new;
+
+  link_old = vui_is_link_up (vui);
+
   vui->admin_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
-  hw_flags = vui->admin_up ? VNET_HW_INTERFACE_FLAG_LINK_UP : 0;
 
-  vnet_hw_interface_set_flags (vnm, vui->hw_if_index, hw_flags);
+  link_new = vui_is_link_up (vui);
+
+  if (link_old != link_new)
+    vnet_hw_interface_set_flags (vnm, vui->hw_if_index, link_new ?
+                                VNET_HW_INTERFACE_FLAG_LINK_UP : 0);
 
   return /* no error */ 0;
 }
 
-#ifndef CLIB_MARCH_VARIANT
 /* *INDENT-OFF* */
 VNET_DEVICE_CLASS (vhost_user_device_class) = {
   .name = "vhost-user",
-  .tx_function = vhost_user_tx,
   .tx_function_n_errors = VHOST_USER_TX_FUNC_N_ERROR,
   .tx_function_error_strings = vhost_user_tx_func_error_strings,
   .format_device_name = format_vhost_user_interface_name,
@@ -646,20 +648,6 @@ VNET_DEVICE_CLASS (vhost_user_device_class) = {
   .format_tx_trace = format_vhost_trace,
 };
 
-#if __x86_64__
-vlib_node_function_t __clib_weak vhost_user_tx_avx512;
-vlib_node_function_t __clib_weak vhost_user_tx_avx2;
-static void __clib_constructor
-vhost_user_tx_multiarch_select (void)
-{
-  if (vhost_user_tx_avx512 && clib_cpu_supports_avx512f ())
-    vhost_user_device_class.tx_function = vhost_user_tx_avx512;
-  else if (vhost_user_tx_avx2 && clib_cpu_supports_avx2 ())
-    vhost_user_device_class.tx_function = vhost_user_tx_avx2;
-}
-#endif
-#endif
-
 /* *INDENT-ON* */
 
 /*