diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
| -rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 124 | 
1 files changed, 69 insertions, 55 deletions
| diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index a4d697373c71..eefbb9b22798 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -1,8 +1,8 @@  /*******************************************************************   * This file is part of the Emulex Linux Device Driver for         *   * Fibre Channel Host Bus Adapters.                                * - * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term * - * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  * + * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *   * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *   * EMULEX and SLI are trademarks of Emulex.                        *   * www.broadcom.com                                                * @@ -132,6 +132,8 @@ lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,  	}  } +#define LPFC_INVALID_REFTAG ((u32)-1) +  /**   * lpfc_update_stats - Update statistical data for the command completion   * @vport: The virtual port on which this call is executing. @@ -734,7 +736,7 @@ lpfc_get_scsi_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,  }  /** - * lpfc_release_scsi_buf - Return a scsi buffer back to hba scsi buf list + * lpfc_release_scsi_buf_s3 - Return a scsi buffer back to hba scsi buf list   * @phba: The Hba for which this call is being executed.   * @psb: The scsi buffer which is being released.   * @@ -972,10 +974,10 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)  #define BG_ERR_TGT	0x2  /* Return BG_ERR_SWAP if swapping CSUM<-->CRC is required for error injection */  #define BG_ERR_SWAP	0x10 -/** +/*   * Return BG_ERR_CHECK if disabling Guard/Ref/App checking is required for   * error injection - **/ + */  #define BG_ERR_CHECK	0x20  /** @@ -1000,7 +1002,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,  	uint32_t op = scsi_get_prot_op(sc);  	uint32_t blksize;  	uint32_t numblks; -	sector_t lba; +	u32 lba;  	int rc = 0;  	int blockoff = 0; @@ -1008,7 +1010,9 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,  		return 0;  	sgpe = scsi_prot_sglist(sc); -	lba = scsi_get_lba(sc); +	lba = t10_pi_ref_tag(sc->request); +	if (lba == LPFC_INVALID_REFTAG) +		return 0;  	/* First check if we need to match the LBA */  	if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) { @@ -1016,11 +1020,11 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,  		numblks = (scsi_bufflen(sc) + blksize - 1) / blksize;  		/* Make sure we have the right LBA if one is specified */ -		if ((phba->lpfc_injerr_lba < lba) || -			(phba->lpfc_injerr_lba >= (lba + numblks))) +		if (phba->lpfc_injerr_lba < (u64)lba || +		    (phba->lpfc_injerr_lba >= (u64)(lba + numblks)))  			return 0;  		if (sgpe) { -			blockoff = phba->lpfc_injerr_lba - lba; +			blockoff = phba->lpfc_injerr_lba - (u64)lba;  			numblks = sg_dma_len(sgpe) /  				sizeof(struct scsi_dif_tuple);  			if (numblks < blockoff) @@ -1589,7 +1593,9 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,  		goto out;  	/* extract some info from the scsi command for pde*/ -	reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ +	reftag = t10_pi_ref_tag(sc->request); +	if (reftag == LPFC_INVALID_REFTAG) +		goto out;  #ifdef CONFIG_SCSI_LPFC_DEBUG_FS  	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1); @@ -1750,7 +1756,9 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,  	/* extract some info from the scsi command */  	blksize = lpfc_cmd_blksize(sc); -	reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ +	reftag = t10_pi_ref_tag(sc->request); +	if (reftag == LPFC_INVALID_REFTAG) +		goto out;  #ifdef CONFIG_SCSI_LPFC_DEBUG_FS  	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1); @@ -1979,7 +1987,9 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,  		goto out;  	/* extract some info from the scsi command for pde*/ -	reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ +	reftag = t10_pi_ref_tag(sc->request); +	if (reftag == LPFC_INVALID_REFTAG) +		goto out;  #ifdef CONFIG_SCSI_LPFC_DEBUG_FS  	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1); @@ -2178,7 +2188,9 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,  	/* extract some info from the scsi command */  	blksize = lpfc_cmd_blksize(sc); -	reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ +	reftag = t10_pi_ref_tag(sc->request); +	if (reftag == LPFC_INVALID_REFTAG) +		goto out;  #ifdef CONFIG_SCSI_LPFC_DEBUG_FS  	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1); @@ -2770,7 +2782,9 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)  			chk_guard = 1;  		src = (struct scsi_dif_tuple *)sg_virt(sgpe); -		start_ref_tag = (uint32_t)scsi_get_lba(cmd); /* Truncate LBA */ +		start_ref_tag = t10_pi_ref_tag(cmd->request); +		if (start_ref_tag == LPFC_INVALID_REFTAG) +			goto out;  		start_app_tag = src->app_tag;  		len = sgpe->length;  		while (src && protsegcnt) { @@ -2861,8 +2875,8 @@ out:  			      SAM_STAT_CHECK_CONDITION;  		phba->bg_guard_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9069 BLKGRD: LBA %lx grd_tag error %x != %x\n", -				(unsigned long)scsi_get_lba(cmd), +				"9069 BLKGRD: reftag %x grd_tag err %x != %x\n", +				t10_pi_ref_tag(cmd->request),  				sum, guard_tag);  	} else if (err_type == BGS_REFTAG_ERR_MASK) { @@ -2873,8 +2887,8 @@ out:  		phba->bg_reftag_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9066 BLKGRD: LBA %lx ref_tag error %x != %x\n", -				(unsigned long)scsi_get_lba(cmd), +				"9066 BLKGRD: reftag %x ref_tag err %x != %x\n", +				t10_pi_ref_tag(cmd->request),  				ref_tag, start_ref_tag);  	} else if (err_type == BGS_APPTAG_ERR_MASK) { @@ -2885,8 +2899,8 @@ out:  		phba->bg_apptag_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9041 BLKGRD: LBA %lx app_tag error %x != %x\n", -				(unsigned long)scsi_get_lba(cmd), +				"9041 BLKGRD: reftag %x app_tag err %x != %x\n", +				t10_pi_ref_tag(cmd->request),  				app_tag, start_app_tag);  	}  } @@ -3062,10 +3076,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  	if (lpfc_bgs_get_invalid_prof(bgstat)) {  		cmd->result = DID_ERROR << 16;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9072 BLKGRD: Invalid BG Profile in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9072 BLKGRD: Invalid BG Profile in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  		ret = (-1);  		goto out; @@ -3074,10 +3088,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  	if (lpfc_bgs_get_uninit_dif_block(bgstat)) {  		cmd->result = DID_ERROR << 16;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9073 BLKGRD: Invalid BG PDIF Block in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9073 BLKGRD: Invalid BG PDIF Block in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  		ret = (-1);  		goto out; @@ -3092,10 +3106,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  			      SAM_STAT_CHECK_CONDITION;  		phba->bg_guard_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9055 BLKGRD: Guard Tag error in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9055 BLKGRD: Guard Tag error in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  	} @@ -3109,10 +3123,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  		phba->bg_reftag_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9056 BLKGRD: Ref Tag error in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9056 BLKGRD: Ref Tag error in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  	} @@ -3126,10 +3140,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  		phba->bg_apptag_err_cnt++;  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9061 BLKGRD: App Tag error in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9061 BLKGRD: App Tag error in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  	} @@ -3170,10 +3184,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,  	if (!ret) {  		/* No error was reported - problem in FW? */  		lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, -				"9057 BLKGRD: Unknown error in cmd" -				" 0x%x lba 0x%llx blk cnt 0x%x " +				"9057 BLKGRD: Unknown error in cmd " +				"0x%x reftag 0x%x blk cnt 0x%x "  				"bgstat=x%x bghm=x%x\n", cmd->cmnd[0], -				(unsigned long long)scsi_get_lba(cmd), +				t10_pi_ref_tag(cmd->request),  				blk_rq_sectors(cmd->request), bgstat, bghm);  		/* Calcuate what type of error it was */ @@ -3685,7 +3699,7 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)  /**   * lpfc_scsi_prep_cmnd_buf - Wrapper function for IOCB/WQE mapping of scsi   * buffer - * @phba: The Hba for which this call is being executed. + * @vport: Pointer to vport object.   * @lpfc_cmd: The scsi buffer which is going to be mapped.   * @tmo: Timeout value for IO   * @@ -3707,7 +3721,7 @@ lpfc_scsi_prep_cmnd_buf(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,   * @phba: Pointer to hba context object.   * @vport: Pointer to vport object.   * @lpfc_cmd: Pointer to lpfc scsi command which reported the error. - * @rsp_iocb: Pointer to response iocb object which reported error. + * @fcpi_parm: FCP Initiator parameter.   *   * This function posts an event when there is a SCSI command reporting   * error from the scsi device. @@ -3822,10 +3836,10 @@ lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_io_buf *psb)  }  /** - * lpfc_handler_fcp_err - FCP response handler + * lpfc_handle_fcp_err - FCP response handler   * @vport: The virtual port for which this call is being executed.   * @lpfc_cmd: Pointer to lpfc_io_buf data structure. - * @rsp_iocb: The response IOCB which contains FCP error. + * @fcpi_parm: FCP Initiator parameter.   *   * This routine is called to process response IOCB with status field   * IOSTAT_FCP_RSP_ERROR. This routine sets result field of scsi command @@ -4009,7 +4023,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,   * lpfc_fcp_io_cmd_wqe_cmpl - Complete a FCP IO   * @phba: The hba for which this call is being executed.   * @pwqeIn: The command WQE for the scsi cmnd. - * @pwqeOut: The response WQE for the scsi cmnd. + * @wcqe: Pointer to driver response CQE object.   *   * This routine assigns scsi command result by looking into response WQE   * status field appropriately. This routine handles QUEUE FULL condition as @@ -4060,7 +4074,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,  	/* Sanity check on return of outstanding command */  	cmd = lpfc_cmd->pCmd; -	if (!cmd || !phba) { +	if (!cmd) {  		lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,  				 "9042 I/O completion: Not an active IO\n");  		spin_unlock(&lpfc_cmd->buf_lock); @@ -4278,7 +4292,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,  		u32 *lp = (u32 *)cmd->sense_buffer;  		lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, -				 "9039 Iodone <%d/%llu> cmd x%p, error " +				 "9039 Iodone <%d/%llu> cmd x%px, error "  				 "x%x SNS x%x x%x Data: x%x x%x\n",  				 cmd->device->id, cmd->device->lun, cmd,  				 cmd->result, *lp, *(lp + 3), cmd->retries, @@ -4605,7 +4619,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,  /**   * lpfc_scsi_prep_cmnd_buf_s3 - SLI-3 IOCB init for the IO - * @phba: Pointer to vport object for which I/O is executed + * @vport: Pointer to vport object.   * @lpfc_cmd: The scsi buffer which is going to be prep'ed.   * @tmo: timeout value for the IO   * @@ -4682,7 +4696,7 @@ static int lpfc_scsi_prep_cmnd_buf_s3(struct lpfc_vport *vport,  /**   * lpfc_scsi_prep_cmnd_buf_s4 - SLI-4 WQE init for the IO - * @phba: Pointer to vport object for which I/O is executed + * @vport: Pointer to vport object.   * @lpfc_cmd: The scsi buffer which is going to be prep'ed.   * @tmo: timeout value for the IO   * @@ -4939,7 +4953,7 @@ lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp)  }  /** - * lpfc_taskmgmt_def_cmpl - IOCB completion routine for task management command + * lpfc_tskmgmt_def_cmpl - IOCB completion routine for task management command   * @phba: The Hba for which this call is being executed.   * @cmdiocbq: Pointer to lpfc_iocbq data structure.   * @rspiocbq: Pointer to lpfc_iocbq data structure. @@ -4998,7 +5012,7 @@ lpfc_check_pci_resettable(struct lpfc_hba *phba)  			break;  		default:  			lpfc_printf_log(phba, KERN_INFO, LOG_INIT, -					"8347 Invalid device found: " +					"8347 Incapable PCI reset device: "  					"0x%04x\n", ptr->device);  			return -EBADSLT;  		} @@ -5084,7 +5098,7 @@ buffer_done:  }  /** - * lpfc_poll_rearm_time - Routine to modify fcp_poll timer of hba + * lpfc_poll_rearm_timer - Routine to modify fcp_poll timer of hba   * @phba: The Hba for which this call is being executed.   *   * This routine modifies fcp_poll_timer  field of @phba by cfg_poll_tmo. @@ -5252,10 +5266,10 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)  			lpfc_printf_vlog(vport,  					 KERN_INFO, LOG_SCSI_CMD,  					 "9033 BLKGRD: rcvd %s cmd:x%x " -					 "sector x%llx cnt %u pt %x\n", +					 "reftag x%x cnt %u pt %x\n",  					 dif_op_str[scsi_get_prot_op(cmnd)],  					 cmnd->cmnd[0], -					 (unsigned long long)scsi_get_lba(cmnd), +					 t10_pi_ref_tag(cmnd->request),  					 blk_rq_sectors(cmnd->request),  					 (cmnd->cmnd[1]>>5));  		} @@ -5265,9 +5279,9 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)  			lpfc_printf_vlog(vport,  					 KERN_INFO, LOG_SCSI_CMD,  					 "9038 BLKGRD: rcvd PROT_NORMAL cmd: " -					 "x%x sector x%llx cnt %u pt %x\n", +					 "x%x reftag x%x cnt %u pt %x\n",  					 cmnd->cmnd[0], -					 (unsigned long long)scsi_get_lba(cmnd), +					 t10_pi_ref_tag(cmnd->request),  					 blk_rq_sectors(cmnd->request),  					 (cmnd->cmnd[1]>>5));  		} | 
