FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
bier_fmask.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 bier_fmask : The BIER fmask
17  *
18  * The BIER fmask contains the bitString that is applied to packets that
19  * egress towards the next-hop. As such the fmask is part of the rewrite
20  * (adj) for that next-hop. It it thus an extension of the next-hop and in
21  * no way associated with the bit-position(s) that are reachable through it.
22  * Fmasks are thus shared by bit-positions that egress through the same
23  * nh (BFR-NBR).
24  * Deag fmasks are also shared in the event that a router has local
25  * bit-positions. This is necessary to prevent the router receiving two copies
26  * of each packet. Consequently it also means that they share the same
27  * disposition data for the global data.
28  */
29 
30 #ifndef __BIER_FMASK_H__
31 #define __BIER_FMASK_H__
32 
33 #include <vlib/vlib.h>
34 
35 #include <vnet/fib/fib_node.h>
36 #include <vnet/mpls/packet.h>
37 #include <vnet/dpo/dpo.h>
38 
39 #include <vnet/bier/bier_types.h>
41 
42 /**
43  * A struct that represents the reference counting of the bits
44  */
45 typedef struct bier_fmask_bits_t_ {
46  /**
47  * each bit in the mask needs to be reference counted
48  * and set/cleared on the 0->1 and 1->0 transitions.
49  */
52 
53  /**
54  * The total number of references to bits set on this mask
55  * in effect a count of the number of children.
56  */
59 
60 /**
61  * Flags on fmask
62  */
64 {
71 
72 #define BIER_FMASK_ATTR_NAMES { \
73  [BIER_FMASK_ATTR_FORWARDING] = "forwarding", \
74  [BIER_FMASK_ATTR_DISP] = "disposition", \
75  [BIER_FMASK_ATTR_MPLS] = "mpls", \
76 }
77 
78 #define FOR_EACH_BIER_FMASK_ATTR(_item) \
79  for (_item = BIER_FMASK_ATTR_FIRST; \
80  _item <= BIER_FMASK_ATTR_LAST; \
81  _item++)
82 
83 typedef enum bier_fmask_flags_t_
84 {
89 
90 /**
91  * An outgoing BIER mask. aka forwarding bit mask (in the RFCs)
92  *
93  * This mask's function is two-fold
94  * 1 - it is logical-AND with the input packet header to produce the
95  * output packet header
96  * 2 - it is logical NAND with the input packet header to modify the bit-mask
97  * for the next lookup
98  */
99 typedef struct bier_fmask_t_ {
100  /**
101  * Required for pool_get_aligned
102  */
103  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
104 
105  /**
106  * The BIER fmask is a child of a FIB entry in the FIB graph.
107  */
109 
110  /**
111  * operational/state flags on the fmask
112  */
114 
115  /**
116  * The bits, and their ref counts, that are set on this mask
117  * This mask changes as BIER entries link to and from this fmask
118  */
120 
121  /**
122  * The key to this fmask - used for store/lookup in the DB
123  */
125 
126  /**
127  * The MPLS label to paint on the header during forwarding
128  */
130 
131  /**
132  * The path-list
133  */
135 
136  /**
137  * the index of this fmask in the parent's child list.
138  */
140 
141  /**
142  * The index into the adj table for the adj that
143  * this fmask resolves via
144  */
146 } bier_fmask_t;
147 
148 extern void bier_fmask_link(index_t bfmi, bier_bp_t bp);
149 extern void bier_fmask_unlink(index_t bfmi, bier_bp_t bp);
150 extern void bier_fmask_unlock(index_t bfmi);
151 extern void bier_fmask_lock(index_t bfmi);
152 
154  const fib_route_path_t *rpath);
155 
156 extern u8* format_bier_fmask(u8 *s, va_list *ap);
157 
159  dpo_id_t *dpo);
160 
161 extern u32 bier_fmask_child_add (fib_node_index_t fib_entry_index,
162  fib_node_type_t child_type,
163  fib_node_index_t child_index);
164 extern void bier_fmask_child_remove (fib_node_index_t fib_entry_index,
165  u32 sibling_index);
166 extern void bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes);
167 extern void bier_fmask_encode (index_t bfmi,
168  bier_table_id_t *btid,
169  fib_route_path_t *rpath);
170 
171 /*
172  * provided for fast data-path access
173  */
175 
176 static inline bier_fmask_t *
178 {
180 }
181 
182 #endif
vlib.h
BIER_FMASK_ATTR_DISP
@ BIER_FMASK_ATTR_DISP
Definition: bier_fmask.h:67
BIER_FMASK_ATTR_FIRST
@ BIER_FMASK_ATTR_FIRST
Definition: bier_fmask.h:65
bier_fmask_bits_t_::bfmb_input_reset_string
bier_bit_string_t bfmb_input_reset_string
each bit in the mask needs to be reference counted and set/cleared on the 0->1 and 1->0 transitions.
Definition: bier_fmask.h:50
bier_fmask_unlock
void bier_fmask_unlock(index_t bfmi)
Definition: bier_fmask.c:254
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
bier_fmask_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
Required for pool_get_aligned.
bier_table_id_t_
The ID of a table.
Definition: bier_types.h:394
bier_fmask_encode
void bier_fmask_encode(index_t bfmi, bier_table_id_t *btid, fib_route_path_t *rpath)
Definition: bier_fmask.c:405
bier_fmask_link
void bier_fmask_link(index_t bfmi, bier_bp_t bp)
Definition: bier_fmask.c:304
packet.h
BIER_FMASK_FLAG_DISP
@ BIER_FMASK_FLAG_DISP
Definition: bier_fmask.h:86
bier_bp_t
u32 bier_bp_t
A bit positon as assigned to egress PEs.
Definition: bier_types.h:294
fib_node.h
fib_node_type_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
bier_fmask_attributes_t
enum bier_fmask_attributes_t_ bier_fmask_attributes_t
Flags on fmask.
bier_fmask_unlink
void bier_fmask_unlink(index_t bfmi, bier_bp_t bp)
Definition: bier_fmask.c:324
BIER_FMASK_ATTR_LAST
@ BIER_FMASK_ATTR_LAST
Definition: bier_fmask.h:69
bier_fmask_child_add
u32 bier_fmask_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: bier_fmask.c:141
bier_fmask_bits_t_
bier_fmask : The BIER fmask
Definition: bier_fmask.h:45
format_bier_fmask
u8 * format_bier_fmask(u8 *s, va_list *ap)
Definition: bier_fmask.c:344
bier_fmask_t_::bfm_label
mpls_label_t bfm_label
The MPLS label to paint on the header during forwarding.
Definition: bier_fmask.h:129
bier_fmask_t_::bfm_flags
bier_fmask_flags_t bfm_flags
operational/state flags on the fmask
Definition: bier_fmask.h:113
BIER_FMASK_ATTR_FORWARDING
@ BIER_FMASK_ATTR_FORWARDING
Definition: bier_fmask.h:66
bier_fmask_bits_t_::bfmb_refs
u32 * bfmb_refs
Definition: bier_fmask.h:51
dpo.h
bier_fmask_pool
bier_fmask_t * bier_fmask_pool
Definition: bier_fmask.c:38
bier_fmask_get_stats
void bier_fmask_get_stats(index_t bfmi, u64 *packets, u64 *bytes)
Definition: bier_fmask.c:394
bier_fmask_lock
void bier_fmask_lock(index_t bfmi)
Definition: bier_fmask.c:269
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
bier_fmask_bits_t_::bfmb_count
u32 bfmb_count
The total number of references to bits set on this mask in effect a count of the number of children.
Definition: bier_fmask.h:57
bier_fmask_bits_t
struct bier_fmask_bits_t_ bier_fmask_bits_t
bier_fmask : The BIER fmask
bier_fmask_attributes_t_
bier_fmask_attributes_t_
Flags on fmask.
Definition: bier_fmask.h:63
bier_fmask_t_::bfm_id
bier_fmask_id_t * bfm_id
The key to this fmask - used for store/lookup in the DB.
Definition: bier_fmask.h:124
BIER_FMASK_FLAG_MPLS
@ BIER_FMASK_FLAG_MPLS
Definition: bier_fmask.h:87
bier_fmask_create_and_lock
index_t bier_fmask_create_and_lock(const bier_fmask_id_t *fmid, const fib_route_path_t *rpath)
Definition: bier_fmask.c:284
bier_fmask_contribute_forwarding
void bier_fmask_contribute_forwarding(index_t bfmi, dpo_id_t *dpo)
Definition: bier_fmask.c:120
index
u32 index
Definition: flow_types.api:221
BIER_FMASK_FLAG_FORWARDING
@ BIER_FMASK_FLAG_FORWARDING
Definition: bier_fmask.h:85
u64
unsigned long u64
Definition: types.h:89
bier_fmask_t
struct bier_fmask_t_ bier_fmask_t
An outgoing BIER mask.
u32
unsigned int u32
Definition: types.h:88
BIER_FMASK_ATTR_MPLS
@ BIER_FMASK_ATTR_MPLS
Definition: bier_fmask.h:68
bier_fmask_t_::bfm_dpo
dpo_id_t bfm_dpo
The index into the adj table for the adj that this fmask resolves via.
Definition: bier_fmask.h:145
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
bier_fmask_t_::bfm_sibling
u32 bfm_sibling
the index of this fmask in the parent's child list.
Definition: bier_fmask.h:139
bier_fmask_child_remove
void bier_fmask_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: bier_fmask.c:152
bier_types.h
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
bier_fmask_t_::bfm_bits
bier_fmask_bits_t bfm_bits
The bits, and their ref counts, that are set on this mask This mask changes as BIER entries link to a...
Definition: bier_fmask.h:119
u8
unsigned char u8
Definition: types.h:56
bier_fmask_t_::bfm_pl
fib_node_index_t bfm_pl
The path-list.
Definition: bier_fmask.h:134
bier_fmask_flags_t_
bier_fmask_flags_t_
Definition: bier_fmask.h:83
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
mpls_label_t
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:26
bier_fmask_flags_t
enum bier_fmask_flags_t_ bier_fmask_flags_t
bier_fmask_t_
An outgoing BIER mask.
Definition: bier_fmask.h:99
bier_fmask_db.h
bier_fmask_id_t_
A key/ID for a BIER forwarding Mas (FMask).
Definition: bier_fmask_db.h:60
bier_bit_string_t_
A Variable length BitString.
Definition: bier_types.h:278
bier_fmask_t_::bfm_node
fib_node_t bfm_node
The BIER fmask is a child of a FIB entry in the FIB graph.
Definition: bier_fmask.h:108
bier_fmask_get
static bier_fmask_t * bier_fmask_get(u32 index)
Definition: bier_fmask.h:177
packets
units packets
Definition: map.api:366