[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Kernel Extensions and Device Support Programming Concepts

FCP and iSCSI Adapter and Device Interface

The adapter device driver does not contain the ddread and ddwrite entry points, but does contain the ddconfig, ddopen, ddclose, dddump, and ddioctl entry points.

Therefore, the adapter device driver's entry in the kernel devsw table contains only those entries plus an additional ddstrategy entry point. This ddstrategy routine is the path that the device driver uses to pass commands to the device driver. Access to these entry points is possible through the following kernel services:

The adapter is accessed by the device driver through the /dev/fscsi# special files, where # indicates ascending numbers 0,1, 2, and so on. The adapter is designed so that multiple devices on the same adapter can be accessed at the same time.

The iSCSI adapter is accessed by the device driver through the /dev/iscsin special files, where n indicates ascending numbers 0, 1, 2, and so on. The adapter is designed so that multiple devices on the same adapter can be accessed at the same time.

For additional information on spanned and gathered write commands, see Understanding the Execution of FCP and iSCSI Initiator I/O Requests.

scsi_buf Structure

The I/O requests made from the device driver to the adapter device driver are completed through the use of the scsi_buf structure, which is defined in the /usr/include/sys/scsi_buf.h header file. This structure, which is similar to the buf structure in other drivers, is passed between the two subsystem drivers through the strategy routine. The following is a brief description of the fields contained in the scsi_buf structure:

Adapter and Device Driver Intercommunication

In a typical request to the device driver, a call is first made to the device driver's strategy routine, which takes care of any necessary queuing. The device driver's strategy routine then calls the device driver's start routine, which fills in the scsi_buf structure and calls the adapter driver's strategy routine through the devstrat kernel service.

The adapter driver's strategy routine validates all of the information contained in the scsi_buf structure and also performs any necessary queuing of the transaction request. If no queuing is necessary, the adapter driver's start subroutine is called.

When an interrupt occurs, adapter driver interrupt routine fills in the status_validity field and the appropriate scsi_status or adapter_status field of the scsi_buf structure. The bufstruct.b_resid field is also filled in with the value of nontransferred bytes. The adapter driver's interrupt routine then passes this newly filled in scsi_buf structure to the iodone kernel service, which then signals the device driver's iodone subroutine. The adapter driver's start routine is also called from the interrupt routine to process any additional transactions on the queue.

The device driver's iodone routine should then process all of the applicable fields in the queued scsi_buf structure for any errors and attempt error recovery if necessary. The device driver should then dequeue the scsi_buf structure and then pass a pointer to the structure back to the iodone kernel service so that it can notify the originator of the request.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]