Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | * node.h: VLIB processing nodes |
| 17 | * |
| 18 | * Copyright (c) 2008 Eliot Dresselhaus |
| 19 | * |
| 20 | * Permission is hereby granted, free of charge, to any person obtaining |
| 21 | * a copy of this software and associated documentation files (the |
| 22 | * "Software"), to deal in the Software without restriction, including |
| 23 | * without limitation the rights to use, copy, modify, merge, publish, |
| 24 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 25 | * permit persons to whom the Software is furnished to do so, subject to |
| 26 | * the following conditions: |
| 27 | * |
| 28 | * The above copyright notice and this permission notice shall be |
| 29 | * included in all copies or substantial portions of the Software. |
| 30 | * |
| 31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 32 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | */ |
| 39 | |
| 40 | #ifndef included_vlib_node_h |
| 41 | #define included_vlib_node_h |
| 42 | |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 43 | #include <vppinfra/cpu.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 44 | #include <vppinfra/longjmp.h> |
Damjan Marion | 2c2b640 | 2017-03-28 14:16:15 +0200 | [diff] [blame] | 45 | #include <vppinfra/lock.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 46 | #include <vlib/trace.h> /* for vlib_trace_filter_t */ |
| 47 | |
| 48 | /* Forward declaration. */ |
| 49 | struct vlib_node_runtime_t; |
| 50 | struct vlib_frame_t; |
| 51 | |
| 52 | /* Internal nodes (including output nodes) move data from node to |
| 53 | node (or out of the graph for output nodes). */ |
| 54 | typedef uword (vlib_node_function_t) (struct vlib_main_t * vm, |
| 55 | struct vlib_node_runtime_t * node, |
| 56 | struct vlib_frame_t * frame); |
| 57 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 58 | typedef enum |
| 59 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | /* An internal node on the call graph (could be output). */ |
| 61 | VLIB_NODE_TYPE_INTERNAL, |
| 62 | |
| 63 | /* Nodes which input data into the processing graph. |
| 64 | Input nodes are called for each iteration of main loop. */ |
| 65 | VLIB_NODE_TYPE_INPUT, |
| 66 | |
| 67 | /* Nodes to be called before all input nodes. |
| 68 | Used, for example, to clean out driver TX rings before |
| 69 | processing input. */ |
| 70 | VLIB_NODE_TYPE_PRE_INPUT, |
| 71 | |
| 72 | /* "Process" nodes which can be suspended and later resumed. */ |
| 73 | VLIB_NODE_TYPE_PROCESS, |
| 74 | |
| 75 | VLIB_N_NODE_TYPE, |
| 76 | } vlib_node_type_t; |
| 77 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 78 | typedef struct _vlib_node_registration |
| 79 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 80 | /* Vector processing function for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 81 | vlib_node_function_t *function; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 82 | |
| 83 | /* Node name. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 84 | char *name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | |
| 86 | /* Name of sibling (if applicable). */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 87 | char *sibling_of; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 88 | |
| 89 | /* Node index filled in by registration. */ |
| 90 | u32 index; |
| 91 | |
| 92 | /* Type of this node. */ |
| 93 | vlib_node_type_t type; |
| 94 | |
| 95 | /* Error strings indexed by error code for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 96 | char **error_strings; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | |
| 98 | /* Buffer format/unformat for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 99 | format_function_t *format_buffer; |
| 100 | unformat_function_t *unformat_buffer; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 101 | |
| 102 | /* Trace format/unformat for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 103 | format_function_t *format_trace; |
| 104 | unformat_function_t *unformat_trace; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | |
| 106 | /* Function to validate incoming frames. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 107 | u8 *(*validate_frame) (struct vlib_main_t * vm, |
| 108 | struct vlib_node_runtime_t *, |
| 109 | struct vlib_frame_t * f); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 110 | |
| 111 | /* Per-node runtime data. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 112 | void *runtime_data; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | |
| 114 | /* Process stack size. */ |
| 115 | u16 process_log2_n_stack_bytes; |
| 116 | |
| 117 | /* Number of bytes of per-node run time data. */ |
| 118 | u8 runtime_data_bytes; |
| 119 | |
| 120 | /* State for input nodes. */ |
| 121 | u8 state; |
| 122 | |
| 123 | /* Node flags. */ |
| 124 | u16 flags; |
| 125 | |
| 126 | /* Size of scalar and vector arguments in bytes. */ |
| 127 | u16 scalar_size, vector_size; |
| 128 | |
| 129 | /* Number of error codes used by this node. */ |
| 130 | u16 n_errors; |
| 131 | |
| 132 | /* Number of next node names that follow. */ |
| 133 | u16 n_next_nodes; |
| 134 | |
| 135 | /* Constructor link-list, don't ask... */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 136 | struct _vlib_node_registration *next_registration; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 137 | |
| 138 | /* Names of next nodes which this node feeds into. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 139 | char *next_nodes[]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 140 | |
| 141 | } vlib_node_registration_t; |
| 142 | |
| 143 | #define VLIB_REGISTER_NODE(x,...) \ |
| 144 | __VA_ARGS__ vlib_node_registration_t x; \ |
| 145 | static void __vlib_add_node_registration_##x (void) \ |
| 146 | __attribute__((__constructor__)) ; \ |
| 147 | static void __vlib_add_node_registration_##x (void) \ |
| 148 | { \ |
| 149 | vlib_main_t * vm = vlib_get_main(); \ |
| 150 | x.next_registration = vm->node_main.node_registrations; \ |
| 151 | vm->node_main.node_registrations = &x; \ |
| 152 | } \ |
Damjan Marion | 72d2c4f | 2018-04-05 21:32:29 +0200 | [diff] [blame] | 153 | static void __vlib_rm_node_registration_##x (void) \ |
| 154 | __attribute__((__destructor__)) ; \ |
| 155 | static void __vlib_rm_node_registration_##x (void) \ |
| 156 | { \ |
| 157 | vlib_main_t * vm = vlib_get_main(); \ |
| 158 | VLIB_REMOVE_FROM_LINKED_LIST (vm->node_main.node_registrations, \ |
| 159 | &x, next_registration); \ |
| 160 | } \ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 161 | __VA_ARGS__ vlib_node_registration_t x |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 162 | |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 163 | #if CLIB_DEBUG > 0 |
| 164 | #define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn) |
| 165 | #define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) |
| 166 | #define VLIB_NODE_FUNCTION_MULTIARCH(node, fn) |
| 167 | #else |
| 168 | #define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \ |
| 169 | uword \ |
| 170 | __attribute__ ((flatten)) \ |
| 171 | __attribute__ ((target (tgt))) \ |
| 172 | CLIB_CPU_OPTIMIZED \ |
| 173 | fn ## _ ## arch ( struct vlib_main_t * vm, \ |
| 174 | struct vlib_node_runtime_t * node, \ |
| 175 | struct vlib_frame_t * frame) \ |
| 176 | { return fn (vm, node, frame); } |
| 177 | |
| 178 | #define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) \ |
| 179 | foreach_march_variant(VLIB_NODE_FUNCTION_CLONE_TEMPLATE, fn) |
| 180 | |
| 181 | #define VLIB_NODE_FUNCTION_MULTIARCH(node, fn) \ |
| 182 | VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) \ |
| 183 | CLIB_MULTIARCH_SELECT_FN(fn, static inline) \ |
| 184 | static void __attribute__((__constructor__)) \ |
| 185 | __vlib_node_function_multiarch_select_##node (void) \ |
| 186 | { node.function = fn ## _multiarch_select(); } |
| 187 | #endif |
| 188 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 189 | always_inline vlib_node_registration_t * |
| 190 | vlib_node_next_registered (vlib_node_registration_t * c) |
| 191 | { |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 192 | c = |
| 193 | clib_elf_section_data_next (c, |
| 194 | c->n_next_nodes * sizeof (c->next_nodes[0])); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 195 | return c; |
| 196 | } |
| 197 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 198 | typedef struct |
| 199 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 200 | /* Total calls, clock ticks and vector elements processed for this node. */ |
| 201 | u64 calls, vectors, clocks, suspends; |
| 202 | u64 max_clock; |
| 203 | u64 max_clock_n; |
| 204 | } vlib_node_stats_t; |
| 205 | |
| 206 | #define foreach_vlib_node_state \ |
| 207 | /* Input node is called each iteration of main loop. \ |
| 208 | This is the default (zero). */ \ |
| 209 | _ (POLLING) \ |
| 210 | /* Input node is called when device signals an interrupt. */ \ |
| 211 | _ (INTERRUPT) \ |
| 212 | /* Input node is never called. */ \ |
| 213 | _ (DISABLED) |
| 214 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 215 | typedef enum |
| 216 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 217 | #define _(f) VLIB_NODE_STATE_##f, |
| 218 | foreach_vlib_node_state |
| 219 | #undef _ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 220 | VLIB_N_NODE_STATE, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 221 | } vlib_node_state_t; |
| 222 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 223 | typedef struct vlib_node_t |
| 224 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 225 | /* Vector processing function for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 226 | vlib_node_function_t *function; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 227 | |
| 228 | /* Node name. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 229 | u8 *name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 230 | |
| 231 | /* Node name index in elog string table. */ |
| 232 | u32 name_elog_string; |
| 233 | |
| 234 | /* Total statistics for this node. */ |
| 235 | vlib_node_stats_t stats_total; |
| 236 | |
| 237 | /* Saved values as of last clear (or zero if never cleared). |
| 238 | Current values are always stats_total - stats_last_clear. */ |
| 239 | vlib_node_stats_t stats_last_clear; |
| 240 | |
| 241 | /* Type of this node. */ |
| 242 | vlib_node_type_t type; |
| 243 | |
| 244 | /* Node index. */ |
| 245 | u32 index; |
| 246 | |
| 247 | /* Index of corresponding node runtime. */ |
| 248 | u32 runtime_index; |
| 249 | |
| 250 | /* Runtime data for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 251 | void *runtime_data; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 252 | |
| 253 | /* Node flags. */ |
| 254 | u16 flags; |
| 255 | |
| 256 | /* Processing function keeps frame. Tells node dispatching code not |
| 257 | to free frame after dispatch is done. */ |
| 258 | #define VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH (1 << 0) |
| 259 | |
| 260 | /* Node counts as output/drop/punt node for stats purposes. */ |
| 261 | #define VLIB_NODE_FLAG_IS_OUTPUT (1 << 1) |
| 262 | #define VLIB_NODE_FLAG_IS_DROP (1 << 2) |
| 263 | #define VLIB_NODE_FLAG_IS_PUNT (1 << 3) |
| 264 | #define VLIB_NODE_FLAG_IS_HANDOFF (1 << 4) |
| 265 | |
| 266 | /* Set if current node runtime has traced vectors. */ |
| 267 | #define VLIB_NODE_FLAG_TRACE (1 << 5) |
| 268 | |
| 269 | #define VLIB_NODE_FLAG_SWITCH_FROM_INTERRUPT_TO_POLLING_MODE (1 << 6) |
| 270 | #define VLIB_NODE_FLAG_SWITCH_FROM_POLLING_TO_INTERRUPT_MODE (1 << 7) |
| 271 | |
| 272 | /* State for input nodes. */ |
| 273 | u8 state; |
| 274 | |
| 275 | /* Number of bytes of run time data. */ |
| 276 | u8 runtime_data_bytes; |
| 277 | |
| 278 | /* Number of error codes used by this node. */ |
| 279 | u16 n_errors; |
| 280 | |
| 281 | /* Size of scalar and vector arguments in bytes. */ |
| 282 | u16 scalar_size, vector_size; |
| 283 | |
| 284 | /* Handle/index in error heap for this node. */ |
| 285 | u32 error_heap_handle; |
| 286 | u32 error_heap_index; |
| 287 | |
| 288 | /* Error strings indexed by error code for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 289 | char **error_strings; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 290 | |
| 291 | /* Vector of next node names. |
| 292 | Only used before next_nodes array is initialized. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 293 | char **next_node_names; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 294 | |
| 295 | /* Next node indices for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 296 | u32 *next_nodes; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 297 | |
| 298 | /* Name of node that we are sibling of. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 299 | char *sibling_of; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 300 | |
| 301 | /* Bitmap of all of this node's siblings. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 302 | uword *sibling_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 303 | |
| 304 | /* Total number of vectors sent to each next node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 305 | u64 *n_vectors_by_next_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 306 | |
| 307 | /* Hash table mapping next node index into slot in |
| 308 | next_nodes vector. Quickly determines whether this node |
| 309 | is connected to given next node and, if so, with which slot. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 310 | uword *next_slot_by_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 311 | |
| 312 | /* Bitmap of node indices which feed this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 313 | uword *prev_node_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 314 | |
| 315 | /* Node/next-index which own enqueue rights with to this node. */ |
| 316 | u32 owner_node_index, owner_next_index; |
| 317 | |
| 318 | /* Buffer format/unformat for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 319 | format_function_t *format_buffer; |
| 320 | unformat_function_t *unformat_buffer; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 321 | |
| 322 | /* Trace buffer format/unformat for this node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 323 | format_function_t *format_trace; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 324 | |
| 325 | /* Function to validate incoming frames. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 326 | u8 *(*validate_frame) (struct vlib_main_t * vm, |
| 327 | struct vlib_node_runtime_t *, |
| 328 | struct vlib_frame_t * f); |
Dave Barach | 6931f59 | 2016-05-13 12:55:01 -0400 | [diff] [blame] | 329 | /* for pretty-printing, not typically valid */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 330 | u8 *state_string; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 331 | } vlib_node_t; |
| 332 | |
| 333 | #define VLIB_INVALID_NODE_INDEX ((u32) ~0) |
| 334 | |
| 335 | /* Max number of vector elements to process at once per node. */ |
| 336 | #define VLIB_FRAME_SIZE 256 |
Dave Barach | d84ba85 | 2017-08-22 17:56:46 -0400 | [diff] [blame] | 337 | #define VLIB_FRAME_ALIGN CLIB_CACHE_LINE_BYTES |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 338 | |
| 339 | /* Calling frame (think stack frame) for a node. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 340 | typedef struct vlib_frame_t |
| 341 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 342 | /* Frame flags. */ |
| 343 | u16 flags; |
| 344 | |
| 345 | /* Number of scalar bytes in arguments. */ |
| 346 | u8 scalar_size; |
| 347 | |
| 348 | /* Number of bytes per vector argument. */ |
| 349 | u8 vector_size; |
| 350 | |
| 351 | /* Number of vector elements currently in frame. */ |
| 352 | u16 n_vectors; |
| 353 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 354 | /* Scalar and vector arguments to next node. */ |
| 355 | u8 arguments[0]; |
| 356 | } vlib_frame_t; |
| 357 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 358 | typedef struct |
| 359 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 360 | /* Frame index. */ |
| 361 | u32 frame_index; |
| 362 | |
| 363 | /* Node runtime for this next. */ |
| 364 | u32 node_runtime_index; |
| 365 | |
| 366 | /* Next frame flags. */ |
| 367 | u32 flags; |
| 368 | |
| 369 | /* Reflects node frame-used flag for this next. */ |
| 370 | #define VLIB_FRAME_NO_FREE_AFTER_DISPATCH \ |
| 371 | VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH |
| 372 | |
| 373 | /* This next frame owns enqueue to node |
| 374 | corresponding to node_runtime_index. */ |
| 375 | #define VLIB_FRAME_OWNER (1 << 15) |
| 376 | |
| 377 | /* Set when frame has been allocated for this next. */ |
| 378 | #define VLIB_FRAME_IS_ALLOCATED VLIB_NODE_FLAG_IS_OUTPUT |
| 379 | |
| 380 | /* Set when frame has been added to pending vector. */ |
| 381 | #define VLIB_FRAME_PENDING VLIB_NODE_FLAG_IS_DROP |
| 382 | |
| 383 | /* Set when frame is to be freed after dispatch. */ |
| 384 | #define VLIB_FRAME_FREE_AFTER_DISPATCH VLIB_NODE_FLAG_IS_PUNT |
| 385 | |
| 386 | /* Set when frame has traced packets. */ |
| 387 | #define VLIB_FRAME_TRACE VLIB_NODE_FLAG_TRACE |
| 388 | |
| 389 | /* Number of vectors enqueue to this next since last overflow. */ |
| 390 | u32 vectors_since_last_overflow; |
| 391 | } vlib_next_frame_t; |
| 392 | |
| 393 | always_inline void |
| 394 | vlib_next_frame_init (vlib_next_frame_t * nf) |
| 395 | { |
| 396 | memset (nf, 0, sizeof (nf[0])); |
| 397 | nf->frame_index = ~0; |
| 398 | nf->node_runtime_index = ~0; |
| 399 | } |
| 400 | |
| 401 | /* A frame pending dispatch by main loop. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 402 | typedef struct |
| 403 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 404 | /* Node and runtime for this frame. */ |
| 405 | u32 node_runtime_index; |
| 406 | |
| 407 | /* Frame index (in the heap). */ |
| 408 | u32 frame_index; |
| 409 | |
| 410 | /* Start of next frames for this node. */ |
| 411 | u32 next_frame_index; |
| 412 | |
| 413 | /* Special value for next_frame_index when there is no next frame. */ |
| 414 | #define VLIB_PENDING_FRAME_NO_NEXT_FRAME ((u32) ~0) |
| 415 | } vlib_pending_frame_t; |
| 416 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 417 | typedef struct vlib_node_runtime_t |
| 418 | { |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 419 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); /**< cacheline mark */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 420 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 421 | vlib_node_function_t *function; /**< Node function to call. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 422 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 423 | vlib_error_t *errors; /**< Vector of errors for this node. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 424 | |
Damjan Marion | 36c1308 | 2017-04-24 20:58:29 +0200 | [diff] [blame] | 425 | #if __SIZEOF_POINTER__ == 4 |
| 426 | u8 pad[8]; |
| 427 | #endif |
| 428 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 429 | u32 clocks_since_last_overflow; /**< Number of clock cycles. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 430 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 431 | u32 max_clock; /**< Maximum clock cycle for an |
| 432 | invocation. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 433 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 434 | u32 max_clock_n; /**< Number of vectors in the recorded |
| 435 | max_clock. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 436 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 437 | u32 calls_since_last_overflow; /**< Number of calls. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 439 | u32 vectors_since_last_overflow; /**< Number of vector elements |
| 440 | processed by this node. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 441 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 442 | u32 next_frame_index; /**< Start of next frames for this |
| 443 | node. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 444 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 445 | u32 node_index; /**< Node index. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 446 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 447 | u32 input_main_loops_per_call; /**< For input nodes: decremented |
| 448 | on each main loop interation until |
| 449 | it reaches zero and function is |
| 450 | called. Allows some input nodes to |
| 451 | be called more than others. */ |
| 452 | |
| 453 | u32 main_loop_count_last_dispatch; /**< Saved main loop counter of last |
| 454 | dispatch of this node. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 455 | |
| 456 | u32 main_loop_vector_stats[2]; |
| 457 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 458 | u16 flags; /**< Copy of main node flags. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 459 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 460 | u16 state; /**< Input node state. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 461 | |
| 462 | u16 n_next_nodes; |
| 463 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 464 | u16 cached_next_index; /**< Next frame index that vector |
| 465 | arguments were last enqueued to |
| 466 | last time this node ran. Set to |
| 467 | zero before first run of this |
| 468 | node. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 469 | |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 470 | u16 thread_index; /**< thread this node runs on */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 471 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 472 | u8 runtime_data[0]; /**< Function dependent |
| 473 | node-runtime data. This data is |
| 474 | thread local, and it is not |
| 475 | cloned from main thread. It needs |
| 476 | to be initialized for each thread |
| 477 | before it is used unless |
| 478 | runtime_data template exists in |
| 479 | vlib_node_t. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 480 | } |
| 481 | vlib_node_runtime_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 482 | |
Damjan Marion | e9f929b | 2017-03-16 11:32:09 +0100 | [diff] [blame] | 483 | #define VLIB_NODE_RUNTIME_DATA_SIZE (sizeof (vlib_node_runtime_t) - STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data)) |
| 484 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 485 | typedef struct |
| 486 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 487 | /* Number of allocated frames for this scalar/vector size. */ |
| 488 | u32 n_alloc_frames; |
| 489 | |
| 490 | /* Vector of free frame indices for this scalar/vector size. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 491 | u32 *free_frame_indices; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 492 | } vlib_frame_size_t; |
| 493 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 494 | typedef struct |
| 495 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 496 | /* Users opaque value for event type. */ |
| 497 | uword opaque; |
| 498 | } vlib_process_event_type_t; |
| 499 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 500 | typedef struct |
| 501 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 502 | /* Node runtime for this process. */ |
| 503 | vlib_node_runtime_t node_runtime; |
| 504 | |
| 505 | /* Where to longjmp when process is done. */ |
| 506 | clib_longjmp_t return_longjmp; |
| 507 | |
| 508 | #define VLIB_PROCESS_RETURN_LONGJMP_RETURN ((uword) ~0 - 0) |
| 509 | #define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND ((uword) ~0 - 1) |
| 510 | |
| 511 | /* Where to longjmp to resume node after suspend. */ |
| 512 | clib_longjmp_t resume_longjmp; |
| 513 | #define VLIB_PROCESS_RESUME_LONGJMP_SUSPEND 0 |
| 514 | #define VLIB_PROCESS_RESUME_LONGJMP_RESUME 1 |
| 515 | |
| 516 | u16 flags; |
| 517 | #define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK (1 << 0) |
| 518 | #define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT (1 << 1) |
| 519 | /* Set to indicate that this process has been added to resume vector. */ |
| 520 | #define VLIB_PROCESS_RESUME_PENDING (1 << 2) |
| 521 | |
| 522 | /* Process function is currently running. */ |
| 523 | #define VLIB_PROCESS_IS_RUNNING (1 << 3) |
| 524 | |
| 525 | /* Size of process stack. */ |
| 526 | u16 log2_n_stack_bytes; |
| 527 | |
| 528 | u32 suspended_process_frame_index; |
| 529 | |
| 530 | /* Number of times this process was suspended. */ |
| 531 | u32 n_suspends; |
| 532 | |
| 533 | /* Vectors of pending event data indexed by event type index. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 534 | void **pending_event_data_by_type_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 535 | |
| 536 | /* Bitmap of event type-indices with non-empty vectors. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 537 | uword *non_empty_event_type_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 538 | |
| 539 | /* Bitmap of event type-indices which are one time events. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 540 | uword *one_time_event_type_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 541 | |
| 542 | /* Type is opaque pointer -- typically a pointer to an event handler |
| 543 | function. Hash table to map opaque to a type index. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 544 | uword *event_type_index_by_type_opaque; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 545 | |
| 546 | /* Pool of currently valid event types. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 547 | vlib_process_event_type_t *event_type_pool; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 548 | |
Dave Barach | 5c20a01 | 2017-06-13 08:48:31 -0400 | [diff] [blame] | 549 | /* |
| 550 | * When suspending saves clock time (10us ticks) when process |
| 551 | * is to be resumed. |
| 552 | */ |
| 553 | u64 resume_clock_interval; |
| 554 | |
| 555 | /* Handle from timer code, to cancel an unexpired timer */ |
| 556 | u32 stop_timer_handle; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 557 | |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 558 | /* Default output function and its argument for any CLI outputs |
| 559 | within the process. */ |
| 560 | vlib_cli_output_function_t *output_function; |
| 561 | uword output_function_arg; |
| 562 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 563 | #ifdef CLIB_UNIX |
| 564 | /* Pad to a multiple of the page size so we can mprotect process stacks */ |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 565 | #define PAGE_SIZE_MULTIPLE 0x1000 |
| 566 | #define ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT __attribute__ ((aligned (PAGE_SIZE_MULTIPLE))) |
| 567 | #else |
| 568 | #define ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 569 | #endif |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 570 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 571 | /* Process stack. Starts here and extends 2^log2_n_stack_bytes |
| 572 | bytes. */ |
| 573 | |
| 574 | #define VLIB_PROCESS_STACK_MAGIC (0xdead7ead) |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 575 | u32 stack[0] ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 576 | } vlib_process_t __attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))); |
| 577 | |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 578 | #ifdef CLIB_UNIX |
| 579 | /* Ensure that the stack is aligned on the multiple of the page size */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 580 | typedef char |
| 581 | assert_process_stack_must_be_aligned_exactly_to_page_size_multiple[(sizeof |
| 582 | (vlib_process_t) |
| 583 | - |
| 584 | PAGE_SIZE_MULTIPLE) |
| 585 | == |
| 586 | 0 ? 0 : |
| 587 | -1]; |
Andrew Yourtchenko | 716d959 | 2016-05-10 10:51:34 +0000 | [diff] [blame] | 588 | #endif |
| 589 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 590 | typedef struct |
| 591 | { |
| 592 | u32 node_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 593 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 594 | u32 one_time_event; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 595 | } vlib_one_time_waiting_process_t; |
| 596 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 597 | typedef struct |
| 598 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 599 | u16 n_data_elts; |
| 600 | |
| 601 | u16 n_data_elt_bytes; |
| 602 | |
| 603 | /* n_data_elts * n_data_elt_bytes */ |
| 604 | u32 n_data_bytes; |
| 605 | |
| 606 | /* Process node & event type to be used to signal event. */ |
| 607 | u32 process_node_index; |
| 608 | |
| 609 | u32 event_type_index; |
| 610 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 611 | union |
| 612 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 613 | u8 inline_event_data[64 - 3 * sizeof (u32) - 2 * sizeof (u16)]; |
| 614 | |
| 615 | /* Vector of event data used only when data does not fit inline. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 616 | u8 *event_data_as_vector; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 617 | }; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 618 | } |
| 619 | vlib_signal_timed_event_data_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 620 | |
| 621 | always_inline uword |
| 622 | vlib_timing_wheel_data_is_timed_event (u32 d) |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 623 | { |
| 624 | return d & 1; |
| 625 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 626 | |
| 627 | always_inline u32 |
| 628 | vlib_timing_wheel_data_set_suspended_process (u32 i) |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 629 | { |
| 630 | return 0 + 2 * i; |
| 631 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 632 | |
| 633 | always_inline u32 |
| 634 | vlib_timing_wheel_data_set_timed_event (u32 i) |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 635 | { |
| 636 | return 1 + 2 * i; |
| 637 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 638 | |
| 639 | always_inline uword |
| 640 | vlib_timing_wheel_data_get_index (u32 d) |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 641 | { |
| 642 | return d / 2; |
| 643 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 644 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 645 | typedef struct |
| 646 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 647 | /* Public nodes. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 648 | vlib_node_t **nodes; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 649 | |
| 650 | /* Node index hashed by node name. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 651 | uword *node_by_name; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 652 | |
| 653 | u32 flags; |
| 654 | #define VLIB_NODE_MAIN_RUNTIME_STARTED (1 << 0) |
| 655 | |
| 656 | /* Nodes segregated by type for cache locality. |
| 657 | Does not apply to nodes of type VLIB_NODE_TYPE_INTERNAL. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 658 | vlib_node_runtime_t *nodes_by_type[VLIB_N_NODE_TYPE]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 659 | |
| 660 | /* Node runtime indices for input nodes with pending interrupts. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 661 | u32 *pending_interrupt_node_runtime_indices; |
Damjan Marion | 2c2b640 | 2017-03-28 14:16:15 +0200 | [diff] [blame] | 662 | clib_spinlock_t pending_interrupt_lock; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 663 | |
| 664 | /* Input nodes are switched from/to interrupt to/from polling mode |
| 665 | when average vector length goes above/below polling/interrupt |
| 666 | thresholds. */ |
| 667 | u32 polling_threshold_vector_length; |
| 668 | u32 interrupt_threshold_vector_length; |
| 669 | |
| 670 | /* Vector of next frames. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 671 | vlib_next_frame_t *next_frames; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 672 | |
| 673 | /* Vector of internal node's frames waiting to be called. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 674 | vlib_pending_frame_t *pending_frames; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 675 | |
| 676 | /* Timing wheel for scheduling time-based node dispatch. */ |
Dave Barach | 5c20a01 | 2017-06-13 08:48:31 -0400 | [diff] [blame] | 677 | void *timing_wheel; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 678 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 679 | vlib_signal_timed_event_data_t *signal_timed_event_data_pool; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 680 | |
| 681 | /* Opaque data vector added via timing_wheel_advance. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 682 | u32 *data_from_advancing_timing_wheel; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 683 | |
| 684 | /* CPU time of next process to be ready on timing wheel. */ |
Dave Barach | 5c20a01 | 2017-06-13 08:48:31 -0400 | [diff] [blame] | 685 | f64 time_next_process_ready; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 686 | |
| 687 | /* Vector of process nodes. |
| 688 | One for each node of type VLIB_NODE_TYPE_PROCESS. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 689 | vlib_process_t **processes; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 690 | |
| 691 | /* Current running process or ~0 if no process running. */ |
| 692 | u32 current_process_index; |
| 693 | |
| 694 | /* Pool of pending process frames. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 695 | vlib_pending_frame_t *suspended_process_frames; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 696 | |
| 697 | /* Vector of event data vectors pending recycle. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 698 | void **recycled_event_data_vectors; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 699 | |
| 700 | /* Current counts of nodes in each state. */ |
| 701 | u32 input_node_counts_by_state[VLIB_N_NODE_STATE]; |
| 702 | |
| 703 | /* Hash of (scalar_size,vector_size) to frame_sizes index. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 704 | uword *frame_size_hash; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 705 | |
| 706 | /* Per-size frame allocation information. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 707 | vlib_frame_size_t *frame_sizes; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 708 | |
| 709 | /* Time of last node runtime stats clear. */ |
| 710 | f64 time_last_runtime_stats_clear; |
| 711 | |
| 712 | /* Node registrations added by constructors */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 713 | vlib_node_registration_t *node_registrations; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 714 | } vlib_node_main_t; |
| 715 | |
Damjan Marion | 0f8ecf0 | 2016-06-27 08:30:30 +0200 | [diff] [blame] | 716 | |
| 717 | #define FRAME_QUEUE_MAX_NELTS 32 |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 718 | typedef struct |
| 719 | { |
| 720 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
Damjan Marion | 0f8ecf0 | 2016-06-27 08:30:30 +0200 | [diff] [blame] | 721 | u64 head; |
| 722 | u64 head_hint; |
| 723 | u64 tail; |
| 724 | u32 n_in_use; |
| 725 | u32 nelts; |
| 726 | u32 written; |
| 727 | u32 threshold; |
| 728 | i32 n_vectors[FRAME_QUEUE_MAX_NELTS]; |
| 729 | } frame_queue_trace_t; |
| 730 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 731 | typedef struct |
| 732 | { |
Damjan Marion | 0f8ecf0 | 2016-06-27 08:30:30 +0200 | [diff] [blame] | 733 | u64 count[FRAME_QUEUE_MAX_NELTS]; |
| 734 | } frame_queue_nelt_counter_t; |
| 735 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 736 | #endif /* included_vlib_node_h */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 737 | |
| 738 | /* |
| 739 | * fd.io coding-style-patch-verification: ON |
| 740 | * |
| 741 | * Local Variables: |
| 742 | * eval: (c-set-style "gnu") |
| 743 | * End: |
| 744 | */ |