sg.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef _SCSI_SG_H
  2. #define _SCSI_SG_H
  3. #define SG_DXFER_NONE -1
  4. #define SG_DXFER_TO_DEV -2
  5. #define SG_DXFER_FROM_DEV -3
  6. #define SG_DXFER_TO_FROM_DEV -4
  7. #define SG_FLAG_DIRECT_IO 1
  8. #define SG_FLAG_LUN_INHIBIT 2
  9. #define SG_FLAG_NO_DXFER 0x10000
  10. #define SG_INFO_OK_MASK 0x1
  11. #define SG_INFO_OK 0x0
  12. #define SG_INFO_CHECK 0x1
  13. #define SG_INFO_DIRECT_IO_MASK 0x6
  14. #define SG_INFO_INDIRECT_IO 0x0
  15. #define SG_INFO_DIRECT_IO 0x2
  16. #define SG_INFO_MIXED_IO 0x4
  17. #define SG_EMULATED_HOST 0x2203
  18. #define SG_SET_TRANSFORM 0x2204
  19. #define SG_GET_TRANSFORM 0x2205
  20. #define SG_SET_RESERVED_SIZE 0x2275
  21. #define SG_GET_RESERVED_SIZE 0x2272
  22. #define SG_GET_SCSI_ID 0x2276
  23. #define SG_SET_FORCE_LOW_DMA 0x2279
  24. #define SG_GET_LOW_DMA 0x227a
  25. #define SG_SET_FORCE_PACK_ID 0x227b
  26. #define SG_GET_PACK_ID 0x227c
  27. #define SG_GET_NUM_WAITING 0x227d
  28. #define SG_GET_SG_TABLESIZE 0x227F
  29. #define SG_GET_VERSION_NUM 0x2282
  30. #define SG_SCSI_RESET 0x2284
  31. #define SG_SCSI_RESET_NOTHING 0
  32. #define SG_SCSI_RESET_DEVICE 1
  33. #define SG_SCSI_RESET_BUS 2
  34. #define SG_SCSI_RESET_HOST 3
  35. #define SG_IO 0x2285
  36. #define SG_GET_REQUEST_TABLE 0x2286
  37. #define SG_SET_KEEP_ORPHAN 0x2287
  38. #define SG_GET_KEEP_ORPHAN 0x2288
  39. #define SG_SCATTER_SZ (8 * 4096)
  40. #define SG_DEFAULT_RETRIES 1
  41. #define SG_DEF_FORCE_LOW_DMA 0
  42. #define SG_DEF_FORCE_PACK_ID 0
  43. #define SG_DEF_KEEP_ORPHAN 0
  44. #define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ
  45. #define SG_MAX_QUEUE 16
  46. #define SG_BIG_BUFF SG_DEF_RESERVED_SIZE
  47. #define SG_MAX_SENSE 16
  48. #define SG_SET_TIMEOUT 0x2201
  49. #define SG_GET_TIMEOUT 0x2202
  50. #define SG_GET_COMMAND_Q 0x2270
  51. #define SG_SET_COMMAND_Q 0x2271
  52. #define SG_SET_DEBUG 0x227e
  53. #define SG_NEXT_CMD_LEN 0x2283
  54. #define SG_DEFAULT_TIMEOUT (60*100) /* 60*HZ */
  55. #define SG_DEF_COMMAND_Q 0
  56. #define SG_DEF_UNDERRUN_FLAG 0
  57. typedef struct sg_iovec {
  58. void *iov_base;
  59. unsigned long iov_len;
  60. } sg_iovec_t;
  61. typedef struct sg_io_hdr {
  62. int interface_id;
  63. int dxfer_direction;
  64. unsigned char cmd_len;
  65. unsigned char mx_sb_len;
  66. unsigned short iovec_count;
  67. unsigned dxfer_len;
  68. void *dxferp;
  69. unsigned char *cmdp;
  70. unsigned char *sbp;
  71. unsigned timeout;
  72. unsigned flags;
  73. int pack_id;
  74. void *usr_ptr;
  75. unsigned char status;
  76. unsigned char masked_status;
  77. unsigned char msg_status;
  78. unsigned char sb_len_wr;
  79. unsigned short host_status;
  80. unsigned short driver_status;
  81. int resid;
  82. unsigned int duration;
  83. unsigned int info;
  84. } sg_io_hdr_t;
  85. struct sg_scsi_id {
  86. int host_no;
  87. int channel;
  88. int scsi_id;
  89. int lun;
  90. int scsi_type;
  91. short h_cmd_per_lun;
  92. short d_queue_depth;
  93. int unused[2];
  94. };
  95. typedef struct sg_req_info {
  96. char req_state;
  97. char orphan;
  98. char sg_io_owned;
  99. char problem;
  100. int pack_id;
  101. void *usr_ptr;
  102. unsigned duration;
  103. int unused;
  104. } sg_req_info_t;
  105. typedef struct sg_io_hdr Sg_io_hdr;
  106. typedef struct sg_io_vec Sg_io_vec;
  107. typedef struct sg_scsi_id Sg_scsi_id;
  108. typedef struct sg_req_info Sg_req_info;
  109. struct sg_header {
  110. int pack_len;
  111. int reply_len;
  112. int pack_id;
  113. int result;
  114. unsigned twelve_byte:1;
  115. unsigned target_status:5;
  116. unsigned host_status:8;
  117. unsigned driver_status:8;
  118. unsigned other_flags:10;
  119. unsigned char sense_buffer[SG_MAX_SENSE];
  120. };
  121. #endif