Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254522
b: refs/heads/master
c: c845ae9
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams committed Jul 3, 2011
1 parent 154b8fd commit 4903d3f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 81 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 338e386d12c2440e39c987d35fda403d319a79a0
refs/heads/master: c845ae96bcb1625a093003248ffaf13b92a81ac2
106 changes: 36 additions & 70 deletions trunk/drivers/scsi/isci/remote_node_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,26 +218,6 @@ static enum sci_status scic_sds_remote_node_context_continue_to_resume_handler(
return SCI_FAILURE_INVALID_STATE;
}

/* --------------------------------------------------------------------------- */

static enum sci_status scic_sds_remote_node_context_default_destruct_handler(
struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback callback,
void *callback_parameter)
{
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: SCIC Remote Node Context 0x%p requested to stop while "
"in unexpected state %d\n",
__func__,
sci_rnc,
sci_base_state_machine_get_state(&sci_rnc->state_machine));

/*
* We have decided that the destruct request on the remote node context can not fail
* since it is either in the initial/destroyed state or is can be destroyed. */
return SCI_SUCCESS;
}

static enum sci_status scic_sds_remote_node_context_default_suspend_handler(
struct scic_sds_remote_node_context *sci_rnc,
u32 suspend_type,
Expand Down Expand Up @@ -315,36 +295,6 @@ static enum sci_status scic_sds_remote_node_context_success_start_task_handler(
return SCI_SUCCESS;
}

/**
*
* @sci_rnc:
* @callback:
* @callback_parameter:
*
* This method handles destruct calls from the various state handlers. The
* remote node context can be requested to destroy from any state. If there was
* a user callback it is always replaced with the request to destroy user
* callback. enum sci_status
*/
static enum sci_status scic_sds_remote_node_context_general_destruct_handler(
struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback callback,
void *callback_parameter)
{
scic_sds_remote_node_context_setup_to_destory(
sci_rnc, callback, callback_parameter
);

sci_base_state_machine_change_state(
&sci_rnc->state_machine,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
);

return SCI_SUCCESS;
}

/* --------------------------------------------------------------------------- */

static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler(
struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback callback,
Expand All @@ -368,18 +318,6 @@ static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler
return SCI_FAILURE_INVALID_STATE;
}

static enum sci_status scic_sds_remote_node_context_invalidating_state_destruct_handler(
struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback callback,
void *callback_parameter)
{
scic_sds_remote_node_context_setup_to_destory(
sci_rnc, callback, callback_parameter
);

return SCI_SUCCESS;
}

/**
*
* @sci_rnc: The remote node context object being suspended.
Expand Down Expand Up @@ -539,56 +477,48 @@ static enum sci_status scic_sds_remote_node_context_await_suspension_state_start

static struct scic_sds_remote_node_context_handlers scic_sds_remote_node_context_state_handler_table[] = {
[SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
.destruct_handler = scic_sds_remote_node_context_default_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_initial_state_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
.destruct_handler = scic_sds_remote_node_context_invalidating_state_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_ready_state_suspend_handler,
.resume_handler = scic_sds_remote_node_context_default_resume_handler,
.start_io_handler = scic_sds_remote_node_context_ready_state_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_tx_suspended_state_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
.start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
},
[SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = {
.destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
.suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
.resume_handler = scic_sds_remote_node_context_await_suspension_state_resume_handler,
.start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
Expand Down Expand Up @@ -1023,3 +953,39 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
return SCI_FAILURE;

}

enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback cb_fn,
void *cb_p)
{
enum scis_sds_remote_node_context_states state;

state = sci_rnc->state_machine.current_state_id;
switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE:
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:
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);
return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE:
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
* can not fail since it is either in the initial/destroyed state or is
* can be destroyed.
*/
return SCI_SUCCESS;
default:
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE;
}
}
13 changes: 3 additions & 10 deletions trunk/drivers/scsi/isci/remote_node_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ typedef enum sci_status (*scic_sds_remote_node_context_io_request)(
);

struct scic_sds_remote_node_context_handlers {
/**
* This handle is invoked to stop the RNC. The callback is invoked when after
* the hardware notification that the RNC has been invalidated.
*/
scic_sds_remote_node_context_operation destruct_handler;

/**
* This handler is invoked when there is a request to suspend the RNC. The
* callback is invoked after the hardware notification that the remote node is
Expand Down Expand Up @@ -260,19 +254,18 @@ bool scic_sds_remote_node_context_is_ready(
#define scic_sds_remote_node_context_get_remote_node_index(rcn) \
((rnc)->remote_node_index)


enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc,
u32 event_code);

enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_node_context *sci_rnc,
scics_sds_remote_node_context_callback callback,
void *callback_parameter);
#define scic_sds_remote_node_context_resume(rnc, callback, parameter) \
((rnc)->state_handlers->resume_handler(rnc, callback, parameter))

#define scic_sds_remote_node_context_suspend(rnc, suspend_type, callback, parameter) \
((rnc)->state_handlers->suspend_handler(rnc, suspend_type, callback, parameter))

#define scic_sds_remote_node_context_destruct(rnc, callback, parameter) \
((rnc)->state_handlers->destruct_handler(rnc, callback, parameter))

#define scic_sds_remote_node_context_start_io(rnc, request) \
((rnc)->state_handlers->start_io_handler(rnc, request))

Expand Down

0 comments on commit 4903d3f

Please sign in to comment.