isci.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * * Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. * * Redistributions in binary form must reproduce the above copyright
  36. * notice, this list of conditions and the following disclaimer in
  37. * the documentation and/or other materials provided with the
  38. * distribution.
  39. * * Neither the name of Intel Corporation nor the names of its
  40. * contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  46. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  47. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  49. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. #ifndef __ISCI_H__
  56. #define __ISCI_H__
  57. #include <linux/interrupt.h>
  58. #include <linux/types.h>
  59. #define DRV_NAME "isci"
  60. #define SCI_PCI_BAR_COUNT 2
  61. #define SCI_NUM_MSI_X_INT 2
  62. #define SCI_SMU_BAR 0
  63. #define SCI_SMU_BAR_SIZE (16*1024)
  64. #define SCI_SCU_BAR 1
  65. #define SCI_SCU_BAR_SIZE (4*1024*1024)
  66. #define SCI_IO_SPACE_BAR0 2
  67. #define SCI_IO_SPACE_BAR1 3
  68. #define ISCI_CAN_QUEUE_VAL 250 /* < SCI_MAX_IO_REQUESTS ? */
  69. #define SCIC_CONTROLLER_STOP_TIMEOUT 5000
  70. #define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF
  71. enum sci_controller_mode {
  72. SCI_MODE_SPEED,
  73. SCI_MODE_SIZE /* deprecated */
  74. };
  75. #define SCI_MAX_PHYS (4)
  76. #define SCI_MAX_PORTS SCI_MAX_PHYS
  77. #define SCI_MIN_SMP_PHYS (38)
  78. #define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
  79. #define SCI_MAX_REMOTE_DEVICES (256)
  80. #define SCI_MIN_REMOTE_DEVICES (16)
  81. #define SCI_MAX_IO_REQUESTS (256)
  82. #define SCI_MIN_IO_REQUESTS (1)
  83. #define SCI_MAX_MSIX_MESSAGES (2)
  84. #define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
  85. #define SCI_MIN_SCATTER_GATHER_ELEMENTS 1
  86. #define SCI_MAX_CONTROLLERS 2
  87. #define SCI_MAX_DOMAINS SCI_MAX_PORTS
  88. /* 2 indicates the maximum number of UFs that can occur for a given IO request.
  89. * The hardware handles reception of additional unsolicited frames while all
  90. * UFs are in use, by holding off the transmitting device. This number could
  91. * be theoretically reduced to 1, but 2 provides for more reliable operation.
  92. * During SATA PIO operation, it is possible under some conditions for there to
  93. * be 3 separate FISes received, back to back to back (PIO Setup, Data, D2H
  94. * Register). It is unlikely to have all 3 pending all at once without some of
  95. * them already being processed.
  96. */
  97. #define SCU_MIN_UNSOLICITED_FRAMES (1)
  98. #define SCU_MIN_CRITICAL_NOTIFICATIONS (24)
  99. #define SCU_MIN_EVENTS (4)
  100. #define SCU_MIN_COMPLETION_QUEUE_SCRATCH (2)
  101. #define SCU_MIN_COMPLETION_QUEUE_ENTRIES (SCU_MIN_CRITICAL_NOTIFICATIONS \
  102. + SCU_MIN_EVENTS \
  103. + SCU_MIN_UNSOLICITED_FRAMES \
  104. + SCI_MIN_IO_REQUESTS \
  105. + SCU_MIN_COMPLETION_QUEUE_SCRATCH)
  106. #define SCU_MAX_CRITICAL_NOTIFICATIONS (384)
  107. #define SCU_MAX_EVENTS (128)
  108. #define SCU_MAX_UNSOLICITED_FRAMES (128)
  109. #define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128)
  110. #define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \
  111. + SCU_MAX_EVENTS \
  112. + SCU_MAX_UNSOLICITED_FRAMES \
  113. + SCI_MAX_IO_REQUESTS \
  114. + SCU_MAX_COMPLETION_QUEUE_SCRATCH)
  115. #if !defined(ENABLE_MINIMUM_MEMORY_MODE)
  116. #define SCU_UNSOLICITED_FRAME_COUNT SCU_MAX_UNSOLICITED_FRAMES
  117. #define SCU_CRITICAL_NOTIFICATION_COUNT SCU_MAX_CRITICAL_NOTIFICATIONS
  118. #define SCU_EVENT_COUNT SCU_MAX_EVENTS
  119. #define SCU_COMPLETION_QUEUE_SCRATCH SCU_MAX_COMPLETION_QUEUE_SCRATCH
  120. #define SCU_IO_REQUEST_COUNT SCI_MAX_IO_REQUESTS
  121. #define SCU_IO_REQUEST_SGE_COUNT SCI_MAX_SCATTER_GATHER_ELEMENTS
  122. #define SCU_COMPLETION_QUEUE_COUNT SCU_MAX_COMPLETION_QUEUE_ENTRIES
  123. #else
  124. #define SCU_UNSOLICITED_FRAME_COUNT SCU_MIN_UNSOLICITED_FRAMES
  125. #define SCU_CRITICAL_NOTIFICATION_COUNT SCU_MIN_CRITICAL_NOTIFICATIONS
  126. #define SCU_EVENT_COUNT SCU_MIN_EVENTS
  127. #define SCU_COMPLETION_QUEUE_SCRATCH SCU_MIN_COMPLETION_QUEUE_SCRATCH
  128. #define SCU_IO_REQUEST_COUNT SCI_MIN_IO_REQUESTS
  129. #define SCU_IO_REQUEST_SGE_COUNT SCI_MIN_SCATTER_GATHER_ELEMENTS
  130. #define SCU_COMPLETION_QUEUE_COUNT SCU_MIN_COMPLETION_QUEUE_ENTRIES
  131. #endif /* !defined(ENABLE_MINIMUM_MEMORY_OPERATION) */
  132. /**
  133. *
  134. *
  135. * The SCU_COMPLETION_QUEUE_COUNT constant indicates the size of the completion
  136. * queue into which the hardware DMAs 32-bit quantas (completion entries).
  137. */
  138. /**
  139. *
  140. *
  141. * This queue must be programmed to a power of 2 size (e.g. 32, 64, 1024, etc.).
  142. */
  143. #if (SCU_COMPLETION_QUEUE_COUNT != 16) && \
  144. (SCU_COMPLETION_QUEUE_COUNT != 32) && \
  145. (SCU_COMPLETION_QUEUE_COUNT != 64) && \
  146. (SCU_COMPLETION_QUEUE_COUNT != 128) && \
  147. (SCU_COMPLETION_QUEUE_COUNT != 256) && \
  148. (SCU_COMPLETION_QUEUE_COUNT != 512) && \
  149. (SCU_COMPLETION_QUEUE_COUNT != 1024)
  150. #error "SCU_COMPLETION_QUEUE_COUNT must be set to a power of 2."
  151. #endif
  152. #if SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES
  153. #error "Invalid configuration of unsolicited frame constants"
  154. #endif /* SCU_MIN_UNSOLICITED_FRAMES > SCU_MAX_UNSOLICITED_FRAMES */
  155. #define SCU_MIN_UF_TABLE_ENTRIES (8)
  156. #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
  157. #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024)
  158. #define SCU_INVALID_FRAME_INDEX (0xFFFF)
  159. #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
  160. #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF)
  161. /*
  162. * Determine the size of the unsolicited frame array including
  163. * unused buffers. */
  164. #if SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES
  165. #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MIN_UF_TABLE_ENTRIES
  166. #else
  167. #define SCU_UNSOLICITED_FRAME_CONTROL_ARRAY_SIZE SCU_MAX_UNSOLICITED_FRAMES
  168. #endif /* SCU_UNSOLICITED_FRAME_COUNT <= SCU_MIN_UF_TABLE_ENTRIES */
  169. /**
  170. * enum sci_status - This is the general return status enumeration for non-IO,
  171. * non-task management related SCI interface methods.
  172. *
  173. *
  174. */
  175. enum sci_status {
  176. /**
  177. * This member indicates successful completion.
  178. */
  179. SCI_SUCCESS = 0,
  180. /**
  181. * This value indicates that the calling method completed successfully,
  182. * but that the IO may have completed before having it's start method
  183. * invoked. This occurs during SAT translation for requests that do
  184. * not require an IO to the target or for any other requests that may
  185. * be completed without having to submit IO.
  186. */
  187. SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  188. /**
  189. * This Value indicates that the SCU hardware returned an early response
  190. * because the io request specified more data than is returned by the
  191. * target device (mode pages, inquiry data, etc.). The completion routine
  192. * will handle this case to get the actual number of bytes transferred.
  193. */
  194. SCI_SUCCESS_IO_DONE_EARLY,
  195. /**
  196. * This member indicates that the object for which a state change is
  197. * being requested is already in said state.
  198. */
  199. SCI_WARNING_ALREADY_IN_STATE,
  200. /**
  201. * This member indicates interrupt coalescence timer may cause SAS
  202. * specification compliance issues (i.e. SMP target mode response
  203. * frames must be returned within 1.9 milliseconds).
  204. */
  205. SCI_WARNING_TIMER_CONFLICT,
  206. /**
  207. * This field indicates a sequence of action is not completed yet. Mostly,
  208. * this status is used when multiple ATA commands are needed in a SATI translation.
  209. */
  210. SCI_WARNING_SEQUENCE_INCOMPLETE,
  211. /**
  212. * This member indicates that there was a general failure.
  213. */
  214. SCI_FAILURE,
  215. /**
  216. * This member indicates that the SCI implementation is unable to complete
  217. * an operation due to a critical flaw the prevents any further operation
  218. * (i.e. an invalid pointer).
  219. */
  220. SCI_FATAL_ERROR,
  221. /**
  222. * This member indicates the calling function failed, because the state
  223. * of the controller is in a state that prevents successful completion.
  224. */
  225. SCI_FAILURE_INVALID_STATE,
  226. /**
  227. * This member indicates the calling function failed, because there is
  228. * insufficient resources/memory to complete the request.
  229. */
  230. SCI_FAILURE_INSUFFICIENT_RESOURCES,
  231. /**
  232. * This member indicates the calling function failed, because the
  233. * controller object required for the operation can't be located.
  234. */
  235. SCI_FAILURE_CONTROLLER_NOT_FOUND,
  236. /**
  237. * This member indicates the calling function failed, because the
  238. * discovered controller type is not supported by the library.
  239. */
  240. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE,
  241. /**
  242. * This member indicates the calling function failed, because the
  243. * requested initialization data version isn't supported.
  244. */
  245. SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION,
  246. /**
  247. * This member indicates the calling function failed, because the
  248. * requested configuration of SAS Phys into SAS Ports is not supported.
  249. */
  250. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION,
  251. /**
  252. * This member indicates the calling function failed, because the
  253. * requested protocol is not supported by the remote device, port,
  254. * or controller.
  255. */
  256. SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  257. /**
  258. * This member indicates the calling function failed, because the
  259. * requested information type is not supported by the SCI implementation.
  260. */
  261. SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE,
  262. /**
  263. * This member indicates the calling function failed, because the
  264. * device already exists.
  265. */
  266. SCI_FAILURE_DEVICE_EXISTS,
  267. /**
  268. * This member indicates the calling function failed, because adding
  269. * a phy to the object is not possible.
  270. */
  271. SCI_FAILURE_ADDING_PHY_UNSUPPORTED,
  272. /**
  273. * This member indicates the calling function failed, because the
  274. * requested information type is not supported by the SCI implementation.
  275. */
  276. SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD,
  277. /**
  278. * This member indicates the calling function failed, because the SCI
  279. * implementation does not support the supplied time limit.
  280. */
  281. SCI_FAILURE_UNSUPPORTED_TIME_LIMIT,
  282. /**
  283. * This member indicates the calling method failed, because the SCI
  284. * implementation does not contain the specified Phy.
  285. */
  286. SCI_FAILURE_INVALID_PHY,
  287. /**
  288. * This member indicates the calling method failed, because the SCI
  289. * implementation does not contain the specified Port.
  290. */
  291. SCI_FAILURE_INVALID_PORT,
  292. /**
  293. * This member indicates the calling method was partly successful
  294. * The port was reset but not all phys in port are operational
  295. */
  296. SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS,
  297. /**
  298. * This member indicates that calling method failed
  299. * The port reset did not complete because none of the phys are operational
  300. */
  301. SCI_FAILURE_RESET_PORT_FAILURE,
  302. /**
  303. * This member indicates the calling method failed, because the SCI
  304. * implementation does not contain the specified remote device.
  305. */
  306. SCI_FAILURE_INVALID_REMOTE_DEVICE,
  307. /**
  308. * This member indicates the calling method failed, because the remote
  309. * device is in a bad state and requires a reset.
  310. */
  311. SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  312. /**
  313. * This member indicates the calling method failed, because the SCI
  314. * implementation does not contain or support the specified IO tag.
  315. */
  316. SCI_FAILURE_INVALID_IO_TAG,
  317. /**
  318. * This member indicates that the operation failed and the user should
  319. * check the response data associated with the IO.
  320. */
  321. SCI_FAILURE_IO_RESPONSE_VALID,
  322. /**
  323. * This member indicates that the operation failed, the failure is
  324. * controller implementation specific, and the response data associated
  325. * with the request is not valid. You can query for the controller
  326. * specific error information via scic_controller_get_request_status()
  327. */
  328. SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  329. /**
  330. * This member indicated that the operation failed because the
  331. * user requested this IO to be terminated.
  332. */
  333. SCI_FAILURE_IO_TERMINATED,
  334. /**
  335. * This member indicates that the operation failed and the associated
  336. * request requires a SCSI abort task to be sent to the target.
  337. */
  338. SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  339. /**
  340. * This member indicates that the operation failed because the supplied
  341. * device could not be located.
  342. */
  343. SCI_FAILURE_DEVICE_NOT_FOUND,
  344. /**
  345. * This member indicates that the operation failed because the
  346. * objects association is required and is not correctly set.
  347. */
  348. SCI_FAILURE_INVALID_ASSOCIATION,
  349. /**
  350. * This member indicates that the operation failed, because a timeout
  351. * occurred.
  352. */
  353. SCI_FAILURE_TIMEOUT,
  354. /**
  355. * This member indicates that the operation failed, because the user
  356. * specified a value that is either invalid or not supported.
  357. */
  358. SCI_FAILURE_INVALID_PARAMETER_VALUE,
  359. /**
  360. * This value indicates that the operation failed, because the number
  361. * of messages (MSI-X) is not supported.
  362. */
  363. SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT,
  364. /**
  365. * This value indicates that the method failed due to a lack of
  366. * available NCQ tags.
  367. */
  368. SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  369. /**
  370. * This value indicates that a protocol violation has occurred on the
  371. * link.
  372. */
  373. SCI_FAILURE_PROTOCOL_VIOLATION,
  374. /**
  375. * This value indicates a failure condition that retry may help to clear.
  376. */
  377. SCI_FAILURE_RETRY_REQUIRED,
  378. /**
  379. * This field indicates the retry limit was reached when a retry is attempted
  380. */
  381. SCI_FAILURE_RETRY_LIMIT_REACHED,
  382. /**
  383. * This member indicates the calling method was partly successful.
  384. * Mostly, this status is used when a LUN_RESET issued to an expander attached
  385. * STP device in READY NCQ substate needs to have RNC suspended/resumed
  386. * before posting TC.
  387. */
  388. SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS,
  389. /**
  390. * This field indicates an illegal phy connection based on the routing attribute
  391. * of both expander phy attached to each other.
  392. */
  393. SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION,
  394. /**
  395. * This field indicates a CONFIG ROUTE INFO command has a response with function result
  396. * INDEX DOES NOT EXIST, usually means exceeding max route index.
  397. */
  398. SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX,
  399. /**
  400. * This value indicates that an unsupported PCI device ID has been
  401. * specified. This indicates that attempts to invoke
  402. * scic_library_allocate_controller() will fail.
  403. */
  404. SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID
  405. };
  406. /**
  407. * enum sci_io_status - This enumeration depicts all of the possible IO
  408. * completion status values. Each value in this enumeration maps directly
  409. * to a value in the enum sci_status enumeration. Please refer to that
  410. * enumeration for detailed comments concerning what the status represents.
  411. *
  412. * Add the API to retrieve the SCU status from the core. Check to see that the
  413. * following status are properly handled: - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL
  414. * - SCI_IO_FAILURE_INVALID_IO_TAG
  415. */
  416. enum sci_io_status {
  417. SCI_IO_SUCCESS = SCI_SUCCESS,
  418. SCI_IO_FAILURE = SCI_FAILURE,
  419. SCI_IO_SUCCESS_COMPLETE_BEFORE_START = SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  420. SCI_IO_SUCCESS_IO_DONE_EARLY = SCI_SUCCESS_IO_DONE_EARLY,
  421. SCI_IO_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  422. SCI_IO_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  423. SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  424. SCI_IO_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  425. SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  426. SCI_IO_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  427. SCI_IO_FAILURE_REQUIRES_SCSI_ABORT = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  428. SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  429. SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  430. SCI_IO_FAILURE_PROTOCOL_VIOLATION = SCI_FAILURE_PROTOCOL_VIOLATION,
  431. SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  432. SCI_IO_FAILURE_RETRY_REQUIRED = SCI_FAILURE_RETRY_REQUIRED,
  433. SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED,
  434. SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE
  435. };
  436. /**
  437. * enum sci_task_status - This enumeration depicts all of the possible task
  438. * completion status values. Each value in this enumeration maps directly
  439. * to a value in the enum sci_status enumeration. Please refer to that
  440. * enumeration for detailed comments concerning what the status represents.
  441. *
  442. * Check to see that the following status are properly handled:
  443. */
  444. enum sci_task_status {
  445. SCI_TASK_SUCCESS = SCI_SUCCESS,
  446. SCI_TASK_FAILURE = SCI_FAILURE,
  447. SCI_TASK_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  448. SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  449. SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  450. SCI_TASK_FAILURE_INVALID_TAG = SCI_FAILURE_INVALID_IO_TAG,
  451. SCI_TASK_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  452. SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  453. SCI_TASK_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  454. SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  455. SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  456. SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS
  457. };
  458. /**
  459. * sci_swab32_cpy - convert between scsi and scu-hardware byte format
  460. * @dest: receive the 4-byte endian swapped version of src
  461. * @src: word aligned source buffer
  462. *
  463. * scu hardware handles SSP/SMP control, response, and unidentified
  464. * frames in "big endian dword" order. Regardless of host endian this
  465. * is always a swab32()-per-dword conversion of the standard definition,
  466. * i.e. single byte fields swapped and multi-byte fields in little-
  467. * endian
  468. */
  469. static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt)
  470. {
  471. u32 *dest = _dest, *src = _src;
  472. while (--word_cnt >= 0)
  473. dest[word_cnt] = swab32(src[word_cnt]);
  474. }
  475. extern unsigned char no_outbound_task_to;
  476. extern u16 ssp_max_occ_to;
  477. extern u16 stp_max_occ_to;
  478. extern u16 ssp_inactive_to;
  479. extern u16 stp_inactive_to;
  480. extern unsigned char phy_gen;
  481. extern unsigned char max_concurr_spinup;
  482. irqreturn_t isci_msix_isr(int vec, void *data);
  483. irqreturn_t isci_intx_isr(int vec, void *data);
  484. irqreturn_t isci_error_isr(int vec, void *data);
  485. /*
  486. * Each timer is associated with a cancellation flag that is set when
  487. * del_timer() is called and checked in the timer callback function. This
  488. * is needed since del_timer_sync() cannot be called with scic_lock held.
  489. * For deinit however, del_timer_sync() is used without holding the lock.
  490. */
  491. struct sci_timer {
  492. struct timer_list timer;
  493. bool cancel;
  494. };
  495. static inline
  496. void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long))
  497. {
  498. tmr->timer.function = fn;
  499. tmr->timer.data = (unsigned long) tmr;
  500. tmr->cancel = 0;
  501. init_timer(&tmr->timer);
  502. }
  503. static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec)
  504. {
  505. tmr->cancel = 0;
  506. mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec));
  507. }
  508. static inline void sci_del_timer(struct sci_timer *tmr)
  509. {
  510. tmr->cancel = 1;
  511. del_timer(&tmr->timer);
  512. }
  513. struct sci_base_state_machine {
  514. const struct sci_base_state *state_table;
  515. u32 initial_state_id;
  516. u32 current_state_id;
  517. u32 previous_state_id;
  518. };
  519. typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);
  520. struct sci_base_state {
  521. sci_state_transition_t enter_state; /* Called on state entry */
  522. sci_state_transition_t exit_state; /* Called on state exit */
  523. };
  524. extern void sci_init_sm(struct sci_base_state_machine *sm,
  525. const struct sci_base_state *state_table,
  526. u32 initial_state);
  527. extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
  528. #endif /* __ISCI_H__ */