vdpa/mlx5: support queue update
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa.h
index de4154b..57044d9 100644 (file)
 #define VIRTIO_F_RING_PACKED 34
 #endif
 
+#define MLX5_VDPA_DEFAULT_TIMER_DELAY_US 100u
+#define MLX5_VDPA_DEFAULT_TIMER_STEP_US 1u
+
 struct mlx5_vdpa_cq {
        uint16_t log_desc_n;
        uint32_t cq_ci:24;
        uint32_t arm_sn:2;
+       uint32_t armed:1;
        int callfd;
        rte_spinlock_t sl;
        struct mlx5_devx_obj *cq;
@@ -70,11 +74,18 @@ struct mlx5_vdpa_query_mr {
        int is_indirect;
 };
 
+enum {
+       MLX5_VDPA_NOTIFIER_STATE_DISABLED,
+       MLX5_VDPA_NOTIFIER_STATE_ENABLED,
+       MLX5_VDPA_NOTIFIER_STATE_ERR
+};
+
 struct mlx5_vdpa_virtq {
        SLIST_ENTRY(mlx5_vdpa_virtq) next;
        uint8_t enable;
        uint16_t index;
        uint16_t vq_size;
+       uint8_t notifier_state;
        struct mlx5_vdpa_priv *priv;
        struct mlx5_devx_obj *virtq;
        struct mlx5_devx_obj *counters;
@@ -100,10 +111,24 @@ struct mlx5_vdpa_steer {
        } rss[7];
 };
 
+enum {
+       MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER,
+       MLX5_VDPA_EVENT_MODE_FIXED_TIMER,
+       MLX5_VDPA_EVENT_MODE_ONLY_INTERRUPT
+};
+
 struct mlx5_vdpa_priv {
        TAILQ_ENTRY(mlx5_vdpa_priv) next;
        uint8_t configured;
-       uint8_t direct_notifier; /* Whether direct notifier is on or off. */
+       uint64_t last_traffic_tic;
+       pthread_t timer_tid;
+       pthread_mutex_t timer_lock;
+       pthread_cond_t timer_cond;
+       volatile uint8_t timer_on;
+       int event_mode;
+       uint32_t event_us;
+       uint32_t timer_delay_us;
+       uint32_t no_traffic_time_s;
        struct rte_vdpa_device *vdev; /* vDPA device. */
        int vid; /* vhost device id. */
        struct ibv_context *ctx; /* Device context. */