vdpa/mlx5: map doorbell
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa.h
index 6282635..c591266 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef RTE_PMD_MLX5_VDPA_H_
 #define RTE_PMD_MLX5_VDPA_H_
 
+#include <linux/virtio_net.h>
 #include <sys/queue.h>
 
 #ifdef PEDANTIC
 #define MLX5_VDPA_INTR_RETRIES 256
 #define MLX5_VDPA_INTR_RETRIES_USEC 1000
 
+#ifndef VIRTIO_F_ORDER_PLATFORM
+#define VIRTIO_F_ORDER_PLATFORM 36
+#endif
+
+#ifndef VIRTIO_F_RING_PACKED
+#define VIRTIO_F_RING_PACKED 34
+#endif
+
 struct mlx5_vdpa_cq {
        uint16_t log_desc_n;
        uint32_t cq_ci:24;
@@ -59,6 +68,34 @@ struct mlx5_vdpa_query_mr {
        int is_indirect;
 };
 
+struct mlx5_vdpa_virtq {
+       SLIST_ENTRY(mlx5_vdpa_virtq) next;
+       uint8_t enable;
+       uint16_t index;
+       uint16_t vq_size;
+       struct mlx5_vdpa_priv *priv;
+       struct mlx5_devx_obj *virtq;
+       struct mlx5_vdpa_event_qp eqp;
+       struct {
+               struct mlx5dv_devx_umem *obj;
+               void *buf;
+               uint32_t size;
+       } umems[3];
+       struct rte_intr_handle intr_handle;
+};
+
+struct mlx5_vdpa_steer {
+       struct mlx5_devx_obj *rqt;
+       void *domain;
+       void *tbl;
+       struct {
+               struct mlx5dv_flow_matcher *matcher;
+               struct mlx5_devx_obj *tir;
+               void *tir_action;
+               void *flow;
+       } rss[7];
+};
+
 struct mlx5_vdpa_priv {
        TAILQ_ENTRY(mlx5_vdpa_priv) next;
        int id; /* vDPA device id. */
@@ -75,6 +112,15 @@ struct mlx5_vdpa_priv {
        struct mlx5dv_devx_event_channel *eventc;
        struct mlx5dv_devx_uar *uar;
        struct rte_intr_handle intr_handle;
+       struct mlx5_devx_obj *td;
+       struct mlx5_devx_obj *tis;
+       uint16_t nr_virtqs;
+       uint64_t features; /* Negotiated features. */
+       uint16_t log_max_rqt_size;
+       SLIST_HEAD(virtq_list, mlx5_vdpa_virtq) virtq_list;
+       struct mlx5_vdpa_steer steer;
+       struct mlx5dv_var *var;
+       void *virtq_db_addr;
        SLIST_HEAD(mr_list, mlx5_vdpa_query_mr) mr_list;
 };
 
@@ -152,4 +198,56 @@ int mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv);
  */
 void mlx5_vdpa_cqe_event_unset(struct mlx5_vdpa_priv *priv);
 
+/**
+ * Release a virtq and all its related resources.
+ *
+ * @param[in] priv
+ *   The vdpa driver private structure.
+ */
+void mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv);
+
+/**
+ * Create all the HW virtqs resources and all their related resources.
+ *
+ * @param[in] priv
+ *   The vdpa driver private structure.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int mlx5_vdpa_virtqs_prepare(struct mlx5_vdpa_priv *priv);
+
+/**
+ * Enable\Disable virtq..
+ *
+ * @param[in] virtq
+ *   The vdpa driver private virtq structure.
+ * @param[in] enable
+ *   Set to enable, otherwise disable.
+ *
+ * @return
+ *   0 on success, a negative value otherwise.
+ */
+int mlx5_vdpa_virtq_enable(struct mlx5_vdpa_virtq *virtq, int enable);
+
+/**
+ * Unset steering and release all its related resources- stop traffic.
+ *
+ * @param[in] priv
+ *   The vdpa driver private structure.
+ */
+int mlx5_vdpa_steer_unset(struct mlx5_vdpa_priv *priv);
+
+/**
+ * Setup steering and all its related resources to enable RSS traffic from the
+ * device to all the Rx host queues.
+ *
+ * @param[in] priv
+ *   The vdpa driver private structure.
+ *
+ * @return
+ *   0 on success, a negative value otherwise.
+ */
+int mlx5_vdpa_steer_setup(struct mlx5_vdpa_priv *priv);
+
 #endif /* RTE_PMD_MLX5_VDPA_H_ */