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.
56 #ifndef _SCIF_SAS_SMP_REMOTE_DEVICE_H_
57 #define _SCIF_SAS_SMP_REMOTE_DEVICE_H_
64 #include <dev/isci/scil/sci_fast_list.h>
65 #include <dev/isci/scil/scif_sas_smp_phy.h>
70 * @brief This file contains the protected interface structures, constants,
71 * and methods for the SCIF_SAS_SMP_REMOTE_DEVICE object.
74 struct SCIF_SAS_CONTROLLER;
75 struct SCIF_SAS_REMOTE_DEVICE;
76 struct SCIF_SAS_INTERNAL_IO_REQUEST;
77 struct SCIF_SAS_REQUEST;
78 struct SCIF_SAS_SMP_PHY;
80 #define SMP_REQUEST_RETRY_WAIT_DURATION 20
81 #define SMP_SPINUP_HOLD_RELEASE_WAIT_DURATION 100
84 * @name SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CODES
86 * These constants depict the various SMP remote device activities.
89 #define NOT_IN_SMP_ACTIVITY 0xff
90 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_NONE 0x0
91 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_DISCOVER 0x1
92 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_TARGET_RESET 0x2
93 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_SATA_SPINUP_HOLD_RELEASE 0x3
94 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CONFIG_ROUTE_TABLE 0x4
95 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CLEAN_ROUTE_TABLE 0x5
96 #define SCIF_SAS_SMP_REMOTE_DEVICE_ACTIVITY_CLEAR_AFFILIATION 0x6
102 * @name SCIF_SAS_CONFIG_ROUTE_TABLE_OPTION_CODES
104 * These constants depict the various configure route table options.
107 #define SCIF_SAS_CONFIG_ROUTE_TABLE_LOWEST_PHY_ONLY 0
108 #define SCIF_SAS_CONFIG_ROUTE_TABLE_MIDDLE_PHY_ONLY 1
109 #define SCIF_SAS_CONFIG_ROUTE_TABLE_HIGHEST_PHY_ONLY 2
110 #define SCIF_SAS_CONFIG_ROUTE_TABLE_ALL_PHYS 3
114 * @struct SCIF_SAS_SMP_REMOTE_DEVICE
116 * @brief The SCIF_SAS_SMP_REMOTE_DEVICE stores data for smp remote devices
117 * (expanders) discovering attached targets.
120 typedef struct SCIF_SAS_SMP_REMOTE_DEVICE
123 * This field stores the current SMP request function in the discovering
126 U32 current_smp_request;
129 * This field indicates a smp device is either in the middle of normal discover
130 * process or in the middle of resetting a expander attahced remote device.
135 * This field stores the current expander phy index for sending out SMP
138 U8 current_activity_phy_index;
141 * This field stores the current route index to config route table for
144 U16 curr_config_route_index;
147 * This field indicates whether a route table of an expander has been cleaned
148 * since a DISCOVER process starts.
150 BOOL is_route_table_cleaned;
153 * This field stores the smp phy whose route entries are edited by sending
154 * CONFIG ROUTE INFO commands.
156 struct SCIF_SAS_SMP_PHY * config_route_smp_phy_anchor;
159 * This field stores the current smp phy on a destination device's smp phy list whose
160 * attached device's sas address is to be edited into this smp device's route table.
161 * When one config route info response is processed, we can find the next smp phy to edit
162 * using this field's value.
164 struct SCIF_SAS_SMP_PHY * curr_config_route_destination_smp_phy;
167 * This field stores the current smp phy to which a PHY CONTROL (clear affiliation)
168 * command is sent out.
170 struct SCIF_SAS_SMP_PHY * curr_clear_affiliation_phy;
173 * This field is to indicate a smp activity for this smp device is
174 * to be started (not yet). The scheduled activity could be Discover or Config
177 U8 scheduled_activity;
180 * This timer is used for waiting before retrying a smp request, or before
181 * sending Discover request after Phy Control during Target Reset.
183 void * smp_activity_timer;
186 * This field save the retry count for internal smp request. Since when
187 * an internal smp request gets retried, it has been destructed already.
192 * This field stores the number of phys for expander device found by decoding
193 * the SMP REPORT GENERAL response.
198 * This field indicates the maximum number of expander route indexes per phy for
199 * this expander device.
201 U16 expander_route_indexes;
204 * This field indicates whether an expander device supports table-to-table
207 BOOL is_table_to_table_supported;
210 * This field indicates whether an expander device is externally configurable.
211 * If it is, it is not self-configuring and is not able to config others.
213 BOOL is_externally_configurable;
216 * This field indicates whether an expander device is able to config others.
218 BOOL is_able_to_config_others;
221 * This field contains the list of all smp phys that connect to another smp phy.
223 SCI_FAST_LIST_T smp_phy_list;
225 }SCIF_SAS_SMP_REMOTE_DEVICE_T;
227 void scif_sas_smp_remote_device_clear(
228 struct SCIF_SAS_REMOTE_DEVICE * fw_device
231 void scif_sas_smp_remote_device_construct(
232 struct SCIF_SAS_REMOTE_DEVICE * fw_device
235 SCI_STATUS scif_sas_smp_remote_device_decode_smp_response(
236 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
237 struct SCIF_SAS_REQUEST * fw_request,
238 void * response_data,
239 SCI_IO_STATUS completion_status
242 SCI_STATUS scif_sas_smp_remote_device_decode_report_general_response(
243 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
244 SMP_RESPONSE_T * smp_response
247 SCI_STATUS scif_sas_smp_remote_device_decode_initial_discover_response(
248 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
249 SMP_RESPONSE_T * smp_response
252 SCI_STATUS scif_sas_smp_remote_device_decode_report_phy_sata_response(
253 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
254 SMP_RESPONSE_T * smp_response
257 SCI_STATUS scif_sas_smp_remote_device_decode_target_reset_phy_control_response(
258 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
259 SMP_RESPONSE_T * smp_response
262 SCI_STATUS scif_sas_smp_remote_device_decode_discover_phy_control_response(
263 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
264 SMP_RESPONSE_T * smp_response
267 SCI_STATUS scif_sas_smp_remote_device_decode_target_reset_discover_response(
268 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
269 SMP_RESPONSE_T * smp_response
272 SCI_STATUS scif_sas_smp_remote_device_decode_spinup_hold_release_discover_response(
273 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
274 SMP_RESPONSE_T * smp_response
277 SCI_STATUS scif_sas_smp_remote_device_decode_config_route_info_response(
278 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
279 SMP_RESPONSE_T * smp_response
282 void scif_sas_smp_remote_device_start_discover(
283 struct SCIF_SAS_REMOTE_DEVICE * fw_device
286 void scif_sas_smp_remote_device_continue_discover(
287 struct SCIF_SAS_REMOTE_DEVICE * fw_device
290 void scif_sas_smp_remote_device_finish_initial_discover(
291 struct SCIF_SAS_REMOTE_DEVICE * fw_device
294 void scif_sas_smp_remote_device_finish_discover(
295 struct SCIF_SAS_REMOTE_DEVICE * fw_device
298 void scif_sas_smp_remote_device_continue_target_reset(
299 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
300 struct SCIF_SAS_REQUEST * fw_request
303 void scif_sas_smp_remote_device_fail_discover(
304 struct SCIF_SAS_REMOTE_DEVICE * fw_device
307 void scif_sas_smp_remote_device_fail_target_reset(
308 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
309 struct SCIF_SAS_REQUEST * fw_request
312 void scif_sas_smp_remote_device_continue_current_activity(
313 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
314 struct SCIF_SAS_REQUEST * fw_request,
318 void scif_sas_smp_remote_device_target_reset_poll(
319 struct SCIF_SAS_REQUEST * fw_request
322 void scif_sas_smp_remote_device_sata_spinup_hold_release(
323 struct SCIF_SAS_REMOTE_DEVICE * fw_device
326 void scif_sas_smp_remote_device_fail_target_spinup_hold_release(
327 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
328 struct SCIF_SAS_REMOTE_DEVICE * target_device
331 void scif_sas_smp_remote_device_retry_internal_io(
332 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
337 BOOL scif_sas_smp_remote_device_is_in_activity(
338 struct SCIF_SAS_REMOTE_DEVICE * fw_device
341 SCIF_SAS_SMP_PHY_T * scif_sas_smp_remote_device_find_smp_phy_by_id(
343 struct SCIF_SAS_SMP_REMOTE_DEVICE * smp_remote_device
346 void scif_sas_smp_remote_device_removed(
347 struct SCIF_SAS_REMOTE_DEVICE * this_device
350 void scif_sas_smp_remote_device_terminated_request_handler(
351 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
352 struct SCIF_SAS_REQUEST * fw_request
355 void scif_sas_smp_remote_device_populate_smp_phy_list(
356 struct SCIF_SAS_REMOTE_DEVICE * fw_device
359 SCI_STATUS scif_sas_smp_remote_device_save_smp_phy_info(
360 struct SCIF_SAS_REMOTE_DEVICE * fw_device,
361 SMP_RESPONSE_DISCOVER_T * discover_response
364 #ifdef SCI_SMP_PHY_LIST_DEBUG_PRINT
365 void scif_sas_smp_remote_device_print_smp_phy_list(
366 struct SCIF_SAS_REMOTE_DEVICE * fw_device
370 void scif_sas_smp_remote_device_configure_upstream_expander_route_info(
371 struct SCIF_SAS_REMOTE_DEVICE * this_device
374 struct SCIF_SAS_REMOTE_DEVICE * scif_sas_remote_device_find_upstream_expander(
375 struct SCIF_SAS_REMOTE_DEVICE * this_device
378 struct SCIF_SAS_REMOTE_DEVICE * scif_sas_remote_device_find_downstream_expander(
379 struct SCIF_SAS_REMOTE_DEVICE * this_device
382 BOOL scif_sas_smp_remote_device_do_config_route_info(
383 struct SCIF_SAS_REMOTE_DEVICE * device_being_config,
384 struct SCIF_SAS_SMP_PHY * destination_smp_phy
387 void scif_sas_smp_remote_device_configure_route_table(
388 struct SCIF_SAS_REMOTE_DEVICE * device_being_config
391 void scif_sas_smp_remote_device_clean_route_table(
392 struct SCIF_SAS_REMOTE_DEVICE * fw_device
395 void scif_sas_smp_remote_device_clean_route_table_entry(
396 struct SCIF_SAS_REMOTE_DEVICE * fw_device
399 void scif_sas_smp_remote_device_cancel_config_route_table_activity(
400 struct SCIF_SAS_REMOTE_DEVICE * fw_device
403 void scif_sas_smp_remote_device_cancel_smp_activity(
404 struct SCIF_SAS_REMOTE_DEVICE * fw_device
407 U8 scif_sas_smp_remote_device_get_config_route_table_method(
408 struct SCIF_SAS_REMOTE_DEVICE * fw_device
411 void scif_sas_smp_remote_device_start_clear_affiliation(
412 struct SCIF_SAS_REMOTE_DEVICE * fw_device
415 void scif_sas_smp_remote_device_continue_clear_affiliation(
416 struct SCIF_SAS_REMOTE_DEVICE * fw_device
419 void scif_sas_smp_remote_device_finish_clear_affiliation(
420 struct SCIF_SAS_REMOTE_DEVICE * fw_device
423 void scif_sas_smp_remote_device_start_target_reset(
424 struct SCIF_SAS_REMOTE_DEVICE * expander_device,
425 struct SCIF_SAS_REMOTE_DEVICE * target_device,
426 struct SCIF_SAS_REQUEST * fw_request
431 #endif // __cplusplus
433 #endif // _SCIF_SAS_SMP_REMOTE_DEVICE_H_