Add types and macros for packed ring.
Showing the changes to include/uapi/linux (2 of 2 files). Show all
Unified · Split
| @@ -75,6 +75,9 @@ · 74 unmodified lines | |||
| 75 | */ | 75 | */ |
| 76 | #define VIRTIO_F_IOMMU_PLATFORM 33 | 76 | #define VIRTIO_F_IOMMU_PLATFORM 33 |
| 77 | 77 | ||
| 78 | /* This feature indicates support for the packed virtqueue layout. */ | ||
| 79 | #define VIRTIO_F_RING_PACKED 34 | ||
| 80 | |||
| 78 | /* | 81 | /* |
| 79 | * Does the device support Single Root I/O Virtualization? | 82 | * Does the device support Single Root I/O Virtualization? |
| 80 | */ | 83 | */ |
| @@ -44,6 +44,13 @@ · 43 unmodified lines | |||
| 44 | /* This means the buffer contains a list of buffer descriptors. */ | 44 | /* This means the buffer contains a list of buffer descriptors. */ |
| 45 | #define VRING_DESC_F_INDIRECT 4 | 45 | #define VRING_DESC_F_INDIRECT 4 |
| 46 | 46 | ||
| 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 | |||
| 47 | /* The Host uses this in used->flags to advise the Guest: don't kick me when | 54 | /* The Host uses this in used->flags to advise the Guest: don't kick me when |
| 48 | * you add a buffer. It's unreliable, so it's simply an optimization. Guest | 55 | * you add a buffer. It's unreliable, so it's simply an optimization. Guest |
| 49 | * will still kick if it's out of buffers. */ | 56 | * will still kick if it's out of buffers. */ |
| @@ -53,6 +60,23 @@ · 3 unmodified lines | |||
| 53 | * optimization. */ | 60 | * optimization. */ |
| 54 | #define VRING_AVAIL_F_NO_INTERRUPT 1 | 61 | #define VRING_AVAIL_F_NO_INTERRUPT 1 |
| 55 | 62 | ||
| 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 | |||
| 56 | /* We support indirect buffer descriptors */ | 80 | /* We support indirect buffer descriptors */ |
| 57 | #define VIRTIO_RING_F_INDIRECT_DESC 28 | 81 | #define VIRTIO_RING_F_INDIRECT_DESC 28 |
| 58 | 82 | ||
| @@ -171,4 +195,32 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) · 112 unmodified lines | |||
| 171 | return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old); | 195 | return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old); |
| 172 | } | 196 | } |
| 173 | 197 | ||
| 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 | |||
| 174 | #endif /* _UAPI_LINUX_VIRTIO_RING_H */ | 226 | #endif /* _UAPI_LINUX_VIRTIO_RING_H */ |