29 .stat_segment_name =
"/net/punt",
152 return (
format (s,
"[%d] %v", pr, punt_reason_data[pr].
pd_name));
162 pc_name =
format (NULL,
"%s", who);
172 pc->pc_name = pc_name;
194 return (((
u64) node_index) << 32 | reason);
231 u32 pri, *prip, *pris;
317 if (0 == punt_reason_data[reason].
pd_users++ &&
318 NULL != punt_reason_data[reason].
pd_fn)
320 punt_reason_data[reason].
pd_data);
377 if (0 == --punt_reason_data[reason].
pd_users &&
378 NULL != punt_reason_data[reason].
pd_fn)
380 punt_reason_data[reason].
pd_data);
405 const char *reason_name,
416 punt_reason_data[
new].
pd_name =
format (NULL,
"%s", reason_name);
418 punt_reason_data[
new].
pd_fn = fn;
438 for (pd = punt_reason_data + 1; pd <
vec_end (punt_reason_data); pd++)
448 u32 *result = va_arg (*args,
u32 *);
457 u32 pri = va_arg (*args,
u32);
462 s =
format (s,
"%U -> %U",
480 s =
format (s,
"%v ", pc->pc_name);
490 u32 pci = va_arg (*args,
u32);
496 s =
format (s,
"%v", pc->pc_name);
503 s =
format (s,
"\n registrations:");
509 s =
format (s,
"\n reasons:");
563 .path =
"show punt client",
564 .short_help =
"show client[s] registered with the punt infra",
586 .path =
"show punt reasons",
587 .short_help =
"show all punt reasons",
608 " (for each punt-reason the edge[s] from punt-dispatch)");
629 .path =
"show punt db",
630 .short_help =
"show the punt DB",
656 .path =
"show punt stats",
657 .short_help =
"show the punt stats",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
int(* punt_reason_walk_cb_t)(vlib_punt_reason_t id, const u8 *name, void *ctx)
Walk each punt reason.
static uword * punt_client_db
DB of clients key'd by their name.
#define vec_foreach_index(var, v)
Iterate over vector indices.
uword unformat_punt_client(unformat_input_t *input, va_list *args)
A registration, by a client, to direct punted traffic to a given node.
#define hash_set(h, key, value)
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
format_function_t format_vlib_node_name
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
int vlib_punt_reason_validate(vlib_punt_reason_t reason)
Validate that a punt reason is assigned.
static void punt_reg_mk_dp(vlib_punt_reason_t reason)
reconstruct the DP per-reason DB
u16 pr_edge
The edge from the punt dispatch node to the requested node.
u32 pr_node_index
node-index to send punted packets to
u8 * format_punt_reason_data(u8 *s, va_list *args)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Combined counter to hold both packets and byte differences.
int vlib_punt_hdl_t
Typedef for a client handle.
#define hash_set_mem(h, key, value)
static punt_reg_t * punt_reg_pool
Pool of registrations.
static vlib_punt_reason_t punt_reason_last
The last allocated punt reason Value 0 is reserved for invalid index.
u32 * pc_regs
The registrations is has made.
u8 * pd_name
The reason name.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u16 pr_locks
number of clients that have made this registration
static uword * punt_reg_db
A DB of all the register nodes against punt reason and node index.
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
u8 * format_vlib_punt_reason(u8 *s, va_list *args)
Format a punt reason.
static punt_client_t * punt_client_pool
Pool of clients.
#define VLIB_INIT_FUNCTION(x)
#define hash_foreach(key_var, value_var, h, body)
#define vec_end(v)
End (last data address) of vector.
#define vec_search(v, E)
Search a vector for the index of the entry that matches.
A client using the punt serivce and its registrations.
struct punt_reg_t_ punt_reg_t
A registration, by a client, to direct punted traffic to a given node.
vlib_punt_hdl_t vlib_punt_client_register(const char *who)
Register a new clinet.
vlib_punt_reason_t pd_reason
The allocated reason value.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
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.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
struct punt_reason_data_t_ punt_reason_data_t
A punt reason.
counter_t packets
packet counter
u32 vlib_combined_counter_n_counters(const vlib_combined_counter_main_t *cm)
The number of counters (not the number of per-thread counters)
static void punt_reg_remove(const punt_reg_t *pr)
static clib_error_t * punt_stats_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_put(P, E)
Free an object E in pool P.
static clib_error_t * punt_reason_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * punt_db_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_del1(v, i)
Delete the element at index I.
u8 * format_punt_reg(u8 *s, va_list *args)
static clib_error_t * punt_init(vlib_main_t *vm)
unformat_function_t unformat_hash_vec_string
void * pd_data
Data to pass to the callback.
int vlib_punt_reason_alloc(vlib_punt_hdl_t client, const char *reason_name, punt_interested_listener_t fn, void *data, vlib_punt_reason_t *reason)
Allocate a new punt reason.
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...
static punt_reason_data_t * punt_reason_data
data for each punt reason
#define vec_free(V)
Free vector's memory (no header).
int vlib_punt_unregister(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node_name)
vlib_punt_reason_t pr_reason
Reason the packets were punted.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void punt_reason_walk(punt_reason_walk_cb_t cb, void *ctx)
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
struct punt_client_t_ punt_client_t
A client using the punt serivce and its registrations.
u8 * format_punt_client(u8 *s, va_list *args)
static vlib_main_t * vlib_get_main(void)
void(* punt_interested_listener_t)(vlib_enable_or_disable_t i, void *data)
counter_t bytes
byte counter
static u64 punt_reg_mk_key(vlib_punt_reason_t reason, u32 node_index)
int vlib_punt_register(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node_name)
Register a node to receive particular punted buffers.
#define hash_create_vec(elts, key_bytes, value_bytes)
static clib_error_t * punt_client_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
punt_interested_listener_t pd_fn
function to invoke if a client becomes interested in the code.
vlib_combined_counter_main_t punt_counters
Counters per punt-reason.
char * name
The counter collection's name.
A collection of combined counters.
u16 ** punt_dp_db
A DB used in the DP per-reason to dispatch packets to the requested nodes.
u32 * pd_owners
Clients/owners that have registered this reason.
#define hash_get_mem(h, key)
enum punt_format_flags_t_ punt_format_flags_t
u8 * pc_name
The name of the client.
static u32 punt_reg_find(vlib_punt_reason_t reason, u32 node_index)
#define vec_foreach(var, vec)
Vector iterator.
static void punt_reg_add(const punt_reg_t *pr)
static int punt_validate_client(vlib_punt_hdl_t client)
enum vlib_punt_reason_t_ vlib_punt_reason_t
The 'syatem' defined punt reasons.
u32 pd_users
clients interested/listening to this reason