FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
stream.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * pg_stream.c: packet generator streams
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 #include <vnet/vnet.h>
41 #include <vnet/pg/pg.h>
42 #include <vnet/ethernet/ethernet.h>
43 #include <vnet/ip/ip.h>
44 #include <vnet/mpls/mpls.h>
45 #include <vnet/devices/devices.h>
46 
47 /* Mark stream active or inactive. */
48 void
49 pg_stream_enable_disable (pg_main_t * pg, pg_stream_t * s, int want_enabled)
50 {
51  vlib_main_t *vm;
52  vnet_main_t *vnm = vnet_get_main ();
54 
55  want_enabled = want_enabled != 0;
56 
57  if (pg_stream_is_enabled (s) == want_enabled)
58  /* No change necessary. */
59  return;
60 
61  if (want_enabled)
62  s->n_packets_generated = 0;
63 
64  /* Toggle enabled flag. */
66 
67  ASSERT (!pool_is_free (pg->streams, s));
68 
72  want_enabled);
73 
74  if (want_enabled)
75  {
78 
81  }
82 
83  if (vlib_num_workers ())
85  else
86  vm = vlib_get_main ();
87 
90  (pg->enabled_streams[s->worker_index]) ?
91  VLIB_NODE_STATE_DISABLED : VLIB_NODE_STATE_POLLING));
92 
93  s->packet_accumulator = 0;
94  s->time_last_generate = 0;
95 }
96 
97 static u8 *
98 format_pg_output_trace (u8 * s, va_list * va)
99 {
100  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
101  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
102  pg_output_trace_t *t = va_arg (*va, pg_output_trace_t *);
103  u32 indent = format_get_indent (s);
104 
105  s = format (s, "%Ubuffer 0x%x: %U",
106  format_white_space, indent,
108 
109  s = format (s, "\n%U%U", format_white_space, indent,
111  sizeof (t->buffer.pre_data));
112 
113  return s;
114 }
115 
116 static u8 *
117 format_pg_interface_name (u8 * s, va_list * args)
118 {
119  pg_main_t *pg = &pg_main;
120  u32 if_index = va_arg (*args, u32);
121  pg_interface_t *pi;
122 
123  pi = pool_elt_at_index (pg->interfaces, if_index);
124  s = format (s, "pg%d", pi->id);
125 
126  return s;
127 }
128 
129 static clib_error_t *
131 {
132  u32 hw_flags = 0;
133 
136 
137  vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
138 
139  return 0;
140 }
141 
142 /* *INDENT-OFF* */
144  .name = "pg",
145  .tx_function = pg_output,
146  .format_device_name = format_pg_interface_name,
147  .format_tx_trace = format_pg_output_trace,
148  .admin_up_down_function = pg_interface_admin_up_down,
149 };
150 /* *INDENT-ON* */
151 
152 static u8 *
155  vnet_link_t link_type, const void *dst_address)
156 {
157  u8 *rewrite = NULL;
158  u16 *h;
159 
160  vec_validate (rewrite, sizeof (*h) - 1);
161  h = (u16 *) rewrite;
162  h[0] = clib_host_to_net_u16 (vnet_link_to_l3_proto (link_type));
163 
164  return (rewrite);
165 }
166 
167 /* *INDENT-OFF* */
168 VNET_HW_INTERFACE_CLASS (pg_interface_class,static) = {
169  .name = "Packet generator",
170  .build_rewrite = pg_build_rewrite,
171 };
172 /* *INDENT-ON* */
173 
174 static u32
176 {
177  /* nothing for now */
178  return 0;
179 }
180 
181 void
183  u32 tx_node_index)
184 {
185  if (enable)
186  {
187  gro_flow_table_init (&pi->flow_table, 1 /* is_l2 */ ,
188  tx_node_index);
189  pi->coalesce_enabled = 1;
190  }
191  else
192  {
193  pi->coalesce_enabled = 0;
195  }
196 }
197 
198 u32
199 pg_interface_add_or_get (pg_main_t * pg, uword if_id, u8 gso_enabled,
200  u32 gso_size, u8 coalesce_enabled)
201 {
202  vnet_main_t *vnm = vnet_get_main ();
204  pg_interface_t *pi;
206  uword *p;
207  u32 i;
208 
209  p = hash_get (pg->if_index_by_if_id, if_id);
210 
211  if (p)
212  {
213  return p[0];
214  }
215  else
216  {
217  u8 hw_addr[6];
218  f64 now = vlib_time_now (vm);
219  u32 rnd;
220 
221  pool_get (pg->interfaces, pi);
222  i = pi - pg->interfaces;
223 
224  rnd = (u32) (now * 1e6);
225  rnd = random_u32 (&rnd);
226  clib_memcpy_fast (hw_addr + 2, &rnd, sizeof (rnd));
227  hw_addr[0] = 2;
228  hw_addr[1] = 0xfe;
229 
230  pi->id = if_id;
231  ethernet_register_interface (vnm, pg_dev_class.index, i, hw_addr,
233  hi = vnet_get_hw_interface (vnm, pi->hw_if_index);
234  if (gso_enabled)
235  {
237  pi->gso_enabled = 1;
238  pi->gso_size = gso_size;
239  if (coalesce_enabled)
240  {
242  }
243  }
244  pi->sw_if_index = hi->sw_if_index;
245 
246  hash_set (pg->if_index_by_if_id, if_id, i);
247 
248  if (vlib_num_workers ())
249  {
252  *pi->lockp = 0;
253  }
254  }
255 
256  return i;
257 }
258 
259 static void
261  pg_edit_group_t * g, pg_edit_t * e, uword want_commit)
262 {
263  u32 i, i0, i1, mask, n_bits_left;
264  u8 *v, *s, *m;
265 
266  i0 = e->lsb_bit_offset / BITS (u8);
267 
268  /* Make space for edit in value and mask. */
271 
272  if (e->type != PG_EDIT_FIXED)
273  {
274  switch (e->type)
275  {
276  case PG_EDIT_RANDOM:
277  case PG_EDIT_INCREMENT:
279  break;
280 
281  default:
282  break;
283  }
284 
285  if (want_commit)
286  {
288  vec_add1 (g->non_fixed_edits, e[0]);
289  }
290  return;
291  }
292 
293  s = g->fixed_packet_data;
294  m = g->fixed_packet_data_mask;
295 
296  n_bits_left = e->n_bits;
297  i0 = e->lsb_bit_offset / BITS (u8);
298  i1 = e->lsb_bit_offset % BITS (u8);
299 
300  v = e->values[PG_EDIT_LO];
301  i = pg_edit_n_alloc_bytes (e) - 1;
302 
303  /* Odd low order bits?. */
304  if (i1 != 0 && n_bits_left > 0)
305  {
306  u32 n = clib_min (n_bits_left, BITS (u8) - i1);
307 
308  mask = pow2_mask (n) << i1;
309 
310  ASSERT (i0 < vec_len (s));
311  ASSERT (i < vec_len (v));
312  ASSERT ((v[i] & ~mask) == 0);
313 
314  s[i0] |= v[i] & mask;
315  m[i0] |= mask;
316 
317  i0--;
318  i--;
319  n_bits_left -= n;
320  }
321 
322  /* Even bytes. */
323  while (n_bits_left >= 8)
324  {
325  ASSERT (i0 < vec_len (s));
326  ASSERT (i < vec_len (v));
327 
328  s[i0] = v[i];
329  m[i0] = ~0;
330 
331  i0--;
332  i--;
333  n_bits_left -= 8;
334  }
335 
336  /* Odd high order bits. */
337  if (n_bits_left > 0)
338  {
339  mask = pow2_mask (n_bits_left);
340 
341  ASSERT (i0 < vec_len (s));
342  ASSERT (i < vec_len (v));
343  ASSERT ((v[i] & ~mask) == 0);
344 
345  s[i0] |= v[i] & mask;
346  m[i0] |= mask;
347  }
348 
349  if (want_commit)
350  pg_edit_free (e);
351 }
352 
353 void
355  u32 group_index,
356  void *packet_data,
357  void *packet_data_mask)
358 {
359  pg_edit_group_t *g = pg_stream_get_group (s, group_index);
360  pg_edit_t *e;
361 
362  vec_foreach (e, g->edits) do_edit (s, g, e, /* want_commit */ 0);
363 
364  clib_memcpy_fast (packet_data, g->fixed_packet_data,
366  clib_memcpy_fast (packet_data_mask, g->fixed_packet_data_mask,
368 }
369 
370 static void
372 {
373  pg_edit_group_t *g;
374  pg_edit_t *e;
375  word i;
376 
377  for (i = vec_len (s->edit_groups) - 1; i >= 0; i--)
378  {
379  g = vec_elt_at_index (s->edit_groups, i);
380  vec_foreach (e, g->edits) do_edit (s, g, e, /* want_commit */ 1);
381 
382  /* All edits have either been performed or added to
383  g->non_fixed_edits. So, we can delete the vector. */
384  vec_free (g->edits);
385  }
386 
389  vec_foreach (g, s->edit_groups)
390  {
391  int i;
393 
394  /* Relocate and copy non-fixed edits from group to stream. */
397 
398  for (i = 0; i < vec_len (g->non_fixed_edits); i++)
400 
402  g->non_fixed_edits, vec_len (g->non_fixed_edits));
404 
406  g->fixed_packet_data, vec_len (g->fixed_packet_data));
409  }
410 }
411 
412 void
414 {
416  pg_stream_t *s;
417  uword *p;
418 
419  if (!pg->stream_index_by_name)
421  = hash_create_vec (0, sizeof (s->name[0]), sizeof (uword));
422 
423  /* Delete any old stream with the same name. */
424  if (s_init->name
425  && (p = hash_get_mem (pg->stream_index_by_name, s_init->name)))
426  {
427  pg_stream_del (pg, p[0]);
428  }
429 
430  pool_get (pg->streams, s);
431  s[0] = s_init[0];
432 
433  /* Give it a name. */
434  if (!s->name)
435  s->name = format (0, "stream%d", s - pg->streams);
436  else
437  s->name = vec_dup (s->name);
438 
439  hash_set_mem (pg->stream_index_by_name, s->name, s - pg->streams);
440 
441  /* Get fixed part of buffer data. */
442  if (s->edit_groups)
444 
445  /* Determine packet size. */
446  switch (s->packet_size_edit_type)
447  {
448  case PG_EDIT_INCREMENT:
449  case PG_EDIT_RANDOM:
450  if (s->min_packet_bytes == s->max_packet_bytes)
452  break;
453 
454  default:
455  /* Get packet size from fixed edits. */
457  if (!s->replay_packet_templates)
460  break;
461  }
462 
464 
465  {
466  int n;
467 
469  n = s->max_packet_bytes / s->buffer_bytes;
470  n += (s->max_packet_bytes % s->buffer_bytes) != 0;
471 
472  vec_resize (s->buffer_indices, n);
473  }
474 
475  /* Find an interface to use. */
476  s->pg_if_index =
477  pg_interface_add_or_get (pg, s->if_id, 0 /* gso_enabled */ ,
478  0 /* gso_size */ , 0 /* coalesce_enabled */ );
479 
480  if (s->sw_if_index[VLIB_RX] == ~0)
481  {
483  /*
484  * Default the RX interface if unset. It's a bad mistake to
485  * set [VLIB_TX] prior to ip lookup, since the ip lookup code
486  * interprets [VLIB_TX] as a fib index...
487  */
488  s->sw_if_index[VLIB_RX] = pi->sw_if_index;
489  }
490 
491  /* Connect the graph. */
493  s->node_index);
494 }
495 
496 void
498 {
499  pg_stream_t *s;
500  pg_buffer_index_t *bi;
501 
502  s = pool_elt_at_index (pg->streams, index);
503 
504  pg_stream_enable_disable (pg, s, /* want_enabled */ 0);
506 
507  vec_foreach (bi, s->buffer_indices)
508  {
510  }
511 
512  pg_stream_free (s);
513  pool_put (pg->streams, s);
514 }
515 
516 void
518 {
519  /* Determine packet size. */
520  switch (s->packet_size_edit_type)
521  {
522  case PG_EDIT_INCREMENT:
523  case PG_EDIT_RANDOM:
524  if (s->min_packet_bytes == s->max_packet_bytes)
526  case PG_EDIT_FIXED:
527  break;
528 
529  default:
530  /* Get packet size from fixed edits. */
532  if (!s->replay_packet_templates)
535  break;
536  }
537 
539 }
540 
541 
542 /*
543  * fd.io coding-style-patch-verification: ON
544  *
545  * Local Variables:
546  * eval: (c-set-style "gnu")
547  * End:
548  */
u32 sw_if_index
Definition: pg.h:304
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
Definition: edit.h:64
u32 next_index
Definition: pg.h:151
static int pg_stream_is_enabled(pg_stream_t *s)
Definition: pg.h:223
#define PG_EDIT_LO
Definition: edit.h:83
#define hash_set(h, key, value)
Definition: hash.h:255
#define clib_min(x, y)
Definition: clib.h:327
#define CLIB_UNUSED(x)
Definition: clib.h:87
u8 * fixed_packet_data
Definition: pg.h:121
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:103
vlib_buffer_t buffer
Definition: pg.h:401
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
Definition: pg.h:324
pg_edit_group_t * edit_groups
Definition: pg.h:107
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:333
uword * stream_index_by_name
Definition: pg.h:333
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
VNET_DEVICE_CLASS(pg_dev_class)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:592
u8 coalesce_enabled
Definition: pg.h:309
u32 worker_index
Definition: pg.h:148
static clib_error_t * pg_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: stream.c:130
u32 buffer_index
Definition: pg.h:402
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
static u32 format_get_indent(u8 *s)
Definition: format.h:72
#define hash_set_mem(h, key, value)
Definition: hash.h:275
vlib_main_t * vm
Definition: in2out_ed.c:1582
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
u64 last_increment_value
Definition: edit.h:87
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
Definition: pool.h:291
pg_buffer_index_t * buffer_indices
Definition: pg.h:173
u32 hw_if_index
Definition: pg.h:304
u16 mask
Definition: flow_types.api:52
pg_edit_type_t packet_size_edit_type
Definition: pg.h:109
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:252
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1173
VNET_HW_INTERFACE_CLASS(pg_interface_class, static)
unsigned char u8
Definition: types.h:56
void pg_stream_change(pg_main_t *pg, pg_stream_t *s)
Definition: stream.c:517
u8 * fixed_packet_data_mask
Definition: pg.h:121
u32 start_byte_offset
Definition: pg.h:68
static pg_edit_group_t * pg_stream_get_group(pg_stream_t *s, u32 group_index)
Definition: pg.h:229
gro_flow_table_t * flow_table
Definition: pg.h:310
double f64
Definition: types.h:142
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:668
u32 gso_size
Definition: pg.h:312
i64 word
Definition: types.h:111
static u8 * format_pg_interface_name(u8 *s, va_list *args)
Definition: stream.c:117
static uword pow2_mask(uword x)
Definition: clib.h:237
u8 * fixed_packet_data_mask
Definition: pg.h:65
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
Definition: bitmap.h:57
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
pg_edit_type_t type
Definition: edit.h:66
vnet_hw_interface_flags_t flags
Definition: interface.h:537
u8 * fixed_packet_data
Definition: pg.h:64
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
i32 lsb_bit_offset
Definition: edit.h:73
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:281
unsigned int u32
Definition: types.h:88
void pg_stream_del(pg_main_t *pg, uword index)
Definition: stream.c:497
#define PG_STREAM_FLAGS_IS_ENABLED
Definition: pg.h:103
uword * if_index_by_if_id
Definition: pg.h:337
u32 buffer_bytes
Definition: pg.h:125
static u32 pg_eth_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
Definition: stream.c:175
volatile u32 * lockp
Definition: pg.h:301
u8 * values[2]
Definition: edit.h:82
f64 packet_accumulator
Definition: pg.h:171
#define hash_get(h, key)
Definition: hash.h:249
u32 last_increment_packet_size
Definition: pg.h:131
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:534
#define hash_unset_mem(h, key)
Definition: hash.h:291
u32 pg_if_index
Definition: pg.h:134
format_function_t format_vnet_buffer
Definition: buffer.h:498
pg_edit_t * non_fixed_edits
Definition: pg.h:61
u8 * name
Definition: pg.h:98
unsigned short u16
Definition: types.h:57
static u64 pg_edit_get_value(pg_edit_t *e, int hi_or_lo)
Definition: edit.h:173
static void pg_stream_free(pg_stream_t *s)
Definition: pg.h:198
vec_header_t h
Definition: buffer.c:322
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:302
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:429
vlib_node_function_t pg_output
Definition: pg.h:353
uword ** enabled_streams
Definition: pg.h:330
u32 n_bits
Definition: edit.h:79
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:96
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:97
static u8 * pg_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Definition: stream.c:153
u8 gso_enabled
Definition: pg.h:311
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
static_always_inline void gro_flow_table_free(gro_flow_table_t *flow_table)
Definition: gro.h:171
u32 min_packet_bytes
Definition: pg.h:112
u32 max_packet_bytes
Definition: pg.h:112
static_always_inline u32 gro_flow_table_init(gro_flow_table_t **flow_table, u8 is_l2, u32 node_index)
Definition: gro.h:120
void pg_edit_group_get_fixed_packet_data(pg_stream_t *s, u32 group_index, void *packet_data, void *packet_data_mask)
Definition: stream.c:354
void pg_interface_enable_disable_coalesce(pg_interface_t *pi, u8 enable, u32 tx_node_index)
Definition: stream.c:182
pg_edit_t * non_fixed_edits
Definition: pg.h:116
u8 ** replay_packet_templates
Definition: pg.h:175
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1582
static void perform_fixed_edits(pg_stream_t *s)
Definition: stream.c:371
pg_stream_t * streams
Definition: pg.h:327
#define ASSERT(truth)
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:178
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
void pg_stream_enable_disable(pg_main_t *pg, pg_stream_t *s, int want_enabled)
Definition: stream.c:49
u32 pg_interface_add_or_get(pg_main_t *pg, uword if_id, u8 gso_enabled, u32 gso_size, u8 coalesce_enabled)
Definition: stream.c:199
void pg_stream_add(pg_main_t *pg, pg_stream_t *s_init)
Definition: stream.c:413
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:174
#define clib_fifo_free(f)
Definition: fifo.h:257
Definition: pg.h:95
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
vl_api_ip4_address_t hi
Definition: arp.api:37
static uword pg_edit_n_alloc_bytes(pg_edit_t *e)
Definition: edit.h:120
u32 node_index
Definition: pg.h:145
static u8 * format_pg_output_trace(u8 *s, va_list *va)
Definition: stream.c:98
u32 sw_if_index[VLIB_N_RX_TX]
Definition: pg.h:142
#define hash_create_vec(elts, key_bytes, value_bytes)
Definition: hash.h:668
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 id
Definition: pg.h:307
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:331
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:498
vnet_l3_packet_type_t vnet_link_to_l3_proto(vnet_link_t link)
Convert a link to to an Ethertype.
Definition: interface.c:1601
u32 if_id
Definition: pg.h:153
u64 uword
Definition: types.h:112
u32 index
Definition: flow_types.api:221
pg_edit_t * edits
Definition: pg.h:58
#define hash_get_mem(h, key)
Definition: hash.h:269
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:165
static void do_edit(pg_stream_t *stream, pg_edit_group_t *g, pg_edit_t *e, uword want_commit)
Definition: stream.c:260
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:507
static u32 vlib_num_workers()
Definition: threads.h:377
u64 n_packets_generated
Definition: pg.h:156
vlib_node_registration_t pg_input_node
(constructor) VLIB_REGISTER_NODE (pg_input_node)
Definition: input.c:1812
pg_main_t pg_main
Definition: init.c:44
#define vec_foreach(var, vec)
Vector iterator.
static void pg_edit_free(pg_edit_t *e)
Definition: edit.h:91
vnet_device_class_t pg_dev_class
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
#define BITS(x)
Definition: clib.h:66
f64 time_last_generate
Definition: pg.h:169
pg_interface_t * interfaces
Definition: pg.h:336
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:33
Definition: defs.h:46
vlib_node_registration_t device_input_node
(constructor) VLIB_REGISTER_NODE (device_input_node)
Definition: devices.c:32
static vlib_main_t * vlib_get_worker_vlib_main(u32 worker_index)
Definition: threads.h:519
u32 flags
Definition: pg.h:100
u32 * buffer_fifo
Definition: pg.h:91