virtio_blk.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
  11. #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
  12. struct virtio_blk_config
  13. {
  14. /* The capacity (in 512-byte sectors). */
  15. __u64 capacity;
  16. /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
  17. __u32 size_max;
  18. /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
  19. __u32 seg_max;
  20. /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
  21. struct virtio_blk_geometry {
  22. __u16 cylinders;
  23. __u8 heads;
  24. __u8 sectors;
  25. } geometry;
  26. } __attribute__((packed));
  27. /* These two define direction. */
  28. #define VIRTIO_BLK_T_IN 0
  29. #define VIRTIO_BLK_T_OUT 1
  30. /* This bit says it's a scsi command, not an actual read or write. */
  31. #define VIRTIO_BLK_T_SCSI_CMD 2
  32. /* Barrier before this op. */
  33. #define VIRTIO_BLK_T_BARRIER 0x80000000
  34. /* This is the first element of the read scatter-gather list. */
  35. struct virtio_blk_outhdr
  36. {
  37. /* VIRTIO_BLK_T* */
  38. __u32 type;
  39. /* io priority. */
  40. __u32 ioprio;
  41. /* Sector (ie. 512 byte offset) */
  42. __u64 sector;
  43. };
  44. /* And this is the final byte of the write scatter-gather list. */
  45. #define VIRTIO_BLK_S_OK 0
  46. #define VIRTIO_BLK_S_IOERR 1
  47. #define VIRTIO_BLK_S_UNSUPP 2
  48. #endif /* _LINUX_VIRTIO_BLK_H */