Commit 7ab92c9e authored by Dan Williams's avatar Dan Williams

isci: make a remote_node_context a proper member of a remote_device

A rnc object has the same lifetime as its associated remote_device.  It might
get re-initialized, but a remote device always has an rnc member.  Preparation
for unifying scic_sds_remote_device and isci_remote_device
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 31e824ed
...@@ -83,8 +83,7 @@ ...@@ -83,8 +83,7 @@
u32 scic_remote_device_get_object_size(void) u32 scic_remote_device_get_object_size(void)
{ {
return sizeof(struct scic_sds_remote_device) return sizeof (struct scic_sds_remote_device);
+ sizeof(struct scic_sds_remote_node_context);
} }
enum sci_status scic_remote_device_da_construct( enum sci_status scic_remote_device_da_construct(
...@@ -111,7 +110,7 @@ enum sci_status scic_remote_device_da_construct( ...@@ -111,7 +110,7 @@ enum sci_status scic_remote_device_da_construct(
&remote_node_index); &remote_node_index);
if (status == SCI_SUCCESS) { if (status == SCI_SUCCESS) {
sci_dev->rnc->remote_node_index = remote_node_index; sci_dev->rnc.remote_node_index = remote_node_index;
scic_sds_port_get_attached_sas_address( scic_sds_port_get_attached_sas_address(
sci_dev->owning_port, &sci_dev->device_address); sci_dev->owning_port, &sci_dev->device_address);
...@@ -176,7 +175,7 @@ enum sci_status scic_remote_device_ea_construct( ...@@ -176,7 +175,7 @@ enum sci_status scic_remote_device_ea_construct(
sci_dev, discover_response); sci_dev, discover_response);
status = scic_sds_controller_allocate_remote_node_context( status = scic_sds_controller_allocate_remote_node_context(
scic, sci_dev, &sci_dev->rnc->remote_node_index); scic, sci_dev, &sci_dev->rnc.remote_node_index);
if (status == SCI_SUCCESS) { if (status == SCI_SUCCESS) {
if (sci_dev->target_protocols.u.bits.attached_ssp_target) { if (sci_dev->target_protocols.u.bits.attached_ssp_target) {
...@@ -694,7 +693,7 @@ static enum sci_status scic_sds_remote_device_core_event_handler( ...@@ -694,7 +693,7 @@ static enum sci_status scic_sds_remote_device_core_event_handler(
case SCU_EVENT_TYPE_RNC_OPS_MISC: case SCU_EVENT_TYPE_RNC_OPS_MISC:
case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
status = scic_sds_remote_node_context_event_handler(sci_dev->rnc, event_code); status = scic_sds_remote_node_context_event_handler(&sci_dev->rnc, event_code);
break; break;
case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
...@@ -702,7 +701,7 @@ static enum sci_status scic_sds_remote_device_core_event_handler( ...@@ -702,7 +701,7 @@ static enum sci_status scic_sds_remote_device_core_event_handler(
status = SCI_SUCCESS; status = SCI_SUCCESS;
/* Suspend the associated RNC */ /* Suspend the associated RNC */
scic_sds_remote_node_context_suspend(sci_dev->rnc, scic_sds_remote_node_context_suspend(&sci_dev->rnc,
SCI_SOFTWARE_SUSPENSION, SCI_SOFTWARE_SUSPENSION,
NULL, NULL); NULL, NULL);
...@@ -889,7 +888,7 @@ static enum sci_status scic_sds_remote_device_stopped_state_start_handler( ...@@ -889,7 +888,7 @@ static enum sci_status scic_sds_remote_device_stopped_state_start_handler(
{ {
enum sci_status status; enum sci_status status;
status = scic_sds_remote_node_context_resume(sci_dev->rnc, status = scic_sds_remote_node_context_resume(&sci_dev->rnc,
scic_sds_remote_device_resume_complete_handler, sci_dev); scic_sds_remote_device_resume_complete_handler, sci_dev);
if (status == SCI_SUCCESS) if (status == SCI_SUCCESS)
...@@ -923,8 +922,8 @@ static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( ...@@ -923,8 +922,8 @@ static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler(
scic = scic_sds_remote_device_get_controller(sci_dev); scic = scic_sds_remote_device_get_controller(sci_dev);
scic_sds_controller_free_remote_node_context(scic, sci_dev, scic_sds_controller_free_remote_node_context(scic, sci_dev,
sci_dev->rnc->remote_node_index); sci_dev->rnc.remote_node_index);
sci_dev->rnc->remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_base_state_machine_change_state(&sci_dev->state_machine,
SCI_BASE_REMOTE_DEVICE_STATE_FINAL); SCI_BASE_REMOTE_DEVICE_STATE_FINAL);
...@@ -948,7 +947,7 @@ static enum sci_status scic_sds_remote_device_starting_state_stop_handler( ...@@ -948,7 +947,7 @@ static enum sci_status scic_sds_remote_device_starting_state_stop_handler(
/* /*
* Destroy the remote node context * Destroy the remote node context
*/ */
scic_sds_remote_node_context_destruct(sci_dev->rnc, scic_sds_remote_node_context_destruct(&sci_dev->rnc,
scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev); scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev);
/* /*
...@@ -971,7 +970,7 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler( ...@@ -971,7 +970,7 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler(
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); SCI_BASE_REMOTE_DEVICE_STATE_STOPPING);
if (sci_dev->started_request_count == 0) { if (sci_dev->started_request_count == 0) {
scic_sds_remote_node_context_destruct(sci_dev->rnc, scic_sds_remote_node_context_destruct(&sci_dev->rnc,
scic_sds_cb_remote_device_rnc_destruct_complete, scic_sds_cb_remote_device_rnc_destruct_complete,
sci_dev); sci_dev);
} else } else
...@@ -1016,8 +1015,8 @@ static enum sci_status scic_sds_remote_device_ready_state_start_task_handler( ...@@ -1016,8 +1015,8 @@ static enum sci_status scic_sds_remote_device_ready_state_start_task_handler(
scic_sds_remote_device_get_port(sci_dev), sci_dev, request); scic_sds_remote_device_get_port(sci_dev), sci_dev, request);
if (result == SCI_SUCCESS) { if (result == SCI_SUCCESS) {
result = scic_sds_remote_node_context_start_task( result = scic_sds_remote_node_context_start_task(&sci_dev->rnc,
sci_dev->rnc, request); request);
if (result == SCI_SUCCESS) if (result == SCI_SUCCESS)
result = scic_sds_request_start(request); result = scic_sds_request_start(request);
...@@ -1046,8 +1045,7 @@ static enum sci_status scic_sds_remote_device_ready_state_start_io_handler( ...@@ -1046,8 +1045,7 @@ static enum sci_status scic_sds_remote_device_ready_state_start_io_handler(
scic_sds_remote_device_get_port(sci_dev), sci_dev, request); scic_sds_remote_device_get_port(sci_dev), sci_dev, request);
if (result == SCI_SUCCESS) { if (result == SCI_SUCCESS) {
result = scic_sds_remote_node_context_start_io( result = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request);
sci_dev->rnc, request);
if (result == SCI_SUCCESS) if (result == SCI_SUCCESS)
result = scic_sds_request_start(request); result = scic_sds_request_start(request);
...@@ -1144,7 +1142,7 @@ static enum sci_status scic_sds_remote_device_stopping_state_complete_request_ha ...@@ -1144,7 +1142,7 @@ static enum sci_status scic_sds_remote_device_stopping_state_complete_request_ha
scic_sds_remote_device_decrement_request_count(sci_dev); scic_sds_remote_device_decrement_request_count(sci_dev);
if (scic_sds_remote_device_get_request_count(sci_dev) == 0) if (scic_sds_remote_device_get_request_count(sci_dev) == 0)
scic_sds_remote_node_context_destruct(sci_dev->rnc, scic_sds_remote_node_context_destruct(&sci_dev->rnc,
scic_sds_cb_remote_device_rnc_destruct_complete, scic_sds_cb_remote_device_rnc_destruct_complete,
sci_dev); sci_dev);
return SCI_SUCCESS; return SCI_SUCCESS;
...@@ -1491,7 +1489,7 @@ static void scic_sds_remote_device_ready_state_enter(struct sci_base_object *obj ...@@ -1491,7 +1489,7 @@ static void scic_sds_remote_device_ready_state_enter(struct sci_base_object *obj
scic_sds_remote_device_state_handler_table, scic_sds_remote_device_state_handler_table,
SCI_BASE_REMOTE_DEVICE_STATE_READY); SCI_BASE_REMOTE_DEVICE_STATE_READY);
scic->remote_device_sequence[sci_dev->rnc->remote_node_index]++; scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++;
if (sci_dev->has_ready_substate_machine) if (sci_dev->has_ready_substate_machine)
sci_base_state_machine_start(&sci_dev->ready_substate_machine); sci_base_state_machine_start(&sci_dev->ready_substate_machine);
...@@ -1585,7 +1583,7 @@ static void scic_sds_remote_device_resetting_state_enter( ...@@ -1585,7 +1583,7 @@ static void scic_sds_remote_device_resetting_state_enter(
); );
scic_sds_remote_node_context_suspend( scic_sds_remote_node_context_suspend(
sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
} }
/** /**
...@@ -1601,7 +1599,7 @@ static void scic_sds_remote_device_resetting_state_exit( ...@@ -1601,7 +1599,7 @@ static void scic_sds_remote_device_resetting_state_exit(
{ {
struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object;
scic_sds_remote_node_context_resume(sci_dev->rnc, NULL, NULL); scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL);
} }
/** /**
...@@ -1661,7 +1659,6 @@ void scic_remote_device_construct(struct scic_sds_port *sci_port, ...@@ -1661,7 +1659,6 @@ void scic_remote_device_construct(struct scic_sds_port *sci_port,
{ {
sci_dev->owning_port = sci_port; sci_dev->owning_port = sci_port;
sci_dev->started_request_count = 0; sci_dev->started_request_count = 0;
sci_dev->rnc = (struct scic_sds_remote_node_context *) &sci_dev[1];
sci_dev->parent.private = NULL; sci_dev->parent.private = NULL;
sci_base_state_machine_construct( sci_base_state_machine_construct(
...@@ -1677,9 +1674,9 @@ void scic_remote_device_construct(struct scic_sds_port *sci_port, ...@@ -1677,9 +1674,9 @@ void scic_remote_device_construct(struct scic_sds_port *sci_port,
scic_sds_remote_node_context_construct( scic_sds_remote_node_context_construct(
sci_dev, sci_dev,
sci_dev->rnc, &sci_dev->rnc,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
); );
sci_object_set_association(sci_dev->rnc, sci_dev); sci_object_set_association(&sci_dev->rnc, sci_dev);
} }
...@@ -297,7 +297,7 @@ struct scic_sds_remote_device { ...@@ -297,7 +297,7 @@ struct scic_sds_remote_device {
* This field contains the SCU silicon remote node context specific * This field contains the SCU silicon remote node context specific
* information. * information.
*/ */
struct scic_sds_remote_node_context *rnc; struct scic_sds_remote_node_context rnc;
/** /**
* This field contains the stated request count for the remote device. The * This field contains the stated request count for the remote device. The
...@@ -523,7 +523,7 @@ extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_tab ...@@ -523,7 +523,7 @@ extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_tab
#define scic_sds_remote_device_get_sequence(sci_dev) \ #define scic_sds_remote_device_get_sequence(sci_dev) \
(\ (\
scic_sds_remote_device_get_controller(sci_dev)-> \ scic_sds_remote_device_get_controller(sci_dev)-> \
remote_device_sequence[(sci_dev)->rnc->remote_node_index] \ remote_device_sequence[(sci_dev)->rnc.remote_node_index] \
) )
/** /**
...@@ -554,7 +554,7 @@ extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_tab ...@@ -554,7 +554,7 @@ extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_tab
* This macro returns the remote node index for this device object * This macro returns the remote node index for this device object
*/ */
#define scic_sds_remote_device_get_index(sci_dev) \ #define scic_sds_remote_device_get_index(sci_dev) \
((sci_dev)->rnc->remote_node_index) ((sci_dev)->rnc.remote_node_index)
/** /**
* scic_sds_remote_device_build_command_context() - * scic_sds_remote_device_build_command_context() -
......
...@@ -1766,7 +1766,7 @@ enum sci_status scic_io_request_construct(struct scic_sds_controller *scic, ...@@ -1766,7 +1766,7 @@ enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
scic_sds_general_request_construct(scic, sci_dev, io_tag, scic_sds_general_request_construct(scic, sci_dev, io_tag,
user_io_request_object, sci_req); user_io_request_object, sci_req);
if (sci_dev->rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
return SCI_FAILURE_INVALID_REMOTE_DEVICE; return SCI_FAILURE_INVALID_REMOTE_DEVICE;
scic_remote_device_get_protocols(sci_dev, &device_protocol); scic_remote_device_get_protocols(sci_dev, &device_protocol);
......
...@@ -87,8 +87,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_h ...@@ -87,8 +87,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_h
device->owning_port, device, request); device->owning_port, device, request);
if (status == SCI_SUCCESS) { if (status == SCI_SUCCESS) {
status = scic_sds_remote_node_context_start_io( status = scic_sds_remote_node_context_start_io(&device->rnc, request);
device->rnc, request);
if (status == SCI_SUCCESS) if (status == SCI_SUCCESS)
status = scic_sds_request_start(request); status = scic_sds_request_start(request);
......
...@@ -173,7 +173,7 @@ static void scu_smp_request_construct_task_context( ...@@ -173,7 +173,7 @@ static void scu_smp_request_construct_task_context(
{ {
dma_addr_t dma_addr; dma_addr_t dma_addr;
struct scic_sds_controller *controller; struct scic_sds_controller *controller;
struct scic_sds_remote_device *target_device; struct scic_sds_remote_device *sci_dev;
struct scic_sds_port *target_port; struct scic_sds_port *target_port;
struct scu_task_context *task_context; struct scu_task_context *task_context;
...@@ -185,7 +185,7 @@ static void scu_smp_request_construct_task_context( ...@@ -185,7 +185,7 @@ static void scu_smp_request_construct_task_context(
task_context = scic_sds_request_get_task_context(sds_request); task_context = scic_sds_request_get_task_context(sds_request);
controller = scic_sds_request_get_controller(sds_request); controller = scic_sds_request_get_controller(sds_request);
target_device = scic_sds_request_get_device(sds_request); sci_dev = scic_sds_request_get_device(sds_request);
target_port = scic_sds_request_get_port(sds_request); target_port = scic_sds_request_get_port(sds_request);
/* /*
...@@ -195,7 +195,7 @@ static void scu_smp_request_construct_task_context( ...@@ -195,7 +195,7 @@ static void scu_smp_request_construct_task_context(
task_context->priority = 0; task_context->priority = 0;
task_context->initiator_request = 1; task_context->initiator_request = 1;
task_context->connection_rate = task_context->connection_rate =
scic_remote_device_get_connection_rate(target_device); scic_remote_device_get_connection_rate(sci_dev);
task_context->protocol_engine_index = task_context->protocol_engine_index =
scic_sds_controller_get_protocol_engine_group(controller); scic_sds_controller_get_protocol_engine_group(controller);
task_context->logical_port_index = task_context->logical_port_index =
...@@ -206,8 +206,7 @@ static void scu_smp_request_construct_task_context( ...@@ -206,8 +206,7 @@ static void scu_smp_request_construct_task_context(
task_context->context_type = SCU_TASK_CONTEXT_TYPE; task_context->context_type = SCU_TASK_CONTEXT_TYPE;
/* 04h */ /* 04h */
task_context->remote_node_index = task_context->remote_node_index = sci_dev->rnc.remote_node_index;
sds_request->target_device->rnc->remote_node_index;
task_context->command_code = 0; task_context->command_code = 0;
task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST; task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST;
......
...@@ -150,7 +150,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_substate_start_request_h ...@@ -150,7 +150,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_substate_start_request_h
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
status = scic_sds_remote_node_context_start_task(device->rnc, request); status = scic_sds_remote_node_context_start_task(&device->rnc, request);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
goto out; goto out;
...@@ -173,9 +173,9 @@ static enum sci_status scic_sds_stp_remote_device_ready_substate_start_request_h ...@@ -173,9 +173,9 @@ static enum sci_status scic_sds_stp_remote_device_ready_substate_start_request_h
* remote node context state machine will take the correct action when * remote node context state machine will take the correct action when
* the remote node context is suspended and later resumed. * the remote node context is suspended and later resumed.
*/ */
scic_sds_remote_node_context_suspend(device->rnc, scic_sds_remote_node_context_suspend(&device->rnc,
SCI_SOFTWARE_SUSPENSION, NULL, NULL); SCI_SOFTWARE_SUSPENSION, NULL, NULL);
scic_sds_remote_node_context_resume(device->rnc, scic_sds_remote_node_context_resume(&device->rnc,
scic_sds_remote_device_continue_request, scic_sds_remote_device_continue_request,
device); device);
...@@ -220,7 +220,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_start_io_h ...@@ -220,7 +220,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_start_io_h
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
status = scic_sds_remote_node_context_start_io(sci_dev->rnc, request); status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
goto out; goto out;
...@@ -263,7 +263,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_event_hand ...@@ -263,7 +263,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_event_hand
if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX
|| scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) { || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) {
status = scic_sds_remote_node_context_resume( status = scic_sds_remote_node_context_resume(
sci_dev->rnc, NULL, NULL); &sci_dev->rnc, NULL, NULL);
} }
} }
...@@ -289,19 +289,16 @@ static enum sci_status scic_sds_stp_remote_device_ready_ncq_substate_start_io_ha ...@@ -289,19 +289,16 @@ static enum sci_status scic_sds_stp_remote_device_ready_ncq_substate_start_io_ha
sci_dev->owning_port, sci_dev->owning_port,
sci_dev, sci_dev,
request); request);
if (status != SCI_SUCCESS)
return status;
if (status == SCI_SUCCESS) { status = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request);
status = scic_sds_remote_node_context_start_io( if (status != SCI_SUCCESS)
sci_dev->rnc, return status;
request);
if (status == SCI_SUCCESS)
status = request->state_handlers->start_handler(request); status = request->state_handlers->start_handler(request);
scic_sds_remote_device_start_request(sci_dev, scic_sds_remote_device_start_request(sci_dev, request, status);
request,
status);
}
} else } else
status = SCI_FAILURE_INVALID_STATE; status = SCI_FAILURE_INVALID_STATE;
...@@ -398,9 +395,8 @@ static enum sci_status scic_sds_stp_remote_device_ready_cmd_substate_suspend_han ...@@ -398,9 +395,8 @@ static enum sci_status scic_sds_stp_remote_device_ready_cmd_substate_suspend_han
{ {
enum sci_status status; enum sci_status status;
status = scic_sds_remote_node_context_suspend( status = scic_sds_remote_node_context_suspend(&sci_dev->rnc,
sci_dev->rnc, suspend_type, NULL, NULL suspend_type, NULL, NULL);
);
return status; return status;
} }
...@@ -685,7 +681,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter( ...@@ -685,7 +681,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
sci_dev->working_request = NULL; sci_dev->working_request = NULL;
if (scic_sds_remote_node_context_is_ready(sci_dev->rnc)) { if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) {
/* /*
* Since the RNC is ready, it's alright to finish completion * Since the RNC is ready, it's alright to finish completion
* processing (e.g. signal the remote device is ready). */ * processing (e.g. signal the remote device is ready). */
...@@ -694,10 +690,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter( ...@@ -694,10 +690,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
); );
} else { } else {
scic_sds_remote_node_context_resume( scic_sds_remote_node_context_resume(
sci_dev->rnc, &sci_dev->rnc,
scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler, scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler,
sci_dev sci_dev);
);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment