The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/isci/scil/scif_sas_smp_activity_clear_affiliation.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
    3  *
    4  * This file is provided under a dual BSD/GPLv2 license.  When using or
    5  * redistributing this file, you may do so under either license.
    6  *
    7  * GPL LICENSE SUMMARY
    8  *
    9  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
   10  *
   11  * This program is free software; you can redistribute it and/or modify
   12  * it under the terms of version 2 of the GNU General Public License as
   13  * published by the Free Software Foundation.
   14  *
   15  * This program is distributed in the hope that it will be useful, but
   16  * WITHOUT ANY WARRANTY; without even the implied warranty of
   17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18  * General Public License for more details.
   19  *
   20  * You should have received a copy of the GNU General Public License
   21  * along with this program; if not, write to the Free Software
   22  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
   23  * The full GNU General Public License is included in this distribution
   24  * in the file called LICENSE.GPL.
   25  *
   26  * BSD LICENSE
   27  *
   28  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
   29  * All rights reserved.
   30  *
   31  * Redistribution and use in source and binary forms, with or without
   32  * modification, are permitted provided that the following conditions
   33  * are met:
   34  *
   35  *   * Redistributions of source code must retain the above copyright
   36  *     notice, this list of conditions and the following disclaimer.
   37  *   * Redistributions in binary form must reproduce the above copyright
   38  *     notice, this list of conditions and the following disclaimer in
   39  *     the documentation and/or other materials provided with the
   40  *     distribution.
   41  *
   42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   43  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   44  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   45  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   46  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   47  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   48  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   50  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   51  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   52  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   53  */
   54 
   55 #include <sys/cdefs.h>
   56 __FBSDID("$FreeBSD$");
   57 
   58 /**
   59  * @file
   60  *
   61  * @brief This file contains the methods for the SCIF_SAS_SMP_REMMOTE object's
   62  *           clear affiliation activity.
   63  */
   64 #include <dev/isci/scil/sci_controller.h>
   65 #include <dev/isci/scil/scif_sas_controller.h>
   66 #include <dev/isci/scil/scif_sas_remote_device.h>
   67 #include <dev/isci/scil/scif_sas_logger.h>
   68 
   69 #include <dev/isci/scil/scif_sas_smp_remote_device.h>
   70 #include <dev/isci/scil/scif_sas_smp_io_request.h>
   71 #include <dev/isci/scil/intel_sas.h>
   72 #include <dev/isci/scil/scic_io_request.h>
   73 #include <dev/isci/scil/scic_remote_device.h>
   74 #include <dev/isci/scil/scif_sas_smp_phy.h>
   75 
   76 //******************************************************************************
   77 //* P R I V A T E   M E T H O D S
   78 //******************************************************************************
   79 
   80 /**
   81  * @brief This method finds the next smp phy (from the anchor_phy) that link to
   82  *           a SATA end device.
   83  *
   84  * @param[in] fw_device the framework SMP device that is clearing affiliation for
   85  *               its remote SATA devices'
   86  *
   87  * @return SCIF_SAS_SMP_PHY_T a smp phy, to which clear affiliation phy control command
   88  *            is to be sent.
   89  */
   90 static
   91 SCIF_SAS_SMP_PHY_T * scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
   92    SCIF_SAS_SMP_PHY_T * anchor_phy
   93 )
   94 {
   95    SCI_FAST_LIST_ELEMENT_T  * element = &anchor_phy->list_element;
   96    SCIF_SAS_SMP_PHY_T * curr_smp_phy = NULL;
   97 
   98    while (element != NULL)
   99    {
  100       curr_smp_phy = (SCIF_SAS_SMP_PHY_T*) sci_fast_list_get_object(element);
  101       element = sci_fast_list_get_next(element);
  102 
  103       if (curr_smp_phy->attached_device_type == SMP_END_DEVICE_ONLY
  104           && curr_smp_phy->u.end_device != NULL)
  105       {
  106          SMP_DISCOVER_RESPONSE_PROTOCOLS_T  dev_protocols;
  107          scic_remote_device_get_protocols(
  108             curr_smp_phy->u.end_device->core_object, &dev_protocols);
  109 
  110          if (dev_protocols.u.bits.attached_stp_target)
  111             return curr_smp_phy;
  112       }
  113    }
  114 
  115    return NULL;
  116 }
  117 
  118 //******************************************************************************
  119 //* P U B L I C   M E T H O D S
  120 //******************************************************************************
  121 
  122 /**
  123  * @brief This method starts the clear affiliation activity for a
  124  *           smp device's remote SATA devices.
  125  *
  126  * @param[in] fw_device the framework SMP device that is clearing affiliation for
  127  *               its remote SATA devices.
  128  *
  129  * @return none
  130  */
  131 void scif_sas_smp_remote_device_start_clear_affiliation(
  132    SCIF_SAS_REMOTE_DEVICE_T * fw_device
  133 )
  134 {
  135    SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
  136       &fw_device->protocol_device.smp_device;
  137 
  138    SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
  139 
  140    if (smp_device->smp_phy_list.list_head != NULL)
  141    {
  142       phy_to_clear_affiliation =
  143          scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
  144             (SCIF_SAS_SMP_PHY_T *)smp_device->smp_phy_list.list_head->object
  145          );
  146    }
  147 
  148    if (phy_to_clear_affiliation != NULL)
  149    {
  150       smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
  151 
  152       //set current activity
  153       fw_device->protocol_device.smp_device.current_activity =
  154          SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CLEAR_AFFILIATION;
  155 
  156       //Set current_smp_request to PHY CONTROL.
  157       fw_device->protocol_device.smp_device.current_smp_request =
  158          SMP_FUNCTION_PHY_CONTROL;
  159 
  160       //reset discover_to_start flag.
  161       fw_device->protocol_device.smp_device.scheduled_activity =
  162          SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_NONE;
  163 
  164       //build PHY Control (clear affiliation) to the phy.
  165       scif_sas_smp_request_construct_phy_control(
  166          fw_device->domain->controller,
  167          fw_device,
  168          PHY_OPERATION_CLEAR_AFFILIATION,
  169          phy_to_clear_affiliation->phy_identifier,
  170          NULL,
  171          NULL
  172       );
  173 
  174       //issue DPC to start this request.
  175       scif_cb_start_internal_io_task_schedule(
  176          fw_device->domain->controller,
  177          scif_sas_controller_start_high_priority_io,
  178          fw_device->domain->controller
  179       );
  180    }
  181    else
  182       scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
  183 }
  184 
  185 
  186 /**
  187  * @brief This method continues the clear affiliation activity for a
  188  *           smp device's remote SATA devices.
  189  *
  190  * @param[in] fw_device the framework SMP device that is clearing affiliation for
  191  *               its remote SATA devices.
  192  *
  193  * @return none
  194  */
  195 void scif_sas_smp_remote_device_continue_clear_affiliation(
  196    SCIF_SAS_REMOTE_DEVICE_T * fw_device
  197 )
  198 {
  199    SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
  200       &fw_device->protocol_device.smp_device;
  201 
  202    //search from next immediate smp phy.
  203    SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
  204 
  205    if (smp_device->curr_clear_affiliation_phy->list_element.next != NULL)
  206    {
  207       phy_to_clear_affiliation =
  208          scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
  209             smp_device->curr_clear_affiliation_phy->list_element.next->object
  210          );
  211    }
  212 
  213    if (phy_to_clear_affiliation != NULL)
  214    {
  215       smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
  216 
  217       //build PHY Control (clear affiliation) to the phy.
  218       scif_sas_smp_request_construct_phy_control(
  219          fw_device->domain->controller,
  220          fw_device,
  221          PHY_OPERATION_CLEAR_AFFILIATION,
  222          phy_to_clear_affiliation->phy_identifier,
  223          NULL,
  224          NULL
  225       );
  226    }
  227    else
  228       scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
  229 }
  230 
  231 
  232 /**
  233  * @brief This method finishes the clear affiliation activity for a
  234  *           smp device's remote SATA devices. It then notify the domain it fihishes
  235  *           the clear affiliation activity.
  236  *
  237  * @param[in] fw_device the framework SMP device that is clearing affiliation for
  238  *               its remote SATA devices.
  239  *
  240  * @return none
  241  */
  242 void scif_sas_smp_remote_device_finish_clear_affiliation(
  243    SCIF_SAS_REMOTE_DEVICE_T * fw_device
  244 )
  245 {
  246    SCIF_SAS_DOMAIN_T * fw_domain = fw_device->domain;
  247 
  248    scif_sas_smp_remote_device_clear(fw_device);
  249 
  250    //let domain continue to clear affiliation on other smp devices.
  251    scif_sas_domain_continue_clear_affiliation(fw_domain);
  252 }
  253 
  254 

Cache object: 2fce5dcc264d2d42d13f1519d6d6f7f5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.