X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fl2%2Fl2_bd.h;h=ffc75339e9729e7209cf25213ce5eec0de994fd6;hb=refs%2Fchanges%2F47%2F11547%2F10;hp=4bb9bc9b24c0b6f5d2cffa628d07e472a83b1011;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h index 4bb9bc9b24c..ffc75339e97 100644 --- a/src/vnet/l2/l2_bd.h +++ b/src/vnet/l2/l2_bd.h @@ -34,7 +34,7 @@ typedef struct vnet_main_t *vnet_main; } bd_main_t; -bd_main_t bd_main; +extern bd_main_t bd_main; /* Bridge domain member */ @@ -49,7 +49,6 @@ typedef struct u16 spare; } l2_flood_member_t; - /* Per-bridge domain configuration */ typedef struct @@ -79,6 +78,9 @@ typedef struct /* Tunnels (Unicast vxlan) are flooded if there are no masters */ u32 tun_normal_count; + /* Interface on which packets are not flooded */ + u32 no_flood_count; + /* hash ip4/ip6 -> mac for arp/nd termination */ uword *mac_by_ip4; uword *mac_by_ip6; @@ -86,8 +88,30 @@ typedef struct /* mac aging */ u8 mac_age; + /* sequence number for bridge domain based flush of MACs */ + u8 seq_num; + + /* Bridge domain tag (C string NULL terminated) */ + u8 *bd_tag; + } l2_bridge_domain_t; +/* Limit Bridge Domain ID to 24 bits to match 24-bit VNI range */ +#define L2_BD_ID_MAX ((1<<24)-1) + +typedef struct +{ + u32 bd_id; + u8 flood; + u8 uu_flood; + u8 forward; + u8 learn; + u8 arp_term; + u8 mac_age; + u8 *bd_tag; + u8 is_add; +} l2_bridge_domain_add_del_args_t; + /* Return 1 if bridge domain has been initialized */ always_inline u32 bd_is_valid (l2_bridge_domain_t * bd_config) @@ -113,28 +137,47 @@ u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index); u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable); void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age); +int bd_add_del (l2_bridge_domain_add_del_args_t * args); /** - * \brief Get or create a bridge domain. + * \brief Get a bridge domain. * - * Get or create a bridge domain with the given bridge domain ID. + * Get a bridge domain with the given bridge domain ID. * * \param bdm bd_main pointer. - * \param bd_id The bridge domain ID or ~0 if an arbitrary unused bridge domain should be used. + * \param bd_id The bridge domain ID * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector. */ -u32 bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id); +u32 bd_find_index (bd_main_t * bdm, u32 bd_id); /** - * \brief Delete a bridge domain. + * \brief Create a bridge domain. * - * Delete an existing bridge domain with the given bridge domain ID. + * Create a bridge domain with the given bridge domain ID * * \param bdm bd_main pointer. - * \param bd_id The bridge domain ID. - * \return 0 on success and -1 if the bridge domain does not exist. + * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector. */ -int bd_delete_bd_index (bd_main_t * bdm, u32 bd_id); +u32 bd_add_bd_index (bd_main_t * bdm, u32 bd_id); + +/** + * \brief Get or create a bridge domain. + * + * Get a bridge domain with the given bridge domain ID, if one exists, otherwise + * create one with the given ID, or the first unused ID if the given ID is ~0.. + * + * \param bdm bd_main pointer. + * \param bd_id The bridge domain ID + * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector. + */ +static inline u32 +bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id) +{ + u32 bd_index = bd_find_index (bdm, bd_id); + if (bd_index == ~0) + return bd_add_bd_index (bdm, bd_id); + return bd_index; +} u32 bd_add_del_ip_mac (u32 bd_index, u8 * ip_addr, u8 * mac_addr, u8 is_ip6, u8 is_add);