Trivial: Clean up some typos.
[vpp.git] / src / plugins / gbp / gbp_endpoint.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_ENDPOINT_H__
17 #define __GBP_ENDPOINT_H__
18
19 #include <plugins/gbp/gbp_types.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/ethernet/mac_address.h>
22
23 #include <vppinfra/bihash_16_8.h>
24 #include <vppinfra/bihash_template.h>
25 #include <vppinfra/bihash_24_8.h>
26 #include <vppinfra/bihash_template.h>
27
28 /**
29  * Flags for each endpoint
30  */
31 typedef enum gbp_endpoint_flags_t_
32 {
33   GBP_ENDPOINT_FLAG_NONE = 0,
34   GBP_ENDPOINT_FLAG_BOUNCE = (1 << 0),
35   GBP_ENDPOINT_FLAG_DYNAMIC = (1 << 1),
36 } gbp_endpoint_flags_t;
37
38 /**
39  * A Group Based Policy Endpoint.
40  * This is typically a VM or container. If the endpoint is local (i.e. on
41  * the same compute node as VPP) then there is one interface per-endpoint.
42  * If the EP is remote,e.g. reachable over a [vxlan] tunnel, then there
43  * will be multiple EPs reachable over the tunnel and they can be distinguished
44  * via either their MAC or IP Address[es].
45  */
46 typedef struct gbp_endpoint_t_
47 {
48   /**
49    * The interface on which the EP is connected
50    */
51   u32 ge_sw_if_index;
52
53   /**
54    * A vector of ip addresses that below to the endpoint
55    */
56   ip46_address_t *ge_ips;
57
58   /**
59    * MAC address of the endpoint
60    */
61   mac_address_t ge_mac;
62
63   /**
64    * The endpoint's designated EPG
65    */
66   epg_id_t ge_epg_id;
67
68   /**
69    * Endpoint flags
70    */
71   gbp_endpoint_flags_t ge_flags;
72 } gbp_endpoint_t;
73
74 extern u8 *format_gbp_endpoint (u8 * s, va_list * args);
75
76 /**
77  * Interface to source EPG DB - a per-interface vector
78  */
79 typedef struct gbp_ep_by_itf_db_t_
80 {
81   index_t *gte_vec;
82 } gbp_ep_by_itf_db_t;
83
84 typedef struct gbp_ep_by_ip_itf_db_t_
85 {
86   clib_bihash_24_8_t gte_table;
87 } gbp_ep_by_ip_itf_db_t;
88
89 typedef struct gbp_ep_by_mac_itf_db_t_
90 {
91   clib_bihash_16_8_t gte_table;
92 } gbp_ep_by_mac_itf_db_t;
93
94 extern int gbp_endpoint_update (u32 sw_if_index,
95                                 const ip46_address_t * ip,
96                                 const mac_address_t * mac,
97                                 epg_id_t epg_id, u32 * handle);
98 extern void gbp_endpoint_delete (u32 handle);
99
100 typedef walk_rc_t (*gbp_endpoint_cb_t) (gbp_endpoint_t * gbpe, void *ctx);
101 extern void gbp_endpoint_walk (gbp_endpoint_cb_t cb, void *ctx);
102
103
104 /**
105  * DP functions and databases
106  */
107 extern gbp_ep_by_itf_db_t gbp_ep_by_itf_db;
108 extern gbp_ep_by_mac_itf_db_t gbp_ep_by_mac_itf_db;
109 extern gbp_ep_by_ip_itf_db_t gbp_ep_by_ip_itf_db;
110 extern gbp_endpoint_t *gbp_endpoint_pool;
111
112 /**
113  * Get the endpoint from a port/interface
114  */
115 always_inline gbp_endpoint_t *
116 gbp_endpoint_get (index_t gbpei)
117 {
118   return (pool_elt_at_index (gbp_endpoint_pool, gbpei));
119 }
120
121 always_inline gbp_endpoint_t *
122 gbp_endpoint_get_itf (u32 sw_if_index)
123 {
124   return (gbp_endpoint_get (gbp_ep_by_itf_db.gte_vec[sw_if_index]));
125 }
126
127 #endif
128
129 /*
130  * fd.io coding-style-patch-verification: ON
131  *
132  * Local Variables:
133  * eval: (c-set-style "gnu")
134  * End:
135  */