FreeBSD/sys/dev/isci/scil/sati_mode_sense.c
/**
 * @brief This method performs the caching mode page specific data
 *        translation based upon the contents of the remote device IDENTIFY
 *        DEVICE data.
 *        For more information on the parameters passed to this method,
 *        please reference sati_translate_command().
 *
 * @param[in] identify This parameter specifies the remote device's
 *            IDENTIFY DEVICE data received as part of the IO request.
 * @param[in] offset This parameter specifies the offset into the data
 *            buffer where the translated data is to be written.
 *
 * @return This method returns the size of the mode page data that was
 *         translated.
 */
@brief This method performs the caching mode page specific data
translation based upon the contents of the remote device IDENTIFY
DEVICE data.
For more information on the parameters passed to this method,
please reference sati_translate_command().

@param[in] identify This parameter specifies the remote device's
IDENTIFY DEVICE data received as part of the IO request.
@param[in] offset This parameter specifies the offset into the data
buffer where the translated data is to be written.

@return This method returns the size of the mode page data that was
translated.
@brief This method performs the caching mode page specific data translation based upon the contents of the remote device IDENTIFY DEVICE data . For more information on the parameters passed to this method please reference sati_translate_command () . @param [ in ] identify This parameter specifies the remote device ' s IDENTIFY DEVICE data received as part of the IO request . @param [ in ] offset This parameter specifies the offset into the data buffer where the translated data is to be written . @return This method returns the size of the mode page data that was translated .
U32 sati_mode_sense_caching_translate_data(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void                       * scsi_io,
   ATA_IDENTIFY_DEVICE_DATA_T * identify,
   U32                          offset
)
{
   U8 * cdb          = sati_cb_get_cdb_address(scsi_io);
   U8   page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
   U32  page_length;
   page_length = sati_mode_sense_copy_initial_data(
                    sequence,
                    scsi_io,
                    offset,
                    page_control,
                    SCSI_MODE_PAGE_CACHING
                 );
   if (page_control == SCSI_MODE_SENSE_PC_CURRENT)
   {
      U8  value;
      if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_WCE_ENABLE) != 0)
      {
         sati_get_data_byte(sequence, scsi_io, offset+2, &value);
         value |= SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT;
         sati_set_data_byte(sequence, scsi_io, offset+2, value);
         sequence->number_data_bytes_set--;
      }
      if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_RA_ENABLE) == 0)
      {
         sati_get_data_byte(sequence, scsi_io, offset+12, &value);
         value |= SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT;
         sati_set_data_byte(sequence, scsi_io, offset+12, value);
         sequence->number_data_bytes_set--;
      }
   }
   return page_length;
}
U32 sati_mode_sense_caching_translate_data ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , ATA_IDENTIFY_DEVICE_DATA_T * identify , U32 offset ) { U8 * cdb = sati_cb_get_cdb_address ( scsi_io ) ; U8 page_control = sati_get_cdb_byte ( cdb , 2 ) >> SCSI_MODE_SENSE_PC_SHIFT ; U32 page_length ; page_length = sati_mode_sense_copy_initial_data ( sequence , scsi_io , offset , page_control , SCSI_MODE_PAGE_CACHING ) ; if ( page_control == SCSI_MODE_SENSE_PC_CURRENT ) { U8 value ; if ( ( identify -> command_set_enabled0 & ATA_IDENTIFY_DEVICE_WCE_ENABLE ) != 0 ) { sati_get_data_byte ( sequence , scsi_io , offset + 2 , & value ) ; value |= SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT ; sati_set_data_byte ( sequence , scsi_io , offset + 2 , value ) ; sequence -> number_data_bytes_set -- ; } if ( ( identify -> command_set_enabled0 & ATA_IDENTIFY_DEVICE_RA_ENABLE ) == 0 ) { sati_get_data_byte ( sequence , scsi_io , offset + 12 , & value ) ; value |= SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT ; sati_set_data_byte ( sequence , scsi_io , offset + 12 , value ) ; sequence -> number_data_bytes_set -- ; } } return page_length ; }
@brief This method performs the caching mode page specific data
        translation based upon the contents of the remote device IDENTIFY
        DEVICE data.
@brief This method performs the caching mode page specific data translation based upon the contents of the remote device IDENTIFY DEVICE data .
// If the request queried for the current values, then // we need to translate the data from the IDENTIFY DEVICE request. // Update the Write Cache Enabled (WCE) bit in the mode page data // buffer based on the identify response. //This byte has been set twice and needs to be decremented // Update the Disable Read Ahead (DRA) bit in the mode page data // buffer based on the identify response. // In SATA the polarity of the bits is inverse. // - SCSI = Disable Read Ahead // - ATA = Read Ahead //This byte has been set twice, the first time in //sati_mode_sense_copy_initial_data. number_data_bytes_set //needs to be decremented