aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/tracedump/tracedump.api
blob: 540b066407462eea98d6984e6cdf1ef2ada6dadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* Hey Emacs use -*- mode: C -*- */
/*
 * tracedump.api - streaming packet trace dump API
 *
 * Copyright (c) 2020 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.
 */

/**
 * @file tracedump.api
 * @brief VPP control-plane API messages.
 *
 * This file defines VPP control-plane binary API messages which are generally
 * called through a shared memory interface.
 */


option version = "0.1.0";

enum trace_filter_flag : u32
{
  TRACE_FF_NONE = 0,
  TRACE_FF_INCLUDE_NODE = 1,
  TRACE_FF_EXCLUDE_NODE = 2,
  TRACE_FF_INCLUDE_CLASSIFIER = 3,
  TRACE_FF_EXCLUDE_CLASSIFIER = 4,
};


/** \brief trace_set_filters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param flag - One of the trace_filter_flag values
    @param node_index = The node-index to include/exclude 
    @param classifier_table_index = The include/exclude classifier table
    @param count = The number of packets to include/exclude
*/
autoreply define trace_set_filters
{
  u32 client_index;
  u32 context;
  vl_api_trace_filter_flag_t flag;	/* TRACE_FF_* */
  u32 count;
  u32 node_index [default = 0xffffffff];
  u32 classifier_table_index [default = 0xffffffff];
  option vat_help =   "trace_set_filters [none] | [(include_node|exclude_node) <node-index>] | [(include_classifier|exclude_classifier) <classifier-index>] [count <count>]";
};


/** \brief trace_capture_packets
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param node_index - graph input node whose packets are captured
    @param max_packets - maximum number of packets to capture
    @param use_filter - if true, apply filters to select/reject packets
    @param verbose - if true, set verbose packet capture flag
    @param pre_capture_clear - if true, clear buffer before capture begins
*/
autoreply define trace_capture_packets
{
  u32 client_index;
  u32 context;
  u32 node_index;
  u32 max_packets;
  bool use_filter;
  bool verbose;
  bool pre_capture_clear;
  option vat_help = "trace_capture_packets [node_index <index>] [max <max>] [pre_capture_clear] [use_filter] [verbose]";
};


/** \brief trace_clear_capture
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
autoreply define trace_clear_capture
{
  u32 client_index;
  u32 context;
  option vat_help = "trace_clear_capture";
};


service {
    rpc trace_dump returns trace_dump_reply
        stream trace_details;
};

define trace_dump {
    /* Client identifier, set from api_main.my_client_index */
    u32 client_index;

    /* Arbitrary context, so client can match reply to request */
    u32 context;

    /* Dispose of any cached data before we begin */
    u8 clear_cache;

    /* iterator positions, both ~0 to just clear the cache */
    u32 thread_id;
    u32 position;

    /* Max number of replies per burst */
    u32 max_records;

    option vat_help = "trace_dump [thread_id <tid>] [position <pos>] [max <max>]";
};

define trace_dump_reply {
    u32 context;
    i32 retval;
    u32 last_thread_id;
    u32 last_position;
    u8 more_this_thread;
    u8 more_threads;
    u8 flush_only;
    u8 done;
};

define trace_details {
    /* Client identifier, set from api_main.my_client_index */
    u32 client_index;

    /* Arbitrary context, so client can match reply to request */
    u32 context;

    /* Position in the cache of this record */
    u32 thread_id;
    u32 position;

    /* More or not */
    u8 more_this_thread;
    u8 more_threads;
    /* Needed when set ends in the middle of a batch */
    u8 done;

    u32 packet_number;
    string trace_data[];
};
lass="cm"> */ #ifndef __LOAD_BALANCE_H__ #define __LOAD_BALANCE_H__ #include <vlib/vlib.h> #include <vnet/ip/lookup.h> #include <vnet/dpo/dpo.h> #include <vnet/fib/fib_types.h> #include <vnet/fib/fib_entry.h> /** * Load-balance main */ typedef struct load_balance_main_t_ { vlib_combined_counter_main_t lbm_to_counters; vlib_combined_counter_main_t lbm_via_counters; } load_balance_main_t; extern load_balance_main_t load_balance_main; /** * The number of buckets that a load-balance object can have and still * fit in one cache-line */ #define LB_NUM_INLINE_BUCKETS 4 /** * @brief One path from an [EU]CMP set that the client wants to add to a * load-balance object */ typedef struct load_balance_path_t_ { /** * ID of the Data-path object. */ dpo_id_t path_dpo; /** * The index of the FIB path */ fib_node_index_t path_index; /** * weight for the path. */ u32 path_weight; } load_balance_path_t; /** * Flags controlling load-balance creation and modification */ typedef enum load_balance_attr_t_ { LOAD_BALANCE_ATTR_USES_MAP = 0, LOAD_BALANCE_ATTR_STICKY = 1, } load_balance_attr_t; #define LOAD_BALANCE_ATTR_NAMES { \ [LOAD_BALANCE_ATTR_USES_MAP] = "uses-map", \ [LOAD_BALANCE_ATTR_STICKY] = "sticky", \ } #define FOR_EACH_LOAD_BALANCE_ATTR(_attr) \ for (_attr = 0; _attr <= LOAD_BALANCE_ATTR_STICKY; _attr++) typedef enum load_balance_flags_t_ { LOAD_BALANCE_FLAG_NONE = 0, LOAD_BALANCE_FLAG_USES_MAP = (1 << 0), LOAD_BALANCE_FLAG_STICKY = (1 << 1), } __attribute__((packed)) load_balance_flags_t; /** * The FIB DPO provieds; * - load-balancing over the next DPOs in the chain/graph * - per-route counters */ typedef struct load_balance_t_ { /** * required for pool_get_aligned. * memebers used in the switch path come first! */ CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); /** * number of buckets in the load-balance. always a power of 2. */ u16 lb_n_buckets; /** * number of buckets in the load-balance - 1. used in the switch path * as part of the hash calculation. */ u16 lb_n_buckets_minus_1; /** * The protocol of packets that traverse this LB. * need in combination with the flow hash config to determine how to hash. * u8. */ dpo_proto_t lb_proto; /** * Flags concenring the LB's creation and modification */ load_balance_flags_t lb_flags; /** * Flags from the load-balance's associated fib_entry_t */ fib_entry_flag_t lb_fib_entry_flags; /** * The number of locks, which is approximately the number of users, * of this load-balance. * Load-balance objects of via-entries are heavily shared by recursives, * so the lock count is a u32. */ u32 lb_locks; /** * index of the load-balance map, INVALID if this LB does not use one */ index_t lb_map; /** * This is the index of the uRPF list for this LB */ index_t lb_urpf; /** * the hash config to use when selecting a bucket. this is a u16 */ flow_hash_config_t lb_hash_config; /** * Vector of buckets containing the next DPOs, sized as lbo_num */ dpo_id_t *lb_buckets; /** * The rest of the cache line is used for buckets. In the common case * where there there are less than 4 buckets, then the buckets are * on the same cachlie and we save ourselves a pointer dereferance in * the data-path. */ dpo_id_t lb_buckets_inline[LB_NUM_INLINE_BUCKETS]; } load_balance_t; STATIC_ASSERT(sizeof(load_balance_t) <= CLIB_CACHE_LINE_BYTES, "A load_balance object size exceeds one cacheline"); /** * Flags controlling load-balance formatting/display */ typedef enum load_balance_format_flags_t_ { LOAD_BALANCE_FORMAT_NONE, LOAD_BALANCE_FORMAT_DETAIL = (1 << 0), } load_balance_format_flags_t; extern index_t load_balance_create(u32 num_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc); extern flow_hash_config_t load_balance_get_default_flow_hash(dpo_proto_t lb_proto); extern void load_balance_multipath_update( const dpo_id_t *dpo, const load_balance_path_t * raw_next_hops, load_balance_flags_t flags); extern void load_balance_set_bucket(index_t lbi, u32 bucket, const dpo_id_t *next); extern void load_balance_set_urpf(index_t lbi, index_t urpf); extern void load_balance_set_fib_entry_flags(index_t lbi, fib_entry_flag_t flags); extern index_t load_balance_get_urpf(index_t lbi); extern u8* format_load_balance(u8 * s, va_list * args); extern const dpo_id_t *load_balance_get_bucket(index_t lbi, u32 bucket); extern int load_balance_is_drop(const dpo_id_t *dpo); extern u16 load_balance_n_buckets(index_t lbi); extern f64 load_balance_get_multipath_tolerance(void); /** * The encapsulation breakages are for fast DP access */ extern load_balance_t *load_balance_pool; static inline load_balance_t* load_balance_get (index_t lbi) { return (pool_elt_at_index(load_balance_pool, lbi)); } #define LB_HAS_INLINE_BUCKETS(_lb) \ ((_lb)->lb_n_buckets <= LB_NUM_INLINE_BUCKETS) static inline const dpo_id_t * load_balance_get_bucket_i (const load_balance_t *lb, u32 bucket) { ASSERT(bucket < lb->lb_n_buckets); if (PREDICT_TRUE(LB_HAS_INLINE_BUCKETS(lb))) { return (&lb->lb_buckets_inline[bucket]); } else { return (&lb->lb_buckets[bucket]); } } extern void load_balance_module_init(void); #endif