[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Kernel Extensions and Device Support Programming Concepts

FCP Adapter Device Driver Routines

This section describes the following routines:

config

The config routine performs all of the processing needed to configure, unconfigure, and read Vital Product Data (VPD) for the FCP adapter. When this routine is called to configure an adapter, it performs the required checks and building of data structures needed to prepare the adapter for the processing of requests.

When asked to unconfigure or terminate an adapter, this routine deallocates any structures defined for the adapter and marks the adapter as unconfigured. This routine can also be called to return the Vital Product Data for the adapter, which contains information that is used to identify the serial number, change level, or part number of the adapter.

open

The open routine establishes a connection between a special file and a file descriptor. This file descriptor is the link to the special file that is the access point to a device and is used by all subsequent calls to perform I/O requests to the device. Interrupts are enabled and any data structures needed by the adapter driver are also initialized.

close

The close routine marks the adapter as closed and disables all future interrupts, which causes the driver to reject all future requests to this adapter.

openx

The openx routine allows a process with the proper authority to open the adapter in diagnostic mode. If the adapter is already open in either normal or diagnostic mode, the openx subroutine has a return value of -1. Improper authority results in an errno value of EPERM,while an already open error results in an errno value of EACCES. If the adapter is in diagnostic mode, only the close and ioctl routines are allowed. All other routines return a value of -1 and an errno value of EACCES.

While in diagnostics mode, the adapter can run diagnostics, run wrap tests, and download microcode. The openx routine is called with an ext parameter that contains the adapter mode and the SC_DIAGNOSTIC value, both of which are defined in the sys/scsi.h header file.

strategy

The strategy routine is the link between the device driver and the FCP adapter device driver for all normal I/O requests. Whenever the FCP device driver receives a call, it builds an scsi_buf structure with the correct parameters and then passes it to this routine, which in turn queues up the request if necessary. Each request on the pending queue is then processed by building the necessary FCP commands required to carry out the request. When the command has completed, the FCP device driver is notified through the iodone kernel service.

ioctl

The ioctl routine allows various diagnostic and nondiagnostic adapter operations. Operations include the following:

start

The start routine is responsible for checking all pending queues and issuing commands to the adapter. When a command is issued to the adapter, the scsi_buf is converted into an adapter specific request needed for the scsi_buf. At this time, the bufstruct.b_addr for the scsi_buf will be mapped for DMA. When the adapter specific request is completed, the adapter will be notified of this request.

interrupt

The interrupt routine is called whenever the adapter posts an interrupt. When this occurs, the interrupt routine will find the scsi_buf corresponding to this interrupt. The buffer for the scsi_buf will be unmapped from DMA. If an error occurred, the status_validity, scsi_status, and adapter_status fields will be set accordingly. The bufstruct.b_resid field will be set with the number of nontransferred bytes. The interrupt handler will then iodone this scsi_buf, which will send the scsi_buf back to the device driver which originated it.

Related Information

For specific information about the FCP adapter device driver operations, see FCP Adapter ioctl Operations.

An introduction to the FCP subsystem is provided by Programming FCP Device Drivers.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]