request.c 40 KB

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