virtio spec 0.8.7
diff --git a/virtio.lyx b/virtio.lyx
index f7c9c38..107172c 100644
--- a/virtio.lyx
+++ b/virtio.lyx
@@ -1,4 +1,4 @@
-#LyX 1.6.7 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.4 created this file. For more info see http://www.lyx.org/
 \lyxformat 345
 \begin_document
 \begin_header
@@ -47,7 +47,7 @@
 \begin_inset Newline newline
 \end_inset
 
-v0.8.10 DRAFT
+v0.8.7 DRAFT
 \begin_inset Newline newline
 \end_inset
 
@@ -63,7 +63,7 @@
 \end_layout
 
 \begin_layout Date
-2010 October 6.
+2010 April 20.
 \end_layout
 
 \begin_layout Chapter
@@ -307,7 +307,7 @@
 
 \begin_layout Standard
 \begin_inset Tabular
-<lyxtabular version="3" rows="8" columns="3">
+<lyxtabular version="3" rows="7" columns="3">
 <features>
 <column alignment="center" valignment="top" width="0">
 <column alignment="center" valignment="top" width="0">
@@ -487,35 +487,6 @@
 </cell>
 </row>
 <row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-6
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ioMemory
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
--
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
 \begin_inset Text
 
@@ -1784,9 +1755,6 @@
 \begin_layout Standard
 The number of descriptors in the table is specified by the Queue Size field
  for this virtqueue.
-\end_layout
-
-\begin_layout Subsection
 \begin_inset CommandInset label
 LatexCommand label
 name "sub:Indirect-Descriptors"
@@ -2079,8 +2047,8 @@
  and processing used buffers from the device.
  As an example, the virtio network device has two virtqueues: the transmit
  virtqueue and the receive virtqueue.
- The driver adds outgoing (read-only) packets to the transmit virtqueue,
- and then frees them after they are used.
+ The driver adds outgoing (read-only) packets are added to the transmit
+ virtqueue, and then frees them after they are used.
  Similarly, incoming (write-only) buffers are added to the receive virtqueue,
  and processed after they are used.
 \end_layout
@@ -2373,7 +2341,7 @@
 before
 \emph default
  checking the suppression flag: it's OK to notify gratuitously, but not
- to omit a required notification.
+ to skip a notification.
  So again, we use a memory barrier here before reading the flags.
 \end_layout
 
@@ -2408,8 +2376,7 @@
 \end_layout
 
 \begin_layout Enumerate
-If the VRING_AVAIL_F_NO_INTERRUPT flag is not set in avail\SpecialChar \nobreakdash-
->flags:
+If the VRING_AVAIL_F_NO_INTERRUPT flag is not set in avail->flags:
 \end_layout
 
 \begin_deeper
@@ -2643,7 +2610,7 @@
 
 \begin_layout Standard
 Any change to configuration space, or new virtqueues, or behavioural changes,
- should be indicated by negotiation of a new feature bit.
+ should be indicated be negotiation of a new feature bit.
  This establishes clarity
 \begin_inset Foot
 status open
@@ -4418,7 +4385,7 @@
 The device can filter incoming packets by any number of destination MAC
  addresses.
 \begin_inset Foot
-status collapsed
+status open
 
 \begin_layout Plain Layout
 Since there are no guarentees, it can use a hash filter orsilently switch
@@ -4594,14 +4561,6 @@
 \end_layout
 
 \begin_layout Description
-VIRTIO_BLK_F_SCSI (7) Device supports scsi packet commands.
-\end_layout
-
-\begin_layout Description
-VIRTIO_BLK_F_FLUSH (9) Cache flush command support.
-\end_layout
-
-\begin_layout Description
 VIRTIO_BLK_F_SECTOR_MAX
 \begin_inset space ~
 \end_inset
@@ -4750,199 +4709,12 @@
 
 \begin_layout Plain Layout
 
+#define VIRTIO_BLK_T_IN          0
 \end_layout
 
 \begin_layout Plain Layout
 
-	u32 type;
-\end_layout
-
-\begin_layout Plain Layout
-
-	u32 ioprio;
-\end_layout
-
-\begin_layout Plain Layout
-
-	u64 sector;
-\end_layout
-
-\begin_layout Plain Layout
-
-	char data[][512];
-\end_layout
-
-\begin_layout Plain Layout
-
-	u8 status;
-\end_layout
-
-\begin_layout Plain Layout
-
-};
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-If the device has VIRTIO_BLK_F_SCSI feature, it can also support scsi packet
- command requests, each of these requests is of form:
-\begin_inset listings
-inline false
-status open
-
-\begin_layout Plain Layout
-
-struct virtio_scsi_pc_req {
-\end_layout
-
-\begin_layout Plain Layout
-
-	u32 type;
-\end_layout
-
-\begin_layout Plain Layout
-
-	u32 ioprio;
-\end_layout
-
-\begin_layout Plain Layout
-
-	u64 sector;
-\end_layout
-
-\begin_layout Plain Layout
-
-    char cmd[];
-\end_layout
-
-\begin_layout Plain Layout
-
-	char data[][512];
-\end_layout
-
-\begin_layout Plain Layout
-
-#define SCSI_SENSE_BUFFERSIZE   96
-\end_layout
-
-\begin_layout Plain Layout
-
-    u8 sense[SCSI_SENSE_BUFFERSIZE];
-\end_layout
-
-\begin_layout Plain Layout
-
-    u32 errors;
-\end_layout
-
-\begin_layout Plain Layout
-
-    u32 data_len;
-\end_layout
-
-\begin_layout Plain Layout
-
-    u32 sense_len;
-\end_layout
-
-\begin_layout Plain Layout
-
-    u32 residual;
-\end_layout
-
-\begin_layout Plain Layout
-
-	u8 status;
-\end_layout
-
-\begin_layout Plain Layout
-
-};
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-The 
-\emph on
-type
-\emph default
- of the request is either a read (VIRTIO_BLK_T_IN), a write (VIRTIO_BLK_T_OUT),
- a scsi packet command (VIRTIO_BLK_T_SCSI_CMD or VIRTIO_BLK_T_SCSI_CMD_OUT
-\begin_inset Foot
-status open
-
-\begin_layout Plain Layout
-the SCSI_CMD and SCSI_CMD_OUT types are equivalent, the device does not
- distinguish between them
-\end_layout
-
-\end_inset
-
-) or a flush (VIRTIO_BLK_T_FLUSH or VIRTIO_BLK_T_FLUSH_OUT
-\begin_inset Foot
-status open
-
-\begin_layout Plain Layout
-the FLUSH and FLUSH_OUT types are equivalent, the device does not distinguish
- between them
-\end_layout
-
-\end_inset
-
-).
- If the device has VIRTIO_BLK_F_BARRIER feature
-\begin_inset space ~
-\end_inset
-
-the high bit (VIRTIO_BLK_T_BARRIER) indicates that this request acts as
- a barrier and that all preceeding requests must be complete before this
- one, and all following requests must not be started until this is complete.
- Note that a barrier does not flush caches in the underlying backend device
- in host, and thus does not serve as data consistency guarantee.
- Driver must use FLUSH request to flush the host cache.
-\end_layout
-
-\begin_layout Standard
-\begin_inset listings
-inline false
-status open
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_IN           0
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_OUT          1
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_SCSI_CMD     2
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_SCSI_CMD_OUT 3
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_FLUSH        4
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_BLK_T_FLUSH_OUT    5
+#define VIRTIO_BLK_T_OUT         1
 \end_layout
 
 \begin_layout Plain Layout
@@ -4950,107 +4722,26 @@
 #define VIRTIO_BLK_T_BARRIER	 0x80000000
 \end_layout
 
-\end_inset
+\begin_layout Plain Layout
 
-
+	u32 type;
 \end_layout
 
-\begin_layout Standard
-The 
-\emph on
-ioprio
-\emph default
- field is a hint about the relative priorities of requests to the device:
- higher numbers indicate more important requests.
+\begin_layout Plain Layout
+
+	u32 ioprio;
 \end_layout
 
-\begin_layout Standard
-The 
-\emph on
-sector
-\emph default
- number indicates the offset (multiplied by 512) where the read or write
- is to occur.
- This field is unused and set to 0 for scsi packet commands and for flush
- commands.
+\begin_layout Plain Layout
+
+	u64 sector;
 \end_layout
 
-\begin_layout Standard
-The 
-\emph on
-cmd
-\emph default
- field is only present for scsi packet command requests, and indicates the
- command to perform.
- This field must reside in a single, separate read-only buffer; command
- length can be derived from the length of this buffer.
- 
-\end_layout
+\begin_layout Plain Layout
 
-\begin_layout Standard
-Note that these first three (four for scsi packet commands) fields are always
- read-only: the 
-\emph on
-data
-\emph default
- field is either read-only or write-only, depending on the request.
- The size of the read or write can be derived from the total size of the
- request buffers.
+	char data[][512];
 \end_layout
 
-\begin_layout Standard
-The
-\emph on
- sense
-\emph default
- field is only present for scsi packet command requests, and indicates the
- buffer for scsi sense data.
-\end_layout
-
-\begin_layout Standard
-The 
-\emph on
-data_len
-\emph default
- field is only present for scsi packet command requests, this field is deprecate
-d, and should be ignored by the driver.
- Historically, devices copied data length there.
-\end_layout
-
-\begin_layout Standard
-The 
-\emph on
-sense_len
-\emph default
- field is only present for scsi packet command requests and indicates the
- number of bytes actually written to the 
-\emph on
-sense
-\emph default
- buffer.
-\end_layout
-
-\begin_layout Standard
-The 
-\emph on
-residual
-\emph default
- field is only present for scsi packet command requests and indicates the
- residual size, calculated as data length - number of bytes actually transferred.
-\end_layout
-
-\begin_layout Standard
-The final 
-\emph on
-status
-\emph default
- byte is written by the device: either VIRTIO_BLK_S_OK for success, VIRTIO_BLK_S
-_IOERR for host or guest error or VIRTIO_BLK_S_UNSUPP for a request unsupported
- by host:
-\begin_inset listings
-inline false
-status open
-
 \begin_layout Plain Layout
 
 #define VIRTIO_BLK_S_OK        0
@@ -5063,7 +4754,12 @@
 
 \begin_layout Plain Layout
 
-#define VIRTIO_BLK_S_UNSUPP    2
+	u8 status;
+\end_layout
+
+\begin_layout Plain Layout
+
+};
 \end_layout
 
 \end_inset
@@ -5072,60 +4768,32 @@
 \end_layout
 
 \begin_layout Standard
-Historically, devices assumed that the fields 
-\emph on
-type
-\emph default
-, 
-\emph on
-ioprio
-\emph default
- and 
-\emph on
-sector
-\emph default
- reside in a single, separate read-only buffer; the fields 
-\emph on
-errors
-\emph default
-, 
-\emph on
-data_len
-\emph default
-, 
-\emph on
-sense_len
-\emph default
- and 
-\emph on
-residual
-\emph default
- reside in a single, separate write-only buffer; the 
-\emph on
-sense
-\emph default
- field in a separate write-only buffer of size 96 bytes, by itself; the
- fields 
-\emph on
-errors
-\emph default
-, 
-\emph on
-data_len
-\emph default
-, 
-\emph on
-sense_len
-\emph default
- and 
-\emph on
-residual
-\emph default
- in a single write-only buffer; and the 
-\emph on
-status
-\emph default
- field is a separate read-only buffer of size 1 byte, by itself.
+The type of the request is either a read (VIRTIO_BLK_T_IN) or a write (VIRTIO_BL
+K_T_OUT); the high bit indicates that this request acts as a barrier and
+ that all preceeding requests must be complete before this one, and all
+ following requests must not be started until this is complete.
+\end_layout
+
+\begin_layout Standard
+The ioprio field is a hint about the relative priorities of requests to
+ the device: higher numbers indicate more important requests.
+\end_layout
+
+\begin_layout Standard
+The sector number indicates the offset (multiplied by 512) where the read
+ or write is to occur.
+\end_layout
+
+\begin_layout Standard
+Note that these first three fields are always read-only: the data field
+ is either read-only or write-only, depending on the type of the request.
+ The size of the read or write can be derived from the total size of the
+ request buffer.
+\end_layout
+
+\begin_layout Standard
+The final byte is written by the device: either VIRTIO_BLK_S_OK or VIRTIO_BLK_S_
+IOERR.
 \end_layout
 
 \begin_layout Chapter*
@@ -5140,9 +4808,7 @@
  The control virtqueues are used to communicate information between the
  device and the driver about ports being opened and closed on either side
  of the connection, indication from the host about whether a particular
- port is a console port, adding new ports, port hot-plug/unplug, etc., and
- indication from the guest about whether a port or a device was successfully
- added, port open/close, etc..
+ port is a console port, port hotunplug, etc.
  For data IO, one or more empty buffers are placed in the receive queue
  for incoming data and outgoing characters are placed in the transmit queue.
 \end_layout
@@ -5165,17 +4831,8 @@
 
 \begin_layout Description
 Virtqueues 0:receiveq(port0).
- 1:transmitq(port0), 2:control receiveq
-\begin_inset Foot
-status open
-
-\begin_layout Plain Layout
-Ports 2 onwards only if VIRTIO_CONSOLE_F_MULTIPORT is set
-\end_layout
-
-\end_inset
-
-, 3:control transmitq, 4:receiveq(port1), 5:transmitq(port1), ...
+ 1:transmitq(port0), 2:control receiveq, 3:control transmitq, 4:receiveq(port1),
+ 5:transmitq(port1), ...
 \end_layout
 
 \begin_layout Description
@@ -5214,7 +4871,8 @@
 layout The size of the console is supplied in the configuration space if
  the VIRTIO_CONSOLE_F_SIZE feature is set.
  Furthermore, if the VIRTIO_CONSOLE_F_MULTIPORT feature is set, the maximum
- number of ports supported by the device can be fetched.
+ number of ports supported by the device and the number of ports currently
+ active can be fetched.
 \begin_inset listings
 inline false
 status open
@@ -5245,6 +4903,11 @@
 
 \begin_layout Plain Layout
 
+	u32 nr_ports;
+\end_layout
+
+\begin_layout Plain Layout
+
 };
 \end_layout
 
@@ -5266,11 +4929,9 @@
 If the VIRTIO_CONSOLE_F_MULTIPORT feature is negotiated, the driver can
  spawn multiple ports, not all of which may be attached to a console.
  Some could be generic ports.
- In this case, the control virtqueues are enabled and according to the max_nr_po
-rts configuration-space value, the appropriate number of virtqueues are
- created.
- A control message indicating the driver is ready is sent to the host.
- The host can then send control messages for adding new ports to the device.
+ In this case, the control virtqueues are enabled and according to the nr_ports
+ configuration-space value, the appropriate number of ports and corresponding
+ virtqueues are spawned.
  After creating and initializing each port, a VIRTIO_CONSOLE_PORT_READY
  control message is sent to the host for that port so the host can let us
  know of any additional configuration options set for that port.
@@ -5293,9 +4954,6 @@
 Because this is high importance and low bandwidth, the current Linux implementat
 ion polls for the buffer to be used, rather than waiting for an interrupt,
  simplifying the implementation significantly.
- However, for generic serial ports with the O_NONBLOCK flag set, the polling
- limitation is relaxed and the consumed buffers are freed upon the next
- write or poll call or when a port is closed or hot-unplugged.
 \end_layout
 
 \end_inset
@@ -5316,17 +4974,9 @@
 \end_layout
 
 \begin_layout Enumerate
-If the driver negotiated the VIRTIO_CONSOLE_F_MULTIPORT feature, active
- ports are announced by the host using the VIRTIO_CONSOLE_PORT_ADD control
- message.
- The same message is used for port hot-plug as well.
-\end_layout
-
-\begin_layout Enumerate
-If the host specified a port `name', a sysfs attribute is created with the
- name filled in, so that udev rules can be written that can create a symlink
- from the port's name to the char device for port discovery by applications
- in the guest.
+If the driver negotiated the VIRTIO_CONSOLE_F_MULTIPORT feature, a configuration
+ change interrupt may occur that bumps up the value of nr_ports.
+ In this case, ports are hot-added.
 \end_layout
 
 \begin_layout Enumerate
@@ -5374,46 +5024,32 @@
 
 \begin_layout Plain Layout
 
+#define VIRTIO_CONSOLE_PORT_READY       0
 \end_layout
 
 \begin_layout Plain Layout
 
-#define VIRTIO_CONSOLE_DEVICE_READY     0
+#define VIRTIO_CONSOLE_CONSOLE_PORT     1
 \end_layout
 
 \begin_layout Plain Layout
 
-#define VIRTIO_CONSOLE_PORT_ADD         1
+#define VIRTIO_CONSOLE_RESIZE           2
 \end_layout
 
 \begin_layout Plain Layout
 
-#define VIRTIO_CONSOLE_PORT_REMOVE      2
+#define VIRTIO_CONSOLE_PORT_OPEN        3
 \end_layout
 
 \begin_layout Plain Layout
 
-#define VIRTIO_CONSOLE_PORT_READY       3
+#define VIRTIO_CONSOLE_PORT_NAME        4
 \end_layout
 
 \begin_layout Plain Layout
 
-#define VIRTIO_CONSOLE_CONSOLE_PORT     4
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_CONSOLE_RESIZE           5
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_CONSOLE_PORT_OPEN        6
-\end_layout
-
-\begin_layout Plain Layout
-
-#define VIRTIO_CONSOLE_PORT_NAME        7
+#define VIRTIO_CONSOLE_PORT_REMOVE      5
 \end_layout
 
 \end_inset