Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 3 | * redistributing this file, you may do so under either license. |
| 4 | * |
| 5 | * GPL LICENSE SUMMARY |
| 6 | * |
| 7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of version 2 of the GNU General Public License as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called LICENSE.GPL. |
| 23 | * |
| 24 | * BSD LICENSE |
| 25 | * |
| 26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 27 | * All rights reserved. |
| 28 | * |
| 29 | * Redistribution and use in source and binary forms, with or without |
| 30 | * modification, are permitted provided that the following conditions |
| 31 | * are met: |
| 32 | * |
| 33 | * * Redistributions of source code must retain the above copyright |
| 34 | * notice, this list of conditions and the following disclaimer. |
| 35 | * * Redistributions in binary form must reproduce the above copyright |
| 36 | * notice, this list of conditions and the following disclaimer in |
| 37 | * the documentation and/or other materials provided with the |
| 38 | * distribution. |
| 39 | * * Neither the name of Intel Corporation nor the names of its |
| 40 | * contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 54 | */ |
| 55 | |
Dan Williams | cc9203b | 2011-05-08 17:34:44 -0700 | [diff] [blame] | 56 | #include "host.h" |
Dan Williams | ce2b326 | 2011-05-08 15:49:15 -0700 | [diff] [blame] | 57 | #include "timers.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 58 | |
| 59 | #define SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT (10) |
| 60 | #define SCIC_SDS_APC_RECONFIGURATION_TIMEOUT (10) |
| 61 | #define SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION (100) |
| 62 | |
| 63 | enum SCIC_SDS_APC_ACTIVITY { |
| 64 | SCIC_SDS_APC_SKIP_PHY, |
| 65 | SCIC_SDS_APC_ADD_PHY, |
| 66 | SCIC_SDS_APC_START_TIMER, |
| 67 | |
| 68 | SCIC_SDS_APC_ACTIVITY_MAX |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * ****************************************************************************** |
| 73 | * General port configuration agent routines |
| 74 | * ****************************************************************************** */ |
| 75 | |
| 76 | /** |
| 77 | * |
| 78 | * @address_one: A SAS Address to be compared. |
| 79 | * @address_two: A SAS Address to be compared. |
| 80 | * |
| 81 | * Compare the two SAS Address and if SAS Address One is greater than SAS |
| 82 | * Address Two then return > 0 else if SAS Address One is less than SAS Address |
| 83 | * Two return < 0 Otherwise they are the same return 0 A signed value of x > 0 |
| 84 | * > y where x is returned for Address One > Address Two y is returned for |
| 85 | * Address One < Address Two 0 is returned ofr Address One = Address Two |
| 86 | */ |
| 87 | static s32 sci_sas_address_compare( |
| 88 | struct sci_sas_address address_one, |
| 89 | struct sci_sas_address address_two) |
| 90 | { |
| 91 | if (address_one.high > address_two.high) { |
| 92 | return 1; |
| 93 | } else if (address_one.high < address_two.high) { |
| 94 | return -1; |
| 95 | } else if (address_one.low > address_two.low) { |
| 96 | return 1; |
| 97 | } else if (address_one.low < address_two.low) { |
| 98 | return -1; |
| 99 | } |
| 100 | |
| 101 | /* The two SAS Address must be identical */ |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * |
| 107 | * @controller: The controller object used for the port search. |
| 108 | * @phy: The phy object to match. |
| 109 | * |
| 110 | * This routine will find a matching port for the phy. This means that the |
| 111 | * port and phy both have the same broadcast sas address and same received sas |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 112 | * address. The port address or the NULL if there is no matching |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 113 | * port. port address if the port can be found to match the phy. |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 114 | * NULL if there is no matching port for the phy. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 115 | */ |
| 116 | static struct scic_sds_port *scic_sds_port_configuration_agent_find_port( |
Edmund Nadolski | ed30c27 | 2011-05-05 01:11:43 +0000 | [diff] [blame] | 117 | struct scic_sds_controller *scic, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 118 | struct scic_sds_phy *phy) |
| 119 | { |
Edmund Nadolski | ed30c27 | 2011-05-05 01:11:43 +0000 | [diff] [blame] | 120 | u8 i; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 121 | struct sci_sas_address port_sas_address; |
| 122 | struct sci_sas_address port_attached_device_address; |
| 123 | struct sci_sas_address phy_sas_address; |
| 124 | struct sci_sas_address phy_attached_device_address; |
| 125 | |
| 126 | /* |
| 127 | * Since this phy can be a member of a wide port check to see if one or |
| 128 | * more phys match the sent and received SAS address as this phy in which |
Edmund Nadolski | ed30c27 | 2011-05-05 01:11:43 +0000 | [diff] [blame] | 129 | * case it should participate in the same port. |
| 130 | */ |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 131 | scic_sds_phy_get_sas_address(phy, &phy_sas_address); |
| 132 | scic_sds_phy_get_attached_sas_address(phy, &phy_attached_device_address); |
| 133 | |
Edmund Nadolski | ed30c27 | 2011-05-05 01:11:43 +0000 | [diff] [blame] | 134 | for (i = 0; i < scic->logical_port_entries; i++) { |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 135 | struct isci_host *ihost = scic_to_ihost(scic); |
| 136 | struct scic_sds_port *sci_port = &ihost->ports[i].sci; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 137 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 138 | scic_sds_port_get_sas_address(sci_port, &port_sas_address); |
| 139 | scic_sds_port_get_attached_sas_address(sci_port, &port_attached_device_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 140 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 141 | if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 && |
| 142 | sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0) |
| 143 | return sci_port; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 146 | return NULL; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /** |
| 150 | * |
| 151 | * @controller: This is the controller object that contains the port agent |
| 152 | * @port_agent: This is the port configruation agent for the controller. |
| 153 | * |
| 154 | * This routine will validate the port configuration is correct for the SCU |
| 155 | * hardware. The SCU hardware allows for port configurations as follows. LP0 |
| 156 | * -> (PE0), (PE0, PE1), (PE0, PE1, PE2, PE3) LP1 -> (PE1) LP2 -> (PE2), (PE2, |
| 157 | * PE3) LP3 -> (PE3) enum sci_status SCI_SUCCESS the port configuration is valid for |
| 158 | * this port configuration agent. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION |
| 159 | * the port configuration is not valid for this port configuration agent. |
| 160 | */ |
| 161 | static enum sci_status scic_sds_port_configuration_agent_validate_ports( |
| 162 | struct scic_sds_controller *controller, |
| 163 | struct scic_sds_port_configuration_agent *port_agent) |
| 164 | { |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 165 | struct isci_host *ihost = scic_to_ihost(controller); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 166 | struct sci_sas_address first_address; |
| 167 | struct sci_sas_address second_address; |
| 168 | |
| 169 | /* |
| 170 | * Sanity check the max ranges for all the phys the max index |
| 171 | * is always equal to the port range index */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 172 | if (port_agent->phy_valid_port_range[0].max_index != 0 || |
| 173 | port_agent->phy_valid_port_range[1].max_index != 1 || |
| 174 | port_agent->phy_valid_port_range[2].max_index != 2 || |
| 175 | port_agent->phy_valid_port_range[3].max_index != 3) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 176 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 177 | |
| 178 | /* |
| 179 | * This is a request to configure a single x4 port or at least attempt |
| 180 | * to make all the phys into a single port */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 181 | if (port_agent->phy_valid_port_range[0].min_index == 0 && |
| 182 | port_agent->phy_valid_port_range[1].min_index == 0 && |
| 183 | port_agent->phy_valid_port_range[2].min_index == 0 && |
| 184 | port_agent->phy_valid_port_range[3].min_index == 0) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 185 | return SCI_SUCCESS; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 186 | |
| 187 | /* |
| 188 | * This is a degenerate case where phy 1 and phy 2 are assigned |
| 189 | * to the same port this is explicitly disallowed by the hardware |
| 190 | * unless they are part of the same x4 port and this condition was |
| 191 | * already checked above. */ |
| 192 | if (port_agent->phy_valid_port_range[2].min_index == 1) { |
| 193 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * PE0 and PE3 can never have the same SAS Address unless they |
| 198 | * are part of the same x4 wide port and we have already checked |
| 199 | * for this condition. */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 200 | scic_sds_phy_get_sas_address(&ihost->phys[0].sci, &first_address); |
| 201 | scic_sds_phy_get_sas_address(&ihost->phys[3].sci, &second_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 202 | |
| 203 | if (sci_sas_address_compare(first_address, second_address) == 0) { |
| 204 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * PE0 and PE1 are configured into a 2x1 ports make sure that the |
| 209 | * SAS Address for PE0 and PE2 are different since they can not be |
| 210 | * part of the same port. */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 211 | if (port_agent->phy_valid_port_range[0].min_index == 0 && |
| 212 | port_agent->phy_valid_port_range[1].min_index == 1) { |
| 213 | scic_sds_phy_get_sas_address(&ihost->phys[0].sci, &first_address); |
| 214 | scic_sds_phy_get_sas_address(&ihost->phys[2].sci, &second_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 215 | |
| 216 | if (sci_sas_address_compare(first_address, second_address) == 0) { |
| 217 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /* |
| 222 | * PE2 and PE3 are configured into a 2x1 ports make sure that the |
| 223 | * SAS Address for PE1 and PE3 are different since they can not be |
| 224 | * part of the same port. */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 225 | if (port_agent->phy_valid_port_range[2].min_index == 2 && |
| 226 | port_agent->phy_valid_port_range[3].min_index == 3) { |
| 227 | scic_sds_phy_get_sas_address(&ihost->phys[1].sci, &first_address); |
| 228 | scic_sds_phy_get_sas_address(&ihost->phys[3].sci, &second_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 229 | |
| 230 | if (sci_sas_address_compare(first_address, second_address) == 0) { |
| 231 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | return SCI_SUCCESS; |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * ****************************************************************************** |
| 240 | * Manual port configuration agent routines |
| 241 | * ****************************************************************************** */ |
| 242 | |
| 243 | /** |
| 244 | * |
| 245 | * |
| 246 | * This routine will verify that all of the phys in the same port are using the |
| 247 | * same SAS address. |
| 248 | */ |
| 249 | static enum sci_status scic_sds_mpc_agent_validate_phy_configuration( |
| 250 | struct scic_sds_controller *controller, |
| 251 | struct scic_sds_port_configuration_agent *port_agent) |
| 252 | { |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 253 | struct isci_host *ihost = scic_to_ihost(controller); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 254 | u32 phy_mask; |
| 255 | u32 assigned_phy_mask; |
| 256 | struct sci_sas_address sas_address; |
| 257 | struct sci_sas_address phy_assigned_address; |
| 258 | u8 port_index; |
| 259 | u8 phy_index; |
| 260 | |
| 261 | assigned_phy_mask = 0; |
| 262 | sas_address.high = 0; |
| 263 | sas_address.low = 0; |
| 264 | |
| 265 | for (port_index = 0; port_index < SCI_MAX_PORTS; port_index++) { |
| 266 | phy_mask = controller->oem_parameters.sds1.ports[port_index].phy_mask; |
| 267 | |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 268 | if (!phy_mask) |
| 269 | continue; |
| 270 | /* |
| 271 | * Make sure that one or more of the phys were not already assinged to |
| 272 | * a different port. */ |
| 273 | if ((phy_mask & ~assigned_phy_mask) == 0) { |
| 274 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 275 | } |
| 276 | |
| 277 | /* Find the starting phy index for this round through the loop */ |
| 278 | for (phy_index = 0; phy_index < SCI_MAX_PHYS; phy_index++) { |
| 279 | if ((phy_mask & (1 << phy_index)) == 0) |
| 280 | continue; |
| 281 | scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, |
| 282 | &sas_address); |
| 283 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 284 | /* |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 285 | * The phy_index can be used as the starting point for the |
| 286 | * port range since the hardware starts all logical ports |
| 287 | * the same as the PE index. */ |
| 288 | port_agent->phy_valid_port_range[phy_index].min_index = port_index; |
| 289 | port_agent->phy_valid_port_range[phy_index].max_index = phy_index; |
| 290 | |
| 291 | if (phy_index != port_index) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 292 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 293 | } |
| 294 | |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 295 | break; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 296 | } |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 297 | |
| 298 | /* |
| 299 | * See how many additional phys are being added to this logical port. |
| 300 | * Note: We have not moved the current phy_index so we will actually |
| 301 | * compare the startting phy with itself. |
| 302 | * This is expected and required to add the phy to the port. */ |
| 303 | while (phy_index < SCI_MAX_PHYS) { |
| 304 | if ((phy_mask & (1 << phy_index)) == 0) |
| 305 | continue; |
| 306 | scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, |
| 307 | &phy_assigned_address); |
| 308 | |
| 309 | if (sci_sas_address_compare(sas_address, phy_assigned_address) != 0) { |
| 310 | /* |
| 311 | * The phy mask specified that this phy is part of the same port |
| 312 | * as the starting phy and it is not so fail this configuration */ |
| 313 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 314 | } |
| 315 | |
| 316 | port_agent->phy_valid_port_range[phy_index].min_index = port_index; |
| 317 | port_agent->phy_valid_port_range[phy_index].max_index = phy_index; |
| 318 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 319 | scic_sds_port_add_phy(&ihost->ports[port_index].sci, |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 320 | &ihost->phys[phy_index].sci); |
| 321 | |
| 322 | assigned_phy_mask |= (1 << phy_index); |
| 323 | } |
| 324 | |
| 325 | phy_index++; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | return scic_sds_port_configuration_agent_validate_ports(controller, port_agent); |
| 329 | } |
| 330 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 331 | static void mpc_agent_timeout(unsigned long data) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 332 | { |
| 333 | u8 index; |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 334 | struct sci_timer *tmr = (struct sci_timer *)data; |
| 335 | struct scic_sds_port_configuration_agent *port_agent; |
| 336 | struct scic_sds_controller *scic; |
| 337 | struct isci_host *ihost; |
| 338 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 339 | u16 configure_phy_mask; |
| 340 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 341 | port_agent = container_of(tmr, typeof(*port_agent), timer); |
| 342 | scic = container_of(port_agent, typeof(*scic), port_agent); |
| 343 | ihost = scic_to_ihost(scic); |
| 344 | |
| 345 | spin_lock_irqsave(&ihost->scic_lock, flags); |
| 346 | |
| 347 | if (tmr->cancel) |
| 348 | goto done; |
| 349 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 350 | port_agent->timer_pending = false; |
| 351 | |
| 352 | /* Find the mask of phys that are reported read but as yet unconfigured into a port */ |
| 353 | configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; |
| 354 | |
| 355 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 356 | struct scic_sds_phy *sci_phy = &ihost->phys[index].sci; |
| 357 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 358 | if (configure_phy_mask & (1 << index)) { |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 359 | port_agent->link_up_handler(scic, port_agent, |
Dan Williams | 4f20ef4 | 2011-05-12 06:00:31 -0700 | [diff] [blame] | 360 | phy_get_non_dummy_port(sci_phy), |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 361 | sci_phy); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 362 | } |
| 363 | } |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 364 | |
| 365 | done: |
| 366 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | /** |
| 370 | * |
| 371 | * @controller: This is the controller object that receives the link up |
| 372 | * notification. |
| 373 | * @port: This is the port object associated with the phy. If the is no |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 374 | * associated port this is an NULL. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 375 | * @phy: This is the phy object which has gone ready. |
| 376 | * |
| 377 | * This method handles the manual port configuration link up notifications. |
| 378 | * Since all ports and phys are associate at initialization time we just turn |
| 379 | * around and notifiy the port object that there is a link up. If this PHY is |
| 380 | * not associated with a port there is no action taken. Is it possible to get a |
| 381 | * link up notification from a phy that has no assocoated port? |
| 382 | */ |
| 383 | static void scic_sds_mpc_agent_link_up( |
| 384 | struct scic_sds_controller *controller, |
| 385 | struct scic_sds_port_configuration_agent *port_agent, |
| 386 | struct scic_sds_port *port, |
| 387 | struct scic_sds_phy *phy) |
| 388 | { |
| 389 | /* |
| 390 | * If the port has an invalid handle then the phy was not assigned to |
| 391 | * a port. This is because the phy was not given the same SAS Address |
| 392 | * as the other PHYs in the port. */ |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 393 | if (port != NULL) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 394 | port_agent->phy_ready_mask |= (1 << scic_sds_phy_get_index(phy)); |
| 395 | |
| 396 | scic_sds_port_link_up(port, phy); |
| 397 | |
| 398 | if ((port->active_phy_mask & (1 << scic_sds_phy_get_index(phy))) != 0) { |
| 399 | port_agent->phy_configured_mask |= (1 << scic_sds_phy_get_index(phy)); |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * |
| 406 | * @controller: This is the controller object that receives the link down |
| 407 | * notification. |
| 408 | * @port: This is the port object associated with the phy. If the is no |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 409 | * associated port this is an NULL. The port is an invalid |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 410 | * handle only if the phy was never port of this port. This happens when |
| 411 | * the phy is not broadcasting the same SAS address as the other phys in the |
| 412 | * assigned port. |
| 413 | * @phy: This is the phy object which has gone link down. |
| 414 | * |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 415 | * This function handles the manual port configuration link down notifications. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 416 | * Since all ports and phys are associated at initialization time we just turn |
| 417 | * around and notifiy the port object of the link down event. If this PHY is |
| 418 | * not associated with a port there is no action taken. Is it possible to get a |
| 419 | * link down notification from a phy that has no assocoated port? |
| 420 | */ |
| 421 | static void scic_sds_mpc_agent_link_down( |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 422 | struct scic_sds_controller *scic, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 423 | struct scic_sds_port_configuration_agent *port_agent, |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 424 | struct scic_sds_port *sci_port, |
| 425 | struct scic_sds_phy *sci_phy) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 426 | { |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 427 | if (sci_port != NULL) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 428 | /* |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 429 | * If we can form a new port from the remainder of the phys |
| 430 | * then we want to start the timer to allow the SCI User to |
| 431 | * cleanup old devices and rediscover the port before |
| 432 | * rebuilding the port with the phys that remain in the ready |
| 433 | * state. |
| 434 | */ |
| 435 | port_agent->phy_ready_mask &= |
| 436 | ~(1 << scic_sds_phy_get_index(sci_phy)); |
| 437 | port_agent->phy_configured_mask &= |
| 438 | ~(1 << scic_sds_phy_get_index(sci_phy)); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 439 | |
| 440 | /* |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 441 | * Check to see if there are more phys waiting to be |
| 442 | * configured into a port. If there are allow the SCI User |
| 443 | * to tear down this port, if necessary, and then reconstruct |
| 444 | * the port after the timeout. |
| 445 | */ |
| 446 | if ((port_agent->phy_configured_mask == 0x0000) && |
| 447 | (port_agent->phy_ready_mask != 0x0000) && |
| 448 | !port_agent->timer_pending) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 449 | port_agent->timer_pending = true; |
| 450 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 451 | sci_mod_timer(&port_agent->timer, |
| 452 | SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 455 | scic_sds_port_link_down(sci_port, sci_phy); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 456 | } |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * ****************************************************************************** |
| 461 | * Automatic port configuration agent routines |
| 462 | * ****************************************************************************** */ |
| 463 | |
| 464 | /** |
| 465 | * |
| 466 | * |
| 467 | * This routine will verify that the phys are assigned a valid SAS address for |
| 468 | * automatic port configuration mode. |
| 469 | */ |
| 470 | static enum sci_status scic_sds_apc_agent_validate_phy_configuration( |
| 471 | struct scic_sds_controller *controller, |
| 472 | struct scic_sds_port_configuration_agent *port_agent) |
| 473 | { |
| 474 | u8 phy_index; |
| 475 | u8 port_index; |
| 476 | struct sci_sas_address sas_address; |
| 477 | struct sci_sas_address phy_assigned_address; |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 478 | struct isci_host *ihost = scic_to_ihost(controller); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 479 | |
| 480 | phy_index = 0; |
| 481 | |
| 482 | while (phy_index < SCI_MAX_PHYS) { |
| 483 | port_index = phy_index; |
| 484 | |
| 485 | /* Get the assigned SAS Address for the first PHY on the controller. */ |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 486 | scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, |
| 487 | &sas_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 488 | |
| 489 | while (++phy_index < SCI_MAX_PHYS) { |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 490 | scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, |
| 491 | &phy_assigned_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 492 | |
| 493 | /* Verify each of the SAS address are all the same for every PHY */ |
| 494 | if (sci_sas_address_compare(sas_address, phy_assigned_address) == 0) { |
| 495 | port_agent->phy_valid_port_range[phy_index].min_index = port_index; |
| 496 | port_agent->phy_valid_port_range[phy_index].max_index = phy_index; |
| 497 | } else { |
| 498 | port_agent->phy_valid_port_range[phy_index].min_index = phy_index; |
| 499 | port_agent->phy_valid_port_range[phy_index].max_index = phy_index; |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | return scic_sds_port_configuration_agent_validate_ports(controller, port_agent); |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 510 | * @controller: This is the controller object that receives the link up |
| 511 | * notification. |
| 512 | * @phy: This is the phy object which has gone link up. |
| 513 | * |
| 514 | * This method handles the automatic port configuration for link up |
| 515 | * notifications. |
| 516 | */ |
| 517 | static void scic_sds_apc_agent_configure_ports( |
| 518 | struct scic_sds_controller *controller, |
| 519 | struct scic_sds_port_configuration_agent *port_agent, |
| 520 | struct scic_sds_phy *phy, |
| 521 | bool start_timer) |
| 522 | { |
| 523 | u8 port_index; |
| 524 | enum sci_status status; |
| 525 | struct scic_sds_port *port; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 526 | enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY; |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 527 | struct isci_host *ihost = scic_to_ihost(controller); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 528 | |
| 529 | port = scic_sds_port_configuration_agent_find_port(controller, phy); |
| 530 | |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 531 | if (port != NULL) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 532 | if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) |
| 533 | apc_activity = SCIC_SDS_APC_ADD_PHY; |
| 534 | else |
| 535 | apc_activity = SCIC_SDS_APC_SKIP_PHY; |
| 536 | } else { |
| 537 | /* |
| 538 | * There is no matching Port for this PHY so lets search through the |
| 539 | * Ports and see if we can add the PHY to its own port or maybe start |
| 540 | * the timer and wait to see if a wider port can be made. |
| 541 | * |
| 542 | * Note the break when we reach the condition of the port id == phy id */ |
| 543 | for ( |
| 544 | port_index = port_agent->phy_valid_port_range[phy->phy_index].min_index; |
| 545 | port_index <= port_agent->phy_valid_port_range[phy->phy_index].max_index; |
| 546 | port_index++ |
| 547 | ) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 548 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 549 | port = &ihost->ports[port_index].sci; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 550 | |
| 551 | /* First we must make sure that this PHY can be added to this Port. */ |
| 552 | if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) { |
| 553 | /* |
| 554 | * Port contains a PHY with a greater PHY ID than the current |
| 555 | * PHY that has gone link up. This phy can not be part of any |
| 556 | * port so skip it and move on. */ |
| 557 | if (port->active_phy_mask > (1 << phy->phy_index)) { |
| 558 | apc_activity = SCIC_SDS_APC_SKIP_PHY; |
| 559 | break; |
| 560 | } |
| 561 | |
| 562 | /* |
| 563 | * We have reached the end of our Port list and have not found |
| 564 | * any reason why we should not either add the PHY to the port |
| 565 | * or wait for more phys to become active. */ |
| 566 | if (port->physical_port_index == phy->phy_index) { |
| 567 | /* |
| 568 | * The Port either has no active PHYs. |
| 569 | * Consider that if the port had any active PHYs we would have |
| 570 | * or active PHYs with |
| 571 | * a lower PHY Id than this PHY. */ |
| 572 | if (apc_activity != SCIC_SDS_APC_START_TIMER) { |
| 573 | apc_activity = SCIC_SDS_APC_ADD_PHY; |
| 574 | } |
| 575 | |
| 576 | break; |
| 577 | } |
| 578 | |
| 579 | /* |
| 580 | * The current Port has no active PHYs and this PHY could be part |
| 581 | * of this Port. Since we dont know as yet setup to start the |
| 582 | * timer and see if there is a better configuration. */ |
| 583 | if (port->active_phy_mask == 0) { |
| 584 | apc_activity = SCIC_SDS_APC_START_TIMER; |
| 585 | } |
| 586 | } else if (port->active_phy_mask != 0) { |
| 587 | /* |
| 588 | * The Port has an active phy and the current Phy can not |
| 589 | * participate in this port so skip the PHY and see if |
| 590 | * there is a better configuration. */ |
| 591 | apc_activity = SCIC_SDS_APC_SKIP_PHY; |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | /* |
| 597 | * Check to see if the start timer operations should instead map to an |
| 598 | * add phy operation. This is caused because we have been waiting to |
| 599 | * add a phy to a port but could not becuase the automatic port |
| 600 | * configuration engine had a choice of possible ports for the phy. |
| 601 | * Since we have gone through a timeout we are going to restrict the |
| 602 | * choice to the smallest possible port. */ |
| 603 | if ( |
| 604 | (start_timer == false) |
| 605 | && (apc_activity == SCIC_SDS_APC_START_TIMER) |
| 606 | ) { |
| 607 | apc_activity = SCIC_SDS_APC_ADD_PHY; |
| 608 | } |
| 609 | |
| 610 | switch (apc_activity) { |
| 611 | case SCIC_SDS_APC_ADD_PHY: |
| 612 | status = scic_sds_port_add_phy(port, phy); |
| 613 | |
| 614 | if (status == SCI_SUCCESS) { |
| 615 | port_agent->phy_configured_mask |= (1 << phy->phy_index); |
| 616 | } |
| 617 | break; |
| 618 | |
| 619 | case SCIC_SDS_APC_START_TIMER: |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 620 | /* |
| 621 | * This can occur for either a link down event, or a link |
| 622 | * up event where we cannot yet tell the port to which a |
| 623 | * phy belongs. |
| 624 | */ |
| 625 | if (port_agent->timer_pending) |
| 626 | sci_del_timer(&port_agent->timer); |
| 627 | |
| 628 | port_agent->timer_pending = true; |
| 629 | sci_mod_timer(&port_agent->timer, |
| 630 | SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 631 | break; |
| 632 | |
| 633 | case SCIC_SDS_APC_SKIP_PHY: |
| 634 | default: |
| 635 | /* do nothing the PHY can not be made part of a port at this time. */ |
| 636 | break; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | /** |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 641 | * scic_sds_apc_agent_link_up - handle apc link up events |
| 642 | * @scic: This is the controller object that receives the link up |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 643 | * notification. |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 644 | * @sci_port: This is the port object associated with the phy. If the is no |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 645 | * associated port this is an NULL. |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 646 | * @sci_phy: This is the phy object which has gone link up. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 647 | * |
| 648 | * This method handles the automatic port configuration for link up |
| 649 | * notifications. Is it possible to get a link down notification from a phy |
| 650 | * that has no assocoated port? |
| 651 | */ |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 652 | static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic, |
| 653 | struct scic_sds_port_configuration_agent *port_agent, |
| 654 | struct scic_sds_port *sci_port, |
| 655 | struct scic_sds_phy *sci_phy) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 656 | { |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 657 | u8 phy_index = sci_phy->phy_index; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 658 | |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 659 | if (!sci_port) { |
| 660 | /* the phy is not the part of this port */ |
| 661 | port_agent->phy_ready_mask |= 1 << phy_index; |
| 662 | scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true); |
| 663 | } else { |
| 664 | /* the phy is already the part of the port */ |
Maciej Trela | 41e2b90 | 2011-04-12 17:28:37 -0700 | [diff] [blame] | 665 | u32 port_state = sci_port->state_machine.current_state_id; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 666 | |
Piotr Sawicki | b382429 | 2011-02-23 00:09:14 -0800 | [diff] [blame] | 667 | /* if the PORT'S state is resetting then the link up is from |
| 668 | * port hard reset in this case, we need to tell the port |
| 669 | * that link up is recieved |
| 670 | */ |
| 671 | BUG_ON(port_state != SCI_BASE_PORT_STATE_RESETTING); |
| 672 | port_agent->phy_ready_mask |= 1 << phy_index; |
| 673 | scic_sds_port_link_up(sci_port, sci_phy); |
| 674 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | /** |
| 678 | * |
| 679 | * @controller: This is the controller object that receives the link down |
| 680 | * notification. |
| 681 | * @port: This is the port object associated with the phy. If the is no |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 682 | * associated port this is an NULL. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 683 | * @phy: This is the phy object which has gone link down. |
| 684 | * |
| 685 | * This method handles the automatic port configuration link down |
| 686 | * notifications. not associated with a port there is no action taken. Is it |
| 687 | * possible to get a link down notification from a phy that has no assocoated |
| 688 | * port? |
| 689 | */ |
| 690 | static void scic_sds_apc_agent_link_down( |
| 691 | struct scic_sds_controller *controller, |
| 692 | struct scic_sds_port_configuration_agent *port_agent, |
| 693 | struct scic_sds_port *port, |
| 694 | struct scic_sds_phy *phy) |
| 695 | { |
| 696 | port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(phy)); |
| 697 | |
Edmund Nadolski | a7e536c | 2011-02-08 09:28:42 -0700 | [diff] [blame] | 698 | if (port != NULL) { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 699 | if (port_agent->phy_configured_mask & (1 << phy->phy_index)) { |
| 700 | enum sci_status status; |
| 701 | |
| 702 | status = scic_sds_port_remove_phy(port, phy); |
| 703 | |
| 704 | if (status == SCI_SUCCESS) { |
| 705 | port_agent->phy_configured_mask &= ~(1 << phy->phy_index); |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 711 | /* configure the phys into ports when the timer fires */ |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 712 | static void apc_agent_timeout(unsigned long data) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 713 | { |
| 714 | u32 index; |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 715 | struct sci_timer *tmr = (struct sci_timer *)data; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 716 | struct scic_sds_port_configuration_agent *port_agent; |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 717 | struct scic_sds_controller *scic; |
| 718 | struct isci_host *ihost; |
| 719 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 720 | u16 configure_phy_mask; |
| 721 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 722 | port_agent = container_of(tmr, typeof(*port_agent), timer); |
| 723 | scic = container_of(port_agent, typeof(*scic), port_agent); |
| 724 | ihost = scic_to_ihost(scic); |
| 725 | |
| 726 | spin_lock_irqsave(&ihost->scic_lock, flags); |
| 727 | |
| 728 | if (tmr->cancel) |
| 729 | goto done; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 730 | |
| 731 | port_agent->timer_pending = false; |
| 732 | |
| 733 | configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; |
| 734 | |
Dan Williams | 4b33981 | 2011-05-06 17:36:38 -0700 | [diff] [blame] | 735 | if (!configure_phy_mask) |
| 736 | return; |
| 737 | |
| 738 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
| 739 | if ((configure_phy_mask & (1 << index)) == 0) |
| 740 | continue; |
| 741 | |
| 742 | scic_sds_apc_agent_configure_ports(scic, port_agent, |
| 743 | &ihost->phys[index].sci, false); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 744 | } |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 745 | |
| 746 | done: |
| 747 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | /* |
| 751 | * ****************************************************************************** |
| 752 | * Public port configuration agent routines |
| 753 | * ****************************************************************************** */ |
| 754 | |
| 755 | /** |
| 756 | * |
| 757 | * |
| 758 | * This method will construct the port configuration agent for operation. This |
| 759 | * call is universal for both manual port configuration and automatic port |
| 760 | * configuration modes. |
| 761 | */ |
| 762 | void scic_sds_port_configuration_agent_construct( |
| 763 | struct scic_sds_port_configuration_agent *port_agent) |
| 764 | { |
| 765 | u32 index; |
| 766 | |
| 767 | port_agent->phy_configured_mask = 0x00; |
| 768 | port_agent->phy_ready_mask = 0x00; |
| 769 | |
| 770 | port_agent->link_up_handler = NULL; |
| 771 | port_agent->link_down_handler = NULL; |
| 772 | |
| 773 | port_agent->timer_pending = false; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 774 | |
| 775 | for (index = 0; index < SCI_MAX_PORTS; index++) { |
| 776 | port_agent->phy_valid_port_range[index].min_index = 0; |
| 777 | port_agent->phy_valid_port_range[index].max_index = 0; |
| 778 | } |
| 779 | } |
| 780 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 781 | enum sci_status scic_sds_port_configuration_agent_initialize( |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 782 | struct scic_sds_controller *scic, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 783 | struct scic_sds_port_configuration_agent *port_agent) |
| 784 | { |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 785 | enum sci_status status; |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 786 | enum scic_port_configuration_mode mode; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 787 | |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 788 | mode = scic->oem_parameters.sds1.controller.mode_type; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 789 | |
| 790 | if (mode == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 791 | status = scic_sds_mpc_agent_validate_phy_configuration( |
| 792 | scic, port_agent); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 793 | |
| 794 | port_agent->link_up_handler = scic_sds_mpc_agent_link_up; |
| 795 | port_agent->link_down_handler = scic_sds_mpc_agent_link_down; |
| 796 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 797 | sci_init_timer(&port_agent->timer, mpc_agent_timeout); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 798 | } else { |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 799 | status = scic_sds_apc_agent_validate_phy_configuration( |
| 800 | scic, port_agent); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 801 | |
| 802 | port_agent->link_up_handler = scic_sds_apc_agent_link_up; |
| 803 | port_agent->link_down_handler = scic_sds_apc_agent_link_down; |
| 804 | |
Edmund Nadolski | ac0eeb4 | 2011-05-19 20:00:51 -0700 | [diff] [blame^] | 805 | sci_init_timer(&port_agent->timer, apc_agent_timeout); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | return status; |
| 809 | } |