Commit 524b5f72 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dan Williams

isci: simplify request state handlers

Instead of filling up tables with default handlers call the default
handler in the only caller.

IMHO the whole state handlers concept is not very suitable for the
isci request.  For example there is a single real instance of the
start handler, and we'd be much better off just having a check for
the right state in the only caller, than all this mess.  It's
quite similar for the abort handler as well.

Even the actual state machine has a lot of states that are rather
pointless.  The initial and constructed states are not needed at all
as the request is not reachable for calls before it's fully set up and
started.  And the abort state should be replaced with an abort actions
and a state transition to the completed state.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 78141676
This diff is collapsed.
......@@ -315,13 +315,6 @@ struct scic_sds_io_request_state_handler {
*/
scic_sds_io_request_handler_t complete_handler;
/**
* The destruct_handler specifies the method invoked when a user attempts to
* destruct a request.
*/
scic_sds_io_request_handler_t destruct_handler;
scic_sds_io_request_task_completion_handler_t tc_completion_handler;
scic_sds_io_request_event_handler_t event_handler;
scic_sds_io_request_frame_handler_t frame_handler;
......@@ -394,24 +387,8 @@ extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substat
((a_request)->state_handlers->complete_handler(a_request))
/**
* scic_sds_io_request_tc_completion() -
*
* This macro invokes the core state task completion handler for the
* struct scic_sds_io_request object.
*/
#define scic_sds_io_request_tc_completion(this_request, completion_code) \
{ \
if (this_request->state_machine.current_state_id \
== SCI_BASE_REQUEST_STATE_STARTED \
&& this_request->has_started_substate_machine \
== false) \
scic_sds_request_started_state_tc_completion_handler(this_request, completion_code); \
else \
this_request->state_handlers->tc_completion_handler(this_request, completion_code); \
}
extern enum sci_status
scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code);
/**
* SCU_SGL_ZERO() -
......@@ -492,33 +469,6 @@ enum sci_status scic_sds_io_request_frame_handler(
enum sci_status scic_sds_task_request_terminate(
struct scic_sds_request *this_request);
/*
* *****************************************************************************
* * DEFAULT STATE HANDLERS
* ***************************************************************************** */
enum sci_status scic_sds_request_default_start_handler(
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_complete_handler(
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_destruct_handler(
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_tc_completion_handler(
struct scic_sds_request *this_request,
u32 completion_code);
enum sci_status scic_sds_request_default_event_handler(
struct scic_sds_request *this_request,
u32 event_code);
enum sci_status scic_sds_request_default_frame_handler(
struct scic_sds_request *this_request,
u32 frame_index);
/*
* *****************************************************************************
* * STARTED STATE HANDLERS
......
......@@ -525,22 +525,13 @@ static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_ha
static const struct scic_sds_io_request_state_handler scic_sds_smp_request_started_substate_handler_table[] = {
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_smp_request_await_response_frame_handler,
},
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
}
};
......
......@@ -180,21 +180,11 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler
static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
},
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
}
};
......
......@@ -671,49 +671,25 @@ enum sci_status scic_sds_stp_packet_request_started_completion_delay_complete_ha
const struct scic_sds_io_request_state_handler scic_sds_stp_packet_request_started_substate_handler_table[] = {
[SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler
.tc_completion_handler = scic_sds_stp_packet_request_packet_phase_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler
},
[SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_packet_request_packet_phase_await_pio_setup_frame_handler
},
[SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler
.tc_completion_handler = scic_sds_stp_packet_request_command_phase_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_packet_request_command_phase_await_tc_completion_frame_handler
},
[SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_packet_request_command_phase_await_d2h_fis_frame_handler
},
[SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_stp_packet_request_started_completion_delay_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler
},
};
......
......@@ -555,21 +555,11 @@ static enum sci_status scic_sds_stp_request_non_data_await_d2h_frame_handler(
static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_non_data_substate_handler_table[] = {
[SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_non_data_await_h2d_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
},
[SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_request_non_data_await_d2h_frame_handler,
}
};
......@@ -1212,40 +1202,21 @@ static enum sci_status scic_sds_stp_request_pio_data_in_await_data_event_handler
static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_pio_substate_handler_table[] = {
[SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_pio_await_h2d_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler
},
[SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_request_pio_await_frame_frame_handler
},
[SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_stp_request_pio_data_in_await_data_event_handler,
.frame_handler = scic_sds_stp_request_pio_data_in_await_data_frame_handler
},
[SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_pio_data_out_await_data_transmit_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
}
};
......@@ -1510,21 +1481,12 @@ static enum sci_status scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler
static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_udma_substate_handler_table[] = {
[SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_request_udma_general_frame_handler,
},
[SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler,
},
};
......@@ -1763,30 +1725,15 @@ static enum sci_status scic_sds_stp_request_soft_reset_await_d2h_frame_handler(
static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_soft_reset_substate_handler_table[] = {
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_asserted_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
},
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_diagnostic_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
},
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = {
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_stp_request_soft_reset_await_d2h_frame_handler,
},
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment