From 9a8a12a06e9e67c4ef339d3002cdc5151341826d Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 23 Jan 2019 16:52:10 +0100 Subject: buffers: wrap vlib_buffer_t to union and expose vector types Change-Id: I1c12e2941cae198ededbb65eb5be51a4eabe2c1b Signed-off-by: Damjan Marion --- src/vlib/buffer_funcs.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/vlib/buffer_funcs.h') diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 60eb8cde09a..c2241476094 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -70,10 +70,21 @@ vlib_buffer_copy_indices (u32 * dst, u32 * src, u32 n_indices) clib_memcpy_fast (dst, src, n_indices * sizeof (u32)); } +STATIC_ASSERT_OFFSET_OF (vlib_buffer_t, template_end, 64); 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)); +#if defined CLIB_HAVE_VEC256 + b->as_u8x32[0] = bt->as_u8x32[0]; + b->as_u8x32[1] = bt->as_u8x32[1]; +#elif defined (CLIB_HAVE_VEC128) + b->as_u8x16[0] = bt->as_u8x16[0]; + b->as_u8x16[1] = bt->as_u8x16[1]; + b->as_u8x16[2] = bt->as_u8x16[2]; + b->as_u8x16[3] = bt->as_u8x16[3]; +#else + clib_memcpy_fast (b, bt, 64); +#endif } /** \brief Translate array of buffer indices into buffer pointers with offset -- cgit 1.2.3-korg