FreeBSD/sys/dev/isci/scil/scif_sas_controller_state_handlers.c
/**
 * @brief This method provides INITIALIZED state specific handling for
 *        when a user attempts to start a controller.
 *
 * @param[in]  controller This parameter specifies the controller object
 *             on which the user is attempting to perform a start
 *             operation.
 * @param[in]  timeout This parameter specifies the timeout value (in
 *             milliseconds) to be utilized for this operation.
 *
 * @return This method returns an indication of whether the start operation
 *         succeeded.
 * @retval SCI_SUCCESS This value is returned when the start operation
 *         begins successfully.
 */
@brief This method provides INITIALIZED state specific handling for
when a user attempts to start a controller.

@param[in]  controller This parameter specifies the controller object
on which the user is attempting to perform a start
operation.
@param[in]  timeout This parameter specifies the timeout value (in
milliseconds) to be utilized for this operation.

@return This method returns an indication of whether the start operation
succeeded.
@retval SCI_SUCCESS This value is returned when the start operation
begins successfully.
@brief This method provides INITIALIZED state specific handling for when a user attempts to start a controller . @param [ in ] controller This parameter specifies the controller object on which the user is attempting to perform a start operation . @param [ in ] timeout This parameter specifies the timeout value ( in milliseconds ) to be utilized for this operation . @return This method returns an indication of whether the start operation succeeded . @retval SCI_SUCCESS This value is returned when the start operation begins successfully .
static
SCI_STATUS scif_sas_controller_initialized_start_handler(
   SCI_BASE_CONTROLLER_T * controller,
   U32                     timeout
)
{
   SCI_STATUS              status        = SCI_SUCCESS;
   SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T *)controller;
   U16                     index         = 0;
   SCI_PHYSICAL_MEMORY_DESCRIPTOR_T internal_reqeust_mde =
      fw_controller->mdes[SCIF_SAS_MDE_INTERNAL_IO];
   void * internal_request_virtual_address =  internal_reqeust_mde.virtual_address;
   POINTER_UINT address = (POINTER_UINT)internal_request_virtual_address;
   SCIF_LOG_TRACE((
      sci_base_object_get_logger(fw_controller),
      SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
      "scif_sas_controller_initialized_start_handler(0x%x, 0x%x) enter\n",
      controller, timeout
   ));
   sci_base_state_machine_change_state(
      &fw_controller->parent.state_machine,
      SCI_BASE_CONTROLLER_STATE_STARTING
   );
   status = scif_sas_controller_validate_mdl(fw_controller);
   if (status == SCI_SUCCESS)
   {
      sci_pool_initialize(fw_controller->internal_request_memory_pool);
      for (index = 0; index < fw_controller->internal_request_entries; index++)
      {
         sci_pool_put(fw_controller->internal_request_memory_pool, address);
         address += scif_sas_internal_request_get_object_size();
      }
      scif_cb_start_internal_io_task_create(fw_controller);
   }
   if (status == SCI_SUCCESS)
   {
      for (index = 0;
           (index < SCI_MAX_DOMAINS) && (status == SCI_SUCCESS);
           index++)
      {
         sci_base_state_machine_change_state(
            &fw_controller->domains[index].parent.state_machine,
            SCI_BASE_DOMAIN_STATE_STARTING
         );
         status = fw_controller->domains[index].operation.status;
      }
   }
   if (status != SCI_SUCCESS)
   {
      SCIF_LOG_ERROR((
         sci_base_object_get_logger(fw_controller),
         SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
         "Controller:0x%x Domain:0x%x Status:0x%x unable to start\n",
         fw_controller, index, status
      ));
      return status;
   }
   status = scic_controller_start(fw_controller->core_object, timeout);
   if (status != SCI_SUCCESS)
   {
      SCIF_LOG_ERROR((
         sci_base_object_get_logger(fw_controller),
         SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION,
         "Controller:0x%x Status:0x%x unable to start controller.\n",
         fw_controller, status
      ));
      sci_base_state_machine_change_state(
         &fw_controller->parent.state_machine,
         SCI_BASE_CONTROLLER_STATE_FAILED
      );
   }
   return status;
}
static SCI_STATUS scif_sas_controller_initialized_start_handler ( SCI_BASE_CONTROLLER_T * controller , U32 timeout ) { SCI_STATUS status = SCI_SUCCESS ; SCIF_SAS_CONTROLLER_T * fw_controller = ( SCIF_SAS_CONTROLLER_T * ) controller ; U16 index = 0 ; SCI_PHYSICAL_MEMORY_DESCRIPTOR_T internal_reqeust_mde = fw_controller -> mdes [ SCIF_SAS_MDE_INTERNAL_IO ] ; void * internal_request_virtual_address = internal_reqeust_mde . virtual_address ; POINTER_UINT address = ( POINTER_UINT ) internal_request_virtual_address ; SCIF_LOG_TRACE ( ( sci_base_object_get_logger ( fw_controller ) , SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION , " \n " , controller , timeout ) ) ; sci_base_state_machine_change_state ( & fw_controller -> parent . state_machine , SCI_BASE_CONTROLLER_STATE_STARTING ) ; status = scif_sas_controller_validate_mdl ( fw_controller ) ; if ( status == SCI_SUCCESS ) { sci_pool_initialize ( fw_controller -> internal_request_memory_pool ) ; for ( index = 0 ; index < fw_controller -> internal_request_entries ; index ++ ) { sci_pool_put ( fw_controller -> internal_request_memory_pool , address ) ; address += scif_sas_internal_request_get_object_size ( ) ; } scif_cb_start_internal_io_task_create ( fw_controller ) ; } if ( status == SCI_SUCCESS ) { for ( index = 0 ; ( index < SCI_MAX_DOMAINS ) && ( status == SCI_SUCCESS ) ; index ++ ) { sci_base_state_machine_change_state ( & fw_controller -> domains [ index ] . parent . state_machine , SCI_BASE_DOMAIN_STATE_STARTING ) ; status = fw_controller -> domains [ index ] . operation . status ; } } if ( status != SCI_SUCCESS ) { SCIF_LOG_ERROR ( ( sci_base_object_get_logger ( fw_controller ) , SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION , " \n " , fw_controller , index , status ) ) ; return status ; } status = scic_controller_start ( fw_controller -> core_object , timeout ) ; if ( status != SCI_SUCCESS ) { SCIF_LOG_ERROR ( ( sci_base_object_get_logger ( fw_controller ) , SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_INITIALIZATION , " \n " , fw_controller , status ) ) ; sci_base_state_machine_change_state ( & fw_controller -> parent . state_machine , SCI_BASE_CONTROLLER_STATE_FAILED ) ; } return status ; }
@brief This method provides INITIALIZED state specific handling for
        when a user attempts to start a controller.
@brief This method provides INITIALIZED state specific handling for when a user attempts to start a controller .
// initialization work for internal request path. It must be done before // starting domain. // fill in the sci_pool for internal requests. // Using DPC for starting internal IOs, if yes, we need to intialize // DPC here. // Kick-start the domain state machines and, by association, the // core port's. // This will ensure we get valid port objects supplied with link up // messages. // Validate that all the domain state machines began successfully. // Attempt to start the core controller.