FreeBSD/sys/dev/isci/scil/sati_passthrough.c
/**
 * @brief This method will translate the SCSI Passthrough command
 *        into the corresponding ATA command.
 *
 * @return Indicate if the command translation succeeded.
 * @retval SATI_SUCCESS This is returned if the command translation was
 *         successful.
 * @retval SATI_FAILURE This is returned if the command translation was
 *         unsuccessful
 */
@brief This method will translate the SCSI Passthrough command
into the corresponding ATA command.

@return Indicate if the command translation succeeded.
@retval SATI_SUCCESS This is returned if the command translation was
successful.
@retval SATI_FAILURE This is returned if the command translation was
unsuccessful
@brief This method will translate the SCSI Passthrough command into the corresponding ATA command . @return Indicate if the command translation succeeded . @retval SATI_SUCCESS This is returned if the command translation was successful . @retval SATI_FAILURE This is returned if the command translation was unsuccessful
SATI_STATUS sati_passthrough_12_translate_command(
   SATI_TRANSLATOR_SEQUENCE_T * sequence,
   void                       * scsi_io,
   void                       * ata_io
)
{
   SATI_STATUS   status;
   U8          * cdb;
   U8          * register_fis;
   status = SATI_FAILURE;
   sequence->type = SATI_SEQUENCE_ATA_PASSTHROUGH_12;
   sequence->state = SATI_SEQUENCE_STATE_TRANSLATE_DATA;
   cdb = sati_cb_get_cdb_address(scsi_io);
   sequence->protocol = PASSTHROUGH_CDB_PROTOCOL (cdb);
   register_fis = sati_cb_get_h2d_register_fis_address(ata_io);
   if (sequence->protocol == PASSTHROUGH_DMA)
   {
      if (PASSTHROUGH_CDB_T_DIR(cdb) == 0x1)
      {
         sequence->protocol = PASSTHROUGH_UDMA_DATA_IN;
      }
      else
      {
         sequence->protocol = PASSTHROUGH_UDMA_DATA_OUT;
      }
   }
   if (sati_passthrough_check_direction(sequence, cdb) != SATI_COMPLETE
       || sati_passthrough_multiple_count_error(cdb)
      )
   {
      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;
   }
   sati_set_ata_features(register_fis, sati_get_cdb_byte(cdb, 3));
   sati_set_ata_sector_count(register_fis, sati_get_cdb_byte(cdb, 4));
   sati_set_ata_lba_low(register_fis, sati_get_cdb_byte(cdb, 5));
   sati_set_ata_lba_mid(register_fis, sati_get_cdb_byte(cdb, 6));
   sati_set_ata_lba_high(register_fis, sati_get_cdb_byte(cdb, 7));
   sati_set_ata_device_head(register_fis, sati_get_cdb_byte(cdb, 8));
   sati_set_ata_command(register_fis, sati_get_cdb_byte(cdb, 9));
   sequence->state = SATI_SEQUENCE_STATE_AWAIT_RESPONSE;
   return SATI_SUCCESS;
}
SATI_STATUS sati_passthrough_12_translate_command ( SATI_TRANSLATOR_SEQUENCE_T * sequence , void * scsi_io , void * ata_io ) { SATI_STATUS status ; U8 * cdb ; U8 * register_fis ; status = SATI_FAILURE ; sequence -> type = SATI_SEQUENCE_ATA_PASSTHROUGH_12 ; sequence -> state = SATI_SEQUENCE_STATE_TRANSLATE_DATA ; cdb = sati_cb_get_cdb_address ( scsi_io ) ; sequence -> protocol = PASSTHROUGH_CDB_PROTOCOL ( cdb ) ; register_fis = sati_cb_get_h2d_register_fis_address ( ata_io ) ; if ( sequence -> protocol == PASSTHROUGH_DMA ) { if ( PASSTHROUGH_CDB_T_DIR ( cdb ) == 0x1 ) { sequence -> protocol = PASSTHROUGH_UDMA_DATA_IN ; } else { sequence -> protocol = PASSTHROUGH_UDMA_DATA_OUT ; } } if ( sati_passthrough_check_direction ( sequence , cdb ) != SATI_COMPLETE || sati_passthrough_multiple_count_error ( cdb ) ) { 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 ; } sati_set_ata_features ( register_fis , sati_get_cdb_byte ( cdb , 3 ) ) ; sati_set_ata_sector_count ( register_fis , sati_get_cdb_byte ( cdb , 4 ) ) ; sati_set_ata_lba_low ( register_fis , sati_get_cdb_byte ( cdb , 5 ) ) ; sati_set_ata_lba_mid ( register_fis , sati_get_cdb_byte ( cdb , 6 ) ) ; sati_set_ata_lba_high ( register_fis , sati_get_cdb_byte ( cdb , 7 ) ) ; sati_set_ata_device_head ( register_fis , sati_get_cdb_byte ( cdb , 8 ) ) ; sati_set_ata_command ( register_fis , sati_get_cdb_byte ( cdb , 9 ) ) ; sequence -> state = SATI_SEQUENCE_STATE_AWAIT_RESPONSE ; return SATI_SUCCESS ; }
@brief This method will translate the SCSI Passthrough command
        into the corresponding ATA command.
@brief This method will translate the SCSI Passthrough command into the corresponding ATA command .
/*
    * CAM will send passthrough commands with protocol set to multiword
    * DMA even though no multiword DMA mode is selected on the device.
    * This is because some controllers (LSI) will only accept
    * ATA_PASSTHROUGH commands with DMA mode - not UDMA_IN/OUT.
    *
    * Since isci does not support multiword DMA, fix this up here.
    */ // Fail due to mismatch