FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
vnet_classify.h
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 #ifndef __included_vnet_classify_h__
16 #define __included_vnet_classify_h__
17 
18 #include <vnet/vnet.h>
19 #include <vnet/api_errno.h> /* for API error numbers */
20 
21 #include <vppinfra/error.h>
22 #include <vppinfra/hash.h>
23 #include <vppinfra/cache.h>
24 #include <vppinfra/crc32.h>
25 #include <vppinfra/xxhash.h>
26 
29 
30 #define CLASSIFY_TRACE 0
31 
32 /*
33  * Classify table option to process packets
34  * CLASSIFY_FLAG_USE_CURR_DATA:
35  * - classify packets starting from VPP node’s current data pointer
36  */
38 {
41 } __clib_packed vnet_classify_flags_t;
42 
43 /*
44  * Classify session action
45  * CLASSIFY_ACTION_SET_IP4_FIB_INDEX:
46  * - Classified IP packets will be looked up
47  * from the specified ipv4 fib table
48  * CLASSIFY_ACTION_SET_IP6_FIB_INDEX:
49  * - Classified IP packets will be looked up
50  * from the specified ipv6 fib table
51  */
53 {
58 } __clib_packed vnet_classify_action_t;
59 
60 struct _vnet_classify_main;
61 typedef struct _vnet_classify_main vnet_classify_main_t;
62 
63 #define foreach_size_in_u32x4 \
64 _(1) \
65 _(2) \
66 _(3) \
67 _(4) \
68 _(5)
69 
70 typedef struct _vnet_classify_entry
71 {
72  /* put into vnet_buffer(b)->l2_classfy.opaque_index */
73  union
74  {
75  struct
76  {
77  u32 opaque_index;
78  /* advance on hit, note it's a signed quantity... */
79  i32 advance;
80  };
81  u64 opaque_count;
82  };
83  /* Hit counter */
84  union
85  {
86  u64 hits;
87  struct _vnet_classify_entry *next_free;
88  };
89  /* last heard time */
90  f64 last_heard;
91 
92  /* Really only need 1 bit */
93  u8 flags;
94 #define VNET_CLASSIFY_ENTRY_FREE (1<<0)
95 
97  u16 metadata;
98  /* Graph node next index */
100 
101  /* Must be aligned to a 16-octet boundary */
102  u32x4 key[0];
104 
105 /**
106  * Check there's no padding in the entry. the key lies on a 16 byte boundary.
107  */
109 
110 static inline int
112 {
113  return e->flags & VNET_CLASSIFY_ENTRY_FREE;
114 }
115 
116 static inline int
118 {
119  return ((e->flags & VNET_CLASSIFY_ENTRY_FREE) == 0);
120 }
121 
122 /* Need these to con the vector allocator */
123 #define _(size) \
124  typedef struct \
125  { \
126  vnet_classify_entry_t e; \
127  u32x4 key[size]; \
128  } __clib_packed vnet_classify_entry_##size##_t;
130 #undef _
131 
132 typedef struct
133 {
134  union
135  {
136  struct
137  {
140  u8 pad[2];
142  };
144  };
146 
147 typedef struct
148 {
149  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
150  /* Mask to apply after skipping N vectors */
152 
153  /* hash Buckets */
155 
156  /* Private allocation arena, protected by the writer lock,
157  * where the entries are stored. */
158  void *mheap;
159 
160  /* User/client data associated with the table */
162 
168 
169  /* Index of next table to try */
171 
172  /* packet offsets */
175  /* Miss next index, return if next_table_index = 0 */
177 
178  /**
179  * All members accessed in the DP above here
180  */
181  CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
182 
183  /* Config parameters */
187 
188  /* Per-bucket working copies, one per thread */
192 
193  /* Free entry freelists */
195 
196  /* Writer (only) lock for this table */
198 
200 
201 /**
202  * Ensure DP fields don't spill over to cache-line 2
203  */
206 
207 /**
208  * The vector size for the classifier
209  * in the add/del table 'match' is the number of vectors of this size
210  */
211 #define VNET_CLASSIFY_VECTOR_SIZE \
212  sizeof (((vnet_classify_table_t *) 0)->mask[0])
213 
214 struct _vnet_classify_main
215 {
216  /* Table pool */
217  vnet_classify_table_t *tables;
218 
219  /* Registered next-index, opaque unformat fcns */
220  unformat_function_t **unformat_l2_next_index_fns;
221  unformat_function_t **unformat_ip_next_index_fns;
222  unformat_function_t **unformat_acl_next_index_fns;
223  unformat_function_t **unformat_policer_next_index_fns;
224  unformat_function_t **unformat_opaque_index_fns;
225 
226  /* Per-interface filter table. [0] is used for pcap */
227  u32 *classify_table_index_by_sw_if_index;
228 
229  /* convenience variables */
232 };
233 
235 
236 u8 *format_classify_table (u8 * s, va_list * args);
237 u8 *format_vnet_classify_table (u8 *s, va_list *args);
238 
240 
243 {
245 
246  return (pool_elt_at_index (vcm->tables, table_index));
247 }
248 
249 static inline u64
251 {
252  u32x4 *mask;
253 
254  union
255  {
256  u32x4 as_u32x4;
257  u64 as_u64[2];
258  } xor_sum __attribute__ ((aligned (sizeof (u32x4))));
259 
260  ASSERT (t);
261  mask = t->mask;
262 #ifdef CLIB_HAVE_VEC128
263  u32x4u *data = (u32x4u *) h;
264  xor_sum.as_u32x4 = data[0 + t->skip_n_vectors] & mask[0];
265  switch (t->match_n_vectors)
266  {
267  case 5:
268  xor_sum.as_u32x4 ^= data[4 + t->skip_n_vectors] & mask[4];
269  /* FALLTHROUGH */
270  case 4:
271  xor_sum.as_u32x4 ^= data[3 + t->skip_n_vectors] & mask[3];
272  /* FALLTHROUGH */
273  case 3:
274  xor_sum.as_u32x4 ^= data[2 + t->skip_n_vectors] & mask[2];
275  /* FALLTHROUGH */
276  case 2:
277  xor_sum.as_u32x4 ^= data[1 + t->skip_n_vectors] & mask[1];
278  /* FALLTHROUGH */
279  case 1:
280  break;
281  default:
282  abort ();
283  }
284 #else
285  u32 skip_u64 = t->skip_n_vectors * 2;
286  u64 *data64 = (u64 *) h;
287  xor_sum.as_u64[0] = data64[0 + skip_u64] & ((u64 *) mask)[0];
288  xor_sum.as_u64[1] = data64[1 + skip_u64] & ((u64 *) mask)[1];
289  switch (t->match_n_vectors)
290  {
291  case 5:
292  xor_sum.as_u64[0] ^= data64[8 + skip_u64] & ((u64 *) mask)[8];
293  xor_sum.as_u64[1] ^= data64[9 + skip_u64] & ((u64 *) mask)[9];
294  /* FALLTHROUGH */
295  case 4:
296  xor_sum.as_u64[0] ^= data64[6 + skip_u64] & ((u64 *) mask)[6];
297  xor_sum.as_u64[1] ^= data64[7 + skip_u64] & ((u64 *) mask)[7];
298  /* FALLTHROUGH */
299  case 3:
300  xor_sum.as_u64[0] ^= data64[4 + skip_u64] & ((u64 *) mask)[4];
301  xor_sum.as_u64[1] ^= data64[5 + skip_u64] & ((u64 *) mask)[5];
302  /* FALLTHROUGH */
303  case 2:
304  xor_sum.as_u64[0] ^= data64[2 + skip_u64] & ((u64 *) mask)[2];
305  xor_sum.as_u64[1] ^= data64[3 + skip_u64] & ((u64 *) mask)[3];
306  /* FALLTHROUGH */
307  case 1:
308  break;
309 
310  default:
311  abort ();
312  }
313 #endif /* CLIB_HAVE_VEC128 */
314 
315 #ifdef clib_crc32c_uses_intrinsics
316  return clib_crc32c ((u8 *) & xor_sum, sizeof (xor_sum));
317 #else
318  return clib_xxhash (xor_sum.as_u64[0] ^ xor_sum.as_u64[1]);
319 #endif
320 }
321 
322 static inline void
324 {
325  u32 bucket_index;
326 
327  ASSERT (is_pow2 (t->nbuckets));
328 
329  bucket_index = hash & (t->nbuckets - 1);
330 
331  CLIB_PREFETCH (&t->buckets[bucket_index], CLIB_CACHE_LINE_BYTES, LOAD);
332 }
333 
334 static inline vnet_classify_entry_t *
336 {
337  u8 *hp = clib_mem_get_heap_base (t->mheap);
338  u8 *vp = hp + offset;
339 
340  return (vnet_classify_entry_t *) vp;
341 }
342 
343 static inline uword
346 {
347  u8 *hp, *vp;
348 
349  hp = (u8 *) clib_mem_get_heap_base (t->mheap);
350  vp = (u8 *) v;
351 
352  ASSERT ((vp - hp) < 0x100000000ULL);
353  return vp - hp;
354 }
355 
356 static inline vnet_classify_entry_t *
359 {
360  u8 *eu8;
361 
362  eu8 = (u8 *) e;
363 
364  eu8 += index * (sizeof (vnet_classify_entry_t) +
365  (t->match_n_vectors * sizeof (u32x4)));
366 
367  return (vnet_classify_entry_t *) eu8;
368 }
369 
370 static inline void
372 {
373  u32 bucket_index;
374  u32 value_index;
377 
378  bucket_index = hash & (t->nbuckets - 1);
379 
380  b = &t->buckets[bucket_index];
381 
382  if (b->offset == 0)
383  return;
384 
385  hash >>= t->log2_nbuckets;
386 
387  e = vnet_classify_get_entry (t, b->offset);
388  value_index = hash & ((1 << b->log2_pages) - 1);
389 
390  e = vnet_classify_entry_at_index (t, e, value_index);
391 
393 }
394 
396  u8 * h, u64 hash, f64 now);
397 
398 static inline vnet_classify_entry_t *
400  u64 hash, f64 now)
401 {
403  u32x4 *mask, *key;
404  union
405  {
406  u32x4 as_u32x4;
407  u64 as_u64[2];
408  } result __attribute__ ((aligned (sizeof (u32x4))));
410  u32 value_index;
411  u32 bucket_index;
412  u32 limit;
413  int i;
414 
415  bucket_index = hash & (t->nbuckets - 1);
416  b = &t->buckets[bucket_index];
417  mask = t->mask;
418 
419  if (b->offset == 0)
420  return 0;
421 
422  hash >>= t->log2_nbuckets;
423 
424  v = vnet_classify_get_entry (t, b->offset);
425  value_index = hash & ((1 << b->log2_pages) - 1);
426  limit = t->entries_per_page;
427  if (PREDICT_FALSE (b->linear_search))
428  {
429  value_index = 0;
430  limit *= (1 << b->log2_pages);
431  }
432 
433  v = vnet_classify_entry_at_index (t, v, value_index);
434 
435 #ifdef CLIB_HAVE_VEC128
436  const u32x4u *data = (const u32x4u *) h;
437  for (i = 0; i < limit; i++)
438  {
439  key = v->key;
440  result.as_u32x4 = (data[0 + t->skip_n_vectors] & mask[0]) ^ key[0];
441  switch (t->match_n_vectors)
442  {
443  case 5:
444  result.as_u32x4 |= (data[4 + t->skip_n_vectors] & mask[4]) ^ key[4];
445  /* FALLTHROUGH */
446  case 4:
447  result.as_u32x4 |= (data[3 + t->skip_n_vectors] & mask[3]) ^ key[3];
448  /* FALLTHROUGH */
449  case 3:
450  result.as_u32x4 |= (data[2 + t->skip_n_vectors] & mask[2]) ^ key[2];
451  /* FALLTHROUGH */
452  case 2:
453  result.as_u32x4 |= (data[1 + t->skip_n_vectors] & mask[1]) ^ key[1];
454  /* FALLTHROUGH */
455  case 1:
456  break;
457  default:
458  abort ();
459  }
460 
461  if (u32x4_zero_byte_mask (result.as_u32x4) == 0xffff)
462  {
463  if (PREDICT_TRUE (now))
464  {
465  v->hits++;
466  v->last_heard = now;
467  }
468  return (v);
469  }
470  v = vnet_classify_entry_at_index (t, v, 1);
471  }
472 #else
473  u32 skip_u64 = t->skip_n_vectors * 2;
474  const u64 *data64 = (const u64 *) h;
475  for (i = 0; i < limit; i++)
476  {
477  key = v->key;
478 
479  result.as_u64[0] =
480  (data64[0 + skip_u64] & ((u64 *) mask)[0]) ^ ((u64 *) key)[0];
481  result.as_u64[1] =
482  (data64[1 + skip_u64] & ((u64 *) mask)[1]) ^ ((u64 *) key)[1];
483  switch (t->match_n_vectors)
484  {
485  case 5:
486  result.as_u64[0] |=
487  (data64[8 + skip_u64] & ((u64 *) mask)[8]) ^ ((u64 *) key)[8];
488  result.as_u64[1] |=
489  (data64[9 + skip_u64] & ((u64 *) mask)[9]) ^ ((u64 *) key)[9];
490  /* FALLTHROUGH */
491  case 4:
492  result.as_u64[0] |=
493  (data64[6 + skip_u64] & ((u64 *) mask)[6]) ^ ((u64 *) key)[6];
494  result.as_u64[1] |=
495  (data64[7 + skip_u64] & ((u64 *) mask)[7]) ^ ((u64 *) key)[7];
496  /* FALLTHROUGH */
497  case 3:
498  result.as_u64[0] |=
499  (data64[4 + skip_u64] & ((u64 *) mask)[4]) ^ ((u64 *) key)[4];
500  result.as_u64[1] |=
501  (data64[5 + skip_u64] & ((u64 *) mask)[5]) ^ ((u64 *) key)[5];
502  /* FALLTHROUGH */
503  case 2:
504  result.as_u64[0] |=
505  (data64[2 + skip_u64] & ((u64 *) mask)[2]) ^ ((u64 *) key)[2];
506  result.as_u64[1] |=
507  (data64[3 + skip_u64] & ((u64 *) mask)[3]) ^ ((u64 *) key)[3];
508  /* FALLTHROUGH */
509  case 1:
510  break;
511  default:
512  abort ();
513  }
514 
515  if (result.as_u64[0] == 0 && result.as_u64[1] == 0)
516  {
517  if (PREDICT_TRUE (now))
518  {
519  v->hits++;
520  v->last_heard = now;
521  }
522  return (v);
523  }
524 
525  v = vnet_classify_entry_at_index (t, v, 1);
526  }
527 #endif /* CLIB_HAVE_VEC128 */
528  return 0;
529 }
530 
532  const u8 *mask, u32 nbuckets,
534  u32 skip_n_vectors,
535  u32 match_n_vectors);
536 
538  const u8 *match, u32 hit_next_index,
539  u32 opaque_index, i32 advance, u8 action,
540  u16 metadata, int is_add);
541 
543  u32 nbuckets, u32 memory_size, u32 skip,
544  u32 match, u32 next_table_index,
545  u32 miss_next_index, u32 *table_index,
546  u8 current_data_flag, i16 current_data_offset,
547  int is_add, int del_chain);
549  u32 table_index, int del_chain);
550 
565 
567  (unformat_function_t * fn);
568 
570  (unformat_function_t * fn);
571 
573  (unformat_function_t * fn);
574 
576  (unformat_function_t * fn);
577 
579  fn);
580 
583  u32 sw_if_index, u32 table_index);
584 
587 
589 u32 classify_lookup_chain (u32 table_index,
590  u8 * mask, u32 n_skip, u32 n_match);
591 
592 #endif /* __included_vnet_classify_h__ */
593 
594 /*
595  * fd.io coding-style-patch-verification: ON
596  *
597  * Local Variables:
598  * eval: (c-set-style "gnu")
599  * End:
600  */
CLASSIFY_FLAG_USE_CURR_DATA
@ CLASSIFY_FLAG_USE_CURR_DATA
Definition: vnet_classify.h:40
vnet_classify_bucket_t::as_u64
u64 as_u64
Definition: vnet_classify.h:143
vnet_classify_hash_packet_inline
static u64 vnet_classify_hash_packet_inline(vnet_classify_table_t *t, const u8 *h)
Definition: vnet_classify.h:250
unformat_l3_match
unformat_function_t unformat_l3_match
Definition: vnet_classify.h:560
unformat_l3_mask
unformat_function_t unformat_l3_mask
Definition: vnet_classify.h:553
vnet_classify_entry_t
struct _vnet_classify_entry vnet_classify_entry_t
unformat_l2_next_index
unformat_function_t unformat_l2_next_index
Definition: vnet_classify.h:556
vnet_classify_table_t::saved_bucket
vnet_classify_bucket_t saved_bucket
Definition: vnet_classify.h:191
ip4_classify_node
vlib_node_registration_t ip4_classify_node
(constructor) VLIB_REGISTER_NODE (ip4_classify_node)
Definition: ip_classify.c:313
ip6_classify_node
vlib_node_registration_t ip6_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_classify_node)
Definition: ip_classify.c:334
vnet_classify_table_get
static_always_inline vnet_classify_table_t * vnet_classify_table_get(u32 table_index)
Definition: vnet_classify.h:242
vnet_classify_entry_is_free
static int vnet_classify_entry_is_free(vnet_classify_entry_t *e)
Definition: vnet_classify.h:111
vnet_classify_table_t::miss_next_index
u32 miss_next_index
Definition: vnet_classify.h:176
clib_mem_get_heap_base
void * clib_mem_get_heap_base(clib_mem_heap_t *heap)
Definition: mem_dlmalloc.c:586
vnet_classify_table_t::current_data_offset
i16 current_data_offset
Definition: vnet_classify.h:173
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vnet_classify_add_del_session
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, const u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, u8 action, u16 metadata, int is_add)
Definition: vnet_classify.c:2745
classify_set_pcap_chain
void classify_set_pcap_chain(vnet_classify_main_t *cm, u32 sw_if_index, u32 table_index)
Definition: vnet_classify.c:1761
vnet_classify_table_t::mask
u32x4 * mask
Definition: vnet_classify.h:151
vnet_classify_main
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:32
unformat_ip_next_index
unformat_function_t unformat_ip_next_index
Definition: vnet_classify.h:557
vnet_classify_delete_table_index
void vnet_classify_delete_table_index(vnet_classify_main_t *cm, u32 table_index, int del_chain)
Definition: vnet_classify.c:164
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
CLIB_CACHE_LINE_ALIGN_MARK
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
unformat_ip4_match
unformat_function_t unformat_ip4_match
Definition: vnet_classify.h:558
classify_sort_table_chain
u32 classify_sort_table_chain(vnet_classify_main_t *cm, u32 table_index)
Definition: vnet_classify.c:1680
classify_get_trace_chain
u32 classify_get_trace_chain(void)
Definition: pnat_test_stubs.h:30
vnet_classify_find_entry
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
Definition: vnet_classify.c:657
unformat_l4_match
unformat_function_t unformat_l4_match
Definition: vnet_classify.h:561
vnet_classify_action_t_
vnet_classify_action_t_
Definition: vnet_classify.h:52
vnet_classify_entry_at_index
static vnet_classify_entry_t * vnet_classify_entry_at_index(vnet_classify_table_t *t, vnet_classify_entry_t *e, u32 index)
Definition: vnet_classify.h:357
u16
unsigned short u16
Definition: types.h:57
vnet_classify_get_entry
static vnet_classify_entry_t * vnet_classify_get_entry(vnet_classify_table_t *t, uword offset)
Definition: vnet_classify.h:335
unformat_l2_match
unformat_function_t unformat_l2_match
Definition: vnet_classify.h:563
u32x4_zero_byte_mask
static u32 u32x4_zero_byte_mask(u32x4 x)
Definition: vector_altivec.h:133
vnet_classify_table_t::entries_per_page
u32 entries_per_page
Definition: vnet_classify.h:165
vnet_classify_bucket_t::offset
u32 offset
Definition: vnet_classify.h:138
vnet_classify_register_unformat_l2_next_index_fn
void vnet_classify_register_unformat_l2_next_index_fn(unformat_function_t *fn)
Definition: vnet_classify.c:90
memory_size
u64 memory_size
Definition: vhost_user.h:124
h
h
Definition: flowhash_template.h:372
key
typedef key
Definition: ipsec_types.api:88
i32
signed int i32
Definition: types.h:77
unformat_classify_match
unformat_function_t unformat_classify_match
Definition: vnet_classify.h:564
unformat_l2_mask
unformat_function_t unformat_l2_mask
Definition: vnet_classify.h:554
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
i16
signed short i16
Definition: types.h:46
CLASSIFY_ACTION_NONE
@ CLASSIFY_ACTION_NONE
Definition: vnet_classify.h:54
unformat_ip6_mask
unformat_function_t unformat_ip6_mask
Definition: vnet_classify.h:552
vnet_classify_register_unformat_acl_next_index_fn
void vnet_classify_register_unformat_acl_next_index_fn(unformat_function_t *fn)
Definition: vnet_classify.c:106
vnet_classify_table_t::skip_n_vectors
u32 skip_n_vectors
Definition: vnet_classify.h:166
error.h
unformat_ip4_mask
unformat_function_t unformat_ip4_mask
Definition: vnet_classify.h:551
vnet_classify_entry_is_busy
static int vnet_classify_entry_is_busy(vnet_classify_entry_t *e)
Definition: vnet_classify.h:117
vnet_classify_table_t::working_copy_lengths
int * working_copy_lengths
Definition: vnet_classify.h:190
offset
struct clib_bihash_value offset
template key/value backing page structure
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_classify_action_t
enum vnet_classify_action_t_ vnet_classify_action_t
STATIC_ASSERT_OFFSET_OF
STATIC_ASSERT_OFFSET_OF(vnet_classify_entry_t, key, 32)
Check there's no padding in the entry.
static_always_inline
#define static_always_inline
Definition: clib.h:112
clib_spinlock_s
Definition: lock.h:51
vnet_classify_table_t::freelists
vnet_classify_entry_t ** freelists
Definition: vnet_classify.h:194
vnet_classify_prefetch_entry
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:371
vnet_classify_flags_t
enum vnet_classify_flags_t_ vnet_classify_flags_t
uword
u64 uword
Definition: types.h:112
crc32.h
vnet_classify_prefetch_bucket
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:323
vnet_classify_register_unformat_ip_next_index_fn
void vnet_classify_register_unformat_ip_next_index_fn(unformat_function_t *fn)
Definition: vnet_classify.c:98
vnet_classify_table_t::buckets
vnet_classify_bucket_t * buckets
Definition: vnet_classify.h:154
VNET_CLASSIFY_ENTRY_FREE
#define VNET_CLASSIFY_ENTRY_FREE
Definition: vnet_classify.h:94
vnet_classify_flags_t_
vnet_classify_flags_t_
Definition: vnet_classify.h:37
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:591
vnet_classify_table_t::working_copies
vnet_classify_entry_t ** working_copies
Definition: vnet_classify.h:189
clib_xxhash
static u64 clib_xxhash(u64 key)
Definition: xxhash.h:58
vnet_classify_table_t
Definition: vnet_classify.h:147
CLASSIFY_ACTION_SET_METADATA
@ CLASSIFY_ACTION_SET_METADATA
Definition: vnet_classify.h:57
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vnet_classify_table_t::user_ctx
uword user_ctx
Definition: vnet_classify.h:161
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vnet_classify_table_t::nbuckets
u32 nbuckets
Definition: vnet_classify.h:163
CLASSIFY_ACTION_SET_IP6_FIB_INDEX
@ CLASSIFY_ACTION_SET_IP6_FIB_INDEX
Definition: vnet_classify.h:56
data
u8 data[128]
Definition: ipsec_types.api:92
CLASSIFY_FLAG_NONE
@ CLASSIFY_FLAG_NONE
Definition: vnet_classify.h:39
vnet_classify_table_t::next_table_index
u32 next_table_index
Definition: vnet_classify.h:170
xxhash.h
vnet_main_t
Definition: vnet.h:76
unformat_classify_mask
unformat_function_t unformat_classify_mask
Definition: vnet_classify.h:555
index
u32 index
Definition: flow_types.api:221
classify_lookup_chain
u32 classify_lookup_chain(u32 table_index, u8 *mask, u32 n_skip, u32 n_match)
Definition: vnet_classify.c:1800
vnet_classify_register_unformat_opaque_index_fn
void vnet_classify_register_unformat_opaque_index_fn(unformat_function_t *fn)
Definition: vnet_classify.c:123
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
u64
unsigned long u64
Definition: types.h:89
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
cache.h
vnet_classify_table_t::match_n_vectors
u32 match_n_vectors
Definition: vnet_classify.h:167
u32
unsigned int u32
Definition: types.h:88
vnet_classify_new_table
vnet_classify_table_t * vnet_classify_new_table(vnet_classify_main_t *cm, const u8 *mask, u32 nbuckets, u32 memory_size, u32 skip_n_vectors, u32 match_n_vectors)
Definition: vnet_classify.c:131
format_vnet_classify_table
u8 * format_vnet_classify_table(u8 *s, va_list *args)
Definition: vnet_classify.c:2207
u32x4
unsigned long long u32x4
Definition: ixge.c:28
as_u64
u64 as_u64
Definition: bihash_doc.h:63
vnet_classify_main_t
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:61
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:225
vnet_classify_find_entry_inline
static vnet_classify_entry_t * vnet_classify_find_entry_inline(vnet_classify_table_t *t, const u8 *h, u64 hash, f64 now)
Definition: vnet_classify.h:399
CLASSIFY_ACTION_SET_IP4_FIB_INDEX
@ CLASSIFY_ACTION_SET_IP4_FIB_INDEX
Definition: vnet_classify.h:55
unformat_vlan_tag
unformat_function_t unformat_vlan_tag
Definition: vnet_classify.h:562
vnet_classify_bucket_t::linear_search
u8 linear_search
Definition: vnet_classify.h:139
vnet_classify_table_t::mheap
void * mheap
Definition: vnet_classify.h:158
vnet_classify_hash_packet
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
vnet_classify_get_offset
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
Definition: vnet_classify.h:344
now
f64 now
Definition: nat44_ei_out2in.c:710
vnet_main
vnet_main_t vnet_main
Definition: misc.c:43
vnet_classify_bucket_t::log2_pages
u8 log2_pages
Definition: vnet_classify.h:141
vlib_main_t
Definition: main.h:102
hash.h
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
vnet_classify_table_t::writer_lock
clib_spinlock_t writer_lock
Definition: vnet_classify.h:197
vnet_classify_add_del_table
int vnet_classify_add_del_table(vnet_classify_main_t *cm, const u8 *mask, u32 nbuckets, u32 memory_size, u32 skip, u32 match, u32 next_table_index, u32 miss_next_index, u32 *table_index, u8 current_data_flag, i16 current_data_offset, int is_add, int del_chain)
Definition: vnet_classify.c:747
pad
u8 pad[3]
log2 (size of the packing page block)
Definition: bihash_doc.h:61
vnet_classify_register_unformat_policer_next_index_fn
void vnet_classify_register_unformat_policer_next_index_fn(unformat_function_t *fn)
Definition: vnet_classify.c:114
vlib_main
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1914
vnet_classify_table_t::current_data_flag
vnet_classify_flags_t current_data_flag
Definition: vnet_classify.h:174
vnet.h
api_errno.h
vnet_classify_table_t::log2_nbuckets
u32 log2_nbuckets
Definition: vnet_classify.h:164
foreach_size_in_u32x4
#define foreach_size_in_u32x4
Definition: vnet_classify.h:63
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
is_pow2
static uword is_pow2(uword x)
Definition: clib.h:267
action
vl_api_mac_event_action_t action
Definition: l2.api:211
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
unformat_ip6_match
unformat_function_t unformat_ip6_match
Definition: vnet_classify.h:559
vnet_classify_bucket_t
Definition: vnet_classify.h:132
format_classify_table
u8 * format_classify_table(u8 *s, va_list *args)
Definition: vnet_classify.c:687
vnet_classify_table_t::data_offset
u32 data_offset
Definition: vnet_classify.h:186
vnet_classify_table_t::linear_buckets
u32 linear_buckets
Definition: vnet_classify.h:184
classify_get_pcap_chain
u32 classify_get_pcap_chain(vnet_classify_main_t *cm, u32 sw_if_index)
Definition: vnet_classify.c:1749
vnet_classify_table_t::active_elements
u32 active_elements
Definition: vnet_classify.h:185
classify_set_trace_chain
void classify_set_trace_chain(vnet_classify_main_t *cm, u32 table_index)
Definition: vnet_classify.c:1734
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105