FreeBSD/sys/dev/isci/scil/sati_log_sense.c
/**
 * @brief This method will translate the SCSI Log Sense command into ATA commands
 *        specified by SATv2. ATA commands Read Log EXT and SMART Read Log will
 *        be issued by this translation.
 *
 * @return SATI_STATUS Indicates if the command translation succeeded.
 *
 */
@brief This method will translate the SCSI Log Sense command into ATA commands
specified by SATv2. ATA commands Read Log EXT and SMART Read Log will
be issued by this translation.

@return SATI_STATUS Indicates if the command translation succeeded.
@brief This method will translate the SCSI Log Sense command into ATA commands specified by SATv2 . ATA commands Read Log EXT and SMART Read Log will be issued by this translation . @return SATI_STATUS Indicates if the command translation succeeded .
SATI_STATUS sati_log_sense_translate_command(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void                       * scsi_io,
   void                       * ata_io
)
{
   U8 * cdb = sati_cb_get_cdb_address(scsi_io);
   SATI_STATUS status = SATI_FAILURE;
   if(SATI_LOG_SENSE_GET_PC_FIELD(cdb) == 1 &&
      (sati_get_cdb_byte(cdb, 3) == 0))
   {
      sequence->allocation_length = (sati_get_cdb_byte(cdb, 7) << 8) |
                                    (sati_get_cdb_byte(cdb, 8));
      switch(SATI_LOG_SENSE_GET_PAGE_CODE(cdb))
      {
         case SCSI_LOG_PAGE_SUPPORTED_PAGES :
            sati_supported_log_page_construct(sequence, scsi_io);
            sequence->type = SATI_SEQUENCE_LOG_SENSE_SUPPORTED_LOG_PAGE;
            status = SATI_COMPLETE;
            break;
         case SCSI_LOG_PAGE_SELF_TEST :
            if((sequence->device->capabilities &
               SATI_DEVICE_CAP_SMART_SELF_TEST_SUPPORT) == 0)
            {
               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
               );
               status = SATI_FAILURE_CHECK_RESPONSE_DATA;
            }
            else
            {
               if((sequence->device->capabilities &
                  SATI_DEVICE_CAP_48BIT_ENABLE))
               {
                  sati_ata_read_log_ext_construct(
                                     ata_io,
                                     sequence,
                                     ATA_LOG_PAGE_EXTENDED_SMART_SELF_TEST,
                                     sizeof(ATA_EXTENDED_SMART_SELF_TEST_LOG_T)
                  );
                  sequence->type =
                            SATI_SEQUENCE_LOG_SENSE_EXTENDED_SELF_TEST_LOG_PAGE;
                  status = SATI_SUCCESS;
               }
               else
               {
                  sati_ata_smart_read_log_construct(
                                       ata_io,
                                       sequence,
                                       ATA_LOG_PAGE_SMART_SELF_TEST,
                                       sizeof(ATA_SMART_SELF_TEST_LOG_T)
                  );
                  sequence->type = SATI_SEQUENCE_LOG_SENSE_SELF_TEST_LOG_PAGE;
                  status = SATI_SUCCESS;
               }
            }
            break;
         case SCSI_LOG_PAGE_INFORMATION_EXCEPTION :
            if(sequence->device->capabilities & SATI_DEVICE_CAP_SMART_SUPPORT)
            {
               if(sequence->device->capabilities & SATI_DEVICE_CAP_SMART_ENABLE)
               {
                  sati_ata_smart_return_status_construct(
                                       ata_io,
                                       sequence,
                                       ATA_SMART_SUB_CMD_RETURN_STATUS
                  );
                  sequence->type =
                                SATI_SEQUENCE_LOG_SENSE_INFO_EXCEPTION_LOG_PAGE;
                  status = SATI_SUCCESS;
               }
               else
               {
                  sati_scsi_sense_data_construct(
                     sequence,
                     scsi_io,
                     SCSI_STATUS_CHECK_CONDITION,
                     SCSI_SENSE_ABORTED_COMMAND,
                     SCSI_ASC_ATA_DEVICE_FEATURE_NOT_ENABLED,
                     SCSI_ASCQ_ATA_DEVICE_FEATURE_NOT_ENABLED
                  );
                  status = SATI_FAILURE_CHECK_RESPONSE_DATA;
               }
            }
            else
            {
               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
               );
               status = SATI_FAILURE_CHECK_RESPONSE_DATA;
            }
            break;
         default :
            sati_scsi_sense_data_construct(
               sequence,
               scsi_io,
               SCSI_STATUS_CHECK_CONDITION,
               SCSI_SENSE_ILLEGAL_REQUEST,
               SCSI_ASC_NO_ADDITIONAL_SENSE ,
               SCSI_ASCQ_NO_ADDITIONAL_SENSE
            );
            status = SATI_FAILURE_CHECK_RESPONSE_DATA;
            break;
      }
   }
   return status;
}
SATI_STATUS sati_log_sense_translate_command ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , void * ata_io ) { U8 * cdb = sati_cb_get_cdb_address ( scsi_io ) ; SATI_STATUS status = SATI_FAILURE ; if ( SATI_LOG_SENSE_GET_PC_FIELD ( cdb ) == 1 && ( sati_get_cdb_byte ( cdb , 3 ) == 0 ) ) { sequence -> allocation_length = ( sati_get_cdb_byte ( cdb , 7 ) << 8 ) | ( sati_get_cdb_byte ( cdb , 8 ) ) ; switch ( SATI_LOG_SENSE_GET_PAGE_CODE ( cdb ) ) { case SCSI_LOG_PAGE_SUPPORTED_PAGES : sati_supported_log_page_construct ( sequence , scsi_io ) ; sequence -> type = SATI_SEQUENCE_LOG_SENSE_SUPPORTED_LOG_PAGE ; status = SATI_COMPLETE ; break ; case SCSI_LOG_PAGE_SELF_TEST : if ( ( sequence -> device -> capabilities & SATI_DEVICE_CAP_SMART_SELF_TEST_SUPPORT ) == 0 ) { 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 ) ; status = SATI_FAILURE_CHECK_RESPONSE_DATA ; } else { if ( ( sequence -> device -> capabilities & SATI_DEVICE_CAP_48BIT_ENABLE ) ) { sati_ata_read_log_ext_construct ( ata_io , sequence , ATA_LOG_PAGE_EXTENDED_SMART_SELF_TEST , sizeof ( ATA_EXTENDED_SMART_SELF_TEST_LOG_T ) ) ; sequence -> type = SATI_SEQUENCE_LOG_SENSE_EXTENDED_SELF_TEST_LOG_PAGE ; status = SATI_SUCCESS ; } else { sati_ata_smart_read_log_construct ( ata_io , sequence , ATA_LOG_PAGE_SMART_SELF_TEST , sizeof ( ATA_SMART_SELF_TEST_LOG_T ) ) ; sequence -> type = SATI_SEQUENCE_LOG_SENSE_SELF_TEST_LOG_PAGE ; status = SATI_SUCCESS ; } } break ; case SCSI_LOG_PAGE_INFORMATION_EXCEPTION : if ( sequence -> device -> capabilities & SATI_DEVICE_CAP_SMART_SUPPORT ) { if ( sequence -> device -> capabilities & SATI_DEVICE_CAP_SMART_ENABLE ) { sati_ata_smart_return_status_construct ( ata_io , sequence , ATA_SMART_SUB_CMD_RETURN_STATUS ) ; sequence -> type = SATI_SEQUENCE_LOG_SENSE_INFO_EXCEPTION_LOG_PAGE ; status = SATI_SUCCESS ; } else { sati_scsi_sense_data_construct ( sequence , scsi_io , SCSI_STATUS_CHECK_CONDITION , SCSI_SENSE_ABORTED_COMMAND , SCSI_ASC_ATA_DEVICE_FEATURE_NOT_ENABLED , SCSI_ASCQ_ATA_DEVICE_FEATURE_NOT_ENABLED ) ; status = SATI_FAILURE_CHECK_RESPONSE_DATA ; } } else { 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 ) ; status = SATI_FAILURE_CHECK_RESPONSE_DATA ; } break ; default : sati_scsi_sense_data_construct ( sequence , scsi_io , SCSI_STATUS_CHECK_CONDITION , SCSI_SENSE_ILLEGAL_REQUEST , SCSI_ASC_NO_ADDITIONAL_SENSE , SCSI_ASCQ_NO_ADDITIONAL_SENSE ) ; status = SATI_FAILURE_CHECK_RESPONSE_DATA ; break ; } } return status ; }
@brief This method will translate the SCSI Log Sense command into ATA commands
        specified by SATv2.
@brief This method will translate the SCSI Log Sense command into ATA commands specified by SATv2 .
//Return Supported Log Pages log page //Return Self-Test Results log page //check if 48-bit Address feature set is supported //ATA Read Log Ext with log address set to 0x07 //ATA Smart Read Log with log address set to 0x06 //Return Informational Exceptions log page //UNSPECIFIED SATv2r9