@@ -600,7 +600,7 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
600600{
601601 struct lpfc_io_buf * lpfc_cmd ;
602602 struct lpfc_sli4_hdw_queue * qp ;
603- struct sli4_sge * sgl ;
603+ struct sli4_sge_le * sgl ;
604604 dma_addr_t pdma_phys_fcp_rsp ;
605605 dma_addr_t pdma_phys_fcp_cmd ;
606606 uint32_t cpu , idx ;
@@ -651,23 +651,23 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
651651 * The balance are sg list bdes. Initialize the
652652 * first two and leave the rest for queuecommand.
653653 */
654- sgl = (struct sli4_sge * )lpfc_cmd -> dma_sgl ;
654+ sgl = (struct sli4_sge_le * )lpfc_cmd -> dma_sgl ;
655655 pdma_phys_fcp_cmd = tmp -> fcp_cmd_rsp_dma_handle ;
656656 sgl -> addr_hi = cpu_to_le32 (putPaddrHigh (pdma_phys_fcp_cmd ));
657657 sgl -> addr_lo = cpu_to_le32 (putPaddrLow (pdma_phys_fcp_cmd ));
658- sgl -> word2 = le32_to_cpu (sgl -> word2 );
659- bf_set (lpfc_sli4_sge_last , sgl , 0 );
660- sgl -> word2 = cpu_to_le32 (sgl -> word2 );
661- sgl -> sge_len = cpu_to_le32 (sizeof (struct fcp_cmnd ));
658+ bf_set_le32 (lpfc_sli4_sge_last , sgl , 0 );
659+ if (cmnd && cmnd -> cmd_len > LPFC_FCP_CDB_LEN )
660+ sgl -> sge_len = cpu_to_le32 (sizeof (struct fcp_cmnd32 ));
661+ else
662+ sgl -> sge_len = cpu_to_le32 (sizeof (struct fcp_cmnd ));
663+
662664 sgl ++ ;
663665
664666 /* Setup the physical region for the FCP RSP */
665- pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof (struct fcp_cmnd );
667+ pdma_phys_fcp_rsp = pdma_phys_fcp_cmd + sizeof (struct fcp_cmnd32 );
666668 sgl -> addr_hi = cpu_to_le32 (putPaddrHigh (pdma_phys_fcp_rsp ));
667669 sgl -> addr_lo = cpu_to_le32 (putPaddrLow (pdma_phys_fcp_rsp ));
668- sgl -> word2 = le32_to_cpu (sgl -> word2 );
669- bf_set (lpfc_sli4_sge_last , sgl , 1 );
670- sgl -> word2 = cpu_to_le32 (sgl -> word2 );
670+ bf_set_le32 (lpfc_sli4_sge_last , sgl , 1 );
671671 sgl -> sge_len = cpu_to_le32 (sizeof (struct fcp_rsp ));
672672
673673 if (lpfc_ndlp_check_qdepth (phba , ndlp )) {
@@ -2608,7 +2608,7 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba,
26082608 iocb_cmd -> ulpLe = 1 ;
26092609
26102610 fcpdl = lpfc_bg_scsi_adjust_dl (phba , lpfc_cmd );
2611- fcp_cmnd -> fcpDl = be32_to_cpu (fcpdl );
2611+ fcp_cmnd -> fcpDl = cpu_to_be32 (fcpdl );
26122612
26132613 /*
26142614 * Due to difference in data length between DIF/non-DIF paths,
@@ -3225,14 +3225,18 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
32253225 * explicitly reinitialized.
32263226 * all iocb memory resources are reused.
32273227 */
3228- fcp_cmnd -> fcpDl = cpu_to_be32 (scsi_bufflen (scsi_cmnd ));
3228+ if (scsi_cmnd -> cmd_len > LPFC_FCP_CDB_LEN )
3229+ ((struct fcp_cmnd32 * )fcp_cmnd )-> fcpDl =
3230+ cpu_to_be32 (scsi_bufflen (scsi_cmnd ));
3231+ else
3232+ fcp_cmnd -> fcpDl = cpu_to_be32 (scsi_bufflen (scsi_cmnd ));
32293233 /* Set first-burst provided it was successfully negotiated */
32303234 if (!test_bit (HBA_FCOE_MODE , & phba -> hba_flag ) &&
32313235 vport -> cfg_first_burst_size &&
32323236 scsi_cmnd -> sc_data_direction == DMA_TO_DEVICE ) {
32333237 u32 init_len , total_len ;
32343238
3235- total_len = be32_to_cpu ( fcp_cmnd -> fcpDl );
3239+ total_len = scsi_bufflen ( scsi_cmnd );
32363240 init_len = min (total_len , vport -> cfg_first_burst_size );
32373241
32383242 /* Word 4 & 5 */
@@ -3420,24 +3424,26 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba,
34203424 }
34213425
34223426 fcpdl = lpfc_bg_scsi_adjust_dl (phba , lpfc_cmd );
3423- fcp_cmnd -> fcpDl = be32_to_cpu (fcpdl );
3427+ if (lpfc_cmd -> pCmd -> cmd_len > LPFC_FCP_CDB_LEN )
3428+ ((struct fcp_cmnd32 * )fcp_cmnd )-> fcpDl = cpu_to_be32 (fcpdl );
3429+ else
3430+ fcp_cmnd -> fcpDl = cpu_to_be32 (fcpdl );
34243431
34253432 /* Set first-burst provided it was successfully negotiated */
34263433 if (!test_bit (HBA_FCOE_MODE , & phba -> hba_flag ) &&
34273434 vport -> cfg_first_burst_size &&
34283435 scsi_cmnd -> sc_data_direction == DMA_TO_DEVICE ) {
34293436 u32 init_len , total_len ;
34303437
3431- total_len = be32_to_cpu ( fcp_cmnd -> fcpDl ) ;
3438+ total_len = fcpdl ;
34323439 init_len = min (total_len , vport -> cfg_first_burst_size );
34333440
34343441 /* Word 4 & 5 */
34353442 wqe -> fcp_iwrite .initial_xfer_len = init_len ;
34363443 wqe -> fcp_iwrite .total_xfer_len = total_len ;
34373444 } else {
34383445 /* Word 4 */
3439- wqe -> fcp_iwrite .total_xfer_len =
3440- be32_to_cpu (fcp_cmnd -> fcpDl );
3446+ wqe -> fcp_iwrite .total_xfer_len = fcpdl ;
34413447 }
34423448
34433449 /*
@@ -3894,7 +3900,10 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,
38943900 fcprsp -> rspInfo3 );
38953901
38963902 scsi_set_resid (cmnd , 0 );
3897- fcpDl = be32_to_cpu (fcpcmd -> fcpDl );
3903+ if (cmnd -> cmd_len > LPFC_FCP_CDB_LEN )
3904+ fcpDl = be32_to_cpu (((struct fcp_cmnd32 * )fcpcmd )-> fcpDl );
3905+ else
3906+ fcpDl = be32_to_cpu (fcpcmd -> fcpDl );
38983907 if (resp_info & RESID_UNDER ) {
38993908 scsi_set_resid (cmnd , be32_to_cpu (fcprsp -> rspResId ));
39003909
@@ -4723,6 +4732,14 @@ static int lpfc_scsi_prep_cmnd_buf_s4(struct lpfc_vport *vport,
47234732 bf_set (wqe_iod , & wqe -> fcp_iread .wqe_com ,
47244733 LPFC_WQE_IOD_NONE );
47254734 }
4735+
4736+ /* Additional fcp cdb length field calculation.
4737+ * LPFC_FCP_CDB_LEN_32 - normal 16 byte cdb length,
4738+ * then divide by 4 for the word count.
4739+ * shift 2 because of the RDDATA/WRDATA.
4740+ */
4741+ if (scsi_cmnd -> cmd_len > LPFC_FCP_CDB_LEN )
4742+ fcp_cmnd -> fcpCntl3 |= 4 << 2 ;
47264743 } else {
47274744 /* From the icmnd template, initialize words 4 - 11 */
47284745 memcpy (& wqe -> words [4 ], & lpfc_icmnd_cmd_template .words [4 ],
@@ -4743,7 +4760,7 @@ static int lpfc_scsi_prep_cmnd_buf_s4(struct lpfc_vport *vport,
47434760
47444761 /* Word 3 */
47454762 bf_set (payload_offset_len , & wqe -> fcp_icmd ,
4746- sizeof (struct fcp_cmnd ) + sizeof (struct fcp_rsp ));
4763+ sizeof (struct fcp_cmnd32 ) + sizeof (struct fcp_rsp ));
47474764
47484765 /* Word 6 */
47494766 bf_set (wqe_ctxt_tag , & wqe -> generic .wqe_com ,
@@ -4798,7 +4815,7 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd,
47984815 int_to_scsilun (lpfc_cmd -> pCmd -> device -> lun ,
47994816 & lpfc_cmd -> fcp_cmnd -> fcp_lun );
48004817
4801- ptr = & fcp_cmnd -> fcpCdb [0 ];
4818+ ptr = & (( struct fcp_cmnd32 * ) fcp_cmnd ) -> fcpCdb [0 ];
48024819 memcpy (ptr , scsi_cmnd -> cmnd , scsi_cmnd -> cmd_len );
48034820 if (scsi_cmnd -> cmd_len < LPFC_FCP_CDB_LEN ) {
48044821 ptr += scsi_cmnd -> cmd_len ;
0 commit comments