diff options
author | Maciej Trela <maciej.trela@intel.com> | 2011-04-12 20:28:37 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:00:37 -0400 |
commit | 41e2b90584695cf5ae3a29eaa115e31913fbefe0 (patch) | |
tree | 060f55d9bba2887ecde8121a55a69c58238c9591 | |
parent | 0ea99d52cbcdb4bf5f5dd3097088a2919a115981 (diff) |
isci: remove base_port abstraction
Merge struct sci_base_port into scic_sds_port. Until now sci_base_port
was referenced indirectly with scic_sds_port->parent field.
'sci_base_port' state machine handlers were also incorporated into
scic_sds_port handlers.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maciej Trela <Maciej.Trela@intel.com>
Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/core/sci_base_port.h | 187 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_controller.c | 10 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port.c | 442 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port.h | 168 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port_configuration_agent.c | 2 |
5 files changed, 285 insertions, 524 deletions
diff --git a/drivers/scsi/isci/core/sci_base_port.h b/drivers/scsi/isci/core/sci_base_port.h deleted file mode 100644 index 252d48c1ab65..000000000000 --- a/drivers/scsi/isci/core/sci_base_port.h +++ /dev/null | |||
@@ -1,187 +0,0 @@ | |||
1 | /* | ||
2 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
3 | * redistributing this file, you may do so under either license. | ||
4 | * | ||
5 | * GPL LICENSE SUMMARY | ||
6 | * | ||
7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of version 2 of the GNU General Public License as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | * The full GNU General Public License is included in this distribution | ||
22 | * in the file called LICENSE.GPL. | ||
23 | * | ||
24 | * BSD LICENSE | ||
25 | * | ||
26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | ||
27 | * All rights reserved. | ||
28 | * | ||
29 | * Redistribution and use in source and binary forms, with or without | ||
30 | * modification, are permitted provided that the following conditions | ||
31 | * are met: | ||
32 | * | ||
33 | * * Redistributions of source code must retain the above copyright | ||
34 | * notice, this list of conditions and the following disclaimer. | ||
35 | * * Redistributions in binary form must reproduce the above copyright | ||
36 | * notice, this list of conditions and the following disclaimer in | ||
37 | * the documentation and/or other materials provided with the | ||
38 | * distribution. | ||
39 | * * Neither the name of Intel Corporation nor the names of its | ||
40 | * contributors may be used to endorse or promote products derived | ||
41 | * from this software without specific prior written permission. | ||
42 | * | ||
43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
54 | */ | ||
55 | |||
56 | #ifndef _SCI_BASE_PORT_H_ | ||
57 | #define _SCI_BASE_PORT_H_ | ||
58 | |||
59 | #include "sci_base_state_machine.h" | ||
60 | #include "sci_object.h" | ||
61 | |||
62 | /** | ||
63 | * enum sci_base_port_states - This enumeration depicts all the states for the | ||
64 | * common port state machine. | ||
65 | * | ||
66 | * | ||
67 | */ | ||
68 | enum sci_base_port_states { | ||
69 | /** | ||
70 | * This state indicates that the port has successfully been stopped. | ||
71 | * In this state no new IO operations are permitted. | ||
72 | * This state is entered from the STOPPING state. | ||
73 | */ | ||
74 | SCI_BASE_PORT_STATE_STOPPED, | ||
75 | |||
76 | /** | ||
77 | * This state indicates that the port is in the process of stopping. | ||
78 | * In this state no new IO operations are permitted, but existing IO | ||
79 | * operations are allowed to complete. | ||
80 | * This state is entered from the READY state. | ||
81 | */ | ||
82 | SCI_BASE_PORT_STATE_STOPPING, | ||
83 | |||
84 | /** | ||
85 | * This state indicates the port is now ready. Thus, the user is | ||
86 | * able to perform IO operations on this port. | ||
87 | * This state is entered from the STARTING state. | ||
88 | */ | ||
89 | SCI_BASE_PORT_STATE_READY, | ||
90 | |||
91 | /** | ||
92 | * This state indicates the port is in the process of performing a hard | ||
93 | * reset. Thus, the user is unable to perform IO operations on this | ||
94 | * port. | ||
95 | * This state is entered from the READY state. | ||
96 | */ | ||
97 | SCI_BASE_PORT_STATE_RESETTING, | ||
98 | |||
99 | /** | ||
100 | * This state indicates the port has failed a reset request. This state | ||
101 | * is entered when a port reset request times out. | ||
102 | * This state is entered from the RESETTING state. | ||
103 | */ | ||
104 | SCI_BASE_PORT_STATE_FAILED, | ||
105 | |||
106 | SCI_BASE_PORT_MAX_STATES | ||
107 | |||
108 | }; | ||
109 | |||
110 | /** | ||
111 | * struct sci_base_port - The base port object abstracts the fields common to | ||
112 | * all SCI port objects. | ||
113 | * | ||
114 | * | ||
115 | */ | ||
116 | struct sci_base_port { | ||
117 | /** | ||
118 | * The field specifies that the parent object for the base controller | ||
119 | * is the base object itself. | ||
120 | */ | ||
121 | struct sci_base_object parent; | ||
122 | |||
123 | /** | ||
124 | * This field contains the information for the base port state machine. | ||
125 | */ | ||
126 | struct sci_base_state_machine state_machine; | ||
127 | }; | ||
128 | |||
129 | struct sci_base_phy; | ||
130 | |||
131 | typedef enum sci_status (*sci_base_port_handler_t) ( | ||
132 | struct sci_base_port *); | ||
133 | |||
134 | typedef enum sci_status (*sci_base_port_phy_handler_t) ( | ||
135 | struct sci_base_port *, | ||
136 | struct sci_base_phy *); | ||
137 | |||
138 | typedef enum sci_status (*sci_base_port_reset_handler_t) ( | ||
139 | struct sci_base_port *, | ||
140 | u32 timeout); | ||
141 | |||
142 | /** | ||
143 | * struct sci_base_port_state_handler - This structure contains all of the | ||
144 | * state handler methods common to base port state machines. Handler | ||
145 | * methods provide the ability to change the behavior for user requests or | ||
146 | * transitions depending on the state the machine is in. | ||
147 | * | ||
148 | * | ||
149 | */ | ||
150 | struct sci_base_port_state_handler { | ||
151 | /** | ||
152 | * The start_handler specifies the method invoked when a user | ||
153 | * attempts to start a port. | ||
154 | */ | ||
155 | sci_base_port_handler_t start_handler; | ||
156 | |||
157 | /** | ||
158 | * The stop_handler specifies the method invoked when a user | ||
159 | * attempts to stop a port. | ||
160 | */ | ||
161 | sci_base_port_handler_t stop_handler; | ||
162 | |||
163 | /** | ||
164 | * The destruct_handler specifies the method invoked when attempting to | ||
165 | * destruct a port. | ||
166 | */ | ||
167 | sci_base_port_handler_t destruct_handler; | ||
168 | |||
169 | /** | ||
170 | * The reset_handler specifies the method invoked when a user | ||
171 | * attempts to hard reset a port. | ||
172 | */ | ||
173 | sci_base_port_reset_handler_t reset_handler; | ||
174 | |||
175 | /** | ||
176 | * The add_phy_handler specifies the method invoked when a user | ||
177 | * attempts to add another phy into the port. | ||
178 | */ | ||
179 | sci_base_port_phy_handler_t add_phy_handler; | ||
180 | |||
181 | /** | ||
182 | * The remove_phy_handler specifies the method invoked when a user | ||
183 | * attempts to remove a phy from the port. | ||
184 | */ | ||
185 | sci_base_port_phy_handler_t remove_phy_handler; | ||
186 | }; | ||
187 | #endif /* _SCI_BASE_PORT_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index 7a0c5905cfbe..577d1df2cfd2 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c | |||
@@ -616,10 +616,10 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller | |||
616 | 616 | ||
617 | for (index = 0; index < scic->logical_port_entries; index++) { | 617 | for (index = 0; index < scic->logical_port_entries; index++) { |
618 | struct scic_sds_port *sci_port = &scic->port_table[index]; | 618 | struct scic_sds_port *sci_port = &scic->port_table[index]; |
619 | sci_base_port_handler_t stop; | 619 | scic_sds_port_handler_t stop; |
620 | 620 | ||
621 | stop = sci_port->state_handlers->parent.stop_handler; | 621 | stop = sci_port->state_handlers->stop_handler; |
622 | port_status = stop(&sci_port->parent); | 622 | port_status = stop(sci_port); |
623 | 623 | ||
624 | if ((port_status != SCI_SUCCESS) && | 624 | if ((port_status != SCI_SUCCESS) && |
625 | (port_status != SCI_FAILURE_INVALID_STATE)) { | 625 | (port_status != SCI_FAILURE_INVALID_STATE)) { |
@@ -2860,8 +2860,8 @@ enum sci_status scic_controller_start(struct scic_sds_controller *scic, | |||
2860 | for (index = 0; index < scic->logical_port_entries; index++) { | 2860 | for (index = 0; index < scic->logical_port_entries; index++) { |
2861 | struct scic_sds_port *sci_port = &scic->port_table[index]; | 2861 | struct scic_sds_port *sci_port = &scic->port_table[index]; |
2862 | 2862 | ||
2863 | result = sci_port->state_handlers->parent.start_handler( | 2863 | result = sci_port->state_handlers->start_handler( |
2864 | &sci_port->parent); | 2864 | sci_port); |
2865 | if (result) | 2865 | if (result) |
2866 | return result; | 2866 | return result; |
2867 | } | 2867 | } |
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c index ef9cb9eb66f4..ff9ac73927a4 100644 --- a/drivers/scsi/isci/core/scic_sds_port.c +++ b/drivers/scsi/isci/core/scic_sds_port.c | |||
@@ -54,7 +54,6 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "intel_sas.h" | 56 | #include "intel_sas.h" |
57 | #include "sci_base_port.h" | ||
58 | #include "scic_controller.h" | 57 | #include "scic_controller.h" |
59 | #include "scic_phy.h" | 58 | #include "scic_phy.h" |
60 | #include "scic_port.h" | 59 | #include "scic_port.h" |
@@ -73,22 +72,6 @@ | |||
73 | #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) | 72 | #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) |
74 | #define SCU_DUMMY_INDEX (0xFFFF) | 73 | #define SCU_DUMMY_INDEX (0xFFFF) |
75 | 74 | ||
76 | static void sci_base_port_construct( | ||
77 | struct sci_base_port *base_port, | ||
78 | const struct sci_base_state *state_table) | ||
79 | { | ||
80 | base_port->parent.private = NULL; | ||
81 | sci_base_state_machine_construct( | ||
82 | &base_port->state_machine, | ||
83 | &base_port->parent, | ||
84 | state_table, | ||
85 | SCI_BASE_PORT_STATE_STOPPED | ||
86 | ); | ||
87 | |||
88 | sci_base_state_machine_start( | ||
89 | &base_port->state_machine | ||
90 | ); | ||
91 | } | ||
92 | 75 | ||
93 | /** | 76 | /** |
94 | * | 77 | * |
@@ -332,8 +315,8 @@ enum sci_status scic_sds_port_add_phy( | |||
332 | struct scic_sds_port *this_port, | 315 | struct scic_sds_port *this_port, |
333 | struct scic_sds_phy *the_phy) | 316 | struct scic_sds_phy *the_phy) |
334 | { | 317 | { |
335 | return this_port->state_handlers->parent.add_phy_handler( | 318 | return this_port->state_handlers->add_phy_handler( |
336 | &this_port->parent, &the_phy->parent); | 319 | this_port, &the_phy->parent); |
337 | } | 320 | } |
338 | 321 | ||
339 | 322 | ||
@@ -350,8 +333,8 @@ enum sci_status scic_sds_port_remove_phy( | |||
350 | struct scic_sds_port *this_port, | 333 | struct scic_sds_port *this_port, |
351 | struct scic_sds_phy *the_phy) | 334 | struct scic_sds_phy *the_phy) |
352 | { | 335 | { |
353 | return this_port->state_handlers->parent.remove_phy_handler( | 336 | return this_port->state_handlers->remove_phy_handler( |
354 | &this_port->parent, &the_phy->parent); | 337 | this_port, &the_phy->parent); |
355 | } | 338 | } |
356 | 339 | ||
357 | /** | 340 | /** |
@@ -632,8 +615,8 @@ enum sci_status scic_port_hard_reset( | |||
632 | struct scic_sds_port *port, | 615 | struct scic_sds_port *port, |
633 | u32 reset_timeout) | 616 | u32 reset_timeout) |
634 | { | 617 | { |
635 | return port->state_handlers->parent.reset_handler( | 618 | return port->state_handlers->reset_handler( |
636 | &port->parent, reset_timeout); | 619 | port, reset_timeout); |
637 | } | 620 | } |
638 | 621 | ||
639 | /** | 622 | /** |
@@ -768,7 +751,7 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port | |||
768 | if ((phy_sas_address.high == port_sas_address.high && | 751 | if ((phy_sas_address.high == port_sas_address.high && |
769 | phy_sas_address.low == port_sas_address.low) || | 752 | phy_sas_address.low == port_sas_address.low) || |
770 | sci_port->active_phy_mask == 0) { | 753 | sci_port->active_phy_mask == 0) { |
771 | struct sci_base_state_machine *sm = &sci_port->parent.state_machine; | 754 | struct sci_base_state_machine *sm = &sci_port->state_machine; |
772 | 755 | ||
773 | scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user); | 756 | scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user); |
774 | if (sm->current_state_id == SCI_BASE_PORT_STATE_RESETTING) | 757 | if (sm->current_state_id == SCI_BASE_PORT_STATE_RESETTING) |
@@ -913,7 +896,7 @@ static void scic_sds_port_timeout_handler(void *port) | |||
913 | u32 current_state; | 896 | u32 current_state; |
914 | 897 | ||
915 | current_state = sci_base_state_machine_get_state( | 898 | current_state = sci_base_state_machine_get_state( |
916 | &sci_port->parent.state_machine); | 899 | &sci_port->state_machine); |
917 | 900 | ||
918 | if (current_state == SCI_BASE_PORT_STATE_RESETTING) { | 901 | if (current_state == SCI_BASE_PORT_STATE_RESETTING) { |
919 | /* | 902 | /* |
@@ -921,7 +904,7 @@ static void scic_sds_port_timeout_handler(void *port) | |||
921 | * timeout fired before the reset completed. | 904 | * timeout fired before the reset completed. |
922 | */ | 905 | */ |
923 | sci_base_state_machine_change_state( | 906 | sci_base_state_machine_change_state( |
924 | &sci_port->parent.state_machine, | 907 | &sci_port->state_machine, |
925 | SCI_BASE_PORT_STATE_FAILED); | 908 | SCI_BASE_PORT_STATE_FAILED); |
926 | } else if (current_state == SCI_BASE_PORT_STATE_STOPPED) { | 909 | } else if (current_state == SCI_BASE_PORT_STATE_STOPPED) { |
927 | /* | 910 | /* |
@@ -1068,22 +1051,16 @@ void scic_port_enable_broadcast_change_notification( | |||
1068 | * * READY SUBSTATE HANDLERS | 1051 | * * READY SUBSTATE HANDLERS |
1069 | * **************************************************************************** */ | 1052 | * **************************************************************************** */ |
1070 | 1053 | ||
1071 | /** | 1054 | /* |
1072 | * | ||
1073 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1074 | * object. | ||
1075 | * | ||
1076 | * This method is the general ready state stop handler for the struct scic_sds_port | 1055 | * This method is the general ready state stop handler for the struct scic_sds_port |
1077 | * object. This function will transition the ready substate machine to its | 1056 | * object. This function will transition the ready substate machine to its |
1078 | * final state. enum sci_status SCI_SUCCESS | 1057 | * final state. enum sci_status SCI_SUCCESS |
1079 | */ | 1058 | */ |
1080 | static enum sci_status scic_sds_port_ready_substate_stop_handler( | 1059 | static enum sci_status scic_sds_port_ready_substate_stop_handler( |
1081 | struct sci_base_port *port) | 1060 | struct scic_sds_port *port) |
1082 | { | 1061 | { |
1083 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
1084 | |||
1085 | sci_base_state_machine_change_state( | 1062 | sci_base_state_machine_change_state( |
1086 | &this_port->parent.state_machine, | 1063 | &port->state_machine, |
1087 | SCI_BASE_PORT_STATE_STOPPING | 1064 | SCI_BASE_PORT_STATE_STOPPING |
1088 | ); | 1065 | ); |
1089 | 1066 | ||
@@ -1100,30 +1077,27 @@ static enum sci_status scic_sds_port_ready_substate_complete_io_handler( | |||
1100 | struct scic_sds_remote_device *device, | 1077 | struct scic_sds_remote_device *device, |
1101 | struct scic_sds_request *io_request) | 1078 | struct scic_sds_request *io_request) |
1102 | { | 1079 | { |
1103 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | 1080 | scic_sds_port_decrement_request_count(port); |
1104 | |||
1105 | scic_sds_port_decrement_request_count(this_port); | ||
1106 | 1081 | ||
1107 | return SCI_SUCCESS; | 1082 | return SCI_SUCCESS; |
1108 | } | 1083 | } |
1109 | 1084 | ||
1110 | static enum sci_status scic_sds_port_ready_substate_add_phy_handler( | 1085 | static enum sci_status scic_sds_port_ready_substate_add_phy_handler( |
1111 | struct sci_base_port *port, | 1086 | struct scic_sds_port *port, |
1112 | struct sci_base_phy *phy) | 1087 | struct sci_base_phy *phy) |
1113 | { | 1088 | { |
1114 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
1115 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1089 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
1116 | enum sci_status status; | 1090 | enum sci_status status; |
1117 | 1091 | ||
1118 | status = scic_sds_port_set_phy(this_port, this_phy); | 1092 | status = scic_sds_port_set_phy(port, this_phy); |
1119 | 1093 | ||
1120 | if (status == SCI_SUCCESS) { | 1094 | if (status == SCI_SUCCESS) { |
1121 | scic_sds_port_general_link_up_handler(this_port, this_phy, true); | 1095 | scic_sds_port_general_link_up_handler(port, this_phy, true); |
1122 | 1096 | ||
1123 | this_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | 1097 | port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; |
1124 | 1098 | ||
1125 | sci_base_state_machine_change_state( | 1099 | sci_base_state_machine_change_state( |
1126 | &this_port->ready_substate_machine, | 1100 | &port->ready_substate_machine, |
1127 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING | 1101 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING |
1128 | ); | 1102 | ); |
1129 | } | 1103 | } |
@@ -1133,22 +1107,21 @@ static enum sci_status scic_sds_port_ready_substate_add_phy_handler( | |||
1133 | 1107 | ||
1134 | 1108 | ||
1135 | static enum sci_status scic_sds_port_ready_substate_remove_phy_handler( | 1109 | static enum sci_status scic_sds_port_ready_substate_remove_phy_handler( |
1136 | struct sci_base_port *port, | 1110 | struct scic_sds_port *port, |
1137 | struct sci_base_phy *phy) | 1111 | struct sci_base_phy *phy) |
1138 | { | 1112 | { |
1139 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
1140 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1113 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
1141 | enum sci_status status; | 1114 | enum sci_status status; |
1142 | 1115 | ||
1143 | status = scic_sds_port_clear_phy(this_port, this_phy); | 1116 | status = scic_sds_port_clear_phy(port, this_phy); |
1144 | 1117 | ||
1145 | if (status == SCI_SUCCESS) { | 1118 | if (status == SCI_SUCCESS) { |
1146 | scic_sds_port_deactivate_phy(this_port, this_phy, true); | 1119 | scic_sds_port_deactivate_phy(port, this_phy, true); |
1147 | 1120 | ||
1148 | this_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | 1121 | port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; |
1149 | 1122 | ||
1150 | sci_base_state_machine_change_state( | 1123 | sci_base_state_machine_change_state( |
1151 | &this_port->ready_substate_machine, | 1124 | &port->ready_substate_machine, |
1152 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING | 1125 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING |
1153 | ); | 1126 | ); |
1154 | } | 1127 | } |
@@ -1204,22 +1177,16 @@ static enum sci_status scic_sds_port_ready_waiting_substate_start_io_handler( | |||
1204 | * * READY SUBSTATE OPERATIONAL HANDLERS | 1177 | * * READY SUBSTATE OPERATIONAL HANDLERS |
1205 | * **************************************************************************** */ | 1178 | * **************************************************************************** */ |
1206 | 1179 | ||
1207 | /** | 1180 | /* |
1208 | * | ||
1209 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1210 | * object. | ||
1211 | * @timeout: This is the timeout for the reset request to complete. | ||
1212 | * | ||
1213 | * This method will casue the port to reset. enum sci_status SCI_SUCCESS | 1181 | * This method will casue the port to reset. enum sci_status SCI_SUCCESS |
1214 | */ | 1182 | */ |
1215 | static enum | 1183 | static enum |
1216 | sci_status scic_sds_port_ready_operational_substate_reset_handler( | 1184 | sci_status scic_sds_port_ready_operational_substate_reset_handler( |
1217 | struct sci_base_port *port, | 1185 | struct scic_sds_port *port, |
1218 | u32 timeout) | 1186 | u32 timeout) |
1219 | { | 1187 | { |
1220 | enum sci_status status = SCI_FAILURE_INVALID_PHY; | 1188 | enum sci_status status = SCI_FAILURE_INVALID_PHY; |
1221 | u32 phy_index; | 1189 | u32 phy_index; |
1222 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | ||
1223 | struct scic_sds_phy *selected_phy = NULL; | 1190 | struct scic_sds_phy *selected_phy = NULL; |
1224 | 1191 | ||
1225 | 1192 | ||
@@ -1227,10 +1194,10 @@ sci_status scic_sds_port_ready_operational_substate_reset_handler( | |||
1227 | for (phy_index = 0; | 1194 | for (phy_index = 0; |
1228 | (phy_index < SCI_MAX_PHYS) && (selected_phy == NULL); | 1195 | (phy_index < SCI_MAX_PHYS) && (selected_phy == NULL); |
1229 | phy_index++) { | 1196 | phy_index++) { |
1230 | selected_phy = sci_port->phy_table[phy_index]; | 1197 | selected_phy = port->phy_table[phy_index]; |
1231 | 1198 | ||
1232 | if ((selected_phy != NULL) && | 1199 | if ((selected_phy != NULL) && |
1233 | !scic_sds_port_active_phy(sci_port, selected_phy)) { | 1200 | !scic_sds_port_active_phy(port, selected_phy)) { |
1234 | /* | 1201 | /* |
1235 | * We found a phy but it is not ready select | 1202 | * We found a phy but it is not ready select |
1236 | * different phy | 1203 | * different phy |
@@ -1244,12 +1211,12 @@ sci_status scic_sds_port_ready_operational_substate_reset_handler( | |||
1244 | status = scic_sds_phy_reset(selected_phy); | 1211 | status = scic_sds_phy_reset(selected_phy); |
1245 | 1212 | ||
1246 | if (status == SCI_SUCCESS) { | 1213 | if (status == SCI_SUCCESS) { |
1247 | isci_timer_start(sci_port->timer_handle, timeout); | 1214 | isci_timer_start(port->timer_handle, timeout); |
1248 | sci_port->not_ready_reason = | 1215 | port->not_ready_reason = |
1249 | SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; | 1216 | SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; |
1250 | 1217 | ||
1251 | sci_base_state_machine_change_state( | 1218 | sci_base_state_machine_change_state( |
1252 | &sci_port->parent.state_machine, | 1219 | &port->state_machine, |
1253 | SCI_BASE_PORT_STATE_RESETTING); | 1220 | SCI_BASE_PORT_STATE_RESETTING); |
1254 | } | 1221 | } |
1255 | } | 1222 | } |
@@ -1310,9 +1277,7 @@ static enum sci_status scic_sds_port_ready_operational_substate_start_io_handler | |||
1310 | struct scic_sds_remote_device *device, | 1277 | struct scic_sds_remote_device *device, |
1311 | struct scic_sds_request *io_request) | 1278 | struct scic_sds_request *io_request) |
1312 | { | 1279 | { |
1313 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | 1280 | scic_sds_port_increment_request_count(port); |
1314 | |||
1315 | scic_sds_port_increment_request_count(this_port); | ||
1316 | 1281 | ||
1317 | return SCI_SUCCESS; | 1282 | return SCI_SUCCESS; |
1318 | } | 1283 | } |
@@ -1322,32 +1287,27 @@ static enum sci_status scic_sds_port_ready_operational_substate_start_io_handler | |||
1322 | * * READY SUBSTATE OPERATIONAL HANDLERS | 1287 | * * READY SUBSTATE OPERATIONAL HANDLERS |
1323 | * **************************************************************************** */ | 1288 | * **************************************************************************** */ |
1324 | 1289 | ||
1325 | /** | 1290 | /* |
1326 | * scic_sds_port_ready_configuring_substate_add_phy_handler() - | ||
1327 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1328 | * object. | ||
1329 | * | ||
1330 | * This is the default method for a port add phy request. It will report a | 1291 | * This is the default method for a port add phy request. It will report a |
1331 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | 1292 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE |
1332 | */ | 1293 | */ |
1333 | static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler( | 1294 | static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler( |
1334 | struct sci_base_port *port, | 1295 | struct scic_sds_port *port, |
1335 | struct sci_base_phy *phy) | 1296 | struct sci_base_phy *phy) |
1336 | { | 1297 | { |
1337 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
1338 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1298 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
1339 | enum sci_status status; | 1299 | enum sci_status status; |
1340 | 1300 | ||
1341 | status = scic_sds_port_set_phy(this_port, this_phy); | 1301 | status = scic_sds_port_set_phy(port, this_phy); |
1342 | 1302 | ||
1343 | if (status == SCI_SUCCESS) { | 1303 | if (status == SCI_SUCCESS) { |
1344 | scic_sds_port_general_link_up_handler(this_port, this_phy, true); | 1304 | scic_sds_port_general_link_up_handler(port, this_phy, true); |
1345 | 1305 | ||
1346 | /* | 1306 | /* |
1347 | * Re-enter the configuring state since this may be the last phy in | 1307 | * Re-enter the configuring state since this may be the last phy in |
1348 | * the port. */ | 1308 | * the port. */ |
1349 | sci_base_state_machine_change_state( | 1309 | sci_base_state_machine_change_state( |
1350 | &this_port->ready_substate_machine, | 1310 | &port->ready_substate_machine, |
1351 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING | 1311 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING |
1352 | ); | 1312 | ); |
1353 | } | 1313 | } |
@@ -1355,32 +1315,27 @@ static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler( | |||
1355 | return status; | 1315 | return status; |
1356 | } | 1316 | } |
1357 | 1317 | ||
1358 | /** | 1318 | /* |
1359 | * scic_sds_port_ready_configuring_substate_remove_phy_handler() - | ||
1360 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1361 | * object. | ||
1362 | * | ||
1363 | * This is the default method for a port remove phy request. It will report a | 1319 | * This is the default method for a port remove phy request. It will report a |
1364 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | 1320 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE |
1365 | */ | 1321 | */ |
1366 | static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler( | 1322 | static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler( |
1367 | struct sci_base_port *port, | 1323 | struct scic_sds_port *port, |
1368 | struct sci_base_phy *phy) | 1324 | struct sci_base_phy *phy) |
1369 | { | 1325 | { |
1370 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
1371 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1326 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
1372 | enum sci_status status; | 1327 | enum sci_status status; |
1373 | 1328 | ||
1374 | status = scic_sds_port_clear_phy(this_port, this_phy); | 1329 | status = scic_sds_port_clear_phy(port, this_phy); |
1375 | 1330 | ||
1376 | if (status == SCI_SUCCESS) { | 1331 | if (status == SCI_SUCCESS) { |
1377 | scic_sds_port_deactivate_phy(this_port, this_phy, true); | 1332 | scic_sds_port_deactivate_phy(port, this_phy, true); |
1378 | 1333 | ||
1379 | /* | 1334 | /* |
1380 | * Re-enter the configuring state since this may be the last phy in | 1335 | * Re-enter the configuring state since this may be the last phy in |
1381 | * the port. */ | 1336 | * the port. */ |
1382 | sci_base_state_machine_change_state( | 1337 | sci_base_state_machine_change_state( |
1383 | &this_port->ready_substate_machine, | 1338 | &port->ready_substate_machine, |
1384 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING | 1339 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING |
1385 | ); | 1340 | ); |
1386 | } | 1341 | } |
@@ -1397,7 +1352,8 @@ static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handl | |||
1397 | * the request count goes to 0 then the port can be reprogrammed with its new | 1352 | * the request count goes to 0 then the port can be reprogrammed with its new |
1398 | * phy data. | 1353 | * phy data. |
1399 | */ | 1354 | */ |
1400 | static enum sci_status scic_sds_port_ready_configuring_substate_complete_io_handler( | 1355 | static enum sci_status |
1356 | scic_sds_port_ready_configuring_substate_complete_io_handler( | ||
1401 | struct scic_sds_port *port, | 1357 | struct scic_sds_port *port, |
1402 | struct scic_sds_remote_device *device, | 1358 | struct scic_sds_remote_device *device, |
1403 | struct scic_sds_request *io_request) | 1359 | struct scic_sds_request *io_request) |
@@ -1414,66 +1370,67 @@ static enum sci_status scic_sds_port_ready_configuring_substate_complete_io_hand | |||
1414 | return SCI_SUCCESS; | 1370 | return SCI_SUCCESS; |
1415 | } | 1371 | } |
1416 | 1372 | ||
1417 | static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func) | 1373 | static enum sci_status default_port_handler(struct scic_sds_port *sci_port, |
1374 | const char *func) | ||
1418 | { | 1375 | { |
1419 | struct scic_sds_port *sci_port; | ||
1420 | |||
1421 | sci_port = container_of(base_port, typeof(*sci_port), parent); | ||
1422 | dev_warn(sciport_to_dev(sci_port), | 1376 | dev_warn(sciport_to_dev(sci_port), |
1423 | "%s: in wrong state: %d\n", func, | 1377 | "%s: in wrong state: %d\n", func, |
1424 | sci_base_state_machine_get_state(&base_port->state_machine)); | 1378 | sci_base_state_machine_get_state(&sci_port->state_machine)); |
1425 | return SCI_FAILURE_INVALID_STATE; | 1379 | return SCI_FAILURE_INVALID_STATE; |
1426 | } | 1380 | } |
1427 | 1381 | ||
1428 | static enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port) | 1382 | static enum sci_status |
1383 | scic_sds_port_default_start_handler(struct scic_sds_port *sci_port) | ||
1429 | { | 1384 | { |
1430 | return default_port_handler(base_port, __func__); | 1385 | return default_port_handler(sci_port, __func__); |
1431 | } | 1386 | } |
1432 | 1387 | ||
1433 | static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port) | 1388 | static enum sci_status |
1389 | scic_sds_port_default_stop_handler(struct scic_sds_port *sci_port) | ||
1434 | { | 1390 | { |
1435 | return default_port_handler(base_port, __func__); | 1391 | return default_port_handler(sci_port, __func__); |
1436 | } | 1392 | } |
1437 | 1393 | ||
1438 | static enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port) | 1394 | static enum sci_status |
1395 | scic_sds_port_default_destruct_handler(struct scic_sds_port *sci_port) | ||
1439 | { | 1396 | { |
1440 | return default_port_handler(base_port, __func__); | 1397 | return default_port_handler(sci_port, __func__); |
1441 | } | 1398 | } |
1442 | 1399 | ||
1443 | static enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port, | 1400 | static enum sci_status |
1444 | u32 timeout) | 1401 | scic_sds_port_default_reset_handler(struct scic_sds_port *sci_port, |
1402 | u32 timeout) | ||
1445 | { | 1403 | { |
1446 | return default_port_handler(base_port, __func__); | 1404 | return default_port_handler(sci_port, __func__); |
1447 | } | 1405 | } |
1448 | 1406 | ||
1449 | static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port, | 1407 | static enum sci_status |
1450 | struct sci_base_phy *base_phy) | 1408 | scic_sds_port_default_add_phy_handler(struct scic_sds_port *sci_port, |
1409 | struct sci_base_phy *base_phy) | ||
1451 | { | 1410 | { |
1452 | return default_port_handler(base_port, __func__); | 1411 | return default_port_handler(sci_port, __func__); |
1453 | } | 1412 | } |
1454 | 1413 | ||
1455 | static enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port, | 1414 | static enum sci_status |
1456 | struct sci_base_phy *base_phy) | 1415 | scic_sds_port_default_remove_phy_handler(struct scic_sds_port *sci_port, |
1416 | struct sci_base_phy *base_phy) | ||
1457 | { | 1417 | { |
1458 | return default_port_handler(base_port, __func__); | 1418 | return default_port_handler(sci_port, __func__); |
1459 | } | 1419 | } |
1460 | 1420 | ||
1461 | /** | 1421 | /* |
1462 | * scic_sds_port_default_frame_handler | ||
1463 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1464 | * object. | ||
1465 | * | ||
1466 | * This is the default method for a port unsolicited frame request. It will | 1422 | * This is the default method for a port unsolicited frame request. It will |
1467 | * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even | 1423 | * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even |
1468 | * possible to receive an unsolicited frame directed to a port object? It | 1424 | * possible to receive an unsolicited frame directed to a port object? It |
1469 | * seems possible if we implementing virtual functions but until then? | 1425 | * seems possible if we implementing virtual functions but until then? |
1470 | */ | 1426 | */ |
1471 | static enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port, | 1427 | static enum sci_status |
1472 | u32 frame_index) | 1428 | scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port, |
1429 | u32 frame_index) | ||
1473 | { | 1430 | { |
1474 | struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); | 1431 | struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); |
1475 | 1432 | ||
1476 | default_port_handler(&sci_port->parent, __func__); | 1433 | default_port_handler(sci_port, __func__); |
1477 | scic_sds_controller_release_frame(scic, frame_index); | 1434 | scic_sds_controller_release_frame(scic, frame_index); |
1478 | 1435 | ||
1479 | return SCI_FAILURE_INVALID_STATE; | 1436 | return SCI_FAILURE_INVALID_STATE; |
@@ -1482,50 +1439,47 @@ static enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port | |||
1482 | static enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port, | 1439 | static enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port, |
1483 | u32 event_code) | 1440 | u32 event_code) |
1484 | { | 1441 | { |
1485 | return default_port_handler(&sci_port->parent, __func__); | 1442 | return default_port_handler(sci_port, __func__); |
1486 | } | 1443 | } |
1487 | 1444 | ||
1488 | static void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port, | 1445 | static void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port, |
1489 | struct scic_sds_phy *sci_phy) | 1446 | struct scic_sds_phy *sci_phy) |
1490 | { | 1447 | { |
1491 | default_port_handler(&sci_port->parent, __func__); | 1448 | default_port_handler(sci_port, __func__); |
1492 | } | 1449 | } |
1493 | 1450 | ||
1494 | static void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port, | 1451 | static void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port, |
1495 | struct scic_sds_phy *sci_phy) | 1452 | struct scic_sds_phy *sci_phy) |
1496 | { | 1453 | { |
1497 | default_port_handler(&sci_port->parent, __func__); | 1454 | default_port_handler(sci_port, __func__); |
1498 | } | 1455 | } |
1499 | 1456 | ||
1500 | static enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port, | 1457 | static enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port, |
1501 | struct scic_sds_remote_device *sci_dev, | 1458 | struct scic_sds_remote_device *sci_dev, |
1502 | struct scic_sds_request *sci_req) | 1459 | struct scic_sds_request *sci_req) |
1503 | { | 1460 | { |
1504 | return default_port_handler(&sci_port->parent, __func__); | 1461 | return default_port_handler(sci_port, __func__); |
1505 | } | 1462 | } |
1506 | 1463 | ||
1507 | static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port, | 1464 | static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port, |
1508 | struct scic_sds_remote_device *sci_dev, | 1465 | struct scic_sds_remote_device *sci_dev, |
1509 | struct scic_sds_request *sci_req) | 1466 | struct scic_sds_request *sci_req) |
1510 | { | 1467 | { |
1511 | return default_port_handler(&sci_port->parent, __func__); | 1468 | return default_port_handler(sci_port, __func__); |
1512 | } | 1469 | } |
1513 | 1470 | ||
1514 | 1471 | ||
1515 | 1472 | ||
1516 | static struct scic_sds_port_state_handler | 1473 | static struct scic_sds_port_state_handler |
1517 | scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] = | 1474 | scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] = { |
1518 | { | ||
1519 | /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */ | ||
1520 | { | 1475 | { |
1521 | { | 1476 | /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */ |
1522 | scic_sds_port_default_start_handler, | 1477 | scic_sds_port_default_start_handler, |
1523 | scic_sds_port_ready_substate_stop_handler, | 1478 | scic_sds_port_ready_substate_stop_handler, |
1524 | scic_sds_port_default_destruct_handler, | 1479 | scic_sds_port_default_destruct_handler, |
1525 | scic_sds_port_default_reset_handler, | 1480 | scic_sds_port_default_reset_handler, |
1526 | scic_sds_port_ready_substate_add_phy_handler, | 1481 | scic_sds_port_ready_substate_add_phy_handler, |
1527 | scic_sds_port_default_remove_phy_handler | 1482 | scic_sds_port_default_remove_phy_handler, |
1528 | }, | ||
1529 | scic_sds_port_default_frame_handler, | 1483 | scic_sds_port_default_frame_handler, |
1530 | scic_sds_port_default_event_handler, | 1484 | scic_sds_port_default_event_handler, |
1531 | scic_sds_port_ready_waiting_substate_link_up_handler, | 1485 | scic_sds_port_ready_waiting_substate_link_up_handler, |
@@ -1533,33 +1487,31 @@ scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] = | |||
1533 | scic_sds_port_ready_waiting_substate_start_io_handler, | 1487 | scic_sds_port_ready_waiting_substate_start_io_handler, |
1534 | scic_sds_port_ready_substate_complete_io_handler, | 1488 | scic_sds_port_ready_substate_complete_io_handler, |
1535 | }, | 1489 | }, |
1536 | /* SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL */ | 1490 | |
1537 | { | 1491 | { |
1538 | { | 1492 | /* SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL */ |
1539 | scic_sds_port_default_start_handler, | 1493 | scic_sds_port_default_start_handler, |
1540 | scic_sds_port_ready_substate_stop_handler, | 1494 | scic_sds_port_ready_substate_stop_handler, |
1541 | scic_sds_port_default_destruct_handler, | 1495 | scic_sds_port_default_destruct_handler, |
1542 | scic_sds_port_ready_operational_substate_reset_handler, | 1496 | scic_sds_port_ready_operational_substate_reset_handler, |
1543 | scic_sds_port_ready_substate_add_phy_handler, | 1497 | scic_sds_port_ready_substate_add_phy_handler, |
1544 | scic_sds_port_ready_substate_remove_phy_handler | 1498 | scic_sds_port_ready_substate_remove_phy_handler, |
1545 | }, | ||
1546 | scic_sds_port_default_frame_handler, | 1499 | scic_sds_port_default_frame_handler, |
1547 | scic_sds_port_default_event_handler, | 1500 | scic_sds_port_default_event_handler, |
1548 | scic_sds_port_ready_operational_substate_link_up_handler, | 1501 | scic_sds_port_ready_operational_substate_link_up_handler, |
1549 | scic_sds_port_ready_operational_substate_link_down_handler, | 1502 | scic_sds_port_ready_operational_substate_link_down_handler, |
1550 | scic_sds_port_ready_operational_substate_start_io_handler, | 1503 | scic_sds_port_ready_operational_substate_start_io_handler, |
1551 | scic_sds_port_ready_substate_complete_io_handler | 1504 | scic_sds_port_ready_substate_complete_io_handler, |
1552 | }, | 1505 | }, |
1553 | /* SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING */ | 1506 | |
1554 | { | 1507 | { |
1555 | { | 1508 | /* SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING */ |
1556 | scic_sds_port_default_start_handler, | 1509 | scic_sds_port_default_start_handler, |
1557 | scic_sds_port_ready_substate_stop_handler, | 1510 | scic_sds_port_ready_substate_stop_handler, |
1558 | scic_sds_port_default_destruct_handler, | 1511 | scic_sds_port_default_destruct_handler, |
1559 | scic_sds_port_default_reset_handler, | 1512 | scic_sds_port_default_reset_handler, |
1560 | scic_sds_port_ready_configuring_substate_add_phy_handler, | 1513 | scic_sds_port_ready_configuring_substate_add_phy_handler, |
1561 | scic_sds_port_ready_configuring_substate_remove_phy_handler | 1514 | scic_sds_port_ready_configuring_substate_remove_phy_handler, |
1562 | }, | ||
1563 | scic_sds_port_default_frame_handler, | 1515 | scic_sds_port_default_frame_handler, |
1564 | scic_sds_port_default_event_handler, | 1516 | scic_sds_port_default_event_handler, |
1565 | scic_sds_port_default_link_up_handler, | 1517 | scic_sds_port_default_link_up_handler, |
@@ -1857,9 +1809,7 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
1857 | struct scic_sds_remote_device *device, | 1809 | struct scic_sds_remote_device *device, |
1858 | struct scic_sds_request *io_request) | 1810 | struct scic_sds_request *io_request) |
1859 | { | 1811 | { |
1860 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | 1812 | scic_sds_port_decrement_request_count(port); |
1861 | |||
1862 | scic_sds_port_decrement_request_count(this_port); | ||
1863 | 1813 | ||
1864 | return SCI_SUCCESS; | 1814 | return SCI_SUCCESS; |
1865 | } | 1815 | } |
@@ -1867,7 +1817,7 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
1867 | /** | 1817 | /** |
1868 | * scic_sds_port_stopped_state_start_handler() - stop a port from "started" | 1818 | * scic_sds_port_stopped_state_start_handler() - stop a port from "started" |
1869 | * | 1819 | * |
1870 | * @port: This is the struct sci_base_port object which is cast into a | 1820 | * @port: This is the struct scic_sds_port object which is cast into a |
1871 | * struct scic_sds_port object. | 1821 | * struct scic_sds_port object. |
1872 | * | 1822 | * |
1873 | * This function takes the struct scic_sds_port from a stopped state and | 1823 | * This function takes the struct scic_sds_port from a stopped state and |
@@ -1883,10 +1833,8 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
1883 | * has transitioned to the SCI_BASE_PORT_STATE_READY. | 1833 | * has transitioned to the SCI_BASE_PORT_STATE_READY. |
1884 | */ | 1834 | */ |
1885 | static enum sci_status | 1835 | static enum sci_status |
1886 | scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) | 1836 | scic_sds_port_stopped_state_start_handler(struct scic_sds_port *sci_port) |
1887 | { | 1837 | { |
1888 | struct scic_sds_port *sci_port = | ||
1889 | container_of(base_port, typeof(*sci_port), parent); | ||
1890 | struct scic_sds_controller *scic = sci_port->owning_controller; | 1838 | struct scic_sds_controller *scic = sci_port->owning_controller; |
1891 | struct isci_host *ihost = sci_object_get_association(scic); | 1839 | struct isci_host *ihost = sci_object_get_association(scic); |
1892 | enum sci_status status = SCI_SUCCESS; | 1840 | enum sci_status status = SCI_SUCCESS; |
@@ -1941,8 +1889,9 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) | |||
1941 | * silicon. | 1889 | * silicon. |
1942 | */ | 1890 | */ |
1943 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { | 1891 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { |
1944 | sci_base_state_machine_change_state(&base_port->state_machine, | 1892 | sci_base_state_machine_change_state( |
1945 | SCI_BASE_PORT_STATE_READY); | 1893 | &sci_port->state_machine, |
1894 | SCI_BASE_PORT_STATE_READY); | ||
1946 | 1895 | ||
1947 | return SCI_SUCCESS; | 1896 | return SCI_SUCCESS; |
1948 | } else | 1897 | } else |
@@ -1955,49 +1904,33 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) | |||
1955 | return status; | 1904 | return status; |
1956 | } | 1905 | } |
1957 | 1906 | ||
1958 | /** | 1907 | /* |
1959 | * | ||
1960 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1961 | * object. | ||
1962 | * | ||
1963 | * This method takes the struct scic_sds_port that is in a stopped state and handles a | 1908 | * This method takes the struct scic_sds_port that is in a stopped state and handles a |
1964 | * stop request. This function takes no action. enum sci_status SCI_SUCCESS the | 1909 | * stop request. This function takes no action. enum sci_status SCI_SUCCESS the |
1965 | * stop request is successful as the struct scic_sds_port object is already stopped. | 1910 | * stop request is successful as the struct scic_sds_port object is already stopped. |
1966 | */ | 1911 | */ |
1967 | static enum sci_status scic_sds_port_stopped_state_stop_handler( | 1912 | static enum sci_status scic_sds_port_stopped_state_stop_handler( |
1968 | struct sci_base_port *port) | 1913 | struct scic_sds_port *port) |
1969 | { | 1914 | { |
1970 | /* We are already stopped so there is nothing to do here */ | 1915 | /* We are already stopped so there is nothing to do here */ |
1971 | return SCI_SUCCESS; | 1916 | return SCI_SUCCESS; |
1972 | } | 1917 | } |
1973 | 1918 | ||
1974 | /** | 1919 | /* |
1975 | * | ||
1976 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1977 | * object. | ||
1978 | * | ||
1979 | * This method takes the struct scic_sds_port that is in a stopped state and handles | 1920 | * This method takes the struct scic_sds_port that is in a stopped state and handles |
1980 | * the destruct request. The stopped state is the only state in which the | 1921 | * the destruct request. The stopped state is the only state in which the |
1981 | * struct scic_sds_port can be destroyed. This function causes the port object to | 1922 | * struct scic_sds_port can be destroyed. This function causes the port object to |
1982 | * transition to the SCI_BASE_PORT_STATE_FINAL. enum sci_status SCI_SUCCESS | 1923 | * transition to the SCI_BASE_PORT_STATE_FINAL. enum sci_status SCI_SUCCESS |
1983 | */ | 1924 | */ |
1984 | static enum sci_status scic_sds_port_stopped_state_destruct_handler( | 1925 | static enum sci_status scic_sds_port_stopped_state_destruct_handler( |
1985 | struct sci_base_port *port) | 1926 | struct scic_sds_port *port) |
1986 | { | 1927 | { |
1987 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | 1928 | sci_base_state_machine_stop(&port->state_machine); |
1988 | |||
1989 | sci_base_state_machine_stop(&this_port->parent.state_machine); | ||
1990 | 1929 | ||
1991 | return SCI_SUCCESS; | 1930 | return SCI_SUCCESS; |
1992 | } | 1931 | } |
1993 | 1932 | ||
1994 | /** | 1933 | /* |
1995 | * | ||
1996 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1997 | * object. | ||
1998 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | ||
1999 | * object. | ||
2000 | * | ||
2001 | * This method takes the struct scic_sds_port that is in a stopped state and handles | 1934 | * This method takes the struct scic_sds_port that is in a stopped state and handles |
2002 | * the add phy request. In MPC mode the only time a phy can be added to a port | 1935 | * the add phy request. In MPC mode the only time a phy can be added to a port |
2003 | * is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status | 1936 | * is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status |
@@ -2005,15 +1938,14 @@ static enum sci_status scic_sds_port_stopped_state_destruct_handler( | |||
2005 | * be added to the port. SCI_SUCCESS if the phy is added to the port. | 1938 | * be added to the port. SCI_SUCCESS if the phy is added to the port. |
2006 | */ | 1939 | */ |
2007 | static enum sci_status scic_sds_port_stopped_state_add_phy_handler( | 1940 | static enum sci_status scic_sds_port_stopped_state_add_phy_handler( |
2008 | struct sci_base_port *port, | 1941 | struct scic_sds_port *port, |
2009 | struct sci_base_phy *phy) | 1942 | struct sci_base_phy *phy) |
2010 | { | 1943 | { |
2011 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
2012 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1944 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
2013 | struct sci_sas_address port_sas_address; | 1945 | struct sci_sas_address port_sas_address; |
2014 | 1946 | ||
2015 | /* Read the port assigned SAS Address if there is one */ | 1947 | /* Read the port assigned SAS Address if there is one */ |
2016 | scic_sds_port_get_sas_address(this_port, &port_sas_address); | 1948 | scic_sds_port_get_sas_address(port, &port_sas_address); |
2017 | 1949 | ||
2018 | if (port_sas_address.high != 0 && port_sas_address.low != 0) { | 1950 | if (port_sas_address.high != 0 && port_sas_address.low != 0) { |
2019 | struct sci_sas_address phy_sas_address; | 1951 | struct sci_sas_address phy_sas_address; |
@@ -2031,17 +1963,11 @@ static enum sci_status scic_sds_port_stopped_state_add_phy_handler( | |||
2031 | } | 1963 | } |
2032 | } | 1964 | } |
2033 | 1965 | ||
2034 | return scic_sds_port_set_phy(this_port, this_phy); | 1966 | return scic_sds_port_set_phy(port, this_phy); |
2035 | } | 1967 | } |
2036 | 1968 | ||
2037 | 1969 | ||
2038 | /** | 1970 | /* |
2039 | * | ||
2040 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2041 | * object. | ||
2042 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | ||
2043 | * object. | ||
2044 | * | ||
2045 | * This method takes the struct scic_sds_port that is in a stopped state and handles | 1971 | * This method takes the struct scic_sds_port that is in a stopped state and handles |
2046 | * the remove phy request. In MPC mode the only time a phy can be removed from | 1972 | * the remove phy request. In MPC mode the only time a phy can be removed from |
2047 | * a port is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status | 1973 | * a port is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status |
@@ -2049,13 +1975,12 @@ static enum sci_status scic_sds_port_stopped_state_add_phy_handler( | |||
2049 | * be added to the port. SCI_SUCCESS if the phy is added to the port. | 1975 | * be added to the port. SCI_SUCCESS if the phy is added to the port. |
2050 | */ | 1976 | */ |
2051 | static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( | 1977 | static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( |
2052 | struct sci_base_port *port, | 1978 | struct scic_sds_port *port, |
2053 | struct sci_base_phy *phy) | 1979 | struct sci_base_phy *phy) |
2054 | { | 1980 | { |
2055 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
2056 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; | 1981 | struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; |
2057 | 1982 | ||
2058 | return scic_sds_port_clear_phy(this_port, this_phy); | 1983 | return scic_sds_port_clear_phy(port, this_phy); |
2059 | } | 1984 | } |
2060 | 1985 | ||
2061 | /* | 1986 | /* |
@@ -2073,16 +1998,7 @@ static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( | |||
2073 | * * STOPPING STATE HANDLERS | 1998 | * * STOPPING STATE HANDLERS |
2074 | * **************************************************************************** */ | 1999 | * **************************************************************************** */ |
2075 | 2000 | ||
2076 | /** | 2001 | /* |
2077 | * | ||
2078 | * @port: This is the struct scic_sds_port object on which the io request count will | ||
2079 | * be decremented. | ||
2080 | * @device: This is the struct scic_sds_remote_device object to which the io request | ||
2081 | * is being directed. This parameter is not required to complete this | ||
2082 | * operation. | ||
2083 | * @io_request: This is the request that is being completed on this port | ||
2084 | * object. This parameter is not required to complete this operation. | ||
2085 | * | ||
2086 | * This method takes the struct scic_sds_port that is in a stopping state and handles | 2002 | * This method takes the struct scic_sds_port that is in a stopping state and handles |
2087 | * the complete io request. Should the request count reach 0 then the port | 2003 | * the complete io request. Should the request count reach 0 then the port |
2088 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS | 2004 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS |
@@ -2095,7 +2011,7 @@ static enum sci_status scic_sds_port_stopping_state_complete_io_handler( | |||
2095 | scic_sds_port_decrement_request_count(sci_port); | 2011 | scic_sds_port_decrement_request_count(sci_port); |
2096 | 2012 | ||
2097 | if (sci_port->started_request_count == 0) { | 2013 | if (sci_port->started_request_count == 0) { |
2098 | sci_base_state_machine_change_state(&sci_port->parent.state_machine, | 2014 | sci_base_state_machine_change_state(&sci_port->state_machine, |
2099 | SCI_BASE_PORT_STATE_STOPPED); | 2015 | SCI_BASE_PORT_STATE_STOPPED); |
2100 | } | 2016 | } |
2101 | 2017 | ||
@@ -2115,29 +2031,23 @@ static enum sci_status scic_sds_port_stopping_state_complete_io_handler( | |||
2115 | * stopping state. enum sci_status SCI_SUCCESS | 2031 | * stopping state. enum sci_status SCI_SUCCESS |
2116 | */ | 2032 | */ |
2117 | static enum sci_status scic_sds_port_reset_state_stop_handler( | 2033 | static enum sci_status scic_sds_port_reset_state_stop_handler( |
2118 | struct sci_base_port *port) | 2034 | struct scic_sds_port *port) |
2119 | { | 2035 | { |
2120 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | ||
2121 | |||
2122 | sci_base_state_machine_change_state( | 2036 | sci_base_state_machine_change_state( |
2123 | &this_port->parent.state_machine, | 2037 | &port->state_machine, |
2124 | SCI_BASE_PORT_STATE_STOPPING | 2038 | SCI_BASE_PORT_STATE_STOPPING |
2125 | ); | 2039 | ); |
2126 | 2040 | ||
2127 | return SCI_SUCCESS; | 2041 | return SCI_SUCCESS; |
2128 | } | 2042 | } |
2129 | 2043 | ||
2130 | /** | 2044 | /* |
2131 | * | ||
2132 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2133 | * object. | ||
2134 | * | ||
2135 | * This method will transition a failed port to its ready state. The port | 2045 | * This method will transition a failed port to its ready state. The port |
2136 | * failed because a hard reset request timed out but at some time later one or | 2046 | * failed because a hard reset request timed out but at some time later one or |
2137 | * more phys in the port became ready. enum sci_status SCI_SUCCESS | 2047 | * more phys in the port became ready. enum sci_status SCI_SUCCESS |
2138 | */ | 2048 | */ |
2139 | static void scic_sds_port_reset_state_link_up_handler( | 2049 | static void scic_sds_port_reset_state_link_up_handler( |
2140 | struct scic_sds_port *this_port, | 2050 | struct scic_sds_port *port, |
2141 | struct scic_sds_phy *phy) | 2051 | struct scic_sds_phy *phy) |
2142 | { | 2052 | { |
2143 | /* | 2053 | /* |
@@ -2153,26 +2063,22 @@ static void scic_sds_port_reset_state_link_up_handler( | |||
2153 | /* | 2063 | /* |
2154 | * In the resetting state we don't notify the user regarding | 2064 | * In the resetting state we don't notify the user regarding |
2155 | * link up and link down notifications. */ | 2065 | * link up and link down notifications. */ |
2156 | scic_sds_port_general_link_up_handler(this_port, phy, false); | 2066 | scic_sds_port_general_link_up_handler(port, phy, false); |
2157 | } | 2067 | } |
2158 | 2068 | ||
2159 | /** | 2069 | /* |
2160 | * | ||
2161 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2162 | * object. | ||
2163 | * | ||
2164 | * This method process link down notifications that occur during a port reset | 2070 | * This method process link down notifications that occur during a port reset |
2165 | * operation. Link downs can occur during the reset operation. enum sci_status | 2071 | * operation. Link downs can occur during the reset operation. enum sci_status |
2166 | * SCI_SUCCESS | 2072 | * SCI_SUCCESS |
2167 | */ | 2073 | */ |
2168 | static void scic_sds_port_reset_state_link_down_handler( | 2074 | static void scic_sds_port_reset_state_link_down_handler( |
2169 | struct scic_sds_port *this_port, | 2075 | struct scic_sds_port *port, |
2170 | struct scic_sds_phy *phy) | 2076 | struct scic_sds_phy *phy) |
2171 | { | 2077 | { |
2172 | /* | 2078 | /* |
2173 | * In the resetting state we don't notify the user regarding | 2079 | * In the resetting state we don't notify the user regarding |
2174 | * link up and link down notifications. */ | 2080 | * link up and link down notifications. */ |
2175 | scic_sds_port_deactivate_phy(this_port, phy, false); | 2081 | scic_sds_port_deactivate_phy(port, phy, false); |
2176 | } | 2082 | } |
2177 | 2083 | ||
2178 | static struct scic_sds_port_state_handler | 2084 | static struct scic_sds_port_state_handler |
@@ -2180,14 +2086,12 @@ scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = | |||
2180 | { | 2086 | { |
2181 | /* SCI_BASE_PORT_STATE_STOPPED */ | 2087 | /* SCI_BASE_PORT_STATE_STOPPED */ |
2182 | { | 2088 | { |
2183 | { | 2089 | scic_sds_port_stopped_state_start_handler, |
2184 | scic_sds_port_stopped_state_start_handler, | 2090 | scic_sds_port_stopped_state_stop_handler, |
2185 | scic_sds_port_stopped_state_stop_handler, | 2091 | scic_sds_port_stopped_state_destruct_handler, |
2186 | scic_sds_port_stopped_state_destruct_handler, | 2092 | scic_sds_port_default_reset_handler, |
2187 | scic_sds_port_default_reset_handler, | 2093 | scic_sds_port_stopped_state_add_phy_handler, |
2188 | scic_sds_port_stopped_state_add_phy_handler, | 2094 | scic_sds_port_stopped_state_remove_phy_handler, |
2189 | scic_sds_port_stopped_state_remove_phy_handler | ||
2190 | }, | ||
2191 | scic_sds_port_default_frame_handler, | 2095 | scic_sds_port_default_frame_handler, |
2192 | scic_sds_port_default_event_handler, | 2096 | scic_sds_port_default_event_handler, |
2193 | scic_sds_port_default_link_up_handler, | 2097 | scic_sds_port_default_link_up_handler, |
@@ -2197,14 +2101,12 @@ scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = | |||
2197 | }, | 2101 | }, |
2198 | /* SCI_BASE_PORT_STATE_STOPPING */ | 2102 | /* SCI_BASE_PORT_STATE_STOPPING */ |
2199 | { | 2103 | { |
2200 | { | 2104 | scic_sds_port_default_start_handler, |
2201 | scic_sds_port_default_start_handler, | 2105 | scic_sds_port_default_stop_handler, |
2202 | scic_sds_port_default_stop_handler, | 2106 | scic_sds_port_default_destruct_handler, |
2203 | scic_sds_port_default_destruct_handler, | 2107 | scic_sds_port_default_reset_handler, |
2204 | scic_sds_port_default_reset_handler, | 2108 | scic_sds_port_default_add_phy_handler, |
2205 | scic_sds_port_default_add_phy_handler, | 2109 | scic_sds_port_default_remove_phy_handler, |
2206 | scic_sds_port_default_remove_phy_handler | ||
2207 | }, | ||
2208 | scic_sds_port_default_frame_handler, | 2110 | scic_sds_port_default_frame_handler, |
2209 | scic_sds_port_default_event_handler, | 2111 | scic_sds_port_default_event_handler, |
2210 | scic_sds_port_default_link_up_handler, | 2112 | scic_sds_port_default_link_up_handler, |
@@ -2214,14 +2116,12 @@ scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = | |||
2214 | }, | 2116 | }, |
2215 | /* SCI_BASE_PORT_STATE_READY */ | 2117 | /* SCI_BASE_PORT_STATE_READY */ |
2216 | { | 2118 | { |
2217 | { | 2119 | scic_sds_port_default_start_handler, |
2218 | scic_sds_port_default_start_handler, | 2120 | scic_sds_port_default_stop_handler, |
2219 | scic_sds_port_default_stop_handler, | 2121 | scic_sds_port_default_destruct_handler, |
2220 | scic_sds_port_default_destruct_handler, | 2122 | scic_sds_port_default_reset_handler, |
2221 | scic_sds_port_default_reset_handler, | 2123 | scic_sds_port_default_add_phy_handler, |
2222 | scic_sds_port_default_add_phy_handler, | 2124 | scic_sds_port_default_remove_phy_handler, |
2223 | scic_sds_port_default_remove_phy_handler | ||
2224 | }, | ||
2225 | scic_sds_port_default_frame_handler, | 2125 | scic_sds_port_default_frame_handler, |
2226 | scic_sds_port_default_event_handler, | 2126 | scic_sds_port_default_event_handler, |
2227 | scic_sds_port_default_link_up_handler, | 2127 | scic_sds_port_default_link_up_handler, |
@@ -2231,14 +2131,12 @@ scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = | |||
2231 | }, | 2131 | }, |
2232 | /* SCI_BASE_PORT_STATE_RESETTING */ | 2132 | /* SCI_BASE_PORT_STATE_RESETTING */ |
2233 | { | 2133 | { |
2234 | { | 2134 | scic_sds_port_default_start_handler, |
2235 | scic_sds_port_default_start_handler, | 2135 | scic_sds_port_reset_state_stop_handler, |
2236 | scic_sds_port_reset_state_stop_handler, | 2136 | scic_sds_port_default_destruct_handler, |
2237 | scic_sds_port_default_destruct_handler, | 2137 | scic_sds_port_default_reset_handler, |
2238 | scic_sds_port_default_reset_handler, | 2138 | scic_sds_port_default_add_phy_handler, |
2239 | scic_sds_port_default_add_phy_handler, | 2139 | scic_sds_port_default_remove_phy_handler, |
2240 | scic_sds_port_default_remove_phy_handler | ||
2241 | }, | ||
2242 | scic_sds_port_default_frame_handler, | 2140 | scic_sds_port_default_frame_handler, |
2243 | scic_sds_port_default_event_handler, | 2141 | scic_sds_port_default_event_handler, |
2244 | scic_sds_port_reset_state_link_up_handler, | 2142 | scic_sds_port_reset_state_link_up_handler, |
@@ -2248,14 +2146,12 @@ scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = | |||
2248 | }, | 2146 | }, |
2249 | /* SCI_BASE_PORT_STATE_FAILED */ | 2147 | /* SCI_BASE_PORT_STATE_FAILED */ |
2250 | { | 2148 | { |
2251 | { | 2149 | scic_sds_port_default_start_handler, |
2252 | scic_sds_port_default_start_handler, | 2150 | scic_sds_port_default_stop_handler, |
2253 | scic_sds_port_default_stop_handler, | 2151 | scic_sds_port_default_destruct_handler, |
2254 | scic_sds_port_default_destruct_handler, | 2152 | scic_sds_port_default_reset_handler, |
2255 | scic_sds_port_default_reset_handler, | 2153 | scic_sds_port_default_add_phy_handler, |
2256 | scic_sds_port_default_add_phy_handler, | 2154 | scic_sds_port_default_remove_phy_handler, |
2257 | scic_sds_port_default_remove_phy_handler | ||
2258 | }, | ||
2259 | scic_sds_port_default_frame_handler, | 2155 | scic_sds_port_default_frame_handler, |
2260 | scic_sds_port_default_event_handler, | 2156 | scic_sds_port_default_event_handler, |
2261 | scic_sds_port_default_link_up_handler, | 2157 | scic_sds_port_default_link_up_handler, |
@@ -2385,7 +2281,7 @@ static void scic_sds_port_stopped_state_enter( | |||
2385 | 2281 | ||
2386 | if ( | 2282 | if ( |
2387 | SCI_BASE_PORT_STATE_STOPPING | 2283 | SCI_BASE_PORT_STATE_STOPPING |
2388 | == this_port->parent.state_machine.previous_state_id | 2284 | == this_port->state_machine.previous_state_id |
2389 | ) { | 2285 | ) { |
2390 | /* | 2286 | /* |
2391 | * If we enter this state becasuse of a request to stop | 2287 | * If we enter this state becasuse of a request to stop |
@@ -2431,7 +2327,7 @@ static void scic_sds_port_ready_state_enter(struct sci_base_object *object) | |||
2431 | struct isci_host *ihost; | 2327 | struct isci_host *ihost; |
2432 | u32 prev_state; | 2328 | u32 prev_state; |
2433 | 2329 | ||
2434 | sci_port = container_of(object, typeof(*sci_port), parent.parent); | 2330 | sci_port = container_of(object, typeof(*sci_port), parent); |
2435 | scic = scic_sds_port_get_controller(sci_port); | 2331 | scic = scic_sds_port_get_controller(sci_port); |
2436 | ihost = sci_object_get_association(scic); | 2332 | ihost = sci_object_get_association(scic); |
2437 | iport = sci_object_get_association(sci_port); | 2333 | iport = sci_object_get_association(sci_port); |
@@ -2439,7 +2335,7 @@ static void scic_sds_port_ready_state_enter(struct sci_base_object *object) | |||
2439 | /* Put the ready state handlers in place though they will not be there long */ | 2335 | /* Put the ready state handlers in place though they will not be there long */ |
2440 | scic_sds_port_set_base_state_handlers(sci_port, SCI_BASE_PORT_STATE_READY); | 2336 | scic_sds_port_set_base_state_handlers(sci_port, SCI_BASE_PORT_STATE_READY); |
2441 | 2337 | ||
2442 | prev_state = sci_port->parent.state_machine.previous_state_id; | 2338 | prev_state = sci_port->state_machine.previous_state_id; |
2443 | if (prev_state == SCI_BASE_PORT_STATE_RESETTING) | 2339 | if (prev_state == SCI_BASE_PORT_STATE_RESETTING) |
2444 | isci_port_hard_reset_complete(iport, SCI_SUCCESS); | 2340 | isci_port_hard_reset_complete(iport, SCI_SUCCESS); |
2445 | else | 2341 | else |
@@ -2456,7 +2352,7 @@ static void scic_sds_port_ready_state_exit(struct sci_base_object *object) | |||
2456 | { | 2352 | { |
2457 | struct scic_sds_port *sci_port; | 2353 | struct scic_sds_port *sci_port; |
2458 | 2354 | ||
2459 | sci_port = container_of(object, typeof(*sci_port), parent.parent); | 2355 | sci_port = container_of(object, typeof(*sci_port), parent); |
2460 | sci_base_state_machine_stop(&sci_port->ready_substate_machine); | 2356 | sci_base_state_machine_stop(&sci_port->ready_substate_machine); |
2461 | scic_sds_port_invalidate_dummy_remote_node(sci_port); | 2357 | scic_sds_port_invalidate_dummy_remote_node(sci_port); |
2462 | } | 2358 | } |
@@ -2587,10 +2483,16 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index, | |||
2587 | { | 2483 | { |
2588 | u32 index; | 2484 | u32 index; |
2589 | 2485 | ||
2590 | sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table); | 2486 | sci_port->parent.private = NULL; |
2487 | sci_base_state_machine_construct(&sci_port->state_machine, | ||
2488 | &sci_port->parent, | ||
2489 | scic_sds_port_state_table, | ||
2490 | SCI_BASE_PORT_STATE_STOPPED); | ||
2491 | |||
2492 | sci_base_state_machine_start(&sci_port->state_machine); | ||
2591 | 2493 | ||
2592 | sci_base_state_machine_construct(&sci_port->ready_substate_machine, | 2494 | sci_base_state_machine_construct(&sci_port->ready_substate_machine, |
2593 | &sci_port->parent.parent, | 2495 | &sci_port->parent, |
2594 | scic_sds_port_ready_substate_table, | 2496 | scic_sds_port_ready_substate_table, |
2595 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING); | 2497 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING); |
2596 | 2498 | ||
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h index 4cd6bbb0b570..528c84d569a0 100644 --- a/drivers/scsi/isci/core/scic_sds_port.h +++ b/drivers/scsi/isci/core/scic_sds_port.h | |||
@@ -56,22 +56,19 @@ | |||
56 | #ifndef _SCIC_SDS_PORT_H_ | 56 | #ifndef _SCIC_SDS_PORT_H_ |
57 | #define _SCIC_SDS_PORT_H_ | 57 | #define _SCIC_SDS_PORT_H_ |
58 | 58 | ||
59 | /** | ||
60 | * This file contains the structures, constants and prototypes for the | ||
61 | * struct scic_sds_port object. | ||
62 | * | ||
63 | * | ||
64 | */ | ||
65 | |||
66 | #include <linux/kernel.h> | 59 | #include <linux/kernel.h> |
67 | #include "sci_controller_constants.h" | 60 | #include "sci_controller_constants.h" |
68 | #include "intel_sas.h" | 61 | #include "intel_sas.h" |
69 | #include "sci_base_port.h" | ||
70 | #include "sci_base_phy.h" | 62 | #include "sci_base_phy.h" |
71 | #include "scu_registers.h" | 63 | #include "scu_registers.h" |
72 | 64 | ||
73 | #define SCIC_SDS_DUMMY_PORT 0xFF | 65 | #define SCIC_SDS_DUMMY_PORT 0xFF |
74 | 66 | ||
67 | struct scic_sds_controller; | ||
68 | struct scic_sds_phy; | ||
69 | struct scic_sds_remote_device; | ||
70 | struct scic_sds_request; | ||
71 | |||
75 | /** | 72 | /** |
76 | * This constant defines the value utilized by SCI Components to indicate | 73 | * This constant defines the value utilized by SCI Components to indicate |
77 | * an invalid handle. | 74 | * an invalid handle. |
@@ -107,10 +104,53 @@ enum scic_sds_port_ready_substates { | |||
107 | SCIC_SDS_PORT_READY_MAX_SUBSTATES | 104 | SCIC_SDS_PORT_READY_MAX_SUBSTATES |
108 | }; | 105 | }; |
109 | 106 | ||
110 | struct scic_sds_controller; | 107 | /** |
111 | struct scic_sds_phy; | 108 | * enum scic_sds_port_states - This enumeration depicts all the states for the |
112 | struct scic_sds_remote_device; | 109 | * common port state machine. |
113 | struct scic_sds_request; | 110 | * |
111 | * | ||
112 | */ | ||
113 | enum scic_sds_port_states { | ||
114 | /** | ||
115 | * This state indicates that the port has successfully been stopped. | ||
116 | * In this state no new IO operations are permitted. | ||
117 | * This state is entered from the STOPPING state. | ||
118 | */ | ||
119 | SCI_BASE_PORT_STATE_STOPPED, | ||
120 | |||
121 | /** | ||
122 | * This state indicates that the port is in the process of stopping. | ||
123 | * In this state no new IO operations are permitted, but existing IO | ||
124 | * operations are allowed to complete. | ||
125 | * This state is entered from the READY state. | ||
126 | */ | ||
127 | SCI_BASE_PORT_STATE_STOPPING, | ||
128 | |||
129 | /** | ||
130 | * This state indicates the port is now ready. Thus, the user is | ||
131 | * able to perform IO operations on this port. | ||
132 | * This state is entered from the STARTING state. | ||
133 | */ | ||
134 | SCI_BASE_PORT_STATE_READY, | ||
135 | |||
136 | /** | ||
137 | * This state indicates the port is in the process of performing a hard | ||
138 | * reset. Thus, the user is unable to perform IO operations on this | ||
139 | * port. | ||
140 | * This state is entered from the READY state. | ||
141 | */ | ||
142 | SCI_BASE_PORT_STATE_RESETTING, | ||
143 | |||
144 | /** | ||
145 | * This state indicates the port has failed a reset request. This state | ||
146 | * is entered when a port reset request times out. | ||
147 | * This state is entered from the RESETTING state. | ||
148 | */ | ||
149 | SCI_BASE_PORT_STATE_FAILED, | ||
150 | |||
151 | SCI_BASE_PORT_MAX_STATES | ||
152 | |||
153 | }; | ||
114 | 154 | ||
115 | /** | 155 | /** |
116 | * struct scic_sds_port - | 156 | * struct scic_sds_port - |
@@ -119,9 +159,15 @@ struct scic_sds_request; | |||
119 | */ | 159 | */ |
120 | struct scic_sds_port { | 160 | struct scic_sds_port { |
121 | /** | 161 | /** |
122 | * This field is the oommon base port object. | 162 | * The field specifies that the parent object for the base controller |
163 | * is the base object itself. | ||
123 | */ | 164 | */ |
124 | struct sci_base_port parent; | 165 | struct sci_base_object parent; |
166 | |||
167 | /** | ||
168 | * This field contains the information for the base port state machine. | ||
169 | */ | ||
170 | struct sci_base_state_machine state_machine; | ||
125 | 171 | ||
126 | /** | 172 | /** |
127 | * This field is the port index that is reported to the SCI USER. | 173 | * This field is the port index that is reported to the SCI USER. |
@@ -214,6 +260,15 @@ struct scic_sds_port { | |||
214 | 260 | ||
215 | }; | 261 | }; |
216 | 262 | ||
263 | struct sci_base_phy; | ||
264 | |||
265 | typedef enum sci_status (*scic_sds_port_handler_t)(struct scic_sds_port *); | ||
266 | |||
267 | typedef enum sci_status (*scic_sds_port_phy_handler_t)(struct scic_sds_port *, | ||
268 | struct sci_base_phy *); | ||
269 | |||
270 | typedef enum sci_status (*scic_sds_port_reset_handler_t)(struct scic_sds_port *, | ||
271 | u32 timeout); | ||
217 | 272 | ||
218 | typedef enum sci_status (*scic_sds_port_event_handler_t)(struct scic_sds_port *, u32); | 273 | typedef enum sci_status (*scic_sds_port_event_handler_t)(struct scic_sds_port *, u32); |
219 | 274 | ||
@@ -221,13 +276,46 @@ typedef enum sci_status (*scic_sds_port_frame_handler_t)(struct scic_sds_port *, | |||
221 | 276 | ||
222 | typedef void (*scic_sds_port_link_handler_t)(struct scic_sds_port *, struct scic_sds_phy *); | 277 | typedef void (*scic_sds_port_link_handler_t)(struct scic_sds_port *, struct scic_sds_phy *); |
223 | 278 | ||
224 | typedef enum sci_status (*scic_sds_port_io_request_handler_t)( | 279 | typedef enum sci_status (*scic_sds_port_io_request_handler_t)(struct scic_sds_port *, |
225 | struct scic_sds_port *, | 280 | struct scic_sds_remote_device *, |
226 | struct scic_sds_remote_device *, | 281 | struct scic_sds_request *); |
227 | struct scic_sds_request *); | ||
228 | 282 | ||
229 | struct scic_sds_port_state_handler { | 283 | struct scic_sds_port_state_handler { |
230 | struct sci_base_port_state_handler parent; | 284 | /** |
285 | * The start_handler specifies the method invoked when a user | ||
286 | * attempts to start a port. | ||
287 | */ | ||
288 | scic_sds_port_handler_t start_handler; | ||
289 | |||
290 | /** | ||
291 | * The stop_handler specifies the method invoked when a user | ||
292 | * attempts to stop a port. | ||
293 | */ | ||
294 | scic_sds_port_handler_t stop_handler; | ||
295 | |||
296 | /** | ||
297 | * The destruct_handler specifies the method invoked when attempting to | ||
298 | * destruct a port. | ||
299 | */ | ||
300 | scic_sds_port_handler_t destruct_handler; | ||
301 | |||
302 | /** | ||
303 | * The reset_handler specifies the method invoked when a user | ||
304 | * attempts to hard reset a port. | ||
305 | */ | ||
306 | scic_sds_port_reset_handler_t reset_handler; | ||
307 | |||
308 | /** | ||
309 | * The add_phy_handler specifies the method invoked when a user | ||
310 | * attempts to add another phy into the port. | ||
311 | */ | ||
312 | scic_sds_port_phy_handler_t add_phy_handler; | ||
313 | |||
314 | /** | ||
315 | * The remove_phy_handler specifies the method invoked when a user | ||
316 | * attempts to remove a phy from the port. | ||
317 | */ | ||
318 | scic_sds_port_phy_handler_t remove_phy_handler; | ||
231 | 319 | ||
232 | scic_sds_port_frame_handler_t frame_handler; | 320 | scic_sds_port_frame_handler_t frame_handler; |
233 | scic_sds_port_event_handler_t event_handler; | 321 | scic_sds_port_event_handler_t event_handler; |
@@ -292,15 +380,6 @@ static inline void scic_sds_port_decrement_request_count(struct scic_sds_port *s | |||
292 | #define scic_sds_port_active_phy(port, phy) \ | 380 | #define scic_sds_port_active_phy(port, phy) \ |
293 | (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0) | 381 | (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0) |
294 | 382 | ||
295 | /* --------------------------------------------------------------------------- */ | ||
296 | |||
297 | |||
298 | |||
299 | |||
300 | /* --------------------------------------------------------------------------- */ | ||
301 | |||
302 | /* --------------------------------------------------------------------------- */ | ||
303 | |||
304 | void scic_sds_port_construct( | 383 | void scic_sds_port_construct( |
305 | struct scic_sds_port *this_port, | 384 | struct scic_sds_port *this_port, |
306 | u8 port_index, | 385 | u8 port_index, |
@@ -312,8 +391,6 @@ enum sci_status scic_sds_port_initialize( | |||
312 | void __iomem *port_configuration_regsiter, | 391 | void __iomem *port_configuration_regsiter, |
313 | void __iomem *viit_registers); | 392 | void __iomem *viit_registers); |
314 | 393 | ||
315 | /* --------------------------------------------------------------------------- */ | ||
316 | |||
317 | enum sci_status scic_sds_port_add_phy( | 394 | enum sci_status scic_sds_port_add_phy( |
318 | struct scic_sds_port *this_port, | 395 | struct scic_sds_port *this_port, |
319 | struct scic_sds_phy *the_phy); | 396 | struct scic_sds_phy *the_phy); |
@@ -332,9 +409,6 @@ void scic_sds_port_deactivate_phy( | |||
332 | struct scic_sds_phy *phy, | 409 | struct scic_sds_phy *phy, |
333 | bool do_notify_user); | 410 | bool do_notify_user); |
334 | 411 | ||
335 | |||
336 | |||
337 | |||
338 | bool scic_sds_port_link_detected( | 412 | bool scic_sds_port_link_detected( |
339 | struct scic_sds_port *this_port, | 413 | struct scic_sds_port *this_port, |
340 | struct scic_sds_phy *phy); | 414 | struct scic_sds_phy *phy); |
@@ -347,11 +421,6 @@ void scic_sds_port_link_down( | |||
347 | struct scic_sds_port *this_port, | 421 | struct scic_sds_port *this_port, |
348 | struct scic_sds_phy *phy); | 422 | struct scic_sds_phy *phy); |
349 | 423 | ||
350 | /* --------------------------------------------------------------------------- */ | ||
351 | |||
352 | |||
353 | /* --------------------------------------------------------------------------- */ | ||
354 | |||
355 | enum sci_status scic_sds_port_start_io( | 424 | enum sci_status scic_sds_port_start_io( |
356 | struct scic_sds_port *this_port, | 425 | struct scic_sds_port *this_port, |
357 | struct scic_sds_remote_device *the_device, | 426 | struct scic_sds_remote_device *the_device, |
@@ -362,23 +431,6 @@ enum sci_status scic_sds_port_complete_io( | |||
362 | struct scic_sds_remote_device *the_device, | 431 | struct scic_sds_remote_device *the_device, |
363 | struct scic_sds_request *the_io_request); | 432 | struct scic_sds_request *the_io_request); |
364 | 433 | ||
365 | /* --------------------------------------------------------------------------- */ | ||
366 | |||
367 | |||
368 | /* --------------------------------------------------------------------------- */ | ||
369 | |||
370 | |||
371 | |||
372 | |||
373 | |||
374 | |||
375 | |||
376 | |||
377 | |||
378 | |||
379 | |||
380 | |||
381 | |||
382 | enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed( | 434 | enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed( |
383 | struct scic_sds_port *this_port); | 435 | struct scic_sds_port *this_port); |
384 | 436 | ||
@@ -390,8 +442,6 @@ bool scic_sds_port_is_valid_phy_assignment( | |||
390 | struct scic_sds_port *this_port, | 442 | struct scic_sds_port *this_port, |
391 | u32 phy_index); | 443 | u32 phy_index); |
392 | 444 | ||
393 | |||
394 | |||
395 | void scic_sds_port_get_sas_address( | 445 | void scic_sds_port_get_sas_address( |
396 | struct scic_sds_port *this_port, | 446 | struct scic_sds_port *this_port, |
397 | struct sci_sas_address *sas_address); | 447 | struct sci_sas_address *sas_address); |
@@ -404,8 +454,4 @@ void scic_sds_port_get_attached_protocols( | |||
404 | struct scic_sds_port *this_port, | 454 | struct scic_sds_port *this_port, |
405 | struct sci_sas_identify_address_frame_protocols *protocols); | 455 | struct sci_sas_identify_address_frame_protocols *protocols); |
406 | 456 | ||
407 | |||
408 | |||
409 | |||
410 | |||
411 | #endif /* _SCIC_SDS_PORT_H_ */ | 457 | #endif /* _SCIC_SDS_PORT_H_ */ |
diff --git a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c index 22703b372c64..a7e3833b1d56 100644 --- a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c +++ b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c | |||
@@ -700,7 +700,7 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic, | |||
700 | scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true); | 700 | scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true); |
701 | } else { | 701 | } else { |
702 | /* the phy is already the part of the port */ | 702 | /* the phy is already the part of the port */ |
703 | u32 port_state = sci_port->parent.state_machine.current_state_id; | 703 | u32 port_state = sci_port->state_machine.current_state_id; |
704 | 704 | ||
705 | /* if the PORT'S state is resetting then the link up is from | 705 | /* if the PORT'S state is resetting then the link up is from |
706 | * port hard reset in this case, we need to tell the port | 706 | * port hard reset in this case, we need to tell the port |