FreeBSD/sys/dev/isci/scil/sati_mode_select.c
/**
 * @brief This method will check the validity of parameter data of Caching mode
 *            page and issue multiple ATA set feature commands to complete the translation.
 *
 * @param[in] page_size This parameter specifies page size of current mode page.
 *
 * @return Indicate if the translation was successful.
 * @retval SATI_SUCCESS
 * @retval SATI_COMPLETE
 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
 */
@brief This method will check the validity of parameter data of Caching mode
page and issue multiple ATA set feature commands to complete the translation.

@param[in] page_size This parameter specifies page size of current mode page.

@return Indicate if the translation was successful.
@brief This method will check the validity of parameter data of Caching mode page and issue multiple ATA set feature commands to complete the translation . @param [ in ] page_size This parameter specifies page size of current mode page . @return Indicate if the translation was successful .
static
SATI_STATUS sati_mode_select_process_mode_page_caching(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void * scsi_io,
   void * ata_io,
   U32 page_size
   )
{
   SATI_STATUS status = SATI_FAILURE_CHECK_RESPONSE_DATA;
   U8 current_mode_page[SCSI_MODE_PAGE_08_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
   U32 mode_page_offset;
   U32 index;
   mode_page_offset = sequence->command_specific_data.process_state.mode_page_offset;
   sequence->type = SATI_SEQUENCE_MODE_SELECT_MODE_PAGE_CACHING;
   for(index = 0; index < SCSI_MODE_PAGE_08_LENGTH; index++)
   {
      sati_get_data_byte(sequence, scsi_io, mode_page_offset+index, &current_mode_page[index]);
   }
   if (((current_mode_page[0] & SCSI_MODE_SELECT_MODE_PAGE_SPF_MASK)!= 0) ||
      (current_mode_page[1] != (SCSI_MODE_PAGE_08_LENGTH-2)) ||
      ((current_mode_page[2] | SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT)!=SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT) ||
      (current_mode_page[3] != 0 ) ||
      (current_mode_page[4] != 0 ) ||
      (current_mode_page[5] != 0 ) ||
      (current_mode_page[6] != 0 ) ||
      (current_mode_page[7] != 0 ) ||
      (current_mode_page[8] != 0 ) ||
      (current_mode_page[9] != 0 ) ||
      (current_mode_page[10] != 0 ) ||
      (current_mode_page[11] != 0 ) ||
      ((current_mode_page[12] & SCSI_MODE_SELECT_MODE_PAGE_08_FSW_LBCSS_NVDIS) != 0) ||
      (current_mode_page[13] != 0 ) ||
      (current_mode_page[14] != 0 ) ||
      (current_mode_page[15] != 0 ))
   {
      return SATI_FAILURE_CHECK_RESPONSE_DATA;
   }
   if(sequence->command_specific_data.process_state.ata_command_sent_for_cmp == 0)
   {
      if ( (current_mode_page[2] & SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT) == 0)
         sati_ata_set_features_construct(ata_io, sequence, ATA_SET_FEATURES_SUB_CMD_DISABLE_CACHE);
      else
         sati_ata_set_features_construct(ata_io, sequence, ATA_SET_FEATURES_SUB_CMD_ENABLE_CACHE);
   }
   else if(sequence->command_specific_data.process_state.ata_command_sent_for_cmp == 1)
   {
      if ( (current_mode_page[12] & SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT) == 0)
         sati_ata_set_features_construct(ata_io, sequence,ATA_SET_FEATURES_SUB_CMD_ENABLE_READ_AHEAD);
      else
         sati_ata_set_features_construct(ata_io, sequence,ATA_SET_FEATURES_SUB_CMD_DISABLE_READ_AHEAD);
      sequence->command_specific_data.process_state.size_of_data_processed += page_size;
      sequence->command_specific_data.process_state.mode_page_offset += page_size;
      sequence->command_specific_data.process_state.current_mode_page_processed = TRUE;
   }
   sequence->command_specific_data.process_state.ata_command_sent_for_cmp++;
   status = SATI_SUCCESS;
   return status;
}
static SATI_STATUS sati_mode_select_process_mode_page_caching ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , void * ata_io , U32 page_size ) { SATI_STATUS status = SATI_FAILURE_CHECK_RESPONSE_DATA ; U8 current_mode_page [ SCSI_MODE_PAGE_08_LENGTH ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; U32 mode_page_offset ; U32 index ; mode_page_offset = sequence -> command_specific_data . process_state . mode_page_offset ; sequence -> type = SATI_SEQUENCE_MODE_SELECT_MODE_PAGE_CACHING ; for ( index = 0 ; index < SCSI_MODE_PAGE_08_LENGTH ; index ++ ) { sati_get_data_byte ( sequence , scsi_io , mode_page_offset + index , & current_mode_page [ index ] ) ; } if ( ( ( current_mode_page [ 0 ] & SCSI_MODE_SELECT_MODE_PAGE_SPF_MASK ) != 0 ) || ( current_mode_page [ 1 ] != ( SCSI_MODE_PAGE_08_LENGTH - 2 ) ) || ( ( current_mode_page [ 2 ] | SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT ) != SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT ) || ( current_mode_page [ 3 ] != 0 ) || ( current_mode_page [ 4 ] != 0 ) || ( current_mode_page [ 5 ] != 0 ) || ( current_mode_page [ 6 ] != 0 ) || ( current_mode_page [ 7 ] != 0 ) || ( current_mode_page [ 8 ] != 0 ) || ( current_mode_page [ 9 ] != 0 ) || ( current_mode_page [ 10 ] != 0 ) || ( current_mode_page [ 11 ] != 0 ) || ( ( current_mode_page [ 12 ] & SCSI_MODE_SELECT_MODE_PAGE_08_FSW_LBCSS_NVDIS ) != 0 ) || ( current_mode_page [ 13 ] != 0 ) || ( current_mode_page [ 14 ] != 0 ) || ( current_mode_page [ 15 ] != 0 ) ) { return SATI_FAILURE_CHECK_RESPONSE_DATA ; } if ( sequence -> command_specific_data . process_state . ata_command_sent_for_cmp == 0 ) { if ( ( current_mode_page [ 2 ] & SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT ) == 0 ) sati_ata_set_features_construct ( ata_io , sequence , ATA_SET_FEATURES_SUB_CMD_DISABLE_CACHE ) ; else sati_ata_set_features_construct ( ata_io , sequence , ATA_SET_FEATURES_SUB_CMD_ENABLE_CACHE ) ; } else if ( sequence -> command_specific_data . process_state . ata_command_sent_for_cmp == 1 ) { if ( ( current_mode_page [ 12 ] & SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT ) == 0 ) sati_ata_set_features_construct ( ata_io , sequence , ATA_SET_FEATURES_SUB_CMD_ENABLE_READ_AHEAD ) ; else sati_ata_set_features_construct ( ata_io , sequence , ATA_SET_FEATURES_SUB_CMD_DISABLE_READ_AHEAD ) ; sequence -> command_specific_data . process_state . size_of_data_processed += page_size ; sequence -> command_specific_data . process_state . mode_page_offset += page_size ; sequence -> command_specific_data . process_state . current_mode_page_processed = TRUE ; } sequence -> command_specific_data . process_state . ata_command_sent_for_cmp ++ ; status = SATI_SUCCESS ; return status ; }
@brief This method will check the validity of parameter data of Caching mode
            page and issue multiple ATA set feature commands to complete the translation.
@brief This method will check the validity of parameter data of Caching mode page and issue multiple ATA set feature commands to complete the translation .
//SCSI_MODE_PAGE_08_LENGTH 0x14= 20 //Check for data validity //SPF(0b); Page length 0x12;Byte2 to Byte15 all 0 with exception DRA and WCE changeable //parameter data passed in containing data that doesn't meet the SAT-2 requirement //byte2 bit2 WCE==0 disable write cache WCE==1 enable write cache //SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT ==0x4, // DRA bit is set to 0, enable Read look ahead AAh; // DRA bit is set to 1, disable with set feature command 55h // SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT== 0x20 // No more ata commands to send