Remove c-11 memcpy checks from perf-critical code
[vpp.git] / src / vnet / devices / virtio / vhost_user_input.c
index 3db4473..32b924f 100644 (file)
@@ -101,7 +101,7 @@ vhost_user_rx_trace (vhost_trace_t * t,
   virtio_net_hdr_mrg_rxbuf_t *hdr;
   u32 hint = 0;
 
-  memset (t, 0, sizeof (*t));
+  clib_memset (t, 0, sizeof (*t));
   t->device_index = vui - vum->vhost_user_interfaces;
   t->qid = qid;
 
@@ -162,8 +162,8 @@ vhost_user_input_copy (vhost_user_intf_t * vui, vhost_copy_t * cpy,
          CLIB_PREFETCH (src2, 64, LOAD);
          CLIB_PREFETCH (src3, 64, LOAD);
 
-         clib_memcpy ((void *) cpy[0].dst, src0, cpy[0].len);
-         clib_memcpy ((void *) cpy[1].dst, src1, cpy[1].len);
+         clib_memcpy_fast ((void *) cpy[0].dst, src0, cpy[0].len);
+         clib_memcpy_fast ((void *) cpy[1].dst, src1, cpy[1].len);
          copy_len -= 2;
          cpy += 2;
        }
@@ -172,7 +172,7 @@ vhost_user_input_copy (vhost_user_intf_t * vui, vhost_copy_t * cpy,
     {
       if (PREDICT_FALSE (!(src0 = map_guest_mem (vui, cpy->src, map_hint))))
        return 1;
-      clib_memcpy ((void *) cpy->dst, src0, cpy->len);
+      clib_memcpy_fast ((void *) cpy->dst, src0, cpy->len);
       copy_len -= 1;
       cpy += 1;
     }
@@ -256,9 +256,13 @@ vhost_user_if_input (vlib_main_t * vm,
   u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
   u32 n_trace = vlib_get_trace_count (vm, node);
   u32 map_hint = 0;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   u16 copy_len = 0;
 
+  /* The descriptor table is not ready yet */
+  if (PREDICT_FALSE (txvq->avail == 0))
+    return 0;
+
   {
     /* do we have pending interrupts ? */
     vhost_user_vring_t *rxvq = &vui->vrings[VHOST_VRING_IDX_RX (qid)];
@@ -637,8 +641,8 @@ VLIB_NODE_FN (vhost_user_input_node) (vlib_main_t * vm,
 
   vec_foreach (dq, rt->devices_and_queues)
   {
-    if (clib_smp_swap (&dq->interrupt_pending, 0) ||
-       (node->state == VLIB_NODE_STATE_POLLING))
+    if ((node->state == VLIB_NODE_STATE_POLLING) ||
+       clib_atomic_swap_acq_n (&dq->interrupt_pending, 0))
       {
        vui =
          pool_elt_at_index (vum->vhost_user_interfaces, dq->dev_instance);
@@ -650,7 +654,6 @@ VLIB_NODE_FN (vhost_user_input_node) (vlib_main_t * vm,
   return n_rx_packets;
 }
 
-#ifndef CLIB_MARCH_VARIANT
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (vhost_user_input_node) = {
   .type = VLIB_NODE_TYPE_INPUT,
@@ -667,7 +670,6 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = {
   .error_strings = vhost_user_input_func_error_strings,
 };
 /* *INDENT-ON* */
-#endif
 
 /*
  * fd.io coding-style-patch-verification: ON