virtio_blk.h 1.3 KB

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