request.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  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. #include "isci.h"
  56. #include "scic_remote_device.h"
  57. #include "scic_io_request.h"
  58. #include "scic_task_request.h"
  59. #include "scic_port.h"
  60. #include "task.h"
  61. #include "request.h"
  62. #include "sata.h"
  63. #include "scu_completion_codes.h"
  64. static enum sci_status isci_request_ssp_request_construct(
  65. struct isci_request *request)
  66. {
  67. enum sci_status status;
  68. dev_dbg(&request->isci_host->pdev->dev,
  69. "%s: request = %p\n",
  70. __func__,
  71. request);
  72. status = scic_io_request_construct_basic_ssp(
  73. request->sci_request_handle
  74. );
  75. return status;
  76. }
  77. static enum sci_status isci_request_stp_request_construct(
  78. struct isci_request *request)
  79. {
  80. struct sas_task *task = isci_request_access_task(request);
  81. enum sci_status status;
  82. struct host_to_dev_fis *register_fis;
  83. dev_dbg(&request->isci_host->pdev->dev,
  84. "%s: request = %p\n",
  85. __func__,
  86. request);
  87. /* Get the host_to_dev_fis from the core and copy
  88. * the fis from the task into it.
  89. */
  90. register_fis = isci_sata_task_to_fis_copy(task);
  91. status = scic_io_request_construct_basic_sata(
  92. request->sci_request_handle
  93. );
  94. /* Set the ncq tag in the fis, from the queue
  95. * command in the task.
  96. */
  97. if (isci_sata_is_task_ncq(task)) {
  98. isci_sata_set_ncq_tag(
  99. register_fis,
  100. task
  101. );
  102. }
  103. return status;
  104. }
  105. /**
  106. * isci_smp_request_build() - This function builds the smp request object.
  107. * @isci_host: This parameter specifies the ISCI host object
  108. * @request: This parameter points to the isci_request object allocated in the
  109. * request construct function.
  110. * @sci_device: This parameter is the handle for the sci core's remote device
  111. * object that is the destination for this request.
  112. *
  113. * SCI_SUCCESS on successfull completion, or specific failure code.
  114. */
  115. static enum sci_status isci_smp_request_build(
  116. struct isci_request *request)
  117. {
  118. enum sci_status status = SCI_FAILURE;
  119. struct sas_task *task = isci_request_access_task(request);
  120. void *command_iu_address =
  121. scic_io_request_get_command_iu_address(
  122. request->sci_request_handle
  123. );
  124. dev_dbg(&request->isci_host->pdev->dev,
  125. "%s: request = %p\n",
  126. __func__,
  127. request);
  128. dev_dbg(&request->isci_host->pdev->dev,
  129. "%s: smp_req len = %d\n",
  130. __func__,
  131. task->smp_task.smp_req.length);
  132. /* copy the smp_command to the address; */
  133. sg_copy_to_buffer(&task->smp_task.smp_req, 1,
  134. (char *)command_iu_address,
  135. sizeof(struct smp_request)
  136. );
  137. status = scic_io_request_construct_smp(request->sci_request_handle);
  138. if (status != SCI_SUCCESS)
  139. dev_warn(&request->isci_host->pdev->dev,
  140. "%s: scic_io_request_construct_smp failed with "
  141. "status = %d\n",
  142. __func__,
  143. status);
  144. return status;
  145. }
  146. /**
  147. * isci_io_request_build() - This function builds the io request object.
  148. * @isci_host: This parameter specifies the ISCI host object
  149. * @request: This parameter points to the isci_request object allocated in the
  150. * request construct function.
  151. * @sci_device: This parameter is the handle for the sci core's remote device
  152. * object that is the destination for this request.
  153. *
  154. * SCI_SUCCESS on successfull completion, or specific failure code.
  155. */
  156. static enum sci_status isci_io_request_build(
  157. struct isci_host *isci_host,
  158. struct isci_request *request,
  159. struct isci_remote_device *isci_device)
  160. {
  161. struct smp_discover_response_protocols dev_protocols;
  162. enum sci_status status = SCI_SUCCESS;
  163. struct sas_task *task = isci_request_access_task(request);
  164. struct scic_sds_remote_device *sci_device = &isci_device->sci;
  165. dev_dbg(&isci_host->pdev->dev,
  166. "%s: isci_device = 0x%p; request = %p, "
  167. "num_scatter = %d\n",
  168. __func__,
  169. isci_device,
  170. request,
  171. task->num_scatter);
  172. /* map the sgl addresses, if present.
  173. * libata does the mapping for sata devices
  174. * before we get the request.
  175. */
  176. if (task->num_scatter &&
  177. !sas_protocol_ata(task->task_proto) &&
  178. !(SAS_PROTOCOL_SMP & task->task_proto)) {
  179. request->num_sg_entries = dma_map_sg(
  180. &isci_host->pdev->dev,
  181. task->scatter,
  182. task->num_scatter,
  183. task->data_dir
  184. );
  185. if (request->num_sg_entries == 0)
  186. return SCI_FAILURE_INSUFFICIENT_RESOURCES;
  187. }
  188. /* build the common request object. For now,
  189. * we will let the core allocate the IO tag.
  190. */
  191. status = scic_io_request_construct(
  192. isci_host->core_controller,
  193. sci_device,
  194. SCI_CONTROLLER_INVALID_IO_TAG,
  195. request,
  196. request->sci_request_mem_ptr,
  197. (struct scic_sds_request **)&request->sci_request_handle
  198. );
  199. if (status != SCI_SUCCESS) {
  200. dev_warn(&isci_host->pdev->dev,
  201. "%s: failed request construct\n",
  202. __func__);
  203. return SCI_FAILURE;
  204. }
  205. sci_object_set_association(request->sci_request_handle, request);
  206. /* Determine protocol and call the appropriate basic constructor */
  207. scic_remote_device_get_protocols(sci_device, &dev_protocols);
  208. if (dev_protocols.u.bits.attached_ssp_target)
  209. status = isci_request_ssp_request_construct(request);
  210. else if (dev_protocols.u.bits.attached_stp_target)
  211. status = isci_request_stp_request_construct(request);
  212. else if (dev_protocols.u.bits.attached_smp_target)
  213. status = isci_smp_request_build(request);
  214. else {
  215. dev_warn(&isci_host->pdev->dev,
  216. "%s: unknown protocol\n", __func__);
  217. return SCI_FAILURE;
  218. }
  219. return SCI_SUCCESS;
  220. }
  221. /**
  222. * isci_request_alloc_core() - This function gets the request object from the
  223. * isci_host dma cache.
  224. * @isci_host: This parameter specifies the ISCI host object
  225. * @isci_request: This parameter will contain the pointer to the new
  226. * isci_request object.
  227. * @isci_device: This parameter is the pointer to the isci remote device object
  228. * that is the destination for this request.
  229. * @gfp_flags: This parameter specifies the os allocation flags.
  230. *
  231. * SCI_SUCCESS on successfull completion, or specific failure code.
  232. */
  233. static int isci_request_alloc_core(
  234. struct isci_host *isci_host,
  235. struct isci_request **isci_request,
  236. struct isci_remote_device *isci_device,
  237. gfp_t gfp_flags)
  238. {
  239. int ret = 0;
  240. dma_addr_t handle;
  241. struct isci_request *request;
  242. /* get pointer to dma memory. This actually points
  243. * to both the isci_remote_device object and the
  244. * sci object. The isci object is at the beginning
  245. * of the memory allocated here.
  246. */
  247. request = dma_pool_alloc(isci_host->dma_pool, gfp_flags, &handle);
  248. if (!request) {
  249. dev_warn(&isci_host->pdev->dev,
  250. "%s: dma_pool_alloc returned NULL\n", __func__);
  251. return -ENOMEM;
  252. }
  253. /* initialize the request object. */
  254. spin_lock_init(&request->state_lock);
  255. request->sci_request_mem_ptr = ((u8 *)request) +
  256. sizeof(struct isci_request);
  257. request->request_daddr = handle;
  258. request->isci_host = isci_host;
  259. request->isci_device = isci_device;
  260. request->io_request_completion = NULL;
  261. request->request_alloc_size = isci_host->dma_pool_alloc_size;
  262. request->num_sg_entries = 0;
  263. request->complete_in_target = false;
  264. INIT_LIST_HEAD(&request->completed_node);
  265. INIT_LIST_HEAD(&request->dev_node);
  266. *isci_request = request;
  267. isci_request_change_state(request, allocated);
  268. return ret;
  269. }
  270. static int isci_request_alloc_io(
  271. struct isci_host *isci_host,
  272. struct sas_task *task,
  273. struct isci_request **isci_request,
  274. struct isci_remote_device *isci_device,
  275. gfp_t gfp_flags)
  276. {
  277. int retval = isci_request_alloc_core(isci_host, isci_request,
  278. isci_device, gfp_flags);
  279. if (!retval) {
  280. (*isci_request)->ttype_ptr.io_task_ptr = task;
  281. (*isci_request)->ttype = io_task;
  282. task->lldd_task = *isci_request;
  283. }
  284. return retval;
  285. }
  286. /**
  287. * isci_request_alloc_tmf() - This function gets the request object from the
  288. * isci_host dma cache and initializes the relevant fields as a sas_task.
  289. * @isci_host: This parameter specifies the ISCI host object
  290. * @sas_task: This parameter is the task struct from the upper layer driver.
  291. * @isci_request: This parameter will contain the pointer to the new
  292. * isci_request object.
  293. * @isci_device: This parameter is the pointer to the isci remote device object
  294. * that is the destination for this request.
  295. * @gfp_flags: This parameter specifies the os allocation flags.
  296. *
  297. * SCI_SUCCESS on successfull completion, or specific failure code.
  298. */
  299. int isci_request_alloc_tmf(
  300. struct isci_host *isci_host,
  301. struct isci_tmf *isci_tmf,
  302. struct isci_request **isci_request,
  303. struct isci_remote_device *isci_device,
  304. gfp_t gfp_flags)
  305. {
  306. int retval = isci_request_alloc_core(isci_host, isci_request,
  307. isci_device, gfp_flags);
  308. if (!retval) {
  309. (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf;
  310. (*isci_request)->ttype = tmf_task;
  311. }
  312. return retval;
  313. }
  314. /**
  315. * isci_request_execute() - This function allocates the isci_request object,
  316. * all fills in some common fields.
  317. * @isci_host: This parameter specifies the ISCI host object
  318. * @sas_task: This parameter is the task struct from the upper layer driver.
  319. * @isci_request: This parameter will contain the pointer to the new
  320. * isci_request object.
  321. * @gfp_flags: This parameter specifies the os allocation flags.
  322. *
  323. * SCI_SUCCESS on successfull completion, or specific failure code.
  324. */
  325. int isci_request_execute(
  326. struct isci_host *isci_host,
  327. struct sas_task *task,
  328. struct isci_request **isci_request,
  329. gfp_t gfp_flags)
  330. {
  331. int ret = 0;
  332. struct scic_sds_remote_device *sci_device;
  333. enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
  334. struct isci_remote_device *isci_device;
  335. struct isci_request *request;
  336. unsigned long flags;
  337. isci_device = task->dev->lldd_dev;
  338. sci_device = &isci_device->sci;
  339. /* do common allocation and init of request object. */
  340. ret = isci_request_alloc_io(
  341. isci_host,
  342. task,
  343. &request,
  344. isci_device,
  345. gfp_flags
  346. );
  347. if (ret)
  348. goto out;
  349. status = isci_io_request_build(isci_host, request, isci_device);
  350. if (status == SCI_SUCCESS) {
  351. spin_lock_irqsave(&isci_host->scic_lock, flags);
  352. /* send the request, let the core assign the IO TAG. */
  353. status = scic_controller_start_io(
  354. isci_host->core_controller,
  355. sci_device,
  356. request->sci_request_handle,
  357. SCI_CONTROLLER_INVALID_IO_TAG
  358. );
  359. if (status == SCI_SUCCESS ||
  360. status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
  361. /* Either I/O started OK, or the core has signaled that
  362. * the device needs a target reset.
  363. *
  364. * In either case, hold onto the I/O for later.
  365. *
  366. * Update it's status and add it to the list in the
  367. * remote device object.
  368. */
  369. isci_request_change_state(request, started);
  370. list_add(&request->dev_node,
  371. &isci_device->reqs_in_process);
  372. if (status == SCI_SUCCESS) {
  373. /* Save the tag for possible task mgmt later. */
  374. request->io_tag = scic_io_request_get_io_tag(
  375. request->sci_request_handle);
  376. } else {
  377. /* The request did not really start in the
  378. * hardware, so clear the request handle
  379. * here so no terminations will be done.
  380. */
  381. request->sci_request_handle = NULL;
  382. }
  383. } else
  384. dev_warn(&isci_host->pdev->dev,
  385. "%s: failed request start (0x%x)\n",
  386. __func__, status);
  387. spin_unlock_irqrestore(&isci_host->scic_lock, flags);
  388. if (status ==
  389. SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
  390. /* Signal libsas that we need the SCSI error
  391. * handler thread to work on this I/O and that
  392. * we want a device reset.
  393. */
  394. spin_lock_irqsave(&task->task_state_lock, flags);
  395. task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
  396. spin_unlock_irqrestore(&task->task_state_lock, flags);
  397. /* Cause this task to be scheduled in the SCSI error
  398. * handler thread.
  399. */
  400. isci_execpath_callback(isci_host, task,
  401. sas_task_abort);
  402. /* Change the status, since we are holding
  403. * the I/O until it is managed by the SCSI
  404. * error handler.
  405. */
  406. status = SCI_SUCCESS;
  407. }
  408. } else
  409. dev_warn(&isci_host->pdev->dev,
  410. "%s: request_construct failed - status = 0x%x\n",
  411. __func__,
  412. status);
  413. out:
  414. if (status != SCI_SUCCESS) {
  415. /* release dma memory on failure. */
  416. isci_request_free(isci_host, request);
  417. request = NULL;
  418. ret = SCI_FAILURE;
  419. }
  420. *isci_request = request;
  421. return ret;
  422. }
  423. /**
  424. * isci_request_process_response_iu() - This function sets the status and
  425. * response iu, in the task struct, from the request object for the upper
  426. * layer driver.
  427. * @sas_task: This parameter is the task struct from the upper layer driver.
  428. * @resp_iu: This parameter points to the response iu of the completed request.
  429. * @dev: This parameter specifies the linux device struct.
  430. *
  431. * none.
  432. */
  433. static void isci_request_process_response_iu(
  434. struct sas_task *task,
  435. struct ssp_response_iu *resp_iu,
  436. struct device *dev)
  437. {
  438. dev_dbg(dev,
  439. "%s: resp_iu = %p "
  440. "resp_iu->status = 0x%x,\nresp_iu->datapres = %d "
  441. "resp_iu->response_data_len = %x, "
  442. "resp_iu->sense_data_len = %x\nrepsonse data: ",
  443. __func__,
  444. resp_iu,
  445. resp_iu->status,
  446. resp_iu->datapres,
  447. resp_iu->response_data_len,
  448. resp_iu->sense_data_len);
  449. task->task_status.stat = resp_iu->status;
  450. /* libsas updates the task status fields based on the response iu. */
  451. sas_ssp_task_response(dev, task, resp_iu);
  452. }
  453. /**
  454. * isci_request_set_open_reject_status() - This function prepares the I/O
  455. * completion for OPEN_REJECT conditions.
  456. * @request: This parameter is the completed isci_request object.
  457. * @response_ptr: This parameter specifies the service response for the I/O.
  458. * @status_ptr: This parameter specifies the exec status for the I/O.
  459. * @complete_to_host_ptr: This parameter specifies the action to be taken by
  460. * the LLDD with respect to completing this request or forcing an abort
  461. * condition on the I/O.
  462. * @open_rej_reason: This parameter specifies the encoded reason for the
  463. * abandon-class reject.
  464. *
  465. * none.
  466. */
  467. static void isci_request_set_open_reject_status(
  468. struct isci_request *request,
  469. struct sas_task *task,
  470. enum service_response *response_ptr,
  471. enum exec_status *status_ptr,
  472. enum isci_completion_selection *complete_to_host_ptr,
  473. enum sas_open_rej_reason open_rej_reason)
  474. {
  475. /* Task in the target is done. */
  476. request->complete_in_target = true;
  477. *response_ptr = SAS_TASK_UNDELIVERED;
  478. *status_ptr = SAS_OPEN_REJECT;
  479. *complete_to_host_ptr = isci_perform_normal_io_completion;
  480. task->task_status.open_rej_reason = open_rej_reason;
  481. }
  482. /**
  483. * isci_request_handle_controller_specific_errors() - This function decodes
  484. * controller-specific I/O completion error conditions.
  485. * @request: This parameter is the completed isci_request object.
  486. * @response_ptr: This parameter specifies the service response for the I/O.
  487. * @status_ptr: This parameter specifies the exec status for the I/O.
  488. * @complete_to_host_ptr: This parameter specifies the action to be taken by
  489. * the LLDD with respect to completing this request or forcing an abort
  490. * condition on the I/O.
  491. *
  492. * none.
  493. */
  494. static void isci_request_handle_controller_specific_errors(
  495. struct isci_remote_device *isci_device,
  496. struct isci_request *request,
  497. struct sas_task *task,
  498. enum service_response *response_ptr,
  499. enum exec_status *status_ptr,
  500. enum isci_completion_selection *complete_to_host_ptr)
  501. {
  502. unsigned int cstatus;
  503. cstatus = scic_request_get_controller_status(
  504. request->sci_request_handle
  505. );
  506. dev_dbg(&request->isci_host->pdev->dev,
  507. "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR "
  508. "- controller status = 0x%x\n",
  509. __func__, request, cstatus);
  510. /* Decode the controller-specific errors; most
  511. * important is to recognize those conditions in which
  512. * the target may still have a task outstanding that
  513. * must be aborted.
  514. *
  515. * Note that there are SCU completion codes being
  516. * named in the decode below for which SCIC has already
  517. * done work to handle them in a way other than as
  518. * a controller-specific completion code; these are left
  519. * in the decode below for completeness sake.
  520. */
  521. switch (cstatus) {
  522. case SCU_TASK_DONE_DMASETUP_DIRERR:
  523. /* Also SCU_TASK_DONE_SMP_FRM_TYPE_ERR: */
  524. case SCU_TASK_DONE_XFERCNT_ERR:
  525. /* Also SCU_TASK_DONE_SMP_UFI_ERR: */
  526. if (task->task_proto == SAS_PROTOCOL_SMP) {
  527. /* SCU_TASK_DONE_SMP_UFI_ERR == Task Done. */
  528. *response_ptr = SAS_TASK_COMPLETE;
  529. /* See if the device has been/is being stopped. Note
  530. * that we ignore the quiesce state, since we are
  531. * concerned about the actual device state.
  532. */
  533. if ((isci_device->status == isci_stopping) ||
  534. (isci_device->status == isci_stopped))
  535. *status_ptr = SAS_DEVICE_UNKNOWN;
  536. else
  537. *status_ptr = SAS_ABORTED_TASK;
  538. request->complete_in_target = true;
  539. *complete_to_host_ptr =
  540. isci_perform_normal_io_completion;
  541. } else {
  542. /* Task in the target is not done. */
  543. *response_ptr = SAS_TASK_UNDELIVERED;
  544. if ((isci_device->status == isci_stopping) ||
  545. (isci_device->status == isci_stopped))
  546. *status_ptr = SAS_DEVICE_UNKNOWN;
  547. else
  548. *status_ptr = SAM_STAT_TASK_ABORTED;
  549. request->complete_in_target = false;
  550. *complete_to_host_ptr =
  551. isci_perform_error_io_completion;
  552. }
  553. break;
  554. case SCU_TASK_DONE_CRC_ERR:
  555. case SCU_TASK_DONE_NAK_CMD_ERR:
  556. case SCU_TASK_DONE_EXCESS_DATA:
  557. case SCU_TASK_DONE_UNEXP_FIS:
  558. /* Also SCU_TASK_DONE_UNEXP_RESP: */
  559. case SCU_TASK_DONE_VIIT_ENTRY_NV: /* TODO - conditions? */
  560. case SCU_TASK_DONE_IIT_ENTRY_NV: /* TODO - conditions? */
  561. case SCU_TASK_DONE_RNCNV_OUTBOUND: /* TODO - conditions? */
  562. /* These are conditions in which the target
  563. * has completed the task, so that no cleanup
  564. * is necessary.
  565. */
  566. *response_ptr = SAS_TASK_COMPLETE;
  567. /* See if the device has been/is being stopped. Note
  568. * that we ignore the quiesce state, since we are
  569. * concerned about the actual device state.
  570. */
  571. if ((isci_device->status == isci_stopping) ||
  572. (isci_device->status == isci_stopped))
  573. *status_ptr = SAS_DEVICE_UNKNOWN;
  574. else
  575. *status_ptr = SAS_ABORTED_TASK;
  576. request->complete_in_target = true;
  577. *complete_to_host_ptr = isci_perform_normal_io_completion;
  578. break;
  579. /* Note that the only open reject completion codes seen here will be
  580. * abandon-class codes; all others are automatically retried in the SCU.
  581. */
  582. case SCU_TASK_OPEN_REJECT_WRONG_DESTINATION:
  583. isci_request_set_open_reject_status(
  584. request, task, response_ptr, status_ptr,
  585. complete_to_host_ptr, SAS_OREJ_WRONG_DEST);
  586. break;
  587. case SCU_TASK_OPEN_REJECT_ZONE_VIOLATION:
  588. /* Note - the return of AB0 will change when
  589. * libsas implements detection of zone violations.
  590. */
  591. isci_request_set_open_reject_status(
  592. request, task, response_ptr, status_ptr,
  593. complete_to_host_ptr, SAS_OREJ_RESV_AB0);
  594. break;
  595. case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1:
  596. isci_request_set_open_reject_status(
  597. request, task, response_ptr, status_ptr,
  598. complete_to_host_ptr, SAS_OREJ_RESV_AB1);
  599. break;
  600. case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2:
  601. isci_request_set_open_reject_status(
  602. request, task, response_ptr, status_ptr,
  603. complete_to_host_ptr, SAS_OREJ_RESV_AB2);
  604. break;
  605. case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3:
  606. isci_request_set_open_reject_status(
  607. request, task, response_ptr, status_ptr,
  608. complete_to_host_ptr, SAS_OREJ_RESV_AB3);
  609. break;
  610. case SCU_TASK_OPEN_REJECT_BAD_DESTINATION:
  611. isci_request_set_open_reject_status(
  612. request, task, response_ptr, status_ptr,
  613. complete_to_host_ptr, SAS_OREJ_BAD_DEST);
  614. break;
  615. case SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY:
  616. isci_request_set_open_reject_status(
  617. request, task, response_ptr, status_ptr,
  618. complete_to_host_ptr, SAS_OREJ_STP_NORES);
  619. break;
  620. case SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED:
  621. isci_request_set_open_reject_status(
  622. request, task, response_ptr, status_ptr,
  623. complete_to_host_ptr, SAS_OREJ_EPROTO);
  624. break;
  625. case SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED:
  626. isci_request_set_open_reject_status(
  627. request, task, response_ptr, status_ptr,
  628. complete_to_host_ptr, SAS_OREJ_CONN_RATE);
  629. break;
  630. case SCU_TASK_DONE_LL_R_ERR:
  631. /* Also SCU_TASK_DONE_ACK_NAK_TO: */
  632. case SCU_TASK_DONE_LL_PERR:
  633. case SCU_TASK_DONE_LL_SY_TERM:
  634. /* Also SCU_TASK_DONE_NAK_ERR:*/
  635. case SCU_TASK_DONE_LL_LF_TERM:
  636. /* Also SCU_TASK_DONE_DATA_LEN_ERR: */
  637. case SCU_TASK_DONE_LL_ABORT_ERR:
  638. case SCU_TASK_DONE_SEQ_INV_TYPE:
  639. /* Also SCU_TASK_DONE_UNEXP_XR: */
  640. case SCU_TASK_DONE_XR_IU_LEN_ERR:
  641. case SCU_TASK_DONE_INV_FIS_LEN:
  642. /* Also SCU_TASK_DONE_XR_WD_LEN: */
  643. case SCU_TASK_DONE_SDMA_ERR:
  644. case SCU_TASK_DONE_OFFSET_ERR:
  645. case SCU_TASK_DONE_MAX_PLD_ERR:
  646. case SCU_TASK_DONE_LF_ERR:
  647. case SCU_TASK_DONE_SMP_RESP_TO_ERR: /* Escalate to dev reset? */
  648. case SCU_TASK_DONE_SMP_LL_RX_ERR:
  649. case SCU_TASK_DONE_UNEXP_DATA:
  650. case SCU_TASK_DONE_UNEXP_SDBFIS:
  651. case SCU_TASK_DONE_REG_ERR:
  652. case SCU_TASK_DONE_SDB_ERR:
  653. case SCU_TASK_DONE_TASK_ABORT:
  654. default:
  655. /* Task in the target is not done. */
  656. *response_ptr = SAS_TASK_UNDELIVERED;
  657. *status_ptr = SAM_STAT_TASK_ABORTED;
  658. request->complete_in_target = false;
  659. *complete_to_host_ptr = isci_perform_error_io_completion;
  660. break;
  661. }
  662. }
  663. /**
  664. * isci_task_save_for_upper_layer_completion() - This function saves the
  665. * request for later completion to the upper layer driver.
  666. * @host: This parameter is a pointer to the host on which the the request
  667. * should be queued (either as an error or success).
  668. * @request: This parameter is the completed request.
  669. * @response: This parameter is the response code for the completed task.
  670. * @status: This parameter is the status code for the completed task.
  671. *
  672. * none.
  673. */
  674. static void isci_task_save_for_upper_layer_completion(
  675. struct isci_host *host,
  676. struct isci_request *request,
  677. enum service_response response,
  678. enum exec_status status,
  679. enum isci_completion_selection task_notification_selection)
  680. {
  681. struct sas_task *task = isci_request_access_task(request);
  682. task_notification_selection
  683. = isci_task_set_completion_status(task, response, status,
  684. task_notification_selection);
  685. /* Tasks aborted specifically by a call to the lldd_abort_task
  686. * function should not be completed to the host in the regular path.
  687. */
  688. switch (task_notification_selection) {
  689. case isci_perform_normal_io_completion:
  690. /* Normal notification (task_done) */
  691. dev_dbg(&host->pdev->dev,
  692. "%s: Normal - task = %p, response=%d (%d), status=%d (%d)\n",
  693. __func__,
  694. task,
  695. task->task_status.resp, response,
  696. task->task_status.stat, status);
  697. /* Add to the completed list. */
  698. list_add(&request->completed_node,
  699. &host->requests_to_complete);
  700. /* Take the request off the device's pending request list. */
  701. list_del_init(&request->dev_node);
  702. break;
  703. case isci_perform_aborted_io_completion:
  704. /* No notification to libsas because this request is
  705. * already in the abort path.
  706. */
  707. dev_warn(&host->pdev->dev,
  708. "%s: Aborted - task = %p, response=%d (%d), status=%d (%d)\n",
  709. __func__,
  710. task,
  711. task->task_status.resp, response,
  712. task->task_status.stat, status);
  713. /* Wake up whatever process was waiting for this
  714. * request to complete.
  715. */
  716. WARN_ON(request->io_request_completion == NULL);
  717. if (request->io_request_completion != NULL) {
  718. /* Signal whoever is waiting that this
  719. * request is complete.
  720. */
  721. complete(request->io_request_completion);
  722. }
  723. break;
  724. case isci_perform_error_io_completion:
  725. /* Use sas_task_abort */
  726. dev_warn(&host->pdev->dev,
  727. "%s: Error - task = %p, response=%d (%d), status=%d (%d)\n",
  728. __func__,
  729. task,
  730. task->task_status.resp, response,
  731. task->task_status.stat, status);
  732. /* Add to the aborted list. */
  733. list_add(&request->completed_node,
  734. &host->requests_to_errorback);
  735. break;
  736. default:
  737. dev_warn(&host->pdev->dev,
  738. "%s: Unknown - task = %p, response=%d (%d), status=%d (%d)\n",
  739. __func__,
  740. task,
  741. task->task_status.resp, response,
  742. task->task_status.stat, status);
  743. /* Add to the error to libsas list. */
  744. list_add(&request->completed_node,
  745. &host->requests_to_errorback);
  746. break;
  747. }
  748. }
  749. /**
  750. * isci_request_io_request_complete() - This function is called by the sci core
  751. * when an io request completes.
  752. * @isci_host: This parameter specifies the ISCI host object
  753. * @request: This parameter is the completed isci_request object.
  754. * @completion_status: This parameter specifies the completion status from the
  755. * sci core.
  756. *
  757. * none.
  758. */
  759. void isci_request_io_request_complete(
  760. struct isci_host *isci_host,
  761. struct isci_request *request,
  762. enum sci_io_status completion_status)
  763. {
  764. struct sas_task *task = isci_request_access_task(request);
  765. struct ssp_response_iu *resp_iu;
  766. void *resp_buf;
  767. unsigned long task_flags;
  768. struct isci_remote_device *isci_device = request->isci_device;
  769. enum service_response response = SAS_TASK_UNDELIVERED;
  770. enum exec_status status = SAS_ABORTED_TASK;
  771. enum isci_request_status request_status;
  772. enum isci_completion_selection complete_to_host
  773. = isci_perform_normal_io_completion;
  774. dev_dbg(&isci_host->pdev->dev,
  775. "%s: request = %p, task = %p,\n"
  776. "task->data_dir = %d completion_status = 0x%x\n",
  777. __func__,
  778. request,
  779. task,
  780. task->data_dir,
  781. completion_status);
  782. spin_lock(&request->state_lock);
  783. request_status = isci_request_get_state(request);
  784. /* Decode the request status. Note that if the request has been
  785. * aborted by a task management function, we don't care
  786. * what the status is.
  787. */
  788. switch (request_status) {
  789. case aborted:
  790. /* "aborted" indicates that the request was aborted by a task
  791. * management function, since once a task management request is
  792. * perfomed by the device, the request only completes because
  793. * of the subsequent driver terminate.
  794. *
  795. * Aborted also means an external thread is explicitly managing
  796. * this request, so that we do not complete it up the stack.
  797. *
  798. * The target is still there (since the TMF was successful).
  799. */
  800. request->complete_in_target = true;
  801. response = SAS_TASK_COMPLETE;
  802. /* See if the device has been/is being stopped. Note
  803. * that we ignore the quiesce state, since we are
  804. * concerned about the actual device state.
  805. */
  806. if ((isci_device->status == isci_stopping)
  807. || (isci_device->status == isci_stopped)
  808. )
  809. status = SAS_DEVICE_UNKNOWN;
  810. else
  811. status = SAS_ABORTED_TASK;
  812. complete_to_host = isci_perform_aborted_io_completion;
  813. /* This was an aborted request. */
  814. spin_unlock(&request->state_lock);
  815. break;
  816. case aborting:
  817. /* aborting means that the task management function tried and
  818. * failed to abort the request. We need to note the request
  819. * as SAS_TASK_UNDELIVERED, so that the scsi mid layer marks the
  820. * target as down.
  821. *
  822. * Aborting also means an external thread is explicitly managing
  823. * this request, so that we do not complete it up the stack.
  824. */
  825. request->complete_in_target = true;
  826. response = SAS_TASK_UNDELIVERED;
  827. if ((isci_device->status == isci_stopping) ||
  828. (isci_device->status == isci_stopped))
  829. /* The device has been /is being stopped. Note that
  830. * we ignore the quiesce state, since we are
  831. * concerned about the actual device state.
  832. */
  833. status = SAS_DEVICE_UNKNOWN;
  834. else
  835. status = SAS_PHY_DOWN;
  836. complete_to_host = isci_perform_aborted_io_completion;
  837. /* This was an aborted request. */
  838. spin_unlock(&request->state_lock);
  839. break;
  840. case terminating:
  841. /* This was an terminated request. This happens when
  842. * the I/O is being terminated because of an action on
  843. * the device (reset, tear down, etc.), and the I/O needs
  844. * to be completed up the stack.
  845. */
  846. request->complete_in_target = true;
  847. response = SAS_TASK_UNDELIVERED;
  848. /* See if the device has been/is being stopped. Note
  849. * that we ignore the quiesce state, since we are
  850. * concerned about the actual device state.
  851. */
  852. if ((isci_device->status == isci_stopping) ||
  853. (isci_device->status == isci_stopped))
  854. status = SAS_DEVICE_UNKNOWN;
  855. else
  856. status = SAS_ABORTED_TASK;
  857. complete_to_host = isci_perform_aborted_io_completion;
  858. /* This was a terminated request. */
  859. spin_unlock(&request->state_lock);
  860. break;
  861. default:
  862. /* The request is done from an SCU HW perspective. */
  863. request->status = completed;
  864. spin_unlock(&request->state_lock);
  865. /* This is an active request being completed from the core. */
  866. switch (completion_status) {
  867. case SCI_IO_FAILURE_RESPONSE_VALID:
  868. dev_dbg(&isci_host->pdev->dev,
  869. "%s: SCI_IO_FAILURE_RESPONSE_VALID (%p/%p)\n",
  870. __func__,
  871. request,
  872. task);
  873. if (sas_protocol_ata(task->task_proto)) {
  874. resp_buf
  875. = scic_stp_io_request_get_d2h_reg_address(
  876. request->sci_request_handle
  877. );
  878. isci_request_process_stp_response(task,
  879. resp_buf
  880. );
  881. } else if (SAS_PROTOCOL_SSP == task->task_proto) {
  882. /* crack the iu response buffer. */
  883. resp_iu
  884. = scic_io_request_get_response_iu_address(
  885. request->sci_request_handle
  886. );
  887. isci_request_process_response_iu(task, resp_iu,
  888. &isci_host->pdev->dev
  889. );
  890. } else if (SAS_PROTOCOL_SMP == task->task_proto) {
  891. dev_err(&isci_host->pdev->dev,
  892. "%s: SCI_IO_FAILURE_RESPONSE_VALID: "
  893. "SAS_PROTOCOL_SMP protocol\n",
  894. __func__);
  895. } else
  896. dev_err(&isci_host->pdev->dev,
  897. "%s: unknown protocol\n", __func__);
  898. /* use the task status set in the task struct by the
  899. * isci_request_process_response_iu call.
  900. */
  901. request->complete_in_target = true;
  902. response = task->task_status.resp;
  903. status = task->task_status.stat;
  904. break;
  905. case SCI_IO_SUCCESS:
  906. case SCI_IO_SUCCESS_IO_DONE_EARLY:
  907. response = SAS_TASK_COMPLETE;
  908. status = SAM_STAT_GOOD;
  909. request->complete_in_target = true;
  910. if (task->task_proto == SAS_PROTOCOL_SMP) {
  911. u8 *command_iu_address
  912. = scic_io_request_get_command_iu_address(
  913. request->sci_request_handle
  914. );
  915. dev_dbg(&isci_host->pdev->dev,
  916. "%s: SMP protocol completion\n",
  917. __func__);
  918. sg_copy_from_buffer(
  919. &task->smp_task.smp_resp, 1,
  920. command_iu_address
  921. + sizeof(struct smp_request),
  922. sizeof(struct smp_resp)
  923. );
  924. } else if (completion_status
  925. == SCI_IO_SUCCESS_IO_DONE_EARLY) {
  926. /* This was an SSP / STP / SATA transfer.
  927. * There is a possibility that less data than
  928. * the maximum was transferred.
  929. */
  930. u32 transferred_length
  931. = scic_io_request_get_number_of_bytes_transferred(
  932. request->sci_request_handle);
  933. task->task_status.residual
  934. = task->total_xfer_len - transferred_length;
  935. /* If there were residual bytes, call this an
  936. * underrun.
  937. */
  938. if (task->task_status.residual != 0)
  939. status = SAS_DATA_UNDERRUN;
  940. dev_dbg(&isci_host->pdev->dev,
  941. "%s: SCI_IO_SUCCESS_IO_DONE_EARLY %d\n",
  942. __func__,
  943. status);
  944. } else
  945. dev_dbg(&isci_host->pdev->dev,
  946. "%s: SCI_IO_SUCCESS\n",
  947. __func__);
  948. break;
  949. case SCI_IO_FAILURE_TERMINATED:
  950. dev_dbg(&isci_host->pdev->dev,
  951. "%s: SCI_IO_FAILURE_TERMINATED (%p/%p)\n",
  952. __func__,
  953. request,
  954. task);
  955. /* The request was terminated explicitly. No handling
  956. * is needed in the SCSI error handler path.
  957. */
  958. request->complete_in_target = true;
  959. response = SAS_TASK_UNDELIVERED;
  960. /* See if the device has been/is being stopped. Note
  961. * that we ignore the quiesce state, since we are
  962. * concerned about the actual device state.
  963. */
  964. if ((isci_device->status == isci_stopping) ||
  965. (isci_device->status == isci_stopped))
  966. status = SAS_DEVICE_UNKNOWN;
  967. else
  968. status = SAS_ABORTED_TASK;
  969. complete_to_host = isci_perform_normal_io_completion;
  970. break;
  971. case SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR:
  972. isci_request_handle_controller_specific_errors(
  973. isci_device, request, task, &response, &status,
  974. &complete_to_host);
  975. break;
  976. case SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED:
  977. /* This is a special case, in that the I/O completion
  978. * is telling us that the device needs a reset.
  979. * In order for the device reset condition to be
  980. * noticed, the I/O has to be handled in the error
  981. * handler. Set the reset flag and cause the
  982. * SCSI error thread to be scheduled.
  983. */
  984. spin_lock_irqsave(&task->task_state_lock, task_flags);
  985. task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
  986. spin_unlock_irqrestore(&task->task_state_lock, task_flags);
  987. /* Fail the I/O. */
  988. response = SAS_TASK_UNDELIVERED;
  989. status = SAM_STAT_TASK_ABORTED;
  990. complete_to_host = isci_perform_error_io_completion;
  991. request->complete_in_target = false;
  992. break;
  993. default:
  994. /* Catch any otherwise unhandled error codes here. */
  995. dev_warn(&isci_host->pdev->dev,
  996. "%s: invalid completion code: 0x%x - "
  997. "isci_request = %p\n",
  998. __func__, completion_status, request);
  999. response = SAS_TASK_UNDELIVERED;
  1000. /* See if the device has been/is being stopped. Note
  1001. * that we ignore the quiesce state, since we are
  1002. * concerned about the actual device state.
  1003. */
  1004. if ((isci_device->status == isci_stopping) ||
  1005. (isci_device->status == isci_stopped))
  1006. status = SAS_DEVICE_UNKNOWN;
  1007. else
  1008. status = SAS_ABORTED_TASK;
  1009. complete_to_host = isci_perform_error_io_completion;
  1010. request->complete_in_target = false;
  1011. break;
  1012. }
  1013. break;
  1014. }
  1015. isci_request_unmap_sgl(request, isci_host->pdev);
  1016. /* Put the completed request on the correct list */
  1017. isci_task_save_for_upper_layer_completion(isci_host, request, response,
  1018. status, complete_to_host
  1019. );
  1020. /* complete the io request to the core. */
  1021. scic_controller_complete_io(isci_host->core_controller,
  1022. &isci_device->sci,
  1023. request->sci_request_handle);
  1024. /* NULL the request handle so it cannot be completed or
  1025. * terminated again, and to cause any calls into abort
  1026. * task to recognize the already completed case.
  1027. */
  1028. request->sci_request_handle = NULL;
  1029. isci_host_can_dequeue(isci_host, 1);
  1030. }
  1031. /**
  1032. * isci_request_io_request_get_transfer_length() - This function is called by
  1033. * the sci core to retrieve the transfer length for a given request.
  1034. * @request: This parameter is the isci_request object.
  1035. *
  1036. * length of transfer for specified request.
  1037. */
  1038. u32 isci_request_io_request_get_transfer_length(struct isci_request *request)
  1039. {
  1040. struct sas_task *task = isci_request_access_task(request);
  1041. dev_dbg(&request->isci_host->pdev->dev,
  1042. "%s: total_xfer_len: %d\n",
  1043. __func__,
  1044. task->total_xfer_len);
  1045. return task->total_xfer_len;
  1046. }
  1047. /**
  1048. * isci_request_io_request_get_data_direction() - This function is called by
  1049. * the sci core to retrieve the data direction for a given request.
  1050. * @request: This parameter is the isci_request object.
  1051. *
  1052. * data direction for specified request.
  1053. */
  1054. enum dma_data_direction isci_request_io_request_get_data_direction(
  1055. struct isci_request *request)
  1056. {
  1057. struct sas_task *task = isci_request_access_task(request);
  1058. return task->data_dir;
  1059. }
  1060. /**
  1061. * isci_request_sge_get_address_field() - This function is called by the sci
  1062. * core to retrieve the address field contents for a given sge.
  1063. * @request: This parameter is the isci_request object.
  1064. * @sge_address: This parameter is the sge.
  1065. *
  1066. * physical address in the specified sge.
  1067. */
  1068. /**
  1069. * isci_request_sge_get_length_field() - This function is called by the sci
  1070. * core to retrieve the length field contents for a given sge.
  1071. * @request: This parameter is the isci_request object.
  1072. * @sge_address: This parameter is the sge.
  1073. *
  1074. * length field value in the specified sge.
  1075. */
  1076. /**
  1077. * isci_request_ssp_io_request_get_cdb_address() - This function is called by
  1078. * the sci core to retrieve the cdb address for a given request.
  1079. * @request: This parameter is the isci_request object.
  1080. *
  1081. * cdb address for specified request.
  1082. */
  1083. void *isci_request_ssp_io_request_get_cdb_address(
  1084. struct isci_request *request)
  1085. {
  1086. struct sas_task *task = isci_request_access_task(request);
  1087. dev_dbg(&request->isci_host->pdev->dev,
  1088. "%s: request->task->ssp_task.cdb = %p\n",
  1089. __func__,
  1090. task->ssp_task.cdb);
  1091. return task->ssp_task.cdb;
  1092. }
  1093. /**
  1094. * isci_request_ssp_io_request_get_cdb_length() - This function is called by
  1095. * the sci core to retrieve the cdb length for a given request.
  1096. * @request: This parameter is the isci_request object.
  1097. *
  1098. * cdb length for specified request.
  1099. */
  1100. u32 isci_request_ssp_io_request_get_cdb_length(
  1101. struct isci_request *request)
  1102. {
  1103. return 16;
  1104. }
  1105. /**
  1106. * isci_request_ssp_io_request_get_lun() - This function is called by the sci
  1107. * core to retrieve the lun for a given request.
  1108. * @request: This parameter is the isci_request object.
  1109. *
  1110. * lun for specified request.
  1111. */
  1112. u32 isci_request_ssp_io_request_get_lun(
  1113. struct isci_request *request)
  1114. {
  1115. struct sas_task *task = isci_request_access_task(request);
  1116. #ifdef DEBUG
  1117. int i;
  1118. for (i = 0; i < 8; i++)
  1119. dev_dbg(&request->isci_host->pdev->dev,
  1120. "%s: task->ssp_task.LUN[%d] = %x\n",
  1121. __func__, i, task->ssp_task.LUN[i]);
  1122. #endif
  1123. return task->ssp_task.LUN[0];
  1124. }
  1125. /**
  1126. * isci_request_ssp_io_request_get_task_attribute() - This function is called
  1127. * by the sci core to retrieve the task attribute for a given request.
  1128. * @request: This parameter is the isci_request object.
  1129. *
  1130. * task attribute for specified request.
  1131. */
  1132. u32 isci_request_ssp_io_request_get_task_attribute(
  1133. struct isci_request *request)
  1134. {
  1135. struct sas_task *task = isci_request_access_task(request);
  1136. dev_dbg(&request->isci_host->pdev->dev,
  1137. "%s: request->task->ssp_task.task_attr = %x\n",
  1138. __func__,
  1139. task->ssp_task.task_attr);
  1140. return task->ssp_task.task_attr;
  1141. }
  1142. /**
  1143. * isci_request_ssp_io_request_get_command_priority() - This function is called
  1144. * by the sci core to retrieve the command priority for a given request.
  1145. * @request: This parameter is the isci_request object.
  1146. *
  1147. * command priority for specified request.
  1148. */
  1149. u32 isci_request_ssp_io_request_get_command_priority(
  1150. struct isci_request *request)
  1151. {
  1152. struct sas_task *task = isci_request_access_task(request);
  1153. dev_dbg(&request->isci_host->pdev->dev,
  1154. "%s: request->task->ssp_task.task_prio = %x\n",
  1155. __func__,
  1156. task->ssp_task.task_prio);
  1157. return task->ssp_task.task_prio;
  1158. }