Target- and Initiator-Mode ioctl Commands

For either target or initiator mode, the SCSI device driver can issue an SCIOEVENT ioctl operation to register for receiving asynchronous event status from the SCSI adapter device driver for a particular device instance. This is an optional call for the SCSI device driver, and is optionally supported for the SCSI adapter device driver. A failing return code from this command, in the absence of any programming error, indicates it is not supported. If the SCSI device driver requires this function, it must check the return code to verify the SCSI adapter device driver supports it.

Only a kernel process or device driver can invoke these ioctls. If attempted by a user process, the ioctl will fail, and the errno global variable will be set to EPERM.

The event registration performed by this ioctl operation is allowed once per device session. Only the first SCIOEVENT ioctl operation is accepted after the device session is opened. Succeeding SCIOEVENT ioctl operations will fail, and the errno global variable will be set to EINVAL. The event registration is canceled automatically when the device session is closed.

The arg parameter to the SCIOEVENT ioctl operation should be set to the address of an sc_event_struct structure, which is defined in the /usr/include/sys/scsi.h file. The following parameters are supported:

Item Description
id The caller sets id to the SCSI ID of the attached SCSI target device for initiator-mode. For target-mode, the caller sets the id to the SCSI ID of the attached SCSI initiator device.
lun The caller sets the lun field to the SCSI LUN of the attached SCSI target device for initiator-mode. For target-mode, the caller sets the lun field to 0.
mode Identifies whether the initiator- or target-mode device is being registered. These values are possible:
SC_IM_MODE
This is an initiator mode device.
SC_TM_MODE
This is a target mode device.
async_correlator The caller places a value in this optional field, which is saved by the SCSI adapter device driver and returned when an event occurs in this field in the sc_event_info structure. This structure is defined in the /user/include/sys/scsi.h file.
async_func The caller fills in the address of a pinned routine that the SCSI adapter device driver calls whenever asynchronous event status is available. The SCSI adapter device driver passes a pointer to a sc_event_info structure to the caller's async_func routine.
Note: All reserved fields should be set to 0 by the caller.

The following values for the errno global variable are supported:

Item Description
0 Indicates successful completion.
EINVAL Either an SCIOSTART or SCIOSTARTTGT has not been issued to this device instance, or this device is already registered for async events.
EPERM Indicates the caller is not running in kernel mode, which is the only mode allowed to run this operation.