interface: add multi tx-queues support for new tx infra
[vpp.git] / src / vnet / interface.h
index 0ffaffe..822d4c3 100644 (file)
@@ -44,6 +44,7 @@
 #include <vppinfra/pcap.h>
 #include <vnet/l3_types.h>
 #include <vppinfra/lock.h>
+#include <vnet/hash/hash.h>
 
 struct vnet_main_t;
 struct vnet_hw_interface_t;
@@ -410,6 +411,9 @@ typedef struct _vnet_hw_interface_class
   /* Flags */
   vnet_hw_interface_class_flags_t flags;
 
+  /* tx hash type for interfaces of this hw class */
+  vnet_hash_fn_type_t tx_hash_fn_type;
+
   /* Function to call when hardware interface is added/deleted. */
   vnet_interface_function_t *interface_add_del_function;
 
@@ -561,6 +565,14 @@ typedef enum vnet_hw_interface_capabilities_t_
    VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM |                              \
    VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM)
 
+#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_OUTER_CKSUM                         \
+  (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM |                        \
+   VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM)
+
+#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM_MASK                          \
+  (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM |                                  \
+   VNET_HW_INTERFACE_CAP_SUPPORTS_TX_OUTER_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)
@@ -570,6 +582,10 @@ typedef enum vnet_hw_interface_capabilities_t_
    VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM |                              \
    VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM)
 
+#define VNET_HW_INTERFACE_CAP_SUPPORTS_TNL_GSO_MASK                           \
+  VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO |                              \
+    VNET_HW_INTERFACE_CAP_SUPPORTS_IPIP_TNL_GSO
+
 #define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1
 #define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT  3
 #define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK     \
@@ -599,6 +615,41 @@ typedef struct
 #define VNET_HW_IF_RXQ_NO_RX_INTERRUPT ~0
 } vnet_hw_if_rx_queue_t;
 
+typedef struct
+{
+  u8 shared_queue : 1;
+  /* hw interface index */
+  u32 hw_if_index;
+
+  /* hardware queue identifier */
+  u32 queue_id;
+
+  /* bitmap of threads which use this queue */
+  clib_bitmap_t *threads;
+} vnet_hw_if_tx_queue_t;
+
+typedef enum
+{
+  VNET_HW_IF_TX_FRAME_HINT_NOT_CHAINED = (1 << 0),
+  VNET_HW_IF_TX_FRAME_HINT_NO_GSO = (1 << 1),
+  VNET_HW_IF_TX_FRAME_HINT_NO_CKSUM_OFFLOAD = (1 << 2),
+} vnet_hw_if_tx_frame_hint_t;
+
+typedef struct
+{
+  u8 shared_queue : 1;
+  vnet_hw_if_tx_frame_hint_t hints : 16;
+  u32 queue_id;
+} vnet_hw_if_tx_frame_t;
+
+typedef struct
+{
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+  vnet_hw_if_tx_frame_t *frame;
+  u32 *lookup_table;
+  u32 n_queues;
+} vnet_hw_if_output_node_runtime_t;
+
 /* Hardware-interface.  This corresponds to a physical wire
    that packets flow over. */
 typedef struct vnet_hw_interface_t
@@ -635,6 +686,9 @@ typedef struct vnet_hw_interface_t
   /* Software index for this hardware interface. */
   u32 sw_if_index;
 
+  /* per thread output-node runtimes */
+  vnet_hw_if_output_node_runtime_t *output_node_thread_runtimes;
+
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
 
   /* Interface name. */
@@ -647,6 +701,9 @@ typedef struct vnet_hw_interface_t
      used by node function vnet_per_buffer_interface_output() */
   u32 output_node_next_index;
 
+  /* called when hw interface is using transmit side packet steering */
+  vnet_hash_fn_t hf;
+
   /* Maximum transmit rate for this interface in bits/sec. */
   f64 max_rate_bits_per_sec;
 
@@ -680,14 +737,14 @@ typedef struct vnet_hw_interface_t
   /* Input node */
   u32 input_node_index;
 
-  /* input node cpu index by queue */
-  u32 *input_node_thread_index_by_queue;
-
   vnet_hw_if_rx_mode default_rx_mode;
 
   /* rx queues */
   u32 *rx_queue_indices;
 
+  /* tx queues */
+  u32 *tx_queue_indices;
+
   /* numa node that hardware device connects to */
   u8 numa_node;
 
@@ -711,7 +768,8 @@ typedef struct
 
 typedef struct
 {
-  vnet_hw_if_rxq_poll_vector_t *rxq_poll_vector;
+  vnet_hw_if_rxq_poll_vector_t *rxq_vector_int;
+  vnet_hw_if_rxq_poll_vector_t *rxq_vector_poll;
   void *rxq_interrupts;
 } vnet_hw_if_rx_node_runtime_t;
 
@@ -955,6 +1013,10 @@ typedef struct
   vnet_hw_if_rx_queue_t *hw_if_rx_queues;
   uword *rxq_index_by_hw_if_index_and_queue_id;
 
+  /* Hardware interface TX queues */
+  vnet_hw_if_tx_queue_t *hw_if_tx_queues;
+  uword *txq_index_by_hw_if_index_and_queue_id;
+
   /* Hash table mapping HW interface name to index. */
   uword *hw_interface_by_name;