|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
79 u64 *x = va_arg (*va,
u64 *);
89 u32 *x = va_arg (*va,
u32 *);
96 u16 *x = va_arg (*va,
u16 *);
105 u8 *x = va_arg (*va,
u8 *);
114 f64 x = va_arg (*va,
f64);
127 f32 x = va_arg (*va,
f64);
140 f64 *x = va_arg (*va,
f64 *);
153 f32 *x = va_arg (*va,
f32 *);
166 u32 len = s ? strlen (s) : 0;
190 if (
len > 0 &&
len != 0xFFFFFFFF)
206 u8 *s = va_arg (*va,
u8 *);
207 u32 n = va_arg (*va,
u32);
215 u8 *s = va_arg (*va,
u8 *);
216 u32 n = va_arg (*va,
u32);
222 void serialize_vec_##n_bits (serialize_main_t * m, va_list * va) \
224 u##n_bits * s = va_arg (*va, u##n_bits *); \
225 u32 n = va_arg (*va, u32); \
226 u##n_bits * p = serialize_get (m, n * sizeof (s[0])); \
230 p[0] = clib_host_to_net_u##n_bits (s[0]); \
231 p[1] = clib_host_to_net_u##n_bits (s[1]); \
232 p[2] = clib_host_to_net_u##n_bits (s[2]); \
233 p[3] = clib_host_to_net_u##n_bits (s[3]); \
241 p[0] = clib_host_to_net_u##n_bits (s[0]); \
248 void unserialize_vec_##n_bits (serialize_main_t * m, va_list * va) \
250 u##n_bits * s = va_arg (*va, u##n_bits *); \
251 u32 n = va_arg (*va, u32); \
252 u##n_bits * p = unserialize_get (m, n * sizeof (s[0])); \
256 s[0] = clib_net_to_host_mem_u##n_bits (&p[0]); \
257 s[1] = clib_net_to_host_mem_u##n_bits (&p[1]); \
258 s[2] = clib_net_to_host_mem_u##n_bits (&p[2]); \
259 s[3] = clib_net_to_host_mem_u##n_bits (&p[3]); \
267 s[0] = clib_net_to_host_mem_u##n_bits (&p[0]); \
280 #define SERIALIZE_VECTOR_CHUNK_SIZE 64
285 void *vec = va_arg (*va,
void *);
286 u32 elt_bytes = va_arg (*va,
u32);
316 p = v = _vec_resize ((
void *) 0, l, (
uword) l * elt_bytes, header_bytes,
332 void **vec = va_arg (*va,
void **);
333 u32 elt_bytes = va_arg (*va,
u32);
335 u32 align = va_arg (*va,
u32);
347 void **vec = va_arg (*va,
void **);
348 u32 elt_bytes = va_arg (*va,
u32);
364 n_u32s = l *
sizeof (
b[0]) /
sizeof (
u32);
368 for (
i = 0;
i < l;
i++)
386 i = (n_u32s *
sizeof (
u32) +
sizeof (
b[0]) - 1) /
sizeof (
b[0]);
388 for (
i = 0;
i < n_u32s;
i++)
413 void *pool = va_arg (*va,
void *);
414 u32 elt_bytes = va_arg (*va,
u32);
447 v = _vec_resize ((
void *) 0, l, (
uword) l * elt_bytes,
sizeof (p[0]),
467 void **result = va_arg (*va,
void **);
468 u32 elt_bytes = va_arg (*va,
u32);
476 void **result = va_arg (*va,
void **);
477 u32 elt_bytes = va_arg (*va,
u32);
478 u32 align = va_arg (*va,
u32);
488 for (
i = 0;
i < n;
i++)
501 for (
i = 0;
i < n;
i++)
512 void *heap = va_arg (*va,
void *);
524 #define foreach_serialize_heap_header_integer \
525 _ (head) _ (tail) _ (used_count) _ (max_len) _ (flags) _ (elt_bytes)
527 #define _(f) serialize_integer (m, h->f, sizeof (h->f));
542 e =
h->elts +
h->head;
543 end =
h->elts +
h->tail;
562 void **result = va_arg (*va,
void **);
576 #define _(f) unserialize_integer (m, &h.f, sizeof (h.f));
597 h.used_elt_bitmap = clib_bitmap_ori (
h.used_elt_bitmap, e -
h.elts);
601 heap = *result = _heap_new (
vl,
h.elt_bytes);
608 end =
h.elts +
h.tail;
640 if (l != magic_bytes)
646 if (memcmp (magic, d, magic_bytes))
700 uword cur_bi, n_left_b, n_left_o;
710 if (n_left_o > 0 && n_left_b > 0)
734 while (n_left_o > 0);
736 if (n_left_o > 0 || n_left_b < n_bytes_to_write)
745 return s->
buffer + cur_bi;
754 uword cur_bi, cur_oi, n_left_b, n_left_o, n_left_to_read;
765 if (n_left_o >= n_bytes_to_read)
778 n_left_to_read = n_bytes_to_read;
779 while (n_left_to_read > 0)
785 if (n_left_o + n_left_b < n_bytes_to_read)
791 n_left_o += n_left_b;
792 n_left_to_read -= n_left_b;
810 && n_left_to_read == n_bytes_to_read && n_left_b >= n_left_to_read)
813 return s->
buffer + cur_bi;
821 n_left_o += n_left_to_read;
827 n =
clib_min (n_left_to_read, n_left_b);
944 p[0] = d[0 * data_stride];
945 p[1] = d[1 * data_stride];
946 p[2] = d[2 * data_stride];
947 p[3] = d[3 * data_stride];
949 d += 4 * data_stride;
959 d += 1 * data_stride;
977 clib_host_to_net_mem_u16 (d + 0 * data_stride);
979 clib_host_to_net_mem_u16 (d + 1 * data_stride);
981 clib_host_to_net_mem_u16 (d + 2 * data_stride);
983 clib_host_to_net_mem_u16 (d + 3 * data_stride);
985 d += 4 * data_stride;
994 clib_host_to_net_mem_u16 (d + 0 * data_stride);
996 d += 1 * data_stride;
1014 clib_host_to_net_mem_u32 (d + 0 * data_stride);
1016 clib_host_to_net_mem_u32 (d + 1 * data_stride);
1018 clib_host_to_net_mem_u32 (d + 2 * data_stride);
1020 clib_host_to_net_mem_u32 (d + 3 * data_stride);
1022 d += 4 * data_stride;
1031 clib_host_to_net_mem_u32 (d + 0 * data_stride);
1033 d += 1 * data_stride;
1050 d[0 * data_stride] = p[0];
1051 d[1 * data_stride] = p[1];
1052 d[2 * data_stride] = p[2];
1053 d[3 * data_stride] = p[3];
1055 d += 4 * data_stride;
1065 d += 1 * data_stride;
1083 clib_net_to_host_mem_u16 (p + 0);
1085 clib_net_to_host_mem_u16 (p + 1);
1087 clib_net_to_host_mem_u16 (p + 2);
1089 clib_net_to_host_mem_u16 (p + 3);
1091 d += 4 * data_stride;
1100 clib_net_to_host_mem_u16 (p + 0);
1102 d += 1 * data_stride;
1120 clib_net_to_host_mem_u32 (p + 0);
1122 clib_net_to_host_mem_u32 (p + 1);
1124 clib_net_to_host_mem_u32 (p + 2);
1126 clib_net_to_host_mem_u32 (p + 3);
1128 d += 4 * data_stride;
1137 clib_net_to_host_mem_u32 (p + 0);
1139 d += 1 * data_stride;
1165 _vec_len (s->
buffer) = 0;
1226 mode = is_read ? O_RDONLY : O_RDWR | O_CREAT | O_TRUNC;
1227 fd = open (file,
mode, 0666);
void unserialize_32(serialize_main_t *m, va_list *va)
void unserialize_f32(serialize_main_t *m, va_list *va)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
__clib_export void unserialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static void serialize_vec_heap_elt(serialize_main_t *m, va_list *va)
__clib_export void unserialize_vector(serialize_main_t *m, va_list *va)
void unserialize_8(serialize_main_t *m, va_list *va)
serialize_main_header_t header
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
__clib_export void serialize_vector(serialize_main_t *m, va_list *va)
__clib_export clib_error_t * unserialize(serialize_main_t *m,...)
static void serialize_stream_set_end_of_stream(serialize_stream_t *s)
void serialize_f64(serialize_main_t *m, va_list *va)
static word unix_error_is_fatal(word error)
static uword serialize_stream_is_end_of_stream(serialize_stream_t *s)
void() serialize_function_t(serialize_main_t *m, va_list *va)
uword clib_setjmp(clib_longjmp_t *save, uword return_value_not_taken)
static void * serialize_write_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes_to_write, uword flags)
vl_api_tunnel_mode_t mode
__clib_export void serialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
#define SERIALIZE_FLAG_IS_WRITE
static void * unserialize_get(serialize_main_t *m, uword n_bytes)
#define vec_serialize(m, v, f)
static uword heap_offset(heap_elt_t *e)
__clib_export void serialize_open_vector(serialize_main_t *m, u8 *vector)
__clib_export void unserialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
vnet_hw_if_output_node_runtime_t * r
void unserialize_16(serialize_main_t *m, va_list *va)
void unserialize_aligned_pool(serialize_main_t *m, va_list *va)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void serialize_error(serialize_main_header_t *m, clib_error_t *error)
#define pool_foreach_region(LO, HI, POOL, BODY)
Optimized iteration through pool.
static heap_header_t * heap_header(void *v)
__clib_export clib_error_t * serialize_open_clib_file(serialize_main_t *m, char *file)
#define clib_error_create(args...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void serialize_64(serialize_main_t *m, va_list *va)
__clib_export clib_error_t * serialize(serialize_main_t *m,...)
static uword heap_elt_size(void *v, heap_elt_t *e)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
uword * unserialize_bitmap(serialize_main_t *m)
static void clib_file_read(serialize_main_header_t *m, serialize_stream_t *s)
__clib_export clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
void serialize_heap(serialize_main_t *m, va_list *va)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define SERIALIZE_VECTOR_CHUNK_SIZE
#define SERIALIZE_FLAG_IS_READ
f64 end
end of the time range
void unserialize_check_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
void serialize_f32(serialize_main_t *m, va_list *va)
static void serialize_likely_small_unsigned_integer(serialize_main_t *m, u64 x)
__clib_export void * serialize_read_write_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes, uword flags)
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
serialize_function_t serialize_vec_32
void serialize_vec_8(serialize_main_t *m, va_list *va)
#define clib_mem_unaligned(pointer, type)
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
static void * unserialize_pool_helper(serialize_main_t *m, u32 elt_bytes, u32 align, serialize_function_t *f)
u32 current_overflow_index
void serialize_8(serialize_main_t *m, va_list *va)
serialize_stream_t stream
__clib_export void serialize_close(serialize_main_t *m)
#define vec_unserialize(m, v, f)
static void serialize_read_write_close(serialize_main_header_t *m, serialize_stream_t *s, uword flags)
__clib_export void serialize_cstring(serialize_main_t *m, char *s)
static void * serialize_read_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes_to_read, uword flags)
__clib_export void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
static void serialize_vector_write(serialize_main_header_t *m, serialize_stream_t *s)
static clib_error_t * serialize_open_clib_file_helper(serialize_main_t *m, char *file, uword is_read)
__clib_export void unserialize_cstring(serialize_main_t *m, char **s)
#define vec_free(V)
Free vector's memory (no header).
template key/value backing page structure
void unserialize_f64(serialize_main_t *m, va_list *va)
__clib_export void unserialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
uword data_function_opaque
void serialize_bitmap(serialize_main_t *m, uword *b)
__clib_export void unserialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
__clib_export void * serialize_close_vector(serialize_main_t *m)
void unserialize_64(serialize_main_t *m, va_list *va)
__clib_export void serialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
void serialize_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
clib_longjmp_t error_longjmp
static heap_elt_t * heap_next(heap_elt_t *e)
#define serialize_error_return(m, args...)
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return_unix(e, args...)
static void unserialize_vec_heap_elt(serialize_main_t *m, va_list *va)
u32 vl(void *p)
GDB callable function: vl - Return vector length of vector.
void unserialize_vec_8(serialize_main_t *m, va_list *va)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
serialize_function_t unserialize_vec_32
void unserialize_aligned_vector(serialize_main_t *m, va_list *va)
void serialize_16(serialize_main_t *m, va_list *va)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static pool_header_t * pool_header(void *v)
Get pool header from user pool pointer.
__clib_export void serialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
__clib_export void unserialize_close(serialize_main_t *m)
static void clib_file_write(serialize_main_header_t *m, serialize_stream_t *s)
#define uword_to_pointer(u, type)
void serialize_pool(serialize_main_t *m, va_list *va)
#define foreach_serialize_heap_header_integer
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
static uword heap_is_free(heap_elt_t *e)
static void serialize_open_clib_file_descriptor_helper(serialize_main_t *m, int fd, uword is_read)
void unserialize_pool(serialize_main_t *m, va_list *va)
__clib_export clib_error_t * va_serialize(serialize_main_t *sm, va_list *va)
__clib_export void serialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
serialize_data_function_t * data_function
void * unserialize_vector_ha(serialize_main_t *m, u32 elt_bytes, u32 header_bytes, u32 align, u32 max_length, serialize_function_t *f)
static void * serialize_get(serialize_main_t *m, uword n_bytes)
__clib_export void serialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
void serialize_32(serialize_main_t *m, va_list *va)
void unserialize_heap(serialize_main_t *m, va_list *va)
vl_api_wireguard_peer_flags_t flags