FreeBSD/sys/dev/isci/scil/scic_sds_stp_request.c
/**
 * @brief This method constructs the SATA request object.
 *
 * @param[in] this_request
 * @param[in] sat_protocol
 * @param[in] transfer_length
 * @param[in] data_direction
 * @param[in] copy_rx_frame
 * @param[in] do_translate_sgl This parameter specifies whether SGL
 *            translation should be performed or if the user is handling
 *            it.
 *
 * @return SCI_STATUS
 */
@brief This method constructs the SATA request object.


@brief This method constructs the SATA request object .
SCI_STATUS scic_sds_io_request_construct_sata(
   SCIC_SDS_REQUEST_T          * this_request,
   U8                            sat_protocol,
   U32                           transfer_length,
   SCI_IO_REQUEST_DATA_DIRECTION data_direction,
   BOOL                          copy_rx_frame,
   BOOL                          do_translate_sgl
)
{
   SCI_STATUS  status = SCI_SUCCESS;
   this_request->protocol = SCIC_STP_PROTOCOL;
   this_request->sat_protocol = sat_protocol;
   switch (sat_protocol)
   {
   case SAT_PROTOCOL_FPDMA:
      scic_sds_stp_optimized_request_construct(
         this_request,
         SCU_TASK_TYPE_FPDMAQ_READ,
         transfer_length,
         data_direction
      );
      if (do_translate_sgl == TRUE)
         scic_sds_request_build_sgl(this_request);
   break;
   case SAT_PROTOCOL_UDMA_DATA_IN:
   case SAT_PROTOCOL_UDMA_DATA_OUT:
      scic_sds_stp_non_ncq_request_construct(this_request);
      scic_sds_stp_optimized_request_construct(
         this_request, SCU_TASK_TYPE_DMA_IN, transfer_length, data_direction
      );
      if (do_translate_sgl == TRUE)
         scic_sds_request_build_sgl(this_request);
      sci_base_state_machine_construct(
         &this_request->started_substate_machine,
         &this_request->parent.parent,
         scic_sds_stp_request_started_udma_substate_table,
         SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE
      );
   break;
   case SAT_PROTOCOL_PIO_DATA_IN:
   case SAT_PROTOCOL_PIO_DATA_OUT:
      status = scic_sds_stp_pio_request_construct(
                  this_request, sat_protocol, copy_rx_frame);
   break;
   case SAT_PROTOCOL_ATA_HARD_RESET:
   case SAT_PROTOCOL_SOFT_RESET:
      status = scic_sds_stp_soft_reset_request_construct(this_request);
   break;
   case SAT_PROTOCOL_NON_DATA:
      status = scic_sds_stp_non_data_request_construct(this_request);
   break;
#if !defined(DISABLE_ATAPI)
   case SAT_PROTOCOL_PACKET_NON_DATA:
   case SAT_PROTOCOL_PACKET_DMA_DATA_IN:
   case SAT_PROTOCOL_PACKET_DMA_DATA_OUT:
   case SAT_PROTOCOL_PACKET_PIO_DATA_IN:
   case SAT_PROTOCOL_PACKET_PIO_DATA_OUT:
      status = scic_sds_stp_packet_request_construct(this_request);
      if (do_translate_sgl == TRUE)
         scic_sds_request_build_sgl(this_request);
   break;
#endif
   case SAT_PROTOCOL_DMA_QUEUED:
   case SAT_PROTOCOL_DMA:
   case SAT_PROTOCOL_DEVICE_DIAGNOSTIC:
   case SAT_PROTOCOL_DEVICE_RESET:
   case SAT_PROTOCOL_RETURN_RESPONSE_INFO:
   default:
      SCIC_LOG_ERROR((
         sci_base_object_get_logger(this_request),
         SCIC_LOG_OBJECT_STP_IO_REQUEST,
         "SCIC IO Request 0x%x received un-handled SAT Protocol %d.\n",
         this_request, sat_protocol
      ));
      status = SCI_FAILURE;
   break;
   }
   if (status == SCI_SUCCESS)
   {
      scic_sds_request_initialize_state_logging(this_request);
      sci_base_state_machine_change_state(
         &this_request->parent.state_machine,
         SCI_BASE_REQUEST_STATE_CONSTRUCTED
      );
   }
   return status;
}
SCI_STATUS scic_sds_io_request_construct_sata ( SCIC_SDS_REQUEST_T * this_request , U8 sat_protocol , U32 transfer_length , SCI_IO_REQUEST_DATA_DIRECTION data_direction , BOOL copy_rx_frame , BOOL do_translate_sgl ) { SCI_STATUS status = SCI_SUCCESS ; this_request -> protocol = SCIC_STP_PROTOCOL ; this_request -> sat_protocol = sat_protocol ; switch ( sat_protocol ) { case SAT_PROTOCOL_FPDMA : scic_sds_stp_optimized_request_construct ( this_request , SCU_TASK_TYPE_FPDMAQ_READ , transfer_length , data_direction ) ; if ( do_translate_sgl == TRUE ) scic_sds_request_build_sgl ( this_request ) ; break ; case SAT_PROTOCOL_UDMA_DATA_IN : case SAT_PROTOCOL_UDMA_DATA_OUT : scic_sds_stp_non_ncq_request_construct ( this_request ) ; scic_sds_stp_optimized_request_construct ( this_request , SCU_TASK_TYPE_DMA_IN , transfer_length , data_direction ) ; if ( do_translate_sgl == TRUE ) scic_sds_request_build_sgl ( this_request ) ; sci_base_state_machine_construct ( & this_request -> started_substate_machine , & this_request -> parent . parent , scic_sds_stp_request_started_udma_substate_table , SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE ) ; break ; case SAT_PROTOCOL_PIO_DATA_IN : case SAT_PROTOCOL_PIO_DATA_OUT : status = scic_sds_stp_pio_request_construct ( this_request , sat_protocol , copy_rx_frame ) ; break ; case SAT_PROTOCOL_ATA_HARD_RESET : case SAT_PROTOCOL_SOFT_RESET : status = scic_sds_stp_soft_reset_request_construct ( this_request ) ; break ; case SAT_PROTOCOL_NON_DATA : status = scic_sds_stp_non_data_request_construct ( this_request ) ; break ; #if ! defined ( DISABLE_ATAPI ) case SAT_PROTOCOL_PACKET_NON_DATA : case SAT_PROTOCOL_PACKET_DMA_DATA_IN : case SAT_PROTOCOL_PACKET_DMA_DATA_OUT : case SAT_PROTOCOL_PACKET_PIO_DATA_IN : case SAT_PROTOCOL_PACKET_PIO_DATA_OUT : status = scic_sds_stp_packet_request_construct ( this_request ) ; if ( do_translate_sgl == TRUE ) scic_sds_request_build_sgl ( this_request ) ; break ; #endif case SAT_PROTOCOL_DMA_QUEUED : case SAT_PROTOCOL_DMA : case SAT_PROTOCOL_DEVICE_DIAGNOSTIC : case SAT_PROTOCOL_DEVICE_RESET : case SAT_PROTOCOL_RETURN_RESPONSE_INFO : default : SCIC_LOG_ERROR ( ( sci_base_object_get_logger ( this_request ) , SCIC_LOG_OBJECT_STP_IO_REQUEST , " \n " , this_request , sat_protocol ) ) ; status = SCI_FAILURE ; break ; } if ( status == SCI_SUCCESS ) { scic_sds_request_initialize_state_logging ( this_request ) ; sci_base_state_machine_change_state ( & this_request -> parent . state_machine , SCI_BASE_REQUEST_STATE_CONSTRUCTED ) ; } return status ; }
@brief This method constructs the SATA request object.
@brief This method constructs the SATA request object .
// Copy over the SGL elements // Copy over the SGL elements