Lines Matching +full:port +full:- +full:phys
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
72 * General port configuration agent routines
93 return -1; in sci_sas_address_compare()
97 return -1; in sci_sas_address_compare()
106 * @ihost: The controller object used for the port search.
109 * This routine will find a matching port for the phy. This means that the
110 * port and phy both have the same broadcast sas address and same received sas
111 * address. The port address or the NULL if there is no matching
112 * port. port address if the port can be found to match the phy.
113 * NULL if there is no matching port for the phy.
126 * Since this phy can be a member of a wide port check to see if one or in sci_port_configuration_agent_find_port()
127 * more phys match the sent and received SAS address as this phy in which in sci_port_configuration_agent_find_port()
128 * case it should participate in the same port. in sci_port_configuration_agent_find_port()
133 for (i = 0; i < ihost->logical_port_entries; i++) { in sci_port_configuration_agent_find_port()
134 struct isci_port *iport = &ihost->ports[i]; in sci_port_configuration_agent_find_port()
149 * @ihost: This is the controller object that contains the port agent
150 * @port_agent: This is the port configuration agent for the controller.
152 * This routine will validate the port configuration is correct for the SCU
153 * hardware. The SCU hardware allows for port configurations as follows. LP0
154 * -> (PE0), (PE0, PE1), (PE0, PE1, PE2, PE3) LP1 -> (PE1) LP2 -> (PE2), (PE2,
155 * PE3) LP3 -> (PE3) enum sci_status SCI_SUCCESS the port configuration is valid for
156 * this port configuration agent. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION
157 * the port configuration is not valid for this port configuration agent.
167 * Sanity check the max ranges for all the phys the max index in sci_port_configuration_agent_validate_ports()
168 * is always equal to the port range index */ in sci_port_configuration_agent_validate_ports()
169 if (port_agent->phy_valid_port_range[0].max_index != 0 || in sci_port_configuration_agent_validate_ports()
170 port_agent->phy_valid_port_range[1].max_index != 1 || in sci_port_configuration_agent_validate_ports()
171 port_agent->phy_valid_port_range[2].max_index != 2 || in sci_port_configuration_agent_validate_ports()
172 port_agent->phy_valid_port_range[3].max_index != 3) in sci_port_configuration_agent_validate_ports()
176 * This is a request to configure a single x4 port or at least attempt in sci_port_configuration_agent_validate_ports()
177 * to make all the phys into a single port */ in sci_port_configuration_agent_validate_ports()
178 if (port_agent->phy_valid_port_range[0].min_index == 0 && in sci_port_configuration_agent_validate_ports()
179 port_agent->phy_valid_port_range[1].min_index == 0 && in sci_port_configuration_agent_validate_ports()
180 port_agent->phy_valid_port_range[2].min_index == 0 && in sci_port_configuration_agent_validate_ports()
181 port_agent->phy_valid_port_range[3].min_index == 0) in sci_port_configuration_agent_validate_ports()
186 * to the same port this is explicitly disallowed by the hardware in sci_port_configuration_agent_validate_ports()
187 * unless they are part of the same x4 port and this condition was in sci_port_configuration_agent_validate_ports()
189 if (port_agent->phy_valid_port_range[2].min_index == 1) { in sci_port_configuration_agent_validate_ports()
195 * are part of the same x4 wide port and we have already checked in sci_port_configuration_agent_validate_ports()
197 sci_phy_get_sas_address(&ihost->phys[0], &first_address); in sci_port_configuration_agent_validate_ports()
198 sci_phy_get_sas_address(&ihost->phys[3], &second_address); in sci_port_configuration_agent_validate_ports()
207 * part of the same port. */ in sci_port_configuration_agent_validate_ports()
208 if (port_agent->phy_valid_port_range[0].min_index == 0 && in sci_port_configuration_agent_validate_ports()
209 port_agent->phy_valid_port_range[1].min_index == 1) { in sci_port_configuration_agent_validate_ports()
210 sci_phy_get_sas_address(&ihost->phys[0], &first_address); in sci_port_configuration_agent_validate_ports()
211 sci_phy_get_sas_address(&ihost->phys[2], &second_address); in sci_port_configuration_agent_validate_ports()
221 * part of the same port. */ in sci_port_configuration_agent_validate_ports()
222 if (port_agent->phy_valid_port_range[2].min_index == 2 && in sci_port_configuration_agent_validate_ports()
223 port_agent->phy_valid_port_range[3].min_index == 3) { in sci_port_configuration_agent_validate_ports()
224 sci_phy_get_sas_address(&ihost->phys[1], &first_address); in sci_port_configuration_agent_validate_ports()
225 sci_phy_get_sas_address(&ihost->phys[3], &second_address); in sci_port_configuration_agent_validate_ports()
237 * Manual port configuration agent routines
240 /* verify all of the phys in the same port are using the same SAS address */
257 phy_mask = ihost->oem_parameters.ports[port_index].phy_mask; in sci_mpc_agent_validate_phy_configuration()
262 * Make sure that one or more of the phys were not already assinged to in sci_mpc_agent_validate_phy_configuration()
263 * a different port. */ in sci_mpc_agent_validate_phy_configuration()
272 sci_phy_get_sas_address(&ihost->phys[phy_index], in sci_mpc_agent_validate_phy_configuration()
277 * port range since the hardware starts all logical ports in sci_mpc_agent_validate_phy_configuration()
279 port_agent->phy_valid_port_range[phy_index].min_index = port_index; in sci_mpc_agent_validate_phy_configuration()
280 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; in sci_mpc_agent_validate_phy_configuration()
290 * See how many additional phys are being added to this logical port. in sci_mpc_agent_validate_phy_configuration()
293 * This is expected and required to add the phy to the port. */ in sci_mpc_agent_validate_phy_configuration()
297 sci_phy_get_sas_address(&ihost->phys[phy_index], in sci_mpc_agent_validate_phy_configuration()
302 * The phy mask specified that this phy is part of the same port in sci_mpc_agent_validate_phy_configuration()
307 port_agent->phy_valid_port_range[phy_index].min_index = port_index; in sci_mpc_agent_validate_phy_configuration()
308 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; in sci_mpc_agent_validate_phy_configuration()
310 sci_port_add_phy(&ihost->ports[port_index], in sci_mpc_agent_validate_phy_configuration()
311 &ihost->phys[phy_index]); in sci_mpc_agent_validate_phy_configuration()
333 spin_lock_irqsave(&ihost->scic_lock, flags); in mpc_agent_timeout()
335 if (tmr->cancel) in mpc_agent_timeout()
338 port_agent->timer_pending = false; in mpc_agent_timeout()
340 /* Find the mask of phys that are reported read but as yet unconfigured into a port */ in mpc_agent_timeout()
341 configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; in mpc_agent_timeout()
344 struct isci_phy *iphy = &ihost->phys[index]; in mpc_agent_timeout()
347 port_agent->link_up_handler(ihost, port_agent, in mpc_agent_timeout()
354 spin_unlock_irqrestore(&ihost->scic_lock, flags); in mpc_agent_timeout()
362 /* If the port is NULL then the phy was not assigned to a port. in sci_mpc_agent_link_up()
364 * the other PHYs in the port. in sci_mpc_agent_link_up()
369 port_agent->phy_ready_mask |= (1 << iphy->phy_index); in sci_mpc_agent_link_up()
371 if ((iport->active_phy_mask & (1 << iphy->phy_index))) in sci_mpc_agent_link_up()
372 port_agent->phy_configured_mask |= (1 << iphy->phy_index); in sci_mpc_agent_link_up()
379 * @port_agent: This is the port configuration agent for the controller.
380 * @iport: This is the port object associated with the phy. If the is no
381 * associated port this is an NULL. The port is an invalid
382 * handle only if the phy was never port of this port. This happens when
383 * the phy is not broadcasting the same SAS address as the other phys in the
384 * assigned port.
387 * This function handles the manual port configuration link down notifications.
388 * Since all ports and phys are associated at initialization time we just turn
389 * around and notifiy the port object of the link down event. If this PHY is
390 * not associated with a port there is no action taken. Is it possible to get a
391 * link down notification from a phy that has no assocoated port?
401 * If we can form a new port from the remainder of the phys in sci_mpc_agent_link_down()
403 * cleanup old devices and rediscover the port before in sci_mpc_agent_link_down()
404 * rebuilding the port with the phys that remain in the ready in sci_mpc_agent_link_down()
407 port_agent->phy_ready_mask &= ~(1 << iphy->phy_index); in sci_mpc_agent_link_down()
408 port_agent->phy_configured_mask &= ~(1 << iphy->phy_index); in sci_mpc_agent_link_down()
411 * Check to see if there are more phys waiting to be in sci_mpc_agent_link_down()
412 * configured into a port. If there are allow the SCI User in sci_mpc_agent_link_down()
413 * to tear down this port, if necessary, and then reconstruct in sci_mpc_agent_link_down()
414 * the port after the timeout. in sci_mpc_agent_link_down()
416 if ((port_agent->phy_configured_mask == 0x0000) && in sci_mpc_agent_link_down()
417 (port_agent->phy_ready_mask != 0x0000) && in sci_mpc_agent_link_down()
418 !port_agent->timer_pending) { in sci_mpc_agent_link_down()
419 port_agent->timer_pending = true; in sci_mpc_agent_link_down()
421 sci_mod_timer(&port_agent->timer, in sci_mpc_agent_link_down()
429 /* verify phys are assigned a valid SAS address for automatic port
447 sci_phy_get_sas_address(&ihost->phys[phy_index], in sci_apc_agent_validate_phy_configuration()
451 sci_phy_get_sas_address(&ihost->phys[phy_index], in sci_apc_agent_validate_phy_configuration()
456 port_agent->phy_valid_port_range[phy_index].min_index = port_index; in sci_apc_agent_validate_phy_configuration()
457 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; in sci_apc_agent_validate_phy_configuration()
459 port_agent->phy_valid_port_range[phy_index].min_index = phy_index; in sci_apc_agent_validate_phy_configuration()
460 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; in sci_apc_agent_validate_phy_configuration()
470 * This routine will restart the automatic port configuration timeout
478 port_agent->timer_pending = true; in sci_apc_agent_start_timer()
479 sci_mod_timer(&port_agent->timer, timeout); in sci_apc_agent_start_timer()
495 if (sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) in sci_apc_agent_configure_ports()
501 * There is no matching Port for this PHY so lets search through the in sci_apc_agent_configure_ports()
502 * Ports and see if we can add the PHY to its own port or maybe start in sci_apc_agent_configure_ports()
503 * the timer and wait to see if a wider port can be made. in sci_apc_agent_configure_ports()
505 * Note the break when we reach the condition of the port id == phy id */ in sci_apc_agent_configure_ports()
506 for (port_index = port_agent->phy_valid_port_range[iphy->phy_index].min_index; in sci_apc_agent_configure_ports()
507 port_index <= port_agent->phy_valid_port_range[iphy->phy_index].max_index; in sci_apc_agent_configure_ports()
510 iport = &ihost->ports[port_index]; in sci_apc_agent_configure_ports()
512 /* First we must make sure that this PHY can be added to this Port. */ in sci_apc_agent_configure_ports()
513 if (sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) { in sci_apc_agent_configure_ports()
515 * Port contains a PHY with a greater PHY ID than the current in sci_apc_agent_configure_ports()
517 * port so skip it and move on. */ in sci_apc_agent_configure_ports()
518 if (iport->active_phy_mask > (1 << iphy->phy_index)) { in sci_apc_agent_configure_ports()
524 * We have reached the end of our Port list and have not found in sci_apc_agent_configure_ports()
525 * any reason why we should not either add the PHY to the port in sci_apc_agent_configure_ports()
526 * or wait for more phys to become active. */ in sci_apc_agent_configure_ports()
527 if (iport->physical_port_index == iphy->phy_index) { in sci_apc_agent_configure_ports()
529 * The Port either has no active PHYs. in sci_apc_agent_configure_ports()
530 * Consider that if the port had any active PHYs we would have in sci_apc_agent_configure_ports()
531 * or active PHYs with in sci_apc_agent_configure_ports()
541 * The current Port has no active PHYs and this PHY could be part in sci_apc_agent_configure_ports()
542 * of this Port. Since we dont know as yet setup to start the in sci_apc_agent_configure_ports()
544 if (iport->active_phy_mask == 0) { in sci_apc_agent_configure_ports()
547 } else if (iport->active_phy_mask != 0) { in sci_apc_agent_configure_ports()
549 * The Port has an active phy and the current Phy can not in sci_apc_agent_configure_ports()
550 * participate in this port so skip the PHY and see if in sci_apc_agent_configure_ports()
560 * add a phy to a port but could not becuase the automatic port in sci_apc_agent_configure_ports()
563 * choice to the smallest possible port. */ in sci_apc_agent_configure_ports()
576 port_agent->phy_configured_mask |= (1 << iphy->phy_index); in sci_apc_agent_configure_ports()
587 /* do nothing the PHY can not be made part of a port at this time. */ in sci_apc_agent_configure_ports()
593 * sci_apc_agent_link_up - handle apc link up events
596 * @port_agent: This is the port configuration agent for the controller.
597 * @iport: This is the port object associated with the phy. If the is no
598 * associated port this is an NULL.
601 * This method handles the automatic port configuration for link up
603 * that has no assocoated port?
610 u8 phy_index = iphy->phy_index; in sci_apc_agent_link_up()
613 /* the phy is not the part of this port */ in sci_apc_agent_link_up()
614 port_agent->phy_ready_mask |= 1 << phy_index; in sci_apc_agent_link_up()
618 /* the phy is already the part of the port */ in sci_apc_agent_link_up()
619 port_agent->phy_ready_mask |= 1 << phy_index; in sci_apc_agent_link_up()
628 * @port_agent: This is the port configuration agent for the controller.
629 * @iport: This is the port object associated with the phy. If the is no
630 * associated port this is an NULL.
633 * This method handles the automatic port configuration link down
634 * notifications. not associated with a port there is no action taken. Is it
636 * port?
644 port_agent->phy_ready_mask &= ~(1 << iphy->phy_index); in sci_apc_agent_link_down()
648 if (port_agent->phy_configured_mask & (1 << iphy->phy_index)) { in sci_apc_agent_link_down()
654 port_agent->phy_configured_mask &= ~(1 << iphy->phy_index); in sci_apc_agent_link_down()
658 /* configure the phys into ports when the timer fires */
671 spin_lock_irqsave(&ihost->scic_lock, flags); in apc_agent_timeout()
673 if (tmr->cancel) in apc_agent_timeout()
676 port_agent->timer_pending = false; in apc_agent_timeout()
678 configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; in apc_agent_timeout()
688 &ihost->phys[index], false); in apc_agent_timeout()
695 spin_unlock_irqrestore(&ihost->scic_lock, flags); in apc_agent_timeout()
700 * Public port configuration agent routines
704 * This method will construct the port configuration agent for operation. This
705 * call is universal for both manual port configuration and automatic port
713 port_agent->phy_configured_mask = 0x00; in sci_port_configuration_agent_construct()
714 port_agent->phy_ready_mask = 0x00; in sci_port_configuration_agent_construct()
716 port_agent->link_up_handler = NULL; in sci_port_configuration_agent_construct()
717 port_agent->link_down_handler = NULL; in sci_port_configuration_agent_construct()
719 port_agent->timer_pending = false; in sci_port_configuration_agent_construct()
722 port_agent->phy_valid_port_range[index].min_index = 0; in sci_port_configuration_agent_construct()
723 port_agent->phy_valid_port_range[index].max_index = 0; in sci_port_configuration_agent_construct()
729 return ihost->port_agent.link_up_handler == sci_apc_agent_link_up; in is_port_config_apc()
739 mode = ihost->oem_parameters.controller.mode_type; in sci_port_configuration_agent_initialize()
745 port_agent->link_up_handler = sci_mpc_agent_link_up; in sci_port_configuration_agent_initialize()
746 port_agent->link_down_handler = sci_mpc_agent_link_down; in sci_port_configuration_agent_initialize()
748 sci_init_timer(&port_agent->timer, mpc_agent_timeout); in sci_port_configuration_agent_initialize()
753 port_agent->link_up_handler = sci_apc_agent_link_up; in sci_port_configuration_agent_initialize()
754 port_agent->link_down_handler = sci_apc_agent_link_down; in sci_port_configuration_agent_initialize()
756 sci_init_timer(&port_agent->timer, apc_agent_timeout); in sci_port_configuration_agent_initialize()