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