FreeBSD/sys/dev/isci/scil/sati_mode_sense.c
/**
 * @brief This method indicates if the page code field in the SCSI CDB
 *        is supported by this translation.
 *        For more information on the parameters passed to this method,
 *        please reference sati_translate_command().
 *
 * @param[in] cdb_length This parameter specifies the length of the SCSI
 *            CDB being translated (e.g. 6-byte, 10-byte, 12-byte, etc.)
 *
 * @return This method returns an indication as to whether the page code
 *         in the CDB is supported.
 * @retval SATI_SUCCESS This value is returned if the page code is
 *         supported.
 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
 *         page code is not supported.
 */
@brief This method indicates if the page code field in the SCSI CDB
is supported by this translation.
For more information on the parameters passed to this method,
please reference sati_translate_command().

@param[in] cdb_length This parameter specifies the length of the SCSI
CDB being translated

@return This method returns an indication as to whether the page code
in the CDB is supported.
@retval SATI_SUCCESS This value is returned if the page code is
supported.
@retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
page code is not supported.
@brief This method indicates if the page code field in the SCSI CDB is supported by this translation . For more information on the parameters passed to this method please reference sati_translate_command () . @param [ in ] cdb_length This parameter specifies the length of the SCSI CDB being translated @return This method returns an indication as to whether the page code in the CDB is supported . @retval SATI_SUCCESS This value is returned if the page code is supported . @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the page code is not supported .
static
SATI_STATUS sati_mode_sense_is_page_code_supported(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void                       * scsi_io,
   U8                           cdb_length
)
{
   U8 * cdb = sati_cb_get_cdb_address(scsi_io);
   switch (sati_get_cdb_byte(cdb, 2) & SCSI_MODE_SENSE_PAGE_CODE_ENABLE)
   {
      case SCSI_MODE_PAGE_CACHING:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CACHING;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CACHING;
      break;
      case SCSI_MODE_PAGE_ALL_PAGES:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_ALL_PAGES;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_ALL_PAGES;
      break;
      case SCSI_MODE_PAGE_READ_WRITE_ERROR:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_READ_WRITE_ERROR;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_READ_WRITE_ERROR;
      break;
      case SCSI_MODE_PAGE_DISCONNECT_RECONNECT:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_DISCONNECT_RECONNECT;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_DISCONNECT_RECONNECT;
      break;
      case SCSI_MODE_PAGE_CONTROL:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CONTROL;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CONTROL;
      break;
      case SCSI_MODE_PAGE_POWER_CONDITION:
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_POWER_CONDITION;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_POWER_CONDITION;
      break;
      case SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL:
         if ((sequence->device->capabilities | SATI_DEVICE_CAP_SMART_SUPPORT)
             == 0)
         {
            if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            {
               sati_scsi_sense_data_construct(
                  sequence,
                  scsi_io,
                  SCSI_STATUS_CHECK_CONDITION,
                  SCSI_SENSE_ILLEGAL_REQUEST,
                  SCSI_ASC_INVALID_FIELD_IN_CDB,
                  SCSI_ASCQ_INVALID_FIELD_IN_CDB
               );
            }
            else
            {
               sati_scsi_sense_data_construct(
                  sequence,
                  scsi_io,
                  SCSI_STATUS_CHECK_CONDITION,
                  SCSI_SENSE_ILLEGAL_REQUEST,
                  SCSI_ASC_INVALID_FIELD_IN_PARM_LIST,
                  SCSI_ASCQ_INVALID_FIELD_IN_PARM_LIST
               );
            }
            return SATI_FAILURE_CHECK_RESPONSE_DATA;
         }
         if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
            sequence->type = SATI_SEQUENCE_MODE_SENSE_6_INFORMATIONAL_EXCP_CONTROL;
         else
            sequence->type = SATI_SEQUENCE_MODE_SENSE_10_INFORMATIONAL_EXCP_CONTROL;
      break;
      default:
         sati_scsi_sense_data_construct(
            sequence,
            scsi_io,
            SCSI_STATUS_CHECK_CONDITION,
            SCSI_SENSE_ILLEGAL_REQUEST,
            SCSI_ASC_INVALID_FIELD_IN_CDB,
            SCSI_ASCQ_INVALID_FIELD_IN_CDB
         );
         return SATI_FAILURE_CHECK_RESPONSE_DATA;
      break;
   }
   return SATI_SUCCESS;
}
static SATI_STATUS sati_mode_sense_is_page_code_supported ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , U8 cdb_length ) { U8 * cdb = sati_cb_get_cdb_address ( scsi_io ) ; switch ( sati_get_cdb_byte ( cdb , 2 ) & SCSI_MODE_SENSE_PAGE_CODE_ENABLE ) { case SCSI_MODE_PAGE_CACHING : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_CACHING ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_CACHING ; break ; case SCSI_MODE_PAGE_ALL_PAGES : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_ALL_PAGES ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_ALL_PAGES ; break ; case SCSI_MODE_PAGE_READ_WRITE_ERROR : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_READ_WRITE_ERROR ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_READ_WRITE_ERROR ; break ; case SCSI_MODE_PAGE_DISCONNECT_RECONNECT : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_DISCONNECT_RECONNECT ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_DISCONNECT_RECONNECT ; break ; case SCSI_MODE_PAGE_CONTROL : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_CONTROL ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_CONTROL ; break ; case SCSI_MODE_PAGE_POWER_CONDITION : if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_POWER_CONDITION ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_POWER_CONDITION ; break ; case SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL : if ( ( sequence -> device -> capabilities | SATI_DEVICE_CAP_SMART_SUPPORT ) == 0 ) { if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) { sati_scsi_sense_data_construct ( sequence , scsi_io , SCSI_STATUS_CHECK_CONDITION , SCSI_SENSE_ILLEGAL_REQUEST , SCSI_ASC_INVALID_FIELD_IN_CDB , SCSI_ASCQ_INVALID_FIELD_IN_CDB ) ; } else { sati_scsi_sense_data_construct ( sequence , scsi_io , SCSI_STATUS_CHECK_CONDITION , SCSI_SENSE_ILLEGAL_REQUEST , SCSI_ASC_INVALID_FIELD_IN_PARM_LIST , SCSI_ASCQ_INVALID_FIELD_IN_PARM_LIST ) ; } return SATI_FAILURE_CHECK_RESPONSE_DATA ; } if ( sati_get_cdb_byte ( cdb , 0 ) == SCSI_MODE_SENSE_6 ) sequence -> type = SATI_SEQUENCE_MODE_SENSE_6_INFORMATIONAL_EXCP_CONTROL ; else sequence -> type = SATI_SEQUENCE_MODE_SENSE_10_INFORMATIONAL_EXCP_CONTROL ; break ; default : sati_scsi_sense_data_construct ( sequence , scsi_io , SCSI_STATUS_CHECK_CONDITION , SCSI_SENSE_ILLEGAL_REQUEST , SCSI_ASC_INVALID_FIELD_IN_CDB , SCSI_ASCQ_INVALID_FIELD_IN_CDB ) ; return SATI_FAILURE_CHECK_RESPONSE_DATA ; break ; } return SATI_SUCCESS ; }
@brief This method indicates if the page code field in the SCSI CDB
        is supported by this translation.
@brief This method indicates if the page code field in the SCSI CDB is supported by this translation .
// The informational exceptions control page is only useful // if SMART is supported. // For a MODE SENSE, utilize INVALID FIELD IN CDB, // For a MODE SELECT, utilize INVALID FIELD IN PARAMETER LIST.