FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
load_balance_map.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 #ifndef __LOAD_BALANCE_MAP_H__
20 #define __LOAD_BALANCE_MAP_H__
21 
22 #include <vlib/vlib.h>
23 #include <vnet/fib/fib_types.h>
24 #include <vnet/dpo/load_balance.h>
25 
27 
28 /**
29  */
30 typedef struct load_balance_map_t_ {
31  /**
32  * required for pool_get_aligned.
33  * memebers used in the switch path come first!
34  */
35  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
36 
37  /**
38  * The buckets of the map that provide the index to index translation.
39  * In the first cacheline.
40  */
42 
43  /**
44  * the vector of paths this MAP represents
45  */
47 
48  /**
49  * the sum of the normalised weights. cache for convenience
50  */
52 
53  /**
54  * Number of locks. Maps are shared by a large number of recrusvie fib_entry_ts
55  */
58 
60  u32 sum_of_weights,
61  const load_balance_path_t *norm_paths);
62 
63 extern void load_balance_map_lock(index_t lmbi);
64 extern void load_balance_map_unlock(index_t lbmi);
65 
67 
68 extern u8* format_load_balance_map(u8 *s, va_list *ap);
69 extern void load_balance_map_show_mem(void);
70 
71 /**
72  * The encapsulation breakages are for fast DP access
73  */
75 
76 static inline load_balance_map_t*
78 {
80 }
81 
82 static inline u16
84  u16 bucket)
85 {
87 
88  lbm = load_balance_map_get(lbmi);
89 
90  return (lbm->lbm_buckets[bucket]);
91 }
92 
93 static inline const dpo_id_t *
95  u16 bucket)
96 {
97  ASSERT(bucket < lb->lb_n_buckets);
98 
99  if (INDEX_INVALID != lb->lb_map)
100  {
101  bucket = load_balance_map_translate(lb->lb_map, bucket);
102  }
103 
105  {
106  return (&lb->lb_buckets_inline[bucket]);
107  }
108  else
109  {
110  return (&lb->lb_buckets[bucket]);
111  }
112 }
113 
114 extern void load_balance_map_module_init(void);
115 
116 #endif
load_balance.h
vlib.h
load_balance_map_t_::lbm_locks
u32 lbm_locks
Number of locks.
Definition: load_balance_map.h:56
load_balance_map_get
static load_balance_map_t * load_balance_map_get(index_t lbmi)
Definition: load_balance_map.h:77
load_balance_map_path_t_
Definition: load_balance_map.c:44
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
load_balance_map_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
required for pool_get_aligned.
load_balance_map_translate
static u16 load_balance_map_translate(index_t lbmi, u16 bucket)
Definition: load_balance_map.h:83
u16
unsigned short u16
Definition: types.h:57
load_balance_t_::lb_map
index_t lb_map
index of the load-balance map, INVALID if this LB does not use one
Definition: load_balance.h:151
load_balance_map_t_::lbm_buckets
u16 * lbm_buckets
The buckets of the map that provide the index to index translation.
Definition: load_balance_map.h:41
load_balance_map_unlock
void load_balance_map_unlock(index_t lbmi)
Definition: load_balance_map.c:474
load_balance_get_fwd_bucket
static const dpo_id_t * load_balance_get_fwd_bucket(const load_balance_t *lb, u16 bucket)
Definition: load_balance_map.h:94
load_balance_map_show_mem
void load_balance_map_show_mem(void)
Definition: load_balance_map.c:547
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
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
load_balance_map_t_
Definition: load_balance_map.h:30
load_balance_map_pool
load_balance_map_t * load_balance_map_pool
The encapsulation breakages are for fast DP access.
Definition: load_balance_map.c:69
LB_HAS_INLINE_BUCKETS
#define LB_HAS_INLINE_BUCKETS(_lb)
Definition: load_balance.h:225
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
u32
unsigned int u32
Definition: types.h:88
load_balance_map_add_or_lock
index_t load_balance_map_add_or_lock(u32 n_buckets, u32 sum_of_weights, const load_balance_path_t *norm_paths)
Definition: load_balance_map.c:437
load_balance_map_t
struct load_balance_map_t_ load_balance_map_t
load_balance_map_module_init
void load_balance_map_module_init(void)
Make/add a new or lock an existing Load-balance map.
Definition: load_balance_map.c:532
load_balance_map_lock
void load_balance_map_lock(index_t lmbi)
Definition: load_balance_map.c:464
u8
unsigned char u8
Definition: types.h:56
load_balance_t_::lb_buckets
dpo_id_t * lb_buckets
Vector of buckets containing the next DPOs, sized as lbo_num.
Definition: load_balance.h:166
load_balance_t_::lb_buckets_inline
dpo_id_t lb_buckets_inline[LB_NUM_INLINE_BUCKETS]
The rest of the cache line is used for buckets.
Definition: load_balance.h:174
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
load_balance_map_path_state_change
void load_balance_map_path_state_change(fib_node_index_t path_index)
the state of a path has changed (it has no doubt gone down).
Definition: load_balance_map.c:513
load_balance_t_
The FIB DPO provieds;.
Definition: load_balance.h:106
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
load_balance_map_t_::lbm_sum_of_norm_weights
u32 lbm_sum_of_norm_weights
the sum of the normalised weights.
Definition: load_balance_map.h:51
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
format_load_balance_map
u8 * format_load_balance_map(u8 *s, va_list *ap)
Definition: load_balance_map.c:93
load_balance_map_t_::lbm_paths
struct load_balance_map_path_t_ * lbm_paths
the vector of paths this MAP represents
Definition: load_balance_map.h:46