diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 15:20:31 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 15:20:31 -0500 |
| commit | 6b9e2cea428cf7af93a84bcb865e478d8bf1c165 (patch) | |
| tree | 11be387e37129fce0c4c111803df1a2e56637b60 /include/uapi/linux | |
| parent | 14ba9a2e4bacc6f5a0dbe0de5390daedd544508f (diff) | |
| parent | f01a2a811ae04124fc9382925038fcbbd2f0b7c8 (diff) | |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin:
"virtio: virtio 1.0 support, misc patches
This adds a lot of infrastructure for virtio 1.0 support. Notable
missing pieces: virtio pci, virtio balloon (needs spec extension),
vhost scsi.
Plus, there are some minor fixes in a couple of places.
Note: some net drivers are affected by these patches. David said he's
fine with merging these patches through my tree.
Rusty's on vacation, he acked using my tree for these, too"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (70 commits)
virtio_ccw: finalize_features error handling
virtio_ccw: future-proof finalize_features
virtio_pci: rename virtio_pci -> virtio_pci_common
virtio_pci: update file descriptions and copyright
virtio_pci: split out legacy device support
virtio_pci: setup config vector indirectly
virtio_pci: setup vqs indirectly
virtio_pci: delete vqs indirectly
virtio_pci: use priv for vq notification
virtio_pci: free up vq->priv
virtio_pci: fix coding style for structs
virtio_pci: add isr field
virtio: drop legacy_only driver flag
virtio_balloon: drop legacy_only driver flag
virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
virtio: allow finalize_features to fail
virtio_ccw: legacy: don't negotiate rev 1/features
virtio: add API to detect legacy devices
virtio_console: fix sparse warnings
vhost: remove unnecessary forward declarations in vhost.h
...
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/Kbuild | 2 | ||||
| -rw-r--r-- | include/uapi/linux/if_tun.h | 17 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_blk.h | 15 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_config.h | 9 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_console.h | 7 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_net.h | 15 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_ring.h | 45 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_scsi.h | 164 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_types.h | 46 |
9 files changed, 266 insertions, 54 deletions
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index 401c4c3ec285..c54fcb5993c3 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild | |||
| @@ -424,10 +424,12 @@ header-y += virtio_blk.h | |||
| 424 | header-y += virtio_config.h | 424 | header-y += virtio_config.h |
| 425 | header-y += virtio_console.h | 425 | header-y += virtio_console.h |
| 426 | header-y += virtio_ids.h | 426 | header-y += virtio_ids.h |
| 427 | header-y += virtio_types.h | ||
| 427 | header-y += virtio_net.h | 428 | header-y += virtio_net.h |
| 428 | header-y += virtio_pci.h | 429 | header-y += virtio_pci.h |
| 429 | header-y += virtio_ring.h | 430 | header-y += virtio_ring.h |
| 430 | header-y += virtio_rng.h | 431 | header-y += virtio_rng.h |
| 432 | header-y += virtio_scsi.h | ||
| 431 | header-y += vm_sockets.h | 433 | header-y += vm_sockets.h |
| 432 | header-y += vt.h | 434 | header-y += vt.h |
| 433 | header-y += wait.h | 435 | header-y += wait.h |
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h index e9502dd1ee2c..18b2403982f9 100644 --- a/include/uapi/linux/if_tun.h +++ b/include/uapi/linux/if_tun.h | |||
| @@ -22,21 +22,11 @@ | |||
| 22 | 22 | ||
| 23 | /* Read queue size */ | 23 | /* Read queue size */ |
| 24 | #define TUN_READQ_SIZE 500 | 24 | #define TUN_READQ_SIZE 500 |
| 25 | 25 | /* TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. */ | |
| 26 | /* TUN device flags */ | 26 | #define TUN_TUN_DEV IFF_TUN |
| 27 | #define TUN_TUN_DEV 0x0001 | 27 | #define TUN_TAP_DEV IFF_TAP |
| 28 | #define TUN_TAP_DEV 0x0002 | ||
| 29 | #define TUN_TYPE_MASK 0x000f | 28 | #define TUN_TYPE_MASK 0x000f |
| 30 | 29 | ||
| 31 | #define TUN_FASYNC 0x0010 | ||
| 32 | #define TUN_NOCHECKSUM 0x0020 | ||
| 33 | #define TUN_NO_PI 0x0040 | ||
| 34 | /* This flag has no real effect */ | ||
| 35 | #define TUN_ONE_QUEUE 0x0080 | ||
| 36 | #define TUN_PERSIST 0x0100 | ||
| 37 | #define TUN_VNET_HDR 0x0200 | ||
| 38 | #define TUN_TAP_MQ 0x0400 | ||
| 39 | |||
| 40 | /* Ioctl defines */ | 30 | /* Ioctl defines */ |
| 41 | #define TUNSETNOCSUM _IOW('T', 200, int) | 31 | #define TUNSETNOCSUM _IOW('T', 200, int) |
| 42 | #define TUNSETDEBUG _IOW('T', 201, int) | 32 | #define TUNSETDEBUG _IOW('T', 201, int) |
| @@ -67,6 +57,7 @@ | |||
| 67 | #define IFF_ONE_QUEUE 0x2000 | 57 | #define IFF_ONE_QUEUE 0x2000 |
| 68 | #define IFF_VNET_HDR 0x4000 | 58 | #define IFF_VNET_HDR 0x4000 |
| 69 | #define IFF_TUN_EXCL 0x8000 | 59 | #define IFF_TUN_EXCL 0x8000 |
| 60 | #define IFF_VNET_LE 0x10000 | ||
| 70 | #define IFF_MULTI_QUEUE 0x0100 | 61 | #define IFF_MULTI_QUEUE 0x0100 |
| 71 | #define IFF_ATTACH_QUEUE 0x0200 | 62 | #define IFF_ATTACH_QUEUE 0x0200 |
| 72 | #define IFF_DETACH_QUEUE 0x0400 | 63 | #define IFF_DETACH_QUEUE 0x0400 |
diff --git a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h index 9ad67b267584..247c8ba8544a 100644 --- a/include/uapi/linux/virtio_blk.h +++ b/include/uapi/linux/virtio_blk.h | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/virtio_ids.h> | 29 | #include <linux/virtio_ids.h> |
| 30 | #include <linux/virtio_config.h> | 30 | #include <linux/virtio_config.h> |
| 31 | #include <linux/virtio_types.h> | ||
| 31 | 32 | ||
| 32 | /* Feature bits */ | 33 | /* Feature bits */ |
| 33 | #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ | 34 | #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ |
| @@ -114,18 +115,18 @@ struct virtio_blk_config { | |||
| 114 | /* This is the first element of the read scatter-gather list. */ | 115 | /* This is the first element of the read scatter-gather list. */ |
| 115 | struct virtio_blk_outhdr { | 116 | struct virtio_blk_outhdr { |
| 116 | /* VIRTIO_BLK_T* */ | 117 | /* VIRTIO_BLK_T* */ |
| 117 | __u32 type; | 118 | __virtio32 type; |
| 118 | /* io priority. */ | 119 | /* io priority. */ |
| 119 | __u32 ioprio; | 120 | __virtio32 ioprio; |
| 120 | /* Sector (ie. 512 byte offset) */ | 121 | /* Sector (ie. 512 byte offset) */ |
| 121 | __u64 sector; | 122 | __virtio64 sector; |
| 122 | }; | 123 | }; |
| 123 | 124 | ||
| 124 | struct virtio_scsi_inhdr { | 125 | struct virtio_scsi_inhdr { |
| 125 | __u32 errors; | 126 | __virtio32 errors; |
| 126 | __u32 data_len; | 127 | __virtio32 data_len; |
| 127 | __u32 sense_len; | 128 | __virtio32 sense_len; |
| 128 | __u32 residual; | 129 | __virtio32 residual; |
| 129 | }; | 130 | }; |
| 130 | 131 | ||
| 131 | /* And this is the final byte of the write scatter-gather list. */ | 132 | /* And this is the final byte of the write scatter-gather list. */ |
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 3ce768c6910d..a6d0cdeaacd4 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h | |||
| @@ -38,14 +38,16 @@ | |||
| 38 | #define VIRTIO_CONFIG_S_DRIVER 2 | 38 | #define VIRTIO_CONFIG_S_DRIVER 2 |
| 39 | /* Driver has used its parts of the config, and is happy */ | 39 | /* Driver has used its parts of the config, and is happy */ |
| 40 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 | 40 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 |
| 41 | /* Driver has finished configuring features */ | ||
| 42 | #define VIRTIO_CONFIG_S_FEATURES_OK 8 | ||
| 41 | /* We've given up on this device. */ | 43 | /* We've given up on this device. */ |
| 42 | #define VIRTIO_CONFIG_S_FAILED 0x80 | 44 | #define VIRTIO_CONFIG_S_FAILED 0x80 |
| 43 | 45 | ||
| 44 | /* Some virtio feature bits (currently bits 28 through 31) are reserved for the | 46 | /* Some virtio feature bits (currently bits 28 through 32) are reserved for the |
| 45 | * transport being used (eg. virtio_ring), the rest are per-device feature | 47 | * transport being used (eg. virtio_ring), the rest are per-device feature |
| 46 | * bits. */ | 48 | * bits. */ |
| 47 | #define VIRTIO_TRANSPORT_F_START 28 | 49 | #define VIRTIO_TRANSPORT_F_START 28 |
| 48 | #define VIRTIO_TRANSPORT_F_END 32 | 50 | #define VIRTIO_TRANSPORT_F_END 33 |
| 49 | 51 | ||
| 50 | /* Do we get callbacks when the ring is completely used, even if we've | 52 | /* Do we get callbacks when the ring is completely used, even if we've |
| 51 | * suppressed them? */ | 53 | * suppressed them? */ |
| @@ -54,4 +56,7 @@ | |||
| 54 | /* Can the device handle any descriptor layout? */ | 56 | /* Can the device handle any descriptor layout? */ |
| 55 | #define VIRTIO_F_ANY_LAYOUT 27 | 57 | #define VIRTIO_F_ANY_LAYOUT 27 |
| 56 | 58 | ||
| 59 | /* v1.0 compliant. */ | ||
| 60 | #define VIRTIO_F_VERSION_1 32 | ||
| 61 | |||
| 57 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ | 62 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ |
diff --git a/include/uapi/linux/virtio_console.h b/include/uapi/linux/virtio_console.h index ba260dd0b33a..b7fb108c9310 100644 --- a/include/uapi/linux/virtio_console.h +++ b/include/uapi/linux/virtio_console.h | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #ifndef _UAPI_LINUX_VIRTIO_CONSOLE_H | 32 | #ifndef _UAPI_LINUX_VIRTIO_CONSOLE_H |
| 33 | #define _UAPI_LINUX_VIRTIO_CONSOLE_H | 33 | #define _UAPI_LINUX_VIRTIO_CONSOLE_H |
| 34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
| 35 | #include <linux/virtio_types.h> | ||
| 35 | #include <linux/virtio_ids.h> | 36 | #include <linux/virtio_ids.h> |
| 36 | #include <linux/virtio_config.h> | 37 | #include <linux/virtio_config.h> |
| 37 | 38 | ||
| @@ -58,9 +59,9 @@ struct virtio_console_config { | |||
| 58 | * particular port. | 59 | * particular port. |
| 59 | */ | 60 | */ |
| 60 | struct virtio_console_control { | 61 | struct virtio_console_control { |
| 61 | __u32 id; /* Port number */ | 62 | __virtio32 id; /* Port number */ |
| 62 | __u16 event; /* The kind of control event (see below) */ | 63 | __virtio16 event; /* The kind of control event (see below) */ |
| 63 | __u16 value; /* Extra information for the key */ | 64 | __virtio16 value; /* Extra information for the key */ |
| 64 | }; | 65 | }; |
| 65 | 66 | ||
| 66 | /* Some events for control messages */ | 67 | /* Some events for control messages */ |
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 172a7f00780c..b5f1677b291c 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/virtio_ids.h> | 29 | #include <linux/virtio_ids.h> |
| 30 | #include <linux/virtio_config.h> | 30 | #include <linux/virtio_config.h> |
| 31 | #include <linux/virtio_types.h> | ||
| 31 | #include <linux/if_ether.h> | 32 | #include <linux/if_ether.h> |
| 32 | 33 | ||
| 33 | /* The feature bitmap for virtio net */ | 34 | /* The feature bitmap for virtio net */ |
| @@ -84,17 +85,17 @@ struct virtio_net_hdr { | |||
| 84 | #define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP | 85 | #define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP |
| 85 | #define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set | 86 | #define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set |
| 86 | __u8 gso_type; | 87 | __u8 gso_type; |
| 87 | __u16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ | 88 | __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ |
| 88 | __u16 gso_size; /* Bytes to append to hdr_len per frame */ | 89 | __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ |
| 89 | __u16 csum_start; /* Position to start checksumming from */ | 90 | __virtio16 csum_start; /* Position to start checksumming from */ |
| 90 | __u16 csum_offset; /* Offset after that to place checksum */ | 91 | __virtio16 csum_offset; /* Offset after that to place checksum */ |
| 91 | }; | 92 | }; |
| 92 | 93 | ||
| 93 | /* This is the version of the header to use when the MRG_RXBUF | 94 | /* This is the version of the header to use when the MRG_RXBUF |
| 94 | * feature has been negotiated. */ | 95 | * feature has been negotiated. */ |
| 95 | struct virtio_net_hdr_mrg_rxbuf { | 96 | struct virtio_net_hdr_mrg_rxbuf { |
| 96 | struct virtio_net_hdr hdr; | 97 | struct virtio_net_hdr hdr; |
| 97 | __u16 num_buffers; /* Number of merged rx buffers */ | 98 | __virtio16 num_buffers; /* Number of merged rx buffers */ |
| 98 | }; | 99 | }; |
| 99 | 100 | ||
| 100 | /* | 101 | /* |
| @@ -149,7 +150,7 @@ typedef __u8 virtio_net_ctrl_ack; | |||
| 149 | * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. | 150 | * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. |
| 150 | */ | 151 | */ |
| 151 | struct virtio_net_ctrl_mac { | 152 | struct virtio_net_ctrl_mac { |
| 152 | __u32 entries; | 153 | __virtio32 entries; |
| 153 | __u8 macs[][ETH_ALEN]; | 154 | __u8 macs[][ETH_ALEN]; |
| 154 | } __attribute__((packed)); | 155 | } __attribute__((packed)); |
| 155 | 156 | ||
| @@ -193,7 +194,7 @@ struct virtio_net_ctrl_mac { | |||
| 193 | * specified. | 194 | * specified. |
| 194 | */ | 195 | */ |
| 195 | struct virtio_net_ctrl_mq { | 196 | struct virtio_net_ctrl_mq { |
| 196 | __u16 virtqueue_pairs; | 197 | __virtio16 virtqueue_pairs; |
| 197 | }; | 198 | }; |
| 198 | 199 | ||
| 199 | #define VIRTIO_NET_CTRL_MQ 4 | 200 | #define VIRTIO_NET_CTRL_MQ 4 |
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index a99f9b7caa67..61c818a7fe70 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | * | 32 | * |
| 33 | * Copyright Rusty Russell IBM Corporation 2007. */ | 33 | * Copyright Rusty Russell IBM Corporation 2007. */ |
| 34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
| 35 | #include <linux/virtio_types.h> | ||
| 35 | 36 | ||
| 36 | /* This marks a buffer as continuing via the next field. */ | 37 | /* This marks a buffer as continuing via the next field. */ |
| 37 | #define VRING_DESC_F_NEXT 1 | 38 | #define VRING_DESC_F_NEXT 1 |
| @@ -61,32 +62,32 @@ | |||
| 61 | /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ | 62 | /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ |
| 62 | struct vring_desc { | 63 | struct vring_desc { |
| 63 | /* Address (guest-physical). */ | 64 | /* Address (guest-physical). */ |
| 64 | __u64 addr; | 65 | __virtio64 addr; |
| 65 | /* Length. */ | 66 | /* Length. */ |
| 66 | __u32 len; | 67 | __virtio32 len; |
| 67 | /* The flags as indicated above. */ | 68 | /* The flags as indicated above. */ |
| 68 | __u16 flags; | 69 | __virtio16 flags; |
| 69 | /* We chain unused descriptors via this, too */ | 70 | /* We chain unused descriptors via this, too */ |
| 70 | __u16 next; | 71 | __virtio16 next; |
| 71 | }; | 72 | }; |
| 72 | 73 | ||
| 73 | struct vring_avail { | 74 | struct vring_avail { |
| 74 | __u16 flags; | 75 | __virtio16 flags; |
| 75 | __u16 idx; | 76 | __virtio16 idx; |
| 76 | __u16 ring[]; | 77 | __virtio16 ring[]; |
| 77 | }; | 78 | }; |
| 78 | 79 | ||
| 79 | /* u32 is used here for ids for padding reasons. */ | 80 | /* u32 is used here for ids for padding reasons. */ |
| 80 | struct vring_used_elem { | 81 | struct vring_used_elem { |
| 81 | /* Index of start of used descriptor chain. */ | 82 | /* Index of start of used descriptor chain. */ |
| 82 | __u32 id; | 83 | __virtio32 id; |
| 83 | /* Total length of the descriptor chain which was used (written to) */ | 84 | /* Total length of the descriptor chain which was used (written to) */ |
| 84 | __u32 len; | 85 | __virtio32 len; |
| 85 | }; | 86 | }; |
| 86 | 87 | ||
| 87 | struct vring_used { | 88 | struct vring_used { |
| 88 | __u16 flags; | 89 | __virtio16 flags; |
| 89 | __u16 idx; | 90 | __virtio16 idx; |
| 90 | struct vring_used_elem ring[]; | 91 | struct vring_used_elem ring[]; |
| 91 | }; | 92 | }; |
| 92 | 93 | ||
| @@ -109,25 +110,25 @@ struct vring { | |||
| 109 | * struct vring_desc desc[num]; | 110 | * struct vring_desc desc[num]; |
| 110 | * | 111 | * |
| 111 | * // A ring of available descriptor heads with free-running index. | 112 | * // A ring of available descriptor heads with free-running index. |
| 112 | * __u16 avail_flags; | 113 | * __virtio16 avail_flags; |
| 113 | * __u16 avail_idx; | 114 | * __virtio16 avail_idx; |
| 114 | * __u16 available[num]; | 115 | * __virtio16 available[num]; |
| 115 | * __u16 used_event_idx; | 116 | * __virtio16 used_event_idx; |
| 116 | * | 117 | * |
| 117 | * // Padding to the next align boundary. | 118 | * // Padding to the next align boundary. |
| 118 | * char pad[]; | 119 | * char pad[]; |
| 119 | * | 120 | * |
| 120 | * // A ring of used descriptor heads with free-running index. | 121 | * // A ring of used descriptor heads with free-running index. |
| 121 | * __u16 used_flags; | 122 | * __virtio16 used_flags; |
| 122 | * __u16 used_idx; | 123 | * __virtio16 used_idx; |
| 123 | * struct vring_used_elem used[num]; | 124 | * struct vring_used_elem used[num]; |
| 124 | * __u16 avail_event_idx; | 125 | * __virtio16 avail_event_idx; |
| 125 | * }; | 126 | * }; |
| 126 | */ | 127 | */ |
| 127 | /* We publish the used event index at the end of the available ring, and vice | 128 | /* We publish the used event index at the end of the available ring, and vice |
| 128 | * versa. They are at the end for backwards compatibility. */ | 129 | * versa. They are at the end for backwards compatibility. */ |
| 129 | #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) | 130 | #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) |
| 130 | #define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num]) | 131 | #define vring_avail_event(vr) (*(__virtio16 *)&(vr)->used->ring[(vr)->num]) |
| 131 | 132 | ||
| 132 | static inline void vring_init(struct vring *vr, unsigned int num, void *p, | 133 | static inline void vring_init(struct vring *vr, unsigned int num, void *p, |
| 133 | unsigned long align) | 134 | unsigned long align) |
| @@ -135,15 +136,15 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p, | |||
| 135 | vr->num = num; | 136 | vr->num = num; |
| 136 | vr->desc = p; | 137 | vr->desc = p; |
| 137 | vr->avail = p + num*sizeof(struct vring_desc); | 138 | vr->avail = p + num*sizeof(struct vring_desc); |
| 138 | vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__u16) | 139 | vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__virtio16) |
| 139 | + align-1) & ~(align - 1)); | 140 | + align-1) & ~(align - 1)); |
| 140 | } | 141 | } |
| 141 | 142 | ||
| 142 | static inline unsigned vring_size(unsigned int num, unsigned long align) | 143 | static inline unsigned vring_size(unsigned int num, unsigned long align) |
| 143 | { | 144 | { |
| 144 | return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num) | 145 | return ((sizeof(struct vring_desc) * num + sizeof(__virtio16) * (3 + num) |
| 145 | + align - 1) & ~(align - 1)) | 146 | + align - 1) & ~(align - 1)) |
| 146 | + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; | 147 | + sizeof(__virtio16) * 3 + sizeof(struct vring_used_elem) * num; |
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | /* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */ | 150 | /* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */ |
diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h new file mode 100644 index 000000000000..42b9370771b0 --- /dev/null +++ b/include/uapi/linux/virtio_scsi.h | |||
| @@ -0,0 +1,164 @@ | |||
| 1 | /* | ||
| 2 | * This header is BSD licensed so anyone can use the definitions to implement | ||
| 3 | * compatible drivers/servers. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * 1. Redistributions of source code must retain the above copyright | ||
| 9 | * notice, this list of conditions and the following disclaimer. | ||
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer in the | ||
| 12 | * documentation and/or other materials provided with the distribution. | ||
| 13 | * | ||
| 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 24 | * SUCH DAMAGE. | ||
| 25 | */ | ||
| 26 | |||
| 27 | #ifndef _LINUX_VIRTIO_SCSI_H | ||
| 28 | #define _LINUX_VIRTIO_SCSI_H | ||
| 29 | |||
| 30 | #include <linux/virtio_types.h> | ||
| 31 | |||
| 32 | #define VIRTIO_SCSI_CDB_SIZE 32 | ||
| 33 | #define VIRTIO_SCSI_SENSE_SIZE 96 | ||
| 34 | |||
| 35 | /* SCSI command request, followed by data-out */ | ||
| 36 | struct virtio_scsi_cmd_req { | ||
| 37 | __u8 lun[8]; /* Logical Unit Number */ | ||
| 38 | __virtio64 tag; /* Command identifier */ | ||
| 39 | __u8 task_attr; /* Task attribute */ | ||
| 40 | __u8 prio; /* SAM command priority field */ | ||
| 41 | __u8 crn; | ||
| 42 | __u8 cdb[VIRTIO_SCSI_CDB_SIZE]; | ||
| 43 | } __attribute__((packed)); | ||
| 44 | |||
| 45 | /* SCSI command request, followed by protection information */ | ||
| 46 | struct virtio_scsi_cmd_req_pi { | ||
| 47 | __u8 lun[8]; /* Logical Unit Number */ | ||
| 48 | __virtio64 tag; /* Command identifier */ | ||
| 49 | __u8 task_attr; /* Task attribute */ | ||
| 50 | __u8 prio; /* SAM command priority field */ | ||
| 51 | __u8 crn; | ||
| 52 | __virtio32 pi_bytesout; /* DataOUT PI Number of bytes */ | ||
| 53 | __virtio32 pi_bytesin; /* DataIN PI Number of bytes */ | ||
| 54 | __u8 cdb[VIRTIO_SCSI_CDB_SIZE]; | ||
| 55 | } __attribute__((packed)); | ||
| 56 | |||
| 57 | /* Response, followed by sense data and data-in */ | ||
| 58 | struct virtio_scsi_cmd_resp { | ||
| 59 | __virtio32 sense_len; /* Sense data length */ | ||
| 60 | __virtio32 resid; /* Residual bytes in data buffer */ | ||
| 61 | __virtio16 status_qualifier; /* Status qualifier */ | ||
| 62 | __u8 status; /* Command completion status */ | ||
| 63 | __u8 response; /* Response values */ | ||
| 64 | __u8 sense[VIRTIO_SCSI_SENSE_SIZE]; | ||
| 65 | } __attribute__((packed)); | ||
| 66 | |||
| 67 | /* Task Management Request */ | ||
| 68 | struct virtio_scsi_ctrl_tmf_req { | ||
| 69 | __virtio32 type; | ||
| 70 | __virtio32 subtype; | ||
| 71 | __u8 lun[8]; | ||
| 72 | __virtio64 tag; | ||
| 73 | } __attribute__((packed)); | ||
| 74 | |||
| 75 | struct virtio_scsi_ctrl_tmf_resp { | ||
| 76 | __u8 response; | ||
| 77 | } __attribute__((packed)); | ||
| 78 | |||
| 79 | /* Asynchronous notification query/subscription */ | ||
| 80 | struct virtio_scsi_ctrl_an_req { | ||
| 81 | __virtio32 type; | ||
| 82 | __u8 lun[8]; | ||
| 83 | __virtio32 event_requested; | ||
| 84 | } __attribute__((packed)); | ||
| 85 | |||
| 86 | struct virtio_scsi_ctrl_an_resp { | ||
| 87 | __virtio32 event_actual; | ||
| 88 | __u8 response; | ||
| 89 | } __attribute__((packed)); | ||
| 90 | |||
| 91 | struct virtio_scsi_event { | ||
| 92 | __virtio32 event; | ||
| 93 | __u8 lun[8]; | ||
| 94 | __virtio32 reason; | ||
| 95 | } __attribute__((packed)); | ||
| 96 | |||
| 97 | struct virtio_scsi_config { | ||
| 98 | __u32 num_queues; | ||
| 99 | __u32 seg_max; | ||
| 100 | __u32 max_sectors; | ||
| 101 | __u32 cmd_per_lun; | ||
| 102 | __u32 event_info_size; | ||
| 103 | __u32 sense_size; | ||
| 104 | __u32 cdb_size; | ||
| 105 | __u16 max_channel; | ||
| 106 | __u16 max_target; | ||
| 107 | __u32 max_lun; | ||
| 108 | } __attribute__((packed)); | ||
| 109 | |||
| 110 | /* Feature Bits */ | ||
| 111 | #define VIRTIO_SCSI_F_INOUT 0 | ||
| 112 | #define VIRTIO_SCSI_F_HOTPLUG 1 | ||
| 113 | #define VIRTIO_SCSI_F_CHANGE 2 | ||
| 114 | #define VIRTIO_SCSI_F_T10_PI 3 | ||
| 115 | |||
| 116 | /* Response codes */ | ||
| 117 | #define VIRTIO_SCSI_S_OK 0 | ||
| 118 | #define VIRTIO_SCSI_S_OVERRUN 1 | ||
| 119 | #define VIRTIO_SCSI_S_ABORTED 2 | ||
| 120 | #define VIRTIO_SCSI_S_BAD_TARGET 3 | ||
| 121 | #define VIRTIO_SCSI_S_RESET 4 | ||
| 122 | #define VIRTIO_SCSI_S_BUSY 5 | ||
| 123 | #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6 | ||
| 124 | #define VIRTIO_SCSI_S_TARGET_FAILURE 7 | ||
| 125 | #define VIRTIO_SCSI_S_NEXUS_FAILURE 8 | ||
| 126 | #define VIRTIO_SCSI_S_FAILURE 9 | ||
| 127 | #define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10 | ||
| 128 | #define VIRTIO_SCSI_S_FUNCTION_REJECTED 11 | ||
| 129 | #define VIRTIO_SCSI_S_INCORRECT_LUN 12 | ||
| 130 | |||
| 131 | /* Controlq type codes. */ | ||
| 132 | #define VIRTIO_SCSI_T_TMF 0 | ||
| 133 | #define VIRTIO_SCSI_T_AN_QUERY 1 | ||
| 134 | #define VIRTIO_SCSI_T_AN_SUBSCRIBE 2 | ||
| 135 | |||
| 136 | /* Valid TMF subtypes. */ | ||
| 137 | #define VIRTIO_SCSI_T_TMF_ABORT_TASK 0 | ||
| 138 | #define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1 | ||
| 139 | #define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2 | ||
| 140 | #define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3 | ||
| 141 | #define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4 | ||
| 142 | #define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5 | ||
| 143 | #define VIRTIO_SCSI_T_TMF_QUERY_TASK 6 | ||
| 144 | #define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7 | ||
| 145 | |||
| 146 | /* Events. */ | ||
| 147 | #define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000 | ||
| 148 | #define VIRTIO_SCSI_T_NO_EVENT 0 | ||
| 149 | #define VIRTIO_SCSI_T_TRANSPORT_RESET 1 | ||
| 150 | #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 | ||
| 151 | #define VIRTIO_SCSI_T_PARAM_CHANGE 3 | ||
| 152 | |||
| 153 | /* Reasons of transport reset event */ | ||
| 154 | #define VIRTIO_SCSI_EVT_RESET_HARD 0 | ||
| 155 | #define VIRTIO_SCSI_EVT_RESET_RESCAN 1 | ||
| 156 | #define VIRTIO_SCSI_EVT_RESET_REMOVED 2 | ||
| 157 | |||
| 158 | #define VIRTIO_SCSI_S_SIMPLE 0 | ||
| 159 | #define VIRTIO_SCSI_S_ORDERED 1 | ||
| 160 | #define VIRTIO_SCSI_S_HEAD 2 | ||
| 161 | #define VIRTIO_SCSI_S_ACA 3 | ||
| 162 | |||
| 163 | |||
| 164 | #endif /* _LINUX_VIRTIO_SCSI_H */ | ||
diff --git a/include/uapi/linux/virtio_types.h b/include/uapi/linux/virtio_types.h new file mode 100644 index 000000000000..e845e8c4cbee --- /dev/null +++ b/include/uapi/linux/virtio_types.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | #ifndef _UAPI_LINUX_VIRTIO_TYPES_H | ||
| 2 | #define _UAPI_LINUX_VIRTIO_TYPES_H | ||
| 3 | /* Type definitions for virtio implementations. | ||
| 4 | * | ||
| 5 | * This header is BSD licensed so anyone can use the definitions to implement | ||
| 6 | * compatible drivers/servers. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | * notice, this list of conditions and the following disclaimer in the | ||
| 15 | * documentation and/or other materials provided with the distribution. | ||
| 16 | * 3. Neither the name of IBM nor the names of its contributors | ||
| 17 | * may be used to endorse or promote products derived from this software | ||
| 18 | * without specific prior written permission. | ||
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND | ||
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE | ||
| 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 29 | * SUCH DAMAGE. | ||
| 30 | * | ||
| 31 | * Copyright (C) 2014 Red Hat, Inc. | ||
| 32 | * Author: Michael S. Tsirkin <mst@redhat.com> | ||
| 33 | */ | ||
| 34 | #include <linux/types.h> | ||
| 35 | |||
| 36 | /* | ||
| 37 | * __virtio{16,32,64} have the following meaning: | ||
| 38 | * - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian | ||
| 39 | * - __le{16,32,64} for standard-compliant virtio devices | ||
| 40 | */ | ||
| 41 | |||
| 42 | typedef __u16 __bitwise__ __virtio16; | ||
| 43 | typedef __u32 __bitwise__ __virtio32; | ||
| 44 | typedef __u64 __bitwise__ __virtio64; | ||
| 45 | |||
| 46 | #endif /* _UAPI_LINUX_VIRTIO_TYPES_H */ | ||
