History

virtio: add packed ring types and macros

Add types and macros for packed ring.

Tiwei Bie committed 7 years ago

Commit 89a91571 parent 4afe60a2 files · +55 −0Browse files

Showing the changes to include/uapi/linux (2 of 2 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/virtio_config.h +3 −0
  2. include/uapi/linux/virtio_ring.h +52 −0
include/uapi/linux/virtio_config.h+3−0
@@ -75,6 +75,9 @@ · 74 unmodified lines
7575 */
7676 #define VIRTIO_F_IOMMU_PLATFORM 33
7777
78+/* This feature indicates support for the packed virtqueue layout. */
79+#define VIRTIO_F_RING_PACKED 34
80+
7881 /*
7982 * Does the device support Single Root I/O Virtualization?
8083 */
include/uapi/linux/virtio_ring.h+52−0
@@ -44,6 +44,13 @@ · 43 unmodified lines
4444 /* This means the buffer contains a list of buffer descriptors. */
4545 #define VRING_DESC_F_INDIRECT 4
4646
47+/*
48+ * Mark a descriptor as available or used in packed ring.
49+ * Notice: they are defined as shifts instead of shifted values.
50+ */
51+#define VRING_PACKED_DESC_F_AVAIL 7
52+#define VRING_PACKED_DESC_F_USED 15
53+
4754 /* The Host uses this in used->flags to advise the Guest: don't kick me when
4855 * you add a buffer. It's unreliable, so it's simply an optimization. Guest
4956 * will still kick if it's out of buffers. */
@@ -53,6 +60,23 @@ · 3 unmodified lines
5360 * optimization. */
5461 #define VRING_AVAIL_F_NO_INTERRUPT 1
5562
63+/* Enable events in packed ring. */
64+#define VRING_PACKED_EVENT_FLAG_ENABLE 0x0
65+/* Disable events in packed ring. */
66+#define VRING_PACKED_EVENT_FLAG_DISABLE 0x1
67+/*
68+ * Enable events for a specific descriptor in packed ring.
69+ * (as specified by Descriptor Ring Change Event Offset/Wrap Counter).
70+ * Only valid if VIRTIO_RING_F_EVENT_IDX has been negotiated.
71+ */
72+#define VRING_PACKED_EVENT_FLAG_DESC 0x2
73+
74+/*
75+ * Wrap counter bit shift in event suppression structure
76+ * of packed ring.
77+ */
78+#define VRING_PACKED_EVENT_F_WRAP_CTR 15
79+
5680 /* We support indirect buffer descriptors */
5781 #define VIRTIO_RING_F_INDIRECT_DESC 28
5882
@@ -171,4 +195,32 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) · 112 unmodified lines
171195 return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
172196 }
173197
198+struct vring_packed_desc_event {
199+ /* Descriptor Ring Change Event Offset/Wrap Counter. */
200+ __le16 off_wrap;
201+ /* Descriptor Ring Change Event Flags. */
202+ __le16 flags;
203+};
204+
205+struct vring_packed_desc {
206+ /* Buffer Address. */
207+ __le64 addr;
208+ /* Buffer Length. */
209+ __le32 len;
210+ /* Buffer ID. */
211+ __le16 id;
212+ /* The flags depending on descriptor type. */
213+ __le16 flags;
214+};
215+
216+struct vring_packed {
217+ unsigned int num;
218+
219+ struct vring_packed_desc *desc;
220+
221+ struct vring_packed_desc_event *driver;
222+
223+ struct vring_packed_desc_event *device;
224+};
225+
174226 #endif /* _UAPI_LINUX_VIRTIO_RING_H */