aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-18 12:24:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-18 12:24:01 -0500
commit53861af9a17022898619a2ae4ead0dfc601b7c13 (patch)
treedc11088d9e86fa1d8d8479974864153a8f976897 /include/uapi
parent5c2770079fb9b8c5bfb7113d9e76de66e77a0e24 (diff)
parent5b40a7daf51812b35cf05d1601a779a7043f8414 (diff)
Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull virtio updates from Rusty Russell: "OK, this has the big virtio 1.0 implementation, as specified by OASIS. On top of tht is the major rework of lguest, to use PCI and virtio 1.0, to double-check the implementation. Then comes the inevitable fixes and cleanups from that work" * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (80 commits) virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice. virtio_net: unconditionally define struct virtio_net_hdr_v1. tools/lguest: don't use legacy definitions for net device in example launcher. virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined. tools/lguest: use common error macros in the example launcher. tools/lguest: give virtqueues names for better error messages tools/lguest: more documentation and checking of virtio 1.0 compliance. lguest: don't look in console features to find emerg_wr. tools/lguest: don't start devices until DRIVER_OK status set. tools/lguest: handle indirect partway through chain. tools/lguest: insert driver references from the 1.0 spec (4.1 Virtio Over PCI) tools/lguest: insert device references from the 1.0 spec (4.1 Virtio Over PCI) tools/lguest: rename virtio_pci_cfg_cap field to match spec. tools/lguest: fix features_accepted logic in example launcher. tools/lguest: handle device reset correctly in example launcher. virtual: Documentation: simplify and generalize paravirt_ops.txt lguest: remove NOTIFY call and eventfd facility. lguest: remove NOTIFY facility from demonstration launcher. lguest: use the PCI console device's emerg_wr for early boot messages. lguest: always put console in PCI slot #1. ...
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/linux/virtio_balloon.h3
-rw-r--r--include/uapi/linux/virtio_blk.h17
-rw-r--r--include/uapi/linux/virtio_config.h2
-rw-r--r--include/uapi/linux/virtio_net.h42
-rw-r--r--include/uapi/linux/virtio_pci.h93
5 files changed, 141 insertions, 16 deletions
diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index be40f7059e93..4b0488f20b2e 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -36,8 +36,7 @@
36/* Size of a PFN in the balloon interface. */ 36/* Size of a PFN in the balloon interface. */
37#define VIRTIO_BALLOON_PFN_SHIFT 12 37#define VIRTIO_BALLOON_PFN_SHIFT 12
38 38
39struct virtio_balloon_config 39struct virtio_balloon_config {
40{
41 /* Number of pages host wants Guest to give up. */ 40 /* Number of pages host wants Guest to give up. */
42 __le32 num_pages; 41 __le32 num_pages;
43 /* Number of pages we've actually got in balloon. */ 42 /* Number of pages we've actually got in balloon. */
diff --git a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h
index 247c8ba8544a..3c53eec4ae22 100644
--- a/include/uapi/linux/virtio_blk.h
+++ b/include/uapi/linux/virtio_blk.h
@@ -31,22 +31,25 @@
31#include <linux/virtio_types.h> 31#include <linux/virtio_types.h>
32 32
33/* Feature bits */ 33/* Feature bits */
34#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
35#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ 34#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
36#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ 35#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
37#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ 36#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
38#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 37#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
39#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ 38#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
40#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
41#define VIRTIO_BLK_F_WCE 9 /* Writeback mode enabled after reset */
42#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ 39#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
43#define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */
44#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ 40#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */
45 41
42/* Legacy feature bits */
43#ifndef VIRTIO_BLK_NO_LEGACY
44#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
45#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
46#define VIRTIO_BLK_F_WCE 9 /* Writeback mode enabled after reset */
47#define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */
46#ifndef __KERNEL__ 48#ifndef __KERNEL__
47/* Old (deprecated) name for VIRTIO_BLK_F_WCE. */ 49/* Old (deprecated) name for VIRTIO_BLK_F_WCE. */
48#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE 50#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE
49#endif 51#endif
52#endif /* !VIRTIO_BLK_NO_LEGACY */
50 53
51#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */ 54#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
52 55
@@ -100,8 +103,10 @@ struct virtio_blk_config {
100#define VIRTIO_BLK_T_IN 0 103#define VIRTIO_BLK_T_IN 0
101#define VIRTIO_BLK_T_OUT 1 104#define VIRTIO_BLK_T_OUT 1
102 105
106#ifndef VIRTIO_BLK_NO_LEGACY
103/* This bit says it's a scsi command, not an actual read or write. */ 107/* This bit says it's a scsi command, not an actual read or write. */
104#define VIRTIO_BLK_T_SCSI_CMD 2 108#define VIRTIO_BLK_T_SCSI_CMD 2
109#endif /* VIRTIO_BLK_NO_LEGACY */
105 110
106/* Cache flush command */ 111/* Cache flush command */
107#define VIRTIO_BLK_T_FLUSH 4 112#define VIRTIO_BLK_T_FLUSH 4
@@ -109,8 +114,10 @@ struct virtio_blk_config {
109/* Get device ID command */ 114/* Get device ID command */
110#define VIRTIO_BLK_T_GET_ID 8 115#define VIRTIO_BLK_T_GET_ID 8
111 116
117#ifndef VIRTIO_BLK_NO_LEGACY
112/* Barrier before this op. */ 118/* Barrier before this op. */
113#define VIRTIO_BLK_T_BARRIER 0x80000000 119#define VIRTIO_BLK_T_BARRIER 0x80000000
120#endif /* !VIRTIO_BLK_NO_LEGACY */
114 121
115/* This is the first element of the read scatter-gather list. */ 122/* This is the first element of the read scatter-gather list. */
116struct virtio_blk_outhdr { 123struct virtio_blk_outhdr {
@@ -122,12 +129,14 @@ struct virtio_blk_outhdr {
122 __virtio64 sector; 129 __virtio64 sector;
123}; 130};
124 131
132#ifndef VIRTIO_BLK_NO_LEGACY
125struct virtio_scsi_inhdr { 133struct virtio_scsi_inhdr {
126 __virtio32 errors; 134 __virtio32 errors;
127 __virtio32 data_len; 135 __virtio32 data_len;
128 __virtio32 sense_len; 136 __virtio32 sense_len;
129 __virtio32 residual; 137 __virtio32 residual;
130}; 138};
139#endif /* !VIRTIO_BLK_NO_LEGACY */
131 140
132/* And this is the final byte of the write scatter-gather list. */ 141/* And this is the final byte of the write scatter-gather list. */
133#define VIRTIO_BLK_S_OK 0 142#define VIRTIO_BLK_S_OK 0
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
index a6d0cdeaacd4..c18264df9504 100644
--- a/include/uapi/linux/virtio_config.h
+++ b/include/uapi/linux/virtio_config.h
@@ -49,12 +49,14 @@
49#define VIRTIO_TRANSPORT_F_START 28 49#define VIRTIO_TRANSPORT_F_START 28
50#define VIRTIO_TRANSPORT_F_END 33 50#define VIRTIO_TRANSPORT_F_END 33
51 51
52#ifndef VIRTIO_CONFIG_NO_LEGACY
52/* Do we get callbacks when the ring is completely used, even if we've 53/* Do we get callbacks when the ring is completely used, even if we've
53 * suppressed them? */ 54 * suppressed them? */
54#define VIRTIO_F_NOTIFY_ON_EMPTY 24 55#define VIRTIO_F_NOTIFY_ON_EMPTY 24
55 56
56/* Can the device handle any descriptor layout? */ 57/* Can the device handle any descriptor layout? */
57#define VIRTIO_F_ANY_LAYOUT 27 58#define VIRTIO_F_ANY_LAYOUT 27
59#endif /* VIRTIO_CONFIG_NO_LEGACY */
58 60
59/* v1.0 compliant. */ 61/* v1.0 compliant. */
60#define VIRTIO_F_VERSION_1 32 62#define VIRTIO_F_VERSION_1 32
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index b5f1677b291c..7bbee79ca293 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -35,7 +35,6 @@
35#define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ 35#define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */
36#define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ 36#define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
37#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ 37#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
38#define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */
39#define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ 38#define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
40#define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ 39#define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
41#define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ 40#define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */
@@ -56,6 +55,10 @@
56 * Steering */ 55 * Steering */
57#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ 56#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
58 57
58#ifndef VIRTIO_NET_NO_LEGACY
59#define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */
60#endif /* VIRTIO_NET_NO_LEGACY */
61
59#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 62#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
60#define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ 63#define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
61 64
@@ -71,19 +74,39 @@ struct virtio_net_config {
71 __u16 max_virtqueue_pairs; 74 __u16 max_virtqueue_pairs;
72} __attribute__((packed)); 75} __attribute__((packed));
73 76
77/*
78 * This header comes first in the scatter-gather list. If you don't
79 * specify GSO or CSUM features, you can simply ignore the header.
80 *
81 * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf,
82 * only flattened.
83 */
84struct virtio_net_hdr_v1 {
85#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
86#define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
87 __u8 flags;
88#define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
89#define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
90#define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */
91#define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */
92#define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */
93 __u8 gso_type;
94 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
95 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */
96 __virtio16 csum_start; /* Position to start checksumming from */
97 __virtio16 csum_offset; /* Offset after that to place checksum */
98 __virtio16 num_buffers; /* Number of merged rx buffers */
99};
100
101#ifndef VIRTIO_NET_NO_LEGACY
74/* This header comes first in the scatter-gather list. 102/* This header comes first in the scatter-gather list.
75 * If VIRTIO_F_ANY_LAYOUT is not negotiated, it must 103 * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
76 * be the first element of the scatter-gather list. If you don't 104 * be the first element of the scatter-gather list. If you don't
77 * specify GSO or CSUM features, you can simply ignore the header. */ 105 * specify GSO or CSUM features, you can simply ignore the header. */
78struct virtio_net_hdr { 106struct virtio_net_hdr {
79#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset 107 /* See VIRTIO_NET_HDR_F_* */
80#define VIRTIO_NET_HDR_F_DATA_VALID 2 // Csum is valid
81 __u8 flags; 108 __u8 flags;
82#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame 109 /* See VIRTIO_NET_HDR_GSO_* */
83#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO)
84#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
85#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
86#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set
87 __u8 gso_type; 110 __u8 gso_type;
88 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 111 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
89 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 112 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */
@@ -97,6 +120,7 @@ struct virtio_net_hdr_mrg_rxbuf {
97 struct virtio_net_hdr hdr; 120 struct virtio_net_hdr hdr;
98 __virtio16 num_buffers; /* Number of merged rx buffers */ 121 __virtio16 num_buffers; /* Number of merged rx buffers */
99}; 122};
123#endif /* ...VIRTIO_NET_NO_LEGACY */
100 124
101/* 125/*
102 * Control virtqueue data structures 126 * Control virtqueue data structures
diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
index 35b552c7f330..75301468359f 100644
--- a/include/uapi/linux/virtio_pci.h
+++ b/include/uapi/linux/virtio_pci.h
@@ -39,7 +39,7 @@
39#ifndef _LINUX_VIRTIO_PCI_H 39#ifndef _LINUX_VIRTIO_PCI_H
40#define _LINUX_VIRTIO_PCI_H 40#define _LINUX_VIRTIO_PCI_H
41 41
42#include <linux/virtio_config.h> 42#include <linux/types.h>
43 43
44#ifndef VIRTIO_PCI_NO_LEGACY 44#ifndef VIRTIO_PCI_NO_LEGACY
45 45
@@ -99,4 +99,95 @@
99/* Vector value used to disable MSI for queue */ 99/* Vector value used to disable MSI for queue */
100#define VIRTIO_MSI_NO_VECTOR 0xffff 100#define VIRTIO_MSI_NO_VECTOR 0xffff
101 101
102#ifndef VIRTIO_PCI_NO_MODERN
103
104/* IDs for different capabilities. Must all exist. */
105
106/* Common configuration */
107#define VIRTIO_PCI_CAP_COMMON_CFG 1
108/* Notifications */
109#define VIRTIO_PCI_CAP_NOTIFY_CFG 2
110/* ISR access */
111#define VIRTIO_PCI_CAP_ISR_CFG 3
112/* Device specific configuration */
113#define VIRTIO_PCI_CAP_DEVICE_CFG 4
114/* PCI configuration access */
115#define VIRTIO_PCI_CAP_PCI_CFG 5
116
117/* This is the PCI capability header: */
118struct virtio_pci_cap {
119 __u8 cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */
120 __u8 cap_next; /* Generic PCI field: next ptr. */
121 __u8 cap_len; /* Generic PCI field: capability length */
122 __u8 cfg_type; /* Identifies the structure. */
123 __u8 bar; /* Where to find it. */
124 __u8 padding[3]; /* Pad to full dword. */
125 __le32 offset; /* Offset within bar. */
126 __le32 length; /* Length of the structure, in bytes. */
127};
128
129struct virtio_pci_notify_cap {
130 struct virtio_pci_cap cap;
131 __le32 notify_off_multiplier; /* Multiplier for queue_notify_off. */
132};
133
134/* Fields in VIRTIO_PCI_CAP_COMMON_CFG: */
135struct virtio_pci_common_cfg {
136 /* About the whole device. */
137 __le32 device_feature_select; /* read-write */
138 __le32 device_feature; /* read-only */
139 __le32 guest_feature_select; /* read-write */
140 __le32 guest_feature; /* read-write */
141 __le16 msix_config; /* read-write */
142 __le16 num_queues; /* read-only */
143 __u8 device_status; /* read-write */
144 __u8 config_generation; /* read-only */
145
146 /* About a specific virtqueue. */
147 __le16 queue_select; /* read-write */
148 __le16 queue_size; /* read-write, power of 2. */
149 __le16 queue_msix_vector; /* read-write */
150 __le16 queue_enable; /* read-write */
151 __le16 queue_notify_off; /* read-only */
152 __le32 queue_desc_lo; /* read-write */
153 __le32 queue_desc_hi; /* read-write */
154 __le32 queue_avail_lo; /* read-write */
155 __le32 queue_avail_hi; /* read-write */
156 __le32 queue_used_lo; /* read-write */
157 __le32 queue_used_hi; /* read-write */
158};
159
160/* Macro versions of offsets for the Old Timers! */
161#define VIRTIO_PCI_CAP_VNDR 0
162#define VIRTIO_PCI_CAP_NEXT 1
163#define VIRTIO_PCI_CAP_LEN 2
164#define VIRTIO_PCI_CAP_CFG_TYPE 3
165#define VIRTIO_PCI_CAP_BAR 4
166#define VIRTIO_PCI_CAP_OFFSET 8
167#define VIRTIO_PCI_CAP_LENGTH 12
168
169#define VIRTIO_PCI_NOTIFY_CAP_MULT 16
170
171#define VIRTIO_PCI_COMMON_DFSELECT 0
172#define VIRTIO_PCI_COMMON_DF 4
173#define VIRTIO_PCI_COMMON_GFSELECT 8
174#define VIRTIO_PCI_COMMON_GF 12
175#define VIRTIO_PCI_COMMON_MSIX 16
176#define VIRTIO_PCI_COMMON_NUMQ 18
177#define VIRTIO_PCI_COMMON_STATUS 20
178#define VIRTIO_PCI_COMMON_CFGGENERATION 21
179#define VIRTIO_PCI_COMMON_Q_SELECT 22
180#define VIRTIO_PCI_COMMON_Q_SIZE 24
181#define VIRTIO_PCI_COMMON_Q_MSIX 26
182#define VIRTIO_PCI_COMMON_Q_ENABLE 28
183#define VIRTIO_PCI_COMMON_Q_NOFF 30
184#define VIRTIO_PCI_COMMON_Q_DESCLO 32
185#define VIRTIO_PCI_COMMON_Q_DESCHI 36
186#define VIRTIO_PCI_COMMON_Q_AVAILLO 40
187#define VIRTIO_PCI_COMMON_Q_AVAILHI 44
188#define VIRTIO_PCI_COMMON_Q_USEDLO 48
189#define VIRTIO_PCI_COMMON_Q_USEDHI 52
190
191#endif /* VIRTIO_PCI_NO_MODERN */
192
102#endif 193#endif