/* * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license. * * GPL LICENSE SUMMARY * * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. * The full GNU General Public License is included in this distribution * in the file called LICENSE.GPL. * * BSD LICENSE * * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "host.h" #define SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT … #define SCIC_SDS_APC_RECONFIGURATION_TIMEOUT … #define SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION … enum SCIC_SDS_APC_ACTIVITY { … }; /* * ****************************************************************************** * General port configuration agent routines * ****************************************************************************** */ /** * sci_sas_address_compare() * @address_one: A SAS Address to be compared. * @address_two: A SAS Address to be compared. * * Compare the two SAS Address and if SAS Address One is greater than SAS * Address Two then return > 0 else if SAS Address One is less than SAS Address * Two return < 0 Otherwise they are the same return 0 A signed value of x > 0 * > y where x is returned for Address One > Address Two y is returned for * Address One < Address Two 0 is returned ofr Address One = Address Two */ static s32 sci_sas_address_compare( struct sci_sas_address address_one, struct sci_sas_address address_two) { … } /** * sci_port_configuration_agent_find_port() * @ihost: The controller object used for the port search. * @iphy: The phy object to match. * * This routine will find a matching port for the phy. This means that the * port and phy both have the same broadcast sas address and same received sas * address. The port address or the NULL if there is no matching * port. port address if the port can be found to match the phy. * NULL if there is no matching port for the phy. */ static struct isci_port *sci_port_configuration_agent_find_port( struct isci_host *ihost, struct isci_phy *iphy) { … } /** * sci_port_configuration_agent_validate_ports() * @ihost: This is the controller object that contains the port agent * @port_agent: This is the port configuration agent for the controller. * * This routine will validate the port configuration is correct for the SCU * hardware. The SCU hardware allows for port configurations as follows. LP0 * -> (PE0), (PE0, PE1), (PE0, PE1, PE2, PE3) LP1 -> (PE1) LP2 -> (PE2), (PE2, * PE3) LP3 -> (PE3) enum sci_status SCI_SUCCESS the port configuration is valid for * this port configuration agent. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION * the port configuration is not valid for this port configuration agent. */ static enum sci_status sci_port_configuration_agent_validate_ports( struct isci_host *ihost, struct sci_port_configuration_agent *port_agent) { … } /* * ****************************************************************************** * Manual port configuration agent routines * ****************************************************************************** */ /* verify all of the phys in the same port are using the same SAS address */ static enum sci_status sci_mpc_agent_validate_phy_configuration(struct isci_host *ihost, struct sci_port_configuration_agent *port_agent) { … } static void mpc_agent_timeout(struct timer_list *t) { … } static void sci_mpc_agent_link_up(struct isci_host *ihost, struct sci_port_configuration_agent *port_agent, struct isci_port *iport, struct isci_phy *iphy) { … } /** * sci_mpc_agent_link_down() * @ihost: This is the controller object that receives the link down * notification. * @port_agent: This is the port configuration agent for the controller. * @iport: This is the port object associated with the phy. If the is no * associated port this is an NULL. The port is an invalid * handle only if the phy was never port of this port. This happens when * the phy is not broadcasting the same SAS address as the other phys in the * assigned port. * @iphy: This is the phy object which has gone link down. * * This function handles the manual port configuration link down notifications. * Since all ports and phys are associated at initialization time we just turn * around and notifiy the port object of the link down event. If this PHY is * not associated with a port there is no action taken. Is it possible to get a * link down notification from a phy that has no assocoated port? */ static void sci_mpc_agent_link_down( struct isci_host *ihost, struct sci_port_configuration_agent *port_agent, struct isci_port *iport, struct isci_phy *iphy) { … } /* verify phys are assigned a valid SAS address for automatic port * configuration mode. */ static enum sci_status sci_apc_agent_validate_phy_configuration(struct isci_host *ihost, struct sci_port_configuration_agent *port_agent) { … } /* * This routine will restart the automatic port configuration timeout * timer for the next time period. This could be caused by either a link * down event or a link up event where we can not yet tell to which a phy * belongs. */ static void sci_apc_agent_start_timer(struct sci_port_configuration_agent *port_agent, u32 timeout) { … } static void sci_apc_agent_configure_ports(struct isci_host *ihost, struct sci_port_configuration_agent *port_agent, struct isci_phy *iphy, bool start_timer) { … } /** * sci_apc_agent_link_up - handle apc link up events * @ihost: This is the controller object that receives the link up * notification. * @port_agent: This is the port configuration agent for the controller. * @iport: This is the port object associated with the phy. If the is no * associated port this is an NULL. * @iphy: This is the phy object which has gone link up. * * This method handles the automatic port configuration for link up * notifications. Is it possible to get a link down notification from a phy * that has no assocoated port? */ static void sci_apc_agent_link_up(struct isci_host *ihost, struct sci_port_configuration_agent *port_agent, struct isci_port *iport, struct isci_phy *iphy) { … } /** * sci_apc_agent_link_down() * @ihost: This is the controller object that receives the link down * notification. * @port_agent: This is the port configuration agent for the controller. * @iport: This is the port object associated with the phy. If the is no * associated port this is an NULL. * @iphy: This is the phy object which has gone link down. * * This method handles the automatic port configuration link down * notifications. not associated with a port there is no action taken. Is it * possible to get a link down notification from a phy that has no assocoated * port? */ static void sci_apc_agent_link_down( struct isci_host *ihost, struct sci_port_configuration_agent *port_agent, struct isci_port *iport, struct isci_phy *iphy) { … } /* configure the phys into ports when the timer fires */ static void apc_agent_timeout(struct timer_list *t) { … } /* * ****************************************************************************** * Public port configuration agent routines * ****************************************************************************** */ /* * This method will construct the port configuration agent for operation. This * call is universal for both manual port configuration and automatic port * configuration modes. */ void sci_port_configuration_agent_construct( struct sci_port_configuration_agent *port_agent) { … } bool is_port_config_apc(struct isci_host *ihost) { … } enum sci_status sci_port_configuration_agent_initialize( struct isci_host *ihost, struct sci_port_configuration_agent *port_agent) { … }