blob: 2946eee8e702ac6b2cf59dcb2fe4a3af68251ed2 [file] [log] [blame]
Dan Williams6f231dd2011-07-02 22:56:22 -07001/*
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
Dan Williams6f231dd2011-07-02 22:56:22 -070056#include "isci.h"
Dan Williams6f231dd2011-07-02 22:56:22 -070057#include "port.h"
58#include "request.h"
Dan Williamse2f8db52011-05-10 02:28:46 -070059
60#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
61#define SCU_DUMMY_INDEX (0xFFFF)
Dan Williams6f231dd2011-07-02 22:56:22 -070062
Dan Williamse5313812011-05-07 10:11:43 -070063static void isci_port_change_state(struct isci_port *iport, enum isci_status status)
64{
65 unsigned long flags;
Dan Williams6f231dd2011-07-02 22:56:22 -070066
Dan Williamse5313812011-05-07 10:11:43 -070067 dev_dbg(&iport->isci_host->pdev->dev,
68 "%s: iport = %p, state = 0x%x\n",
69 __func__, iport, status);
Dan Williams6f231dd2011-07-02 22:56:22 -070070
Dan Williamse5313812011-05-07 10:11:43 -070071 /* XXX pointless lock */
72 spin_lock_irqsave(&iport->state_lock, flags);
73 iport->status = status;
74 spin_unlock_irqrestore(&iport->state_lock, flags);
75}
Dan Williams6f231dd2011-07-02 22:56:22 -070076
Dan Williamse2f8db52011-05-10 02:28:46 -070077/*
78 * This function will indicate which protocols are supported by this port.
79 * @sci_port: a handle corresponding to the SAS port for which to return the
80 * supported protocols.
81 * @protocols: This parameter specifies a pointer to a data structure
82 * which the core will copy the protocol values for the port from the
83 * transmit_identification register.
84 */
85static void
86scic_sds_port_get_protocols(struct scic_sds_port *sci_port,
87 struct scic_phy_proto *protocols)
Dan Williams6f231dd2011-07-02 22:56:22 -070088{
Dan Williamse2f8db52011-05-10 02:28:46 -070089 u8 index;
90
91 protocols->all = 0;
92
93 for (index = 0; index < SCI_MAX_PHYS; index++) {
94 if (sci_port->phy_table[index] != NULL) {
95 scic_sds_phy_get_protocols(sci_port->phy_table[index],
96 protocols);
97 }
98 }
Dan Williams6f231dd2011-07-02 22:56:22 -070099}
100
Dan Williams6f231dd2011-07-02 22:56:22 -0700101/**
Dan Williamse2f8db52011-05-10 02:28:46 -0700102 * This method requests a list (mask) of the phys contained in the supplied SAS
103 * port.
104 * @sci_port: a handle corresponding to the SAS port for which to return the
105 * phy mask.
Dan Williams6f231dd2011-07-02 22:56:22 -0700106 *
Dan Williamse2f8db52011-05-10 02:28:46 -0700107 * Return a bit mask indicating which phys are a part of this port. Each bit
108 * corresponds to a phy identifier (e.g. bit 0 = phy id 0).
Dan Williams6f231dd2011-07-02 22:56:22 -0700109 */
Dan Williamse2f8db52011-05-10 02:28:46 -0700110static u32 scic_sds_port_get_phys(struct scic_sds_port *sci_port)
Dan Williams6f231dd2011-07-02 22:56:22 -0700111{
Dan Williamse2f8db52011-05-10 02:28:46 -0700112 u32 index;
113 u32 mask;
114
115 mask = 0;
116
117 for (index = 0; index < SCI_MAX_PHYS; index++) {
118 if (sci_port->phy_table[index] != NULL) {
119 mask |= (1 << index);
120 }
121 }
122
123 return mask;
Dan Williams6f231dd2011-07-02 22:56:22 -0700124}
125
Dan Williamse2f8db52011-05-10 02:28:46 -0700126/**
127 * scic_port_get_properties() - This method simply returns the properties
128 * regarding the port, such as: physical index, protocols, sas address, etc.
129 * @port: this parameter specifies the port for which to retrieve the physical
130 * index.
131 * @properties: This parameter specifies the properties structure into which to
132 * copy the requested information.
133 *
134 * Indicate if the user specified a valid port. SCI_SUCCESS This value is
135 * returned if the specified port was valid. SCI_FAILURE_INVALID_PORT This
136 * value is returned if the specified port is not valid. When this value is
137 * returned, no data is copied to the properties output parameter.
138 */
139static enum sci_status scic_port_get_properties(struct scic_sds_port *port,
140 struct scic_port_properties *prop)
Dan Williams6f231dd2011-07-02 22:56:22 -0700141{
Dan Williamse2f8db52011-05-10 02:28:46 -0700142 if ((port == NULL) ||
143 (port->logical_port_index == SCIC_SDS_DUMMY_PORT))
144 return SCI_FAILURE_INVALID_PORT;
Dan Williams6f231dd2011-07-02 22:56:22 -0700145
Dan Williamse2f8db52011-05-10 02:28:46 -0700146 prop->index = port->logical_port_index;
147 prop->phy_mask = scic_sds_port_get_phys(port);
148 scic_sds_port_get_sas_address(port, &prop->local.sas_address);
149 scic_sds_port_get_protocols(port, &prop->local.protocols);
150 scic_sds_port_get_attached_sas_address(port, &prop->remote.sas_address);
Dan Williams6f231dd2011-07-02 22:56:22 -0700151
Dan Williamse2f8db52011-05-10 02:28:46 -0700152 return SCI_SUCCESS;
Dan Williams6f231dd2011-07-02 22:56:22 -0700153}
154
Jeff Skirvin61aaff42011-06-21 12:16:33 -0700155static void scic_port_bcn_enable(struct scic_sds_port *sci_port)
156{
157 struct scic_sds_phy *sci_phy;
158 u32 val;
159 int i;
160
161 for (i = 0; i < ARRAY_SIZE(sci_port->phy_table); i++) {
162 sci_phy = sci_port->phy_table[i];
163 if (!sci_phy)
164 continue;
165 val = readl(&sci_phy->link_layer_registers->link_layer_control);
166 /* clear the bit by writing 1. */
167 writel(val, &sci_phy->link_layer_registers->link_layer_control);
168 }
169}
170
171/* called under scic_lock to stabilize phy:port associations */
172void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport)
173{
174 int i;
175
176 clear_bit(IPORT_BCN_BLOCKED, &iport->flags);
177 wake_up(&ihost->eventq);
178
179 if (!test_and_clear_bit(IPORT_BCN_PENDING, &iport->flags))
180 return;
181
182 for (i = 0; i < ARRAY_SIZE(iport->sci.phy_table); i++) {
183 struct scic_sds_phy *sci_phy = iport->sci.phy_table[i];
184 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
185
186 if (!sci_phy)
187 continue;
188
189 ihost->sas_ha.notify_port_event(&iphy->sas_phy,
190 PORTE_BROADCAST_RCVD);
191 break;
192 }
193}
194
195void isci_port_bc_change_received(struct isci_host *ihost,
196 struct scic_sds_port *sci_port,
197 struct scic_sds_phy *sci_phy)
198{
199 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
200 struct isci_port *iport = iphy->isci_port;
201
202 if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) {
203 dev_dbg(&ihost->pdev->dev,
204 "%s: disabled BCN; isci_phy = %p, sas_phy = %p\n",
205 __func__, iphy, &iphy->sas_phy);
206 set_bit(IPORT_BCN_PENDING, &iport->flags);
207 atomic_inc(&iport->event);
208 wake_up(&ihost->eventq);
209 } else {
210 dev_dbg(&ihost->pdev->dev,
211 "%s: isci_phy = %p, sas_phy = %p\n",
212 __func__, iphy, &iphy->sas_phy);
213
214 ihost->sas_ha.notify_port_event(&iphy->sas_phy,
215 PORTE_BROADCAST_RCVD);
216 }
217 scic_port_bcn_enable(sci_port);
218}
219
Dan Williamse2f8db52011-05-10 02:28:46 -0700220static void isci_port_link_up(struct isci_host *isci_host,
221 struct scic_sds_port *port,
222 struct scic_sds_phy *phy)
Dan Williams6f231dd2011-07-02 22:56:22 -0700223{
224 unsigned long flags;
225 struct scic_port_properties properties;
Dan Williams4b339812011-05-06 17:36:38 -0700226 struct isci_phy *isci_phy = sci_phy_to_iphy(phy);
Dan Williamse5313812011-05-07 10:11:43 -0700227 struct isci_port *isci_port = sci_port_to_iport(port);
Dan Williams6f231dd2011-07-02 22:56:22 -0700228 unsigned long success = true;
229
230 BUG_ON(isci_phy->isci_port != NULL);
Bartosz Barcinski6cb4d6b2011-04-12 17:28:43 -0700231
Dan Williams6f231dd2011-07-02 22:56:22 -0700232 isci_phy->isci_port = isci_port;
233
234 dev_dbg(&isci_host->pdev->dev,
235 "%s: isci_port = %p\n",
236 __func__, isci_port);
237
238 spin_lock_irqsave(&isci_phy->sas_phy.frame_rcvd_lock, flags);
239
240 isci_port_change_state(isci_phy->isci_port, isci_starting);
241
242 scic_port_get_properties(port, &properties);
243
Dave Jiangd7b90fc2011-05-04 18:22:33 -0700244 if (phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) {
Dan Williams150fc6f2011-02-25 10:25:21 -0800245 u64 attached_sas_address;
Dan Williams6f231dd2011-07-02 22:56:22 -0700246
Dan Williams6f231dd2011-07-02 22:56:22 -0700247 isci_phy->sas_phy.oob_mode = SATA_OOB_MODE;
Dave Jiangf2f30082011-05-04 15:02:02 -0700248 isci_phy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis);
Dan Williams6f231dd2011-07-02 22:56:22 -0700249
250 /*
251 * For direct-attached SATA devices, the SCI core will
252 * automagically assign a SAS address to the end device
253 * for the purpose of creating a port. This SAS address
254 * will not be the same as assigned to the PHY and needs
255 * to be obtained from struct scic_port_properties properties.
256 */
Dan Williams150fc6f2011-02-25 10:25:21 -0800257 attached_sas_address = properties.remote.sas_address.high;
258 attached_sas_address <<= 32;
259 attached_sas_address |= properties.remote.sas_address.low;
260 swab64s(&attached_sas_address);
Dan Williams6f231dd2011-07-02 22:56:22 -0700261
Dan Williams150fc6f2011-02-25 10:25:21 -0800262 memcpy(&isci_phy->sas_phy.attached_sas_addr,
263 &attached_sas_address, sizeof(attached_sas_address));
Dave Jiangd7b90fc2011-05-04 18:22:33 -0700264 } else if (phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
Dan Williams6f231dd2011-07-02 22:56:22 -0700265 isci_phy->sas_phy.oob_mode = SAS_OOB_MODE;
Dave Jiang4b7ebd02011-05-04 15:37:52 -0700266 isci_phy->sas_phy.frame_rcvd_size = sizeof(struct sas_identify_frame);
Dan Williams6f231dd2011-07-02 22:56:22 -0700267
268 /* Copy the attached SAS address from the IAF */
269 memcpy(isci_phy->sas_phy.attached_sas_addr,
Dave Jiang4b7ebd02011-05-04 15:37:52 -0700270 isci_phy->frame_rcvd.iaf.sas_addr, SAS_ADDR_SIZE);
Dan Williams6f231dd2011-07-02 22:56:22 -0700271 } else {
272 dev_err(&isci_host->pdev->dev, "%s: unkown target\n", __func__);
273 success = false;
274 }
275
Dan Williams83e51432011-02-18 09:25:13 -0800276 isci_phy->sas_phy.phy->negotiated_linkrate = sci_phy_linkrate(phy);
277
Dan Williams6f231dd2011-07-02 22:56:22 -0700278 spin_unlock_irqrestore(&isci_phy->sas_phy.frame_rcvd_lock, flags);
279
280 /* Notify libsas that we have an address frame, if indeed
281 * we've found an SSP, SMP, or STP target */
282 if (success)
283 isci_host->sas_ha.notify_port_event(&isci_phy->sas_phy,
284 PORTE_BYTES_DMAED);
285}
286
287
288/**
289 * isci_port_link_down() - This function is called by the sci core when a link
290 * becomes inactive.
291 * @isci_host: This parameter specifies the isci host object.
292 * @phy: This parameter specifies the isci phy with the active link.
293 * @port: This parameter specifies the isci port with the active link.
294 *
295 */
Dan Williamse2f8db52011-05-10 02:28:46 -0700296static void isci_port_link_down(struct isci_host *isci_host,
297 struct isci_phy *isci_phy,
298 struct isci_port *isci_port)
Dan Williams6f231dd2011-07-02 22:56:22 -0700299{
300 struct isci_remote_device *isci_device;
301
302 dev_dbg(&isci_host->pdev->dev,
303 "%s: isci_port = %p\n", __func__, isci_port);
304
305 if (isci_port) {
306
307 /* check to see if this is the last phy on this port. */
Jeff Skirvin61aaff42011-06-21 12:16:33 -0700308 if (isci_phy->sas_phy.port &&
309 isci_phy->sas_phy.port->num_phys == 1) {
310 atomic_inc(&isci_port->event);
311 isci_port_bcn_enable(isci_host, isci_port);
Dan Williams6f231dd2011-07-02 22:56:22 -0700312
Jeff Skirvin61aaff42011-06-21 12:16:33 -0700313 /* change the state for all devices on this port. The
314 * next task sent to this device will be returned as
315 * SAS_TASK_UNDELIVERED, and the scsi mid layer will
316 * remove the target
Dan Williams6f231dd2011-07-02 22:56:22 -0700317 */
318 list_for_each_entry(isci_device,
319 &isci_port->remote_dev_list,
320 node) {
321 dev_dbg(&isci_host->pdev->dev,
322 "%s: isci_device = %p\n",
323 __func__, isci_device);
324 isci_remote_device_change_state(isci_device,
325 isci_stopping);
326 }
327 }
328 isci_port_change_state(isci_port, isci_stopping);
329 }
330
331 /* Notify libsas of the borken link, this will trigger calls to our
332 * isci_port_deformed and isci_dev_gone functions.
333 */
334 sas_phy_disconnected(&isci_phy->sas_phy);
335 isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy,
336 PHYE_LOSS_OF_SIGNAL);
337
338 isci_phy->isci_port = NULL;
339
340 dev_dbg(&isci_host->pdev->dev,
341 "%s: isci_port = %p - Done\n", __func__, isci_port);
342}
343
344
345/**
Dan Williams6f231dd2011-07-02 22:56:22 -0700346 * isci_port_ready() - This function is called by the sci core when a link
347 * becomes ready.
348 * @isci_host: This parameter specifies the isci host object.
349 * @port: This parameter specifies the sci port with the active link.
350 *
351 */
Dan Williamse2f8db52011-05-10 02:28:46 -0700352static void isci_port_ready(struct isci_host *isci_host, struct isci_port *isci_port)
Dan Williams6f231dd2011-07-02 22:56:22 -0700353{
354 dev_dbg(&isci_host->pdev->dev,
355 "%s: isci_port = %p\n", __func__, isci_port);
356
357 complete_all(&isci_port->start_complete);
358 isci_port_change_state(isci_port, isci_ready);
359 return;
360}
361
362/**
363 * isci_port_not_ready() - This function is called by the sci core when a link
364 * is not ready. All remote devices on this link will be removed if they are
365 * in the stopping state.
366 * @isci_host: This parameter specifies the isci host object.
367 * @port: This parameter specifies the sci port with the active link.
368 *
369 */
Dan Williamse2f8db52011-05-10 02:28:46 -0700370static void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *isci_port)
Dan Williams6f231dd2011-07-02 22:56:22 -0700371{
372 dev_dbg(&isci_host->pdev->dev,
373 "%s: isci_port = %p\n", __func__, isci_port);
374}
375
Dan Williamse2f8db52011-05-10 02:28:46 -0700376static void isci_port_stop_complete(struct scic_sds_controller *scic,
377 struct scic_sds_port *sci_port,
378 enum sci_status completion_status)
379{
380 dev_dbg(&scic_to_ihost(scic)->pdev->dev, "Port stop complete\n");
381}
382
Dan Williams6f231dd2011-07-02 22:56:22 -0700383/**
384 * isci_port_hard_reset_complete() - This function is called by the sci core
385 * when the hard reset complete notification has been received.
386 * @port: This parameter specifies the sci port with the active link.
387 * @completion_status: This parameter specifies the core status for the reset
388 * process.
389 *
390 */
Dan Williamse2f8db52011-05-10 02:28:46 -0700391static void isci_port_hard_reset_complete(struct isci_port *isci_port,
392 enum sci_status completion_status)
Dan Williams6f231dd2011-07-02 22:56:22 -0700393{
394 dev_dbg(&isci_port->isci_host->pdev->dev,
395 "%s: isci_port = %p, completion_status=%x\n",
396 __func__, isci_port, completion_status);
397
398 /* Save the status of the hard reset from the port. */
399 isci_port->hard_reset_status = completion_status;
400
401 complete_all(&isci_port->hard_reset_complete);
402}
Dan Williams4393aa42011-03-31 13:10:44 -0700403
Dan Williamse2f8db52011-05-10 02:28:46 -0700404/* This method will return a true value if the specified phy can be assigned to
405 * this port The following is a list of phys for each port that are allowed: -
406 * Port 0 - 3 2 1 0 - Port 1 - 1 - Port 2 - 3 2 - Port 3 - 3 This method
407 * doesn't preclude all configurations. It merely ensures that a phy is part
408 * of the allowable set of phy identifiers for that port. For example, one
409 * could assign phy 3 to port 0 and no other phys. Please refer to
410 * scic_sds_port_is_phy_mask_valid() for information regarding whether the
411 * phy_mask for a port can be supported. bool true if this is a valid phy
412 * assignment for the port false if this is not a valid phy assignment for the
413 * port
414 */
415bool scic_sds_port_is_valid_phy_assignment(struct scic_sds_port *sci_port,
416 u32 phy_index)
417{
418 /* Initialize to invalid value. */
419 u32 existing_phy_index = SCI_MAX_PHYS;
420 u32 index;
421
422 if ((sci_port->physical_port_index == 1) && (phy_index != 1)) {
423 return false;
424 }
425
426 if (sci_port->physical_port_index == 3 && phy_index != 3) {
427 return false;
428 }
429
430 if (
431 (sci_port->physical_port_index == 2)
432 && ((phy_index == 0) || (phy_index == 1))
433 ) {
434 return false;
435 }
436
437 for (index = 0; index < SCI_MAX_PHYS; index++) {
438 if ((sci_port->phy_table[index] != NULL)
439 && (index != phy_index)) {
440 existing_phy_index = index;
441 }
442 }
443
444 /*
445 * Ensure that all of the phys in the port are capable of
446 * operating at the same maximum link rate. */
447 if (
448 (existing_phy_index < SCI_MAX_PHYS)
449 && (sci_port->owning_controller->user_parameters.sds1.phys[
450 phy_index].max_speed_generation !=
451 sci_port->owning_controller->user_parameters.sds1.phys[
452 existing_phy_index].max_speed_generation)
453 )
454 return false;
455
456 return true;
457}
458
459/**
460 *
461 * @sci_port: This is the port object for which to determine if the phy mask
462 * can be supported.
463 *
464 * This method will return a true value if the port's phy mask can be supported
465 * by the SCU. The following is a list of valid PHY mask configurations for
466 * each port: - Port 0 - [[3 2] 1] 0 - Port 1 - [1] - Port 2 - [[3] 2]
467 * - Port 3 - [3] This method returns a boolean indication specifying if the
468 * phy mask can be supported. true if this is a valid phy assignment for the
469 * port false if this is not a valid phy assignment for the port
470 */
471static bool scic_sds_port_is_phy_mask_valid(
472 struct scic_sds_port *sci_port,
473 u32 phy_mask)
474{
475 if (sci_port->physical_port_index == 0) {
476 if (((phy_mask & 0x0F) == 0x0F)
477 || ((phy_mask & 0x03) == 0x03)
478 || ((phy_mask & 0x01) == 0x01)
479 || (phy_mask == 0))
480 return true;
481 } else if (sci_port->physical_port_index == 1) {
482 if (((phy_mask & 0x02) == 0x02)
483 || (phy_mask == 0))
484 return true;
485 } else if (sci_port->physical_port_index == 2) {
486 if (((phy_mask & 0x0C) == 0x0C)
487 || ((phy_mask & 0x04) == 0x04)
488 || (phy_mask == 0))
489 return true;
490 } else if (sci_port->physical_port_index == 3) {
491 if (((phy_mask & 0x08) == 0x08)
492 || (phy_mask == 0))
493 return true;
494 }
495
496 return false;
497}
498
499/**
500 *
501 * @sci_port: This parameter specifies the port from which to return a
502 * connected phy.
503 *
504 * This method retrieves a currently active (i.e. connected) phy contained in
505 * the port. Currently, the lowest order phy that is connected is returned.
506 * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is
507 * returned if there are no currently active (i.e. connected to a remote end
508 * point) phys contained in the port. All other values specify a struct scic_sds_phy
509 * object that is active in the port.
510 */
511static struct scic_sds_phy *scic_sds_port_get_a_connected_phy(
512 struct scic_sds_port *sci_port
513 ) {
514 u32 index;
515 struct scic_sds_phy *phy;
516
517 for (index = 0; index < SCI_MAX_PHYS; index++) {
518 /*
519 * Ensure that the phy is both part of the port and currently
520 * connected to the remote end-point. */
521 phy = sci_port->phy_table[index];
522 if (
523 (phy != NULL)
524 && scic_sds_port_active_phy(sci_port, phy)
525 ) {
526 return phy;
527 }
528 }
529
530 return NULL;
531}
532
533/**
534 * scic_sds_port_set_phy() -
535 * @out]: port The port object to which the phy assignement is being made.
536 * @out]: phy The phy which is being assigned to the port.
537 *
538 * This method attempts to make the assignment of the phy to the port. If
539 * successful the phy is assigned to the ports phy table. bool true if the phy
540 * assignment can be made. false if the phy assignement can not be made. This
541 * is a functional test that only fails if the phy is currently assigned to a
542 * different port.
543 */
544static enum sci_status scic_sds_port_set_phy(
545 struct scic_sds_port *port,
546 struct scic_sds_phy *phy)
547{
548 /*
549 * Check to see if we can add this phy to a port
550 * that means that the phy is not part of a port and that the port does
551 * not already have a phy assinged to the phy index. */
552 if (
553 (port->phy_table[phy->phy_index] == NULL)
Dan Williams4f20ef42011-05-12 06:00:31 -0700554 && (phy_get_non_dummy_port(phy) == NULL)
Dan Williamse2f8db52011-05-10 02:28:46 -0700555 && scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)
556 ) {
557 /*
558 * Phy is being added in the stopped state so we are in MPC mode
559 * make logical port index = physical port index */
560 port->logical_port_index = port->physical_port_index;
561 port->phy_table[phy->phy_index] = phy;
562 scic_sds_phy_set_port(phy, port);
563
564 return SCI_SUCCESS;
565 }
566
567 return SCI_FAILURE;
568}
569
570/**
571 * scic_sds_port_clear_phy() -
572 * @out]: port The port from which the phy is being cleared.
573 * @out]: phy The phy being cleared from the port.
574 *
575 * This method will clear the phy assigned to this port. This method fails if
576 * this phy is not currently assinged to this port. bool true if the phy is
577 * removed from the port. false if this phy is not assined to this port.
578 */
579static enum sci_status scic_sds_port_clear_phy(
580 struct scic_sds_port *port,
581 struct scic_sds_phy *phy)
582{
583 /* Make sure that this phy is part of this port */
584 if (port->phy_table[phy->phy_index] == phy &&
Dan Williams4f20ef42011-05-12 06:00:31 -0700585 phy_get_non_dummy_port(phy) == port) {
Dan Williamse2f8db52011-05-10 02:28:46 -0700586 struct scic_sds_controller *scic = port->owning_controller;
587 struct isci_host *ihost = scic_to_ihost(scic);
588
589 /* Yep it is assigned to this port so remove it */
590 scic_sds_phy_set_port(phy, &ihost->ports[SCI_MAX_PORTS].sci);
591 port->phy_table[phy->phy_index] = NULL;
592 return SCI_SUCCESS;
593 }
594
595 return SCI_FAILURE;
596}
597
Dan Williamse2f8db52011-05-10 02:28:46 -0700598
599/**
600 * This method requests the SAS address for the supplied SAS port from the SCI
601 * implementation.
602 * @sci_port: a handle corresponding to the SAS port for which to return the
603 * SAS address.
604 * @sas_address: This parameter specifies a pointer to a SAS address structure
605 * into which the core will copy the SAS address for the port.
606 *
607 */
608void scic_sds_port_get_sas_address(
609 struct scic_sds_port *sci_port,
610 struct sci_sas_address *sas_address)
611{
612 u32 index;
613
614 sas_address->high = 0;
615 sas_address->low = 0;
616
617 for (index = 0; index < SCI_MAX_PHYS; index++) {
618 if (sci_port->phy_table[index] != NULL) {
619 scic_sds_phy_get_sas_address(sci_port->phy_table[index], sas_address);
620 }
621 }
622}
623
624/*
625 * This function requests the SAS address for the device directly attached to
626 * this SAS port.
627 * @sci_port: a handle corresponding to the SAS port for which to return the
628 * SAS address.
629 * @sas_address: This parameter specifies a pointer to a SAS address structure
630 * into which the core will copy the SAS address for the device directly
631 * attached to the port.
632 *
633 */
634void scic_sds_port_get_attached_sas_address(
635 struct scic_sds_port *sci_port,
636 struct sci_sas_address *sas_address)
637{
638 struct scic_sds_phy *sci_phy;
639
640 /*
641 * Ensure that the phy is both part of the port and currently
642 * connected to the remote end-point.
643 */
644 sci_phy = scic_sds_port_get_a_connected_phy(sci_port);
645 if (sci_phy) {
646 if (sci_phy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) {
647 scic_sds_phy_get_attached_sas_address(sci_phy,
648 sas_address);
649 } else {
650 scic_sds_phy_get_sas_address(sci_phy, sas_address);
651 sas_address->low += sci_phy->phy_index;
652 }
653 } else {
654 sas_address->high = 0;
655 sas_address->low = 0;
656 }
657}
658
659/**
660 * scic_sds_port_construct_dummy_rnc() - create dummy rnc for si workaround
661 *
662 * @sci_port: logical port on which we need to create the remote node context
663 * @rni: remote node index for this remote node context.
664 *
665 * This routine will construct a dummy remote node context data structure
666 * This structure will be posted to the hardware to work around a scheduler
667 * error in the hardware.
668 */
669static void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u16 rni)
670{
671 union scu_remote_node_context *rnc;
672
673 rnc = &sci_port->owning_controller->remote_node_context_table[rni];
674
675 memset(rnc, 0, sizeof(union scu_remote_node_context));
676
677 rnc->ssp.remote_sas_address_hi = 0;
678 rnc->ssp.remote_sas_address_lo = 0;
679
680 rnc->ssp.remote_node_index = rni;
681 rnc->ssp.remote_node_port_width = 1;
682 rnc->ssp.logical_port_index = sci_port->physical_port_index;
683
684 rnc->ssp.nexus_loss_timer_enable = false;
685 rnc->ssp.check_bit = false;
686 rnc->ssp.is_valid = true;
687 rnc->ssp.is_remote_node_context = true;
688 rnc->ssp.function_number = 0;
689 rnc->ssp.arbitration_wait_time = 0;
690}
691
692/**
693 * scic_sds_port_construct_dummy_task() - create dummy task for si workaround
694 * @sci_port The logical port on which we need to create the
695 * remote node context.
696 * context.
697 * @tci The remote node index for this remote node context.
698 *
699 * This routine will construct a dummy task context data structure. This
700 * structure will be posted to the hardwre to work around a scheduler error
701 * in the hardware.
702 *
703 */
704static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tci)
705{
706 struct scu_task_context *task_context;
707
708 task_context = scic_sds_controller_get_task_context_buffer(sci_port->owning_controller, tci);
709
710 memset(task_context, 0, sizeof(struct scu_task_context));
711
712 task_context->abort = 0;
713 task_context->priority = 0;
714 task_context->initiator_request = 1;
715 task_context->connection_rate = 1;
716 task_context->protocol_engine_index = 0;
717 task_context->logical_port_index = sci_port->physical_port_index;
718 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP;
719 task_context->task_index = scic_sds_io_tag_get_index(tci);
720 task_context->valid = SCU_TASK_CONTEXT_VALID;
721 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
722
723 task_context->remote_node_index = sci_port->reserved_rni;
724 task_context->command_code = 0;
725
726 task_context->link_layer_control = 0;
727 task_context->do_not_dma_ssp_good_response = 1;
728 task_context->strict_ordering = 0;
729 task_context->control_frame = 0;
730 task_context->timeout_enable = 0;
731 task_context->block_guard_enable = 0;
732
733 task_context->address_modifier = 0;
734
735 task_context->task_phase = 0x01;
736}
737
738static void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port)
739{
740 struct scic_sds_controller *scic = sci_port->owning_controller;
741
742 if (sci_port->reserved_tci != SCU_DUMMY_INDEX)
743 scic_controller_free_io_tag(scic, sci_port->reserved_tci);
744
745 if (sci_port->reserved_rni != SCU_DUMMY_INDEX)
746 scic_sds_remote_node_table_release_remote_node_index(&scic->available_remote_nodes,
747 1, sci_port->reserved_rni);
748
749 sci_port->reserved_rni = SCU_DUMMY_INDEX;
750 sci_port->reserved_tci = SCU_DUMMY_INDEX;
751}
752
753/**
754 * This method performs initialization of the supplied port. Initialization
755 * includes: - state machine initialization - member variable initialization
756 * - configuring the phy_mask
757 * @sci_port:
758 * @transport_layer_registers:
759 * @port_task_scheduler_registers:
760 * @port_configuration_regsiter:
761 *
762 * enum sci_status SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION This value is returned
763 * if the phy being added to the port
764 */
765enum sci_status scic_sds_port_initialize(
766 struct scic_sds_port *sci_port,
767 void __iomem *port_task_scheduler_registers,
768 void __iomem *port_configuration_regsiter,
769 void __iomem *viit_registers)
770{
771 sci_port->port_task_scheduler_registers = port_task_scheduler_registers;
772 sci_port->port_pe_configuration_register = port_configuration_regsiter;
773 sci_port->viit_registers = viit_registers;
774
775 return SCI_SUCCESS;
776}
777
Dan Williamse2f8db52011-05-10 02:28:46 -0700778
779/**
780 * This method assigns the direct attached device ID for this port.
781 *
782 * @param[in] sci_port The port for which the direct attached device id is to
783 * be assigned.
784 * @param[in] device_id The direct attached device ID to assign to the port.
785 * This will be the RNi for the device
786 */
787void scic_sds_port_setup_transports(
788 struct scic_sds_port *sci_port,
789 u32 device_id)
790{
791 u8 index;
792
793 for (index = 0; index < SCI_MAX_PHYS; index++) {
794 if (sci_port->active_phy_mask & (1 << index))
795 scic_sds_phy_setup_transport(sci_port->phy_table[index], device_id);
796 }
797}
798
799/**
800 *
801 * @sci_port: This is the port on which the phy should be enabled.
802 * @sci_phy: This is the specific phy which to enable.
803 * @do_notify_user: This parameter specifies whether to inform the user (via
804 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
805 *
806 * This function will activate the phy in the port.
807 * Activation includes: - adding
808 * the phy to the port - enabling the Protocol Engine in the silicon. -
809 * notifying the user that the link is up. none
810 */
811static void scic_sds_port_activate_phy(struct scic_sds_port *sci_port,
812 struct scic_sds_phy *sci_phy,
813 bool do_notify_user)
814{
815 struct scic_sds_controller *scic = sci_port->owning_controller;
816 struct isci_host *ihost = scic_to_ihost(scic);
817
818 if (sci_phy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA)
819 scic_sds_phy_resume(sci_phy);
820
821 sci_port->active_phy_mask |= 1 << sci_phy->phy_index;
822
823 scic_sds_controller_clear_invalid_phy(scic, sci_phy);
824
825 if (do_notify_user == true)
826 isci_port_link_up(ihost, sci_port, sci_phy);
827}
828
829void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
830 struct scic_sds_phy *sci_phy,
831 bool do_notify_user)
832{
833 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
834 struct isci_port *iport = sci_port_to_iport(sci_port);
835 struct isci_host *ihost = scic_to_ihost(scic);
836 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
837
838 sci_port->active_phy_mask &= ~(1 << sci_phy->phy_index);
839
840 sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
841
842 /* Re-assign the phy back to the LP as if it were a narrow port */
843 writel(sci_phy->phy_index,
844 &sci_port->port_pe_configuration_register[sci_phy->phy_index]);
845
846 if (do_notify_user == true)
847 isci_port_link_down(ihost, iphy, iport);
848}
849
850/**
851 *
852 * @sci_port: This is the port on which the phy should be disabled.
853 * @sci_phy: This is the specific phy which to disabled.
854 *
855 * This function will disable the phy and report that the phy is not valid for
856 * this port object. None
857 */
858static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port,
859 struct scic_sds_phy *sci_phy)
860{
861 struct scic_sds_controller *scic = sci_port->owning_controller;
862
863 /*
864 * Check to see if we have alreay reported this link as bad and if
865 * not go ahead and tell the SCI_USER that we have discovered an
866 * invalid link.
867 */
868 if ((scic->invalid_phy_mask & (1 << sci_phy->phy_index)) == 0) {
869 scic_sds_controller_set_invalid_phy(scic, sci_phy);
870 dev_warn(&scic_to_ihost(scic)->pdev->dev, "Invalid link up!\n");
871 }
872}
873
Piotr Sawickie91f41e2011-05-11 23:52:21 +0000874static bool is_port_ready_state(enum scic_sds_port_states state)
875{
876 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000877 case SCI_PORT_READY:
878 case SCI_PORT_SUB_WAITING:
879 case SCI_PORT_SUB_OPERATIONAL:
880 case SCI_PORT_SUB_CONFIGURING:
Piotr Sawickie91f41e2011-05-11 23:52:21 +0000881 return true;
882 default:
883 return false;
884 }
885}
886
887/* flag dummy rnc hanling when exiting a ready state */
888static void port_state_machine_change(struct scic_sds_port *sci_port,
889 enum scic_sds_port_states state)
890{
Edmund Nadolskie3013702011-06-02 00:10:43 +0000891 struct sci_base_state_machine *sm = &sci_port->sm;
Piotr Sawickie91f41e2011-05-11 23:52:21 +0000892 enum scic_sds_port_states old_state = sm->current_state_id;
893
894 if (is_port_ready_state(old_state) && !is_port_ready_state(state))
895 sci_port->ready_exit = true;
896
Edmund Nadolskie3013702011-06-02 00:10:43 +0000897 sci_change_state(sm, state);
Piotr Sawickie91f41e2011-05-11 23:52:21 +0000898 sci_port->ready_exit = false;
899}
900
Dan Williamse2f8db52011-05-10 02:28:46 -0700901/**
902 * scic_sds_port_general_link_up_handler - phy can be assigned to port?
903 * @sci_port: scic_sds_port object for which has a phy that has gone link up.
904 * @sci_phy: This is the struct scic_sds_phy object that has gone link up.
905 * @do_notify_user: This parameter specifies whether to inform the user (via
906 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
907 *
908 * Determine if this phy can be assigned to this
909 * port . If the phy is not a valid PHY for
910 * this port then the function will notify the user. A PHY can only be
911 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in
912 * the same port. none
913 */
914static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port,
915 struct scic_sds_phy *sci_phy,
916 bool do_notify_user)
917{
918 struct sci_sas_address port_sas_address;
919 struct sci_sas_address phy_sas_address;
920
921 scic_sds_port_get_attached_sas_address(sci_port, &port_sas_address);
922 scic_sds_phy_get_attached_sas_address(sci_phy, &phy_sas_address);
923
924 /* If the SAS address of the new phy matches the SAS address of
925 * other phys in the port OR this is the first phy in the port,
926 * then activate the phy and allow it to be used for operations
927 * in this port.
928 */
929 if ((phy_sas_address.high == port_sas_address.high &&
930 phy_sas_address.low == port_sas_address.low) ||
931 sci_port->active_phy_mask == 0) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000932 struct sci_base_state_machine *sm = &sci_port->sm;
Dan Williamse2f8db52011-05-10 02:28:46 -0700933
934 scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user);
Edmund Nadolskie3013702011-06-02 00:10:43 +0000935 if (sm->current_state_id == SCI_PORT_RESETTING)
936 port_state_machine_change(sci_port, SCI_PORT_READY);
Dan Williamse2f8db52011-05-10 02:28:46 -0700937 } else
938 scic_sds_port_invalid_link_up(sci_port, sci_phy);
939}
940
941
942
943/**
944 * This method returns false if the port only has a single phy object assigned.
945 * If there are no phys or more than one phy then the method will return
946 * true.
947 * @sci_port: The port for which the wide port condition is to be checked.
948 *
949 * bool true Is returned if this is a wide ported port. false Is returned if
950 * this is a narrow port.
951 */
952static bool scic_sds_port_is_wide(struct scic_sds_port *sci_port)
953{
954 u32 index;
955 u32 phy_count = 0;
956
957 for (index = 0; index < SCI_MAX_PHYS; index++) {
958 if (sci_port->phy_table[index] != NULL) {
959 phy_count++;
960 }
961 }
962
963 return phy_count != 1;
964}
965
966/**
967 * This method is called by the PHY object when the link is detected. if the
968 * port wants the PHY to continue on to the link up state then the port
969 * layer must return true. If the port object returns false the phy object
970 * must halt its attempt to go link up.
971 * @sci_port: The port associated with the phy object.
972 * @sci_phy: The phy object that is trying to go link up.
973 *
974 * true if the phy object can continue to the link up condition. true Is
975 * returned if this phy can continue to the ready state. false Is returned if
976 * can not continue on to the ready state. This notification is in place for
977 * wide ports and direct attached phys. Since there are no wide ported SATA
978 * devices this could become an invalid port configuration.
979 */
980bool scic_sds_port_link_detected(
981 struct scic_sds_port *sci_port,
982 struct scic_sds_phy *sci_phy)
983{
984 if ((sci_port->logical_port_index != SCIC_SDS_DUMMY_PORT) &&
985 (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) &&
986 scic_sds_port_is_wide(sci_port)) {
987 scic_sds_port_invalid_link_up(sci_port, sci_phy);
988
989 return false;
990 }
991
992 return true;
993}
994
Edmund Nadolski5553ba22011-05-19 11:59:10 +0000995static void port_timeout(unsigned long data)
Dan Williamse2f8db52011-05-10 02:28:46 -0700996{
Edmund Nadolski5553ba22011-05-19 11:59:10 +0000997 struct sci_timer *tmr = (struct sci_timer *)data;
998 struct scic_sds_port *sci_port = container_of(tmr, typeof(*sci_port), timer);
999 struct isci_host *ihost = scic_to_ihost(sci_port->owning_controller);
1000 unsigned long flags;
Dan Williamse2f8db52011-05-10 02:28:46 -07001001 u32 current_state;
1002
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001003 spin_lock_irqsave(&ihost->scic_lock, flags);
1004
1005 if (tmr->cancel)
1006 goto done;
1007
Edmund Nadolskie3013702011-06-02 00:10:43 +00001008 current_state = sci_port->sm.current_state_id;
Dan Williamse2f8db52011-05-10 02:28:46 -07001009
Edmund Nadolskie3013702011-06-02 00:10:43 +00001010 if (current_state == SCI_PORT_RESETTING) {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001011 /* if the port is still in the resetting state then the timeout
1012 * fired before the reset completed.
Dan Williamse2f8db52011-05-10 02:28:46 -07001013 */
Edmund Nadolskie3013702011-06-02 00:10:43 +00001014 port_state_machine_change(sci_port, SCI_PORT_FAILED);
1015 } else if (current_state == SCI_PORT_STOPPED) {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001016 /* if the port is stopped then the start request failed In this
1017 * case stay in the stopped state.
Dan Williamse2f8db52011-05-10 02:28:46 -07001018 */
1019 dev_err(sciport_to_dev(sci_port),
1020 "%s: SCIC Port 0x%p failed to stop before tiemout.\n",
1021 __func__,
1022 sci_port);
Edmund Nadolskie3013702011-06-02 00:10:43 +00001023 } else if (current_state == SCI_PORT_STOPPING) {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001024 /* if the port is still stopping then the stop has not completed */
1025 isci_port_stop_complete(sci_port->owning_controller,
1026 sci_port,
1027 SCI_FAILURE_TIMEOUT);
Dan Williamse2f8db52011-05-10 02:28:46 -07001028 } else {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001029 /* The port is in the ready state and we have a timer
Dan Williamse2f8db52011-05-10 02:28:46 -07001030 * reporting a timeout this should not happen.
1031 */
1032 dev_err(sciport_to_dev(sci_port),
1033 "%s: SCIC Port 0x%p is processing a timeout operation "
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001034 "in state %d.\n", __func__, sci_port, current_state);
Dan Williamse2f8db52011-05-10 02:28:46 -07001035 }
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001036
1037done:
1038 spin_unlock_irqrestore(&ihost->scic_lock, flags);
Dan Williamse2f8db52011-05-10 02:28:46 -07001039}
1040
1041/* --------------------------------------------------------------------------- */
1042
1043/**
1044 * This function updates the hardwares VIIT entry for this port.
1045 *
1046 *
1047 */
1048static void scic_sds_port_update_viit_entry(struct scic_sds_port *sci_port)
1049{
1050 struct sci_sas_address sas_address;
1051
1052 scic_sds_port_get_sas_address(sci_port, &sas_address);
1053
1054 writel(sas_address.high,
1055 &sci_port->viit_registers->initiator_sas_address_hi);
1056 writel(sas_address.low,
1057 &sci_port->viit_registers->initiator_sas_address_lo);
1058
1059 /* This value get cleared just in case its not already cleared */
1060 writel(0, &sci_port->viit_registers->reserved);
1061
1062 /* We are required to update the status register last */
1063 writel(SCU_VIIT_ENTRY_ID_VIIT |
1064 SCU_VIIT_IPPT_INITIATOR |
1065 ((1 << sci_port->physical_port_index) << SCU_VIIT_ENTRY_LPVIE_SHIFT) |
1066 SCU_VIIT_STATUS_ALL_VALID,
1067 &sci_port->viit_registers->status);
1068}
1069
1070/**
1071 * This method returns the maximum allowed speed for data transfers on this
1072 * port. This maximum allowed speed evaluates to the maximum speed of the
1073 * slowest phy in the port.
1074 * @sci_port: This parameter specifies the port for which to retrieve the
1075 * maximum allowed speed.
1076 *
1077 * This method returns the maximum negotiated speed of the slowest phy in the
1078 * port.
1079 */
1080enum sas_linkrate scic_sds_port_get_max_allowed_speed(
1081 struct scic_sds_port *sci_port)
1082{
1083 u16 index;
1084 enum sas_linkrate max_allowed_speed = SAS_LINK_RATE_6_0_GBPS;
1085 struct scic_sds_phy *phy = NULL;
1086
1087 /*
1088 * Loop through all of the phys in this port and find the phy with the
1089 * lowest maximum link rate. */
1090 for (index = 0; index < SCI_MAX_PHYS; index++) {
1091 phy = sci_port->phy_table[index];
1092 if (
1093 (phy != NULL)
1094 && (scic_sds_port_active_phy(sci_port, phy) == true)
1095 && (phy->max_negotiated_speed < max_allowed_speed)
1096 )
1097 max_allowed_speed = phy->max_negotiated_speed;
1098 }
1099
1100 return max_allowed_speed;
1101}
1102
Dan Williamse2f8db52011-05-10 02:28:46 -07001103/**
1104 *
1105 * @sci_port: This is the struct scic_sds_port object to suspend.
1106 *
1107 * This method will susped the port task scheduler for this port object. none
1108 */
1109static void
1110scic_sds_port_suspend_port_task_scheduler(struct scic_sds_port *port)
1111{
1112 u32 pts_control_value;
1113
1114 pts_control_value = readl(&port->port_task_scheduler_registers->control);
1115 pts_control_value |= SCU_PTSxCR_GEN_BIT(SUSPEND);
1116 writel(pts_control_value, &port->port_task_scheduler_registers->control);
1117}
1118
1119/**
1120 * scic_sds_port_post_dummy_request() - post dummy/workaround request
1121 * @sci_port: port to post task
1122 *
1123 * Prevent the hardware scheduler from posting new requests to the front
1124 * of the scheduler queue causing a starvation problem for currently
1125 * ongoing requests.
1126 *
1127 */
1128static void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port)
1129{
1130 u32 command;
1131 struct scu_task_context *task_context;
1132 struct scic_sds_controller *scic = sci_port->owning_controller;
1133 u16 tci = sci_port->reserved_tci;
1134
1135 task_context = scic_sds_controller_get_task_context_buffer(scic, tci);
1136
1137 task_context->abort = 0;
1138
1139 command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
1140 sci_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1141 tci;
1142
1143 scic_sds_controller_post_request(scic, command);
1144}
1145
1146/**
1147 * This routine will abort the dummy request. This will alow the hardware to
1148 * power down parts of the silicon to save power.
1149 *
1150 * @sci_port: The port on which the task must be aborted.
1151 *
1152 */
1153static void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port)
1154{
1155 struct scic_sds_controller *scic = sci_port->owning_controller;
1156 u16 tci = sci_port->reserved_tci;
1157 struct scu_task_context *tc;
1158 u32 command;
1159
1160 tc = scic_sds_controller_get_task_context_buffer(scic, tci);
1161
1162 tc->abort = 1;
1163
1164 command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT |
1165 sci_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1166 tci;
1167
1168 scic_sds_controller_post_request(scic, command);
1169}
1170
1171/**
1172 *
1173 * @sci_port: This is the struct scic_sds_port object to resume.
1174 *
1175 * This method will resume the port task scheduler for this port object. none
1176 */
1177static void
1178scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port)
1179{
1180 u32 pts_control_value;
1181
1182 pts_control_value = readl(&port->port_task_scheduler_registers->control);
1183 pts_control_value &= ~SCU_PTSxCR_GEN_BIT(SUSPEND);
1184 writel(pts_control_value, &port->port_task_scheduler_registers->control);
1185}
1186
Dan Williams9269e0e2011-05-12 07:42:17 -07001187static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001188{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001189 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001190
Dan Williamse2f8db52011-05-10 02:28:46 -07001191 scic_sds_port_suspend_port_task_scheduler(sci_port);
1192
1193 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS;
1194
1195 if (sci_port->active_phy_mask != 0) {
1196 /* At least one of the phys on the port is ready */
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001197 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001198 SCI_PORT_SUB_OPERATIONAL);
Dan Williamse2f8db52011-05-10 02:28:46 -07001199 }
1200}
1201
Dan Williams9269e0e2011-05-12 07:42:17 -07001202static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001203{
1204 u32 index;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001205 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001206 struct scic_sds_controller *scic = sci_port->owning_controller;
1207 struct isci_host *ihost = scic_to_ihost(scic);
1208 struct isci_port *iport = sci_port_to_iport(sci_port);
1209
Dan Williamse2f8db52011-05-10 02:28:46 -07001210 isci_port_ready(ihost, iport);
1211
1212 for (index = 0; index < SCI_MAX_PHYS; index++) {
1213 if (sci_port->phy_table[index]) {
1214 writel(sci_port->physical_port_index,
1215 &sci_port->port_pe_configuration_register[
1216 sci_port->phy_table[index]->phy_index]);
1217 }
1218 }
1219
1220 scic_sds_port_update_viit_entry(sci_port);
1221
1222 scic_sds_port_resume_port_task_scheduler(sci_port);
1223
1224 /*
1225 * Post the dummy task for the port so the hardware can schedule
1226 * io correctly
1227 */
1228 scic_sds_port_post_dummy_request(sci_port);
1229}
1230
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001231static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci_port)
1232{
1233 struct scic_sds_controller *scic = sci_port->owning_controller;
1234 u8 phys_index = sci_port->physical_port_index;
1235 union scu_remote_node_context *rnc;
1236 u16 rni = sci_port->reserved_rni;
1237 u32 command;
1238
1239 rnc = &scic->remote_node_context_table[rni];
1240
1241 rnc->ssp.is_valid = false;
1242
1243 /* ensure the preceding tc abort request has reached the
1244 * controller and give it ample time to act before posting the rnc
1245 * invalidate
1246 */
1247 readl(&scic->smu_registers->interrupt_status); /* flush */
1248 udelay(10);
1249
1250 command = SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE |
1251 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1252
1253 scic_sds_controller_post_request(scic, command);
1254}
1255
Dan Williamse2f8db52011-05-10 02:28:46 -07001256/**
1257 *
1258 * @object: This is the object which is cast to a struct scic_sds_port object.
1259 *
1260 * This method will perform the actions required by the struct scic_sds_port on
Edmund Nadolskie3013702011-06-02 00:10:43 +00001261 * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports
Dan Williamse2f8db52011-05-10 02:28:46 -07001262 * the port not ready and suspends the port task scheduler. none
1263 */
Dan Williams9269e0e2011-05-12 07:42:17 -07001264static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001265{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001266 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001267 struct scic_sds_controller *scic = sci_port->owning_controller;
1268 struct isci_host *ihost = scic_to_ihost(scic);
1269 struct isci_port *iport = sci_port_to_iport(sci_port);
1270
1271 /*
1272 * Kill the dummy task for this port if it has not yet posted
1273 * the hardware will treat this as a NOP and just return abort
1274 * complete.
1275 */
1276 scic_sds_port_abort_dummy_request(sci_port);
1277
1278 isci_port_not_ready(ihost, iport);
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001279
1280 if (sci_port->ready_exit)
1281 scic_sds_port_invalidate_dummy_remote_node(sci_port);
Dan Williamse2f8db52011-05-10 02:28:46 -07001282}
1283
Dan Williams9269e0e2011-05-12 07:42:17 -07001284static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001285{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001286 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001287 struct scic_sds_controller *scic = sci_port->owning_controller;
1288 struct isci_host *ihost = scic_to_ihost(scic);
1289 struct isci_port *iport = sci_port_to_iport(sci_port);
1290
Dan Williamse2f8db52011-05-10 02:28:46 -07001291 if (sci_port->active_phy_mask == 0) {
1292 isci_port_not_ready(ihost, iport);
1293
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001294 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001295 SCI_PORT_SUB_WAITING);
Dan Williamse2f8db52011-05-10 02:28:46 -07001296 } else if (sci_port->started_request_count == 0)
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001297 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001298 SCI_PORT_SUB_OPERATIONAL);
Dan Williamse2f8db52011-05-10 02:28:46 -07001299}
1300
Dan Williams9269e0e2011-05-12 07:42:17 -07001301static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001302{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001303 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001304
1305 scic_sds_port_suspend_port_task_scheduler(sci_port);
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001306 if (sci_port->ready_exit)
1307 scic_sds_port_invalidate_dummy_remote_node(sci_port);
Dan Williamse2f8db52011-05-10 02:28:46 -07001308}
1309
Piotr Sawickid76f71d2011-05-11 23:52:26 +00001310enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
1311{
1312 struct scic_sds_controller *scic = sci_port->owning_controller;
Piotr Sawickid76f71d2011-05-11 23:52:26 +00001313 enum sci_status status = SCI_SUCCESS;
1314 enum scic_sds_port_states state;
1315 u32 phy_mask;
1316
Edmund Nadolskie3013702011-06-02 00:10:43 +00001317 state = sci_port->sm.current_state_id;
1318 if (state != SCI_PORT_STOPPED) {
Piotr Sawickid76f71d2011-05-11 23:52:26 +00001319 dev_warn(sciport_to_dev(sci_port),
1320 "%s: in wrong state: %d\n", __func__, state);
1321 return SCI_FAILURE_INVALID_STATE;
1322 }
1323
1324 if (sci_port->assigned_device_count > 0) {
1325 /* TODO This is a start failure operation because
1326 * there are still devices assigned to this port.
1327 * There must be no devices assigned to a port on a
1328 * start operation.
1329 */
1330 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
1331 }
1332
Piotr Sawickid76f71d2011-05-11 23:52:26 +00001333 if (sci_port->reserved_rni == SCU_DUMMY_INDEX) {
1334 u16 rni = scic_sds_remote_node_table_allocate_remote_node(
1335 &scic->available_remote_nodes, 1);
1336
1337 if (rni != SCU_DUMMY_INDEX)
1338 scic_sds_port_construct_dummy_rnc(sci_port, rni);
1339 else
1340 status = SCI_FAILURE_INSUFFICIENT_RESOURCES;
1341 sci_port->reserved_rni = rni;
1342 }
1343
1344 if (sci_port->reserved_tci == SCU_DUMMY_INDEX) {
1345 /* Allocate a TCI and remove the sequence nibble */
1346 u16 tci = scic_controller_allocate_io_tag(scic);
1347
1348 if (tci != SCU_DUMMY_INDEX)
1349 scic_sds_port_construct_dummy_task(sci_port, tci);
1350 else
1351 status = SCI_FAILURE_INSUFFICIENT_RESOURCES;
1352 sci_port->reserved_tci = tci;
1353 }
1354
1355 if (status == SCI_SUCCESS) {
1356 phy_mask = scic_sds_port_get_phys(sci_port);
1357
1358 /*
1359 * There are one or more phys assigned to this port. Make sure
1360 * the port's phy mask is in fact legal and supported by the
1361 * silicon.
1362 */
1363 if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) {
1364 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001365 SCI_PORT_READY);
Piotr Sawickid76f71d2011-05-11 23:52:26 +00001366
1367 return SCI_SUCCESS;
1368 }
1369 status = SCI_FAILURE;
1370 }
1371
1372 if (status != SCI_SUCCESS)
1373 scic_sds_port_destroy_dummy_resources(sci_port);
1374
1375 return status;
1376}
1377
Piotr Sawicki8bc80d32011-05-11 23:52:31 +00001378enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port)
1379{
1380 enum scic_sds_port_states state;
1381
Edmund Nadolskie3013702011-06-02 00:10:43 +00001382 state = sci_port->sm.current_state_id;
Piotr Sawicki8bc80d32011-05-11 23:52:31 +00001383 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001384 case SCI_PORT_STOPPED:
Piotr Sawicki8bc80d32011-05-11 23:52:31 +00001385 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001386 case SCI_PORT_SUB_WAITING:
1387 case SCI_PORT_SUB_OPERATIONAL:
1388 case SCI_PORT_SUB_CONFIGURING:
1389 case SCI_PORT_RESETTING:
Piotr Sawicki8bc80d32011-05-11 23:52:31 +00001390 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001391 SCI_PORT_STOPPING);
Piotr Sawicki8bc80d32011-05-11 23:52:31 +00001392 return SCI_SUCCESS;
1393 default:
1394 dev_warn(sciport_to_dev(sci_port),
1395 "%s: in wrong state: %d\n", __func__, state);
1396 return SCI_FAILURE_INVALID_STATE;
1397 }
1398}
1399
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001400static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 timeout)
1401{
1402 enum sci_status status = SCI_FAILURE_INVALID_PHY;
1403 struct scic_sds_phy *selected_phy = NULL;
1404 enum scic_sds_port_states state;
1405 u32 phy_index;
1406
Edmund Nadolskie3013702011-06-02 00:10:43 +00001407 state = sci_port->sm.current_state_id;
1408 if (state != SCI_PORT_SUB_OPERATIONAL) {
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001409 dev_warn(sciport_to_dev(sci_port),
1410 "%s: in wrong state: %d\n", __func__, state);
1411 return SCI_FAILURE_INVALID_STATE;
1412 }
1413
1414 /* Select a phy on which we can send the hard reset request. */
1415 for (phy_index = 0; phy_index < SCI_MAX_PHYS && !selected_phy; phy_index++) {
1416 selected_phy = sci_port->phy_table[phy_index];
1417 if (selected_phy &&
1418 !scic_sds_port_active_phy(sci_port, selected_phy)) {
1419 /*
1420 * We found a phy but it is not ready select
1421 * different phy
1422 */
1423 selected_phy = NULL;
1424 }
1425 }
1426
1427 /* If we have a phy then go ahead and start the reset procedure */
1428 if (!selected_phy)
1429 return status;
1430 status = scic_sds_phy_reset(selected_phy);
1431
1432 if (status != SCI_SUCCESS)
1433 return status;
1434
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001435 sci_mod_timer(&sci_port->timer, timeout);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001436 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
1437
1438 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001439 SCI_PORT_RESETTING);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001440 return SCI_SUCCESS;
1441}
1442
1443/**
1444 * scic_sds_port_add_phy() -
1445 * @sci_port: This parameter specifies the port in which the phy will be added.
1446 * @sci_phy: This parameter is the phy which is to be added to the port.
1447 *
1448 * This method will add a PHY to the selected port. This method returns an
1449 * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other
1450 * status is a failure to add the phy to the port.
1451 */
1452enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1453 struct scic_sds_phy *sci_phy)
1454{
1455 enum sci_status status;
1456 enum scic_sds_port_states state;
1457
Edmund Nadolskie3013702011-06-02 00:10:43 +00001458 state = sci_port->sm.current_state_id;
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001459 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001460 case SCI_PORT_STOPPED: {
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001461 struct sci_sas_address port_sas_address;
1462
1463 /* Read the port assigned SAS Address if there is one */
1464 scic_sds_port_get_sas_address(sci_port, &port_sas_address);
1465
1466 if (port_sas_address.high != 0 && port_sas_address.low != 0) {
1467 struct sci_sas_address phy_sas_address;
1468
1469 /* Make sure that the PHY SAS Address matches the SAS Address
1470 * for this port
1471 */
1472 scic_sds_phy_get_sas_address(sci_phy, &phy_sas_address);
1473
1474 if (port_sas_address.high != phy_sas_address.high ||
1475 port_sas_address.low != phy_sas_address.low)
1476 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
1477 }
1478 return scic_sds_port_set_phy(sci_port, sci_phy);
1479 }
Edmund Nadolskie3013702011-06-02 00:10:43 +00001480 case SCI_PORT_SUB_WAITING:
1481 case SCI_PORT_SUB_OPERATIONAL:
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001482 status = scic_sds_port_set_phy(sci_port, sci_phy);
1483
1484 if (status != SCI_SUCCESS)
1485 return status;
1486
1487 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true);
1488 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001489 port_state_machine_change(sci_port, SCI_PORT_SUB_CONFIGURING);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001490
1491 return status;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001492 case SCI_PORT_SUB_CONFIGURING:
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001493 status = scic_sds_port_set_phy(sci_port, sci_phy);
1494
1495 if (status != SCI_SUCCESS)
1496 return status;
1497 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true);
1498
1499 /* Re-enter the configuring state since this may be the last phy in
1500 * the port.
1501 */
1502 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001503 SCI_PORT_SUB_CONFIGURING);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001504 return SCI_SUCCESS;
1505 default:
1506 dev_warn(sciport_to_dev(sci_port),
1507 "%s: in wrong state: %d\n", __func__, state);
1508 return SCI_FAILURE_INVALID_STATE;
1509 }
1510}
1511
1512/**
1513 * scic_sds_port_remove_phy() -
1514 * @sci_port: This parameter specifies the port in which the phy will be added.
1515 * @sci_phy: This parameter is the phy which is to be added to the port.
1516 *
1517 * This method will remove the PHY from the selected PORT. This method returns
1518 * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any
1519 * other status is a failure to add the phy to the port.
1520 */
1521enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
1522 struct scic_sds_phy *sci_phy)
1523{
1524 enum sci_status status;
1525 enum scic_sds_port_states state;
1526
Edmund Nadolskie3013702011-06-02 00:10:43 +00001527 state = sci_port->sm.current_state_id;
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001528
1529 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001530 case SCI_PORT_STOPPED:
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001531 return scic_sds_port_clear_phy(sci_port, sci_phy);
Edmund Nadolskie3013702011-06-02 00:10:43 +00001532 case SCI_PORT_SUB_OPERATIONAL:
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001533 status = scic_sds_port_clear_phy(sci_port, sci_phy);
1534 if (status != SCI_SUCCESS)
1535 return status;
1536
1537 scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
1538 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1539 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001540 SCI_PORT_SUB_CONFIGURING);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001541 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001542 case SCI_PORT_SUB_CONFIGURING:
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001543 status = scic_sds_port_clear_phy(sci_port, sci_phy);
1544
1545 if (status != SCI_SUCCESS)
1546 return status;
1547 scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
1548
1549 /* Re-enter the configuring state since this may be the last phy in
1550 * the port
1551 */
1552 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001553 SCI_PORT_SUB_CONFIGURING);
Piotr Sawicki051266c2011-05-12 19:10:14 +00001554 return SCI_SUCCESS;
1555 default:
1556 dev_warn(sciport_to_dev(sci_port),
1557 "%s: in wrong state: %d\n", __func__, state);
1558 return SCI_FAILURE_INVALID_STATE;
1559 }
1560}
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001561
Piotr Sawicki051266c2011-05-12 19:10:14 +00001562enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1563 struct scic_sds_phy *sci_phy)
1564{
1565 enum scic_sds_port_states state;
1566
Edmund Nadolskie3013702011-06-02 00:10:43 +00001567 state = sci_port->sm.current_state_id;
Piotr Sawicki051266c2011-05-12 19:10:14 +00001568 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001569 case SCI_PORT_SUB_WAITING:
Piotr Sawicki051266c2011-05-12 19:10:14 +00001570 /* Since this is the first phy going link up for the port we
1571 * can just enable it and continue
1572 */
1573 scic_sds_port_activate_phy(sci_port, sci_phy, true);
1574
1575 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001576 SCI_PORT_SUB_OPERATIONAL);
Piotr Sawicki051266c2011-05-12 19:10:14 +00001577 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001578 case SCI_PORT_SUB_OPERATIONAL:
Piotr Sawicki051266c2011-05-12 19:10:14 +00001579 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true);
1580 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001581 case SCI_PORT_RESETTING:
Piotr Sawicki051266c2011-05-12 19:10:14 +00001582 /* TODO We should make sure that the phy that has gone
1583 * link up is the same one on which we sent the reset. It is
1584 * possible that the phy on which we sent the reset is not the
1585 * one that has gone link up and we want to make sure that
1586 * phy being reset comes back. Consider the case where a
1587 * reset is sent but before the hardware processes the reset it
1588 * get a link up on the port because of a hot plug event.
1589 * because of the reset request this phy will go link down
1590 * almost immediately.
1591 */
1592
1593 /* In the resetting state we don't notify the user regarding
1594 * link up and link down notifications.
1595 */
1596 scic_sds_port_general_link_up_handler(sci_port, sci_phy, false);
1597 return SCI_SUCCESS;
1598 default:
1599 dev_warn(sciport_to_dev(sci_port),
1600 "%s: in wrong state: %d\n", __func__, state);
1601 return SCI_FAILURE_INVALID_STATE;
1602 }
1603}
1604
1605enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
1606 struct scic_sds_phy *sci_phy)
1607{
1608 enum scic_sds_port_states state;
1609
Edmund Nadolskie3013702011-06-02 00:10:43 +00001610 state = sci_port->sm.current_state_id;
Piotr Sawicki051266c2011-05-12 19:10:14 +00001611 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001612 case SCI_PORT_SUB_OPERATIONAL:
Piotr Sawicki051266c2011-05-12 19:10:14 +00001613 scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
1614
1615 /* If there are no active phys left in the port, then
1616 * transition the port to the WAITING state until such time
1617 * as a phy goes link up
1618 */
1619 if (sci_port->active_phy_mask == 0)
1620 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001621 SCI_PORT_SUB_WAITING);
Piotr Sawicki051266c2011-05-12 19:10:14 +00001622 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001623 case SCI_PORT_RESETTING:
Piotr Sawicki051266c2011-05-12 19:10:14 +00001624 /* In the resetting state we don't notify the user regarding
1625 * link up and link down notifications. */
1626 scic_sds_port_deactivate_phy(sci_port, sci_phy, false);
Piotr Sawickibd6713b2011-05-12 19:10:03 +00001627 return SCI_SUCCESS;
1628 default:
1629 dev_warn(sciport_to_dev(sci_port),
1630 "%s: in wrong state: %d\n", __func__, state);
1631 return SCI_FAILURE_INVALID_STATE;
1632 }
1633}
1634
Dan Williams68138202011-05-12 07:16:06 -07001635enum sci_status scic_sds_port_start_io(struct scic_sds_port *sci_port,
1636 struct scic_sds_remote_device *sci_dev,
1637 struct scic_sds_request *sci_req)
1638{
1639 enum scic_sds_port_states state;
Dan Williamse2f8db52011-05-10 02:28:46 -07001640
Edmund Nadolskie3013702011-06-02 00:10:43 +00001641 state = sci_port->sm.current_state_id;
Dan Williams68138202011-05-12 07:16:06 -07001642 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001643 case SCI_PORT_SUB_WAITING:
Dan Williams68138202011-05-12 07:16:06 -07001644 return SCI_FAILURE_INVALID_STATE;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001645 case SCI_PORT_SUB_OPERATIONAL:
Dan Williams68138202011-05-12 07:16:06 -07001646 sci_port->started_request_count++;
1647 return SCI_SUCCESS;
1648 default:
1649 dev_warn(sciport_to_dev(sci_port),
1650 "%s: in wrong state: %d\n", __func__, state);
1651 return SCI_FAILURE_INVALID_STATE;
1652 }
1653}
1654
1655enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port,
1656 struct scic_sds_remote_device *sci_dev,
1657 struct scic_sds_request *sci_req)
1658{
1659 enum scic_sds_port_states state;
1660
Edmund Nadolskie3013702011-06-02 00:10:43 +00001661 state = sci_port->sm.current_state_id;
Dan Williams68138202011-05-12 07:16:06 -07001662 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001663 case SCI_PORT_STOPPED:
Dan Williams68138202011-05-12 07:16:06 -07001664 dev_warn(sciport_to_dev(sci_port),
1665 "%s: in wrong state: %d\n", __func__, state);
1666 return SCI_FAILURE_INVALID_STATE;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001667 case SCI_PORT_STOPPING:
Dan Williams68138202011-05-12 07:16:06 -07001668 scic_sds_port_decrement_request_count(sci_port);
1669
1670 if (sci_port->started_request_count == 0)
1671 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001672 SCI_PORT_STOPPED);
Dan Williams68138202011-05-12 07:16:06 -07001673 break;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001674 case SCI_PORT_READY:
1675 case SCI_PORT_RESETTING:
1676 case SCI_PORT_FAILED:
1677 case SCI_PORT_SUB_WAITING:
1678 case SCI_PORT_SUB_OPERATIONAL:
Dan Williams68138202011-05-12 07:16:06 -07001679 scic_sds_port_decrement_request_count(sci_port);
1680 break;
Edmund Nadolskie3013702011-06-02 00:10:43 +00001681 case SCI_PORT_SUB_CONFIGURING:
Dan Williams68138202011-05-12 07:16:06 -07001682 scic_sds_port_decrement_request_count(sci_port);
1683 if (sci_port->started_request_count == 0) {
1684 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001685 SCI_PORT_SUB_OPERATIONAL);
Dan Williams68138202011-05-12 07:16:06 -07001686 }
1687 break;
1688 }
1689 return SCI_SUCCESS;
1690}
Dan Williamse2f8db52011-05-10 02:28:46 -07001691
1692/**
1693 *
1694 * @sci_port: This is the port object which to suspend.
1695 *
1696 * This method will enable the SCU Port Task Scheduler for this port object but
1697 * will leave the port task scheduler in a suspended state. none
1698 */
1699static void
1700scic_sds_port_enable_port_task_scheduler(struct scic_sds_port *port)
1701{
1702 u32 pts_control_value;
1703
1704 pts_control_value = readl(&port->port_task_scheduler_registers->control);
1705 pts_control_value |= SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND);
1706 writel(pts_control_value, &port->port_task_scheduler_registers->control);
1707}
1708
1709/**
1710 *
1711 * @sci_port: This is the port object which to resume.
1712 *
1713 * This method will disable the SCU port task scheduler for this port object.
1714 * none
1715 */
1716static void
1717scic_sds_port_disable_port_task_scheduler(struct scic_sds_port *port)
1718{
1719 u32 pts_control_value;
1720
1721 pts_control_value = readl(&port->port_task_scheduler_registers->control);
1722 pts_control_value &=
1723 ~(SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND));
1724 writel(pts_control_value, &port->port_task_scheduler_registers->control);
1725}
1726
1727static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
1728{
1729 struct scic_sds_controller *scic = sci_port->owning_controller;
1730 u8 phys_index = sci_port->physical_port_index;
1731 union scu_remote_node_context *rnc;
1732 u16 rni = sci_port->reserved_rni;
1733 u32 command;
1734
1735 rnc = &scic->remote_node_context_table[rni];
1736 rnc->ssp.is_valid = true;
1737
1738 command = SCU_CONTEXT_COMMAND_POST_RNC_32 |
1739 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1740
1741 scic_sds_controller_post_request(scic, command);
1742
1743 /* ensure hardware has seen the post rnc command and give it
1744 * ample time to act before sending the suspend
1745 */
1746 readl(&scic->smu_registers->interrupt_status); /* flush */
1747 udelay(10);
1748
1749 command = SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX |
1750 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1751
1752 scic_sds_controller_post_request(scic, command);
1753}
1754
Dan Williams9269e0e2011-05-12 07:42:17 -07001755static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001756{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001757 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001758
Edmund Nadolskie3013702011-06-02 00:10:43 +00001759 if (sci_port->sm.previous_state_id == SCI_PORT_STOPPING) {
Dan Williamse2f8db52011-05-10 02:28:46 -07001760 /*
1761 * If we enter this state becasuse of a request to stop
1762 * the port then we want to disable the hardwares port
1763 * task scheduler. */
1764 scic_sds_port_disable_port_task_scheduler(sci_port);
1765 }
1766}
1767
Dan Williams9269e0e2011-05-12 07:42:17 -07001768static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001769{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001770 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001771
1772 /* Enable and suspend the port task scheduler */
1773 scic_sds_port_enable_port_task_scheduler(sci_port);
1774}
1775
Dan Williams9269e0e2011-05-12 07:42:17 -07001776static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001777{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001778 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001779 struct scic_sds_controller *scic = sci_port->owning_controller;
1780 struct isci_host *ihost = scic_to_ihost(scic);
1781 struct isci_port *iport = sci_port_to_iport(sci_port);
1782 u32 prev_state;
1783
Edmund Nadolskie3013702011-06-02 00:10:43 +00001784 prev_state = sci_port->sm.previous_state_id;
1785 if (prev_state == SCI_PORT_RESETTING)
Dan Williamse2f8db52011-05-10 02:28:46 -07001786 isci_port_hard_reset_complete(iport, SCI_SUCCESS);
1787 else
1788 isci_port_not_ready(ihost, iport);
1789
1790 /* Post and suspend the dummy remote node context for this port. */
1791 scic_sds_port_post_dummy_remote_node(sci_port);
1792
1793 /* Start the ready substate machine */
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001794 port_state_machine_change(sci_port,
Edmund Nadolskie3013702011-06-02 00:10:43 +00001795 SCI_PORT_SUB_WAITING);
Dan Williamse2f8db52011-05-10 02:28:46 -07001796}
1797
Dan Williams9269e0e2011-05-12 07:42:17 -07001798static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001799{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001800 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001801
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001802 sci_del_timer(&sci_port->timer);
Dan Williamse2f8db52011-05-10 02:28:46 -07001803}
1804
Dan Williams9269e0e2011-05-12 07:42:17 -07001805static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001806{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001807 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001808
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001809 sci_del_timer(&sci_port->timer);
Dan Williamse2f8db52011-05-10 02:28:46 -07001810
1811 scic_sds_port_destroy_dummy_resources(sci_port);
1812}
1813
Dan Williams9269e0e2011-05-12 07:42:17 -07001814static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
Dan Williamse2f8db52011-05-10 02:28:46 -07001815{
Edmund Nadolskie3013702011-06-02 00:10:43 +00001816 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
Dan Williamse2f8db52011-05-10 02:28:46 -07001817 struct isci_port *iport = sci_port_to_iport(sci_port);
1818
Dan Williamse2f8db52011-05-10 02:28:46 -07001819 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
1820}
1821
1822/* --------------------------------------------------------------------------- */
1823
1824static const struct sci_base_state scic_sds_port_state_table[] = {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001825 [SCI_PORT_STOPPED] = {
Dan Williamse2f8db52011-05-10 02:28:46 -07001826 .enter_state = scic_sds_port_stopped_state_enter,
1827 .exit_state = scic_sds_port_stopped_state_exit
1828 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001829 [SCI_PORT_STOPPING] = {
Dan Williamse2f8db52011-05-10 02:28:46 -07001830 .exit_state = scic_sds_port_stopping_state_exit
1831 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001832 [SCI_PORT_READY] = {
Dan Williamse2f8db52011-05-10 02:28:46 -07001833 .enter_state = scic_sds_port_ready_state_enter,
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001834 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001835 [SCI_PORT_SUB_WAITING] = {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001836 .enter_state = scic_sds_port_ready_substate_waiting_enter,
1837 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001838 [SCI_PORT_SUB_OPERATIONAL] = {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001839 .enter_state = scic_sds_port_ready_substate_operational_enter,
1840 .exit_state = scic_sds_port_ready_substate_operational_exit
1841 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001842 [SCI_PORT_SUB_CONFIGURING] = {
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001843 .enter_state = scic_sds_port_ready_substate_configuring_enter,
1844 .exit_state = scic_sds_port_ready_substate_configuring_exit
Dan Williamse2f8db52011-05-10 02:28:46 -07001845 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001846 [SCI_PORT_RESETTING] = {
Dan Williamse2f8db52011-05-10 02:28:46 -07001847 .exit_state = scic_sds_port_resetting_state_exit
1848 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001849 [SCI_PORT_FAILED] = {
Dan Williamse2f8db52011-05-10 02:28:46 -07001850 .enter_state = scic_sds_port_failed_state_enter,
1851 }
1852};
1853
1854void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
1855 struct scic_sds_controller *scic)
1856{
Edmund Nadolski12ef6542011-06-02 00:10:50 +00001857 sci_init_sm(&sci_port->sm, scic_sds_port_state_table, SCI_PORT_STOPPED);
Dan Williamse2f8db52011-05-10 02:28:46 -07001858
Dan Williamse2f8db52011-05-10 02:28:46 -07001859 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
1860 sci_port->physical_port_index = index;
1861 sci_port->active_phy_mask = 0;
Piotr Sawickie91f41e2011-05-11 23:52:21 +00001862 sci_port->ready_exit = false;
Dan Williamse2f8db52011-05-10 02:28:46 -07001863
1864 sci_port->owning_controller = scic;
1865
1866 sci_port->started_request_count = 0;
1867 sci_port->assigned_device_count = 0;
1868
1869 sci_port->reserved_rni = SCU_DUMMY_INDEX;
1870 sci_port->reserved_tci = SCU_DUMMY_INDEX;
1871
Edmund Nadolski5553ba22011-05-19 11:59:10 +00001872 sci_init_timer(&sci_port->timer, port_timeout);
1873
Dan Williamse2f8db52011-05-10 02:28:46 -07001874 sci_port->port_task_scheduler_registers = NULL;
1875
1876 for (index = 0; index < SCI_MAX_PHYS; index++)
1877 sci_port->phy_table[index] = NULL;
1878}
1879
1880void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index)
1881{
1882 INIT_LIST_HEAD(&iport->remote_dev_list);
1883 INIT_LIST_HEAD(&iport->domain_dev_list);
1884 spin_lock_init(&iport->state_lock);
1885 init_completion(&iport->start_complete);
1886 iport->isci_host = ihost;
1887 isci_port_change_state(iport, isci_freed);
Jeff Skirvin61aaff42011-06-21 12:16:33 -07001888 atomic_set(&iport->event, 0);
Dan Williamse2f8db52011-05-10 02:28:46 -07001889}
1890
1891/**
1892 * isci_port_get_state() - This function gets the status of the port object.
1893 * @isci_port: This parameter points to the isci_port object
1894 *
1895 * status of the object as a isci_status enum.
1896 */
1897enum isci_status isci_port_get_state(
1898 struct isci_port *isci_port)
1899{
1900 return isci_port->status;
1901}
1902
Dan Williamse2f8db52011-05-10 02:28:46 -07001903void scic_sds_port_broadcast_change_received(
1904 struct scic_sds_port *sci_port,
1905 struct scic_sds_phy *sci_phy)
1906{
1907 struct scic_sds_controller *scic = sci_port->owning_controller;
1908 struct isci_host *ihost = scic_to_ihost(scic);
1909
1910 /* notify the user. */
1911 isci_port_bc_change_received(ihost, sci_port, sci_phy);
1912}
1913
Dan Williams4393aa42011-03-31 13:10:44 -07001914int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
1915 struct isci_phy *iphy)
Dan Williams6f231dd2011-07-02 22:56:22 -07001916{
Dan Williams4393aa42011-03-31 13:10:44 -07001917 unsigned long flags;
Dan Williams6f231dd2011-07-02 22:56:22 -07001918 enum sci_status status;
1919 int ret = TMF_RESP_FUNC_COMPLETE;
Dan Williams6f231dd2011-07-02 22:56:22 -07001920
Dan Williams4393aa42011-03-31 13:10:44 -07001921 dev_dbg(&ihost->pdev->dev, "%s: iport = %p\n",
1922 __func__, iport);
Dan Williams6f231dd2011-07-02 22:56:22 -07001923
Dan Williams4393aa42011-03-31 13:10:44 -07001924 init_completion(&iport->hard_reset_complete);
Dan Williams6f231dd2011-07-02 22:56:22 -07001925
Dan Williams4393aa42011-03-31 13:10:44 -07001926 spin_lock_irqsave(&ihost->scic_lock, flags);
Dan Williams6f231dd2011-07-02 22:56:22 -07001927
1928 #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT
Dan Williamse5313812011-05-07 10:11:43 -07001929 status = scic_port_hard_reset(&iport->sci, ISCI_PORT_RESET_TIMEOUT);
Dan Williams6f231dd2011-07-02 22:56:22 -07001930
Dan Williams4393aa42011-03-31 13:10:44 -07001931 spin_unlock_irqrestore(&ihost->scic_lock, flags);
Dan Williams6f231dd2011-07-02 22:56:22 -07001932
1933 if (status == SCI_SUCCESS) {
Dan Williams4393aa42011-03-31 13:10:44 -07001934 wait_for_completion(&iport->hard_reset_complete);
Dan Williams6f231dd2011-07-02 22:56:22 -07001935
Dan Williams4393aa42011-03-31 13:10:44 -07001936 dev_dbg(&ihost->pdev->dev,
1937 "%s: iport = %p; hard reset completion\n",
1938 __func__, iport);
Dan Williams6f231dd2011-07-02 22:56:22 -07001939
Dan Williams4393aa42011-03-31 13:10:44 -07001940 if (iport->hard_reset_status != SCI_SUCCESS)
Dan Williams6f231dd2011-07-02 22:56:22 -07001941 ret = TMF_RESP_FUNC_FAILED;
1942 } else {
1943 ret = TMF_RESP_FUNC_FAILED;
1944
Dan Williams4393aa42011-03-31 13:10:44 -07001945 dev_err(&ihost->pdev->dev,
1946 "%s: iport = %p; scic_port_hard_reset call"
Dan Williams6f231dd2011-07-02 22:56:22 -07001947 " failed 0x%x\n",
Dan Williams4393aa42011-03-31 13:10:44 -07001948 __func__, iport, status);
Dan Williams6f231dd2011-07-02 22:56:22 -07001949
1950 }
1951
1952 /* If the hard reset for the port has failed, consider this
1953 * the same as link failures on all phys in the port.
1954 */
1955 if (ret != TMF_RESP_FUNC_COMPLETE) {
Dan Williams4393aa42011-03-31 13:10:44 -07001956 dev_err(&ihost->pdev->dev,
1957 "%s: iport = %p; hard reset failed "
Dan Williams6f231dd2011-07-02 22:56:22 -07001958 "(0x%x) - sending link down to libsas for phy %p\n",
Dan Williams4393aa42011-03-31 13:10:44 -07001959 __func__, iport, iport->hard_reset_status, iphy);
Dan Williams6f231dd2011-07-02 22:56:22 -07001960
Dan Williams4393aa42011-03-31 13:10:44 -07001961 isci_port_link_down(ihost, iphy, iport);
Dan Williams6f231dd2011-07-02 22:56:22 -07001962 }
1963
1964 return ret;
1965}
Dave Jiang09d7da12011-03-26 16:11:51 -07001966
Dan Williamse2f8db52011-05-10 02:28:46 -07001967/**
1968 * isci_port_deformed() - This function is called by libsas when a port becomes
1969 * inactive.
1970 * @phy: This parameter specifies the libsas phy with the inactive port.
1971 *
1972 */
1973void isci_port_deformed(struct asd_sas_phy *phy)
Dave Jiang09d7da12011-03-26 16:11:51 -07001974{
Dan Williamse2f8db52011-05-10 02:28:46 -07001975 pr_debug("%s: sas_phy = %p\n", __func__, phy);
1976}
1977
1978/**
1979 * isci_port_formed() - This function is called by libsas when a port becomes
1980 * active.
1981 * @phy: This parameter specifies the libsas phy with the active port.
1982 *
1983 */
1984void isci_port_formed(struct asd_sas_phy *phy)
1985{
1986 pr_debug("%s: sas_phy = %p, sas_port = %p\n", __func__, phy, phy->port);
Dave Jiang09d7da12011-03-26 16:11:51 -07001987}