FreeBSD/sys/dev/isci/scil/sati_passthrough.c
/**
 * @brief This method will construct the sense data buffer in the user's
 *        sense data buffer location.  Additionally, it will set the user's
 *        SCSI status.
 *
 * @param[in]     sequence This parameter specifies the translation sequence
 *                for which to construct the sense data.
 * @param[in]     register_fis This parameter specifies the fis from which
 *                to get the data.
 * @param[in,out] scsi_io This parameter specifies the user's IO request
 *                for which to construct the sense data.
 * @param[in]     scsi_status This parameter specifies the SCSI status
 *                value for the user's IO request.
 * @param[in]     sense_key This parameter specifies the sense key to
 *                be set for the user's IO request.
 * @param[in]     additional_sense_code This parameter specifies the
 *                additional sense code (ASC) key to be set for the user's
 *                IO request.
 * @param[in]     additional_sense_code_qualifier This parameter specifies
 *                the additional sense code qualifier (ASCQ) key to be set
 *                for the user's IO request.
 *
 * @return none
 */
@brief This method will construct the sense data buffer in the user's
sense data buffer location.  Additionally, it will set the user's
SCSI status.

@param[in]     sequence This parameter specifies the translation sequence
for which to construct the sense data.
@param[in]     register_fis This parameter specifies the fis from which
to get the data.
@param[in,out] scsi_io This parameter specifies the user's IO request
for which to construct the sense data.
@param[in]     scsi_status This parameter specifies the SCSI status
value for the user's IO request.
@param[in]     sense_key This parameter specifies the sense key to
be set for the user's IO request.
@param[in]     additional_sense_code This parameter specifies the
additional sense code (ASC) key to be set for the user's
IO request.
@param[in]     additional_sense_code_qualifier This parameter specifies
the additional sense code qualifier (ASCQ) key to be set
for the user's IO request.

@return none
@brief This method will construct the sense data buffer in the user ' s sense data buffer location . Additionally it will set the user ' s SCSI status . @param [ in ] sequence This parameter specifies the translation sequence for which to construct the sense data . @param [ in ] register_fis This parameter specifies the fis from which to get the data . @param [ in out ] scsi_io This parameter specifies the user ' s IO request for which to construct the sense data . @param [ in ] scsi_status This parameter specifies the SCSI status value for the user ' s IO request . @param [ in ] sense_key This parameter specifies the sense key to be set for the user ' s IO request . @param [ in ] additional_sense_code This parameter specifies the additional sense code ( ASC ) key to be set for the user ' s IO request . @param [ in ] additional_sense_code_qualifier This parameter specifies the additional sense code qualifier ( ASCQ ) key to be set for the user ' s IO request . @return none
static
void sati_passthrough_construct_sense(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   U8                         * register_fis,
   void                       * scsi_io,
   U8                           scsi_status,
   U8                           sense_key,
   U8                           additional_sense_code,
   U8                           additional_sense_code_qualifier
)
{
   U8                    * sense_data;
   U32                     sense_len;
   U8                    * cdb;
   unsigned char           sector_count_upper;
   unsigned char           lba_upper;
#ifdef SATI_TRANSPORT_SUPPORTS_SAS
   SCI_SSP_RESPONSE_IU_T * rsp_iu = (SCI_SSP_RESPONSE_IU_T*)
                                    sati_cb_get_response_iu_address(scsi_io);
   sati_scsi_common_response_iu_construct(
      rsp_iu,
      scsi_status,
      SCSI_FIXED_SENSE_DATA_BASE_LENGTH,
      SCSI_RESPONSE_DATA_PRES_SENSE_DATA
   );
   sense_data                   = (U8*) rsp_iu->data;
   sense_len                    = SSP_RESPONSE_IU_MAX_DATA * 4;  
#else
   sense_data = sati_cb_get_sense_data_address(scsi_io);
   sense_len  = sati_cb_get_sense_data_length(scsi_io);
#endif 
   sati_scsi_sense_data_construct(
      sequence,
      scsi_io,
      scsi_status,
      sense_key,
      additional_sense_code,
      additional_sense_code_qualifier
   );
   cdb = sati_cb_get_cdb_address(scsi_io);
   if (sati_get_ata_sector_count_ext(register_fis) != 0) {
      sector_count_upper = 1;
   } else {
       sector_count_upper = 0;
   }
   if (sati_get_ata_lba_high_ext(register_fis) != 0 ||
       sati_get_ata_lba_mid_ext(register_fis) != 0 ||
       sati_get_ata_lba_low_ext(register_fis) != 0) {
      lba_upper = 1;
   } else {
       lba_upper = 0;
   }
   sati_set_sense_data_byte(sense_data, sense_len, 3,  (U8)sati_get_ata_error(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 4,  (U8)sati_get_ata_status(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 5,  sati_get_ata_device(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 6,  sati_get_ata_sector_count(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 8,  (PASSTHROUGH_CDB_EXTEND(cdb) << 7) | (sector_count_upper << 6) | (lba_upper << 5));
   sati_set_sense_data_byte(sense_data, sense_len, 9,  sati_get_ata_lba_low(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 10, sati_get_ata_lba_mid(register_fis));
   sati_set_sense_data_byte(sense_data, sense_len, 11, sati_get_ata_lba_high(register_fis));
   sequence->is_sense_response_set = TRUE;
}
static void sati_passthrough_construct_sense ( SATI_TRANSLATOR_SEQUENCE_T * sequence , U8 * register_fis , void * scsi_io , U8 scsi_status , U8 sense_key , U8 additional_sense_code , U8 additional_sense_code_qualifier ) { U8 * sense_data ; U32 sense_len ; U8 * cdb ; unsigned char sector_count_upper ; unsigned char lba_upper ; #ifdef SATI_TRANSPORT_SUPPORTS_SAS SCI_SSP_RESPONSE_IU_T * rsp_iu = ( SCI_SSP_RESPONSE_IU_T * ) sati_cb_get_response_iu_address ( scsi_io ) ; sati_scsi_common_response_iu_construct ( rsp_iu , scsi_status , SCSI_FIXED_SENSE_DATA_BASE_LENGTH , SCSI_RESPONSE_DATA_PRES_SENSE_DATA ) ; sense_data = ( U8 * ) rsp_iu -> data ; sense_len = SSP_RESPONSE_IU_MAX_DATA * 4 ; #else sense_data = sati_cb_get_sense_data_address ( scsi_io ) ; sense_len = sati_cb_get_sense_data_length ( scsi_io ) ; #endif sati_scsi_sense_data_construct ( sequence , scsi_io , scsi_status , sense_key , additional_sense_code , additional_sense_code_qualifier ) ; cdb = sati_cb_get_cdb_address ( scsi_io ) ; if ( sati_get_ata_sector_count_ext ( register_fis ) != 0 ) { sector_count_upper = 1 ; } else { sector_count_upper = 0 ; } if ( sati_get_ata_lba_high_ext ( register_fis ) != 0 || sati_get_ata_lba_mid_ext ( register_fis ) != 0 || sati_get_ata_lba_low_ext ( register_fis ) != 0 ) { lba_upper = 1 ; } else { lba_upper = 0 ; } sati_set_sense_data_byte ( sense_data , sense_len , 3 , ( U8 ) sati_get_ata_error ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 4 , ( U8 ) sati_get_ata_status ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 5 , sati_get_ata_device ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 6 , sati_get_ata_sector_count ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 8 , ( PASSTHROUGH_CDB_EXTEND ( cdb ) << 7 ) | ( sector_count_upper << 6 ) | ( lba_upper << 5 ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 9 , sati_get_ata_lba_low ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 10 , sati_get_ata_lba_mid ( register_fis ) ) ; sati_set_sense_data_byte ( sense_data , sense_len , 11 , sati_get_ata_lba_high ( register_fis ) ) ; sequence -> is_sense_response_set = TRUE ; }
@brief This method will construct the sense data buffer in the user's
        sense data buffer location.
@brief This method will construct the sense data buffer in the user ' s sense data buffer location .
// dwords to bytes // SATI_TRANSPORT_SUPPORTS_SAS // Information section // Command specific section