aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c1329
1 files changed, 980 insertions, 349 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 167b66dd34c7..da59c4f0168f 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2008 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2009 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -31,8 +31,10 @@
31#include <scsi/scsi_transport_fc.h> 31#include <scsi/scsi_transport_fc.h>
32 32
33#include "lpfc_version.h" 33#include "lpfc_version.h"
34#include "lpfc_hw4.h"
34#include "lpfc_hw.h" 35#include "lpfc_hw.h"
35#include "lpfc_sli.h" 36#include "lpfc_sli.h"
37#include "lpfc_sli4.h"
36#include "lpfc_nl.h" 38#include "lpfc_nl.h"
37#include "lpfc_disc.h" 39#include "lpfc_disc.h"
38#include "lpfc_scsi.h" 40#include "lpfc_scsi.h"
@@ -57,6 +59,8 @@ static char *dif_op_str[] = {
57 "SCSI_PROT_READ_CONVERT", 59 "SCSI_PROT_READ_CONVERT",
58 "SCSI_PROT_WRITE_CONVERT" 60 "SCSI_PROT_WRITE_CONVERT"
59}; 61};
62static void
63lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
60 64
61static void 65static void
62lpfc_debug_save_data(struct scsi_cmnd *cmnd) 66lpfc_debug_save_data(struct scsi_cmnd *cmnd)
@@ -112,6 +116,27 @@ lpfc_debug_save_dif(struct scsi_cmnd *cmnd)
112} 116}
113 117
114/** 118/**
119 * lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge.
120 * @phba: Pointer to HBA object.
121 * @lpfc_cmd: lpfc scsi command object pointer.
122 *
123 * This function is called from the lpfc_prep_task_mgmt_cmd function to
124 * set the last bit in the response sge entry.
125 **/
126static void
127lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
128 struct lpfc_scsi_buf *lpfc_cmd)
129{
130 struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl;
131 if (sgl) {
132 sgl += 1;
133 sgl->word2 = le32_to_cpu(sgl->word2);
134 bf_set(lpfc_sli4_sge_last, sgl, 1);
135 sgl->word2 = cpu_to_le32(sgl->word2);
136 }
137}
138
139/**
115 * lpfc_update_stats - Update statistical data for the command completion 140 * lpfc_update_stats - Update statistical data for the command completion
116 * @phba: Pointer to HBA object. 141 * @phba: Pointer to HBA object.
117 * @lpfc_cmd: lpfc scsi command object pointer. 142 * @lpfc_cmd: lpfc scsi command object pointer.
@@ -325,7 +350,7 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
325 350
326 vports = lpfc_create_vport_work_array(phba); 351 vports = lpfc_create_vport_work_array(phba);
327 if (vports != NULL) 352 if (vports != NULL)
328 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { 353 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
329 shost = lpfc_shost_from_vport(vports[i]); 354 shost = lpfc_shost_from_vport(vports[i]);
330 shost_for_each_device(sdev, shost) { 355 shost_for_each_device(sdev, shost) {
331 new_queue_depth = 356 new_queue_depth =
@@ -379,7 +404,7 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
379 404
380 vports = lpfc_create_vport_work_array(phba); 405 vports = lpfc_create_vport_work_array(phba);
381 if (vports != NULL) 406 if (vports != NULL)
382 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { 407 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
383 shost = lpfc_shost_from_vport(vports[i]); 408 shost = lpfc_shost_from_vport(vports[i]);
384 shost_for_each_device(sdev, shost) { 409 shost_for_each_device(sdev, shost) {
385 if (vports[i]->cfg_lun_queue_depth <= 410 if (vports[i]->cfg_lun_queue_depth <=
@@ -427,7 +452,7 @@ lpfc_scsi_dev_block(struct lpfc_hba *phba)
427 452
428 vports = lpfc_create_vport_work_array(phba); 453 vports = lpfc_create_vport_work_array(phba);
429 if (vports != NULL) 454 if (vports != NULL)
430 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { 455 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
431 shost = lpfc_shost_from_vport(vports[i]); 456 shost = lpfc_shost_from_vport(vports[i]);
432 shost_for_each_device(sdev, shost) { 457 shost_for_each_device(sdev, shost) {
433 rport = starget_to_rport(scsi_target(sdev)); 458 rport = starget_to_rport(scsi_target(sdev));
@@ -438,22 +463,23 @@ lpfc_scsi_dev_block(struct lpfc_hba *phba)
438} 463}
439 464
440/** 465/**
441 * lpfc_new_scsi_buf - Scsi buffer allocator 466 * lpfc_new_scsi_buf_s3 - Scsi buffer allocator for HBA with SLI3 IF spec
442 * @vport: The virtual port for which this call being executed. 467 * @vport: The virtual port for which this call being executed.
468 * @num_to_allocate: The requested number of buffers to allocate.
443 * 469 *
444 * This routine allocates a scsi buffer, which contains all the necessary 470 * This routine allocates a scsi buffer for device with SLI-3 interface spec,
445 * information needed to initiate a SCSI I/O. The non-DMAable buffer region 471 * the scsi buffer contains all the necessary information needed to initiate
446 * contains information to build the IOCB. The DMAable region contains 472 * a SCSI I/O. The non-DMAable buffer region contains information to build
447 * memory for the FCP CMND, FCP RSP, and the initial BPL. In addition to 473 * the IOCB. The DMAable region contains memory for the FCP CMND, FCP RSP,
448 * allocating memory, the FCP CMND and FCP RSP BDEs are setup in the BPL 474 * and the initial BPL. In addition to allocating memory, the FCP CMND and
449 * and the BPL BDE is setup in the IOCB. 475 * FCP RSP BDEs are setup in the BPL and the BPL BDE is setup in the IOCB.
450 * 476 *
451 * Return codes: 477 * Return codes:
452 * NULL - Error 478 * int - number of scsi buffers that were allocated.
453 * Pointer to lpfc_scsi_buf data structure - Success 479 * 0 = failure, less than num_to_alloc is a partial failure.
454 **/ 480 **/
455static struct lpfc_scsi_buf * 481static int
456lpfc_new_scsi_buf(struct lpfc_vport *vport) 482lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc)
457{ 483{
458 struct lpfc_hba *phba = vport->phba; 484 struct lpfc_hba *phba = vport->phba;
459 struct lpfc_scsi_buf *psb; 485 struct lpfc_scsi_buf *psb;
@@ -463,107 +489,401 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport)
463 dma_addr_t pdma_phys_fcp_rsp; 489 dma_addr_t pdma_phys_fcp_rsp;
464 dma_addr_t pdma_phys_bpl; 490 dma_addr_t pdma_phys_bpl;
465 uint16_t iotag; 491 uint16_t iotag;
492 int bcnt;
466 493
467 psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); 494 for (bcnt = 0; bcnt < num_to_alloc; bcnt++) {
468 if (!psb) 495 psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
469 return NULL; 496 if (!psb)
497 break;
498
499 /*
500 * Get memory from the pci pool to map the virt space to pci
501 * bus space for an I/O. The DMA buffer includes space for the
502 * struct fcp_cmnd, struct fcp_rsp and the number of bde's
503 * necessary to support the sg_tablesize.
504 */
505 psb->data = pci_pool_alloc(phba->lpfc_scsi_dma_buf_pool,
506 GFP_KERNEL, &psb->dma_handle);
507 if (!psb->data) {
508 kfree(psb);
509 break;
510 }
511
512 /* Initialize virtual ptrs to dma_buf region. */
513 memset(psb->data, 0, phba->cfg_sg_dma_buf_size);
514
515 /* Allocate iotag for psb->cur_iocbq. */
516 iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq);
517 if (iotag == 0) {
518 pci_pool_free(phba->lpfc_scsi_dma_buf_pool,
519 psb->data, psb->dma_handle);
520 kfree(psb);
521 break;
522 }
523 psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP;
524
525 psb->fcp_cmnd = psb->data;
526 psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd);
527 psb->fcp_bpl = psb->data + sizeof(struct fcp_cmnd) +
528 sizeof(struct fcp_rsp);
529
530 /* Initialize local short-hand pointers. */
531 bpl = psb->fcp_bpl;
532 pdma_phys_fcp_cmd = psb->dma_handle;
533 pdma_phys_fcp_rsp = psb->dma_handle + sizeof(struct fcp_cmnd);
534 pdma_phys_bpl = psb->dma_handle + sizeof(struct fcp_cmnd) +
535 sizeof(struct fcp_rsp);
536
537 /*
538 * The first two bdes are the FCP_CMD and FCP_RSP. The balance
539 * are sg list bdes. Initialize the first two and leave the
540 * rest for queuecommand.
541 */
542 bpl[0].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_cmd));
543 bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd));
544 bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd);
545 bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64;
546 bpl[0].tus.w = le32_to_cpu(bpl[0].tus.w);
547
548 /* Setup the physical region for the FCP RSP */
549 bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp));
550 bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp));
551 bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp);
552 bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64;
553 bpl[1].tus.w = le32_to_cpu(bpl[1].tus.w);
554
555 /*
556 * Since the IOCB for the FCP I/O is built into this
557 * lpfc_scsi_buf, initialize it with all known data now.
558 */
559 iocb = &psb->cur_iocbq.iocb;
560 iocb->un.fcpi64.bdl.ulpIoTag32 = 0;
561 if ((phba->sli_rev == 3) &&
562 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) {
563 /* fill in immediate fcp command BDE */
564 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_IMMED;
565 iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd);
566 iocb->un.fcpi64.bdl.addrLow = offsetof(IOCB_t,
567 unsli3.fcp_ext.icd);
568 iocb->un.fcpi64.bdl.addrHigh = 0;
569 iocb->ulpBdeCount = 0;
570 iocb->ulpLe = 0;
571 /* fill in responce BDE */
572 iocb->unsli3.fcp_ext.rbde.tus.f.bdeFlags =
573 BUFF_TYPE_BDE_64;
574 iocb->unsli3.fcp_ext.rbde.tus.f.bdeSize =
575 sizeof(struct fcp_rsp);
576 iocb->unsli3.fcp_ext.rbde.addrLow =
577 putPaddrLow(pdma_phys_fcp_rsp);
578 iocb->unsli3.fcp_ext.rbde.addrHigh =
579 putPaddrHigh(pdma_phys_fcp_rsp);
580 } else {
581 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
582 iocb->un.fcpi64.bdl.bdeSize =
583 (2 * sizeof(struct ulp_bde64));
584 iocb->un.fcpi64.bdl.addrLow =
585 putPaddrLow(pdma_phys_bpl);
586 iocb->un.fcpi64.bdl.addrHigh =
587 putPaddrHigh(pdma_phys_bpl);
588 iocb->ulpBdeCount = 1;
589 iocb->ulpLe = 1;
590 }
591 iocb->ulpClass = CLASS3;
592 psb->status = IOSTAT_SUCCESS;
593 /* Put it back into the SCSI buffer list */
594 lpfc_release_scsi_buf_s4(phba, psb);
470 595
471 /*
472 * Get memory from the pci pool to map the virt space to pci bus space
473 * for an I/O. The DMA buffer includes space for the struct fcp_cmnd,
474 * struct fcp_rsp and the number of bde's necessary to support the
475 * sg_tablesize.
476 */
477 psb->data = pci_pool_alloc(phba->lpfc_scsi_dma_buf_pool, GFP_KERNEL,
478 &psb->dma_handle);
479 if (!psb->data) {
480 kfree(psb);
481 return NULL;
482 } 596 }
483 597
484 /* Initialize virtual ptrs to dma_buf region. */ 598 return bcnt;
485 memset(psb->data, 0, phba->cfg_sg_dma_buf_size); 599}
486 600
487 /* Allocate iotag for psb->cur_iocbq. */ 601/**
488 iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq); 602 * lpfc_sli4_fcp_xri_aborted - Fast-path process of fcp xri abort
489 if (iotag == 0) { 603 * @phba: pointer to lpfc hba data structure.
490 pci_pool_free(phba->lpfc_scsi_dma_buf_pool, 604 * @axri: pointer to the fcp xri abort wcqe structure.
491 psb->data, psb->dma_handle); 605 *
492 kfree (psb); 606 * This routine is invoked by the worker thread to process a SLI4 fast-path
493 return NULL; 607 * FCP aborted xri.
608 **/
609void
610lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
611 struct sli4_wcqe_xri_aborted *axri)
612{
613 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
614 struct lpfc_scsi_buf *psb, *next_psb;
615 unsigned long iflag = 0;
616
617 spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock, iflag);
618 list_for_each_entry_safe(psb, next_psb,
619 &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) {
620 if (psb->cur_iocbq.sli4_xritag == xri) {
621 list_del(&psb->list);
622 psb->status = IOSTAT_SUCCESS;
623 spin_unlock_irqrestore(
624 &phba->sli4_hba.abts_scsi_buf_list_lock,
625 iflag);
626 lpfc_release_scsi_buf_s4(phba, psb);
627 return;
628 }
494 } 629 }
495 psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP; 630 spin_unlock_irqrestore(&phba->sli4_hba.abts_scsi_buf_list_lock,
631 iflag);
632}
496 633
497 psb->fcp_cmnd = psb->data; 634/**
498 psb->fcp_rsp = psb->data + sizeof(struct fcp_cmnd); 635 * lpfc_sli4_repost_scsi_sgl_list - Repsot the Scsi buffers sgl pages as block
499 psb->fcp_bpl = psb->data + sizeof(struct fcp_cmnd) + 636 * @phba: pointer to lpfc hba data structure.
500 sizeof(struct fcp_rsp); 637 *
638 * This routine walks the list of scsi buffers that have been allocated and
639 * repost them to the HBA by using SGL block post. This is needed after a
640 * pci_function_reset/warm_start or start. The lpfc_hba_down_post_s4 routine
641 * is responsible for moving all scsi buffers on the lpfc_abts_scsi_sgl_list
642 * to the lpfc_scsi_buf_list. If the repost fails, reject all scsi buffers.
643 *
644 * Returns: 0 = success, non-zero failure.
645 **/
646int
647lpfc_sli4_repost_scsi_sgl_list(struct lpfc_hba *phba)
648{
649 struct lpfc_scsi_buf *psb;
650 int index, status, bcnt = 0, rcnt = 0, rc = 0;
651 LIST_HEAD(sblist);
652
653 for (index = 0; index < phba->sli4_hba.scsi_xri_cnt; index++) {
654 psb = phba->sli4_hba.lpfc_scsi_psb_array[index];
655 if (psb) {
656 /* Remove from SCSI buffer list */
657 list_del(&psb->list);
658 /* Add it to a local SCSI buffer list */
659 list_add_tail(&psb->list, &sblist);
660 if (++rcnt == LPFC_NEMBED_MBOX_SGL_CNT) {
661 bcnt = rcnt;
662 rcnt = 0;
663 }
664 } else
665 /* A hole present in the XRI array, need to skip */
666 bcnt = rcnt;
501 667
502 /* Initialize local short-hand pointers. */ 668 if (index == phba->sli4_hba.scsi_xri_cnt - 1)
503 bpl = psb->fcp_bpl; 669 /* End of XRI array for SCSI buffer, complete */
504 pdma_phys_fcp_cmd = psb->dma_handle; 670 bcnt = rcnt;
505 pdma_phys_fcp_rsp = psb->dma_handle + sizeof(struct fcp_cmnd);
506 pdma_phys_bpl = psb->dma_handle + sizeof(struct fcp_cmnd) +
507 sizeof(struct fcp_rsp);
508 671
509 /* 672 /* Continue until collect up to a nembed page worth of sgls */
510 * The first two bdes are the FCP_CMD and FCP_RSP. The balance are sg 673 if (bcnt == 0)
511 * list bdes. Initialize the first two and leave the rest for 674 continue;
512 * queuecommand. 675 /* Now, post the SCSI buffer list sgls as a block */
513 */ 676 status = lpfc_sli4_post_scsi_sgl_block(phba, &sblist, bcnt);
514 bpl[0].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_cmd)); 677 /* Reset SCSI buffer count for next round of posting */
515 bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd)); 678 bcnt = 0;
516 bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd); 679 while (!list_empty(&sblist)) {
517 bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64; 680 list_remove_head(&sblist, psb, struct lpfc_scsi_buf,
518 bpl[0].tus.w = le32_to_cpu(bpl[0].tus.w); 681 list);
519 682 if (status) {
520 /* Setup the physical region for the FCP RSP */ 683 /* Put this back on the abort scsi list */
521 bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp)); 684 psb->status = IOSTAT_LOCAL_REJECT;
522 bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp)); 685 psb->result = IOERR_ABORT_REQUESTED;
523 bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp); 686 rc++;
524 bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64; 687 } else
525 bpl[1].tus.w = le32_to_cpu(bpl[1].tus.w); 688 psb->status = IOSTAT_SUCCESS;
689 /* Put it back into the SCSI buffer list */
690 lpfc_release_scsi_buf_s4(phba, psb);
691 }
692 }
693 return rc;
694}
526 695
527 /* 696/**
528 * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf, 697 * lpfc_new_scsi_buf_s4 - Scsi buffer allocator for HBA with SLI4 IF spec
529 * initialize it with all known data now. 698 * @vport: The virtual port for which this call being executed.
530 */ 699 * @num_to_allocate: The requested number of buffers to allocate.
531 iocb = &psb->cur_iocbq.iocb; 700 *
532 iocb->un.fcpi64.bdl.ulpIoTag32 = 0; 701 * This routine allocates a scsi buffer for device with SLI-4 interface spec,
533 if ((phba->sli_rev == 3) && 702 * the scsi buffer contains all the necessary information needed to initiate
534 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) { 703 * a SCSI I/O.
535 /* fill in immediate fcp command BDE */ 704 *
536 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_IMMED; 705 * Return codes:
706 * int - number of scsi buffers that were allocated.
707 * 0 = failure, less than num_to_alloc is a partial failure.
708 **/
709static int
710lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc)
711{
712 struct lpfc_hba *phba = vport->phba;
713 struct lpfc_scsi_buf *psb;
714 struct sli4_sge *sgl;
715 IOCB_t *iocb;
716 dma_addr_t pdma_phys_fcp_cmd;
717 dma_addr_t pdma_phys_fcp_rsp;
718 dma_addr_t pdma_phys_bpl, pdma_phys_bpl1;
719 uint16_t iotag, last_xritag = NO_XRI;
720 int status = 0, index;
721 int bcnt;
722 int non_sequential_xri = 0;
723 int rc = 0;
724 LIST_HEAD(sblist);
725
726 for (bcnt = 0; bcnt < num_to_alloc; bcnt++) {
727 psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
728 if (!psb)
729 break;
730
731 /*
732 * Get memory from the pci pool to map the virt space to pci bus
733 * space for an I/O. The DMA buffer includes space for the
734 * struct fcp_cmnd, struct fcp_rsp and the number of bde's
735 * necessary to support the sg_tablesize.
736 */
737 psb->data = pci_pool_alloc(phba->lpfc_scsi_dma_buf_pool,
738 GFP_KERNEL, &psb->dma_handle);
739 if (!psb->data) {
740 kfree(psb);
741 break;
742 }
743
744 /* Initialize virtual ptrs to dma_buf region. */
745 memset(psb->data, 0, phba->cfg_sg_dma_buf_size);
746
747 /* Allocate iotag for psb->cur_iocbq. */
748 iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq);
749 if (iotag == 0) {
750 kfree(psb);
751 break;
752 }
753
754 psb->cur_iocbq.sli4_xritag = lpfc_sli4_next_xritag(phba);
755 if (psb->cur_iocbq.sli4_xritag == NO_XRI) {
756 pci_pool_free(phba->lpfc_scsi_dma_buf_pool,
757 psb->data, psb->dma_handle);
758 kfree(psb);
759 break;
760 }
761 if (last_xritag != NO_XRI
762 && psb->cur_iocbq.sli4_xritag != (last_xritag+1)) {
763 non_sequential_xri = 1;
764 } else
765 list_add_tail(&psb->list, &sblist);
766 last_xritag = psb->cur_iocbq.sli4_xritag;
767
768 index = phba->sli4_hba.scsi_xri_cnt++;
769 psb->cur_iocbq.iocb_flag |= LPFC_IO_FCP;
770
771 psb->fcp_bpl = psb->data;
772 psb->fcp_cmnd = (psb->data + phba->cfg_sg_dma_buf_size)
773 - (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp));
774 psb->fcp_rsp = (struct fcp_rsp *)((uint8_t *)psb->fcp_cmnd +
775 sizeof(struct fcp_cmnd));
776
777 /* Initialize local short-hand pointers. */
778 sgl = (struct sli4_sge *)psb->fcp_bpl;
779 pdma_phys_bpl = psb->dma_handle;
780 pdma_phys_fcp_cmd =
781 (psb->dma_handle + phba->cfg_sg_dma_buf_size)
782 - (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp));
783 pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof(struct fcp_cmnd);
784
785 /*
786 * The first two bdes are the FCP_CMD and FCP_RSP. The balance
787 * are sg list bdes. Initialize the first two and leave the
788 * rest for queuecommand.
789 */
790 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd));
791 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd));
792 bf_set(lpfc_sli4_sge_len, sgl, sizeof(struct fcp_cmnd));
793 bf_set(lpfc_sli4_sge_last, sgl, 0);
794 sgl->word2 = cpu_to_le32(sgl->word2);
795 sgl->word3 = cpu_to_le32(sgl->word3);
796 sgl++;
797
798 /* Setup the physical region for the FCP RSP */
799 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp));
800 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp));
801 bf_set(lpfc_sli4_sge_len, sgl, sizeof(struct fcp_rsp));
802 bf_set(lpfc_sli4_sge_last, sgl, 1);
803 sgl->word2 = cpu_to_le32(sgl->word2);
804 sgl->word3 = cpu_to_le32(sgl->word3);
805
806 /*
807 * Since the IOCB for the FCP I/O is built into this
808 * lpfc_scsi_buf, initialize it with all known data now.
809 */
810 iocb = &psb->cur_iocbq.iocb;
811 iocb->un.fcpi64.bdl.ulpIoTag32 = 0;
812 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BDE_64;
813 /* setting the BLP size to 2 * sizeof BDE may not be correct.
814 * We are setting the bpl to point to out sgl. An sgl's
815 * entries are 16 bytes, a bpl entries are 12 bytes.
816 */
537 iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd); 817 iocb->un.fcpi64.bdl.bdeSize = sizeof(struct fcp_cmnd);
538 iocb->un.fcpi64.bdl.addrLow = offsetof(IOCB_t, 818 iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_fcp_cmd);
539 unsli3.fcp_ext.icd); 819 iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_fcp_cmd);
540 iocb->un.fcpi64.bdl.addrHigh = 0;
541 iocb->ulpBdeCount = 0;
542 iocb->ulpLe = 0;
543 /* fill in responce BDE */
544 iocb->unsli3.fcp_ext.rbde.tus.f.bdeFlags = BUFF_TYPE_BDE_64;
545 iocb->unsli3.fcp_ext.rbde.tus.f.bdeSize =
546 sizeof(struct fcp_rsp);
547 iocb->unsli3.fcp_ext.rbde.addrLow =
548 putPaddrLow(pdma_phys_fcp_rsp);
549 iocb->unsli3.fcp_ext.rbde.addrHigh =
550 putPaddrHigh(pdma_phys_fcp_rsp);
551 } else {
552 iocb->un.fcpi64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
553 iocb->un.fcpi64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64));
554 iocb->un.fcpi64.bdl.addrLow = putPaddrLow(pdma_phys_bpl);
555 iocb->un.fcpi64.bdl.addrHigh = putPaddrHigh(pdma_phys_bpl);
556 iocb->ulpBdeCount = 1; 820 iocb->ulpBdeCount = 1;
557 iocb->ulpLe = 1; 821 iocb->ulpLe = 1;
822 iocb->ulpClass = CLASS3;
823 if (phba->cfg_sg_dma_buf_size > SGL_PAGE_SIZE)
824 pdma_phys_bpl1 = pdma_phys_bpl + SGL_PAGE_SIZE;
825 else
826 pdma_phys_bpl1 = 0;
827 psb->dma_phys_bpl = pdma_phys_bpl;
828 phba->sli4_hba.lpfc_scsi_psb_array[index] = psb;
829 if (non_sequential_xri) {
830 status = lpfc_sli4_post_sgl(phba, pdma_phys_bpl,
831 pdma_phys_bpl1,
832 psb->cur_iocbq.sli4_xritag);
833 if (status) {
834 /* Put this back on the abort scsi list */
835 psb->status = IOSTAT_LOCAL_REJECT;
836 psb->result = IOERR_ABORT_REQUESTED;
837 rc++;
838 } else
839 psb->status = IOSTAT_SUCCESS;
840 /* Put it back into the SCSI buffer list */
841 lpfc_release_scsi_buf_s4(phba, psb);
842 break;
843 }
844 }
845 if (bcnt) {
846 status = lpfc_sli4_post_scsi_sgl_block(phba, &sblist, bcnt);
847 /* Reset SCSI buffer count for next round of posting */
848 while (!list_empty(&sblist)) {
849 list_remove_head(&sblist, psb, struct lpfc_scsi_buf,
850 list);
851 if (status) {
852 /* Put this back on the abort scsi list */
853 psb->status = IOSTAT_LOCAL_REJECT;
854 psb->result = IOERR_ABORT_REQUESTED;
855 rc++;
856 } else
857 psb->status = IOSTAT_SUCCESS;
858 /* Put it back into the SCSI buffer list */
859 lpfc_release_scsi_buf_s4(phba, psb);
860 }
558 } 861 }
559 iocb->ulpClass = CLASS3;
560 862
561 return psb; 863 return bcnt + non_sequential_xri - rc;
562} 864}
563 865
564/** 866/**
565 * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list list of Hba 867 * lpfc_new_scsi_buf - Wrapper funciton for scsi buffer allocator
566 * @phba: The Hba for which this call is being executed. 868 * @vport: The virtual port for which this call being executed.
869 * @num_to_allocate: The requested number of buffers to allocate.
870 *
871 * This routine wraps the actual SCSI buffer allocator function pointer from
872 * the lpfc_hba struct.
873 *
874 * Return codes:
875 * int - number of scsi buffers that were allocated.
876 * 0 = failure, less than num_to_alloc is a partial failure.
877 **/
878static inline int
879lpfc_new_scsi_buf(struct lpfc_vport *vport, int num_to_alloc)
880{
881 return vport->phba->lpfc_new_scsi_buf(vport, num_to_alloc);
882}
883
884/**
885 * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list of the HBA
886 * @phba: The HBA for which this call is being executed.
567 * 887 *
568 * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list 888 * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list
569 * and returns to caller. 889 * and returns to caller.
@@ -591,7 +911,7 @@ lpfc_get_scsi_buf(struct lpfc_hba * phba)
591} 911}
592 912
593/** 913/**
594 * lpfc_release_scsi_buf - Return a scsi buffer back to hba's lpfc_scsi_buf_list 914 * lpfc_release_scsi_buf - Return a scsi buffer back to hba scsi buf list
595 * @phba: The Hba for which this call is being executed. 915 * @phba: The Hba for which this call is being executed.
596 * @psb: The scsi buffer which is being released. 916 * @psb: The scsi buffer which is being released.
597 * 917 *
@@ -599,7 +919,7 @@ lpfc_get_scsi_buf(struct lpfc_hba * phba)
599 * lpfc_scsi_buf_list list. 919 * lpfc_scsi_buf_list list.
600 **/ 920 **/
601static void 921static void
602lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) 922lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
603{ 923{
604 unsigned long iflag = 0; 924 unsigned long iflag = 0;
605 925
@@ -610,21 +930,69 @@ lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
610} 930}
611 931
612/** 932/**
613 * lpfc_scsi_prep_dma_buf - Routine to do DMA mapping for scsi buffer 933 * lpfc_release_scsi_buf_s4: Return a scsi buffer back to hba scsi buf list.
934 * @phba: The Hba for which this call is being executed.
935 * @psb: The scsi buffer which is being released.
936 *
937 * This routine releases @psb scsi buffer by adding it to tail of @phba
938 * lpfc_scsi_buf_list list. For SLI4 XRI's are tied to the scsi buffer
939 * and cannot be reused for at least RA_TOV amount of time if it was
940 * aborted.
941 **/
942static void
943lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
944{
945 unsigned long iflag = 0;
946
947 if (psb->status == IOSTAT_LOCAL_REJECT
948 && psb->result == IOERR_ABORT_REQUESTED) {
949 spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock,
950 iflag);
951 psb->pCmd = NULL;
952 list_add_tail(&psb->list,
953 &phba->sli4_hba.lpfc_abts_scsi_buf_list);
954 spin_unlock_irqrestore(&phba->sli4_hba.abts_scsi_buf_list_lock,
955 iflag);
956 } else {
957
958 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
959 psb->pCmd = NULL;
960 list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list);
961 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
962 }
963}
964
965/**
966 * lpfc_release_scsi_buf: Return a scsi buffer back to hba scsi buf list.
967 * @phba: The Hba for which this call is being executed.
968 * @psb: The scsi buffer which is being released.
969 *
970 * This routine releases @psb scsi buffer by adding it to tail of @phba
971 * lpfc_scsi_buf_list list.
972 **/
973static void
974lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
975{
976
977 phba->lpfc_release_scsi_buf(phba, psb);
978}
979
980/**
981 * lpfc_scsi_prep_dma_buf_s3 - DMA mapping for scsi buffer to SLI3 IF spec
614 * @phba: The Hba for which this call is being executed. 982 * @phba: The Hba for which this call is being executed.
615 * @lpfc_cmd: The scsi buffer which is going to be mapped. 983 * @lpfc_cmd: The scsi buffer which is going to be mapped.
616 * 984 *
617 * This routine does the pci dma mapping for scatter-gather list of scsi cmnd 985 * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
618 * field of @lpfc_cmd. This routine scans through sg elements and format the 986 * field of @lpfc_cmd for device with SLI-3 interface spec. This routine scans
619 * bdea. This routine also initializes all IOCB fields which are dependent on 987 * through sg elements and format the bdea. This routine also initializes all
620 * scsi command request buffer. 988 * IOCB fields which are dependent on scsi command request buffer.
621 * 989 *
622 * Return codes: 990 * Return codes:
623 * 1 - Error 991 * 1 - Error
624 * 0 - Success 992 * 0 - Success
625 **/ 993 **/
626static int 994static int
627lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) 995lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
628{ 996{
629 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd; 997 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
630 struct scatterlist *sgel = NULL; 998 struct scatterlist *sgel = NULL;
@@ -827,8 +1195,8 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc)
827 * @reftag: out: ref tag (reference tag) 1195 * @reftag: out: ref tag (reference tag)
828 * 1196 *
829 * Description: 1197 * Description:
830 * Extract DIF paramters from the command if possible. Otherwise, 1198 * Extract DIF parameters from the command if possible. Otherwise,
831 * use default paratmers. 1199 * use default parameters.
832 * 1200 *
833 **/ 1201 **/
834static inline void 1202static inline void
@@ -1312,10 +1680,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1312 uint32_t bgstat = bgf->bgstat; 1680 uint32_t bgstat = bgf->bgstat;
1313 uint64_t failing_sector = 0; 1681 uint64_t failing_sector = 0;
1314 1682
1315 printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%lx " 1683 printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%x "
1316 "bgstat=0x%x bghm=0x%x\n", 1684 "bgstat=0x%x bghm=0x%x\n",
1317 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd), 1685 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd),
1318 cmd->request->nr_sectors, bgstat, bghm); 1686 blk_rq_sectors(cmd->request), bgstat, bghm);
1319 1687
1320 spin_lock(&_dump_buf_lock); 1688 spin_lock(&_dump_buf_lock);
1321 if (!_dump_buf_done) { 1689 if (!_dump_buf_done) {
@@ -1412,6 +1780,133 @@ out:
1412} 1780}
1413 1781
1414/** 1782/**
1783 * lpfc_scsi_prep_dma_buf_s4 - DMA mapping for scsi buffer to SLI4 IF spec
1784 * @phba: The Hba for which this call is being executed.
1785 * @lpfc_cmd: The scsi buffer which is going to be mapped.
1786 *
1787 * This routine does the pci dma mapping for scatter-gather list of scsi cmnd
1788 * field of @lpfc_cmd for device with SLI-4 interface spec.
1789 *
1790 * Return codes:
1791 * 1 - Error
1792 * 0 - Success
1793 **/
1794static int
1795lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1796{
1797 struct scsi_cmnd *scsi_cmnd = lpfc_cmd->pCmd;
1798 struct scatterlist *sgel = NULL;
1799 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
1800 struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl;
1801 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
1802 dma_addr_t physaddr;
1803 uint32_t num_bde = 0;
1804 uint32_t dma_len;
1805 uint32_t dma_offset = 0;
1806 int nseg;
1807
1808 /*
1809 * There are three possibilities here - use scatter-gather segment, use
1810 * the single mapping, or neither. Start the lpfc command prep by
1811 * bumping the bpl beyond the fcp_cmnd and fcp_rsp regions to the first
1812 * data bde entry.
1813 */
1814 if (scsi_sg_count(scsi_cmnd)) {
1815 /*
1816 * The driver stores the segment count returned from pci_map_sg
1817 * because this a count of dma-mappings used to map the use_sg
1818 * pages. They are not guaranteed to be the same for those
1819 * architectures that implement an IOMMU.
1820 */
1821
1822 nseg = scsi_dma_map(scsi_cmnd);
1823 if (unlikely(!nseg))
1824 return 1;
1825 sgl += 1;
1826 /* clear the last flag in the fcp_rsp map entry */
1827 sgl->word2 = le32_to_cpu(sgl->word2);
1828 bf_set(lpfc_sli4_sge_last, sgl, 0);
1829 sgl->word2 = cpu_to_le32(sgl->word2);
1830 sgl += 1;
1831
1832 lpfc_cmd->seg_cnt = nseg;
1833 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1834 printk(KERN_ERR "%s: Too many sg segments from "
1835 "dma_map_sg. Config %d, seg_cnt %d\n",
1836 __func__, phba->cfg_sg_seg_cnt,
1837 lpfc_cmd->seg_cnt);
1838 scsi_dma_unmap(scsi_cmnd);
1839 return 1;
1840 }
1841
1842 /*
1843 * The driver established a maximum scatter-gather segment count
1844 * during probe that limits the number of sg elements in any
1845 * single scsi command. Just run through the seg_cnt and format
1846 * the sge's.
1847 * When using SLI-3 the driver will try to fit all the BDEs into
1848 * the IOCB. If it can't then the BDEs get added to a BPL as it
1849 * does for SLI-2 mode.
1850 */
1851 scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) {
1852 physaddr = sg_dma_address(sgel);
1853 dma_len = sg_dma_len(sgel);
1854 bf_set(lpfc_sli4_sge_len, sgl, sg_dma_len(sgel));
1855 sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
1856 sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
1857 if ((num_bde + 1) == nseg)
1858 bf_set(lpfc_sli4_sge_last, sgl, 1);
1859 else
1860 bf_set(lpfc_sli4_sge_last, sgl, 0);
1861 bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
1862 sgl->word2 = cpu_to_le32(sgl->word2);
1863 sgl->word3 = cpu_to_le32(sgl->word3);
1864 dma_offset += dma_len;
1865 sgl++;
1866 }
1867 } else {
1868 sgl += 1;
1869 /* clear the last flag in the fcp_rsp map entry */
1870 sgl->word2 = le32_to_cpu(sgl->word2);
1871 bf_set(lpfc_sli4_sge_last, sgl, 1);
1872 sgl->word2 = cpu_to_le32(sgl->word2);
1873 }
1874
1875 /*
1876 * Finish initializing those IOCB fields that are dependent on the
1877 * scsi_cmnd request_buffer. Note that for SLI-2 the bdeSize is
1878 * explicitly reinitialized.
1879 * all iocb memory resources are reused.
1880 */
1881 fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd));
1882
1883 /*
1884 * Due to difference in data length between DIF/non-DIF paths,
1885 * we need to set word 4 of IOCB here
1886 */
1887 iocb_cmd->un.fcpi.fcpi_parm = scsi_bufflen(scsi_cmnd);
1888 return 0;
1889}
1890
1891/**
1892 * lpfc_scsi_prep_dma_buf - Wrapper function for DMA mapping of scsi buffer
1893 * @phba: The Hba for which this call is being executed.
1894 * @lpfc_cmd: The scsi buffer which is going to be mapped.
1895 *
1896 * This routine wraps the actual DMA mapping function pointer from the
1897 * lpfc_hba struct.
1898 *
1899 * Return codes:
1900 * 1 - Error
1901 * 0 - Success
1902 **/
1903static inline int
1904lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1905{
1906 return phba->lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
1907}
1908
1909/**
1415 * lpfc_send_scsi_error_event - Posts an event when there is SCSI error 1910 * lpfc_send_scsi_error_event - Posts an event when there is SCSI error
1416 * @phba: Pointer to hba context object. 1911 * @phba: Pointer to hba context object.
1417 * @vport: Pointer to vport object. 1912 * @vport: Pointer to vport object.
@@ -1504,15 +1999,15 @@ lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport,
1504} 1999}
1505 2000
1506/** 2001/**
1507 * lpfc_scsi_unprep_dma_buf - Routine to un-map DMA mapping of scatter gather 2002 * lpfc_scsi_unprep_dma_buf - Un-map DMA mapping of SG-list for dev
1508 * @phba: The Hba for which this call is being executed. 2003 * @phba: The HBA for which this call is being executed.
1509 * @psb: The scsi buffer which is going to be un-mapped. 2004 * @psb: The scsi buffer which is going to be un-mapped.
1510 * 2005 *
1511 * This routine does DMA un-mapping of scatter gather list of scsi command 2006 * This routine does DMA un-mapping of scatter gather list of scsi command
1512 * field of @lpfc_cmd. 2007 * field of @lpfc_cmd for device with SLI-3 interface spec.
1513 **/ 2008 **/
1514static void 2009static void
1515lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) 2010lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
1516{ 2011{
1517 /* 2012 /*
1518 * There are only two special cases to consider. (1) the scsi command 2013 * There are only two special cases to consider. (1) the scsi command
@@ -1676,7 +2171,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
1676 * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine 2171 * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine
1677 * @phba: The Hba for which this call is being executed. 2172 * @phba: The Hba for which this call is being executed.
1678 * @pIocbIn: The command IOCBQ for the scsi cmnd. 2173 * @pIocbIn: The command IOCBQ for the scsi cmnd.
1679 * @pIocbOut: The response IOCBQ for the scsi cmnd . 2174 * @pIocbOut: The response IOCBQ for the scsi cmnd.
1680 * 2175 *
1681 * This routine assigns scsi command result by looking into response IOCB 2176 * This routine assigns scsi command result by looking into response IOCB
1682 * status field appropriately. This routine handles QUEUE FULL condition as 2177 * status field appropriately. This routine handles QUEUE FULL condition as
@@ -1957,13 +2452,13 @@ lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd)
1957} 2452}
1958 2453
1959/** 2454/**
1960 * lpfc_scsi_prep_cmnd - Routine to convert scsi cmnd to FCP information unit 2455 * lpfc_scsi_prep_cmnd - Wrapper func for convert scsi cmnd to FCP info unit
1961 * @vport: The virtual port for which this call is being executed. 2456 * @vport: The virtual port for which this call is being executed.
1962 * @lpfc_cmd: The scsi command which needs to send. 2457 * @lpfc_cmd: The scsi command which needs to send.
1963 * @pnode: Pointer to lpfc_nodelist. 2458 * @pnode: Pointer to lpfc_nodelist.
1964 * 2459 *
1965 * This routine initializes fcp_cmnd and iocb data structure from scsi command 2460 * This routine initializes fcp_cmnd and iocb data structure from scsi command
1966 * to transfer. 2461 * to transfer for device with SLI3 interface spec.
1967 **/ 2462 **/
1968static void 2463static void
1969lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, 2464lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
@@ -2013,8 +2508,11 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2013 if (scsi_sg_count(scsi_cmnd)) { 2508 if (scsi_sg_count(scsi_cmnd)) {
2014 if (datadir == DMA_TO_DEVICE) { 2509 if (datadir == DMA_TO_DEVICE) {
2015 iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR; 2510 iocb_cmd->ulpCommand = CMD_FCP_IWRITE64_CR;
2016 iocb_cmd->un.fcpi.fcpi_parm = 0; 2511 if (phba->sli_rev < LPFC_SLI_REV4) {
2017 iocb_cmd->ulpPU = 0; 2512 iocb_cmd->un.fcpi.fcpi_parm = 0;
2513 iocb_cmd->ulpPU = 0;
2514 } else
2515 iocb_cmd->ulpPU = PARM_READ_CHECK;
2018 fcp_cmnd->fcpCntl3 = WRITE_DATA; 2516 fcp_cmnd->fcpCntl3 = WRITE_DATA;
2019 phba->fc4OutputRequests++; 2517 phba->fc4OutputRequests++;
2020 } else { 2518 } else {
@@ -2051,13 +2549,14 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2051} 2549}
2052 2550
2053/** 2551/**
2054 * lpfc_scsi_prep_task_mgmt_cmnd - Convert scsi TM cmnd to FCP information unit 2552 * lpfc_scsi_prep_task_mgmt_cmnd - Convert SLI3 scsi TM cmd to FCP info unit
2055 * @vport: The virtual port for which this call is being executed. 2553 * @vport: The virtual port for which this call is being executed.
2056 * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. 2554 * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure.
2057 * @lun: Logical unit number. 2555 * @lun: Logical unit number.
2058 * @task_mgmt_cmd: SCSI task management command. 2556 * @task_mgmt_cmd: SCSI task management command.
2059 * 2557 *
2060 * This routine creates FCP information unit corresponding to @task_mgmt_cmd. 2558 * This routine creates FCP information unit corresponding to @task_mgmt_cmd
2559 * for device with SLI-3 interface spec.
2061 * 2560 *
2062 * Return codes: 2561 * Return codes:
2063 * 0 - Error 2562 * 0 - Error
@@ -2106,14 +2605,56 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
2106 * The driver will provide the timeout mechanism. 2605 * The driver will provide the timeout mechanism.
2107 */ 2606 */
2108 piocb->ulpTimeout = 0; 2607 piocb->ulpTimeout = 0;
2109 } else { 2608 } else
2110 piocb->ulpTimeout = lpfc_cmd->timeout; 2609 piocb->ulpTimeout = lpfc_cmd->timeout;
2111 } 2610
2611 if (vport->phba->sli_rev == LPFC_SLI_REV4)
2612 lpfc_sli4_set_rsp_sgl_last(vport->phba, lpfc_cmd);
2112 2613
2113 return 1; 2614 return 1;
2114} 2615}
2115 2616
2116/** 2617/**
2618 * lpfc_scsi_api_table_setup - Set up scsi api fucntion jump table
2619 * @phba: The hba struct for which this call is being executed.
2620 * @dev_grp: The HBA PCI-Device group number.
2621 *
2622 * This routine sets up the SCSI interface API function jump table in @phba
2623 * struct.
2624 * Returns: 0 - success, -ENODEV - failure.
2625 **/
2626int
2627lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp)
2628{
2629
2630 phba->lpfc_scsi_unprep_dma_buf = lpfc_scsi_unprep_dma_buf;
2631 phba->lpfc_scsi_prep_cmnd = lpfc_scsi_prep_cmnd;
2632 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf;
2633
2634 switch (dev_grp) {
2635 case LPFC_PCI_DEV_LP:
2636 phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s3;
2637 phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3;
2638 phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3;
2639 break;
2640 case LPFC_PCI_DEV_OC:
2641 phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s4;
2642 phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4;
2643 phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4;
2644 break;
2645 default:
2646 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2647 "1418 Invalid HBA PCI-device group: 0x%x\n",
2648 dev_grp);
2649 return -ENODEV;
2650 break;
2651 }
2652 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf;
2653 phba->lpfc_rampdown_queue_depth = lpfc_rampdown_queue_depth;
2654 return 0;
2655}
2656
2657/**
2117 * lpfc_taskmgmt_def_cmpl - IOCB completion routine for task management command 2658 * lpfc_taskmgmt_def_cmpl - IOCB completion routine for task management command
2118 * @phba: The Hba for which this call is being executed. 2659 * @phba: The Hba for which this call is being executed.
2119 * @cmdiocbq: Pointer to lpfc_iocbq data structure. 2660 * @cmdiocbq: Pointer to lpfc_iocbq data structure.
@@ -2135,73 +2676,6 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,
2135} 2676}
2136 2677
2137/** 2678/**
2138 * lpfc_scsi_tgt_reset - Target reset handler
2139 * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure
2140 * @vport: The virtual port for which this call is being executed.
2141 * @tgt_id: Target ID.
2142 * @lun: Lun number.
2143 * @rdata: Pointer to lpfc_rport_data.
2144 *
2145 * This routine issues a TARGET RESET iocb to reset a target with @tgt_id ID.
2146 *
2147 * Return Code:
2148 * 0x2003 - Error
2149 * 0x2002 - Success.
2150 **/
2151static int
2152lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,
2153 unsigned tgt_id, unsigned int lun,
2154 struct lpfc_rport_data *rdata)
2155{
2156 struct lpfc_hba *phba = vport->phba;
2157 struct lpfc_iocbq *iocbq;
2158 struct lpfc_iocbq *iocbqrsp;
2159 int ret;
2160 int status;
2161
2162 if (!rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
2163 return FAILED;
2164
2165 lpfc_cmd->rdata = rdata;
2166 status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun,
2167 FCP_TARGET_RESET);
2168 if (!status)
2169 return FAILED;
2170
2171 iocbq = &lpfc_cmd->cur_iocbq;
2172 iocbqrsp = lpfc_sli_get_iocbq(phba);
2173
2174 if (!iocbqrsp)
2175 return FAILED;
2176
2177 /* Issue Target Reset to TGT <num> */
2178 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
2179 "0702 Issue Target Reset to TGT %d Data: x%x x%x\n",
2180 tgt_id, rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
2181 status = lpfc_sli_issue_iocb_wait(phba,
2182 &phba->sli.ring[phba->sli.fcp_ring],
2183 iocbq, iocbqrsp, lpfc_cmd->timeout);
2184 if (status != IOCB_SUCCESS) {
2185 if (status == IOCB_TIMEDOUT) {
2186 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
2187 ret = TIMEOUT_ERROR;
2188 } else
2189 ret = FAILED;
2190 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
2191 } else {
2192 ret = SUCCESS;
2193 lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4];
2194 lpfc_cmd->status = iocbqrsp->iocb.ulpStatus;
2195 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
2196 (lpfc_cmd->result & IOERR_DRVR_MASK))
2197 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
2198 }
2199
2200 lpfc_sli_release_iocbq(phba, iocbqrsp);
2201 return ret;
2202}
2203
2204/**
2205 * lpfc_info - Info entry point of scsi_host_template data structure 2679 * lpfc_info - Info entry point of scsi_host_template data structure
2206 * @host: The scsi host for which this call is being executed. 2680 * @host: The scsi host for which this call is being executed.
2207 * 2681 *
@@ -2305,7 +2779,6 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2305 struct Scsi_Host *shost = cmnd->device->host; 2779 struct Scsi_Host *shost = cmnd->device->host;
2306 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2780 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2307 struct lpfc_hba *phba = vport->phba; 2781 struct lpfc_hba *phba = vport->phba;
2308 struct lpfc_sli *psli = &phba->sli;
2309 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 2782 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
2310 struct lpfc_nodelist *ndlp = rdata->pnode; 2783 struct lpfc_nodelist *ndlp = rdata->pnode;
2311 struct lpfc_scsi_buf *lpfc_cmd; 2784 struct lpfc_scsi_buf *lpfc_cmd;
@@ -2378,15 +2851,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2378 if (cmnd->cmnd[0] == READ_10) 2851 if (cmnd->cmnd[0] == READ_10)
2379 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2852 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2380 "9035 BLKGRD: READ @ sector %llu, " 2853 "9035 BLKGRD: READ @ sector %llu, "
2381 "count %lu\n", 2854 "count %u\n",
2382 (unsigned long long)scsi_get_lba(cmnd), 2855 (unsigned long long)scsi_get_lba(cmnd),
2383 cmnd->request->nr_sectors); 2856 blk_rq_sectors(cmnd->request));
2384 else if (cmnd->cmnd[0] == WRITE_10) 2857 else if (cmnd->cmnd[0] == WRITE_10)
2385 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2858 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2386 "9036 BLKGRD: WRITE @ sector %llu, " 2859 "9036 BLKGRD: WRITE @ sector %llu, "
2387 "count %lu cmd=%p\n", 2860 "count %u cmd=%p\n",
2388 (unsigned long long)scsi_get_lba(cmnd), 2861 (unsigned long long)scsi_get_lba(cmnd),
2389 cmnd->request->nr_sectors, 2862 blk_rq_sectors(cmnd->request),
2390 cmnd); 2863 cmnd);
2391 2864
2392 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); 2865 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
@@ -2406,15 +2879,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2406 if (cmnd->cmnd[0] == READ_10) 2879 if (cmnd->cmnd[0] == READ_10)
2407 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2880 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2408 "9040 dbg: READ @ sector %llu, " 2881 "9040 dbg: READ @ sector %llu, "
2409 "count %lu\n", 2882 "count %u\n",
2410 (unsigned long long)scsi_get_lba(cmnd), 2883 (unsigned long long)scsi_get_lba(cmnd),
2411 cmnd->request->nr_sectors); 2884 blk_rq_sectors(cmnd->request));
2412 else if (cmnd->cmnd[0] == WRITE_10) 2885 else if (cmnd->cmnd[0] == WRITE_10)
2413 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2886 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2414 "9041 dbg: WRITE @ sector %llu, " 2887 "9041 dbg: WRITE @ sector %llu, "
2415 "count %lu cmd=%p\n", 2888 "count %u cmd=%p\n",
2416 (unsigned long long)scsi_get_lba(cmnd), 2889 (unsigned long long)scsi_get_lba(cmnd),
2417 cmnd->request->nr_sectors, cmnd); 2890 blk_rq_sectors(cmnd->request), cmnd);
2418 else 2891 else
2419 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2892 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2420 "9042 dbg: parser not implemented\n"); 2893 "9042 dbg: parser not implemented\n");
@@ -2427,7 +2900,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2427 lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp); 2900 lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp);
2428 2901
2429 atomic_inc(&ndlp->cmd_pending); 2902 atomic_inc(&ndlp->cmd_pending);
2430 err = lpfc_sli_issue_iocb(phba, &phba->sli.ring[psli->fcp_ring], 2903 err = lpfc_sli_issue_iocb(phba, LPFC_FCP_RING,
2431 &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); 2904 &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB);
2432 if (err) { 2905 if (err) {
2433 atomic_dec(&ndlp->cmd_pending); 2906 atomic_dec(&ndlp->cmd_pending);
@@ -2490,7 +2963,6 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2490 struct Scsi_Host *shost = cmnd->device->host; 2963 struct Scsi_Host *shost = cmnd->device->host;
2491 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2964 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2492 struct lpfc_hba *phba = vport->phba; 2965 struct lpfc_hba *phba = vport->phba;
2493 struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring];
2494 struct lpfc_iocbq *iocb; 2966 struct lpfc_iocbq *iocb;
2495 struct lpfc_iocbq *abtsiocb; 2967 struct lpfc_iocbq *abtsiocb;
2496 struct lpfc_scsi_buf *lpfc_cmd; 2968 struct lpfc_scsi_buf *lpfc_cmd;
@@ -2531,7 +3003,10 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2531 icmd = &abtsiocb->iocb; 3003 icmd = &abtsiocb->iocb;
2532 icmd->un.acxri.abortType = ABORT_TYPE_ABTS; 3004 icmd->un.acxri.abortType = ABORT_TYPE_ABTS;
2533 icmd->un.acxri.abortContextTag = cmd->ulpContext; 3005 icmd->un.acxri.abortContextTag = cmd->ulpContext;
2534 icmd->un.acxri.abortIoTag = cmd->ulpIoTag; 3006 if (phba->sli_rev == LPFC_SLI_REV4)
3007 icmd->un.acxri.abortIoTag = iocb->sli4_xritag;
3008 else
3009 icmd->un.acxri.abortIoTag = cmd->ulpIoTag;
2535 3010
2536 icmd->ulpLe = 1; 3011 icmd->ulpLe = 1;
2537 icmd->ulpClass = cmd->ulpClass; 3012 icmd->ulpClass = cmd->ulpClass;
@@ -2542,7 +3017,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2542 3017
2543 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; 3018 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;
2544 abtsiocb->vport = vport; 3019 abtsiocb->vport = vport;
2545 if (lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0) == IOCB_ERROR) { 3020 if (lpfc_sli_issue_iocb(phba, LPFC_FCP_RING, abtsiocb, 0) ==
3021 IOCB_ERROR) {
2546 lpfc_sli_release_iocbq(phba, abtsiocb); 3022 lpfc_sli_release_iocbq(phba, abtsiocb);
2547 ret = FAILED; 3023 ret = FAILED;
2548 goto out; 3024 goto out;
@@ -2579,157 +3055,334 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2579 return ret; 3055 return ret;
2580} 3056}
2581 3057
3058static char *
3059lpfc_taskmgmt_name(uint8_t task_mgmt_cmd)
3060{
3061 switch (task_mgmt_cmd) {
3062 case FCP_ABORT_TASK_SET:
3063 return "ABORT_TASK_SET";
3064 case FCP_CLEAR_TASK_SET:
3065 return "FCP_CLEAR_TASK_SET";
3066 case FCP_BUS_RESET:
3067 return "FCP_BUS_RESET";
3068 case FCP_LUN_RESET:
3069 return "FCP_LUN_RESET";
3070 case FCP_TARGET_RESET:
3071 return "FCP_TARGET_RESET";
3072 case FCP_CLEAR_ACA:
3073 return "FCP_CLEAR_ACA";
3074 case FCP_TERMINATE_TASK:
3075 return "FCP_TERMINATE_TASK";
3076 default:
3077 return "unknown";
3078 }
3079}
3080
2582/** 3081/**
2583 * lpfc_device_reset_handler - scsi_host_template eh_device_reset entry point 3082 * lpfc_send_taskmgmt - Generic SCSI Task Mgmt Handler
2584 * @cmnd: Pointer to scsi_cmnd data structure. 3083 * @vport: The virtual port for which this call is being executed.
3084 * @rdata: Pointer to remote port local data
3085 * @tgt_id: Target ID of remote device.
3086 * @lun_id: Lun number for the TMF
3087 * @task_mgmt_cmd: type of TMF to send
2585 * 3088 *
2586 * This routine does a device reset by sending a TARGET_RESET task management 3089 * This routine builds and sends a TMF (SCSI Task Mgmt Function) to
2587 * command. 3090 * a remote port.
2588 * 3091 *
2589 * Return code : 3092 * Return Code:
2590 * 0x2003 - Error 3093 * 0x2003 - Error
2591 * 0x2002 - Success 3094 * 0x2002 - Success.
2592 **/ 3095 **/
2593static int 3096static int
2594lpfc_device_reset_handler(struct scsi_cmnd *cmnd) 3097lpfc_send_taskmgmt(struct lpfc_vport *vport, struct lpfc_rport_data *rdata,
3098 unsigned tgt_id, unsigned int lun_id,
3099 uint8_t task_mgmt_cmd)
2595{ 3100{
2596 struct Scsi_Host *shost = cmnd->device->host;
2597 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2598 struct lpfc_hba *phba = vport->phba; 3101 struct lpfc_hba *phba = vport->phba;
2599 struct lpfc_scsi_buf *lpfc_cmd; 3102 struct lpfc_scsi_buf *lpfc_cmd;
2600 struct lpfc_iocbq *iocbq, *iocbqrsp; 3103 struct lpfc_iocbq *iocbq;
2601 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3104 struct lpfc_iocbq *iocbqrsp;
2602 struct lpfc_nodelist *pnode = rdata->pnode; 3105 int ret;
2603 unsigned long later;
2604 int ret = SUCCESS;
2605 int status; 3106 int status;
2606 int cnt;
2607 struct lpfc_scsi_event_header scsi_event;
2608 3107
2609 lpfc_block_error_handler(cmnd); 3108 if (!rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
2610 /*
2611 * If target is not in a MAPPED state, delay the reset until
2612 * target is rediscovered or devloss timeout expires.
2613 */
2614 later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
2615 while (time_after(later, jiffies)) {
2616 if (!pnode || !NLP_CHK_NODE_ACT(pnode))
2617 return FAILED;
2618 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
2619 break;
2620 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
2621 rdata = cmnd->device->hostdata;
2622 if (!rdata)
2623 break;
2624 pnode = rdata->pnode;
2625 }
2626
2627 scsi_event.event_type = FC_REG_SCSI_EVENT;
2628 scsi_event.subcategory = LPFC_EVENT_TGTRESET;
2629 scsi_event.lun = 0;
2630 memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name));
2631 memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name));
2632
2633 fc_host_post_vendor_event(shost,
2634 fc_get_event_number(),
2635 sizeof(scsi_event),
2636 (char *)&scsi_event,
2637 LPFC_NL_VENDOR_ID);
2638
2639 if (!rdata || pnode->nlp_state != NLP_STE_MAPPED_NODE) {
2640 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2641 "0721 LUN Reset rport "
2642 "failure: msec x%x rdata x%p\n",
2643 jiffies_to_msecs(jiffies - later), rdata);
2644 return FAILED; 3109 return FAILED;
2645 } 3110
2646 lpfc_cmd = lpfc_get_scsi_buf(phba); 3111 lpfc_cmd = lpfc_get_scsi_buf(phba);
2647 if (lpfc_cmd == NULL) 3112 if (lpfc_cmd == NULL)
2648 return FAILED; 3113 return FAILED;
2649 lpfc_cmd->timeout = 60; 3114 lpfc_cmd->timeout = 60;
2650 lpfc_cmd->rdata = rdata; 3115 lpfc_cmd->rdata = rdata;
2651 3116
2652 status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, 3117 status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun_id,
2653 cmnd->device->lun, 3118 task_mgmt_cmd);
2654 FCP_TARGET_RESET);
2655 if (!status) { 3119 if (!status) {
2656 lpfc_release_scsi_buf(phba, lpfc_cmd); 3120 lpfc_release_scsi_buf(phba, lpfc_cmd);
2657 return FAILED; 3121 return FAILED;
2658 } 3122 }
2659 iocbq = &lpfc_cmd->cur_iocbq;
2660 3123
2661 /* get a buffer for this IOCB command response */ 3124 iocbq = &lpfc_cmd->cur_iocbq;
2662 iocbqrsp = lpfc_sli_get_iocbq(phba); 3125 iocbqrsp = lpfc_sli_get_iocbq(phba);
2663 if (iocbqrsp == NULL) { 3126 if (iocbqrsp == NULL) {
2664 lpfc_release_scsi_buf(phba, lpfc_cmd); 3127 lpfc_release_scsi_buf(phba, lpfc_cmd);
2665 return FAILED; 3128 return FAILED;
2666 } 3129 }
3130
2667 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, 3131 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
2668 "0703 Issue target reset to TGT %d LUN %d " 3132 "0702 Issue %s to TGT %d LUN %d "
2669 "rpi x%x nlp_flag x%x\n", cmnd->device->id, 3133 "rpi x%x nlp_flag x%x\n",
2670 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); 3134 lpfc_taskmgmt_name(task_mgmt_cmd), tgt_id, lun_id,
2671 status = lpfc_sli_issue_iocb_wait(phba, 3135 rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
2672 &phba->sli.ring[phba->sli.fcp_ring], 3136
3137 status = lpfc_sli_issue_iocb_wait(phba, LPFC_FCP_RING,
2673 iocbq, iocbqrsp, lpfc_cmd->timeout); 3138 iocbq, iocbqrsp, lpfc_cmd->timeout);
2674 if (status == IOCB_TIMEDOUT) { 3139 if (status != IOCB_SUCCESS) {
2675 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; 3140 if (status == IOCB_TIMEDOUT) {
2676 ret = TIMEOUT_ERROR; 3141 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
2677 } else { 3142 ret = TIMEOUT_ERROR;
2678 if (status != IOCB_SUCCESS) 3143 } else
2679 ret = FAILED; 3144 ret = FAILED;
2680 lpfc_release_scsi_buf(phba, lpfc_cmd); 3145 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
2681 } 3146 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2682 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 3147 "0727 TMF %s to TGT %d LUN %d failed (%d, %d)\n",
2683 "0713 SCSI layer issued device reset (%d, %d) " 3148 lpfc_taskmgmt_name(task_mgmt_cmd),
2684 "return x%x status x%x result x%x\n", 3149 tgt_id, lun_id, iocbqrsp->iocb.ulpStatus,
2685 cmnd->device->id, cmnd->device->lun, ret,
2686 iocbqrsp->iocb.ulpStatus,
2687 iocbqrsp->iocb.un.ulpWord[4]); 3150 iocbqrsp->iocb.un.ulpWord[4]);
3151 } else
3152 ret = SUCCESS;
3153
2688 lpfc_sli_release_iocbq(phba, iocbqrsp); 3154 lpfc_sli_release_iocbq(phba, iocbqrsp);
2689 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id, cmnd->device->lun, 3155
2690 LPFC_CTX_TGT); 3156 if (ret != TIMEOUT_ERROR)
3157 lpfc_release_scsi_buf(phba, lpfc_cmd);
3158
3159 return ret;
3160}
3161
3162/**
3163 * lpfc_chk_tgt_mapped -
3164 * @vport: The virtual port to check on
3165 * @cmnd: Pointer to scsi_cmnd data structure.
3166 *
3167 * This routine delays until the scsi target (aka rport) for the
3168 * command exists (is present and logged in) or we declare it non-existent.
3169 *
3170 * Return code :
3171 * 0x2003 - Error
3172 * 0x2002 - Success
3173 **/
3174static int
3175lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd)
3176{
3177 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3178 struct lpfc_nodelist *pnode = rdata->pnode;
3179 unsigned long later;
3180
3181 /*
3182 * If target is not in a MAPPED state, delay until
3183 * target is rediscovered or devloss timeout expires.
3184 */
3185 later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
3186 while (time_after(later, jiffies)) {
3187 if (!pnode || !NLP_CHK_NODE_ACT(pnode))
3188 return FAILED;
3189 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
3190 return SUCCESS;
3191 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
3192 rdata = cmnd->device->hostdata;
3193 if (!rdata)
3194 return FAILED;
3195 pnode = rdata->pnode;
3196 }
3197 if (!pnode || !NLP_CHK_NODE_ACT(pnode) ||
3198 (pnode->nlp_state != NLP_STE_MAPPED_NODE))
3199 return FAILED;
3200 return SUCCESS;
3201}
3202
3203/**
3204 * lpfc_reset_flush_io_context -
3205 * @vport: The virtual port (scsi_host) for the flush context
3206 * @tgt_id: If aborting by Target contect - specifies the target id
3207 * @lun_id: If aborting by Lun context - specifies the lun id
3208 * @context: specifies the context level to flush at.
3209 *
3210 * After a reset condition via TMF, we need to flush orphaned i/o
3211 * contexts from the adapter. This routine aborts any contexts
3212 * outstanding, then waits for their completions. The wait is
3213 * bounded by devloss_tmo though.
3214 *
3215 * Return code :
3216 * 0x2003 - Error
3217 * 0x2002 - Success
3218 **/
3219static int
3220lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id,
3221 uint64_t lun_id, lpfc_ctx_cmd context)
3222{
3223 struct lpfc_hba *phba = vport->phba;
3224 unsigned long later;
3225 int cnt;
3226
3227 cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
2691 if (cnt) 3228 if (cnt)
2692 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring], 3229 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
2693 cmnd->device->id, cmnd->device->lun, 3230 tgt_id, lun_id, context);
2694 LPFC_CTX_TGT);
2695 later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies; 3231 later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
2696 while (time_after(later, jiffies) && cnt) { 3232 while (time_after(later, jiffies) && cnt) {
2697 schedule_timeout_uninterruptible(msecs_to_jiffies(20)); 3233 schedule_timeout_uninterruptible(msecs_to_jiffies(20));
2698 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id, 3234 cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
2699 cmnd->device->lun, LPFC_CTX_TGT);
2700 } 3235 }
2701 if (cnt) { 3236 if (cnt) {
2702 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 3237 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2703 "0719 device reset I/O flush failure: " 3238 "0724 I/O flush failure for context %s : cnt x%x\n",
2704 "cnt x%x\n", cnt); 3239 ((context == LPFC_CTX_LUN) ? "LUN" :
2705 ret = FAILED; 3240 ((context == LPFC_CTX_TGT) ? "TGT" :
3241 ((context == LPFC_CTX_HOST) ? "HOST" : "Unknown"))),
3242 cnt);
3243 return FAILED;
2706 } 3244 }
2707 return ret; 3245 return SUCCESS;
3246}
3247
3248/**
3249 * lpfc_device_reset_handler - scsi_host_template eh_device_reset entry point
3250 * @cmnd: Pointer to scsi_cmnd data structure.
3251 *
3252 * This routine does a device reset by sending a LUN_RESET task management
3253 * command.
3254 *
3255 * Return code :
3256 * 0x2003 - Error
3257 * 0x2002 - Success
3258 **/
3259static int
3260lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
3261{
3262 struct Scsi_Host *shost = cmnd->device->host;
3263 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3264 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3265 struct lpfc_nodelist *pnode = rdata->pnode;
3266 unsigned tgt_id = cmnd->device->id;
3267 unsigned int lun_id = cmnd->device->lun;
3268 struct lpfc_scsi_event_header scsi_event;
3269 int status;
3270
3271 lpfc_block_error_handler(cmnd);
3272
3273 status = lpfc_chk_tgt_mapped(vport, cmnd);
3274 if (status == FAILED) {
3275 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3276 "0721 Device Reset rport failure: rdata x%p\n", rdata);
3277 return FAILED;
3278 }
3279
3280 scsi_event.event_type = FC_REG_SCSI_EVENT;
3281 scsi_event.subcategory = LPFC_EVENT_LUNRESET;
3282 scsi_event.lun = lun_id;
3283 memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name));
3284 memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name));
3285
3286 fc_host_post_vendor_event(shost, fc_get_event_number(),
3287 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
3288
3289 status = lpfc_send_taskmgmt(vport, rdata, tgt_id, lun_id,
3290 FCP_LUN_RESET);
3291
3292 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3293 "0713 SCSI layer issued Device Reset (%d, %d) "
3294 "return x%x\n", tgt_id, lun_id, status);
3295
3296 /*
3297 * We have to clean up i/o as : they may be orphaned by the TMF;
3298 * or if the TMF failed, they may be in an indeterminate state.
3299 * So, continue on.
3300 * We will report success if all the i/o aborts successfully.
3301 */
3302 status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
3303 LPFC_CTX_LUN);
3304 return status;
3305}
3306
3307/**
3308 * lpfc_target_reset_handler - scsi_host_template eh_target_reset entry point
3309 * @cmnd: Pointer to scsi_cmnd data structure.
3310 *
3311 * This routine does a target reset by sending a TARGET_RESET task management
3312 * command.
3313 *
3314 * Return code :
3315 * 0x2003 - Error
3316 * 0x2002 - Success
3317 **/
3318static int
3319lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
3320{
3321 struct Scsi_Host *shost = cmnd->device->host;
3322 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3323 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3324 struct lpfc_nodelist *pnode = rdata->pnode;
3325 unsigned tgt_id = cmnd->device->id;
3326 unsigned int lun_id = cmnd->device->lun;
3327 struct lpfc_scsi_event_header scsi_event;
3328 int status;
3329
3330 lpfc_block_error_handler(cmnd);
3331
3332 status = lpfc_chk_tgt_mapped(vport, cmnd);
3333 if (status == FAILED) {
3334 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3335 "0722 Target Reset rport failure: rdata x%p\n", rdata);
3336 return FAILED;
3337 }
3338
3339 scsi_event.event_type = FC_REG_SCSI_EVENT;
3340 scsi_event.subcategory = LPFC_EVENT_TGTRESET;
3341 scsi_event.lun = 0;
3342 memcpy(scsi_event.wwpn, &pnode->nlp_portname, sizeof(struct lpfc_name));
3343 memcpy(scsi_event.wwnn, &pnode->nlp_nodename, sizeof(struct lpfc_name));
3344
3345 fc_host_post_vendor_event(shost, fc_get_event_number(),
3346 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
3347
3348 status = lpfc_send_taskmgmt(vport, rdata, tgt_id, lun_id,
3349 FCP_TARGET_RESET);
3350
3351 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3352 "0723 SCSI layer issued Target Reset (%d, %d) "
3353 "return x%x\n", tgt_id, lun_id, status);
3354
3355 /*
3356 * We have to clean up i/o as : they may be orphaned by the TMF;
3357 * or if the TMF failed, they may be in an indeterminate state.
3358 * So, continue on.
3359 * We will report success if all the i/o aborts successfully.
3360 */
3361 status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
3362 LPFC_CTX_TGT);
3363 return status;
2708} 3364}
2709 3365
2710/** 3366/**
2711 * lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point 3367 * lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point
2712 * @cmnd: Pointer to scsi_cmnd data structure. 3368 * @cmnd: Pointer to scsi_cmnd data structure.
2713 * 3369 *
2714 * This routine does target reset to all target on @cmnd->device->host. 3370 * This routine does target reset to all targets on @cmnd->device->host.
3371 * This emulates Parallel SCSI Bus Reset Semantics.
2715 * 3372 *
2716 * Return Code: 3373 * Return code :
2717 * 0x2003 - Error 3374 * 0x2003 - Error
2718 * 0x2002 - Success 3375 * 0x2002 - Success
2719 **/ 3376 **/
2720static int 3377static int
2721lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) 3378lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
2722{ 3379{
2723 struct Scsi_Host *shost = cmnd->device->host; 3380 struct Scsi_Host *shost = cmnd->device->host;
2724 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 3381 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2725 struct lpfc_hba *phba = vport->phba;
2726 struct lpfc_nodelist *ndlp = NULL; 3382 struct lpfc_nodelist *ndlp = NULL;
2727 int match;
2728 int ret = SUCCESS, status = SUCCESS, i;
2729 int cnt;
2730 struct lpfc_scsi_buf * lpfc_cmd;
2731 unsigned long later;
2732 struct lpfc_scsi_event_header scsi_event; 3383 struct lpfc_scsi_event_header scsi_event;
3384 int match;
3385 int ret = SUCCESS, status, i;
2733 3386
2734 scsi_event.event_type = FC_REG_SCSI_EVENT; 3387 scsi_event.event_type = FC_REG_SCSI_EVENT;
2735 scsi_event.subcategory = LPFC_EVENT_BUSRESET; 3388 scsi_event.subcategory = LPFC_EVENT_BUSRESET;
@@ -2737,13 +3390,11 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
2737 memcpy(scsi_event.wwpn, &vport->fc_portname, sizeof(struct lpfc_name)); 3390 memcpy(scsi_event.wwpn, &vport->fc_portname, sizeof(struct lpfc_name));
2738 memcpy(scsi_event.wwnn, &vport->fc_nodename, sizeof(struct lpfc_name)); 3391 memcpy(scsi_event.wwnn, &vport->fc_nodename, sizeof(struct lpfc_name));
2739 3392
2740 fc_host_post_vendor_event(shost, 3393 fc_host_post_vendor_event(shost, fc_get_event_number(),
2741 fc_get_event_number(), 3394 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
2742 sizeof(scsi_event),
2743 (char *)&scsi_event,
2744 LPFC_NL_VENDOR_ID);
2745 3395
2746 lpfc_block_error_handler(cmnd); 3396 lpfc_block_error_handler(cmnd);
3397
2747 /* 3398 /*
2748 * Since the driver manages a single bus device, reset all 3399 * Since the driver manages a single bus device, reset all
2749 * targets known to the driver. Should any target reset 3400 * targets known to the driver. Should any target reset
@@ -2766,16 +3417,11 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
2766 spin_unlock_irq(shost->host_lock); 3417 spin_unlock_irq(shost->host_lock);
2767 if (!match) 3418 if (!match)
2768 continue; 3419 continue;
2769 lpfc_cmd = lpfc_get_scsi_buf(phba); 3420
2770 if (lpfc_cmd) { 3421 status = lpfc_send_taskmgmt(vport, ndlp->rport->dd_data,
2771 lpfc_cmd->timeout = 60; 3422 i, 0, FCP_TARGET_RESET);
2772 status = lpfc_scsi_tgt_reset(lpfc_cmd, vport, i, 3423
2773 cmnd->device->lun, 3424 if (status != SUCCESS) {
2774 ndlp->rport->dd_data);
2775 if (status != TIMEOUT_ERROR)
2776 lpfc_release_scsi_buf(phba, lpfc_cmd);
2777 }
2778 if (!lpfc_cmd || status != SUCCESS) {
2779 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 3425 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2780 "0700 Bus Reset on target %d failed\n", 3426 "0700 Bus Reset on target %d failed\n",
2781 i); 3427 i);
@@ -2783,25 +3429,16 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
2783 } 3429 }
2784 } 3430 }
2785 /* 3431 /*
2786 * All outstanding txcmplq I/Os should have been aborted by 3432 * We have to clean up i/o as : they may be orphaned by the TMFs
2787 * the targets. Unfortunately, some targets do not abide by 3433 * above; or if any of the TMFs failed, they may be in an
2788 * this forcing the driver to double check. 3434 * indeterminate state.
3435 * We will report success if all the i/o aborts successfully.
2789 */ 3436 */
2790 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST); 3437
2791 if (cnt) 3438 status = lpfc_reset_flush_io_context(vport, 0, 0, LPFC_CTX_HOST);
2792 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring], 3439 if (status != SUCCESS)
2793 0, 0, LPFC_CTX_HOST);
2794 later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
2795 while (time_after(later, jiffies) && cnt) {
2796 schedule_timeout_uninterruptible(msecs_to_jiffies(20));
2797 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST);
2798 }
2799 if (cnt) {
2800 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2801 "0715 Bus Reset I/O flush failure: "
2802 "cnt x%x left x%x\n", cnt, i);
2803 ret = FAILED; 3440 ret = FAILED;
2804 } 3441
2805 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 3442 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2806 "0714 SCSI layer issued Bus Reset Data: x%x\n", ret); 3443 "0714 SCSI layer issued Bus Reset Data: x%x\n", ret);
2807 return ret; 3444 return ret;
@@ -2825,11 +3462,10 @@ lpfc_slave_alloc(struct scsi_device *sdev)
2825{ 3462{
2826 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; 3463 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
2827 struct lpfc_hba *phba = vport->phba; 3464 struct lpfc_hba *phba = vport->phba;
2828 struct lpfc_scsi_buf *scsi_buf = NULL;
2829 struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); 3465 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
2830 uint32_t total = 0, i; 3466 uint32_t total = 0;
2831 uint32_t num_to_alloc = 0; 3467 uint32_t num_to_alloc = 0;
2832 unsigned long flags; 3468 int num_allocated = 0;
2833 3469
2834 if (!rport || fc_remote_port_chkready(rport)) 3470 if (!rport || fc_remote_port_chkready(rport))
2835 return -ENXIO; 3471 return -ENXIO;
@@ -2863,20 +3499,13 @@ lpfc_slave_alloc(struct scsi_device *sdev)
2863 (phba->cfg_hba_queue_depth - total)); 3499 (phba->cfg_hba_queue_depth - total));
2864 num_to_alloc = phba->cfg_hba_queue_depth - total; 3500 num_to_alloc = phba->cfg_hba_queue_depth - total;
2865 } 3501 }
2866 3502 num_allocated = lpfc_new_scsi_buf(vport, num_to_alloc);
2867 for (i = 0; i < num_to_alloc; i++) { 3503 if (num_to_alloc != num_allocated) {
2868 scsi_buf = lpfc_new_scsi_buf(vport); 3504 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
2869 if (!scsi_buf) { 3505 "0708 Allocation request of %d "
2870 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 3506 "command buffers did not succeed. "
2871 "0706 Failed to allocate " 3507 "Allocated %d buffers.\n",
2872 "command buffer\n"); 3508 num_to_alloc, num_allocated);
2873 break;
2874 }
2875
2876 spin_lock_irqsave(&phba->scsi_buf_list_lock, flags);
2877 phba->total_scsi_bufs++;
2878 list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list);
2879 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, flags);
2880 } 3509 }
2881 return 0; 3510 return 0;
2882} 3511}
@@ -2942,7 +3571,8 @@ struct scsi_host_template lpfc_template = {
2942 .info = lpfc_info, 3571 .info = lpfc_info,
2943 .queuecommand = lpfc_queuecommand, 3572 .queuecommand = lpfc_queuecommand,
2944 .eh_abort_handler = lpfc_abort_handler, 3573 .eh_abort_handler = lpfc_abort_handler,
2945 .eh_device_reset_handler= lpfc_device_reset_handler, 3574 .eh_device_reset_handler = lpfc_device_reset_handler,
3575 .eh_target_reset_handler = lpfc_target_reset_handler,
2946 .eh_bus_reset_handler = lpfc_bus_reset_handler, 3576 .eh_bus_reset_handler = lpfc_bus_reset_handler,
2947 .slave_alloc = lpfc_slave_alloc, 3577 .slave_alloc = lpfc_slave_alloc,
2948 .slave_configure = lpfc_slave_configure, 3578 .slave_configure = lpfc_slave_configure,
@@ -2962,7 +3592,8 @@ struct scsi_host_template lpfc_vport_template = {
2962 .info = lpfc_info, 3592 .info = lpfc_info,
2963 .queuecommand = lpfc_queuecommand, 3593 .queuecommand = lpfc_queuecommand,
2964 .eh_abort_handler = lpfc_abort_handler, 3594 .eh_abort_handler = lpfc_abort_handler,
2965 .eh_device_reset_handler= lpfc_device_reset_handler, 3595 .eh_device_reset_handler = lpfc_device_reset_handler,
3596 .eh_target_reset_handler = lpfc_target_reset_handler,
2966 .eh_bus_reset_handler = lpfc_bus_reset_handler, 3597 .eh_bus_reset_handler = lpfc_bus_reset_handler,
2967 .slave_alloc = lpfc_slave_alloc, 3598 .slave_alloc = lpfc_slave_alloc,
2968 .slave_configure = lpfc_slave_configure, 3599 .slave_configure = lpfc_slave_configure,