FD.io VPP  v18.07.1-19-g511ce25
Vector Packet Processing
bier_table.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 #ifndef __BIER_TABLE_H__
17 #define __BIER_TABLE_H__
18 
19 #include <vlib/vlib.h>
20 #include <vnet/fib/fib_types.h>
21 #include <vnet/bier/bier_types.h>
22 #include <vnet/bier/bier_entry.h>
23 
24 #include <vnet/dpo/dpo.h>
25 
26 /**
27  * Forward declarations
28  */
29 struct bier_route_update_t_;
30 
31 /**
32  * A BIER Table is the bit-indexed forwarding table.
33  * Each entry (bit-position) represents one destination, and its reachability
34  *
35  * The number of entries in a table is thus the maximum supported
36  * bit-position. Since this is smal <4096, the table is a flat arry
37  */
38 typedef struct bier_table_t_ {
39  /**
40  * required for pool_get_aligned.
41  * memebers used in the switch path come first!
42  */
43  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
44 
45  /**
46  * Save the MPLS local label associated with the table
47  */
49 
50  /**
51  * The path-list used for the ECMP-tables
52  */
54 
55  /**
56  * The index of the lfib entry created for this table.
57  * Only the EOS is required.
58  */
60 
61  /**
62  * Number of locks on the table
63  */
65 
66  /**
67  * Entries in the table
68  * This is a vector sized to the appropriate number of entries
69  * given the table's supported Bit-string length
70  */
72 
73  /**
74  * The identity/key or the table. we need the hdr_len in the data-path
75  */
77 
78  /**
79  * f-masks in the ECMP table
80  * This is a vector sized to the appropriate number of entries
81  * given the table's supported Bit-string length.
82  * In the ECMP table the LB choice has been pre-resolved, so each entry
83  * links to just one f-mask, i.e. there is a 1:1 mapping of bit-position to
84  * fmask. For efficient forwarding we collapse the fmasks up to the table.
85  */
87 } bier_table_t;
88 
90  "BIER table fits on 2 cache lines");
91 
93  mpls_label_t ll);
94 extern index_t bier_table_lock(const bier_table_id_t *id);
95 extern void bier_table_unlock(const bier_table_id_t *id);
96 
97 extern void bier_table_route_add(const bier_table_id_t *bti,
98  bier_bp_t bp,
99  fib_route_path_t *brp);
100 extern void bier_table_route_remove(const bier_table_id_t *bti,
101  bier_bp_t bp,
102  fib_route_path_t *brp);
103 
104 extern void bier_table_show_all(vlib_main_t * vm,
106 
107 extern const bier_table_id_t *bier_table_get_id(index_t bti);
108 
109 extern u8 *format_bier_table (u8 *s, va_list *args);
110 extern u8 *format_bier_table_entry (u8 *s, va_list *args);
111 
113 extern void bier_table_ecmp_unlock(index_t bti);
114 extern void bier_table_ecmp_set_fmask(index_t bti,
115  bier_bp_t bp,
116  index_t bfmi);
117 
119  dpo_id_t *dpo);
120 
121 /**
122  * Types and functions to walk the ECMP tables of a main table
123  */
124 typedef void (*bier_table_ecmp_walk_fn_t)(index_t btei,
125  void *ctx);
126 extern void bier_table_ecmp_walk(index_t bti,
128  void *ctx);
129 extern int bier_table_is_main (const bier_table_t *bt);
130 
131 /**
132  * Types and functions to walk all the BIER Tables
133  */
134 typedef void (*bier_tables_walk_fn_t)(const bier_table_t *bt,
135  void *ctx);
137  void *ctx);
138 
139 /**
140  * Types and functions to walk all the entries in one BIER Table
141  */
142 typedef void (*bier_table_walk_fn_t)(const bier_table_t *bt,
143  const bier_entry_t *be,
144  void *ctx);
145 extern void bier_table_walk(const bier_table_id_t *id,
147  void *ctx);
148 
149 /*
150  * provided for fast data plane access.
151  */
153 
154 static inline bier_table_t *
156 {
157  return (pool_elt_at_index(bier_table_pool, bti));
158 }
159 
160 static inline const index_t
162  bier_bp_t bp)
163 {
164  return (bt->bt_entries[BIER_BP_TO_INDEX(bp)]);
165 }
166 
167 static inline const index_t
169  bier_bp_t bp)
170 {
171  return (bt->bt_fmasks[BIER_BP_TO_INDEX(bp)]);
172 }
173 
174 #endif
void bier_table_ecmp_set_fmask(index_t bti, bier_bp_t bp, index_t bfmi)
Definition: bier_table.c:724
void bier_table_route_add(const bier_table_id_t *bti, bier_bp_t bp, fib_route_path_t *brp)
Definition: bier_table.c:549
bier_table_t * bier_table_pool
Memory pool of all the allocated tables.
Definition: bier_table.c:32
void bier_table_show_all(vlib_main_t *vm, bier_show_flags_t flags)
Definition: bier_table.c:834
A representation of a path as described by a route producer.
Definition: fib_types.h:460
u16 bt_locks
Number of locks on the table.
Definition: bier_table.h:64
index_t * bt_fmasks
f-masks in the ECMP table This is a vector sized to the appropriate number of entries given the table...
Definition: bier_table.h:86
enum bier_show_flags_t_ bier_show_flags_t
Flags to control show output.
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
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
void(* bier_table_ecmp_walk_fn_t)(index_t btei, void *ctx)
Types and functions to walk the ECMP tables of a main table.
Definition: bier_table.h:124
void bier_table_contribute_forwarding(index_t bti, dpo_id_t *dpo)
Definition: bier_table.c:664
static bier_table_t * bier_table_get(index_t bti)
Definition: bier_table.h:155
The ID of a table.
Definition: bier_types.h:394
void bier_table_unlock(const bier_table_id_t *id)
Definition: bier_table.c:218
unsigned char u8
Definition: types.h:56
void(* bier_tables_walk_fn_t)(const bier_table_t *bt, void *ctx)
Types and functions to walk all the BIER Tables.
Definition: bier_table.h:134
u8 * format_bier_table_entry(u8 *s, va_list *args)
Definition: bier_table.c:742
int bier_table_is_main(const bier_table_t *bt)
Definition: bier_table.c:53
mpls_label_t bt_ll
Save the MPLS local label associated with the table.
Definition: bier_table.h:48
void bier_table_ecmp_unlock(index_t bti)
Definition: bier_table.c:462
u32 bier_bp_t
A bit positon as assigned to egress PEs.
Definition: bier_types.h:294
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:168
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:464
unsigned short u16
Definition: types.h:57
u8 * format_bier_table(u8 *s, va_list *args)
Definition: bier_table.c:777
static const index_t bier_table_fwd_lookup(const bier_table_t *bt, bier_bp_t bp)
Definition: bier_table.h:168
u32 flags
Definition: vhost_user.h:110
vlib_main_t * vm
Definition: buffer.c:294
STATIC_ASSERT((sizeof(bier_table_t)<=2 *CLIB_CACHE_LINE_BYTES),"BIER table fits on 2 cache lines")
static const index_t bier_table_lookup(const bier_table_t *bt, bier_bp_t bp)
Definition: bier_table.h:161
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
const bier_table_id_t * bier_table_get_id(index_t bti)
Definition: bier_table.c:524
fib_node_index_t bt_lfei
The index of the lfib entry created for this table.
Definition: bier_table.h:59
The BIER entry.
Definition: bier_entry.h:46
index_t * bt_entries
Entries in the table This is a vector sized to the appropriate number of entries given the table&#39;s su...
Definition: bier_table.h:71
long ctx[MAX_CONNS]
Definition: main.c:126
void bier_table_route_remove(const bier_table_id_t *bti, bier_bp_t bp, fib_route_path_t *brp)
Definition: bier_table.c:601
fib_node_index_t bt_pl
The path-list used for the ECMP-tables.
Definition: bier_table.h:53
void(* bier_table_walk_fn_t)(const bier_table_t *bt, const bier_entry_t *be, void *ctx)
Types and functions to walk all the entries in one BIER Table.
Definition: bier_table.h:142
index_t bier_table_lock(const bier_table_id_t *id)
Definition: bier_table.c:374
bier_table_id_t bt_id
The identity/key or the table.
Definition: bier_table.h:76
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
required for pool_get_aligned.
void bier_tables_walk(bier_tables_walk_fn_t fn, void *ctx)
Definition: bier_table.c:853
A BIER Table is the bit-indexed forwarding table.
Definition: bier_table.h:38
#define BIER_BP_TO_INDEX(bp)
Definition: bier_types.h:296
struct bier_table_t_ bier_table_t
A BIER Table is the bit-indexed forwarding table.
void bier_table_walk(const bier_table_id_t *id, bier_table_walk_fn_t fn, void *ctx)
Definition: bier_table.c:861
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:62
void bier_table_ecmp_walk(index_t bti, bier_table_ecmp_walk_fn_t fn, void *ctx)
Definition: bier_table.c:706
index_t bier_table_ecmp_create_and_lock(const bier_table_id_t *id)
Definition: bier_table.c:456
index_t bier_table_add_or_lock(const bier_table_id_t *id, mpls_label_t ll)
Definition: bier_table.c:397