virtio_blk.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _LINUX_VIRTIO_BLK_H
  2. #define _LINUX_VIRTIO_BLK_H
  3. /* This header is BSD licensed so anyone can use the definitions to implement
  4. * compatible drivers/servers. */
  5. #include <linux/types.h>
  6. #include <linux/virtio_config.h>
  7. /* The ID for virtio_block */
  8. #define VIRTIO_ID_BLOCK 2
  9. /* Feature bits */
  10. #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
  11. #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
  12. #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
  13. #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
  14. #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
  15. #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
  16. struct virtio_blk_config
  17. {
  18. /* The capacity (in 512-byte sectors). */
  19. __u64 capacity;
  20. /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
  21. __u32 size_max;
  22. /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
  23. __u32 seg_max;
  24. /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */
  25. struct virtio_blk_geometry {
  26. __u16 cylinders;
  27. __u8 heads;
  28. __u8 sectors;
  29. } geometry;
  30. /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
  31. __u32 blk_size;
  32. } __attribute__((packed));
  33. /* These two define direction. */
  34. #define VIRTIO_BLK_T_IN 0
  35. #define VIRTIO_BLK_T_OUT 1
  36. /* This bit says it's a scsi command, not an actual read or write. */
  37. #define VIRTIO_BLK_T_SCSI_CMD 2
  38. /* Barrier before this op. */
  39. #define VIRTIO_BLK_T_BARRIER 0x80000000
  40. /* This is the first element of the read scatter-gather list. */
  41. struct virtio_blk_outhdr
  42. {
  43. /* VIRTIO_BLK_T* */
  44. __u32 type;
  45. /* io priority. */
  46. __u32 ioprio;
  47. /* Sector (ie. 512 byte offset) */
  48. __u64 sector;
  49. };
  50. /* And this is the final byte of the write scatter-gather list. */
  51. #define VIRTIO_BLK_S_OK 0
  52. #define VIRTIO_BLK_S_IOERR 1
  53. #define VIRTIO_BLK_S_UNSUPP 2
  54. #endif /* _LINUX_VIRTIO_BLK_H */