diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2017-11-10 06:53:54 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-11-10 21:10:46 +0000 |
commit | b8d4481a93f919291d4b682ef0ac8948a9f1be32 (patch) | |
tree | 3505693e8a697635773fc54c9c7f1cc2aafaf6a1 /src/vnet/l2 | |
parent | e178399942c655d0fea162611527ea57192669c0 (diff) |
Break up vpe.api
- makes the VAPI generated file more consumable.
- VOM build times improve.
Change-Id: I838488930bd23a0d3818adfdffdbca3eead382df
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vnet/l2')
-rw-r--r-- | src/vnet/l2/l2.api | 100 | ||||
-rw-r--r-- | src/vnet/l2/l2_api.c | 178 |
2 files changed, 273 insertions, 5 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api index 404a47888d8..0ef71139331 100644 --- a/src/vnet/l2/l2.api +++ b/src/vnet/l2/l2.api @@ -380,6 +380,106 @@ autoreply define l2_interface_pbb_tag_rewrite u32 i_sid; }; +/** \brief L2 interface patch add / del request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param rx_sw_if_index - receive side interface + @param tx_sw_if_index - transmit side interface + @param is_add - if non-zero set up the interface patch, else remove it +*/ +autoreply define l2_patch_add_del +{ + u32 client_index; + u32 context; + u32 rx_sw_if_index; + u32 tx_sw_if_index; + u8 is_add; +}; + +/** \brief Set L2 XConnect between two interfaces request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param rx_sw_if_index - Receive interface index + @param tx_sw_if_index - Transmit interface index + @param enable - enable xconnect if not 0, else set to L3 mode +*/ +autoreply define sw_interface_set_l2_xconnect +{ + u32 client_index; + u32 context; + u32 rx_sw_if_index; + u32 tx_sw_if_index; + u8 enable; +}; + +/** \brief Interface bridge mode request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param rx_sw_if_index - the interface + @param bd_id - bridge domain id + @param bvi - Setup interface as a bvi, bridge mode only + @param shg - Shared horizon group, for bridge mode only + @param enable - Enable beige mode if not 0, else set to L3 mode +*/ +autoreply define sw_interface_set_l2_bridge +{ + u32 client_index; + u32 context; + u32 rx_sw_if_index; + u32 bd_id; + u8 shg; + u8 bvi; + u8 enable; +}; + +/** \brief Set bridge domain ip to mac entry request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param bd_id - the bridge domain to set the flags for + @param is_add - if non-zero, add the entry, else clear it + @param is_ipv6 - if non-zero, ipv6 address, else ipv4 address + @param mac_address - MAC address + @param +*/ +autoreply define bd_ip_mac_add_del +{ + u32 client_index; + u32 context; + u32 bd_id; + u8 is_add; + u8 is_ipv6; + u8 ip_address[16]; + u8 mac_address[6]; +}; + +/** \brief L2 interface ethernet flow point filtering enable/disable request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param sw_if_index - interface to enable/disable filtering on + @param enable_disable - if non-zero enable filtering, else disable +*/ +autoreply define l2_interface_efp_filter +{ + u32 client_index; + u32 context; + u32 sw_if_index; + u32 enable_disable; +}; + +/** \brief Interface set vpath request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param sw_if_index - interface used to reach neighbor + @param enable - if non-zero enable, else disable +*/ +autoreply define sw_interface_set_vpath +{ + u32 client_index; + u32 context; + u32 sw_if_index; + u8 enable; +}; + /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c index 8fd94b0e40a..f62bad14b00 100644 --- a/src/vnet/l2/l2_api.c +++ b/src/vnet/l2/l2_api.c @@ -58,12 +58,18 @@ _(L2FIB_FLUSH_BD, l2fib_flush_bd) \ _(L2FIB_ADD_DEL, l2fib_add_del) \ _(WANT_L2_MACS_EVENTS, want_l2_macs_events) \ _(L2_FLAGS, l2_flags) \ -_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \ -_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \ -_(BRIDGE_FLAGS, bridge_flags) \ +_(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \ +_(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \ +_(L2_PATCH_ADD_DEL, l2_patch_add_del) \ +_(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \ +_(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \ +_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \ +_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \ +_(BRIDGE_FLAGS, bridge_flags) \ _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \ -_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \ -_(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) +_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \ +_(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) \ +_(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) static void send_l2_xconnect_details (unix_shared_memory_queue_t * q, u32 context, @@ -628,6 +634,168 @@ static void REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY); } +static void + vl_api_sw_interface_set_l2_xconnect_t_handler + (vl_api_sw_interface_set_l2_xconnect_t * mp) +{ + vl_api_sw_interface_set_l2_xconnect_reply_t *rmp; + int rv = 0; + u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index); + u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index); + vlib_main_t *vm = vlib_get_main (); + vnet_main_t *vnm = vnet_get_main (); + + VALIDATE_RX_SW_IF_INDEX (mp); + + if (mp->enable) + { + VALIDATE_TX_SW_IF_INDEX (mp); + rv = set_int_l2_mode (vm, vnm, MODE_L2_XC, + rx_sw_if_index, 0, 0, 0, tx_sw_if_index); + } + else + { + rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0); + } + + BAD_RX_SW_IF_INDEX_LABEL; + BAD_TX_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY); +} + +static void + vl_api_sw_interface_set_l2_bridge_t_handler + (vl_api_sw_interface_set_l2_bridge_t * mp) +{ + bd_main_t *bdm = &bd_main; + vl_api_sw_interface_set_l2_bridge_reply_t *rmp; + int rv = 0; + vlib_main_t *vm = vlib_get_main (); + vnet_main_t *vnm = vnet_get_main (); + + VALIDATE_RX_SW_IF_INDEX (mp); + u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index); + + + if (mp->enable) + { + VALIDATE_BD_ID (mp); + u32 bd_id = ntohl (mp->bd_id); + u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id); + u32 bvi = mp->bvi; + u8 shg = mp->shg; + rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE, + rx_sw_if_index, bd_index, bvi, shg, 0); + } + else + { + rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0); + } + + BAD_RX_SW_IF_INDEX_LABEL; + BAD_BD_ID_LABEL; + + REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY); +} + +static void +vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp) +{ + bd_main_t *bdm = &bd_main; + vl_api_bd_ip_mac_add_del_reply_t *rmp; + int rv = 0; + u32 bd_id = ntohl (mp->bd_id); + u32 bd_index; + uword *p; + + if (bd_id == 0) + { + rv = VNET_API_ERROR_BD_NOT_MODIFIABLE; + goto out; + } + + p = hash_get (bdm->bd_index_by_bd_id, bd_id); + if (p == 0) + { + rv = VNET_API_ERROR_NO_SUCH_ENTRY; + goto out; + } + + bd_index = p[0]; + if (bd_add_del_ip_mac (bd_index, mp->ip_address, + mp->mac_address, mp->is_ipv6, mp->is_add)) + rv = VNET_API_ERROR_UNSPECIFIED; + +out: + REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY); +} + +extern void l2_efp_filter_configure (vnet_main_t * vnet_main, + u32 sw_if_index, u32 enable); + +static void +vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t * + mp) +{ + int rv; + vl_api_l2_interface_efp_filter_reply_t *rmp; + vnet_main_t *vnm = vnet_get_main (); + + // enable/disable the feature + l2_efp_filter_configure (vnm, mp->sw_if_index, mp->enable_disable); + rv = vnm->api_errno; + + REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY); +} + +static void +vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp) +{ + extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, + int is_add); + vl_api_l2_patch_add_del_reply_t *rmp; + int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, + int is_add); + int rv = 0; + + VALIDATE_RX_SW_IF_INDEX (mp); + VALIDATE_TX_SW_IF_INDEX (mp); + + rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index), + ntohl (mp->tx_sw_if_index), + (int) (mp->is_add != 0)); + + BAD_RX_SW_IF_INDEX_LABEL; + BAD_TX_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY); +} + +static void +vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp) +{ + vl_api_sw_interface_set_vpath_reply_t *rmp; + int rv = 0; + u32 sw_if_index = ntohl (mp->sw_if_index); + + VALIDATE_SW_IF_INDEX (mp); + + l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable); + vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4", + sw_if_index, mp->enable, 0, 0); + vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4", + sw_if_index, mp->enable, 0, 0); + vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6", + sw_if_index, mp->enable, 0, 0); + vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6", + sw_if_index, mp->enable, 0, 0); + + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY); +} + /* * l2_api_hookup * Add vpe's API message handlers to the table. |