2015-12-08 15:45:58 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Cisco and/or its affiliates.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* node.h: VLIB processing nodes
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Eliot Dresselhaus
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef included_vlib_node_h
|
|
|
|
#define included_vlib_node_h
|
|
|
|
|
2016-05-11 23:07:18 +02:00
|
|
|
#include <vppinfra/cpu.h>
|
2015-12-08 15:45:58 -07:00
|
|
|
#include <vppinfra/longjmp.h>
|
2017-03-28 14:16:15 +02:00
|
|
|
#include <vppinfra/lock.h>
|
2015-12-08 15:45:58 -07:00
|
|
|
#include <vlib/trace.h> /* for vlib_trace_filter_t */
|
|
|
|
|
|
|
|
/* Forward declaration. */
|
|
|
|
struct vlib_node_runtime_t;
|
|
|
|
struct vlib_frame_t;
|
|
|
|
|
|
|
|
/* Internal nodes (including output nodes) move data from node to
|
|
|
|
node (or out of the graph for output nodes). */
|
|
|
|
typedef uword (vlib_node_function_t) (struct vlib_main_t * vm,
|
|
|
|
struct vlib_node_runtime_t * node,
|
|
|
|
struct vlib_frame_t * frame);
|
|
|
|
|
Metadata / opaque formatting belongs in vpp
VPP graph dispatch trace record description:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Major Version | Minor Version | NStrings | ProtoHint |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer index (big endian) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ VPP graph node name ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Metadata ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque 2 ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VPP ASCII packet trace (if NStrings > 4) | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Packet data (up to 16K) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Graph dispatch records comprise a version stamp, an indication of how
many NULL-terminated strings will follow the record header, and a
protocol hint.
The buffer index allows downstream consumers of these data to easily
filter/track single packets as they traverse the forwarding
graph. FWIW, the 32-bit buffer index is stored in big endian format.
As of this writing, major version = 1, minor version = 0. Nstrings
will be either 4 or 5.
Here is the current set of protocol hints:
typedef enum
{
VLIB_NODE_PROTO_HINT_NONE = 0,
VLIB_NODE_PROTO_HINT_ETHERNET,
VLIB_NODE_PROTO_HINT_IP4,
VLIB_NODE_PROTO_HINT_IP6,
VLIB_NODE_PROTO_HINT_TCP,
VLIB_NODE_PROTO_HINT_UDP,
VLIB_NODE_N_PROTO_HINTS,
} vlib_node_proto_hint_t;
Example: VLIB_NODE_PROTO_HINT_IP6 means that the first octet of packet
data SHOULD be 0x60, and should begin an ipv6 packet header.
Change-Id: Idf310bad80cc0e4207394c80f18db5f77c378741
Signed-off-by: Dave Barach <dave@barachs.net>
2018-11-27 16:52:59 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
VLIB_NODE_PROTO_HINT_NONE = 0,
|
|
|
|
VLIB_NODE_PROTO_HINT_ETHERNET,
|
|
|
|
VLIB_NODE_PROTO_HINT_IP4,
|
|
|
|
VLIB_NODE_PROTO_HINT_IP6,
|
|
|
|
VLIB_NODE_PROTO_HINT_TCP,
|
|
|
|
VLIB_NODE_PROTO_HINT_UDP,
|
|
|
|
VLIB_NODE_N_PROTO_HINTS,
|
|
|
|
} vlib_node_proto_hint_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* An internal node on the call graph (could be output). */
|
|
|
|
VLIB_NODE_TYPE_INTERNAL,
|
|
|
|
|
|
|
|
/* Nodes which input data into the processing graph.
|
|
|
|
Input nodes are called for each iteration of main loop. */
|
|
|
|
VLIB_NODE_TYPE_INPUT,
|
|
|
|
|
|
|
|
/* Nodes to be called before all input nodes.
|
|
|
|
Used, for example, to clean out driver TX rings before
|
|
|
|
processing input. */
|
|
|
|
VLIB_NODE_TYPE_PRE_INPUT,
|
|
|
|
|
|
|
|
/* "Process" nodes which can be suspended and later resumed. */
|
|
|
|
VLIB_NODE_TYPE_PROCESS,
|
|
|
|
|
|
|
|
VLIB_N_NODE_TYPE,
|
|
|
|
} vlib_node_type_t;
|
|
|
|
|
2018-05-28 21:26:47 +02:00
|
|
|
typedef struct _vlib_node_fn_registration
|
|
|
|
{
|
|
|
|
vlib_node_function_t *function;
|
2021-03-10 14:35:28 +01:00
|
|
|
clib_march_variant_type_t march_variant;
|
2018-05-28 21:26:47 +02:00
|
|
|
struct _vlib_node_fn_registration *next_registration;
|
|
|
|
} vlib_node_fn_registration_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct _vlib_node_registration
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Vector processing function for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_node_function_t *function;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2018-05-28 21:26:47 +02:00
|
|
|
/* Node function candidate registration with priority */
|
|
|
|
vlib_node_fn_registration_t *node_fn_registrations;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Node name. */
|
2016-07-08 08:13:45 -04:00
|
|
|
char *name;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Name of sibling (if applicable). */
|
2016-07-08 08:13:45 -04:00
|
|
|
char *sibling_of;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node index filled in by registration. */
|
|
|
|
u32 index;
|
|
|
|
|
|
|
|
/* Type of this node. */
|
|
|
|
vlib_node_type_t type;
|
|
|
|
|
|
|
|
/* Error strings indexed by error code for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
char **error_strings;
|
2021-05-06 14:09:50 +02:00
|
|
|
vlib_error_desc_t *error_counters;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Buffer format/unformat for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
format_function_t *format_buffer;
|
|
|
|
unformat_function_t *unformat_buffer;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Trace format/unformat for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
format_function_t *format_trace;
|
|
|
|
unformat_function_t *unformat_trace;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Function to validate incoming frames. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u8 *(*validate_frame) (struct vlib_main_t * vm,
|
|
|
|
struct vlib_node_runtime_t *,
|
|
|
|
struct vlib_frame_t * f);
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Per-node runtime data. */
|
2016-07-08 08:13:45 -04:00
|
|
|
void *runtime_data;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Process stack size. */
|
|
|
|
u16 process_log2_n_stack_bytes;
|
|
|
|
|
|
|
|
/* Number of bytes of per-node run time data. */
|
|
|
|
u8 runtime_data_bytes;
|
|
|
|
|
|
|
|
/* State for input nodes. */
|
|
|
|
u8 state;
|
|
|
|
|
|
|
|
/* Node flags. */
|
|
|
|
u16 flags;
|
|
|
|
|
Metadata / opaque formatting belongs in vpp
VPP graph dispatch trace record description:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Major Version | Minor Version | NStrings | ProtoHint |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer index (big endian) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ VPP graph node name ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Metadata ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque 2 ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VPP ASCII packet trace (if NStrings > 4) | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Packet data (up to 16K) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Graph dispatch records comprise a version stamp, an indication of how
many NULL-terminated strings will follow the record header, and a
protocol hint.
The buffer index allows downstream consumers of these data to easily
filter/track single packets as they traverse the forwarding
graph. FWIW, the 32-bit buffer index is stored in big endian format.
As of this writing, major version = 1, minor version = 0. Nstrings
will be either 4 or 5.
Here is the current set of protocol hints:
typedef enum
{
VLIB_NODE_PROTO_HINT_NONE = 0,
VLIB_NODE_PROTO_HINT_ETHERNET,
VLIB_NODE_PROTO_HINT_IP4,
VLIB_NODE_PROTO_HINT_IP6,
VLIB_NODE_PROTO_HINT_TCP,
VLIB_NODE_PROTO_HINT_UDP,
VLIB_NODE_N_PROTO_HINTS,
} vlib_node_proto_hint_t;
Example: VLIB_NODE_PROTO_HINT_IP6 means that the first octet of packet
data SHOULD be 0x60, and should begin an ipv6 packet header.
Change-Id: Idf310bad80cc0e4207394c80f18db5f77c378741
Signed-off-by: Dave Barach <dave@barachs.net>
2018-11-27 16:52:59 -05:00
|
|
|
/* protocol at b->data[b->current_data] upon entry to the dispatch fn */
|
|
|
|
u8 protocol_hint;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Size of scalar and vector arguments in bytes. */
|
2022-01-18 16:24:23 +01:00
|
|
|
u8 vector_size, aux_size;
|
|
|
|
u16 scalar_size;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Number of error codes used by this node. */
|
|
|
|
u16 n_errors;
|
|
|
|
|
|
|
|
/* Number of next node names that follow. */
|
|
|
|
u16 n_next_nodes;
|
|
|
|
|
|
|
|
/* Constructor link-list, don't ask... */
|
2016-07-08 08:13:45 -04:00
|
|
|
struct _vlib_node_registration *next_registration;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Names of next nodes which this node feeds into. */
|
2016-07-08 08:13:45 -04:00
|
|
|
char *next_nodes[];
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
} vlib_node_registration_t;
|
|
|
|
|
2018-08-10 22:39:11 +02:00
|
|
|
#ifndef CLIB_MARCH_VARIANT
|
2021-03-06 12:26:28 +01:00
|
|
|
#define VLIB_REGISTER_NODE(x, ...) \
|
|
|
|
__VA_ARGS__ vlib_node_registration_t x; \
|
|
|
|
static void __vlib_add_node_registration_##x (void) \
|
|
|
|
__attribute__ ((__constructor__)); \
|
|
|
|
static void __vlib_add_node_registration_##x (void) \
|
|
|
|
{ \
|
|
|
|
vlib_global_main_t *vgm = vlib_get_global_main (); \
|
|
|
|
x.next_registration = vgm->node_registrations; \
|
|
|
|
vgm->node_registrations = &x; \
|
|
|
|
} \
|
|
|
|
static void __vlib_rm_node_registration_##x (void) \
|
|
|
|
__attribute__ ((__destructor__)); \
|
|
|
|
static void __vlib_rm_node_registration_##x (void) \
|
|
|
|
{ \
|
|
|
|
vlib_global_main_t *vgm = vlib_get_global_main (); \
|
|
|
|
VLIB_REMOVE_FROM_LINKED_LIST (vgm->node_registrations, &x, \
|
|
|
|
next_registration); \
|
|
|
|
} \
|
|
|
|
__VA_ARGS__ vlib_node_registration_t x
|
2018-08-10 22:39:11 +02:00
|
|
|
#else
|
|
|
|
#define VLIB_REGISTER_NODE(x,...) \
|
2019-09-02 19:00:33 +02:00
|
|
|
STATIC_ASSERT (sizeof(# __VA_ARGS__) != 7,"node " #x " must not be declared as static"); \
|
2018-08-10 22:39:11 +02:00
|
|
|
static __clib_unused vlib_node_registration_t __clib_unused_##x
|
|
|
|
#endif
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2018-08-27 22:43:23 +02:00
|
|
|
#ifndef CLIB_MARCH_VARIANT
|
|
|
|
#define CLIB_MARCH_VARIANT_STR "default"
|
|
|
|
#else
|
|
|
|
#define _CLIB_MARCH_VARIANT_STR(s) __CLIB_MARCH_VARIANT_STR(s)
|
|
|
|
#define __CLIB_MARCH_VARIANT_STR(s) #s
|
|
|
|
#define CLIB_MARCH_VARIANT_STR _CLIB_MARCH_VARIANT_STR(CLIB_MARCH_VARIANT)
|
|
|
|
#endif
|
|
|
|
|
2021-03-10 14:35:28 +01:00
|
|
|
#define VLIB_NODE_FN(node) \
|
2022-10-12 16:02:18 +02:00
|
|
|
uword CLIB_MARCH_SFX (node##_fn) (vlib_main_t *, vlib_node_runtime_t *, \
|
|
|
|
vlib_frame_t *); \
|
2021-03-10 14:35:28 +01:00
|
|
|
static vlib_node_fn_registration_t CLIB_MARCH_SFX ( \
|
|
|
|
node##_fn_registration) = { \
|
|
|
|
.function = &CLIB_MARCH_SFX (node##_fn), \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static void __clib_constructor CLIB_MARCH_SFX (node##_multiarch_register) ( \
|
|
|
|
void) \
|
|
|
|
{ \
|
|
|
|
extern vlib_node_registration_t node; \
|
|
|
|
vlib_node_fn_registration_t *r; \
|
|
|
|
r = &CLIB_MARCH_SFX (node##_fn_registration); \
|
|
|
|
r->march_variant = CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE); \
|
|
|
|
r->next_registration = node.node_fn_registrations; \
|
|
|
|
node.node_fn_registrations = r; \
|
|
|
|
} \
|
2021-04-30 11:11:08 +02:00
|
|
|
uword CLIB_MARCH_SFX (node##_fn)
|
2018-05-28 21:26:47 +02:00
|
|
|
|
2020-03-10 14:35:32 +00:00
|
|
|
unformat_function_t unformat_vlib_node_variant;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Total calls, clock ticks and vector elements processed for this node. */
|
|
|
|
u64 calls, vectors, clocks, suspends;
|
|
|
|
u64 max_clock;
|
|
|
|
u64 max_clock_n;
|
|
|
|
} vlib_node_stats_t;
|
|
|
|
|
|
|
|
#define foreach_vlib_node_state \
|
|
|
|
/* Input node is called each iteration of main loop. \
|
|
|
|
This is the default (zero). */ \
|
|
|
|
_ (POLLING) \
|
|
|
|
/* Input node is called when device signals an interrupt. */ \
|
|
|
|
_ (INTERRUPT) \
|
|
|
|
/* Input node is never called. */ \
|
|
|
|
_ (DISABLED)
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
#define _(f) VLIB_NODE_STATE_##f,
|
|
|
|
foreach_vlib_node_state
|
|
|
|
#undef _
|
2016-07-08 08:13:45 -04:00
|
|
|
VLIB_N_NODE_STATE,
|
2015-12-08 15:45:58 -07:00
|
|
|
} vlib_node_state_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct vlib_node_t
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Vector processing function for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_node_function_t *function;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node name. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u8 *name;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node name index in elog string table. */
|
|
|
|
u32 name_elog_string;
|
|
|
|
|
|
|
|
/* Total statistics for this node. */
|
|
|
|
vlib_node_stats_t stats_total;
|
|
|
|
|
|
|
|
/* Saved values as of last clear (or zero if never cleared).
|
|
|
|
Current values are always stats_total - stats_last_clear. */
|
|
|
|
vlib_node_stats_t stats_last_clear;
|
|
|
|
|
|
|
|
/* Type of this node. */
|
|
|
|
vlib_node_type_t type;
|
|
|
|
|
|
|
|
/* Node index. */
|
|
|
|
u32 index;
|
|
|
|
|
|
|
|
/* Index of corresponding node runtime. */
|
|
|
|
u32 runtime_index;
|
|
|
|
|
|
|
|
/* Runtime data for this node. */
|
2022-03-19 00:07:52 +01:00
|
|
|
u8 *runtime_data;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node flags. */
|
|
|
|
u16 flags;
|
|
|
|
|
|
|
|
/* Processing function keeps frame. Tells node dispatching code not
|
|
|
|
to free frame after dispatch is done. */
|
|
|
|
#define VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH (1 << 0)
|
|
|
|
|
|
|
|
/* Node counts as output/drop/punt node for stats purposes. */
|
|
|
|
#define VLIB_NODE_FLAG_IS_OUTPUT (1 << 1)
|
|
|
|
#define VLIB_NODE_FLAG_IS_DROP (1 << 2)
|
|
|
|
#define VLIB_NODE_FLAG_IS_PUNT (1 << 3)
|
|
|
|
#define VLIB_NODE_FLAG_IS_HANDOFF (1 << 4)
|
|
|
|
|
|
|
|
/* Set if current node runtime has traced vectors. */
|
|
|
|
#define VLIB_NODE_FLAG_TRACE (1 << 5)
|
|
|
|
|
|
|
|
#define VLIB_NODE_FLAG_SWITCH_FROM_INTERRUPT_TO_POLLING_MODE (1 << 6)
|
|
|
|
#define VLIB_NODE_FLAG_SWITCH_FROM_POLLING_TO_INTERRUPT_MODE (1 << 7)
|
2019-09-24 18:10:49 +02:00
|
|
|
#define VLIB_NODE_FLAG_TRACE_SUPPORTED (1 << 8)
|
2021-03-19 13:12:41 -07:00
|
|
|
#define VLIB_NODE_FLAG_ADAPTIVE_MODE (1 << 9)
|
2024-08-29 14:01:06 +02:00
|
|
|
#define VLIB_NODE_FLAG_ALLOW_LAZY_NEXT_NODES (1 << 10)
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* State for input nodes. */
|
|
|
|
u8 state;
|
|
|
|
|
|
|
|
/* Number of bytes of run time data. */
|
|
|
|
u8 runtime_data_bytes;
|
|
|
|
|
Metadata / opaque formatting belongs in vpp
VPP graph dispatch trace record description:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Major Version | Minor Version | NStrings | ProtoHint |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer index (big endian) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ VPP graph node name ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Metadata ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Buffer Opaque 2 ... ... | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VPP ASCII packet trace (if NStrings > 4) | NULL octet |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Packet data (up to 16K) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Graph dispatch records comprise a version stamp, an indication of how
many NULL-terminated strings will follow the record header, and a
protocol hint.
The buffer index allows downstream consumers of these data to easily
filter/track single packets as they traverse the forwarding
graph. FWIW, the 32-bit buffer index is stored in big endian format.
As of this writing, major version = 1, minor version = 0. Nstrings
will be either 4 or 5.
Here is the current set of protocol hints:
typedef enum
{
VLIB_NODE_PROTO_HINT_NONE = 0,
VLIB_NODE_PROTO_HINT_ETHERNET,
VLIB_NODE_PROTO_HINT_IP4,
VLIB_NODE_PROTO_HINT_IP6,
VLIB_NODE_PROTO_HINT_TCP,
VLIB_NODE_PROTO_HINT_UDP,
VLIB_NODE_N_PROTO_HINTS,
} vlib_node_proto_hint_t;
Example: VLIB_NODE_PROTO_HINT_IP6 means that the first octet of packet
data SHOULD be 0x60, and should begin an ipv6 packet header.
Change-Id: Idf310bad80cc0e4207394c80f18db5f77c378741
Signed-off-by: Dave Barach <dave@barachs.net>
2018-11-27 16:52:59 -05:00
|
|
|
/* protocol at b->data[b->current_data] upon entry to the dispatch fn */
|
|
|
|
u8 protocol_hint;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Number of error codes used by this node. */
|
|
|
|
u16 n_errors;
|
|
|
|
|
|
|
|
/* Size of scalar and vector arguments in bytes. */
|
2021-12-23 17:05:02 +01:00
|
|
|
u16 frame_size, scalar_offset, vector_offset, magic_offset, aux_offset;
|
|
|
|
u16 frame_size_index;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Handle/index in error heap for this node. */
|
|
|
|
u32 error_heap_handle;
|
|
|
|
u32 error_heap_index;
|
|
|
|
|
2020-10-07 18:05:37 +02:00
|
|
|
/* Counter structures indexed by counter code for this node. */
|
2021-05-06 14:09:50 +02:00
|
|
|
vlib_error_desc_t *error_counters;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Vector of next node names.
|
|
|
|
Only used before next_nodes array is initialized. */
|
2016-07-08 08:13:45 -04:00
|
|
|
char **next_node_names;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Next node indices for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u32 *next_nodes;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Name of node that we are sibling of. */
|
2016-07-08 08:13:45 -04:00
|
|
|
char *sibling_of;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Bitmap of all of this node's siblings. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *sibling_bitmap;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Total number of vectors sent to each next node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u64 *n_vectors_by_next_node;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Hash table mapping next node index into slot in
|
|
|
|
next_nodes vector. Quickly determines whether this node
|
|
|
|
is connected to given next node and, if so, with which slot. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *next_slot_by_node;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Bitmap of node indices which feed this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *prev_node_bitmap;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node/next-index which own enqueue rights with to this node. */
|
|
|
|
u32 owner_node_index, owner_next_index;
|
|
|
|
|
|
|
|
/* Buffer format/unformat for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
format_function_t *format_buffer;
|
|
|
|
unformat_function_t *unformat_buffer;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Trace buffer format/unformat for this node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
format_function_t *format_trace;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Function to validate incoming frames. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u8 *(*validate_frame) (struct vlib_main_t * vm,
|
|
|
|
struct vlib_node_runtime_t *,
|
|
|
|
struct vlib_frame_t * f);
|
2016-05-13 12:55:01 -04:00
|
|
|
/* for pretty-printing, not typically valid */
|
2016-07-08 08:13:45 -04:00
|
|
|
u8 *state_string;
|
2018-08-27 22:43:23 +02:00
|
|
|
|
|
|
|
/* Node function candidate registration with priority */
|
|
|
|
vlib_node_fn_registration_t *node_fn_registrations;
|
2015-12-08 15:45:58 -07:00
|
|
|
} vlib_node_t;
|
|
|
|
|
|
|
|
#define VLIB_INVALID_NODE_INDEX ((u32) ~0)
|
|
|
|
|
|
|
|
/* Max number of vector elements to process at once per node. */
|
|
|
|
#define VLIB_FRAME_SIZE 256
|
2021-12-23 17:05:02 +01:00
|
|
|
/* Number of extra elements allocated at the end of vecttor. */
|
|
|
|
#define VLIB_FRAME_SIZE_EXTRA 4
|
|
|
|
/* Frame data alignment */
|
|
|
|
#define VLIB_FRAME_DATA_ALIGN 16
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Calling frame (think stack frame) for a node. */
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct vlib_frame_t
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Frame flags. */
|
2018-09-14 14:38:53 +02:00
|
|
|
u16 frame_flags;
|
|
|
|
|
|
|
|
/* User flags. Used for sending hints to the next node. */
|
2015-12-08 15:45:58 -07:00
|
|
|
u16 flags;
|
|
|
|
|
2021-12-23 17:05:02 +01:00
|
|
|
/* Scalar, vector and aux offsets in this frame. */
|
|
|
|
u16 scalar_offset, vector_offset, aux_offset;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Number of vector elements currently in frame. */
|
|
|
|
u16 n_vectors;
|
|
|
|
|
2022-09-05 15:30:18 +00:00
|
|
|
/* Index of frame size corresponding to allocated node. */
|
|
|
|
u16 frame_size_index;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Scalar and vector arguments to next node. */
|
|
|
|
u8 arguments[0];
|
|
|
|
} vlib_frame_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2019-07-15 15:40:56 +02:00
|
|
|
/* Frame pointer. */
|
|
|
|
vlib_frame_t *frame;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node runtime for this next. */
|
|
|
|
u32 node_runtime_index;
|
|
|
|
|
|
|
|
/* Next frame flags. */
|
|
|
|
u32 flags;
|
|
|
|
|
|
|
|
/* Reflects node frame-used flag for this next. */
|
|
|
|
#define VLIB_FRAME_NO_FREE_AFTER_DISPATCH \
|
|
|
|
VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH
|
|
|
|
|
2019-02-21 20:24:54 +01:00
|
|
|
/* Don't append this frame */
|
|
|
|
#define VLIB_FRAME_NO_APPEND (1 << 14)
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* This next frame owns enqueue to node
|
|
|
|
corresponding to node_runtime_index. */
|
|
|
|
#define VLIB_FRAME_OWNER (1 << 15)
|
|
|
|
|
|
|
|
/* Set when frame has been allocated for this next. */
|
|
|
|
#define VLIB_FRAME_IS_ALLOCATED VLIB_NODE_FLAG_IS_OUTPUT
|
|
|
|
|
|
|
|
/* Set when frame has been added to pending vector. */
|
|
|
|
#define VLIB_FRAME_PENDING VLIB_NODE_FLAG_IS_DROP
|
|
|
|
|
|
|
|
/* Set when frame is to be freed after dispatch. */
|
|
|
|
#define VLIB_FRAME_FREE_AFTER_DISPATCH VLIB_NODE_FLAG_IS_PUNT
|
|
|
|
|
|
|
|
/* Set when frame has traced packets. */
|
|
|
|
#define VLIB_FRAME_TRACE VLIB_NODE_FLAG_TRACE
|
|
|
|
|
|
|
|
/* Number of vectors enqueue to this next since last overflow. */
|
|
|
|
u32 vectors_since_last_overflow;
|
|
|
|
} vlib_next_frame_t;
|
|
|
|
|
|
|
|
always_inline void
|
|
|
|
vlib_next_frame_init (vlib_next_frame_t * nf)
|
|
|
|
{
|
2018-10-17 10:38:51 -04:00
|
|
|
clib_memset (nf, 0, sizeof (nf[0]));
|
2015-12-08 15:45:58 -07:00
|
|
|
nf->node_runtime_index = ~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A frame pending dispatch by main loop. */
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Frame index (in the heap). */
|
2019-07-15 15:40:56 +02:00
|
|
|
vlib_frame_t *frame;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2021-04-15 19:54:44 +02:00
|
|
|
/* Node and runtime for this frame. */
|
|
|
|
u32 node_runtime_index;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Start of next frames for this node. */
|
|
|
|
u32 next_frame_index;
|
|
|
|
|
|
|
|
/* Special value for next_frame_index when there is no next frame. */
|
|
|
|
#define VLIB_PENDING_FRAME_NO_NEXT_FRAME ((u32) ~0)
|
|
|
|
} vlib_pending_frame_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct vlib_node_runtime_t
|
|
|
|
{
|
2017-03-16 11:32:09 +01:00
|
|
|
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); /**< cacheline mark */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
vlib_node_function_t *function; /**< Node function to call. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
vlib_error_t *errors; /**< Vector of errors for this node. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 clocks_since_last_overflow; /**< Number of clock cycles. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 max_clock; /**< Maximum clock cycle for an
|
|
|
|
invocation. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 max_clock_n; /**< Number of vectors in the recorded
|
|
|
|
max_clock. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 calls_since_last_overflow; /**< Number of calls. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 vectors_since_last_overflow; /**< Number of vector elements
|
|
|
|
processed by this node. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 next_frame_index; /**< Start of next frames for this
|
|
|
|
node. */
|
|
|
|
|
|
|
|
u32 node_index; /**< Node index. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 input_main_loops_per_call; /**< For input nodes: decremented
|
|
|
|
on each main loop interation until
|
|
|
|
it reaches zero and function is
|
|
|
|
called. Allows some input nodes to
|
|
|
|
be called more than others. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u32 main_loop_count_last_dispatch; /**< Saved main loop counter of last
|
|
|
|
dispatch of this node. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
u32 main_loop_vector_stats[2];
|
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u16 flags; /**< Copy of main node flags. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u16 state; /**< Input node state. */
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
u16 n_next_nodes;
|
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u16 cached_next_index; /**< Next frame index that vector
|
|
|
|
arguments were last enqueued to
|
|
|
|
last time this node ran. Set to
|
|
|
|
zero before first run of this
|
|
|
|
node. */
|
|
|
|
|
2022-03-29 15:13:26 +00:00
|
|
|
CLIB_ALIGN_MARK (runtime_data_pad, 8);
|
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
u8 runtime_data[0]; /**< Function dependent
|
|
|
|
node-runtime data. This data is
|
|
|
|
thread local, and it is not
|
|
|
|
cloned from main thread. It needs
|
|
|
|
to be initialized for each thread
|
|
|
|
before it is used unless
|
|
|
|
runtime_data template exists in
|
|
|
|
vlib_node_t. */
|
2016-07-08 08:13:45 -04:00
|
|
|
}
|
|
|
|
vlib_node_runtime_t;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-03-16 11:32:09 +01:00
|
|
|
#define VLIB_NODE_RUNTIME_DATA_SIZE (sizeof (vlib_node_runtime_t) - STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data))
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Number of allocated frames for this scalar/vector size. */
|
|
|
|
u32 n_alloc_frames;
|
|
|
|
|
2021-12-23 17:05:02 +01:00
|
|
|
/* Frame size */
|
|
|
|
u16 frame_size;
|
|
|
|
|
2019-07-15 15:40:56 +02:00
|
|
|
/* Vector of free frames for this scalar/vector size. */
|
|
|
|
vlib_frame_t **free_frames;
|
2015-12-08 15:45:58 -07:00
|
|
|
} vlib_frame_size_t;
|
|
|
|
|
2021-12-23 17:05:02 +01:00
|
|
|
STATIC_ASSERT_SIZEOF (vlib_frame_size_t, 16);
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Users opaque value for event type. */
|
|
|
|
uword opaque;
|
|
|
|
} vlib_process_event_type_t;
|
|
|
|
|
2024-09-10 17:07:49 +02:00
|
|
|
#define foreach_vlib_process_state \
|
|
|
|
_ (NOT_STARTED, "not started") \
|
|
|
|
_ (RUNNING, "running") \
|
|
|
|
_ (SUSPENDED, "suspended") \
|
|
|
|
_ (WAIT_FOR_EVENT, "event wait") \
|
|
|
|
_ (WAIT_FOR_CLOCK, "clock wait") \
|
|
|
|
_ (WAIT_FOR_EVENT_OR_CLOCK, "any wait") \
|
|
|
|
_ (WAIT_FOR_ONE_TIME_EVENT, "one time event wait") \
|
|
|
|
_ (YIELD, "yield")
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
#define _(n, s) VLIB_PROCESS_STATE_##n,
|
|
|
|
foreach_vlib_process_state VLIB_PROCESS_N_STATES
|
|
|
|
#undef _
|
|
|
|
} __clib_packed vlib_process_state_t;
|
|
|
|
|
|
|
|
STATIC_ASSERT (VLIB_PROCESS_STATE_NOT_STARTED == 0, "");
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
VLIB_PROCESS_RESTORE_REASON_UNKNOWN = 0,
|
|
|
|
VLIB_PROCESS_RESTORE_REASON_EVENT,
|
|
|
|
VLIB_PROCESS_RESTORE_REASON_CLOCK,
|
|
|
|
VLIB_PROCESS_RESTORE_REASON_TIMED_EVENT,
|
|
|
|
VLIB_PROCESS_RESTORE_REASON_YIELD,
|
|
|
|
VLIB_PROCRSS_N_RESTORE_REASON
|
|
|
|
} __clib_packed vlib_process_restore_reason_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
vlib_process_restore_reason_t reason;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
u32 runtime_index;
|
|
|
|
u32 timed_event_data_pool_index;
|
|
|
|
};
|
|
|
|
} __clib_packed vlib_process_restore_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2020-05-20 22:01:44 +02:00
|
|
|
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Node runtime for this process. */
|
|
|
|
vlib_node_runtime_t node_runtime;
|
|
|
|
|
|
|
|
/* Where to longjmp when process is done. */
|
|
|
|
clib_longjmp_t return_longjmp;
|
|
|
|
|
|
|
|
#define VLIB_PROCESS_RETURN_LONGJMP_RETURN ((uword) ~0 - 0)
|
|
|
|
#define VLIB_PROCESS_RETURN_LONGJMP_SUSPEND ((uword) ~0 - 1)
|
|
|
|
|
|
|
|
/* Where to longjmp to resume node after suspend. */
|
|
|
|
clib_longjmp_t resume_longjmp;
|
|
|
|
#define VLIB_PROCESS_RESUME_LONGJMP_SUSPEND 0
|
|
|
|
#define VLIB_PROCESS_RESUME_LONGJMP_RESUME 1
|
|
|
|
|
2024-09-10 17:07:49 +02:00
|
|
|
/* Process state. */
|
|
|
|
vlib_process_state_t state;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2024-09-10 17:07:49 +02:00
|
|
|
/* Process is added to resume list due to pending event */
|
|
|
|
u8 event_resume_pending : 1;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Size of process stack. */
|
|
|
|
u16 log2_n_stack_bytes;
|
|
|
|
|
|
|
|
u32 suspended_process_frame_index;
|
|
|
|
|
|
|
|
/* Number of times this process was suspended. */
|
|
|
|
u32 n_suspends;
|
|
|
|
|
|
|
|
/* Vectors of pending event data indexed by event type index. */
|
2022-03-23 16:59:23 +01:00
|
|
|
u8 **pending_event_data_by_type_index;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Bitmap of event type-indices with non-empty vectors. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *non_empty_event_type_bitmap;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Bitmap of event type-indices which are one time events. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *one_time_event_type_bitmap;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Type is opaque pointer -- typically a pointer to an event handler
|
|
|
|
function. Hash table to map opaque to a type index. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *event_type_index_by_type_opaque;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Pool of currently valid event types. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_process_event_type_t *event_type_pool;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2017-06-13 08:48:31 -04:00
|
|
|
/*
|
|
|
|
* When suspending saves clock time (10us ticks) when process
|
|
|
|
* is to be resumed.
|
|
|
|
*/
|
|
|
|
u64 resume_clock_interval;
|
|
|
|
|
|
|
|
/* Handle from timer code, to cancel an unexpired timer */
|
|
|
|
u32 stop_timer_handle;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2016-05-10 10:51:34 +00:00
|
|
|
/* Default output function and its argument for any CLI outputs
|
|
|
|
within the process. */
|
|
|
|
vlib_cli_output_function_t *output_function;
|
|
|
|
uword output_function_arg;
|
|
|
|
|
2020-05-20 22:01:44 +02:00
|
|
|
/* Process stack */
|
2015-12-08 15:45:58 -07:00
|
|
|
#define VLIB_PROCESS_STACK_MAGIC (0xdead7ead)
|
2020-05-20 22:01:44 +02:00
|
|
|
u32 *stack;
|
|
|
|
} vlib_process_t;
|
2016-05-10 10:51:34 +00:00
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u32 node_index;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
u32 one_time_event;
|
2015-12-08 15:45:58 -07:00
|
|
|
} vlib_one_time_waiting_process_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
u16 n_data_elts;
|
|
|
|
|
|
|
|
u16 n_data_elt_bytes;
|
|
|
|
|
|
|
|
/* n_data_elts * n_data_elt_bytes */
|
|
|
|
u32 n_data_bytes;
|
|
|
|
|
|
|
|
/* Process node & event type to be used to signal event. */
|
|
|
|
u32 process_node_index;
|
|
|
|
|
|
|
|
u32 event_type_index;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
union
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
u8 inline_event_data[64 - 3 * sizeof (u32) - 2 * sizeof (u16)];
|
|
|
|
|
|
|
|
/* Vector of event data used only when data does not fit inline. */
|
2016-07-08 08:13:45 -04:00
|
|
|
u8 *event_data_as_vector;
|
2015-12-08 15:45:58 -07:00
|
|
|
};
|
2016-07-08 08:13:45 -04:00
|
|
|
}
|
|
|
|
vlib_signal_timed_event_data_t;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
always_inline uword
|
|
|
|
vlib_timing_wheel_data_is_timed_event (u32 d)
|
2016-07-08 08:13:45 -04:00
|
|
|
{
|
|
|
|
return d & 1;
|
|
|
|
}
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
always_inline u32
|
|
|
|
vlib_timing_wheel_data_set_suspended_process (u32 i)
|
2016-07-08 08:13:45 -04:00
|
|
|
{
|
|
|
|
return 0 + 2 * i;
|
|
|
|
}
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
always_inline u32
|
|
|
|
vlib_timing_wheel_data_set_timed_event (u32 i)
|
2016-07-08 08:13:45 -04:00
|
|
|
{
|
|
|
|
return 1 + 2 * i;
|
|
|
|
}
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
always_inline uword
|
|
|
|
vlib_timing_wheel_data_get_index (u32 d)
|
2016-07-08 08:13:45 -04:00
|
|
|
{
|
|
|
|
return d / 2;
|
|
|
|
}
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2021-03-10 14:35:28 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
clib_march_variant_type_t index;
|
|
|
|
int priority;
|
|
|
|
char *suffix;
|
|
|
|
char *desc;
|
|
|
|
} vlib_node_fn_variant_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-12-08 15:45:58 -07:00
|
|
|
/* Public nodes. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_node_t **nodes;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node index hashed by node name. */
|
2016-07-08 08:13:45 -04:00
|
|
|
uword *node_by_name;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
#define VLIB_NODE_MAIN_RUNTIME_STARTED (1 << 0)
|
|
|
|
|
|
|
|
/* Nodes segregated by type for cache locality.
|
|
|
|
Does not apply to nodes of type VLIB_NODE_TYPE_INTERNAL. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_node_runtime_t *nodes_by_type[VLIB_N_NODE_TYPE];
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Node runtime indices for input nodes with pending interrupts. */
|
2023-07-23 14:24:22 +02:00
|
|
|
void *input_node_interrupts;
|
|
|
|
void *pre_input_node_interrupts;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Input nodes are switched from/to interrupt to/from polling mode
|
|
|
|
when average vector length goes above/below polling/interrupt
|
|
|
|
thresholds. */
|
|
|
|
u32 polling_threshold_vector_length;
|
|
|
|
u32 interrupt_threshold_vector_length;
|
|
|
|
|
|
|
|
/* Vector of next frames. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_next_frame_t *next_frames;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Vector of internal node's frames waiting to be called. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_pending_frame_t *pending_frames;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Timing wheel for scheduling time-based node dispatch. */
|
2017-06-13 08:48:31 -04:00
|
|
|
void *timing_wheel;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_signal_timed_event_data_t *signal_timed_event_data_pool;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
2024-09-10 17:07:49 +02:00
|
|
|
/* Vector of process nodes waiting for restore */
|
|
|
|
vlib_process_restore_t *process_restore_current;
|
|
|
|
|
|
|
|
/* Vector of process nodes waiting for restore in next greaph scheduler run
|
|
|
|
*/
|
|
|
|
vlib_process_restore_t *process_restore_next;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* CPU time of next process to be ready on timing wheel. */
|
2017-06-13 08:48:31 -04:00
|
|
|
f64 time_next_process_ready;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Vector of process nodes.
|
|
|
|
One for each node of type VLIB_NODE_TYPE_PROCESS. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_process_t **processes;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Current running process or ~0 if no process running. */
|
|
|
|
u32 current_process_index;
|
|
|
|
|
|
|
|
/* Pool of pending process frames. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_pending_frame_t *suspended_process_frames;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Vector of event data vectors pending recycle. */
|
2016-07-08 08:13:45 -04:00
|
|
|
void **recycled_event_data_vectors;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Current counts of nodes in each state. */
|
|
|
|
u32 input_node_counts_by_state[VLIB_N_NODE_STATE];
|
|
|
|
|
|
|
|
/* Per-size frame allocation information. */
|
2016-07-08 08:13:45 -04:00
|
|
|
vlib_frame_size_t *frame_sizes;
|
2015-12-08 15:45:58 -07:00
|
|
|
|
|
|
|
/* Time of last node runtime stats clear. */
|
|
|
|
f64 time_last_runtime_stats_clear;
|
|
|
|
|
2019-07-23 10:22:31 -04:00
|
|
|
/* Node index from error code */
|
|
|
|
u32 *node_by_error;
|
2021-03-10 14:35:28 +01:00
|
|
|
|
|
|
|
/* Node Function Variants */
|
|
|
|
vlib_node_fn_variant_t *variants;
|
|
|
|
|
|
|
|
/* Node Function Default Variant Index */
|
|
|
|
u32 node_fn_default_march_variant;
|
|
|
|
|
|
|
|
/* Node Function march Variant by Suffix Hash */
|
|
|
|
uword *node_fn_march_variant_by_suffix;
|
2015-12-08 15:45:58 -07:00
|
|
|
} vlib_node_main_t;
|
|
|
|
|
2019-07-23 10:22:31 -04:00
|
|
|
typedef u16 vlib_error_t;
|
|
|
|
|
|
|
|
always_inline u32
|
|
|
|
vlib_error_get_node (vlib_node_main_t * nm, vlib_error_t e)
|
|
|
|
{
|
|
|
|
return nm->node_by_error[e];
|
|
|
|
}
|
|
|
|
|
|
|
|
always_inline u32
|
|
|
|
vlib_error_get_code (vlib_node_main_t * nm, vlib_error_t e)
|
|
|
|
{
|
|
|
|
u32 node_index = nm->node_by_error[e];
|
|
|
|
vlib_node_t *n = nm->nodes[node_index];
|
|
|
|
u32 error_code = e - n->error_heap_index;
|
|
|
|
return error_code;
|
|
|
|
}
|
2016-06-27 08:30:30 +02:00
|
|
|
|
2019-06-04 10:59:02 +08:00
|
|
|
#define FRAME_QUEUE_MAX_NELTS 64
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
|
2016-06-27 08:30:30 +02:00
|
|
|
u64 head;
|
|
|
|
u64 tail;
|
|
|
|
u32 n_in_use;
|
|
|
|
u32 nelts;
|
|
|
|
u32 written;
|
|
|
|
u32 threshold;
|
|
|
|
i32 n_vectors[FRAME_QUEUE_MAX_NELTS];
|
|
|
|
} frame_queue_trace_t;
|
|
|
|
|
2016-07-08 08:13:45 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-06-27 08:30:30 +02:00
|
|
|
u64 count[FRAME_QUEUE_MAX_NELTS];
|
|
|
|
} frame_queue_nelt_counter_t;
|
|
|
|
|
2015-12-08 15:45:58 -07:00
|
|
|
#endif /* included_vlib_node_h */
|
2016-07-08 08:13:45 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* fd.io coding-style-patch-verification: ON
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* eval: (c-set-style "gnu")
|
|
|
|
* End:
|
|
|
|
*/
|