1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of version 2 of the GNU General *
11 * Public License as published by the Free Software Foundation. *
12 * This program is distributed in the hope that it will be useful. *
13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
20 *******************************************************************/
22 #include <linux/pci.h>
23 #include <linux/interrupt.h>
24 #include <linux/delay.h>
26 #include <scsi/scsi.h>
27 #include <scsi/scsi_device.h>
28 #include <scsi/scsi_host.h>
29 #include <scsi/scsi_tcq.h>
30 #include <scsi/scsi_transport_fc.h>
32 #include "lpfc_version.h"
35 #include "lpfc_disc.h"
36 #include "lpfc_scsi.h"
38 #include "lpfc_logmsg.h"
39 #include "lpfc_crtn.h"
41 #define LPFC_RESET_WAIT 2
42 #define LPFC_ABORT_WAIT 2
45 * This routine allocates a scsi buffer, which contains all the necessary
46 * information needed to initiate a SCSI I/O. The non-DMAable buffer region
47 * contains information to build the IOCB. The DMAable region contains
48 * memory for the FCP CMND, FCP RSP, and the inital BPL. In addition to
49 * allocating memeory, the FCP CMND and FCP RSP BDEs are setup in the BPL
50 * and the BPL BDE is setup in the IOCB.
52 static struct lpfc_scsi_buf *
53 lpfc_new_scsi_buf(struct lpfc_vport *vport)
55 struct lpfc_hba *phba = vport->phba;
56 struct lpfc_scsi_buf *psb;
57 struct ulp_bde64 *bpl;
62 psb = kmalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
65 memset(psb, 0, sizeof (struct lpfc_scsi_buf));
68 * Get memory from the pci pool to map the virt space to pci bus space
69 * for an I/O. The DMA buffer includes space for the struct fcp_cmnd,
70 * struct fcp_rsp and the number of bde's necessary to support the
73 psb->data = pci_pool_alloc(phba->lpfc_scsi_dma_buf_pool, GFP_KERNEL,
80 /* Initialize virtual ptrs to dma_buf region. */
81 memset(psb->data, 0, phba->cfg_sg_dma_buf_size);
83 /* Allocate iotag for psb->cur_iocbq. */
84 iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq);
86 pci_pool_free(phba->lpfc_scsi_dma_buf_pool,
87 psb->data, psb->dma_handle);
91 psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP;
93 psb->fcp_cmnd = psb->data;
94 psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd);
95 psb->fcp_bpl = psb->data + sizeof(struct fcp_cmnd) +
96 sizeof(struct fcp_rsp);
98 /* Initialize local short-hand pointers. */
100 pdma_phys = psb->dma_handle;
103 * The first two bdes are the FCP_CMD and FCP_RSP. The balance are sg
104 * list bdes. Initialize the first two and leave the rest for
107 bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys));
108 bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys));
109 bpl->tus.f.bdeSize = sizeof (struct fcp_cmnd);
110 bpl->tus.f.bdeFlags = BUFF_USE_CMND;
111 bpl->tus.w = le32_to_cpu(bpl->tus.w);
114 /* Setup the physical region for the FCP RSP */
115 pdma_phys += sizeof (struct fcp_cmnd);
116 bpl->addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys));
117 bpl->addrLow = le32_to_cpu(putPaddrLow(pdma_phys));
118 bpl->tus.f.bdeSize = sizeof (struct fcp_rsp);
119 bpl->tus.f.bdeFlags = (BUFF_USE_CMND | BUFF_USE_RCV);
120 bpl->tus.w = le32_to_cpu(bpl->tus.w);
123 * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf,
124 * initialize it with all known data now.
126 pdma_phys += (sizeof (struct fcp_rsp));
127 iocb = &psb->cur_iocbq.iocb;
128 iocb->un.fcpi64.bdl.ulpIoTag32 = 0;
129 iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys);
130 iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys);
131 iocb->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64));
132 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDL;
133 iocb->ulpBdeCount = 1;
134 iocb->ulpClass = CLASS3;
139 static struct lpfc_scsi_buf*
140 lpfc_get_scsi_buf(struct lpfc_hba * phba)
142 struct lpfc_scsi_buf * lpfc_cmd = NULL;
143 struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list;
144 unsigned long iflag = 0;
146 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
147 list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list);
149 lpfc_cmd->seg_cnt = 0;
150 lpfc_cmd->nonsg_phys = 0;
152 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
157 lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)
159 unsigned long iflag = 0;
161 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
163 list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list);
164 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
168 lpfc_scsi_prep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd)
170 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
171 struct scatterlist *sgel = NULL;
172 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
173 struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl;
174 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
176 uint32_t i, num_bde = 0;
177 int datadir = scsi_cmnd->sc_data_direction;
181 * There are three possibilities here - use scatter-gather segment, use
182 * the single mapping, or neither. Start the lpfc command prep by
183 * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
187 if (scsi_cmnd->use_sg) {
189 * The driver stores the segment count returned from pci_map_sg
190 * because this a count of dma-mappings used to map the use_sg
191 * pages. They are not guaranteed to be the same for those
192 * architectures that implement an IOMMU.
194 sgel = (struct scatterlist *)scsi_cmnd->request_buffer;
195 lpfc_cmd->seg_cnt = dma_map_sg(&phba->pcidev->dev, sgel,
196 scsi_cmnd->use_sg, datadir);
197 if (lpfc_cmd->seg_cnt == 0)
200 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
201 printk(KERN_ERR "%s: Too many sg segments from "
202 "dma_map_sg. Config %d, seg_cnt %d",
203 __FUNCTION__, phba->cfg_sg_seg_cnt,
205 dma_unmap_sg(&phba->pcidev->dev, sgel,
206 lpfc_cmd->seg_cnt, datadir);
211 * The driver established a maximum scatter-gather segment count
212 * during probe that limits the number of sg elements in any
213 * single scsi command. Just run through the seg_cnt and format
216 for (i = 0; i < lpfc_cmd->seg_cnt; i++) {
217 physaddr = sg_dma_address(sgel);
218 bpl->addrLow = le32_to_cpu(putPaddrLow(physaddr));
219 bpl->addrHigh = le32_to_cpu(putPaddrHigh(physaddr));
220 bpl->tus.f.bdeSize = sg_dma_len(sgel);
221 if (datadir == DMA_TO_DEVICE)
222 bpl->tus.f.bdeFlags = 0;
224 bpl->tus.f.bdeFlags = BUFF_USE_RCV;
225 bpl->tus.w = le32_to_cpu(bpl->tus.w);
230 } else if (scsi_cmnd->request_buffer && scsi_cmnd->request_bufflen) {
231 physaddr = dma_map_single(&phba->pcidev->dev,
232 scsi_cmnd->request_buffer,
233 scsi_cmnd->request_bufflen,
235 dma_error = dma_mapping_error(physaddr);
237 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
238 "%d:0718 Unable to dma_map_single "
239 "request_buffer: x%x\n",
240 phba->brd_no, dma_error);
244 lpfc_cmd->nonsg_phys = physaddr;
245 bpl->addrLow = le32_to_cpu(putPaddrLow(physaddr));
246 bpl->addrHigh = le32_to_cpu(putPaddrHigh(physaddr));
247 bpl->tus.f.bdeSize = scsi_cmnd->request_bufflen;
248 if (datadir == DMA_TO_DEVICE)
249 bpl->tus.f.bdeFlags = 0;
251 bpl->tus.f.bdeFlags = BUFF_USE_RCV;
252 bpl->tus.w = le32_to_cpu(bpl->tus.w);
258 * Finish initializing those IOCB fields that are dependent on the
259 * scsi_cmnd request_buffer. Note that the bdeSize is explicitly
260 * reinitialized since all iocb memory resources are used many times
261 * for transmit, receive, and continuation bpl's.
263 iocb_cmd->un.fcpi64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64));
264 iocb_cmd->un.fcpi64.bdl.bdeSize +=
265 (num_bde * sizeof (struct ulp_bde64));
266 iocb_cmd->ulpBdeCount = 1;
268 fcp_cmnd->fcpDl = be32_to_cpu(scsi_cmnd->request_bufflen);
273 lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)
276 * There are only two special cases to consider. (1) the scsi command
277 * requested scatter-gather usage or (2) the scsi command allocated
278 * a request buffer, but did not request use_sg. There is a third
279 * case, but it does not require resource deallocation.
281 if ((psb->seg_cnt > 0) && (psb->pCmd->use_sg)) {
282 dma_unmap_sg(&phba->pcidev->dev, psb->pCmd->request_buffer,
283 psb->seg_cnt, psb->pCmd->sc_data_direction);
285 if ((psb->nonsg_phys) && (psb->pCmd->request_bufflen)) {
286 dma_unmap_single(&phba->pcidev->dev, psb->nonsg_phys,
287 psb->pCmd->request_bufflen,
288 psb->pCmd->sc_data_direction);
294 lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
295 struct lpfc_iocbq *rsp_iocb)
297 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
298 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd;
299 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
300 struct lpfc_hba *phba = vport->phba;
301 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
302 uint32_t resp_info = fcprsp->rspStatus2;
303 uint32_t scsi_status = fcprsp->rspStatus3;
305 uint32_t host_status = DID_OK;
307 uint32_t logit = LOG_FCP | LOG_FCP_ERROR;
310 * If this is a task management command, there is no
311 * scsi packet associated with this lpfc_cmd. The driver
314 if (fcpcmd->fcpCntl2) {
319 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
320 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
321 if (snslen > SCSI_SENSE_BUFFERSIZE)
322 snslen = SCSI_SENSE_BUFFERSIZE;
324 if (resp_info & RSP_LEN_VALID)
325 rsplen = be32_to_cpu(fcprsp->rspRspLen);
326 memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
328 lp = (uint32_t *)cmnd->sense_buffer;
330 if (!scsi_status && (resp_info & RESID_UNDER))
333 lpfc_printf_log(phba, KERN_WARNING, logit,
334 "%d:0730 FCP command x%x failed: x%x SNS x%x x%x "
335 "Data: x%x x%x x%x x%x x%x\n",
336 phba->brd_no, cmnd->cmnd[0], scsi_status,
337 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
338 be32_to_cpu(fcprsp->rspResId),
339 be32_to_cpu(fcprsp->rspSnsLen),
340 be32_to_cpu(fcprsp->rspRspLen),
343 if (resp_info & RSP_LEN_VALID) {
344 rsplen = be32_to_cpu(fcprsp->rspRspLen);
345 if ((rsplen != 0 && rsplen != 4 && rsplen != 8) ||
346 (fcprsp->rspInfo3 != RSP_NO_FAILURE)) {
347 host_status = DID_ERROR;
353 if (resp_info & RESID_UNDER) {
354 cmnd->resid = be32_to_cpu(fcprsp->rspResId);
356 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
357 "%d:0716 FCP Read Underrun, expected %d, "
358 "residual %d Data: x%x x%x x%x\n", phba->brd_no,
359 be32_to_cpu(fcpcmd->fcpDl), cmnd->resid,
360 fcpi_parm, cmnd->cmnd[0], cmnd->underflow);
363 * If there is an under run check if under run reported by
364 * storage array is same as the under run reported by HBA.
365 * If this is not same, there is a dropped frame.
367 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) &&
369 (cmnd->resid != fcpi_parm)) {
370 lpfc_printf_log(phba, KERN_WARNING,
371 LOG_FCP | LOG_FCP_ERROR,
372 "%d:0735 FCP Read Check Error and Underrun "
373 "Data: x%x x%x x%x x%x\n", phba->brd_no,
374 be32_to_cpu(fcpcmd->fcpDl),
376 fcpi_parm, cmnd->cmnd[0]);
377 cmnd->resid = cmnd->request_bufflen;
378 host_status = DID_ERROR;
381 * The cmnd->underflow is the minimum number of bytes that must
382 * be transfered for this command. Provided a sense condition
383 * is not present, make sure the actual amount transferred is at
384 * least the underflow value or fail.
386 if (!(resp_info & SNS_LEN_VALID) &&
387 (scsi_status == SAM_STAT_GOOD) &&
388 (cmnd->request_bufflen - cmnd->resid) < cmnd->underflow) {
389 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
390 "%d:0717 FCP command x%x residual "
391 "underrun converted to error "
392 "Data: x%x x%x x%x\n", phba->brd_no,
393 cmnd->cmnd[0], cmnd->request_bufflen,
394 cmnd->resid, cmnd->underflow);
396 host_status = DID_ERROR;
398 } else if (resp_info & RESID_OVER) {
399 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
400 "%d:0720 FCP command x%x residual "
401 "overrun error. Data: x%x x%x \n",
402 phba->brd_no, cmnd->cmnd[0],
403 cmnd->request_bufflen, cmnd->resid);
404 host_status = DID_ERROR;
407 * Check SLI validation that all the transfer was actually done
408 * (fcpi_parm should be zero). Apply check only to reads.
410 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
411 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
412 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
413 "%d:0734 FCP Read Check Error Data: "
414 "x%x x%x x%x x%x\n", phba->brd_no,
415 be32_to_cpu(fcpcmd->fcpDl),
416 be32_to_cpu(fcprsp->rspResId),
417 fcpi_parm, cmnd->cmnd[0]);
418 host_status = DID_ERROR;
419 cmnd->resid = cmnd->request_bufflen;
423 cmnd->result = ScsiResult(host_status, scsi_status);
427 lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
428 struct lpfc_iocbq *pIocbOut)
430 struct lpfc_scsi_buf *lpfc_cmd =
431 (struct lpfc_scsi_buf *) pIocbIn->context1;
432 struct lpfc_vport *vport = pIocbIn->vport;
433 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
434 struct lpfc_nodelist *pnode = rdata->pnode;
435 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
437 struct scsi_device *sdev, *tmp_sdev;
440 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4];
441 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
443 if (lpfc_cmd->status) {
444 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
445 (lpfc_cmd->result & IOERR_DRVR_MASK))
446 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
447 else if (lpfc_cmd->status >= IOSTAT_CNT)
448 lpfc_cmd->status = IOSTAT_DEFAULT;
450 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
451 "%d:0729 FCP cmd x%x failed <%d/%d> status: "
452 "x%x result: x%x Data: x%x x%x\n",
453 phba->brd_no, cmd->cmnd[0], cmd->device->id,
454 cmd->device->lun, lpfc_cmd->status,
455 lpfc_cmd->result, pIocbOut->iocb.ulpContext,
456 lpfc_cmd->cur_iocbq.iocb.ulpIoTag);
458 switch (lpfc_cmd->status) {
459 case IOSTAT_FCP_RSP_ERROR:
460 /* Call FCP RSP handler to determine result */
461 lpfc_handle_fcp_err(vport, lpfc_cmd, pIocbOut);
463 case IOSTAT_NPORT_BSY:
464 case IOSTAT_FABRIC_BSY:
465 cmd->result = ScsiResult(DID_BUS_BUSY, 0);
468 cmd->result = ScsiResult(DID_ERROR, 0);
473 || (pnode->nlp_state != NLP_STE_MAPPED_NODE))
474 cmd->result = ScsiResult(DID_BUS_BUSY, SAM_STAT_BUSY);
476 cmd->result = ScsiResult(DID_OK, 0);
479 if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
480 uint32_t *lp = (uint32_t *)cmd->sense_buffer;
482 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
483 "%d:0710 Iodone <%d/%d> cmd %p, error x%x "
484 "SNS x%x x%x Data: x%x x%x\n",
485 phba->brd_no, cmd->device->id,
486 cmd->device->lun, cmd, cmd->result,
487 *lp, *(lp + 3), cmd->retries, cmd->resid);
490 result = cmd->result;
492 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
495 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
496 lpfc_release_scsi_buf(phba, lpfc_cmd);
500 if (!result && pnode != NULL &&
501 ((jiffies - pnode->last_ramp_up_time) >
502 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
503 ((jiffies - pnode->last_q_full_time) >
504 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
505 (phba->cfg_lun_queue_depth > sdev->queue_depth)) {
506 shost_for_each_device(tmp_sdev, sdev->host) {
507 if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) {
508 if (tmp_sdev->id != sdev->id)
510 if (tmp_sdev->ordered_tags)
511 scsi_adjust_queue_depth(tmp_sdev,
513 tmp_sdev->queue_depth+1);
515 scsi_adjust_queue_depth(tmp_sdev,
517 tmp_sdev->queue_depth+1);
519 pnode->last_ramp_up_time = jiffies;
525 * Check for queue full. If the lun is reporting queue full, then
526 * back off the lun queue depth to prevent target overloads.
528 if (result == SAM_STAT_TASK_SET_FULL && pnode != NULL) {
529 pnode->last_q_full_time = jiffies;
531 shost_for_each_device(tmp_sdev, sdev->host) {
532 if (tmp_sdev->id != sdev->id)
534 depth = scsi_track_queue_full(tmp_sdev,
535 tmp_sdev->queue_depth - 1);
538 * The queue depth cannot be lowered any more.
539 * Modify the returned error code to store
540 * the final depth value set by
541 * scsi_track_queue_full.
544 depth = sdev->host->cmd_per_lun;
547 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
548 "%d:0711 detected queue full - lun queue depth "
549 " adjusted to %d.\n", phba->brd_no, depth);
553 lpfc_release_scsi_buf(phba, lpfc_cmd);
557 lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
558 struct lpfc_nodelist *pnode)
560 struct lpfc_hba *phba = vport->phba;
561 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
562 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
563 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
564 struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq);
565 int datadir = scsi_cmnd->sc_data_direction;
567 lpfc_cmd->fcp_rsp->rspSnsLen = 0;
568 /* clear task management bits */
569 lpfc_cmd->fcp_cmnd->fcpCntl2 = 0;
571 int_to_scsilun(lpfc_cmd->pCmd->device->lun,
572 &lpfc_cmd->fcp_cmnd->fcp_lun);
574 memcpy(&fcp_cmnd->fcpCdb[0], scsi_cmnd->cmnd, 16);
576 if (scsi_cmnd->device->tagged_supported) {
577 switch (scsi_cmnd->tag) {
578 case HEAD_OF_QUEUE_TAG:
579 fcp_cmnd->fcpCntl1 = HEAD_OF_Q;
581 case ORDERED_QUEUE_TAG:
582 fcp_cmnd->fcpCntl1 = ORDERED_Q;
585 fcp_cmnd->fcpCntl1 = SIMPLE_Q;
589 fcp_cmnd->fcpCntl1 = 0;
592 * There are three possibilities here - use scatter-gather segment, use
593 * the single mapping, or neither. Start the lpfc command prep by
594 * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
597 if (scsi_cmnd->use_sg) {
598 if (datadir == DMA_TO_DEVICE) {
599 iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR;
600 iocb_cmd->un.fcpi.fcpi_parm = 0;
602 fcp_cmnd->fcpCntl3 = WRITE_DATA;
603 phba->fc4OutputRequests++;
605 iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR;
606 iocb_cmd->ulpPU = PARM_READ_CHECK;
607 iocb_cmd->un.fcpi.fcpi_parm =
608 scsi_cmnd->request_bufflen;
609 fcp_cmnd->fcpCntl3 = READ_DATA;
610 phba->fc4InputRequests++;
612 } else if (scsi_cmnd->request_buffer && scsi_cmnd->request_bufflen) {
613 if (datadir == DMA_TO_DEVICE) {
614 iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR;
615 iocb_cmd->un.fcpi.fcpi_parm = 0;
617 fcp_cmnd->fcpCntl3 = WRITE_DATA;
618 phba->fc4OutputRequests++;
620 iocb_cmd->ulpCommand = CMD_FCP_IREAD64_CR;
621 iocb_cmd->ulpPU = PARM_READ_CHECK;
622 iocb_cmd->un.fcpi.fcpi_parm =
623 scsi_cmnd->request_bufflen;
624 fcp_cmnd->fcpCntl3 = READ_DATA;
625 phba->fc4InputRequests++;
628 iocb_cmd->ulpCommand = CMD_FCP_ICMND64_CR;
629 iocb_cmd->un.fcpi.fcpi_parm = 0;
631 fcp_cmnd->fcpCntl3 = 0;
632 phba->fc4ControlRequests++;
636 * Finish initializing those IOCB fields that are independent
637 * of the scsi_cmnd request_buffer
639 piocbq->iocb.ulpContext = pnode->nlp_rpi;
640 if (pnode->nlp_fcp_info & NLP_FCP_2_DEVICE)
641 piocbq->iocb.ulpFCP2Rcvy = 1;
643 piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f);
644 piocbq->context1 = lpfc_cmd;
645 piocbq->iocb_cmpl = lpfc_scsi_cmd_iocb_cmpl;
646 piocbq->iocb.ulpTimeout = lpfc_cmd->timeout;
647 piocbq->vport = vport;
651 lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
652 struct lpfc_scsi_buf *lpfc_cmd,
654 uint8_t task_mgmt_cmd)
656 struct lpfc_iocbq *piocbq;
658 struct fcp_cmnd *fcp_cmnd;
659 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
660 struct lpfc_nodelist *ndlp = rdata->pnode;
662 if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) {
666 piocbq = &(lpfc_cmd->cur_iocbq);
667 piocbq->vport = vport;
669 piocb = &piocbq->iocb;
671 fcp_cmnd = lpfc_cmd->fcp_cmnd;
672 int_to_scsilun(lun, &lpfc_cmd->fcp_cmnd->fcp_lun);
673 fcp_cmnd->fcpCntl2 = task_mgmt_cmd;
675 piocb->ulpCommand = CMD_FCP_ICMND64_CR;
677 piocb->ulpContext = ndlp->nlp_rpi;
678 if (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) {
679 piocb->ulpFCP2Rcvy = 1;
681 piocb->ulpClass = (ndlp->nlp_fcp_info & 0x0f);
683 /* ulpTimeout is only one byte */
684 if (lpfc_cmd->timeout > 0xff) {
686 * Do not timeout the command at the firmware level.
687 * The driver will provide the timeout mechanism.
689 piocb->ulpTimeout = 0;
691 piocb->ulpTimeout = lpfc_cmd->timeout;
698 lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,
699 struct lpfc_iocbq *cmdiocbq,
700 struct lpfc_iocbq *rspiocbq)
702 struct lpfc_scsi_buf *lpfc_cmd =
703 (struct lpfc_scsi_buf *) cmdiocbq->context1;
705 lpfc_release_scsi_buf(phba, lpfc_cmd);
710 lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,
711 unsigned tgt_id, unsigned int lun,
712 struct lpfc_rport_data *rdata)
714 struct lpfc_hba *phba = vport->phba;
715 struct lpfc_iocbq *iocbq;
716 struct lpfc_iocbq *iocbqrsp;
722 lpfc_cmd->rdata = rdata;
723 ret = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun,
728 iocbq = &lpfc_cmd->cur_iocbq;
729 iocbqrsp = lpfc_sli_get_iocbq(phba);
734 /* Issue Target Reset to TGT <num> */
735 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
736 "%d:0702 Issue Target Reset to TGT %d "
738 phba->brd_no, tgt_id, rdata->pnode->nlp_rpi,
739 rdata->pnode->nlp_flag);
741 ret = lpfc_sli_issue_iocb_wait(phba,
742 &phba->sli.ring[phba->sli.fcp_ring],
743 iocbq, iocbqrsp, lpfc_cmd->timeout);
744 if (ret != IOCB_SUCCESS) {
745 if (ret == IOCB_TIMEDOUT)
746 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
747 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
750 lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4];
751 lpfc_cmd->status = iocbqrsp->iocb.ulpStatus;
752 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
753 (lpfc_cmd->result & IOERR_DRVR_MASK))
754 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
757 lpfc_sli_release_iocbq(phba, iocbqrsp);
762 lpfc_info(struct Scsi_Host *host)
764 struct lpfc_vport *vport = (struct lpfc_vport *) host->hostdata;
765 struct lpfc_hba *phba = vport->phba;
767 static char lpfcinfobuf[384];
769 memset(lpfcinfobuf,0,384);
770 if (phba && phba->pcidev){
771 strncpy(lpfcinfobuf, phba->ModelDesc, 256);
772 len = strlen(lpfcinfobuf);
773 snprintf(lpfcinfobuf + len,
775 " on PCI bus %02x device %02x irq %d",
776 phba->pcidev->bus->number,
779 len = strlen(lpfcinfobuf);
781 snprintf(lpfcinfobuf + len,
790 static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba)
792 unsigned long poll_tmo_expires =
793 (jiffies + msecs_to_jiffies(phba->cfg_poll_tmo));
795 if (phba->sli.ring[LPFC_FCP_RING].txcmplq_cnt)
796 mod_timer(&phba->fcp_poll_timer,
800 void lpfc_poll_start_timer(struct lpfc_hba * phba)
802 lpfc_poll_rearm_timer(phba);
805 void lpfc_poll_timeout(unsigned long ptr)
807 struct lpfc_hba *phba = (struct lpfc_hba *) ptr;
809 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
810 lpfc_sli_poll_fcp_ring (phba);
811 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
812 lpfc_poll_rearm_timer(phba);
817 lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
819 struct Scsi_Host *shost = cmnd->device->host;
820 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
821 struct lpfc_hba *phba = vport->phba;
822 struct lpfc_sli *psli = &phba->sli;
823 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
824 struct lpfc_nodelist *ndlp = rdata->pnode;
825 struct lpfc_scsi_buf *lpfc_cmd;
826 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
829 err = fc_remote_port_chkready(rport);
832 goto out_fail_command;
836 * Catch race where our node has transitioned, but the
837 * transport is still transitioning.
840 cmnd->result = ScsiResult(DID_BUS_BUSY, 0);
841 goto out_fail_command;
843 lpfc_cmd = lpfc_get_scsi_buf(phba);
844 if (lpfc_cmd == NULL) {
845 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
846 "%d:0707 driver's buffer pool is empty, "
847 "IO busied\n", phba->brd_no);
852 * Store the midlayer's command structure for the completion phase
853 * and complete the command initialization.
855 lpfc_cmd->pCmd = cmnd;
856 lpfc_cmd->rdata = rdata;
857 lpfc_cmd->timeout = 0;
858 cmnd->host_scribble = (unsigned char *)lpfc_cmd;
859 cmnd->scsi_done = done;
861 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
863 goto out_host_busy_free_buf;
865 lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp);
867 err = lpfc_sli_issue_iocb(phba, &phba->sli.ring[psli->fcp_ring],
868 &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB);
870 goto out_host_busy_free_buf;
872 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
873 lpfc_sli_poll_fcp_ring(phba);
874 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
875 lpfc_poll_rearm_timer(phba);
880 out_host_busy_free_buf:
881 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
882 lpfc_release_scsi_buf(phba, lpfc_cmd);
884 return SCSI_MLQUEUE_HOST_BUSY;
892 lpfc_block_error_handler(struct scsi_cmnd *cmnd)
894 struct Scsi_Host *shost = cmnd->device->host;
895 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
897 spin_lock_irq(shost->host_lock);
898 while (rport->port_state == FC_PORTSTATE_BLOCKED) {
899 spin_unlock_irq(shost->host_lock);
901 spin_lock_irq(shost->host_lock);
903 spin_unlock_irq(shost->host_lock);
908 lpfc_abort_handler(struct scsi_cmnd *cmnd)
910 struct Scsi_Host *shost = cmnd->device->host;
911 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
912 struct lpfc_hba *phba = vport->phba;
913 struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring];
914 struct lpfc_iocbq *iocb;
915 struct lpfc_iocbq *abtsiocb;
916 struct lpfc_scsi_buf *lpfc_cmd;
918 unsigned int loop_count = 0;
921 lpfc_block_error_handler(cmnd);
922 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
926 * If pCmd field of the corresponding lpfc_scsi_buf structure
927 * points to a different SCSI command, then the driver has
928 * already completed this command, but the midlayer did not
929 * see the completion before the eh fired. Just return
932 iocb = &lpfc_cmd->cur_iocbq;
933 if (lpfc_cmd->pCmd != cmnd)
936 BUG_ON(iocb->context1 != lpfc_cmd);
938 abtsiocb = lpfc_sli_get_iocbq(phba);
939 if (abtsiocb == NULL) {
945 * The scsi command can not be in txq and it is in flight because the
946 * pCmd is still pointig at the SCSI command we have to abort. There
947 * is no need to search the txcmplq. Just send an abort to the FW.
951 icmd = &abtsiocb->iocb;
952 icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
953 icmd->un.acxri.abortContextTag = cmd->ulpContext;
954 icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
957 icmd->ulpClass = cmd->ulpClass;
958 if (lpfc_is_link_up(phba))
959 icmd->ulpCommand = CMD_ABORT_XRI_CN;
961 icmd->ulpCommand = CMD_CLOSE_XRI_CN;
963 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;
964 abtsiocb->vport = vport;
965 if (lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0) == IOCB_ERROR) {
966 lpfc_sli_release_iocbq(phba, abtsiocb);
971 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
972 lpfc_sli_poll_fcp_ring (phba);
974 /* Wait for abort to complete */
975 while (lpfc_cmd->pCmd == cmnd)
977 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
978 lpfc_sli_poll_fcp_ring (phba);
980 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ);
982 > (2 * phba->cfg_devloss_tmo)/LPFC_ABORT_WAIT)
986 if (lpfc_cmd->pCmd == cmnd) {
988 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
989 "%d:0748 abort handler timed out waiting for "
990 "abort to complete: ret %#x, ID %d, LUN %d, "
992 phba->brd_no, ret, cmnd->device->id,
993 cmnd->device->lun, cmnd->serial_number);
997 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
998 "%d:0749 SCSI Layer I/O Abort Request "
999 "Status x%x ID %d LUN %d snum %#lx\n",
1000 phba->brd_no, ret, cmnd->device->id,
1001 cmnd->device->lun, cmnd->serial_number);
1007 lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1009 struct Scsi_Host *shost = cmnd->device->host;
1010 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1011 struct lpfc_hba *phba = vport->phba;
1012 struct lpfc_scsi_buf *lpfc_cmd;
1013 struct lpfc_iocbq *iocbq, *iocbqrsp;
1014 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
1015 struct lpfc_nodelist *pnode = rdata->pnode;
1016 uint32_t cmd_result = 0, cmd_status = 0;
1018 int iocb_status = IOCB_SUCCESS;
1021 lpfc_block_error_handler(cmnd);
1024 * If target is not in a MAPPED state, delay the reset until
1025 * target is rediscovered or devloss timeout expires.
1031 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
1032 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
1034 rdata = cmnd->device->hostdata;
1036 (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) {
1037 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1038 "%d:0721 LUN Reset rport failure:"
1039 " cnt x%x rdata x%p\n",
1040 phba->brd_no, loopcnt, rdata);
1043 pnode = rdata->pnode;
1047 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
1051 lpfc_cmd = lpfc_get_scsi_buf(phba);
1052 if (lpfc_cmd == NULL)
1055 lpfc_cmd->timeout = 60;
1056 lpfc_cmd->rdata = rdata;
1058 ret = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, cmnd->device->lun,
1061 goto out_free_scsi_buf;
1063 iocbq = &lpfc_cmd->cur_iocbq;
1065 /* get a buffer for this IOCB command response */
1066 iocbqrsp = lpfc_sli_get_iocbq(phba);
1067 if (iocbqrsp == NULL)
1068 goto out_free_scsi_buf;
1070 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
1071 "%d:0703 Issue target reset to TGT %d LUN %d rpi x%x "
1072 "nlp_flag x%x\n", phba->brd_no, cmnd->device->id,
1073 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1075 iocb_status = lpfc_sli_issue_iocb_wait(phba,
1076 &phba->sli.ring[phba->sli.fcp_ring],
1077 iocbq, iocbqrsp, lpfc_cmd->timeout);
1079 if (iocb_status == IOCB_TIMEDOUT)
1080 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
1082 if (iocb_status == IOCB_SUCCESS)
1087 cmd_result = iocbqrsp->iocb.un.ulpWord[4];
1088 cmd_status = iocbqrsp->iocb.ulpStatus;
1090 lpfc_sli_release_iocbq(phba, iocbqrsp);
1093 * All outstanding txcmplq I/Os should have been aborted by the device.
1094 * Unfortunately, some targets do not abide by this forcing the driver
1097 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1098 cmnd->device->id, cmnd->device->lun,
1101 lpfc_sli_abort_iocb(phba,
1102 &phba->sli.ring[phba->sli.fcp_ring],
1103 cmnd->device->id, cmnd->device->lun,
1107 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1110 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1113 cnt = lpfc_sli_sum_iocb(phba,
1114 &phba->sli.ring[phba->sli.fcp_ring],
1115 cmnd->device->id, cmnd->device->lun,
1120 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1121 "%d:0719 device reset I/O flush failure: cnt x%x\n",
1127 if (iocb_status != IOCB_TIMEDOUT) {
1128 lpfc_release_scsi_buf(phba, lpfc_cmd);
1130 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1131 "%d:0713 SCSI layer issued device reset (%d, %d) "
1132 "return x%x status x%x result x%x\n",
1133 phba->brd_no, cmnd->device->id, cmnd->device->lun,
1134 ret, cmd_status, cmd_result);
1141 lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1143 struct Scsi_Host *shost = cmnd->device->host;
1144 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1145 struct lpfc_hba *phba = vport->phba;
1146 struct lpfc_nodelist *ndlp = NULL;
1148 int ret = FAILED, i, err_count = 0;
1150 struct lpfc_scsi_buf * lpfc_cmd;
1152 lpfc_block_error_handler(cmnd);
1154 lpfc_cmd = lpfc_get_scsi_buf(phba);
1155 if (lpfc_cmd == NULL)
1158 /* The lpfc_cmd storage is reused. Set all loop invariants. */
1159 lpfc_cmd->timeout = 60;
1162 * Since the driver manages a single bus device, reset all
1163 * targets known to the driver. Should any target reset
1164 * fail, this routine returns failure to the midlayer.
1166 for (i = 0; i < LPFC_MAX_TARGET; i++) {
1167 /* Search for mapped node by target ID */
1169 spin_lock_irq(shost->host_lock);
1170 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
1171 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
1172 i == ndlp->nlp_sid &&
1178 spin_unlock_irq(shost->host_lock);
1182 ret = lpfc_scsi_tgt_reset(lpfc_cmd, vport, i,
1184 ndlp->rport->dd_data);
1185 if (ret != SUCCESS) {
1186 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1187 "%d:0700 Bus Reset on target %d failed\n",
1194 if (ret != IOCB_TIMEDOUT)
1195 lpfc_release_scsi_buf(phba, lpfc_cmd);
1203 * All outstanding txcmplq I/Os should have been aborted by
1204 * the targets. Unfortunately, some targets do not abide by
1205 * this forcing the driver to double check.
1207 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1208 0, 0, LPFC_CTX_HOST);
1210 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1211 0, 0, 0, LPFC_CTX_HOST);
1214 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1217 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1220 cnt = lpfc_sli_sum_iocb(phba,
1221 &phba->sli.ring[phba->sli.fcp_ring],
1222 0, 0, LPFC_CTX_HOST);
1226 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1227 "%d:0715 Bus Reset I/O flush failure: cnt x%x left x%x\n",
1228 phba->brd_no, cnt, i);
1232 lpfc_printf_log(phba,
1235 "%d:0714 SCSI layer issued Bus Reset Data: x%x\n",
1242 lpfc_slave_alloc(struct scsi_device *sdev)
1244 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
1245 struct lpfc_hba *phba = vport->phba;
1246 struct lpfc_scsi_buf *scsi_buf = NULL;
1247 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
1248 uint32_t total = 0, i;
1249 uint32_t num_to_alloc = 0;
1250 unsigned long flags;
1252 if (!rport || fc_remote_port_chkready(rport))
1255 sdev->hostdata = rport->dd_data;
1258 * Populate the cmds_per_lun count scsi_bufs into this host's globally
1259 * available list of scsi buffers. Don't allocate more than the
1260 * HBA limit conveyed to the midlayer via the host structure. The
1261 * formula accounts for the lun_queue_depth + error handlers + 1
1262 * extra. This list of scsi bufs exists for the lifetime of the driver.
1264 total = phba->total_scsi_bufs;
1265 num_to_alloc = phba->cfg_lun_queue_depth + 2;
1266 if (total >= phba->cfg_hba_queue_depth) {
1267 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
1268 "%d:0704 At limitation of %d preallocated "
1269 "command buffers\n", phba->brd_no, total);
1271 } else if (total + num_to_alloc > phba->cfg_hba_queue_depth) {
1272 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
1273 "%d:0705 Allocation request of %d command "
1274 "buffers will exceed max of %d. Reducing "
1275 "allocation request to %d.\n", phba->brd_no,
1276 num_to_alloc, phba->cfg_hba_queue_depth,
1277 (phba->cfg_hba_queue_depth - total));
1278 num_to_alloc = phba->cfg_hba_queue_depth - total;
1281 for (i = 0; i < num_to_alloc; i++) {
1282 scsi_buf = lpfc_new_scsi_buf(vport);
1284 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1285 "%d:0706 Failed to allocate command "
1286 "buffer\n", phba->brd_no);
1290 spin_lock_irqsave(&phba->scsi_buf_list_lock, flags);
1291 phba->total_scsi_bufs++;
1292 list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list);
1293 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, flags);
1299 lpfc_slave_configure(struct scsi_device *sdev)
1301 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
1302 struct lpfc_hba *phba = vport->phba;
1303 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1305 if (sdev->tagged_supported)
1306 scsi_activate_tcq(sdev, phba->cfg_lun_queue_depth);
1308 scsi_deactivate_tcq(sdev, phba->cfg_lun_queue_depth);
1311 * Initialize the fc transport attributes for the target
1312 * containing this scsi device. Also note that the driver's
1313 * target pointer is stored in the starget_data for the
1314 * driver's sysfs entry point functions.
1316 rport->dev_loss_tmo = phba->cfg_devloss_tmo;
1318 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
1319 lpfc_sli_poll_fcp_ring(phba);
1320 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
1321 lpfc_poll_rearm_timer(phba);
1328 lpfc_slave_destroy(struct scsi_device *sdev)
1330 sdev->hostdata = NULL;
1334 struct scsi_host_template lpfc_template = {
1335 .module = THIS_MODULE,
1336 .name = LPFC_DRIVER_NAME,
1338 .queuecommand = lpfc_queuecommand,
1339 .eh_abort_handler = lpfc_abort_handler,
1340 .eh_device_reset_handler= lpfc_device_reset_handler,
1341 .eh_bus_reset_handler = lpfc_bus_reset_handler,
1342 .slave_alloc = lpfc_slave_alloc,
1343 .slave_configure = lpfc_slave_configure,
1344 .slave_destroy = lpfc_slave_destroy,
1345 .scan_finished = lpfc_scan_finished,
1346 .scan_start = lpfc_scan_start,
1348 .sg_tablesize = LPFC_SG_SEG_CNT,
1349 .cmd_per_lun = LPFC_CMD_PER_LUN,
1350 .use_clustering = ENABLE_CLUSTERING,
1351 .shost_attrs = lpfc_hba_attrs,
1352 .max_sectors = 0xFFFF,