diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-04-27 19:32:45 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:00:39 -0400 |
commit | ab2e8f7d07f577ee39228fb3454b9f29eab0f312 (patch) | |
tree | 9f3fc14b955f689a29d6777349db0f49c8dcf3e0 /drivers/scsi/isci/remote_device.h | |
parent | be2f41c611b65353fa3ae0c155cf906b348dc864 (diff) |
isci: merge remote_device substates into a single state machine
A substate is just a state, so uplevel the smp and stp device substates.
Three tricks at work here:
1/ scic_sds_remote_device_ready_state_enter: needs to know the the device type
so it can immediately transition to a stp or smp ready substate.
2/ scic_sds_remote_device_ready_state_exit: needs to know the device type. In
the ssp case the device is no longer ready, in the stp, and smp case we have
simply exited to a ready "substate".
3/ scic_sds_remote_device_resume_complete_handler: The one location
where we directly check the current state against
SCI_BASE_REMOTE_DEVICE_STATE_READY needed to comprehend the possible ready
substates.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/remote_device.h')
-rw-r--r-- | drivers/scsi/isci/remote_device.h | 208 |
1 files changed, 34 insertions, 174 deletions
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h index 62623c766388..dda217a6bd3a 100644 --- a/drivers/scsi/isci/remote_device.h +++ b/drivers/scsi/isci/remote_device.h | |||
@@ -68,9 +68,7 @@ enum scic_remote_device_not_ready_reason_code { | |||
68 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, | 68 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, |
69 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, | 69 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, |
70 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, | 70 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, |
71 | |||
72 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX | 71 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX |
73 | |||
74 | }; | 72 | }; |
75 | 73 | ||
76 | struct scic_sds_remote_device { | 74 | struct scic_sds_remote_device { |
@@ -132,19 +130,6 @@ struct scic_sds_remote_device { | |||
132 | u32 not_ready_reason; | 130 | u32 not_ready_reason; |
133 | 131 | ||
134 | /** | 132 | /** |
135 | * This field is true if this remote device has an initialzied ready substate | ||
136 | * machine. SSP devices do not have a ready substate machine and STP devices | ||
137 | * have a ready substate machine. | ||
138 | */ | ||
139 | bool has_ready_substate_machine; | ||
140 | |||
141 | /** | ||
142 | * This field contains the state machine for the ready substate machine for | ||
143 | * this struct scic_sds_remote_device object. | ||
144 | */ | ||
145 | struct sci_base_state_machine ready_substate_machine; | ||
146 | |||
147 | /** | ||
148 | * This field maintains the set of state handlers for the remote device | 133 | * This field maintains the set of state handlers for the remote device |
149 | * object. These are changed each time the remote device enters a new state. | 134 | * object. These are changed each time the remote device enters a new state. |
150 | */ | 135 | */ |
@@ -171,10 +156,6 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, | |||
171 | struct isci_remote_device *idev); | 156 | struct isci_remote_device *idev); |
172 | void isci_remote_device_nuke_requests(struct isci_host *ihost, | 157 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
173 | struct isci_remote_device *idev); | 158 | struct isci_remote_device *idev); |
174 | void isci_remote_device_ready(struct isci_host *ihost, | ||
175 | struct isci_remote_device *idev); | ||
176 | void isci_remote_device_not_ready(struct isci_host *ihost, | ||
177 | struct isci_remote_device *idev, u32 reason); | ||
178 | void isci_remote_device_gone(struct domain_device *domain_dev); | 159 | void isci_remote_device_gone(struct domain_device *domain_dev); |
179 | int isci_remote_device_found(struct domain_device *domain_dev); | 160 | int isci_remote_device_found(struct domain_device *domain_dev); |
180 | bool isci_device_is_reset_pending(struct isci_host *ihost, | 161 | bool isci_device_is_reset_pending(struct isci_host *ihost, |
@@ -278,77 +259,6 @@ enum scic_sds_remote_device_states { | |||
278 | SCI_BASE_REMOTE_DEVICE_STATE_READY, | 259 | SCI_BASE_REMOTE_DEVICE_STATE_READY, |
279 | 260 | ||
280 | /** | 261 | /** |
281 | * This state indicates that the remote device is in the process of | ||
282 | * stopping. In this state no new IO operations are permitted, but | ||
283 | * existing IO operations are allowed to complete. | ||
284 | * This state is entered from the READY state. | ||
285 | * This state is entered from the FAILED state. | ||
286 | */ | ||
287 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | ||
288 | |||
289 | /** | ||
290 | * This state indicates that the remote device has failed. | ||
291 | * In this state no new IO operations are permitted. | ||
292 | * This state is entered from the INITIALIZING state. | ||
293 | * This state is entered from the READY state. | ||
294 | */ | ||
295 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | ||
296 | |||
297 | /** | ||
298 | * This state indicates the device is being reset. | ||
299 | * In this state no new IO operations are permitted. | ||
300 | * This state is entered from the READY state. | ||
301 | */ | ||
302 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | ||
303 | |||
304 | /** | ||
305 | * Simply the final state for the base remote device state machine. | ||
306 | */ | ||
307 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | ||
308 | }; | ||
309 | |||
310 | /** | ||
311 | * enum scic_sds_ssp_remote_device_ready_substates - | ||
312 | * | ||
313 | * This is the enumeration of the ready substates for the | ||
314 | * struct scic_sds_remote_device. | ||
315 | */ | ||
316 | enum scic_sds_ssp_remote_device_ready_substates { | ||
317 | /** | ||
318 | * This is the initial state for the remote device ready substate. | ||
319 | */ | ||
320 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, | ||
321 | |||
322 | /** | ||
323 | * This is the ready operational substate for the remote device. | ||
324 | * This is the normal operational state for a remote device. | ||
325 | */ | ||
326 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, | ||
327 | |||
328 | /** | ||
329 | * This is the suspended state for the remote device. This is the state | ||
330 | * that the device is placed in when a RNC suspend is received by | ||
331 | * the SCU hardware. | ||
332 | */ | ||
333 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, | ||
334 | |||
335 | /** | ||
336 | * This is the final state that the device is placed in before a change | ||
337 | * to the base state machine. | ||
338 | */ | ||
339 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, | ||
340 | |||
341 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES | ||
342 | }; | ||
343 | |||
344 | /** | ||
345 | * enum scic_sds_stp_remote_device_ready_substates - | ||
346 | * | ||
347 | * This is the enumeration for the struct scic_sds_remote_device ready substates | ||
348 | * for the STP remote device. | ||
349 | */ | ||
350 | enum scic_sds_stp_remote_device_ready_substates { | ||
351 | /** | ||
352 | * This is the idle substate for the stp remote device. When there are no | 262 | * This is the idle substate for the stp remote device. When there are no |
353 | * active IO for the device it is is in this state. | 263 | * active IO for the device it is is in this state. |
354 | */ | 264 | */ |
@@ -381,14 +291,7 @@ enum scic_sds_stp_remote_device_ready_substates { | |||
381 | * coming to be recovered from certain hardware specific error. | 291 | * coming to be recovered from certain hardware specific error. |
382 | */ | 292 | */ |
383 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, | 293 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, |
384 | }; | ||
385 | 294 | ||
386 | /** | ||
387 | * enum scic_sds_smp_remote_device_ready_substates - | ||
388 | * | ||
389 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. | ||
390 | */ | ||
391 | enum scic_sds_smp_remote_device_ready_substates { | ||
392 | /** | 295 | /** |
393 | * This is the ready operational substate for the remote device. This is the | 296 | * This is the ready operational substate for the remote device. This is the |
394 | * normal operational state for a remote device. | 297 | * normal operational state for a remote device. |
@@ -400,6 +303,35 @@ enum scic_sds_smp_remote_device_ready_substates { | |||
400 | * the device is placed in when a RNC suspend is received by the SCU hardware. | 303 | * the device is placed in when a RNC suspend is received by the SCU hardware. |
401 | */ | 304 | */ |
402 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | 305 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, |
306 | |||
307 | /** | ||
308 | * This state indicates that the remote device is in the process of | ||
309 | * stopping. In this state no new IO operations are permitted, but | ||
310 | * existing IO operations are allowed to complete. | ||
311 | * This state is entered from the READY state. | ||
312 | * This state is entered from the FAILED state. | ||
313 | */ | ||
314 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | ||
315 | |||
316 | /** | ||
317 | * This state indicates that the remote device has failed. | ||
318 | * In this state no new IO operations are permitted. | ||
319 | * This state is entered from the INITIALIZING state. | ||
320 | * This state is entered from the READY state. | ||
321 | */ | ||
322 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | ||
323 | |||
324 | /** | ||
325 | * This state indicates the device is being reset. | ||
326 | * In this state no new IO operations are permitted. | ||
327 | * This state is entered from the READY state. | ||
328 | */ | ||
329 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | ||
330 | |||
331 | /** | ||
332 | * Simply the final state for the base remote device state machine. | ||
333 | */ | ||
334 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | ||
403 | }; | 335 | }; |
404 | 336 | ||
405 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) | 337 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) |
@@ -541,10 +473,6 @@ struct scic_sds_remote_device_state_handler { | |||
541 | scic_sds_remote_device_frame_handler_t frame_handler; | 473 | scic_sds_remote_device_frame_handler_t frame_handler; |
542 | }; | 474 | }; |
543 | 475 | ||
544 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; | ||
545 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; | ||
546 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; | ||
547 | |||
548 | /** | 476 | /** |
549 | * scic_sds_remote_device_increment_request_count() - | 477 | * scic_sds_remote_device_increment_request_count() - |
550 | * | 478 | * |
@@ -672,92 +600,24 @@ enum sci_status scic_sds_remote_device_start_io( | |||
672 | struct scic_sds_remote_device *sci_dev, | 600 | struct scic_sds_remote_device *sci_dev, |
673 | struct scic_sds_request *io_request); | 601 | struct scic_sds_request *io_request); |
674 | 602 | ||
675 | enum sci_status scic_sds_remote_device_complete_io( | 603 | enum sci_status scic_sds_remote_device_start_task( |
676 | struct scic_sds_controller *controller, | 604 | struct scic_sds_controller *controller, |
677 | struct scic_sds_remote_device *sci_dev, | 605 | struct scic_sds_remote_device *sci_dev, |
678 | struct scic_sds_request *io_request); | 606 | struct scic_sds_request *io_request); |
679 | 607 | ||
680 | enum sci_status scic_sds_remote_device_resume( | 608 | enum sci_status scic_sds_remote_device_complete_io( |
681 | struct scic_sds_remote_device *sci_dev); | 609 | struct scic_sds_controller *controller, |
610 | struct scic_sds_remote_device *sci_dev, | ||
611 | struct scic_sds_request *io_request); | ||
682 | 612 | ||
683 | enum sci_status scic_sds_remote_device_suspend( | 613 | enum sci_status scic_sds_remote_device_suspend( |
684 | struct scic_sds_remote_device *sci_dev, | 614 | struct scic_sds_remote_device *sci_dev, |
685 | u32 suspend_type); | 615 | u32 suspend_type); |
686 | 616 | ||
687 | enum sci_status scic_sds_remote_device_start_task( | ||
688 | struct scic_sds_controller *controller, | ||
689 | struct scic_sds_remote_device *sci_dev, | ||
690 | struct scic_sds_request *io_request); | ||
691 | |||
692 | void scic_sds_remote_device_post_request( | 617 | void scic_sds_remote_device_post_request( |
693 | struct scic_sds_remote_device *sci_dev, | 618 | struct scic_sds_remote_device *sci_dev, |
694 | u32 request); | 619 | u32 request); |
695 | 620 | ||
696 | #define scic_sds_remote_device_is_atapi(sci_dev) false | 621 | #define scic_sds_remote_device_is_atapi(sci_dev) false |
697 | 622 | ||
698 | void scic_sds_remote_device_start_request( | ||
699 | struct scic_sds_remote_device *sci_dev, | ||
700 | struct scic_sds_request *sci_req, | ||
701 | enum sci_status status); | ||
702 | |||
703 | void scic_sds_remote_device_continue_request(void *sci_dev); | ||
704 | |||
705 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
706 | struct scic_sds_remote_device *sci_dev); | ||
707 | |||
708 | enum sci_status scic_sds_remote_device_default_fail_handler( | ||
709 | struct scic_sds_remote_device *sci_dev); | ||
710 | |||
711 | enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
712 | struct scic_sds_remote_device *sci_dev); | ||
713 | |||
714 | enum sci_status scic_sds_remote_device_default_reset_handler( | ||
715 | struct scic_sds_remote_device *device); | ||
716 | |||
717 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | ||
718 | struct scic_sds_remote_device *device); | ||
719 | |||
720 | enum sci_status scic_sds_remote_device_default_start_request_handler( | ||
721 | struct scic_sds_remote_device *device, | ||
722 | struct scic_sds_request *request); | ||
723 | |||
724 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | ||
725 | struct scic_sds_remote_device *device, | ||
726 | struct scic_sds_request *request); | ||
727 | |||
728 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | ||
729 | struct scic_sds_remote_device *device, | ||
730 | struct scic_sds_request *request); | ||
731 | |||
732 | enum sci_status scic_sds_remote_device_default_suspend_handler( | ||
733 | struct scic_sds_remote_device *sci_dev, | ||
734 | u32 suspend_type); | ||
735 | |||
736 | enum sci_status scic_sds_remote_device_default_resume_handler( | ||
737 | struct scic_sds_remote_device *sci_dev); | ||
738 | |||
739 | |||
740 | enum sci_status scic_sds_remote_device_default_frame_handler( | ||
741 | struct scic_sds_remote_device *sci_dev, | ||
742 | u32 frame_index); | ||
743 | |||
744 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | ||
745 | struct scic_sds_remote_device *device); | ||
746 | |||
747 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | ||
748 | struct scic_sds_remote_device *device); | ||
749 | |||
750 | enum sci_status scic_sds_remote_device_general_frame_handler( | ||
751 | struct scic_sds_remote_device *sci_dev, | ||
752 | u32 frame_index); | ||
753 | |||
754 | enum sci_status scic_sds_remote_device_general_event_handler( | ||
755 | struct scic_sds_remote_device *sci_dev, | ||
756 | u32 event_code); | ||
757 | |||
758 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( | ||
759 | struct scic_sds_remote_device *sci_dev); | ||
760 | |||
761 | |||
762 | |||
763 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ | 623 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |