FIB: encode the label stack in the FIB path during table dump
[vpp.git] / src / vnet / mfib / mfib_entry_src.h
1 /*
2  * Copyright (c) 2018 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 __MFIB_ENTRY_SRC_H__
17 #define __MFIB_ENTRY_SRC_H__
18
19 #include <vnet/mfib/mfib_entry.h>
20
21 /**
22  * MFIB extensions to each path
23  */
24 typedef struct mfib_path_ext_t_
25 {
26     mfib_itf_flags_t mfpe_flags;
27     fib_node_index_t mfpe_path;
28 } mfib_path_ext_t;
29
30 /**
31  * The source of an MFIB entry
32  */
33 typedef struct mfib_entry_src_t_
34 {
35     /**
36      * Which source this is
37      */
38     mfib_source_t mfes_src;
39
40     /**
41      * Route flags
42      */
43     mfib_entry_flags_t mfes_flags;
44
45     /**
46      * The reference count on the entry. this is a u32
47      * since there is no path-list sharing in mfib, so the number
48      * os children could be high.
49      */
50     u32 mfes_ref_count;
51
52     /**
53      * The path-list of forwarding interfaces
54      */
55     fib_node_index_t mfes_pl;
56
57     /**
58      * RPF-ID
59      */
60     fib_rpf_id_t mfes_rpf_id;
61
62     /**
63      * Hash table of path extensions
64      */
65     mfib_path_ext_t *mfes_exts;
66
67     /**
68      * Covering entry (if needed)
69      */
70     struct {
71         fib_node_index_t mfes_cover;
72         u32 mfes_sibling;
73     };
74
75     /**
76      * The hash table of all interfaces.
77      *  This is forwarding time information derived from the paths
78      *  and their extensions.
79      */
80     mfib_itf_t *mfes_itfs;
81 } mfib_entry_src_t;
82
83 /**
84  * signals from the sources to the caller
85  */
86 typedef enum mfib_src_res_t_
87 {
88     MFIB_SRC_OK,
89     MFIB_SRC_REEVALUATE,
90 } mfib_src_res_t;
91
92 /**
93  * A function provided by each source to be invoked when it is activated
94  */
95 typedef void (*mfib_entry_src_activiate_t) (mfib_entry_t*, mfib_entry_src_t*);
96
97 /**
98  * A function provided by each source to be invoked when it is deactivated
99  */
100 typedef void (*mfib_entry_src_deactiviate_t) (mfib_entry_t*, mfib_entry_src_t*);
101
102 /**
103  * A function provided by each source to be invoked when the cover changes
104  */
105 typedef mfib_src_res_t (*mfib_entry_src_cover_change_t) (mfib_entry_t*, mfib_entry_src_t*);
106
107 /**
108  * A function provided by each source to be invoked when the cover is updated
109  */
110 typedef mfib_src_res_t (*mfib_entry_src_cover_update_t) (mfib_entry_t*, mfib_entry_src_t*);
111
112 /**
113  * Virtual function table provided by each_source
114  */
115 typedef struct mfib_entry_src_vft_t_
116 {
117     mfib_entry_src_activiate_t mev_activate;
118     mfib_entry_src_deactiviate_t mev_deactivate;
119     mfib_entry_src_cover_change_t mev_cover_change;
120     mfib_entry_src_cover_update_t mev_cover_update;
121 } mfib_entry_src_vft;
122
123 extern void mfib_entry_src_register(mfib_source_t, const mfib_entry_src_vft*);
124
125 extern void mfib_entry_src_deactivate(mfib_entry_t *mfib_entry,
126                                       mfib_entry_src_t *bsrc);
127
128 extern void mfib_entry_src_activate(mfib_entry_t *mfib_entry,
129                                     mfib_entry_src_t *bsrc);
130
131 extern mfib_src_res_t mfib_entry_src_cover_change(mfib_entry_t *mfib_entry,
132                                                   mfib_entry_src_t *bsrc);
133
134 extern mfib_src_res_t mfib_entry_src_cover_update(mfib_entry_t *mfib_entry,
135                                                   mfib_entry_src_t *bsrc);
136
137 extern mfib_entry_src_t* mfib_entry_get_best_src(const mfib_entry_t *mfib_entry);
138
139 extern void mfib_entry_src_module_init(void);
140 extern void mfib_entry_src_rr_module_init(void);
141
142 #endif