devices: vhost not reading packets from vring
[vpp.git] / src / vnet / devices / virtio / vhost_user.h
index ff06695..7ebea93 100644 (file)
 #define VRING_USED_F_NO_NOTIFY  1
 #define VRING_AVAIL_F_NO_INTERRUPT 1
 
-#define DBG_SOCK(args...)                       \
-  {                                             \
-    vhost_user_main_t *_vum = &vhost_user_main; \
-    if (_vum->debug)                            \
-      clib_warning(args);                       \
-  };
-
-#define VHOST_DEBUG_VQ 0
-
-#if VHOST_DEBUG_VQ == 1
-#define DBG_VQ(args...) clib_warning(args);
-#else
-#define DBG_VQ(args...)
-#endif
+#define vu_log_debug(dev, f, ...) \
+{                                                                             \
+  vlib_log(VLIB_LOG_LEVEL_DEBUG, vhost_user_main.log_default, "%U: " f,       \
+          format_vnet_hw_if_index_name, vnet_get_main(),                     \
+          dev->hw_if_index, ##__VA_ARGS__);                                  \
+};
+
+#define vu_log_warn(dev, f, ...) \
+{                                                                             \
+  vlib_log(VLIB_LOG_LEVEL_WARNING, vhost_user_main.log_default, "%U: " f,     \
+          format_vnet_hw_if_index_name, vnet_get_main(),                     \
+          dev->hw_if_index, ##__VA_ARGS__);                                  \
+};
+#define vu_log_err(dev, f, ...) \
+{                                                                             \
+  vlib_log(VLIB_LOG_LEVEL_ERR, vhost_user_main.log_default, "%U: " f,         \
+          format_vnet_hw_if_index_name, vnet_get_main(),                     \
+          dev->hw_if_index, ##__VA_ARGS__);                                  \
+};
 
 #define UNIX_GET_FD(unixfd_idx) ({ \
     typeof(unixfd_idx) __unixfd_idx = (unixfd_idx); \
@@ -232,6 +237,9 @@ typedef struct
   vring_desc_t *desc;
   vring_avail_t *avail;
   vring_used_t *used;
+  uword desc_user_addr;
+  uword used_user_addr;
+  uword avail_user_addr;
   f64 int_deadline;
   u8 started;
   u8 enabled;
@@ -245,6 +253,14 @@ typedef struct
 
   /* The rx queue policy (interrupt/adaptive/polling) for this queue */
   u32 mode;
+
+  /*
+   * It contains the device queue number. -1 if it does not. The idea is
+   * to not invoke vnet_hw_interface_assign_rx_thread and
+   * vnet_hw_interface_unassign_rx_thread more than once for the duration of
+   * the interface even if it is disconnected and reconnected.
+   */
+  i16 qid;
 } vhost_user_vring_t;
 
 #define VHOST_USER_EVENT_START_TIMER 1
@@ -253,7 +269,7 @@ typedef struct
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-  u32 is_up;
+  u32 is_ready;
   u32 admin_up;
   u32 unix_server_index;
   u32 clib_file_index;
@@ -288,9 +304,6 @@ typedef struct
   /* Whether to use spinlock or per_cpu_tx_qid assignment */
   u8 use_tx_spinlock;
   u16 *per_cpu_tx_qid;
-
-  /* Vector of active rx queues for this interface */
-  u16 *rx_queues;
 } vhost_user_intf_t;
 
 typedef struct
@@ -345,8 +358,8 @@ typedef struct
   /* The number of rx interface/queue pairs in interrupt mode */
   u32 ifq_count;
 
-  /* debug on or off */
-  u8 debug;
+  /* logging */
+  vlib_log_class_t log_default;
 } vhost_user_main_t;
 
 typedef struct