From sacadmin Thu Nov 10 18:51:44 2005
Received: from jurassic.eng.sun.com (jurassic.SFBay.Sun.COM [129.146.228.31])
	by sac.sfbay.sun.com (8.12.9+Sun/8.12.9) with ESMTP id jAB2piIQ000243
	for <psarc@sac.eng.sun.com>; Thu, 10 Nov 2005 18:51:44 -0800 (PST)
Received: from [129.146.228.109] (cyber.SFBay.Sun.COM [129.146.228.109])
	by jurassic.eng.sun.com (8.13.5+Sun/8.13.5) with ESMTP id jAB2phdE555880
	for <psarc@sac.eng.sun.com>; Thu, 10 Nov 2005 18:51:44 -0800 (PST)
Message-ID: <43740780.20601@Eng.Sun.COM>
Date: Thu, 10 Nov 2005 18:52:48 -0800
From: Bart Smaalders <bart.smaalders@eng.sun.com>
Organization: Sun Microsystems
User-Agent: Mail/News 1.5 (X11/20051106)
MIME-Version: 1.0
To: psarc@sac.eng.sun.com
Subject: PSARC/2005/679 SATA HBA Framework Support (Updated)
Content-Type: multipart/mixed;
 boundary="------------050609060508090104040406"
Status: RO
Content-Length: 43361

This is a multi-part message in MIME format.
--------------050609060508090104040406
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


I'm submitting this fasttrack for Pawel Wojcik as an addendum
to his team's previous fasttrack, PSARC/2004/779 SATA HBA
Framework Support.

This fasttrack expires on 11/16/2005.  As before, patch
binding is requested.

This case consists of several relatively minor modifications.
These include:

1. Added an additional SATA HBA driver for the Silicon
    Image 3142 chipset.

2. Added an explanation of the 2-phased development in
    section 3.1 along with functionality and features for
    both development phases.

3. Expanded the exported interfaces to include one more
    interface structure, scsi target number for sata devices,
    and a few sata-specific subcommands of the DEVCTL_AP_CONTROL ioctl.

4. Expanded the imported interfaces to include two functions
    of the Generic SCSI HBA interface.

5. Changed the man pages describing interface between SATA framework
    and SATA HBA drivers due to moving of the header
    file to a different directory and due to structure member name
    changes. Corrected wording as well.

6. Added two HBA-specifc driver man pages(marvell88sx and si3124).

7. Added a sata man page(Solaris SATA Architecture).

8. Added a an explanation of the diversion for SCSI-ATA-Translation
    spec draft as noted in section 5.

9. Corrected technical description, other wording change.

10. Expanded the glossary.


I have attached an updated version of the project proposal.  The
man pages have been placed in the manpages directory, along with
diffs from the previous version (if it existed).


-- 
Bart Smaalders			Solaris Kernel Performance
barts@cyber.eng.sun.com		http://blogs.sun.com/barts

--------------050609060508090104040406
Content-Type: text/plain;
 name="SHF_PSARC_changed.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="SHF_PSARC_changed.txt"

SATA HBA Framework
===================
 
v1.6 November 5, 2005


1  Introduction
----------------
Serial ATA (SATA) is the next generation storage interconnect, designed to 
replace parallel ATA (PATA) technology. SATA is the proactive evolution
of the ATA interface from a parallel bus to a serial bus architecture.
SATA delivers better functionality and higher performance then parallel ATA 
(PATA) technology. Some of the features include enhanced command queuing, 
hotplugging support, point-to-point connectivity and fine-grained power 
management.
Command Queuing and it's SATA-2 enhanced version called Native Command
Queueing (NCQ) provides I/O throughput comparable to SCSI, at lower device
cost. Hotplugging support increases system maintainability. Point-to-point
connectivity eliminates bus arbitration and contention. Fine-grained power
management allows better power management with lesser performance impact.

Serial ATA International Organization (SATA-IO) is the group responsible
for defining the specification and driving the adoption of SATA technology.
See the reference [4,5] for more information.

Other operating systems, like Windows XP and Linux already have SATAcontroller 
drivers utilizing advances SATA features such as command queuing and
hotplugging. 
Existing SATA support in Solaris does not support these features, rendering 
Solaris-running systems slower and less competitive.

Current Solaris support for SATA controllers utilizes pci-ide/ata driver
combination and is limited to controllers operating in a compatibility mode,
emulating generic parallel ATA controllers (register layout and
functionality). These drivers limits the SATA controllers and devices
functionality to that of a PATA functionality.
Some of the limitations are:

    * Non-compatibility mode is not supported
    * Hotplugging feature is not supported
    * 'cmdk' target driver doesn't have all the functionality as in 'sd' driver
      (e.g: Tag Queuing feature).
    * The current 'cmdk' devinfo model doesn't cover all possible SATA hw
      configurations (e.g: port multiplier, multiple ports for each controller,
      etc.).
    * Existing implementation of ATA controllers are platform specific, one
      set of drivers for sparc, and one for x86.
    * Existing pci-ide/ata framework interfaces are not public, thus requiring
      Sun to invest into development of drivers for any new SATA controllers.

Extensive modification of existing, generic pci-ide and ata drivers to
support advanced SATA features and variety of SATA controllers that do
not emulate parallel ATA controller cannot be justified. Instead, a new SATA
framework is being developed that is designed from the start to incorporate
the SATA features, and designed to allow for the eventual development of
SATA HBA drivers by third parties.

SATA controllers are expected to evolve fast and be increasingly employed in a 
variety of platforms, including systems manufactured by Sun.  Unification of the 
driver for all platforms is desired, to lower maintenance cost. 
NSG platforms (e.g: Thumper) based on Opteron processors use SATA controllers 
operating in non-compatible mode. SATA hotplug feature is one of the 
requirements for Thumper platform. Also, there are several new platforms from 
OEMs like Intel, Dell, HP, etc. that use new SATA controller interfaces which 
are considered Tier 1 systems for Solaris/X86 market.


2  Proposal Summary
--------------------

This project proposes a new framework for supporting SATA HBA controller
drivers working in conjunction with existing SCSA framework and the 
common sd target driver.  Attached SATA devices will be seen by the operating 
system as SCSI devices.

The SATA HBA framework will take care of SCSA interface, SCSI to SATA 
translation, command emulation, hotpluggimg support and cfgadm interfacing,
port multiplier support, SCSI device enumeration and target, control and 
attachment point nodes creation.

The controller specific SATA HBA driver will only deal with hardware specific 
implementation of the SATA port interfaces and device detection and control.

SATA HBA framework with cooperating SATA HBA driver emulates SCSI HBA driver 
and SCSI drives behavior and functionality, satisfying the SCSA interface and
sd target driver expectations like a typical SCSI HBA driver.

The implementation will based on the SATA specification version 1.0a with 
selected SATA II extensions, for hotplugging, Port Multiplier, Native Command 
Queuing (NCQ) and Gen-2 Signaling Speed.  The SATA framework interfaces 
requested committment level is Consolidation Private.

The major components of the project are:

          o SATA HBA framework kernel module, platform neutral
          o cfgadm(1m) plug-in for SATA hotplug support
          o SATA HBA driver for Marvel controller hardware (88SX50XX/88SX60XX),
            platform neutral
	  o SATA HBA driver for Silicon Image 3124 controller hardware,
	    platfrom neutral
          o Man page describing SATA cfgadm user interface
          o SATA HBA driver-specifc man pages
	  o Man page describing Solaris SATA architecture

The implementation will be tested on the NSG platform, code named 'Thumper', 
that uses Marvel SATA controller (88SX5080 and 88SX6080). Additional SATA HBA 
driver for a different architecture SATA controller  (SiliconImage 3124) will 
be developed in parallel to validate the generality of the SATA
HBA framework functionality and interface.

The PSARC Fast Track review is expected to provide overall review of the 
proposed architecture and proposed interfaces.


3 Goals and Requirements
-------------------------

The main goal of this project is to implement generic SATA HBA driver framework 
in Solaris with stable interfaces facilitaiting internal SATA drivers 
development,
as well as unification of SATA support for x86 and SPARC platforms and reuse
of established SCSA framework and sd target driver.

In the future, raising commitment level will facilitate development of SATA HBA
driver by third-party developers.
 
The requirements for the SATA HBA framework are:

    * Re-use of existing SCSA framework functionality and interfaces.
    * Re-use of common sd driver as a target driver.
    * Simple interface to SATA HBA drivers.
    * Support for SATA II features: hotplugging support, Native Command
      Queuing, Port Multiplier support
    * SMART support
    * Compatibility with cfgadm interface for hotplug.
    * Platform neutrality.
    * Flexibility and extensibility of the SATA HBA interface to accommodate
      needs of existing and future SATA controllers and Solaris OS.
    * Stable and fully defined interface with SATA HBA drivers suitable for
      third-party driver developers.

3.1 Development Phases

The project will be implemented in two phases. Phase 1 will define and 
implement SATA HBA framework interfaces as a kernel module and will implement
SATA HBA driver for Marvel controller hardware using the new SATA framework.
Additional SATA HBA driver for Silicon Image 3124 SATA controller will be
also developed in phase 1.
The SATA HBA framework interfaces will be committed initially as Consolidation
Private interfaces.
The functionality provided in this phase includes support for hot plugging of
SATA drives and basic power management. Only SATA hard drives will be supported
in phase 1.
Phase 1 components will be tested on the new NSG platform, code named
'Thumper', that uses Marvel SATA controller 88sx6081. Silicon Image SATA HBA
driver will be tested on plug-in HBA cards.

Phase 1 implementation will be platform neutral, but the SATA HBA framework,
Marvell 88sx60XX SATA HBA driver and Silicon Image SI3124 SATA HBA driver
will be delivered only for x86 platform.
Phase 1 will not provide FMA support.

Phase 2 of this project will expand functionality of the SATA HBA Framework
to support legacy command queuing, native Command Queuing, Port Multipliers
(see [6]), SMART, and SATA-ATAPI devices.
Phase 2 will also provide FMA support.
It may also raise the commitment level on the defined SATA Framework
interfaces to 'Evolving' state. This would allow third party driver writers
to implement new SATA HBA drivers.  The documentation to support writing new
SATA HBA drivers and a code template for a sample driver will be delivered
in second phase of the project.
The additional component delivered in phase 2 is: 

    * Sample SATA HBA driver (code template)

Note: Additional native-mode SATA HBA drivers (e.g: ICH6, CK804 etc.) may
be developed in phase-2 of this project but with a dependency on phase 1
components.



4  Technical Description
-------------------------

4.1 Architecture

4.1.1 Basic Architecture Model


                    +-----------------+
                    |     cfgadm      |
                    +-------^---------+
                            |
                            v
                    +=================+
                    | SATA Hot Plug   | SATA specific
                    | library         | plug-in
                    +=======^=========+ library
                            |                            Solaris I/O
                            |                                ^
                            |              USER              | 
      ======================|================================|================
                            |             KERNEL             | 
                            |                        +-------v---------+
             cfgadm plug-in |                        |   SD driver     |
                     IOCTLs |                        | (target driver) |
                            |                        +-------^---------+
                            |                                ^
                            |             SCSA               |
                  +=========v==========+  Interface  +-------v---------+
                  | SATA HBA Framework |<----------->| SCSA Framework  |
                  +=========^==========+             +-----------------+
                            |
                            | SATA HBA
                            | Interface
                            |
                  +=========v==========+
                  | SATA HBA Driver    |
                  | (eg. Marvel driver)|
                  +====================+
                            |
                            V
           ( SATA devices: SATA disks, SATA ATAPI CDROMs, ...)
           

            Figure 1: Basic Architecture Model Diagram
            
            

4.1.2 Components

The proposed SATA driver architecture model consists of the following 
components:

4.1.2.1 SATA HBA Framework (new)


Implemented as a kernel module that interfaces with the SCSA framework and 
cfgadm and provides generic SATA interfaces to hardware specific SATA HBA 
driver.  The SATA HBA framework :

    * Implements and exports generic SCSI HBA interface.
    * Performs initial SATA devices configuration and setup, including Port
      Multipliers.
    * Emulates SCSI operations that have no equivalent in SATA.
    * Translates SCSI operations into appropriate SATA operations.
    * Controls SATA operation sequences needed for SCSI operations.
    * Provides data buffer DMA resources setup.
    * Translates SATA operation status and error information into SCSI format.
    * Provides devctl interface for cfgadm.
    * Controls hotplug and operator-directed operations.
    * Performs dynamic reconfiguration based on asynchronous hotplug events.
             
All access to the SATA HBA driver (and SATA HBA) is via SATA HBA framework. SATA 
HBA framework presents to the system each registered instance of the SATA HBA  
as the SCSI HBA instance. The basic functionality of SCSI HBA driver is provided 
by combined SATA HBA framework and SATA HBA driver functionality. Attached SATA 
devices are treated as SCSI devices and are controlled by the sd target driver 
via SCSI transport layer. 

The SATA device nodes are self-identifying, as they are connected point-to-point
to device ports. The sd nodes and their properties are created dynamically  
(using standard nexus mechanisms) by SATA HBA framework during SATA HBA instance 
attachment process and are removed/adde dynamically in response to hotplug 
events and added/removed via 'cfgadm' commands.

Operation requests for the SATA HBA passed via sata packet  driver are simple 
basic operations on the SATA ports and requests for handling SATA device 
commands.

Operations specified by scsi packets are translated by SATA HBA framework into 
equivalent SATA device operations (in SATA packet envelope - sata packet), or 
emulated within the framework,  or rejected if none of the above could be done. 
Data buffer DMA mapping and DMA resources allocation is performed by the SATA 
HBA framework.  While translating SCSI operations into SATA operations, SATA HBA 
framework takes into consideration  SATA HBA capabilities and attached devices 
capabilities and sends to  SATA HBA driver (via SATA HBA Interface) fully formed 
SATA device commands, including standard registers setup. The status of the SATA 
operation, including error information is translated into SCSI format by SATA 
HBA framework.
             
SATA HBA framework creates attachment points for each device port and a single
control node for each SATA HBA instance. Device control IOCTLs are processed by
the SATA HBA framework and are translated into SATA 
operations, if necessary. Selected IOCTLs that cannot be handled by SATA HBA
framework are passed to standard nexus IOCTL handler ndi_devctl_ioctl().
Other IOCTLs are passed to the SATA HBA driver.

Hotplug events detected by the SATA HBA driver are handled by SATA HBA framework 
which performs necessary internal configuration/reconfiguration and error 
handling operations.


4.1.2.2  SATA HBA driver (new)

Controller/Hardware specific driver (e.g: Marvel driver) in Solaris written for 
the interfaces defined by the SATA HBA framework.  The controller-specific SATA 
HBA driver:
    * Registers itself with the SATA HBA framework
    * Attaches/detaches each instance of the HBA via SATA HBA framework service
      functions
    * Monitors and reports state of the SATA device ports
    * Maintains connection with attached SATA devices and Port Multipliers
    * Reports changes of SATA device ports state
    * Sends SATA commands to attached devices and controls transfer of data and
      status of the operations
    * Controls SATA commands queuing and execution order
    * Performs control operations requested by SATA HBA framework on ports and
      devices

HBA capabilities and configuration are exposed to SATA HBA framework via 
sata_hba_tran interface structure along with the vector of interface functions.  
SATA HBA framework invokes HBA services by calling exported functions.

SATA HBA driver is not aware of SCSA interface requirements nor SCSI-to-SATA 
translations.


4.1.2.3 SCSA Framework

The current SCSA framework in Solaris. The SCSI transport layer provides 
interface between sd target driver and SATA HBA framework/SATA HBA instance  
registered with the SCSA framework as SCSI HBA instance.


4.1.2.4 sd target Driver
 
The current Solaris 'sd' driver. No changes are necessary. Some performance 
improvement may be gained if sd driver could be made aware of the SATA queue 
depth.


4.1.2.5 cfgadm(1m) plug-in for SATA (new)

Implements SATA specific hotplug operations for cfgadm(1m) framework. It uses 
devctl_* interfaces defined in libdevice.so to communicate with the SATA HBA 
framework to perform hotplug operations on the attachment point.  This plug-in 
will not support enclosure nor storage arrays hotplugging.


4.2 Interfaces


The new interfaces are of Consolidation Private stability classifications. 
Interfaces on Figure 1 labeled 'SATA HBA Interface' and 'cfgadm plug-in IOCTLs' 
are of particular interest as they are defined on the SATA HBA framework 
boundary.


4.2.1 Exported Interfaces

Exported Interfaces are new interfaces (to be reviewed by PSARC). All new 
interfaces are Consolidation Private.
       
+------------------------------------------------------------------------------+
| Interface                 | Classification   | Comments                      |
|                           |                  |                               |
|------------------------------------------------------------------------------|
| sata                      | Consolidation    | New kernel module             |
|------------------------------------------------------------------------------| 
| sata_hba_tran             | Consolidation    | SATA Host Bus Adapter (HBA)   |
|                           | Private          | driver transport vector struct|
|------------------------------------------------------------------------------|
| sata_tran_probe_port()    | Consolidation    | sata_hba_tran component       |
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_tran_start()         | Consolidation    | sata_hba_tran component       | 
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_tran_abort()         | Consolidation    | sata_hba_tran component       | 
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_tran_reset_dport()   | Consolidation    | sata_hba_tran component       |
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_tran_selftest()      | Consolidation    | sata_hba_tran component       | 
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_tran_hotplug_ops     | Consolidation    | sata_hba_tran component       | 
|------------------------------------------------------------------------------|
| sata_tran_port_activate() | Consolidation    | sata_tran__hotplug_ops        |
|                           | Private          | component                     | 
|------------------------------------------------------------------------------|
| sata_tran_port_deactivate()| Consolidation   | sata_tran_hotplug_ops         |           
|                           | Private          | component                     | 
|------------------------------------------------------------------------------|
| sata_tran_pwrmgt_ops      | Consolidation    | sata_hba_tran component       | 
|                           | Private          |                               | 
|------------------------------------------------------------------------------|
| sata_tran_get_pwr_level() | Consolidation    | sata_tran_pwrmgt_ops          | 
|                           | Private          | component                     | 
|------------------------------------------------------------------------------|
| sata_tran_ioctl()         | Consolidation    | sata_hba_tran component       | 
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| sata_address              | Consolidation    | structure specifying SATA     |
|                           | Private          | or device location            | 
|------------------------------------------------------------------------------|
| sata_device               | Consolidation    | structure describing state of |
|                           | Private          | SATA port and type of an      |
|                           |                  | attached device               |
|------------------------------------------------------------------------------|
| sata_pkt                  | Consolidation    | structure defining sata packet| 
|                           | Private          | - device, buffer, operation,  |
|                           |                  | status, etc.                  |
|------------------------------------------------------------------------------|
| sata_cmd                  | Consolidation    | Structure specifying SATA cmd |
|                           | Private          | and information necessary for |
|                           |                  | cmd execution.                |
|------------------------------------------------------------------------------|
| sata_port_scr             | Consolidation    | Structure describing state of |
|                           | Private          | a sata port - embedded in the |
|                           |                  | sata_device structure.        |
|------------------------------------------------------------------------------|
| sata_hba_init()           | Consolidation    | Register SATA HBA driver with |
|                           | Private          | SATA HBA framework            |
|------------------------------------------------------------------------------|
| sata_hba_attach()         | Consolidation    |Attach SATA HBA driver instance| 
|                           |  Private         |                               |
|------------------------------------------------------------------------------|
| sata_hba_detach()         | Consolidation    |Detach SATA HBA driver instance| 
|                           | Private          |                               | 
|------------------------------------------------------------------------------|
| sata_hba_fini()           | Consolidation    | Unregister SATA HBA driver    | 
|                           | Private          | from SATA HBA framework       |
|------------------------------------------------------------------------------|
| sata_hba_event_notify()   | Consolidation    | Report asynchronous event     | 
|                           | Private          |   SATA HBA framework          |
|------------------------------------------------------------------------------|
| sata.so.1                 | Consolidation    | Class bound cfgadm plug-in for| 
|                           | Private          | attachment point of class sata|
|------------------------------------------------------------------------------|
| SATA devctl node          | Consolidation    | Devctl node (minor number     | 
| (minor number)            | Private          | format)                       |
|------------------------------------------------------------------------------|
| SATA AP node              | Consolidation    | Attachment Point node         | 
| (minor number)            | Private          | (minor number format)         |
|------------------------------------------------------------------------------|
| SCSI target number for    | Consolidation    | SCSI target number for SATA   | 
| SATA device               | Private          | device (number format)        |
|------------------------------------------------------------------------------|
| SATA_AP_MINOR_TO_SATA_ADDRESS | Consolidation| Macro used by cfgadm plug-in  |
|                               | Private      |                               |
|------------------------------------------------------------------------------|
| SATA_AP_MINOR_TO_INSTANCE | Consolidation    | Macro used by cfgadm plug-in  |
|                           | Private          |                               |
|------------------------------------------------------------------------------|
| DDI_NT_SATA_ATTACHMENT_POINT | Consolidation | SATA attachment point type    |
|                              | Private       |                               | 
|------------------------------------------------------------------------------|
| SATA_CFGA_RESET_PORT      | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_RESET_DEVICE    | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_SELF_TEST       | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_PORT_DEACTIVATE | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_PORT_ACTIVATE   | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_GET_AP_TYPE     | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_GET_AP_INFO     | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_GET_MODEL_INFO  | Consolidation    | Subcommand of                 | 
|                           | Private          | DEVCTL_AP_CONTROL             |
|------------------------------------------------------------------------------|
| SATA_CFGA_GET_REVFIRMWARE_INFO | Consolidation | Subcommand of               | 
|                                | Private       | DEVCTL_AP_CONTROL           |
|------------------------------------------------------------------------------|
| SATA_CFGA_GET_SERIALNUMBER_INFO| Consolidation | Subcommand of               | 
|                                | Private       | DEVCTL_AP_CONTROL           |
+------------------------------------------------------------------------------+

      

4.2.1.1  Exported Interfaces Description

The sata_hba_tran structure is the basic interface between SATA HBA framework 
and SATA HBA driver.  It describes SATA HBA instance capabilities and basic SATA 
ports configuration and contains a functions vector used for passing requests 
from SATA HBA framework to SATA HBA driver. This structure is linked with a SATA 
HBA framework software state structure specific to the attached SATA HBA 
instance.

The sata_address structure is used to specify address of the sata  port or the 
SATA device itself.

The sata_device structure contains sata_address and information related to the 
addressed SATA port or SATA device.

The sata_pkt structure is used to pass fully formed SATA command and all 
information necessary for execution of such SATA command, including data buffer, 
allocated data buffer DMA resources, status and error information. This 
structure is linked (using opaque pointer) to scsi packet, so SATA HBA framework 
can maintain corelation between scsi packet sent from sd target driver and sata 
packet used to communicate with SATA HBA driver.

The sata_cmd structure is used to specify in SATA command, including standard
register content, and adition information needed for cmd setup and execution.

The sata_hba_init() and sata_hba_fini() are SATA HBA framework functions used to 
register/unregister SATA HBA driver to/from SATA HBA framework.  SATA HBA driver 
calling these function causes SATA HBA framework to call SCSA interface 
registering/unregistering SCSI HBA driver.

The sata_hba_attach() and sata_hba_detach() are SATA HBA framework functions 
used to attach/detach specific SATA HBA instance.

The sata_hba_event_notify() is SATA HBA framework function used by SATA HBA 
driver to pass hotplug event notification.

The sata.so.1 is sata-specific cfgadm plug-in implementing SATA hotplug 
operations and sata-specific control operations.

The devctl and Attachment Point minor number is used to specify controller and 
attachment point (SATA device port). The format of the minor number allows for 
64 controllers with up to 32 SATA ports each, up to 2048  directly attached  
SATA devices and up to 30720 attached SATA devices when port multipliers are 
employed. 17 bits of the minor device number are used for this purpose.

SATA_AP_MINOR_TO_* are macros converting minor number to controller instance and 
to SATA port address.

DDI_NT_SATA_ATTACHMENT_POINT is a new type of the attachment point created for 
each SATA device port.

SATA_CFGA_* are subcommands of DEVCTL_AP_CONTROL ioctl used by cfgadm SATA 
plug-in to fetch an attachment point related data and to request SATA device 
port related test and recovery operations.

For further details please refer to SATA HBA framework Specification 
http://solaris-x86.sfbay/Projects/SATA/SHF_Functional_Spec.html


4.2.2 Imported Interfaces

These interfaces are stable or Consolidation Private interfaces.

+------------------------------------------------------------------------------+
| Interface            | Classification        | Comments                      |
|                      |                       |                               |
|------------------------------------------------------------------------------|
| scsi                 | stable                | Existing SCSA framework       |
|                      |                       | Kernel module                 |
|------------------------------------------------------------------------------|
| scsi_hba_tran        | stable                | SCSI Host Bus Adapter (HBA)   |
|                      |                       | driver transport vector struct| 
|                      |                       | scsi_hab_tran(9s)             |
|------------------------------------------------------------------------------|
| scsi_hba_attach()    | stable                | scsi_hba_attach(9F)           |
|------------------------------------------------------------------------------|
| scsi_hba_detach()    | stable                | scsi_hba_detach(9F)           |
|------------------------------------------------------------------------------|
| scsi_hba_pkt_alloc() | stable                | scsi_hba_pkt_alloc(9F)        |
|------------------------------------------------------------------------------|
| scsi_hba_pkt_free()  | stable                | scsi_hba_pkt_free(9F)         |
|------------------------------------------------------------------------------|
| scsi_hba_init()      | stable                | scsi_hba_init(9F)             |
|------------------------------------------------------------------------------|
| scsi_hba_fini()      | stable                | scsi_hba_fini(9F)             |
|------------------------------------------------------------------------------|
| scsi_pkt             | stable                | scsi_pkt(9S)                  |
|------------------------------------------------------------------------------|
| SCMD_*               | stable                | Subset of SCSA command list.  |
|                      |                       | Mandatory comands only        |
|------------------------------------------------------------------------------|
| ddi_dma_attr         | stable                | ddi_dma_attr_t(9s)            |
|------------------------------------------------------------------------------|
| cb_ops               | stable                | cb_ops(9s)                    |
|------------------------------------------------------------------------------|
| cb_open              | stable                | cb_open(9s)                   |
|------------------------------------------------------------------------------|
| cb_close             | stable                | cb_close(9s)                  |
|------------------------------------------------------------------------------|
| cb_ioctl             | stable                | cb_ioctl(9s)                  |
|------------------------------------------------------------------------------|
| ndi_devi_alloc_sleep()| Consolidation Private| Nexus interface               |
|------------------------------------------------------------------------------|
| ndi_devi_online()    | Consolidation Private | Nexus interface               |
|------------------------------------------------------------------------------|
| ndi_devi_offline()   | Consolidation Private | Nexus interface               |
|------------------------------------------------------------------------------|
| ndi_devi_free()      | Consolidation Private | Nexus interface               |
|------------------------------------------------------------------------------|
| ndi_devi_ioctl()     | Consolidation Private | Nexus interface               |
|------------------------------------------------------------------------------|
| scsi_hba_nodename_compatible_get() | Consolidation | Generic SCSI HBA        |
|                                    | Private       | interface
|------------------------------------------------------------------------------|
| scsi_hba_nodename_compatible_free()| Consolidation | Generic SCSI HBA        |
|                                    | Private       | interface
|------------------------------------------------------------------------------|
| DEVCTL_BUS_GETSTATE  | Consolidation Private | passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_DEVICE_ONLINE | Consolidation Private | passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_DEVICE_OFFLINE| Consolidation Private | passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_DEVICE_GETSTATE| Consolidation Private| passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_DEVICE_REMOVE | Consolidation Private | passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_BUS_DEV_CREATE| Consolidation Private | passed to ndi_devctl_ioctl()  |
|------------------------------------------------------------------------------|
| DEVCTL_BUS_RESET     | Consolidation Private | converted to port reset       |
|------------------------------------------------------------------------------|
| DEVCTL_BUS_RESETALL  | Consolidation Private | no op                         |
|------------------------------------------------------------------------------|
| DEVCTL_BUS_QUIESCE   | Consolidation Private | no op                         |
|------------------------------------------------------------------------------|
| DEVCTL_BUS_UNQUIESCE | Consolidation Private | no op                         |
|------------------------------------------------------------------------------|
| cfgadm               | stable                | cfgadm(1M)                    |
|------------------------------------------------------------------------------|
| DEVCTL_AP_DISCONNECT | Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
|------------------------------------------------------------------------------|
| DEVCTL_AP_UNCONFIGURE| Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
|------------------------------------------------------------------------------|
| DEVCTL_AP_CONNECT    | Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
|------------------------------------------------------------------------------|
| DEVCTL_AP_CONFIGURE  | Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
|------------------------------------------------------------------------------|
| DEVCTL_GET_STATE     | Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
|------------------------------------------------------------------------------|
| DEVCTL_AP_CONTROL    | Consolidation Private | existing attachment point     |
|                      |                       | operation                     |
+------------------------------------------------------------------------------+


4.2.1.1  Imported Interfaces Description

Majority of imported interfaces are public, stable interfaces described in man 
pages. Nexus interfaces are Consolidation Private.

The SCSI command set SCMD_* is a minimal required SCSI command set, a subset of 
all SCSI commands supported by the sd target driver. Unsupported SCSI commands 
are rejected by the SATA HBA framework or SATA HBA driver with appropriate sense 
information returned in scsi_pkt, emulating the behavior of a SCSI device
that rejects unsupported command.



4.3 User Interface

This project uses standard cfgadm(1M) user command interface to manually control 
hotplug operations. No other user interface is defined.
The proposal for SATA-specific cfgadm plug-in user interface is described in
cfgadm_sata man page.

In the future expansion of the SATA HBA framework functionality the automatic 
detection of the hotplug events by a SATA HBA driver may be propagated to the 
event framework.



5 References 
--------------

[1] Information Technology AT Attachment with Packet Interface - 7, Volume 1

[2] Information Technology AT Attachment with Packet Interface - 7, Volume 2

[3] Information Technology AT Attachment with Packet Interface - 7, Volume 2

[4] Serial ATA: High Speed Serialized AT Attachment 1.0.a

[5] Serial ATA II: Extensions to Serial ATA 1.0.a

[6]  Serial ATA II:  Port Multiplier; rev 1.1

[7] SCSI/ATA Translation (SAT) draft T10/1711-D rev 2

[8] SATA HBA Framework Functional Specification

Note:
The  T10/1711-D [7] specification is still in the draft stage. SATA framework
implementation does not fully comply with this draft at this time. T10/1711-D
is still a very fluid draft, constantly being appended and modified. In pahse 1
of the SATA project it will be used only as an example of the basic translation
matrix.

The minimal SCSI/ATA translation implemented in SATA framework in phase 1 will
be tuned to the minimal needs of the sd target driver in Solaris. In reality it
means that there will be some omissions of the proposed translation, some
extensions as well as differences in emulation vs direct and partial
translation to ATA commands.

In phase 2 of the SATA project the SAT layer will be extended to include SMART
support. At that time scsi-to-ata translation compliance level will be adjusted
as well.

6 Glossary
-----------

Explanation of uncommon terms:


Compatibilty mode / non-compatability mode:

These terms are used in other offcial documents in differing contexts.
In this document, compatibility mode refers to a tranditional PATA controller 
which presents a standardized ATA register set layout and register 
functionality.
Non-compatible mode refers to controllers that do not not present such a 
standard layout and a registers functionality. Often a layout is proprietary
and not compatible with any other SATA controller.


GEN-2 Signaling Speed:

3.0 Gbps, signaling speed of SATA II physical interface


NCQ (Native Command Queuing):

The command queuing model derived from legacy queuing but with enhancement to 
take advantage of Serial ATA and  minimizing required protocol round trips to 
reduce overhead.


Port Multiplier:
 
A device allowing one active host serial connection to be multiplexed to 
multiple device connections. Only one active host connection is supported (via 
dedicated "host" port) and up to 15 device connections (device ports). Port 
multipliers cannot be cascaded.


SATA:

Serial ATA. An evolution of Parallel ATA physical storage interface. Serial ATA 
is a serial link -- a single cable with a minimum of four wires creates a 
point-to-point connection between devices. The serial protocol was defined by 
ATA/ATAPI-7 V3 specification.
The Serial ATA International Organization (SATA-IO) is currently the group 
responsible for developing, managing and driving adoption of the Serial ATA 
specification (currently revision 1.0a.)


SATA II:

Enhancement to Serial ATA 1.0a specification that provides additional 
capabilities while retaining Serial ATA 1.0a compatibility and desktop cost 
structure.

SATA Device Port:

A port (with PHY) that can be used to connect SATA device.

SATA PHY
SATA Physical Layer interface

SMART
Self-Monitoring, Analysis and Reporting Technology, used to monitor the health
status of hard disks that support SMART technology.






--------------050609060508090104040406--

From sacadmin Tue Jan  3 13:52:32 2006
Received: from jurassic.eng.sun.com (jurassic.SFBay.Sun.COM [129.146.68.36])
	by sac.sfbay.sun.com (8.12.9+Sun/8.12.9) with ESMTP id k03LqVIQ000938
	for <psarc@sac.eng.sun.com>; Tue, 3 Jan 2006 13:52:31 -0800 (PST)
Received: from [129.146.228.109] (cyber.SFBay.Sun.COM [129.146.228.109])
	by jurassic.eng.sun.com (8.13.5+Sun/8.13.5) with ESMTP id k03LqV2r710327;
	Tue, 3 Jan 2006 13:52:31 -0800 (PST)
Message-ID: <43BAF249.9050003@Sun.COM>
Date: Tue, 03 Jan 2006 13:53:13 -0800
From: Bart Smaalders <bart.smaalders@Sun.COM>
Organization: Sun Microsystems
User-Agent: Mail/News 1.5 (X11/20051106)
MIME-Version: 1.0
To: psarc@sac.eng.sun.com
CC: Pawel.Wojcik@Sun.COM, sata-dev@Sun.COM
Subject: PSARC/2005/679 SATA HBA Framework Support (Updated)
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Status: RO
Content-Length: 625


I'd like to amend this fasttrack in a minor fashion; due to
some irritating disconnects with Sun legal, the Marvel driver
portion of this putback will be delayed somewhat.  Thus, phase 1
will omit the Marvel Driver; once the legal issues are resolved
the Marvel driver will go back as well.  The delay is expected to
be small.

As this represents no substantive change to the case, and a
working driver still accompanies the SATA framework, I'm submitting
this as a simple update of an already approved arc case.

- Bart



-- 
Bart Smaalders			Solaris Kernel Performance
barts@cyber.eng.sun.com		http://blogs.sun.com/barts

