Blame SOURCES/0001-net-virtio-add-packed-virtqueue-defines.patch

2c1bf6
From 93f21370ca38ae61dc2d938adf569f6668381c32 Mon Sep 17 00:00:00 2001
2c1bf6
From: Jens Freimann <jfreimann@redhat.com>
2c1bf6
Date: Mon, 17 Dec 2018 22:31:30 +0100
2c1bf6
Subject: [PATCH 01/18] net/virtio: add packed virtqueue defines
2c1bf6
2c1bf6
[ upstream commit 4c3f5822eb21476fbbd807a7c40584c1090695e5 ]
2c1bf6
2c1bf6
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
2c1bf6
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2c1bf6
(cherry picked from commit 4c3f5822eb21476fbbd807a7c40584c1090695e5)
2c1bf6
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
2c1bf6
---
2c1bf6
 drivers/net/virtio/virtio_pci.h  |  1 +
2c1bf6
 drivers/net/virtio/virtio_ring.h | 30 ++++++++++++++++++++++++++++++
2c1bf6
 drivers/net/virtio/virtqueue.h   |  6 ++++++
2c1bf6
 3 files changed, 37 insertions(+)
2c1bf6
2c1bf6
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
2c1bf6
index e961a58ca..4c975a531 100644
2c1bf6
--- a/drivers/net/virtio/virtio_pci.h
2c1bf6
+++ b/drivers/net/virtio/virtio_pci.h
2c1bf6
@@ -113,6 +113,7 @@ struct virtnet_ctl;
2c1bf6
 
2c1bf6
 #define VIRTIO_F_VERSION_1		32
2c1bf6
 #define VIRTIO_F_IOMMU_PLATFORM	33
2c1bf6
+#define VIRTIO_F_RING_PACKED		34
2c1bf6
 
2c1bf6
 /*
2c1bf6
  * Some VirtIO feature bits (currently bits 28 through 31) are
2c1bf6
diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h
2c1bf6
index 9e3c2a015..464449074 100644
2c1bf6
--- a/drivers/net/virtio/virtio_ring.h
2c1bf6
+++ b/drivers/net/virtio/virtio_ring.h
2c1bf6
@@ -15,6 +15,10 @@
2c1bf6
 #define VRING_DESC_F_WRITE      2
2c1bf6
 /* This means the buffer contains a list of buffer descriptors. */
2c1bf6
 #define VRING_DESC_F_INDIRECT   4
2c1bf6
+/* This flag means the descriptor was made available by the driver */
2c1bf6
+#define VRING_DESC_F_AVAIL(b)   ((uint16_t)(b) << 7)
2c1bf6
+/* This flag means the descriptor was used by the device */
2c1bf6
+#define VRING_DESC_F_USED(b)    ((uint16_t)(b) << 15)
2c1bf6
 
2c1bf6
 /* The Host uses this in used->flags to advise the Guest: don't kick me
2c1bf6
  * when you add a buffer.  It's unreliable, so it's simply an
2c1bf6
@@ -54,6 +58,32 @@ struct vring_used {
2c1bf6
 	struct vring_used_elem ring[0];
2c1bf6
 };
2c1bf6
 
2c1bf6
+/* For support of packed virtqueues in Virtio 1.1 the format of descriptors
2c1bf6
+ * looks like this.
2c1bf6
+ */
2c1bf6
+struct vring_packed_desc {
2c1bf6
+	uint64_t addr;
2c1bf6
+	uint32_t len;
2c1bf6
+	uint16_t id;
2c1bf6
+	uint16_t flags;
2c1bf6
+};
2c1bf6
+
2c1bf6
+#define RING_EVENT_FLAGS_ENABLE 0x0
2c1bf6
+#define RING_EVENT_FLAGS_DISABLE 0x1
2c1bf6
+#define RING_EVENT_FLAGS_DESC 0x2
2c1bf6
+struct vring_packed_desc_event {
2c1bf6
+	uint16_t desc_event_off_wrap;
2c1bf6
+	uint16_t desc_event_flags;
2c1bf6
+};
2c1bf6
+
2c1bf6
+struct vring_packed {
2c1bf6
+	unsigned int num;
2c1bf6
+	struct vring_packed_desc *desc_packed;
2c1bf6
+	struct vring_packed_desc_event *driver_event;
2c1bf6
+	struct vring_packed_desc_event *device_event;
2c1bf6
+
2c1bf6
+};
2c1bf6
+
2c1bf6
 struct vring {
2c1bf6
 	unsigned int num;
2c1bf6
 	struct vring_desc  *desc;
2c1bf6
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
2c1bf6
index 2e2abf15b..1525c7d10 100644
2c1bf6
--- a/drivers/net/virtio/virtqueue.h
2c1bf6
+++ b/drivers/net/virtio/virtqueue.h
2c1bf6
@@ -161,11 +161,17 @@ struct virtio_pmd_ctrl {
2c1bf6
 struct vq_desc_extra {
2c1bf6
 	void *cookie;
2c1bf6
 	uint16_t ndescs;
2c1bf6
+	uint16_t next;
2c1bf6
 };
2c1bf6
 
2c1bf6
 struct virtqueue {
2c1bf6
 	struct virtio_hw  *hw; /**< virtio_hw structure pointer. */
2c1bf6
 	struct vring vq_ring;  /**< vring keeping desc, used and avail */
2c1bf6
+	struct vring_packed ring_packed;  /**< vring keeping descs */
2c1bf6
+	bool avail_wrap_counter;
2c1bf6
+	bool used_wrap_counter;
2c1bf6
+	uint16_t event_flags_shadow;
2c1bf6
+	uint16_t avail_used_flags;
2c1bf6
 	/**
2c1bf6
 	 * Last consumed descriptor in the used table,
2c1bf6
 	 * trails vq_ring.used->idx.
2c1bf6
-- 
2c1bf6
2.21.0
2c1bf6