summaryrefslogtreecommitdiff
path: root/drivers/scsi/isci/remote_node_context.c
diff options
context:
space:
mode:
authorEdmund Nadolski <edmund.nadolski@intel.com>2011-06-02 04:10:43 +0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 15:04:50 +0400
commite301370ac553a9a0ac0d1d25e769b86cf60395b3 (patch)
tree58c00e0aeb21c3101df389d4b5e34f47e4b32119 /drivers/scsi/isci/remote_node_context.c
parent8d2c65c09c9e0adc16070562e7944c1c3277f332 (diff)
downloadlinux-e301370ac553a9a0ac0d1d25e769b86cf60395b3.tar.xz
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: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/remote_node_context.c')
-rw-r--r--drivers/scsi/isci/remote_node_context.c154
1 files changed, 70 insertions, 84 deletions
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index e7fa5bac7d53..24b1d8acf7b8 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -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: