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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
59 * @brief This file contains the methods for the SCIF_SAS_SMP_REMMOTE object's
60 * clear affiliation activity.
62 #include <dev/isci/scil/sci_controller.h>
63 #include <dev/isci/scil/scif_sas_controller.h>
64 #include <dev/isci/scil/scif_sas_remote_device.h>
65 #include <dev/isci/scil/scif_sas_logger.h>
67 #include <dev/isci/scil/scif_sas_smp_remote_device.h>
68 #include <dev/isci/scil/scif_sas_smp_io_request.h>
69 #include <dev/isci/scil/intel_sas.h>
70 #include <dev/isci/scil/scic_io_request.h>
71 #include <dev/isci/scil/scic_remote_device.h>
72 #include <dev/isci/scil/scif_sas_smp_phy.h>
74 //******************************************************************************
75 //* P R I V A T E M E T H O D S
76 //******************************************************************************
79 * @brief This method finds the next smp phy (from the anchor_phy) that link to
82 * @param[in] fw_device the framework SMP device that is clearing affiliation for
83 * its remote SATA devices'
85 * @return SCIF_SAS_SMP_PHY_T a smp phy, to which clear affiliation phy control command
89 SCIF_SAS_SMP_PHY_T * scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
90 SCIF_SAS_SMP_PHY_T * anchor_phy
93 SCI_FAST_LIST_ELEMENT_T * element = &anchor_phy->list_element;
94 SCIF_SAS_SMP_PHY_T * curr_smp_phy = NULL;
96 while (element != NULL)
98 curr_smp_phy = (SCIF_SAS_SMP_PHY_T*) sci_fast_list_get_object(element);
99 element = sci_fast_list_get_next(element);
101 if (curr_smp_phy->attached_device_type == SMP_END_DEVICE_ONLY
102 && curr_smp_phy->u.end_device != NULL)
104 SMP_DISCOVER_RESPONSE_PROTOCOLS_T dev_protocols;
105 scic_remote_device_get_protocols(
106 curr_smp_phy->u.end_device->core_object, &dev_protocols);
108 if (dev_protocols.u.bits.attached_stp_target)
116 //******************************************************************************
117 //* P U B L I C M E T H O D S
118 //******************************************************************************
121 * @brief This method starts the clear affiliation activity for a
122 * smp device's remote SATA devices.
124 * @param[in] fw_device the framework SMP device that is clearing affiliation for
125 * its remote SATA devices.
129 void scif_sas_smp_remote_device_start_clear_affiliation(
130 SCIF_SAS_REMOTE_DEVICE_T * fw_device
133 SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
134 &fw_device->protocol_device.smp_device;
136 SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
138 if (smp_device->smp_phy_list.list_head != NULL)
140 phy_to_clear_affiliation =
141 scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
142 (SCIF_SAS_SMP_PHY_T *)smp_device->smp_phy_list.list_head->object
146 if (phy_to_clear_affiliation != NULL)
148 smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
150 //set current activity
151 fw_device->protocol_device.smp_device.current_activity =
152 SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CLEAR_AFFILIATION;
154 //Set current_smp_request to PHY CONTROL.
155 fw_device->protocol_device.smp_device.current_smp_request =
156 SMP_FUNCTION_PHY_CONTROL;
158 //reset discover_to_start flag.
159 fw_device->protocol_device.smp_device.scheduled_activity =
160 SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_NONE;
162 //build PHY Control (clear affiliation) to the phy.
163 scif_sas_smp_request_construct_phy_control(
164 fw_device->domain->controller,
166 PHY_OPERATION_CLEAR_AFFILIATION,
167 phy_to_clear_affiliation->phy_identifier,
172 //issue DPC to start this request.
173 scif_cb_start_internal_io_task_schedule(
174 fw_device->domain->controller,
175 scif_sas_controller_start_high_priority_io,
176 fw_device->domain->controller
180 scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
185 * @brief This method continues the clear affiliation activity for a
186 * smp device's remote SATA devices.
188 * @param[in] fw_device the framework SMP device that is clearing affiliation for
189 * its remote SATA devices.
193 void scif_sas_smp_remote_device_continue_clear_affiliation(
194 SCIF_SAS_REMOTE_DEVICE_T * fw_device
197 SCIF_SAS_SMP_REMOTE_DEVICE_T * smp_device =
198 &fw_device->protocol_device.smp_device;
200 //search from next immediate smp phy.
201 SCIF_SAS_SMP_PHY_T * phy_to_clear_affiliation = NULL;
203 if (smp_device->curr_clear_affiliation_phy->list_element.next != NULL)
205 phy_to_clear_affiliation =
206 scif_sas_smp_remote_device_find_next_smp_phy_link_to_sata(
207 smp_device->curr_clear_affiliation_phy->list_element.next->object
211 if (phy_to_clear_affiliation != NULL)
213 smp_device->curr_clear_affiliation_phy = phy_to_clear_affiliation;
215 //build PHY Control (clear affiliation) to the phy.
216 scif_sas_smp_request_construct_phy_control(
217 fw_device->domain->controller,
219 PHY_OPERATION_CLEAR_AFFILIATION,
220 phy_to_clear_affiliation->phy_identifier,
226 scif_sas_smp_remote_device_finish_clear_affiliation(fw_device);
231 * @brief This method finishes the clear affiliation activity for a
232 * smp device's remote SATA devices. It then notify the domain it fihishes
233 * the clear affiliation activity.
235 * @param[in] fw_device the framework SMP device that is clearing affiliation for
236 * its remote SATA devices.
240 void scif_sas_smp_remote_device_finish_clear_affiliation(
241 SCIF_SAS_REMOTE_DEVICE_T * fw_device
244 SCIF_SAS_DOMAIN_T * fw_domain = fw_device->domain;
246 scif_sas_smp_remote_device_clear(fw_device);
248 //let domain continue to clear affiliation on other smp devices.
249 scif_sas_domain_continue_clear_affiliation(fw_domain);