FreeBSD/sys/dev/isci/scil/scic_sds_controller.c
/**
 * This method is the SCIC_SDS_CONTROLLER start handler for the initialized
 * state.
 *    - Validate we have a good memory descriptor table
 *    - Initialze the physical memory before programming the hardware
 *    - Program the SCU hardware with the physical memory addresses passed in
 *      the memory descriptor table.
 *    - Initialzie the TCi pool
 *    - Initialize the RNi pool
 *    - Initialize the completion queue
 *    - Initialize the unsolicited frame data
 *    - Take the SCU port task scheduler out of reset
 *    - Start the first phy object.
 *    - Transition to SCI_BASE_CONTROLLER_STATE_STARTING.
 *
 * @param[in] controller This is the SCI_BASE_CONTROLLER object which is cast
 *       into a SCIC_SDS_CONTROLLER object.
 * @param[in] timeout This is the allowed time for the controller object to
 *       reach the started state.
 *
 * @return SCI_STATUS
 * @retval SCI_SUCCESS if all of the controller start operations complete
 * @retval SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD if one or more of the
 *         memory descriptor fields is invalid.
 */
This method is the SCIC_SDS_CONTROLLER start handler for the initialized
state.
- Validate we have a good memory descriptor table
- Initialze the physical memory before programming the hardware
- Program the SCU hardware with the physical memory addresses passed in
the memory descriptor table.

@param[in] controller This is the SCI_BASE_CONTROLLER object which is cast
into a SCIC_SDS_CONTROLLER object.
@param[in] timeout This is the allowed time for the controller object to
reach the started state.

@return SCI_STATUS
@retval SCI_SUCCESS if all of the controller start operations complete
@retval SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD if one or more of the
memory descriptor fields is invalid.
This method is the SCIC_SDS_CONTROLLER start handler for the initialized state . - Validate we have a good memory descriptor table - Initialze the physical memory before programming the hardware - Program the SCU hardware with the physical memory addresses passed in the memory descriptor table . @param [ in ] controller This is the SCI_BASE_CONTROLLER object which is cast into a SCIC_SDS_CONTROLLER object . @param [ in ] timeout This is the allowed time for the controller object to reach the started state . @return SCI_STATUS @retval SCI_SUCCESS if all of the controller start operations complete @retval SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD if one or more of the memory descriptor fields is invalid .
static
SCI_STATUS scic_sds_controller_initialized_state_start_handler(
   SCI_BASE_CONTROLLER_T * controller,
   U32                     timeout
)
{
   U16                     index;
   SCI_STATUS              result;
   SCIC_SDS_CONTROLLER_T * this_controller;
   this_controller = (SCIC_SDS_CONTROLLER_T *)controller;
   result = scic_sds_controller_validate_memory_descriptor_table(this_controller);
   if (result == SCI_SUCCESS)
   {
      scic_sds_controller_ram_initialization(this_controller);
   }
   if (SCI_SUCCESS == result)
   {
      sci_pool_initialize(this_controller->tci_pool);
      for (index = 0; index < this_controller->task_context_entries; index++)
      {
         sci_pool_put(this_controller->tci_pool, index);
      }
      scic_sds_remote_node_table_initialize(
         &this_controller->available_remote_nodes,
         this_controller->remote_node_entries
      );
   }
   if (SCI_SUCCESS == result)
   {
      scic_controller_disable_interrupts(controller);
      scic_sds_controller_enable_port_task_scheduler(this_controller);
      scic_sds_controller_assign_task_entries(this_controller);
      scic_sds_controller_initialize_completion_queue(this_controller);
      scic_sds_controller_initialize_unsolicited_frame_queue(this_controller);
      result = scic_sds_controller_initialize_phy_startup(this_controller);
   }
   for (
          index = 0;
          (index < this_controller->logical_port_entries) && (result == SCI_SUCCESS);
          index++
       )
   {
      result = this_controller->port_table[index].
         state_handlers->parent.start_handler(&this_controller->port_table[index].parent);
   }
   if (SCI_SUCCESS == result)
   {
      scic_sds_controller_start_next_phy(this_controller);
      if (timeout != 0)
         scic_cb_timer_start(controller, this_controller->timeout_timer, timeout);
      sci_base_state_machine_change_state(
         scic_sds_controller_get_base_state_machine(this_controller),
         SCI_BASE_CONTROLLER_STATE_STARTING
      );
   }
   return result;
}
static SCI_STATUS scic_sds_controller_initialized_state_start_handler ( SCI_BASE_CONTROLLER_T * controller , U32 timeout ) { U16 index ; SCI_STATUS result ; SCIC_SDS_CONTROLLER_T * this_controller ; this_controller = ( SCIC_SDS_CONTROLLER_T * ) controller ; result = scic_sds_controller_validate_memory_descriptor_table ( this_controller ) ; if ( result == SCI_SUCCESS ) { scic_sds_controller_ram_initialization ( this_controller ) ; } if ( SCI_SUCCESS == result ) { sci_pool_initialize ( this_controller -> tci_pool ) ; for ( index = 0 ; index < this_controller -> task_context_entries ; index ++ ) { sci_pool_put ( this_controller -> tci_pool , index ) ; } scic_sds_remote_node_table_initialize ( & this_controller -> available_remote_nodes , this_controller -> remote_node_entries ) ; } if ( SCI_SUCCESS == result ) { scic_controller_disable_interrupts ( controller ) ; scic_sds_controller_enable_port_task_scheduler ( this_controller ) ; scic_sds_controller_assign_task_entries ( this_controller ) ; scic_sds_controller_initialize_completion_queue ( this_controller ) ; scic_sds_controller_initialize_unsolicited_frame_queue ( this_controller ) ; result = scic_sds_controller_initialize_phy_startup ( this_controller ) ; } for ( index = 0 ; ( index < this_controller -> logical_port_entries ) && ( result == SCI_SUCCESS ) ; index ++ ) { result = this_controller -> port_table [ index ] . state_handlers -> parent . start_handler ( & this_controller -> port_table [ index ] . parent ) ; } if ( SCI_SUCCESS == result ) { scic_sds_controller_start_next_phy ( this_controller ) ; if ( timeout != 0 ) scic_cb_timer_start ( controller , this_controller -> timeout_timer , timeout ) ; sci_base_state_machine_change_state ( scic_sds_controller_get_base_state_machine ( this_controller ) , SCI_BASE_CONTROLLER_STATE_STARTING ) ; } return result ; }
This method is the SCIC_SDS_CONTROLLER start handler for the initialized
 state.
This method is the SCIC_SDS_CONTROLLER start handler for the initialized state .
// Make sure that the SCI User filled in the memory descriptor table correctly // The memory descriptor list looks good so program the hardware // Build the TCi free pool // Build the RNi free pool // Before anything else lets make sure we will not be interrupted // by the hardware. // Enable the port task scheduler // Assign all the task entries to this controller physical function // Now initialze the completion queue // Initialize the unsolicited frame queue for use // Setup the phy start timer // Start all of the ports on this controller // See if the user requested to timeout this operation.