isci: make a remote_node_context a proper member of a remote_device
authorDan Williams <dan.j.williams@intel.com>
Tue, 19 Apr 2011 20:48:49 +0000 (13:48 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sun, 3 Jul 2011 11:00:37 +0000 (04:00 -0700)
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: Dan Williams <dan.j.williams@intel.com>
drivers/scsi/isci/core/scic_sds_remote_device.c
drivers/scsi/isci/core/scic_sds_remote_device.h
drivers/scsi/isci/core/scic_sds_request.c
drivers/scsi/isci/core/scic_sds_smp_remote_device.c
drivers/scsi/isci/core/scic_sds_smp_request.c
drivers/scsi/isci/core/scic_sds_stp_remote_device.c

index fa7828d4d97535e7c888faab23a514f0f4435750..04295274b71ae98f579e057db98d0681414f27ab 100644 (file)
@@ -83,8 +83,7 @@
 
 u32 scic_remote_device_get_object_size(void)
 {
-       return sizeof(struct scic_sds_remote_device)
-              + sizeof(struct scic_sds_remote_node_context);
+       return sizeof (struct scic_sds_remote_device);
 }
 
 enum sci_status scic_remote_device_da_construct(
@@ -111,7 +110,7 @@ enum sci_status scic_remote_device_da_construct(
                &remote_node_index);
 
        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(
                        sci_dev->owning_port, &sci_dev->device_address);
@@ -176,7 +175,7 @@ enum sci_status scic_remote_device_ea_construct(
                sci_dev, discover_response);
 
        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 (sci_dev->target_protocols.u.bits.attached_ssp_target) {
@@ -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_SUSPEND_TX:
        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;
        case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
 
@@ -702,7 +701,7 @@ static enum sci_status  scic_sds_remote_device_core_event_handler(
                        status = SCI_SUCCESS;
 
                        /* 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,
                                                              NULL, NULL);
 
@@ -889,7 +888,7 @@ static enum sci_status scic_sds_remote_device_stopped_state_start_handler(
 {
        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);
 
        if (status == SCI_SUCCESS)
@@ -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_sds_controller_free_remote_node_context(scic, sci_dev,
-                                                    sci_dev->rnc->remote_node_index);
-       sci_dev->rnc->remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
+                                                    sci_dev->rnc.remote_node_index);
+       sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
 
        sci_base_state_machine_change_state(&sci_dev->state_machine,
                                            SCI_BASE_REMOTE_DEVICE_STATE_FINAL);
@@ -948,7 +947,7 @@ static enum sci_status scic_sds_remote_device_starting_state_stop_handler(
        /*
         * 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);
 
        /*
@@ -971,7 +970,7 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler(
                                            SCI_BASE_REMOTE_DEVICE_STATE_STOPPING);
 
        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,
                        sci_dev);
        } else
@@ -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);
 
        if (result == SCI_SUCCESS) {
-               result = scic_sds_remote_node_context_start_task(
-                       sci_dev->rnc, request);
+               result = scic_sds_remote_node_context_start_task(&sci_dev->rnc,
+                                                                request);
                if (result == SCI_SUCCESS)
                        result = scic_sds_request_start(request);
 
@@ -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);
 
        if (result == SCI_SUCCESS) {
-               result = scic_sds_remote_node_context_start_io(
-                       sci_dev->rnc, request);
+               result = scic_sds_remote_node_context_start_io(&sci_dev->rnc, request);
                if (result == SCI_SUCCESS)
                        result = scic_sds_request_start(request);
 
@@ -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);
 
        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,
                                                      sci_dev);
        return SCI_SUCCESS;
@@ -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,
                          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)
                sci_base_state_machine_start(&sci_dev->ready_substate_machine);
@@ -1585,7 +1583,7 @@ static void scic_sds_remote_device_resetting_state_enter(
                );
 
        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(
 {
        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,
 {
        sci_dev->owning_port = sci_port;
        sci_dev->started_request_count = 0;
-       sci_dev->rnc = (struct scic_sds_remote_node_context *) &sci_dev[1];
        sci_dev->parent.private = NULL;
 
        sci_base_state_machine_construct(
@@ -1677,9 +1674,9 @@ void scic_remote_device_construct(struct scic_sds_port *sci_port,
 
        scic_sds_remote_node_context_construct(
                sci_dev,
-               sci_dev->rnc,
+               &sci_dev->rnc,
                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);
 }
index 5d3df92212ebb8fd90c6a18f8926986a232eec8b..7f43f3003e817f321316628d4b3bfa6129442d74 100644 (file)
@@ -297,7 +297,7 @@ struct scic_sds_remote_device {
         * This field contains the SCU silicon remote node context specific
         * 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
@@ -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) \
        (\
                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
  * This macro returns the remote node index for this device object
  */
 #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() -
index 8a608f01cedaffcf2d4890d8f4bd07909d296568..63ebbf39dc90f681fce43a16bf3f06cbc6c80d8b 100644 (file)
@@ -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,
                                           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;
 
        scic_remote_device_get_protocols(sci_dev, &device_protocol);
index 471cb7d1142dab80cfdfcdbeccad558e61308680..cd55c0a8dae3e4fec566ec61d602c16387e4b6b4 100644 (file)
@@ -87,8 +87,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_h
                        device->owning_port, device, request);
 
        if (status == SCI_SUCCESS) {
-               status = scic_sds_remote_node_context_start_io(
-                               device->rnc, request);
+               status = scic_sds_remote_node_context_start_io(&device->rnc, request);
 
                if (status == SCI_SUCCESS)
                        status = scic_sds_request_start(request);
index f53f21b8b9c06d8ecd45a2504fb453409d91219b..3274d62ac3b224d323f808ea4e3918b73f7ff54a 100644 (file)
@@ -173,7 +173,7 @@ static void scu_smp_request_construct_task_context(
 {
        dma_addr_t dma_addr;
        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 scu_task_context *task_context;
 
@@ -185,7 +185,7 @@ static void scu_smp_request_construct_task_context(
        task_context = scic_sds_request_get_task_context(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);
 
        /*
@@ -195,7 +195,7 @@ static void scu_smp_request_construct_task_context(
        task_context->priority = 0;
        task_context->initiator_request = 1;
        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 =
                scic_sds_controller_get_protocol_engine_group(controller);
        task_context->logical_port_index =
@@ -206,8 +206,7 @@ static void scu_smp_request_construct_task_context(
        task_context->context_type = SCU_TASK_CONTEXT_TYPE;
 
        /* 04h */
-       task_context->remote_node_index =
-               sds_request->target_device->rnc->remote_node_index;
+       task_context->remote_node_index = sci_dev->rnc.remote_node_index;
        task_context->command_code = 0;
        task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST;
 
index b15357b2ce0823dbe2194283f922ba5aa74d0380..848cb4711b6313914e5ba0f651f8fdd58d42666d 100644 (file)
@@ -150,7 +150,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_substate_start_request_h
        if (status != SCI_SUCCESS)
                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)
                goto out;
 
@@ -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
         * 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);
-       scic_sds_remote_node_context_resume(device->rnc,
+       scic_sds_remote_node_context_resume(&device->rnc,
                        scic_sds_remote_device_continue_request,
                        device);
 
@@ -220,7 +220,7 @@ static enum sci_status scic_sds_stp_remote_device_ready_idle_substate_start_io_h
        if (status != SCI_SUCCESS)
                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)
                goto out;
 
@@ -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
                    || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) {
                        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
                                sci_dev->owning_port,
                                sci_dev,
                                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(&sci_dev->rnc, request);
+               if (status != SCI_SUCCESS)
+                       return status;
 
-                       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,
-                                                            request,
-                                                            status);
-               }
+               scic_sds_remote_device_start_request(sci_dev, request, status);
        } else
                status = SCI_FAILURE_INVALID_STATE;
 
@@ -398,9 +395,8 @@ static enum sci_status scic_sds_stp_remote_device_ready_cmd_substate_suspend_han
 {
        enum sci_status status;
 
-       status = scic_sds_remote_node_context_suspend(
-               sci_dev->rnc, suspend_type, NULL, NULL
-               );
+       status = scic_sds_remote_node_context_suspend(&sci_dev->rnc,
+                                                     suspend_type, NULL, NULL);
 
        return status;
 }
@@ -685,7 +681,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
 
        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
                 * processing (e.g. signal the remote device is ready). */
@@ -694,10 +690,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
                        );
        } else {
                scic_sds_remote_node_context_resume(
-                       sci_dev->rnc,
+                       &sci_dev->rnc,
                        scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler,
-                       sci_dev
-                       );
+                       sci_dev);
        }
 }