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