|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
15 #ifndef __included_ioam_cache_h__
16 #define __included_ioam_cache_h__
159 #define MAX_CACHE_ENTRIES 4096
161 #define MAX_CACHE_TS_ENTRIES 1048576
163 #define IOAM_CACHE_TABLE_DEFAULT_HASH_NUM_BUCKETS (4 * 1024)
164 #define IOAM_CACHE_TABLE_DEFAULT_HASH_MEMORY_SIZE (2<<20)
236 t1 = (
ip->src_address.as_u64[0] ^
ip->src_address.as_u64[1]);
237 t1 = (flow_hash_config & IP_FLOW_HASH_SRC_ADDR) ? t1 : 0;
239 t2 = (
ip->dst_address.as_u64[0] ^
ip->dst_address.as_u64[1]);
240 t2 = (flow_hash_config & IP_FLOW_HASH_DST_ADDR) ? t2 : 0;
242 a = (flow_hash_config & IP_FLOW_HASH_REVERSE_SRC_DST) ? t2 : t1;
243 b = (flow_hash_config & IP_FLOW_HASH_REVERSE_SRC_DST) ? t1 : t2;
244 b ^= (flow_hash_config & IP_FLOW_HASH_PROTO) ?
protocol : 0;
249 t1 = (flow_hash_config & IP_FLOW_HASH_SRC_PORT) ? t1 : 0;
250 t2 = (flow_hash_config & IP_FLOW_HASH_DST_PORT) ? t2 : 0;
252 c = (flow_hash_config & IP_FLOW_HASH_REVERSE_SRC_DST) ?
253 ((t1 << 16) | t2) : ((t2 << 16) | t1);
266 #define HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE_ID 30
267 #define HBH_OPTION_TYPE_IOAM_E2E_CACHE_ID 31
273 }) ioam_e2e_id_option_t;
279 }) ioam_e2e_cache_option_t;
281 #define IOAM_E2E_ID_OPTION_RND ((sizeof(ioam_e2e_id_option_t) + 7) & ~7)
282 #define IOAM_E2E_ID_HBH_EXT_LEN (IOAM_E2E_ID_OPTION_RND >> 3)
283 #define IOAM_E2E_CACHE_OPTION_RND ((sizeof(ioam_e2e_cache_option_t) + 7) & ~7)
284 #define IOAM_E2E_CACHE_HBH_EXT_LEN (IOAM_E2E_CACHE_OPTION_RND >> 3)
290 e2e_option->id.as_u64[0] =
address->as_u64[0];
291 e2e_option->id.as_u64[1] =
address->as_u64[1];
328 IP_FLOW_HASH_REVERSE_SRC_DST);
331 kv.
key = (
u64) flow_hash << 32 | seq_no;
336 if (clib_bihash_search_8_8 (&
cm->ioam_rewrite_cache_table, &kv, &
value) >=
349 clib_bihash_add_del_8_8 (&
cm->ioam_rewrite_cache_table, &kv, 0);
372 u32 rewrite_len = 0, e2e_id_offset = 0;
374 ioam_e2e_id_option_t *e2e = 0;
378 pool_index = entry -
cm->ioam_rewrite_pool;
381 sizeof (ip6_address_t));
383 sizeof (ip6_address_t));
387 rewrite_len = ((hbh0->
length + 1) << 3);
392 entry->
next_hop.as_u64[0] = e2e->id.as_u64[0];
393 entry->
next_hop.as_u64[1] = e2e->id.as_u64[1];
399 e2e_id_offset = (
u8 *) e2e - (
u8 *) hbh0;
414 kv.
key = (
u64) flow_hash << 32 | seq_no;
416 if (clib_bihash_search_8_8 (&
cm->ioam_rewrite_cache_table, &kv, &
value) >=
422 kv.
value = pool_index;
423 clib_bihash_add_del_8_8 (&
cm->ioam_rewrite_cache_table, &kv, 1);
437 ip6_address_t *segments = 0;
438 ip6_address_t *this_seg = 0;
443 clib_memset (this_seg, 0xfe,
sizeof (ip6_address_t));
456 cm->lookup_table_nbuckets = 1 <<
max_log2 (
cm->lookup_table_nbuckets);
459 clib_bihash_init_8_8 (&
cm->ioam_rewrite_cache_table,
460 "ioam rewrite cache table",
461 cm->lookup_table_nbuckets,
cm->lookup_table_size);
473 clib_bihash_free_8_8 (&
cm->ioam_rewrite_cache_table);
479 cm->ioam_rewrite_pool = 0;
481 cm->sr_rewrite_template = 0;
492 s =
format (s,
"%d: %U:%d to %U:%d seq_no %lu\n",
493 (e -
cm->ioam_rewrite_pool),
510 #define IOAM_CACHE_TS_TIMEOUT 1.0 //SYN timeout 1 sec
511 #define IOAM_CACHE_TS_TICK 100e-3
513 #define IOAM_CACHE_TS_TIMEOUT_TICKS IOAM_CACHE_TS_TICK*9
514 #define TIMER_HANDLE_INVALID ((u32) ~0)
540 cm->lookup_table_nbuckets = 1 <<
max_log2 (
cm->lookup_table_nbuckets);
542 for (
i = 0;
i < no_of_threads;
i++)
547 tw_timer_wheel_init_16t_2w_512sl (&
cm->timer_wheels[
i],
563 = tw_timer_start_16t_2w_512sl (&
cm->timer_wheels[entry->
pool_id],
571 tw_timer_stop_16t_2w_512sl (&
cm->timer_wheels[entry->
pool_id],
596 pool_put (
cm->ioam_ts_pool[thread_id], entry);
597 cm->ts_stats[thread_id].inuse--;
611 for (
i = 0;
i < no_of_threads;
i++)
618 cm->ioam_ts_pool = 0;
619 tw_timer_wheel_free_16t_2w_512sl (&
cm->timer_wheels[
i]);
651 cm->ts_stats[thread_id].add_failed++;
658 *pool_index = entry -
cm->ioam_ts_pool[thread_id];
661 sizeof (ip6_address_t));
663 sizeof (ip6_address_t));
675 cm->ts_stats[thread_id].inuse++;
699 if (entry && entry->
hbh)
757 u32 * pool_index,
u8 * thread_id,
u8 response_seen)
761 ioam_e2e_cache_option_t *e2e = 0;
765 (ioam_e2e_cache_option_t *) ((
u8 *) hbh0 +
cm->rewrite_pool_index_offset);
766 if ((
u8 *) e2e < ((
u8 *) hbh0 + ((hbh0->
length + 1) << 3))
771 *thread_id = e2e->pool_id;
796 u32 thread_id = va_arg (*args,
u32);
798 ioam_e2e_id_option_t *e2e = 0;
813 "%d: %U:%d to %U:%d seq_no %u buffer %u %U \n\t\tCreated at %U Received %d\n",
827 "%d: %U:%d to %U:%d seq_no %u Buffer %u \n\t\tCreated at %U Received %d\n",
856 ioam_e2e_cache_option_t *e2e = 0;
857 ioam_e2e_id_option_t *e2e_id = 0;
863 rewrite_len = ((hbh->
length + 1) << 3);
870 cm->rewrite_pool_index_offset = rewrite_len;
871 e2e = (ioam_e2e_cache_option_t *) (
cm->rewrite + rewrite_len);
874 e2e->hdr.length =
sizeof (ioam_e2e_cache_option_t) -
878 (ioam_e2e_id_option_t *) ((
u8 *) e2e +
sizeof (ioam_e2e_cache_option_t));
883 e2e_id->e2e_type = 1;
895 cm->rewrite_pool_index_offset = 0;
#define IOAM_CACHE_TS_TIMEOUT
ioam_cache_entry_t * ioam_rewrite_pool
static int ioam_cache_ts_lookup(ip6_header_t *ip0, u8 protocol, u16 src_port, u16 dst_port, u32 seq_no, ip6_hop_by_hop_header_t **hbh, u32 *pool_index, u8 *thread_id, u8 response_seen)
static ioam_cache_entry_t * ioam_cache_lookup(ip6_header_t *ip0, u16 src_port, u16 dst_port, u32 seq_no)
static u8 * format_ioam_cache_ts_entry(u8 *s, va_list *args)
u32 timer_handle
Handle returned from tw_start_timer.
static ioam_cache_entry_t * ioam_cache_entry_cleanup(u32 pool_index)
vl_api_ip_port_and_mask_t dst_port
static u8 * format_ioam_cache_entry(u8 *s, va_list *args)
static void ioam_cache_ts_entry_free(u32 thread_id, ioam_cache_ts_entry_t *entry, u32 node_index)
#define MAX_CACHE_ENTRIES
ip6_address_t sr_localsid_cache
ip6_address_t src_address
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
ip6_address_t dst_address
ioam_cache_main_t ioam_cache_main
int ip6_address_compare(ip6_address_t *a1, ip6_address_t *a2)
tw_timer_wheel_16t_2w_512sl_t * timer_wheels
per thread single-wheel
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
int ip6_ioam_set_rewrite(u8 **rwp, int has_trace_option, int has_pot_option, int has_seqno_option)
static void ioam_cache_ts_check_and_send(u32 thread_id, i32 pool_index)
vlib_node_registration_t ioam_cache_ts_node
(constructor) VLIB_REGISTER_NODE (ioam_cache_ts_node)
#define HBH_OPTION_TYPE_SKIP_UNKNOWN
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static int ip6_ioam_ts_cache_cleanup_rewrite(void)
static int ioam_cache_ts_table_destroy(vlib_main_t *vm)
u64 lookup_table_nbuckets
vlib_worker_thread_t * vlib_worker_threads
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
typedef CLIB_PACKED(struct { ip6_hop_by_hop_option_t hdr;u8 e2e_type;u8 reserved[5];ip6_address_t id;}) ioam_e2e_id_option_t
static int ioam_cache_ts_add(ip6_header_t *ip0, u16 src_port, u16 dst_port, u32 seq_no, u8 max_responses, u64 now, u32 thread_id, u32 *pool_index)
#define TIMER_HANDLE_INVALID
static int ip6_ioam_ts_cache_set_rewrite(void)
static uword max_log2(uword x)
Segment Routing data structures definitions.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define pool_foreach(VAR, POOL)
Iterate through pool.
static u32 ip6_compute_flow_hash_ext(const ip6_header_t *ip, u8 protocol, u16 src_port, u16 dst_port, flow_hash_config_t flow_hash_config)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
u32 ip6_add_from_cache_hbh_node_index
static void ioam_cache_ts_send(u32 thread_id, i32 pool_index)
u8 rewrite_pool_index_offset
#define IOAM_E2E_CACHE_HBH_EXT_LEN
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void * ip6_ioam_find_hbh_option(ip6_hop_by_hop_header_t *hbh0, u8 option)
f64 end
end of the time range
enum flow_hash_config_t_ flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple + flowlabel without the "reverse" bit.
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
vl_api_ip_port_and_mask_t src_port
vnet_feature_config_main_t * cm
clib_bihash_8_8_t ioam_rewrite_cache_table
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
manual_print typedef address
static int ioam_cache_add(vlib_buffer_t *b0, ip6_header_t *ip0, u16 src_port, u16 dst_port, ip6_hop_by_hop_header_t *hbh0, u32 seq_no)
#define MAX_CACHE_TS_ENTRIES
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
u32 ip6_reset_ts_hbh_node_index
#define IOAM_CACHE_TABLE_DEFAULT_HASH_NUM_BUCKETS
static void ioam_e2e_id_rewrite_handler(ioam_e2e_id_option_t *e2e_option, ip6_address_t *address)
#define pool_alloc_aligned(P, N, A)
Allocate N more free elements to pool (general version).
ip6_address_t src_address
ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main
static int ioam_cache_table_init(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
u32 ip6_hbh_pop_node_index
static void ioam_cache_ts_timer_set(ioam_cache_main_t *cm, ioam_cache_ts_entry_t *entry, u32 interval)
vlib_node_registration_t ioam_cache_node
(constructor) VLIB_REGISTER_NODE (ioam_cache_node)
description fragment has unexpected format
u32 cleanup_process_node_index
#define IOAM_E2E_ID_HBH_EXT_LEN
#define IOAM_CACHE_TABLE_DEFAULT_HASH_MEMORY_SIZE
static void ioam_cache_entry_free(ioam_cache_entry_t *entry)
vl_api_ip_proto_t protocol
#define HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE_ID
void ioam_cache_ts_timer_node_enable(vlib_main_t *vm, u8 enable)
8 octet key, 8 octet key value pair
static int ioam_cache_table_destroy(vlib_main_t *vm)
#define IOAM_CACHE_TS_TICK
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
ioam_cache_ts_pool_stats_t * ts_stats
#define pool_free(p)
Free a pool.
static u8 * ip6_sr_compute_rewrite_string_insert(ip6_address_t *sl)
SR rewrite string computation for SRH insertion (inline)
static int ioam_cache_ts_table_init(vlib_main_t *vm)
ip6_hop_by_hop_header_t * hbh
ip6_address_t sr_localsid_ts
ioam_cache_ts_entry_t ** ioam_ts_pool
static f64 vlib_time_now(vlib_main_t *vm)
void expired_cache_ts_timer_callback(u32 *expired_timers)
u32 expected_to_expire
entry should expire at this clock tick
#define hash_mix64(a0, b0, c0)
static int ioam_cache_ts_entry_cleanup(u32 thread_id, u32 pool_index)
#define HBH_OPTION_TYPE_IOAM_E2E_CACHE_ID
static void ioam_cache_sr_rewrite_template_create(void)
ip6_address_t dst_address
u64 cpu_time_main_loop_start
u8 * format_ip6_hop_by_hop_ext_hdr(u8 *s, va_list *args)
#define IOAM_E2E_CACHE_OPTION_RND
static void ioam_cache_ts_timer_reset(ioam_cache_main_t *cm, ioam_cache_ts_entry_t *entry)
#define IOAM_E2E_ID_OPTION_RND
VLIB buffer representation.
static int ioam_cache_ts_update(u32 thread_id, i32 pool_index, u32 buffer_index, ip6_hop_by_hop_header_t *hbh)