FD.io VPP  v16.09
Vector Packet Processing
l2_bd.h
Go to the documentation of this file.
1 /*
2  * l2_bd.h : layer 2 bridge domain
3  *
4  * Copyright (c) 2013 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef included_l2bd_h
19 #define included_l2bd_h
20 
21 #include <vlib/vlib.h>
22 #include <vnet/vnet.h>
23 
24 typedef struct
25 {
26  /* hash bd_id -> bd_index */
28 
29  /* Busy bd_index bitmap */
31 
32  /* convenience */
35 } bd_main_t;
36 
38 
39 /* Bridge domain member */
40 
41 #define L2_FLOOD_MEMBER_NORMAL 0
42 #define L2_FLOOD_MEMBER_BVI 1
43 
44 typedef struct
45 {
46  u32 sw_if_index; /* the output L2 interface */
47  u8 flags; /* 0=normal, 1=bvi */
48  u8 shg; /* split horizon group number */
51 
52 
53 /* Per-bridge domain configuration */
54 
55 typedef struct
56 {
58  /*
59  * Contains bit enables for flooding, learning, and forwarding.
60  * All other feature bits should always be set.
61  *
62  * identity of the bridge-domain's BVI interface
63  * set to ~0 if there is no BVI
64  */
66 
67  /* bridge domain id, not to be confused with bd_index */
69 
70  /* Vector of members in the replication group */
72 
73  /* hash ip4/ip6 -> mac for arp termination */
76 
78 
79 /* Return 1 if bridge domain has been initialized */
82 {
83  return (bd_config->feature_bitmap != 0);
84 }
85 
86 /* Init bridge domain if not done already */
87 void bd_validate (l2_bridge_domain_t * bd_config);
88 
89 
90 void
91 bd_add_member (l2_bridge_domain_t * bd_config, l2_flood_member_t * member);
92 
93 u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
94 
95 
96 #define L2_LEARN (1<<0)
97 #define L2_FWD (1<<1)
98 #define L2_FLOOD (1<<2)
99 #define L2_UU_FLOOD (1<<3)
100 #define L2_ARP_TERM (1<<4)
101 
102 u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
103 
104 /**
105  * \brief Get or create a bridge domain.
106  *
107  * Get or create a bridge domain with the given bridge domain ID.
108  *
109  * \param bdm bd_main pointer.
110  * \param bd_id The bridge domain ID or ~0 if an arbitrary unused bridge domain should be used.
111  * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector.
112  */
114 
115 /**
116  * \brief Delete a bridge domain.
117  *
118  * Delete an existing bridge domain with the given bridge domain ID.
119  *
120  * \param bdm bd_main pointer.
121  * \param bd_id The bridge domain ID.
122  * \return 0 on success and -1 if the bridge domain does not exist.
123  */
124 int bd_delete_bd_index (bd_main_t * bdm, u32 bd_id);
125 
126 u32 bd_add_del_ip_mac (u32 bd_index,
127  u8 * ip_addr, u8 * mac_addr, u8 is_ip6, u8 is_add);
128 
129 #endif
130 
131 /*
132  * fd.io coding-style-patch-verification: ON
133  *
134  * Local Variables:
135  * eval: (c-set-style "gnu")
136  * End:
137  */
u32 bvi_sw_if_index
Definition: l2_bd.h:65
l2_flood_member_t * members
Definition: l2_bd.h:71
void bd_add_member(l2_bridge_domain_t *bd_config, l2_flood_member_t *member)
Definition: l2_bd.c:108
int bd_delete_bd_index(bd_main_t *bdm, u32 bd_id)
Delete a bridge domain.
Definition: l2_bd.c:86
#define always_inline
Definition: clib.h:84
bd_main_t bd_main
Definition: l2_bd.h:37
uword * bd_index_by_bd_id
Definition: l2_bd.h:27
vnet_main_t * vnet_main
Definition: l2_bd.h:34
u32 bd_set_flags(vlib_main_t *vm, u32 bd_index, u32 flags, u32 enable)
Set the learn/forward/flood flags for the bridge domain.
Definition: l2_bd.c:180
uword * bd_index_bitmap
Definition: l2_bd.h:30
static u32 bd_is_valid(l2_bridge_domain_t *bd_config)
Definition: l2_bd.h:81
u32 bd_remove_member(l2_bridge_domain_t *bd_config, u32 sw_if_index)
Definition: l2_bd.c:137
uword * mac_by_ip6
Definition: l2_bd.h:75
u32 bd_add_del_ip_mac(u32 bd_index, u8 *ip_addr, u8 *mac_addr, u8 is_ip6, u8 is_add)
Add/delete IP address to MAC address mapping.
Definition: l2_bd.c:508
unsigned int u32
Definition: types.h:88
u64 uword
Definition: types.h:112
vlib_main_t * vlib_main
Definition: l2_bd.h:33
unsigned short u16
Definition: types.h:57
u32 feature_bitmap
Definition: l2_bd.h:57
unsigned char u8
Definition: types.h:56
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.c:54
uword * mac_by_ip4
Definition: l2_bd.h:74
u32 sw_if_index
Definition: l2_bd.h:46
u32 flags
Definition: vhost-user.h:76
void bd_validate(l2_bridge_domain_t *bd_config)
Init bridge domain if not done already.
Definition: l2_bd.c:42