Use the proper SCSI midlayer interfaces for PI
Subsystems (3)
This is the remainder of the PI interface cleanup patches.
Changes since v2:
- lpfc patch remains unchanged.
- For mpt3sas I addressed the zeroday endianness warning and fixed a copy and paste error for the check flags.
Please review, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH v3 1/2 scsi: mpt3sas: Use the proper SCSI midlayer interfaces for PI
Use the SCSI midlayer interfaces to query protection interval, reference tag, and per-command DIX flags.
Cc Sreekanth Reddy <[email protected]>
Cc Kashyap Desai <[email protected]>
Signed-off-by Martin K. Petersen <[email protected]>
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 43 +++++++++------------------- 1 file changed, 13 insertions(+), 30 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +13 -30
@@ -5048,48 +5048,31 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, Mpi25SCSIIORequest_t *mpi_request) {u16 eedp_flags; -unsigned char prot_op =scsi_get_prot_op (scmd); -unsigned char prot_type =scsi_get_prot_type (scmd);Mpi25SCSIIORequest_t *mpi_request_3v = (Mpi25SCSIIORequest_t *)mpi_request; -if (prot_type ==SCSI_PROT_DIF_TYPE0 || prot_op ==SCSI_PROT_NORMAL ) -return ; - -if (prot_op ==SCSI_PROT_READ_STRIP ) +switch (scsi_get_prot_op (scmd)) { +case SCSI_PROT_READ_STRIP : eedp_flags =MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP ; -else if (prot_op ==SCSI_PROT_WRITE_INSERT ) +break ; +case SCSI_PROT_WRITE_INSERT : eedp_flags =MPI2_SCSIIO_EEDPFLAGS_INSERT_OP ; -else +break ; +default :return ; + } -switch (prot_type) { -case SCSI_PROT_DIF_TYPE1 : -case SCSI_PROT_DIF_TYPE2 : +if (scmd->prot_flags &SCSI_PROT_GUARD_CHECK ) + eedp_flags |=MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD ; -/* -* enable ref/guard checking -* auto increment ref tag -*/ +if (scmd->prot_flags &SCSI_PROT_REF_CHECK ) { eedp_flags |=MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG | -MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG | -MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD ; +MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG ; mpi_request->CDB.EEDP32.PrimaryReferenceTag = -cpu_to_be32 (t10_pi_ref_tag (scsi_cmd_to_rq (scmd))); -break ; - -case SCSI_PROT_DIF_TYPE3 : - -/* -* enable guard checking -*/ - eedp_flags |=MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD ; - -break ; +cpu_to_be32 (scsi_prot_ref_tag (scmd)); } - mpi_request_3v->EEDPBlockSize = -cpu_to_le16 (scmd->device->sector_size); + mpi_request_3v->EEDPBlockSize =cpu_to_le16 (scsi_prot_interval (scmd));if (ioc->is_gen35_ioc) eedp_flags |=MPI25_SCSIIO_EEDPFLAGS_APPTAG_DISABLE_MODE ;
Signature · 1 line
2.32.0
PATCH v3 2/2 scsi: lpfc: Use the proper SCSI midlayer interfaces for PI
In reply to Martin K. PetersenUse the SCSI midlayer interfaces to query protection interval, reference tag, per-command DIX flags, and logical block count.
CC James Smart <[email protected]>
CC Dick Kennedy <[email protected]>
Signed-off-by Martin K. Petersen <[email protected]>
--- drivers/scsi/lpfc/lpfc_scsi.c | 120 ++++++++++++++-------------------- 1 file changed, 48 insertions(+), 72 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +48 -72
@@ -96,30 +96,6 @@ static void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmndstatic void lpfc_vmid_assign_cs_ctl (struct lpfc_vport *vport,struct lpfc_vmid *vmid); -static inline unsigned -lpfc_cmd_blksize (struct scsi_cmnd *sc) -{ -return sc->device->sector_size; -} - -#define LPFC_CHECK_PROTECT_GUARD 1 -#define LPFC_CHECK_PROTECT_REF 2 -static inline unsigned -lpfc_cmd_protect (struct scsi_cmnd *sc,int flag) -{ -return 1 ; -} - -static inline unsigned -lpfc_cmd_guard_csum (struct scsi_cmnd *sc) -{ -if (lpfc_prot_group_type (NULL , sc) ==LPFC_PG_TYPE_NO_DIF ) -return 0 ; -if (scsi_host_get_guard (sc->device->host) ==SHOST_DIX_GUARD_IP ) -return 1 ; -return 0 ; -} -/** * lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge. * @phba: Pointer to HBA object.
@@ -1046,13 +1022,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,return 0 ; sgpe =scsi_prot_sglist (sc); - lba =t10_pi_ref_tag (scsi_cmd_to_rq (sc)); + lba =scsi_prot_ref_tag (sc);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 ) { - blksize =lpfc_cmd_blksize (sc); + blksize =scsi_prot_interval (sc); numblks = (scsi_bufflen (sc) + blksize -1 ) / blksize;/* Make sure we have the right LBA if one is specified */
@@ -1441,7 +1417,7 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc, {uint8_t ret =0 ; -if (lpfc_cmd_guard_csum (sc)) { +if (sc->prot_flags &SCSI_PROT_IP_CHECKSUM ) {switch (scsi_get_prot_op (sc)) {case SCSI_PROT_READ_INSERT :case SCSI_PROT_WRITE_STRIP :
@@ -1521,7 +1497,7 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc, {uint8_t ret =0 ; -if (lpfc_cmd_guard_csum (sc)) { +if (sc->prot_flags &SCSI_PROT_IP_CHECKSUM ) {switch (scsi_get_prot_op (sc)) {case SCSI_PROT_READ_INSERT :case SCSI_PROT_WRITE_STRIP :
@@ -1629,7 +1605,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc, goto out;/* extract some info from the scsi command for pde*/ - reftag =t10_pi_ref_tag (scsi_cmd_to_rq (sc)); + reftag =scsi_prot_ref_tag (sc);if (reftag ==LPFC_INVALID_REFTAG ) goto out;
@@ -1668,12 +1644,12 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,* protection data is automatically generated, not checked. */ if (datadir ==DMA_FROM_DEVICE ) { -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_GUARD )) +if (sc->prot_flags &SCSI_PROT_GUARD_CHECK )bf_set (pde6_ce, pde6, checking);else bf_set (pde6_ce, pde6,0 ); -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_REF )) +if (sc->prot_flags &SCSI_PROT_REF_CHECK )bf_set (pde6_re, pde6, checking);else bf_set (pde6_re, pde6,0 );
@@ -1791,8 +1767,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, goto out;/* extract some info from the scsi command */ - blksize =lpfc_cmd_blksize (sc); - reftag =t10_pi_ref_tag (scsi_cmd_to_rq (sc)); + blksize =scsi_prot_interval (sc); + reftag =scsi_prot_ref_tag (sc);if (reftag ==LPFC_INVALID_REFTAG ) goto out;
@@ -1832,12 +1808,12 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,bf_set (pde6_optx, pde6, txop);bf_set (pde6_oprx, pde6, rxop); -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_GUARD )) +if (sc->prot_flags &SCSI_PROT_GUARD_CHECK )bf_set (pde6_ce, pde6, checking);else bf_set (pde6_ce, pde6,0 ); -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_REF )) +if (sc->prot_flags &SCSI_PROT_REF_CHECK )bf_set (pde6_re, pde6, checking);else bf_set (pde6_re, pde6,0 );
@@ -2023,7 +1999,7 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc, goto out;/* extract some info from the scsi command for pde*/ - reftag =t10_pi_ref_tag (scsi_cmd_to_rq (sc)); + reftag =scsi_prot_ref_tag (sc);if (reftag ==LPFC_INVALID_REFTAG ) goto out;
@@ -2051,12 +2027,12 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,* protection data is automatically generated, not checked. */ if (sc->sc_data_direction ==DMA_FROM_DEVICE ) { -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_GUARD )) +if (sc->prot_flags &SCSI_PROT_GUARD_CHECK )bf_set (lpfc_sli4_sge_dif_ce, diseed, checking);else bf_set (lpfc_sli4_sge_dif_ce, diseed,0 ); -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_REF )) +if (sc->prot_flags &SCSI_PROT_REF_CHECK )bf_set (lpfc_sli4_sge_dif_re, diseed, checking);else bf_set (lpfc_sli4_sge_dif_re, diseed,0 );
@@ -2223,8 +2199,8 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, goto out;/* extract some info from the scsi command */ - blksize =lpfc_cmd_blksize (sc); - reftag =t10_pi_ref_tag (scsi_cmd_to_rq (sc)); + blksize =scsi_prot_interval (sc); + reftag =scsi_prot_ref_tag (sc);if (reftag ==LPFC_INVALID_REFTAG ) goto out;
@@ -2281,9 +2257,8 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, diseed->ref_tag =cpu_to_le32 (reftag); diseed->ref_tag_tran = diseed->ref_tag; -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_GUARD )) { +if (sc->prot_flags &SCSI_PROT_GUARD_CHECK ) {bf_set (lpfc_sli4_sge_dif_ce, diseed, checking); - }else {bf_set (lpfc_sli4_sge_dif_ce, diseed,0 );/*
@@ -2300,7 +2275,7 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, } -if (lpfc_cmd_protect (sc,LPFC_CHECK_PROTECT_REF )) +if (sc->prot_flags &SCSI_PROT_REF_CHECK )bf_set (lpfc_sli4_sge_dif_re, diseed, checking);else bf_set (lpfc_sli4_sge_dif_re, diseed,0 );
@@ -2557,7 +2532,7 @@ lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba,* DIF (trailer) attached to it. Must ajust FCP data length * to account for the protection data. */ - fcpdl += (fcpdl /lpfc_cmd_blksize (sc)) *8 ; + fcpdl += (fcpdl /scsi_prot_interval (sc)) *8 ;return fcpdl; }
@@ -2811,14 +2786,14 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)* data length is a multiple of the blksize. */ sgde =scsi_sglist (cmd); - blksize =lpfc_cmd_blksize (cmd); + blksize =scsi_prot_interval (cmd); data_src = (uint8_t *)sg_virt (sgde); data_len = sgde->length;if ((data_len & (blksize -1 )) ==0 ) chk_guard =1 ; src = (struct scsi_dif_tuple *)sg_virt (sgpe); - start_ref_tag =t10_pi_ref_tag (scsi_cmd_to_rq (cmd)); + start_ref_tag =scsi_prot_ref_tag (cmd);if (start_ref_tag ==LPFC_INVALID_REFTAG ) goto out; start_app_tag = src->app_tag;
@@ -2839,7 +2814,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)/* First Guard Tag checking */ if (chk_guard) { guard_tag = src->guard_tag; -if (lpfc_cmd_guard_csum (cmd)) +if (cmd->prot_flags + &SCSI_PROT_IP_CHECKSUM ) sum =lpfc_bg_csum (data_src, blksize);else
@@ -2910,7 +2886,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) phba->bg_guard_err_cnt++;lpfc_printf_log (phba,KERN_WARNING ,LOG_FCP |LOG_BG ,"9069 BLKGRD: reftag %x grd_tag err %x != %x\n" , -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), +scsi_prot_ref_tag (cmd), sum, guard_tag); }else if (err_type ==BGS_REFTAG_ERR_MASK ) {
@@ -2920,7 +2896,7 @@ lpfc_calc_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 ,"9066 BLKGRD: reftag %x ref_tag err %x != %x\n" , -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), +scsi_prot_ref_tag (cmd), ref_tag, start_ref_tag); }else if (err_type ==BGS_APPTAG_ERR_MASK ) {
@@ -2930,7 +2906,7 @@ lpfc_calc_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 ,"9041 BLKGRD: reftag %x app_tag err %x != %x\n" , -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), +scsi_prot_ref_tag (cmd), app_tag, start_app_tag); } }
@@ -2992,7 +2968,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd," 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], (unsigned long long )scsi_get_lba (cmd), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_reftag_err (bgstat)) {
@@ -3007,7 +2983,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd," 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], (unsigned long long )scsi_get_lba (cmd), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_apptag_err (bgstat)) {
@@ -3022,7 +2998,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd," 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], (unsigned long long )scsi_get_lba (cmd), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_hi_water_mark_present (bgstat)) {
@@ -3066,9 +3042,9 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd," 0x%x lba 0x%llx blk cnt 0x%x " "bgstat=x%x bghm=x%x\n" , cmd->cmnd[0 ], (unsigned long long )scsi_get_lba (cmd), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm); -/* Calcuate what type of error it was */ +/* Calculate what type of error it was */ lpfc_calc_bg_err (phba, lpfc_cmd); }return ret;
@@ -3103,8 +3079,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); ret = (-1 ); goto out; }
@@ -3115,8 +3091,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); ret = (-1 ); goto out; }
@@ -3131,8 +3107,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_reftag_err (bgstat)) {
@@ -3146,8 +3122,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_apptag_err (bgstat)) {
@@ -3161,8 +3137,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_hi_water_mark_present (bgstat)) {
@@ -3205,10 +3181,10 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,"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 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmd)), - blk_rq_sectors(scsi_cmd_to_rq(cmd)), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); -/* Calcuate what type of error it was */ +/* Calculate what type of error it was */ lpfc_calc_bg_err (phba, lpfc_cmd); } out:
@@ -5549,8 +5525,8 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)"reftag x%x cnt %u pt %x\n" , dif_op_str[scsi_get_prot_op (cmnd)], cmnd->cmnd[0 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmnd)), -blk_rq_sectors (scsi_cmd_to_rq (cmnd)), +scsi_prot_ref_tag (cmnd), +scsi_logical_block_count (cmnd), (cmnd->cmnd[1]>>5)); } err =lpfc_bg_scsi_prep_dma_buf (phba, lpfc_cmd);
@@ -5561,8 +5537,8 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)"9038 BLKGRD: rcvd PROT_NORMAL cmd: " "x%x reftag x%x cnt %u pt %x\n" , cmnd->cmnd[0 ], -t10_pi_ref_tag (scsi_cmd_to_rq (cmnd)), -blk_rq_sectors (scsi_cmd_to_rq (cmnd)), +scsi_prot_ref_tag (cmnd), +scsi_logical_block_count (cmnd), (cmnd->cmnd[1]>>5)); } err =lpfc_scsi_prep_dma_buf (phba, lpfc_cmd);
Signature · 1 line
2.32.0