request.c 39 KB

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