misc: deprecate gbp and its dependents
[vpp.git] / extras / deprecated / plugins / gbp / gbp_bridge_domain.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_BRIDGE_DOMAIN_H__
17 #define __GBP_BRIDGE_DOMAIN_H__
18
19 #include <plugins/gbp/gbp_types.h>
20 #include <plugins/gbp/gbp_itf.h>
21
22 #include <vnet/fib/fib_types.h>
23 #include <vnet/l2/l2_bd.h>
24
25 /**
26  * Bridge Domain Flags
27  */
28 typedef enum gbp_bridge_domain_flags_t_
29 {
30   GBP_BD_FLAG_NONE = 0,
31   GBP_BD_FLAG_DO_NOT_LEARN = (1 << 0),
32   GBP_BD_FLAG_UU_FWD_DROP = (1 << 1),
33   GBP_BD_FLAG_MCAST_DROP = (1 << 2),
34   GBP_BD_FLAG_UCAST_ARP = (1 << 3),
35 } gbp_bridge_domain_flags_t;
36
37 /**
38  * A bridge Domain Representation.
39  * This is a standard bridge-domain plus all the attributes it must
40  * have to supprt the GBP model.
41  */
42 typedef struct gbp_bridge_domain_t_
43 {
44   /**
45    * Bridge-domain ID
46    */
47   u32 gb_bd_id;
48   u32 gb_bd_index;
49
50   /**
51    * Index of the Route-domain this BD is associated with. This is used as the
52    * 'scope' of the packets for contract matching.
53    */
54   u32 gb_rdi;
55
56   /**
57    * Flags conttrolling behaviour
58    */
59   gbp_bridge_domain_flags_t gb_flags;
60
61   /**
62    * The BD's BVI interface (obligatory)
63    */
64   u32 gb_bvi_sw_if_index;
65
66   /**
67    * The BD's MAC spine-proxy interface (optional)
68    */
69   u32 gb_uu_fwd_sw_if_index;
70
71   /**
72    * The BD's interface to sned Broadcast and multicast packets
73    */
74   gbp_itf_hdl_t gb_bm_flood_itf;
75
76   /**
77    * The index of the BD's VNI interface on which packets from
78    * unkown endpoints arrive
79    */
80   u32 gb_vni;
81
82   /**
83    * locks/references to the BD so it does not get deleted (from the API)
84    * whilst it is still being used
85    */
86   u32 gb_locks;
87 } gbp_bridge_domain_t;
88
89 extern void gbp_bridge_domain_itf_add (index_t gbdi,
90                                        u32 sw_if_index,
91                                        l2_bd_port_type_t type);
92 extern void gbp_bridge_domain_itf_del (index_t gbdi,
93                                        u32 sw_if_index,
94                                        l2_bd_port_type_t type);
95
96 extern int gbp_bridge_domain_add_and_lock (u32 bd_id,
97                                            u32 rd_id,
98                                            gbp_bridge_domain_flags_t flags,
99                                            u32 bvi_sw_if_index,
100                                            u32 uu_fwd_sw_if_index,
101                                            u32 bm_flood_sw_if_index);
102
103 extern void gbp_bridge_domain_unlock (index_t gbi);
104 extern index_t gbp_bridge_domain_find_and_lock (u32 bd_id);
105 extern int gbp_bridge_domain_delete (u32 bd_id);
106 extern index_t gbp_bridge_domain_index (const gbp_bridge_domain_t *);
107 extern u32 gbp_bridge_domain_get_bd_id (index_t gbdi);
108
109 typedef int (*gbp_bridge_domain_cb_t) (gbp_bridge_domain_t * gb, void *ctx);
110 extern void gbp_bridge_domain_walk (gbp_bridge_domain_cb_t bgpe, void *ctx);
111
112 extern u8 *format_gbp_bridge_domain (u8 * s, va_list * args);
113 extern u8 *format_gbp_bridge_domain_flags (u8 * s, va_list * args);
114
115 /**
116  * DB of bridge_domains
117  */
118 typedef struct gbp_bridge_domain_db_t
119 {
120   uword *gbd_by_bd_id;
121   index_t *gbd_by_bd_index;
122 } gbp_bridge_domain_db_t;
123
124 extern gbp_bridge_domain_db_t gbp_bridge_domain_db;
125 extern gbp_bridge_domain_t *gbp_bridge_domain_pool;
126
127 always_inline gbp_bridge_domain_t *
128 gbp_bridge_domain_get (index_t i)
129 {
130   return (pool_elt_at_index (gbp_bridge_domain_pool, i));
131 }
132
133 always_inline gbp_bridge_domain_t *
134 gbp_bridge_domain_get_by_bd_index (u32 bd_index)
135 {
136   return (gbp_bridge_domain_get
137           (gbp_bridge_domain_db.gbd_by_bd_index[bd_index]));
138 }
139
140 extern gbp_scope_t *gbp_scope_by_bd_index;
141
142 always_inline gbp_scope_t
143 gbp_bridge_domain_get_scope (u32 bd_index)
144 {
145   return (gbp_scope_by_bd_index[bd_index]);
146 }
147
148 #endif
149
150 /*
151  * fd.io coding-style-patch-verification: ON
152  *
153  * Local Variables:
154  * eval: (c-set-style "gnu")
155  * End:
156  */