Commit 068b2c03 authored by Dan Williams's avatar Dan Williams

isci: kill some long macros

Delete some macros that are longer to type than the open coded operation
that they perform.

scic_sds_phy_get_base_state_machine
scic_sds_phy_get_starting_substate_machine
scic_sds_port_get_base_state_machine
scic_sds_port_get_ready_substate_machine
scic_sds_remote_device_get_base_state_machine
scic_sds_remote_device_get_ready_substate_machine
scic_sds_remote_node_context_set_remote_node_index
scic_sds_controller_get_base_state_machine

Also performs some collateral cleanups like killing casts that assume
structure member ordering, and consolidating a lot of duplicated default
handler code (the primary callers of the *_get_base_state_machine macros) via
a helper.
Reported-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent f942f32e
...@@ -739,9 +739,8 @@ static void scic_sds_controller_transition_to_ready( ...@@ -739,9 +739,8 @@ static void scic_sds_controller_transition_to_ready(
* We move into the ready state, because some of the phys/ports * We move into the ready state, because some of the phys/ports
* may be up and operational. * may be up and operational.
*/ */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&scic->parent.state_machine,
scic_sds_controller_get_base_state_machine(scic), SCI_BASE_CONTROLLER_STATE_READY);
SCI_BASE_CONTROLLER_STATE_READY);
isci_host_start_complete(ihost, status); isci_host_start_complete(ihost, status);
} }
...@@ -751,18 +750,12 @@ void scic_sds_controller_timeout_handler(void *_scic) ...@@ -751,18 +750,12 @@ void scic_sds_controller_timeout_handler(void *_scic)
{ {
struct scic_sds_controller *scic = _scic; struct scic_sds_controller *scic = _scic;
struct isci_host *ihost = sci_object_get_association(scic); struct isci_host *ihost = sci_object_get_association(scic);
enum sci_base_controller_states current_state; struct sci_base_state_machine *sm = &scic->parent.state_machine;
current_state = sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(scic));
if (current_state == SCI_BASE_CONTROLLER_STATE_STARTING) { if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING)
scic_sds_controller_transition_to_ready( scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
scic, SCI_FAILURE_TIMEOUT); else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) {
} else if (current_state == SCI_BASE_CONTROLLER_STATE_STOPPING) { sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED);
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_FAILED);
isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT); isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
} else /* / @todo Now what do we want to do in this case? */ } else /* / @todo Now what do we want to do in this case? */
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
...@@ -1619,16 +1612,15 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic) ...@@ -1619,16 +1612,15 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__, dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
interrupt_status); interrupt_status);
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&scic->parent.state_machine,
scic_sds_controller_get_base_state_machine(scic), SCI_BASE_CONTROLLER_STATE_FAILED);
SCI_BASE_CONTROLLER_STATE_FAILED);
return; return;
} }
/* /* If we dont process any completions I am not sure that we want to do this.
* If we dont process any completions I am not sure that we want to do this. * We are in the middle of a hardware fault and should probably be reset.
* We are in the middle of a hardware fault and should probably be reset. */ */
SMU_IMR_WRITE(scic, 0x00000000); SMU_IMR_WRITE(scic, 0x00000000);
} }
...@@ -1655,12 +1647,8 @@ void scic_sds_controller_link_up( ...@@ -1655,12 +1647,8 @@ void scic_sds_controller_link_up(
else else
dev_dbg(scic_to_dev(scic), dev_dbg(scic_to_dev(scic),
"%s: SCIC Controller linkup event from phy %d in " "%s: SCIC Controller linkup event from phy %d in "
"unexpected state %d\n", "unexpected state %d\n", __func__, sci_phy->phy_index,
__func__, state);
sci_phy->phy_index,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
} }
...@@ -2125,11 +2113,7 @@ enum sci_status scic_controller_initialize( ...@@ -2125,11 +2113,7 @@ enum sci_status scic_controller_initialize(
else else
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC Controller initialize operation requested " "%s: SCIC Controller initialize operation requested "
"in invalid state %d\n", "in invalid state %d\n", __func__, state);
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
return status; return status;
} }
...@@ -2180,11 +2164,7 @@ enum sci_status scic_controller_start( ...@@ -2180,11 +2164,7 @@ enum sci_status scic_controller_start(
else else
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC Controller start operation requested in " "%s: SCIC Controller start operation requested in "
"invalid state %d\n", "invalid state %d\n", __func__, state);
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
return status; return status;
} }
...@@ -2207,11 +2187,7 @@ enum sci_status scic_controller_stop( ...@@ -2207,11 +2187,7 @@ enum sci_status scic_controller_stop(
else else
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC Controller stop operation requested in " "%s: SCIC Controller stop operation requested in "
"invalid state %d\n", "invalid state %d\n", __func__, state);
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
return status; return status;
} }
...@@ -2233,11 +2209,7 @@ enum sci_status scic_controller_reset( ...@@ -2233,11 +2209,7 @@ enum sci_status scic_controller_reset(
else else
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC Controller reset operation requested in " "%s: SCIC Controller reset operation requested in "
"invalid state %d\n", "invalid state %d\n", __func__, state);
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
return status; return status;
} }
...@@ -2765,128 +2737,57 @@ struct scic_sds_controller *scic_controller_alloc(struct device *dev) ...@@ -2765,128 +2737,57 @@ struct scic_sds_controller *scic_controller_alloc(struct device *dev)
return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL); return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
} }
/* static enum sci_status default_controller_handler(struct sci_base_controller *base_scic,
* ***************************************************************************** const char *func)
* * DEFAULT STATE HANDLERS {
* ***************************************************************************** */ struct scic_sds_controller *scic = container_of(base_scic, typeof(*scic), parent);
u32 state = base_scic->state_machine.current_state_id;
dev_warn(scic_to_dev(scic), "%s: invalid state %d\n", func, state);
return SCI_FAILURE_INVALID_STATE;
}
/**
*
* @controller: This is struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @remote_device: This is struct sci_base_remote_device which, if it was used, would
* be cast to a struct scic_sds_remote_device.
* @io_request: This is the struct sci_base_request which, if it was used, would be
* cast to a SCIC_SDS_IO_REQUEST.
* @io_tag: This is the IO tag to be assigned to the IO request or
* SCI_CONTROLLER_INVALID_IO_TAG.
*
* This method is called when the struct scic_sds_controller default start io/task
* handler is in place. - Issue a warning message enum sci_status
* SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_controller_default_start_operation_handler( static enum sci_status scic_sds_controller_default_start_operation_handler(
struct sci_base_controller *controller, struct sci_base_controller *base_scic,
struct sci_base_remote_device *remote_device, struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request, struct sci_base_request *io_request,
u16 io_tag) u16 io_tag)
{ {
struct scic_sds_controller *this_controller; return default_controller_handler(base_scic, __func__);
this_controller = (struct scic_sds_controller *)controller;
dev_warn(scic_to_dev(this_controller),
"%s: SCIC Controller requested to start an io/task from "
"invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
this_controller)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @controller: This is struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @remote_device: This is struct sci_base_remote_device which, if it was used, would
* be cast to a struct scic_sds_remote_device.
* @io_request: This is the struct sci_base_request which, if it was used, would be
* cast to a SCIC_SDS_IO_REQUEST.
*
* This method is called when the struct scic_sds_controller default request handler
* is in place. - Issue a warning message enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_controller_default_request_handler( static enum sci_status scic_sds_controller_default_request_handler(
struct sci_base_controller *controller, struct sci_base_controller *base_scic,
struct sci_base_remote_device *remote_device, struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request) struct sci_base_request *io_request)
{ {
struct scic_sds_controller *this_controller; return default_controller_handler(base_scic, __func__);
this_controller = (struct scic_sds_controller *)controller;
dev_warn(scic_to_dev(this_controller),
"%s: SCIC Controller request operation from invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
this_controller)));
return SCI_FAILURE_INVALID_STATE;
} }
/* static enum sci_status scic_sds_controller_general_reset_handler(struct sci_base_controller *base_scic)
* *****************************************************************************
* * GENERAL (COMMON) STATE HANDLERS
* ***************************************************************************** */
/**
*
* @controller: The struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
*
* This method is called when the struct scic_sds_controller is in the ready state
* reset handler is in place. - Transition to
* SCI_BASE_CONTROLLER_STATE_RESETTING enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_controller_general_reset_handler(
struct sci_base_controller *controller)
{ {
struct scic_sds_controller *this_controller; /* The reset operation is not a graceful cleanup just perform the state
* transition.
this_controller = (struct scic_sds_controller *)controller; */
sci_base_state_machine_change_state(&base_scic->state_machine,
/* SCI_BASE_CONTROLLER_STATE_RESETTING);
* The reset operation is not a graceful cleanup just perform the state
* transition. */
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(this_controller),
SCI_BASE_CONTROLLER_STATE_RESETTING
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/*
* *****************************************************************************
* * RESET STATE HANDLERS
* ***************************************************************************** */
static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic) static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic)
{ {
struct sci_base_state_machine *sm = &base_scic->state_machine;
enum sci_status result = SCI_SUCCESS; enum sci_status result = SCI_SUCCESS;
struct scic_sds_controller *scic; struct scic_sds_controller *scic;
struct isci_host *ihost; struct isci_host *ihost;
u32 index; u32 index, state;
scic = container_of(base_scic, typeof(*scic), parent); scic = container_of(base_scic, typeof(*scic), parent);
ihost = sci_object_get_association(scic); ihost = sci_object_get_association(scic);
sci_base_state_machine_change_state( sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING);
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_INITIALIZING);
scic->timeout_timer = isci_timer_create(ihost, scic->timeout_timer = isci_timer_create(ihost,
scic, scic,
...@@ -3028,13 +2929,10 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct ...@@ -3028,13 +2929,10 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
/* Advance the controller state machine */ /* Advance the controller state machine */
if (result == SCI_SUCCESS) if (result == SCI_SUCCESS)
sci_base_state_machine_change_state( state = SCI_BASE_CONTROLLER_STATE_INITIALIZED;
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_INITIALIZED);
else else
sci_base_state_machine_change_state( state = SCI_BASE_CONTROLLER_STATE_FAILED;
scic_sds_controller_get_base_state_machine(scic), sci_base_state_machine_change_state(sm, state);
SCI_BASE_CONTROLLER_STATE_FAILED);
return result; return result;
} }
...@@ -3065,14 +2963,14 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct ...@@ -3065,14 +2963,14 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
* descriptor fields is invalid. * descriptor fields is invalid.
*/ */
static enum sci_status scic_sds_controller_initialized_state_start_handler( static enum sci_status scic_sds_controller_initialized_state_start_handler(
struct sci_base_controller *controller, struct sci_base_controller *base_scic,
u32 timeout) u32 timeout)
{ {
u16 index; u16 index;
enum sci_status result; enum sci_status result;
struct scic_sds_controller *scic; struct scic_sds_controller *scic;
scic = (struct scic_sds_controller *)controller; scic = container_of(base_scic, typeof(*scic), parent);
/* /*
* Make sure that the SCI User filled in the memory descriptor * Make sure that the SCI User filled in the memory descriptor
...@@ -3135,9 +3033,8 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler( ...@@ -3135,9 +3033,8 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler(
isci_timer_start(scic->timeout_timer, timeout); isci_timer_start(scic->timeout_timer, timeout);
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_scic->state_machine,
scic_sds_controller_get_base_state_machine(scic), SCI_BASE_CONTROLLER_STATE_STARTING);
SCI_BASE_CONTROLLER_STATE_STARTING);
} }
return result; return result;
...@@ -3197,33 +3094,15 @@ static void scic_sds_controller_starting_state_link_down_handler( ...@@ -3197,33 +3094,15 @@ static void scic_sds_controller_starting_state_link_down_handler(
/* scic_sds_port_link_down(port, phy); */ /* scic_sds_port_link_down(port, phy); */
} }
/* static enum sci_status scic_sds_controller_ready_state_stop_handler(struct sci_base_controller *base_scic,
* ***************************************************************************** u32 timeout)
* * READY STATE HANDLERS
* ***************************************************************************** */
/**
*
* @controller: The struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @timeout: The timeout for when the stop operation should report a failure.
*
* This method is called when the struct scic_sds_controller is in the ready state
* stop handler is called. - Start the timeout timer - Transition to
* SCI_BASE_CONTROLLER_STATE_STOPPING. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_controller_ready_state_stop_handler(
struct sci_base_controller *controller,
u32 timeout)
{ {
struct scic_sds_controller *scic = struct scic_sds_controller *scic;
(struct scic_sds_controller *)controller;
scic = container_of(base_scic, typeof(*scic), parent);
isci_timer_start(scic->timeout_timer, timeout); isci_timer_start(scic->timeout_timer, timeout);
sci_base_state_machine_change_state(&base_scic->state_machine,
sci_base_state_machine_change_state( SCI_BASE_CONTROLLER_STATE_STOPPING);
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_STOPPING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -3749,33 +3628,16 @@ static inline void scic_sds_controller_stopping_state_exit( ...@@ -3749,33 +3628,16 @@ static inline void scic_sds_controller_stopping_state_exit(
isci_timer_stop(scic->timeout_timer); isci_timer_stop(scic->timeout_timer);
} }
/** static void scic_sds_controller_resetting_state_enter(struct sci_base_object *object)
*
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
* object.
*
* This method implements the actions taken by the struct scic_sds_controller on entry
* to the SCI_BASE_CONTROLLER_STATE_RESETTING. - Set the state handlers to the
* controllers resetting state. - Write to the SCU hardware reset register to
* force a reset - Transition to the SCI_BASE_CONTROLLER_STATE_RESET none
*/
static void scic_sds_controller_resetting_state_enter(
struct sci_base_object *object)
{ {
struct scic_sds_controller *this_controller; struct scic_sds_controller *scic;
this_controller = (struct scic_sds_controller *)object;
scic_sds_controller_reset_hardware(this_controller);
sci_base_state_machine_change_state( scic = container_of(object, typeof(*scic), parent.parent);
scic_sds_controller_get_base_state_machine(this_controller), scic_sds_controller_reset_hardware(scic);
SCI_BASE_CONTROLLER_STATE_RESET sci_base_state_machine_change_state(&scic->parent.state_machine,
); SCI_BASE_CONTROLLER_STATE_RESET);
} }
/* --------------------------------------------------------------------------- */
const struct sci_base_state scic_sds_controller_state_table[] = { const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_INITIAL] = { [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
.enter_state = scic_sds_controller_initial_state_enter, .enter_state = scic_sds_controller_initial_state_enter,
...@@ -3800,4 +3662,3 @@ const struct sci_base_state scic_sds_controller_state_table[] = { ...@@ -3800,4 +3662,3 @@ const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_STOPPED] = {}, [SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
[SCI_BASE_CONTROLLER_STATE_FAILED] = {} [SCI_BASE_CONTROLLER_STATE_FAILED] = {}
}; };
...@@ -420,15 +420,6 @@ extern const struct sci_base_state scic_sds_controller_state_table[]; ...@@ -420,15 +420,6 @@ extern const struct sci_base_state scic_sds_controller_state_table[];
} \ } \
} }
/**
* scic_sds_controller_get_base_state_machine() -
*
* This is a helper macro that gets the base state machine for the controller
* object
*/
#define scic_sds_controller_get_base_state_machine(this_controller) \
(&(this_controller)->parent.state_machine)
/** /**
* scic_sds_controller_get_port_configuration_agent() - * scic_sds_controller_get_port_configuration_agent() -
* *
......
...@@ -246,7 +246,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, ...@@ -246,7 +246,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
0x1F4); 0x1F4);
/* We can exit the initial state to the stopped state */ /* We can exit the initial state to the stopped state */
sci_base_state_machine_change_state(scic_sds_phy_get_base_state_machine(sci_phy), sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
SCI_BASE_PHY_STATE_STOPPED); SCI_BASE_PHY_STATE_STOPPED);
return SCI_SUCCESS; return SCI_SUCCESS;
...@@ -267,13 +267,10 @@ void scic_sds_phy_sata_timeout(void *phy) ...@@ -267,13 +267,10 @@ void scic_sds_phy_sata_timeout(void *phy)
__func__, __func__,
sci_phy); sci_phy);
sci_base_state_machine_stop( sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
scic_sds_phy_get_starting_substate_machine(sci_phy));
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(sci_phy), SCI_BASE_PHY_STATE_STARTING);
SCI_BASE_PHY_STATE_STARTING
);
} }
/** /**
...@@ -390,9 +387,8 @@ enum sci_status scic_sds_phy_initialize( ...@@ -390,9 +387,8 @@ enum sci_status scic_sds_phy_initialize(
/* /*
* There is nothing that needs to be done in this state just * There is nothing that needs to be done in this state just
* transition to the stopped state. */ * transition to the stopped state. */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(sci_phy), SCI_BASE_PHY_STATE_STOPPED);
SCI_BASE_PHY_STATE_STOPPED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -716,9 +712,9 @@ static void scic_sds_phy_start_sata_link_training( ...@@ -716,9 +712,9 @@ static void scic_sds_phy_start_sata_link_training(
} }
/** /**
* This method performs processing common to all protocols upon completion of * scic_sds_phy_complete_link_training - perform processing common to
* link training. * all protocols upon completion of link training.
* @this_phy: This parameter specifies the phy object for which link training * @sci_phy: This parameter specifies the phy object for which link training
* has completed. * has completed.
* @max_link_rate: This parameter specifies the maximum link rate to be * @max_link_rate: This parameter specifies the maximum link rate to be
* associated with this phy. * associated with this phy.
...@@ -727,37 +723,25 @@ static void scic_sds_phy_start_sata_link_training( ...@@ -727,37 +723,25 @@ static void scic_sds_phy_start_sata_link_training(
* *
*/ */
static void scic_sds_phy_complete_link_training( static void scic_sds_phy_complete_link_training(
struct scic_sds_phy *this_phy, struct scic_sds_phy *sci_phy,
enum sci_sas_link_rate max_link_rate, enum sci_sas_link_rate max_link_rate,
u32 next_state) u32 next_state)
{ {
this_phy->max_negotiated_speed = max_link_rate; sci_phy->max_negotiated_speed = max_link_rate;
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), next_state next_state);
);
} }
/**
*
* @this_phy: The struct scic_sds_phy object to restart.
*
* This method restarts the struct scic_sds_phy objects base state machine in the
* starting state from any starting substate. none
*/
static void scic_sds_phy_restart_starting_state( static void scic_sds_phy_restart_starting_state(
struct scic_sds_phy *this_phy) struct scic_sds_phy *sci_phy)
{ {
/* Stop the current substate machine */ /* Stop the current substate machine */
sci_base_state_machine_stop( sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
scic_sds_phy_get_starting_substate_machine(this_phy)
);
/* Re-enter the base state machine starting state */ /* Re-enter the base state machine starting state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(this_phy), SCI_BASE_PHY_STATE_STARTING);
SCI_BASE_PHY_STATE_STARTING
);
} }
/* **************************************************************************** /* ****************************************************************************
...@@ -1041,7 +1025,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han ...@@ -1041,7 +1025,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han
} }
/** /**
* * scic_sds_phy_starting_substate_await_sata_phy_event_handler -
* @phy: This struct scic_sds_phy object which has received an event. * @phy: This struct scic_sds_phy object which has received an event.
* @event_code: This is the event code which the phy object is to decode. * @event_code: This is the event code which the phy object is to decode.
* *
...@@ -1054,42 +1038,39 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han ...@@ -1054,42 +1038,39 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han
* failure event SCI_FAILURE on any unexpected event notifation * failure event SCI_FAILURE on any unexpected event notifation
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler( static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler(
struct scic_sds_phy *this_phy, struct scic_sds_phy *sci_phy, u32 event_code)
u32 event_code)
{ {
u32 result = SCI_SUCCESS; u32 result = SCI_SUCCESS;
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
scic_sds_phy_restart_starting_state(this_phy); scic_sds_phy_restart_starting_state(sci_phy);
break; break;
case SCU_EVENT_SATA_SPINUP_HOLD: case SCU_EVENT_SATA_SPINUP_HOLD:
/* /* These events might be received since we dont know how many may be in
* These events might be received since we dont know how many may be in * the completion queue while waiting for power
* the completion queue while waiting for power */ */
break; break;
case SCU_EVENT_SATA_PHY_DETECTED: case SCU_EVENT_SATA_PHY_DETECTED:
this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
/* We have received the SATA PHY notification change state */ /* We have received the SATA PHY notification change state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN
);
break; break;
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
/* /* There has been a change in the phy type before OOB/SN for the
* There has been a change in the phy type before OOB/SN for the * SATA finished start down the SAS link traning path.
* SATA finished start down the SAS link traning path. */ */
scic_sds_phy_start_sas_link_training(this_phy); scic_sds_phy_start_sas_link_training(sci_phy);
break; break;
default: default:
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%s: PHY starting substate machine received " "%s: PHY starting substate machine received "
"unexpected event_code %x\n", "unexpected event_code %x\n",
__func__, __func__,
...@@ -1182,7 +1163,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han ...@@ -1182,7 +1163,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han
} }
/** /**
* * scic_sds_phy_starting_substate_await_sig_fis_event_handler -
* @phy: This struct scic_sds_phy object which has received an event. * @phy: This struct scic_sds_phy object which has received an event.
* @event_code: This is the event code which the phy object is to decode. * @event_code: This is the event code which the phy object is to decode.
* *
...@@ -1196,27 +1177,24 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han ...@@ -1196,27 +1177,24 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han
* unexpected event notifation * unexpected event notifation
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler( static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler(
struct scic_sds_phy *this_phy, struct scic_sds_phy *sci_phy, u32 event_code)
u32 event_code)
{ {
u32 result = SCI_SUCCESS; u32 result = SCI_SUCCESS;
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SATA_PHY_DETECTED: case SCU_EVENT_SATA_PHY_DETECTED:
/* Backup the state machine */ /* Backup the state machine */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN
);
break; break;
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
scic_sds_phy_restart_starting_state(this_phy); scic_sds_phy_restart_starting_state(sci_phy);
break; break;
default: default:
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%s: PHY starting substate machine received " "%s: PHY starting substate machine received "
"unexpected event_code %x\n", "unexpected event_code %x\n",
__func__, __func__,
...@@ -1249,15 +1227,14 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handle ...@@ -1249,15 +1227,14 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handle
* unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler( static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler(
struct scic_sds_phy *this_phy, struct scic_sds_phy *sci_phy, u32 frame_index)
u32 frame_index)
{ {
enum sci_status result; enum sci_status result;
u32 *frame_words; u32 *frame_words;
struct sci_sas_identify_address_frame *identify_frame; struct sci_sas_identify_address_frame *identify_frame;
result = scic_sds_unsolicited_frame_control_get_header( result = scic_sds_unsolicited_frame_control_get_header(
&(scic_sds_phy_get_controller(this_phy)->uf_control), &(scic_sds_phy_get_controller(sci_phy)->uf_control),
frame_index, frame_index,
(void **)&frame_words); (void **)&frame_words);
...@@ -1269,49 +1246,43 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler ...@@ -1269,49 +1246,43 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler
identify_frame = (struct sci_sas_identify_address_frame *)frame_words; identify_frame = (struct sci_sas_identify_address_frame *)frame_words;
if (identify_frame->address_frame_type == 0) { if (identify_frame->address_frame_type == 0) {
/* u32 state;
* Byte swap the rest of the frame so we can make
* a copy of the buffer */ /* Byte swap the rest of the frame so we can make
* a copy of the buffer
*/
frame_words[1] = SCIC_SWAP_DWORD(frame_words[1]); frame_words[1] = SCIC_SWAP_DWORD(frame_words[1]);
frame_words[2] = SCIC_SWAP_DWORD(frame_words[2]); frame_words[2] = SCIC_SWAP_DWORD(frame_words[2]);
frame_words[3] = SCIC_SWAP_DWORD(frame_words[3]); frame_words[3] = SCIC_SWAP_DWORD(frame_words[3]);
frame_words[4] = SCIC_SWAP_DWORD(frame_words[4]); frame_words[4] = SCIC_SWAP_DWORD(frame_words[4]);
frame_words[5] = SCIC_SWAP_DWORD(frame_words[5]); frame_words[5] = SCIC_SWAP_DWORD(frame_words[5]);
memcpy( memcpy(&sci_phy->phy_type.sas.identify_address_frame_buffer,
&this_phy->phy_type.sas.identify_address_frame_buffer,
identify_frame, identify_frame,
sizeof(struct sci_sas_identify_address_frame) sizeof(struct sci_sas_identify_address_frame));
);
if (identify_frame->protocols.u.bits.smp_target) { if (identify_frame->protocols.u.bits.smp_target) {
/* /* We got the IAF for an expander PHY go to the final state since
* We got the IAF for an expander PHY go to the final state since * there are no power requirements for expander phys.
* there are no power requirements for expander phys. */ */
sci_base_state_machine_change_state( state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL;
scic_sds_phy_get_starting_substate_machine(this_phy),
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
);
} else { } else {
/* We got the IAF we can now go to the await spinup semaphore state */ /* We got the IAF we can now go to the await spinup semaphore state */
sci_base_state_machine_change_state( state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER;
scic_sds_phy_get_starting_substate_machine(this_phy),
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
);
} }
sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
state);
result = SCI_SUCCESS; result = SCI_SUCCESS;
} else } else
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%s: PHY starting substate machine received " "%s: PHY starting substate machine received "
"unexpected frame id %x\n", "unexpected frame id %x\n",
__func__, __func__,
frame_index); frame_index);
/* Regardless of the result release this frame since we are done with it */ /* Regardless of the result release this frame since we are done with it */
scic_sds_controller_release_frame( scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
scic_sds_phy_get_controller(this_phy), frame_index frame_index);
);
return result; return result;
} }
...@@ -1331,7 +1302,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler ...@@ -1331,7 +1302,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler
* data * data
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler( static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler(
struct scic_sds_phy *this_phy, struct scic_sds_phy *sci_phy,
u32 frame_index) u32 frame_index)
{ {
enum sci_status result; enum sci_status result;
...@@ -1340,7 +1311,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle ...@@ -1340,7 +1311,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
u32 *fis_frame_data; u32 *fis_frame_data;
result = scic_sds_unsolicited_frame_control_get_header( result = scic_sds_unsolicited_frame_control_get_header(
&(scic_sds_phy_get_controller(this_phy)->uf_control), &(scic_sds_phy_get_controller(sci_phy)->uf_control),
frame_index, frame_index,
(void **)&frame_words); (void **)&frame_words);
...@@ -1350,40 +1321,33 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle ...@@ -1350,40 +1321,33 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
fis_frame_header = (struct sata_fis_header *)frame_words; fis_frame_header = (struct sata_fis_header *)frame_words;
if ( if ((fis_frame_header->fis_type == SATA_FIS_TYPE_REGD2H) &&
(fis_frame_header->fis_type == SATA_FIS_TYPE_REGD2H) !(fis_frame_header->status & ATA_STATUS_REG_BSY_BIT)) {
&& !(fis_frame_header->status & ATA_STATUS_REG_BSY_BIT)
) {
scic_sds_unsolicited_frame_control_get_buffer( scic_sds_unsolicited_frame_control_get_buffer(
&(scic_sds_phy_get_controller(this_phy)->uf_control), &(scic_sds_phy_get_controller(sci_phy)->uf_control),
frame_index, frame_index,
(void **)&fis_frame_data (void **)&fis_frame_data);
);
scic_sds_controller_copy_sata_response( scic_sds_controller_copy_sata_response(
&this_phy->phy_type.sata.signature_fis_buffer, &sci_phy->phy_type.sata.signature_fis_buffer,
frame_words, frame_words,
fis_frame_data fis_frame_data);
);
/* We got the IAF we can now go to the await spinup semaphore state */ /* We got the IAF we can now go to the await spinup semaphore state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
);
result = SCI_SUCCESS; result = SCI_SUCCESS;
} else } else
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%s: PHY starting substate machine received " "%s: PHY starting substate machine received "
"unexpected frame id %x\n", "unexpected frame id %x\n",
__func__, __func__,
frame_index); frame_index);
/* Regardless of the result release this frame since we are done with it */ /* Regardless of the result release this frame since we are done with it */
scic_sds_controller_release_frame( scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
scic_sds_phy_get_controller(this_phy), frame_index frame_index);
);
return result; return result;
} }
...@@ -1394,7 +1358,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle ...@@ -1394,7 +1358,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
* ***************************************************************************** */ * ***************************************************************************** */
/** /**
* * scic_sds_phy_starting_substate_await_sas_power_consume_power_handler -
* @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
* object. * object.
* *
...@@ -1404,19 +1368,17 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle ...@@ -1404,19 +1368,17 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
* SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler( static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler(
struct scic_sds_phy *this_phy) struct scic_sds_phy *sci_phy)
{ {
u32 enable_spinup; u32 enable_spinup;
enable_spinup = SCU_SAS_ENSPINUP_READ(this_phy); enable_spinup = SCU_SAS_ENSPINUP_READ(sci_phy);
enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
SCU_SAS_ENSPINUP_WRITE(this_phy, enable_spinup); SCU_SAS_ENSPINUP_WRITE(sci_phy, enable_spinup);
/* Change state to the final state this substate machine has run to completion */ /* Change state to the final state this substate machine has run to completion */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1431,27 +1393,25 @@ static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_po ...@@ -1431,27 +1393,25 @@ static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_po
* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler( static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler(
struct scic_sds_phy *this_phy) struct scic_sds_phy *sci_phy)
{ {
u32 scu_sas_pcfg_value; u32 scu_sas_pcfg_value;
/* Release the spinup hold state and reset the OOB state machine */ /* Release the spinup hold state and reset the OOB state machine */
scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy); scu_sas_pcfg_value = SCU_SAS_PCFG_READ(sci_phy);
scu_sas_pcfg_value &= scu_sas_pcfg_value &=
~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value); SCU_SAS_PCFG_WRITE(sci_phy, scu_sas_pcfg_value);
/* Now restart the OOB operation */ /* Now restart the OOB operation */
scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value); SCU_SAS_PCFG_WRITE(sci_phy, scu_sas_pcfg_value);
/* Change state to the final state this substate machine has run to completion */ /* Change state to the final state this substate machine has run to completion */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1566,7 +1526,7 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t ...@@ -1566,7 +1526,7 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t
* **************************************************************************** */ * **************************************************************************** */
/** /**
* * scic_sds_phy_starting_initial_substate_enter -
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object.
* *
* This method will perform the actions required by the struct scic_sds_phy on * This method will perform the actions required by the struct scic_sds_phy on
...@@ -1574,21 +1534,18 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t ...@@ -1574,21 +1534,18 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t
* handlers are put in place for the struct scic_sds_phy object. - The state is * handlers are put in place for the struct scic_sds_phy object. - The state is
* changed to the wait phy type event notification. none * changed to the wait phy type event notification. none
*/ */
static void scic_sds_phy_starting_initial_substate_enter( static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_phy *this_phy; struct scic_sds_phy *sci_phy;
this_phy = (struct scic_sds_phy *)object; sci_phy = (struct scic_sds_phy *)object;
scic_sds_phy_set_starting_substate_handlers( scic_sds_phy_set_starting_substate_handlers(
this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
/* This is just an temporary state go off to the starting state */ /* This is just an temporary state go off to the starting state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
scic_sds_phy_get_starting_substate_machine(this_phy), SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
);
} }
/** /**
...@@ -1892,23 +1849,20 @@ static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit( ...@@ -1892,23 +1849,20 @@ static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
* object state handlers for this state. - Change base state machine to the * object state handlers for this state. - Change base state machine to the
* ready state. none * ready state. none
*/ */
static void scic_sds_phy_starting_final_substate_enter( static void scic_sds_phy_starting_final_substate_enter(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_phy *this_phy; struct scic_sds_phy *sci_phy;
this_phy = (struct scic_sds_phy *)object; sci_phy = container_of(object, typeof(*sci_phy), parent.parent);
scic_sds_phy_set_starting_substate_handlers( scic_sds_phy_set_starting_substate_handlers(sci_phy,
this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
);
/* /* State machine has run to completion so exit out and change
* State machine has run to completion so exit out and change * the base state machine to the ready state
* the base state machine to the ready state */ */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(this_phy), SCI_BASE_PHY_STATE_READY);
SCI_BASE_PHY_STATE_READY);
} }
/* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */
...@@ -2150,153 +2104,85 @@ enum sci_status scic_sds_phy_default_consume_power_handler( ...@@ -2150,153 +2104,85 @@ enum sci_status scic_sds_phy_default_consume_power_handler(
* attempts to start it. - The phy state machine is transitioned to the * attempts to start it. - The phy state machine is transitioned to the
* SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_phy_stopped_state_start_handler( static enum sci_status scic_sds_phy_stopped_state_start_handler(struct sci_base_phy *base_phy)
struct sci_base_phy *phy)
{ {
struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)phy; struct isci_host *ihost;
struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); struct scic_sds_phy *sci_phy;
struct isci_host *ihost = sci_object_get_association(scic); struct scic_sds_controller *scic;
sci_phy = container_of(base_phy, typeof(*sci_phy), parent);
scic = scic_sds_phy_get_controller(sci_phy),
ihost = sci_object_get_association(scic);
/* Create the SIGNATURE FIS Timeout timer for this phy */ /* Create the SIGNATURE FIS Timeout timer for this phy */
sci_phy->sata_timeout_timer = sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy,
isci_timer_create( scic_sds_phy_sata_timeout);
ihost,
sci_phy,
scic_sds_phy_sata_timeout);
if (sci_phy->sata_timeout_timer != NULL) { if (sci_phy->sata_timeout_timer)
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(sci_phy), SCI_BASE_PHY_STATE_STARTING);
SCI_BASE_PHY_STATE_STARTING);
}
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/** static enum sci_status scic_sds_phy_stopped_state_destroy_handler(struct sci_base_phy *base_phy)
*
* @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
* object.
*
* This method takes the struct scic_sds_phy from a stopped state and destroys it. -
* This function takes no action. Shouldnt this function transition the
* struct sci_base_phy::state_machine to the SCI_BASE_PHY_STATE_FINAL? enum sci_status
* SCI_SUCCESS
*/
static enum sci_status scic_sds_phy_stopped_state_destroy_handler(
struct sci_base_phy *phy)
{ {
struct scic_sds_phy *this_phy;
this_phy = (struct scic_sds_phy *)phy;
/* @todo what do we actually need to do here? */
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/* static enum sci_status scic_sds_phy_ready_state_stop_handler(struct sci_base_phy *base_phy)
* ******************************************************************************
* * PHY STARTING STATE HANDLERS
* ****************************************************************************** */
/* All of these state handlers are mapped to the starting sub-state machine */
/*
* ******************************************************************************
* * PHY READY STATE HANDLERS
* ****************************************************************************** */
/**
*
* @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
* object.
*
* This method takes the struct scic_sds_phy from a ready state and attempts to stop
* it. - The phy state machine is transitioned to the
* SCI_BASE_PHY_STATE_STOPPED. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_phy_ready_state_stop_handler(
struct sci_base_phy *phy)
{ {
struct scic_sds_phy *this_phy; sci_base_state_machine_change_state(&base_phy->state_machine,
SCI_BASE_PHY_STATE_STOPPED);
this_phy = (struct scic_sds_phy *)phy;
sci_base_state_machine_change_state(
scic_sds_phy_get_base_state_machine(this_phy),
SCI_BASE_PHY_STATE_STOPPED
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/** static enum sci_status scic_sds_phy_ready_state_reset_handler(struct sci_base_phy *base_phy)
*
* @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
* object.
*
* This method takes the struct scic_sds_phy from a ready state and attempts to reset
* it. - The phy state machine is transitioned to the
* SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_phy_ready_state_reset_handler(
struct sci_base_phy *phy)
{ {
struct scic_sds_phy *this_phy; sci_base_state_machine_change_state(&base_phy->state_machine,
SCI_BASE_PHY_STATE_RESETTING);
this_phy = (struct scic_sds_phy *)phy;
sci_base_state_machine_change_state(
scic_sds_phy_get_base_state_machine(this_phy),
SCI_BASE_PHY_STATE_RESETTING
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/** /**
* * scic_sds_phy_ready_state_event_handler -
* @phy: This is the struct scic_sds_phy object which has received the event. * @phy: This is the struct scic_sds_phy object which has received the event.
* *
* This method request the struct scic_sds_phy handle the received event. The only * This method request the struct scic_sds_phy handle the received event. The only
* event that we are interested in while in the ready state is the link failure * event that we are interested in while in the ready state is the link failure
* event. - decoded event is a link failure - transition the struct scic_sds_phy back * event. - decoded event is a link failure - transition the struct scic_sds_phy back
* to the SCI_BASE_PHY_STATE_STARTING state. - any other event recived will * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will
* report a warning message enum sci_status SCI_SUCCESS if the event received is a * report a warning message enum sci_status SCI_SUCCESS if the event received is a
* link failure SCI_FAILURE_INVALID_STATE for any other event received. * link failure SCI_FAILURE_INVALID_STATE for any other event received.
*/ */
static enum sci_status scic_sds_phy_ready_state_event_handler( static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy,
struct scic_sds_phy *this_phy, u32 event_code)
u32 event_code)
{ {
enum sci_status result = SCI_FAILURE; enum sci_status result = SCI_FAILURE;
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(this_phy), SCI_BASE_PHY_STATE_STARTING);
SCI_BASE_PHY_STATE_STARTING
);
result = SCI_SUCCESS; result = SCI_SUCCESS;
break; break;
case SCU_EVENT_BROADCAST_CHANGE: case SCU_EVENT_BROADCAST_CHANGE:
/* Broadcast change received. Notify the port. */ /* Broadcast change received. Notify the port. */
if (scic_sds_phy_get_port(this_phy) != NULL) if (scic_sds_phy_get_port(sci_phy) != NULL)
scic_sds_port_broadcast_change_received(this_phy->owning_port, this_phy); scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy);
else else
this_phy->bcn_received_while_port_unassigned = true; sci_phy->bcn_received_while_port_unassigned = true;
break; break;
default: default:
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%sP SCIC PHY 0x%p ready state machine received " "%sP SCIC PHY 0x%p ready state machine received "
"unexpected event_code %x\n", "unexpected event_code %x\n",
__func__, __func__, sci_phy, event_code);
this_phy,
event_code);
result = SCI_FAILURE_INVALID_STATE; result = SCI_FAILURE_INVALID_STATE;
break; break;
...@@ -2305,40 +2191,24 @@ static enum sci_status scic_sds_phy_ready_state_event_handler( ...@@ -2305,40 +2191,24 @@ static enum sci_status scic_sds_phy_ready_state_event_handler(
return result; return result;
} }
/* --------------------------------------------------------------------------- */ static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy,
u32 event_code)
/**
*
* @this_phy: This is the struct scic_sds_phy object which is receiving the event.
* @event_code: This is the event code to be processed.
*
* This is the resetting state event handler. enum sci_status
* SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_phy_resetting_state_event_handler(
struct scic_sds_phy *this_phy,
u32 event_code)
{ {
enum sci_status result = SCI_FAILURE; enum sci_status result = SCI_FAILURE;
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_HARD_RESET_TRANSMITTED: case SCU_EVENT_HARD_RESET_TRANSMITTED:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_phy->parent.state_machine,
scic_sds_phy_get_base_state_machine(this_phy), SCI_BASE_PHY_STATE_STARTING);
SCI_BASE_PHY_STATE_STARTING
);
result = SCI_SUCCESS; result = SCI_SUCCESS;
break; break;
default: default:
dev_warn(sciphy_to_dev(this_phy), dev_warn(sciphy_to_dev(sci_phy),
"%s: SCIC PHY 0x%p resetting state machine received " "%s: SCIC PHY 0x%p resetting state machine received "
"unexpected event_code %x\n", "unexpected event_code %x\n",
__func__, __func__, sci_phy, event_code);
this_phy,
event_code);
result = SCI_FAILURE_INVALID_STATE; result = SCI_FAILURE_INVALID_STATE;
break; break;
......
...@@ -316,24 +316,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha ...@@ -316,24 +316,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha
#define scic_sds_phy_get_controller(phy) \ #define scic_sds_phy_get_controller(phy) \
(scic_sds_port_get_controller((phy)->owning_port)) (scic_sds_port_get_controller((phy)->owning_port))
/**
* scic_sds_phy_get_base_state_machine() - This macro returns the state machine
* for the base phy
*
*
*/
#define scic_sds_phy_get_base_state_machine(phy) \
(&(phy)->parent.state_machine)
/**
* scic_sds_phy_get_starting_substate_machine() - This macro returns the
* starting substate machine for this phy
*
*
*/
#define scic_sds_phy_get_starting_substate_machine(phy) \
(&(phy)->starting_substate_machine)
/** /**
* scic_sds_phy_set_state_handlers() - This macro sets the state handlers for * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for
* this phy object * this phy object
...@@ -354,27 +336,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha ...@@ -354,27 +336,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha
&scic_sds_phy_state_handler_table[(state_id)] \ &scic_sds_phy_state_handler_table[(state_id)] \
) )
/**
* scic_sds_phy_is_ready() -
*
* This macro returns true if the current base state for this phy is
* SCI_BASE_PHY_STATE_READY
*/
#define scic_sds_phy_is_ready(phy) \
(\
SCI_BASE_PHY_STATE_READY \
== sci_base_state_machine_get_state(\
scic_sds_phy_get_base_state_machine(phy) \
) \
)
/* --------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------- */
void scic_sds_phy_construct( void scic_sds_phy_construct(
struct scic_sds_phy *this_phy, struct scic_sds_phy *this_phy,
struct scic_sds_port *owning_port, struct scic_sds_port *owning_port,
...@@ -404,8 +365,6 @@ enum sci_status scic_sds_phy_reset( ...@@ -404,8 +365,6 @@ enum sci_status scic_sds_phy_reset(
void scic_sds_phy_sata_timeout( void scic_sds_phy_sata_timeout(
void *cookie); void *cookie);
/* --------------------------------------------------------------------------- */
void scic_sds_phy_suspend( void scic_sds_phy_suspend(
struct scic_sds_phy *this_phy); struct scic_sds_phy *this_phy);
...@@ -416,8 +375,6 @@ void scic_sds_phy_setup_transport( ...@@ -416,8 +375,6 @@ void scic_sds_phy_setup_transport(
struct scic_sds_phy *this_phy, struct scic_sds_phy *this_phy,
u32 device_id); u32 device_id);
/* --------------------------------------------------------------------------- */
enum sci_status scic_sds_phy_event_handler( enum sci_status scic_sds_phy_event_handler(
struct scic_sds_phy *this_phy, struct scic_sds_phy *this_phy,
u32 event_code); u32 event_code);
...@@ -445,11 +402,6 @@ void scic_sds_phy_get_attached_phy_protocols( ...@@ -445,11 +402,6 @@ void scic_sds_phy_get_attached_phy_protocols(
struct scic_sds_phy *this_phy, struct scic_sds_phy *this_phy,
struct sci_sas_identify_address_frame_protocols *protocols); struct sci_sas_identify_address_frame_protocols *protocols);
/*
* ****************************************************************************-
* * SCIC SDS PHY Handler Methods
* ****************************************************************************- */
enum sci_status scic_sds_phy_default_start_handler( enum sci_status scic_sds_phy_default_start_handler(
struct sci_base_phy *phy); struct sci_base_phy *phy);
......
...@@ -576,12 +576,10 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index, ...@@ -576,12 +576,10 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table); sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table);
sci_base_state_machine_construct( sci_base_state_machine_construct(&sci_port->ready_substate_machine,
scic_sds_port_get_ready_substate_machine(sci_port), &sci_port->parent.parent,
&sci_port->parent.parent, scic_sds_port_ready_substate_table,
scic_sds_port_ready_substate_table, SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
SCIC_SDS_PORT_READY_SUBSTATE_WAITING
);
sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
sci_port->physical_port_index = port_index; sci_port->physical_port_index = port_index;
...@@ -1339,9 +1337,9 @@ static void scic_sds_port_ready_operational_substate_link_up_handler( ...@@ -1339,9 +1337,9 @@ static void scic_sds_port_ready_operational_substate_link_up_handler(
/** /**
* scic_sds_port_ready_operational_substate_link_down_handler() - * scic_sds_port_ready_operational_substate_link_down_handler() -
* @this_port: This is the struct scic_sds_port object that which has a phy that has * @sci_port: This is the struct scic_sds_port object that which has a phy that has
* gone link down. * gone link down.
* @the_phy: This is the struct scic_sds_phy object that has gone link down. * @sci_phy: This is the struct scic_sds_phy object that has gone link down.
* *
* This method is the ready operational substate link down handler for the * This method is the ready operational substate link down handler for the
* struct scic_sds_port object. This function notifies the SCI User that the phy has * struct scic_sds_port object. This function notifies the SCI User that the phy has
...@@ -1349,21 +1347,18 @@ static void scic_sds_port_ready_operational_substate_link_up_handler( ...@@ -1349,21 +1347,18 @@ static void scic_sds_port_ready_operational_substate_link_up_handler(
* state to the ready waiting substate. none * state to the ready waiting substate. none
*/ */
static void scic_sds_port_ready_operational_substate_link_down_handler( static void scic_sds_port_ready_operational_substate_link_down_handler(
struct scic_sds_port *this_port, struct scic_sds_port *sci_port,
struct scic_sds_phy *the_phy) struct scic_sds_phy *sci_phy)
{ {
scic_sds_port_deactivate_phy(this_port, the_phy, true); scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
/* /*
* If there are no active phys left in the port, then transition * If there are no active phys left in the port, then transition
* the port to the WAITING state until such time as a phy goes * the port to the WAITING state until such time as a phy goes
* link up. */ * link up. */
if (this_port->active_phy_mask == 0) { if (sci_port->active_phy_mask == 0)
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_port->ready_substate_machine,
scic_sds_port_get_ready_substate_machine(this_port), SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
SCIC_SDS_PORT_READY_SUBSTATE_WAITING
);
}
} }
/** /**
...@@ -1820,169 +1815,52 @@ const struct sci_base_state scic_sds_port_ready_substate_table[] = { ...@@ -1820,169 +1815,52 @@ const struct sci_base_state scic_sds_port_ready_substate_table[] = {
}, },
}; };
/* static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func)
* ***************************************************************************
* * DEFAULT HANDLERS
* *************************************************************************** */
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for port a start request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_start_handler(
struct sci_base_port *port)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; struct scic_sds_port *sci_port;
sci_port = container_of(base_port, typeof(*sci_port), parent);
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to start while in invalid " "%s: in wrong state: %d\n", func,
"state %d\n", sci_base_state_machine_get_state(&base_port->state_machine));
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port)
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port stop request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_stop_handler(
struct sci_base_port *port)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; return default_port_handler(base_port, __func__);
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to stop while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
} }
/** static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port)
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port destruct request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_destruct_handler(
struct sci_base_port *port)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; return default_port_handler(base_port, __func__);
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to destruct while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port)
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
* @timeout: This is the timeout for the reset request to complete.
*
* This is the default method for a port reset request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_reset_handler(
struct sci_base_port *port,
u32 timeout)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; return default_port_handler(base_port, __func__);
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to reset while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port,
* u32 timeout)
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port add phy request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_add_phy_handler(
struct sci_base_port *port,
struct sci_base_phy *phy)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; return default_port_handler(base_port, __func__);
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to add phy 0x%p while in "
"invalid state %d\n",
__func__,
port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
} }
/** static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port,
* struct sci_base_phy *base_phy)
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port remove phy request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_remove_phy_handler(
struct sci_base_port *port,
struct sci_base_phy *phy)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)port; return default_port_handler(base_port, __func__);
}
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to remove phy 0x%p while in "
"invalid state %d\n",
__func__,
port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE; enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port,
struct sci_base_phy *base_phy)
{
return default_port_handler(base_port, __func__);
} }
/** /**
* * scic_sds_port_default_frame_handler
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object. * object.
* *
...@@ -1991,149 +1869,48 @@ enum sci_status scic_sds_port_default_remove_phy_handler( ...@@ -1991,149 +1869,48 @@ enum sci_status scic_sds_port_default_remove_phy_handler(
* possible to receive an unsolicited frame directed to a port object? It * possible to receive an unsolicited frame directed to a port object? It
* seems possible if we implementing virtual functions but until then? * seems possible if we implementing virtual functions but until then?
*/ */
enum sci_status scic_sds_port_default_frame_handler( enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port,
struct scic_sds_port *port, u32 frame_index)
u32 frame_index) {
{ struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
dev_warn(sciport_to_dev(port),
"%s: SCIC Port 0x%p requested to process frame %d while in "
"invalid state %d\n",
__func__,
port,
frame_index,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(port)));
scic_sds_controller_release_frame(
scic_sds_port_get_controller(port), frame_index
);
return SCI_FAILURE_INVALID_STATE;
}
/** default_port_handler(&sci_port->parent, __func__);
* scic_sds_controller_release_frame(scic, frame_index);
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port event request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_event_handler(
struct scic_sds_port *port,
u32 event_code)
{
dev_warn(sciport_to_dev(port),
"%s: SCIC Port 0x%p requested to process event 0x%x while "
"in invalid state %d\n",
__func__,
port,
event_code,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port,
* u32 event_code)
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port link up notification. It will report
* a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
void scic_sds_port_default_link_up_handler(
struct scic_sds_port *this_port,
struct scic_sds_phy *phy)
{ {
dev_warn(sciport_to_dev(this_port), return default_port_handler(&sci_port->parent, __func__);
"%s: SCIC Port 0x%p received link_up notification from phy "
"0x%p while in invalid state %d\n",
__func__,
this_port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
} }
/** void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port,
* struct scic_sds_phy *sci_phy)
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port link down notification. It will
* report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
void scic_sds_port_default_link_down_handler(
struct scic_sds_port *this_port,
struct scic_sds_phy *phy)
{ {
dev_warn(sciport_to_dev(this_port), default_port_handler(&sci_port->parent, __func__);
"%s: SCIC Port 0x%p received link down notification from "
"phy 0x%p while in invalid state %d\n",
__func__,
this_port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
} }
/** void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port,
* struct scic_sds_phy *sci_phy)
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port start io request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_start_io_handler(
struct scic_sds_port *this_port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
{ {
dev_warn(sciport_to_dev(this_port), default_port_handler(&sci_port->parent, __func__);
"%s: SCIC Port 0x%p requested to start io request 0x%p "
"while in invalid state %d\n",
__func__,
this_port,
io_request,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port,
* struct scic_sds_remote_device *sci_dev,
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port struct scic_sds_request *sci_req)
* object.
*
* This is the default method for a port complete io request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_complete_io_handler(
struct scic_sds_port *this_port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
{ {
dev_warn(sciport_to_dev(this_port), return default_port_handler(&sci_port->parent, __func__);
"%s: SCIC Port 0x%p requested to complete io request 0x%p "
"while in invalid state %d\n",
__func__,
this_port,
io_request,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
return SCI_FAILURE_INVALID_STATE;
} }
/* static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port,
* **************************************************************************** struct scic_sds_remote_device *sci_dev,
* * GENERAL STATE HANDLERS struct scic_sds_request *sci_req)
* **************************************************************************** */ {
return default_port_handler(&sci_port->parent, __func__);
}
/** /**
* *
...@@ -2160,11 +1937,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler( ...@@ -2160,11 +1937,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler(
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/*
* ****************************************************************************
* * STOPPED STATE HANDLERS
* **************************************************************************** */
/** /**
* scic_sds_port_stopped_state_start_handler() - stop a port from "started" * scic_sds_port_stopped_state_start_handler() - stop a port from "started"
* *
...@@ -2242,9 +2014,8 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) ...@@ -2242,9 +2014,8 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port)
* silicon. * silicon.
*/ */
if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) {
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_port->state_machine,
scic_sds_port_get_base_state_machine(sci_port), SCI_BASE_PORT_STATE_READY);
SCI_BASE_PORT_STATE_READY);
return SCI_SUCCESS; return SCI_SUCCESS;
} else } else
...@@ -2390,19 +2161,15 @@ static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( ...@@ -2390,19 +2161,15 @@ static enum sci_status scic_sds_port_stopped_state_remove_phy_handler(
* object will transition to the stopped state. enum sci_status SCI_SUCCESS * object will transition to the stopped state. enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_port_stopping_state_complete_io_handler( static enum sci_status scic_sds_port_stopping_state_complete_io_handler(
struct scic_sds_port *port, struct scic_sds_port *sci_port,
struct scic_sds_remote_device *device, struct scic_sds_remote_device *device,
struct scic_sds_request *io_request) struct scic_sds_request *io_request)
{ {
struct scic_sds_port *this_port = (struct scic_sds_port *)port; scic_sds_port_decrement_request_count(sci_port);
scic_sds_port_decrement_request_count(this_port);
if (this_port->started_request_count == 0) { if (sci_port->started_request_count == 0) {
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_port->parent.state_machine,
scic_sds_port_get_base_state_machine(this_port), SCI_BASE_PORT_STATE_STOPPED);
SCI_BASE_PORT_STATE_STOPPED
);
} }
return SCI_SUCCESS; return SCI_SUCCESS;
...@@ -2727,9 +2494,8 @@ static void scic_sds_port_stopped_state_exit( ...@@ -2727,9 +2494,8 @@ static void scic_sds_port_stopped_state_exit(
} }
/** /**
* * scic_sds_port_ready_state_enter -
* @object: This is the struct sci_base_object which is cast to a * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
* struct scic_sds_port object.
* *
* This method will perform the actions required by the struct scic_sds_port on * This method will perform the actions required by the struct scic_sds_port on
* entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state
...@@ -2738,50 +2504,40 @@ static void scic_sds_port_stopped_state_exit( ...@@ -2738,50 +2504,40 @@ static void scic_sds_port_stopped_state_exit(
*/ */
static void scic_sds_port_ready_state_enter(struct sci_base_object *object) static void scic_sds_port_ready_state_enter(struct sci_base_object *object)
{ {
struct scic_sds_port *sci_port = (struct scic_sds_port *)object; struct scic_sds_controller *scic;
struct isci_port *iport = sci_object_get_association(sci_port); struct scic_sds_port *sci_port;
struct scic_sds_controller *scic = struct isci_port *iport;
scic_sds_port_get_controller(sci_port); struct isci_host *ihost;
struct isci_host *ihost = sci_object_get_association(scic); u32 prev_state;
/* sci_port = container_of(object, typeof(*sci_port), parent.parent);
* Put the ready state handlers in place though they will not be scic = scic_sds_port_get_controller(sci_port);
* there long ihost = sci_object_get_association(scic);
*/ iport = sci_object_get_association(sci_port);
scic_sds_port_set_base_state_handlers(sci_port,
SCI_BASE_PORT_STATE_READY);
if (sci_port->parent.state_machine.previous_state_id == /* Put the ready state handlers in place though they will not be there long */
SCI_BASE_PORT_STATE_RESETTING) scic_sds_port_set_base_state_handlers(sci_port, SCI_BASE_PORT_STATE_READY);
prev_state = sci_port->parent.state_machine.previous_state_id;
if (prev_state == SCI_BASE_PORT_STATE_RESETTING)
isci_port_hard_reset_complete(iport, SCI_SUCCESS); isci_port_hard_reset_complete(iport, SCI_SUCCESS);
else /* Notify the caller that the port is not yet ready */ else
isci_port_not_ready(ihost, iport); isci_port_not_ready(ihost, iport);
/* Post and suspend the dummy remote node context for this port. */ /* Post and suspend the dummy remote node context for this port. */
scic_sds_port_post_dummy_remote_node(sci_port); scic_sds_port_post_dummy_remote_node(sci_port);
/* Start the ready substate machine */ /* Start the ready substate machine */
sci_base_state_machine_start( sci_base_state_machine_start(&sci_port->ready_substate_machine);
scic_sds_port_get_ready_substate_machine(sci_port));
} }
/** static void scic_sds_port_ready_state_exit(struct sci_base_object *object)
*
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
*
* This method will perform the actions required by the struct scic_sds_port on
* exiting the SCI_BASE_STATE_READY. This function does nothing. none
*/
static void scic_sds_port_ready_state_exit(
struct sci_base_object *object)
{ {
struct scic_sds_port *this_port; struct scic_sds_port *sci_port;
this_port = (struct scic_sds_port *)object;
sci_base_state_machine_stop(&this_port->ready_substate_machine);
scic_sds_port_invalidate_dummy_remote_node(this_port); sci_port = container_of(object, typeof(*sci_port), parent.parent);
sci_base_state_machine_stop(&sci_port->ready_substate_machine);
scic_sds_port_invalidate_dummy_remote_node(sci_port);
} }
/** /**
......
...@@ -250,14 +250,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t ...@@ -250,14 +250,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t
#define scic_sds_port_get_controller(this_port) \ #define scic_sds_port_get_controller(this_port) \
((this_port)->owning_controller) ((this_port)->owning_controller)
/**
* scic_sds_port_get_base_state_machine() -
*
* Helper macro to get the base state machine for this port
*/
#define scic_sds_port_get_base_state_machine(this_port) \
(&(this_port)->parent.state_machine)
/** /**
* scic_sds_port_set_base_state_handlers() - * scic_sds_port_set_base_state_handlers() -
* *
...@@ -267,14 +259,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t ...@@ -267,14 +259,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t
scic_sds_port_set_state_handlers(\ scic_sds_port_set_state_handlers(\
(this_port), &scic_sds_port_state_handler_table[(state_id)]) (this_port), &scic_sds_port_state_handler_table[(state_id)])
/**
* scic_sds_port_get_ready_substate_machine() -
*
* Helper macro to get the ready substate machine for this port
*/
#define scic_sds_port_get_ready_substate_machine(this_port) \
(&(this_port)->ready_substate_machine)
/** /**
* scic_sds_port_set_state_handlers() - * scic_sds_port_set_state_handlers() -
* *
......
...@@ -135,8 +135,7 @@ enum sci_status scic_remote_device_da_construct( ...@@ -135,8 +135,7 @@ enum sci_status scic_remote_device_da_construct(
&remote_node_index); &remote_node_index);
if (status == SCI_SUCCESS) { if (status == SCI_SUCCESS) {
scic_sds_remote_node_context_set_remote_node_index( sci_dev->rnc->remote_node_index = remote_node_index;
sci_dev->rnc, remote_node_index);
scic_sds_port_get_attached_sas_address( scic_sds_port_get_attached_sas_address(
sci_dev->owning_port, &sci_dev->device_address); sci_dev->owning_port, &sci_dev->device_address);
...@@ -510,16 +509,14 @@ bool scic_sds_remote_device_is_atapi( ...@@ -510,16 +509,14 @@ bool scic_sds_remote_device_is_atapi(
static void scic_sds_cb_remote_device_rnc_destruct_complete( static void scic_sds_cb_remote_device_rnc_destruct_complete(
void *user_parameter) void *user_parameter)
{ {
struct scic_sds_remote_device *this_device; struct scic_sds_remote_device *sci_dev;
this_device = (struct scic_sds_remote_device *)user_parameter; sci_dev = (struct scic_sds_remote_device *)user_parameter;
BUG_ON(this_device->started_request_count != 0); BUG_ON(sci_dev->started_request_count != 0);
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_dev->parent.state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
);
} }
/** /**
...@@ -649,206 +646,64 @@ static enum sci_status scic_sds_remote_device_terminate_requests( ...@@ -649,206 +646,64 @@ static enum sci_status scic_sds_remote_device_terminate_requests(
return status; return status;
} }
/* static enum sci_status default_device_handler(struct sci_base_remote_device *base_dev,
* ***************************************************************************** const char *func)
* * DEFAULT STATE HANDLERS
* ***************************************************************************** */
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default start handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_start_handler(
struct sci_base_remote_device *device)
{ {
struct scic_sds_remote_device *sds_device = struct scic_sds_remote_device *sci_dev;
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to start while in wrong "
"state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
dev_warn(scirdev_to_dev(sci_dev),
"%s: in wrong state: %d\n", func,
sci_base_state_machine_get_state(&base_dev->state_machine));
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
/** enum sci_status scic_sds_remote_device_default_start_handler(
* struct sci_base_remote_device *base_dev)
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default stop handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_remote_device_default_stop_handler(
struct sci_base_remote_device *device)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device; }
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to stop while in wrong "
"state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE; static enum sci_status scic_sds_remote_device_default_stop_handler(
struct sci_base_remote_device *base_dev)
{
return default_device_handler(base_dev, __func__);
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default fail handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_fail_handler( enum sci_status scic_sds_remote_device_default_fail_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to fail while in wrong "
"state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default destruct handler. It logs a warning and returns
* a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_destruct_handler( enum sci_status scic_sds_remote_device_default_destruct_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to destroy while in "
"wrong state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default reset handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_reset_handler( enum sci_status scic_sds_remote_device_default_reset_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to reset while in wrong "
"state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default reset complete handler. It logs a warning and
* returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_reset_complete_handler( enum sci_status scic_sds_remote_device_default_reset_complete_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to complete reset while "
"in wrong state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default suspend handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_suspend_handler( enum sci_status scic_sds_remote_device_default_suspend_handler(
struct scic_sds_remote_device *this_device, struct scic_sds_remote_device *sci_dev, u32 suspend_type)
u32 suspend_type)
{ {
dev_warn(scirdev_to_dev(this_device), return default_device_handler(&sci_dev->parent, __func__);
"%s: SCIC Remote Device 0x%p requested to suspend %d while "
"in wrong state %d\n",
__func__,
this_device,
suspend_type,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
this_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
*
* This method is the default resume handler. It logs a warning and returns a
* failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_resume_handler( enum sci_status scic_sds_remote_device_default_resume_handler(
struct scic_sds_remote_device *this_device) struct scic_sds_remote_device *sci_dev)
{ {
dev_warn(scirdev_to_dev(this_device), return default_device_handler(&sci_dev->parent, __func__);
"%s: SCIC Remote Device requested to resume while in "
"wrong state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
this_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/** /**
...@@ -960,109 +815,27 @@ enum sci_status scic_sds_remote_device_default_frame_handler( ...@@ -960,109 +815,27 @@ enum sci_status scic_sds_remote_device_default_frame_handler(
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
* @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST
* to start.
*
* This method is the default start io handler. It logs a warning and returns
* a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_start_request_handler( enum sci_status scic_sds_remote_device_default_start_request_handler(
struct sci_base_remote_device *device, struct sci_base_remote_device *base_dev,
struct sci_base_request *request) struct sci_base_request *request)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to start io request %p "
"while in wrong state %d\n",
__func__,
request,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
(struct scic_sds_remote_device *)device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
* @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST
* to complete.
*
* This method is the default complete io handler. It logs a warning and
* returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_complete_request_handler( enum sci_status scic_sds_remote_device_default_complete_request_handler(
struct sci_base_remote_device *device, struct sci_base_remote_device *base_dev,
struct sci_base_request *request) struct sci_base_request *request)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to complete io_request %p "
"while in wrong state %d\n",
__func__,
request,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
* @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST
* to continue.
*
* This method is the default continue io handler. It logs a warning and
* returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_remote_device_default_continue_request_handler( enum sci_status scic_sds_remote_device_default_continue_request_handler(
struct sci_base_remote_device *device, struct sci_base_remote_device *base_dev,
struct sci_base_request *request) struct sci_base_request *request)
{ {
struct scic_sds_remote_device *sds_device = return default_device_handler(base_dev, __func__);
(struct scic_sds_remote_device *)device;
dev_warn(scirdev_to_dev(sds_device),
"%s: SCIC Remote Device requested to continue io request %p "
"while in wrong state %d\n",
__func__,
request,
sci_base_state_machine_get_state(
scic_sds_remote_device_get_base_state_machine(
sds_device)));
return SCI_FAILURE_INVALID_STATE;
} }
/**
*
* @device: The struct sci_base_remote_device which is then cast into a
* struct scic_sds_remote_device.
* @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST
* to complete.
*
* This method is the default complete task handler. It logs a warning and
* returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE
*/
/*
* *****************************************************************************
* * NORMAL STATE HANDLERS
* ***************************************************************************** */
/** /**
* *
* @device: The struct sci_base_remote_device which is then cast into a * @device: The struct sci_base_remote_device which is then cast into a
...@@ -1146,45 +919,32 @@ enum sci_status scic_sds_remote_device_general_event_handler( ...@@ -1146,45 +919,32 @@ enum sci_status scic_sds_remote_device_general_event_handler(
* which to construct the remote device. * which to construct the remote device.
*/ */
static enum sci_status scic_sds_remote_device_stopped_state_start_handler( static enum sci_status scic_sds_remote_device_stopped_state_start_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
enum sci_status status; enum sci_status status;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; struct scic_sds_remote_device *sci_dev;
status = scic_sds_remote_node_context_resume( sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
this_device->rnc,
scic_sds_remote_device_resume_complete_handler,
this_device
);
if (status == SCI_SUCCESS) { status = scic_sds_remote_node_context_resume(sci_dev->rnc,
sci_base_state_machine_change_state( scic_sds_remote_device_resume_complete_handler, sci_dev);
scic_sds_remote_device_get_base_state_machine(this_device),
SCI_BASE_REMOTE_DEVICE_STATE_STARTING if (status == SCI_SUCCESS)
); sci_base_state_machine_change_state(&base_dev->state_machine,
} SCI_BASE_REMOTE_DEVICE_STATE_STARTING);
return status; return status;
} }
/**
*
* @this_device: The struct sci_base_remote_device which is cast into a
* struct scic_sds_remote_device.
*
* This method will stop a struct scic_sds_remote_device that is already in a stopped
* state. This is not considered an error since the device is already stopped.
* enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( static enum sci_status scic_sds_remote_device_stopped_state_stop_handler(
struct sci_base_remote_device *this_device) struct sci_base_remote_device *base_dev)
{ {
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/** /**
* *
* @this_device: The struct sci_base_remote_device which is cast into a * @sci_dev: The struct sci_base_remote_device which is cast into a
* struct scic_sds_remote_device. * struct scic_sds_remote_device.
* *
* This method will destruct a struct scic_sds_remote_device that is in a stopped * This method will destruct a struct scic_sds_remote_device that is in a stopped
...@@ -1194,25 +954,19 @@ static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( ...@@ -1194,25 +954,19 @@ static enum sci_status scic_sds_remote_device_stopped_state_stop_handler(
* enum sci_status SCI_SUCCESS * enum sci_status SCI_SUCCESS
*/ */
static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; struct scic_sds_remote_device *sci_dev;
struct scic_sds_controller *scic;
scic_sds_controller_free_remote_node_context(
scic_sds_remote_device_get_controller(this_device),
this_device,
this_device->rnc->remote_node_index
);
scic_sds_remote_node_context_set_remote_node_index( sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
this_device->rnc, scic = scic_sds_remote_device_get_controller(sci_dev);
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX scic_sds_controller_free_remote_node_context(scic, sci_dev,
); sci_dev->rnc->remote_node_index);
sci_dev->rnc->remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_dev->state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_FINAL);
SCI_BASE_REMOTE_DEVICE_STATE_FINAL
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1223,86 +977,49 @@ static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( ...@@ -1223,86 +977,49 @@ static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler(
* ***************************************************************************** */ * ***************************************************************************** */
static enum sci_status scic_sds_remote_device_starting_state_stop_handler( static enum sci_status scic_sds_remote_device_starting_state_stop_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; struct scic_sds_remote_device *sci_dev;
sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
/* /*
* This device has not yet started so there had better be no IO requests * This device has not yet started so there had better be no IO requests
*/ */
BUG_ON(this_device->started_request_count != 0); BUG_ON(sci_dev->started_request_count != 0);
/* /*
* Destroy the remote node context * Destroy the remote node context
*/ */
scic_sds_remote_node_context_destruct( scic_sds_remote_node_context_destruct(sci_dev->rnc,
this_device->rnc, scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev);
scic_sds_cb_remote_device_rnc_destruct_complete,
this_device
);
/* /*
* Transition to the stopping state and wait for the remote node to * Transition to the stopping state and wait for the remote node to
* complete being posted and invalidated. * complete being posted and invalidated.
*/ */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_dev->state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_STOPPING);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/*
* *****************************************************************************
* * INITIALIZING STATE HANDLERS
* ***************************************************************************** */
/* There is nothing to do here for SSP devices */
/*
* *****************************************************************************
* * READY STATE HANDLERS
* ***************************************************************************** */
/**
*
* @this_device: The struct scic_sds_remote_device object to be suspended.
*
* This method is the resume handler for the struct scic_sds_remote_device object. It
* will post an RNC resume to the SCU hardware. enum sci_status SCI_SUCCESS
*/
/**
*
* @device: The struct sci_base_remote_device object which is cast to a
* struct scic_sds_remote_device object.
*
* This method is the default stop handler for the struct scic_sds_remote_device ready
* substate machine. It will stop the current substate machine and transition
* the base state machine to SCI_BASE_REMOTE_DEVICE_STATE_STOPPING. enum sci_status
* SCI_SUCCESS
*/
enum sci_status scic_sds_remote_device_ready_state_stop_handler( enum sci_status scic_sds_remote_device_ready_state_stop_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; struct scic_sds_remote_device *sci_dev;
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
/* Request the parent state machine to transition to the stopping state */ /* Request the parent state machine to transition to the stopping state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_dev->state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_STOPPING);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
);
if (this_device->started_request_count == 0) { if (sci_dev->started_request_count == 0) {
scic_sds_remote_node_context_destruct( scic_sds_remote_node_context_destruct(sci_dev->rnc,
this_device->rnc,
scic_sds_cb_remote_device_rnc_destruct_complete, scic_sds_cb_remote_device_rnc_destruct_complete,
this_device sci_dev);
);
} else } else
status = scic_sds_remote_device_terminate_requests(this_device); status = scic_sds_remote_device_terminate_requests(sci_dev);
return status; return status;
} }
...@@ -1315,30 +1032,18 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler( ...@@ -1315,30 +1032,18 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler(
* This is the ready state device reset handler enum sci_status * This is the ready state device reset handler enum sci_status
*/ */
enum sci_status scic_sds_remote_device_ready_state_reset_handler( enum sci_status scic_sds_remote_device_ready_state_reset_handler(
struct sci_base_remote_device *device) struct sci_base_remote_device *base_dev)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; struct scic_sds_remote_device *sci_dev;
sci_dev = container_of(base_dev, typeof(*sci_dev), parent);
/* Request the parent state machine to transition to the stopping state */ /* Request the parent state machine to transition to the stopping state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&base_dev->state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_RESETTING);
SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
/**
*
* @device: The struct sci_base_remote_device object which is cast to a
* struct scic_sds_remote_device object.
*
* This is the default fail handler for the struct scic_sds_remote_device ready
* substate machine. It will stop the current ready substate and transition
* the remote device object to the SCI_BASE_REMOTE_DEVICE_STATE_FAILED.
* enum sci_status SCI_SUCCESS
*/
/** /**
* *
* @device: The struct sci_base_remote_device which is cast to a * @device: The struct sci_base_remote_device which is cast to a
...@@ -1775,19 +1480,15 @@ const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_h ...@@ -1775,19 +1480,15 @@ const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_h
static void scic_sds_remote_device_initial_state_enter( static void scic_sds_remote_device_initial_state_enter(
struct sci_base_object *object) struct sci_base_object *object)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object;
SET_STATE_HANDLER( sci_dev = container_of(object, typeof(*sci_dev), parent.parent);
this_device, SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table,
scic_sds_remote_device_state_handler_table, SCI_BASE_REMOTE_DEVICE_STATE_INITIAL);
SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
);
/* Initial state is a transitional state to the stopped state */ /* Initial state is a transitional state to the stopped state */
sci_base_state_machine_change_state( sci_base_state_machine_change_state(&sci_dev->parent.state_machine,
scic_sds_remote_device_get_base_state_machine(this_device), SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
);
} }
/** /**
...@@ -1803,29 +1504,28 @@ static void scic_sds_remote_device_initial_state_enter( ...@@ -1803,29 +1504,28 @@ static void scic_sds_remote_device_initial_state_enter(
static void scic_sds_remote_device_stopped_state_enter( static void scic_sds_remote_device_stopped_state_enter(
struct sci_base_object *object) struct sci_base_object *object)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev;
(struct scic_sds_remote_device *)object; struct scic_sds_controller *scic;
struct scic_sds_controller *scic = struct isci_remote_device *idev;
scic_sds_remote_device_get_controller(sci_dev); struct isci_host *ihost;
struct isci_host *ihost = sci_object_get_association(scic); u32 prev_state;
struct isci_remote_device *idev =
sci_object_get_association(sci_dev);
SET_STATE_HANDLER(sci_dev, sci_dev = container_of(object, typeof(*sci_dev), parent.parent);
scic_sds_remote_device_state_handler_table, scic = scic_sds_remote_device_get_controller(sci_dev);
ihost = sci_object_get_association(scic);
idev = sci_object_get_association(sci_dev);
SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table,
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
/* /* If we are entering from the stopping state let the SCI User know that
* If we are entering from the stopping state let the SCI User know that
* the stop operation has completed. * the stop operation has completed.
*/ */
if (sci_dev->parent.state_machine.previous_state_id == prev_state = sci_dev->parent.state_machine.previous_state_id;
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING)
isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS); isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS);
scic_sds_controller_remote_device_stopped( scic_sds_controller_remote_device_stopped(scic, sci_dev);
scic_sds_remote_device_get_controller(sci_dev),
sci_dev);
} }
/** /**
......
...@@ -376,22 +376,6 @@ extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev ...@@ -376,22 +376,6 @@ extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev
#define scic_sds_remote_device_set_state_handlers(this_device, handlers) \ #define scic_sds_remote_device_set_state_handlers(this_device, handlers) \
((this_device)->state_handlers = (handlers)) ((this_device)->state_handlers = (handlers))
/**
* scic_sds_remote_device_get_base_state_machine() -
*
* This macro returns the base sate machine object for the remote device.
*/
#define scic_sds_remote_device_get_base_state_machine(this_device) \
(&(this_device)->parent.state_machine)
/**
* scic_sds_remote_device_get_ready_substate_machine() -
*
* This macro returns the remote device ready substate machine
*/
#define scic_sds_remote_device_get_ready_substate_machine(this_device) \
(&(this_device)->ready_substate_machine)
/** /**
* scic_sds_remote_device_get_port() - * scic_sds_remote_device_get_port() -
* *
......
...@@ -296,9 +296,6 @@ void scic_sds_remote_node_context_construct_buffer( ...@@ -296,9 +296,6 @@ void scic_sds_remote_node_context_construct_buffer(
bool scic_sds_remote_node_context_is_ready( bool scic_sds_remote_node_context_is_ready(
struct scic_sds_remote_node_context *this_rnc); struct scic_sds_remote_node_context *this_rnc);
#define scic_sds_remote_node_context_set_remote_node_index(rnc, rni) \
((rnc)->remote_node_index = (rni))
#define scic_sds_remote_node_context_get_remote_node_index(rcn) \ #define scic_sds_remote_node_context_get_remote_node_index(rcn) \
((rnc)->remote_node_index) ((rnc)->remote_node_index)
......
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