sata_hba.h revision b5fc475bca6525d8da80728128eefb7100aaf66b
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A * SATA Host Bus Adapter (HBA) driver transport definitions 1N/A/* SATA Framework definitions */ 1N/A /* Multiplier (PMult) */ 1N/A * SATA device address 1N/A * Address qualifier flags are used to specify what is addressed (device 1N/A * or port) and where (controller or port multiplier data port). 1N/A * SATA address Qualifier flags (in qual field of sata_address struct). 1N/A * They are mutually exclusive. 1N/A * SATA port status and control register block. 1N/A * The sstatus, serror, scontrol, sactive and snotific 1N/A * are the copies of the SATA port status and control registers. 1N/A * (Port SStatus, SError, SControl, SActive and SNotification are 1N/A * defined by Serial ATA r1.0a sepc and Serial ATA II spec. 1N/A * SATA Device Structure (rev 1) 1N/A * or an attached drive: 1N/A * fields are used to specify SATA address (see sata_address structure 1N/A * The satadev_scr structure is used to pass the content of a port 1N/A * status and control registers. 1N/A * The satadev_add_info field is used by SATA HBA driver to return an 1N/A * additional information, which type depends on the function using 1N/A * sata_device as argument. For example: 1N/A * - in case of sata_tran_probe_port() this field should contain 1N/A * a number of available Port Multiplier device ports; 1N/A * - in case of sata_hba_event_notify() this field may contain 1N/A * a value specific for a reported event. 1N/A /* function specific */ 1N/A * satadev_state field of sata_device structure. 1N/A * Common flags specifying current state of a port or an attached drive. 1N/A * These states are mutually exclusive, obviously 1N/A * Attached drive specific states (satadev_state field of the sata_device 1N/A * SATA_DSTATE_PWR_ACTIVE, SATA_DSTATE_PWR_IDLE and SATA_DSTATE_PWR_STANDBY 1N/A * are mutually exclusive. All other states may be combined with each other 1N/A * and with one of the power states. 1N/A * These flags may be used only if the address qualifier (satadev_addr.qual) is 1N/A * set to SATA_ADDR_DCPORT or SATA_ADDR_DPMPORT value. 1N/A/* Mask for drive power states */ 1N/A * SATA Port specific states (satadev_state field of sata_device structure). 1N/A * SATA_PSTATE_PWRON and SATA_PSTATE_PWROFF are mutually exclusive. 1N/A * All other states may be combined with each other and with one of the power 1N/A * These flags may be used only if the address qualifier (satadev_addr.qual) is 1N/A * set to SATA_ADDR_CPORT or SATA_ADDR_PMPORT value. 1N/A/* Mask for the valid port-specific state flags */ 1N/A/* Mask for a port power states */ 1N/A * Device type (in satadev_type field of sata_device structure). 1N/A * More device types may be added in the future. 1N/A * SATA cmd structure (rev 1) 1N/A * SATA HBA framework always sets all fields except status_reg and error_reg. 1N/A * SATA HBA driver action depends on the addressing type specified by 1N/A * If LBA48 addressing is indicated, SATA HBA driver has to load values from 1N/A * satacmd_sec_count_msb_reg, satacmd_lba_low_msb_reg, 1N/A * satacmd_lba_mid_msb_reg and satacmd_lba_hi_msb_reg 1N/A * to appropriate registers prior to loading other registers. 1N/A * For other addressing modes, SATA HBA driver should skip loading values 1N/A * from satacmd_sec_count_msb_reg, satacmd_lba_low_msb_reg, 1N/A * satacmd_lba_mid_msb_reg and satacmd_lba_hi_msb_reg 1N/A * fields and load only remaining field values to corresponding registers. 1N/A * satacmd_sec_count_msb and satamcd_sec_count_lsb values are loaded into 1N/A * sec_count register, satacmd_sec_count_msb loaded first (if LBA48 1N/A * addressing is used). 1N/A * satacmd_lba_low_msb and satacmd_lba_low_lsb values are loaded into the 1N/A * lba_low register, satacmd_lba_low_msb loaded first (if LBA48 addressing 1N/A * is used). The lba_low register is the newer name for the old 1N/A * sector_number register. 1N/A * satacmd_lba_mid_msb and satacmd_lba_mid_lsb values are loaded into lba_mid 1N/A * register, satacmd_lba_mid_msb loaded first (if LBA48 addressing is used). 1N/A * The lba_mid register is the newer name for the old cylinder_low register. 1N/A * satacmd_lba_high_msb and satacmd_lba_high_lsb values are loaded into 1N/A * the lba_high regster, satacmd_lba_high_msb loaded first (if LBA48 1N/A * addressing is used). The lba_high register is a newer name for the old 1N/A * cylinder_high register. 1N/A * No addressing mode is selected when an ata command does not involve actual 1N/A * SET FEATURE command), or the ATAPI PACKET command is sent. 1N/A * If ATAPI PACKET command is sent and tagged commands are used, 1N/A * SATA HBA driver has to provide and manage a tag value and 1N/A * set it into the sector_count register. 1N/A * Device Control register is not specified in sata_cmd structure - SATA HBA 1N/A * driver shall set it accordingly to current mode of operation (interrupt 1N/A * Buffer structure's b_flags should be used to determine the 1N/A * address type of b_un.b_addr. However, there is no need to allocate DMA 1N/A * resources for the buffer in SATA HBA driver. 1N/A * DMA resources for a buffer structure are allocated by the SATA HBA 1N/A * and it should be based on the DMA cookies list. 1N/A * Upon completion of a command, SATA HBA driver has to update 1N/A * satacmd_status_reg and satacmd_error_reg to reflect the contents of 1N/A * the corresponding device status and error registers. 1N/A * specify what register fields should be updated in sata_cmd structure. 1N/A * If the command completed with error, SATA HBA driver has to update 1N/A * satacmd_sec_count_msb, satacmd_sec_count_lsb, satacmd_lba_low_msb, 1N/A * satacmd_lba_low_lsb, satacmd_lba_mid_msb, satacmd_lba_mid_lsb, 1N/A * satacmd_lba_high_msb and satacmd_lba_high_lsb to values read from the 1N/A * corresponding device registers. 1N/A * If an operation could not complete because of the port error, the 1N/A * If ATAPI PACKET command was sent and command completed with error, 1N/A * rqsense structure has to be filed by SATA HBA driver. The satacmd_arq_cdb 1N/A * points to pre-set request sense cdb that may be used for issuing request 1N/A * sense data from the device. 1N/A * The sata_max_queue_depth field specifies the maximum allowable queue depth 1N/A * minus one, i.e. for maximum queue depth of 32, sata_max_queue_depth would 1N/A * be set to value 0x1f. 1N/A * If FPDMA-type command was sent and command completed with error, the HBA 1N/A * driver may use pre-set command READ LOG EXTENDED command pointed to 1N/A * by satacmd_rle_sata_cmd field to retrieve error data from a device. 1N/A * Only ATA register fields of the sata_cmd are set-up for that purpose. 1N/A * If the READ MULTIPLIER command was specified in cmd_reg (command directed 1N/A * to a port multiplier host port rather then to an attached device), 1N/A * upon the command completion SATA HBA driver has to update_sector count 1N/A * and lba fields of the sata_cmd structure to values returned via 1N/A * command block registers (task file registers). 1N/A /* kept for binary compat. */ 1N/A * Error retrieval buffer 1N/A * dma handle pointer 1N/A * (for buffer DMA syncing) 1N/A * Valid only in error 1N/A /* ptr to dma cookie list */ 1N/A/* ATA address type (in satacmd_addr_type field */ 1N/A * satacmd_flags : contain data transfer direction flags, 1N/A * tagged queuing type flags, queued command flag, and reset state handling 1N/A * Direction flags are mutually exclusive. 1N/A * Tagged Queuing type flags 1N/A * These flags indicate how the SATA command should be queued. 1N/A * Simple-queue-tagged command. It may be executed out-of-order in respect 1N/A * to other queued commands. 1N/A * Ordered-queue-tagged command. It cannot be executed out-of-order in 1N/A * respect to other commands, i.e. it should be executed in the order of 1N/A * being transported to the HBA. 1N/A * Translated head-of-queue-tagged scsi commands and commands that are 1N/A * to be put at the head of the queue are treated as sata_queue_otag 1N/A * This flag indicates that sata_cmd was set-up for DMA Queued command 1N/A * (either READ_DMA_QUEUED, READ_DMA_QUEUED_EXT, WRITE_DMA_QUEUED or 1N/A * WRITE_DMA_QUEUED_EXT command) or one of the Native Command Queuing commands 1N/A * (either READ_FPDMA_QUEUED or WRITE_FPDMA_QUEUED). 1N/A * This flag will be used only if sata_tran_hba_flags indicates controller 1N/A * support for queuing and the device for which sata_cmd is prepared supports 1N/A * either legacy queuing (indicated by Device Identify data word 83 bit 2) 1N/A * or NCQ (indicated by word 76 of Device Identify data). 1N/A * Reset state handling 1N/A * SATA HBA device enters reset state if the device was subjected to 1N/A * the Device Reset (may also enter this state if the device was reset 1N/A * as a side effect of port reset). SATA HBA driver sets this state. 1N/A * Device stays in this condition until explicit request from SATA HBA 1N/A * framework to clear the state. 1N/A * SATA Packet structure (rev 1) 1N/A * hba_driver_private is for a private use of the SATA HBA driver; 1N/A * satapkt_framework_private is used only by SATA HBA framework; 1N/A * satapkt_comp is a callback function to be called when packet 1N/A * execution is completed (for any reason) if mode of operation is not 1N/A * synchronous (SATA_OPMODE_SYNCH); 1N/A * satapkt_reason specifies why the packet operation was completed 1N/A * NOTE: after the packet completion callback SATA HBA driver should not 1N/A * attempt to access any sata_pkt fields because sata_pkt is not valid anymore 1N/A * (it could have been destroyed). 1N/A * Since satapkt_hba_driver_private field cannot be retrieved, any hba private 1N/A * data respources allocated per packet and accessed via this pointer should 1N/A * either be freed before the completion callback is done, or the pointer has 1N/A * to be saved by the HBA driver before the completion callback. 1N/A /* HBA driver private data */ 1N/A /* SATA framework priv data */ 1N/A /* Rqsted mode of operation */ 1N/A * Operation mode flags (in satapkt_op_mode field of sata_pkt structure). 1N/A * Use to specify what should be a mode of operation for specified command. 1N/A * Default (000b) means use Interrupt and Asynchronous mode to 1N/A * perform an operation. 1N/A * Synchronous operation menas that the packet operation has to be completed 1N/A * before the function called to initiate the operation returns. 1N/A * satapkt_reason values: 1N/A * SATA_PKT_QUEUE_FULL - cmd not sent because of queue full (detected 1N/A * by the controller). If a device reject command for this reason, it 1N/A * should be reported as SATA_PKT_DEV_ERROR 1N/A * SATA_PKT_CMD_NOT_SUPPORTED - command not supported by a controller 1N/A * Controller is unable to send such command to a device. 1N/A * If device rejects a command, it should be reported as 1N/A * SATA_PKT_DEV_ERROR. 1N/A * SATA_PKT_DEV_ERROR - cmd failed because of device reported an error. 1N/A * The content of status_reg (ERROR bit has to be set) and error_reg 1N/A * fields of the sata_cmd structure have to be set and will be used 1N/A * by SATA HBA Framework to determine the error cause. 1N/A * SATA_PKT_PORT_ERROR - cmd failed because of a link or a port error. 1N/A * Link failed / no communication with a device / communication error 1N/A * or other port related error was detected by a controller. 1N/A * SATA_PKT_ABORTED - cmd execution was aborted by the request from the 1N/A * framework. Abort mechanism is HBA driver specific. 1N/A * SATA_PKT_TIMEOUT - cmd execution has timed-out. Timeout specified by 1N/A * pkt_time was exceeded. The command was terminated by the SATA HBA 1N/A * SATA_PKT_COMPLETED - this is a value returned when an operation 1N/A * completes without errors. 1N/A * SATA_PKT_BUSY - packet was not accepted for execution because the 1N/A * driver was busy performing some other operation(s). 1N/A * SATA_PKT_RESET - packet execution was aborted because of device 1N/A * reset originated by either the HBA driver or the SATA framework. 1N/A * Error retrieval sata packet types 1N/A * Hoplug functions vector structure (rev 1) 1N/A * Power management functions vector structure (rev 1) 1N/A * The embedded function returns information about the controller's 1N/A * Additional functions may be added in the future without changes to 1N/A * sata_tran structure. 1N/A * SATA port PHY Power Level 1N/A * These states correspond to the interface power management state as defined 1N/A * in Serial ATA spec. 1N/A * SATA HBA Tran structure (rev 1) 1N/A * Registered with SATA Framework 1N/A * dma_attr is a pointer to data (buffer) dma attibutes of the controller 1N/A * The qdepth field specifies number of commands that may be accepted by 1N/A * the controller. Value range 1-32. A value greater than 1 indicates that 1N/A * the controller supports queuing. Support for Native Command Queuing 1N/A * indicated by SATA_CTLF_NCQ flag also requires qdepth set to a value 1N/A /* Hotplug vector */ 1N/A /* Power mgt vector */ 1N/A * Controller's features support flags (sata_tran_hba_features_support). 1N/A * Note: SATA_CTLF_NCQ indicates that SATA controller supports NCQ in addition 1N/A * to legacy queuing commands, indicated by SATA_CTLF_QCMD flag. 1N/A * sata_tran_start() return values. 1N/A * When pkt is not accepted, the satapkt_reason has to be updated 1N/A * before function returns - it should reflect the same reason for not being 1N/A * executed as the return status of above functions. 1N/A * If pkt was accepted and executed synchronously, 1N/A * satapk_reason should indicate a completion status. 1N/A * sata_tran_abort() abort type flag 1N/A * Events handled by SATA HBA Framework 1N/A * More then one event may be reported at the same time 1N/A * SATA_EVNT__DEVICE_ATTACHED 1N/A * HBA detected the presence of a device ( electrical connection with 1N/A * a device was detected ). 1N/A * SATA_EVNT_DEVICE_DETACHED 1N/A * HBA detected the detachment of a device (electrical connection with 1N/A * a device was broken) 1N/A * SATA_EVNT_LINK_LOST 1N/A * HBA lost link with an attached device 1N/A * SATA_EVNT_LINK_ESTABLISHED 1N/A * HBA established a link with an attached device 1N/A * SATA_EVNT_PORT_FAILED 1N/A * HBA has determined that the port failed and is unuseable 1N/A * SATA_EVENT_DEVICE_RESET 1N/A * SATA device was reset, causing loss of the device setting 1N/A * SATA_EVNT_PWR_LEVEL_CHANGED 1N/A * A port or entire SATA controller power level has changed 1N/A * SATA Framework interface entry points 1N/A#
endif /* _SATA_HBA_H */