PageRenderTime 106ms CodeModel.GetById 50ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/scsi/hpsa.h

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