virtio: refactor pci device code
[vpp.git] / src / vnet / devices / virtio / virtio.h
index 68462d8..e1ba71d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/virtio_net.h>
 #include <linux/virtio_pci.h>
 #include <linux/virtio_ring.h>
+#include <vnet/gso/gro.h>
 
 #define foreach_virtio_net_features      \
   _ (VIRTIO_NET_F_CSUM, 0)     /* Host handles pkts w/ partial csum */ \
@@ -69,9 +70,6 @@ typedef enum
 #undef _
 } virtio_if_flag_t;
 
-#define VIRTIO_NUM_RX_DESC 256
-#define VIRTIO_NUM_TX_DESC 256
-
 #define VIRTIO_FEATURE(X) (1ULL << X)
 
 #define TX_QUEUE(X) ((X*2) + 1)
@@ -79,6 +77,9 @@ typedef enum
 #define TX_QUEUE_ACCESS(X) (X/2)
 #define RX_QUEUE_ACCESS(X) (X/2)
 
+#define VIRTIO_NUM_RX_DESC 256
+#define VIRTIO_NUM_TX_DESC 256
+
 #define foreach_virtio_if_types \
   _ (TAP, 0)                    \
   _ (TUN, 1)                    \
@@ -92,15 +93,6 @@ typedef enum
     VIRTIO_IF_N_TYPES = (1 << 3),
 } virtio_if_type_t;
 
-
-typedef struct
-{
-  u8 mac[6];
-  u16 status;
-  u16 max_virtqueue_pairs;
-  u16 mtu;
-} virtio_net_config_t;
-
 #define VIRTIO_RING_FLAG_MASK_INT 1
 
 typedef struct
@@ -123,6 +115,7 @@ typedef struct
   u16 last_used_idx;
   u16 last_kick_avail_idx;
   u32 call_file_index;
+  gro_flow_table_t *flow_table;
 } virtio_vring_t;
 
 typedef union
@@ -137,6 +130,8 @@ typedef union
   u32 as_u32;
 } pci_addr_t;
 
+typedef struct _virtio_pci_func virtio_pci_func_t;
+
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
@@ -165,6 +160,7 @@ typedef struct
   u32 sw_if_index;
 
     CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
+  int packet_coalesce;
   union
   {
     u32 id;
@@ -179,6 +175,7 @@ typedef struct
   clib_error_t *error;
   u8 support_int_mode;         /* support interrupt mode */
   u16 max_queue_pairs;
+  u16 msix_table_size;
   u8 status;
   u8 mac_addr[6];
   u8 *host_if_name;
@@ -190,8 +187,10 @@ typedef struct
   ip6_address_t host_ip6_addr;
   u8 host_ip6_prefix_len;
   u32 host_mtu_size;
+  u32 tap_flags;
   int ifindex;
   virtio_vring_t *cxq_vring;
+  const virtio_pci_func_t *virtio_pci_func;
 } virtio_if_t;
 
 typedef struct
@@ -219,6 +218,7 @@ extern void virtio_free_rx_buffers (vlib_main_t * vm, virtio_vring_t * vring);
 extern void virtio_set_net_hdr_size (virtio_if_t * vif);
 extern void virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr,
                         u32 type);
+extern void virtio_set_packet_coalesce (virtio_if_t * vif);
 extern void virtio_pci_legacy_notify_queue (vlib_main_t * vm,
                                            virtio_if_t * vif, u16 queue_id);
 format_function_t format_virtio_device_name;
@@ -239,7 +239,6 @@ virtio_kick (vlib_main_t * vm, virtio_vring_t * vring, virtio_if_t * vif)
     }
 }
 
-
 #define virtio_log_debug(vif, f, ...)                          \
 {                                                              \
   vlib_log(VLIB_LOG_LEVEL_DEBUG, virtio_main.log_default,      \