xref: /freebsd/sys/dev/isci/scil/sci_overview.h (revision 718cf2ccb9956613756ab15d7a0e28f2c8e91cab)
1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro 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  * $FreeBSD$
55f11c7f63SJim Harris  */
56f11c7f63SJim Harris #ifndef _SCI_OVERVIEW_H_
57f11c7f63SJim Harris #define _SCI_OVERVIEW_H_
58f11c7f63SJim Harris 
59f11c7f63SJim Harris /**
60f11c7f63SJim Harris @mainpage The Intel Storage Controller Interface (SCI)
61f11c7f63SJim Harris 
62f11c7f63SJim Harris SCI provides a common interface across intel storage controller hardware.
63f11c7f63SJim Harris This includes abstracting differences between Physical PCI functions and
64f11c7f63SJim Harris Virtual PCI functions.  The SCI is comprised of four primary components:
65f11c7f63SJim Harris -# SCI Base classes
66f11c7f63SJim Harris -# SCI Core
67f11c7f63SJim Harris -# SCI Framework
68f11c7f63SJim Harris 
69f11c7f63SJim Harris It is important to recognize that no component, object, or functionality in
70f11c7f63SJim Harris SCI directly allocates memory from the operating system.  It is expected that
71f11c7f63SJim Harris the SCI User (OS specific driver code) allocates and frees all memory from
72f11c7f63SJim Harris and to the operating system itself.
73f11c7f63SJim Harris 
74f11c7f63SJim Harris The C language is utilized to implement SCI.  Although C is not an object
75f11c7f63SJim Harris oriented language the SCI driver components, methods, and structures are
76f11c7f63SJim Harris modeled and organized following object oriented principles.
77f11c7f63SJim Harris 
78f11c7f63SJim Harris The Unified Modeling Language is utilized to present graphical depictions
79f11c7f63SJim Harris of the SCI classes and their relationships.
80f11c7f63SJim Harris 
81f11c7f63SJim Harris The following figure denotes the meanings of the colors utilized in UML
82f11c7f63SJim Harris diagrams throughout this document.
83f11c7f63SJim Harris @image latex object_color_key.eps "Object Color Legend" width=8cm
84f11c7f63SJim Harris 
85f11c7f63SJim Harris The following figure denotes the meanings for input and output arrows that
86f11c7f63SJim Harris are utilized to define parameters for methods defined in this specification.
87f11c7f63SJim Harris @image latex arrow_image.eps "Method Parameter Symbol Definition"
88f11c7f63SJim Harris 
89f11c7f63SJim Harris @page abbreviations_section Abbreviations
90f11c7f63SJim Harris 
91f11c7f63SJim Harris - ATA: Advanced Technology Attachment
92f11c7f63SJim Harris - IAF: Identify Address Frame
93f11c7f63SJim Harris - SAS: Serial Attached SCSI
94f11c7f63SJim Harris - SAT: SCSI to ATA Translation
95f11c7f63SJim Harris - SATA: Serial ATA
96f11c7f63SJim Harris - SCI: Storage Controller Interface
97f11c7f63SJim Harris - SCIC: SCI Core
98f11c7f63SJim Harris - SCIF: SCI Framework
99f11c7f63SJim Harris - SCU: Storage Controller Unit
100f11c7f63SJim Harris - SDS: SCU Driver Standard (i.e. non-virtualization)
101f11c7f63SJim Harris - SDV: SCU Driver Virtualized
102f11c7f63SJim Harris - SDVP: SDV Physical (PCI function)
103f11c7f63SJim Harris - SDVV: SDV Virtual (PCI function)
104f11c7f63SJim Harris - SGE: Scatter-Gather Element
105f11c7f63SJim Harris - SGL: Scatter-Gather List
106f11c7f63SJim Harris - SGPIO: Serial General Purpose Input/Output
107f11c7f63SJim Harris - SSC: Spread Spectrum Clocking
108f11c7f63SJim Harris 
109f11c7f63SJim Harris @page definitions_section Definitions
110f11c7f63SJim Harris 
111f11c7f63SJim Harris - <b>construct</b> - The term "construct" is utilized throughout the
112f11c7f63SJim Harris   interface to indicate when an object is being created.  Typically construct
113f11c7f63SJim Harris   methods perform pure memory initialization.  No "construct" method ever
114f11c7f63SJim Harris   performs memory allocation.  It is incumbent upon the SCI user to provide
115f11c7f63SJim Harris   the necessary memory.
116f11c7f63SJim Harris - <b>initialize</b> - The term "initialize" is utilized throughout the
117f11c7f63SJim Harris   interface to indicate when an object is performing actions on other objects
118f11c7f63SJim Harris   or on physical resources in an attempt to allow these resources to become
119f11c7f63SJim Harris   operational.
120f11c7f63SJim Harris - <b>protected</b> - The term "protected" is utilized to denote a method
121f11c7f63SJim Harris   defined in this standard that MUST NOT be invoked directly by operating
122f11c7f63SJim Harris   system specific driver code.
123f11c7f63SJim Harris - <b>SCI Component</b> - An SCI component is one of: SCI base classes, Core,
124f11c7f63SJim Harris   or Framework.
125f11c7f63SJim Harris - <b>SCI User</b> - The user callbacks for each SCI Component represent the
126f11c7f63SJim Harris   dependencies that the SCI component implementation has upon the operating
127f11c7f63SJim Harris   system/environment specific portion of the driver.  It is essentially a
128f11c7f63SJim Harris   set of functions or macro definitions that are specific to a particular
129f11c7f63SJim Harris   operating system.
130f11c7f63SJim Harris - <b>THIN</b> - A term utilized to describe an SCI Component implementation
131f11c7f63SJim Harris   that is built to conserve memory.
132f11c7f63SJim Harris 
133f11c7f63SJim Harris @page inheritance SCI Inheritance Hierarchy
134f11c7f63SJim Harris 
135f11c7f63SJim Harris This section describes the inheritance (i.e. "is-a") relationships between
136f11c7f63SJim Harris the various objects in SCI.  Due to various operating environment requirements
137f11c7f63SJim Harris the programming language employed for the SCI driver is C.  As a result, one
138f11c7f63SJim Harris might be curious how inheritance shall be applied in such an environment.
139f11c7f63SJim Harris The SCI driver source shall maintain generalization relationships by ensuring
140f11c7f63SJim Harris that child object structures shall contain an instance of their parent's
141f11c7f63SJim Harris structure as the very first member of their structure.  As a result, parent
142f11c7f63SJim Harris object methods can be invoked with a child structure parameter.  This works
143f11c7f63SJim Harris since casting of the child structure to the parent structure inside the parent
144f11c7f63SJim Harris method will yield correct access to the parent structure fields.
145f11c7f63SJim Harris 
146f11c7f63SJim Harris Consider the following example:
147f11c7f63SJim Harris <pre>
148f11c7f63SJim Harris typedef struct SCI_OBJECT
149f11c7f63SJim Harris {
150f11c7f63SJim Harris    U32 object_type;
151f11c7f63SJim Harris };
152f11c7f63SJim Harris 
153f11c7f63SJim Harris typedef struct SCI_CONTROLLER
154f11c7f63SJim Harris {
155f11c7f63SJim Harris    U32 state;
156f11c7f63SJim Harris 
157f11c7f63SJim Harris } SCI_CONTROLLER_T;
158f11c7f63SJim Harris 
159f11c7f63SJim Harris typedef struct SCIC_CONTROLLER
160f11c7f63SJim Harris {
161f11c7f63SJim Harris    SCI_CONTROLLER_T parent;
162f11c7f63SJim Harris    U32 type;
163f11c7f63SJim Harris 
164f11c7f63SJim Harris } SCIC_CONTROLLER_T;
165f11c7f63SJim Harris </pre>
166f11c7f63SJim Harris 
167f11c7f63SJim Harris With the above structure orientation, a user would be allowed to perform
168f11c7f63SJim Harris method invocations in a manner similar to the following:
169f11c7f63SJim Harris <pre>
170f11c7f63SJim Harris SCIC_CONTROLLER_T scic_controller;
171f11c7f63SJim Harris scic_controller_initialize((SCIC_CONTROLLER_T*) &scic_controller);
172f11c7f63SJim Harris 
173f11c7f63SJim Harris // OR
174f11c7f63SJim Harris 
175f11c7f63SJim Harris sci_object_get_association(&scic_controller);
176f11c7f63SJim Harris </pre>
177f11c7f63SJim Harris @note The actual interface will not require type casting.
178f11c7f63SJim Harris 
179f11c7f63SJim Harris The following diagram graphically depicts the inheritance relationships
180f11c7f63SJim Harris between the various objects defined in the Storage Controller Interface.
181f11c7f63SJim Harris @image latex inheritance.eps "SCI Inheritance Hierarchy" width=16cm
182f11c7f63SJim Harris 
183f11c7f63SJim Harris @page sci_classes SCI Classes
184f11c7f63SJim Harris 
185f11c7f63SJim Harris This section depicts the common classes and utility functions across the
186f11c7f63SJim Harris entire set of SCI Components.  Descriptions about each of the specific
187f11c7f63SJim Harris objects will be found in the header file definition in the File Documentation
188f11c7f63SJim Harris section.
189f11c7f63SJim Harris 
190f11c7f63SJim Harris The following is a list of features that can be found in the SCI base classes:
191f11c7f63SJim Harris -# Logging utility methods, constants, and type definitions
192f11c7f63SJim Harris -# Memory Descriptor object methods common to the core and framework.
193f11c7f63SJim Harris -# Controller object methods common to SCI derived controller objects.
194f11c7f63SJim Harris -# Library object methods common to SCI derived library objects.
195f11c7f63SJim Harris -# Storage standard (e.g. SAS, SATA) defined constants, structures, etc.
196f11c7f63SJim Harris -# Standard types utilized by SCI sub-components.
197f11c7f63SJim Harris -# The ability to associate/link SCI objects together or to user objects.
198f11c7f63SJim Harris 
199f11c7f63SJim Harris SCI class methods can be overridden by sub-classes in the SCI Core,
200f11c7f63SJim Harris SCI Framework, etc.  SCI class methods that MUST NOT be invoked directly
201f11c7f63SJim Harris by operating system specific driver code shall be adorned with a
202f11c7f63SJim Harris <code>[protected]</code> keyword.  These <code>[protected]</code> API are still
203f11c7f63SJim Harris defined as part of the specification in order to demonstrate commonality across
204f11c7f63SJim Harris components as well as provide a common description of related methods.  If
205f11c7f63SJim Harris these methods are invoked directly by operating system specific code, the
206f11c7f63SJim Harris operation of the driver as a whole is not specified or supported.
207f11c7f63SJim Harris 
208f11c7f63SJim Harris The following UML diagram graphically depicts the SCI base classes and their
209f11c7f63SJim Harris relationships to one another.
210f11c7f63SJim Harris @image latex sci_base_classes.eps "SCI Classes" width=4cm
211f11c7f63SJim Harris 
212f11c7f63SJim Harris @page associations_section Associations
213f11c7f63SJim Harris The sci_object class provides functionality common to all SCI objects.
214f11c7f63SJim Harris An important feature provided by this base class is the means by which to
215f11c7f63SJim Harris associate one object to another.  An SCI object can be made to have an
216f11c7f63SJim Harris association to another SCI object.  Additionally, an SCI object can be
217f11c7f63SJim Harris made to have an association to a non-SCI based object.  For example, an SCI
218f11c7f63SJim Harris Framework library can have it's association set to an operating system
219f11c7f63SJim Harris specific adapter/device driver structre.
220f11c7f63SJim Harris 
221f11c7f63SJim Harris Simply put, the association that an object has is a handle (i.e. a void pointer)
222f11c7f63SJim Harris to a user structure.  This enables the user of the SCI object to
223f11c7f63SJim Harris easily determine it's own associated structure. This association is useful
224f11c7f63SJim Harris because the user is now enabled to easily determine their pertinent information
225f11c7f63SJim Harris inside of their SCI user callback methods.
226f11c7f63SJim Harris 
227f11c7f63SJim Harris Setting an association within an SCI object is generally optional.  The
228f11c7f63SJim Harris primary case in which an association is not optional is in the case of IO
229f11c7f63SJim Harris request objects.  These associations are necessary in order  to fill
230f11c7f63SJim Harris to fill in appropriate information for an IO request (i.e. CDB address, size,
231f11c7f63SJim Harris SGL information, etc.) in an efficient manner.
232f11c7f63SJim Harris 
233f11c7f63SJim Harris In the case of other objects, the user is free to not create associations.
234f11c7f63SJim Harris When the user chooses not to create an association, the user is responsible for
235f11c7f63SJim Harris being able to determine their data structures based on the SCI object handles.
236f11c7f63SJim Harris Additionally, the user may be forced to invoke additional functionality in
237f11c7f63SJim Harris situations where the SCI Framework is employed.  If the user does not
238f11c7f63SJim Harris establish proper associations between objects (i.e. SCIC Library to SCIF Library), then the framework is unable to automate interactions.  Users should
239f11c7f63SJim Harris strongly consider establishing associations between SCI Framework objects and
240f11c7f63SJim Harris OS Driver related structures.
241f11c7f63SJim Harris 
242f11c7f63SJim Harris Example Associations:
243f11c7f63SJim Harris - The user might set the scif_controller association to their adapter or
244f11c7f63SJim Harris controller object.
245f11c7f63SJim Harris - The user might set the scif_domain association to their SCSI bus object.
246f11c7f63SJim Harris 
247f11c7f63SJim Harris If SCIF is being utilized, then the framework will set the associations
248f11c7f63SJim Harris in the core.  In this situation, the user should only set the associations
249f11c7f63SJim Harris in the framework objects, unless otherwise directed.
250f11c7f63SJim Harris */
251f11c7f63SJim Harris 
252f11c7f63SJim Harris #endif // _SCI_OVERVIEW_H_
253f11c7f63SJim Harris 
254