FreeBSD/sys/dev/isci/scil/sati_util.c
/**
 * @brief This method will construct the fixed format 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,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 fixed format 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,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 fixed format 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 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
void sati_scsi_fixed_sense_data_construct(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void                       * scsi_io,
   U8                           scsi_status,
   U8                           response_code,
   U8                           sense_key,
   U8                           additional_sense_code,
   U8                           additional_sense_code_qualifier
)
{
    U8 * sense_data;
    U32  sense_len;
    sati_scsi_get_sense_data_buffer(sequence, scsi_io, scsi_status, &sense_data, &sense_len);
    sati_set_sense_data_byte(
      sense_data,
      sense_len,
      0,
      response_code | SCSI_FIXED_SENSE_DATA_VALID_BIT
    );
    sati_set_sense_data_byte(sense_data, sense_len, 1,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 2,  sense_key);
    sati_set_sense_data_byte(sense_data, sense_len, 3,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 4,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 5,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 6,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 7,  (sense_len < 18 ? sense_len - 1 : 17) - 7);
    sati_set_sense_data_byte(sense_data, sense_len, 8,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 9,  0);
    sati_set_sense_data_byte(sense_data, sense_len, 10, 0);
    sati_set_sense_data_byte(sense_data, sense_len, 11, 0);
    sati_set_sense_data_byte(sense_data, sense_len, 12, additional_sense_code);
    sati_set_sense_data_byte(sense_data, sense_len, 13, additional_sense_code_qualifier);
    sati_set_sense_data_byte(sense_data, sense_len, 14, 0);
    sati_set_sense_data_byte(sense_data, sense_len, 15, 0);
    sati_set_sense_data_byte(sense_data, sense_len, 16, 0);
    sati_set_sense_data_byte(sense_data, sense_len, 17, 0);
}
void sati_scsi_fixed_sense_data_construct ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , U8 scsi_status , U8 response_code , U8 sense_key , U8 additional_sense_code , U8 additional_sense_code_qualifier ) { U8 * sense_data ; U32 sense_len ; sati_scsi_get_sense_data_buffer ( sequence , scsi_io , scsi_status , & sense_data , & sense_len ) ; sati_set_sense_data_byte ( sense_data , sense_len , 0 , response_code | SCSI_FIXED_SENSE_DATA_VALID_BIT ) ; sati_set_sense_data_byte ( sense_data , sense_len , 1 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 2 , sense_key ) ; sati_set_sense_data_byte ( sense_data , sense_len , 3 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 4 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 5 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 6 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 7 , ( sense_len < 18 ? sense_len - 1 : 17 ) - 7 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 8 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 9 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 10 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 11 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 12 , additional_sense_code ) ; sati_set_sense_data_byte ( sense_data , sense_len , 13 , additional_sense_code_qualifier ) ; sati_set_sense_data_byte ( sense_data , sense_len , 14 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 15 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 16 , 0 ) ; sati_set_sense_data_byte ( sense_data , sense_len , 17 , 0 ) ; }
@brief This method will construct the fixed format sense data buffer
           in the user's sense data buffer location.
@brief This method will construct the fixed format sense data buffer in the user ' s sense data buffer location .
// Write out the sense data format per SPC-4. // We utilize the fixed format sense data format.