virtio_blk.h 1.8 KB

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