X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Finterface.h;h=8424b71c54594ea628ec89c2c0275c317760a199;hb=7da8829d8;hp=71d6a775708225026624eb8905a6cd99cfcf7914;hpb=7d2094c12b01ac1f902755157361bd0eb547abac;p=vpp.git diff --git a/src/vnet/interface.h b/src/vnet/interface.h index 71d6a775708..8424b71c545 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -313,23 +313,24 @@ __VA_ARGS__ vnet_device_class_t x static __clib_unused vnet_device_class_t __clib_unused_##x #endif -#define VNET_DEVICE_CLASS_TX_FN(devclass) \ -uword CLIB_MARCH_SFX (devclass##_tx_fn)(); \ -static vlib_node_fn_registration_t \ - CLIB_MARCH_SFX(devclass##_tx_fn_registration) = \ - { .function = &CLIB_MARCH_SFX (devclass##_tx_fn), }; \ - \ -static void __clib_constructor \ -CLIB_MARCH_SFX (devclass##_tx_fn_multiarch_register) (void) \ -{ \ - extern vnet_device_class_t devclass; \ - vlib_node_fn_registration_t *r; \ - r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration); \ - r->priority = CLIB_MARCH_FN_PRIORITY(); \ - r->next_registration = devclass.tx_fn_registrations; \ - devclass.tx_fn_registrations = r; \ -} \ -uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn) +#define VNET_DEVICE_CLASS_TX_FN(devclass) \ + uword CLIB_MARCH_SFX (devclass##_tx_fn) (); \ + static vlib_node_fn_registration_t CLIB_MARCH_SFX ( \ + devclass##_tx_fn_registration) = { \ + .function = &CLIB_MARCH_SFX (devclass##_tx_fn), \ + }; \ + \ + static void __clib_constructor CLIB_MARCH_SFX ( \ + devclass##_tx_fn_multiarch_register) (void) \ + { \ + extern vnet_device_class_t devclass; \ + vlib_node_fn_registration_t *r; \ + r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration); \ + r->march_variant = CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE); \ + r->next_registration = devclass.tx_fn_registrations; \ + devclass.tx_fn_registrations = r; \ + } \ + uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn) /** * Link Type: A description of the protocol of packets on the link. @@ -364,11 +365,17 @@ typedef enum vnet_link_t_ _link <= VNET_LINK_NSH; \ _link++) +#define FOR_EACH_VNET_IP_LINK(_link) \ + for (_link = VNET_LINK_IP4; \ + _link <= VNET_LINK_IP6; \ + _link++) + /** - * @brief Number of link types. Not part of the enum so it does not have to be included in - * switch statements + * @brief Number of link types. Not part of the enum so it does not have to be + * included in switch statements */ #define VNET_LINK_NUM (VNET_LINK_NSH+1) +#define VNET_N_LINKS VNET_LINK_NUM /** * @brief Convert a link to to an Ethertype @@ -503,21 +510,64 @@ typedef enum vnet_hw_interface_flags_t_ VNET_HW_INTERFACE_FLAG_HALF_DUPLEX = (1 << 1), VNET_HW_INTERFACE_FLAG_FULL_DUPLEX = (1 << 2), - /* rx mode flags */ - VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE = (1 << 16), + /* non-broadcast multiple access */ + VNET_HW_INTERFACE_FLAG_NBMA = (1 << 19), +} vnet_hw_interface_flags_t; + +typedef enum vnet_hw_interface_capabilities_t_ +{ + VNET_HW_INTERFACE_CAP_NONE, /* tx checksum offload */ - VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD = (1 << 17), + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_CKSUM = (1 << 0), + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM = (1 << 1), + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM = (1 << 2), + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM = (1 << 3), + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM = (1 << 4), + + /* rx checksum offload */ + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_IP4_CKSUM = (1 << 5), + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM = (1 << 6), + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM = (1 << 7), + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_IP4_OUTER_CKSUM = (1 << 8), + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_OUTER_CKSUM = (1 << 9), /* gso */ - VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO = (1 << 18), + VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO = (1 << 10), + VNET_HW_INTERFACE_CAP_SUPPORTS_UDP_GSO = (1 << 11), + VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO = (1 << 12), + VNET_HW_INTERFACE_CAP_SUPPORTS_IPIP_TNL_GSO = (1 << 13), + VNET_HW_INTERFACE_CAP_SUPPORTS_GENEVE_TNL_GSO = (1 << 14), + VNET_HW_INTERFACE_CAP_SUPPORTS_GRE_TNL_GSO = (1 << 15), + VNET_HW_INTERFACE_CAP_SUPPORTS_UDP_TNL_GSO = (1 << 16), + VNET_HW_INTERFACE_CAP_SUPPORTS_IP_TNL_GSO = (1 << 17), + + /* lro */ + VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_LRO = (1 << 18), + + /* rx mode */ + VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE = (1 << 30), + /* hw/driver can switch between l2-promisc and l3-dmac-filter modes */ + VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER = (1 << 31), +} vnet_hw_interface_capabilities_t; - /* non-broadcast multiple access */ - VNET_HW_INTERFACE_FLAG_NBMA = (1 << 19), +#define VNET_HW_INTERFACE_CAP_SUPPORTS_L4_TX_CKSUM \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM) - /* hw/driver can switch between l2-promisc and l3-dmac-filter modes */ - VNET_HW_INTERFACE_FLAG_SUPPORTS_MAC_FILTER = (1 << 20), -} vnet_hw_interface_flags_t; +#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM) + +#define VNET_HW_INTERFACE_CAP_SUPPORTS_L4_RX_CKSUM \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM) + +#define VNET_HW_INTERFACE_CAP_SUPPORTS_RX_CKSUM \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_RX_IP4_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM) #define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1 #define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT 3 @@ -525,6 +575,29 @@ typedef enum vnet_hw_interface_flags_t_ (VNET_HW_INTERFACE_FLAG_HALF_DUPLEX | \ VNET_HW_INTERFACE_FLAG_FULL_DUPLEX) +typedef struct +{ + /* hw interface index */ + u32 hw_if_index; + + /* device instance */ + u32 dev_instance; + + /* index of thread pollling this queue */ + u32 thread_index; + + /* file index of queue interrupt line */ + u32 file_index; + + /* hardware queue identifier */ + u32 queue_id; + + /* mode */ + vnet_hw_if_rx_mode mode : 8; +#define VNET_HW_IF_RXQ_THREAD_ANY ~0 +#define VNET_HW_IF_RXQ_NO_RX_INTERRUPT ~0 +} vnet_hw_if_rx_queue_t; + /* Hardware-interface. This corresponds to a physical wire that packets flow over. */ typedef struct vnet_hw_interface_t @@ -536,6 +609,8 @@ typedef struct vnet_hw_interface_t /* flags */ vnet_hw_interface_flags_t flags; + /* capabilities flags */ + vnet_hw_interface_capabilities_t caps; /* link speed in kbps */ u32 link_speed; @@ -562,6 +637,8 @@ typedef struct vnet_hw_interface_t /* Software index for this hardware interface. */ u32 sw_if_index; + CLIB_CACHE_LINE_ALIGN_MARK (cacheline1); + /* Next index in interface-output node for this interface used by node function vnet_per_buffer_interface_output() */ u32 output_node_next_index; @@ -602,12 +679,10 @@ typedef struct vnet_hw_interface_t /* input node cpu index by queue */ u32 *input_node_thread_index_by_queue; - /* vnet_hw_if_rx_mode by queue */ - u8 *rx_mode_by_queue; vnet_hw_if_rx_mode default_rx_mode; - /* device input device_and_queue runtime index */ - uword *dq_runtime_index_by_queue; + /* rx queues */ + u32 *rx_queue_indices; /* numa node that hardware device connects to */ u8 numa_node; @@ -621,6 +696,21 @@ typedef struct vnet_hw_interface_t u32 trace_classify_table_index; } vnet_hw_interface_t; +STATIC_ASSERT_OFFSET_OF (vnet_hw_interface_t, cacheline1, + CLIB_CACHE_LINE_BYTES); + +typedef struct +{ + u32 dev_instance; + u32 queue_id; +} vnet_hw_if_rxq_poll_vector_t; + +typedef struct +{ + vnet_hw_if_rxq_poll_vector_t *rxq_poll_vector; + void *rxq_interrupts; +} vnet_hw_if_rx_node_runtime_t; + extern vnet_device_class_t vnet_local_interface_device_class; typedef enum @@ -857,6 +947,10 @@ typedef struct /* Hardware interfaces. */ vnet_hw_interface_t *hw_interfaces; + /* Hardware interface RX queues */ + vnet_hw_if_rx_queue_t *hw_if_rx_queues; + uword *rxq_index_by_hw_if_index_and_queue_id; + /* Hash table mapping HW interface name to index. */ uword *hw_interface_by_name; @@ -918,8 +1012,6 @@ void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add); int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance); -vlib_node_function_t *vnet_interface_output_node_get (void); - void vnet_register_format_buffer_opaque_helper (vnet_buffer_opquae_formatter_t fn); @@ -944,6 +1036,8 @@ typedef struct int vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t *); +extern vlib_node_registration_t vnet_interface_output_node; + #endif /* included_vnet_interface_h */ /*