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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
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.
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.
56 #include "intel_sas.h"
57 #include "sci_base_port.h"
58 #include "scic_controller.h"
60 #include "scic_port.h"
61 #include "scic_sds_controller.h"
62 #include "scic_sds_phy.h"
63 #include "scic_sds_phy_registers.h"
64 #include "scic_sds_port.h"
65 #include "scic_sds_port_registers.h"
66 #include "scic_sds_remote_device.h"
67 #include "scic_sds_remote_node_context.h"
68 #include "scic_sds_request.h"
69 #include "sci_environment.h"
72 static void scic_sds_port_invalid_link_up(
73 struct scic_sds_port
*this_port
,
74 struct scic_sds_phy
*phy
);
75 static void scic_sds_port_timeout_handler(
77 #define SCIC_SDS_PORT_MIN_TIMER_COUNT (SCI_MAX_PORTS)
78 #define SCIC_SDS_PORT_MAX_TIMER_COUNT (SCI_MAX_PORTS)
80 #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
82 void sci_base_port_construct(
83 struct sci_base_port
*base_port
,
84 const struct sci_base_state
*state_table
)
86 base_port
->parent
.private = NULL
;
87 sci_base_state_machine_construct(
88 &base_port
->state_machine
,
91 SCI_BASE_PORT_STATE_STOPPED
94 sci_base_state_machine_start(
95 &base_port
->state_machine
101 * @this_port: This is the port object to which the phy is being assigned.
102 * @phy_index: This is the phy index that is being assigned to the port.
104 * This method will return a true value if the specified phy can be assigned to
105 * this port The following is a list of phys for each port that are allowed: -
106 * Port 0 - 3 2 1 0 - Port 1 - 1 - Port 2 - 3 2 - Port 3 - 3 This method
107 * doesn't preclude all configurations. It merely ensures that a phy is part
108 * of the allowable set of phy identifiers for that port. For example, one
109 * could assign phy 3 to port 0 and no other phys. Please refer to
110 * scic_sds_port_is_phy_mask_valid() for information regarding whether the
111 * phy_mask for a port can be supported. bool true if this is a valid phy
112 * assignment for the port false if this is not a valid phy assignment for the
115 bool scic_sds_port_is_valid_phy_assignment(
116 struct scic_sds_port
*this_port
,
119 /* Initialize to invalid value. */
120 u32 existing_phy_index
= SCI_MAX_PHYS
;
123 if ((this_port
->physical_port_index
== 1) && (phy_index
!= 1)) {
127 if (this_port
->physical_port_index
== 3 && phy_index
!= 3) {
132 (this_port
->physical_port_index
== 2)
133 && ((phy_index
== 0) || (phy_index
== 1))
138 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
139 if ((this_port
->phy_table
[index
] != NULL
)
140 && (index
!= phy_index
)) {
141 existing_phy_index
= index
;
146 * Ensure that all of the phys in the port are capable of
147 * operating at the same maximum link rate. */
149 (existing_phy_index
< SCI_MAX_PHYS
)
150 && (this_port
->owning_controller
->user_parameters
.sds1
.phys
[
151 phy_index
].max_speed_generation
!=
152 this_port
->owning_controller
->user_parameters
.sds1
.phys
[
153 existing_phy_index
].max_speed_generation
)
161 * This method requests a list (mask) of the phys contained in the supplied SAS
163 * @this_port: a handle corresponding to the SAS port for which to return the
166 * Return a bit mask indicating which phys are a part of this port. Each bit
167 * corresponds to a phy identifier (e.g. bit 0 = phy id 0).
169 u32
scic_sds_port_get_phys(struct scic_sds_port
*this_port
)
176 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
177 if (this_port
->phy_table
[index
] != NULL
) {
178 mask
|= (1 << index
);
187 * @this_port: This is the port object for which to determine if the phy mask
190 * This method will return a true value if the port's phy mask can be supported
191 * by the SCU. The following is a list of valid PHY mask configurations for
192 * each port: - Port 0 - [[3 2] 1] 0 - Port 1 - [1] - Port 2 - [[3] 2]
193 * - Port 3 - [3] This method returns a boolean indication specifying if the
194 * phy mask can be supported. true if this is a valid phy assignment for the
195 * port false if this is not a valid phy assignment for the port
197 bool scic_sds_port_is_phy_mask_valid(
198 struct scic_sds_port
*this_port
,
201 if (this_port
->physical_port_index
== 0) {
202 if (((phy_mask
& 0x0F) == 0x0F)
203 || ((phy_mask
& 0x03) == 0x03)
204 || ((phy_mask
& 0x01) == 0x01)
207 } else if (this_port
->physical_port_index
== 1) {
208 if (((phy_mask
& 0x02) == 0x02)
211 } else if (this_port
->physical_port_index
== 2) {
212 if (((phy_mask
& 0x0C) == 0x0C)
213 || ((phy_mask
& 0x04) == 0x04)
216 } else if (this_port
->physical_port_index
== 3) {
217 if (((phy_mask
& 0x08) == 0x08)
227 * @this_port: This parameter specifies the port from which to return a
230 * This method retrieves a currently active (i.e. connected) phy contained in
231 * the port. Currently, the lowest order phy that is connected is returned.
232 * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is
233 * returned if there are no currently active (i.e. connected to a remote end
234 * point) phys contained in the port. All other values specify a struct scic_sds_phy
235 * object that is active in the port.
237 static struct scic_sds_phy
*scic_sds_port_get_a_connected_phy(
238 struct scic_sds_port
*this_port
241 struct scic_sds_phy
*phy
;
243 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
245 * Ensure that the phy is both part of the port and currently
246 * connected to the remote end-point. */
247 phy
= this_port
->phy_table
[index
];
250 && scic_sds_port_active_phy(this_port
, phy
)
260 * scic_sds_port_set_phy() -
261 * @out]: port The port object to which the phy assignement is being made.
262 * @out]: phy The phy which is being assigned to the port.
264 * This method attempts to make the assignment of the phy to the port. If
265 * successful the phy is assigned to the ports phy table. bool true if the phy
266 * assignment can be made. false if the phy assignement can not be made. This
267 * is a functional test that only fails if the phy is currently assigned to a
270 enum sci_status
scic_sds_port_set_phy(
271 struct scic_sds_port
*port
,
272 struct scic_sds_phy
*phy
)
275 * Check to see if we can add this phy to a port
276 * that means that the phy is not part of a port and that the port does
277 * not already have a phy assinged to the phy index. */
279 (port
->phy_table
[phy
->phy_index
] == NULL
)
280 && (scic_sds_phy_get_port(phy
) == NULL
)
281 && scic_sds_port_is_valid_phy_assignment(port
, phy
->phy_index
)
284 * Phy is being added in the stopped state so we are in MPC mode
285 * make logical port index = physical port index */
286 port
->logical_port_index
= port
->physical_port_index
;
287 port
->phy_table
[phy
->phy_index
] = phy
;
288 scic_sds_phy_set_port(phy
, port
);
297 * scic_sds_port_clear_phy() -
298 * @out]: port The port from which the phy is being cleared.
299 * @out]: phy The phy being cleared from the port.
301 * This method will clear the phy assigned to this port. This method fails if
302 * this phy is not currently assinged to this port. bool true if the phy is
303 * removed from the port. false if this phy is not assined to this port.
305 enum sci_status
scic_sds_port_clear_phy(
306 struct scic_sds_port
*port
,
307 struct scic_sds_phy
*phy
)
309 /* Make sure that this phy is part of this port */
311 (port
->phy_table
[phy
->phy_index
] == phy
)
312 && (scic_sds_phy_get_port(phy
) == port
)
314 /* Yep it is assigned to this port so remove it */
315 scic_sds_phy_set_port(
317 &scic_sds_port_get_controller(port
)->port_table
[SCI_MAX_PORTS
]
320 port
->phy_table
[phy
->phy_index
] = NULL
;
329 * scic_sds_port_add_phy() -
330 * @this_port: This parameter specifies the port in which the phy will be added.
331 * @the_phy: This parameter is the phy which is to be added to the port.
333 * This method will add a PHY to the selected port. This method returns an
334 * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other status
335 * is failre to add the phy to the port.
337 enum sci_status
scic_sds_port_add_phy(
338 struct scic_sds_port
*this_port
,
339 struct scic_sds_phy
*the_phy
)
341 return this_port
->state_handlers
->parent
.add_phy_handler(
342 &this_port
->parent
, &the_phy
->parent
);
347 * scic_sds_port_remove_phy() -
348 * @this_port: This parameter specifies the port in which the phy will be added.
349 * @the_phy: This parameter is the phy which is to be added to the port.
351 * This method will remove the PHY from the selected PORT. This method returns
352 * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any other
353 * status is failre to add the phy to the port.
355 enum sci_status
scic_sds_port_remove_phy(
356 struct scic_sds_port
*this_port
,
357 struct scic_sds_phy
*the_phy
)
359 return this_port
->state_handlers
->parent
.remove_phy_handler(
360 &this_port
->parent
, &the_phy
->parent
);
364 * This method requests the SAS address for the supplied SAS port from the SCI
366 * @this_port: a handle corresponding to the SAS port for which to return the
368 * @sas_address: This parameter specifies a pointer to a SAS address structure
369 * into which the core will copy the SAS address for the port.
372 void scic_sds_port_get_sas_address(
373 struct scic_sds_port
*this_port
,
374 struct sci_sas_address
*sas_address
)
378 sas_address
->high
= 0;
379 sas_address
->low
= 0;
381 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
382 if (this_port
->phy_table
[index
] != NULL
) {
383 scic_sds_phy_get_sas_address(this_port
->phy_table
[index
], sas_address
);
389 * This method will indicate which protocols are supported by this port.
390 * @this_port: a handle corresponding to the SAS port for which to return the
391 * supported protocols.
392 * @protocols: This parameter specifies a pointer to an IAF protocol field
393 * structure into which the core will copy the protocol values for the port.
394 * The values are returned as part of a bit mask in order to allow for
395 * multi-protocol support.
398 static void scic_sds_port_get_protocols(
399 struct scic_sds_port
*this_port
,
400 struct sci_sas_identify_address_frame_protocols
*protocols
)
404 protocols
->u
.all
= 0;
406 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
407 if (this_port
->phy_table
[index
] != NULL
) {
408 scic_sds_phy_get_protocols(this_port
->phy_table
[index
], protocols
);
414 * This method requests the SAS address for the device directly attached to
416 * @this_port: a handle corresponding to the SAS port for which to return the
418 * @sas_address: This parameter specifies a pointer to a SAS address structure
419 * into which the core will copy the SAS address for the device directly
420 * attached to the port.
423 void scic_sds_port_get_attached_sas_address(
424 struct scic_sds_port
*this_port
,
425 struct sci_sas_address
*sas_address
)
427 struct sci_sas_identify_address_frame_protocols protocols
;
428 struct scic_sds_phy
*phy
;
431 * Ensure that the phy is both part of the port and currently
432 * connected to the remote end-point. */
433 phy
= scic_sds_port_get_a_connected_phy(this_port
);
435 scic_sds_phy_get_attached_phy_protocols(phy
, &protocols
);
437 if (!protocols
.u
.bits
.stp_target
) {
438 scic_sds_phy_get_attached_sas_address(phy
, sas_address
);
440 scic_sds_phy_get_sas_address(phy
, sas_address
);
441 sas_address
->low
+= phy
->phy_index
;
444 sas_address
->high
= 0;
445 sas_address
->low
= 0;
450 * This method will indicate which protocols are supported by this remote
452 * @this_port: a handle corresponding to the SAS port for which to return the
453 * supported protocols.
454 * @protocols: This parameter specifies a pointer to an IAF protocol field
455 * structure into which the core will copy the protocol values for the port.
456 * The values are returned as part of a bit mask in order to allow for
457 * multi-protocol support.
460 void scic_sds_port_get_attached_protocols(
461 struct scic_sds_port
*this_port
,
462 struct sci_sas_identify_address_frame_protocols
*protocols
)
464 struct scic_sds_phy
*phy
;
467 * Ensure that the phy is both part of the port and currently
468 * connected to the remote end-point. */
469 phy
= scic_sds_port_get_a_connected_phy(this_port
);
471 scic_sds_phy_get_attached_phy_protocols(phy
, protocols
);
473 protocols
->u
.all
= 0;
477 * This method returns the amount of memory requred for a port object.
483 * This method returns the minimum number of timers required for all port
490 * This method returns the maximum number of timers required for all port
503 void scic_sds_port_construct(
504 struct scic_sds_port
*this_port
,
506 struct scic_sds_controller
*owning_controller
)
510 sci_base_port_construct(
512 scic_sds_port_state_table
515 sci_base_state_machine_construct(
516 scic_sds_port_get_ready_substate_machine(this_port
),
517 &this_port
->parent
.parent
,
518 scic_sds_port_ready_substate_table
,
519 SCIC_SDS_PORT_READY_SUBSTATE_WAITING
522 this_port
->logical_port_index
= SCIC_SDS_DUMMY_PORT
;
523 this_port
->physical_port_index
= port_index
;
524 this_port
->active_phy_mask
= 0;
526 this_port
->owning_controller
= owning_controller
;
528 this_port
->started_request_count
= 0;
529 this_port
->assigned_device_count
= 0;
531 this_port
->timer_handle
= NULL
;
533 this_port
->port_task_scheduler_registers
= NULL
;
535 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
536 this_port
->phy_table
[index
] = NULL
;
541 * This method performs initialization of the supplied port. Initialization
542 * includes: - state machine initialization - member variable initialization
543 * - configuring the phy_mask
545 * @transport_layer_registers:
546 * @port_task_scheduler_registers:
547 * @port_configuration_regsiter:
549 * enum sci_status SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION This value is returned
550 * if the phy being added to the port
552 enum sci_status
scic_sds_port_initialize(
553 struct scic_sds_port
*this_port
,
554 void __iomem
*port_task_scheduler_registers
,
555 void __iomem
*port_configuration_regsiter
,
556 void __iomem
*viit_registers
)
558 this_port
->port_task_scheduler_registers
= port_task_scheduler_registers
;
559 this_port
->port_pe_configuration_register
= port_configuration_regsiter
;
560 this_port
->viit_registers
= viit_registers
;
563 * If this is not the dummy port make the assignment of
564 * the timer and start the state machine */
565 if (this_port
->physical_port_index
!= SCI_MAX_PORTS
) {
566 /* / @todo should we create the timer at create time? */
567 this_port
->timer_handle
= isci_event_timer_create(
568 scic_sds_port_get_controller(this_port
),
569 scic_sds_port_timeout_handler
,
575 * Force the dummy port into a condition where it rejects all requests
576 * as its in an invalid state for any operation.
577 * / @todo should we set a set of specical handlers for the dummy port? */
578 scic_sds_port_set_base_state_handlers(
579 this_port
, SCI_BASE_PORT_STATE_STOPPED
588 * @this_port: This is the struct scic_sds_port object for which has a phy that has
590 * @the_phy: This is the struct scic_sds_phy object that has gone link up.
591 * @do_notify_user: This parameter specifies whether to inform the user (via
592 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
594 * This method is the a general link up handler for the struct scic_sds_port object.
595 * This function will determine if this struct scic_sds_phy can be assigned to this
596 * struct scic_sds_port object. If the struct scic_sds_phy object can is not a valid PHY for
597 * this port then the function will notify the SCIC_USER. A PHY can only be
598 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in
599 * the same port. none
601 void scic_sds_port_general_link_up_handler(
602 struct scic_sds_port
*this_port
,
603 struct scic_sds_phy
*the_phy
,
606 struct sci_sas_address port_sas_address
;
607 struct sci_sas_address phy_sas_address
;
609 scic_sds_port_get_attached_sas_address(this_port
, &port_sas_address
);
610 scic_sds_phy_get_attached_sas_address(the_phy
, &phy_sas_address
);
613 * If the SAS address of the new phy matches the SAS address of
614 * other phys in the port OR this is the first phy in the port,
615 * then activate the phy and allow it to be used for operations
619 (phy_sas_address
.high
== port_sas_address
.high
)
620 && (phy_sas_address
.low
== port_sas_address
.low
)
622 || (this_port
->active_phy_mask
== 0)
624 scic_sds_port_activate_phy(this_port
, the_phy
, do_notify_user
);
626 if (this_port
->parent
.state_machine
.current_state_id
627 == SCI_BASE_PORT_STATE_RESETTING
) {
628 sci_base_state_machine_change_state(
629 &this_port
->parent
.state_machine
, SCI_BASE_PORT_STATE_READY
633 scic_sds_port_invalid_link_up(this_port
, the_phy
);
638 enum sci_status
scic_port_start(struct scic_sds_port
*port
)
640 return port
->state_handlers
->parent
.start_handler(&port
->parent
);
644 enum sci_status
scic_port_stop(struct scic_sds_port
*port
)
646 return port
->state_handlers
->parent
.stop_handler(&port
->parent
);
650 enum sci_status
scic_port_get_properties(
651 struct scic_sds_port
*port
,
652 struct scic_port_properties
*prop
)
654 if ((port
== NULL
) ||
655 (port
->logical_port_index
== SCIC_SDS_DUMMY_PORT
))
656 return SCI_FAILURE_INVALID_PORT
;
658 prop
->index
= port
->logical_port_index
;
659 prop
->phy_mask
= scic_sds_port_get_phys(port
);
660 scic_sds_port_get_sas_address(port
, &prop
->local
.sas_address
);
661 scic_sds_port_get_protocols(port
, &prop
->local
.protocols
);
662 scic_sds_port_get_attached_sas_address(port
, &prop
->remote
.sas_address
);
663 scic_sds_port_get_attached_protocols(port
, &prop
->remote
.protocols
);
669 enum sci_status
scic_port_hard_reset(
670 struct scic_sds_port
*port
,
673 return port
->state_handlers
->parent
.reset_handler(
674 &port
->parent
, reset_timeout
);
678 * This method assigns the direct attached device ID for this port.
680 * @param[in] this_port The port for which the direct attached device id is to
682 * @param[in] device_id The direct attached device ID to assign to the port.
683 * This will be the RNi for the device
685 void scic_sds_port_setup_transports(
686 struct scic_sds_port
*this_port
,
691 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
692 if (this_port
->active_phy_mask
& (1 << index
))
693 scic_sds_phy_setup_transport(this_port
->phy_table
[index
], device_id
);
699 * @this_port: This is the port on which the phy should be enabled.
700 * @the_phy: This is the specific phy which to enable.
701 * @do_notify_user: This parameter specifies whether to inform the user (via
702 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
704 * This method will activate the phy in the port. Activation includes: - adding
705 * the phy to the port - enabling the Protocol Engine in the silicon. -
706 * notifying the user that the link is up. none
708 void scic_sds_port_activate_phy(
709 struct scic_sds_port
*this_port
,
710 struct scic_sds_phy
*the_phy
,
713 struct scic_sds_controller
*controller
;
714 struct sci_sas_identify_address_frame_protocols protocols
;
716 controller
= scic_sds_port_get_controller(this_port
);
717 scic_sds_phy_get_attached_phy_protocols(the_phy
, &protocols
);
719 /* If this is sata port then the phy has already been resumed */
720 if (!protocols
.u
.bits
.stp_target
) {
721 scic_sds_phy_resume(the_phy
);
724 this_port
->active_phy_mask
|= 1 << the_phy
->phy_index
;
726 scic_sds_controller_clear_invalid_phy(controller
, the_phy
);
728 if (do_notify_user
== true)
729 isci_event_port_link_up(this_port
->owning_controller
,
736 * @this_port: This is the port on which the phy should be deactivated.
737 * @the_phy: This is the specific phy that is no longer active in the port.
738 * @do_notify_user: This parameter specifies whether to inform the user (via
739 * isci_event_port_link_down()) as to the fact that a new phy as become
742 * This method will deactivate the supplied phy in the port. none
744 void scic_sds_port_deactivate_phy(
745 struct scic_sds_port
*this_port
,
746 struct scic_sds_phy
*the_phy
,
749 this_port
->active_phy_mask
&= ~(1 << the_phy
->phy_index
);
751 the_phy
->max_negotiated_speed
= SCI_SAS_NO_LINK_RATE
;
753 /* Re-assign the phy back to the LP as if it were a narrow port */
754 SCU_PCSPExCR_WRITE(this_port
, the_phy
->phy_index
, the_phy
->phy_index
);
756 if (do_notify_user
== true)
757 isci_event_port_link_down(this_port
->owning_controller
,
764 * @this_port: This is the port on which the phy should be disabled.
765 * @the_phy: This is the specific phy which to disabled.
767 * This method will disable the phy and report that the phy is not valid for
768 * this port object. None
770 static void scic_sds_port_invalid_link_up(
771 struct scic_sds_port
*this_port
,
772 struct scic_sds_phy
*the_phy
)
774 struct scic_sds_controller
*controller
= scic_sds_port_get_controller(this_port
);
777 * Check to see if we have alreay reported this link as bad and if not go
778 * ahead and tell the SCI_USER that we have discovered an invalid link. */
779 if ((controller
->invalid_phy_mask
& (1 << the_phy
->phy_index
)) == 0) {
780 scic_sds_controller_set_invalid_phy(controller
, the_phy
);
782 isci_event_port_invalid_link_up(controller
, this_port
, the_phy
);
787 * This method returns false if the port only has a single phy object assigned.
788 * If there are no phys or more than one phy then the method will return
790 * @this_port: The port for which the wide port condition is to be checked.
792 * bool true Is returned if this is a wide ported port. false Is returned if
793 * this is a narrow port.
795 static bool scic_sds_port_is_wide(struct scic_sds_port
*this_port
)
800 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
801 if (this_port
->phy_table
[index
] != NULL
) {
806 return phy_count
!= 1;
810 * This method is called by the PHY object when the link is detected. if the
811 * port wants the PHY to continue on to the link up state then the port
812 * layer must return true. If the port object returns false the phy object
813 * must halt its attempt to go link up.
814 * @this_port: The port associated with the phy object.
815 * @the_phy: The phy object that is trying to go link up.
817 * true if the phy object can continue to the link up condition. true Is
818 * returned if this phy can continue to the ready state. false Is returned if
819 * can not continue on to the ready state. This notification is in place for
820 * wide ports and direct attached phys. Since there are no wide ported SATA
821 * devices this could become an invalid port configuration.
823 bool scic_sds_port_link_detected(
824 struct scic_sds_port
*this_port
,
825 struct scic_sds_phy
*the_phy
)
827 struct sci_sas_identify_address_frame_protocols protocols
;
829 scic_sds_phy_get_attached_phy_protocols(the_phy
, &protocols
);
832 (this_port
->logical_port_index
!= SCIC_SDS_DUMMY_PORT
)
833 && (protocols
.u
.bits
.stp_target
)
834 && scic_sds_port_is_wide(this_port
)
836 scic_sds_port_invalid_link_up(this_port
, the_phy
);
845 * This method is the entry point for the phy to inform the port that it is now
851 void scic_sds_port_link_up(
852 struct scic_sds_port
*this_port
,
853 struct scic_sds_phy
*the_phy
)
855 the_phy
->is_in_link_training
= false;
857 this_port
->state_handlers
->link_up_handler(this_port
, the_phy
);
861 * This method is the entry point for the phy to inform the port that it is no
862 * longer in a ready state
867 void scic_sds_port_link_down(
868 struct scic_sds_port
*this_port
,
869 struct scic_sds_phy
*the_phy
)
871 this_port
->state_handlers
->link_down_handler(this_port
, the_phy
);
875 * This method is called to start an IO request on this port.
882 enum sci_status
scic_sds_port_start_io(
883 struct scic_sds_port
*this_port
,
884 struct scic_sds_remote_device
*the_device
,
885 struct scic_sds_request
*the_io_request
)
887 return this_port
->state_handlers
->start_io_handler(
888 this_port
, the_device
, the_io_request
);
892 * This method is called to complete an IO request to the port.
899 enum sci_status
scic_sds_port_complete_io(
900 struct scic_sds_port
*this_port
,
901 struct scic_sds_remote_device
*the_device
,
902 struct scic_sds_request
*the_io_request
)
904 return this_port
->state_handlers
->complete_io_handler(
905 this_port
, the_device
, the_io_request
);
909 * This method is provided to timeout requests for port operations. Mostly its
910 * for the port reset operation.
914 static void scic_sds_port_timeout_handler(void *port
)
916 struct scic_sds_port
*this_port
= port
;
919 current_state
= sci_base_state_machine_get_state(
920 &this_port
->parent
.state_machine
);
922 if (current_state
== SCI_BASE_PORT_STATE_RESETTING
) {
924 * if the port is still in the resetting state then the timeout fired
925 * before the reset completed. */
926 sci_base_state_machine_change_state(
927 &this_port
->parent
.state_machine
,
928 SCI_BASE_PORT_STATE_FAILED
930 } else if (current_state
== SCI_BASE_PORT_STATE_STOPPED
) {
932 * if the port is stopped then the start request failed
933 * In this case stay in the stopped state. */
934 dev_err(sciport_to_dev(this_port
),
935 "%s: SCIC Port 0x%p failed to stop before tiemout.\n",
938 } else if (current_state
== SCI_BASE_PORT_STATE_STOPPING
) {
939 /* if the port is still stopping then the stop has not completed */
940 isci_event_port_stop_complete(
941 scic_sds_port_get_controller(this_port
),
947 * The port is in the ready state and we have a timer reporting a timeout
948 * this should not happen. */
949 dev_err(sciport_to_dev(this_port
),
950 "%s: SCIC Port 0x%p is processing a timeout operation "
958 /* --------------------------------------------------------------------------- */
961 * This function updates the hardwares VIIT entry for this port.
965 void scic_sds_port_update_viit_entry(struct scic_sds_port
*this_port
)
967 struct sci_sas_address sas_address
;
969 scic_sds_port_get_sas_address(this_port
, &sas_address
);
971 scu_port_viit_register_write(
972 this_port
, initiator_sas_address_hi
, sas_address
.high
);
974 scu_port_viit_register_write(
975 this_port
, initiator_sas_address_lo
, sas_address
.low
);
977 /* This value get cleared just in case its not already cleared */
978 scu_port_viit_register_write(
979 this_port
, reserved
, 0);
981 /* We are required to update the status register last */
982 scu_port_viit_register_write(
984 SCU_VIIT_ENTRY_ID_VIIT
985 | SCU_VIIT_IPPT_INITIATOR
986 | ((1 << this_port
->physical_port_index
) << SCU_VIIT_ENTRY_LPVIE_SHIFT
)
987 | SCU_VIIT_STATUS_ALL_VALID
993 * This method returns the maximum allowed speed for data transfers on this
994 * port. This maximum allowed speed evaluates to the maximum speed of the
995 * slowest phy in the port.
996 * @this_port: This parameter specifies the port for which to retrieve the
997 * maximum allowed speed.
999 * This method returns the maximum negotiated speed of the slowest phy in the
1002 enum sci_sas_link_rate
scic_sds_port_get_max_allowed_speed(
1003 struct scic_sds_port
*this_port
)
1006 enum sci_sas_link_rate max_allowed_speed
= SCI_SAS_600_GB
;
1007 struct scic_sds_phy
*phy
= NULL
;
1010 * Loop through all of the phys in this port and find the phy with the
1011 * lowest maximum link rate. */
1012 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
1013 phy
= this_port
->phy_table
[index
];
1016 && (scic_sds_port_active_phy(this_port
, phy
) == true)
1017 && (phy
->max_negotiated_speed
< max_allowed_speed
)
1019 max_allowed_speed
= phy
->max_negotiated_speed
;
1022 return max_allowed_speed
;
1027 * This method passes the event to core user.
1028 * @this_port: The port that a BCN happens.
1029 * @this_phy: The phy that receives BCN.
1032 void scic_sds_port_broadcast_change_received(
1033 struct scic_sds_port
*this_port
,
1034 struct scic_sds_phy
*this_phy
)
1036 /* notify the user. */
1037 isci_event_port_bc_change_primitive_received(
1038 this_port
->owning_controller
, this_port
, this_phy
1044 * This API methhod enables the broadcast change notification from underneath
1046 * @this_port: The port that a BCN had been disabled from.
1049 void scic_port_enable_broadcast_change_notification(
1050 struct scic_sds_port
*port
)
1052 struct scic_sds_phy
*phy
;
1056 /* Loop through all of the phys to enable BCN. */
1057 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
1058 phy
= port
->phy_table
[index
];
1060 register_value
= SCU_SAS_LLCTL_READ(phy
);
1062 /* clear the bit by writing 1. */
1063 SCU_SAS_LLCTL_WRITE(phy
, register_value
);
1069 * ****************************************************************************
1070 * * READY SUBSTATE HANDLERS
1071 * **************************************************************************** */
1075 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1078 * This method is the general ready state stop handler for the struct scic_sds_port
1079 * object. This function will transition the ready substate machine to its
1080 * final state. enum sci_status SCI_SUCCESS
1082 static enum sci_status
scic_sds_port_ready_substate_stop_handler(
1083 struct sci_base_port
*port
)
1085 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1087 sci_base_state_machine_change_state(
1088 &this_port
->parent
.state_machine
,
1089 SCI_BASE_PORT_STATE_STOPPING
1097 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1099 * @device: This is the struct sci_base_remote_device object which is not used in this
1101 * @io_request: This is the struct sci_base_request object which is not used in this
1104 * This method is the general ready substate complete io handler for the
1105 * struct scic_sds_port object. This function decrments the outstanding request count
1106 * for this port object. enum sci_status SCI_SUCCESS
1108 static enum sci_status
scic_sds_port_ready_substate_complete_io_handler(
1109 struct scic_sds_port
*port
,
1110 struct scic_sds_remote_device
*device
,
1111 struct scic_sds_request
*io_request
)
1113 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1115 scic_sds_port_decrement_request_count(this_port
);
1120 static enum sci_status
scic_sds_port_ready_substate_add_phy_handler(
1121 struct sci_base_port
*port
,
1122 struct sci_base_phy
*phy
)
1124 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1125 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
1126 enum sci_status status
;
1128 status
= scic_sds_port_set_phy(this_port
, this_phy
);
1130 if (status
== SCI_SUCCESS
) {
1131 scic_sds_port_general_link_up_handler(this_port
, this_phy
, true);
1133 this_port
->not_ready_reason
= SCIC_PORT_NOT_READY_RECONFIGURING
;
1135 sci_base_state_machine_change_state(
1136 &this_port
->ready_substate_machine
,
1137 SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
1145 static enum sci_status
scic_sds_port_ready_substate_remove_phy_handler(
1146 struct sci_base_port
*port
,
1147 struct sci_base_phy
*phy
)
1149 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1150 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
1151 enum sci_status status
;
1153 status
= scic_sds_port_clear_phy(this_port
, this_phy
);
1155 if (status
== SCI_SUCCESS
) {
1156 scic_sds_port_deactivate_phy(this_port
, this_phy
, true);
1158 this_port
->not_ready_reason
= SCIC_PORT_NOT_READY_RECONFIGURING
;
1160 sci_base_state_machine_change_state(
1161 &this_port
->ready_substate_machine
,
1162 SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
1170 * ****************************************************************************
1171 * * READY SUBSTATE WAITING HANDLERS
1172 * **************************************************************************** */
1176 * @this_port: This is the struct scic_sds_port object that which has a phy that has
1178 * @the_phy: This is the struct scic_sds_phy object that has gone link up.
1180 * This method is the ready waiting substate link up handler for the
1181 * struct scic_sds_port object. This methos will report the link up condition for
1182 * this port and will transition to the ready operational substate. none
1184 static void scic_sds_port_ready_waiting_substate_link_up_handler(
1185 struct scic_sds_port
*this_port
,
1186 struct scic_sds_phy
*the_phy
)
1189 * Since this is the first phy going link up for the port we can just enable
1190 * it and continue. */
1191 scic_sds_port_activate_phy(this_port
, the_phy
, true);
1193 sci_base_state_machine_change_state(
1194 &this_port
->ready_substate_machine
,
1195 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
1201 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1203 * @device: This is the struct sci_base_remote_device object which is not used in this
1205 * @io_request: This is the struct sci_base_request object which is not used in this
1208 * This method is the ready waiting substate start io handler for the
1209 * struct scic_sds_port object. The port object can not accept new requests so the
1210 * request is failed. enum sci_status SCI_FAILURE_INVALID_STATE
1212 static enum sci_status
scic_sds_port_ready_waiting_substate_start_io_handler(
1213 struct scic_sds_port
*port
,
1214 struct scic_sds_remote_device
*device
,
1215 struct scic_sds_request
*io_request
)
1217 return SCI_FAILURE_INVALID_STATE
;
1221 * ****************************************************************************
1222 * * READY SUBSTATE OPERATIONAL HANDLERS
1223 * **************************************************************************** */
1227 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1229 * @timeout: This is the timeout for the reset request to complete.
1231 * This method will casue the port to reset. enum sci_status SCI_SUCCESS
1233 static enum sci_status
scic_sds_port_ready_operational_substate_reset_handler(
1234 struct sci_base_port
*port
,
1237 enum sci_status status
= SCI_FAILURE_INVALID_PHY
;
1239 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1240 struct scic_sds_phy
*selected_phy
= NULL
;
1243 /* Select a phy on which we can send the hard reset request. */
1246 (phy_index
< SCI_MAX_PHYS
)
1247 && (selected_phy
== NULL
);
1250 selected_phy
= this_port
->phy_table
[phy_index
];
1253 (selected_phy
!= NULL
)
1254 && !scic_sds_port_active_phy(this_port
, selected_phy
)
1256 /* We found a phy but it is not ready select different phy */
1257 selected_phy
= NULL
;
1261 /* If we have a phy then go ahead and start the reset procedure */
1262 if (selected_phy
!= NULL
) {
1263 status
= scic_sds_phy_reset(selected_phy
);
1265 if (status
== SCI_SUCCESS
) {
1266 isci_event_timer_start(
1267 scic_sds_port_get_controller(this_port
),
1268 this_port
->timer_handle
,
1272 this_port
->not_ready_reason
= SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED
;
1274 sci_base_state_machine_change_state(
1275 &this_port
->parent
.state_machine
,
1276 SCI_BASE_PORT_STATE_RESETTING
1285 * scic_sds_port_ready_operational_substate_link_up_handler() -
1286 * @this_port: This is the struct scic_sds_port object that which has a phy that has
1288 * @the_phy: This is the struct scic_sds_phy object that has gone link up.
1290 * This method is the ready operational substate link up handler for the
1291 * struct scic_sds_port object. This function notifies the SCI User that the phy has
1292 * gone link up. none
1294 static void scic_sds_port_ready_operational_substate_link_up_handler(
1295 struct scic_sds_port
*this_port
,
1296 struct scic_sds_phy
*the_phy
)
1298 scic_sds_port_general_link_up_handler(this_port
, the_phy
, true);
1302 * scic_sds_port_ready_operational_substate_link_down_handler() -
1303 * @this_port: This is the struct scic_sds_port object that which has a phy that has
1305 * @the_phy: This is the struct scic_sds_phy object that has gone link down.
1307 * This method is the ready operational substate link down handler for the
1308 * struct scic_sds_port object. This function notifies the SCI User that the phy has
1309 * gone link down and if this is the last phy in the port the port will change
1310 * state to the ready waiting substate. none
1312 static void scic_sds_port_ready_operational_substate_link_down_handler(
1313 struct scic_sds_port
*this_port
,
1314 struct scic_sds_phy
*the_phy
)
1316 scic_sds_port_deactivate_phy(this_port
, the_phy
, true);
1319 * If there are no active phys left in the port, then transition
1320 * the port to the WAITING state until such time as a phy goes
1322 if (this_port
->active_phy_mask
== 0) {
1323 sci_base_state_machine_change_state(
1324 scic_sds_port_get_ready_substate_machine(this_port
),
1325 SCIC_SDS_PORT_READY_SUBSTATE_WAITING
1332 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1334 * @device: This is the struct sci_base_remote_device object which is not used in this
1336 * @io_request: This is the struct sci_base_request object which is not used in this
1339 * This method is the ready operational substate start io handler for the
1340 * struct scic_sds_port object. This function incremetns the outstanding request
1341 * count for this port object. enum sci_status SCI_SUCCESS
1343 static enum sci_status
scic_sds_port_ready_operational_substate_start_io_handler(
1344 struct scic_sds_port
*port
,
1345 struct scic_sds_remote_device
*device
,
1346 struct scic_sds_request
*io_request
)
1348 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1350 scic_sds_port_increment_request_count(this_port
);
1356 * ****************************************************************************
1357 * * READY SUBSTATE OPERATIONAL HANDLERS
1358 * **************************************************************************** */
1361 * scic_sds_port_ready_configuring_substate_add_phy_handler() -
1362 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1365 * This is the default method for a port add phy request. It will report a
1366 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1368 static enum sci_status
scic_sds_port_ready_configuring_substate_add_phy_handler(
1369 struct sci_base_port
*port
,
1370 struct sci_base_phy
*phy
)
1372 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1373 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
1374 enum sci_status status
;
1376 status
= scic_sds_port_set_phy(this_port
, this_phy
);
1378 if (status
== SCI_SUCCESS
) {
1379 scic_sds_port_general_link_up_handler(this_port
, this_phy
, true);
1382 * Re-enter the configuring state since this may be the last phy in
1384 sci_base_state_machine_change_state(
1385 &this_port
->ready_substate_machine
,
1386 SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
1394 * scic_sds_port_ready_configuring_substate_remove_phy_handler() -
1395 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1398 * This is the default method for a port remove phy request. It will report a
1399 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1401 static enum sci_status
scic_sds_port_ready_configuring_substate_remove_phy_handler(
1402 struct sci_base_port
*port
,
1403 struct sci_base_phy
*phy
)
1405 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
1406 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
1407 enum sci_status status
;
1409 status
= scic_sds_port_clear_phy(this_port
, this_phy
);
1411 if (status
== SCI_SUCCESS
) {
1412 scic_sds_port_deactivate_phy(this_port
, this_phy
, true);
1415 * Re-enter the configuring state since this may be the last phy in
1417 sci_base_state_machine_change_state(
1418 &this_port
->ready_substate_machine
,
1419 SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
1427 * scic_sds_port_ready_configuring_substate_complete_io_handler() -
1428 * @port: This is the port that is being requested to complete the io request.
1429 * @device: This is the device on which the io is completing.
1431 * This method will decrement the outstanding request count for this port. If
1432 * the request count goes to 0 then the port can be reprogrammed with its new
1435 static enum sci_status
scic_sds_port_ready_configuring_substate_complete_io_handler(
1436 struct scic_sds_port
*port
,
1437 struct scic_sds_remote_device
*device
,
1438 struct scic_sds_request
*io_request
)
1440 scic_sds_port_decrement_request_count(port
);
1442 if (port
->started_request_count
== 0) {
1443 sci_base_state_machine_change_state(
1444 &port
->ready_substate_machine
,
1445 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
1452 /* --------------------------------------------------------------------------- */
1454 struct scic_sds_port_state_handler
1455 scic_sds_port_ready_substate_handler_table
[SCIC_SDS_PORT_READY_MAX_SUBSTATES
] =
1457 /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */
1460 scic_sds_port_default_start_handler
,
1461 scic_sds_port_ready_substate_stop_handler
,
1462 scic_sds_port_default_destruct_handler
,
1463 scic_sds_port_default_reset_handler
,
1464 scic_sds_port_ready_substate_add_phy_handler
,
1465 scic_sds_port_default_remove_phy_handler
1467 scic_sds_port_default_frame_handler
,
1468 scic_sds_port_default_event_handler
,
1469 scic_sds_port_ready_waiting_substate_link_up_handler
,
1470 scic_sds_port_default_link_down_handler
,
1471 scic_sds_port_ready_waiting_substate_start_io_handler
,
1472 scic_sds_port_ready_substate_complete_io_handler
,
1474 /* SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL */
1477 scic_sds_port_default_start_handler
,
1478 scic_sds_port_ready_substate_stop_handler
,
1479 scic_sds_port_default_destruct_handler
,
1480 scic_sds_port_ready_operational_substate_reset_handler
,
1481 scic_sds_port_ready_substate_add_phy_handler
,
1482 scic_sds_port_ready_substate_remove_phy_handler
1484 scic_sds_port_default_frame_handler
,
1485 scic_sds_port_default_event_handler
,
1486 scic_sds_port_ready_operational_substate_link_up_handler
,
1487 scic_sds_port_ready_operational_substate_link_down_handler
,
1488 scic_sds_port_ready_operational_substate_start_io_handler
,
1489 scic_sds_port_ready_substate_complete_io_handler
1491 /* SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING */
1494 scic_sds_port_default_start_handler
,
1495 scic_sds_port_ready_substate_stop_handler
,
1496 scic_sds_port_default_destruct_handler
,
1497 scic_sds_port_default_reset_handler
,
1498 scic_sds_port_ready_configuring_substate_add_phy_handler
,
1499 scic_sds_port_ready_configuring_substate_remove_phy_handler
1501 scic_sds_port_default_frame_handler
,
1502 scic_sds_port_default_event_handler
,
1503 scic_sds_port_default_link_up_handler
,
1504 scic_sds_port_default_link_down_handler
,
1505 scic_sds_port_default_start_io_handler
,
1506 scic_sds_port_ready_configuring_substate_complete_io_handler
1512 * scic_sds_port_set_ready_state_handlers() -
1514 * This macro sets the port ready substate handlers.
1516 #define scic_sds_port_set_ready_state_handlers(port, state_id) \
1517 scic_sds_port_set_state_handlers(\
1518 port, &scic_sds_port_ready_substate_handler_table[(state_id)] \
1522 * ******************************************************************************
1523 * * PORT STATE PRIVATE METHODS
1524 * ****************************************************************************** */
1528 * @this_port: This is the struct scic_sds_port object to suspend.
1530 * This method will susped the port task scheduler for this port object. none
1532 static void scic_sds_port_suspend_port_task_scheduler(
1533 struct scic_sds_port
*this_port
)
1535 u32 pts_control_value
;
1537 pts_control_value
= scu_port_task_scheduler_read(this_port
, control
);
1539 pts_control_value
|= SCU_PTSxCR_GEN_BIT(SUSPEND
);
1541 scu_port_task_scheduler_write(this_port
, control
, pts_control_value
);
1546 * @this_port: This is the struct scic_sds_port object to resume.
1548 * This method will resume the port task scheduler for this port object. none
1550 static void scic_sds_port_resume_port_task_scheduler(
1551 struct scic_sds_port
*this_port
)
1553 u32 pts_control_value
;
1555 pts_control_value
= scu_port_task_scheduler_read(this_port
, control
);
1557 pts_control_value
&= ~SCU_PTSxCR_GEN_BIT(SUSPEND
);
1559 scu_port_task_scheduler_write(this_port
, control
, pts_control_value
);
1563 * ******************************************************************************
1564 * * PORT READY SUBSTATE METHODS
1565 * ****************************************************************************** */
1569 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
1571 * This method will perform the actions required by the struct scic_sds_port on
1572 * entering the SCIC_SDS_PORT_READY_SUBSTATE_WAITING. This function checks the
1573 * port for any ready phys. If there is at least one phy in a ready state then
1574 * the port transitions to the ready operational substate. none
1576 static void scic_sds_port_ready_substate_waiting_enter(
1577 struct sci_base_object
*object
)
1579 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)object
;
1581 scic_sds_port_set_ready_state_handlers(
1582 this_port
, SCIC_SDS_PORT_READY_SUBSTATE_WAITING
1585 scic_sds_port_suspend_port_task_scheduler(this_port
);
1587 this_port
->not_ready_reason
= SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS
;
1589 if (this_port
->active_phy_mask
!= 0) {
1590 /* At least one of the phys on the port is ready */
1591 sci_base_state_machine_change_state(
1592 &this_port
->ready_substate_machine
,
1593 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
1600 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
1602 * This method will perform the actions required by the struct scic_sds_port on
1603 * entering the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function sets
1604 * the state handlers for the port object, notifies the SCI User that the port
1605 * is ready, and resumes port operations. none
1607 static void scic_sds_port_ready_substate_operational_enter(
1608 struct sci_base_object
*object
)
1611 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)object
;
1613 scic_sds_port_set_ready_state_handlers(
1614 this_port
, SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
1617 isci_event_port_ready(
1618 scic_sds_port_get_controller(this_port
), this_port
1621 for (index
= 0; index
< SCI_MAX_PHYS
; index
++) {
1622 if (this_port
->phy_table
[index
] != NULL
) {
1623 scic_sds_port_write_phy_assignment(
1624 this_port
, this_port
->phy_table
[index
]
1629 scic_sds_port_update_viit_entry(this_port
);
1631 scic_sds_port_resume_port_task_scheduler(this_port
);
1636 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
1638 * This method will perform the actions required by the struct scic_sds_port on
1639 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports
1640 * the port not ready and suspends the port task scheduler. none
1642 static void scic_sds_port_ready_substate_operational_exit(
1643 struct sci_base_object
*object
)
1645 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)object
;
1647 isci_event_port_not_ready(
1648 scic_sds_port_get_controller(this_port
),
1650 this_port
->not_ready_reason
1655 * ******************************************************************************
1656 * * PORT READY CONFIGURING METHODS
1657 * ****************************************************************************** */
1660 * scic_sds_port_ready_substate_configuring_enter() -
1661 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
1663 * This method will perform the actions required by the struct scic_sds_port on
1664 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports
1665 * the port not ready and suspends the port task scheduler. none
1667 static void scic_sds_port_ready_substate_configuring_enter(
1668 struct sci_base_object
*object
)
1670 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)object
;
1672 scic_sds_port_set_ready_state_handlers(
1673 this_port
, SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
1676 if (this_port
->active_phy_mask
== 0) {
1677 isci_event_port_not_ready(
1678 scic_sds_port_get_controller(this_port
),
1680 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS
1683 sci_base_state_machine_change_state(
1684 &this_port
->ready_substate_machine
,
1685 SCIC_SDS_PORT_READY_SUBSTATE_WAITING
1687 } else if (this_port
->started_request_count
== 0) {
1688 sci_base_state_machine_change_state(
1689 &this_port
->ready_substate_machine
,
1690 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
1695 static void scic_sds_port_ready_substate_configuring_exit(
1696 struct sci_base_object
*object
)
1698 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)object
;
1700 scic_sds_port_suspend_port_task_scheduler(this_port
);
1703 /* --------------------------------------------------------------------------- */
1705 const struct sci_base_state scic_sds_port_ready_substate_table
[] = {
1706 [SCIC_SDS_PORT_READY_SUBSTATE_WAITING
] = {
1707 .enter_state
= scic_sds_port_ready_substate_waiting_enter
,
1709 [SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL
] = {
1710 .enter_state
= scic_sds_port_ready_substate_operational_enter
,
1711 .exit_state
= scic_sds_port_ready_substate_operational_exit
1713 [SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
] = {
1714 .enter_state
= scic_sds_port_ready_substate_configuring_enter
,
1715 .exit_state
= scic_sds_port_ready_substate_configuring_exit
1720 * ***************************************************************************
1721 * * DEFAULT HANDLERS
1722 * *************************************************************************** */
1726 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1729 * This is the default method for port a start request. It will report a
1730 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1732 enum sci_status
scic_sds_port_default_start_handler(
1733 struct sci_base_port
*port
)
1735 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1737 dev_warn(sciport_to_dev(sci_port
),
1738 "%s: SCIC Port 0x%p requested to start while in invalid "
1742 sci_base_state_machine_get_state(
1743 scic_sds_port_get_base_state_machine(
1744 (struct scic_sds_port
*)port
)));
1746 return SCI_FAILURE_INVALID_STATE
;
1751 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1754 * This is the default method for a port stop request. It will report a
1755 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1757 static enum sci_status
scic_sds_port_default_stop_handler(
1758 struct sci_base_port
*port
)
1760 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1762 dev_warn(sciport_to_dev(sci_port
),
1763 "%s: SCIC Port 0x%p requested to stop while in invalid "
1767 sci_base_state_machine_get_state(
1768 scic_sds_port_get_base_state_machine(
1769 (struct scic_sds_port
*)port
)));
1771 return SCI_FAILURE_INVALID_STATE
;
1776 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1779 * This is the default method for a port destruct request. It will report a
1780 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1782 enum sci_status
scic_sds_port_default_destruct_handler(
1783 struct sci_base_port
*port
)
1785 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1787 dev_warn(sciport_to_dev(sci_port
),
1788 "%s: SCIC Port 0x%p requested to destruct while in invalid "
1792 sci_base_state_machine_get_state(
1793 scic_sds_port_get_base_state_machine(
1794 (struct scic_sds_port
*)port
)));
1796 return SCI_FAILURE_INVALID_STATE
;
1801 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1803 * @timeout: This is the timeout for the reset request to complete.
1805 * This is the default method for a port reset request. It will report a
1806 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1808 enum sci_status
scic_sds_port_default_reset_handler(
1809 struct sci_base_port
*port
,
1812 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1814 dev_warn(sciport_to_dev(sci_port
),
1815 "%s: SCIC Port 0x%p requested to reset while in invalid "
1819 sci_base_state_machine_get_state(
1820 scic_sds_port_get_base_state_machine(
1821 (struct scic_sds_port
*)port
)));
1823 return SCI_FAILURE_INVALID_STATE
;
1828 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1831 * This is the default method for a port add phy request. It will report a
1832 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1834 static enum sci_status
scic_sds_port_default_add_phy_handler(
1835 struct sci_base_port
*port
,
1836 struct sci_base_phy
*phy
)
1838 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1840 dev_warn(sciport_to_dev(sci_port
),
1841 "%s: SCIC Port 0x%p requested to add phy 0x%p while in "
1842 "invalid state %d\n",
1846 sci_base_state_machine_get_state(
1847 scic_sds_port_get_base_state_machine(
1848 (struct scic_sds_port
*)port
)));
1850 return SCI_FAILURE_INVALID_STATE
;
1855 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1858 * This is the default method for a port remove phy request. It will report a
1859 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1861 enum sci_status
scic_sds_port_default_remove_phy_handler(
1862 struct sci_base_port
*port
,
1863 struct sci_base_phy
*phy
)
1865 struct scic_sds_port
*sci_port
= (struct scic_sds_port
*)port
;
1867 dev_warn(sciport_to_dev(sci_port
),
1868 "%s: SCIC Port 0x%p requested to remove phy 0x%p while in "
1869 "invalid state %d\n",
1873 sci_base_state_machine_get_state(
1874 scic_sds_port_get_base_state_machine(
1875 (struct scic_sds_port
*)port
)));
1877 return SCI_FAILURE_INVALID_STATE
;
1882 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1885 * This is the default method for a port unsolicited frame request. It will
1886 * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even
1887 * possible to receive an unsolicited frame directed to a port object? It
1888 * seems possible if we implementing virtual functions but until then?
1890 enum sci_status
scic_sds_port_default_frame_handler(
1891 struct scic_sds_port
*port
,
1894 dev_warn(sciport_to_dev(port
),
1895 "%s: SCIC Port 0x%p requested to process frame %d while in "
1896 "invalid state %d\n",
1900 sci_base_state_machine_get_state(
1901 scic_sds_port_get_base_state_machine(port
)));
1903 scic_sds_controller_release_frame(
1904 scic_sds_port_get_controller(port
), frame_index
1907 return SCI_FAILURE_INVALID_STATE
;
1912 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1915 * This is the default method for a port event request. It will report a
1916 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1918 enum sci_status
scic_sds_port_default_event_handler(
1919 struct scic_sds_port
*port
,
1922 dev_warn(sciport_to_dev(port
),
1923 "%s: SCIC Port 0x%p requested to process event 0x%x while "
1924 "in invalid state %d\n",
1928 sci_base_state_machine_get_state(
1929 scic_sds_port_get_base_state_machine(
1930 (struct scic_sds_port
*)port
)));
1932 return SCI_FAILURE_INVALID_STATE
;
1937 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1940 * This is the default method for a port link up notification. It will report
1941 * a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1943 void scic_sds_port_default_link_up_handler(
1944 struct scic_sds_port
*this_port
,
1945 struct scic_sds_phy
*phy
)
1947 dev_warn(sciport_to_dev(this_port
),
1948 "%s: SCIC Port 0x%p received link_up notification from phy "
1949 "0x%p while in invalid state %d\n",
1953 sci_base_state_machine_get_state(
1954 scic_sds_port_get_base_state_machine(this_port
)));
1959 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1962 * This is the default method for a port link down notification. It will
1963 * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1965 void scic_sds_port_default_link_down_handler(
1966 struct scic_sds_port
*this_port
,
1967 struct scic_sds_phy
*phy
)
1969 dev_warn(sciport_to_dev(this_port
),
1970 "%s: SCIC Port 0x%p received link down notification from "
1971 "phy 0x%p while in invalid state %d\n",
1975 sci_base_state_machine_get_state(
1976 scic_sds_port_get_base_state_machine(this_port
)));
1981 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1984 * This is the default method for a port start io request. It will report a
1985 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1987 enum sci_status
scic_sds_port_default_start_io_handler(
1988 struct scic_sds_port
*this_port
,
1989 struct scic_sds_remote_device
*device
,
1990 struct scic_sds_request
*io_request
)
1992 dev_warn(sciport_to_dev(this_port
),
1993 "%s: SCIC Port 0x%p requested to start io request 0x%p "
1994 "while in invalid state %d\n",
1998 sci_base_state_machine_get_state(
1999 scic_sds_port_get_base_state_machine(this_port
)));
2001 return SCI_FAILURE_INVALID_STATE
;
2006 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2009 * This is the default method for a port complete io request. It will report a
2010 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
2012 static enum sci_status
scic_sds_port_default_complete_io_handler(
2013 struct scic_sds_port
*this_port
,
2014 struct scic_sds_remote_device
*device
,
2015 struct scic_sds_request
*io_request
)
2017 dev_warn(sciport_to_dev(this_port
),
2018 "%s: SCIC Port 0x%p requested to complete io request 0x%p "
2019 "while in invalid state %d\n",
2023 sci_base_state_machine_get_state(
2024 scic_sds_port_get_base_state_machine(this_port
)));
2026 return SCI_FAILURE_INVALID_STATE
;
2030 * ****************************************************************************
2031 * * GENERAL STATE HANDLERS
2032 * **************************************************************************** */
2036 * @port: This is the struct scic_sds_port object on which the io request count will
2038 * @device: This is the struct scic_sds_remote_device object to which the io request
2039 * is being directed. This parameter is not required to complete this
2041 * @io_request: This is the request that is being completed on this port
2042 * object. This parameter is not required to complete this operation.
2044 * This is a general complete io request handler for the struct scic_sds_port object.
2045 * enum sci_status SCI_SUCCESS
2047 static enum sci_status
scic_sds_port_general_complete_io_handler(
2048 struct scic_sds_port
*port
,
2049 struct scic_sds_remote_device
*device
,
2050 struct scic_sds_request
*io_request
)
2052 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2054 scic_sds_port_decrement_request_count(this_port
);
2060 * ****************************************************************************
2061 * * STOPPED STATE HANDLERS
2062 * **************************************************************************** */
2066 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2069 * This method takes the struct scic_sds_port from a stopped state and attempts to
2070 * start it. To start a port it must have no assiged devices and it must have
2071 * at least one phy assigned to it. If those conditions are met then the port
2072 * can transition to the ready state. enum sci_status
2073 * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION This struct scic_sds_port object could
2074 * not be started because the port configuration is not valid. SCI_SUCCESS the
2075 * start request is successful and the struct scic_sds_port object has transitioned to
2076 * the SCI_BASE_PORT_STATE_READY.
2078 static enum sci_status
scic_sds_port_stopped_state_start_handler(
2079 struct sci_base_port
*port
)
2082 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2084 if (this_port
->assigned_device_count
> 0) {
2086 * / @todo This is a start failure operation because there are still
2087 * / devices assigned to this port. There must be no devices
2088 * / assigned to a port on a start operation. */
2089 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION
;
2092 phy_mask
= scic_sds_port_get_phys(this_port
);
2095 * There are one or more phys assigned to this port. Make sure
2096 * the port's phy mask is in fact legal and supported by the
2098 if (scic_sds_port_is_phy_mask_valid(this_port
, phy_mask
) == true) {
2099 sci_base_state_machine_change_state(
2100 scic_sds_port_get_base_state_machine(this_port
),
2101 SCI_BASE_PORT_STATE_READY
2107 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION
;
2112 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2115 * This method takes the struct scic_sds_port that is in a stopped state and handles a
2116 * stop request. This function takes no action. enum sci_status SCI_SUCCESS the
2117 * stop request is successful as the struct scic_sds_port object is already stopped.
2119 static enum sci_status
scic_sds_port_stopped_state_stop_handler(
2120 struct sci_base_port
*port
)
2122 /* We are already stopped so there is nothing to do here */
2128 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2131 * This method takes the struct scic_sds_port that is in a stopped state and handles
2132 * the destruct request. The stopped state is the only state in which the
2133 * struct scic_sds_port can be destroyed. This function causes the port object to
2134 * transition to the SCI_BASE_PORT_STATE_FINAL. enum sci_status SCI_SUCCESS
2136 static enum sci_status
scic_sds_port_stopped_state_destruct_handler(
2137 struct sci_base_port
*port
)
2139 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2141 sci_base_state_machine_stop(&this_port
->parent
.state_machine
);
2148 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2150 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
2153 * This method takes the struct scic_sds_port that is in a stopped state and handles
2154 * the add phy request. In MPC mode the only time a phy can be added to a port
2155 * is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status
2156 * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION is returned when the phy can not
2157 * be added to the port. SCI_SUCCESS if the phy is added to the port.
2159 static enum sci_status
scic_sds_port_stopped_state_add_phy_handler(
2160 struct sci_base_port
*port
,
2161 struct sci_base_phy
*phy
)
2163 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2164 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
2165 struct sci_sas_address port_sas_address
;
2167 /* Read the port assigned SAS Address if there is one */
2168 scic_sds_port_get_sas_address(this_port
, &port_sas_address
);
2170 if (port_sas_address
.high
!= 0 && port_sas_address
.low
!= 0) {
2171 struct sci_sas_address phy_sas_address
;
2174 * Make sure that the PHY SAS Address matches the SAS Address
2176 scic_sds_phy_get_sas_address(this_phy
, &phy_sas_address
);
2179 (port_sas_address
.high
!= phy_sas_address
.high
)
2180 || (port_sas_address
.low
!= phy_sas_address
.low
)
2182 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION
;
2186 return scic_sds_port_set_phy(this_port
, this_phy
);
2192 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2194 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
2197 * This method takes the struct scic_sds_port that is in a stopped state and handles
2198 * the remove phy request. In MPC mode the only time a phy can be removed from
2199 * a port is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status
2200 * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION is returned when the phy can not
2201 * be added to the port. SCI_SUCCESS if the phy is added to the port.
2203 static enum sci_status
scic_sds_port_stopped_state_remove_phy_handler(
2204 struct sci_base_port
*port
,
2205 struct sci_base_phy
*phy
)
2207 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2208 struct scic_sds_phy
*this_phy
= (struct scic_sds_phy
*)phy
;
2210 return scic_sds_port_clear_phy(this_port
, this_phy
);
2214 * ****************************************************************************
2215 * * READY STATE HANDLERS
2216 * **************************************************************************** */
2219 * ****************************************************************************
2220 * * RESETTING STATE HANDLERS
2221 * **************************************************************************** */
2224 * ****************************************************************************
2225 * * STOPPING STATE HANDLERS
2226 * **************************************************************************** */
2230 * @port: This is the struct scic_sds_port object on which the io request count will
2232 * @device: This is the struct scic_sds_remote_device object to which the io request
2233 * is being directed. This parameter is not required to complete this
2235 * @io_request: This is the request that is being completed on this port
2236 * object. This parameter is not required to complete this operation.
2238 * This method takes the struct scic_sds_port that is in a stopping state and handles
2239 * the complete io request. Should the request count reach 0 then the port
2240 * object will transition to the stopped state. enum sci_status SCI_SUCCESS
2242 static enum sci_status
scic_sds_port_stopping_state_complete_io_handler(
2243 struct scic_sds_port
*port
,
2244 struct scic_sds_remote_device
*device
,
2245 struct scic_sds_request
*io_request
)
2247 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2249 scic_sds_port_decrement_request_count(this_port
);
2251 if (this_port
->started_request_count
== 0) {
2252 sci_base_state_machine_change_state(
2253 scic_sds_port_get_base_state_machine(this_port
),
2254 SCI_BASE_PORT_STATE_STOPPED
2262 * ****************************************************************************
2263 * * RESETTING STATE HANDLERS
2264 * **************************************************************************** */
2268 * @port: This is the port object which is being requested to stop.
2270 * This method will stop a failed port. This causes a transition to the
2271 * stopping state. enum sci_status SCI_SUCCESS
2273 static enum sci_status
scic_sds_port_reset_state_stop_handler(
2274 struct sci_base_port
*port
)
2276 struct scic_sds_port
*this_port
= (struct scic_sds_port
*)port
;
2278 sci_base_state_machine_change_state(
2279 &this_port
->parent
.state_machine
,
2280 SCI_BASE_PORT_STATE_STOPPING
2288 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2291 * This method will transition a failed port to its ready state. The port
2292 * failed because a hard reset request timed out but at some time later one or
2293 * more phys in the port became ready. enum sci_status SCI_SUCCESS
2295 static void scic_sds_port_reset_state_link_up_handler(
2296 struct scic_sds_port
*this_port
,
2297 struct scic_sds_phy
*phy
)
2300 * / @todo We should make sure that the phy that has gone link up is the same
2301 * / one on which we sent the reset. It is possible that the phy on
2302 * / which we sent the reset is not the one that has gone link up and we
2303 * / want to make sure that phy being reset comes back. Consider the
2304 * / case where a reset is sent but before the hardware processes the
2305 * / reset it get a link up on the port because of a hot plug event.
2306 * / because of the reset request this phy will go link down almost
2310 * In the resetting state we don't notify the user regarding
2311 * link up and link down notifications. */
2312 scic_sds_port_general_link_up_handler(this_port
, phy
, false);
2317 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
2320 * This method process link down notifications that occur during a port reset
2321 * operation. Link downs can occur during the reset operation. enum sci_status
2324 static void scic_sds_port_reset_state_link_down_handler(
2325 struct scic_sds_port
*this_port
,
2326 struct scic_sds_phy
*phy
)
2329 * In the resetting state we don't notify the user regarding
2330 * link up and link down notifications. */
2331 scic_sds_port_deactivate_phy(this_port
, phy
, false);
2334 /* --------------------------------------------------------------------------- */
2336 struct scic_sds_port_state_handler
2337 scic_sds_port_state_handler_table
[SCI_BASE_PORT_MAX_STATES
] =
2339 /* SCI_BASE_PORT_STATE_STOPPED */
2342 scic_sds_port_stopped_state_start_handler
,
2343 scic_sds_port_stopped_state_stop_handler
,
2344 scic_sds_port_stopped_state_destruct_handler
,
2345 scic_sds_port_default_reset_handler
,
2346 scic_sds_port_stopped_state_add_phy_handler
,
2347 scic_sds_port_stopped_state_remove_phy_handler
2349 scic_sds_port_default_frame_handler
,
2350 scic_sds_port_default_event_handler
,
2351 scic_sds_port_default_link_up_handler
,
2352 scic_sds_port_default_link_down_handler
,
2353 scic_sds_port_default_start_io_handler
,
2354 scic_sds_port_default_complete_io_handler
2356 /* SCI_BASE_PORT_STATE_STOPPING */
2359 scic_sds_port_default_start_handler
,
2360 scic_sds_port_default_stop_handler
,
2361 scic_sds_port_default_destruct_handler
,
2362 scic_sds_port_default_reset_handler
,
2363 scic_sds_port_default_add_phy_handler
,
2364 scic_sds_port_default_remove_phy_handler
2366 scic_sds_port_default_frame_handler
,
2367 scic_sds_port_default_event_handler
,
2368 scic_sds_port_default_link_up_handler
,
2369 scic_sds_port_default_link_down_handler
,
2370 scic_sds_port_default_start_io_handler
,
2371 scic_sds_port_stopping_state_complete_io_handler
2373 /* SCI_BASE_PORT_STATE_READY */
2376 scic_sds_port_default_start_handler
,
2377 scic_sds_port_default_stop_handler
,
2378 scic_sds_port_default_destruct_handler
,
2379 scic_sds_port_default_reset_handler
,
2380 scic_sds_port_default_add_phy_handler
,
2381 scic_sds_port_default_remove_phy_handler
2383 scic_sds_port_default_frame_handler
,
2384 scic_sds_port_default_event_handler
,
2385 scic_sds_port_default_link_up_handler
,
2386 scic_sds_port_default_link_down_handler
,
2387 scic_sds_port_default_start_io_handler
,
2388 scic_sds_port_general_complete_io_handler
2390 /* SCI_BASE_PORT_STATE_RESETTING */
2393 scic_sds_port_default_start_handler
,
2394 scic_sds_port_reset_state_stop_handler
,
2395 scic_sds_port_default_destruct_handler
,
2396 scic_sds_port_default_reset_handler
,
2397 scic_sds_port_default_add_phy_handler
,
2398 scic_sds_port_default_remove_phy_handler
2400 scic_sds_port_default_frame_handler
,
2401 scic_sds_port_default_event_handler
,
2402 scic_sds_port_reset_state_link_up_handler
,
2403 scic_sds_port_reset_state_link_down_handler
,
2404 scic_sds_port_default_start_io_handler
,
2405 scic_sds_port_general_complete_io_handler
2407 /* SCI_BASE_PORT_STATE_FAILED */
2410 scic_sds_port_default_start_handler
,
2411 scic_sds_port_default_stop_handler
,
2412 scic_sds_port_default_destruct_handler
,
2413 scic_sds_port_default_reset_handler
,
2414 scic_sds_port_default_add_phy_handler
,
2415 scic_sds_port_default_remove_phy_handler
2417 scic_sds_port_default_frame_handler
,
2418 scic_sds_port_default_event_handler
,
2419 scic_sds_port_default_link_up_handler
,
2420 scic_sds_port_default_link_down_handler
,
2421 scic_sds_port_default_start_io_handler
,
2422 scic_sds_port_general_complete_io_handler
2427 * ******************************************************************************
2428 * * PORT STATE PRIVATE METHODS
2429 * ****************************************************************************** */
2433 * @this_port: This is the port object which to suspend.
2435 * This method will enable the SCU Port Task Scheduler for this port object but
2436 * will leave the port task scheduler in a suspended state. none
2438 static void scic_sds_port_enable_port_task_scheduler(
2439 struct scic_sds_port
*this_port
)
2441 u32 pts_control_value
;
2443 pts_control_value
= scu_port_task_scheduler_read(this_port
, control
);
2445 pts_control_value
|= SCU_PTSxCR_GEN_BIT(ENABLE
) | SCU_PTSxCR_GEN_BIT(SUSPEND
);
2447 scu_port_task_scheduler_write(this_port
, control
, pts_control_value
);
2452 * @this_port: This is the port object which to resume.
2454 * This method will disable the SCU port task scheduler for this port object.
2457 static void scic_sds_port_disable_port_task_scheduler(
2458 struct scic_sds_port
*this_port
)
2460 u32 pts_control_value
;
2462 pts_control_value
= scu_port_task_scheduler_read(this_port
, control
);
2464 pts_control_value
&= ~(SCU_PTSxCR_GEN_BIT(ENABLE
)
2465 | SCU_PTSxCR_GEN_BIT(SUSPEND
));
2467 scu_port_task_scheduler_write(this_port
, control
, pts_control_value
);
2471 * ******************************************************************************
2472 * * PORT STATE METHODS
2473 * ****************************************************************************** */
2477 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2479 * This method will perform the actions required by the struct scic_sds_port on
2480 * entering the SCI_BASE_PORT_STATE_STOPPED. This function sets the stopped
2481 * state handlers for the struct scic_sds_port object and disables the port task
2482 * scheduler in the hardware. none
2484 static void scic_sds_port_stopped_state_enter(
2485 struct sci_base_object
*object
)
2487 struct scic_sds_port
*this_port
;
2489 this_port
= (struct scic_sds_port
*)object
;
2491 scic_sds_port_set_base_state_handlers(
2492 this_port
, SCI_BASE_PORT_STATE_STOPPED
2496 SCI_BASE_PORT_STATE_STOPPING
2497 == this_port
->parent
.state_machine
.previous_state_id
2500 * If we enter this state becasuse of a request to stop
2501 * the port then we want to disable the hardwares port
2502 * task scheduler. */
2503 scic_sds_port_disable_port_task_scheduler(this_port
);
2509 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2511 * This method will perform the actions required by the struct scic_sds_port on
2512 * exiting the SCI_BASE_STATE_STOPPED. This function enables the SCU hardware
2513 * port task scheduler. none
2515 static void scic_sds_port_stopped_state_exit(
2516 struct sci_base_object
*object
)
2518 struct scic_sds_port
*this_port
;
2520 this_port
= (struct scic_sds_port
*)object
;
2522 /* Enable and suspend the port task scheduler */
2523 scic_sds_port_enable_port_task_scheduler(this_port
);
2528 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2530 * This method will perform the actions required by the struct scic_sds_port on
2531 * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state
2532 * handlers for the struct scic_sds_port object, reports the port object as not ready
2533 * and starts the ready substate machine. none
2535 static void scic_sds_port_ready_state_enter(
2536 struct sci_base_object
*object
)
2538 struct scic_sds_port
*this_port
;
2540 this_port
= (struct scic_sds_port
*)object
;
2542 /* Put the ready state handlers in place though they will not be there long */
2543 scic_sds_port_set_base_state_handlers(
2544 this_port
, SCI_BASE_PORT_STATE_READY
2548 SCI_BASE_PORT_STATE_RESETTING
2549 == this_port
->parent
.state_machine
.previous_state_id
2551 isci_event_port_hard_reset_complete(
2552 scic_sds_port_get_controller(this_port
),
2557 /* Notify the caller that the port is not yet ready */
2558 isci_event_port_not_ready(
2559 scic_sds_port_get_controller(this_port
),
2561 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS
2565 /* Start the ready substate machine */
2566 sci_base_state_machine_start(
2567 scic_sds_port_get_ready_substate_machine(this_port
)
2573 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2575 * This method will perform the actions required by the struct scic_sds_port on
2576 * exiting the SCI_BASE_STATE_READY. This function does nothing. none
2578 static void scic_sds_port_ready_state_exit(
2579 struct sci_base_object
*object
)
2581 struct scic_sds_port
*this_port
;
2583 this_port
= (struct scic_sds_port
*)object
;
2585 sci_base_state_machine_stop(&this_port
->ready_substate_machine
);
2590 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2592 * This method will perform the actions required by the struct scic_sds_port on
2593 * entering the SCI_BASE_PORT_STATE_RESETTING. This function sets the resetting
2594 * state handlers for the struct scic_sds_port object. none
2596 static void scic_sds_port_resetting_state_enter(
2597 struct sci_base_object
*object
)
2599 struct scic_sds_port
*this_port
;
2601 this_port
= (struct scic_sds_port
*)object
;
2603 scic_sds_port_set_base_state_handlers(
2604 this_port
, SCI_BASE_PORT_STATE_RESETTING
2610 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2612 * This method will perform the actions required by the struct scic_sds_port on
2613 * exiting the SCI_BASE_STATE_RESETTING. This function does nothing. none
2615 static void scic_sds_port_resetting_state_exit(
2616 struct sci_base_object
*object
)
2618 struct scic_sds_port
*this_port
;
2620 this_port
= (struct scic_sds_port
*)object
;
2622 isci_event_timer_stop(
2623 scic_sds_port_get_controller(this_port
),
2624 this_port
->timer_handle
2630 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2632 * This method will perform the actions required by the struct scic_sds_port on
2633 * entering the SCI_BASE_PORT_STATE_STOPPING. This function sets the stopping
2634 * state handlers for the struct scic_sds_port object. none
2636 static void scic_sds_port_stopping_state_enter(
2637 struct sci_base_object
*object
)
2639 struct scic_sds_port
*this_port
;
2641 this_port
= (struct scic_sds_port
*)object
;
2643 scic_sds_port_set_base_state_handlers(
2644 this_port
, SCI_BASE_PORT_STATE_STOPPING
2650 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2652 * This method will perform the actions required by the struct scic_sds_port on
2653 * exiting the SCI_BASE_STATE_STOPPING. This function does nothing. none
2655 static void scic_sds_port_stopping_state_exit(
2656 struct sci_base_object
*object
)
2658 struct scic_sds_port
*this_port
;
2660 this_port
= (struct scic_sds_port
*)object
;
2662 isci_event_timer_stop(
2663 scic_sds_port_get_controller(this_port
),
2664 this_port
->timer_handle
2670 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
2672 * This method will perform the actions required by the struct scic_sds_port on
2673 * entering the SCI_BASE_PORT_STATE_STOPPING. This function sets the stopping
2674 * state handlers for the struct scic_sds_port object. none
2676 static void scic_sds_port_failed_state_enter(
2677 struct sci_base_object
*object
)
2679 struct scic_sds_port
*this_port
;
2681 this_port
= (struct scic_sds_port
*)object
;
2683 scic_sds_port_set_base_state_handlers(
2685 SCI_BASE_PORT_STATE_FAILED
2688 isci_event_port_hard_reset_complete(
2689 scic_sds_port_get_controller(this_port
),
2695 /* --------------------------------------------------------------------------- */
2697 const struct sci_base_state scic_sds_port_state_table
[] = {
2698 [SCI_BASE_PORT_STATE_STOPPED
] = {
2699 .enter_state
= scic_sds_port_stopped_state_enter
,
2700 .exit_state
= scic_sds_port_stopped_state_exit
2702 [SCI_BASE_PORT_STATE_STOPPING
] = {
2703 .enter_state
= scic_sds_port_stopping_state_enter
,
2704 .exit_state
= scic_sds_port_stopping_state_exit
2706 [SCI_BASE_PORT_STATE_READY
] = {
2707 .enter_state
= scic_sds_port_ready_state_enter
,
2708 .exit_state
= scic_sds_port_ready_state_exit
2710 [SCI_BASE_PORT_STATE_RESETTING
] = {
2711 .enter_state
= scic_sds_port_resetting_state_enter
,
2712 .exit_state
= scic_sds_port_resetting_state_exit
2714 [SCI_BASE_PORT_STATE_FAILED
] = {
2715 .enter_state
= scic_sds_port_failed_state_enter
,