diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 113 |
1 files changed, 85 insertions, 28 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index c97751c95d77..bf34178b80bf 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -609,6 +609,32 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc) | |||
609 | } | 609 | } |
610 | 610 | ||
611 | /** | 611 | /** |
612 | * lpfc_sli4_vport_delete_fcp_xri_aborted -Remove all ndlp references for vport | ||
613 | * @vport: pointer to lpfc vport data structure. | ||
614 | * | ||
615 | * This routine is invoked by the vport cleanup for deletions and the cleanup | ||
616 | * for an ndlp on removal. | ||
617 | **/ | ||
618 | void | ||
619 | lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport) | ||
620 | { | ||
621 | struct lpfc_hba *phba = vport->phba; | ||
622 | struct lpfc_scsi_buf *psb, *next_psb; | ||
623 | unsigned long iflag = 0; | ||
624 | |||
625 | spin_lock_irqsave(&phba->hbalock, iflag); | ||
626 | spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); | ||
627 | list_for_each_entry_safe(psb, next_psb, | ||
628 | &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) { | ||
629 | if (psb->rdata && psb->rdata->pnode | ||
630 | && psb->rdata->pnode->vport == vport) | ||
631 | psb->rdata = NULL; | ||
632 | } | ||
633 | spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock); | ||
634 | spin_unlock_irqrestore(&phba->hbalock, iflag); | ||
635 | } | ||
636 | |||
637 | /** | ||
612 | * lpfc_sli4_fcp_xri_aborted - Fast-path process of fcp xri abort | 638 | * lpfc_sli4_fcp_xri_aborted - Fast-path process of fcp xri abort |
613 | * @phba: pointer to lpfc hba data structure. | 639 | * @phba: pointer to lpfc hba data structure. |
614 | * @axri: pointer to the fcp xri abort wcqe structure. | 640 | * @axri: pointer to the fcp xri abort wcqe structure. |
@@ -640,7 +666,11 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, | |||
640 | psb->status = IOSTAT_SUCCESS; | 666 | psb->status = IOSTAT_SUCCESS; |
641 | spin_unlock( | 667 | spin_unlock( |
642 | &phba->sli4_hba.abts_scsi_buf_list_lock); | 668 | &phba->sli4_hba.abts_scsi_buf_list_lock); |
643 | ndlp = psb->rdata->pnode; | 669 | if (psb->rdata && psb->rdata->pnode) |
670 | ndlp = psb->rdata->pnode; | ||
671 | else | ||
672 | ndlp = NULL; | ||
673 | |||
644 | rrq_empty = list_empty(&phba->active_rrq_list); | 674 | rrq_empty = list_empty(&phba->active_rrq_list); |
645 | spin_unlock_irqrestore(&phba->hbalock, iflag); | 675 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
646 | if (ndlp) | 676 | if (ndlp) |
@@ -964,36 +994,29 @@ lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
964 | static struct lpfc_scsi_buf* | 994 | static struct lpfc_scsi_buf* |
965 | lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | 995 | lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) |
966 | { | 996 | { |
967 | struct lpfc_scsi_buf *lpfc_cmd = NULL; | 997 | struct lpfc_scsi_buf *lpfc_cmd ; |
968 | struct lpfc_scsi_buf *start_lpfc_cmd = NULL; | ||
969 | struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list; | ||
970 | unsigned long iflag = 0; | 998 | unsigned long iflag = 0; |
971 | int found = 0; | 999 | int found = 0; |
972 | 1000 | ||
973 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); | 1001 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); |
974 | list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list); | 1002 | list_for_each_entry(lpfc_cmd, &phba->lpfc_scsi_buf_list, |
975 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); | 1003 | list) { |
976 | while (!found && lpfc_cmd) { | ||
977 | if (lpfc_test_rrq_active(phba, ndlp, | 1004 | if (lpfc_test_rrq_active(phba, ndlp, |
978 | lpfc_cmd->cur_iocbq.sli4_xritag)) { | 1005 | lpfc_cmd->cur_iocbq.sli4_xritag)) |
979 | lpfc_release_scsi_buf_s4(phba, lpfc_cmd); | 1006 | continue; |
980 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); | 1007 | list_del(&lpfc_cmd->list); |
981 | list_remove_head(scsi_buf_list, lpfc_cmd, | ||
982 | struct lpfc_scsi_buf, list); | ||
983 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, | ||
984 | iflag); | ||
985 | if (lpfc_cmd == start_lpfc_cmd) { | ||
986 | lpfc_cmd = NULL; | ||
987 | break; | ||
988 | } else | ||
989 | continue; | ||
990 | } | ||
991 | found = 1; | 1008 | found = 1; |
992 | lpfc_cmd->seg_cnt = 0; | 1009 | lpfc_cmd->seg_cnt = 0; |
993 | lpfc_cmd->nonsg_phys = 0; | 1010 | lpfc_cmd->nonsg_phys = 0; |
994 | lpfc_cmd->prot_seg_cnt = 0; | 1011 | lpfc_cmd->prot_seg_cnt = 0; |
1012 | break; | ||
995 | } | 1013 | } |
996 | return lpfc_cmd; | 1014 | spin_unlock_irqrestore(&phba->scsi_buf_list_lock, |
1015 | iflag); | ||
1016 | if (!found) | ||
1017 | return NULL; | ||
1018 | else | ||
1019 | return lpfc_cmd; | ||
997 | } | 1020 | } |
998 | /** | 1021 | /** |
999 | * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list of the HBA | 1022 | * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list of the HBA |
@@ -1981,12 +2004,14 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
1981 | struct scatterlist *sgel = NULL; | 2004 | struct scatterlist *sgel = NULL; |
1982 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; | 2005 | struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; |
1983 | struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl; | 2006 | struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl; |
2007 | struct sli4_sge *first_data_sgl; | ||
1984 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; | 2008 | IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; |
1985 | dma_addr_t physaddr; | 2009 | dma_addr_t physaddr; |
1986 | uint32_t num_bde = 0; | 2010 | uint32_t num_bde = 0; |
1987 | uint32_t dma_len; | 2011 | uint32_t dma_len; |
1988 | uint32_t dma_offset = 0; | 2012 | uint32_t dma_offset = 0; |
1989 | int nseg; | 2013 | int nseg; |
2014 | struct ulp_bde64 *bde; | ||
1990 | 2015 | ||
1991 | /* | 2016 | /* |
1992 | * There are three possibilities here - use scatter-gather segment, use | 2017 | * There are three possibilities here - use scatter-gather segment, use |
@@ -2011,7 +2036,7 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
2011 | bf_set(lpfc_sli4_sge_last, sgl, 0); | 2036 | bf_set(lpfc_sli4_sge_last, sgl, 0); |
2012 | sgl->word2 = cpu_to_le32(sgl->word2); | 2037 | sgl->word2 = cpu_to_le32(sgl->word2); |
2013 | sgl += 1; | 2038 | sgl += 1; |
2014 | 2039 | first_data_sgl = sgl; | |
2015 | lpfc_cmd->seg_cnt = nseg; | 2040 | lpfc_cmd->seg_cnt = nseg; |
2016 | if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { | 2041 | if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { |
2017 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:" | 2042 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:" |
@@ -2047,6 +2072,17 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
2047 | dma_offset += dma_len; | 2072 | dma_offset += dma_len; |
2048 | sgl++; | 2073 | sgl++; |
2049 | } | 2074 | } |
2075 | /* setup the performance hint (first data BDE) if enabled */ | ||
2076 | if (phba->sli3_options & LPFC_SLI4_PERFH_ENABLED) { | ||
2077 | bde = (struct ulp_bde64 *) | ||
2078 | &(iocb_cmd->unsli3.sli3Words[5]); | ||
2079 | bde->addrLow = first_data_sgl->addr_lo; | ||
2080 | bde->addrHigh = first_data_sgl->addr_hi; | ||
2081 | bde->tus.f.bdeSize = | ||
2082 | le32_to_cpu(first_data_sgl->sge_len); | ||
2083 | bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64; | ||
2084 | bde->tus.w = cpu_to_le32(bde->tus.w); | ||
2085 | } | ||
2050 | } else { | 2086 | } else { |
2051 | sgl += 1; | 2087 | sgl += 1; |
2052 | /* clear the last flag in the fcp_rsp map entry */ | 2088 | /* clear the last flag in the fcp_rsp map entry */ |
@@ -2471,6 +2507,16 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2471 | lpfc_worker_wake_up(phba); | 2507 | lpfc_worker_wake_up(phba); |
2472 | break; | 2508 | break; |
2473 | case IOSTAT_LOCAL_REJECT: | 2509 | case IOSTAT_LOCAL_REJECT: |
2510 | case IOSTAT_REMOTE_STOP: | ||
2511 | if (lpfc_cmd->result == IOERR_ELXSEC_KEY_UNWRAP_ERROR || | ||
2512 | lpfc_cmd->result == | ||
2513 | IOERR_ELXSEC_KEY_UNWRAP_COMPARE_ERROR || | ||
2514 | lpfc_cmd->result == IOERR_ELXSEC_CRYPTO_ERROR || | ||
2515 | lpfc_cmd->result == | ||
2516 | IOERR_ELXSEC_CRYPTO_COMPARE_ERROR) { | ||
2517 | cmd->result = ScsiResult(DID_NO_CONNECT, 0); | ||
2518 | break; | ||
2519 | } | ||
2474 | if (lpfc_cmd->result == IOERR_INVALID_RPI || | 2520 | if (lpfc_cmd->result == IOERR_INVALID_RPI || |
2475 | lpfc_cmd->result == IOERR_NO_RESOURCES || | 2521 | lpfc_cmd->result == IOERR_NO_RESOURCES || |
2476 | lpfc_cmd->result == IOERR_ABORT_REQUESTED || | 2522 | lpfc_cmd->result == IOERR_ABORT_REQUESTED || |
@@ -2478,7 +2524,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2478 | cmd->result = ScsiResult(DID_REQUEUE, 0); | 2524 | cmd->result = ScsiResult(DID_REQUEUE, 0); |
2479 | break; | 2525 | break; |
2480 | } | 2526 | } |
2481 | |||
2482 | if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED || | 2527 | if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED || |
2483 | lpfc_cmd->result == IOERR_TX_DMA_FAILED) && | 2528 | lpfc_cmd->result == IOERR_TX_DMA_FAILED) && |
2484 | pIocbOut->iocb.unsli3.sli3_bg.bgstat) { | 2529 | pIocbOut->iocb.unsli3.sli3_bg.bgstat) { |
@@ -2497,7 +2542,17 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2497 | "on unprotected cmd\n"); | 2542 | "on unprotected cmd\n"); |
2498 | } | 2543 | } |
2499 | } | 2544 | } |
2500 | 2545 | if ((lpfc_cmd->status == IOSTAT_REMOTE_STOP) | |
2546 | && (phba->sli_rev == LPFC_SLI_REV4) | ||
2547 | && (pnode && NLP_CHK_NODE_ACT(pnode))) { | ||
2548 | /* This IO was aborted by the target, we don't | ||
2549 | * know the rxid and because we did not send the | ||
2550 | * ABTS we cannot generate and RRQ. | ||
2551 | */ | ||
2552 | lpfc_set_rrq_active(phba, pnode, | ||
2553 | lpfc_cmd->cur_iocbq.sli4_xritag, | ||
2554 | 0, 0); | ||
2555 | } | ||
2501 | /* else: fall through */ | 2556 | /* else: fall through */ |
2502 | default: | 2557 | default: |
2503 | cmd->result = ScsiResult(DID_ERROR, 0); | 2558 | cmd->result = ScsiResult(DID_ERROR, 0); |
@@ -2508,9 +2563,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2508 | || (pnode->nlp_state != NLP_STE_MAPPED_NODE)) | 2563 | || (pnode->nlp_state != NLP_STE_MAPPED_NODE)) |
2509 | cmd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, | 2564 | cmd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, |
2510 | SAM_STAT_BUSY); | 2565 | SAM_STAT_BUSY); |
2511 | } else { | 2566 | } else |
2512 | cmd->result = ScsiResult(DID_OK, 0); | 2567 | cmd->result = ScsiResult(DID_OK, 0); |
2513 | } | ||
2514 | 2568 | ||
2515 | if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) { | 2569 | if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) { |
2516 | uint32_t *lp = (uint32_t *)cmd->sense_buffer; | 2570 | uint32_t *lp = (uint32_t *)cmd->sense_buffer; |
@@ -3004,11 +3058,11 @@ lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
3004 | * transport is still transitioning. | 3058 | * transport is still transitioning. |
3005 | */ | 3059 | */ |
3006 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { | 3060 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
3007 | cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); | 3061 | cmnd->result = ScsiResult(DID_IMM_RETRY, 0); |
3008 | goto out_fail_command; | 3062 | goto out_fail_command; |
3009 | } | 3063 | } |
3010 | if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) | 3064 | if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) |
3011 | goto out_host_busy; | 3065 | goto out_tgt_busy; |
3012 | 3066 | ||
3013 | lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp); | 3067 | lpfc_cmd = lpfc_get_scsi_buf(phba, ndlp); |
3014 | if (lpfc_cmd == NULL) { | 3068 | if (lpfc_cmd == NULL) { |
@@ -3125,6 +3179,9 @@ lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
3125 | out_host_busy: | 3179 | out_host_busy: |
3126 | return SCSI_MLQUEUE_HOST_BUSY; | 3180 | return SCSI_MLQUEUE_HOST_BUSY; |
3127 | 3181 | ||
3182 | out_tgt_busy: | ||
3183 | return SCSI_MLQUEUE_TARGET_BUSY; | ||
3184 | |||
3128 | out_fail_command: | 3185 | out_fail_command: |
3129 | done(cmnd); | 3186 | done(cmnd); |
3130 | return 0; | 3187 | return 0; |