Pawel Wojcik's Weblog Pawel Wojcik's Weblog

Thursday Jan 11, 2007

As many of you noticed, Solaris now supports SATA controllers and devices. To simplify writing SATA HBA drivers the new module and a set of interfaces was created, referred to as either SATA Framework or SATA module. I was a principal architect of SATA framework, but several other Sun engineers were participating in the conceptual design and the shaping of the interfaces.
It is not small piece of software - the source, sata.c, is over 300k in size. Reading this code, with associated header files may be a little confusing. So, I created an overview of the sata module, explaining what it is, how it fits in Solaris kernel, what it does, what are the interfaces and how sample operations are performed. Hopefully, it will be useful for all that want to improve and expand SATA support in Solaris Similar overview was presented about a year ago at Silicon Valley Open Solaris User Group meeting in Santa Clara and on various occasions internally in Sun organization. The overview that I plan to present here will have several parts. Here is the first one...

Up to the time of introduction of SATA Framework, Solaris support for SATA controllers was limited to controllers operating in a compatibility mode, emulating generic, parallel ATA controllers. Only generic ATA interfaces are used, i.e. task files registers and bus master control registers. This was clearly inadequate for SATA controllers not implementing standard ATA interfaces and for providing fine-control access to serial interfaces and SATA-native features. Hotplugging feature in particular was not supported in existing pci-ide/ata framework. Queuing, particularly SATA NCQ could not be supported without extensive changes to pci-ide and ata driver.

The goals of the SATA framework project:
  • Facilitate usage of existing Solaris scsi layer and common scsi target driver.
  • Provide common processing and algorithms that all SATA HBA drivers using scsa and scsi target driver would otherwise have to implement.
  • Provide native SATA support (as opposed to emulating legacy IDE devices),
  • Provide configuration management and hotplugging support for SATA HBA drivers.
  • Minimize SATA HBA driver complexity.
  • Provide platform neutrality.
  • Provide stable interface suitable for a third-party driver developers.
Why SCSI? Because Solaris scsi layer and target driver (sd) are a mature drivers (however imperfect) with already tried and tested capabilities and features. Furthermore, device naming and handling would appear to other system entities/application layers the same as for scsi devices. And lastly, T10 standard body and SATA manufacturers fairly early started an effort to define common definitions and and requirements for emulating SCSI device behavior.
SATA HBA Framework was intended as the support module interfacing SATA HBA driver (hardware specific) with existing Solaris SCSI framework. The goal was to isolate hardware-specific SATA HBA driver from SCSI related operations and interfaces and to implement generic, SATA-specific operations for use by SATA HBA driver. SATA HBA driver could be then concerned only with hardware initialization and interface to attached SATA devices, while SATA HBA Framework would implement generic SATA operations and interface with generic SCSA framework and SCSI target drivers.
SATA HBA driver in conjunction with SATA HBA Framework would be treated by SCSI framework as an SCSI HBA driver. SATA HBA Framework and SATA drivers are intended to be platform-neutral - common code would be used on x86, x64 and sparc based platforms (existing ATA support in Solaris uses different drivers on x86/x64 and sparc platforms). Additional goal was to make SATA HBA Framework interface public, thus allowing third-party developers to write simple SATA HBA drivers without Sun engineers involvement.

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


SATA Framework features:
  • Implemented as a loadable kernel module.
  • Implements and exports generic SCSI HBA interface.
  • Performs initial SATA devices configuration and setup.
  • 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 hotplugging and operator-directed operations.
  • Performs dynamic reconfiguration based on asynchronous hotplugging events.
  • Generates sysevents that may be consumed/monitored by other system entities.


TO BE CONTINUED....

Comments:

[Trackback] Pawel Wojcik wrote: As many of you noticed, Solaris now supports SATA controllers and devices. To simplify writing SATA HBA drivers the new module and a set of interfaces was created, referred to as either SATA Framework or SATA module. I was a princip...

Posted by UNIX-WORLD NEWS on January 12, 2007 at 10:16 AM PST #

Post a Comment:
Comments are closed for this entry.