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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __MFIB_ENTRY_H__
17 #define __MFIB_ENTRY_H__
19 #include <vnet/fib/fib_node.h>
20 #include <vnet/mfib/mfib_types.h>
21 #include <vnet/mfib/mfib_itf.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/dpo/dpo.h>
26 * An entry in a FIB table.
28 * This entry represents a route added to the FIB that is stored
29 * in one of the FIB tables.
31 typedef struct mfib_entry_t_ {
32 CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
34 * Base class. The entry's node representation in the graph.
38 * The prefix of the route
40 mfib_prefix_t mfe_prefix;
42 * The index of the FIB table this entry is in
46 * the path-list for which this entry is a child. This is also the path-list
47 * that is contributing forwarding for this entry.
49 fib_node_index_t mfe_parent;
51 * index of this entry in the parent's child list.
52 * This is set when this entry is added as a child, but can also
53 * be changed by the parent as it manages its list.
58 * A vector of sources contributing forwarding
60 struct mfib_entry_src_t_ *mfe_srcs;
63 * 2nd cache line has the members used in the data plane
65 CLIB_CACHE_LINE_ALIGN_MARK(cacheline1);
68 * The Replicate DPO used for forwarding.
75 mfib_entry_flags_t mfe_flags;
78 * A hash table of interfaces
83 #define MFIB_ENTRY_FORMAT_BRIEF (0x0)
84 #define MFIB_ENTRY_FORMAT_DETAIL (0x1)
85 #define MFIB_ENTRY_FORMAT_DETAIL2 (0x2)
87 extern u8 *format_mfib_entry(u8 * s, va_list * args);
90 extern fib_node_index_t mfib_entry_create(u32 fib_index,
92 const mfib_prefix_t *prefix,
93 mfib_entry_flags_t entry_flags);
95 extern int mfib_entry_update(fib_node_index_t fib_entry_index,
97 mfib_entry_flags_t entry_flags,
100 extern void mfib_entry_path_update(fib_node_index_t fib_entry_index,
101 mfib_source_t source,
102 const fib_route_path_t *rpath,
103 mfib_itf_flags_t itf_flags);
106 extern int mfib_entry_path_remove(fib_node_index_t fib_entry_index,
107 mfib_source_t source,
108 const fib_route_path_t *rpath);
110 extern int mfib_entry_delete(fib_node_index_t mfib_entry_index,
111 mfib_source_t source);
113 extern int mfib_entry_cmp_for_sort(void *i1, void *i2);
115 extern u32 mfib_entry_child_add(fib_node_index_t mfib_entry_index,
116 fib_node_type_t type,
117 fib_node_index_t child_index);
118 extern void mfib_entry_child_remove(fib_node_index_t mfib_entry_index,
121 extern void mfib_entry_lock(fib_node_index_t fib_entry_index);
122 extern void mfib_entry_unlock(fib_node_index_t fib_entry_index);
124 extern void mfib_entry_get_prefix(fib_node_index_t fib_entry_index,
126 extern u32 mfib_entry_get_fib_index(fib_node_index_t fib_entry_index);
128 extern void mfib_entry_contribute_forwarding(
129 fib_node_index_t mfib_entry_index,
130 fib_forward_chain_type_t type,
133 extern void mfib_entry_encode(fib_node_index_t fib_entry_index,
134 fib_route_path_encode_t **api_rpaths);
136 extern void mfib_entry_module_init(void);
139 extern mfib_entry_t *mfib_entry_pool;
141 static inline mfib_entry_t *
142 mfib_entry_get (fib_node_index_t index)
144 return (pool_elt_at_index(mfib_entry_pool, index));
146 static inline fib_node_index_t
147 mfib_entry_get_index (const mfib_entry_t *mfe)
149 return (mfe - mfib_entry_pool);
153 static inline mfib_itf_t *
154 mfib_entry_itf_find (mfib_itf_t *itfs,
159 p = hash_get(itfs, sw_if_index);
163 return (mfib_itf_get(p[0]));
169 static inline mfib_itf_t *
170 mfib_entry_get_itf (const mfib_entry_t *mfe,
173 return (mfib_entry_itf_find(mfe->mfe_itfs, sw_if_index));