cciss.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #ifndef CCISS_H
  2. #define CCISS_H
  3. #include <linux/genhd.h>
  4. #include "cciss_cmd.h"
  5. #define NWD 16
  6. #define NWD_SHIFT 4
  7. #define MAX_PART (1 << NWD_SHIFT)
  8. #define IO_OK 0
  9. #define IO_ERROR 1
  10. #define MAJOR_NR COMPAQ_CISS_MAJOR
  11. struct ctlr_info;
  12. typedef struct ctlr_info ctlr_info_t;
  13. struct access_method {
  14. void (*submit_command)(ctlr_info_t *h, CommandList_struct *c);
  15. void (*set_intr_mask)(ctlr_info_t *h, unsigned long val);
  16. unsigned long (*fifo_full)(ctlr_info_t *h);
  17. unsigned long (*intr_pending)(ctlr_info_t *h);
  18. unsigned long (*command_completed)(ctlr_info_t *h);
  19. };
  20. typedef struct _drive_info_struct
  21. {
  22. __u32 LunID;
  23. int usage_count;
  24. struct request_queue *queue;
  25. sector_t nr_blocks;
  26. int block_size;
  27. int heads;
  28. int sectors;
  29. int cylinders;
  30. int raid_level; /* set to -1 to indicate that
  31. * the drive is not in use/configured
  32. */
  33. int busy_configuring; /*This is set when the drive is being removed
  34. *to prevent it from being opened or it's queue
  35. *from being started.
  36. */
  37. } drive_info_struct;
  38. #ifdef CONFIG_CISS_SCSI_TAPE
  39. struct sendcmd_reject_list {
  40. int ncompletions;
  41. unsigned long *complete; /* array of NR_CMDS tags */
  42. };
  43. #endif
  44. struct ctlr_info
  45. {
  46. int ctlr;
  47. char devname[8];
  48. char *product_name;
  49. char firm_ver[4]; // Firmware version
  50. struct pci_dev *pdev;
  51. __u32 board_id;
  52. void __iomem *vaddr;
  53. unsigned long paddr;
  54. unsigned long io_mem_addr;
  55. unsigned long io_mem_length;
  56. CfgTable_struct __iomem *cfgtable;
  57. unsigned int intr;
  58. int interrupts_enabled;
  59. int major;
  60. int max_commands;
  61. int commands_outstanding;
  62. int max_outstanding; /* Debug */
  63. int num_luns;
  64. int highest_lun;
  65. int usage_count; /* number of opens all all minor devices */
  66. // information about each logical volume
  67. drive_info_struct drv[CISS_MAX_LUN];
  68. struct access_method access;
  69. /* queue and queue Info */
  70. CommandList_struct *reqQ;
  71. CommandList_struct *cmpQ;
  72. unsigned int Qdepth;
  73. unsigned int maxQsinceinit;
  74. unsigned int maxSG;
  75. spinlock_t lock;
  76. //* pointers to command and error info pool */
  77. CommandList_struct *cmd_pool;
  78. dma_addr_t cmd_pool_dhandle;
  79. ErrorInfo_struct *errinfo_pool;
  80. dma_addr_t errinfo_pool_dhandle;
  81. unsigned long *cmd_pool_bits;
  82. int nr_allocs;
  83. int nr_frees;
  84. int busy_configuring;
  85. int busy_initializing;
  86. /* This element holds the zero based queue number of the last
  87. * queue to be started. It is used for fairness.
  88. */
  89. int next_to_run;
  90. // Disk structures we need to pass back
  91. struct gendisk *gendisk[NWD];
  92. #ifdef CONFIG_CISS_SCSI_TAPE
  93. void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
  94. /* list of block side commands the scsi error handling sucked up */
  95. /* and saved for later processing */
  96. struct sendcmd_reject_list scsi_rejects;
  97. #endif
  98. unsigned char alive;
  99. };
  100. /* Defining the diffent access_menthods */
  101. /*
  102. * Memory mapped FIFO interface (SMART 53xx cards)
  103. */
  104. #define SA5_DOORBELL 0x20
  105. #define SA5_REQUEST_PORT_OFFSET 0x40
  106. #define SA5_REPLY_INTR_MASK_OFFSET 0x34
  107. #define SA5_REPLY_PORT_OFFSET 0x44
  108. #define SA5_INTR_STATUS 0x30
  109. #define SA5_SCRATCHPAD_OFFSET 0xB0
  110. #define SA5_CTCFG_OFFSET 0xB4
  111. #define SA5_CTMEM_OFFSET 0xB8
  112. #define SA5_INTR_OFF 0x08
  113. #define SA5B_INTR_OFF 0x04
  114. #define SA5_INTR_PENDING 0x08
  115. #define SA5B_INTR_PENDING 0x04
  116. #define FIFO_EMPTY 0xffffffff
  117. #define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
  118. #define CISS_ERROR_BIT 0x02
  119. #define CCISS_INTR_ON 1
  120. #define CCISS_INTR_OFF 0
  121. /*
  122. Send the command to the hardware
  123. */
  124. static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c)
  125. {
  126. #ifdef CCISS_DEBUG
  127. printk("Sending %x - down to controller\n", c->busaddr );
  128. #endif /* CCISS_DEBUG */
  129. writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
  130. h->commands_outstanding++;
  131. if ( h->commands_outstanding > h->max_outstanding)
  132. h->max_outstanding = h->commands_outstanding;
  133. }
  134. /*
  135. * This card is the opposite of the other cards.
  136. * 0 turns interrupts on...
  137. * 0x08 turns them off...
  138. */
  139. static void SA5_intr_mask(ctlr_info_t *h, unsigned long val)
  140. {
  141. if (val)
  142. { /* Turn interrupts on */
  143. h->interrupts_enabled = 1;
  144. writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  145. } else /* Turn them off */
  146. {
  147. h->interrupts_enabled = 0;
  148. writel( SA5_INTR_OFF,
  149. h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  150. }
  151. }
  152. /*
  153. * This card is the opposite of the other cards.
  154. * 0 turns interrupts on...
  155. * 0x04 turns them off...
  156. */
  157. static void SA5B_intr_mask(ctlr_info_t *h, unsigned long val)
  158. {
  159. if (val)
  160. { /* Turn interrupts on */
  161. h->interrupts_enabled = 1;
  162. writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  163. } else /* Turn them off */
  164. {
  165. h->interrupts_enabled = 0;
  166. writel( SA5B_INTR_OFF,
  167. h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  168. }
  169. }
  170. /*
  171. * Returns true if fifo is full.
  172. *
  173. */
  174. static unsigned long SA5_fifo_full(ctlr_info_t *h)
  175. {
  176. if( h->commands_outstanding >= h->max_commands)
  177. return(1);
  178. else
  179. return(0);
  180. }
  181. /*
  182. * returns value read from hardware.
  183. * returns FIFO_EMPTY if there is nothing to read
  184. */
  185. static unsigned long SA5_completed(ctlr_info_t *h)
  186. {
  187. unsigned long register_value
  188. = readl(h->vaddr + SA5_REPLY_PORT_OFFSET);
  189. if(register_value != FIFO_EMPTY)
  190. {
  191. h->commands_outstanding--;
  192. #ifdef CCISS_DEBUG
  193. printk("cciss: Read %lx back from board\n", register_value);
  194. #endif /* CCISS_DEBUG */
  195. }
  196. #ifdef CCISS_DEBUG
  197. else
  198. {
  199. printk("cciss: FIFO Empty read\n");
  200. }
  201. #endif
  202. return ( register_value);
  203. }
  204. /*
  205. * Returns true if an interrupt is pending..
  206. */
  207. static unsigned long SA5_intr_pending(ctlr_info_t *h)
  208. {
  209. unsigned long register_value =
  210. readl(h->vaddr + SA5_INTR_STATUS);
  211. #ifdef CCISS_DEBUG
  212. printk("cciss: intr_pending %lx\n", register_value);
  213. #endif /* CCISS_DEBUG */
  214. if( register_value & SA5_INTR_PENDING)
  215. return 1;
  216. return 0 ;
  217. }
  218. /*
  219. * Returns true if an interrupt is pending..
  220. */
  221. static unsigned long SA5B_intr_pending(ctlr_info_t *h)
  222. {
  223. unsigned long register_value =
  224. readl(h->vaddr + SA5_INTR_STATUS);
  225. #ifdef CCISS_DEBUG
  226. printk("cciss: intr_pending %lx\n", register_value);
  227. #endif /* CCISS_DEBUG */
  228. if( register_value & SA5B_INTR_PENDING)
  229. return 1;
  230. return 0 ;
  231. }
  232. static struct access_method SA5_access = {
  233. SA5_submit_command,
  234. SA5_intr_mask,
  235. SA5_fifo_full,
  236. SA5_intr_pending,
  237. SA5_completed,
  238. };
  239. static struct access_method SA5B_access = {
  240. SA5_submit_command,
  241. SA5B_intr_mask,
  242. SA5_fifo_full,
  243. SA5B_intr_pending,
  244. SA5_completed,
  245. };
  246. struct board_type {
  247. __u32 board_id;
  248. char *product_name;
  249. struct access_method *access;
  250. };
  251. #define CCISS_LOCK(i) (&hba[i]->lock)
  252. #endif /* CCISS_H */