BIER API and load-balancing fixes
[vpp.git] / src / vnet / bier / bier_entry.h
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  * bier_entry : The BIER entry
17  *
18  * The interface to the BIER entry is through a bier_entry_t* rather
19  * than an index. This is becuase the BIER table allocates the entries
20  * in a contiguous array once and only once when the table is created.
21  * this is done for forwarding performance. The entry is thus not subject
22  * to realloc, and does not need to be malloc'd when a route to that
23  * bit-position is first learned.
24  *
25  */
26
27 #ifndef __BIER_ENTRY_H__
28 #define __BIER_ENTRY_H__
29
30 #include <vlib/vlib.h>
31 #include <vnet/fib/fib_node.h>
32 #include <vnet/bier/bier_types.h>
33
34 /**
35  * Forward declarations
36  */
37 struct bier_route_update_t_;
38 struct bier_fmask_db_t_;
39
40 /**
41  * The BIER entry
42  *
43  * the BIER entry is the representation of a BIER forwarding egress router (BFER)
44  * (or the egress PE) that is assigned a bit position.
45  */
46 typedef struct bier_entry_t_ {
47     /**
48      * linkage into the FIB graph
49      */
50     fib_node_t be_node;
51
52     /**
53      * The index of the BIER table in which this entry resides
54      */
55     index_t be_bti;
56
57     /**
58      * the bit position this entry represents.
59      *  this is the key table insertion
60      */
61     bier_bp_t be_bp;
62
63     /**
64      * the FIB path-list this entry resolves through.
65      * the path-list is itself resoved on the entry's fmasks
66      */
67     fib_node_index_t be_path_list;
68     /**
69      * sibling index on the path list
70      */
71     fib_node_index_t be_sibling_index;
72 } bier_entry_t;
73
74 extern index_t bier_entry_create(index_t bti,
75                                  bier_bp_t bp);
76 extern void bier_entry_delete(index_t bei);
77
78 extern void bier_entry_path_update (index_t bei,
79                                     const fib_route_path_t *rpaths);
80
81 extern void bier_entry_path_add(index_t bei,
82                                 const fib_route_path_t *brp);
83
84 extern int bier_entry_path_remove(index_t bei,
85                                   const fib_route_path_t *brp);
86
87 extern u8* format_bier_entry(u8* s, va_list *ap);
88
89 extern void bier_entry_contribute_forwarding(index_t bei,
90                                              dpo_id_t *dpo);
91
92 extern bier_entry_t *bier_entry_pool;
93 always_inline bier_entry_t* bier_entry_get(index_t bei)
94 {
95     return (&bier_entry_pool[bei]);
96 }
97 #endif