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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <vlib/vlib.h>
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()
26 typedef enum vlib_punt_reason_t_
32 * Walk each punt reason
34 typedef int (*punt_reason_walk_cb_t) (vlib_punt_reason_t id,
35 const u8 * name, void *ctx);
37 extern void punt_reason_walk (punt_reason_walk_cb_t cb, void *cxt);
40 * @brief Format a punt reason
42 extern u8 *format_vlib_punt_reason (u8 * s, va_list * args);
45 * Typedef for a client handle
47 typedef int vlib_punt_hdl_t;
50 * @brief Register a new clinet
52 * @param who - The name of the client
54 * @retrun the handle the punt infra allocated for this client that must
55 * be used when the client wishes to use the infra
57 vlib_punt_hdl_t vlib_punt_client_register (const char *who);
59 typedef void (*punt_interested_listener_t) (vlib_enable_or_disable_t i,
63 * Allocate a new punt reason
64 * @param fn - A callback to invoke when an entity becomes [un]interested
66 * @param data - To be passed in the callback function.
68 extern int vlib_punt_reason_alloc (vlib_punt_hdl_t client,
69 const char *reason_name,
70 punt_interested_listener_t fn,
71 void *data, vlib_punt_reason_t * reason);
74 * Validate that a punt reason is assigned
76 extern int vlib_punt_reason_validate (vlib_punt_reason_t reason);
79 * @brief Register a node to receive particular punted buffers
81 * @paran client - The registered client registering for the packets
82 * @param reason - The reason the packet was punted
83 * @param node - The node to which the punted packets will be sent
85 extern int vlib_punt_register (vlib_punt_hdl_t client,
86 vlib_punt_reason_t reason, const char *node);
87 extern int vlib_punt_unregister (vlib_punt_hdl_t client,
88 vlib_punt_reason_t pr, const char *node);
91 * FOR USE IN THE DP ONLY
93 * Arc[s] to follow for each reason
95 extern u16 **punt_dp_db;
98 * FOR USE IN THE DP ONLY
100 * Per-reason counters
102 extern vlib_combined_counter_main_t punt_counters;
107 * fd.io coding-style-patch-verification: ON
110 * eval: (c-set-style "gnu")