aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/isci/scil/scif_sas_design.h
blob: 1f2e8a851287c4d040e1a0791c8a4010602020d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*-
 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
 *
 * This file is provided under a dual BSD/GPLv2 license.  When using or
 * redistributing this file, you may do so under either license.
 *
 * GPL LICENSE SUMMARY
 *
 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 * The full GNU General Public License is included in this distribution
 * in the file called LICENSE.GPL.
 *
 * BSD LICENSE
 *
 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 */
#ifndef _SCIF_SAS_DESIGN_H_
#define _SCIF_SAS_DESIGN_H_

/**
@page scif_sas_design_page SCIF SAS High Level Design

<b>Authors:</b>
- Nathan Marushak

<b>Key Contributors:</b>
- Richard Boyd

@section scif_sas_scope_and_audience Scope and Audience

This document provides design information relating to the SAS specific
implementation of the SCI Framework.  Driver developers are the primary
audience for this document.  The reader is expected to have an understanding
of the SCU Software Architecture Specification, the Storage Controller
Interface Specification, and the SCI Base Design.

@section scif_sas_overview Overview

To begin, it's important to discuss the utilization of state machines in
the design.  State machines are pervasive in this design, because of the
abilities they provide.  A properly implemented state machine allows the
developer to code for a specific task.  The developer is not encumbered
with needed to handle other situations all in a single function.  For
example, if a specific event can only occur when the object is in a specific
state, then the event handler is added to handle such an event.  Thus, a
single function is not spliced to handle multiple events under various
potentially disparate conditions.

Additionally, the SCI Base Design document specifies a number of state
machines, objects, and methods that are heavily utilized by this design.
Please refer to Base Design specification for further information.

Many of the framework objects have state machines associated with them.
As a result, there are a number of state entrance and exit methods as well
as event handlers for each individual state.  This design places all of
the state entrance and exit methods for a given state machine into a single
file (e.g. scif_sas_controller_states.c).  Furthermore, all of the state
event handler methods are also placed into a single file (e.g.
scif_sas_controller_state_handlers.c).  This format is reused for each
object that contains state machine(s).

Some of the SAS framework objects contain sub-state machines.  These
sub-state machines are started upon entrance to the super-state and stopped
upon exit of the super-state.

All other method, data, constant description information will be found in
the remaining source file (e.g. scif_sas_controller.c).  As a result, please
be sure to follow the link to that specific object/file definition for
further information.

@note Currently a large number of function pointers are utilized during the
course of a normal IO request.  Once stability of the driver is achieved,
performance improvements will be made as needed.  This likely will include
removal of the function pointers from the IO path.

@section scif_sas_use_cases Use Cases

The following use case diagram depicts the high-level user interactions with
the SAS framework.  This diagram does not encompass all use cases implemented
in the system.  The low-level design section will contain detailed use cases
for each significant object and their associated detailed sequences and/or
activities.  For the purposes of readability, the use cases are not directly
connected to the associated actor utilizing the use case.  Instead naming
is utilized to different which actor is involved with the use case.

Actors:
- The Framework user also called the OS Specific Driver initiates activities in
the Framework.
- The SCI Core calls back into the Framework as a result of an operation either
started by the OS Specific Driver or by the Framework itself.

@image latex Use_Case_Diagram__SCIF_SAS__Use_Cases.eps "SCIF SAS OS Use Cases" width=11cm
@image html Use_Case_Diagram__SCIF_SAS__Use_Cases.jpg "SCIF SAS OS Use Cases"

@section scif_sas_class_hierarchy Class Hierarchy

This section delineates the high-level class organization for the SCIF_SAS
component.  Details concerning each class will be found in the corresponding
low-level design sections.  Furthermore, additional classes not germane to
the overall architecture of the component will also be defined in these
low-level design sections.

@image latex Class_Diagram__scif_sas__Class_Diagram.eps "SCIF SAS Class Diagram" width=16cm
@image html Class_Diagram__scif_sas__Class_Diagram.jpg "SCIF SAS Class Diagram"

For more information on each object appearing in the diagram, please
reference the subsequent sections.

@section scif_sas_library SCIF SAS Library

First, the SCIF_SAS_LIBRARY object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the library object.

The SCIF_SAS_LIBRARY object is broken down into 2 individual source files
and one direct header file.  These files delineate the methods, members, etc.
associated with this object.  Please reference these files directly for
further design information:
- scif_sas_library.h
- scif_sas_library.c

@section scif_sas_controller SCIF SAS Controller

First, the SCIF_SAS_CONTROLLER object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the controller object.

The SCIF_SAS_CONTROLLER object is broken down into 3 individual source files
and one direct header file.  These files delineate the methods, members, etc.
associated with this object.  Please reference these files directly for
further design information:
- scif_sas_controller.h
- scif_sas_controller.c
- scif_sas_controller_state_handlers.c
- scif_sas_controller_states.c

@section scif_sas_domain SCIF SAS Domain

First, the SCIF_SAS_DOMAIN object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the SCIF_SAS_DOMAIN object.

The SCIF_SAS_DOMAIN object is broken down into 3 individual
source files and one direct header file.  These files delineate the
methods, members, etc. associated with this object.  Please reference
these files directly for
further design information:
- scif_sas_domain.h
- scif_sas_domain.c
- scif_sas_domain_state_handlers.c
- scif_sas_domain_states.c

@section scif_sas_remote_device SCIF SAS Remote Device

First, the SCIF_SAS_REMOTE_DEVICE object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the SCIF_SAS_REMOTE_DEVICE object.

The SCIF_SAS_REMOTE_DEVICE object is broken down into 7 individual source files
and one direct header file.  These files delineate the methods, members, etc.
associated with this object.  Methods, data, and functionality specific to a
particular protocol type (e.g. SMP, STP, etc.) are broken out into their own
object/file.  SSP specific remote device functionality is covered by the base
classes (common files).  Please reference these files directly for further
design information:
- scif_sas_remote_device.h
- scif_sas_smp_remote_device.h
- scif_sas_stp_remote_device.h
- scif_sas_remote_device.c
- scif_sas_remote_device_state_handlers.c
- scif_sas_remote_device_states.c
- scif_sas_remote_device_starting_substate_handlers.c
- scif_sas_remote_device_starting_substates.c
- scif_sas_remote_device_ready_substate_handlers.c
- scif_sas_remote_device_ready_substates.c
- scif_sas_smp_remote_device.c
- scif_sas_stp_remote_device.c

The SCIF_SAS_REMOTE_DEVICE object has sub-state machines defined for
the READY and STARTING super-states.  For more information on the
super-state machine please refer to SCI_BASE_REMOTE_DEVICE_STATES
in the SCI Base design document.

In the SCIF_SAS_REMOTE_DEVICE_STARTING_SUBSTATES sub-state machine,
the remote device currently has to wait for the core to
return an indication that the remote device has successfully started
and become ready.  If all goes well, then the remote device will
transition into the READY state.

For more information on the starting sub-state machine states please refer
to the scif_sas_remote_device.h::_SCIF_SAS_REMOTE_DEVICE_STARTING_SUBSTATES
enumeration.

@image latex State_Machine_Diagram__STARTING_SUB-STATE__STARTING_SUB-STATE.eps "SCIF SAS Remote Device Starting Sub-state Machine Diagram" width=16cm
@image html State_Machine_Diagram__STARTING_SUB-STATE__STARTING_SUB-STATE.jpg "SCIF SAS Remote Device Starting Sub-state Machine Diagram"

In the SCIF_SAS_REMOTE_DEVICE_READY_SUBSTATES sub-state machine,
the remote device currently only allows new host IO requests during the
OPERATIONAL state.  In the TASK MANAGEMENT state only new task management
requests are allowed.

For more information on the ready sub-state machine states please refer
to the scif_sas_remote_device.h::_SCIF_SAS_REMOTE_DEVICE_READY_SUBSTATES
enumeration.

@image latex State_Machine_Diagram__READY_SUB-STATE__READY_SUB-STATE.eps "SCIF SAS Remote Device Ready Sub-state Machine Diagram" width=16cm
@image html State_Machine_Diagram__READY_SUB-STATE__READY_SUB-STATE.jpg "SCIF SAS Remote Device Ready Sub-state Machine Diagram"

@section scif_sas_request SCIF SAS Request

The SCIF_SAS_REQUEST object provide common functionality for the
SCIF_SAS_IO_REQUEST and the SCIF_SAS_TASK_REQUEST objects.  This object
does not directly map to an SCI defined object, but its children do.  For
additional information, you may reference the SCIF_SAS_IO_REQUEST or
SCIF_SAS_TASK_REQUEST objects.

The SCIF_SAS_REQUEST object is broken down into 1 individual source file
and one direct header file.  These files delineate the methods, members, etc.
associated with this object.  Please reference these files directly for
further design information:
- scif_sas_request.h
- scif_sas_request.c

@section scif_sas_io_request SCIF SAS IO Request

First, the SCIF_SAS_IO_REQUEST object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the SCIF_SAS_IO_REQUEST object.

The SCIF_SAS_IO_REQUEST object is broken down into 3 individual
source files and one direct header file.  These files delineate the
methods, members, etc. associated with this object.  Please reference
these files directly for further design information:
- scif_sas_io_request.h
- scif_sas_smp_io_request.h
- scif_sas_stp_io_request.h
- scif_sas_sati_binding.h
- scif_sas_io_request.c
- scif_sas_io_request_state_handlers.c
- scif_sas_io_request_states.c
- scif_sas_smp_io_request.c
- scif_sas_stp_io_request.c

@section scif_sas_task_request SCIF SAS Task Request

First, the SCIF_SAS_TASK_REQUEST object provides an implementation
for the roles and responsibilities defined in the Storage Controller
Interface (SCI) specification.  It is suggested that the user read the
storage controller interface specification for background information on
the SCIF_SAS_TASK_REQUEST object.

The SCIF_SAS_TASK_REQUEST object is broken down into 3 individual
source files and one direct header file.  These files delineate the
methods, members, etc. associated with this object.  Please reference
these files directly for further design information:
- scif_sas_task_request.h
- scif_sas_stp_task_request.h
- scif_sas_task_request.c
- scif_sas_task_request_state_handlers.c
- scif_sas_task_request_states.c
- scif_sas_stp_task_request.c

@section scif_sas_internal_io_request SCIF SAS INTERNAL IO Request

The SCIF_SAS_INTERNAL_IO_REQUEST object fulfills the SCI's need to create
and send out the internal io request. These internal io requests could be
smp request for expander device discover process, or stp request for NCQ
error handling. Internal IOs consume the reserved internal io space in
scif_sas_controller. When an internal IO is constructed, it is put into an
internal high priority queue. A defferred task (start_internal_io_task) will be
scheduled at the end of every completion process. The task looks up the high
priority queue and starts each internal io in the queue. There is one exception
that start_internal_io_task is scheduled immediately when the first internal io
is constructed. A retry mechanism is also provided for internal io. When an
internal io response is decoded, if the decoding indicates a retry is needed,
the internal io will be retried.

Please refer to these files directly for further design information:
- scif_sas_internal_io_request.h
- scif_sas_internal_io_request.c
- scif_sas_controller.h

@section scif_sas_smp_remote_device SCIF SAS SMP REMOTE DEVICE

The SCIF SAS SMP REMOTE DEVICE object represents the expander device and fulfills
its SMP discover activities. The discover procedure includes a initial discover
phase and a following SATA spinup_hold release phase, if there are expander attached
SATA device is discovered and in spinup_hold conditon. The SCIF SAS SMP REMOTE DEVICE
object also fulfills expander attached device Target Reset (Phy Control) activity.

@image latex Discover Process.eps "SMP Discover Activity Diagram" width=10cm
@image html Discover Process.jpg "SMP Discover Activity Diagram"

Please refer to these files directly for further design information:
- scif_sas_smp_remote_device.h
- scif_sas_smp_remote_device.c
- scif_sas_smp_request.h
- scif_sas_smp_request.c
*/

#endif // _SCIF_SAS_DESIGN_H_