25 #define REP_DBG(_rep, _fmt, _args...) \ 28 clib_warning("rep:[%s]:" _fmt, \ 29 replicate_format(replicate_get_index((_rep)), \ 35 #define REP_DBG(_p, _fmt, _args...) 38 #define foreach_replicate_dpo_error \ 39 _(BUFFER_ALLOCATION_FAILURE, "Buffer Allocation Failure") 42 #define _(sym,str) REPLICATE_DPO_ERROR_##sym, 49 #define _(sym,string) string, 67 return (rep - replicate_pool);
89 memset(rep, 0,
sizeof(*rep));
140 u32 indent = va_arg(*args,
u32);
196 ASSERT(bucket < rep->rep_n_buckets);
274 ASSERT(bucket < n_buckets);
393 dpo_id_t *new_buckets, *old_buckets, *tmp_dpo;
466 for (ii = n_buckets; ii < old_n_buckets; ii++)
616 .path =
"show replicate",
617 .short_help =
"show replicate [<index>]",
634 u32 n_left_from, * from, * to_next, next_index;
641 while (n_left_from > 0)
646 to_next, n_left_to_next);
648 while (n_left_from > 0 && n_left_to_next > 0)
650 u32 next0, ci0, bi0, bucket, repi0;
665 cm, thread_index, repi0, 1,
676 REPLICATE_DPO_ERROR_BUFFER_ALLOCATION_FAILURE, 1);
679 for (bucket = 0; bucket < num_cloned; bucket++)
681 ci0 = rm->
clones[thread_index][bucket];
703 to_next, n_left_to_next,
727 s =
format (s,
"replicate: %d via %U",
746 .name =
"ip4-replicate",
747 .vector_size =
sizeof (
u32),
772 .name =
"ip6-replicate",
773 .vector_size =
sizeof (
u32),
798 .name =
"mpls-replicate",
799 .vector_size =
sizeof (
u32),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
dpo_lock_fn_t dv_lock
A reference counting lock function.
static void replicate_destroy(replicate_t *rep)
#define REP_DBG(_p, _fmt, _args...)
static dpo_id_t * replicate_get_buckets(replicate_t *rep)
sll srl srl sll sra u16x4 i
A virtual function table regisitered for a DPO type.
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static void replicate_unlock(dpo_id_t *dpo)
u8 * format_dpo_type(u8 *s, va_list *args)
format a DPO type
dpo_id_t path_dpo
ID of the Data-path object.
replicate_t * replicate_pool
Pool of all DPOs.
static void replicate_fill_buckets(replicate_t *rep, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets)
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
u32 rep_locks
The number of locks, which is approximately the number of users, of this load-balance.
static void replicate_set_bucket_i(replicate_t *rep, u32 bucket, dpo_id_t *buckets, const dpo_id_t *next)
enum replicate_format_flags_t_ replicate_format_flags_t
Flags controlling load-balance formatting/display.
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
dpo_proto_t rep_proto
The protocol of packets that traverse this REP.
Combined counter to hold both packets and byte differences.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
dpo_id_t * rep_buckets
Vector of buckets containing the next DPOs, sized as repo_num.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static u8 vlib_buffer_clone(vlib_main_t *vm, u32 src_buffer, u32 *buffers, u8 n_buffers, u16 head_end_offset)
Create multiple clones of buffer and store them in the supplied array.
static replicate_t * replicate_get(index_t repi)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_len(p)
Number of elements in pool vector.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
void replicate_set_bucket(index_t repi, u32 bucket, const dpo_id_t *next)
static const char *const *const replicate_nodes[DPO_PROTO_NUM]
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static u8 * format_replicate_trace(u8 *s, va_list *args)
static char * replicate_dpo_error_strings[]
#define MPLS_IS_REPLICATE
The top bit of the index, which is the result of the MPLS lookup is used to determine if the DPO is a...
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
static const char *const replicate_ip6_nodes[]
static replicate_t * replicate_create_i(u32 num_buckets, dpo_proto_t rep_proto)
#define REP_HAS_INLINE_BUCKETS(_rep)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
static clib_error_t * replicate_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static const char *const replicate_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a replicate object.
static index_t replicate_get_index(const replicate_t *rep)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
static void replicate_mem_show(void)
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
counter_t packets
packet counter
dpo_type_t dpoi_type
the type
clib_error_t * replicate_dpo_init(vlib_main_t *vm)
static load_balance_path_t * replicate_multipath_next_hop_fixup(load_balance_path_t *nhs, dpo_proto_t drop_proto)
static u8 * replicate_format(index_t repi, replicate_format_flags_t flags, u32 indent, u8 *s)
#define pool_put(P, E)
Free an object E in pool P.
vlib_combined_counter_main_t repm_counters
u32 node_index
Node index.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static uword replicate_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
static const char *const replicate_mpls_nodes[]
static_always_inline uword vlib_get_thread_index(void)
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
#define vec_free(V)
Free vector's memory (no header).
vlib_node_registration_t ip4_replicate_node
IP4 replication node.
#define VLIB_BUFFER_IS_TRACED
u8 * format_replicate(u8 *s, va_list *args)
static uword ip6_replicate(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
index_t replicate_create(u32 n_buckets, dpo_proto_t rep_proto)
vlib_node_registration_t mpls_replicate_node
MPLS replication node.
#define VLIB_CLI_COMMAND(x,...)
dpo_id_t rep_buckets_inline[REP_NUM_INLINE_BUCKETS]
The rest of the cache line is used for buckets.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
int replicate_is_drop(const dpo_id_t *dpo)
static replicate_t * replicate_alloc_i(void)
u16 rep_n_buckets
number of buckets in the load-balance.
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject
static void replicate_lock(dpo_id_t *dpo)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
counter_t bytes
byte counter
static u8 * format_replicate_dpo(u8 *s, va_list *args)
const dpo_id_t * replicate_get_bucket(index_t repi, u32 bucket)
static void replicate_set_n_buckets(replicate_t *rep, u32 n_buckets)
index_t dpoi_index
the index of objects of that type
#define foreach_replicate_dpo_error
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 path_weight
weight for the path.
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
#define REP_NUM_INLINE_BUCKETS
The number of buckets that a load-balance object can have and still fit in one cache-line.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
replicate_main_t replicate_main
The one instance of replicate main.
static const dpo_id_t * replicate_get_bucket_i(const replicate_t *rep, u32 bucket)
One path from an [EU]CMP set that the client wants to add to a load-balance object.
A collection of combined counters.
#define VLIB_REGISTER_NODE(x,...)
int dpo_is_drop(const dpo_id_t *dpo)
The Drop DPO will drop all packets, no questions asked.
static u32 vlib_num_workers()
vlib_node_registration_t ip6_replicate_node
IPv6 replication node.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
#define CLIB_MEMORY_BARRIER()
u16 dpoi_next_node
The next VLIB node to follow.
struct replicate_trace_t_ replicate_trace_t
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void replicate_module_init(void)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword ip4_replicate(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword mpls_replicate(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
static uword pool_elts(void *v)
Number of active elements in a pool.