Use the proper SCSI midlayer interface for PI
Subsystems (5)
This is the remainder of the PI interface cleanup patches which remove the guesswork about what and how to check from the low-level drivers.
There are no functional changes since v1. I renamed the function to get the logical block count as requested by Bart and updated the driver patches accordingly.
Please review!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH v2 1/5 scsi: core: Add helper to return number of logical blocks in a request
--- include/scsi/scsi_cmnd.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/scsi/scsi_cmnd.h +7 -0
@@ -232,6 +232,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)return blk_rq_pos (scmd->request) >> shift; } +static inline unsigned int scsi_logical_block_count (struct scsi_cmnd *scmd) +{ +unsigned int shift =ilog2 (scmd->device->sector_size) -SECTOR_SHIFT ; + +return blk_rq_bytes (scmd->request) >> shift; +} +/* * The operations below are hints that tell the controller driver how * to handle I/Os with DIF or similar types of protection information.
Signature · 1 line
2.32.0
Re: [PATCH v2 1/5] scsi: core: Add helper to return number of logical blocks in a request
Quoted 11 lines · Martin K. Petersen
Cc Bart Van Assche <[email protected]>Signed-off-by Martin K. Petersen <[email protected]>--- include/scsi/scsi_cmnd.h | 7 +++++++ 1 file changed, 7 insertions(+)include/scsi/scsi_cmnd.h +0
-0
include/scsi/scsi_cmnd.h static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) · line 240
Quoted 9 lines
include/scsi/scsi_cmnd.h +6
-0@@ -232,6 +232,13 @@ static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)return blk_rq_pos (scmd->request) >> shift; } +static inline unsigned int scsi_logical_block_count (struct scsi_cmnd *scmd) +{ +unsigned int shift =ilog2 (scmd->device->sector_size) -SECTOR_SHIFT ; + +return blk_rq_bytes (scmd->request) >> shift; +}
Martin K. Petersen
AppliedRe: [PATCH v2 1/5] scsi: core: Add helper to return number of logical blocks in a request
In reply to Martin K. PetersenQuoted 1 line · Martin K. Petersen
Applied to 5.15/scsi-queue, thanks!
[1/5] scsi: core: Add helper to return number of logical blocks in a request
https://git.kernel.org/mkp/scsi/c/6a20e21ae1e2 [2/5] scsi: isci: Use the proper SCSI midlayer interfaces for PI https://git.kernel.org/mkp/scsi/c/4cc0096e2d54 [3/5] scsi: mpi3mr: Use the proper SCSI midlayer interfaces for PI https://git.kernel.org/mkp/scsi/c/92cc94adfce4
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH v2 2/5 scsi: isci: Use the proper SCSI midlayer interfaces for PI
In reply to Martin K. PetersenUse scsi_prot_ref_tag() instead of scsi_get_lba() to get the reference tag for a given I/O.
--- drivers/scsi/isci/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/isci/request.c +2 -2
@@ -341,7 +341,7 @@ static void scu_ssp_ireq_dif_insert(struct isci_request *ireq, u8 type, u8 op) tc->reserved_E8_0 =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_gen =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_gen =scsi_prot_ref_tag (scmd);else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_gen =0 ; }
@@ -369,7 +369,7 @@ static void scu_ssp_ireq_dif_strip(struct isci_request *ireq, u8 type, u8 op) tc->app_tag_gen =0 ;if ((type &SCSI_PROT_DIF_TYPE1 ) || (type &SCSI_PROT_DIF_TYPE2 )) - tc->ref_tag_seed_verify =scsi_get_lba (scmd) &0xffffffff ; + tc->ref_tag_seed_verify =scsi_prot_ref_tag (scmd);else if (type &SCSI_PROT_DIF_TYPE3 ) tc->ref_tag_seed_verify =0 ;
Signature · 1 line
2.32.0
Re: [PATCH v2 2/5] scsi: isci: Use the proper SCSI midlayer interfaces for PI
Quoted 2 lines · Martin K. Petersen
Use
scsi_prot_ref_tag()instead ofscsi_get_lba()to get the reference tag for a given I/O.
PATCH v2 3/5 scsi: mpi3mr: Use the proper SCSI midlayer interfaces for PI
In reply to Martin K. PetersenUse the SCSI midlayer interfaces to query protection interval, reference tag, and per-command DIX flags
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 59 +++++++++++---------------------- 1 file changed, 20 insertions(+), 39 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +20 -39
@@ -1963,7 +1963,6 @@ static void mpi3mr_setup_eedp(struct mpi3mr_ioc *mrioc, {u16 eedp_flags =0 ;unsigned char prot_op =scsi_get_prot_op (scmd); -unsigned char prot_type =scsi_get_prot_type (scmd);switch (prot_op) {case SCSI_PROT_NORMAL :
@@ -1983,60 +1982,42 @@ static void mpi3mr_setup_eedp(struct mpi3mr_ioc *mrioc, scsiio_req->msg_flags |=MPI3_SCSIIO_MSGFLAGS_METASGL_VALID ;break ;case SCSI_PROT_READ_PASS : - eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK | -MPI3_EEDPFLAGS_CHK_REF_TAG |MPI3_EEDPFLAGS_CHK_APP_TAG | -MPI3_EEDPFLAGS_CHK_GUARD ; + eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK ; scsiio_req->msg_flags |=MPI3_SCSIIO_MSGFLAGS_METASGL_VALID ;break ;case SCSI_PROT_WRITE_PASS : -if (scsi_host_get_guard (scmd->device->host) - &SHOST_DIX_GUARD_IP ) { - eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK_REGEN | -MPI3_EEDPFLAGS_CHK_APP_TAG | -MPI3_EEDPFLAGS_CHK_GUARD | -MPI3_EEDPFLAGS_INCR_PRI_REF_TAG ; +if (scmd->prot_flags &SCSI_PROT_IP_CHECKSUM ) { + eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK_REGEN ; scsiio_req->sgl[0 ].eedp.application_tag_translation_mask =0xffff ; - }else { - eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK | -MPI3_EEDPFLAGS_CHK_REF_TAG | -MPI3_EEDPFLAGS_CHK_APP_TAG | -MPI3_EEDPFLAGS_CHK_GUARD ; - } + }else + eedp_flags =MPI3_EEDPFLAGS_EEDP_OP_CHECK ; + scsiio_req->msg_flags |=MPI3_SCSIIO_MSGFLAGS_METASGL_VALID ;break ;default :return ; } -if (scsi_host_get_guard (scmd->device->host) &SHOST_DIX_GUARD_IP ) +if (scmd->prot_flags &SCSI_PROT_GUARD_CHECK ) + eedp_flags |=MPI3_EEDPFLAGS_CHK_GUARD ; + +if (scmd->prot_flags &SCSI_PROT_IP_CHECKSUM ) eedp_flags |=MPI3_EEDPFLAGS_HOST_GUARD_IP_CHKSUM ; -switch (prot_type) { -case SCSI_PROT_DIF_TYPE0 : - eedp_flags |=MPI3_EEDPFLAGS_INCR_PRI_REF_TAG ; +if (scmd->prot_flags &SCSI_PROT_REF_CHECK ) { + eedp_flags |=MPI3_EEDPFLAGS_CHK_REF_TAG | +MPI3_EEDPFLAGS_INCR_PRI_REF_TAG ; scsiio_req->cdb.eedp32.primary_reference_tag = -cpu_to_be32 (t10_pi_ref_tag (scmd->request)); -break ; -case SCSI_PROT_DIF_TYPE1 : -case SCSI_PROT_DIF_TYPE2 : - eedp_flags |=MPI3_EEDPFLAGS_INCR_PRI_REF_TAG | -MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE | -MPI3_EEDPFLAGS_CHK_GUARD ; - scsiio_req->cdb.eedp32.primary_reference_tag = -cpu_to_be32 (t10_pi_ref_tag (scmd->request)); -break ; -case SCSI_PROT_DIF_TYPE3 : - eedp_flags |=MPI3_EEDPFLAGS_CHK_GUARD | -MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE ; -break ; - -default : - scsiio_req->msg_flags &= ~(MPI3_SCSIIO_MSGFLAGS_METASGL_VALID ); -return ; +cpu_to_be32 (scsi_prot_ref_tag (scmd)); } -switch (scmd->device->sector_size) { +if (scmd->prot_flags &SCSI_PROT_REF_INCREMENT ) + eedp_flags |=MPI3_EEDPFLAGS_INCR_PRI_REF_TAG ; + + eedp_flags |=MPI3_EEDPFLAGS_ESC_MODE_APPTAG_DISABLE ; + +switch (scsi_prot_interval (scmd)) {case 512 : scsiio_req->sgl[0 ].eedp.user_data_size =MPI3_EEDP_UDS_512 ;break ;
Signature · 1 line
2.32.0
RE: [PATCH v2 3/5] scsi: mpi3mr: Use the proper SCSI midlayer interfaces for PI
Quoted 1 line
Subject: [PATCH v2 3/5] scsi: mpi3mr: Use the proper SCSI midlayer
interfaces
Quoted 3 lines
for PI
Use the SCSI midlayer interfaces to query protection interval, reference
tag,
Quoted 9 lines
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/mpi3mr/mpi3mr_os.c | 59 +++++++++++---------------------- 1 file changed, 20 insertions(+), 39 deletions(-)
PATCH v2 4/5 scsi: mpt3sas: Use the proper SCSI midlayer interfaces for PI
In reply to Martin K. PetersenUse the SCSI midlayer interfaces to query protection interval, reference tag, and per-command DIX flags.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +6 -22
@@ -5062,33 +5062,17 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,else return ; -switch (prot_type) { -case SCSI_PROT_DIF_TYPE1 : -case SCSI_PROT_DIF_TYPE2 : +if (scmd->prot_op &SCSI_PROT_GUARD_CHECK ) + eedp_flags |=MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD ; -/* -* enable ref/guard checking -* auto increment ref tag -*/ +if (scmd->prot_op &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 (scmd->request)); -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 =scsi_prot_interval (scmd);if (ioc->is_gen35_ioc) eedp_flags |=MPI25_SCSIIO_EEDPFLAGS_APPTAG_DISABLE_MODE ;
Signature · 1 line
2.32.0
kernel test robot
build botRe: [PATCH v2 4/5] scsi: mpt3sas: Use the proper SCSI midlayer interfaces for PI
I love your patch! Perhaps something to improve:
Hi "Martin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next next-20210806] [cannot apply to v5.14-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Martin-K-Petersen/scsi-core-Add-helper-to-return-number-of-logical-blocks-in-a-request/20210806-130031 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: arm64-randconfig-s032-20210806 (attached as .config) compiler: aarch64-linux-gcc (GCC) 10.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-348-gf0e6938b-dirty
# https://github.com/0day-ci/linux/commit/953afbb2ac9054f86b27ff634dbaf8311e27b6aa
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Martin-K-Petersen/scsi-core-Add-helper-to-return-number-of-logical-blocks-in-a-request/20210806-130031 git checkout 953afbb2ac9054f86b27ff634dbaf8311e27b6aa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/scsi/mpt3sas/mpt3sas_scsih.c:5075:39: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] EEDPBlockSize @@ got unsigned int @@
drivers/scsi/mpt3sas/mpt3sas_scsih.c:5075:39: sparse: expected restricted __le16 [usertype] EEDPBlockSize
drivers/scsi/mpt3sas/mpt3sas_scsih.c:5075:39: sparse: got unsigned int
drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10843:25: sparse: sparse: cast to restricted __le32
vim +5075 drivers/scsi/mpt3sas/mpt3sas_scsih.c
5036
5037 /**
5038 * _scsih_setup_eedp - setup MPI request for EEDP transfer
5039 * @ioc: per adapter object
5040 * @scmd: pointer to scsi command object
5041 * @mpi_request: pointer to the SCSI_IO request message frame
5042 *
5043 * Supporting protection 1 and 3.
5044 */
5045 static void
5046 _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
5047 Mpi25SCSIIORequest_t *mpi_request)
5048 {
5049 u16 eedp_flags;
5050 unsigned char prot_op = scsi_get_prot_op(scmd);
5051 unsigned char prot_type = scsi_get_prot_type(scmd);
5052 Mpi25SCSIIORequest_t *mpi_request_3v =
5053 (Mpi25SCSIIORequest_t *)mpi_request;
5054
5055 if (prot_type == SCSI_PROT_DIF_TYPE0 || prot_op == SCSI_PROT_NORMAL)
5056 return;
5057
5058 if (prot_op == SCSI_PROT_READ_STRIP)
5059 eedp_flags = MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP;
5060 else if (prot_op == SCSI_PROT_WRITE_INSERT)
5061 eedp_flags = MPI2_SCSIIO_EEDPFLAGS_INSERT_OP;
5062 else
5063 return;
5064
5065 if (scmd->prot_op & SCSI_PROT_GUARD_CHECK)
5066 eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
5067
5068 if (scmd->prot_op & SCSI_PROT_REF_CHECK) {
5069 eedp_flags |= MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG |
5070 MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG;
5071 mpi_request->CDB.EEDP32.PrimaryReferenceTag =
5072 cpu_to_be32(scsi_prot_ref_tag(scmd));
5073 }
5074
> 5075 mpi_request_3v->EEDPBlockSize = scsi_prot_interval(scmd);
5076
5077 if (ioc->is_gen35_ioc)
5078 eedp_flags |= MPI25_SCSIIO_EEDPFLAGS_APPTAG_DISABLE_MODE;
5079 mpi_request->EEDPFlags = cpu_to_le16(eedp_flags);
5080 }
5081
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v2 5/5 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.
--- drivers/scsi/lpfc/lpfc_scsi.c | 116 ++++++++++++++-------------------- 1 file changed, 46 insertions(+), 70 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +46 -70
@@ -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 (sc->request); + 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 (sc->request); + 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 (sc->request); + 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 (sc->request); + 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 (sc->request); + 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 (cmd->request); + 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 (cmd->request), +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 (cmd->request), +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 (cmd->request), +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(cmd->request), 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(cmd->request), 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(cmd->request), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_hi_water_mark_present (bgstat)) {
@@ -3066,7 +3042,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(cmd->request), bgstat, bghm); + scsi_logical_block_count(cmd), bgstat, bghm);/* Calcuate what type of error it was */ lpfc_calc_bg_err (phba, lpfc_cmd);
@@ -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 (cmd->request), - blk_rq_sectors(cmd->request), 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 (cmd->request), - blk_rq_sectors(cmd->request), 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 (cmd->request), - blk_rq_sectors(cmd->request), 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 (cmd->request), - blk_rq_sectors(cmd->request), 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 (cmd->request), - blk_rq_sectors(cmd->request), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm); }if (lpfc_bgs_get_hi_water_mark_present (bgstat)) {
@@ -3205,8 +3181,8 @@ 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 (cmd->request), - blk_rq_sectors(cmd->request), bgstat, bghm); +scsi_prot_ref_tag (cmd), + scsi_logical_block_count(cmd), bgstat, bghm);/* Calcuate what type of error it was */ lpfc_calc_bg_err (phba, lpfc_cmd);
@@ -5553,8 +5529,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 (cmnd->request), -blk_rq_sectors (cmnd->request), +scsi_prot_ref_tag (cmnd), +scsi_logical_block_count (cmnd), (cmnd->cmnd[1]>>5)); } err =lpfc_bg_scsi_prep_dma_buf (phba, lpfc_cmd);
@@ -5565,8 +5541,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 (cmnd->request), -blk_rq_sectors (cmnd->request), +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
Re: [PATCH v2 5/5] scsi: lpfc: Use the proper SCSI midlayer interfaces for PI
Quoted 10 lines · Martin K. Petersen
Use 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 | 116 ++++++++++++++-------------------- 1 file changed, 46 insertions(+), 70 deletions(-)
Looks good.
-- james