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