FreeBSD/sys/dev/isci/scil/scic_sds_stp_request.c
/**
 * @brief This method process TC completions while in the state where
 *        we are waiting for TC completions.
 *
 * @param[in] this_request
 * @param[in] completion_code
 *
 * @return SCI_STATUS
 */
@brief This method process TC completions while in the state where
we are waiting for TC completions.




@brief This method process TC completions while in the state where we are waiting for TC completions .
static
SCI_STATUS scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler(
   SCIC_SDS_REQUEST_T * request,
   U32                  completion_code
)
{
   SCI_STATUS               status = SCI_SUCCESS;
   SCIC_SDS_STP_REQUEST_T * this_request = (SCIC_SDS_STP_REQUEST_T *)request;
   switch (SCU_GET_COMPLETION_TL_STATUS(completion_code))
   {
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
      scic_sds_stp_request_udma_complete_request(
         &this_request->parent, SCU_TASK_DONE_GOOD, SCI_SUCCESS
      );
   break;
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_FIS):
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR):
      if (this_request->d2h_reg_fis.fis_type == SATA_FIS_TYPE_REGD2H)
      {
         scic_sds_remote_device_suspend(
            this_request->parent.target_device,
            SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))
         );
         scic_sds_stp_request_udma_complete_request(
            &this_request->parent,
            SCU_TASK_DONE_CHECK_RESPONSE,
            SCI_FAILURE_IO_RESPONSE_VALID
         );
      }
      else
      {
         sci_base_state_machine_change_state(
            &this_request->parent.started_substate_machine,
            SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE
         );
      }
   break;
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_INV_FIS_LEN):
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR):
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_R_ERR):
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CMD_LL_R_ERR):
   case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CRC_ERR):
      scic_sds_remote_device_suspend(
         this_request->parent.target_device,
         SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))
      );
   default:
      SCIC_LOG_ERROR((
         sci_base_object_get_logger(&this_request->parent),
         SCIC_LOG_OBJECT_STP_IO_REQUEST,
         "SCIC IO Request 0x%x returning CONTROLLER_SPECIFIC_IO_ERR for completion code 0x%x\n",
         &this_request->parent, completion_code
      ));
      scic_sds_stp_request_udma_complete_request(
         &this_request->parent,
         SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
         SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
      );
      break;
   }
   return status;
}
static SCI_STATUS scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler ( SCIC_SDS_REQUEST_T * request , U32 completion_code ) { SCI_STATUS status = SCI_SUCCESS ; SCIC_SDS_STP_REQUEST_T * this_request = ( SCIC_SDS_STP_REQUEST_T * ) request ; switch ( SCU_GET_COMPLETION_TL_STATUS ( completion_code ) ) { case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_GOOD ) : scic_sds_stp_request_udma_complete_request ( & this_request -> parent , SCU_TASK_DONE_GOOD , SCI_SUCCESS ) ; break ; case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_UNEXP_FIS ) : case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_REG_ERR ) : if ( this_request -> d2h_reg_fis . fis_type == SATA_FIS_TYPE_REGD2H ) { scic_sds_remote_device_suspend ( this_request -> parent . target_device , SCU_EVENT_SPECIFIC ( SCU_NORMALIZE_COMPLETION_STATUS ( completion_code ) ) ) ; scic_sds_stp_request_udma_complete_request ( & this_request -> parent , SCU_TASK_DONE_CHECK_RESPONSE , SCI_FAILURE_IO_RESPONSE_VALID ) ; } else { sci_base_state_machine_change_state ( & this_request -> parent . started_substate_machine , SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE ) ; } break ; case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_INV_FIS_LEN ) : case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_MAX_PLD_ERR ) : case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_LL_R_ERR ) : case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_CMD_LL_R_ERR ) : case SCU_MAKE_COMPLETION_STATUS ( SCU_TASK_DONE_CRC_ERR ) : scic_sds_remote_device_suspend ( this_request -> parent . target_device , SCU_EVENT_SPECIFIC ( SCU_NORMALIZE_COMPLETION_STATUS ( completion_code ) ) ) ; default : SCIC_LOG_ERROR ( ( sci_base_object_get_logger ( & this_request -> parent ) , SCIC_LOG_OBJECT_STP_IO_REQUEST , " \n " , & this_request -> parent , completion_code ) ) ; scic_sds_stp_request_udma_complete_request ( & this_request -> parent , SCU_NORMALIZE_COMPLETION_STATUS ( completion_code ) , SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR ) ; break ; } return status ; }
@brief This method process TC completions while in the state where
        we are waiting for TC completions.
@brief This method process TC completions while in the state where we are waiting for TC completions .
// We must check ther response buffer to see if the D2H Register FIS was // received before we got the TC completion. // If we have an error completion status for the TC then we can expect a // D2H register FIS from the device so we must change state to wait for it /// @todo Check to see if any of these completion status need to wait for ///       the device to host register fis. /// @todo We can retry the command for SCU_TASK_DONE_CMD_LL_R_ERR - this comes only for B0 // Fall through to the default case // All other completion status cause the IO to be complete.