2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
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.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
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
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.
55 #include <sys/cdefs.h>
56 __FBSDID("$FreeBSD$");
61 * @brief This file contains the methods for the SCIF_SAS_SMP_REMMOTE object's
62 * clear affiliation activity.
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>
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>
76 //******************************************************************************
77 //* P R I V A T E M E T H O D S
78 //******************************************************************************
81 * @brief This method finds the next smp phy (from the anchor_phy) that link to
84 * @param[in] fw_device the framework SMP device that is clearing affiliation for
85 * its remote SATA devices'
87 * @return SCIF_SAS_SMP_PHY_T a smp phy, to which clear affiliation phy control command
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
95 SCI_FAST_LIST_ELEMENT_T * element = &anchor_phy->list_element;
96 SCIF_SAS_SMP_PHY_T * curr_smp_phy = NULL;
98 while (element != NULL)
100 curr_smp_phy = (SCIF_SAS_SMP_PHY_T*) sci_fast_list_get_object(element);
101 element = sci_fast_list_get_next(element);
103 if (curr_smp_phy->attached_device_type == SMP_END_DEVICE_ONLY
104 && curr_smp_phy->u.end_device != NULL)
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);
110 if (dev_protocols.u.bits.attached_stp_target)
118 //******************************************************************************
119 //* P U B L I C M E T H O D S
120 //******************************************************************************
123 * @brief This method starts the clear affiliation activity for a
124 * smp device's remote SATA devices.
126 * @param[in] fw_device the framework SMP device that is clearing affiliation for
127 * its remote SATA devices.
131 void scif_sas_smp_remote_device_start_clear_affiliation(
132 SCIF_SAS_REMOTE_DEVICE_T * fw_device
135 SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
136 &fw_device->protocol_device.smp_device;
138 SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
140 if (smp_device->smp_phy_list.list_head != NULL)
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
148 if (phy_to_clear_affiliation != NULL)
150 smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
152 //set current activity
153 fw_device->protocol_device.smp_device.current_activity =
154 SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CLEAR_AFFILIATION;
156 //Set current_smp_request to PHY CONTROL.
157 fw_device->protocol_device.smp_device.current_smp_request =
158 SMP_FUNCTION_PHY_CONTROL;
160 //reset discover_to_start flag.
161 fw_device->protocol_device.smp_device.scheduled_activity =
162 SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_NONE;
164 //build PHY Control (clear affiliation) to the phy.
165 scif_sas_smp_request_construct_phy_control(
166 fw_device->domain->controller,
168 PHY_OPERATION_CLEAR_AFFILIATION,
169 phy_to_clear_affiliation->phy_identifier,
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
182 scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
187 * @brief This method continues the clear affiliation activity for a
188 * smp device's remote SATA devices.
190 * @param[in] fw_device the framework SMP device that is clearing affiliation for
191 * its remote SATA devices.
195 void scif_sas_smp_remote_device_continue_clear_affiliation(
196 SCIF_SAS_REMOTE_DEVICE_T * fw_device
199 SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
200 &fw_device->protocol_device.smp_device;
202 //search from next immediate smp phy.
203 SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
205 if (smp_device->curr_clear_affiliation_phy->list_element.next != NULL)
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
213 if (phy_to_clear_affiliation != NULL)
215 smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
217 //build PHY Control (clear affiliation) to the phy.
218 scif_sas_smp_request_construct_phy_control(
219 fw_device->domain->controller,
221 PHY_OPERATION_CLEAR_AFFILIATION,
222 phy_to_clear_affiliation->phy_identifier,
228 scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
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.
237 * @param[in] fw_device the framework SMP device that is clearing affiliation for
238 * its remote SATA devices.
242 void scif_sas_smp_remote_device_finish_clear_affiliation(
243 SCIF_SAS_REMOTE_DEVICE_T * fw_device
246 SCIF_SAS_DOMAIN_T * fw_domain = fw_device->domain;
248 scif_sas_smp_remote_device_clear(fw_device);
250 //let domain continue to clear affiliation on other smp devices.
251 scif_sas_domain_continue_clear_affiliation(fw_domain);