15 #ifndef __included_vnet_classify_h__ 16 #define __included_vnet_classify_h__ 30 #define CLASSIFY_TRACE 0 37 #define CLASSIFY_FLAG_USE_CURR_DATA 1 55 struct _vnet_classify_main;
58 #define foreach_size_in_u32x4 \ 82 #define VNET_CLASSIFY_ENTRY_FREE (1<<0) 90 struct _vnet_classify_entry * next_free;
97 }) vnet_classify_entry_t;
115 typedef CLIB_PACKED(struct { \ 119 }) vnet_classify_entry_##size##_t; 183 struct _vnet_classify_main
196 u32 *classify_table_index_by_sw_if_index;
218 } xor_sum __attribute__ ((aligned (
sizeof (
u32x4))));
222 #ifdef CLIB_HAVE_VEC128 223 u32x4u *
data = (u32x4u *) h;
247 xor_sum.as_u64[0] = data64[0 + skip_u64] & ((
u64 *) mask)[0];
248 xor_sum.as_u64[1] = data64[1 + skip_u64] & ((
u64 *) mask)[1];
252 xor_sum.as_u64[0] ^= data64[8 + skip_u64] & ((
u64 *) mask)[8];
253 xor_sum.as_u64[1] ^= data64[9 + skip_u64] & ((
u64 *) mask)[9];
256 xor_sum.as_u64[0] ^= data64[6 + skip_u64] & ((
u64 *) mask)[6];
257 xor_sum.as_u64[1] ^= data64[7 + skip_u64] & ((
u64 *) mask)[7];
260 xor_sum.as_u64[0] ^= data64[4 + skip_u64] & ((
u64 *) mask)[4];
261 xor_sum.as_u64[1] ^= data64[5 + skip_u64] & ((
u64 *) mask)[5];
264 xor_sum.as_u64[0] ^= data64[2 + skip_u64] & ((
u64 *) mask)[2];
265 xor_sum.as_u64[1] ^= data64[3 + skip_u64] & ((
u64 *) mask)[3];
275 #ifdef clib_crc32c_uses_intrinsics 276 return clib_crc32c ((
u8 *) & xor_sum,
sizeof (xor_sum));
278 return clib_xxhash (xor_sum.as_u64[0] ^ xor_sum.as_u64[1]);
289 bucket_index = hash & (t->
nbuckets - 1);
294 static inline vnet_classify_entry_t *
305 vnet_classify_entry_t * v)
312 ASSERT ((vp - hp) < 0x100000000ULL);
316 static inline vnet_classify_entry_t *
318 vnet_classify_entry_t * e,
u32 index)
324 eu8 += index * (
sizeof (vnet_classify_entry_t) +
327 return (vnet_classify_entry_t *) eu8;
336 vnet_classify_entry_t *e;
338 bucket_index = hash & (t->
nbuckets - 1);
348 value_index = hash & ((1 << b->log2_pages) - 1);
358 static inline vnet_classify_entry_t *
362 vnet_classify_entry_t *v;
368 } result __attribute__ ((aligned (
sizeof (
u32x4))));
375 bucket_index = hash & (t->
nbuckets - 1);
385 value_index = hash & ((1 << b->log2_pages) - 1);
390 limit *= (1 << b->log2_pages);
395 #ifdef CLIB_HAVE_VEC128 396 u32x4u *
data = (u32x4u *) h;
397 for (i = 0; i < limit; i++)
400 result.as_u32x4 = (data[0 + t->
skip_n_vectors] & mask[0]) ^ key[0];
404 result.as_u32x4 |= (data[4 + t->
skip_n_vectors] & mask[4]) ^ key[4];
407 result.as_u32x4 |= (data[3 + t->
skip_n_vectors] & mask[3]) ^ key[3];
410 result.as_u32x4 |= (data[2 + t->
skip_n_vectors] & mask[2]) ^ key[2];
413 result.as_u32x4 |= (data[1 + t->
skip_n_vectors] & mask[1]) ^ key[1];
435 for (i = 0; i < limit; i++)
440 (data64[0 + skip_u64] & ((
u64 *) mask)[0]) ^ ((
u64 *)
key)[0];
442 (data64[1 + skip_u64] & ((
u64 *) mask)[1]) ^ ((
u64 *)
key)[1];
447 (data64[8 + skip_u64] & ((
u64 *) mask)[8]) ^ ((
u64 *)
key)[8];
449 (data64[9 + skip_u64] & ((
u64 *) mask)[9]) ^ ((
u64 *)
key)[9];
453 (data64[6 + skip_u64] & ((
u64 *) mask)[6]) ^ ((
u64 *)
key)[6];
455 (data64[7 + skip_u64] & ((
u64 *) mask)[7]) ^ ((
u64 *)
key)[7];
459 (data64[4 + skip_u64] & ((
u64 *) mask)[4]) ^ ((
u64 *)
key)[4];
461 (data64[5 + skip_u64] & ((
u64 *) mask)[5]) ^ ((
u64 *)
key)[5];
465 (data64[2 + skip_u64] & ((
u64 *) mask)[2]) ^ ((
u64 *)
key)[2];
467 (data64[3 + skip_u64] & ((
u64 *) mask)[3]) ^ ((
u64 *)
key)[3];
475 if (result.as_u64[0] == 0 && result.as_u64[1] == 0)
492 u8 * mask,
u32 nbuckets,
495 u32 match_n_vectors);
503 u8 action,
u32 metadata,
int is_add);
511 u32 next_table_index,
514 u8 current_data_flag,
515 i16 current_data_offset,
516 int is_add,
int del_chain);
557 u8 * mask,
u32 n_skip,
u32 n_match);
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
unformat_function_t unformat_ip4_match
vnet_classify_entry_t ** working_copies
unformat_function_t unformat_vlan_tag
u8 pad[3]
log2 (size of the packing page block)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
unformat_function_t unformat_l2_mask
unformat_function_t unformat_ip_next_index
enum vnet_classify_action_t_ vnet_classify_action_t
vl_api_wireguard_peer_flags_t flags
#define foreach_size_in_u32x4
static vnet_classify_entry_t * vnet_classify_find_entry_inline(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
#define VNET_CLASSIFY_ENTRY_FREE
unformat_function_t unformat_ip6_mask
static u64 clib_xxhash(u64 key)
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, u8 action, u32 metadata, int is_add)
unformat_function_t unformat_classify_match
vnet_classify_table_t * vnet_classify_new_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip_n_vectors, u32 match_n_vectors)
unformat_function_t unformat_l3_mask
void classify_set_pcap_chain(vnet_classify_main_t *cm, u32 sw_if_index, u32 table_index)
unformat_function_t unformat_ip4_mask
unformat_function_t unformat_classify_mask
clib_spinlock_t writer_lock
void vnet_classify_register_unformat_opaque_index_fn(unformat_function_t *fn)
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
void classify_set_trace_chain(vnet_classify_main_t *cm, u32 table_index)
u8 * format_classify_table(u8 *s, va_list *args)
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
static int vnet_classify_entry_is_free(vnet_classify_entry_t *e)
u32 classify_sort_table_chain(vnet_classify_main_t *cm, u32 table_index)
static u64 vnet_classify_hash_packet_inline(vnet_classify_table_t *t, u8 *h)
u32 classify_lookup_chain(u32 table_index, u8 *mask, u32 n_skip, u32 n_match)
unformat_function_t unformat_l3_match
vnet_classify_entry_t * entries
u32 classify_get_trace_chain(void)
unformat_function_t unformat_l2_next_index
void vnet_classify_register_unformat_policer_next_index_fn(unformat_function_t *fn)
u32 classify_get_pcap_chain(vnet_classify_main_t *cm, u32 sw_if_index)
static vnet_classify_entry_t * vnet_classify_entry_at_index(vnet_classify_table_t *t, vnet_classify_entry_t *e, u32 index)
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
vnet_classify_bucket_t saved_bucket
#define CLIB_PREFETCH(addr, size, type)
void vnet_classify_register_unformat_l2_next_index_fn(unformat_function_t *fn)
sll srl srl sll sra u16x4 i
void vnet_classify_register_unformat_acl_next_index_fn(unformat_function_t *fn)
void * clib_mem_get_heap_base(clib_mem_heap_t *heap)
struct _vnet_classify_main vnet_classify_main_t
typedef CLIB_PACKED(struct _vnet_classify_entry { u32 next_index;union { struct { u32 opaque_index;i32 advance;};u64 opaque_count;};u8 flags;#define VNET_CLASSIFY_ENTRY_FREE vnet_classify_action_t action;u16 metadata;union { u64 hits;struct _vnet_classify_entry *next_free;};f64 last_heard;u32x4 key[0];}) vnet_classify_entry_t
unformat_function_t unformat_ip6_match
static uword is_pow2(uword x)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
static int vnet_classify_entry_is_busy(vnet_classify_entry_t *e)
struct _vlib_node_registration vlib_node_registration_t
template key/value backing page structure
vlib_node_registration_t ip6_classify_node
(constructor) VLIB_REGISTER_NODE (ip6_classify_node)
vl_api_mac_event_action_t action
vnet_classify_bucket_t * buckets
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
vlib_node_registration_t ip4_classify_node
(constructor) VLIB_REGISTER_NODE (ip4_classify_node)
unformat_function_t unformat_l4_match
void vnet_classify_register_unformat_ip_next_index_fn(unformat_function_t *fn)
struct clib_bihash_value offset
template key/value backing page structure
unformat_function_t unformat_l2_match
int * working_copy_lengths
#define CLIB_CACHE_LINE_BYTES
vnet_classify_entry_t ** freelists
vnet_classify_main_t vnet_classify_main
vl_api_interface_index_t sw_if_index
static u32 u32x4_zero_byte_mask(u32x4 x)
static vnet_classify_entry_t * vnet_classify_get_entry(vnet_classify_table_t *t, uword offset)
int vnet_classify_add_del_table(vnet_classify_main_t *cm, 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)