FD.io VPP  v18.01.2-1-g9b554f3
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  * The FIB DPO provieds;
51  * - load-balancing over the next DPOs in the chain/graph
52  * - per-route counters
53  */
54 typedef struct replicate_t_ {
55  /**
56  * number of buckets in the load-balance. always a power of 2.
57  */
59 
60  /**
61  * The protocol of packets that traverse this REP.
62  * need in combination with the flow hash config to determine how to hash.
63  * u8.
64  */
66 
67  /**
68  * The number of locks, which is approximately the number of users,
69  * of this load-balance.
70  * Load-balance objects of via-entries are heavily shared by recursives,
71  * so the lock count is a u32.
72  */
74 
75  /**
76  * Vector of buckets containing the next DPOs, sized as repo_num
77  */
79 
80  /**
81  * The rest of the cache line is used for buckets. In the common case
82  * where there there are less than 4 buckets, then the buckets are
83  * on the same cachlie and we save ourselves a pointer dereferance in
84  * the data-path.
85  */
86  dpo_id_t rep_buckets_inline[REP_NUM_INLINE_BUCKETS];
87 } replicate_t;
88 
90  "A replicate object size exceeds one cachline");
91 
92 /**
93  * Flags controlling load-balance formatting/display
94  */
99 
100 extern index_t replicate_create(u32 num_buckets,
101  dpo_proto_t rep_proto);
102 extern void replicate_multipath_update(
103  const dpo_id_t *dpo,
104  load_balance_path_t *next_hops);
105 
106 extern void replicate_set_bucket(index_t repi,
107  u32 bucket,
108  const dpo_id_t *next);
109 
110 extern u8* format_replicate(u8 * s, va_list * args);
111 
112 extern const dpo_id_t *replicate_get_bucket(index_t repi,
113  u32 bucket);
114 extern int replicate_is_drop(const dpo_id_t *dpo);
115 
116 /**
117  * The encapsulation breakages are for fast DP access
118  */
120 static inline replicate_t*
122 {
123  repi &= ~MPLS_IS_REPLICATE;
124  return (pool_elt_at_index(replicate_pool, repi));
125 }
126 
127 #define REP_HAS_INLINE_BUCKETS(_rep) \
128  ((_rep)->rep_n_buckets <= REP_NUM_INLINE_BUCKETS)
129 
130 static inline const dpo_id_t *
132  u32 bucket)
133 {
134  ASSERT(bucket < rep->rep_n_buckets);
135 
137  {
138  return (&rep->rep_buckets_inline[bucket]);
139  }
140  else
141  {
142  return (&rep->rep_buckets[bucket]);
143  }
144 }
145 
146 extern void replicate_module_init(void);
147 
148 #endif
The FIB DPO provieds;.
Definition: replicate_dpo.h:54
const dpo_id_t * replicate_get_bucket(index_t repi, u32 bucket)
#define PREDICT_TRUE(x)
Definition: clib.h:106
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
void replicate_set_bucket(index_t repi, u32 bucket, const dpo_id_t *next)
u32 rep_locks
The number of locks, which is approximately the number of users, of this load-balance.
Definition: replicate_dpo.h:73
enum replicate_format_flags_t_ replicate_format_flags_t
Flags controlling load-balance formatting/display.
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:41
dpo_proto_t rep_proto
The protocol of packets that traverse this REP.
Definition: replicate_dpo.h:65
index_t replicate_create(u32 num_buckets, dpo_proto_t rep_proto)
dpo_id_t * rep_buckets
Vector of buckets containing the next DPOs, sized as repo_num.
Definition: replicate_dpo.h:78
static replicate_t * replicate_get(index_t repi)
replicate_t * replicate_pool
The encapsulation breakages are for fast DP access.
Definition: replicate_dpo.c:57
#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:58
replicate_main_t replicate_main
The one instance of replicate main.
Definition: replicate_dpo.c:62
#define REP_HAS_INLINE_BUCKETS(_rep)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
int replicate_is_drop(const dpo_id_t *dpo)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:166
replicate main
Definition: replicate_dpo.h:33
replicate_format_flags_t_
Flags controlling load-balance formatting/display.
Definition: replicate_dpo.h:95
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:459
struct replicate_main_t_ replicate_main_t
replicate main
vlib_combined_counter_main_t repm_counters
Definition: replicate_dpo.h:35
STATIC_ASSERT(sizeof(replicate_t)<=CLIB_CACHE_LINE_BYTES,"A replicate object size exceeds one cachline")
dpo_id_t rep_buckets_inline[REP_NUM_INLINE_BUCKETS]
The rest of the cache line is used for buckets.
Definition: replicate_dpo.h:86
u8 * format_replicate(u8 *s, va_list *args)
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
u16 rep_n_buckets
number of buckets in the load-balance.
Definition: replicate_dpo.h:58
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
#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
static const dpo_id_t * replicate_get_bucket_i(const replicate_t *rep, u32 bucket)
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:62
A collection of combined counters.
Definition: counter.h:180
void replicate_module_init(void)
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
struct replicate_t_ replicate_t
The FIB DPO provieds;.