Home | History | Annotate | Download | only in linux
      1 #ifndef _LINUX_VIRTIO_BLK_H
      2 #define _LINUX_VIRTIO_BLK_H
      3 #include <linux/virtio_config.h>
      4 
      5 /* The ID for virtio_block */
      6 #define VIRTIO_ID_BLOCK	2
      7 
      8 /* Feature bits */
      9 #define VIRTIO_BLK_F_BARRIER	0	/* Does host support barriers? */
     10 #define VIRTIO_BLK_F_SIZE_MAX	1	/* Indicates maximum segment size */
     11 #define VIRTIO_BLK_F_SEG_MAX	2	/* Indicates maximum # of segments */
     12 
     13 struct virtio_blk_config
     14 {
     15 	/* The capacity (in 512-byte sectors). */
     16 	__le64 capacity;
     17 	/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
     18 	__le32 size_max;
     19 	/* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
     20 	__le32 seg_max;
     21 } __attribute__((packed));
     22 
     23 /* These two define direction. */
     24 #define VIRTIO_BLK_T_IN		0
     25 #define VIRTIO_BLK_T_OUT	1
     26 
     27 /* This bit says it's a scsi command, not an actual read or write. */
     28 #define VIRTIO_BLK_T_SCSI_CMD	2
     29 
     30 /* Barrier before this op. */
     31 #define VIRTIO_BLK_T_BARRIER	0x80000000
     32 
     33 /* This is the first element of the read scatter-gather list. */
     34 struct virtio_blk_outhdr
     35 {
     36 	/* VIRTIO_BLK_T* */
     37 	__u32 type;
     38 	/* io priority. */
     39 	__u32 ioprio;
     40 	/* Sector (ie. 512 byte offset) */
     41 	__u64 sector;
     42 };
     43 
     44 #define VIRTIO_BLK_S_OK		0
     45 #define VIRTIO_BLK_S_IOERR	1
     46 #define VIRTIO_BLK_S_UNSUPP	2
     47 
     48 /* This is the first element of the write scatter-gather list */
     49 struct virtio_blk_inhdr
     50 {
     51 	unsigned char status;
     52 };
     53 #endif /* _LINUX_VIRTIO_BLK_H */
     54