FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
hash.h
Go to the documentation of this file.
1 /*
2  * SPDX-License-Identifier: Apache-2.0
3  * Copyright(c) 2021 Cisco Systems, Inc.
4  */
5 
6 #ifndef __VNET_HASH_H__
7 #define __VNET_HASH_H__
8 
9 #include <vlib/vlib.h>
10 
11 #define foreach_vnet_hash_fn_types \
12  _ (ETHERNET, 0, "hash-fn-ethernet") \
13  _ (IP, 1, "hash-fn-ip")
14 
15 typedef enum
16 {
17 #define _(f, n, s) VNET_HASH_FN_TYPE_##f,
19 #undef _
22 
23 typedef void (*vnet_hash_fn_t) (void **p, u32 *h, u32 n_packets);
24 
26 {
27  const char *name;
28  const char *description;
29  int priority;
31 
34 
35 typedef struct
36 {
39 
41 
42 #define VNET_REGISTER_HASH_FUNCTION(x, ...) \
43  __VA_ARGS__ vnet_hash_function_registration_t __vnet_hash_function_##x; \
44  static void __clib_constructor __vnet_hash_function_registration_##x (void) \
45  { \
46  vnet_hash_main_t *hm = &vnet_hash_main; \
47  __vnet_hash_function_##x.next = hm->hash_registrations; \
48  hm->hash_registrations = &__vnet_hash_function_##x; \
49  } \
50  __VA_ARGS__ vnet_hash_function_registration_t __vnet_hash_function_##x
51 
54  vnet_hash_fn_type_t ftype);
58 
59 #endif
vlib.h
foreach_vnet_hash_fn_types
#define foreach_vnet_hash_fn_types
Definition: hash.h:11
format_vnet_hash
format_function_t format_vnet_hash
Definition: hash.h:57
vnet_hash_function_registration::priority
int priority
Definition: hash.h:29
name
string name[64]
Definition: fib.api:25
vnet_hash_fn_t
void(* vnet_hash_fn_t)(void **p, u32 *h, u32 n_packets)
Definition: hash.h:23
vnet_hash_fn_type_t
vnet_hash_fn_type_t
Definition: hash.h:15
vnet_hash_function_registration_t
struct vnet_hash_function_registration vnet_hash_function_registration_t
h
h
Definition: flowhash_template.h:372
vnet_hash_function_registration::next
struct vnet_hash_function_registration * next
Definition: hash.h:32
vnet_hash_function_from_func
vnet_hash_function_registration_t * vnet_hash_function_from_func(vnet_hash_fn_t fn, vnet_hash_fn_type_t ftype)
Definition: hash.c:58
VNET_HASH_FN_TYPE_N
@ VNET_HASH_FN_TYPE_N
Definition: hash.h:20
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
vnet_hash_main
vnet_hash_main_t vnet_hash_main
Definition: hash.c:11
vnet_hash_function_registration
Definition: hash.h:25
u32
unsigned int u32
Definition: types.h:88
vnet_hash_main_t
Definition: hash.h:35
vnet_hash_function_registration::description
const char * description
Definition: hash.h:28
vnet_hash_function_from_name
vnet_hash_fn_t vnet_hash_function_from_name(const char *name, vnet_hash_fn_type_t ftype)
Definition: hash.c:43
vnet_hash_main_t::hash_registrations
vnet_hash_function_registration_t * hash_registrations
Definition: hash.h:37
vnet_hash_default_function
vnet_hash_fn_t vnet_hash_default_function(vnet_hash_fn_type_t ftype)
select hash func with highest priority
Definition: hash.c:29
vnet_hash_function_registration::name
const char * name
Definition: hash.h:27