提交 e301370a 编写于 作者: E Edmund Nadolski 提交者: Dan Williams

isci: state machine cleanup

This cleans up several areas of the state machine mechanism:

 o Rename sci_base_state_machine_change_state to sci_change_state
 o Remove sci_base_state_machine_get_state function
 o Rename 'state_machine' struct member to 'sm' in client structs
 o Shorten the name of request states
 o Shorten state machine state names as follows:
        SCI_BASE_CONTROLLER_STATE_xxx to SCIC_xxx
        SCI_BASE_PHY_STATE_xxx to SCI_PHY_xxx
        SCIC_SDS_PHY_STARTING_SUBSTATE_xxx to SCI_PHY_SUB_xxx
        SCI_BASE_PORT_STATE_xxx to SCI_PORT_xxx and
        SCIC_SDS_PORT_READY_SUBSTATE_xxx to SCI_PORT_SUB_xxx
        SCI_BASE_REMOTE_DEVICE_STATE_xxx to SCI_DEV_xxx
        SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_STP_DEV_xxx
        SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_SMP_DEV_xxx
        SCIC_SDS_REMOTE_NODE_CONTEXT_xxx_STATE to SCI_RNC_xxx
Signed-off-by: NEdmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: NDave Jiang <dave.jiang@intel.com>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
上级 8d2c65c0
......@@ -635,8 +635,7 @@ static void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
interrupt_status);
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_FAILED);
sci_change_state(&scic->sm, SCIC_FAILED);
return;
}
......@@ -895,14 +894,12 @@ static void scic_sds_controller_transition_to_ready(
{
struct isci_host *ihost = scic_to_ihost(scic);
if (scic->state_machine.current_state_id ==
SCI_BASE_CONTROLLER_STATE_STARTING) {
if (scic->sm.current_state_id == SCIC_STARTING) {
/*
* We move into the ready state, because some of the phys/ports
* may be up and operational.
*/
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_READY);
sci_change_state(&scic->sm, SCIC_READY);
isci_host_start_complete(ihost, status);
}
......@@ -912,18 +909,18 @@ static bool is_phy_starting(struct scic_sds_phy *sci_phy)
{
enum scic_sds_phy_states state;
state = sci_phy->state_machine.current_state_id;
state = sci_phy->sm.current_state_id;
switch (state) {
case SCI_BASE_PHY_STATE_STARTING:
case SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF:
case SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL:
case SCI_PHY_STARTING:
case SCI_PHY_SUB_INITIAL:
case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
case SCI_PHY_SUB_AWAIT_IAF_UF:
case SCI_PHY_SUB_AWAIT_SAS_POWER:
case SCI_PHY_SUB_AWAIT_SATA_POWER:
case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
case SCI_PHY_SUB_FINAL:
return true;
default:
return false;
......@@ -957,7 +954,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
for (index = 0; index < SCI_MAX_PHYS; index++) {
sci_phy = &ihost->phys[index].sci;
state = sci_phy->state_machine.current_state_id;
state = sci_phy->sm.current_state_id;
if (!phy_get_non_dummy_port(sci_phy))
continue;
......@@ -968,12 +965,9 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
* - have an indication of a connected device and it has
* finished the link training process.
*/
if ((sci_phy->is_in_link_training == false &&
state == SCI_BASE_PHY_STATE_INITIAL) ||
(sci_phy->is_in_link_training == false &&
state == SCI_BASE_PHY_STATE_STOPPED) ||
(sci_phy->is_in_link_training == true &&
is_phy_starting(sci_phy))) {
if ((sci_phy->is_in_link_training == false && state == SCI_PHY_INITIAL) ||
(sci_phy->is_in_link_training == false && state == SCI_PHY_STOPPED) ||
(sci_phy->is_in_link_training == true && is_phy_starting(sci_phy))) {
is_controller_start_complete = false;
break;
}
......@@ -1059,8 +1053,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
enum sci_status result;
u16 index;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
if (scic->sm.current_state_id != SCIC_INITIALIZED) {
dev_warn(scic_to_dev(scic),
"SCIC Controller start operation requested in "
"invalid state\n");
......@@ -1108,8 +1101,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
sci_mod_timer(&scic->timer, timeout);
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_STARTING);
sci_change_state(&scic->sm, SCIC_STARTING);
return SCI_SUCCESS;
}
......@@ -1279,8 +1271,7 @@ static void isci_host_completion_routine(unsigned long data)
static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
u32 timeout)
{
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_READY) {
if (scic->sm.current_state_id != SCIC_READY) {
dev_warn(scic_to_dev(scic),
"SCIC Controller stop operation requested in "
"invalid state\n");
......@@ -1288,8 +1279,7 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
}
sci_mod_timer(&scic->timer, timeout);
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_STOPPING);
sci_change_state(&scic->sm, SCIC_STOPPING);
return SCI_SUCCESS;
}
......@@ -1307,17 +1297,16 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
*/
static enum sci_status scic_controller_reset(struct scic_sds_controller *scic)
{
switch (scic->state_machine.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_RESET:
case SCI_BASE_CONTROLLER_STATE_READY:
case SCI_BASE_CONTROLLER_STATE_STOPPED:
case SCI_BASE_CONTROLLER_STATE_FAILED:
switch (scic->sm.current_state_id) {
case SCIC_RESET:
case SCIC_READY:
case SCIC_STOPPED:
case SCIC_FAILED:
/*
* The reset operation is not a graceful cleanup, just
* perform the state transition.
*/
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_RESETTING);
sci_change_state(&scic->sm, SCIC_RESETTING);
return SCI_SUCCESS;
default:
dev_warn(scic_to_dev(scic),
......@@ -1416,15 +1405,14 @@ static void isci_user_parameters_get(
static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_RESET);
sci_change_state(&scic->sm, SCIC_RESET);
}
static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_del_timer(&scic->timer);
}
......@@ -1551,7 +1539,7 @@ static enum sci_status scic_controller_set_interrupt_coalescence(
static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* set the default interrupt coalescence number and timeout value. */
scic_controller_set_interrupt_coalescence(scic, 0x10, 250);
......@@ -1559,7 +1547,7 @@ static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine
static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* disable interrupt coalescence. */
scic_controller_set_interrupt_coalescence(scic, 0, 0);
......@@ -1650,7 +1638,7 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll
static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* Stop all of the components for this controller */
scic_sds_controller_stop_phys(scic);
......@@ -1660,7 +1648,7 @@ static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machi
static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_del_timer(&scic->timer);
}
......@@ -1691,36 +1679,35 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic)
static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
scic_sds_controller_reset_hardware(scic);
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_RESET);
sci_change_state(&scic->sm, SCIC_RESET);
}
static const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_INITIAL] = {
[SCIC_INITIAL] = {
.enter_state = scic_sds_controller_initial_state_enter,
},
[SCI_BASE_CONTROLLER_STATE_RESET] = {},
[SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {},
[SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {},
[SCI_BASE_CONTROLLER_STATE_STARTING] = {
[SCIC_RESET] = {},
[SCIC_INITIALIZING] = {},
[SCIC_INITIALIZED] = {},
[SCIC_STARTING] = {
.exit_state = scic_sds_controller_starting_state_exit,
},
[SCI_BASE_CONTROLLER_STATE_READY] = {
[SCIC_READY] = {
.enter_state = scic_sds_controller_ready_state_enter,
.exit_state = scic_sds_controller_ready_state_exit,
},
[SCI_BASE_CONTROLLER_STATE_RESETTING] = {
[SCIC_RESETTING] = {
.enter_state = scic_sds_controller_resetting_state_enter,
},
[SCI_BASE_CONTROLLER_STATE_STOPPING] = {
[SCIC_STOPPING] = {
.enter_state = scic_sds_controller_stopping_state_enter,
.exit_state = scic_sds_controller_stopping_state_exit,
},
[SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
[SCI_BASE_CONTROLLER_STATE_FAILED] = {}
[SCIC_STOPPED] = {},
[SCIC_FAILED] = {}
};
static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic)
......@@ -1774,7 +1761,7 @@ static void controller_timeout(unsigned long data)
struct sci_timer *tmr = (struct sci_timer *)data;
struct scic_sds_controller *scic = container_of(tmr, typeof(*scic), timer);
struct isci_host *ihost = scic_to_ihost(scic);
struct sci_base_state_machine *sm = &scic->state_machine;
struct sci_base_state_machine *sm = &scic->sm;
unsigned long flags;
spin_lock_irqsave(&ihost->scic_lock, flags);
......@@ -1782,10 +1769,10 @@ static void controller_timeout(unsigned long data)
if (tmr->cancel)
goto done;
if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING)
if (sm->current_state_id == SCIC_STARTING)
scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) {
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED);
else if (sm->current_state_id == SCIC_STOPPING) {
sci_change_state(sm, SCIC_FAILED);
isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
} else /* / @todo Now what do we want to do in this case? */
dev_err(scic_to_dev(scic),
......@@ -1820,11 +1807,11 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
struct isci_host *ihost = scic_to_ihost(scic);
u8 i;
sci_base_state_machine_construct(&scic->state_machine,
sci_base_state_machine_construct(&scic->sm,
scic_sds_controller_state_table,
SCI_BASE_CONTROLLER_STATE_INITIAL);
SCIC_INITIAL);
sci_base_state_machine_start(&scic->state_machine);
sci_base_state_machine_start(&scic->sm);
scic->scu_registers = scu_base;
scic->smu_registers = smu_base;
......@@ -1899,11 +1886,11 @@ int scic_oem_parameters_validate(struct scic_sds_oem_params *oem)
static enum sci_status scic_oem_parameters_set(struct scic_sds_controller *scic,
union scic_oem_parameters *scic_parms)
{
u32 state = scic->state_machine.current_state_id;
u32 state = scic->sm.current_state_id;
if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
if (state == SCIC_RESET ||
state == SCIC_INITIALIZING ||
state == SCIC_INITIALIZED) {
if (scic_oem_parameters_validate(&scic_parms->sds1))
return SCI_FAILURE_INVALID_PARAMETER_VALUE;
......@@ -2168,10 +2155,8 @@ static enum sci_status scic_controller_set_mode(struct scic_sds_controller *scic
{
enum sci_status status = SCI_SUCCESS;
if ((scic->state_machine.current_state_id ==
SCI_BASE_CONTROLLER_STATE_INITIALIZING) ||
(scic->state_machine.current_state_id ==
SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
if ((scic->sm.current_state_id == SCIC_INITIALIZING) ||
(scic->sm.current_state_id == SCIC_INITIALIZED)) {
switch (operating_mode) {
case SCI_MODE_SPEED:
scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
......@@ -2216,20 +2201,19 @@ static void scic_sds_controller_initialize_power_control(struct scic_sds_control
static enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
{
struct sci_base_state_machine *sm = &scic->state_machine;
struct sci_base_state_machine *sm = &scic->sm;
enum sci_status result = SCI_SUCCESS;
struct isci_host *ihost = scic_to_ihost(scic);
u32 index, state;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_RESET) {
if (scic->sm.current_state_id != SCIC_RESET) {
dev_warn(scic_to_dev(scic),
"SCIC Controller initialize operation requested "
"in invalid state\n");
return SCI_FAILURE_INVALID_STATE;
}
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING);
sci_change_state(sm, SCIC_INITIALIZING);
sci_init_timer(&scic->phy_timer, phy_startup_timeout);
......@@ -2374,10 +2358,10 @@ static enum sci_status scic_controller_initialize(struct scic_sds_controller *sc
/* Advance the controller state machine */
if (result == SCI_SUCCESS)
state = SCI_BASE_CONTROLLER_STATE_INITIALIZED;
state = SCIC_INITIALIZED;
else
state = SCI_BASE_CONTROLLER_STATE_FAILED;
sci_base_state_machine_change_state(sm, state);
state = SCIC_FAILED;
sci_change_state(sm, state);
return result;
}
......@@ -2386,11 +2370,11 @@ static enum sci_status scic_user_parameters_set(
struct scic_sds_controller *scic,
union scic_user_parameters *scic_parms)
{
u32 state = scic->state_machine.current_state_id;
u32 state = scic->sm.current_state_id;
if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
if (state == SCIC_RESET ||
state == SCIC_INITIALIZING ||
state == SCIC_INITIALIZED) {
u16 index;
/*
......@@ -2612,15 +2596,15 @@ int isci_host_init(struct isci_host *isci_host)
void scic_sds_controller_link_up(struct scic_sds_controller *scic,
struct scic_sds_port *port, struct scic_sds_phy *phy)
{
switch (scic->state_machine.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STARTING:
switch (scic->sm.current_state_id) {
case SCIC_STARTING:
sci_del_timer(&scic->phy_timer);
scic->phy_startup_timer_pending = false;
scic->port_agent.link_up_handler(scic, &scic->port_agent,
port, phy);
scic_sds_controller_start_next_phy(scic);
break;
case SCI_BASE_CONTROLLER_STATE_READY:
case SCIC_READY:
scic->port_agent.link_up_handler(scic, &scic->port_agent,
port, phy);
break;
......@@ -2628,16 +2612,16 @@ void scic_sds_controller_link_up(struct scic_sds_controller *scic,
dev_dbg(scic_to_dev(scic),
"%s: SCIC Controller linkup event from phy %d in "
"unexpected state %d\n", __func__, phy->phy_index,
scic->state_machine.current_state_id);
scic->sm.current_state_id);
}
}
void scic_sds_controller_link_down(struct scic_sds_controller *scic,
struct scic_sds_port *port, struct scic_sds_phy *phy)
{
switch (scic->state_machine.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STARTING:
case SCI_BASE_CONTROLLER_STATE_READY:
switch (scic->sm.current_state_id) {
case SCIC_STARTING:
case SCIC_READY:
scic->port_agent.link_down_handler(scic, &scic->port_agent,
port, phy);
break;
......@@ -2647,7 +2631,7 @@ void scic_sds_controller_link_down(struct scic_sds_controller *scic,
"unexpected state %d\n",
__func__,
phy->phy_index,
scic->state_machine.current_state_id);
scic->sm.current_state_id);
}
}
......@@ -2663,8 +2647,7 @@ static bool scic_sds_controller_has_remote_devices_stopping(
for (index = 0; index < controller->remote_node_entries; index++) {
if ((controller->device_table[index] != NULL) &&
(controller->device_table[index]->state_machine.current_state_id
== SCI_BASE_REMOTE_DEVICE_STATE_STOPPING))
(controller->device_table[index]->sm.current_state_id == SCI_DEV_STOPPING))
return true;
}
......@@ -2678,19 +2661,17 @@ static bool scic_sds_controller_has_remote_devices_stopping(
void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev)
{
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_STOPPING) {
if (scic->sm.current_state_id != SCIC_STOPPING) {
dev_dbg(scic_to_dev(scic),
"SCIC Controller 0x%p remote device stopped event "
"from device 0x%p in unexpected state %d\n",
scic, sci_dev,
scic->state_machine.current_state_id);
scic->sm.current_state_id);
return;
}
if (!scic_sds_controller_has_remote_devices_stopping(scic)) {
sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_STOPPED);
sci_change_state(&scic->sm, SCIC_STOPPED);
}
}
......@@ -2948,8 +2929,7 @@ enum sci_status scic_controller_start_io(
{
enum sci_status status;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_READY) {
if (scic->sm.current_state_id != SCIC_READY) {
dev_warn(scic_to_dev(scic), "invalid state to start I/O");
return SCI_FAILURE_INVALID_STATE;
}
......@@ -2986,8 +2966,7 @@ enum sci_status scic_controller_terminate_request(
{
enum sci_status status;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_READY) {
if (scic->sm.current_state_id != SCIC_READY) {
dev_warn(scic_to_dev(scic),
"invalid state to terminate request\n");
return SCI_FAILURE_INVALID_STATE;
......@@ -3037,11 +3016,11 @@ enum sci_status scic_controller_complete_io(
enum sci_status status;
u16 index;
switch (scic->state_machine.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STOPPING:
switch (scic->sm.current_state_id) {
case SCIC_STOPPING:
/* XXX: Implement this function */
return SCI_FAILURE;
case SCI_BASE_CONTROLLER_STATE_READY:
case SCIC_READY:
status = scic_sds_remote_device_complete_io(scic, rdev, request);
if (status != SCI_SUCCESS)
return status;
......@@ -3060,8 +3039,7 @@ enum sci_status scic_controller_continue_io(struct scic_sds_request *sci_req)
{
struct scic_sds_controller *scic = sci_req->owning_controller;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_READY) {
if (scic->sm.current_state_id != SCIC_READY) {
dev_warn(scic_to_dev(scic), "invalid state to continue I/O");
return SCI_FAILURE_INVALID_STATE;
}
......@@ -3107,8 +3085,7 @@ enum sci_task_status scic_controller_start_task(
{
enum sci_status status;
if (scic->state_machine.current_state_id !=
SCI_BASE_CONTROLLER_STATE_READY) {
if (scic->sm.current_state_id != SCIC_READY) {
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller starting task from invalid "
"state\n",
......
......@@ -134,7 +134,7 @@ struct scic_sds_controller {
* This field contains the information for the base controller state
* machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
/**
* Timer for controller start/stop operations.
......@@ -359,7 +359,7 @@ enum scic_sds_controller_states {
/**
* Simply the initial state for the base controller state machine.
*/
SCI_BASE_CONTROLLER_STATE_INITIAL = 0,
SCIC_INITIAL = 0,
/**
* This state indicates that the controller is reset. The memory for
......@@ -368,7 +368,7 @@ enum scic_sds_controller_states {
* This state is entered from the INITIAL state.
* This state is entered from the RESETTING state.
*/
SCI_BASE_CONTROLLER_STATE_RESET,
SCIC_RESET,
/**
* This state is typically an action state that indicates the controller
......@@ -376,28 +376,28 @@ enum scic_sds_controller_states {
* are permitted.
* This state is entered from the RESET state.
*/
SCI_BASE_CONTROLLER_STATE_INITIALIZING,
SCIC_INITIALIZING,
/**
* This state indicates that the controller has been successfully
* initialized. In this state no new IO operations are permitted.
* This state is entered from the INITIALIZING state.
*/
SCI_BASE_CONTROLLER_STATE_INITIALIZED,
SCIC_INITIALIZED,
/**
* This state indicates the the controller is in the process of becoming
* ready (i.e. starting). In this state no new IO operations are permitted.
* This state is entered from the INITIALIZED state.
*/
SCI_BASE_CONTROLLER_STATE_STARTING,
SCIC_STARTING,
/**
* This state indicates the controller is now ready. Thus, the user
* is able to perform IO operations on the controller.
* This state is entered from the STARTING state.
*/
SCI_BASE_CONTROLLER_STATE_READY,
SCIC_READY,
/**
* This state is typically an action state that indicates the controller
......@@ -408,7 +408,7 @@ enum scic_sds_controller_states {
* This state is entered from the FAILED state.
* This state is entered from the STOPPED state.
*/
SCI_BASE_CONTROLLER_STATE_RESETTING,
SCIC_RESETTING,
/**
* This state indicates that the controller is in the process of stopping.
......@@ -416,14 +416,14 @@ enum scic_sds_controller_states {
* operations are allowed to complete.
* This state is entered from the READY state.
*/
SCI_BASE_CONTROLLER_STATE_STOPPING,
SCIC_STOPPING,
/**
* This state indicates that the controller has successfully been stopped.
* In this state no new IO operations are permitted.
* This state is entered from the STOPPING state.
*/
SCI_BASE_CONTROLLER_STATE_STOPPED,
SCIC_STOPPED,
/**
* This state indicates that the controller could not successfully be
......@@ -433,10 +433,7 @@ enum scic_sds_controller_states {
* This state is entered from the STOPPING state.
* This state is entered from the RESETTING state.
*/
SCI_BASE_CONTROLLER_STATE_FAILED,
SCI_BASE_CONTROLLER_MAX_STATES
SCIC_FAILED,
};
......
此差异已折叠。
......@@ -94,7 +94,7 @@ struct scic_sds_phy {
/**
* This field contains the information for the base phy state machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
/**
* This field specifies the port object that owns/contains this phy.
......@@ -410,7 +410,7 @@ enum scic_sds_phy_states {
/**
* Simply the initial state for the base domain state machine.
*/
SCI_BASE_PHY_STATE_INITIAL,
SCI_PHY_INITIAL,
/**
* This state indicates that the phy has successfully been stopped.
......@@ -420,7 +420,7 @@ enum scic_sds_phy_states {
* This state is entered from the READY state.
* This state is entered from the RESETTING state.
*/
SCI_BASE_PHY_STATE_STOPPED,
SCI_PHY_STOPPED,
/**
* This state indicates that the phy is in the process of becomming
......@@ -429,57 +429,57 @@ enum scic_sds_phy_states {
* This state is entered from the READY state.
* This state is entered from the RESETTING state.
*/
SCI_BASE_PHY_STATE_STARTING,
SCI_PHY_STARTING,
/**
* Initial state
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL,
SCI_PHY_SUB_INITIAL,
/**
* Wait state for the hardware OSSP event type notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN,
SCI_PHY_SUB_AWAIT_OSSP_EN,
/**
* Wait state for the PHY speed notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN,
SCI_PHY_SUB_AWAIT_SAS_SPEED_EN,
/**
* Wait state for the IAF Unsolicited frame notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF,
SCI_PHY_SUB_AWAIT_IAF_UF,
/**
* Wait state for the request to consume power
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER,
SCI_PHY_SUB_AWAIT_SAS_POWER,
/**
* Wait state for request to consume power
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
SCI_PHY_SUB_AWAIT_SATA_POWER,
/**
* Wait state for the SATA PHY notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
SCI_PHY_SUB_AWAIT_SATA_PHY_EN,
/**
* Wait for the SATA PHY speed notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
SCI_PHY_SUB_AWAIT_SATA_SPEED_EN,
/**
* Wait state for the SIGNATURE FIS unsolicited frame notification
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
SCI_PHY_SUB_AWAIT_SIG_FIS_UF,
/**
* Exit state for this state machine
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
SCI_PHY_SUB_FINAL,
/**
* This state indicates the the phy is now ready. Thus, the user
......@@ -487,19 +487,19 @@ enum scic_sds_phy_states {
* is currently part of a valid port.
* This state is entered from the STARTING state.
*/
SCI_BASE_PHY_STATE_READY,
SCI_PHY_READY,
/**
* This state indicates that the phy is in the process of being reset.
* In this state no new IO operations are permitted on this phy.
* This state is entered from the READY state.
*/
SCI_BASE_PHY_STATE_RESETTING,
SCI_PHY_RESETTING,
/**
* Simply the final state for the base phy state machine.
*/
SCI_BASE_PHY_STATE_FINAL,
SCI_PHY_FINAL,
};
/**
......
此差异已折叠。
......@@ -84,7 +84,7 @@ struct scic_sds_port {
/**
* This field contains the information for the base port state machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
bool ready_exit;
......@@ -224,7 +224,7 @@ enum scic_sds_port_states {
* In this state no new IO operations are permitted.
* This state is entered from the STOPPING state.
*/
SCI_BASE_PORT_STATE_STOPPED,
SCI_PORT_STOPPED,
/**
* This state indicates that the port is in the process of stopping.
......@@ -232,33 +232,33 @@ enum scic_sds_port_states {
* operations are allowed to complete.
* This state is entered from the READY state.
*/
SCI_BASE_PORT_STATE_STOPPING,
SCI_PORT_STOPPING,
/**
* This state indicates the port is now ready. Thus, the user is
* able to perform IO operations on this port.
* This state is entered from the STARTING state.
*/
SCI_BASE_PORT_STATE_READY,
SCI_PORT_READY,
/**
* The substate where the port is started and ready but has no
* active phys.
*/
SCIC_SDS_PORT_READY_SUBSTATE_WAITING,
SCI_PORT_SUB_WAITING,
/**
* The substate where the port is started and ready and there is
* at least one phy operational.
*/
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL,
SCI_PORT_SUB_OPERATIONAL,
/**
* The substate where the port is started and there was an
* add/remove phy event. This state is only used in Automatic
* Port Configuration Mode (APC)
*/
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING,
SCI_PORT_SUB_CONFIGURING,
/**
* This state indicates the port is in the process of performing a hard
......@@ -266,14 +266,14 @@ enum scic_sds_port_states {
* port.
* This state is entered from the READY state.
*/
SCI_BASE_PORT_STATE_RESETTING,
SCI_PORT_RESETTING,
/**
* This state indicates the port has failed a reset request. This state
* is entered when a port reset request times out.
* This state is entered from the RESETTING state.
*/
SCI_BASE_PORT_STATE_FAILED,
SCI_PORT_FAILED,
};
......
......@@ -661,13 +661,13 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true);
} else {
/* the phy is already the part of the port */
u32 port_state = sci_port->state_machine.current_state_id;
u32 port_state = sci_port->sm.current_state_id;
/* if the PORT'S state is resetting then the link up is from
* port hard reset in this case, we need to tell the port
* that link up is recieved
*/
BUG_ON(port_state != SCI_BASE_PORT_STATE_RESETTING);
BUG_ON(port_state != SCI_PORT_RESETTING);
port_agent->phy_ready_mask |= 1 << phy_index;
scic_sds_port_link_up(sci_port, sci_phy);
}
......
此差异已折叠。
......@@ -74,7 +74,7 @@ struct scic_sds_remote_device {
* This field contains the information for the base remote device state
* machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
/**
* This field is the programmed device port width. This value is
......@@ -109,7 +109,7 @@ struct scic_sds_remote_device {
/**
* This field contains the stated request count for the remote device. The
* device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all
* device can not reach the SCI_DEV_STOPPED until all
* requests are complete and the rnc_posted value is false.
*/
u32 started_request_count;
......@@ -213,7 +213,7 @@ enum scic_sds_remote_device_states {
/**
* Simply the initial state for the base remote device state machine.
*/
SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
SCI_DEV_INITIAL,
/**
* This state indicates that the remote device has successfully been
......@@ -221,7 +221,7 @@ enum scic_sds_remote_device_states {
* This state is entered from the INITIAL state.
* This state is entered from the STOPPING state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
SCI_DEV_STOPPED,
/**
* This state indicates the the remote device is in the process of
......@@ -229,34 +229,34 @@ enum scic_sds_remote_device_states {
* are permitted.
* This state is entered from the STOPPED state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
SCI_DEV_STARTING,
/**
* This state indicates the remote device is now ready. Thus, the user
* is able to perform IO operations on the remote device.
* This state is entered from the STARTING state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_READY,
SCI_DEV_READY,
/**
* This is the idle substate for the stp remote device. When there are no
* active IO for the device it is is in this state.
*/
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
SCI_STP_DEV_IDLE,
/**
* This is the command state for for the STP remote device. This state is
* entered when the device is processing a non-NCQ command. The device object
* will fail any new start IO requests until this command is complete.
*/
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
SCI_STP_DEV_CMD,
/**
* This is the NCQ state for the STP remote device. This state is entered
* when the device is processing an NCQ reuqest. It will remain in this state
* so long as there is one or more NCQ requests being processed.
*/
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ,
SCI_STP_DEV_NCQ,
/**
* This is the NCQ error state for the STP remote device. This state is
......@@ -264,25 +264,25 @@ enum scic_sds_remote_device_states {
* NCQ state. The device object will only accept a READ LOG command while in
* this state.
*/
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR,
SCI_STP_DEV_NCQ_ERROR,
/**
* This is the READY substate indicates the device is waiting for the RESET task
* coming to be recovered from certain hardware specific error.
*/
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET,
SCI_STP_DEV_AWAIT_RESET,
/**
* This is the ready operational substate for the remote device. This is the
* normal operational state for a remote device.
*/
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
SCI_SMP_DEV_IDLE,
/**
* This is the suspended state for the remote device. This is the state that
* the device is placed in when a RNC suspend is received by the SCU hardware.
*/
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
SCI_SMP_DEV_CMD,
/**
* This state indicates that the remote device is in the process of
......@@ -291,7 +291,7 @@ enum scic_sds_remote_device_states {
* This state is entered from the READY state.
* This state is entered from the FAILED state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
SCI_DEV_STOPPING,
/**
* This state indicates that the remote device has failed.
......@@ -299,19 +299,19 @@ enum scic_sds_remote_device_states {
* This state is entered from the INITIALIZING state.
* This state is entered from the READY state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
SCI_DEV_FAILED,
/**
* This state indicates the device is being reset.
* In this state no new IO operations are permitted.
* This state is entered from the READY state.
*/
SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
SCI_DEV_RESETTING,
/**
* Simply the final state for the base remote device state machine.
*/
SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
SCI_DEV_FINAL,
};
static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
......
......@@ -84,9 +84,9 @@
bool scic_sds_remote_node_context_is_ready(
struct scic_sds_remote_node_context *sci_rnc)
{
u32 current_state = sci_base_state_machine_get_state(&sci_rnc->state_machine);
u32 current_state = sci_rnc->sm.current_state_id;
if (current_state == SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) {
if (current_state == SCI_RNC_READY) {
return true;
}
......@@ -268,12 +268,12 @@ static void scic_sds_remote_node_context_invalidate_context_buffer(
static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
/* Check to see if we have gotten back to the initial state because
* someone requested to destroy the remote node context object.
*/
if (sm->previous_state_id == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE) {
if (sm->previous_state_id == SCI_RNC_INVALIDATING) {
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
scic_sds_remote_node_context_notify_user(rnc);
}
......@@ -281,21 +281,21 @@ static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_sta
static void scic_sds_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), state_machine);
struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), sm);
scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
}
static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_invalidate_context_buffer(rnc);
}
static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
struct scic_sds_remote_device *sci_dev;
struct domain_device *dev;
......@@ -318,7 +318,7 @@ static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_st
static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
......@@ -328,41 +328,41 @@ static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state
static void scic_sds_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_continue_state_transitions(rnc);
}
static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm)
{
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_continue_state_transitions(rnc);
}
static const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
[SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
[SCI_RNC_INITIAL] = {
.enter_state = scic_sds_remote_node_context_initial_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
[SCI_RNC_POSTING] = {
.enter_state = scic_sds_remote_node_context_posting_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
[SCI_RNC_INVALIDATING] = {
.enter_state = scic_sds_remote_node_context_invalidating_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
[SCI_RNC_RESUMING] = {
.enter_state = scic_sds_remote_node_context_resuming_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
[SCI_RNC_READY] = {
.enter_state = scic_sds_remote_node_context_ready_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
[SCI_RNC_TX_SUSPENDED] = {
.enter_state = scic_sds_remote_node_context_tx_suspended_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
[SCI_RNC_TX_RX_SUSPENDED] = {
.enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = { },
[SCI_RNC_AWAIT_SUSPENSION] = { },
};
void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
......@@ -373,11 +373,11 @@ void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context
rnc->remote_node_index = remote_node_index;
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
sci_base_state_machine_construct(&rnc->state_machine,
sci_base_state_machine_construct(&rnc->sm,
scic_sds_remote_node_context_state_table,
SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE);
SCI_RNC_INITIAL);
sci_base_state_machine_start(&rnc->state_machine);
sci_base_state_machine_start(&rnc->sm);
}
enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc,
......@@ -385,26 +385,24 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
state = sci_rnc->sm.current_state_id;
switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE:
case SCI_RNC_POSTING:
switch (scu_get_event_code(event_code)) {
case SCU_EVENT_POST_RNC_COMPLETE:
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_READY);
break;
default:
goto out;
}
break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE:
case SCI_RNC_INVALIDATING:
if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) {
if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL)
state = SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE;
state = SCI_RNC_INITIAL;
else
state = SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE;
sci_base_state_machine_change_state(&sci_rnc->state_machine,
state);
state = SCI_RNC_POSTING;
sci_change_state(&sci_rnc->sm, state);
} else {
switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
......@@ -421,10 +419,9 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
}
}
break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE:
case SCI_RNC_RESUMING:
if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) {
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_READY);
} else {
switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
......@@ -441,32 +438,28 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
}
}
break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE:
case SCI_RNC_READY:
switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TL_RNC_SUSPEND_TX:
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED);
sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break;
case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED);
sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break;
default:
goto out;
}
break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE:
case SCI_RNC_AWAIT_SUSPENSION:
switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TL_RNC_SUSPEND_TX:
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED);
sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break;
case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED);
sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break;
default:
......@@ -493,22 +486,21 @@ enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_nod
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
state = sci_rnc->sm.current_state_id;
switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE:
case SCI_RNC_INVALIDATING:
scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE:
case SCI_RNC_POSTING:
case SCI_RNC_RESUMING:
case SCI_RNC_READY:
case SCI_RNC_TX_SUSPENDED:
case SCI_RNC_TX_RX_SUSPENDED:
case SCI_RNC_AWAIT_SUSPENSION:
scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING);
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE:
case SCI_RNC_INITIAL:
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state);
/* We have decided that the destruct request on the remote node context
......@@ -530,8 +522,8 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
if (state != SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) {
state = sci_rnc->sm.current_state_id;
if (state != SCI_RNC_READY) {
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE;
......@@ -546,8 +538,7 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node
SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX);
}
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_AWAIT_SUSPENSION);
return SCI_SUCCESS;
}
......@@ -557,27 +548,26 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
state = sci_rnc->sm.current_state_id;
switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE:
case SCI_RNC_INITIAL:
if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
return SCI_FAILURE_INVALID_STATE;
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
scic_sds_remote_node_context_construct_buffer(sci_rnc);
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_POSTING);
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE:
case SCI_RNC_POSTING:
case SCI_RNC_INVALIDATING:
case SCI_RNC_RESUMING:
if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY)
return SCI_FAILURE_INVALID_STATE;
sci_rnc->user_callback = cb_fn;
sci_rnc->user_cookie = cb_p;
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE: {
case SCI_RNC_TX_SUSPENDED: {
struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
struct domain_device *dev = sci_dev_to_domain(sci_dev);
......@@ -585,27 +575,23 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
/* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */
if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
if (sci_dev->is_direct_attached) {
/* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
} else {
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING);
}
} else
return SCI_FAILURE;
return SCI_SUCCESS;
}
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE:
case SCI_RNC_TX_RX_SUSPENDED:
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
sci_base_state_machine_change_state(&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
return SCI_FAILURE_INVALID_STATE;
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE:
case SCI_RNC_AWAIT_SUSPENSION:
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
return SCI_SUCCESS;
default:
......@@ -620,8 +606,8 @@ enum sci_status scic_sds_remote_node_context_start_io(struct scic_sds_remote_nod
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
if (state != SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) {
state = sci_rnc->sm.current_state_id;
if (state != SCI_RNC_READY) {
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state);
return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
......@@ -634,14 +620,14 @@ enum sci_status scic_sds_remote_node_context_start_task(struct scic_sds_remote_n
{
enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id;
state = sci_rnc->sm.current_state_id;
switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE:
case SCI_RNC_RESUMING:
case SCI_RNC_READY:
case SCI_RNC_AWAIT_SUSPENSION:
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE:
case SCI_RNC_TX_SUSPENDED:
case SCI_RNC_TX_RX_SUSPENDED:
scic_sds_remote_node_context_resume(sci_rnc, NULL, NULL);
return SCI_SUCCESS;
default:
......
......@@ -92,45 +92,45 @@ enum scis_sds_remote_node_context_states {
* This state is the initial state for a remote node context. On a resume
* request the remote node context will transition to the posting state.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE,
SCI_RNC_INITIAL,
/**
* This is a transition state that posts the RNi to the hardware. Once the RNC
* is posted the remote node context will be made ready.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE,
SCI_RNC_POSTING,
/**
* This is a transition state that will post an RNC invalidate to the
* hardware. Once the invalidate is complete the remote node context will
* transition to the posting state.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE,
SCI_RNC_INVALIDATING,
/**
* This is a transition state that will post an RNC resume to the hardare.
* Once the event notification of resume complete is received the remote node
* context will transition to the ready state.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE,
SCI_RNC_RESUMING,
/**
* This is the state that the remote node context must be in to accept io
* request operations.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE,
SCI_RNC_READY,
/**
* This is the state that the remote node context transitions to when it gets
* a TX suspend notification from the hardware.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE,
SCI_RNC_TX_SUSPENDED,
/**
* This is the state that the remote node context transitions to when it gets
* a TX RX suspend notification from the hardware.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE,
SCI_RNC_TX_RX_SUSPENDED,
/**
* This state is a wait state for the remote node context that waits for a
......@@ -138,7 +138,7 @@ enum scis_sds_remote_node_context_states {
* there is a request to supend the remote node context or when there is a TC
* completion where the remote node will be suspended by the hardware.
*/
SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE
SCI_RNC_AWAIT_SUSPENSION
};
/**
......@@ -194,7 +194,7 @@ struct scic_sds_remote_node_context {
/**
* This field contains the data for the object's state machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
};
void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
......
此差异已折叠。
......@@ -96,37 +96,42 @@ struct scic_sds_stp_request {
u32 udma;
struct scic_sds_stp_pio_request {
/**
* Total transfer for the entire PIO request recorded at request constuction
* time.
/*
* Total transfer for the entire PIO request recorded
* at request constuction time.
*
* @todo Should we just decrement this value for each byte of data transitted
* or received to elemenate the current_transfer_bytes field?
* @todo Should we just decrement this value for each
* byte of data transitted or received to elemenate
* the current_transfer_bytes field?
*/
u32 total_transfer_bytes;
/**
* Total number of bytes received/transmitted in data frames since the start
* of the IO request. At the end of the IO request this should equal the
/*
* Total number of bytes received/transmitted in data
* frames since the start of the IO request. At the
* end of the IO request this should equal the
* total_transfer_bytes.
*/
u32 current_transfer_bytes;
/**
* The number of bytes requested in the in the PIO setup.
/*
* The number of bytes requested in the in the PIO
* setup.
*/
u32 pio_transfer_bytes;
/**
* PIO Setup ending status value to tell us if we need to wait for another FIS
* or if the transfer is complete. On the receipt of a D2H FIS this will be
/*
* PIO Setup ending status value to tell us if we need
* to wait for another FIS or if the transfer is
* complete. On the receipt of a D2H FIS this will be
* the status field of that FIS.
*/
u8 ending_status;
/**
* On receipt of a D2H FIS this will be the ending error field if the
* ending_status has the SATA_STATUS_ERR bit set.
/*
* On receipt of a D2H FIS this will be the ending
* error field if the ending_status has the
* SATA_STATUS_ERR bit set.
*/
u8 ending_error;
......@@ -138,8 +143,9 @@ struct scic_sds_stp_request {
} pio;
struct {
/**
* The number of bytes requested in the PIO setup before CDB data frame.
/*
* The number of bytes requested in the PIO setup
* before CDB data frame.
*/
u32 device_preferred_cdb_length;
} packet;
......@@ -147,57 +153,59 @@ struct scic_sds_stp_request {
};
struct scic_sds_request {
/**
* This field contains the information for the base request state machine.
/*
* This field contains the information for the base request state
* machine.
*/
struct sci_base_state_machine state_machine;
struct sci_base_state_machine sm;
/**
/*
* This field simply points to the controller to which this IO request
* is associated.
*/
struct scic_sds_controller *owning_controller;
/**
* This field simply points to the remote device to which this IO request
* is associated.
/*
* This field simply points to the remote device to which this IO
* request is associated.
*/
struct scic_sds_remote_device *target_device;
/**
/*
* This field is utilized to determine if the SCI user is managing
* the IO tag for this request or if the core is managing it.
*/
bool was_tag_assigned_by_user;
/**
/*
* This field indicates the IO tag for this request. The IO tag is
* comprised of the task_index and a sequence count. The sequence count
* is utilized to help identify tasks from one life to another.
*/
u16 io_tag;
/**
/*
* This field specifies the protocol being utilized for this
* IO request.
*/
enum sci_request_protocol protocol;
/**
/*
* This field indicates the completion status taken from the SCUs
* completion code. It indicates the completion result for the SCU hardware.
* completion code. It indicates the completion result for the SCU
* hardware.
*/
u32 scu_status;
/**
* This field indicates the completion status returned to the SCI user. It
* indicates the users view of the io request completion.
/*
* This field indicates the completion status returned to the SCI user.
* It indicates the users view of the io request completion.
*/
u32 sci_status;
/**
* This field contains the value to be utilized when posting (e.g. Post_TC,
* Post_TC_Abort) this request to the silicon.
/*
* This field contains the value to be utilized when posting
* (e.g. Post_TC, * Post_TC_Abort) this request to the silicon.
*/
u32 post_context;
......@@ -208,26 +216,26 @@ struct scic_sds_request {
#define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2)
struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
/**
/*
* This field indicates if this request is a task management request or
* normal IO request.
*/
bool is_task_management_request;
/**
* This field is a pointer to the stored rx frame data. It is used in STP
* internal requests and SMP response frames. If this field is non-NULL the
* saved frame must be released on IO request completion.
/*
* This field is a pointer to the stored rx frame data. It is used in
* STP internal requests and SMP response frames. If this field is
* non-NULL the saved frame must be released on IO request completion.
*
* @todo In the future do we want to keep a list of RX frame buffers?
*/
u32 saved_rx_frame_index;
/**
* This field in the recorded device sequence for the io request. This is
* recorded during the build operation and is compared in the start
* operation. If the sequence is different then there was a change of
* devices from the build to start operations.
/*
* This field in the recorded device sequence for the io request.
* This is recorded during the build operation and is compared in the
* start operation. If the sequence is different then there was a
* change of devices from the build to start operations.
*/
u8 device_sequence;
......@@ -286,7 +294,7 @@ struct isci_request {
dma_addr_t request_daddr;
dma_addr_t zero_scatter_daddr;
unsigned int num_sg_entries; /* returned by pci_alloc_sg */
unsigned int num_sg_entries; /* returned by pci_alloc_sg */
/** Note: "io_request_completion" is completed in two different ways
* depending on whether this is a TMF or regular request.
......@@ -315,104 +323,105 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_
*
*/
enum sci_base_request_states {
/**
/*
* Simply the initial state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_INITIAL,
SCI_REQ_INIT,
/**
* This state indicates that the request has been constructed. This state
* is entered from the INITIAL state.
/*
* This state indicates that the request has been constructed.
* This state is entered from the INITIAL state.
*/
SCI_BASE_REQUEST_STATE_CONSTRUCTED,
SCI_REQ_CONSTRUCTED,
/**
* This state indicates that the request has been started. This state is
* entered from the CONSTRUCTED state.
/*
* This state indicates that the request has been started. This state
* is entered from the CONSTRUCTED state.
*/
SCI_BASE_REQUEST_STATE_STARTED,
SCI_REQ_STARTED,
SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE,
SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE,
SCI_REQ_STP_UDMA_WAIT_TC_COMP,
SCI_REQ_STP_UDMA_WAIT_D2H,
SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE,
SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE,
SCI_REQ_STP_NON_DATA_WAIT_H2D,
SCI_REQ_STP_NON_DATA_WAIT_D2H,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE,
SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED,
SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG,
SCI_REQ_STP_SOFT_RESET_WAIT_D2H,
/**
* While in this state the IO request object is waiting for the TC completion
* notification for the H2D Register FIS
/*
* While in this state the IO request object is waiting for the TC
* completion notification for the H2D Register FIS
*/
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE,
SCI_REQ_STP_PIO_WAIT_H2D,
/**
* While in this state the IO request object is waiting for either a PIO Setup
* FIS or a D2H register FIS. The type of frame received is based on the
* result of the prior frame and line conditions.
/*
* While in this state the IO request object is waiting for either a
* PIO Setup FIS or a D2H register FIS. The type of frame received is
* based on the result of the prior frame and line conditions.
*/
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE,
SCI_REQ_STP_PIO_WAIT_FRAME,
/**
* While in this state the IO request object is waiting for a DATA frame from
* the device.
/*
* While in this state the IO request object is waiting for a DATA
* frame from the device.
*/
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE,
SCI_REQ_STP_PIO_DATA_IN,
/**
* While in this state the IO request object is waiting to transmit the next data
* frame to the device.
/*
* While in this state the IO request object is waiting to transmit
* the next data frame to the device.
*/
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE,
SCI_REQ_STP_PIO_DATA_OUT,
/**
/*
* The AWAIT_TC_COMPLETION sub-state indicates that the started raw
* task management request is waiting for the transmission of the
* initial frame (i.e. command, task, etc.).
*/
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION,
SCI_REQ_TASK_WAIT_TC_COMP,
/**
/*
* This sub-state indicates that the started task management request
* is waiting for the reception of an unsolicited frame
* (i.e. response IU).
*/
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE,
SCI_REQ_TASK_WAIT_TC_RESP,
/**
/*
* This sub-state indicates that the started task management request
* is waiting for the reception of an unsolicited frame
* (i.e. response IU).
*/
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE,
SCI_REQ_SMP_WAIT_RESP,
/**
* The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is
* waiting for the transmission of the initial frame (i.e. command, task, etc.).
/*
* The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
* request is waiting for the transmission of the initial frame
* (i.e. command, task, etc.).
*/
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION,
SCI_REQ_SMP_WAIT_TC_COMP,
/**
/*
* This state indicates that the request has completed.
* This state is entered from the STARTED state. This state is entered from
* the ABORTING state.
* This state is entered from the STARTED state. This state is entered
* from the ABORTING state.
*/
SCI_BASE_REQUEST_STATE_COMPLETED,
SCI_REQ_COMPLETED,
/**
/*
* This state indicates that the request is in the process of being
* terminated/aborted.
* This state is entered from the CONSTRUCTED state.
* This state is entered from the STARTED state.
*/
SCI_BASE_REQUEST_STATE_ABORTING,
SCI_REQ_ABORTING,
/**
/*
* Simply the final state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_FINAL,
SCI_REQ_FINAL,
};
/**
......@@ -498,13 +507,18 @@ enum sci_base_request_states {
enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req);
enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req);
enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
u32 event_code);
enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
u32 frame_index);
enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req);
extern enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req);
extern enum sci_status scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code);
enum sci_status
scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
u32 event_code);
enum sci_status
scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
u32 frame_index);
enum sci_status
scic_sds_task_request_terminate(struct scic_sds_request *sci_req);
extern enum sci_status
scic_sds_request_complete(struct scic_sds_request *sci_req);
extern enum sci_status
scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code);
/* XXX open code in caller */
static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
......@@ -523,8 +537,8 @@ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
}
/* XXX open code in caller */
static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req,
void *virt_addr)
static inline dma_addr_t
scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr)
{
struct isci_request *ireq = sci_req_to_ireq(sci_req);
......@@ -543,9 +557,8 @@ static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *s
*
* status of the object as a isci_request_status enum.
*/
static inline
enum isci_request_status isci_request_get_state(
struct isci_request *isci_request)
static inline enum isci_request_status
isci_request_get_state(struct isci_request *isci_request)
{
BUG_ON(isci_request == NULL);
......@@ -566,9 +579,9 @@ enum isci_request_status isci_request_get_state(
* @status: This Parameter is the new status of the object
*
*/
static inline enum isci_request_status isci_request_change_state(
struct isci_request *isci_request,
enum isci_request_status status)
static inline enum isci_request_status
isci_request_change_state(struct isci_request *isci_request,
enum isci_request_status status)
{
enum isci_request_status old_state;
unsigned long flags;
......@@ -597,10 +610,10 @@ static inline enum isci_request_status isci_request_change_state(
*
* state previous to any change.
*/
static inline enum isci_request_status isci_request_change_started_to_newstate(
struct isci_request *isci_request,
struct completion *completion_ptr,
enum isci_request_status newstate)
static inline enum isci_request_status
isci_request_change_started_to_newstate(struct isci_request *isci_request,
struct completion *completion_ptr,
enum isci_request_status newstate)
{
enum isci_request_status old_state;
unsigned long flags;
......@@ -615,6 +628,7 @@ static inline enum isci_request_status isci_request_change_started_to_newstate(
isci_request->io_request_completion = completion_ptr;
isci_request->status = newstate;
}
spin_unlock_irqrestore(&isci_request->state_lock, flags);
dev_dbg(&isci_request->isci_host->pdev->dev,
......@@ -635,13 +649,13 @@ static inline enum isci_request_status isci_request_change_started_to_newstate(
*
* state previous to any change.
*/
static inline enum isci_request_status isci_request_change_started_to_aborted(
struct isci_request *isci_request,
struct completion *completion_ptr)
static inline enum isci_request_status
isci_request_change_started_to_aborted(struct isci_request *isci_request,
struct completion *completion_ptr)
{
return isci_request_change_started_to_newstate(
isci_request, completion_ptr, aborted
);
return isci_request_change_started_to_newstate(isci_request,
completion_ptr,
aborted);
}
/**
* isci_request_free() - This function frees the request object.
......@@ -649,62 +663,33 @@ static inline enum isci_request_status isci_request_change_started_to_aborted(
* @isci_request: This parameter points to the isci_request object
*
*/
static inline void isci_request_free(
struct isci_host *isci_host,
struct isci_request *isci_request)
static inline void isci_request_free(struct isci_host *isci_host,
struct isci_request *isci_request)
{
if (!isci_request)
return;
/* release the dma memory if we fail. */
dma_pool_free(isci_host->dma_pool, isci_request,
dma_pool_free(isci_host->dma_pool,
isci_request,
isci_request->request_daddr);
}
#define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr)
/* #define ISCI_REQUEST_VALIDATE_ACCESS
*/
#ifdef ISCI_REQUEST_VALIDATE_ACCESS
static inline
struct sas_task *isci_request_access_task(struct isci_request *isci_request)
{
BUG_ON(isci_request->ttype != io_task);
return isci_request->ttype_ptr.io_task_ptr;
}
static inline
struct isci_tmf *isci_request_access_tmf(struct isci_request *isci_request)
{
BUG_ON(isci_request->ttype != tmf_task);
return isci_request->ttype_ptr.tmf_task_ptr;
}
#else /* not ISCI_REQUEST_VALIDATE_ACCESS */
#define isci_request_access_task(RequestPtr) \
((RequestPtr)->ttype_ptr.io_task_ptr)
#define isci_request_access_tmf(RequestPtr) \
((RequestPtr)->ttype_ptr.tmf_task_ptr)
#endif /* not ISCI_REQUEST_VALIDATE_ACCESS */
#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
int isci_request_alloc_tmf(
struct isci_host *isci_host,
struct isci_tmf *isci_tmf,
struct isci_request **isci_request,
struct isci_remote_device *isci_device,
gfp_t gfp_flags);
int isci_request_alloc_tmf(struct isci_host *isci_host,
struct isci_tmf *isci_tmf,
struct isci_request **isci_request,
struct isci_remote_device *isci_device,
gfp_t gfp_flags);
int isci_request_execute(
struct isci_host *isci_host,
struct sas_task *task,
struct isci_request **request,
gfp_t gfp_flags);
int isci_request_execute(struct isci_host *isci_host,
struct sas_task *task,
struct isci_request **request,
gfp_t gfp_flags);
/**
* isci_request_unmap_sgl() - This function unmaps the DMA address of a given
......@@ -713,9 +698,8 @@ int isci_request_execute(
* @*pdev: This Parameter is the pci_device struct for the controller
*
*/
static inline void isci_request_unmap_sgl(
struct isci_request *request,
struct pci_dev *pdev)
static inline void
isci_request_unmap_sgl(struct isci_request *request, struct pci_dev *pdev)
{
struct sas_task *task = isci_request_access_task(request);
......@@ -758,9 +742,9 @@ static inline void isci_request_unmap_sgl(
*
* pointer to the next sge for specified request.
*/
static inline void *isci_request_io_request_get_next_sge(
struct isci_request *request,
void *current_sge_address)
static inline void *
isci_request_io_request_get_next_sge(struct isci_request *request,
void *current_sge_address)
{
struct sas_task *task = isci_request_access_task(request);
void *ret = NULL;
......@@ -791,15 +775,20 @@ static inline void *isci_request_io_request_get_next_sge(
return ret;
}
void isci_terminate_pending_requests(struct isci_host *isci_host,
struct isci_remote_device *isci_device,
enum isci_request_status new_request_state);
enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
u16 io_tag,
struct scic_sds_request *sci_req);
enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req);
enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req);
void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag);
void
isci_terminate_pending_requests(struct isci_host *isci_host,
struct isci_remote_device *isci_device,
enum isci_request_status new_request_state);
enum sci_status
scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
u16 io_tag,
struct scic_sds_request *sci_req);
enum sci_status
scic_task_request_construct_ssp(struct scic_sds_request *sci_req);
enum sci_status
scic_task_request_construct_sata(struct scic_sds_request *sci_req);
void
scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag);
void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req);
#endif /* !defined(_ISCI_REQUEST_H_) */
......@@ -127,16 +127,7 @@ void sci_base_state_machine_stop(
sci_state_machine_exit_state(sm);
}
/**
* This method performs an update to the current state of the state machine.
* @sm: This parameter specifies the state machine for which
* the caller wishes to perform a state change.
* @next_state: This parameter specifies the new state for the state machine.
*
*/
void sci_base_state_machine_change_state(
struct sci_base_state_machine *sm,
u32 next_state)
void sci_change_state(struct sci_base_state_machine *sm, u32 next_state)
{
sci_state_machine_exit_state(sm);
......@@ -145,18 +136,3 @@ void sci_base_state_machine_change_state(
sci_state_machine_enter_state(sm);
}
/**
* This method simply returns the current state of the state machine to the
* caller.
* @sm: This parameter specifies the state machine for which to
* retrieve the current state.
*
* This method returns a u32 value indicating the current state for the
* supplied state machine.
*/
u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm)
{
return sm->current_state_id;
}
......@@ -117,8 +117,6 @@ void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
u32 initial_state);
void sci_base_state_machine_start(struct sci_base_state_machine *sm);
void sci_base_state_machine_stop(struct sci_base_state_machine *sm);
void sci_base_state_machine_change_state(struct sci_base_state_machine *sm,
u32 next_state);
u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm);
void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
#endif /* _SCI_BASE_STATE_MACHINE_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册