deprecated.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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. /**
  56. * This file contains isci module object implementation.
  57. *
  58. *
  59. */
  60. #include "isci.h"
  61. #include "request.h"
  62. #include "sata.h"
  63. #include "task.h"
  64. /**
  65. * scic_cb_stall_execution() - This method is called when the core requires the
  66. * OS driver to stall execution. This method is utilized during
  67. * initialization or non-performance paths only.
  68. * @microseconds: This parameter specifies the number of microseconds for which
  69. * to stall. The operating system driver is allowed to round this value up
  70. * where necessary.
  71. *
  72. * none.
  73. */
  74. void scic_cb_stall_execution(
  75. u32 microseconds)
  76. {
  77. udelay(microseconds);
  78. }
  79. /**
  80. * scic_cb_io_request_get_physical_address() - This callback method asks the
  81. * user to provide the physical address for the supplied virtual address
  82. * when building an io request object.
  83. * @controller: This parameter is the core controller object handle.
  84. * @io_request: This parameter is the io request object handle for which the
  85. * physical address is being requested.
  86. *
  87. *
  88. */
  89. void scic_cb_io_request_get_physical_address(
  90. struct scic_sds_controller *controller,
  91. struct scic_sds_request *io_request,
  92. void *virtual_address,
  93. dma_addr_t *physical_address)
  94. {
  95. struct isci_request *request =
  96. (struct isci_request *)sci_object_get_association(io_request);
  97. char *requested_address = (char *)virtual_address;
  98. char *base_address = (char *)request;
  99. BUG_ON(requested_address < base_address);
  100. BUG_ON((requested_address - base_address) >=
  101. request->request_alloc_size);
  102. *physical_address = request->request_daddr +
  103. (requested_address - base_address);
  104. }
  105. /**
  106. * scic_cb_io_request_get_transfer_length() - This callback method asks the
  107. * user to provide the number of bytes to be transfered as part of this
  108. * request.
  109. * @scic_user_io_request: This parameter points to the user's IO request
  110. * object. It is a cookie that allows the user to provide the necessary
  111. * information for this callback.
  112. *
  113. * This method returns the number of payload data bytes to be transfered for
  114. * this IO request.
  115. */
  116. u32 scic_cb_io_request_get_transfer_length(
  117. void *scic_user_io_request)
  118. {
  119. return isci_request_io_request_get_transfer_length(
  120. scic_user_io_request
  121. );
  122. }
  123. /**
  124. * scic_cb_io_request_get_data_direction() - This callback method asks the user
  125. * to provide the data direction for this request.
  126. * @scic_user_io_request: This parameter points to the user's IO request
  127. * object. It is a cookie that allows the user to provide the necessary
  128. * information for this callback.
  129. */
  130. enum dma_data_direction scic_cb_io_request_get_data_direction(void *req)
  131. {
  132. return isci_request_io_request_get_data_direction(req);
  133. }
  134. /**
  135. * scic_cb_io_request_get_next_sge() - This callback method asks the user to
  136. * provide the address to where the next Scatter-Gather Element is located.
  137. * @scic_user_io_request: This parameter points to the user's IO request
  138. * object. It is a cookie that allows the user to provide the necessary
  139. * information for this callback.
  140. * @current_sge_address: This parameter specifies the address for the current
  141. * SGE (i.e. the one that has just processed).
  142. *
  143. * An address specifying the location for the next scatter gather element to be
  144. * processed.
  145. */
  146. void scic_cb_io_request_get_next_sge(
  147. void *scic_user_io_request,
  148. void *current_sge_address,
  149. void **next_sge)
  150. {
  151. *next_sge = isci_request_io_request_get_next_sge(
  152. scic_user_io_request,
  153. current_sge_address
  154. );
  155. }
  156. /**
  157. * scic_cb_sge_get_address_field() - This callback method asks the user to
  158. * provide the contents of the "address" field in the Scatter-Gather Element.
  159. * @scic_user_io_request: This parameter points to the user's IO request
  160. * object. It is a cookie that allows the user to provide the necessary
  161. * information for this callback.
  162. * @sge_address: This parameter specifies the address for the SGE from which to
  163. * retrieve the address field.
  164. *
  165. * A physical address specifying the contents of the SGE's address field.
  166. */
  167. dma_addr_t scic_cb_sge_get_address_field(
  168. void *scic_user_io_request,
  169. void *sge_address)
  170. {
  171. return isci_request_sge_get_address_field(
  172. scic_user_io_request,
  173. sge_address
  174. );
  175. }
  176. /**
  177. * scic_cb_sge_get_length_field() - This callback method asks the user to
  178. * provide the contents of the "length" field in the Scatter-Gather Element.
  179. * @scic_user_io_request: This parameter points to the user's IO request
  180. * object. It is a cookie that allows the user to provide the necessary
  181. * information for this callback.
  182. * @sge_address: This parameter specifies the address for the SGE from which to
  183. * retrieve the address field.
  184. *
  185. * This method returns the length field specified inside the SGE referenced by
  186. * the sge_address parameter.
  187. */
  188. u32 scic_cb_sge_get_length_field(
  189. void *scic_user_io_request,
  190. void *sge_address)
  191. {
  192. return isci_request_sge_get_length_field(
  193. scic_user_io_request,
  194. sge_address
  195. );
  196. }
  197. /**
  198. * scic_cb_ssp_io_request_get_cdb_address() - This callback method asks the
  199. * user to provide the address for the command descriptor block (CDB)
  200. * associated with this IO request.
  201. * @scic_user_io_request: This parameter points to the user's IO request
  202. * object. It is a cookie that allows the user to provide the necessary
  203. * information for this callback.
  204. *
  205. * This method returns the virtual address of the CDB.
  206. */
  207. void *scic_cb_ssp_io_request_get_cdb_address(
  208. void *scic_user_io_request)
  209. {
  210. return isci_request_ssp_io_request_get_cdb_address(
  211. scic_user_io_request
  212. );
  213. }
  214. /**
  215. * scic_cb_ssp_io_request_get_cdb_length() - This callback method asks the user
  216. * to provide the length of the command descriptor block (CDB) associated
  217. * with this IO request.
  218. * @scic_user_io_request: This parameter points to the user's IO request
  219. * object. It is a cookie that allows the user to provide the necessary
  220. * information for this callback.
  221. *
  222. * This method returns the length of the CDB.
  223. */
  224. u32 scic_cb_ssp_io_request_get_cdb_length(
  225. void *scic_user_io_request)
  226. {
  227. return isci_request_ssp_io_request_get_cdb_length(
  228. scic_user_io_request
  229. );
  230. }
  231. /**
  232. * scic_cb_ssp_io_request_get_lun() - This callback method asks the user to
  233. * provide the Logical Unit (LUN) associated with this IO request.
  234. * @scic_user_io_request: This parameter points to the user's IO request
  235. * object. It is a cookie that allows the user to provide the necessary
  236. * information for this callback.
  237. *
  238. * This method returns the LUN associated with this request. This should be u64?
  239. */
  240. u32 scic_cb_ssp_io_request_get_lun(
  241. void *scic_user_io_request)
  242. {
  243. return isci_request_ssp_io_request_get_lun(scic_user_io_request);
  244. }
  245. /**
  246. * scic_cb_ssp_io_request_get_task_attribute() - This callback method asks the
  247. * user to provide the task attribute associated with this IO request.
  248. * @scic_user_io_request: This parameter points to the user's IO request
  249. * object. It is a cookie that allows the user to provide the necessary
  250. * information for this callback.
  251. *
  252. * This method returns the task attribute associated with this IO request.
  253. */
  254. u32 scic_cb_ssp_io_request_get_task_attribute(
  255. void *scic_user_io_request)
  256. {
  257. return isci_request_ssp_io_request_get_task_attribute(
  258. scic_user_io_request
  259. );
  260. }
  261. /**
  262. * scic_cb_ssp_io_request_get_command_priority() - This callback method asks
  263. * the user to provide the command priority associated with this IO request.
  264. * @scic_user_io_request: This parameter points to the user's IO request
  265. * object. It is a cookie that allows the user to provide the necessary
  266. * information for this callback.
  267. *
  268. * This method returns the command priority associated with this IO request.
  269. */
  270. u32 scic_cb_ssp_io_request_get_command_priority(
  271. void *scic_user_io_request)
  272. {
  273. return isci_request_ssp_io_request_get_command_priority(
  274. scic_user_io_request
  275. );
  276. }
  277. /**
  278. * scic_cb_ssp_task_request_get_lun() - This method returns the Logical Unit to
  279. * be utilized for this task management request.
  280. * @scic_user_task_request: This parameter points to the user's task request
  281. * object. It is a cookie that allows the user to provide the necessary
  282. * information for this callback.
  283. *
  284. * This method returns the LUN associated with this request. This should be u64?
  285. */
  286. u32 scic_cb_ssp_task_request_get_lun(
  287. void *scic_user_task_request)
  288. {
  289. return isci_task_ssp_request_get_lun(
  290. (struct isci_request *)scic_user_task_request
  291. );
  292. }
  293. /**
  294. * scic_cb_ssp_task_request_get_function() - This method returns the task
  295. * management function to be utilized for this task request.
  296. * @scic_user_task_request: This parameter points to the user's task request
  297. * object. It is a cookie that allows the user to provide the necessary
  298. * information for this callback.
  299. *
  300. * This method returns an unsigned byte representing the task management
  301. * function to be performed.
  302. */
  303. u8 scic_cb_ssp_task_request_get_function(
  304. void *scic_user_task_request)
  305. {
  306. return isci_task_ssp_request_get_function(
  307. (struct isci_request *)scic_user_task_request
  308. );
  309. }
  310. /**
  311. * scic_cb_ssp_task_request_get_io_tag_to_manage() - This method returns the
  312. * task management IO tag to be managed. Depending upon the task management
  313. * function the value returned from this method may be ignored.
  314. * @scic_user_task_request: This parameter points to the user's task request
  315. * object. It is a cookie that allows the user to provide the necessary
  316. * information for this callback.
  317. *
  318. * This method returns an unsigned 16-bit word depicting the IO tag to be
  319. * managed.
  320. */
  321. u16 scic_cb_ssp_task_request_get_io_tag_to_manage(
  322. void *scic_user_task_request)
  323. {
  324. return isci_task_ssp_request_get_io_tag_to_manage(
  325. (struct isci_request *)scic_user_task_request
  326. );
  327. }
  328. /**
  329. * scic_cb_ssp_task_request_get_response_data_address() - This callback method
  330. * asks the user to provide the virtual address of the response data buffer
  331. * for the supplied IO request.
  332. * @scic_user_task_request: This parameter points to the user's task request
  333. * object. It is a cookie that allows the user to provide the necessary
  334. * information for this callback.
  335. *
  336. * This method returns the virtual address for the response data buffer
  337. * associated with this IO request.
  338. */
  339. void *scic_cb_ssp_task_request_get_response_data_address(
  340. void *scic_user_task_request)
  341. {
  342. return isci_task_ssp_request_get_response_data_address(
  343. (struct isci_request *)scic_user_task_request
  344. );
  345. }
  346. /**
  347. * scic_cb_ssp_task_request_get_response_data_length() - This callback method
  348. * asks the user to provide the length of the response data buffer for the
  349. * supplied IO request.
  350. * @scic_user_task_request: This parameter points to the user's task request
  351. * object. It is a cookie that allows the user to provide the necessary
  352. * information for this callback.
  353. *
  354. * This method returns the length of the response buffer data associated with
  355. * this IO request.
  356. */
  357. u32 scic_cb_ssp_task_request_get_response_data_length(
  358. void *scic_user_task_request)
  359. {
  360. return isci_task_ssp_request_get_response_data_length(
  361. (struct isci_request *)scic_user_task_request
  362. );
  363. }
  364. #if !defined(DISABLE_ATAPI)
  365. /**
  366. * scic_cb_stp_packet_io_request_get_cdb_address() - This user callback asks
  367. * the user to provide stp packet io's the CDB address.
  368. * @scic_user_io_request:
  369. *
  370. * The packet IO's cdb adress.
  371. */
  372. void *scic_cb_stp_packet_io_request_get_cdb_address(
  373. void *scic_user_io_request)
  374. {
  375. return isci_request_stp_packet_io_request_get_cdb_address(
  376. scic_user_io_request
  377. );
  378. }
  379. /**
  380. * scic_cb_stp_packet_io_request_get_cdb_length() - This user callback asks the
  381. * user to provide stp packet io's the CDB length.
  382. * @scic_user_io_request:
  383. *
  384. * The packet IO's cdb length.
  385. */
  386. u32 scic_cb_stp_packet_io_request_get_cdb_length(
  387. void *scic_user_io_request)
  388. {
  389. return isci_request_stp_packet_io_request_get_cdb_length(
  390. scic_user_io_request
  391. );
  392. }
  393. #endif /* #if !defined(DISABLE_ATAPI) */
  394. /**
  395. * scic_cb_io_request_do_copy_rx_frames() - This callback method asks the user
  396. * if the received RX frame data is to be copied to the SGL or should be
  397. * stored by the SCI core to be retrieved later with the
  398. * scic_io_request_get_rx_frame().
  399. * @scic_user_io_request: This parameter points to the user's IO request
  400. * object. It is a cookie that allows the user to provide the necessary
  401. * information for this callback.
  402. *
  403. * This method returns true if the SCI core should copy the received frame data
  404. * to the SGL location or false if the SCI user wants to retrieve the frame
  405. * data at a later time.
  406. */
  407. bool scic_cb_io_request_do_copy_rx_frames(
  408. void *scic_user_io_request)
  409. {
  410. struct sas_task *task
  411. = isci_request_access_task(
  412. (struct isci_request *)scic_user_io_request
  413. );
  414. return (task->data_dir == DMA_NONE) ? false : true;
  415. }
  416. /**
  417. * scic_cb_get_virtual_address() - This callback method asks the user to
  418. * provide the virtual address for the supplied physical address.
  419. * @controller: This parameter is the core controller object handle.
  420. * @physical_address: This parameter is the physical address which is to be
  421. * returned as a virtual address.
  422. *
  423. * The method returns the virtual address for the supplied physical address.
  424. */
  425. void *scic_cb_get_virtual_address(
  426. struct scic_sds_controller *controller,
  427. dma_addr_t physical_address)
  428. {
  429. void *virt_addr = (void *)phys_to_virt(physical_address);
  430. return virt_addr;
  431. }
  432. /**
  433. * scic_cb_request_get_sat_protocol() - This callback method asks the user to
  434. * return the SAT protocol definition for this IO request. This method is
  435. * only called by the SCI core if the request type constructed is SATA.
  436. * @scic_user_io_request: This parameter points to the user's IO request
  437. * object. It is a cookie that allows the user to provide the necessary
  438. * information for this callback.
  439. *
  440. * This method returns one of the sat.h defined protocols for the given io
  441. * request.
  442. */
  443. u8 scic_cb_request_get_sat_protocol(
  444. void *scic_user_io_request)
  445. {
  446. return isci_sata_get_sat_protocol(
  447. (struct isci_request *)scic_user_io_request
  448. );
  449. }