FreeBSD/sys/dev/isci/scil/scic_sds_smp_request.c
/**
 * @brief This method is called by the SCI user to build an SMP
 *        IO request.
 *
 * @pre
 *        - The user must have previously called scic_io_request_construct()
 *          on the supplied IO request.
 *
 * @param[in]  scic_io_request This parameter specifies the handle to the
 *             io request object to be built.
 *
 * @return Indicate if the controller successfully built the IO request.
 * @retval SCI_SUCCESS This value is returned if the IO request was
 *         successfully built.
 * @retval SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned if the
 *         remote_device does not support the SMP protocol.
 * @retval SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the
 *         user did not properly set the association between the SCIC IO
 *         request and the user's IO request.  Please refer to the
 *         sci_object_set_association() routine for more
 *         information.
 */
@brief This method is called by the SCI user to build an SMP
IO request.

@pre
- The user must have previously called scic_io_request_construct()
on the supplied IO request.

@param[in]  scic_io_request This parameter specifies the handle to the
io request object to be built.

@return Indicate if the controller successfully built the IO request.
@retval SCI_SUCCESS This value is returned if the IO request was
successfully built.
@retval SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned if the
remote_device does not support the SMP protocol.
@retval SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the
user did not properly set the association between the SCIC IO
request and the user's IO request.  Please refer to the
sci_object_set_association() routine for more
information.
@brief This method is called by the SCI user to build an SMP IO request . @pre - The user must have previously called scic_io_request_construct () on the supplied IO request . @param [ in ] scic_io_request This parameter specifies the handle to the io request object to be built . @return Indicate if the controller successfully built the IO request . @retval SCI_SUCCESS This value is returned if the IO request was successfully built . @retval SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned if the remote_device does not support the SMP protocol . @retval SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not properly set the association between the SCIC IO request and the user ' s IO request . Please refer to the sci_object_set_association () routine for more information .
SCI_STATUS scic_io_request_construct_smp(
   SCI_IO_REQUEST_HANDLE_T  scic_smp_request
)
{
   SMP_REQUEST_T smp_request;
   SCIC_SDS_REQUEST_T *this_request = (SCIC_SDS_REQUEST_T *) scic_smp_request;
   SCIC_LOG_TRACE((
      sci_base_object_get_logger(this_request),
      SCIC_LOG_OBJECT_SMP_IO_REQUEST,
      "scic_io_request_construct_smp(0x%x) enter\n",
      this_request
   ));
   this_request->protocol                     = SCIC_SMP_PROTOCOL;
   this_request->has_started_substate_machine = TRUE;
   sci_base_state_machine_construct(
      &this_request->started_substate_machine,
      &this_request->parent.parent,
      scic_sds_smp_request_started_substate_table,
      SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE
   );
   memcpy((char *)&smp_request,
        this_request->command_buffer,
        sizeof(SMP_REQUEST_T));
   if( smp_request.header.request_length == 0 )
   {
       switch( smp_request.header.function )
       {
       case SMP_FUNCTION_DISCOVER:
       case SMP_FUNCTION_REPORT_PHY_ERROR_LOG:
       case SMP_FUNCTION_REPORT_PHY_SATA:
       case SMP_FUNCTION_REPORT_ROUTE_INFORMATION:
           smp_request.header.request_length = 2;
           break;
       case SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION:
       case SMP_FUNCTION_PHY_CONTROL:
       case SMP_FUNCTION_PHY_TEST:
           smp_request.header.request_length = 9;
           break;
       }
   }
   scu_smp_request_construct_task_context(
      this_request,
      &smp_request
   );
   sci_base_state_machine_change_state(
      &this_request->parent.state_machine,
      SCI_BASE_REQUEST_STATE_CONSTRUCTED
   );
   return SCI_SUCCESS;
}
SCI_STATUS scic_io_request_construct_smp ( SCI_IO_REQUEST_HANDLE_T scic_smp_request ) { SMP_REQUEST_T smp_request ; SCIC_SDS_REQUEST_T * this_request = ( SCIC_SDS_REQUEST_T * ) scic_smp_request ; SCIC_LOG_TRACE ( ( sci_base_object_get_logger ( this_request ) , SCIC_LOG_OBJECT_SMP_IO_REQUEST , " \n " , this_request ) ) ; this_request -> protocol = SCIC_SMP_PROTOCOL ; this_request -> has_started_substate_machine = TRUE ; sci_base_state_machine_construct ( & this_request -> started_substate_machine , & this_request -> parent . parent , scic_sds_smp_request_started_substate_table , SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE ) ; memcpy ( ( char * ) & smp_request , this_request -> command_buffer , sizeof ( SMP_REQUEST_T ) ) ; if ( smp_request . header . request_length == 0 ) { switch ( smp_request . header . function ) { case SMP_FUNCTION_DISCOVER : case SMP_FUNCTION_REPORT_PHY_ERROR_LOG : case SMP_FUNCTION_REPORT_PHY_SATA : case SMP_FUNCTION_REPORT_ROUTE_INFORMATION : smp_request . header . request_length = 2 ; break ; case SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION : case SMP_FUNCTION_PHY_CONTROL : case SMP_FUNCTION_PHY_TEST : smp_request . header . request_length = 9 ; break ; } } scu_smp_request_construct_task_context ( this_request , & smp_request ) ; sci_base_state_machine_change_state ( & this_request -> parent . state_machine , SCI_BASE_REQUEST_STATE_CONSTRUCTED ) ; return SCI_SUCCESS ; }
@brief This method is called by the SCI user to build an SMP
        IO request.
@brief This method is called by the SCI user to build an SMP IO request .
// Construct the started sub-state machine. // Construct the SMP SCU Task Context // Look at the SMP requests' header fields; for certain SAS 1.x SMP // functions under SAS 2.0, a zero request length really indicates // a non-zero default length. // Default - zero is a valid default for 2.0.