cciss.h 7.2 KB

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