net/ngbe: support MTU set
[dpdk.git] / lib / vhost / vhost.h
index f628714..05ccc35 100644 (file)
 #include "rte_vhost_async.h"
 
 /* Used to indicate that the device is running on a data core */
-#define VIRTIO_DEV_RUNNING 1
+#define VIRTIO_DEV_RUNNING ((uint32_t)1 << 0)
 /* Used to indicate that the device is ready to operate */
-#define VIRTIO_DEV_READY 2
+#define VIRTIO_DEV_READY ((uint32_t)1 << 1)
 /* Used to indicate that the built-in vhost net device backend is enabled */
-#define VIRTIO_DEV_BUILTIN_VIRTIO_NET 4
+#define VIRTIO_DEV_BUILTIN_VIRTIO_NET ((uint32_t)1 << 2)
 /* Used to indicate that the device has its own data path and configured */
-#define VIRTIO_DEV_VDPA_CONFIGURED 8
+#define VIRTIO_DEV_VDPA_CONFIGURED ((uint32_t)1 << 3)
 /* Used to indicate that the feature negotiation failed */
-#define VIRTIO_DEV_FEATURES_FAILED 16
+#define VIRTIO_DEV_FEATURES_FAILED ((uint32_t)1 << 4)
+/* Used to indicate that the virtio_net tx code should fill TX ol_flags */
+#define VIRTIO_DEV_LEGACY_OL_FLAGS ((uint32_t)1 << 5)
 
 /* Backend value set by guest. */
 #define VIRTIO_DEV_STOPPED -1
@@ -46,8 +48,8 @@
 
 #define MAX_PKT_BURST 32
 
-#define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2)
-#define VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 4)
+#define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST)
+#define VHOST_MAX_ASYNC_VEC 2048
 
 #define PACKED_DESC_ENQUEUE_USED_FLAG(w)       \
        ((w) ? (VRING_DESC_F_AVAIL | VRING_DESC_F_USED | VRING_DESC_F_WRITE) : \
@@ -117,6 +119,42 @@ struct vring_used_elem_packed {
        uint32_t count;
 };
 
+/**
+ * inflight async packet information
+ */
+struct async_inflight_info {
+       struct rte_mbuf *mbuf;
+       uint16_t descs; /* num of descs inflight */
+       uint16_t nr_buffers; /* num of buffers inflight for packed ring */
+};
+
+struct vhost_async {
+       /* operation callbacks for DMA */
+       struct rte_vhost_async_channel_ops ops;
+
+       struct rte_vhost_iov_iter iov_iter[VHOST_MAX_ASYNC_IT];
+       struct rte_vhost_iovec iovec[VHOST_MAX_ASYNC_VEC];
+       uint16_t iter_idx;
+       uint16_t iovec_idx;
+
+       /* data transfer status */
+       struct async_inflight_info *pkts_info;
+       uint16_t pkts_idx;
+       uint16_t pkts_inflight_n;
+       union {
+               struct vring_used_elem  *descs_split;
+               struct vring_used_elem_packed *buffers_packed;
+       };
+       union {
+               uint16_t desc_idx_split;
+               uint16_t buffer_idx_packed;
+       };
+       union {
+               uint16_t last_desc_idx_split;
+               uint16_t last_buffer_idx_packed;
+       };
+};
+
 /**
  * Structure contains variables relevant to RX/TX virtqueues.
  */
@@ -162,6 +200,7 @@ struct vhost_virtqueue {
 
        uint16_t                batch_copy_nb_elems;
        struct batch_copy_elem  *batch_copy_elems;
+       int                     numa_node;
        bool                    used_wrap_counter;
        bool                    avail_wrap_counter;
 
@@ -190,25 +229,7 @@ struct vhost_virtqueue {
        struct rte_vhost_resubmit_info *resubmit_inflight;
        uint64_t                global_counter;
 
-       /* operation callbacks for async dma */
-       struct rte_vhost_async_channel_ops      async_ops;
-
-       struct rte_vhost_iov_iter *it_pool;
-       struct iovec *vec_pool;
-
-       /* async data transfer status */
-       struct async_inflight_info *async_pkts_info;
-       uint16_t        async_pkts_idx;
-       uint16_t        async_pkts_inflight_n;
-       uint16_t        async_last_pkts_n;
-       struct vring_used_elem  *async_descs_split;
-       uint16_t async_desc_idx;
-       uint16_t last_async_desc_idx;
-
-       /* vq async features */
-       bool            async_inorder;
-       bool            async_registered;
-       uint16_t        async_threshold;
+       struct vhost_async      *async;
 
        int                     notif_enable;
 #define VIRTIO_UNINITIALIZED_NOTIF     (-1)
@@ -359,6 +380,7 @@ struct virtio_net {
        int16_t                 broadcast_rarp;
        uint32_t                nr_vring;
        int                     async_copy;
+
        int                     extbuf;
        int                     linearbuf;
        struct vhost_virtqueue  *virtqueue[VHOST_MAX_QUEUE_PAIRS * 2];
@@ -674,7 +696,7 @@ int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
 void vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *dev);
 
 void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
-void vhost_set_builtin_virtio_net(int vid, bool enable);
+void vhost_setup_virtio_net(int vid, bool enable, bool legacy_ol_flags);
 void vhost_enable_extbuf(int vid);
 void vhost_enable_linearbuf(int vid);
 int vhost_enable_guest_notification(struct virtio_net *dev,