OASIS Virtual I/O Device (VIRTIO) TC

  • 1.  [PATCH] mmio: split desc/avail/used/enable

    Posted 09-15-2013 13:11
    This is similar to what I proposed for PCI:
    - deprecate QueuePFN and move it to legacy interface
    section
    - Add 64-bit QueueDesc QueueAvail QueueUsed
    - Add explicit QueueEnable

    Needed to resolve issues
    https://tools.oasis-open.org/issues/browse/VIRTIO-23
    https://tools.oasis-open.org/issues/browse/VIRTIO-32

    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    ---
    virtio-v1.0-wd01-part1-specification.txt | 136 ++++++++++++++++++++++++-------
    1 file changed, 106 insertions(+), 30 deletions(-)

    diff --git a/virtio-v1.0-wd01-part1-specification.txt b/virtio-v1.0-wd01-part1-specification.txt
    index 645bfbc..154ab3e 100644
    --- a/virtio-v1.0-wd01-part1-specification.txt
    +++ b/virtio-v1.0-wd01-part1-specification.txt
    @@ -1353,17 +1353,10 @@ configuration space. The following list presents their layout:
    Device driver must write a value to the GuestFeaturesSel
    register before writing to the GuestFeatures register.

    -• 0x028 | W | GuestPageSize
    - Guest page size.
    - Device driver must write the guest page size in bytes to the
    - register during initialization, before any queues are used.
    - This value must be a power of 2 and is used by the Host to
    - calculate Guest address of the first queue page (see QueuePFN).
    -
    • 0x030 | W | QueueSel
    Virtual queue index (first queue is 0).
    Writing to this register selects the virtual queue that the
    - following operations on QueueNum, QueueAlign and QueuePFN apply
    + following operations on other queue-specific registers apply
    to.

    • 0x034 | R | QueueNumMax
    @@ -1371,8 +1364,7 @@ configuration space. The following list presents their layout:
    Reading from the register returns the maximum size of the queue
    the Host is ready to process or zero (0x0) if the queue is not
    available. This applies to the queue selected by writing to
    - QueueSel and is allowed only when QueuePFN is set to zero
    - (0x0), so when the queue is not actively used.
    + QueueSel and is allowed only when queue is not enabled.

    • 0x038 | W | QueueNum
    Virtual queue size.
    @@ -1382,23 +1374,13 @@ configuration space. The following list presents their layout:
    queue the Guest will use. This applies to the queue selected by
    writing to QueueSel.

    -• 0x03c | W | QueueAlign
    - Used Ring alignment in the virtual queue.
    - Writing to this register notifies the Host about alignment
    - boundary of the Used Ring in bytes. This value must be a power
    - of 2 and applies to the queue selected by writing to QueueSel.
    -
    -• 0x040 | RW | QueuePFN
    - Guest physical page number of the virtual queue.
    - Writing to this register notifies the host about location of the
    - virtual queue in the Guest's physical address space. This value
    - is the index number of a page starting with the queue
    - Descriptor Table. Value zero (0x0) means physical address zero
    - (0x00000000) and is illegal. When the Guest stops using the
    - queue it must write zero (0x0) to this register.
    - Reading from this register returns the currently used page
    - number of the queue, therefore a value other than zero (0x0)
    - means that the queue is in use.
    +• 0x044 | RW | QueueEnable
    + Enable/disable the virtual queue.
    + Writing 0x1 to this register notifies the host that queue has been
    + setup and can now be used.
    + Writing 0x1 to this register requests that host stop using
    + the queue. When the Guest stops using the queue it must write
    + zero (0x0) to this register.
    Both read and write accesses apply to the queue selected by
    writing to QueueSel.

    @@ -1436,6 +1418,22 @@ Reading from this register returns a bit mask of interrupts
    register triggers a device reset.
    Also see "2.2.1. Device Initialization".

    +• 0x080 | RW | QueueDescLow
    +• 0x084 | RW | QueueDescHigh
    +• 0x088 | RW | QueueAvailLow
    +• 0x08c | RW | QueueAvailHigh
    +• 0x090 | RW | QueueUsedLow
    +• 0x094 | RW | QueueUsedHigh
    + Descriptor table/Available ring/Used ring addresses of the virtual queue.
    + These registers specify the low and high 32 bit parts
    + of the 64 bit physical address of the first byte of Descriptor
    + table/Available ring/Used ring parts of the virtual queue,
    + respectively.
    + Guest is forbidden from writing these registers while the queue is enabled
    + (see QueueEnable).
    + Both read and write accesses apply to the queue selected by
    + writing to QueueSel.
    +
    • 0x100+ | RW | Config
    Device-specific configuration space starts at an offset 0x100
    and is accessed with byte alignment. Its meaning and size
    @@ -1451,6 +1449,64 @@ Writing to registers described as “R” and reading from
    registers described as “W” is not permitted and can cause
    undefined behavior.

    +2.3.2.2.1 Legacy Interface: A Note on MMIO Device Layout
    +--------------------------
    +When used through the legacy interface, an MMIO Device
    +supports the following layout:
    +
    +• Offset from the device base address | Direction | Name
    + Description
    +
    +• 0x000 | R | MagicValue
    +• 0x004 | R | Version
    +• 0x008 | R | DeviceID
    +• 0x00c | R | VendorID
    +• 0x010 | R | HostFeatures
    +• 0x014 | W | HostFeaturesSel
    +• 0x020 | W | GuestFeatures
    +• 0x024 | W | GuestFeaturesSel
    +• 0x028 | W | GuestPageSize
    + Guest page size.
    + Device driver must write the guest page size in bytes to the
    + register during initialization, before any queues are used.
    + This value must be a power of 2 and is used by the Host to
    + calculate Guest address of the first queue page (see QueuePFN).
    +
    +• 0x030 | W | QueueSel
    +• 0x034 | R | QueueNumMax
    +• 0x038 | W | QueueNum
    +• 0x03c | W | QueueAlign
    + Used Ring alignment in the virtual queue.
    + Writing to this register notifies the Host about alignment
    + boundary of the Used Ring in bytes. This value must be a power
    + of 2 and applies to the queue selected by writing to QueueSel.
    +
    +• 0x040 | RW | QueuePFN
    + Guest physical page number of the virtual queue.
    + Writing to this register notifies the host about location of the
    + virtual queue in the Guest's physical address space. This value
    + is the index number of a page starting with the queue
    + Descriptor Table. Value zero (0x0) means physical address zero
    + (0x00000000) and is illegal. When the Guest stops using the
    + queue it must write zero (0x0) to this register.
    + Reading from this register returns the currently used page
    + number of the queue, therefore a value other than zero (0x0)
    + means that the queue is in use.
    + Both read and write accesses apply to the queue selected by
    + writing to QueueSel.
    +
    +• 0x050 | W | QueueNotify
    +• 0x60 | R | InterruptStatus
    +• 0x064 | W | InterruptACK
    +• 0x070 | RW | Status
    +• 0x100+ | RW | Config
    +
    +The meaning of each field in this table matches the
    +one specified in "2.3.2.2. MMIO Device Layout", with the
    +exception of the legacy GuestPageSize, QueueAlign and QueuePFN fields
    +which are used with the legacy Virtqueue layout
    +(see "2.1.4.1. Legacy Interfaces: A Note on Virtqueue Layout").
    +
    2.3.2.3. MMIO-specific Initialization And Device Operation
    ---------------------------------------------------------

    @@ -1467,7 +1523,7 @@ done before the virtqueues are configured.
    1. Select the queue writing its index (first queue is 0) to the
    QueueSel register.

    -2. Check if the queue is not already in use: read QueuePFN
    +2. Check if the queue is not already in use: read QueueEnable
    register, returned value should be zero (0x0).

    3. Read maximum queue size (number of elements) from the
    @@ -1485,8 +1541,28 @@ done before the virtqueues are configured.
    6. Notify the Host about the used alignment by writing its value
    in bytes to QueueAlign register.

    -7. Write the physical number of the first page of the queue to
    - the QueuePFN register.
    +7. Write the physical addresses of first byte of the queue
    + Descriptor Table, Available Ring and Used Ring into
    + QueueDescLow, QueueDescHigh, QueueAvailLow, QueueAvailHigh,
    + QueueUsedLow, QueueUsedHigh registers, respectively.
    +
    +7. Write 0x1 into the QueueEnable register.
    +
    +2.3.2.3.1.1.1 Legacy Interfaces: Virtqueue Configuration
    +-----------------------------------
    +When the device is used through the legacy interface
    +QueueEnable, QueueDescLow, QueueDescHigh, QueueAvailLow, QueueAvailHigh,
    +QueueUsedLow and QueueUsedHigh registers are not available.
    +
    +Instead, QueuePFN register is used
    +
    +- to check if the queue is not already in use: read QueuePFN
    +register, returned value should be zero (0x0);
    +
    +- to enable queue: write the physical number of the first page of the queue
    +to the QueuePFN register.
    +
    +- to disable queue: zero (0x0) to the QueuePFN register.

    2.3.2.3.2. Notifying The Device
    ------------------------------
    --
    MST



  • 2.  Re: [virtio] [PATCH] mmio: split desc/avail/used/enable

    Posted 09-16-2013 13:10
    On Sun, 2013-09-15 at 14:10 +0100, Michael S. Tsirkin wrote: > This is similar to what I proposed for PCI: > - deprecate QueuePFN and move it to legacy interface > section > - Add 64-bit QueueDesc QueueAvail QueueUsed > - Add explicit QueueEnable > > Needed to resolve issues > https://tools.oasis-open.org/issues/browse/VIRTIO-23 > https://tools.oasis-open.org/issues/browse/VIRTIO-32 > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> This is not exactly what I had in mind, but seems close enough :-) I'll have a closer look before the next conf call. Thanks for making my work easier :-) Pawel


  • 3.  Re: [virtio] [PATCH] mmio: split desc/avail/used/enable

    Posted 09-18-2013 09:29
    On Mon, Sep 16, 2013 at 02:09:49PM +0100, Pawel Moll wrote: > On Sun, 2013-09-15 at 14:10 +0100, Michael S. Tsirkin wrote: > > This is similar to what I proposed for PCI: > > - deprecate QueuePFN and move it to legacy interface > > section > > - Add 64-bit QueueDesc QueueAvail QueueUsed > > - Add explicit QueueEnable > > > > Needed to resolve issues > > https://tools.oasis-open.org/issues/browse/VIRTIO-23 > > https://tools.oasis-open.org/issues/browse/VIRTIO-32 > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > This is not exactly what I had in mind, but seems close enough :-) I'll > have a closer look before the next conf call. > > Thanks for making my work easier :-) > > Pawel > If what you have in mind mostly involves small changes (e.g. layout change), an incremental patch might be easier for me and possibly others to review. To generate that, you can pick a version which combines core changes and MMIO changes here: git://git.kernel.org/pub/scm/virt/kvm/mst/virtio-text.git split-avail-used-VIRTIO-23 pci changes are on a separate branch since they are needed for the new layout. -- MST -- MST


  • 4.  Re: [virtio] [PATCH] mmio: split desc/avail/used/enable

    Posted 09-18-2013 09:31
    On Mon, Sep 16, 2013 at 02:09:49PM +0100, Pawel Moll wrote:
    > On Sun, 2013-09-15 at 14:10 +0100, Michael S. Tsirkin wrote:
    > > This is similar to what I proposed for PCI:
    > > - deprecate QueuePFN and move it to legacy interface
    > > section
    > > - Add 64-bit QueueDesc QueueAvail QueueUsed
    > > - Add explicit QueueEnable
    > >
    > > Needed to resolve issues
    > > https://tools.oasis-open.org/issues/browse/VIRTIO-23
    > > https://tools.oasis-open.org/issues/browse/VIRTIO-32
    > >
    > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    >
    > This is not exactly what I had in mind, but seems close enough :-) I'll
    > have a closer look before the next conf call.
    >
    > Thanks for making my work easier :-)
    >
    > Pawel
    >

    If what you have in mind mostly involves small changes
    (e.g. layout change), an incremental patch might be easier for me
    and possibly others to review.

    To generate that, you can pick a version which combines core
    changes and MMIO changes here:

    git://git.kernel.org/pub/scm/virt/kvm/mst/virtio-text.git split-avail-used-VIRTIO-23

    pci changes are on a separate branch since they are needed
    for the new layout.

    --
    MST
    --
    MST