Avoid atomic ops when polling queues
[vpp.git] / src / vnet / devices / virtio / vhost-user.h
index dd23a90..105b92b 100644 (file)
@@ -23,6 +23,7 @@
 #define VHOST_VRING_IDX_RX(qid)         (2*qid)
 #define VHOST_VRING_IDX_TX(qid)         (2*qid + 1)
 
+#define VHOST_USER_VRING_NOFD_MASK      0x100
 #define VIRTQ_DESC_F_NEXT               1
 #define VIRTQ_DESC_F_INDIRECT           4
 #define VHOST_USER_REPLY_MASK       (0x1 << 2)
@@ -42,6 +43,7 @@
 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
 
 #define VRING_USED_F_NO_NOTIFY  1
+#define VRING_AVAIL_F_NO_INTERRUPT 1
 
 #define foreach_virtio_net_feature      \
  _ (VIRTIO_NET_F_MRG_RXBUF, 15)         \
@@ -190,7 +192,7 @@ typedef struct vhost_user_msg {
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-  u16 qsz;
+  u16 qsz_mask;
   u16 last_avail_idx;
   u16 last_used_idx;
   u16 n_since_last_int;
@@ -207,17 +209,24 @@ typedef struct
   u32 callfd_idx;
   u32 kickfd_idx;
   u64 log_guest_addr;
+
+  /* The rx queue policy (interrupt/adaptive/polling) for this queue */
+  u32 mode;
 } vhost_user_vring_t;
 
+#define VHOST_USER_EVENT_START_TIMER 1
+#define VHOST_USER_EVENT_STOP_TIMER  2
+
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   u32 is_up;
   u32 admin_up;
   u32 unix_server_index;
-  u32 unix_file_index;
+  u32 clib_file_index;
   char sock_filename[256];
   int sock_errno;
+  uword if_index;
   u32 hw_if_index, sw_if_index;
 
   //Feature negotiation
@@ -247,16 +256,10 @@ typedef struct
   u8 use_tx_spinlock;
   u16 *per_cpu_tx_qid;
 
-  /* Vector of workers for this interface */
-  u32 *workers;
+  /* Vector of active rx queues for this interface */
+  u16 *rx_queues;
 } vhost_user_intf_t;
 
-typedef struct
-{
-  u16 vhost_iface_index;
-  u16 qid;
-} vhost_iface_and_queue_t;
-
 typedef struct
 {
   uword dst;
@@ -279,7 +282,6 @@ typedef struct
 
 typedef struct
 {
-  vhost_iface_and_queue_t *rx_queues;
   u32 rx_buffers_len;
   u32 rx_buffers[VHOST_USER_RX_BUFFERS_N];
 
@@ -293,6 +295,7 @@ typedef struct
 
 typedef struct
 {
+  mhash_t if_index_by_sock_name;
   u32 mtu_bytes;
   vhost_user_intf_t *vhost_user_interfaces;
   u32 *show_dev_instance_by_real_dev_instance;
@@ -300,17 +303,17 @@ typedef struct
   f64 coalesce_time;
   int dont_dump_vhost_user_memory;
 
-  /** first cpu index */
-  u32 input_cpu_first_index;
-
-  /** total cpu count */
-  u32 input_cpu_count;
-
   /** Per-CPU data for vhost-user */
   vhost_cpu_t *cpus;
 
   /** Pseudo random iterator */
   u32 random;
+
+  /* The number of rx interface/queue pairs in interrupt mode */
+  u32 ifq_count;
+
+  /* debug on or off */
+  u8 debug;
 } vhost_user_main_t;
 
 typedef struct