hptiop.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * HighPoint RR3xxx controller driver for Linux
  3. * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * Please report bugs/comments/suggestions to linux@highpoint-tech.com
  15. *
  16. * For more information, visit http://www.highpoint-tech.com
  17. */
  18. #ifndef _HPTIOP_H_
  19. #define _HPTIOP_H_
  20. struct hpt_iopmu
  21. {
  22. __le32 resrved0[4];
  23. __le32 inbound_msgaddr0;
  24. __le32 inbound_msgaddr1;
  25. __le32 outbound_msgaddr0;
  26. __le32 outbound_msgaddr1;
  27. __le32 inbound_doorbell;
  28. __le32 inbound_intstatus;
  29. __le32 inbound_intmask;
  30. __le32 outbound_doorbell;
  31. __le32 outbound_intstatus;
  32. __le32 outbound_intmask;
  33. __le32 reserved1[2];
  34. __le32 inbound_queue;
  35. __le32 outbound_queue;
  36. };
  37. #define IOPMU_QUEUE_EMPTY 0xffffffff
  38. #define IOPMU_QUEUE_MASK_HOST_BITS 0xf0000000
  39. #define IOPMU_QUEUE_ADDR_HOST_BIT 0x80000000
  40. #define IOPMU_QUEUE_REQUEST_SIZE_BIT 0x40000000
  41. #define IOPMU_QUEUE_REQUEST_RESULT_BIT 0x40000000
  42. #define IOPMU_OUTBOUND_INT_MSG0 1
  43. #define IOPMU_OUTBOUND_INT_MSG1 2
  44. #define IOPMU_OUTBOUND_INT_DOORBELL 4
  45. #define IOPMU_OUTBOUND_INT_POSTQUEUE 8
  46. #define IOPMU_OUTBOUND_INT_PCI 0x10
  47. #define IOPMU_INBOUND_INT_MSG0 1
  48. #define IOPMU_INBOUND_INT_MSG1 2
  49. #define IOPMU_INBOUND_INT_DOORBELL 4
  50. #define IOPMU_INBOUND_INT_ERROR 8
  51. #define IOPMU_INBOUND_INT_POSTQUEUE 0x10
  52. enum hpt_iopmu_message {
  53. /* host-to-iop messages */
  54. IOPMU_INBOUND_MSG0_NOP = 0,
  55. IOPMU_INBOUND_MSG0_RESET,
  56. IOPMU_INBOUND_MSG0_FLUSH,
  57. IOPMU_INBOUND_MSG0_SHUTDOWN,
  58. IOPMU_INBOUND_MSG0_STOP_BACKGROUND_TASK,
  59. IOPMU_INBOUND_MSG0_START_BACKGROUND_TASK,
  60. IOPMU_INBOUND_MSG0_MAX = 0xff,
  61. /* iop-to-host messages */
  62. IOPMU_OUTBOUND_MSG0_REGISTER_DEVICE_0 = 0x100,
  63. IOPMU_OUTBOUND_MSG0_REGISTER_DEVICE_MAX = 0x1ff,
  64. IOPMU_OUTBOUND_MSG0_UNREGISTER_DEVICE_0 = 0x200,
  65. IOPMU_OUTBOUND_MSG0_UNREGISTER_DEVICE_MAX = 0x2ff,
  66. IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_0 = 0x300,
  67. IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_MAX = 0x3ff,
  68. };
  69. struct hpt_iop_request_header
  70. {
  71. __le32 size;
  72. __le32 type;
  73. __le32 flags;
  74. __le32 result;
  75. __le32 context; /* host context */
  76. __le32 context_hi32;
  77. };
  78. #define IOP_REQUEST_FLAG_SYNC_REQUEST 1
  79. #define IOP_REQUEST_FLAG_BIST_REQUEST 2
  80. #define IOP_REQUEST_FLAG_REMAPPED 4
  81. #define IOP_REQUEST_FLAG_OUTPUT_CONTEXT 8
  82. enum hpt_iop_request_type {
  83. IOP_REQUEST_TYPE_GET_CONFIG = 0,
  84. IOP_REQUEST_TYPE_SET_CONFIG,
  85. IOP_REQUEST_TYPE_BLOCK_COMMAND,
  86. IOP_REQUEST_TYPE_SCSI_COMMAND,
  87. IOP_REQUEST_TYPE_IOCTL_COMMAND,
  88. IOP_REQUEST_TYPE_MAX
  89. };
  90. enum hpt_iop_result_type {
  91. IOP_RESULT_PENDING = 0,
  92. IOP_RESULT_SUCCESS,
  93. IOP_RESULT_FAIL,
  94. IOP_RESULT_BUSY,
  95. IOP_RESULT_RESET,
  96. IOP_RESULT_INVALID_REQUEST,
  97. IOP_RESULT_BAD_TARGET,
  98. IOP_RESULT_MODE_SENSE_CHECK_CONDITION,
  99. };
  100. struct hpt_iop_request_get_config
  101. {
  102. struct hpt_iop_request_header header;
  103. __le32 interface_version;
  104. __le32 firmware_version;
  105. __le32 max_requests;
  106. __le32 request_size;
  107. __le32 max_sg_count;
  108. __le32 data_transfer_length;
  109. __le32 alignment_mask;
  110. __le32 max_devices;
  111. __le32 sdram_size;
  112. };
  113. struct hpt_iop_request_set_config
  114. {
  115. struct hpt_iop_request_header header;
  116. __le32 iop_id;
  117. __le16 vbus_id;
  118. __le16 max_host_request_size;
  119. __le32 reserve[6];
  120. };
  121. struct hpt_iopsg
  122. {
  123. __le32 size;
  124. __le32 eot; /* non-zero: end of table */
  125. __le64 pci_address;
  126. };
  127. struct hpt_iop_request_block_command
  128. {
  129. struct hpt_iop_request_header header;
  130. u8 channel;
  131. u8 target;
  132. u8 lun;
  133. u8 pad1;
  134. __le16 command; /* IOP_BLOCK_COMMAND_{READ,WRITE} */
  135. __le16 sectors;
  136. __le64 lba;
  137. struct hpt_iopsg sg_list[1];
  138. };
  139. #define IOP_BLOCK_COMMAND_READ 1
  140. #define IOP_BLOCK_COMMAND_WRITE 2
  141. #define IOP_BLOCK_COMMAND_VERIFY 3
  142. #define IOP_BLOCK_COMMAND_FLUSH 4
  143. #define IOP_BLOCK_COMMAND_SHUTDOWN 5
  144. struct hpt_iop_request_scsi_command
  145. {
  146. struct hpt_iop_request_header header;
  147. u8 channel;
  148. u8 target;
  149. u8 lun;
  150. u8 pad1;
  151. u8 cdb[16];
  152. __le32 dataxfer_length;
  153. struct hpt_iopsg sg_list[1];
  154. };
  155. struct hpt_iop_request_ioctl_command
  156. {
  157. struct hpt_iop_request_header header;
  158. __le32 ioctl_code;
  159. __le32 inbuf_size;
  160. __le32 outbuf_size;
  161. __le32 bytes_returned;
  162. u8 buf[1];
  163. /* out data should be put at buf[(inbuf_size+3)&~3] */
  164. };
  165. #define HPTIOP_MAX_REQUESTS 256u
  166. struct hptiop_request {
  167. struct hptiop_request * next;
  168. void * req_virt;
  169. u32 req_shifted_phy;
  170. struct scsi_cmnd * scp;
  171. int index;
  172. };
  173. struct hpt_scsi_pointer {
  174. int mapped;
  175. int sgcnt;
  176. dma_addr_t dma_handle;
  177. };
  178. #define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp)
  179. struct hptiop_hba {
  180. struct hpt_iopmu __iomem * iop;
  181. struct Scsi_Host * host;
  182. struct pci_dev * pcidev;
  183. /* IOP config info */
  184. u32 interface_version;
  185. u32 firmware_version;
  186. u32 sdram_size;
  187. u32 max_devices;
  188. u32 max_requests;
  189. u32 max_request_size;
  190. u32 max_sg_descriptors;
  191. u32 req_size; /* host-allocated request buffer size */
  192. int iopintf_v2: 1;
  193. int initialized: 1;
  194. int msg_done: 1;
  195. struct hptiop_request * req_list;
  196. struct hptiop_request reqs[HPTIOP_MAX_REQUESTS];
  197. /* used to free allocated dma area */
  198. void * dma_coherent;
  199. dma_addr_t dma_coherent_handle;
  200. atomic_t reset_count;
  201. atomic_t resetting;
  202. wait_queue_head_t reset_wq;
  203. wait_queue_head_t ioctl_wq;
  204. };
  205. struct hpt_ioctl_k
  206. {
  207. struct hptiop_hba * hba;
  208. u32 ioctl_code;
  209. u32 inbuf_size;
  210. u32 outbuf_size;
  211. void * inbuf;
  212. void * outbuf;
  213. u32 * bytes_returned;
  214. void (*done)(struct hpt_ioctl_k *);
  215. int result; /* HPT_IOCTL_RESULT_ */
  216. };
  217. #define HPT_IOCTL_RESULT_OK 0
  218. #define HPT_IOCTL_RESULT_FAILED (-1)
  219. #if 0
  220. #define dprintk(fmt, args...) do { printk(fmt, ##args); } while(0)
  221. #else
  222. #define dprintk(fmt, args...)
  223. #endif
  224. #endif