From 6df98f70033813e7fbedf08b572869e9e0e6c9c2 Mon Sep 17 00:00:00 2001 From: rusty Date: Fri, 4 Oct 2013 02:49:00 +0000 Subject: Copy linear layout to CCW, MMIO sections. Revision r49 "virtqueue: flexible layout, size, alignment" moved the linear assumption into the legacy section. We also need it in the per-transport sections until (if?) those two transports go non-linear. Just copied the paragraph, with variable names changed to match the particular transport field nomenclature. Signed-off-by: Rusty Russell git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio@52 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- virtio-v1.0-wd01-part1-specification.txt | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt index 73e1e8b..b5a5835 100644 --- a/virtio-v1.0-wd01-part1-specification.txt +++ b/virtio-v1.0-wd01-part1-specification.txt @@ -1396,6 +1396,27 @@ Writing to registers described as “R” and reading from registers described as “W” is not permitted and can cause undefined behavior. +100.3.2.2.1. Virtqueue Layout +------------------------------ + +The virtqueue is physically contiguous, with padded added to make the +used ring meet the QueueAlign value: + ++-------------------+-----------------------------------+-----------+ +| Descriptor Table | Available Ring (padding) | Used Ring | ++-------------------+-----------------------------------+-----------+ + +The calculation for total size is as follows: + + #define ALIGN(x) (((x) + QueueAlign) & ~QueueAlign) + static inline unsigned vring_size(unsigned int QueueNum) + { + return ALIGN(sizeof(struct vring_desc)*QueueNum + + sizeof(u16)*(3 + QueueNum)) + + ALIGN(sizeof(u16)*3 + sizeof(struct vring_used_elem)*QueueNum); + } + + 2.3.2.3. MMIO-specific Initialization And Device Operation --------------------------------------------------------- @@ -1542,6 +1563,26 @@ queue contains the guest address for queue index. The actual number of allocated buffers is transmitted in num and their alignment in align. +100.3.3.2.1. Virtqueue Layout +------------------------------ + +The virtqueue is physically contiguous, with padded added to make the +used ring meet the align value: + ++-------------------+-----------------------------------+-----------+ +| Descriptor Table | Available Ring (padding) | Used Ring | ++-------------------+-----------------------------------+-----------+ + +The calculation for total size is as follows: + + #define ALIGN(x) (((x) + align) & ~align) + static inline unsigned vring_size(unsigned int num) + { + return ALIGN(sizeof(struct vring_desc)*num + + sizeof(u16)*(3 + num)) + + ALIGN(sizeof(u16)*3 + sizeof(struct vring_used_elem)*num); + } + 2.3.3.2.2. Communicating Status Information ------------------------------------------- -- cgit v1.2.3