L3 cross connect
[vpp.git] / src / plugins / l3xc / l3xc.h
1 /*
2  * Copyright (c) 2019 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 /**
17  * A L3 cross connect will send all traffic that is received on the input
18  * interface to the [set of] paths requested.
19  * It is a much more memory efficient solution than using a separate IP table
20  * for each input interface and much faster than an ABF match all rule.
21  */
22
23 #ifndef __L3XC_H__
24 #define __L3XC_H__
25
26 #include <vnet/fib/fib_node.h>
27
28 #define L3XC_PLUGIN_VERSION_MAJOR 1
29 #define L3XC_PLUGIN_VERSION_MINOR 0
30
31 /**
32  */
33 typedef struct l3xc_t_
34 {
35   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
36   /**
37    * Linkage into the FIB graph
38    */
39   fib_node_t l3xc_node;
40
41   /**
42    * The path-list describing how to forward in case of a match
43    */
44   fib_node_index_t l3xc_pl;
45
46   fib_protocol_t l3xc_proto;
47
48   /**
49    * Sibling index on the path-list
50    */
51   u32 l3xc_sibling;
52
53   /**
54    * The input interface
55    */
56   u32 l3xc_sw_if_index;
57
58   /**
59    * DPO for forwarding
60    */
61   dpo_id_t l3xc_dpo;
62 } l3xc_t;
63
64 /**
65  * Create or update an L3XC Policy
66  *
67  * @param sw_if_index_index the input interface
68  * @param rpaths The set of paths to add to the forwarding set
69  * @return error code
70  */
71 extern int l3xc_update (u32 sw_if_index,
72                         u8 is_ip6, const fib_route_path_t * rpaths);
73
74 /**
75  * Delete an L3XC.
76  *
77  * @param sw_if_index_index the input interface
78  */
79 extern int l3xc_delete (u32 sw_if_index, u8 is_ip6);
80
81 /**
82  * Callback function invoked during a walk of all policies
83  */
84 typedef int (*l3xc_walk_cb_t) (index_t l3xci, void *ctx);
85
86 /**
87  * Walk/visit each of the L3XC policies
88  */
89 extern void l3xc_walk (l3xc_walk_cb_t cb, void *ctx);
90
91 /**
92  * Find a L3 XC object from an interfce and FIB protocol
93  */
94 extern index_t l3xc_find (u32 sw_if_index, fib_protocol_t fproto);
95
96 /**
97  * Data-plane functions
98  */
99 extern l3xc_t *l3xc_pool;
100
101 static_always_inline l3xc_t *
102 l3xc_get (u32 index)
103 {
104   return (pool_elt_at_index (l3xc_pool, index));
105 }
106
107 extern vlib_node_registration_t l3xc_ip4_node;
108 extern vlib_node_registration_t l3xc_ip6_node;
109
110 /*
111  * fd.io coding-style-patch-verification: ON
112  *
113  * Local Variables:
114  * eval: (c-set-style "gnu")
115  * End:
116  */
117
118 #endif