57 u32 data_offset,
u32 n_bytes)
70 for (i = 0; i < n_bytes; i++)
71 if ((bd[i] & pm[i]) != pd[
i])
95 ASSERT (v0 >= v_min && v0 <= v_max);
102 if (is_net_byte_order)
103 v0 = clib_host_to_net_u16 (v0);
108 if (is_net_byte_order)
109 v0 = clib_host_to_net_u32 (v0);
114 if (is_net_byte_order)
115 v0 = clib_host_to_net_u64 (v0);
124 u32 n_bits,
u32 is_net_byte_order,
u32 is_increment)
126 ASSERT (v0 >= v_min && v0 <= v_max);
127 ASSERT (v1 >= v_min && v1 <= (v_max + is_increment));
135 if (is_net_byte_order)
137 v0 = clib_host_to_net_u16 (v0);
138 v1 = clib_host_to_net_u16 (v1);
145 if (is_net_byte_order)
147 v0 = clib_host_to_net_u32 (v0);
148 v1 = clib_host_to_net_u32 (v1);
155 if (is_net_byte_order)
157 v0 = clib_host_to_net_u64 (v0);
158 v1 = clib_host_to_net_u64 (v1);
171 u32 byte_offset,
u32 is_net_byte_order,
u64 v_min,
u64 v_max)
175 while (n_buffers >= 4)
187 a0 = (
void *) b0 + byte_offset;
188 a1 = (
void *) b1 + byte_offset;
189 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
190 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
192 set_2 (a0, a1, v_min, v_min, v_min, v_max, n_bits, is_net_byte_order,
199 while (n_buffers > 0)
208 a0 = (
void *) b0 + byte_offset;
210 set_1 (a0, v_min, v_min, v_max, n_bits, is_net_byte_order);
223 u32 is_net_byte_order,
229 ASSERT (v >= v_min && v <= v_max);
231 while (n_buffers >= 4)
244 a0 = (
void *) b0 + byte_offset;
245 a1 = (
void *) b1 + byte_offset;
246 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
247 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
251 v = v > v_max ? v_min : v;
253 v_old + 0, v_old + 1, v_min, v_max, n_bits, is_net_byte_order,
257 sum += 2 * v_old + 1;
262 sum -= 2 * v_old + 1;
265 set_1 (a0, v + 0, v_min, v_max, n_bits, is_net_byte_order);
270 v = v > v_max ? v_min : v;
271 set_1 (a1, v + 0, v_min, v_max, n_bits, is_net_byte_order);
281 while (n_buffers > 0)
291 a0 = (
void *) b0 + byte_offset;
297 v = v > v_max ? v_min : v;
299 ASSERT (v_old >= v_min && v_old <= v_max);
300 set_1 (a0, v_old, v_min, v_max, n_bits, is_net_byte_order);
318 u32 is_net_byte_order,
322 u64 v_diff = v_max - v_min + 1;
333 while (n_buffers >= 4)
346 a0 = (
void *) b0 + byte_offset;
347 a1 = (
void *) b1 + byte_offset;
348 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
349 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
356 u##n * r = random_data; \ 359 random_data = r + 2; \ 376 v0 = v0 > v_max ? v0 - v_diff : v0;
377 v1 = v1 > v_max ? v1 - v_diff : v1;
378 v0 = v0 > v_max ? v0 - v_diff : v0;
379 v1 = v1 > v_max ? v1 - v_diff : v1;
384 set_2 (a0, a1, v0, v1, v_min, v_max, n_bits, is_net_byte_order,
391 while (n_buffers > 0)
401 a0 = (
void *) b0 + byte_offset;
408 u##n * r = random_data; \ 410 random_data = r + 1; \ 426 v0 = v0 > v_max ? v0 - v_diff : v0;
427 v0 = v0 > v_max ? v0 - v_diff : v0;
432 set_1 (a0, v0, v_min, v_max, n_bits, is_net_byte_order);
442 clib_mem_unaligned (a##i, t) = \ 443 clib_host_to_net_##t ((clib_net_to_host_mem_##t (a##i) &~ mask) \ 452 ASSERT (v0 >= v_min && v0 <= v_max);
453 if (max_bits ==
BITS (
u8))
454 ((
u8 *) a0)[0] = (((
u8 *) a0)[0] & ~mask) | (v0 << shift);
456 else if (max_bits ==
BITS (
u16))
460 else if (max_bits ==
BITS (
u32))
464 else if (max_bits ==
BITS (
u64))
476 ASSERT (v0 >= v_min && v0 <= v_max);
477 ASSERT (v1 >= v_min && v1 <= v_max + is_increment);
478 if (max_bits ==
BITS (
u8))
480 ((
u8 *) a0)[0] = (((
u8 *) a0)[0] & ~mask) | (v0 << shift);
481 ((
u8 *) a1)[0] = (((
u8 *) a1)[0] & ~mask) | (v1 << shift);
484 else if (max_bits ==
BITS (
u16))
489 else if (max_bits ==
BITS (
u32))
494 else if (max_bits ==
BITS (
u64))
514 while (n_buffers >= 4)
526 a0 = (
void *) b0 + byte_offset;
527 a1 = (
void *) b1 + byte_offset;
528 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
529 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
532 v_min, v_min, v_min, v_max, max_bits, n_bits, mask, shift,
539 while (n_buffers > 0)
548 a0 = (
void *) b0 + byte_offset;
550 setbits_1 (a0, v_min, v_min, v_max, max_bits, n_bits, mask, shift);
567 ASSERT (v >= v_min && v <= v_max);
569 while (n_buffers >= 4)
582 a0 = (
void *) b0 + byte_offset;
583 a1 = (
void *) b1 + byte_offset;
584 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
585 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
589 v = v > v_max ? v_min : v;
591 v_old + 0, v_old + 1,
592 v_min, v_max, max_bits, n_bits, mask, shift,
598 setbits_1 (a0, v + 0, v_min, v_max, max_bits, n_bits, mask, shift);
601 v = v > v_max ? v_min : v;
602 setbits_1 (a1, v + 0, v_min, v_max, max_bits, n_bits, mask, shift);
609 while (n_buffers > 0)
619 a0 = (
void *) b0 + byte_offset;
623 v = v > v_max ? v_min : v;
625 ASSERT (v_old >= v_min && v_old <= v_max);
626 setbits_1 (a0, v_old, v_min, v_max, max_bits, n_bits, mask, shift);
644 u64 v_diff = v_max - v_min + 1;
653 while (n_buffers >= 4)
666 a0 = (
void *) b0 + byte_offset;
667 a1 = (
void *) b1 + byte_offset;
668 CLIB_PREFETCH ((
void *) b2 + byte_offset,
sizeof (v_min), WRITE);
669 CLIB_PREFETCH ((
void *) b3 + byte_offset,
sizeof (v_min), WRITE);
676 u##n * r = random_data; \ 679 random_data = r + 2; \ 696 v0 = v0 > v_max ? v0 - v_diff : v0;
697 v1 = v1 > v_max ? v1 - v_diff : v1;
698 v0 = v0 > v_max ? v0 - v_diff : v0;
699 v1 = v1 > v_max ? v1 - v_diff : v1;
701 setbits_2 (a0, a1, v0, v1, v_min, v_max, max_bits, n_bits, mask, shift,
708 while (n_buffers > 0)
718 a0 = (
void *) b0 + byte_offset;
725 u##n * r = random_data; \ 727 random_data = r + 1; \ 743 v0 = v0 > v_max ? v0 - v_diff : v0;
744 v0 = v0 > v_max ? v0 - v_diff : v0;
746 setbits_1 (a0, v0, v_min, v_max, max_bits, n_bits, mask, shift);
760 u32 max_bits, l0, l1, h1, start_bit;
769 start_bit = l0 *
BITS (
u8);
771 max_bits = hi_bit - start_bit;
776 if (edit_type == PG_EDIT_INCREMENT) \ 777 v = do_set_increment (pg, s, buffers, n_buffers, \ 784 else if (edit_type == PG_EDIT_RANDOM) \ 785 do_set_random (pg, s, buffers, n_buffers, \ 792 do_set_fixed (pg, s, buffers, n_buffers, \ 799 if (l1 == 0 && h1 == 0)
815 u32 n_bits = max_bits;
819 mask = ((
u64) 1 << (
u64) n_bits) - 1;
820 mask &= ~(((
u64) 1 << (
u64) shift) - 1);
822 mask <<= max_bits - n_bits;
823 shift += max_bits - n_bits;
829 if (edit_type == PG_EDIT_INCREMENT) \ 830 v = do_setbits_increment (pg, s, buffers, n_buffers, \ 831 BITS (u##n), n_bits, \ 832 l0, v_min, v_max, v, \ 834 else if (edit_type == PG_EDIT_RANDOM) \ 835 do_setbits_random (pg, s, buffers, n_buffers, \ 836 BITS (u##n), n_bits, \ 840 do_setbits_fixed (pg, s, buffers, n_buffers, \ 841 BITS (u##n), n_bits, \ 863 u64 v_min, v_max, length_sum;
894 length_sum = v_min * n_buffers;
914 u32 * buffers,
u32 n_buffers)
919 static u32 *unused_buffers = 0;
921 while (n_buffers > 0)
939 if (n_bytes_left > 0)
940 b->
flags |= VLIB_BUFFER_NEXT_PRESENT;
942 b->
flags &= ~VLIB_BUFFER_NEXT_PRESENT;
955 ASSERT (n_bytes_left == 0);
961 if (
vec_len (unused_buffers) > 0)
964 _vec_len (unused_buffers) = 0;
989 lo_bit = hi_bit - e->
n_bits;
992 =
do_it (pg, s, buffers, n_buffers, lo_bit, hi_bit, v_min, v_max,
1022 u32 * buffers,
u32 * next_buffers,
u32 n_buffers)
1026 while (n_buffers >= 4)
1033 ni0 = next_buffers[0];
1034 ni1 = next_buffers[1];
1039 b0->
flags |= VLIB_BUFFER_NEXT_PRESENT;
1040 b1->
flags |= VLIB_BUFFER_NEXT_PRESENT;
1049 while (n_buffers > 0)
1055 ni0 = next_buffers[0];
1060 b0->
flags |= VLIB_BUFFER_NEXT_PRESENT;
1069 u32 n_buffers,
u32 data_offset,
u32 n_data,
u32 set_data)
1150 u32 * buffers,
u32 * next_buffers,
u32 n_alloc)
1159 if (n_allocated == 0)
1166 n_alloc = n_allocated;
1179 if (is_start_of_packet)
1196 u32 buffer_alloc_request = 0;
1197 u32 buffer_alloc_result;
1198 u32 current_buffer_index;
1220 buffer_alloc_request += (
vec_len (d0) + (buf_sz - 1)) / buf_sz;
1222 i = ((i + 1) == l) ? 0 : i + 1;
1226 ASSERT (buffer_alloc_request > 0);
1231 if (buffer_alloc_result < buffer_alloc_request)
1233 clib_warning (
"alloc failure, got %d not %d", buffer_alloc_result,
1234 buffer_alloc_request);
1243 current_buffer_index = 0;
1251 u32 bytes_to_copy, bytes_this_chunk;
1262 while (bytes_to_copy)
1264 bytes_this_chunk =
clib_min (bytes_to_copy, buf_sz);
1275 not_last = bytes_this_chunk < bytes_to_copy;
1279 b->
flags |= VLIB_BUFFER_NEXT_PRESENT;
1280 b->
next_buffer = buffers[current_buffer_index + 1];
1282 bytes_to_copy -= bytes_this_chunk;
1283 data_offset += bytes_this_chunk;
1284 current_buffer_index++;
1287 i = ((i + 1) == l) ? 0 : i + 1;
1294 for (i = 0; i < n_alloc; i++)
1313 word i, n_in_fifo, n_alloc, n_free, n_added;
1314 u32 *tail, *start, *end, *last_tail, *last_start;
1319 if (n_in_fifo >= n_buffers)
1322 n_alloc = n_buffers - n_in_fifo;
1354 last_tail = last_start = 0;
1362 if (n_free < n_alloc)
1369 if (tail + n_alloc <= end)
1379 if (n_added == n && n_alloc > n_added)
1382 (pg, s, bi, start, last_start, n_alloc - n_added);
1395 return n_in_fifo + n_added;
1454 u32 * buffers,
u32 n_buffers)
1492 sizeof (b0[0]) -
sizeof (b0->
pre_data));
1494 sizeof (b1[0]) -
sizeof (b1->
pre_data));
1521 sizeof (b0[0]) -
sizeof (b0->
pre_data));
1533 u32 *to_next, n_this_frame, n_left, n_trace, n_packets_in_fifo;
1534 uword n_packets_generated;
1541 u32 current_config_index = ~(
u32) 0;
1546 n_packets_in_fifo =
pg_stream_fill (pg, s, n_packets_to_generate);
1547 n_packets_to_generate =
clib_min (n_packets_in_fifo, n_packets_to_generate);
1548 n_packets_generated = 0;
1553 current_config_index =
1559 while (n_packets_to_generate > 0)
1561 u32 *head, *start, *end;
1583 n_this_frame = n_packets_to_generate;
1584 if (n_this_frame > n_left)
1585 n_this_frame = n_left;
1591 if (head + n_this_frame <= end)
1610 if (current_config_index != ~(
u32) 0)
1611 for (i = 0; i < n_this_frame; i++)
1616 vnet_buffer (b)->feature_arc_index = feature_arc_index;
1626 n_packets_to_generate -= n_this_frame;
1627 n_packets_generated += n_this_frame;
1628 n_left -= n_this_frame;
1634 for (i = 0; i < n_this_frame; i++)
1637 ASSERT ((b->
flags & VLIB_BUFFER_NEXT_PRESENT) == 0 ||
1644 return n_packets_generated;
1700 uword n_packets = 0;
1701 u32 worker_index = 0;
1708 pg_stream_t *s = vec_elt_at_index (pg->streams, i);
1709 n_packets += pg_input_stream (node, pg, s);
1720 .sibling_of =
"device-input",
1726 .state = VLIB_NODE_STATE_DISABLED,
vnet_config_main_t config_main
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
#define clib_fifo_head(v)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static uword clib_fifo_elts(void *v)
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
pg_edit_group_t * edit_groups
#define clib_memcpy_fast(a, b, c)
#define clib_fifo_advance_tail(f, n_elts)
static f64 vlib_time_now(vlib_main_t *vm)
#define clib_fifo_resize(f, n_elts)
static void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
void(* edit_function)(struct pg_main_t *pg, struct pg_stream_t *s, struct pg_edit_group_t *g, u32 *buffers, u32 n_buffers)
u32 * config_index_by_sw_if_index
u16 current_length
Nbytes between current data and the end of this buffer.
static vlib_frame_t * vlib_get_frame(vlib_main_t *vm, vlib_frame_t *f)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define STRUCT_OFFSET_OF(t, f)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static_always_inline int vnet_have_features(u8 arc, u32 sw_if_index)
pg_buffer_index_t * buffer_indices
pg_edit_type_t packet_size_edit_type
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
u8 * fixed_packet_data_mask
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
#define static_always_inline
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
#define ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX
vlib_combined_counter_main_t * combined_sw_if_counters
static uword clib_fifo_free_elts(void *v)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define vlib_get_new_next_frame(vm, node, next_index, vectors, n_vectors_left)
static u32 vlib_get_current_worker_index()
#define vec_end(v)
End (last data address) of vector.
static vlib_next_frame_t * vlib_node_runtime_get_next_frame(vlib_main_t *vm, vlib_node_runtime_t *n, u32 next_index)
u32 last_increment_packet_size
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
format_function_t format_vnet_buffer
u32 current_replay_packet_index
u32 ** replay_buffers_by_thread
static u64 pg_edit_get_value(pg_edit_t *e, int hi_or_lo)
static void * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
format_function_t * format_buffer
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
static void vlib_buffer_free_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers, does not free the buffer chain for each buffer.
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
#define clib_warning(format, args...)
static uword max_pow2(uword x)
static void * vlib_frame_scalar_args(vlib_frame_t *f)
Get pointer to frame scalar data.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
pg_edit_t * non_fixed_edits
u8 ** replay_packet_templates
static uword clib_fifo_advance_head(void *v, uword n_elts)
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
void pg_stream_enable_disable(pg_main_t *pg, pg_stream_t *s, int is_enable)
static uword vlib_buffer_index_length_in_chain(vlib_main_t *vm, u32 bi)
Get length in bytes of the buffer index buffer chain.
#define clib_mem_unaligned(pointer, type)
static vlib_main_t * vlib_get_main(void)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
u8 device_input_feature_arc_index
Feature arc index for device-input.
u32 sw_if_index[VLIB_N_RX_TX]
#define clib_fifo_add1(f, e)
static_always_inline void vlib_buffer_copy_indices(u32 *dst, u32 *src, u32 n_indices)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
VLIB buffer representation.
#define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE
f64 rate_packets_per_second
static u32 vlib_num_workers()
#define STRUCT_SIZE_OF(t, f)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define vec_foreach(var, vec)
Vector iterator.
static void vlib_frame_no_append(vlib_frame_t *f)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
vnet_feature_config_main_t * feature_config_mains
feature config main objects
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
vnet_feature_main_t feature_main
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
clib_random_buffer_t random_buffer
pg_interface_t * interfaces