Use the open, openx, close, read, readx, write, writex, and ioctl subroutines to implement Direct Access Storage Device (DASD) operations. Observe the special considerations for using these subroutines:
The openx subroutine is intended primarily for use by diagnostic commands and utilities. Appropriate authority is required for execution. Attempting to execute this subroutine without the proper authority results in a return value of -1, with the errno global variable set to EACCES.
The ext parameter passed to the openx subroutine selects the operation to be used for the target adapter. The /usr/include/sys/scsi.h file defines the following possible values for the ext parameter:
This mode of operation is transparent to the rest of the system. A diagnostic open does not fail if the only open to an adapter is the daemon open, and the daemon open does not fail if an adapter is in Diagnostic mode. However, when an adapter is placed in Diagnostic mode, all queuing of asynchronous events to the daemon is filtered. The Daemon mode provides the authority needed to perform microcode downloads to the adapter and controller.
The ioctl subroutine can call the IOCINFO, SD_SCSICMD, and SD_RESET operations.
The IOCINFO operation is the only operation defined for all device drivers that use the ioctl subroutine. The IOCINFO operation returns the devinfo structure defined in the /usr/include/sys/devinfo.h file. This ioctl operation can be directed to an adapter, controller, or DASD. The device can be opened in normal mode for this ioctl operation.
When the device has been successfully opened in Diagnostic mode, the SD_SCSICMD operation provides the means for issuing any Serial DASD subsystem command to a specified device. The Serial DASD subsystem commands are modeled after those for SCSI. The following Serial DASD subsystem commands are valid and use the same command descriptor block, including the operation code, as their corresponding SCSI command. The SCSI commands are defined in the /usr/include/sys/scsi.h file:
The following Serial DASD subsystem commands can be issued when the device is not in Diagnostic mode, but the caller has root authority:
The Serial DASD Fence command does not correspond with any SCSI command. For more information, see "Serial DASD Fence Command" .
If the SD_SCSICMD operation is issued with any other Serial DASD subsystem command and the device is not in Diagnostic mode, the SD_SCSICMD operation returns a value of -1 and sets the errno global variable to a value of EACCES. The device driver performs no error recovery or error logging when this ioctl operation fails. The status_validity byte, scsi_bus_status byte, and the adapter_status byte are returned via the arg parameter. This parameter contains the address of a sc_iocmd structure, which is defined in the /usr/include/sys/scsi.h file.
The devinfo structure, which is returned from the IOCINFO ioctl operation, defines the maximum transfer size for the command. The structure returns a value of -1 and sets the errno global variable to a value of EINVAL if an attempt is made to transfer more than the maximum transfer size. If the Serial DASD subsystem command cannot complete in the time specified in the sc_iocmd structure, a -1 value is returned and the errno global variable is set to a value of ETIMEDOUT.
The SD_SCSICMD operation uses the sc_iocmd structure with the following status validity values:
Value | Description |
---|---|
0x00 | Command successful |
0x01 | Valid scsi_bus_status byte only |
0x02 | Valid adapter status only |
0x04 | Valid alert register contents |
The SD_SCSICMD operation also uses the following reserved fields:
The SD_RESET operation provides an interface for issuing resets and quiesces to the Serial DASD adapter. The adapter is the /dev/serdasdaN file, where N is 0 or a positive integer. To send a reset or quiesce operation to an adapter, the adapter must be opened in SC_DIAGNOSTIC mode. The arg parameter of the ioctl call is a pointer to a sd_ioctl_parms structure, which is defined in the /usr/include/sys/serdasd.h file.
If the SD_RESET ioctl is issued when the device is not in Diagnostic mode, the ioctl returns a value of -1 and sets the errno global variable to a value of EACCES. If the Serial DASD adapter does not respond to the SD_RESET ioctl, a value of -1 is return, and the errno global variable is set to a value of EIO.
The following fields of the sd_ioctl_parms structure are used with this ioctl command.
The ioctl subroutine, open, openx subroutine.
Serial DASD Subsystem Device Driver.
Device-Dependent Subroutines for Serial DASD Operations.
Device-Dependent Subroutines for Serial DASD Controller Operations.
Error Conditions for Serial DASD Subroutines.
Reliability, Availability, and Serviceability (RAS) Daemon for the Serial DASD Subsystem.
Serial DASD Concurrent Mode of Operation Interface.
Serial Direct Access Storage Device (DASD) Overview in AIX 5L Version 5.2 Kernel Extensions and Device Support Programming Concepts.