hpsa.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /*
  2. * Disk Array driver for HP Smart Array SAS controllers
  3. * Copyright 2000, 2014 Hewlett-Packard Development Company, L.P.
  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, GOOD TITLE or
  12. * NON INFRINGEMENT. See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * Questions/Comments/Bugfixes to iss_storagedev@hp.com
  19. *
  20. */
  21. #ifndef HPSA_H
  22. #define HPSA_H
  23. #include <scsi/scsicam.h>
  24. #define IO_OK 0
  25. #define IO_ERROR 1
  26. struct ctlr_info;
  27. struct access_method {
  28. void (*submit_command)(struct ctlr_info *h,
  29. struct CommandList *c);
  30. void (*set_intr_mask)(struct ctlr_info *h, unsigned long val);
  31. bool (*intr_pending)(struct ctlr_info *h);
  32. unsigned long (*command_completed)(struct ctlr_info *h, u8 q);
  33. };
  34. struct hpsa_scsi_dev_t {
  35. int devtype;
  36. int bus, target, lun; /* as presented to the OS */
  37. unsigned char scsi3addr[8]; /* as presented to the HW */
  38. #define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
  39. unsigned char device_id[16]; /* from inquiry pg. 0x83 */
  40. unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
  41. unsigned char model[16]; /* bytes 16-31 of inquiry data */
  42. unsigned char raid_level; /* from inquiry page 0xC1 */
  43. unsigned char volume_offline; /* discovered via TUR or VPD */
  44. u16 queue_depth; /* max queue_depth for this device */
  45. atomic_t reset_cmds_out; /* Count of commands to-be affected */
  46. atomic_t ioaccel_cmds_out; /* Only used for physical devices
  47. * counts commands sent to physical
  48. * device via "ioaccel" path.
  49. */
  50. u32 ioaccel_handle;
  51. int offload_config; /* I/O accel RAID offload configured */
  52. int offload_enabled; /* I/O accel RAID offload enabled */
  53. int offload_to_be_enabled;
  54. int hba_ioaccel_enabled;
  55. int offload_to_mirror; /* Send next I/O accelerator RAID
  56. * offload request to mirror drive
  57. */
  58. struct raid_map_data raid_map; /* I/O accelerator RAID map */
  59. /*
  60. * Pointers from logical drive map indices to the phys drives that
  61. * make those logical drives. Note, multiple logical drives may
  62. * share physical drives. You can have for instance 5 physical
  63. * drives with 3 logical drives each using those same 5 physical
  64. * disks. We need these pointers for counting i/o's out to physical
  65. * devices in order to honor physical device queue depth limits.
  66. */
  67. struct hpsa_scsi_dev_t *phys_disk[RAID_MAP_MAX_ENTRIES];
  68. int nphysical_disks;
  69. int supports_aborts;
  70. #define HPSA_DO_NOT_EXPOSE 0x0
  71. #define HPSA_SG_ATTACH 0x1
  72. #define HPSA_ULD_ATTACH 0x2
  73. #define HPSA_SCSI_ADD (HPSA_SG_ATTACH | HPSA_ULD_ATTACH)
  74. u8 expose_state;
  75. };
  76. struct reply_queue_buffer {
  77. u64 *head;
  78. size_t size;
  79. u8 wraparound;
  80. u32 current_entry;
  81. dma_addr_t busaddr;
  82. };
  83. #pragma pack(1)
  84. struct bmic_controller_parameters {
  85. u8 led_flags;
  86. u8 enable_command_list_verification;
  87. u8 backed_out_write_drives;
  88. u16 stripes_for_parity;
  89. u8 parity_distribution_mode_flags;
  90. u16 max_driver_requests;
  91. u16 elevator_trend_count;
  92. u8 disable_elevator;
  93. u8 force_scan_complete;
  94. u8 scsi_transfer_mode;
  95. u8 force_narrow;
  96. u8 rebuild_priority;
  97. u8 expand_priority;
  98. u8 host_sdb_asic_fix;
  99. u8 pdpi_burst_from_host_disabled;
  100. char software_name[64];
  101. char hardware_name[32];
  102. u8 bridge_revision;
  103. u8 snapshot_priority;
  104. u32 os_specific;
  105. u8 post_prompt_timeout;
  106. u8 automatic_drive_slamming;
  107. u8 reserved1;
  108. u8 nvram_flags;
  109. #define HBA_MODE_ENABLED_FLAG (1 << 3)
  110. u8 cache_nvram_flags;
  111. u8 drive_config_flags;
  112. u16 reserved2;
  113. u8 temp_warning_level;
  114. u8 temp_shutdown_level;
  115. u8 temp_condition_reset;
  116. u8 max_coalesce_commands;
  117. u32 max_coalesce_delay;
  118. u8 orca_password[4];
  119. u8 access_id[16];
  120. u8 reserved[356];
  121. };
  122. #pragma pack()
  123. struct ctlr_info {
  124. int ctlr;
  125. char devname[8];
  126. char *product_name;
  127. struct pci_dev *pdev;
  128. u32 board_id;
  129. void __iomem *vaddr;
  130. unsigned long paddr;
  131. int nr_cmds; /* Number of commands allowed on this controller */
  132. #define HPSA_CMDS_RESERVED_FOR_ABORTS 2
  133. #define HPSA_CMDS_RESERVED_FOR_DRIVER 1
  134. struct CfgTable __iomem *cfgtable;
  135. int interrupts_enabled;
  136. int max_commands;
  137. atomic_t commands_outstanding;
  138. # define PERF_MODE_INT 0
  139. # define DOORBELL_INT 1
  140. # define SIMPLE_MODE_INT 2
  141. # define MEMQ_MODE_INT 3
  142. unsigned int intr[MAX_REPLY_QUEUES];
  143. unsigned int msix_vector;
  144. unsigned int msi_vector;
  145. int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
  146. struct access_method access;
  147. char hba_mode_enabled;
  148. /* queue and queue Info */
  149. unsigned int Qdepth;
  150. unsigned int maxSG;
  151. spinlock_t lock;
  152. int maxsgentries;
  153. u8 max_cmd_sg_entries;
  154. int chainsize;
  155. struct SGDescriptor **cmd_sg_list;
  156. struct ioaccel2_sg_element **ioaccel2_cmd_sg_list;
  157. /* pointers to command and error info pool */
  158. struct CommandList *cmd_pool;
  159. dma_addr_t cmd_pool_dhandle;
  160. struct io_accel1_cmd *ioaccel_cmd_pool;
  161. dma_addr_t ioaccel_cmd_pool_dhandle;
  162. struct io_accel2_cmd *ioaccel2_cmd_pool;
  163. dma_addr_t ioaccel2_cmd_pool_dhandle;
  164. struct ErrorInfo *errinfo_pool;
  165. dma_addr_t errinfo_pool_dhandle;
  166. unsigned long *cmd_pool_bits;
  167. int scan_finished;
  168. spinlock_t scan_lock;
  169. wait_queue_head_t scan_wait_queue;
  170. struct Scsi_Host *scsi_host;
  171. spinlock_t devlock; /* to protect hba[ctlr]->dev[]; */
  172. int ndevices; /* number of used elements in .dev[] array. */
  173. struct hpsa_scsi_dev_t *dev[HPSA_MAX_DEVICES];
  174. /*
  175. * Performant mode tables.
  176. */
  177. u32 trans_support;
  178. u32 trans_offset;
  179. struct TransTable_struct __iomem *transtable;
  180. unsigned long transMethod;
  181. /* cap concurrent passthrus at some reasonable maximum */
  182. #define HPSA_MAX_CONCURRENT_PASSTHRUS (10)
  183. atomic_t passthru_cmds_avail;
  184. /*
  185. * Performant mode completion buffers
  186. */
  187. size_t reply_queue_size;
  188. struct reply_queue_buffer reply_queue[MAX_REPLY_QUEUES];
  189. u8 nreply_queues;
  190. u32 *blockFetchTable;
  191. u32 *ioaccel1_blockFetchTable;
  192. u32 *ioaccel2_blockFetchTable;
  193. u32 __iomem *ioaccel2_bft2_regs;
  194. unsigned char *hba_inquiry_data;
  195. u32 driver_support;
  196. u32 fw_support;
  197. int ioaccel_support;
  198. int ioaccel_maxsg;
  199. u64 last_intr_timestamp;
  200. u32 last_heartbeat;
  201. u64 last_heartbeat_timestamp;
  202. u32 heartbeat_sample_interval;
  203. atomic_t firmware_flash_in_progress;
  204. u32 __percpu *lockup_detected;
  205. struct delayed_work monitor_ctlr_work;
  206. struct delayed_work rescan_ctlr_work;
  207. int remove_in_progress;
  208. /* Address of h->q[x] is passed to intr handler to know which queue */
  209. u8 q[MAX_REPLY_QUEUES];
  210. char intrname[MAX_REPLY_QUEUES][16]; /* "hpsa0-msix00" names */
  211. u32 TMFSupportFlags; /* cache what task mgmt funcs are supported. */
  212. #define HPSATMF_BITS_SUPPORTED (1 << 0)
  213. #define HPSATMF_PHYS_LUN_RESET (1 << 1)
  214. #define HPSATMF_PHYS_NEX_RESET (1 << 2)
  215. #define HPSATMF_PHYS_TASK_ABORT (1 << 3)
  216. #define HPSATMF_PHYS_TSET_ABORT (1 << 4)
  217. #define HPSATMF_PHYS_CLEAR_ACA (1 << 5)
  218. #define HPSATMF_PHYS_CLEAR_TSET (1 << 6)
  219. #define HPSATMF_PHYS_QRY_TASK (1 << 7)
  220. #define HPSATMF_PHYS_QRY_TSET (1 << 8)
  221. #define HPSATMF_PHYS_QRY_ASYNC (1 << 9)
  222. #define HPSATMF_IOACCEL_ENABLED (1 << 15)
  223. #define HPSATMF_MASK_SUPPORTED (1 << 16)
  224. #define HPSATMF_LOG_LUN_RESET (1 << 17)
  225. #define HPSATMF_LOG_NEX_RESET (1 << 18)
  226. #define HPSATMF_LOG_TASK_ABORT (1 << 19)
  227. #define HPSATMF_LOG_TSET_ABORT (1 << 20)
  228. #define HPSATMF_LOG_CLEAR_ACA (1 << 21)
  229. #define HPSATMF_LOG_CLEAR_TSET (1 << 22)
  230. #define HPSATMF_LOG_QRY_TASK (1 << 23)
  231. #define HPSATMF_LOG_QRY_TSET (1 << 24)
  232. #define HPSATMF_LOG_QRY_ASYNC (1 << 25)
  233. u32 events;
  234. #define CTLR_STATE_CHANGE_EVENT (1 << 0)
  235. #define CTLR_ENCLOSURE_HOT_PLUG_EVENT (1 << 1)
  236. #define CTLR_STATE_CHANGE_EVENT_PHYSICAL_DRV (1 << 4)
  237. #define CTLR_STATE_CHANGE_EVENT_LOGICAL_DRV (1 << 5)
  238. #define CTLR_STATE_CHANGE_EVENT_REDUNDANT_CNTRL (1 << 6)
  239. #define CTLR_STATE_CHANGE_EVENT_AIO_ENABLED_DISABLED (1 << 30)
  240. #define CTLR_STATE_CHANGE_EVENT_AIO_CONFIG_CHANGE (1 << 31)
  241. #define RESCAN_REQUIRED_EVENT_BITS \
  242. (CTLR_ENCLOSURE_HOT_PLUG_EVENT | \
  243. CTLR_STATE_CHANGE_EVENT_PHYSICAL_DRV | \
  244. CTLR_STATE_CHANGE_EVENT_LOGICAL_DRV | \
  245. CTLR_STATE_CHANGE_EVENT_AIO_ENABLED_DISABLED | \
  246. CTLR_STATE_CHANGE_EVENT_AIO_CONFIG_CHANGE)
  247. spinlock_t offline_device_lock;
  248. struct list_head offline_device_list;
  249. int acciopath_status;
  250. int raid_offload_debug;
  251. int needs_abort_tags_swizzled;
  252. struct workqueue_struct *resubmit_wq;
  253. struct workqueue_struct *rescan_ctlr_wq;
  254. atomic_t abort_cmds_available;
  255. wait_queue_head_t abort_cmd_wait_queue;
  256. wait_queue_head_t event_sync_wait_queue;
  257. struct mutex reset_mutex;
  258. };
  259. struct offline_device_entry {
  260. unsigned char scsi3addr[8];
  261. struct list_head offline_list;
  262. };
  263. #define HPSA_ABORT_MSG 0
  264. #define HPSA_DEVICE_RESET_MSG 1
  265. #define HPSA_RESET_TYPE_CONTROLLER 0x00
  266. #define HPSA_RESET_TYPE_BUS 0x01
  267. #define HPSA_RESET_TYPE_TARGET 0x03
  268. #define HPSA_RESET_TYPE_LUN 0x04
  269. #define HPSA_MSG_SEND_RETRY_LIMIT 10
  270. #define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS (10000)
  271. /* Maximum time in seconds driver will wait for command completions
  272. * when polling before giving up.
  273. */
  274. #define HPSA_MAX_POLL_TIME_SECS (20)
  275. /* During SCSI error recovery, HPSA_TUR_RETRY_LIMIT defines
  276. * how many times to retry TEST UNIT READY on a device
  277. * while waiting for it to become ready before giving up.
  278. * HPSA_MAX_WAIT_INTERVAL_SECS is the max wait interval
  279. * between sending TURs while waiting for a device
  280. * to become ready.
  281. */
  282. #define HPSA_TUR_RETRY_LIMIT (20)
  283. #define HPSA_MAX_WAIT_INTERVAL_SECS (30)
  284. /* HPSA_BOARD_READY_WAIT_SECS is how long to wait for a board
  285. * to become ready, in seconds, before giving up on it.
  286. * HPSA_BOARD_READY_POLL_INTERVAL_MSECS * is how long to wait
  287. * between polling the board to see if it is ready, in
  288. * milliseconds. HPSA_BOARD_READY_POLL_INTERVAL and
  289. * HPSA_BOARD_READY_ITERATIONS are derived from those.
  290. */
  291. #define HPSA_BOARD_READY_WAIT_SECS (120)
  292. #define HPSA_BOARD_NOT_READY_WAIT_SECS (100)
  293. #define HPSA_BOARD_READY_POLL_INTERVAL_MSECS (100)
  294. #define HPSA_BOARD_READY_POLL_INTERVAL \
  295. ((HPSA_BOARD_READY_POLL_INTERVAL_MSECS * HZ) / 1000)
  296. #define HPSA_BOARD_READY_ITERATIONS \
  297. ((HPSA_BOARD_READY_WAIT_SECS * 1000) / \
  298. HPSA_BOARD_READY_POLL_INTERVAL_MSECS)
  299. #define HPSA_BOARD_NOT_READY_ITERATIONS \
  300. ((HPSA_BOARD_NOT_READY_WAIT_SECS * 1000) / \
  301. HPSA_BOARD_READY_POLL_INTERVAL_MSECS)
  302. #define HPSA_POST_RESET_PAUSE_MSECS (3000)
  303. #define HPSA_POST_RESET_NOOP_RETRIES (12)
  304. /* Defining the diffent access_menthods */
  305. /*
  306. * Memory mapped FIFO interface (SMART 53xx cards)
  307. */
  308. #define SA5_DOORBELL 0x20
  309. #define SA5_REQUEST_PORT_OFFSET 0x40
  310. #define SA5_REQUEST_PORT64_LO_OFFSET 0xC0
  311. #define SA5_REQUEST_PORT64_HI_OFFSET 0xC4
  312. #define SA5_REPLY_INTR_MASK_OFFSET 0x34
  313. #define SA5_REPLY_PORT_OFFSET 0x44
  314. #define SA5_INTR_STATUS 0x30
  315. #define SA5_SCRATCHPAD_OFFSET 0xB0
  316. #define SA5_CTCFG_OFFSET 0xB4
  317. #define SA5_CTMEM_OFFSET 0xB8
  318. #define SA5_INTR_OFF 0x08
  319. #define SA5B_INTR_OFF 0x04
  320. #define SA5_INTR_PENDING 0x08
  321. #define SA5B_INTR_PENDING 0x04
  322. #define FIFO_EMPTY 0xffffffff
  323. #define HPSA_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
  324. #define HPSA_ERROR_BIT 0x02
  325. /* Performant mode flags */
  326. #define SA5_PERF_INTR_PENDING 0x04
  327. #define SA5_PERF_INTR_OFF 0x05
  328. #define SA5_OUTDB_STATUS_PERF_BIT 0x01
  329. #define SA5_OUTDB_CLEAR_PERF_BIT 0x01
  330. #define SA5_OUTDB_CLEAR 0xA0
  331. #define SA5_OUTDB_CLEAR_PERF_BIT 0x01
  332. #define SA5_OUTDB_STATUS 0x9C
  333. #define HPSA_INTR_ON 1
  334. #define HPSA_INTR_OFF 0
  335. /*
  336. * Inbound Post Queue offsets for IO Accelerator Mode 2
  337. */
  338. #define IOACCEL2_INBOUND_POSTQ_32 0x48
  339. #define IOACCEL2_INBOUND_POSTQ_64_LOW 0xd0
  340. #define IOACCEL2_INBOUND_POSTQ_64_HI 0xd4
  341. /*
  342. Send the command to the hardware
  343. */
  344. static void SA5_submit_command(struct ctlr_info *h,
  345. struct CommandList *c)
  346. {
  347. writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
  348. (void) readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
  349. }
  350. static void SA5_submit_command_no_read(struct ctlr_info *h,
  351. struct CommandList *c)
  352. {
  353. writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
  354. }
  355. static void SA5_submit_command_ioaccel2(struct ctlr_info *h,
  356. struct CommandList *c)
  357. {
  358. writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
  359. }
  360. /*
  361. * This card is the opposite of the other cards.
  362. * 0 turns interrupts on...
  363. * 0x08 turns them off...
  364. */
  365. static void SA5_intr_mask(struct ctlr_info *h, unsigned long val)
  366. {
  367. if (val) { /* Turn interrupts on */
  368. h->interrupts_enabled = 1;
  369. writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  370. (void) readl(h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  371. } else { /* Turn them off */
  372. h->interrupts_enabled = 0;
  373. writel(SA5_INTR_OFF,
  374. h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  375. (void) readl(h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  376. }
  377. }
  378. static void SA5_performant_intr_mask(struct ctlr_info *h, unsigned long val)
  379. {
  380. if (val) { /* turn on interrupts */
  381. h->interrupts_enabled = 1;
  382. writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  383. (void) readl(h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  384. } else {
  385. h->interrupts_enabled = 0;
  386. writel(SA5_PERF_INTR_OFF,
  387. h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  388. (void) readl(h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
  389. }
  390. }
  391. static unsigned long SA5_performant_completed(struct ctlr_info *h, u8 q)
  392. {
  393. struct reply_queue_buffer *rq = &h->reply_queue[q];
  394. unsigned long register_value = FIFO_EMPTY;
  395. /* msi auto clears the interrupt pending bit. */
  396. if (unlikely(!(h->msi_vector || h->msix_vector))) {
  397. /* flush the controller write of the reply queue by reading
  398. * outbound doorbell status register.
  399. */
  400. (void) readl(h->vaddr + SA5_OUTDB_STATUS);
  401. writel(SA5_OUTDB_CLEAR_PERF_BIT, h->vaddr + SA5_OUTDB_CLEAR);
  402. /* Do a read in order to flush the write to the controller
  403. * (as per spec.)
  404. */
  405. (void) readl(h->vaddr + SA5_OUTDB_STATUS);
  406. }
  407. if ((((u32) rq->head[rq->current_entry]) & 1) == rq->wraparound) {
  408. register_value = rq->head[rq->current_entry];
  409. rq->current_entry++;
  410. atomic_dec(&h->commands_outstanding);
  411. } else {
  412. register_value = FIFO_EMPTY;
  413. }
  414. /* Check for wraparound */
  415. if (rq->current_entry == h->max_commands) {
  416. rq->current_entry = 0;
  417. rq->wraparound ^= 1;
  418. }
  419. return register_value;
  420. }
  421. /*
  422. * returns value read from hardware.
  423. * returns FIFO_EMPTY if there is nothing to read
  424. */
  425. static unsigned long SA5_completed(struct ctlr_info *h,
  426. __attribute__((unused)) u8 q)
  427. {
  428. unsigned long register_value
  429. = readl(h->vaddr + SA5_REPLY_PORT_OFFSET);
  430. if (register_value != FIFO_EMPTY)
  431. atomic_dec(&h->commands_outstanding);
  432. #ifdef HPSA_DEBUG
  433. if (register_value != FIFO_EMPTY)
  434. dev_dbg(&h->pdev->dev, "Read %lx back from board\n",
  435. register_value);
  436. else
  437. dev_dbg(&h->pdev->dev, "FIFO Empty read\n");
  438. #endif
  439. return register_value;
  440. }
  441. /*
  442. * Returns true if an interrupt is pending..
  443. */
  444. static bool SA5_intr_pending(struct ctlr_info *h)
  445. {
  446. unsigned long register_value =
  447. readl(h->vaddr + SA5_INTR_STATUS);
  448. return register_value & SA5_INTR_PENDING;
  449. }
  450. static bool SA5_performant_intr_pending(struct ctlr_info *h)
  451. {
  452. unsigned long register_value = readl(h->vaddr + SA5_INTR_STATUS);
  453. if (!register_value)
  454. return false;
  455. /* Read outbound doorbell to flush */
  456. register_value = readl(h->vaddr + SA5_OUTDB_STATUS);
  457. return register_value & SA5_OUTDB_STATUS_PERF_BIT;
  458. }
  459. #define SA5_IOACCEL_MODE1_INTR_STATUS_CMP_BIT 0x100
  460. static bool SA5_ioaccel_mode1_intr_pending(struct ctlr_info *h)
  461. {
  462. unsigned long register_value = readl(h->vaddr + SA5_INTR_STATUS);
  463. return (register_value & SA5_IOACCEL_MODE1_INTR_STATUS_CMP_BIT) ?
  464. true : false;
  465. }
  466. #define IOACCEL_MODE1_REPLY_QUEUE_INDEX 0x1A0
  467. #define IOACCEL_MODE1_PRODUCER_INDEX 0x1B8
  468. #define IOACCEL_MODE1_CONSUMER_INDEX 0x1BC
  469. #define IOACCEL_MODE1_REPLY_UNUSED 0xFFFFFFFFFFFFFFFFULL
  470. static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
  471. {
  472. u64 register_value;
  473. struct reply_queue_buffer *rq = &h->reply_queue[q];
  474. BUG_ON(q >= h->nreply_queues);
  475. register_value = rq->head[rq->current_entry];
  476. if (register_value != IOACCEL_MODE1_REPLY_UNUSED) {
  477. rq->head[rq->current_entry] = IOACCEL_MODE1_REPLY_UNUSED;
  478. if (++rq->current_entry == rq->size)
  479. rq->current_entry = 0;
  480. /*
  481. * @todo
  482. *
  483. * Don't really need to write the new index after each command,
  484. * but with current driver design this is easiest.
  485. */
  486. wmb();
  487. writel((q << 24) | rq->current_entry, h->vaddr +
  488. IOACCEL_MODE1_CONSUMER_INDEX);
  489. atomic_dec(&h->commands_outstanding);
  490. }
  491. return (unsigned long) register_value;
  492. }
  493. static struct access_method SA5_access = {
  494. SA5_submit_command,
  495. SA5_intr_mask,
  496. SA5_intr_pending,
  497. SA5_completed,
  498. };
  499. static struct access_method SA5_ioaccel_mode1_access = {
  500. SA5_submit_command,
  501. SA5_performant_intr_mask,
  502. SA5_ioaccel_mode1_intr_pending,
  503. SA5_ioaccel_mode1_completed,
  504. };
  505. static struct access_method SA5_ioaccel_mode2_access = {
  506. SA5_submit_command_ioaccel2,
  507. SA5_performant_intr_mask,
  508. SA5_performant_intr_pending,
  509. SA5_performant_completed,
  510. };
  511. static struct access_method SA5_performant_access = {
  512. SA5_submit_command,
  513. SA5_performant_intr_mask,
  514. SA5_performant_intr_pending,
  515. SA5_performant_completed,
  516. };
  517. static struct access_method SA5_performant_access_no_read = {
  518. SA5_submit_command_no_read,
  519. SA5_performant_intr_mask,
  520. SA5_performant_intr_pending,
  521. SA5_performant_completed,
  522. };
  523. struct board_type {
  524. u32 board_id;
  525. char *product_name;
  526. struct access_method *access;
  527. };
  528. #endif /* HPSA_H */