Remove c-11 memcpy checks from perf-critical code
[vpp.git] / src / vnet / devices / virtio / vhost_user_output.c
index 8205949..58db1a9 100644 (file)
@@ -205,8 +205,8 @@ vhost_user_tx_copy (vhost_user_intf_t * vui, vhost_copy_t * cpy,
          CLIB_PREFETCH ((void *) cpy[2].src, 64, LOAD);
          CLIB_PREFETCH ((void *) cpy[3].src, 64, LOAD);
 
-         clib_memcpy (dst0, (void *) cpy[0].src, cpy[0].len);
-         clib_memcpy (dst1, (void *) cpy[1].src, cpy[1].len);
+         clib_memcpy_fast (dst0, (void *) cpy[0].src, cpy[0].len);
+         clib_memcpy_fast (dst1, (void *) cpy[1].src, cpy[1].len);
 
          vhost_user_log_dirty_pages_2 (vui, cpy[0].dst, cpy[0].len, 1);
          vhost_user_log_dirty_pages_2 (vui, cpy[1].dst, cpy[1].len, 1);
@@ -218,7 +218,7 @@ vhost_user_tx_copy (vhost_user_intf_t * vui, vhost_copy_t * cpy,
     {
       if (PREDICT_FALSE (!(dst0 = map_guest_mem (vui, cpy->dst, map_hint))))
        return 1;
-      clib_memcpy (dst0, (void *) cpy->src, cpy->len);
+      clib_memcpy_fast (dst0, (void *) cpy->src, cpy->len);
       vhost_user_log_dirty_pages_2 (vui, cpy->dst, cpy->len, 1);
       copy_len -= 1;
       cpy += 1;
@@ -230,7 +230,7 @@ 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 *buffers = vlib_frame_vector_args (frame);
   u32 n_left = frame->n_vectors;
   vhost_user_main_t *vum = &vhost_user_main;
   vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
@@ -261,6 +261,12 @@ VNET_DEVICE_CLASS_TX_FN (vhost_user_device_class) (vlib_main_t * vm,
     VHOST_VRING_IDX_RX (*vec_elt_at_index
                        (vui->per_cpu_tx_qid, thread_index));
   rxvq = &vui->vrings[qid];
+  if (PREDICT_FALSE (rxvq->avail == 0))
+    {
+      error = VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL;
+      goto done3;
+    }
+
   if (PREDICT_FALSE (vui->use_tx_spinlock))
     vhost_user_vring_lock (vui, qid);
 
@@ -549,7 +555,7 @@ done3:
         thread_index, vui->sw_if_index, n_left);
     }
 
-  vlib_buffer_free (vm, vlib_frame_args (frame), frame->n_vectors);
+  vlib_buffer_free (vm, vlib_frame_vector_args (frame), frame->n_vectors);
   return frame->n_vectors;
 }