diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-25 09:03:27 -0500 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-29 03:54:54 -0500 |
| commit | b28e0506fafd9c987bba7a6a71ea02a37fcabdea (patch) | |
| tree | d106164f315a92e8894454fdf93226bff5f53d3e /include/uapi/linux | |
| parent | b7392d2247cfe6771f95d256374f1a8e6a6f48d6 (diff) | |
virtio_ring: document alignment requirements
Host needs to know vring element alignment requirements:
simply doing alignof on structures doesn't work reliably: on some
platforms gcc has alignof(uint32_t) == 2.
Add macros for alignment as specified in virtio 1.0 cs01,
export them to userspace as well.
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/virtio_ring.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 61c818a7fe70..a3318f31e8e7 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h | |||
| @@ -101,6 +101,13 @@ struct vring { | |||
| 101 | struct vring_used *used; | 101 | struct vring_used *used; |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | /* Alignment requirements for vring elements. | ||
| 105 | * When using pre-virtio 1.0 layout, these fall out naturally. | ||
| 106 | */ | ||
| 107 | #define VRING_AVAIL_ALIGN_SIZE 2 | ||
| 108 | #define VRING_USED_ALIGN_SIZE 4 | ||
| 109 | #define VRING_DESC_ALIGN_SIZE 16 | ||
| 110 | |||
| 104 | /* The standard layout for the ring is a continuous chunk of memory which looks | 111 | /* The standard layout for the ring is a continuous chunk of memory which looks |
| 105 | * like this. We assume num is a power of 2. | 112 | * like this. We assume num is a power of 2. |
| 106 | * | 113 | * |
