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