FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
punt.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __PUNT_H__
17 #define __PUNT_H__
18 
19 #include <vlib/vlib.h>
20 
21 /**
22  * The 'syatem' defined punt reasons.
23  * Only add to this list reasons defined and used within the vlib subsystem.
24  * To define new reasons in e.g. plgins, use punt_reason_alloc()
25  */
26 typedef enum vlib_punt_reason_t_
27 {
30 
31 /**
32  * Walk each punt reason
33  */
35  void *ctx);
36 
37 extern void punt_reason_walk (punt_reason_walk_cb_t cb, void *cxt);
38 
39 /**
40  * @brief Format a punt reason
41  */
42 extern u8 *format_vlib_punt_reason (u8 * s, va_list * args);
43 
44 /**
45  * @brief Unformat a punt reason
46  */
47 extern uword unformat_punt_reason (unformat_input_t *input, va_list *args);
48 
49 /**
50  * Typedef for a client handle
51  */
52 typedef int vlib_punt_hdl_t;
53 
54 /**
55  * @brief Register a new clinet
56  *
57  * @param who - The name of the client
58  *
59  * @retrun the handle the punt infra allocated for this client that must
60  * be used when the client wishes to use the infra
61  */
63 
65  void *data);
66 
67 /**
68  * Allocate a new punt reason
69  * @param fn - A callback to invoke when an entity becomes
70  * [un]interested in the punt code.
71  * @param data - To be passed in the callback function.
72  * @param flags - flags associated with the punt reason
73  * @param flags_format - formatting function to display those flags (may be
74  * NULL)
75  */
76 extern int vlib_punt_reason_alloc (vlib_punt_hdl_t client,
77  const char *reason_name,
79  vlib_punt_reason_t *reason, u32 flags,
80  format_function_t *flags_format);
81 
82 /**
83  * Validate that a punt reason is assigned
84  */
86 
87 /**
88  * @brief Register a node to receive particular punted buffers
89  *
90  * @paran client - The registered client registering for the packets
91  * @param reason - The reason the packet was punted
92  * @param node - The node to which the punted packets will be sent
93  */
94 extern int vlib_punt_register (vlib_punt_hdl_t client,
95  vlib_punt_reason_t reason, const char *node);
96 extern int vlib_punt_unregister (vlib_punt_hdl_t client,
97  vlib_punt_reason_t pr, const char *node);
98 
100 
101 /**
102  * FOR USE IN THE DP ONLY
103  *
104  * Arc[s] to follow for each reason
105  */
106 extern u16 **punt_dp_db;
107 
108 /**
109  * FOR USE IN THE DP ONLY
110  *
111  * Per-reason counters
112  */
114 
115 #endif
116 
117 /*
118  * fd.io coding-style-patch-verification: ON
119  *
120  * Local Variables:
121  * eval: (c-set-style "gnu")
122  * End:
123  */
vlib.h
vlib_punt_reason_t
enum vlib_punt_reason_t_ vlib_punt_reason_t
The 'syatem' defined punt reasons.
vlib_punt_reason_t_
vlib_punt_reason_t_
The 'syatem' defined punt reasons.
Definition: punt.h:26
name
string name[64]
Definition: fib.api:25
unformat_punt_reason
uword unformat_punt_reason(unformat_input_t *input, va_list *args)
Unformat a punt reason.
Definition: punt.c:479
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
u16
unsigned short u16
Definition: types.h:57
unformat_input_t
struct _unformat_input_t unformat_input_t
punt_counters
vlib_combined_counter_main_t punt_counters
FOR USE IN THE DP ONLY.
Definition: punt.c:27
vlib_enable_or_disable_t
vlib_enable_or_disable_t
Definition: defs.h:76
format_vlib_punt_reason
u8 * format_vlib_punt_reason(u8 *s, va_list *args)
Format a punt reason.
Definition: punt.c:158
PUNT_N_REASONS
@ PUNT_N_REASONS
Definition: punt.h:28
vlib_punt_register
int vlib_punt_register(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node)
Register a node to receive particular punted buffers.
Definition: punt.c:283
punt_interested_listener_t
void(* punt_interested_listener_t)(vlib_enable_or_disable_t i, void *data)
Definition: punt.h:64
uword
u64 uword
Definition: types.h:112
punt_dp_db
u16 ** punt_dp_db
FOR USE IN THE DP ONLY.
Definition: punt.c:129
data
u8 data[128]
Definition: ipsec_types.api:95
id
u8 id[64]
Definition: dhcp.api:160
vlib_punt_unregister
int vlib_punt_unregister(vlib_punt_hdl_t client, vlib_punt_reason_t pr, const char *node)
Definition: punt.c:352
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
u32
unsigned int u32
Definition: types.h:88
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
vlib_punt_hdl_t
int vlib_punt_hdl_t
Typedef for a client handle.
Definition: punt.h:52
vlib_punt_reason_alloc
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, u32 flags, format_function_t *flags_format)
Allocate a new punt reason.
Definition: punt.c:425
u8
unsigned char u8
Definition: types.h:56
i
int i
Definition: flowhash_template.h:376
vlib_punt_reason_validate
int vlib_punt_reason_validate(vlib_punt_reason_t reason)
Validate that a punt reason is assigned.
Definition: punt.c:410
vlib_punt_reason_get_flags
u32 vlib_punt_reason_get_flags(vlib_punt_reason_t pr)
Definition: punt.c:419
punt_reason_walk_cb_t
int(* punt_reason_walk_cb_t)(vlib_punt_reason_t id, const u8 *name, void *ctx)
Walk each punt reason.
Definition: punt.h:34
punt_reason_walk
void punt_reason_walk(punt_reason_walk_cb_t cb, void *cxt)
Definition: punt.c:457
vlib_punt_client_register
vlib_punt_hdl_t vlib_punt_client_register(const char *who)
Register a new clinet.
Definition: punt.c:171
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105