From 4331df88a9c1db818c600d93e44b9cabab04e525 Mon Sep 17 00:00:00 2001 From: mstsirkin Date: Tue, 16 Feb 2016 17:10:51 +0000 Subject: virtio-ring.h -> virtio-queue.h Since vring* and VRING* have been replaced with virtq* and VIRTQ* respectively, rename the header virtio_ring.h to virtio_queue.h. Suggested-by: Kevin Lo Signed-off-by: Michael S. Tsirkin Acked-by: Cornelia Huck git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio/branches/v1.0@558 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- cl-cs03.tex | 2 +- content.tex | 4 +- headerfile.tex | 4 +- makezip.sh | 4 +- specvars.tex | 2 +- virtio-queue.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ virtio-ring.h | 122 --------------------------------------------------------- 7 files changed, 130 insertions(+), 130 deletions(-) create mode 100644 virtio-queue.h delete mode 100644 virtio-ring.h diff --git a/cl-cs03.tex b/cl-cs03.tex index ab26d64..72925ca 100644 --- a/cl-cs03.tex +++ b/cl-cs03.tex @@ -43,7 +43,7 @@ virtio-ring: comment fixup virtio_ring.h included with spec has this text: /* Support for avail_idx and used_idx fields */ it should really refer to avail_event and used_event. -See Appendix \ref{sec:virtio-ring.h}. +See Appendix \ref{sec:virtio-queue.h}. } \\ \hline 486 & 15 Mar 2015 & Jason Wang & {VIRTIO-136: diff --git a/content.tex b/content.tex index 38e9e43..36f2f78 100644 --- a/content.tex +++ b/content.tex @@ -442,7 +442,7 @@ this implies that loops in the descriptor chain are forbidden! \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors} Some devices benefit by concurrently dispatching a large number -of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-ring.h}~\nameref{sec:virtio-ring.h}). To increase +of large requests. The VIRTIO_F_INDIRECT_DESC feature allows this (see \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}). To increase ring capacity the driver can store a table of indirect descriptors anywhere in memory, and insert a descriptor in main virtqueue (with \field{flags}\&VIRTQ_DESC_F_INDIRECT on) that refers to memory buffer @@ -717,7 +717,7 @@ helper routines in a more usable form, in include/uapi/linux/virtio_ring.h. This was explicitly licensed by IBM and Red Hat under the (3-clause) BSD license so that it can be freely used by all other projects, and is reproduced (with slight -variation) in \ref{sec:virtio-ring.h}~\nameref{sec:virtio-ring.h}. +variation) in \ref{sec:virtio-queue.h}~\nameref{sec:virtio-queue.h}. \chapter{General Initialization And Device Operation}\label{sec:General Initialization And Device Operation} diff --git a/headerfile.tex b/headerfile.tex index b1a92c2..cdc8114 100644 --- a/headerfile.tex +++ b/headerfile.tex @@ -1,8 +1,8 @@ -\chapter{virtio_ring.h}\label{sec:virtio-ring.h} +\chapter{virtio_queue.h}\label{sec:virtio-queue.h} This file is also available at the link \virtiourlh. All definitions in this section are for non-normative reference only. -\lstinputlisting{virtio-ring.h} +\lstinputlisting{virtio-queue.h} diff --git a/makezip.sh b/makezip.sh index de52abf..3c94f8e 100755 --- a/makezip.sh +++ b/makezip.sh @@ -17,8 +17,8 @@ fi zip -d $SPECDOC.zip tex/.gitattributes rm -fr listings mkdir -p listings -cp virtio-ring.h listings/virtio_ring.h -zip $SPECDOC.zip listings/virtio_ring.h +cp virtio-queue.h listings/virtio_queue.h +zip $SPECDOC.zip listings/virtio_queue.h rm -fr tmpfilesforzip mkdir -p tmpfilesforzip/tex echo "$SPECDOC" > tmpfilesforzip/tex/REVISION diff --git a/specvars.tex b/specvars.tex index 1f7cd9f..84f8bae 100644 --- a/specvars.tex +++ b/specvars.tex @@ -7,7 +7,7 @@ \urldef \virtiourltex\url{\virtiourlbase/tex/} \urldef \virtiourlpdf\url{\virtiourlbase/\virtiospecfile.pdf} \urldef \virtiourlhtml\url{\virtiourlbase/\virtiospecfile.html} -\urldef \virtiourlh\url{\virtiourlbase/listings/virtio_ring.h} +\urldef \virtiourlh\url{\virtiourlbase/listings/virtio_queue.h} \urldef \virtiourllatestpdf\url{http://docs.oasis-open.org/virtio/virtio/v\virtiorev/virtio-v\virtiorev.pdf} \urldef \virtiourllatesthtml\url{http://docs.oasis-open.org/virtio/virtio/v\virtiorev/virtio-v\virtiorev.html} \newcommand{\virtioworkproduct}{Standards Track Work Product} diff --git a/virtio-queue.h b/virtio-queue.h new file mode 100644 index 0000000..5a1e87d --- /dev/null +++ b/virtio-queue.h @@ -0,0 +1,122 @@ +#ifndef VIRTQUEUE_H +#define VIRTQUEUE_H +/* An interface for efficient virtio implementation. + * + * This header is BSD licensed so anyone can use the definitions + * to implement compatible drivers/servers. + * + * Copyright 2007, 2009, IBM Corporation + * Copyright 2011, Red Hat, Inc + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of IBM nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include + +/* This marks a buffer as continuing via the next field. */ +#define VIRTQ_DESC_F_NEXT 1 +/* This marks a buffer as write-only (otherwise read-only). */ +#define VIRTQ_DESC_F_WRITE 2 +/* This means the buffer contains a list of buffer descriptors. */ +#define VIRTQ_DESC_F_INDIRECT 4 + +/* The device uses this in used->flags to advise the driver: don't kick me + * when you add a buffer. It's unreliable, so it's simply an + * optimization. */ +#define VIRTQ_USED_F_NO_NOTIFY 1 +/* The driver uses this in avail->flags to advise the device: don't + * interrupt me when you consume a buffer. It's unreliable, so it's + * simply an optimization. */ +#define VIRTQ_AVAIL_F_NO_INTERRUPT 1 + +/* Support for indirect descriptors */ +#define VIRTIO_F_INDIRECT_DESC 28 + +/* Support for avail_event and used_event fields */ +#define VIRTIO_F_EVENT_IDX 29 + +/* Arbitrary descriptor layouts. */ +#define VIRTIO_F_ANY_LAYOUT 27 + +/* Virtqueue descriptors: 16 bytes. + * These can chain together via "next". */ +struct virtq_desc { + /* Address (guest-physical). */ + le64 addr; + /* Length. */ + le32 len; + /* The flags as indicated above. */ + le16 flags; + /* We chain unused descriptors via this, too */ + le16 next; +}; + +struct virtq_avail { + le16 flags; + le16 idx; + le16 ring[]; + /* Only if VIRTIO_F_EVENT_IDX: le16 used_event; */ +}; + +/* le32 is used here for ids for padding reasons. */ +struct virtq_used_elem { + /* Index of start of used descriptor chain. */ + le32 id; + /* Total length of the descriptor chain which was written to. */ + le32 len; +}; + +struct virtq_used { + le16 flags; + le16 idx; + struct virtq_used_elem ring[]; + /* Only if VIRTIO_F_EVENT_IDX: le16 avail_event; */ +}; + +struct virtq { + unsigned int num; + + struct virtq_desc *desc; + struct virtq_avail *avail; + struct virtq_used *used; +}; + +static inline int virtq_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old_idx) +{ + return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old_idx); +} + +/* Get location of event indices (only with VIRTIO_F_EVENT_IDX) */ +static inline le16 *virtq_used_event(struct virtq *vq) +{ + /* For backwards compat, used event index is at *end* of avail ring. */ + return &vq->avail->ring[vq->num]; +} + +static inline le16 *virtq_avail_event(struct virtq *vq) +{ + /* For backwards compat, avail event index is at *end* of used ring. */ + return (le16 *)&vq->used->ring[vq->num]; +} +#endif /* VIRTQUEUE_H */ diff --git a/virtio-ring.h b/virtio-ring.h deleted file mode 100644 index 5a1e87d..0000000 --- a/virtio-ring.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef VIRTQUEUE_H -#define VIRTQUEUE_H -/* An interface for efficient virtio implementation. - * - * This header is BSD licensed so anyone can use the definitions - * to implement compatible drivers/servers. - * - * Copyright 2007, 2009, IBM Corporation - * Copyright 2011, Red Hat, Inc - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of IBM nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include - -/* This marks a buffer as continuing via the next field. */ -#define VIRTQ_DESC_F_NEXT 1 -/* This marks a buffer as write-only (otherwise read-only). */ -#define VIRTQ_DESC_F_WRITE 2 -/* This means the buffer contains a list of buffer descriptors. */ -#define VIRTQ_DESC_F_INDIRECT 4 - -/* The device uses this in used->flags to advise the driver: don't kick me - * when you add a buffer. It's unreliable, so it's simply an - * optimization. */ -#define VIRTQ_USED_F_NO_NOTIFY 1 -/* The driver uses this in avail->flags to advise the device: don't - * interrupt me when you consume a buffer. It's unreliable, so it's - * simply an optimization. */ -#define VIRTQ_AVAIL_F_NO_INTERRUPT 1 - -/* Support for indirect descriptors */ -#define VIRTIO_F_INDIRECT_DESC 28 - -/* Support for avail_event and used_event fields */ -#define VIRTIO_F_EVENT_IDX 29 - -/* Arbitrary descriptor layouts. */ -#define VIRTIO_F_ANY_LAYOUT 27 - -/* Virtqueue descriptors: 16 bytes. - * These can chain together via "next". */ -struct virtq_desc { - /* Address (guest-physical). */ - le64 addr; - /* Length. */ - le32 len; - /* The flags as indicated above. */ - le16 flags; - /* We chain unused descriptors via this, too */ - le16 next; -}; - -struct virtq_avail { - le16 flags; - le16 idx; - le16 ring[]; - /* Only if VIRTIO_F_EVENT_IDX: le16 used_event; */ -}; - -/* le32 is used here for ids for padding reasons. */ -struct virtq_used_elem { - /* Index of start of used descriptor chain. */ - le32 id; - /* Total length of the descriptor chain which was written to. */ - le32 len; -}; - -struct virtq_used { - le16 flags; - le16 idx; - struct virtq_used_elem ring[]; - /* Only if VIRTIO_F_EVENT_IDX: le16 avail_event; */ -}; - -struct virtq { - unsigned int num; - - struct virtq_desc *desc; - struct virtq_avail *avail; - struct virtq_used *used; -}; - -static inline int virtq_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old_idx) -{ - return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old_idx); -} - -/* Get location of event indices (only with VIRTIO_F_EVENT_IDX) */ -static inline le16 *virtq_used_event(struct virtq *vq) -{ - /* For backwards compat, used event index is at *end* of avail ring. */ - return &vq->avail->ring[vq->num]; -} - -static inline le16 *virtq_avail_event(struct virtq *vq) -{ - /* For backwards compat, avail event index is at *end* of used ring. */ - return (le16 *)&vq->used->ring[vq->num]; -} -#endif /* VIRTQUEUE_H */ -- cgit v1.2.3