virtio-net pci config space

来源:互联网 发布:淘宝app用户体验报告 编辑:程序博客网 时间:2024/06/18 08:06
Introduction
This article will focus on the details of virtio 1.0 device PCI config space. It will be centered around a sample virtio net PCI config taken from a real running virtual machine and explain every single field.


Sample PCI Config Space For Virtio Net Device
The following is the hexadecimal dump of the configuration space of a virtio net device:
00:04.0 Ethernet controller: Red Hat, Inc Device 1041 (rev 01)
00: f4 1a 41 10 07 05 10 00 01 00 00 02 00 00 00 00
10: 00 00 00 00 00 20 bd fe 00 00 00 00 00 00 00 00
20: 0c 00 00 fe 00 00 00 00 00 00 00 00 f4 1a 00 11
30: 00 00 b8 fe 98 00 00 00 00 00 00 00 0b 01 00 00
40: 09 00 10 01 04 00 00 00 00 00 00 00 00 10 00 00
50: 09 40 10 03 04 00 00 00 00 10 00 00 00 10 00 00
60: 09 50 10 04 04 00 00 00 00 20 00 00 00 10 00 00
70: 09 60 14 02 04 00 00 00 00 30 00 00 00 00 40 00
80: 00 10 00 00 09 70 14 05 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 11 84 02 80 01 00 00 00
a0: 01 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Config Item Explanation
Please refer to 'PCI Device Structure' in PCI - OSDev Wiki for a complete reference of PCI config space layout for type 00 device.
The PCI Device ID is calculated by adding 0x1040 to the Virtio Device ID.  
Device ID : 0x1041
PCI Device ID 0x1000 through 0x107F inclusive is a virtio device:
Vendor ID: 0x1af4
Bit 4 is on, meaning that capability list is in use.
Status: 0x0010
System error control enabled, Legacy interrupt disabled, io and memory space both enabled, capable of acting as bus master.
Command: 0x0507
Network Controller
Class code: 0x02
Ethernet Controller
Subclass: 0x00
Normal decode, Together with the subclass code to further specify the device.
Prog IF: 0x00
Virtio 1.0
Revision ID: 0x01
Not supporting built-in self test
BIST: 0x00
General device
Header type: 0x00
Latency count to hold the bus
Latency Timer: 0x00
Not specifying cache line size
Cache Line Size: 0x00
None
BAR0: 0x00000000
A memory bar at 0xfebd2000
BAR1: 0xfebd2000
None
BAR2: 0x00000000
None
BAR3: 0x00000000
A 64bit memory bar at 0xfe00000000000000
BAR4: 0xfe00000c
Lower 32bit of the memory location BAR4  points at
BAR5: 0x00000000
None
Cardbus CIS Pointer: 0x0000
Emulating existing hardware, not relevant for virtio net device
Subsystem ID: 0x1100
PCI Vendor ID
Subsystem Vendor ID: 0x1af4
Start of the capability list
Capabilities Pointer: 0x98
Max bus latency device, not set
Max latency: 0x00
Burst period length the device needs, not set
Min Grant: 0x00
The interrupt pin the device uses
Interrupt PIN: 0x01
Input of system interrupt controllers the interrupt pin connects to
Interrupt Line: 0x0b


Capability List Explanation
First capability at 0x98:
11 84 02 80
01 00 00 00
01 08 00 00
MSI-X capablility
Capability ID: 0x11
Next capability at 84
Next Pointer: 0x84
MSI-X enabled
Message Control: 0x8020
Vector table location
Vector table offset 0x000000
Vector table BAR 0x01
PBA location
PBA offset 0x00000800
PBA BAR 0x01


Second capability at 0x84:
09 70 14 05
​00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00
Vendor-specific capability
Vendor: 0x09
Next capability at 0x70
Next Pointer: 0x70
Lens of this capability struct
Len: 0x14
PCI Configuration access - an alternative way to access other config regions
Type: 0x05
Not specified
BAR: 0x00
Padding
Padding: 0x000000
Not specified
Offset 0x00000000
Not specified
Length: 0x00000000
Not specified
pci_cfg_data 0x00000000


Third capability at 0x70
09 60 14 02
​04 00 00 00
00 30 00 00
00 00 40 00
00 10 00 00
Vendor-specific capability
Vendor: 0x09
Next capability at 0x60
Next Pointer: 0x60
Lens of this capability struct
Len: 0x14
Notifications - the place(s) to delivery queue notification/kick
Type: 0x02
The forth BAR
BAR: 0x04
Padding
Padding: 0x000000
Offset within the BAR
Offset: 0x00003000
Length of the notification structure within the BAR
Length: 0x00400000


Forth capability at 0x60:
09 50 10 04
​04 00 00 00
00 20 00 00
00 10 00 00
Vendor-specific capability
Vendor: 0x09
Next capability at 0x50
Next Pointer: 0x50
Lens of this capability struct
Len: 0x10
Device specific configuration
Type: 0x04
The forth BAR
BAR 0x04
Padding
Padding: 0x000000
Offset within the BAR
Offset: 0x00002000
Length of the notification structure within the BAR
Length: 0x0001000


Fifth capability at 0x50:
09 40 10 03
​04 00 00 00
00 10 00 00
00 10 00 00
Vendor-specific capability
Vendor: 0x09
Next capability at 0x40
Next: 0x40
Lens of this capability struct
Len: 0x10
ISR Status for queue and device configuration interrupt
Type: 0x03
The forth BAR
BAR: 0x04
Padding
Padding: 0x000000
Offset within the BAR
Offset: 0x00001000
Length of the notification structure
Lenght: 0x0001000


Sixth capability at 0x40
09 00 10 01
04 00 00 00
00 00 00 00
00 10 00 00
Vendor-specific capability
Vendor: 0x09
Last capabillity struct in the list
Next Pointer: 0x00
Lens of this capability struct
Len: 0x10
Common configuration - common Virtio device configuration
Type: 0x01
The forth BAR
BAR: 0x04
Padding
Padding: 0x000000
Offset within the BAR
Offset: 0x00000000
Length of the notification structure
Length: 0x0001000
0 0