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/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/linux')
| -rw-r--r-- | include/linux/virtio.h | 12 | ||||
| -rw-r--r-- | include/linux/virtio_byteorder.h | 59 | ||||
| -rw-r--r-- | include/linux/virtio_config.h | 103 | ||||
| -rw-r--r-- | include/linux/virtio_scsi.h | 162 |
4 files changed, 162 insertions, 174 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 65261a7244fc..d09e0938fd60 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
| @@ -75,6 +75,9 @@ unsigned int virtqueue_get_vring_size(struct virtqueue *vq); | |||
| 75 | 75 | ||
| 76 | bool virtqueue_is_broken(struct virtqueue *vq); | 76 | bool virtqueue_is_broken(struct virtqueue *vq); |
| 77 | 77 | ||
| 78 | void *virtqueue_get_avail(struct virtqueue *vq); | ||
| 79 | void *virtqueue_get_used(struct virtqueue *vq); | ||
| 80 | |||
| 78 | /** | 81 | /** |
| 79 | * virtio_device - representation of a device using virtio | 82 | * virtio_device - representation of a device using virtio |
| 80 | * @index: unique position on the virtio bus | 83 | * @index: unique position on the virtio bus |
| @@ -101,11 +104,12 @@ struct virtio_device { | |||
| 101 | const struct virtio_config_ops *config; | 104 | const struct virtio_config_ops *config; |
| 102 | const struct vringh_config_ops *vringh_config; | 105 | const struct vringh_config_ops *vringh_config; |
| 103 | struct list_head vqs; | 106 | struct list_head vqs; |
| 104 | /* Note that this is a Linux set_bit-style bitmap. */ | 107 | u64 features; |
| 105 | unsigned long features[1]; | ||
| 106 | void *priv; | 108 | void *priv; |
| 107 | }; | 109 | }; |
| 108 | 110 | ||
| 111 | bool virtio_device_is_legacy_only(struct virtio_device_id id); | ||
| 112 | |||
| 109 | static inline struct virtio_device *dev_to_virtio(struct device *_dev) | 113 | static inline struct virtio_device *dev_to_virtio(struct device *_dev) |
| 110 | { | 114 | { |
| 111 | return container_of(_dev, struct virtio_device, dev); | 115 | return container_of(_dev, struct virtio_device, dev); |
| @@ -128,6 +132,8 @@ int virtio_device_restore(struct virtio_device *dev); | |||
| 128 | * @id_table: the ids serviced by this driver. | 132 | * @id_table: the ids serviced by this driver. |
| 129 | * @feature_table: an array of feature numbers supported by this driver. | 133 | * @feature_table: an array of feature numbers supported by this driver. |
| 130 | * @feature_table_size: number of entries in the feature table array. | 134 | * @feature_table_size: number of entries in the feature table array. |
| 135 | * @feature_table_legacy: same as feature_table but when working in legacy mode. | ||
| 136 | * @feature_table_size_legacy: number of entries in feature table legacy array. | ||
| 131 | * @probe: the function to call when a device is found. Returns 0 or -errno. | 137 | * @probe: the function to call when a device is found. Returns 0 or -errno. |
| 132 | * @remove: the function to call when a device is removed. | 138 | * @remove: the function to call when a device is removed. |
| 133 | * @config_changed: optional function to call when the device configuration | 139 | * @config_changed: optional function to call when the device configuration |
| @@ -138,6 +144,8 @@ struct virtio_driver { | |||
| 138 | const struct virtio_device_id *id_table; | 144 | const struct virtio_device_id *id_table; |
| 139 | const unsigned int *feature_table; | 145 | const unsigned int *feature_table; |
| 140 | unsigned int feature_table_size; | 146 | unsigned int feature_table_size; |
| 147 | const unsigned int *feature_table_legacy; | ||
| 148 | unsigned int feature_table_size_legacy; | ||
| 141 | int (*probe)(struct virtio_device *dev); | 149 | int (*probe)(struct virtio_device *dev); |
| 142 | void (*scan)(struct virtio_device *dev); | 150 | void (*scan)(struct virtio_device *dev); |
| 143 | void (*remove)(struct virtio_device *dev); | 151 | void (*remove)(struct virtio_device *dev); |
diff --git a/include/linux/virtio_byteorder.h b/include/linux/virtio_byteorder.h new file mode 100644 index 000000000000..51865d05b267 --- /dev/null +++ b/include/linux/virtio_byteorder.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #ifndef _LINUX_VIRTIO_BYTEORDER_H | ||
| 2 | #define _LINUX_VIRTIO_BYTEORDER_H | ||
| 3 | #include <linux/types.h> | ||
| 4 | #include <uapi/linux/virtio_types.h> | ||
| 5 | |||
| 6 | /* | ||
| 7 | * Low-level memory accessors for handling virtio in modern little endian and in | ||
| 8 | * compatibility native endian format. | ||
| 9 | */ | ||
| 10 | |||
| 11 | static inline u16 __virtio16_to_cpu(bool little_endian, __virtio16 val) | ||
| 12 | { | ||
| 13 | if (little_endian) | ||
| 14 | return le16_to_cpu((__force __le16)val); | ||
| 15 | else | ||
| 16 | return (__force u16)val; | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline __virtio16 __cpu_to_virtio16(bool little_endian, u16 val) | ||
| 20 | { | ||
| 21 | if (little_endian) | ||
| 22 | return (__force __virtio16)cpu_to_le16(val); | ||
| 23 | else | ||
| 24 | return (__force __virtio16)val; | ||
| 25 | } | ||
| 26 | |||
| 27 | static inline u32 __virtio32_to_cpu(bool little_endian, __virtio32 val) | ||
| 28 | { | ||
| 29 | if (little_endian) | ||
| 30 | return le32_to_cpu((__force __le32)val); | ||
| 31 | else | ||
| 32 | return (__force u32)val; | ||
| 33 | } | ||
| 34 | |||
| 35 | static inline __virtio32 __cpu_to_virtio32(bool little_endian, u32 val) | ||
| 36 | { | ||
| 37 | if (little_endian) | ||
| 38 | return (__force __virtio32)cpu_to_le32(val); | ||
| 39 | else | ||
| 40 | return (__force __virtio32)val; | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline u64 __virtio64_to_cpu(bool little_endian, __virtio64 val) | ||
| 44 | { | ||
| 45 | if (little_endian) | ||
| 46 | return le64_to_cpu((__force __le64)val); | ||
| 47 | else | ||
| 48 | return (__force u64)val; | ||
| 49 | } | ||
| 50 | |||
| 51 | static inline __virtio64 __cpu_to_virtio64(bool little_endian, u64 val) | ||
| 52 | { | ||
| 53 | if (little_endian) | ||
| 54 | return (__force __virtio64)cpu_to_le64(val); | ||
| 55 | else | ||
| 56 | return (__force __virtio64)val; | ||
| 57 | } | ||
| 58 | |||
| 59 | #endif /* _LINUX_VIRTIO_BYTEORDER */ | ||
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 7f4ef66873ef..7979f850e7ac 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <linux/err.h> | 4 | #include <linux/err.h> |
| 5 | #include <linux/bug.h> | 5 | #include <linux/bug.h> |
| 6 | #include <linux/virtio.h> | 6 | #include <linux/virtio.h> |
| 7 | #include <linux/virtio_byteorder.h> | ||
| 7 | #include <uapi/linux/virtio_config.h> | 8 | #include <uapi/linux/virtio_config.h> |
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| @@ -46,6 +47,7 @@ | |||
| 46 | * vdev: the virtio_device | 47 | * vdev: the virtio_device |
| 47 | * This gives the final feature bits for the device: it can change | 48 | * This gives the final feature bits for the device: it can change |
| 48 | * the dev->feature bits if it wants. | 49 | * the dev->feature bits if it wants. |
| 50 | * Returns 0 on success or error status | ||
| 49 | * @bus_name: return the bus name associated with the device | 51 | * @bus_name: return the bus name associated with the device |
| 50 | * vdev: the virtio_device | 52 | * vdev: the virtio_device |
| 51 | * This returns a pointer to the bus name a la pci_name from which | 53 | * This returns a pointer to the bus name a la pci_name from which |
| @@ -66,8 +68,8 @@ struct virtio_config_ops { | |||
| 66 | vq_callback_t *callbacks[], | 68 | vq_callback_t *callbacks[], |
| 67 | const char *names[]); | 69 | const char *names[]); |
| 68 | void (*del_vqs)(struct virtio_device *); | 70 | void (*del_vqs)(struct virtio_device *); |
| 69 | u32 (*get_features)(struct virtio_device *vdev); | 71 | u64 (*get_features)(struct virtio_device *vdev); |
| 70 | void (*finalize_features)(struct virtio_device *vdev); | 72 | int (*finalize_features)(struct virtio_device *vdev); |
| 71 | const char *(*bus_name)(struct virtio_device *vdev); | 73 | const char *(*bus_name)(struct virtio_device *vdev); |
| 72 | int (*set_vq_affinity)(struct virtqueue *vq, int cpu); | 74 | int (*set_vq_affinity)(struct virtqueue *vq, int cpu); |
| 73 | }; | 75 | }; |
| @@ -77,23 +79,70 @@ void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | |||
| 77 | unsigned int fbit); | 79 | unsigned int fbit); |
| 78 | 80 | ||
| 79 | /** | 81 | /** |
| 80 | * virtio_has_feature - helper to determine if this device has this feature. | 82 | * __virtio_test_bit - helper to test feature bits. For use by transports. |
| 83 | * Devices should normally use virtio_has_feature, | ||
| 84 | * which includes more checks. | ||
| 81 | * @vdev: the device | 85 | * @vdev: the device |
| 82 | * @fbit: the feature bit | 86 | * @fbit: the feature bit |
| 83 | */ | 87 | */ |
| 84 | static inline bool virtio_has_feature(const struct virtio_device *vdev, | 88 | static inline bool __virtio_test_bit(const struct virtio_device *vdev, |
| 89 | unsigned int fbit) | ||
| 90 | { | ||
| 91 | /* Did you forget to fix assumptions on max features? */ | ||
| 92 | if (__builtin_constant_p(fbit)) | ||
| 93 | BUILD_BUG_ON(fbit >= 64); | ||
| 94 | else | ||
| 95 | BUG_ON(fbit >= 64); | ||
| 96 | |||
| 97 | return vdev->features & BIT_ULL(fbit); | ||
| 98 | } | ||
| 99 | |||
| 100 | /** | ||
| 101 | * __virtio_set_bit - helper to set feature bits. For use by transports. | ||
| 102 | * @vdev: the device | ||
| 103 | * @fbit: the feature bit | ||
| 104 | */ | ||
| 105 | static inline void __virtio_set_bit(struct virtio_device *vdev, | ||
| 106 | unsigned int fbit) | ||
| 107 | { | ||
| 108 | /* Did you forget to fix assumptions on max features? */ | ||
| 109 | if (__builtin_constant_p(fbit)) | ||
| 110 | BUILD_BUG_ON(fbit >= 64); | ||
| 111 | else | ||
| 112 | BUG_ON(fbit >= 64); | ||
| 113 | |||
| 114 | vdev->features |= BIT_ULL(fbit); | ||
| 115 | } | ||
| 116 | |||
| 117 | /** | ||
| 118 | * __virtio_clear_bit - helper to clear feature bits. For use by transports. | ||
| 119 | * @vdev: the device | ||
| 120 | * @fbit: the feature bit | ||
| 121 | */ | ||
| 122 | static inline void __virtio_clear_bit(struct virtio_device *vdev, | ||
| 85 | unsigned int fbit) | 123 | unsigned int fbit) |
| 86 | { | 124 | { |
| 87 | /* Did you forget to fix assumptions on max features? */ | 125 | /* Did you forget to fix assumptions on max features? */ |
| 88 | if (__builtin_constant_p(fbit)) | 126 | if (__builtin_constant_p(fbit)) |
| 89 | BUILD_BUG_ON(fbit >= 32); | 127 | BUILD_BUG_ON(fbit >= 64); |
| 90 | else | 128 | else |
| 91 | BUG_ON(fbit >= 32); | 129 | BUG_ON(fbit >= 64); |
| 92 | 130 | ||
| 131 | vdev->features &= ~BIT_ULL(fbit); | ||
| 132 | } | ||
| 133 | |||
| 134 | /** | ||
| 135 | * virtio_has_feature - helper to determine if this device has this feature. | ||
| 136 | * @vdev: the device | ||
| 137 | * @fbit: the feature bit | ||
| 138 | */ | ||
| 139 | static inline bool virtio_has_feature(const struct virtio_device *vdev, | ||
| 140 | unsigned int fbit) | ||
| 141 | { | ||
| 93 | if (fbit < VIRTIO_TRANSPORT_F_START) | 142 | if (fbit < VIRTIO_TRANSPORT_F_START) |
| 94 | virtio_check_driver_offered_feature(vdev, fbit); | 143 | virtio_check_driver_offered_feature(vdev, fbit); |
| 95 | 144 | ||
| 96 | return test_bit(fbit, vdev->features); | 145 | return __virtio_test_bit(vdev, fbit); |
| 97 | } | 146 | } |
| 98 | 147 | ||
| 99 | static inline | 148 | static inline |
| @@ -152,6 +201,37 @@ int virtqueue_set_affinity(struct virtqueue *vq, int cpu) | |||
| 152 | return 0; | 201 | return 0; |
| 153 | } | 202 | } |
| 154 | 203 | ||
| 204 | /* Memory accessors */ | ||
| 205 | static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val) | ||
| 206 | { | ||
| 207 | return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 208 | } | ||
| 209 | |||
| 210 | static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val) | ||
| 211 | { | ||
| 212 | return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 213 | } | ||
| 214 | |||
| 215 | static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val) | ||
| 216 | { | ||
| 217 | return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 218 | } | ||
| 219 | |||
| 220 | static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val) | ||
| 221 | { | ||
| 222 | return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 223 | } | ||
| 224 | |||
| 225 | static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val) | ||
| 226 | { | ||
| 227 | return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 228 | } | ||
| 229 | |||
| 230 | static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) | ||
| 231 | { | ||
| 232 | return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
| 233 | } | ||
| 234 | |||
| 155 | /* Config space accessors. */ | 235 | /* Config space accessors. */ |
| 156 | #define virtio_cread(vdev, structname, member, ptr) \ | 236 | #define virtio_cread(vdev, structname, member, ptr) \ |
| 157 | do { \ | 237 | do { \ |
| @@ -239,12 +319,13 @@ static inline u16 virtio_cread16(struct virtio_device *vdev, | |||
| 239 | { | 319 | { |
| 240 | u16 ret; | 320 | u16 ret; |
| 241 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); | 321 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); |
| 242 | return ret; | 322 | return virtio16_to_cpu(vdev, (__force __virtio16)ret); |
| 243 | } | 323 | } |
| 244 | 324 | ||
| 245 | static inline void virtio_cwrite16(struct virtio_device *vdev, | 325 | static inline void virtio_cwrite16(struct virtio_device *vdev, |
| 246 | unsigned int offset, u16 val) | 326 | unsigned int offset, u16 val) |
| 247 | { | 327 | { |
| 328 | val = (__force u16)cpu_to_virtio16(vdev, val); | ||
| 248 | vdev->config->set(vdev, offset, &val, sizeof(val)); | 329 | vdev->config->set(vdev, offset, &val, sizeof(val)); |
| 249 | } | 330 | } |
| 250 | 331 | ||
| @@ -253,12 +334,13 @@ static inline u32 virtio_cread32(struct virtio_device *vdev, | |||
| 253 | { | 334 | { |
| 254 | u32 ret; | 335 | u32 ret; |
| 255 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); | 336 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); |
| 256 | return ret; | 337 | return virtio32_to_cpu(vdev, (__force __virtio32)ret); |
| 257 | } | 338 | } |
| 258 | 339 | ||
| 259 | static inline void virtio_cwrite32(struct virtio_device *vdev, | 340 | static inline void virtio_cwrite32(struct virtio_device *vdev, |
| 260 | unsigned int offset, u32 val) | 341 | unsigned int offset, u32 val) |
| 261 | { | 342 | { |
| 343 | val = (__force u32)cpu_to_virtio32(vdev, val); | ||
| 262 | vdev->config->set(vdev, offset, &val, sizeof(val)); | 344 | vdev->config->set(vdev, offset, &val, sizeof(val)); |
| 263 | } | 345 | } |
| 264 | 346 | ||
| @@ -267,12 +349,13 @@ static inline u64 virtio_cread64(struct virtio_device *vdev, | |||
| 267 | { | 349 | { |
| 268 | u64 ret; | 350 | u64 ret; |
| 269 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); | 351 | vdev->config->get(vdev, offset, &ret, sizeof(ret)); |
| 270 | return ret; | 352 | return virtio64_to_cpu(vdev, (__force __virtio64)ret); |
| 271 | } | 353 | } |
| 272 | 354 | ||
| 273 | static inline void virtio_cwrite64(struct virtio_device *vdev, | 355 | static inline void virtio_cwrite64(struct virtio_device *vdev, |
| 274 | unsigned int offset, u64 val) | 356 | unsigned int offset, u64 val) |
| 275 | { | 357 | { |
| 358 | val = (__force u64)cpu_to_virtio64(vdev, val); | ||
| 276 | vdev->config->set(vdev, offset, &val, sizeof(val)); | 359 | vdev->config->set(vdev, offset, &val, sizeof(val)); |
| 277 | } | 360 | } |
| 278 | 361 | ||
diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h deleted file mode 100644 index de429d1f4357..000000000000 --- a/include/linux/virtio_scsi.h +++ /dev/null | |||
| @@ -1,162 +0,0 @@ | |||
| 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 | #define VIRTIO_SCSI_CDB_SIZE 32 | ||
| 31 | #define VIRTIO_SCSI_SENSE_SIZE 96 | ||
| 32 | |||
| 33 | /* SCSI command request, followed by data-out */ | ||
| 34 | struct virtio_scsi_cmd_req { | ||
| 35 | u8 lun[8]; /* Logical Unit Number */ | ||
| 36 | u64 tag; /* Command identifier */ | ||
| 37 | u8 task_attr; /* Task attribute */ | ||
| 38 | u8 prio; /* SAM command priority field */ | ||
| 39 | u8 crn; | ||
| 40 | u8 cdb[VIRTIO_SCSI_CDB_SIZE]; | ||
| 41 | } __packed; | ||
| 42 | |||
| 43 | /* SCSI command request, followed by protection information */ | ||
| 44 | struct virtio_scsi_cmd_req_pi { | ||
| 45 | u8 lun[8]; /* Logical Unit Number */ | ||
| 46 | u64 tag; /* Command identifier */ | ||
| 47 | u8 task_attr; /* Task attribute */ | ||
| 48 | u8 prio; /* SAM command priority field */ | ||
| 49 | u8 crn; | ||
| 50 | u32 pi_bytesout; /* DataOUT PI Number of bytes */ | ||
| 51 | u32 pi_bytesin; /* DataIN PI Number of bytes */ | ||
| 52 | u8 cdb[VIRTIO_SCSI_CDB_SIZE]; | ||
| 53 | } __packed; | ||
| 54 | |||
| 55 | /* Response, followed by sense data and data-in */ | ||
| 56 | struct virtio_scsi_cmd_resp { | ||
| 57 | u32 sense_len; /* Sense data length */ | ||
| 58 | u32 resid; /* Residual bytes in data buffer */ | ||
| 59 | u16 status_qualifier; /* Status qualifier */ | ||
| 60 | u8 status; /* Command completion status */ | ||
| 61 | u8 response; /* Response values */ | ||
| 62 | u8 sense[VIRTIO_SCSI_SENSE_SIZE]; | ||
| 63 | } __packed; | ||
| 64 | |||
| 65 | /* Task Management Request */ | ||
| 66 | struct virtio_scsi_ctrl_tmf_req { | ||
| 67 | u32 type; | ||
| 68 | u32 subtype; | ||
| 69 | u8 lun[8]; | ||
| 70 | u64 tag; | ||
| 71 | } __packed; | ||
| 72 | |||
| 73 | struct virtio_scsi_ctrl_tmf_resp { | ||
| 74 | u8 response; | ||
| 75 | } __packed; | ||
| 76 | |||
| 77 | /* Asynchronous notification query/subscription */ | ||
| 78 | struct virtio_scsi_ctrl_an_req { | ||
| 79 | u32 type; | ||
| 80 | u8 lun[8]; | ||
| 81 | u32 event_requested; | ||
| 82 | } __packed; | ||
| 83 | |||
| 84 | struct virtio_scsi_ctrl_an_resp { | ||
| 85 | u32 event_actual; | ||
| 86 | u8 response; | ||
| 87 | } __packed; | ||
| 88 | |||
| 89 | struct virtio_scsi_event { | ||
| 90 | u32 event; | ||
| 91 | u8 lun[8]; | ||
| 92 | u32 reason; | ||
| 93 | } __packed; | ||
| 94 | |||
| 95 | struct virtio_scsi_config { | ||
| 96 | u32 num_queues; | ||
| 97 | u32 seg_max; | ||
| 98 | u32 max_sectors; | ||
| 99 | u32 cmd_per_lun; | ||
| 100 | u32 event_info_size; | ||
| 101 | u32 sense_size; | ||
| 102 | u32 cdb_size; | ||
| 103 | u16 max_channel; | ||
| 104 | u16 max_target; | ||
| 105 | u32 max_lun; | ||
| 106 | } __packed; | ||
| 107 | |||
| 108 | /* Feature Bits */ | ||
| 109 | #define VIRTIO_SCSI_F_INOUT 0 | ||
| 110 | #define VIRTIO_SCSI_F_HOTPLUG 1 | ||
| 111 | #define VIRTIO_SCSI_F_CHANGE 2 | ||
| 112 | #define VIRTIO_SCSI_F_T10_PI 3 | ||
| 113 | |||
| 114 | /* Response codes */ | ||
| 115 | #define VIRTIO_SCSI_S_OK 0 | ||
| 116 | #define VIRTIO_SCSI_S_OVERRUN 1 | ||
| 117 | #define VIRTIO_SCSI_S_ABORTED 2 | ||
| 118 | #define VIRTIO_SCSI_S_BAD_TARGET 3 | ||
| 119 | #define VIRTIO_SCSI_S_RESET 4 | ||
| 120 | #define VIRTIO_SCSI_S_BUSY 5 | ||
| 121 | #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6 | ||
| 122 | #define VIRTIO_SCSI_S_TARGET_FAILURE 7 | ||
| 123 | #define VIRTIO_SCSI_S_NEXUS_FAILURE 8 | ||
| 124 | #define VIRTIO_SCSI_S_FAILURE 9 | ||
| 125 | #define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10 | ||
| 126 | #define VIRTIO_SCSI_S_FUNCTION_REJECTED 11 | ||
| 127 | #define VIRTIO_SCSI_S_INCORRECT_LUN 12 | ||
| 128 | |||
| 129 | /* Controlq type codes. */ | ||
| 130 | #define VIRTIO_SCSI_T_TMF 0 | ||
| 131 | #define VIRTIO_SCSI_T_AN_QUERY 1 | ||
| 132 | #define VIRTIO_SCSI_T_AN_SUBSCRIBE 2 | ||
| 133 | |||
| 134 | /* Valid TMF subtypes. */ | ||
| 135 | #define VIRTIO_SCSI_T_TMF_ABORT_TASK 0 | ||
| 136 | #define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1 | ||
| 137 | #define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2 | ||
| 138 | #define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3 | ||
| 139 | #define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4 | ||
| 140 | #define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5 | ||
| 141 | #define VIRTIO_SCSI_T_TMF_QUERY_TASK 6 | ||
| 142 | #define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7 | ||
| 143 | |||
| 144 | /* Events. */ | ||
| 145 | #define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000 | ||
| 146 | #define VIRTIO_SCSI_T_NO_EVENT 0 | ||
| 147 | #define VIRTIO_SCSI_T_TRANSPORT_RESET 1 | ||
| 148 | #define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 | ||
| 149 | #define VIRTIO_SCSI_T_PARAM_CHANGE 3 | ||
| 150 | |||
| 151 | /* Reasons of transport reset event */ | ||
| 152 | #define VIRTIO_SCSI_EVT_RESET_HARD 0 | ||
| 153 | #define VIRTIO_SCSI_EVT_RESET_RESCAN 1 | ||
| 154 | #define VIRTIO_SCSI_EVT_RESET_REMOVED 2 | ||
| 155 | |||
| 156 | #define VIRTIO_SCSI_S_SIMPLE 0 | ||
| 157 | #define VIRTIO_SCSI_S_ORDERED 1 | ||
| 158 | #define VIRTIO_SCSI_S_HEAD 2 | ||
| 159 | #define VIRTIO_SCSI_S_ACA 3 | ||
| 160 | |||
| 161 | |||
| 162 | #endif /* _LINUX_VIRTIO_SCSI_H */ | ||
