xref: /freebsd/sys/dev/isci/scil/scif_sas_domain.h (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
1 /*-
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.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
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.
12  *
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.
17  *
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.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
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
38  *     distribution.
39  *
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.
51  *
52  * $FreeBSD$
53  */
54 #ifndef _SCIF_SAS_DOMAIN_H_
55 #define _SCIF_SAS_DOMAIN_H_
56 
57 /**
58  * @file
59  *
60  * @brief This file contains the protected interface structures, constants,
61  *        and methods for the SCIF_SAS_DOMAIN object.
62  */
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif // __cplusplus
67 
68 #include <dev/isci/scil/sci_abstract_list.h>
69 #include <dev/isci/scil/sci_fast_list.h>
70 #include <dev/isci/scil/scif_domain.h>
71 
72 #include <dev/isci/scil/sci_base_domain.h>
73 #include <dev/isci/scil/scif_sas_request.h>
74 #include <dev/isci/scil/scif_sas_task_request.h>
75 #include <dev/isci/scil/scif_sas_remote_device.h>
76 
77 
78 extern SCI_BASE_DOMAIN_STATE_HANDLER_T scif_sas_domain_state_handler_table[];
79 extern SCI_BASE_STATE_T scif_sas_domain_state_table[];
80 
81 #define PORT_HARD_RESET_TIMEOUT 1000 //1000 miliseconds
82 
83 #define SCIF_DOMAIN_DISCOVER_TIMEOUT 20000 // miliseconds
84 
85 /**
86  * @struct SCIF_SAS_DOMAIN
87  *
88  * @brief The SCI SAS Framework domain object abstracts the SAS domain
89  *        level behavior for the framework component.  Additionally,
90  *        it provides a higher level of abstraction for the core port
91  *        object.  There is a 1:1 correspondance between core ports and
92  *        framework domain objects.  Essentially, each core port provides
93  *        the access to the remote devices in the domain.
94  */
95 typedef struct SCIF_SAS_DOMAIN
96 {
97    /**
98     * The SCI_BASE_DOMAIN is the parent object for the SCIF_SAS_DOMAIN
99     * object.
100     */
101    SCI_BASE_DOMAIN_T  parent;
102 
103    /**
104     * This field contains the handle for the SCI Core port object that
105     * is managed by this framework domain object.
106     */
107    SCI_PORT_HANDLE_T  core_object;
108 
109    /**
110     * This field specifies the controller containing this domain object.
111     */
112    struct SCIF_SAS_CONTROLLER * controller;
113 
114    /**
115     * This field references the list of state specific handler methods to
116     * be utilized for this domain instance.
117     */
118    SCI_BASE_DOMAIN_STATE_HANDLER_T * state_handlers;
119 
120    /**
121     * This field contains references to all of the devices contained in
122     * this domain.
123     */
124    SCI_ABSTRACT_LIST_T  remote_device_list;
125 
126    /**
127     * This field contains the list of all outstanding request (IO or
128     * management) in this domain.
129     */
130    SCI_FAST_LIST_T  request_list;
131 
132    /**
133     * This field indicates whether the core port object is in a ready state
134     * or not.
135     */
136    BOOL  is_port_ready;
137 
138    /**
139     * This field indicates the number of remote devices that have been
140     * started in this domain.
141     */
142    U32  device_start_count;
143 
144    /**
145     * This field indicates the number of remote devices that are currently
146     * in the process of becoming ready.  This field is utilized to gate
147     * the transition back to the READY state for the domain.
148     */
149    U32  device_start_in_progress_count;
150 
151    /**
152     * This field records how many broadcast change primitve are
153     * received and not processed yet.
154     */
155    U32  broadcast_change_count;
156 
157    /**
158     * This fields indicates whether the expanders in this domain need to
159     * have there config route table configured by our driver. For expample,
160     * if we found the top level expander is a self-configuring expander and
161     * it is able to config others, all the expanders in this domain don't
162     * need to configure route table.
163     */
164    BOOL is_config_route_table_needed;
165 
166    struct
167    {
168       /**
169        * This field provides the domain object a scratch area to indicate
170        * status of an ongoing operation.
171        */
172       SCI_STATUS  status;
173 
174       /**
175        * This is the timer handle that is utilized to time the discovery
176        * or domain reset operations.
177        */
178       void * timer;
179 
180       /**
181        * This field specifies the timeout value, in milliseconds, for the
182        * entire operation (discovery or reset).
183        */
184       U32 timeout;
185 
186       /**
187        * This field specifies the timeout value, in milliseconds, for a
188        * single device.
189        */
190       U32 device_timeout;
191 
192    } operation;
193 
194 } SCIF_SAS_DOMAIN_T;
195 
196 void scif_sas_domain_construct(
197    SCIF_SAS_DOMAIN_T          * fw_domain,
198    U8                           domain_id,
199    struct SCIF_SAS_CONTROLLER * fw_controller
200 );
201 
202 void scif_sas_domain_terminate_requests(
203    SCIF_SAS_DOMAIN_T        * fw_domain,
204    SCIF_SAS_REMOTE_DEVICE_T * fw_device,
205    SCIF_SAS_REQUEST_T       * fw_request,
206    SCIF_SAS_TASK_REQUEST_T  * fw_requestor
207 );
208 
209 SCIF_SAS_REQUEST_T * scif_sas_domain_get_request_by_io_tag(
210    SCIF_SAS_DOMAIN_T * fw_domain,
211    U16                 io_tag
212 );
213 
214 void scif_sas_domain_transition_to_stopped_state(
215    SCIF_SAS_DOMAIN_T * fw_domain
216 );
217 
218 void scif_sas_domain_initialize(
219    SCIF_SAS_DOMAIN_T * fw_domain
220 );
221 
222 void scif_sas_domain_remote_device_start_complete(
223    SCIF_SAS_DOMAIN_T        * fw_domain,
224    SCIF_SAS_REMOTE_DEVICE_T * fw_device
225 );
226 
227 BOOL scif_sas_domain_is_in_smp_activity(
228    SCIF_SAS_DOMAIN_T        * fw_domain
229 );
230 
231 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_get_device_by_containing_device(
232    SCIF_SAS_DOMAIN_T        * fw_domain,
233    SCIF_SAS_REMOTE_DEVICE_T * containing_device,
234    U8                         expander_phy_id
235 );
236 
237 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_device_in_spinup_hold(
238    SCIF_SAS_DOMAIN_T        * fw_domain
239 );
240 
241 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_device_has_scheduled_activity(
242    SCIF_SAS_DOMAIN_T        * fw_domain,
243    U8                         smp_activity
244 );
245 
246 void scif_sas_domain_start_smp_activity(
247   SCIF_SAS_DOMAIN_T        * fw_domain
248 );
249 
250 void scif_sas_domain_remove_expander_device(
251    SCIF_SAS_DOMAIN_T        * fw_domain,
252    SCIF_SAS_REMOTE_DEVICE_T * fw_device
253 );
254 
255 void scif_sas_domain_start_smp_discover(
256    SCIF_SAS_DOMAIN_T        * fw_domain,
257    SCIF_SAS_REMOTE_DEVICE_T * top_expander
258 );
259 
260 void scif_sas_domain_continue_discover(
261    SCIF_SAS_DOMAIN_T * fw_domain
262 );
263 
264 void scif_sas_domain_finish_discover(
265    SCIF_SAS_DOMAIN_T * fw_domain
266 );
267 
268 void scif_sas_domain_transition_to_discovering_state(
269    SCIF_SAS_DOMAIN_T * fw_domain
270 );
271 
272 void scif_sas_domain_cancel_smp_activities(
273    SCIF_SAS_DOMAIN_T * fw_domain
274 );
275 
276 U8 scif_sas_domain_get_smp_request_count(
277    SCIF_SAS_DOMAIN_T * fw_domain
278 );
279 
280 void scif_sas_domain_schedule_clear_affiliation(
281    SCIF_SAS_DOMAIN_T * fw_domain
282 );
283 
284 void scif_sas_domain_start_clear_affiliation(
285    SCIF_SAS_DOMAIN_T * fw_domain
286 );
287 
288 void scif_sas_domain_continue_clear_affiliation(
289    SCIF_SAS_DOMAIN_T * fw_domain
290 );
291 
292 void scif_sas_domain_release_resource(
293    struct SCIF_SAS_CONTROLLER * fw_controller,
294    SCIF_SAS_DOMAIN_T     * fw_domain
295 );
296 
297 SCIF_SAS_REMOTE_DEVICE_T * scif_sas_domain_find_next_ea_target_reset(
298    SCIF_SAS_DOMAIN_T * fw_domain
299 );
300 
301 #if !defined(DISABLE_WIDE_PORTED_TARGETS)
302 void scif_sas_domain_update_device_port_width(
303    SCIF_SAS_DOMAIN_T     * fw_domain,
304    SCI_PORT_HANDLE_T      port
305 );
306 #else  //!defined(DISABLE_WIDE_PORTED_TARGETS)
307 #define scif_sas_domain_update_device_port_width(domain, port)
308 #endif //!defined(DISABLE_WIDE_PORTED_TARGETS)
309 
310 #ifdef SCI_LOGGING
311 void scif_sas_domain_initialize_state_logging(
312    SCIF_SAS_DOMAIN_T *fw_domain
313 );
314 
315 void scif_sas_domain_deinitialize_state_logging(
316    SCIF_SAS_DOMAIN_T *fw_domain
317 );
318 #else // SCI_LOGGING
319 #define scif_sas_domain_initialize_state_logging(x)
320 #define scif_sas_domain_deinitialize_state_logging(x)
321 #endif // SCI_LOGGING
322 
323 #ifdef __cplusplus
324 }
325 #endif // __cplusplus
326 
327 #endif // _SCIF_SAS_DOMAIN_H_
328 
329