@@ -96,30 +96,6 @@ static void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmnd
9696static void lpfc_vmid_assign_cs_ctl (struct lpfc_vport * vport ,
9797 struct lpfc_vmid * vmid );
9898
99- static inline unsigned
100- lpfc_cmd_blksize (struct scsi_cmnd * sc )
101- {
102- return sc -> device -> sector_size ;
103- }
104-
105- #define LPFC_CHECK_PROTECT_GUARD 1
106- #define LPFC_CHECK_PROTECT_REF 2
107- static inline unsigned
108- lpfc_cmd_protect (struct scsi_cmnd * sc , int flag )
109- {
110- return 1 ;
111- }
112-
113- static inline unsigned
114- lpfc_cmd_guard_csum (struct scsi_cmnd * sc )
115- {
116- if (lpfc_prot_group_type (NULL , sc ) == LPFC_PG_TYPE_NO_DIF )
117- return 0 ;
118- if (scsi_host_get_guard (sc -> device -> host ) == SHOST_DIX_GUARD_IP )
119- return 1 ;
120- return 0 ;
121- }
122-
12399/**
124100 * lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge.
125101 * @phba: Pointer to HBA object.
@@ -1046,13 +1022,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
10461022 return 0 ;
10471023
10481024 sgpe = scsi_prot_sglist (sc );
1049- lba = t10_pi_ref_tag ( scsi_cmd_to_rq ( sc ) );
1025+ lba = scsi_prot_ref_tag ( sc );
10501026 if (lba == LPFC_INVALID_REFTAG )
10511027 return 0 ;
10521028
10531029 /* First check if we need to match the LBA */
10541030 if (phba -> lpfc_injerr_lba != LPFC_INJERR_LBA_OFF ) {
1055- blksize = lpfc_cmd_blksize (sc );
1031+ blksize = scsi_prot_interval (sc );
10561032 numblks = (scsi_bufflen (sc ) + blksize - 1 ) / blksize ;
10571033
10581034 /* 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,
14411417{
14421418 uint8_t ret = 0 ;
14431419
1444- if (lpfc_cmd_guard_csum ( sc ) ) {
1420+ if (sc -> prot_flags & SCSI_PROT_IP_CHECKSUM ) {
14451421 switch (scsi_get_prot_op (sc )) {
14461422 case SCSI_PROT_READ_INSERT :
14471423 case SCSI_PROT_WRITE_STRIP :
@@ -1521,7 +1497,7 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
15211497{
15221498 uint8_t ret = 0 ;
15231499
1524- if (lpfc_cmd_guard_csum ( sc ) ) {
1500+ if (sc -> prot_flags & SCSI_PROT_IP_CHECKSUM ) {
15251501 switch (scsi_get_prot_op (sc )) {
15261502 case SCSI_PROT_READ_INSERT :
15271503 case SCSI_PROT_WRITE_STRIP :
@@ -1629,7 +1605,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
16291605 goto out ;
16301606
16311607 /* extract some info from the scsi command for pde*/
1632- reftag = t10_pi_ref_tag ( scsi_cmd_to_rq ( sc ) );
1608+ reftag = scsi_prot_ref_tag ( sc );
16331609 if (reftag == LPFC_INVALID_REFTAG )
16341610 goto out ;
16351611
@@ -1668,12 +1644,12 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
16681644 * protection data is automatically generated, not checked.
16691645 */
16701646 if (datadir == DMA_FROM_DEVICE ) {
1671- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_GUARD ) )
1647+ if (sc -> prot_flags & SCSI_PROT_GUARD_CHECK )
16721648 bf_set (pde6_ce , pde6 , checking );
16731649 else
16741650 bf_set (pde6_ce , pde6 , 0 );
16751651
1676- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_REF ) )
1652+ if (sc -> prot_flags & SCSI_PROT_REF_CHECK )
16771653 bf_set (pde6_re , pde6 , checking );
16781654 else
16791655 bf_set (pde6_re , pde6 , 0 );
@@ -1791,8 +1767,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
17911767 goto out ;
17921768
17931769 /* extract some info from the scsi command */
1794- blksize = lpfc_cmd_blksize (sc );
1795- reftag = t10_pi_ref_tag ( scsi_cmd_to_rq ( sc ) );
1770+ blksize = scsi_prot_interval (sc );
1771+ reftag = scsi_prot_ref_tag ( sc );
17961772 if (reftag == LPFC_INVALID_REFTAG )
17971773 goto out ;
17981774
@@ -1832,12 +1808,12 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
18321808 bf_set (pde6_optx , pde6 , txop );
18331809 bf_set (pde6_oprx , pde6 , rxop );
18341810
1835- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_GUARD ) )
1811+ if (sc -> prot_flags & SCSI_PROT_GUARD_CHECK )
18361812 bf_set (pde6_ce , pde6 , checking );
18371813 else
18381814 bf_set (pde6_ce , pde6 , 0 );
18391815
1840- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_REF ) )
1816+ if (sc -> prot_flags & SCSI_PROT_REF_CHECK )
18411817 bf_set (pde6_re , pde6 , checking );
18421818 else
18431819 bf_set (pde6_re , pde6 , 0 );
@@ -2023,7 +1999,7 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
20231999 goto out ;
20242000
20252001 /* extract some info from the scsi command for pde*/
2026- reftag = t10_pi_ref_tag ( scsi_cmd_to_rq ( sc ) );
2002+ reftag = scsi_prot_ref_tag ( sc );
20272003 if (reftag == LPFC_INVALID_REFTAG )
20282004 goto out ;
20292005
@@ -2051,12 +2027,12 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
20512027 * protection data is automatically generated, not checked.
20522028 */
20532029 if (sc -> sc_data_direction == DMA_FROM_DEVICE ) {
2054- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_GUARD ) )
2030+ if (sc -> prot_flags & SCSI_PROT_GUARD_CHECK )
20552031 bf_set (lpfc_sli4_sge_dif_ce , diseed , checking );
20562032 else
20572033 bf_set (lpfc_sli4_sge_dif_ce , diseed , 0 );
20582034
2059- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_REF ) )
2035+ if (sc -> prot_flags & SCSI_PROT_REF_CHECK )
20602036 bf_set (lpfc_sli4_sge_dif_re , diseed , checking );
20612037 else
20622038 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,
22232199 goto out ;
22242200
22252201 /* extract some info from the scsi command */
2226- blksize = lpfc_cmd_blksize (sc );
2227- reftag = t10_pi_ref_tag ( scsi_cmd_to_rq ( sc ) );
2202+ blksize = scsi_prot_interval (sc );
2203+ reftag = scsi_prot_ref_tag ( sc );
22282204 if (reftag == LPFC_INVALID_REFTAG )
22292205 goto out ;
22302206
@@ -2281,9 +2257,8 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
22812257 diseed -> ref_tag = cpu_to_le32 (reftag );
22822258 diseed -> ref_tag_tran = diseed -> ref_tag ;
22832259
2284- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_GUARD ) ) {
2260+ if (sc -> prot_flags & SCSI_PROT_GUARD_CHECK ) {
22852261 bf_set (lpfc_sli4_sge_dif_ce , diseed , checking );
2286-
22872262 } else {
22882263 bf_set (lpfc_sli4_sge_dif_ce , diseed , 0 );
22892264 /*
@@ -2300,7 +2275,7 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
23002275 }
23012276
23022277
2303- if (lpfc_cmd_protect ( sc , LPFC_CHECK_PROTECT_REF ) )
2278+ if (sc -> prot_flags & SCSI_PROT_REF_CHECK )
23042279 bf_set (lpfc_sli4_sge_dif_re , diseed , checking );
23052280 else
23062281 bf_set (lpfc_sli4_sge_dif_re , diseed , 0 );
@@ -2557,7 +2532,7 @@ lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba,
25572532 * DIF (trailer) attached to it. Must ajust FCP data length
25582533 * to account for the protection data.
25592534 */
2560- fcpdl += (fcpdl / lpfc_cmd_blksize (sc )) * 8 ;
2535+ fcpdl += (fcpdl / scsi_prot_interval (sc )) * 8 ;
25612536
25622537 return fcpdl ;
25632538}
@@ -2811,14 +2786,14 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
28112786 * data length is a multiple of the blksize.
28122787 */
28132788 sgde = scsi_sglist (cmd );
2814- blksize = lpfc_cmd_blksize (cmd );
2789+ blksize = scsi_prot_interval (cmd );
28152790 data_src = (uint8_t * )sg_virt (sgde );
28162791 data_len = sgde -> length ;
28172792 if ((data_len & (blksize - 1 )) == 0 )
28182793 chk_guard = 1 ;
28192794
28202795 src = (struct scsi_dif_tuple * )sg_virt (sgpe );
2821- start_ref_tag = t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) );
2796+ start_ref_tag = scsi_prot_ref_tag ( cmd );
28222797 if (start_ref_tag == LPFC_INVALID_REFTAG )
28232798 goto out ;
28242799 start_app_tag = src -> app_tag ;
@@ -2839,7 +2814,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
28392814 /* First Guard Tag checking */
28402815 if (chk_guard ) {
28412816 guard_tag = src -> guard_tag ;
2842- if (lpfc_cmd_guard_csum (cmd ))
2817+ if (cmd -> prot_flags
2818+ & SCSI_PROT_IP_CHECKSUM )
28432819 sum = lpfc_bg_csum (data_src ,
28442820 blksize );
28452821 else
@@ -2910,7 +2886,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
29102886 phba -> bg_guard_err_cnt ++ ;
29112887 lpfc_printf_log (phba , KERN_WARNING , LOG_FCP | LOG_BG ,
29122888 "9069 BLKGRD: reftag %x grd_tag err %x != %x\n" ,
2913- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
2889+ scsi_prot_ref_tag ( cmd ),
29142890 sum , guard_tag );
29152891
29162892 } 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)
29202896 phba -> bg_reftag_err_cnt ++ ;
29212897 lpfc_printf_log (phba , KERN_WARNING , LOG_FCP | LOG_BG ,
29222898 "9066 BLKGRD: reftag %x ref_tag err %x != %x\n" ,
2923- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
2899+ scsi_prot_ref_tag ( cmd ),
29242900 ref_tag , start_ref_tag );
29252901
29262902 } 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)
29302906 phba -> bg_apptag_err_cnt ++ ;
29312907 lpfc_printf_log (phba , KERN_WARNING , LOG_FCP | LOG_BG ,
29322908 "9041 BLKGRD: reftag %x app_tag err %x != %x\n" ,
2933- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
2909+ scsi_prot_ref_tag ( cmd ),
29342910 app_tag , start_app_tag );
29352911 }
29362912}
@@ -2992,7 +2968,7 @@ lpfc_sli4_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
29922968 " 0x%x lba 0x%llx blk cnt 0x%x "
29932969 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
29942970 (unsigned long long )scsi_get_lba (cmd ),
2995- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
2971+ scsi_logical_block_count ( cmd ), bgstat , bghm );
29962972 }
29972973
29982974 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,
30072983 " 0x%x lba 0x%llx blk cnt 0x%x "
30082984 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
30092985 (unsigned long long )scsi_get_lba (cmd ),
3010- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
2986+ scsi_logical_block_count ( cmd ), bgstat , bghm );
30112987 }
30122988
30132989 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,
30222998 " 0x%x lba 0x%llx blk cnt 0x%x "
30232999 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
30243000 (unsigned long long )scsi_get_lba (cmd ),
3025- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3001+ scsi_logical_block_count ( cmd ), bgstat , bghm );
30263002 }
30273003
30283004 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,
30663042 " 0x%x lba 0x%llx blk cnt 0x%x "
30673043 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
30683044 (unsigned long long )scsi_get_lba (cmd ),
3069- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3045+ scsi_logical_block_count ( cmd ), bgstat , bghm );
30703046
3071- /* Calcuate what type of error it was */
3047+ /* Calculate what type of error it was */
30723048 lpfc_calc_bg_err (phba , lpfc_cmd );
30733049 }
30743050 return ret ;
@@ -3103,8 +3079,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
31033079 "9072 BLKGRD: Invalid BG Profile in cmd "
31043080 "0x%x reftag 0x%x blk cnt 0x%x "
31053081 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3106- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3107- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3082+ scsi_prot_ref_tag ( cmd ),
3083+ scsi_logical_block_count ( cmd ), bgstat , bghm );
31083084 ret = (-1 );
31093085 goto out ;
31103086 }
@@ -3115,8 +3091,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
31153091 "9073 BLKGRD: Invalid BG PDIF Block in cmd "
31163092 "0x%x reftag 0x%x blk cnt 0x%x "
31173093 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3118- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3119- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3094+ scsi_prot_ref_tag ( cmd ),
3095+ scsi_logical_block_count ( cmd ), bgstat , bghm );
31203096 ret = (-1 );
31213097 goto out ;
31223098 }
@@ -3131,8 +3107,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,
31313107 "9055 BLKGRD: Guard Tag error in cmd "
31323108 "0x%x reftag 0x%x blk cnt 0x%x "
31333109 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3134- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3135- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3110+ scsi_prot_ref_tag ( cmd ),
3111+ scsi_logical_block_count ( cmd ), bgstat , bghm );
31363112 }
31373113
31383114 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,
31463122 "9056 BLKGRD: Ref Tag error in cmd "
31473123 "0x%x reftag 0x%x blk cnt 0x%x "
31483124 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3149- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3150- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3125+ scsi_prot_ref_tag ( cmd ),
3126+ scsi_logical_block_count ( cmd ), bgstat , bghm );
31513127 }
31523128
31533129 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,
31613137 "9061 BLKGRD: App Tag error in cmd "
31623138 "0x%x reftag 0x%x blk cnt 0x%x "
31633139 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3164- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3165- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3140+ scsi_prot_ref_tag ( cmd ),
3141+ scsi_logical_block_count ( cmd ), bgstat , bghm );
31663142 }
31673143
31683144 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,
32053181 "9057 BLKGRD: Unknown error in cmd "
32063182 "0x%x reftag 0x%x blk cnt 0x%x "
32073183 "bgstat=x%x bghm=x%x\n" , cmd -> cmnd [0 ],
3208- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmd ) ),
3209- blk_rq_sectors ( scsi_cmd_to_rq ( cmd ) ), bgstat , bghm );
3184+ scsi_prot_ref_tag ( cmd ),
3185+ scsi_logical_block_count ( cmd ), bgstat , bghm );
32103186
3211- /* Calcuate what type of error it was */
3187+ /* Calculate what type of error it was */
32123188 lpfc_calc_bg_err (phba , lpfc_cmd );
32133189 }
32143190out :
@@ -5715,8 +5691,8 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
57155691 "reftag x%x cnt %u pt %x\n" ,
57165692 dif_op_str [scsi_get_prot_op (cmnd )],
57175693 cmnd -> cmnd [0 ],
5718- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmnd ) ),
5719- blk_rq_sectors ( scsi_cmd_to_rq ( cmnd ) ),
5694+ scsi_prot_ref_tag ( cmnd ),
5695+ scsi_logical_block_count ( cmnd ),
57205696 (cmnd -> cmnd [1 ]>>5 ));
57215697 }
57225698 err = lpfc_bg_scsi_prep_dma_buf (phba , lpfc_cmd );
@@ -5727,8 +5703,8 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
57275703 "9038 BLKGRD: rcvd PROT_NORMAL cmd: "
57285704 "x%x reftag x%x cnt %u pt %x\n" ,
57295705 cmnd -> cmnd [0 ],
5730- t10_pi_ref_tag ( scsi_cmd_to_rq ( cmnd ) ),
5731- blk_rq_sectors ( scsi_cmd_to_rq ( cmnd ) ),
5706+ scsi_prot_ref_tag ( cmnd ),
5707+ scsi_logical_block_count ( cmnd ),
57325708 (cmnd -> cmnd [1 ]>>5 ));
57335709 }
57345710 err = lpfc_scsi_prep_dma_buf (phba , lpfc_cmd );
0 commit comments