X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Finterface_funcs.h;h=42b69bdf789021b5c79934e044c4824269e5d7dd;hb=70083ee74c3141bbefb185525315f1b34497dcaa;hp=ab808dfa5450dfbad83a1914bde4482e51d5b496;hpb=75152289284aaf1116d62c6cdef5a3b0c793fa15;p=vpp.git diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h index ab808dfa545..42b69bdf789 100644 --- a/src/vnet/interface_funcs.h +++ b/src/vnet/interface_funcs.h @@ -73,7 +73,8 @@ always_inline vnet_sw_interface_t * vnet_get_sup_sw_interface (vnet_main_t * vnm, u32 sw_if_index) { vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index); - if (sw->type == VNET_SW_INTERFACE_TYPE_SUB) + if (sw->type == VNET_SW_INTERFACE_TYPE_SUB || + sw->type == VNET_SW_INTERFACE_TYPE_P2P) sw = vnet_get_sw_interface (vnm, sw->sup_sw_if_index); return sw; } @@ -86,6 +87,15 @@ vnet_get_sup_hw_interface (vnet_main_t * vnm, u32 sw_if_index) return vnet_get_hw_interface (vnm, sw->hw_if_index); } +always_inline vnet_hw_interface_t * +vnet_get_sw_hw_interface (vnet_main_t * vnm, u32 sw_if_index) +{ + vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index); + if (sw->type == VNET_SW_INTERFACE_TYPE_HARDWARE) + return vnet_get_hw_interface (vnm, sw->hw_if_index); + return vnet_get_sup_hw_interface (vnm, sw_if_index); +} + always_inline vnet_hw_interface_class_t * vnet_get_hw_interface_class (vnet_main_t * vnm, u32 hw_class_index) { @@ -159,6 +169,14 @@ u32 vnet_register_interface (vnet_main_t * vnm, u32 dev_instance, u32 hw_class_index, u32 hw_instance); +/** + * Set interface output node - for interface registered without its output/tx + * nodes created because its VNET_DEVICE_CLASS did not specify any tx_function. + * This is typically the case for tunnel interfaces. + */ +void vnet_set_interface_output_node (vnet_main_t * vnm, + u32 hw_if_index, u32 node_index); + /* Creates a software interface given template. */ clib_error_t *vnet_create_sw_interface (vnet_main_t * vnm, vnet_sw_interface_t * template, @@ -183,26 +201,38 @@ vnet_sw_interface_is_admin_up (vnet_main_t * vnm, u32 sw_if_index) } always_inline uword -vnet_hw_interface_get_flags (vnet_main_t * vnm, u32 hw_if_index) +vnet_swif_is_api_visible (vnet_sw_interface_t * si) { - vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); - return hw->flags; + return !(si->flags & VNET_SW_INTERFACE_FLAG_HIDDEN); } always_inline uword -vnet_hw_interface_get_mtu (vnet_main_t * vnm, u32 hw_if_index, - vlib_rx_or_tx_t dir) +vnet_sw_interface_is_api_visible (vnet_main_t * vnm, u32 sw_if_index) +{ + vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index); + return vnet_swif_is_api_visible (si); +} + +always_inline uword +vnet_sw_interface_is_api_valid (vnet_main_t * vnm, u32 sw_if_index) +{ + return !pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index) + && vnet_sw_interface_is_api_visible (vnm, sw_if_index); +} + +always_inline uword +vnet_hw_interface_get_flags (vnet_main_t * vnm, u32 hw_if_index) { vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); - return hw->max_l3_packet_bytes[dir]; + return hw->flags; } always_inline uword vnet_sw_interface_get_mtu (vnet_main_t * vnm, u32 sw_if_index, vlib_rx_or_tx_t dir) { - vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); - return (hw->max_l3_packet_bytes[dir]); + vnet_sw_interface_t *sw = vnet_get_sw_interface (vnm, sw_if_index); + return (sw->max_l3_packet_bytes[dir]); } always_inline uword @@ -216,7 +246,7 @@ always_inline vlib_frame_t * vnet_get_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index) { vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); - return vlib_get_frame_to_node (vnm->vlib_main, hw->output_node_index); + return vlib_get_frame_to_node (vlib_get_main (), hw->output_node_index); } always_inline void @@ -224,7 +254,7 @@ vnet_put_frame_to_sw_interface (vnet_main_t * vnm, u32 sw_if_index, vlib_frame_t * f) { vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); - return vlib_put_frame_to_node (vnm->vlib_main, hw->output_node_index, f); + return vlib_put_frame_to_node (vlib_get_main (), hw->output_node_index, f); } /* Change interface flags (e.g. up, down, enable, disable). */ @@ -253,10 +283,29 @@ clib_error_t *vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index, /* Change interface mac address*/ clib_error_t *vnet_hw_interface_change_mac_address (vnet_main_t * vnm, u32 hw_if_index, - u64 mac_address); + u8 * mac_address); + +/* Change rx-mode */ +clib_error_t *set_hw_interface_change_rx_mode (vnet_main_t * vnm, + u32 hw_if_index, + u8 queue_id_valid, + u32 queue_id, + vnet_hw_interface_rx_mode + mode); + +/* Set the MTU on the SW interface */ +int vnet_sw_interface_set_mtu (vnet_main_t * vnm, u32 sw_if_index, u32 mtu); + +/* update the unnumbered state of an interface */ +void vnet_sw_interface_update_unnumbered (u32 sw_if_index, + u32 ip_sw_if_index, u8 enable); + +int vnet_sw_interface_stats_collect_enable_disable (u32 sw_if_index, + u8 enable); /* Formats sw/hw interface. */ format_function_t format_vnet_hw_interface; +format_function_t format_vnet_hw_interface_rx_mode; format_function_t format_vnet_sw_interface; format_function_t format_vnet_sw_interface_name; format_function_t format_vnet_sw_interface_name_override; @@ -280,9 +329,8 @@ typedef struct u32 is_deleted; } vnet_interface_output_runtime_t; -/* Interface output functions. */ +/* Interface output function. */ void *vnet_interface_output_node_multiarch_select (void); -void *vnet_interface_output_node_flatten_multiarch_select (void); word vnet_sw_interface_compare (vnet_main_t * vnm, uword sw_if_index0, uword sw_if_index1);