#ifndef _LINUX_VIRTIO_BLK_H #define _LINUX_VIRTIO_BLK_H /* This header is BSD licensed so anyone can use the definitions to implement * compatible drivers/servers. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of IBM nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <linux/types.h> #include <linux/virtio_ids.h> #include <linux/virtio_config.h> #include <linux/virtio_types.h> /* Feature bits */ #define VIRTIO_BLK_F_SIZE_MAX … #define VIRTIO_BLK_F_SEG_MAX … #define VIRTIO_BLK_F_GEOMETRY … #define VIRTIO_BLK_F_RO … #define VIRTIO_BLK_F_BLK_SIZE … #define VIRTIO_BLK_F_TOPOLOGY … #define VIRTIO_BLK_F_MQ … #define VIRTIO_BLK_F_DISCARD … #define VIRTIO_BLK_F_WRITE_ZEROES … #define VIRTIO_BLK_F_SECURE_ERASE … #define VIRTIO_BLK_F_ZONED … /* Legacy feature bits */ #ifndef VIRTIO_BLK_NO_LEGACY #define VIRTIO_BLK_F_BARRIER … #define VIRTIO_BLK_F_SCSI … #define VIRTIO_BLK_F_FLUSH … #define VIRTIO_BLK_F_CONFIG_WCE … #ifndef __KERNEL__ /* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */ #define VIRTIO_BLK_F_WCE … #endif #endif /* !VIRTIO_BLK_NO_LEGACY */ #define VIRTIO_BLK_ID_BYTES … struct virtio_blk_config { … } __attribute__((packed)); /* * Command types * * Usage is a bit tricky as some bits are used as flags and some are not. * * Rules: * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own * and may not be combined with any of the other flags. */ /* These two define direction. */ #define VIRTIO_BLK_T_IN … #define VIRTIO_BLK_T_OUT … #ifndef VIRTIO_BLK_NO_LEGACY /* This bit says it's a scsi command, not an actual read or write. */ #define VIRTIO_BLK_T_SCSI_CMD … #endif /* VIRTIO_BLK_NO_LEGACY */ /* Cache flush command */ #define VIRTIO_BLK_T_FLUSH … /* Get device ID command */ #define VIRTIO_BLK_T_GET_ID … /* Discard command */ #define VIRTIO_BLK_T_DISCARD … /* Write zeroes command */ #define VIRTIO_BLK_T_WRITE_ZEROES … /* Secure erase command */ #define VIRTIO_BLK_T_SECURE_ERASE … /* Zone append command */ #define VIRTIO_BLK_T_ZONE_APPEND … /* Report zones command */ #define VIRTIO_BLK_T_ZONE_REPORT … /* Open zone command */ #define VIRTIO_BLK_T_ZONE_OPEN … /* Close zone command */ #define VIRTIO_BLK_T_ZONE_CLOSE … /* Finish zone command */ #define VIRTIO_BLK_T_ZONE_FINISH … /* Reset zone command */ #define VIRTIO_BLK_T_ZONE_RESET … /* Reset All zones command */ #define VIRTIO_BLK_T_ZONE_RESET_ALL … #ifndef VIRTIO_BLK_NO_LEGACY /* Barrier before this op. */ #define VIRTIO_BLK_T_BARRIER … #endif /* !VIRTIO_BLK_NO_LEGACY */ /* * This comes first in the read scatter-gather list. * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, * this is the first element of the read scatter-gather list. */ struct virtio_blk_outhdr { … }; /* * Supported zoned device models. */ /* Regular block device */ #define VIRTIO_BLK_Z_NONE … /* Host-managed zoned device */ #define VIRTIO_BLK_Z_HM … /* Host-aware zoned device */ #define VIRTIO_BLK_Z_HA … /* * Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply. */ struct virtio_blk_zone_descriptor { … }; struct virtio_blk_zone_report { … }; /* * Supported zone types. */ /* Conventional zone */ #define VIRTIO_BLK_ZT_CONV … /* Sequential Write Required zone */ #define VIRTIO_BLK_ZT_SWR … /* Sequential Write Preferred zone */ #define VIRTIO_BLK_ZT_SWP … /* * Zone states that are available for zones of all types. */ /* Not a write pointer (conventional zones only) */ #define VIRTIO_BLK_ZS_NOT_WP … /* Empty */ #define VIRTIO_BLK_ZS_EMPTY … /* Implicitly Open */ #define VIRTIO_BLK_ZS_IOPEN … /* Explicitly Open */ #define VIRTIO_BLK_ZS_EOPEN … /* Closed */ #define VIRTIO_BLK_ZS_CLOSED … /* Read-Only */ #define VIRTIO_BLK_ZS_RDONLY … /* Full */ #define VIRTIO_BLK_ZS_FULL … /* Offline */ #define VIRTIO_BLK_ZS_OFFLINE … /* Unmap this range (only valid for write zeroes command) */ #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP … /* Discard/write zeroes range for each request. */ struct virtio_blk_discard_write_zeroes { … }; #ifndef VIRTIO_BLK_NO_LEGACY struct virtio_scsi_inhdr { … }; #endif /* !VIRTIO_BLK_NO_LEGACY */ /* And this is the final byte of the write scatter-gather list. */ #define VIRTIO_BLK_S_OK … #define VIRTIO_BLK_S_IOERR … #define VIRTIO_BLK_S_UNSUPP … /* Error codes that are specific to zoned block devices */ #define VIRTIO_BLK_S_ZONE_INVALID_CMD … #define VIRTIO_BLK_S_ZONE_UNALIGNED_WP … #define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE … #define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE … #endif /* _LINUX_VIRTIO_BLK_H */