From fffcbe327c69e510239fff5627034aa2ab4b2d84 Mon Sep 17 00:00:00 2001
From: rusty <rusty@0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652>
Date: Thu, 5 Jun 2014 06:44:53 +0000
Subject: pci: switch from subsystem id to device id

Switch virtio pci to use standard device id instead of using the
subsystem id.

Unfortunately, there's no system to the way KVM allocated
device IDs to virtio devices, we'll just have to
specify these using a table, and use a new range for
future devices. For existing devices this results in
two possible IDs that all drivers will need to match.
Unfortunate, but the cost is small.

As a nice side effect, this allows us to make non-transitional
devices use IDs 0x40 and up, this reduces even further the
chance that a non transitional device will match legacy drivers.

And, it's probably a good idea to allow drivers to match
specific subsystem IDs if they
want to, so relax requirement for drivers to match all
subsystem/vendor ID configurations, but allow them to do so.

To avoid confusion, say "PCI Device ID" and
"PCI Subsystem ID" everywhere, prefix "PCI"
for other standard registers, for consistency.

VIRTIO-102

Note: issue reporter suggested 0x10XX where XX is the virtio
device ID. This would conflict with legacy devices, which seem
to have used 7 IDs in the range 0x1000 to 0x103f without any
system. Let's use a new range 0x1040 to 0x107f for
non-transitional devices, and add a table documenting the
transitional IDs used by in practice.

(Approved at 2014-06-04 meeting:
  https://lists.oasis-open.org/archives/virtio/201406/msg00013.html )

Cc: Andrew Thornton <andrewth@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@au1.ibm.com>

git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio@376 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652
---
 content.tex | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)

(limited to 'content.tex')

diff --git a/content.tex b/content.tex
index 514982f..7f1eecb 100644
--- a/content.tex
+++ b/content.tex
@@ -963,31 +963,48 @@ respectively.
 
 \subsection{PCI Device Discovery}\label{sec:Virtio Transport Options / Virtio Over PCI Bus / PCI Device Discovery}
 
-Any PCI device with Vendor ID 0x1AF4, and Device ID 0x1000 through
-0x103F inclusive is a virtio device\footnote{The actual value within this range is ignored
-}.
-
-The Subsystem Device ID indicates which virtio device is
-supported by the device, as indicated in section \ref{sec:Device Types}.
+Any PCI device with PCI Vendor ID 0x1AF4, and PCI Device ID 0x1000 through
+0x103F inclusive is a virtio device. The actual value within this range
+indicates which virtio device is supported by the device.
+The PCI Device ID is calculated by adding 0xFFF to the Virtio Device ID,
+as indicated in section \ref{sec:Device Types}.
 
 \devicenormative{\subsubsection}{PCI Device Discovery}{Virtio Transport Options / Virtio Over PCI Bus / PCI Device Discovery}
-The Subsystem Vendor ID SHOULD reflect
-the PCI Vendor ID of the environment (it's currently only used
-for informational purposes by the driver).
 
-Non-transitional devices SHOULD have a Revision ID of 1 or higher.
+Devices MUST have the PCI Vendor ID 0x1AF4.
+Devices MUST have the PCI Device ID calculated by adding 0xFFF
+to the Virtio Device ID,
+as indicated in section \ref{sec:Device Types}.
+For example, the network card device with the Virtio Device ID 1
+has the PCI Device ID 0x1000.
+
+The PCI Subsystem Vendor ID and the PCI Subsystem Device ID MAY reflect
+the PCI Vendor and Device ID of the environment (for informational purposes by the driver).
+
+Non-transitional devices SHOULD have a PCI Revision ID of 1 or higher.
+Non-transitional devices SHOULD have a PCI Subsystem Device ID of 0x40 or higher.
 
 This is to reduce the chance of a legacy driver attempting
 to drive the device.
 
 \drivernormative{\subsubsection}{PCI Device Discovery}{Virtio Transport Options / Virtio Over PCI Bus / PCI Device Discovery}
-All drivers MUST match devices with any Revision ID, this
-is to allow devices to be versioned without breaking drivers.
+Drivers MUST match devices with the PCI Vendor ID 0x1AF4 and
+the PCI Device ID calculated by adding 0xFFF to the Virtio Device ID,
+as indicated in section \ref{sec:Device Types}.
+
+Drivers MUST match devices with any Revision ID, and
+MAY match devices with any Subsystem Vendor ID and
+Subsystem Device ID, this is to allow devices to be
+versioned without breaking drivers.
 
-Drivers MUST match any Revision ID value. 
+Drivers MUST match any PCI Revision ID value.
+Drivers MAY match any PCI Subsystem Vendor ID and any
+PCI Subsystem Device ID value.
 
 \subsubsection{Legacy Interfaces: A Note on PCI Device Discovery}\label{sec:Virtio Transport Options / Virtio Over PCI Bus / PCI Device Discovery / Legacy Interfaces: A Note on PCI Device Discovery}
-Transitional devices MUST have a Revision ID of 0.
+Transitional devices MUST have a PCI Revision ID of 0.
+Transitional devices MUST have the PCI Subsystem Device ID
+matching the Virtio Device ID, as indicated in section \ref{sec:Device Types}.
 
 This is to match legacy drivers.
 
-- 
cgit v1.2.3

