scic_controller.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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 _SCIC_CONTROLLER_H_
  56. #define _SCIC_CONTROLLER_H_
  57. /**
  58. * This file contains all of the interface methods that can be called by an
  59. * SCIC user on a controller object.
  60. *
  61. *
  62. */
  63. #include "sci_status.h"
  64. #include "sci_controller.h"
  65. #include "scic_config_parameters.h"
  66. struct scic_sds_request;
  67. struct scic_sds_phy;
  68. struct scic_sds_port;
  69. struct scic_sds_remote_device;
  70. enum sci_controller_mode {
  71. SCI_MODE_SPEED, /* Optimized for performance */
  72. SCI_MODE_SIZE /* Optimized for memory use */
  73. };
  74. /**
  75. * scic_controller_construct() - This method will attempt to construct a
  76. * controller object utilizing the supplied parameter information.
  77. * @c: This parameter specifies the controller to be constructed.
  78. * @scu_base: mapped base address of the scu registers
  79. * @smu_base: mapped base address of the smu registers
  80. *
  81. * Indicate if the controller was successfully constructed or if it failed in
  82. * some way. SCI_SUCCESS This value is returned if the controller was
  83. * successfully constructed. SCI_WARNING_TIMER_CONFLICT This value is returned
  84. * if the interrupt coalescence timer may cause SAS compliance issues for SMP
  85. * Target mode response processing. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE
  86. * This value is returned if the controller does not support the supplied type.
  87. * SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION This value is returned if the
  88. * controller does not support the supplied initialization data version.
  89. */
  90. enum sci_status scic_controller_construct(struct scic_sds_controller *c,
  91. void __iomem *scu_base,
  92. void __iomem *smu_base);
  93. /**
  94. * scic_controller_enable_interrupts() - This method will enable all controller
  95. * interrupts.
  96. * @controller: This parameter specifies the controller for which to enable
  97. * interrupts.
  98. *
  99. */
  100. void scic_controller_enable_interrupts(
  101. struct scic_sds_controller *controller);
  102. /**
  103. * scic_controller_disable_interrupts() - This method will disable all
  104. * controller interrupts.
  105. * @controller: This parameter specifies the controller for which to disable
  106. * interrupts.
  107. *
  108. */
  109. void scic_controller_disable_interrupts(
  110. struct scic_sds_controller *controller);
  111. /**
  112. * scic_controller_initialize() - This method will initialize the controller
  113. * hardware managed by the supplied core controller object. This method
  114. * will bring the physical controller hardware out of reset and enable the
  115. * core to determine the capabilities of the hardware being managed. Thus,
  116. * the core controller can determine it's exact physical (DMA capable)
  117. * memory requirements.
  118. * @controller: This parameter specifies the controller to be initialized.
  119. *
  120. * The SCI Core user must have called scic_controller_construct() on the
  121. * supplied controller object previously. Indicate if the controller was
  122. * successfully initialized or if it failed in some way. SCI_SUCCESS This value
  123. * is returned if the controller hardware was successfully initialized.
  124. */
  125. enum sci_status scic_controller_initialize(
  126. struct scic_sds_controller *controller);
  127. /**
  128. * scic_controller_get_suggested_start_timeout() - This method returns the
  129. * suggested scic_controller_start() timeout amount. The user is free to
  130. * use any timeout value, but this method provides the suggested minimum
  131. * start timeout value. The returned value is based upon empirical
  132. * information determined as a result of interoperability testing.
  133. * @controller: the handle to the controller object for which to return the
  134. * suggested start timeout.
  135. *
  136. * This method returns the number of milliseconds for the suggested start
  137. * operation timeout.
  138. */
  139. u32 scic_controller_get_suggested_start_timeout(
  140. struct scic_sds_controller *controller);
  141. /**
  142. * scic_controller_start() - This method will start the supplied core
  143. * controller. This method will start the staggered spin up operation. The
  144. * SCI User completion callback is called when the following conditions are
  145. * met: -# the return status of this method is SCI_SUCCESS. -# after all of
  146. * the phys have successfully started or been given the opportunity to start.
  147. * @controller: the handle to the controller object to start.
  148. * @timeout: This parameter specifies the number of milliseconds in which the
  149. * start operation should complete.
  150. *
  151. * The SCI Core user must have filled in the physical memory descriptor
  152. * structure via the sci_controller_get_memory_descriptor_list() method. The
  153. * SCI Core user must have invoked the scic_controller_initialize() method
  154. * prior to invoking this method. The controller must be in the INITIALIZED or
  155. * STARTED state. Indicate if the controller start method succeeded or failed
  156. * in some way. SCI_SUCCESS if the start operation succeeded.
  157. * SCI_WARNING_ALREADY_IN_STATE if the controller is already in the STARTED
  158. * state. SCI_FAILURE_INVALID_STATE if the controller is not either in the
  159. * INITIALIZED or STARTED states. SCI_FAILURE_INVALID_MEMORY_DESCRIPTOR if
  160. * there are inconsistent or invalid values in the supplied
  161. * struct sci_physical_memory_descriptor array.
  162. */
  163. enum sci_status scic_controller_start(
  164. struct scic_sds_controller *controller,
  165. u32 timeout);
  166. /**
  167. * scic_controller_stop() - This method will stop an individual controller
  168. * object.This method will invoke the associated user callback upon
  169. * completion. The completion callback is called when the following
  170. * conditions are met: -# the method return status is SCI_SUCCESS. -# the
  171. * controller has been quiesced. This method will ensure that all IO
  172. * requests are quiesced, phys are stopped, and all additional operation by
  173. * the hardware is halted.
  174. * @controller: the handle to the controller object to stop.
  175. * @timeout: This parameter specifies the number of milliseconds in which the
  176. * stop operation should complete.
  177. *
  178. * The controller must be in the STARTED or STOPPED state. Indicate if the
  179. * controller stop method succeeded or failed in some way. SCI_SUCCESS if the
  180. * stop operation successfully began. SCI_WARNING_ALREADY_IN_STATE if the
  181. * controller is already in the STOPPED state. SCI_FAILURE_INVALID_STATE if the
  182. * controller is not either in the STARTED or STOPPED states.
  183. */
  184. enum sci_status scic_controller_stop(
  185. struct scic_sds_controller *controller,
  186. u32 timeout);
  187. /**
  188. * scic_controller_reset() - This method will reset the supplied core
  189. * controller regardless of the state of said controller. This operation is
  190. * considered destructive. In other words, all current operations are wiped
  191. * out. No IO completions for outstanding devices occur. Outstanding IO
  192. * requests are not aborted or completed at the actual remote device.
  193. * @controller: the handle to the controller object to reset.
  194. *
  195. * Indicate if the controller reset method succeeded or failed in some way.
  196. * SCI_SUCCESS if the reset operation successfully started. SCI_FATAL_ERROR if
  197. * the controller reset operation is unable to complete.
  198. */
  199. enum sci_status scic_controller_reset(
  200. struct scic_sds_controller *controller);
  201. /**
  202. * scic_controller_start_io() - This method is called by the SCI user to
  203. * send/start an IO request. If the method invocation is successful, then
  204. * the IO request has been queued to the hardware for processing.
  205. * @controller: the handle to the controller object for which to start an IO
  206. * request.
  207. * @remote_device: the handle to the remote device object for which to start an
  208. * IO request.
  209. * @io_request: the handle to the io request object to start.
  210. * @io_tag: This parameter specifies a previously allocated IO tag that the
  211. * user desires to be utilized for this request. This parameter is optional.
  212. * The user is allowed to supply SCI_CONTROLLER_INVALID_IO_TAG as the value
  213. * for this parameter.
  214. *
  215. * - IO tags are a protected resource. It is incumbent upon the SCI Core user
  216. * to ensure that each of the methods that may allocate or free available IO
  217. * tags are handled in a mutually exclusive manner. This method is one of said
  218. * methods requiring proper critical code section protection (e.g. semaphore,
  219. * spin-lock, etc.). - For SATA, the user is required to manage NCQ tags. As a
  220. * result, it is expected the user will have set the NCQ tag field in the host
  221. * to device register FIS prior to calling this method. There is also a
  222. * requirement for the user to call scic_stp_io_set_ncq_tag() prior to invoking
  223. * the scic_controller_start_io() method. scic_controller_allocate_tag() for
  224. * more information on allocating a tag. Indicate if the controller
  225. * successfully started the IO request. SCI_IO_SUCCESS if the IO request was
  226. * successfully started. Determine the failure situations and return values.
  227. */
  228. enum sci_io_status scic_controller_start_io(
  229. struct scic_sds_controller *controller,
  230. struct scic_sds_remote_device *remote_device,
  231. struct scic_sds_request *io_request,
  232. u16 io_tag);
  233. /**
  234. * scic_controller_start_task() - This method is called by the SCIC user to
  235. * send/start a framework task management request.
  236. * @controller: the handle to the controller object for which to start the task
  237. * management request.
  238. * @remote_device: the handle to the remote device object for which to start
  239. * the task management request.
  240. * @task_request: the handle to the task request object to start.
  241. * @io_tag: This parameter specifies a previously allocated IO tag that the
  242. * user desires to be utilized for this request. Note this not the io_tag
  243. * of the request being managed. It is to be utilized for the task request
  244. * itself. This parameter is optional. The user is allowed to supply
  245. * SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
  246. *
  247. * - IO tags are a protected resource. It is incumbent upon the SCI Core user
  248. * to ensure that each of the methods that may allocate or free available IO
  249. * tags are handled in a mutually exclusive manner. This method is one of said
  250. * methods requiring proper critical code section protection (e.g. semaphore,
  251. * spin-lock, etc.). - The user must synchronize this task with completion
  252. * queue processing. If they are not synchronized then it is possible for the
  253. * io requests that are being managed by the task request can complete before
  254. * starting the task request. scic_controller_allocate_tag() for more
  255. * information on allocating a tag. Indicate if the controller successfully
  256. * started the IO request. SCI_TASK_SUCCESS if the task request was
  257. * successfully started. SCI_TASK_FAILURE_REQUIRES_SCSI_ABORT This value is
  258. * returned if there is/are task(s) outstanding that require termination or
  259. * completion before this request can succeed.
  260. */
  261. enum sci_task_status scic_controller_start_task(
  262. struct scic_sds_controller *controller,
  263. struct scic_sds_remote_device *remote_device,
  264. struct scic_sds_request *task_request,
  265. u16 io_tag);
  266. /**
  267. * scic_controller_complete_task() - This method will perform core specific
  268. * completion operations for task management request. After this method is
  269. * invoked, the user should consider the task request as invalid until it is
  270. * properly reused (i.e. re-constructed).
  271. * @controller: The handle to the controller object for which to complete the
  272. * task management request.
  273. * @remote_device: The handle to the remote device object for which to complete
  274. * the task management request.
  275. * @task_request: the handle to the task management request object to complete.
  276. *
  277. * Indicate if the controller successfully completed the task management
  278. * request. SCI_SUCCESS if the completion process was successful.
  279. */
  280. enum sci_status scic_controller_complete_task(
  281. struct scic_sds_controller *controller,
  282. struct scic_sds_remote_device *remote_device,
  283. struct scic_sds_request *task_request);
  284. /**
  285. * scic_controller_terminate_request() - This method is called by the SCI Core
  286. * user to terminate an ongoing (i.e. started) core IO request. This does
  287. * not abort the IO request at the target, but rather removes the IO request
  288. * from the host controller.
  289. * @controller: the handle to the controller object for which to terminate a
  290. * request.
  291. * @remote_device: the handle to the remote device object for which to
  292. * terminate a request.
  293. * @request: the handle to the io or task management request object to
  294. * terminate.
  295. *
  296. * Indicate if the controller successfully began the terminate process for the
  297. * IO request. SCI_SUCCESS if the terminate process was successfully started
  298. * for the request. Determine the failure situations and return values.
  299. */
  300. enum sci_status scic_controller_terminate_request(
  301. struct scic_sds_controller *controller,
  302. struct scic_sds_remote_device *remote_device,
  303. struct scic_sds_request *request);
  304. /**
  305. * scic_controller_complete_io() - This method will perform core specific
  306. * completion operations for an IO request. After this method is invoked,
  307. * the user should consider the IO request as invalid until it is properly
  308. * reused (i.e. re-constructed).
  309. * @controller: The handle to the controller object for which to complete the
  310. * IO request.
  311. * @remote_device: The handle to the remote device object for which to complete
  312. * the IO request.
  313. * @io_request: the handle to the io request object to complete.
  314. *
  315. * - IO tags are a protected resource. It is incumbent upon the SCI Core user
  316. * to ensure that each of the methods that may allocate or free available IO
  317. * tags are handled in a mutually exclusive manner. This method is one of said
  318. * methods requiring proper critical code section protection (e.g. semaphore,
  319. * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
  320. * Core user, using the scic_controller_allocate_io_tag() method, then it is
  321. * the responsibility of the caller to invoke the scic_controller_free_io_tag()
  322. * method to free the tag (i.e. this method will not free the IO tag). Indicate
  323. * if the controller successfully completed the IO request. SCI_SUCCESS if the
  324. * completion process was successful.
  325. */
  326. enum sci_status scic_controller_complete_io(
  327. struct scic_sds_controller *controller,
  328. struct scic_sds_remote_device *remote_device,
  329. struct scic_sds_request *io_request);
  330. /**
  331. * scic_controller_get_port_handle() - This method simply provides the user
  332. * with a unique handle for a given SAS/SATA core port index.
  333. * @controller: This parameter represents the handle to the controller object
  334. * from which to retrieve a port (SAS or SATA) handle.
  335. * @port_index: This parameter specifies the port index in the controller for
  336. * which to retrieve the port handle. 0 <= port_index < maximum number of
  337. * phys.
  338. * @port_handle: This parameter specifies the retrieved port handle to be
  339. * provided to the caller.
  340. *
  341. * Indicate if the retrieval of the port handle was successful. SCI_SUCCESS
  342. * This value is returned if the retrieval was successful.
  343. * SCI_FAILURE_INVALID_PORT This value is returned if the supplied port id is
  344. * not in the supported range.
  345. */
  346. enum sci_status scic_controller_get_port_handle(
  347. struct scic_sds_controller *controller,
  348. u8 port_index,
  349. struct scic_sds_port **port_handle);
  350. /**
  351. * scic_controller_get_phy_handle() - This method simply provides the user with
  352. * a unique handle for a given SAS/SATA phy index/identifier.
  353. * @controller: This parameter represents the handle to the controller object
  354. * from which to retrieve a phy (SAS or SATA) handle.
  355. * @phy_index: This parameter specifies the phy index in the controller for
  356. * which to retrieve the phy handle. 0 <= phy_index < maximum number of phys.
  357. * @phy_handle: This parameter specifies the retrieved phy handle to be
  358. * provided to the caller.
  359. *
  360. * Indicate if the retrieval of the phy handle was successful. SCI_SUCCESS This
  361. * value is returned if the retrieval was successful. SCI_FAILURE_INVALID_PHY
  362. * This value is returned if the supplied phy id is not in the supported range.
  363. */
  364. enum sci_status scic_controller_get_phy_handle(
  365. struct scic_sds_controller *controller,
  366. u8 phy_index,
  367. struct scic_sds_phy **phy_handle);
  368. /**
  369. * scic_controller_allocate_io_tag() - This method will allocate a tag from the
  370. * pool of free IO tags. Direct allocation of IO tags by the SCI Core user
  371. * is optional. The scic_controller_start_io() method will allocate an IO
  372. * tag if this method is not utilized and the tag is not supplied to the IO
  373. * construct routine. Direct allocation of IO tags may provide additional
  374. * performance improvements in environments capable of supporting this usage
  375. * model. Additionally, direct allocation of IO tags also provides
  376. * additional flexibility to the SCI Core user. Specifically, the user may
  377. * retain IO tags across the lives of multiple IO requests.
  378. * @controller: the handle to the controller object for which to allocate the
  379. * tag.
  380. *
  381. * IO tags are a protected resource. It is incumbent upon the SCI Core user to
  382. * ensure that each of the methods that may allocate or free available IO tags
  383. * are handled in a mutually exclusive manner. This method is one of said
  384. * methods requiring proper critical code section protection (e.g. semaphore,
  385. * spin-lock, etc.). An unsigned integer representing an available IO tag.
  386. * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there are no
  387. * currently available tags to be allocated. All return other values indicate a
  388. * legitimate tag.
  389. */
  390. u16 scic_controller_allocate_io_tag(
  391. struct scic_sds_controller *controller);
  392. /**
  393. * scic_controller_free_io_tag() - This method will free an IO tag to the pool
  394. * of free IO tags. This method provides the SCI Core user more flexibility
  395. * with regards to IO tags. The user may desire to keep an IO tag after an
  396. * IO request has completed, because they plan on re-using the tag for a
  397. * subsequent IO request. This method is only legal if the tag was
  398. * allocated via scic_controller_allocate_io_tag().
  399. * @controller: This parameter specifies the handle to the controller object
  400. * for which to free/return the tag.
  401. * @io_tag: This parameter represents the tag to be freed to the pool of
  402. * available tags.
  403. *
  404. * - IO tags are a protected resource. It is incumbent upon the SCI Core user
  405. * to ensure that each of the methods that may allocate or free available IO
  406. * tags are handled in a mutually exclusive manner. This method is one of said
  407. * methods requiring proper critical code section protection (e.g. semaphore,
  408. * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
  409. * Core user, using the scic_controller_allocate_io_tag() method, then it is
  410. * the responsibility of the caller to invoke this method to free the tag. This
  411. * method returns an indication of whether the tag was successfully put back
  412. * (freed) to the pool of available tags. SCI_SUCCESS This return value
  413. * indicates the tag was successfully placed into the pool of available IO
  414. * tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
  415. * is not a valid IO tag value.
  416. */
  417. enum sci_status scic_controller_free_io_tag(
  418. struct scic_sds_controller *controller,
  419. u16 io_tag);
  420. /**
  421. * scic_controller_set_mode() - This method allows the user to configure the
  422. * SCI core into either a performance mode or a memory savings mode.
  423. * @controller: This parameter represents the handle to the controller object
  424. * for which to update the operating mode.
  425. * @mode: This parameter specifies the new mode for the controller.
  426. *
  427. * Indicate if the user successfully change the operating mode of the
  428. * controller. SCI_SUCCESS The user successfully updated the mode.
  429. */
  430. enum sci_status scic_controller_set_mode(
  431. struct scic_sds_controller *controller,
  432. enum sci_controller_mode mode);
  433. /**
  434. * scic_controller_set_interrupt_coalescence() - This method allows the user to
  435. * configure the interrupt coalescence.
  436. * @controller: This parameter represents the handle to the controller object
  437. * for which its interrupt coalesce register is overridden.
  438. * @coalesce_number: Used to control the number of entries in the Completion
  439. * Queue before an interrupt is generated. If the number of entries exceed
  440. * this number, an interrupt will be generated. The valid range of the input
  441. * is [0, 256]. A setting of 0 results in coalescing being disabled.
  442. * @coalesce_timeout: Timeout value in microseconds. The valid range of the
  443. * input is [0, 2700000] . A setting of 0 is allowed and results in no
  444. * interrupt coalescing timeout.
  445. *
  446. * Indicate if the user successfully set the interrupt coalesce parameters.
  447. * SCI_SUCCESS The user successfully updated the interrutp coalescence.
  448. * SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range.
  449. */
  450. enum sci_status scic_controller_set_interrupt_coalescence(
  451. struct scic_sds_controller *controller,
  452. u32 coalesce_number,
  453. u32 coalesce_timeout);
  454. struct device;
  455. struct scic_sds_controller *scic_controller_alloc(struct device *dev);
  456. #endif /* _SCIC_CONTROLLER_H_ */