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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __GBP_ENDPOINT_GROUP_H__
17 #define __GBP_ENDPOINT_GROUP_H__
19 #include <plugins/gbp/gbp_types.h>
21 #include <vnet/fib/fib_types.h>
24 * Endpoint Retnetion Policy
26 typedef struct gbp_endpoint_retention_t_
28 /** Aging timeout for remote endpoints */
29 u32 remote_ep_timeout;
30 } gbp_endpoint_retention_t;
33 * An Endpoint Group representation
35 typedef struct gpb_endpoint_group_t_
43 * Sclass. Could be unset => ~0
48 * Bridge-domain ID the EPG is in
54 * route-domain/IP-table ID the EPG is in
59 * Is the EPG an external/NAT
64 * the uplink interface dedicated to the EPG
66 u32 gg_uplink_sw_if_index;
69 * The DPO used in the L3 path for forwarding internal subnets
71 dpo_id_t gg_dpo[FIB_PROTOCOL_IP_MAX];
74 * Locks/references to this EPG
81 gbp_endpoint_retention_t gg_retention;
82 } gbp_endpoint_group_t;
85 * EPG DB, key'd on EGP-ID
87 typedef struct gbp_endpoint_group_db_t_
89 uword *gg_hash_sclass;
90 } gbp_endpoint_group_db_t;
92 extern int gbp_endpoint_group_add_and_lock (vnid_t vnid,
96 u32 uplink_sw_if_index,
97 const gbp_endpoint_retention_t *
99 extern index_t gbp_endpoint_group_find (sclass_t sclass);
100 extern int gbp_endpoint_group_delete (sclass_t sclass);
101 extern void gbp_endpoint_group_unlock (index_t index);
102 extern void gbp_endpoint_group_lock (index_t index);
103 extern u32 gbp_endpoint_group_get_bd_id (const gbp_endpoint_group_t *);
105 extern gbp_endpoint_group_t *gbp_endpoint_group_get (index_t i);
106 extern index_t gbp_endpoint_group_get_fib_index (const gbp_endpoint_group_t *
107 gg, fib_protocol_t fproto);
109 typedef int (*gbp_endpoint_group_cb_t) (gbp_endpoint_group_t * gbpe,
111 extern void gbp_endpoint_group_walk (gbp_endpoint_group_cb_t bgpe, void *ctx);
114 extern u8 *format_gbp_endpoint_group (u8 * s, va_list * args);
117 * DP functions and databases
119 extern gbp_endpoint_group_db_t gbp_endpoint_group_db;
120 extern gbp_endpoint_group_t *gbp_endpoint_group_pool;
121 extern uword *gbp_epg_sclass_db;
124 gbp_epg_itf_lookup_sclass (sclass_t sclass)
128 p = hash_get (gbp_endpoint_group_db.gg_hash_sclass, sclass);
132 gbp_endpoint_group_t *gg;
134 gg = pool_elt_at_index (gbp_endpoint_group_pool, p[0]);
135 return (gg->gg_uplink_sw_if_index);
140 always_inline const dpo_id_t *
141 gbp_epg_dpo_lookup (sclass_t sclass, fib_protocol_t fproto)
145 p = hash_get (gbp_endpoint_group_db.gg_hash_sclass, sclass);
149 gbp_endpoint_group_t *gg;
151 gg = pool_elt_at_index (gbp_endpoint_group_pool, p[0]);
152 return (&gg->gg_dpo[fproto]);
160 * fd.io coding-style-patch-verification: ON
163 * eval: (c-set-style "gnu")