xref: /freebsd/sys/dev/isci/scil/sci_overview.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1f11c7f63SJim Harris /*-
2718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3718cf2ccSPedro F. Giffuni  *
4f11c7f63SJim Harris  * This file is provided under a dual BSD/GPLv2 license.  When using or
5f11c7f63SJim Harris  * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris  *
7f11c7f63SJim Harris  * GPL LICENSE SUMMARY
8f11c7f63SJim Harris  *
9f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris  *
11f11c7f63SJim Harris  * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris  * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris  * published by the Free Software Foundation.
14f11c7f63SJim Harris  *
15f11c7f63SJim Harris  * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris  * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18f11c7f63SJim Harris  * General Public License for more details.
19f11c7f63SJim Harris  *
20f11c7f63SJim Harris  * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris  * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris  * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris  * in the file called LICENSE.GPL.
25f11c7f63SJim Harris  *
26f11c7f63SJim Harris  * BSD LICENSE
27f11c7f63SJim Harris  *
28f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris  * All rights reserved.
30f11c7f63SJim Harris  *
31f11c7f63SJim Harris  * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris  * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris  * are met:
34f11c7f63SJim Harris  *
35f11c7f63SJim Harris  *   * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris  *   * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris  *     the documentation and/or other materials provided with the
40f11c7f63SJim Harris  *     distribution.
41f11c7f63SJim Harris  *
42f11c7f63SJim Harris  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris  */
54f11c7f63SJim Harris #ifndef _SCI_OVERVIEW_H_
55f11c7f63SJim Harris #define _SCI_OVERVIEW_H_
56f11c7f63SJim Harris 
57f11c7f63SJim Harris /**
58f11c7f63SJim Harris @mainpage The Intel Storage Controller Interface (SCI)
59f11c7f63SJim Harris 
60f11c7f63SJim Harris SCI provides a common interface across intel storage controller hardware.
61f11c7f63SJim Harris This includes abstracting differences between Physical PCI functions and
62f11c7f63SJim Harris Virtual PCI functions.  The SCI is comprised of four primary components:
63f11c7f63SJim Harris -# SCI Base classes
64f11c7f63SJim Harris -# SCI Core
65f11c7f63SJim Harris -# SCI Framework
66f11c7f63SJim Harris 
67f11c7f63SJim Harris It is important to recognize that no component, object, or functionality in
68f11c7f63SJim Harris SCI directly allocates memory from the operating system.  It is expected that
69f11c7f63SJim Harris the SCI User (OS specific driver code) allocates and frees all memory from
70f11c7f63SJim Harris and to the operating system itself.
71f11c7f63SJim Harris 
72f11c7f63SJim Harris The C language is utilized to implement SCI.  Although C is not an object
73f11c7f63SJim Harris oriented language the SCI driver components, methods, and structures are
74f11c7f63SJim Harris modeled and organized following object oriented principles.
75f11c7f63SJim Harris 
76f11c7f63SJim Harris The Unified Modeling Language is utilized to present graphical depictions
77f11c7f63SJim Harris of the SCI classes and their relationships.
78f11c7f63SJim Harris 
79f11c7f63SJim Harris The following figure denotes the meanings of the colors utilized in UML
80f11c7f63SJim Harris diagrams throughout this document.
81f11c7f63SJim Harris @image latex object_color_key.eps "Object Color Legend" width=8cm
82f11c7f63SJim Harris 
83f11c7f63SJim Harris The following figure denotes the meanings for input and output arrows that
84f11c7f63SJim Harris are utilized to define parameters for methods defined in this specification.
85f11c7f63SJim Harris @image latex arrow_image.eps "Method Parameter Symbol Definition"
86f11c7f63SJim Harris 
87f11c7f63SJim Harris @page abbreviations_section Abbreviations
88f11c7f63SJim Harris 
89f11c7f63SJim Harris - ATA: Advanced Technology Attachment
90f11c7f63SJim Harris - IAF: Identify Address Frame
91f11c7f63SJim Harris - SAS: Serial Attached SCSI
92f11c7f63SJim Harris - SAT: SCSI to ATA Translation
93f11c7f63SJim Harris - SATA: Serial ATA
94f11c7f63SJim Harris - SCI: Storage Controller Interface
95f11c7f63SJim Harris - SCIC: SCI Core
96f11c7f63SJim Harris - SCIF: SCI Framework
97f11c7f63SJim Harris - SCU: Storage Controller Unit
98f11c7f63SJim Harris - SDS: SCU Driver Standard (i.e. non-virtualization)
99f11c7f63SJim Harris - SDV: SCU Driver Virtualized
100f11c7f63SJim Harris - SDVP: SDV Physical (PCI function)
101f11c7f63SJim Harris - SDVV: SDV Virtual (PCI function)
102f11c7f63SJim Harris - SGE: Scatter-Gather Element
103f11c7f63SJim Harris - SGL: Scatter-Gather List
104f11c7f63SJim Harris - SGPIO: Serial General Purpose Input/Output
105f11c7f63SJim Harris - SSC: Spread Spectrum Clocking
106f11c7f63SJim Harris 
107f11c7f63SJim Harris @page definitions_section Definitions
108f11c7f63SJim Harris 
109f11c7f63SJim Harris - <b>construct</b> - The term "construct" is utilized throughout the
110f11c7f63SJim Harris   interface to indicate when an object is being created.  Typically construct
111f11c7f63SJim Harris   methods perform pure memory initialization.  No "construct" method ever
112f11c7f63SJim Harris   performs memory allocation.  It is incumbent upon the SCI user to provide
113f11c7f63SJim Harris   the necessary memory.
114f11c7f63SJim Harris - <b>initialize</b> - The term "initialize" is utilized throughout the
115f11c7f63SJim Harris   interface to indicate when an object is performing actions on other objects
116f11c7f63SJim Harris   or on physical resources in an attempt to allow these resources to become
117f11c7f63SJim Harris   operational.
118f11c7f63SJim Harris - <b>protected</b> - The term "protected" is utilized to denote a method
119f11c7f63SJim Harris   defined in this standard that MUST NOT be invoked directly by operating
120f11c7f63SJim Harris   system specific driver code.
121f11c7f63SJim Harris - <b>SCI Component</b> - An SCI component is one of: SCI base classes, Core,
122f11c7f63SJim Harris   or Framework.
123f11c7f63SJim Harris - <b>SCI User</b> - The user callbacks for each SCI Component represent the
124f11c7f63SJim Harris   dependencies that the SCI component implementation has upon the operating
125f11c7f63SJim Harris   system/environment specific portion of the driver.  It is essentially a
126f11c7f63SJim Harris   set of functions or macro definitions that are specific to a particular
127f11c7f63SJim Harris   operating system.
128f11c7f63SJim Harris - <b>THIN</b> - A term utilized to describe an SCI Component implementation
129f11c7f63SJim Harris   that is built to conserve memory.
130f11c7f63SJim Harris 
131f11c7f63SJim Harris @page inheritance SCI Inheritance Hierarchy
132f11c7f63SJim Harris 
133f11c7f63SJim Harris This section describes the inheritance (i.e. "is-a") relationships between
134f11c7f63SJim Harris the various objects in SCI.  Due to various operating environment requirements
135f11c7f63SJim Harris the programming language employed for the SCI driver is C.  As a result, one
136f11c7f63SJim Harris might be curious how inheritance shall be applied in such an environment.
137f11c7f63SJim Harris The SCI driver source shall maintain generalization relationships by ensuring
138f11c7f63SJim Harris that child object structures shall contain an instance of their parent's
139f11c7f63SJim Harris structure as the very first member of their structure.  As a result, parent
140f11c7f63SJim Harris object methods can be invoked with a child structure parameter.  This works
141f11c7f63SJim Harris since casting of the child structure to the parent structure inside the parent
142f11c7f63SJim Harris method will yield correct access to the parent structure fields.
143f11c7f63SJim Harris 
144f11c7f63SJim Harris Consider the following example:
145f11c7f63SJim Harris <pre>
146f11c7f63SJim Harris typedef struct SCI_OBJECT
147f11c7f63SJim Harris {
148f11c7f63SJim Harris    U32 object_type;
149f11c7f63SJim Harris };
150f11c7f63SJim Harris 
151f11c7f63SJim Harris typedef struct SCI_CONTROLLER
152f11c7f63SJim Harris {
153f11c7f63SJim Harris    U32 state;
154f11c7f63SJim Harris 
155f11c7f63SJim Harris } SCI_CONTROLLER_T;
156f11c7f63SJim Harris 
157f11c7f63SJim Harris typedef struct SCIC_CONTROLLER
158f11c7f63SJim Harris {
159f11c7f63SJim Harris    SCI_CONTROLLER_T parent;
160f11c7f63SJim Harris    U32 type;
161f11c7f63SJim Harris 
162f11c7f63SJim Harris } SCIC_CONTROLLER_T;
163f11c7f63SJim Harris </pre>
164f11c7f63SJim Harris 
165f11c7f63SJim Harris With the above structure orientation, a user would be allowed to perform
166f11c7f63SJim Harris method invocations in a manner similar to the following:
167f11c7f63SJim Harris <pre>
168f11c7f63SJim Harris SCIC_CONTROLLER_T scic_controller;
169f11c7f63SJim Harris scic_controller_initialize((SCIC_CONTROLLER_T*) &scic_controller);
170f11c7f63SJim Harris 
171f11c7f63SJim Harris // OR
172f11c7f63SJim Harris 
173f11c7f63SJim Harris sci_object_get_association(&scic_controller);
174f11c7f63SJim Harris </pre>
175f11c7f63SJim Harris @note The actual interface will not require type casting.
176f11c7f63SJim Harris 
177f11c7f63SJim Harris The following diagram graphically depicts the inheritance relationships
178f11c7f63SJim Harris between the various objects defined in the Storage Controller Interface.
179f11c7f63SJim Harris @image latex inheritance.eps "SCI Inheritance Hierarchy" width=16cm
180f11c7f63SJim Harris 
181f11c7f63SJim Harris @page sci_classes SCI Classes
182f11c7f63SJim Harris 
183f11c7f63SJim Harris This section depicts the common classes and utility functions across the
184f11c7f63SJim Harris entire set of SCI Components.  Descriptions about each of the specific
185f11c7f63SJim Harris objects will be found in the header file definition in the File Documentation
186f11c7f63SJim Harris section.
187f11c7f63SJim Harris 
188f11c7f63SJim Harris The following is a list of features that can be found in the SCI base classes:
189f11c7f63SJim Harris -# Logging utility methods, constants, and type definitions
190f11c7f63SJim Harris -# Memory Descriptor object methods common to the core and framework.
191f11c7f63SJim Harris -# Controller object methods common to SCI derived controller objects.
192f11c7f63SJim Harris -# Library object methods common to SCI derived library objects.
193f11c7f63SJim Harris -# Storage standard (e.g. SAS, SATA) defined constants, structures, etc.
194f11c7f63SJim Harris -# Standard types utilized by SCI sub-components.
195f11c7f63SJim Harris -# The ability to associate/link SCI objects together or to user objects.
196f11c7f63SJim Harris 
197f11c7f63SJim Harris SCI class methods can be overridden by sub-classes in the SCI Core,
198f11c7f63SJim Harris SCI Framework, etc.  SCI class methods that MUST NOT be invoked directly
199f11c7f63SJim Harris by operating system specific driver code shall be adorned with a
200f11c7f63SJim Harris <code>[protected]</code> keyword.  These <code>[protected]</code> API are still
201f11c7f63SJim Harris defined as part of the specification in order to demonstrate commonality across
202f11c7f63SJim Harris components as well as provide a common description of related methods.  If
203f11c7f63SJim Harris these methods are invoked directly by operating system specific code, the
204f11c7f63SJim Harris operation of the driver as a whole is not specified or supported.
205f11c7f63SJim Harris 
206f11c7f63SJim Harris The following UML diagram graphically depicts the SCI base classes and their
207f11c7f63SJim Harris relationships to one another.
208f11c7f63SJim Harris @image latex sci_base_classes.eps "SCI Classes" width=4cm
209f11c7f63SJim Harris 
210f11c7f63SJim Harris @page associations_section Associations
211f11c7f63SJim Harris The sci_object class provides functionality common to all SCI objects.
212f11c7f63SJim Harris An important feature provided by this base class is the means by which to
213f11c7f63SJim Harris associate one object to another.  An SCI object can be made to have an
214f11c7f63SJim Harris association to another SCI object.  Additionally, an SCI object can be
215f11c7f63SJim Harris made to have an association to a non-SCI based object.  For example, an SCI
216f11c7f63SJim Harris Framework library can have it's association set to an operating system
217*17db4b52SGordon Bergling specific adapter/device driver structure.
218f11c7f63SJim Harris 
219f11c7f63SJim Harris Simply put, the association that an object has is a handle (i.e. a void pointer)
220f11c7f63SJim Harris to a user structure.  This enables the user of the SCI object to
221f11c7f63SJim Harris easily determine it's own associated structure. This association is useful
222f11c7f63SJim Harris because the user is now enabled to easily determine their pertinent information
223f11c7f63SJim Harris inside of their SCI user callback methods.
224f11c7f63SJim Harris 
225f11c7f63SJim Harris Setting an association within an SCI object is generally optional.  The
226f11c7f63SJim Harris primary case in which an association is not optional is in the case of IO
227f11c7f63SJim Harris request objects.  These associations are necessary in order  to fill
228f11c7f63SJim Harris to fill in appropriate information for an IO request (i.e. CDB address, size,
229f11c7f63SJim Harris SGL information, etc.) in an efficient manner.
230f11c7f63SJim Harris 
231f11c7f63SJim Harris In the case of other objects, the user is free to not create associations.
232f11c7f63SJim Harris When the user chooses not to create an association, the user is responsible for
233f11c7f63SJim Harris being able to determine their data structures based on the SCI object handles.
234f11c7f63SJim Harris Additionally, the user may be forced to invoke additional functionality in
235f11c7f63SJim Harris situations where the SCI Framework is employed.  If the user does not
236f11c7f63SJim Harris establish proper associations between objects (i.e. SCIC Library to SCIF Library), then the framework is unable to automate interactions.  Users should
237f11c7f63SJim Harris strongly consider establishing associations between SCI Framework objects and
238f11c7f63SJim Harris OS Driver related structures.
239f11c7f63SJim Harris 
240f11c7f63SJim Harris Example Associations:
241f11c7f63SJim Harris - The user might set the scif_controller association to their adapter or
242f11c7f63SJim Harris controller object.
243f11c7f63SJim Harris - The user might set the scif_domain association to their SCSI bus object.
244f11c7f63SJim Harris 
245f11c7f63SJim Harris If SCIF is being utilized, then the framework will set the associations
246f11c7f63SJim Harris in the core.  In this situation, the user should only set the associations
247f11c7f63SJim Harris in the framework objects, unless otherwise directed.
248f11c7f63SJim Harris */
249f11c7f63SJim Harris 
250f11c7f63SJim Harris #endif // _SCI_OVERVIEW_H_
251f11c7f63SJim Harris 
252