scic_controller.h 27 KB

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