diff options
-rw-r--r-- | src/plugins/avf/input.c | 2 | ||||
-rw-r--r-- | src/plugins/avf/output.c | 2 | ||||
-rw-r--r-- | src/plugins/marvell/pp2/output.c | 2 | ||||
-rw-r--r-- | src/vlib/buffer_funcs.h | 10 | ||||
-rw-r--r-- | src/vlib/buffer_node.h | 12 | ||||
-rw-r--r-- | src/vnet/pg/input.c | 7 |
6 files changed, 20 insertions, 15 deletions
diff --git a/src/plugins/avf/input.c b/src/plugins/avf/input.c index b784bf731c1..fc884ce39f6 100644 --- a/src/plugins/avf/input.c +++ b/src/plugins/avf/input.c @@ -295,7 +295,7 @@ avf_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, or_q1x4 |= q1x4; u64x4_store_unaligned (q1x4, ptd->qw1s + n_rx_packets); - clib_memcpy_fast (bi, rxq->bufs + next, 4 * sizeof (u32)); + vlib_buffer_copy_indices (bi, rxq->bufs + next, 4); /* next */ next = (next + 4) & mask; diff --git a/src/plugins/avf/output.c b/src/plugins/avf/output.c index 0db333be823..47803fc2729 100644 --- a/src/plugins/avf/output.c +++ b/src/plugins/avf/output.c @@ -66,7 +66,7 @@ avf_tx_enqueue (vlib_main_t * vm, avf_txq_t * txq, u32 * buffers, if (or_flags & VLIB_BUFFER_NEXT_PRESENT) goto one_by_one; - clib_memcpy_fast (txq->bufs + next, buffers, sizeof (u32) * 4); + vlib_buffer_copy_indices (txq->bufs + next, buffers, 4); if (use_va_dma) { diff --git a/src/plugins/marvell/pp2/output.c b/src/plugins/marvell/pp2/output.c index dbd106a5930..911b2f55a17 100644 --- a/src/plugins/marvell/pp2/output.c +++ b/src/plugins/marvell/pp2/output.c @@ -101,7 +101,7 @@ mrvl_pp2_interface_tx (vlib_main_t * vm, buffers = vlib_frame_vector_args (frame); u16 n_copy = clib_min (outq->size - slot, n_sent); - clib_memcpy_fast (outq->buffers + slot, buffers, n_copy * sizeof (u32)); + vlib_buffer_copy_indices (outq->buffers + slot, buffers, n_copy); if (PREDICT_FALSE (n_copy < n_sent)) clib_memcpy_fast (outq->buffers, buffers + n_copy, (n_sent - n_copy) * sizeof (u32)); diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 8fbb58d68b3..f5781c8b173 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -65,6 +65,12 @@ vlib_get_buffer (vlib_main_t * vm, u32 buffer_index) } static_always_inline void +vlib_buffer_copy_indices (u32 * dst, u32 * src, u32 n_indices) +{ + clib_memcpy_fast (dst, src, n_indices * sizeof (u32)); +} + +static_always_inline void vlib_buffer_copy_template (vlib_buffer_t * b, vlib_buffer_t * bt) { clib_memcpy_fast (b, bt, STRUCT_OFFSET_OF (vlib_buffer_t, template_end)); @@ -454,7 +460,7 @@ vlib_buffer_alloc_from_free_list (vlib_main_t * vm, /* following code is intentionaly duplicated to allow compiler to optimize fast path when n_buffers is constant value */ src = fl->buffers + len - n_buffers; - clib_memcpy_fast (buffers, src, n_buffers * sizeof (u32)); + vlib_buffer_copy_indices (buffers, src, n_buffers); _vec_len (fl->buffers) -= n_buffers; /* Verify that buffers are known free. */ @@ -465,7 +471,7 @@ vlib_buffer_alloc_from_free_list (vlib_main_t * vm, } src = fl->buffers + len - n_buffers; - clib_memcpy_fast (buffers, src, n_buffers * sizeof (u32)); + vlib_buffer_copy_indices (buffers, src, n_buffers); _vec_len (fl->buffers) -= n_buffers; /* Verify that buffers are known free. */ diff --git a/src/vlib/buffer_node.h b/src/vlib/buffer_node.h index 2163b72de5e..7e488783fc5 100644 --- a/src/vlib/buffer_node.h +++ b/src/vlib/buffer_node.h @@ -383,7 +383,7 @@ vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node, #ifdef CLIB_HAVE_VEC512 if (n_enqueued >= 32) { - clib_memcpy_fast (to_next, buffers, 32 * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, 32); nexts += 32; to_next += 32; buffers += 32; @@ -397,7 +397,7 @@ vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node, #ifdef CLIB_HAVE_VEC256 if (n_enqueued >= 16) { - clib_memcpy_fast (to_next, buffers, 16 * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, 16); nexts += 16; to_next += 16; buffers += 16; @@ -411,7 +411,7 @@ vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node, #ifdef CLIB_HAVE_VEC128 if (n_enqueued >= 8) { - clib_memcpy_fast (to_next, buffers, 8 * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, 8); nexts += 8; to_next += 8; buffers += 8; @@ -424,7 +424,7 @@ vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node, if (n_enqueued >= 4) { - clib_memcpy_fast (to_next, buffers, 4 * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, 4); nexts += 4; to_next += 4; buffers += 4; @@ -459,7 +459,7 @@ vlib_buffer_enqueue_to_single_next (vlib_main_t * vm, if (PREDICT_TRUE (n_left_to_next >= count)) { - clib_memcpy_fast (to_next, buffers, count * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, count); n_left_to_next -= count; vlib_put_next_frame (vm, node, next_index, n_left_to_next); return; @@ -467,7 +467,7 @@ vlib_buffer_enqueue_to_single_next (vlib_main_t * vm, n_enq = n_left_to_next; next: - clib_memcpy_fast (to_next, buffers, n_enq * sizeof (u32)); + vlib_buffer_copy_indices (to_next, buffers, n_enq); n_left_to_next -= n_enq; if (PREDICT_FALSE (count > n_enq)) diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c index 792c67cd88d..6088b91271e 100644 --- a/src/vnet/pg/input.c +++ b/src/vnet/pg/input.c @@ -1590,13 +1590,12 @@ pg_generate_packets (vlib_node_runtime_t * node, head = clib_fifo_head (bi0->buffer_fifo); if (head + n_this_frame <= end) - clib_memcpy_fast (to_next, head, n_this_frame * sizeof (u32)); + vlib_buffer_copy_indices (to_next, head, n_this_frame); else { u32 n = end - head; - clib_memcpy_fast (to_next + 0, head, n * sizeof (u32)); - clib_memcpy_fast (to_next + n, start, - (n_this_frame - n) * sizeof (u32)); + vlib_buffer_copy_indices (to_next + 0, head, n); + vlib_buffer_copy_indices (to_next + n, start, n_this_frame - n); } if (s->replay_packet_templates == 0) |