19fbe302bSMichael S. Tsirkin #ifndef _LINUX_VIRTIO_BLK_H 29fbe302bSMichael S. Tsirkin #define _LINUX_VIRTIO_BLK_H 39fbe302bSMichael S. Tsirkin /* This header is BSD licensed so anyone can use the definitions to implement 49fbe302bSMichael S. Tsirkin * compatible drivers/servers. 59fbe302bSMichael S. Tsirkin * 69fbe302bSMichael S. Tsirkin * Redistribution and use in source and binary forms, with or without 79fbe302bSMichael S. Tsirkin * modification, are permitted provided that the following conditions 89fbe302bSMichael S. Tsirkin * are met: 99fbe302bSMichael S. Tsirkin * 1. Redistributions of source code must retain the above copyright 109fbe302bSMichael S. Tsirkin * notice, this list of conditions and the following disclaimer. 119fbe302bSMichael S. Tsirkin * 2. Redistributions in binary form must reproduce the above copyright 129fbe302bSMichael S. Tsirkin * notice, this list of conditions and the following disclaimer in the 139fbe302bSMichael S. Tsirkin * documentation and/or other materials provided with the distribution. 149fbe302bSMichael S. Tsirkin * 3. Neither the name of IBM nor the names of its contributors 159fbe302bSMichael S. Tsirkin * may be used to endorse or promote products derived from this software 169fbe302bSMichael S. Tsirkin * without specific prior written permission. 179fbe302bSMichael S. Tsirkin * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 189fbe302bSMichael S. Tsirkin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 199fbe302bSMichael S. Tsirkin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 209fbe302bSMichael S. Tsirkin * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 219fbe302bSMichael S. Tsirkin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 229fbe302bSMichael S. Tsirkin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 239fbe302bSMichael S. Tsirkin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 249fbe302bSMichael S. Tsirkin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 259fbe302bSMichael S. Tsirkin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 269fbe302bSMichael S. Tsirkin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 279fbe302bSMichael S. Tsirkin * SUCH DAMAGE. */ 289fbe302bSMichael S. Tsirkin #include "standard-headers/linux/types.h" 299fbe302bSMichael S. Tsirkin #include "standard-headers/linux/virtio_ids.h" 309fbe302bSMichael S. Tsirkin #include "standard-headers/linux/virtio_config.h" 319fbe302bSMichael S. Tsirkin #include "standard-headers/linux/virtio_types.h" 329fbe302bSMichael S. Tsirkin 339fbe302bSMichael S. Tsirkin /* Feature bits */ 349fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ 359fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ 369fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ 379fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 389fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ 399fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ 409fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ 41caa1ee43SChangpeng Liu #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ 42caa1ee43SChangpeng Liu #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ 4393e0932bSPeter Xu #define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */ 44c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_F_ZONED 17 /* Zoned block device */ 459fbe302bSMichael S. Tsirkin 469fbe302bSMichael S. Tsirkin /* Legacy feature bits */ 479fbe302bSMichael S. Tsirkin #ifndef VIRTIO_BLK_NO_LEGACY 489fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ 499fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ 50b89485a5SPaolo Bonzini #define VIRTIO_BLK_F_FLUSH 9 /* Flush command supported */ 519fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */ 52b89485a5SPaolo Bonzini /* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */ 53b89485a5SPaolo Bonzini #define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH 549fbe302bSMichael S. Tsirkin #endif /* !VIRTIO_BLK_NO_LEGACY */ 559fbe302bSMichael S. Tsirkin 569fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_ID_BYTES 20 /* ID string length */ 579fbe302bSMichael S. Tsirkin 589fbe302bSMichael S. Tsirkin struct virtio_blk_config { 599fbe302bSMichael S. Tsirkin /* The capacity (in 512-byte sectors). */ 60e6546342SJason Wang __virtio64 capacity; 619fbe302bSMichael S. Tsirkin /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ 62e6546342SJason Wang __virtio32 size_max; 639fbe302bSMichael S. Tsirkin /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ 64e6546342SJason Wang __virtio32 seg_max; 654eb867e9SMichael S. Tsirkin /* geometry of the device (if VIRTIO_BLK_F_GEOMETRY) */ 669fbe302bSMichael S. Tsirkin struct virtio_blk_geometry { 67e6546342SJason Wang __virtio16 cylinders; 689fbe302bSMichael S. Tsirkin uint8_t heads; 699fbe302bSMichael S. Tsirkin uint8_t sectors; 709fbe302bSMichael S. Tsirkin } geometry; 719fbe302bSMichael S. Tsirkin 729fbe302bSMichael S. Tsirkin /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ 73e6546342SJason Wang __virtio32 blk_size; 749fbe302bSMichael S. Tsirkin 759fbe302bSMichael S. Tsirkin /* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */ 769fbe302bSMichael S. Tsirkin /* exponent for physical block per logical block. */ 779fbe302bSMichael S. Tsirkin uint8_t physical_block_exp; 789fbe302bSMichael S. Tsirkin /* alignment offset in logical blocks. */ 799fbe302bSMichael S. Tsirkin uint8_t alignment_offset; 809fbe302bSMichael S. Tsirkin /* minimum I/O size without performance penalty in logical blocks. */ 81e6546342SJason Wang __virtio16 min_io_size; 829fbe302bSMichael S. Tsirkin /* optimal sustained I/O size in logical blocks. */ 83e6546342SJason Wang __virtio32 opt_io_size; 849fbe302bSMichael S. Tsirkin 859fbe302bSMichael S. Tsirkin /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */ 869fbe302bSMichael S. Tsirkin uint8_t wce; 879fbe302bSMichael S. Tsirkin uint8_t unused; 889fbe302bSMichael S. Tsirkin 899fbe302bSMichael S. Tsirkin /* number of vqs, only available when VIRTIO_BLK_F_MQ is set */ 90e6546342SJason Wang __virtio16 num_queues; 91caa1ee43SChangpeng Liu 92caa1ee43SChangpeng Liu /* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */ 93caa1ee43SChangpeng Liu /* 94caa1ee43SChangpeng Liu * The maximum discard sectors (in 512-byte sectors) for 95caa1ee43SChangpeng Liu * one segment. 96caa1ee43SChangpeng Liu */ 97e6546342SJason Wang __virtio32 max_discard_sectors; 98caa1ee43SChangpeng Liu /* 99caa1ee43SChangpeng Liu * The maximum number of discard segments in a 100caa1ee43SChangpeng Liu * discard command. 101caa1ee43SChangpeng Liu */ 102e6546342SJason Wang __virtio32 max_discard_seg; 103caa1ee43SChangpeng Liu /* Discard commands must be aligned to this number of sectors. */ 104e6546342SJason Wang __virtio32 discard_sector_alignment; 105caa1ee43SChangpeng Liu 106caa1ee43SChangpeng Liu /* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */ 107caa1ee43SChangpeng Liu /* 108caa1ee43SChangpeng Liu * The maximum number of write zeroes sectors (in 512-byte sectors) in 109caa1ee43SChangpeng Liu * one segment. 110caa1ee43SChangpeng Liu */ 111e6546342SJason Wang __virtio32 max_write_zeroes_sectors; 112caa1ee43SChangpeng Liu /* 113caa1ee43SChangpeng Liu * The maximum number of segments in a write zeroes 114caa1ee43SChangpeng Liu * command. 115caa1ee43SChangpeng Liu */ 116e6546342SJason Wang __virtio32 max_write_zeroes_seg; 117caa1ee43SChangpeng Liu /* 118caa1ee43SChangpeng Liu * Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the 119caa1ee43SChangpeng Liu * deallocation of one or more of the sectors. 120caa1ee43SChangpeng Liu */ 121caa1ee43SChangpeng Liu uint8_t write_zeroes_may_unmap; 122caa1ee43SChangpeng Liu 123caa1ee43SChangpeng Liu uint8_t unused1[3]; 12493e0932bSPeter Xu 12593e0932bSPeter Xu /* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */ 12693e0932bSPeter Xu /* 12793e0932bSPeter Xu * The maximum secure erase sectors (in 512-byte sectors) for 12893e0932bSPeter Xu * one segment. 12993e0932bSPeter Xu */ 13093e0932bSPeter Xu __virtio32 max_secure_erase_sectors; 13193e0932bSPeter Xu /* 13293e0932bSPeter Xu * The maximum number of secure erase segments in a 13393e0932bSPeter Xu * secure erase command. 13493e0932bSPeter Xu */ 13593e0932bSPeter Xu __virtio32 max_secure_erase_seg; 13693e0932bSPeter Xu /* Secure erase commands must be aligned to this number of sectors. */ 13793e0932bSPeter Xu __virtio32 secure_erase_sector_alignment; 13893e0932bSPeter Xu 139c5c0fdbeSDavid 'Digit' Turner /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */ 140c5c0fdbeSDavid 'Digit' Turner struct virtio_blk_zoned_characteristics { 141*d0bf492fSCédric Le Goater __virtio32 zone_sectors; 142*d0bf492fSCédric Le Goater __virtio32 max_open_zones; 143*d0bf492fSCédric Le Goater __virtio32 max_active_zones; 144*d0bf492fSCédric Le Goater __virtio32 max_append_sectors; 145*d0bf492fSCédric Le Goater __virtio32 write_granularity; 146c5c0fdbeSDavid 'Digit' Turner uint8_t model; 147c5c0fdbeSDavid 'Digit' Turner uint8_t unused2[3]; 148c5c0fdbeSDavid 'Digit' Turner } zoned; 1499fbe302bSMichael S. Tsirkin } QEMU_PACKED; 1509fbe302bSMichael S. Tsirkin 1519fbe302bSMichael S. Tsirkin /* 1529fbe302bSMichael S. Tsirkin * Command types 1539fbe302bSMichael S. Tsirkin * 1549fbe302bSMichael S. Tsirkin * Usage is a bit tricky as some bits are used as flags and some are not. 1559fbe302bSMichael S. Tsirkin * 1569fbe302bSMichael S. Tsirkin * Rules: 1579fbe302bSMichael S. Tsirkin * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or 1589fbe302bSMichael S. Tsirkin * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own 1599fbe302bSMichael S. Tsirkin * and may not be combined with any of the other flags. 1609fbe302bSMichael S. Tsirkin */ 1619fbe302bSMichael S. Tsirkin 1629fbe302bSMichael S. Tsirkin /* These two define direction. */ 1639fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_IN 0 1649fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_OUT 1 1659fbe302bSMichael S. Tsirkin 1669fbe302bSMichael S. Tsirkin #ifndef VIRTIO_BLK_NO_LEGACY 1679fbe302bSMichael S. Tsirkin /* This bit says it's a scsi command, not an actual read or write. */ 1689fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_SCSI_CMD 2 1699fbe302bSMichael S. Tsirkin #endif /* VIRTIO_BLK_NO_LEGACY */ 1709fbe302bSMichael S. Tsirkin 1719fbe302bSMichael S. Tsirkin /* Cache flush command */ 1729fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_FLUSH 4 1739fbe302bSMichael S. Tsirkin 1749fbe302bSMichael S. Tsirkin /* Get device ID command */ 1759fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_GET_ID 8 1769fbe302bSMichael S. Tsirkin 177da054c64SPaolo Bonzini /* Discard command */ 178da054c64SPaolo Bonzini #define VIRTIO_BLK_T_DISCARD 11 179da054c64SPaolo Bonzini 180da054c64SPaolo Bonzini /* Write zeroes command */ 181da054c64SPaolo Bonzini #define VIRTIO_BLK_T_WRITE_ZEROES 13 182da054c64SPaolo Bonzini 18393e0932bSPeter Xu /* Secure erase command */ 18493e0932bSPeter Xu #define VIRTIO_BLK_T_SECURE_ERASE 14 18593e0932bSPeter Xu 186c5c0fdbeSDavid 'Digit' Turner /* Zone append command */ 187c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_APPEND 15 188c5c0fdbeSDavid 'Digit' Turner 189c5c0fdbeSDavid 'Digit' Turner /* Report zones command */ 190c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_REPORT 16 191c5c0fdbeSDavid 'Digit' Turner 192c5c0fdbeSDavid 'Digit' Turner /* Open zone command */ 193c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_OPEN 18 194c5c0fdbeSDavid 'Digit' Turner 195c5c0fdbeSDavid 'Digit' Turner /* Close zone command */ 196c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_CLOSE 20 197c5c0fdbeSDavid 'Digit' Turner 198c5c0fdbeSDavid 'Digit' Turner /* Finish zone command */ 199c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_FINISH 22 200c5c0fdbeSDavid 'Digit' Turner 201c5c0fdbeSDavid 'Digit' Turner /* Reset zone command */ 202c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_RESET 24 203c5c0fdbeSDavid 'Digit' Turner 204c5c0fdbeSDavid 'Digit' Turner /* Reset All zones command */ 205c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_T_ZONE_RESET_ALL 26 206c5c0fdbeSDavid 'Digit' Turner 2079fbe302bSMichael S. Tsirkin #ifndef VIRTIO_BLK_NO_LEGACY 2089fbe302bSMichael S. Tsirkin /* Barrier before this op. */ 2099fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_T_BARRIER 0x80000000 2109fbe302bSMichael S. Tsirkin #endif /* !VIRTIO_BLK_NO_LEGACY */ 2119fbe302bSMichael S. Tsirkin 2124eb867e9SMichael S. Tsirkin /* 2134eb867e9SMichael S. Tsirkin * This comes first in the read scatter-gather list. 2144eb867e9SMichael S. Tsirkin * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, 2154eb867e9SMichael S. Tsirkin * this is the first element of the read scatter-gather list. 2164eb867e9SMichael S. Tsirkin */ 2179fbe302bSMichael S. Tsirkin struct virtio_blk_outhdr { 2189fbe302bSMichael S. Tsirkin /* VIRTIO_BLK_T* */ 2199fbe302bSMichael S. Tsirkin __virtio32 type; 2209fbe302bSMichael S. Tsirkin /* io priority. */ 2219fbe302bSMichael S. Tsirkin __virtio32 ioprio; 2229fbe302bSMichael S. Tsirkin /* Sector (ie. 512 byte offset) */ 2239fbe302bSMichael S. Tsirkin __virtio64 sector; 2249fbe302bSMichael S. Tsirkin }; 2259fbe302bSMichael S. Tsirkin 226c5c0fdbeSDavid 'Digit' Turner /* 227c5c0fdbeSDavid 'Digit' Turner * Supported zoned device models. 228c5c0fdbeSDavid 'Digit' Turner */ 229c5c0fdbeSDavid 'Digit' Turner 230c5c0fdbeSDavid 'Digit' Turner /* Regular block device */ 231c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_Z_NONE 0 232c5c0fdbeSDavid 'Digit' Turner /* Host-managed zoned device */ 233c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_Z_HM 1 234c5c0fdbeSDavid 'Digit' Turner /* Host-aware zoned device */ 235c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_Z_HA 2 236c5c0fdbeSDavid 'Digit' Turner 237c5c0fdbeSDavid 'Digit' Turner /* 238c5c0fdbeSDavid 'Digit' Turner * Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply. 239c5c0fdbeSDavid 'Digit' Turner */ 240c5c0fdbeSDavid 'Digit' Turner struct virtio_blk_zone_descriptor { 241c5c0fdbeSDavid 'Digit' Turner /* Zone capacity */ 242*d0bf492fSCédric Le Goater __virtio64 z_cap; 243c5c0fdbeSDavid 'Digit' Turner /* The starting sector of the zone */ 244*d0bf492fSCédric Le Goater __virtio64 z_start; 245c5c0fdbeSDavid 'Digit' Turner /* Zone write pointer position in sectors */ 246*d0bf492fSCédric Le Goater __virtio64 z_wp; 247c5c0fdbeSDavid 'Digit' Turner /* Zone type */ 248c5c0fdbeSDavid 'Digit' Turner uint8_t z_type; 249c5c0fdbeSDavid 'Digit' Turner /* Zone state */ 250c5c0fdbeSDavid 'Digit' Turner uint8_t z_state; 251c5c0fdbeSDavid 'Digit' Turner uint8_t reserved[38]; 252c5c0fdbeSDavid 'Digit' Turner }; 253c5c0fdbeSDavid 'Digit' Turner 254c5c0fdbeSDavid 'Digit' Turner struct virtio_blk_zone_report { 255*d0bf492fSCédric Le Goater __virtio64 nr_zones; 256c5c0fdbeSDavid 'Digit' Turner uint8_t reserved[56]; 257c5c0fdbeSDavid 'Digit' Turner struct virtio_blk_zone_descriptor zones[]; 258c5c0fdbeSDavid 'Digit' Turner }; 259c5c0fdbeSDavid 'Digit' Turner 260c5c0fdbeSDavid 'Digit' Turner /* 261c5c0fdbeSDavid 'Digit' Turner * Supported zone types. 262c5c0fdbeSDavid 'Digit' Turner */ 263c5c0fdbeSDavid 'Digit' Turner 264c5c0fdbeSDavid 'Digit' Turner /* Conventional zone */ 265c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZT_CONV 1 266c5c0fdbeSDavid 'Digit' Turner /* Sequential Write Required zone */ 267c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZT_SWR 2 268c5c0fdbeSDavid 'Digit' Turner /* Sequential Write Preferred zone */ 269c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZT_SWP 3 270c5c0fdbeSDavid 'Digit' Turner 271c5c0fdbeSDavid 'Digit' Turner /* 272c5c0fdbeSDavid 'Digit' Turner * Zone states that are available for zones of all types. 273c5c0fdbeSDavid 'Digit' Turner */ 274c5c0fdbeSDavid 'Digit' Turner 275c5c0fdbeSDavid 'Digit' Turner /* Not a write pointer (conventional zones only) */ 276c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_NOT_WP 0 277c5c0fdbeSDavid 'Digit' Turner /* Empty */ 278c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_EMPTY 1 279c5c0fdbeSDavid 'Digit' Turner /* Implicitly Open */ 280c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_IOPEN 2 281c5c0fdbeSDavid 'Digit' Turner /* Explicitly Open */ 282c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_EOPEN 3 283c5c0fdbeSDavid 'Digit' Turner /* Closed */ 284c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_CLOSED 4 285c5c0fdbeSDavid 'Digit' Turner /* Read-Only */ 286c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_RDONLY 13 287c5c0fdbeSDavid 'Digit' Turner /* Full */ 288c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_FULL 14 289c5c0fdbeSDavid 'Digit' Turner /* Offline */ 290c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_ZS_OFFLINE 15 291c5c0fdbeSDavid 'Digit' Turner 292caa1ee43SChangpeng Liu /* Unmap this range (only valid for write zeroes command) */ 293caa1ee43SChangpeng Liu #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 294caa1ee43SChangpeng Liu 295caa1ee43SChangpeng Liu /* Discard/write zeroes range for each request. */ 296caa1ee43SChangpeng Liu struct virtio_blk_discard_write_zeroes { 297caa1ee43SChangpeng Liu /* discard/write zeroes start sector */ 298caa1ee43SChangpeng Liu uint64_t sector; 299caa1ee43SChangpeng Liu /* number of discard/write zeroes sectors */ 300caa1ee43SChangpeng Liu uint32_t num_sectors; 301caa1ee43SChangpeng Liu /* flags for this range */ 302caa1ee43SChangpeng Liu uint32_t flags; 303caa1ee43SChangpeng Liu }; 304caa1ee43SChangpeng Liu 3059fbe302bSMichael S. Tsirkin #ifndef VIRTIO_BLK_NO_LEGACY 3069fbe302bSMichael S. Tsirkin struct virtio_scsi_inhdr { 3079fbe302bSMichael S. Tsirkin __virtio32 errors; 3089fbe302bSMichael S. Tsirkin __virtio32 data_len; 3099fbe302bSMichael S. Tsirkin __virtio32 sense_len; 3109fbe302bSMichael S. Tsirkin __virtio32 residual; 3119fbe302bSMichael S. Tsirkin }; 3129fbe302bSMichael S. Tsirkin #endif /* !VIRTIO_BLK_NO_LEGACY */ 3139fbe302bSMichael S. Tsirkin 3149fbe302bSMichael S. Tsirkin /* And this is the final byte of the write scatter-gather list. */ 3159fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_S_OK 0 3169fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_S_IOERR 1 3179fbe302bSMichael S. Tsirkin #define VIRTIO_BLK_S_UNSUPP 2 318c5c0fdbeSDavid 'Digit' Turner 319c5c0fdbeSDavid 'Digit' Turner /* Error codes that are specific to zoned block devices */ 320c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_S_ZONE_INVALID_CMD 3 321c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4 322c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5 323c5c0fdbeSDavid 'Digit' Turner #define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6 324c5c0fdbeSDavid 'Digit' Turner 3259fbe302bSMichael S. Tsirkin #endif /* _LINUX_VIRTIO_BLK_H */ 326