7413d8a2c7873dad672f904022137d96b496fa90
[vpp.git] / vnet / vnet / fib / fib_walk.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 #ifndef __FIB_WALK_H__
17 #define __FIB_WALK_H__
18
19 #include <vnet/fib/fib_node.h>
20
21 /**
22  * @brief Walk priorities.
23  * Strict priorities. All walks a priority n are completed before n+1 is started.
24  * Increasing numerical value implies decreasing priority.
25  */
26 typedef enum fib_walk_priority_t_
27 {
28     FIB_WALK_PRIORITY_HIGH = 0,
29     FIB_WALK_PRIORITY_LOW  = 1,
30 } fib_walk_priority_t;
31
32 #define FIB_WALK_PRIORITY_NUM ((fib_walk_priority_t)(FIB_WALK_PRIORITY_LOW+1))
33
34 #define FIB_WALK_PRIORITIES {           \
35     [FIB_WALK_PRIORITY_HIGH] = "high",  \
36     [FIB_WALK_PRIORITY_LOW]  = "low",   \
37 }
38
39 #define FOR_EACH_FIB_WALK_PRIORITY(_prio)         \
40     for ((_prio) = FIB_WALK_PRIORITY_HIGH;        \
41          (_prio) < FIB_WALK_PRIORITY_NUM;         \
42          (_prio)++)
43
44 extern void fib_walk_module_init(void);
45
46 extern void fib_walk_async(fib_node_type_t parent_type,
47                            fib_node_index_t parent_index,
48                            fib_walk_priority_t prio,
49                            fib_node_back_walk_ctx_t *ctx);
50
51 extern void fib_walk_sync(fib_node_type_t parent_type,
52                           fib_node_index_t parent_index,
53                           fib_node_back_walk_ctx_t *ctx);
54
55 extern u8* format_fib_walk_priority(u8 *s, va_list ap);
56
57 #endif
58