Skip to contentSkip to conversation

Improve consistency of pci-ids.txt, use symbolic constants for QEMU devices

PATCH In review Paolo Bonzini 1 participant 8 messages Dec 13, 2012 – Jan 8, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover Improve consistency of pci-ids.txt, use symbolic constants for QEMU devices

Five small, boring patches. Inspired by Gerd's patch at
http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05229.html which unfortunately is already out of date.

Paolo Bonzini (5):
docs: move pci-ids.txt to docs/specs/
reorganize pci-ids.txt
virtio-9p: use symbolic constant, add to pci-ids.txt
ivshmem: use symbolic constant for PCI ID, add to pci-ids.txt
pci: use constants for devices under the 1B36 device ID, document them

 docs/specs/pci-ids.txt     | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/9pfs/virtio-9p-device.c |  2 +-
 hw/ivshmem.c               |  7 +++++--
 hw/pci.h                   |  8 ++++++++
 hw/pci_bridge_dev.c        |  8 ++------
 hw/serial-pci.c            | 12 +++++------
 pci-ids.txt                | 31 ----------------------------
 7 files changed, 72 insertions(+), 46 deletions(-)
 create mode 100644 docs/specs/pci-ids.txt
 delete mode 100644 pci-ids.txt
Signature · 1 line
1.8.0.1
#1 lore raw

PATCH v2 1/5 docs: move pci-ids.txt to docs/specs/

---
 pci-ids.txt => docs/specs/pci-ids.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename pci-ids.txt => docs/specs/pci-ids.txt (100%)
docs/specs/pci-ids.txt renamed from pci-ids.txt +0 -0
similarity index 100%
rename from pci-ids.txt
rename to docs/specs/pci-ids.txt
Signature · 1 line
1.8.0.1
#2 lore raw

PATCH v2 2/5 reorganize pci-ids.txt

In reply to Paolo Bonzini

Some devices were missing, and we're using two PCI vendor ids. This patch only adds devices that are already documented in hw/pci.h.

---
 docs/specs/pci-ids.txt | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
docs/specs/pci-ids.txt +14 -13
index 73125a8..df2527f 100644
@@ -3,29 +3,30 @@ PCI IDs for qemu
 ================
 
 Red Hat, Inc. donates a part of its device ID range to qemu, to be used for
-virtual devices.  The vendor ID is 1af4 (formerly Qumranet ID).
+virtual devices.  The vendor IDs are 1af4 (formerly Qumranet ID) and 1b36.
 
-The 1000 -> 10ff device ID range is used for VirtIO devices.
+Contact Gerd Hoffmann <[email protected]> to get a device ID assigned
+for your devices.
 
-The 1100 device ID is used as PCI Subsystem ID for existing hardware
-devices emulated by qemu.
+1af4 vendor ID
+--------------
 
-All other device IDs are reserved.
-
-
-VirtIO Device IDs
------------------
+The 1000 -> 10ff device ID range is used as follows for virtio-pci devices.
+Note that this allocation separate from the virtio device IDs, which are
+maintained as part of the virtio specification.
 
 1af4:1000  network device
 1af4:1001  block device
 1af4:1002  balloon device
 1af4:1003  console device
-
-1af4:1004  Reserved.
-   to      Contact Gerd Hoffmann <[email protected]> to get a
-1af4:10ef  device ID assigned for your new virtio device.
+1af4:1004  SCSI host bus adapter device
+1af4:1005  entropy generator device
 
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking
 1af4:10ff  upstream merge or shipping a distro/product) to avoid conflicts.
 
+1af4:1100  Used as PCI Subsystem ID for existing hardware devices emulated
+           by qemu.
+
+All other device IDs are reserved.
Signature · 1 line
1.8.0.1
#3 lore raw

PATCH v2 3/5 virtio-9p: use symbolic constant, add to pci-ids.txt

In reply to Paolo Bonzini
---
 docs/specs/pci-ids.txt     | 1 +
 hw/9pfs/virtio-9p-device.c | 2 +-
 hw/pci.h                   | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
docs/specs/pci-ids.txt +1 -0
index df2527f..2d5329a 100644
@@ -21,6 +21,7 @@ maintained as part of the virtio specification.
 1af4:1003  console device
 1af4:1004  SCSI host bus adapter device
 1af4:1005  entropy generator device
+1af4:1009  9p filesystem device
 
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking
hw/9pfs/virtio-9p-device.c +1 -1
index b8220ab..e338c46 100644
@@ -170,7 +170,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data)
 
     k->init = virtio_9p_init_pci;
     k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
-    k->device_id = 0x1009;
+    k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
     k->revision = VIRTIO_PCI_ABI_VERSION;
     k->class_id = 0x2;
     dc->props = virtio_9p_properties;
hw/pci.h +1 -0
index 4da0c2a..0719521 100644
@@ -77,6 +77,7 @@
 #define PCI_DEVICE_ID_VIRTIO_CONSOLE     0x1003
 #define PCI_DEVICE_ID_VIRTIO_SCSI        0x1004
 #define PCI_DEVICE_ID_VIRTIO_RNG         0x1005
+#define PCI_DEVICE_ID_VIRTIO_9P          0x1009
 
 #define FMT_PCIBUS                      PRIx64
 
Signature · 1 line
1.8.0.1
#4 lore raw

PATCH v2 4/5 ivshmem: use symbolic constant for PCI ID, add to pci-ids.txt

In reply to Paolo Bonzini

Due to disagreement on a name that is generic enough for hw/pci.h, the symbolic constants are placed in the .c files.

---
 docs/specs/pci-ids.txt | 2 ++
 hw/ivshmem.c           | 7 +++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
docs/specs/pci-ids.txt +2 -0
index 2d5329a..e76b196 100644
@@ -30,4 +30,6 @@ maintained as part of the virtio specification.
 1af4:1100  Used as PCI Subsystem ID for existing hardware devices emulated
            by qemu.
 
+1af4:1110  ivshmem device (shared memory, docs/specs/ivshmem_device_spec.txt)
+
 All other device IDs are reserved.
hw/ivshmem.c +5 -2
index f6dbb21..9520daa 100644
@@ -28,6 +28,9 @@
 #include <sys/mman.h>
 #include <sys/types.h>
 
+#define PCI_VENDOR_ID_IVSHMEM   PCI_VENDOR_ID_REDHAT_QUMRANET
+#define PCI_DEVICE_ID_IVSHMEM   0x1110
+
 #define IVSHMEM_IOEVENTFD   0
 #define IVSHMEM_MSI     1
 
@@ -799,8 +802,8 @@ static void ivshmem_class_init(ObjectClass *klass, void *data)
 
     k->init = pci_ivshmem_init;
     k->exit = pci_ivshmem_uninit;
-    k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
-    k->device_id = 0x1110;
+    k->vendor_id = PCI_VENDOR_ID_IVSHMEM;
+    k->device_id = PCI_DEVICE_ID_IVSHMEM;
     k->class_id = PCI_CLASS_MEMORY_RAM;
     dc->reset = ivshmem_reset;
     dc->props = ivshmem_properties;
Signature · 1 line
1.8.0.1
#5 lore raw

PATCH v2 5/5 pci: use constants for devices under the 1B36 device ID, document them

In reply to Paolo Bonzini
---
 docs/specs/pci-ids.txt | 15 +++++++++++++++
 hw/pci.h               |  7 +++++++
 hw/pci_bridge_dev.c    |  8 ++------
 hw/serial-pci.c        | 12 ++++++------
 4 files changed, 30 insertions(+), 12 deletions(-)
docs/specs/pci-ids.txt +15 -0
index e76b196..3c65e1a 100644
@@ -33,3 +33,18 @@ maintained as part of the virtio specification.
 1af4:1110  ivshmem device (shared memory, docs/specs/ivshmem_device_spec.txt)
 
 All other device IDs are reserved.
+
+1b36 vendor ID
+--------------
+
+The 0000 -> 00ff device ID range is used as follows for QEMU-specific
+PCI devices (other than virtio):
+
+1b36:0001  PCI-PCI bridge
+1b36:0002  PCI serial port (16550A) adapter (docs/specs/pci-serial.txt)
+1b36:0003  PCI Dual-port 16550A adapter (docs/specs/pci-serial.txt)
+1b36:0004  PCI Quad-port 16550A adapter (docs/specs/pci-serial.txt)
+
+All these devices are documented in docs/specs.
+
+The 0100 device ID is used for the QXL video card device.
hw/pci.h +7 -0
index 0719521..4b2a09b 100644
@@ -79,6 +79,13 @@
 #define PCI_DEVICE_ID_VIRTIO_RNG         0x1005
 #define PCI_DEVICE_ID_VIRTIO_9P          0x1009
 
+#define PCI_VENDOR_ID_REDHAT             0x1b36
+#define PCI_DEVICE_ID_REDHAT_BRIDGE      0x0001
+#define PCI_DEVICE_ID_REDHAT_SERIAL      0x0002
+#define PCI_DEVICE_ID_REDHAT_SERIAL2     0x0003
+#define PCI_DEVICE_ID_REDHAT_SERIAL4     0x0004
+#define PCI_DEVICE_ID_REDHAT_QXL         0x0100
+
 #define FMT_PCIBUS                      PRIx64
 
 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
hw/pci_bridge_dev.c +2 -6
index f706396..d72bd3d 100644
@@ -27,10 +27,6 @@
 #include "memory.h"
 #include "pci_internals.h"
 
-#define REDHAT_PCI_VENDOR_ID 0x1b36
-#define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID
-#define PCI_BRIDGE_DEV_DEVICE_ID 0x1
-
 struct PCIBridgeDev {
     PCIBridge bridge;
     MemoryRegion bar;
@@ -146,8 +142,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data)
     k->init = pci_bridge_dev_initfn;
     k->exit = pci_bridge_dev_exitfn;
     k->config_write = pci_bridge_dev_write_config;
-    k->vendor_id = PCI_BRIDGE_DEV_VENDOR_ID;
-    k->device_id = PCI_BRIDGE_DEV_DEVICE_ID;
+    k->vendor_id = PCI_VENDOR_ID_REDHAT;
+    k->device_id = PCI_DEVICE_ID_REDHAT_BRIDGE;
     k->class_id = PCI_CLASS_BRIDGE_PCI;
     k->is_bridge = 1,
     dc->desc = "Standard PCI Bridge";
hw/serial-pci.c +6 -6
index 95dc5c8..f7be5fd 100644
@@ -185,8 +185,8 @@ static void serial_pci_class_initfn(ObjectClass *klass, void *data)
     PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
     pc->init = serial_pci_init;
     pc->exit = serial_pci_exit;
-    pc->vendor_id = 0x1b36; /* Red Hat */
-    pc->device_id = 0x0002;
+    pc->vendor_id = PCI_VENDOR_ID_REDHAT;
+    pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL;
     pc->revision = 1;
     pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL;
     dc->vmsd = &vmstate_pci_serial;
@@ -199,8 +199,8 @@ static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data)
     PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
     pc->init = multi_serial_pci_init;
     pc->exit = multi_serial_pci_exit;
-    pc->vendor_id = 0x1b36; /* Red Hat */
-    pc->device_id = 0x0003;
+    pc->vendor_id = PCI_VENDOR_ID_REDHAT;
+    pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL2;
     pc->revision = 1;
     pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL;
     dc->vmsd = &vmstate_pci_multi_serial;
@@ -213,8 +213,8 @@ static void multi_4x_serial_pci_class_initfn(ObjectClass *klass, void *data)
     PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
     pc->init = multi_serial_pci_init;
     pc->exit = multi_serial_pci_exit;
-    pc->vendor_id = 0x1b36; /* Red Hat */
-    pc->device_id = 0x0004;
+    pc->vendor_id = PCI_VENDOR_ID_REDHAT;
+    pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL4;
     pc->revision = 1;
     pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL;
     dc->vmsd = &vmstate_pci_multi_serial;
Signature · 1 line
1.8.0.1
#6 lore raw
In reply to Paolo Bonzini

Il 13/12/2012 10:19, Paolo Bonzini ha scritto:

Quoted 3 lines

Five small, boring patches. Inspired by Gerd's patch at
http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05229.html which unfortunately is already out of date.

Ping...

Paolo

Quoted 18 lines

Paolo Bonzini (5):
docs: move pci-ids.txt to docs/specs/
reorganize pci-ids.txt
virtio-9p: use symbolic constant, add to pci-ids.txt
ivshmem: use symbolic constant for PCI ID, add to pci-ids.txt
pci: use constants for devices under the 1B36 device ID, document them

 docs/specs/pci-ids.txt     | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/9pfs/virtio-9p-device.c |  2 +-
 hw/ivshmem.c               |  7 +++++--
 hw/pci.h                   |  8 ++++++++
 hw/pci_bridge_dev.c        |  8 ++------
 hw/serial-pci.c            | 12 +++++------
 pci-ids.txt                | 31 ----------------------------
 7 files changed, 72 insertions(+), 46 deletions(-)
 create mode 100644 docs/specs/pci-ids.txt
 delete mode 100644 pci-ids.txt
#7 lore raw

Il 27/12/2012 17:29, Paolo Bonzini ha scritto:

Quoted 6 lines

Il 13/12/2012 10:19, Paolo Bonzini ha scritto:

Quoted 3 lines

Five small, boring patches. Inspired by Gerd's patch at
http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05229.html which unfortunately is already out of date.

Ping...

Ping^2...

Paolo

Quoted 23 lines

Paolo

Quoted 18 lines

Paolo Bonzini (5):
docs: move pci-ids.txt to docs/specs/
reorganize pci-ids.txt
virtio-9p: use symbolic constant, add to pci-ids.txt
ivshmem: use symbolic constant for PCI ID, add to pci-ids.txt
pci: use constants for devices under the 1B36 device ID, document them

 docs/specs/pci-ids.txt     | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/9pfs/virtio-9p-device.c |  2 +-
 hw/ivshmem.c               |  7 +++++--
 hw/pci.h                   |  8 ++++++++
 hw/pci_bridge_dev.c        |  8 ++------
 hw/serial-pci.c            | 12 +++++------
 pci-ids.txt                | 31 ----------------------------
 7 files changed, 72 insertions(+), 46 deletions(-)
 create mode 100644 docs/specs/pci-ids.txt
 delete mode 100644 pci-ids.txt