FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
replicate_dpo.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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  * @brief
17  *
18  */
19 
20 #ifndef __REPLICATE_DPO_H__
21 #define __REPLICATE_DPO_H__
22 
23 #include <vlib/vlib.h>
24 #include <vnet/ip/lookup.h>
25 #include <vnet/dpo/dpo.h>
26 #include <vnet/dpo/load_balance.h>
27 #include <vnet/fib/fib_types.h>
28 #include <vnet/mpls/mpls_types.h>
29 
30 /**
31  * replicate main
32  */
33 typedef struct replicate_main_t_
34 {
36 
37  /* per-cpu vector of cloned packets */
40 
42 
43 /**
44  * The number of buckets that a load-balance object can have and still
45  * fit in one cache-line
46  */
47 #define REP_NUM_INLINE_BUCKETS 4
48 
49 /**
50  * Flags on the replicate DPO
51  */
52 typedef enum replicate_flags_t_
53 {
56 } __clib_packed replicate_flags_t;
57 
58 /**
59  * The FIB DPO provieds;
60  * - load-balancing over the next DPOs in the chain/graph
61  * - per-route counters
62  */
63 typedef struct replicate_t_ {
64  /**
65  * required for pool_get_aligned.
66  * memebers used in the switch path come first!
67  */
68  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
69 
70  /**
71  * number of buckets in the replicate.
72  */
74 
75  /**
76  * The protocol of packets that traverse this REP.
77  * need in combination with the flow hash config to determine how to hash.
78  * u8.
79  */
81 
82  /**
83  * Flags specifying the replicate properties/behaviour
84  */
86 
87  /**
88  * The number of locks, which is approximately the number of users,
89  * of this load-balance.
90  * Load-balance objects of via-entries are heavily shared by recursives,
91  * so the lock count is a u32.
92  */
94 
95  /**
96  * Vector of buckets containing the next DPOs, sized as repo_num
97  */
99 
100  /**
101  * The rest of the cache line is used for buckets. In the common case
102  * where there there are less than 4 buckets, then the buckets are
103  * on the same cachlie and we save ourselves a pointer dereferance in
104  * the data-path.
105  */
107 } replicate_t;
108 
110  "A replicate object size exceeds one cacheline");
111 
112 /**
113  * Flags controlling load-balance formatting/display
114  */
119 
120 extern index_t replicate_create(u32 num_buckets,
121  dpo_proto_t rep_proto);
122 extern void replicate_multipath_update(
123  const dpo_id_t *dpo,
124  load_balance_path_t *next_hops);
125 
126 extern void replicate_set_bucket(index_t repi,
127  u32 bucket,
128  const dpo_id_t *next);
129 
130 extern u8* format_replicate(u8 * s, va_list * args);
131 
132 extern const dpo_id_t *replicate_get_bucket(index_t repi,
133  u32 bucket);
134 extern int replicate_is_drop(const dpo_id_t *dpo);
135 
136 extern u16 replicate_n_buckets(index_t repi);
137 
139  index_t repi);
140 
141 /**
142  * The encapsulation breakages are for fast DP access
143  */
145 static inline replicate_t*
147 {
148  repi &= ~MPLS_IS_REPLICATE;
149  return (pool_elt_at_index(replicate_pool, repi));
150 }
151 
152 #define REP_HAS_INLINE_BUCKETS(_rep) \
153  ((_rep)->rep_n_buckets <= REP_NUM_INLINE_BUCKETS)
154 
155 static inline const dpo_id_t *
157  u32 bucket)
158 {
159  ASSERT(bucket < rep->rep_n_buckets);
160 
162  {
163  return (&rep->rep_buckets_inline[bucket]);
164  }
165  else
166  {
167  return (&rep->rep_buckets[bucket]);
168  }
169 }
170 
171 extern void replicate_module_init(void);
172 
173 #endif
load_balance.h
vlib.h
replicate_is_drop
int replicate_is_drop(const dpo_id_t *dpo)
Definition: replicate_dpo.c:233
STATIC_ASSERT
STATIC_ASSERT(sizeof(replicate_t)<=CLIB_CACHE_LINE_BYTES, "A replicate object size exceeds one cacheline")
replicate_multipath_update
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
Definition: replicate_dpo.c:318
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
replicate_create
index_t replicate_create(u32 num_buckets, dpo_proto_t rep_proto)
Definition: replicate_dpo.c:192
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
REP_NUM_INLINE_BUCKETS
#define REP_NUM_INLINE_BUCKETS
The number of buckets that a load-balance object can have and still fit in one cache-line.
Definition: replicate_dpo.h:47
next
u16 * next
Definition: nat44_ei_out2in.c:718
replicate_get_bucket_i
static const dpo_id_t * replicate_get_bucket_i(const replicate_t *rep, u32 bucket)
Definition: replicate_dpo.h:156
REP_HAS_INLINE_BUCKETS
#define REP_HAS_INLINE_BUCKETS(_rep)
Definition: replicate_dpo.h:152
u16
unsigned short u16
Definition: types.h:57
replicate_t_
The FIB DPO provieds;.
Definition: replicate_dpo.h:63
format_replicate
u8 * format_replicate(u8 *s, va_list *args)
Definition: replicate_dpo.c:152
replicate_flags_t_
replicate_flags_t_
Flags on the replicate DPO.
Definition: replicate_dpo.h:52
replicate_set_bucket
void replicate_set_bucket(index_t repi, u32 bucket, const dpo_id_t *next)
Definition: replicate_dpo.c:216
replicate_t_::rep_locks
u32 rep_locks
The number of locks, which is approximately the number of users, of this load-balance.
Definition: replicate_dpo.h:93
replicate_t_::rep_n_buckets
u16 rep_n_buckets
number of buckets in the replicate.
Definition: replicate_dpo.h:73
replicate_pool
replicate_t * replicate_pool
The encapsulation breakages are for fast DP access.
Definition: replicate_dpo.c:57
dpo.h
MPLS_IS_REPLICATE
#define MPLS_IS_REPLICATE
The top bit of the index, which is the result of the MPLS lookup is used to determine if the DPO is a...
Definition: mpls_types.h:66
replicate_t
struct replicate_t_ replicate_t
The FIB DPO provieds;.
fib_types.h
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
replicate_main_t_::clones
u32 ** clones
Definition: replicate_dpo.h:38
replicate_t_::rep_flags
replicate_flags_t rep_flags
Flags specifying the replicate properties/behaviour.
Definition: replicate_dpo.h:85
REPLICATE_FLAGS_NONE
@ REPLICATE_FLAGS_NONE
Definition: replicate_dpo.h:54
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
mpls_types.h
replicate_main_t_
replicate main
Definition: replicate_dpo.h:33
replicate_t_::rep_buckets
dpo_id_t * rep_buckets
Vector of buckets containing the next DPOs, sized as repo_num.
Definition: replicate_dpo.h:98
replicate_main
replicate_main_t replicate_main
The one instance of replicate main.
Definition: replicate_dpo.c:62
replicate_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
required for pool_get_aligned.
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
u32
unsigned int u32
Definition: types.h:88
REPLICATE_FORMAT_DETAIL
@ REPLICATE_FORMAT_DETAIL
Definition: replicate_dpo.h:117
replicate_main_t_::repm_counters
vlib_combined_counter_main_t repm_counters
Definition: replicate_dpo.h:35
replicate_t_::rep_buckets_inline
dpo_id_t rep_buckets_inline[REP_NUM_INLINE_BUCKETS]
The rest of the cache line is used for buckets.
Definition: replicate_dpo.h:106
replicate_module_init
void replicate_module_init(void)
Definition: replicate_dpo.c:667
REPLICATE_FLAGS_HAS_LOCAL
@ REPLICATE_FLAGS_HAS_LOCAL
Definition: replicate_dpo.h:55
replicate_format_flags_t_
replicate_format_flags_t_
Flags controlling load-balance formatting/display.
Definition: replicate_dpo.h:115
u8
unsigned char u8
Definition: types.h:56
lookup.h
replicate_format_flags_t
enum replicate_format_flags_t_ replicate_format_flags_t
Flags controlling load-balance formatting/display.
replicate_dup
index_t replicate_dup(replicate_flags_t flags, index_t repi)
Definition: replicate_dpo.c:523
replicate_flags_t
enum replicate_flags_t_ replicate_flags_t
Flags on the replicate DPO.
replicate_get_bucket
const dpo_id_t * replicate_get_bucket(index_t repi, u32 bucket)
Definition: replicate_dpo.c:252
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
replicate_main_t
struct replicate_main_t_ replicate_main_t
replicate main
replicate_get
static replicate_t * replicate_get(index_t repi)
Definition: replicate_dpo.h:146
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
REPLICATE_FORMAT_NONE
@ REPLICATE_FORMAT_NONE
Definition: replicate_dpo.h:116
load_balance_path_t_
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:62
replicate_t_::rep_proto
dpo_proto_t rep_proto
The protocol of packets that traverse this REP.
Definition: replicate_dpo.h:80
replicate_n_buckets
u16 replicate_n_buckets(index_t repi)
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105