cciss.h 7.3 KB

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