GBP Endpoint Learning
[vpp.git] / src / plugins / gbp / gbp_recirc.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 __GBP_RECIRC_H__
17 #define __GBP_RECIRC_H__
18
19 #include <plugins/gbp/gbp_types.h>
20 #include <vnet/fib/fib_types.h>
21
22 /**
23  * An Endpoint Group representation
24  */
25 typedef struct gpb_recirc_t_
26 {
27   /**
28    * EPG ID that packets will classify to when they arrive on this recirc
29    */
30   epg_id_t gr_epg;
31
32   /**
33    * The index of the EPG
34    */
35   index_t gr_epgi;
36
37   /**
38    * FIB indices the EPG is mapped to
39    */
40   u32 gr_fib_index[FIB_PROTOCOL_IP_MAX];
41
42   /**
43    * Is the interface for packets post-NAT translation (i.e. ext)
44    * or pre-NAT translation (i.e. internal)
45    */
46   u8 gr_is_ext;
47
48   /**
49    */
50   u32 gr_sw_if_index;
51   u32 gr_itf;
52
53   /**
54    * The endpoint created to represent the reric interface
55    */
56   index_t gr_ep;
57 } gbp_recirc_t;
58
59 extern int gbp_recirc_add (u32 sw_if_index, epg_id_t epg_id, u8 is_ext);
60 extern void gbp_recirc_delete (u32 sw_if_index);
61
62 typedef int (*gbp_recirc_cb_t) (gbp_recirc_t * gbpe, void *ctx);
63 extern void gbp_recirc_walk (gbp_recirc_cb_t bgpe, void *ctx);
64
65 /**
66  * Data plane functions
67  */
68 extern gbp_recirc_t *gbp_recirc_pool;
69 extern index_t *gbp_recirc_db;
70
71 always_inline gbp_recirc_t *
72 gbp_recirc_get (u32 sw_if_index)
73 {
74   return (pool_elt_at_index (gbp_recirc_pool, gbp_recirc_db[sw_if_index]));
75 }
76 #endif
77
78 /*
79  * fd.io coding-style-patch-verification: ON
80  *
81  * Local Variables:
82  * eval: (c-set-style "gnu")
83  * End:
84  */