[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


B    SCSI/CAM Routines

This appendix contains a description of each of the routines described in this guide, in reference-page format. The routines are included in alphabetical order.


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


cam_logger


Name

cam_logger - Allocates a system error log buffer and fills in a uerf error log packet


Syntax

u_long cam_logger (cam_err_hdr, bus, target, lun)
CAM_ERR_HDR *cam_err_hdr;
long bus;
long target;
long lun;


Arguments

cam_err_hdr
Pointer to the Error Header structure.

bus
SCSI target's bus controller number.

target
SCSI target's ID number.

lun
SCSI target's logical unit number.


Description

The cam_logger routine allocates a system error log buffer and fills in a uerf error log packet. The routine fills in the bus, target, and LUN information from the Error Header structure passed to it and copies the Error Header structure and the Error Entry structures and data to the error log buffer.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccfg_attach


Name

ccfg_attach - Calls a SCSI/CAM peripheral driver's attach routine after a match on the cpd_name member of the CAM_PERIPHERAL_DRIVER structure is found


Syntax

int ccfg_attach (attach)
struct device *attach;


Arguments

attach
Pointer to the device information contained in the device structure.


Description

The ccfg_attach routine calls a SCSI/CAM peripheral driver's attach routine after a match on the cpd_name member of the CAM_PERIPHERAL_DRIVER structure is found. The routine is called during autoconfiguration. The ccfg_attach routine locates the configured driver in the SCSI/CAM peripheral driver configuration table. If the driver is located successfully, the SCSI/CAM peripheral driver's attach routine is called with a pointer to the unit information structure for the device from the kernel device structure. The SCSI/CAM peripheral driver's attach routine performs its own attach initialization.


Return Value

0 = success
1 = failure
The return value is ignored by autoconfiguration code.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccfg_edtscan


Name

ccfg_edtscan - Issues SCSI INQUIRY commands to all possible SCSI targets and LUNs attached to a bus or a particular bus/target/lun


Syntax

U32 ccfg_edtscan (scan_type, bus, target, lun)
long scan_type;
long bus;
long target;
long lun;


Arguments

scan_type
Types of scans are: EDT_FULLSCAN, which traverses the CAM_EDT_ENTRY structure and sends an INQUIRY command to each target and LUN; EDT_PARTSCAN, which sends an INQUIRY command only to targets and LUNs flagged as ``not found''; and EDT_SINGLESCAN, which sends an INQUIRY command to the selected bus, target, and LUN passed as arguments.

bus
SCSI target's bus controller number.

target
SCSI target's ID number.

lun
SCSI target's logical unit number.


Description

The ccfg_edtscan routine issues SCSI INQUIRY commands to all possible SCSI targets and LUNs attached to a bus or a particular bus/target/lun. The routine uses the CAM subsystem in the normal manner by sending SCSI I/O CCBs to the SIMs. The INQUIRY data returned is stored in the EDT structures and the cam_tlun_found flag is set. SCSI/CAM peripheral device drivers can call this routine to reissue a full, partial, or single bus scan command.


Return Value

CAM_SUCCESS
CAM_FAILURE


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccfg_slave


Name

ccfg_slave - Calls a SCSI/CAM peripheral driver's slave routine after a match on the cpd_name member of the CAM_PERIPHERAL_DRIVER structure is found


Syntax

int ccfg_slave (attach, csr)
struct device *attach;
caddr_t csr;


Arguments

attach
Pointer to the device information contained in the device structure.

csr
The virtual address of the control and status register (CSR) address.


Description

The ccfg_slave routine calls a SCSI/CAM peripheral driver's slave routine after a match on the cpd_name member of the CAM_PERIPHERAL_DRIVER structure is found. The routine is called during autoconfiguration. The ccfg_slave routine locates the configured driver in the SCSI/CAM peripheral driver configuration table. If the driver is located successfully, the SCSI/CAM peripheral driver's slave routine is called with a pointer to the unit information structure for the device from the kernel device structure and the virtual address of its control and status register (CSR). The SCSI/CAM peripheral driver's slave routine performs its own slave initialization.


Return Value

0 = slave is alive
1 = slave is not alive


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_abort_ccb_bld


Name

ccmn_abort_ccb_bld - Creates an ABORT CCB and sends it to the XPT


Syntax

CCB_ABORT * ccmn_abort_ccb_bld (dev, cam_flags, abort_ccb)
dev_t dev;
u_long cam_flags;
CCB_HEADER *abort_ccb;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before. terminating I/O
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

abort_ccb
Pointer to the CAM control block (CCB) header structure to abort.


Description

The ccmn_abort_ccb_bld routine creates an ABORT CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine fills in the address of the CCB to be aborted and calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_ABORT pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_abort_que


Name

ccmn_abort_que - Sends an ABORT CCB request for each SCSI I/O CCB on the active queue


Syntax

void ccmn_abort_que (pd)
PDRV_DEVICE *pd;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.


Description

The ccmn_abort_que routine sends an ABORT CCB request for each SCSI I/O CCB on the active queue. This routine must be called with the Peripheral Device structure locked.

The ccmn_abort_que routine calls the ccmn_abort_ccb_bld routine to create an ABORT CCB for the first active CCB on the active queue and to send it to the XPT. It calls the ccmn_send_ccb routine to send the ABORT CCB for each of the other CCBs on the active queue that are marked as active to the XPT. The ccmn_abort_que routine then calls the ccmn_rel_ccb routine to return the ABORT CCB to the XPT.


Return Value

None


See Also

ccmn_abort_ccb_bld, ccmn_rel_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_attach_device


Name

ccmn_attach_device - Creates and attaches a device structure to the controller structure that corresponds to the SCSI controller


Syntax

void ccmn_attach_device (dev, dev_type, dev_name)
dev_t dev;
caddr_t dev_type;
caddr_t dev_name;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

dev_type
Pointer to the device-type string, for example, "disk" or "tape".

dev_name
Pointer to the device-name string as it appears in the /dev directory, for example, "rz0".


Description

The ccmn_attach_device routine creates and attaches a device structure to the controller structure that corresponds to the SCSI controller. The routine finds the controller structure for a device, fills in the device structure, and attaches the device structure to the controller structure.


Return Value

None


See Also

ccmn_errlog , ccmn_find_ctlr


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_bdr_ccb_bld


Name

ccmn_bdr_ccb_bld - Creates a BUS DEVICE RESET CCB and sends it to the XPT


Syntax

CCB_RESETDEV * ccmn_bdr_ccb_bld (dev, cam_flags)
dev_t dev;
u_long cam_flags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.


Description

The ccmn_bdr_ccb_bld routine creates a BUS DEVICE RESET CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_RESETDEV pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_br_ccb_bld


Name

ccmn_br_ccb_bld - Creates a BUS RESET CCB and sends it to the XPT


Syntax

CCB_RESETBUS * ccmn_br_ccb_bld (dev, cam_flags)
dev_t dev;
u_long cam_flags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.


Description

The ccmn_br_ccb_bld routine creates a BUS RESET CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_RESETBUS pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_ccb_status


Name

ccmn_ccb_status - Assigns individual CAM status values to generic categories


Syntax

int ccmn_ccb_status (ccb)
CCB_HEADER *ccb;


Arguments

ccb
Pointer to the CAM control block (CCB) header structure whose status is to be categorized.


Description

The ccmn_ccb_status routine assigns individual CAM status values to generic categories. The following table shows the returned category for each CAM status value:
CAM Status Assigned Category
CAM_REQ_INPROG CAT_INPROG
CAM_REQ_CMP CAT_CMP
CAM_REQ_ABORTED CAT_ABORT
CAM_UA_ABORT CAT_ABORT
CAM_REQ_CMP_ERR CAT_CMP_ERR
CAM_BUSY CAT_BUSY
CAM_REQ_INVALID CAT_CCB_ERR
CAM_PATH_INVALID CAT_NO_DEVICE
CAM_DEV_NOT_THERE CAT_NO_DEVICE
CAM_UA_TERMIO CAT_ABORT
CAM_SEL_TIMEOUT CAT_DEVICE_ERR
CAM_CMD_TIMEOUT CAT_DEVICE_ERR
CAM_MSG_REJECT_REC CAT_DEVICE_ERR
CAM_SCSI_BUS_RESET CAT_RESET
CAM_UNCOR_PARITY CAT_DEVICE_ERR
CAM_AUTOSENSE_FAIL CAT_BAD_AUTO
CAM_NO_HBA CAT_NO_DEVICE
CAM_DATA_RUN_ERR CAT_DEVICE_ERR
CAM_UNEXP_BUSFREE CAT_DEVICE_ERR
CAM_SEQUENCE_FAIL CAT_DEVICE_ERR
CAM_CCB_LEN_ERR CAT_CCB_ERR
CAM_PROVIDE_FAIL CAT_CCB_ERR
CAM_BDR_SENT CAT_RESET
CAM_REQ_TERMIO CAT_ABORT
CAM_LUN_INVALID CAT_NO_DEVICE
CAM_TID_INVALID CAT_NO_DEVICE
CAM_FUNC_NOTAVAIL CAT_CCB_ERR
CAM_NO_NEXUS CAT_NO_DEVICE
CAM_IID_INVALID CAT_NO_DEVICE
CAM_SCSI_BUSY CAT_SCSI_BUSY
Other CAT_UNKNOWN


Return Value

The following categories can be returned:
CAM Status Assigned Category
CAT_INPROG Request is in progress.
CAT_CMP Request has completed without error.
CAT_CMP_ERR Request has completed with error.
CAT_ABORT Request either has been aborted or terminated, or it cannot be aborted or terminated.
CAT_BUSY CAM is busy.
CAT_SCSI_BUSY SCSI is busy.
CAT_NO_DEVICE No device at address specified in request.
CAT_DEVICE_ERR Bus or device problems.
CAT_BAD_AUTO Invalid autosense data.
CAT_CCB_ERR Invalid CCB.
CAT_RESET Unit or bus has detected a reset condition.
CAT_UNKNOWN Invalid CAM status.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_check_idle


Name

ccmn_check_idle - Checks that there are no opens against a device


Syntax

void ccmn_check_idle (start_unit, num_units, cmajor, bmajor, spec_size)
U32 start_unit;
U32 num_units;
dev_t cmajor;
dev_t bmajor;
U32 spec_size;


Arguments

start_unit
The address (bus, target, and LUN) of the first unit to check for opens.

num_units
The number of units to check for opens.

cmajor
The character device major number.

bmajor
The block device major number.

spec_size
The size of the device-specific structure for the device.


Description

The ccmn_check_idle routine checks that there are no opens against a device. This routine calls the ccmn_rel_dbuf routine to deallocate all structures pertaining to the device whose driver is being unloaded.

The ccmn_check_idle routine scans the Peripheral Device Unit Table looking for devices that match the block device major number and the character device major number in the PDRV_DEVICE structure members pd_bmajor and pd_cmajor. If no opens exist for the devices that are to be unloaded, it rescans the Peripheral Device Unit Table and deallocates all structures relating to the devices whose driver is being unloaded. The ccmn_check_idle routine must be called with the Peripheral Device Unit Table locked.


Return Value

None


See Also

ccmn_rel_dbuf


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_close_unit


Name

ccmn_close_unit - Handles the common close for all SCSI/CAM peripheral device drivers


Syntax

void ccmn_close_unit (dev)
dev_t dev;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.


Description

The ccmn_close_unit routine handles the common close for all SCSI/CAM peripheral device drivers. It sets the open count to zero.


Return Value

None


See Also

ccmn_open_unit


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_DoSpecialCmd


Name

ccmn_DoSpecialCmd - Provides a simplified interface to the special command routine


Syntax

int ccmn_DoSpecialCmd (dev, cmd, data, flags, ccb, sflags)
dev_t dev;
int cmd;
caddr_t data;
int flags;
CCB_SCSIIO *ccb;
int sflags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cmd
The ioctl command such as SCSI_FORMAT_UNIT. The ioctl commands are defined in /usr/sys/include/io/cam/rzdisk.h.

data

The user data buffer.

flags
Flags set when a file is open.

ccb
Pointer to the SCSI I/O CCB structure or NULL.

sflags
SCSI/CAM special I/O control flags. Setting this field is optional. The available bits are:
Flag Name Description
SA_NO_ERROR_RECOVERY Do not perform error recovery.
SA_NO_ERROR_LOGGING Do not log error messages.
SA_NO_SLEEP_INTR Do not allow sleep interrupts.
SA_NO_SIMQ_THAW Leave SIM queue frozen when there are errors.
SA_NO_WAIT_FOR_IO Do not wait for I/O to complete.


Description

The ccmn_DoSpecialCmd routine provides a simplified interface to the special command routine. The routine prepares for and issues special SCSI ioctl commands.


Return Value

The ccmn_DoSpecialCmd routine returns a value of 0 (zero) upon successful completion. It returns the appropriate error code on failure.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_errlog


Name

ccmn_errlog - Reports error conditions for the SCSI/CAM peripheral device driver


Syntax

void ccmn_errlog (func_str, opt_str, flags, ccb, dev, unused)
u_char *func_str;
u_char *opt_str;
u_long flags;
CCB_HEADER *ccb;
dev_t dev;
u_char *unused;


Arguments

func_str
Pointer to function in which the error was detected.

opt_str
Pointer to optional logging string.

flags
Flags for peripheral drivers error types. The flags are: CAM_INFORMATIONAL, CAM_SOFTERR, CAM_HARDERR, CAM_SOFTWARE, and CAM_DUMP_ALL. They are defined in the /usr/sys/include/io/cam/cam_logger.h file.

ccb
Pointer to the CAM control block (CCB) header structure.

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

unused
Unused. It is needed to match the number of arguments expected by the CAM_ERROR macro, which is defined in the /usr/sys/include/io/cam/cam_errlog.h file


Description

The ccmn_errlog routine reports error conditions for the SCSI/CAM peripheral device driver. The routine is passed a pointer to the name of the function in which the error was detected. The routine builds informational strings based on the error condition.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_find_ctlr


Name

ccmn_find_ctlr - Finds the controller structure that corresponds to the SCSI controller that the device must be attached to


Syntax

struct controller * ccmn_find_ctlr (dev)
dev_t dev;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.


Description

The ccmn_find_ctlr routine finds the controller structure that corresponds to the SCSI controller that the device must be attached to. This routine must be called with the Peripheral Device Unit Table locked.


Return Value

Controller for the device or NULL if no controller is found.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_gdev_ccb_bld


Name

ccmn_gdev_ccb_bld - Creates a GET DEVICE TYPE CCB and sends it to the XPT


Syntax

CCB_GETDEV * ccmn_gdev_ccb_bld (dev, cam_flags, inq_addr)
dev_t dev;
u_long cam_flags;
u_char *inq_addr;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

inq_addr
Pointer to the address for Inquiry data returned.


Description

The ccmn_gdev_ccb_bld routine creates a GET DEVICE TYPE CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The ccmn_gdev_ccb_bld routine calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_GETDEV pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_get_bp


Name

ccmn_get_bp - Allocates a buf structure


Syntax

register struct buf * ccmn_get_bp()


Arguments

None


Description

The ccmn_get_bp routine allocates a buf structure. This function must not be called at interrupt context. The function may sleep while waiting for resources.


Return Value

Pointer to buf structure. This pointer may be NULL.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_get_ccb


Name

ccmn_get_ccb - Allocates a CCB and fills in the common portion of the CCB header


Syntax

CCB_HEADER * ccmn_get_ccb (dev, func_code, cam_flags, ccb_len)
dev_t dev;
u_char func_code;
u_long cam_flags;
u_short ccb_len;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

func_code
The XPT function code for the CCB. See American National Standard for Information Systems, SCSI-2 Common Access Method: Transport and SCSI Interface Module, working draft, X3T9.2/90-186, Section 8.1.2, for a list of the function codes.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

ccb_len
The length of the CCB.


Description

The ccmn_get_ccb routine allocates a CCB and fills in the common portion of the CCB header. The routine calls the xpt_ccb_alloc routine to allocate a CCB structure. The ccmn_get_ccb routine fills in the common portion of the CCB header and returns a pointer to that CCB_HEADER.


Return Value

Pointer to newly allocated CCB header.


See Also

xpt_ccb_alloc


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_get_dbuf


Name

ccmn_get_dbuf - Allocates a data buffer area of the size specified by calling the kernel memory allocation routines


Syntax

char * ccmn_get_dbuf (size)
u_long size;


Arguments

size

Size of buffer (in bytes).


Description

The ccmn_get_dbuf routine allocates a data buffer area of the size specified by calling the kernel memory allocation routines.


Return Value

Pointer to kernel data space. If this is NULL, no data buffers are available and no more can be allocated.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_init


Name

ccmn_init - Initializes the XPT and the unit table lock structure


Syntax

void ccmn_init()


Arguments

None


Description

The ccmn_init routine initializes the XPT and the unit table lock structure. The first time the ccmn_init routine is called, it calls the xpt_init routine to request the XPT to initialize the CAM subsystem.


Return Value

None


See Also

xpt_init


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_io_ccb_bld


Name

ccmn_io_ccb_bld - Allocates a SCSI I/O CCB and fills it in


Syntax

CCB_SCSIIO * ccmn_io_ccb_bld (dev, data_addr, data_len, sense_len, cam_flags, comp_func, tag_action, timeout, bp)
dev_t dev;
u_char *data_addr;
u_long data_len;
u_short sense_len;
u_long cam_flags;
void (*comp_func)();
u_char tag_action;
u_long timeout;
struct buf *bp;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

data_addr
Pointer to the data buffer.

data_len
Size of the data transfer.

sense_len
Length of the sense data buffer to be returned on autosense, which is predefined as 64 bytes in the DEC_AUTO_SENSE_SIZE environment variable but can be larger.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

comp_func
SCSI device driver I/O callback completion function. This pointer may be NULL if the CAM DISABLE CALLBACK bit is set in the CAM FLAGS field.

tag_action
Type of action to perform for tagged requests:
CAM_SIMPLE_QTAG Tag for simple queue
CAM_HEAD_QTAG Tag for head of queue
CAM_ORDERED_QTAG Tag for ordered queue

timeout
Timeout for the request (in seconds). A value of 0 (zero) indicates the default, which is 5 seconds.

bp
A buf structure pointer, which is used for request mapping. This pointer may be NULL.


Description

The ccmn_io_ccb_bld routine allocates a SCSI I/O CCB and fills it in. The routine calls the ccmn_get_ccb routine to obtain a CCB structure with the header portion filled in. The ccmn_io_ccb_bld routine fills in the SCSI I/O-specific fields from the parameters passed and checks the length of the sense data to see if it exceeds the length of the reserved sense buffer. If it does, a sense buffer is allocated using the ccmn_get_dbuf routine.


Return Value

Pointer to a SCSI I/O CCB


See Also

ccmn_get_ccb, ccmn_get_dbuf


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_mode_select


Name

ccmn_mode_select - Creates a SCSI I/O CCB for the MODE SELECT command, sends it to the XPT for processing, and sleeps while waiting for it to complete.


Syntax

CCB_SCSIIO* ccmn_mode_select (pd, sense_len, cam_flags, comp_func, tag_action, timeout, ms_index)
PDRV_DEVICE *pd;
u_short sense_len;
u_long cam_flags;
void (*comp_func)();
u_char tag_action;
u_long timeout;
unsigned ms_index;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

sense_len
Length of the sense data buffer to be returned on autosense, which is predefined as 64 bytes in the DEC_AUTO_SENSE_SIZE environment variable but can be larger.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

comp_func
SCSI device driver I/O callback completion function. This pointer may be NULL if the CAM DISABLE CALLBACK bit is set in the CAM FLAGS field.

tag_action
Type of action to perform for tagged requests:
CAM_SIMPLE_QTAG Tag for simple queue
CAM_HEAD_QTAG Tag for head of queue
CAM_ORDERED_QTAG Tag for ordered queue

timeout
Timeout for the request (in seconds). A value of 0 (zero) indicates the default, which is 5 seconds.

ms_index
An index into a page in the Mode Select Table that is pointed to in the Device Descriptor structure.


Description

The ccmn_mode_select routine creates a SCSI I/O CCB for the MODE SELECT command and sends it to the XPT for processing. The routine calls the ccmn_io_ccb_bld routine to obtain a SCSI I/O CCB structure. It uses the ms_index parameter to index into the Mode Select Table pointed to by the dd_modsel_tbl member of the Device Descriptor structure for the SCSI device. The ccmn_mode_select routine calls the ccmn_send_ccb_wait routine to send the SCSI I/O CCB to the XPT and wait for it to complete. The ccmn_mode_select routine sleeps at a noninterruptible priority. It requires the callback completion function to issue a wakeup call on the address of the CCB.


Return Value

CCB_SCSIIO pointer


See Also

ccmn_io_ccb_bld, ccmn_send_ccb_wait


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_open_unit


Name

ccmn_open_unit - Handles the common open for all SCSI/CAM peripheral device drivers


Syntax

int ccmn_open_unit (dev, scsi_dev_type, flag, dev_size)
dev_t dev;
u_long scsi_dev_type;
u_long flag;
u_long dev_size;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

scsi_dev_type
SCSI device type value from Inquiry data.

flag

Indicates whether or not the device is being opened for exclusive use. A setting of 1 means exclusive use; a setting of 0 (zero) means nonexclusive use.

dev_size
The device-specific structure size (in bytes).


Description

The ccmn_open_unit routine handles the common open for all SCSI/CAM peripheral device drivers. It must be called for each open before any SCSI device-specific open code is executed.

On the first call to the ccmn_open_unit routine for a device, the ccmn_gdev_ccb_bld routine is called to issue a GET DEVICE TYPE CCB to obtain the Inquiry data. The ccmn_open_unit routine allocates the Peripheral Device structure, PDRV_DEVICE, and a device-specific structure, either TAPE_SPECIFIC or DISK_SPECIFIC, based on the device size argument passed. The routine also searches the cam_devdesc_tab to obtain a pointer to the Device Descriptor structure for the SCSI device and increments the open count. The statically allocated pdrv_unit_table structure contains a pointer to the PDRV_DEVICE structure. The PDRV_DEVICE structure contains pointers to the DEV_DESC structure and to the device-specific structure.


Return Value

The ccmn_open_unit routine returns a value of 0 (zero) upon successful completion.


Diagnostics

The ccmn_open_unit routine fails under the following conditions:

[EBUSY]
The device is already opened and the exclusive use bit is set.

[ENXIO]
The device does not exist or the scsi_dev_type parameter does not match the device type in the Inquiry data returned by GET DEVICE TYPE CCB. The scsi_dev_type was not configured.

[EFAULT]
The device requested would go beyond the size of the pdrv_unit_table.


See Also

ccmn_close_unit, ccmn_gdev_ccb_bld


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_pinq_ccb_bld


Name

ccmn_pinq_ccb_bld - Creates a PATH INQUIRY CCB and sends it to the XPT


Syntax

CCB_PATHINQ * ccmn_pinq_ccb_bld (dev, cam_flags)
dev_t dev;
u_long cam_flags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.


Description

The ccmn_pinq_ccb_bld routine creates a PATH INQUIRY CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and fill in the common portion of the CCB header. The routine calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_PATHINQ pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_rel_bp


Name

ccmn_rel_bp - Deallocates a buf structure


Syntax

void ccmn_rel_bp (bp)
struct buf *bp;


Arguments

bp
A buf structure pointer, which is used for request mapping.


Description

The ccmn_rel_bp routine deallocates a buf structure.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_rel_ccb


Name

ccmn_rel_ccb - Releases a CCB and returns the sense data buffer for SCSI I/O CCBs, if allocated


Syntax

void ccmn_rel_ccb (ccb)
CCB_HEADER *ccb;


Arguments

ccb
Pointer to the CAM control block (CCB) header structure to be released.


Description

The ccmn_rel_ccb routine releases a CCB and returns the sense data buffer for SCSI I/O CCBs, if allocated. The routine calls the xpt_ccb_free routine to release a CCB structure. For SCSI I/O CCBs, if the sense data length is greater than the default sense data length, the ccmn_rel_ccb routine calls the ccmn_rel_dbuf routine to return the sense data buffer to the data buffer pool.


Return Value

None


See Also

ccmn_rel_dbuf, xpt_ccb_free


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_rel_dbuf


Name

ccmn_rel_dbuf - Deallocates a data buffer


Syntax

void ccmn_rel_dbuf (addr, size)
u_char *addr;
U32 size;


Arguments

addr

Pointer to the address of the data buffer to deallocate.

size

Number of bytes to deallocate.


Description

The ccmn_rel_dbuf routine deallocates a data buffer.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_rem_ccb


Name

ccmn_rem_ccb - Removes a SCSI I/O CCB request from the SCSI/CAM peripheral driver active queue and starts a tagged request if a tagged CCB is pending


Syntax

void ccmn_rem_ccb (pd, ccb)
PDRV_DEVICE *pd;
CCB_SCSIIO *ccb;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

ccb
Pointer to the SCSI I/O CCB structure to remove from the active queue.


Description

The ccmn_rem_ccb routine removes a SCSI I/O CCB request from the SCSI/CAM peripheral driver active queue and starts a tagged request if a tagged CCB is pending. If a tagged CCB is pending, the ccmn_rem_ccb routine places the request on the active queue and calls the xpt_action routine to start the tagged request.


Return Value

None


See Also

xpt_action


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_rsq_ccb_bld


Name

ccmn_rsq_ccb_bld - Creates a RELEASE SIM QUEUE CCB and sends it to the XPT


Syntax

CCB_RELSIM * ccmn_rsq_ccb_bld (dev, cam_flags)
dev_t dev;
u_long cam_flags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.


Description

The ccmn_rsq_ccb_bld routine creates a RELEASE SIM QUEUE CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_RELSIM pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_sasy_ccb_bld


Name

ccmn_sasy_ccb_bld - Creates a SET ASYNCHRONOUS CALLBACK CCB and sends it to the XPT


Syntax

CCB_SETASYNC * ccmn_sasy_ccb_bld (dev, cam_flags, async_flags, callb_func, buf, buflen)
dev_t dev;
u_long cam_flags;
u_long async_flags;
void (*callb_func)();
u_char *buf;
u_char buflen;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

async_flags
Asynchronous callback CCB flags for registering a callback routine for a specific bus, target, and LUN. The flags are defined in the /usr/sys/include/io/cam/cam.h file.

callb_func
Asynchronous callback function.

buf
SCSI/CAM peripheral buffer for asynchronous information.

buflen
Allocated SCSI/CAM peripheral buffer length.


Description

The ccmn_sasy_ccb_bld routine creates a SET ASYNCHRONOUS CALLBACK CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine fills in the asynchronous fields of the CCB and calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_SETASYNC pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_sdev_ccb_bld


Name

ccmn_sdev_ccb_bld - Creates a SET DEVICE TYPE CCB and sends it to the XPT


Syntax

CCB_SETDEV * ccmn_sdev_ccb_bld (dev, cam_flags, scsi_dev_type)
dev_t dev;
u_long cam_flags;
u_char scsi_dev_type;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

scsi_dev_type
SCSI device type value from Inquiry data.


Description

The ccmn_sdev_ccb_bld routine creates a SET DEVICE TYPE CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine fills in the device type field of the CCB and calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_SETDEV pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_send_ccb


Name

ccmn_send_ccb - Sends CCBs to the XPT layer by calling the xpt_action routine


Syntax

int ccmn_send_ccb (pd, ccb, retry)
PDRV_DEVICE *pd;
CCB_HEADER *ccb;
u_char retry;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

ccb
Pointer to the CAM control block (CCB) header structure to be sent to the xpt_action routine to handle the request.

retry
Indicates whether this request is a retry of a request that is already on the active queue. A 1 indicates RETRY, and a 0 (zero) indicates NOT_RETRY.


Description

The ccmn_send_ccb routine sends CCBs to the XPT layer by calling the xpt_action routine. This routine must be called with the Peripheral Device structure locked.

For SCSI I/O CCBs that are not retries, the request is placed on the active queue. If the CCB is a tagged request and the tag queue size for the device has been reached, the request is placed on the tagged pending queue so that the request can be sent to the XPT at a later time. A high-water mark of half the queue depth for the SCSI device is used for tagged requests so that other initiators on the SCSI bus will not be blocked from using the device.


Return Value

Value returned from the xpt_action routine.


See Also

xpt_action


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_send_ccb_wait


Name

ccmn_send_ccb_wait - Sends CCBs to the XPT layer by calling the xpt_action routine and sleeps while waiting for the CCB to complete.


Syntax

int ccmn_send_ccb_wait (pd, ccb, retry, sleep-pri)
PDRV_DEVICE *pd;
CCB_HEADER *ccb;
u_char retry;
int sleep-pri;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

ccb
Pointer to the CAM control block (CCB) header structure to be sent to the xpt_action routine to handle the request.

retry
Indicates whether this request is a retry of a request that is already on the active queue. A 1 indicates RETRY, and a 0 (zero) indicates NOT_RETRY.

sleep-pri
Specifies the priority at which to sleep.


Description

The ccmn_send_ccb_wait routine sends CCBs to the XPT layer by calling the xpt_action routine. Then, it calls sleep to wait for the CCB to complete. The routine sleeps on the address of the CCB at the priority specified by sleep-pri. This routine requires the callback completion function for the SCSI I/O CCB to issue a wakeup call on the address of the CCB. The ccmn_send_ccb_wait routine should be called only to send SCSI I/O CCBs to the XPT layer. This routine must be called with the Peripheral Device structure locked.

For SCSI I/O CCBs that are not retries, the request is placed on the active queue. If the CCB is a tagged request and the tag queue size for the device has been reached, the request is placed on the tagged pending queue so that the request can be sent to the XPT at a later time. A high-water mark of half the queue depth for the SCSI device is used for tagged requests so that other initiators on the SCSI bus will not be blocked from using the device.


Return Value

The following values can be returned:
Value Description
EINTR The sleep was interrupted by a signal. This status can occur only if the sleep-priority is interruptible.
0 The CCB has completed either because it received the return value from xpt_action or because a wakeup was issued by the callback completion function.


See Also

xpt_action


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_start_unit


Name

ccmn_start_unit - Creates a SCSI I/O CCB for the START UNIT command, sends it to the XPT for processing, and sleeps while waiting for it to complete


Syntax

CCB_SCSIIO * ccmn_start_unit (pd, sense_len, cam_flags, comp_func, tag_action, timeout)
PDRV_DEVICE *pd;
u_short sense_len;
u_long cam_flags;
void (*comp_func)();
u_char tag_action;
u_long timeout;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

sense_len
Length of the sense data buffer to be returned on autosense, which is predefined as 64 bytes in the DEC_AUTO_SENSE_SIZE environment variable but can be larger.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

comp_func
SCSI device driver I/O callback completion function. This pointer may be NULL if the CAM DISABLE CALLBACK bit is set in the CAM FLAGS field.

tag_action
Type of action to perform for tagged requests:
CAM_SIMPLE_QTAG Tag for simple queue
CAM_HEAD_QTAG Tag for head of queue
CAM_ORDERED_QTAG Tag for ordered queue

timeout
Timeout for the request (in seconds). A value of 0 (zero) indicates the default, which is 5 seconds.


Description

The ccmn_start_unit routine creates a SCSI I/O CCB for the START UNIT command and sends it to the XPT for processing.

The ccmn_start_unit routine calls the ccmn_io_ccb_bld routine to obtain a SCSI I/O CCB structure. The ccmn_start_unit routine calls the ccmn_send_ccb_wait routine to send the SCSI I/O CCB to the XPT and wait for it to complete. The ccmn_start_unit routine sleeps at a noninterruptible priority. It requires the callback completion function to issue a wakeup call on the address of the CCB.


Return Value

CCB_SCSIIO pointer


See Also

ccmn_io_ccb_bld, ccmn_send_ccb_wait


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_SysSpecialCmd


Name

ccmn_SysSpecialCmd - Lets a system request issue of SCSI I/O commands to the SCSI/CAM special I/O interface


Syntax

ccmn_SysSpecialCmd (dev, cmd, data, flags, ccb, sflags)
dev_t dev;
int cmd;
caddr_t data;
int flags;
CCB_SCSIIO *ccb;
int sflags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cmd
The ioctl command. Refer to the commands defined in /usr/sys/include/io/cam/rzdisk.h.

data

The kernel data buffer.

flags
Flags set when a file is open.

ccb
Pointer to the SCSI I/O CCB structure. This field is optional.

sflags
SCSI/CAM special I/O control flags. The available flags are:
Flag Name Description
SA_NO_ERROR_RECOVERY Do not perform error recovery.
SA_NO_ERROR_LOGGING Do not log error messages.
SA_NO_SLEEP_INTR Do not allow sleep interrupts.
SA_NO_SIMQ_THAW Leave SIM queue frozen when there are errors.
SA_NO_WAIT_FOR_IO Do not wait for I/O to complete.


Description

The ccmn_SysSpecialCmd routine lets a system request issue of SCSI I/O commands to the SCSI/CAM special I/O interface. This permits existing SCSI commands to be issued from within kernel code.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_term_ccb_bld


Name

ccmn_term_ccb_bld - Creates a TERMINATE I/O CCB and sends it to the XPT


Syntax

CCB_TERMIO * ccmn_term_ccb_bld (dev, cam_flags, term_ccb)
dev_t dev;
u_long cam_flags;
CCB_HEADER *term_ccb;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

term_ccb
Pointer to the CAM control block (CCB) header structure to terminate.


Description

The ccmn_term_ccb_bld routine creates a TERMINATE I/O CCB and sends it to the XPT. The routine calls the ccmn_get_ccb routine to allocate a CCB structure and to fill in the common portion of the CCB header. The routine fills in the CCB to be terminated and calls the ccmn_send_ccb routine to send the CCB structure to the XPT. The request is carried out immediately, so it is not placed on the device driver's active queue.


Return Value

CCB_TERMIO pointer


See Also

ccmn_get_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_term_que


Name

ccmn_term_que - Sends a TERMINATE I/O CCB request for each SCSI I/O CCB on the active queue


Syntax

void ccmn_term_que (pd)
PDRV_DEVICE *pd;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.


Description

The ccmn_term_que routine sends a TERMINATE I/O CCB request for each SCSI I/O CCB on the active queue. This routine must be called with the Peripheral Device structure locked.

The ccmn_term_que routine calls the ccmn_term_ccb_bld routine to create a TERMINATE I/O CCB for the first active CCB on the active queue and send it to the XPT. It calls the ccmn_send_ccb routine to send the TERMINATE I/O CCB for each of the other CCBs on the active queue that are marked as active to the XPT. The ccmn_term_que routine then calls the ccmn_rel_ccb routine to return the TERMINATE I/O CCB to the XPT.


Return Value

None


See Also

ccmn_rel_ccb, ccmn_send_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ccmn_tur


Name

ccmn_tur - Creates a SCSI I/O CCB for the TEST UNIT READY command, sends it to the XPT for processing, and sleeps while waiting for it to complete.


Syntax

CCB_SCSIIO * ccmn_tur (pd, sense_len, cam_flags, comp_func, tag_action, timeout)
PDRV_DEVICE *pd;
u_short sense_len;
u_long cam_flags;
void (*comp_func)();
u_char tag_action;
u_long timeout;


Arguments

pd
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

sense_len
Length of the sense data buffer to be returned on autosense, which is predefined as 64 bytes in the DEC_AUTO_SENSE_SIZE environment variable but can be larger.

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable autodisconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.

comp_func
SCSI device driver I/O callback completion function. This pointer may be NULL if the CAM DISABLE CALLBACK bit is set in the CAM FLAGS field.

tag_action
Type of action to perform for tagged requests:
CAM_SIMPLE_QTAG Tag for simple queue
CAM_HEAD_QTAG Tag for head of queue
CAM_ORDERED_QTAG Tag for ordered queue

timeout
Timeout for the request (in seconds). A value of 0 (zero) indicates the default, which is 5 seconds.


Description

The ccmn_tur routine creates a SCSI I/O CCB for the TEST UNIT READY command and sends it to the XPT for processing.

The ccmn_tur routine calls the ccmn_io_ccb_bld routine to obtain a SCSI I/O CCB structure. The ccmn_tur routine calls the ccmn_send_ccb_wait routine to send the SCSI I/O CCB to the XPT and waits for it to complete. The ccmn_tur routine sleeps at a noninterruptible priority. It requires the callback completion function to issue a wakeup call on the address of the CCB.


Return Value

CCB_SCSIIO pointer


See Also

ccmn_io_ccb_bld, ccmn_send_ccb_wait


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_CamFunction


Name

cdbg_CamFunction - Reports CAM XPT function codes


Syntax

char * cdbg_CamFunction (cam_function, report_format)
register u_char cam_function;
int report_format;


Arguments

cam_function
The entry from the CAM XPT Function Code Table.

report_format
The format of the message text returned, which can be CDBG_BRIEF or CDBG_FULL.


Description

The cdbg_CamFunction routine reports CAM XPT function codes. Program constants are defined to allow either the function code name only or a brief explanation to be printed. The XPT function codes are defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

Returns a pointer to a text string.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_CamStatus


Name

cdbg_CamStatus - Decodes CAM CCB status codes


Syntax

char * cdbg_CamStatus (cam_status, report_format)
register u_char cam_status;
int report_format;


Arguments

cam_status
The information from the CAM SCSI I/O CCB.

report_format
The format of the message text returned, which can be CDBG_BRIEF or CDBG_FULL.


Description

The cdbg_CamStatus routine decodes CAM CCB status codes. Program constants are defined to allow either the status code name only or a brief explanation to be printed. The CAM status codes are defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

Returns a pointer to a text string.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpABORT


Name

cdbg_DumpABORT - Dumps the contents of an ABORT CCB


Syntax

void cdbg_DumpABORT (ccb)
register CCB_ABORT *ccb;


Arguments

ccb
Pointer to the ABORT CCB.


Description

The cdbg_DumpABORT routine dumps the contents of an ABORT CCB. The ABORT CCB is defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpBuffer


Name

cdbg_DumpBuffer - Dumps the contents of a data buffer in hexadecimal bytes


Syntax

void cdbg_DumpBuffer (buffer, size)
char *buffer;
register int size;


Arguments

buffer
SCSI/CAM peripheral buffer pointer.

size

Size of buffer (in bytes).


Description

The cdbg_DumpBuffer routine dumps the contents of a data buffer in hexadecimal bytes. The calling routine must display a header line. The format of the dump is 16 bytes per line.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpCCBHeader


Name

cdbg_DumpCCBHeader - Dumps the contents of a CAM control block (CCB) header structure


Syntax

void cdbg_DumpCCBHeader (ccb)
register CCB_HEADER *ccb;


Arguments

ccb
Pointer to the CAM control block (CCB) header structure.


Description

The cdbg_DumpCCBHeader routine dumps the contents of a CAM control block (CCB) header structure. The CCB header structure is defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpCCBHeaderFlags


Name

cdbg_DumpCCBHeaderFlags - Dumps the contents of the cam_flags member of a CAM control block (CCB) header structure


Syntax

void cdbg_DumpCCBHeaderFlags (cam_flags)
register u_long cam_flags;


Arguments

cam_flags
The cam_flags flag names and their bit definitions are listed in the table that follows:
Flag Name Description
CAM_DIR_RESV Data direction (00: reserved).
CAM_DIR_IN Data direction (01: DATA IN).
CAM_DIR_OUT Data direction (10: DATA OUT).
CAM_DIR_NONE Data direction (11: no data).
CAM_DIS_AUTOSENSE Disable autosense feature.
CAM_SCATTER_VALID Scatter/gather list is valid.
CAM_DIS_CALLBACK Disable callback feature.
CAM_CDB_LINKED CCB contains linked CDB.
CAM_QUEUE_ENABLE SIM queue actions are enabled.
CAM_CDB_POINTER CDB field contains pointer.
CAM_DIS_DISCONNECT Disable disconnect.
CAM_INITIATE_SYNC Attempt synchronous data transfer after issuing Synchronous Data Transfer Request (SDTR).
CAM_DIS_SYNC Disable synchronous mode and go to asynchronous mode.
CAM_SIM_QHEAD Place CCB at head of SIM queue.
CAM_SIM_QFREEZE Return SIM queue to frozen state.
CAM_SIM_QFRZDIS Disable the SIM queue frozen state.
CAM_ENG_SYNC Flush residual bytes from HBA data engine before terminating I/O.
CAM_ENG_SGLIST Scatter/gather list is for HBA engine.
CAM_CDB_PHYS CDB pointer is physical address.
CAM_DATA_PHYS Scatter/gather/buffer data pointers are physical addresses.
CAM_SNS_BUF_PHYS Autosense data pointer is physical address.
CAM_MSG_BUF_PHYS Message buffer pointer is physical address.
CAM_NXT_CCB_PHYS Next CCB pointer is physical address.
CAM_CALLBCK_PHYS Callback function pointer is physical address.
CAM_DATAB_VALID Data buffer valid.
CAM_STATUS_VALID Status buffer valid.
CAM_MSGB_VALID Message buffer valid.
CAM_TGT_PHASE_MODE SIM will run in phase mode.
CAM_TGT_CCB_AVAIL Target CCB available.
CAM_DIS_AUTODISC Disable disconnect.
CAM_DIS_AUTOSRP Disable autosave/restore pointers.


Description

The cdbg_DumpCCBHeaderFlags routine dumps the contents of the cam_flags member of a CAM control block (CCB) header structure. The CCB header structure is defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpInquiryData


Name

cdbg_DumpInquiryData - Dumps the contents of an ALL_INQ_DATA structure


Syntax

void cdbg_DumpInquiryData (inquiry)
register ALL_INQ_DATA *inquiry;


Arguments

inquiry
Pointer to the ALL_INQ_DATA structure.


Description

The cdbg_DumpInquiryData routine dumps the contents of an ALL_INQ_DATA structure. The ALL_INQ_DATA structure is defined in the /usr/sys/include/io/cam/scsi_all.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpPDRVws


Name

cdbg_DumpPDRVws - Dumps the contents of a SCSI/CAM Peripheral Device Driver Working Set structure


Syntax

void cdbg_DumpPDRVws (pws)
register PDRV_WS *pws;


Arguments

pws
Pointer to the SCSI/CAM Peripheral Device Driver Working Set structure.


Description

The cdbg_DumpPDRVws routine dumps the contents of a SCSI/CAM Peripheral Device Driver Working Set structure. The SCSI/CAM Peripheral Device Driver Working Set structure is defined in the /usr/sys/include/io/cam/pdrv.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpSCSIIO


Name

cdbg_DumpSCSIIO - Dumps the contents of a SCSI I/O CCB


Syntax

void cdbg_DumpSCSIIO (ccb)
register CCB_SCSIIO *ccb;


Arguments

ccb
Pointer to the SCSI I/O CCB structure.


Description

The cdbg_DumpSCSIIO routine dumps the contents of a SCSI I/O CCB. The SCSI I/O CCB is defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_DumpTERMIO


Name

cdbg_DumpTERMIO - Dumps the contents of a TERMINATE I/O CCB


Syntax

void cdbg_DumpTERMIO (ccb)
register CCB_TERMIO *ccb;


Arguments

ccb
Pointer to the TERMINATE I/O CCB.


Description

The cdbg_DumpTERMIO routine dumps the contents of a TERMINATE I/O CCB. The TERMINATE I/O CCB is defined in the /usr/sys/include/io/cam/cam.h file.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_GetDeviceName


Name

cdbg_GetDeviceName - Returns a pointer to a character string that describes the dtype member of an ALL_INQ_DATA structure


Syntax

char * cdbg_GetDeviceName (device_type)
register device_type;


Arguments

device_type
SCSI device type value from Inquiry data.


Description

The cdbg_GetDeviceName routine returns a pointer to a character string that describes the dtype member of an ALL_INQ_DATA structure. The ALL_INQ_DATA structure is defined in the /usr/sys/include/io/cam/scsi_all.h file.


Return Value

Returns a pointer to a text string.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_ScsiStatus


Name

cdbg_ScsiStatus - Reports SCSI status codes


Syntax

char * cdbg_ScsiStatus (scsi_status, report_format)
register u_char scsi_status;
int report_format;


Arguments

scsi_status
The SCSI status from the CAM SCSI I/O CCB.

report_format
The format of the message text returned, which can be CDBG_BRIEF or CDBG_FULL.


Description

The cdbg_ScsiStatus routine reports SCSI status codes. Program constants are defined to allow either the status code name only or a brief explanation to be printed. The SCSI status codes are defined in the /usr/sys/include/io/cam/scsi_status.h file.


Return Value

Returns a pointer to a text string.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cdbg_SystemStatus


Name

cdbg_SystemStatus - Reports system error codes


Syntax

char * cdbg_SystemStatus (errno)
int errno;


Arguments

errno
The error number.


Description

The cdbg_SystemStatus routine reports system error codes. The system error codes are defined in the /usr/sys/include/sys/errno.h file.


Return Value

Returns a pointer to a text string.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_async


Name

cgen_async - Handles notification of asynchronous events


Syntax

void cgen_async (opcode, path_id, target, lun, buf_ptr, data_cnt)
u_long opcode;
u_char path_id;
u_char target;
u_char lun;
caddr_t buf_ptr;
u_char data_cnt;


Arguments

opcode
SCSI asynchronous callback operation code.

path_id
SCSI target's bus controller number.

target
SCSI target's ID number.

lun
SCSI target's logical unit number.

buf_ptr
Buffer address for asynchronous event notification (AEN).

data_cnt
Number of bytes the XPT had to transfer from the SIM's buffer or the limit of the SCSI/CAM peripheral buffer.


Description

The cgen_async routine handles notification of asynchronous events. The routine is called when an asynchronous event notification (AEN), bus device reset (BDR), or bus reset (BR) occurs. The routine sets the CGEN_RESET_STATE flag and clears the CGEN_RESET_PEND_STATE flag for BDRs and bus resets. The routine sets the CGEN_UNIT_ATTEN_STATE flag for AENs.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_attach


Name

cgen_attach - Is called for each bus, target, and LUN after the cgen_slave routine returns SUCCESS


Syntax

int cgen_attach (device)
struct device *device;


Arguments

device
Pointer to the device information contained in the device structure.


Description

The cgen_attach routine is called for each bus, target, and LUN after the cgen_slave routine returns SUCCESS. The routine calls the ccmn_open_unit routine, passing the bus, target, and LUN information.

The cgen_attach routine calls the ccmn_close_unit routine to close the device. If a device of the specified type is found, the device identification string is printed.


Return Value

PROBE_FAILURE
PROBE_SUCCESS


See Also

ccmn_close_unit , ccmn_open_unit , cgen_slave


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_ccb_chkcond


Name

cgen_ccb_chkcond - Decodes the autosense data for a device driver


Syntax

int cgen_ccb_chkcond (pdrv_dev, ccb)
PDRV_DEVICE *pdrv_dev;
CCB_SCSIIO *ccb;


Arguments

pdrv_dev
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

ccb
Pointer to the SCSI I/O CCB structure.


Description

The cgen_ccb_chkcond routine decodes the autosense data for a device driver and returns the appropriate status to the calling routine. The routine is called when a SCSI I/O CCB is returned with a CAM status of CAM_REQ_CMP_ERR (request completed with error) and a SCSI status of SCSI_STAT_CHECK_CONDITION. The routine also sets the appropriate flags in the Generic-Specific structure.


Return Value

An integer indicating one of the following values:
Flag Name Description
CHK_CHK_NOSENSE Request sense did not complete without error. Sense buffer contents cannot be used to determine error condition.
CHK_SENSE_NOT_VALID Valid bit in sense buffer is not set; sense data is useless.
CHK_EOM End of media detected.
CHK_FILEMARK Filemark detected.
CHK_ILI Incorrect record length detected.
CHK_NOSENSE_BITS Sense key equals no sense, but there are no bits set in byte 2 of sense data.
CHK_SOFTERR Soft error detected; corrected by unit.
CHK_NOT_READY Unit is not ready.
CHK_HARDERR Unit has detected a hard error.
CHK_UNIT_ATTEN Unit has either had media change or just powered up.
CHK_DATA_PROT Unit is write protected.
CHK_UNSUPPORTED Sense key that is unsupported has been returned.
CHK_CMD_ABORTED Unit aborted this command.
CHK_INFORMATIONAL Unit is reporting informational message.
CHK_UNKNOWN_KEY Unit has returned sense key that is not supported by SCSI 2 specification.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_close


Name

cgen_close - Closes the device


Syntax

int cgen_close (dev, flags, fmt)
dev_t dev;
nt flags;
int fmt;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

flags
Flags set when a file is open.

fmt
Indicates whether to close the character or block device.


Description

The cgen_close routine closes the device. The routine checks any device flags that are defined to see if action is required, such as rewind on close or release the unit. The cgen_close closes the device by calling the ccmn_close_unit routine.


Return Value

The cgen_close routine returns GENERIC_SUCCESS upon successful completion.


Diagnostics

The cgen_close routine fails under the following condition:

[ENOMEM]
Resource problem


See Also

ccmn_close_unit


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_done


Name

cgen_done - Serves as the entry point for all nonread and nonwrite I/O callbacks


Syntax

void cgen_done (ccb)
CCB_SCSIIO *ccb;


Arguments

ccb
Pointer to the SCSI I/O CCB structure.


Description

The cgen_done routine is the the entry point for all nonread and nonwrite I/O callbacks. The generic device driver uses two callback entry points, one for all nonuser I/O requests and one for all user I/O requests. The SCSI/CAM peripheral device driver writer can declare multiple callback routines for each type of command and can fill the CCB with the address of the appropriate callback routine.

This is a generic routine for all nonread and nonwrite SCSI I/O CCBs. The SCSI I/O CCB should not contain a pointer to a buf structure in the cam_req_map member of the structure. If it does, then a wake-up call is issued on the address of the CCB and the error is reported. If the SCSI I/O CCB does not contain a pointer to a buf structure in the cam_req_map member, then a wake-up call is issued on the address of the CCB and the CCB is removed from the active queues. No CCB completion status is checked because that is the responsibility of the routine that created the CCB and is waiting for completion status. When this routine is entered, context is on the interrupt stack and the driver cannot sleep while waiting for an event.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_ioctl


Name

cgen_ioctl - Handles user process requests for specific actions other than read, write, open, or close for SCSI tape devices


Syntax

int cgen_ioctl (dev, cmd, data, flags)
dev_t dev;
int cmd;
caddt_t data;
int flags;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

cmd
The ioctl command DEVIOCGET.

data

Pointer to the kernel copy of the structure passed by the user process.

flags
User process flags.


Description

The cgen_ioctl routine handles user process requests for specific actions other than read, write, open, or close for SCSI tape devices. The routine currently issues a DEVIOCGET ioctl command for the device, which fills out the devget structure passed in, and then calls the cgen_mode_sns routine, which issues a SCSI_MODE_SENSE to the device to determine the device's state. The routine then calls the ccmn_rel_ccb routine to release the CCB. When the call to cgen_mode_sns has completed, the cgen_ioctl routine fills out the rest of the devget structure, based on information contained in the mode sense data.


Return Value

[EINVAL] Invalid command.


See Also

ccmn_rel_ccb , cgen_mode_sns , ioctl(2)


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_iodone


Name

cgen_iodone - Serves as the entry point for all read and write I/O callbacks


Syntax

int cgen_iodone (ccb)
CCB_SCSIIO *ccb;


Arguments

ccb
Pointer to the SCSI I/O CCB structure.


Description

The cgen_iodone routine is the entry point for all read and write I/O callbacks. This is a generic routine for all read and write SCSI I/O CCBs. The SCSI I/O CCB should contain a pointer to a buf structure in the cam_req_map member of the structure. If it does not, then a wake-up call is issued on the address of the CCB and the error is reported. If the SCSI I/O CCB does contain a pointer to a buf structure in the cam_req_map member, as it should, then the completion status is decoded. Depending on the CCB's completion status, the correct fields within the buf structure are filled out.

The device's active queues may need to be aborted because of errors or because the device is a sequential access device and the transaction was an asynchronous request.

The CCB is removed from the active queues by a call to the ccmn_rem_ccb routine and is released back to the free CCB pool by a call to the ccmn_rel_ccb routine. When the cgen_iodone routine is entered, context is on the interrupt stack and the driver cannot sleep while waiting for an event.


Return Value

None


See Also

ccmn_rem_ccb , ccmn_rel_ccb


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_minphys


Name

cgen_minphys - Compares the b_bcount with the maximum transfer limit for the device


Syntax

void cgen_minphys (bp)
register struct buf *bp;


Arguments

bp
A buf structure pointer, which is used for request mapping.


Description

The cgen_minphys routine compares the b_bcount with the maximum transfer limit for the device. The routine compares the b_bcount field in the buf structure with the maximum transfer limit for the device in the Device Descriptor structure. The count is adjusted if it is greater than the limit.


Return Value

None


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_mode_sns


Name

cgen_mode_sns - Issues a SCSI_MODE_SENSE command to the unit defined


Syntax

CCB_SCSIIO * cgen_mode_sns (pdrv_dev, action, done, page_code, page_ctrl, sleep)
PDRV_DEVICE *pdrv_dev;
CGEN_ACTION *action;
void (*done)();
u_char page_code;
u_char page_ctrl;
u_long sleep;


Arguments

pdrv_dev
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

action
Pointer to the caller's Generic Action structure.

done

The address of the completion routine to be called when the SCSI command has completed.

page_code
The user process's target page.

page_ctrl
The page control settings field.

sleep
Whether or not the GENERIC_SLEEP flag is set.


Description

The cgen_mode_sns routine issues a SCSI_MODE_SENSE command to the unit defined. The CGEN_ACTION structure is filled in for the calling routine based on the completion status of the CCB.


Return Value

NULL - command could not be issued
CCB_SCSIIO pointer


See Also

ccmn_ccb_status


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_open


Name

cgen_open - Is called by the kernel when a user process requests an open of the device


Syntax

int cgen_open (dev, flags, fmt)
dev_t dev;
int flags;
int fmt;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

flags
Flags set when a file is open.

fmt
Indicates whether to open the character or block device.


Description

The kernel calls the cgen_open routine when a user process requests an open of the device. The cgen_open routine calls the ccmn_open_unit routine, which manages the SMP_LOCKS and, if passed the exclusive use flag for SCSI devices, makes sure that no other process has opened the device. If the ccmn_open_unit routine returns success, the necessary data structures are allocated.

The cgen_open routine calls the ccmn_sasy_ccb_bld routine to register for asynchronous event notification for the device. The cgen_open routine then enters a for loop based on the power-up time specified in the Device Descriptor structure for the device. Within the loop, calls are made to the cgen_ready routine, which calls the ccmn_tur routine to issue a TEST UNIT READY command to the device.

The cgen_open routine calls the ccmn_rel_ccb routine to release the CCB. The cgen_open routine checks certain state flags for the device to decide whether to send the initial SCSI mode select pages to the device. Depending on the setting of the state flags CGEN_UNIT_ATTEN_STATE and CGEN_RESET_STATE, the cgen_open routine calls the cgen_open_sel routine for each mode select page to be sent to the device. The cgen_open_sel routine fills out the Generic Action structure based on the completion status of the CCB for each mode select page it sends.


Return Value

The cgen_open routine returns GENERIC_SUCCESS upon successful completion.


Diagnostics

The cgen_open routine fails under the following conditions:

[EBUSY]
The device is already opened and the exclusive use bit is set.

[ENOMEM]
Resource problem.

[EINVAL]
The scsi_dev_type parameter does not match the device type in the Inquiry data returned by GET DEVICE TYPE CCB. The scsi_dev_type was not configured.

[ENXIO]
The device does not exist.

[EIO]
Check device conditions.


See Also

ccmn_close_unit , ccmn_open_unit , ccmn_rel_ccb , ccmn_sasy_ccb_bld , ccmn_tur , cgen_open_sel , cgen_close


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_open_sel


Name

cgen_open_sel - Issues a SCSI_MODE_SELECT command to the SCSI device


Syntax

void cgen_open_sel (pdrv_dev, action, ms_index, done, sleep)
PDRV_DEVICE *pdrv_dev;
CGEN_ACTION *action;
u_long ms_index;
void (*done)();
u_long sleep;


Arguments

pdrv_dev
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

action
Pointer to the caller's Generic Action structure.

ms_index
An index into a page in the Mode Select Table that is pointed to in the Device Descriptor structure.

done

The address of the completion routine to be called when the SCSI command has completed.

sleep
Whether or not the GENERIC_SLEEP flag is set.


Description

The cgen_open_sel routine issues a SCSI_MODE_SELECT command to the SCSI device. The mode select data sent to the device is based on the data contained in the Mode Select Table structure for the device, if one is defined. The CGEN_ACTION structure is filled in for the calling routine based on the completion status of the CCB.

The cgen_open_sel routine calls the ccmn_mode_select routine to create a SCSI I/O CCB and send it to the XPT for processing.


Return Value

None


See Also

ccmn_ccb_status , ccmn_mode_select


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_read


Name

cgen_read - Handles synchronous read requests for user processes


Syntax

int cgen_read (dev, uio)
dev_t dev;
struct uio *uio;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

uio
Pointer to the device information contained in the uio I/O structure.


Description

The cgen_read routine handles synchronous read requests for user processes. It passes the user process requests to the cgen_strategy routine. The cgen_read routine calls the ccmn_get_bp routine to allocate a buf structure for the user process read request. When the I/O is complete, the cgen_read routine calls the ccmn_rel_bp routine to deallocate the buf structure.


Return Value

The cgen_read routine passes the return from the physio routine.


See Also

ccmn_get_bp , ccmn_rel_bp , cgen_strategy


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_ready


Name

cgen_ready - Issues a TEST UNIT READY command to the unit defined


Syntax

void cgen_ready (pdrv_dev, action, done, sleep)
PDRV_DEVICE *pdrv_dev;
CGEN_ACTION *action;
void (*done)();
u_long sleep;


Arguments

pdrv_dev
Pointer to the CAM Peripheral Device structure allocated for each SCSI device in the system.

action
Pointer to the caller's Generic Action structure.

done

The address of the completion routine to be called when the SCSI command has completed.

sleep
Whether or not the GENERIC_SLEEP flag is set.


Description

The cgen_ready routine issues a TEST UNIT READY command to the unit defined. The routine calls the ccmn_tur routine to issue the TEST UNIT READY command and sleeps while waiting for command status.


Return Value

None


See Also

ccmn_tur


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_slave


Name

cgen_slave - Is called at system boot to initialize the lower levels


Syntax

int cgen_slave (device, reg)
struct device *device;
caddr_t reg;


Arguments

device
Pointer to the device information contained in the device structure.

reg
The virtual address of the controller.


Description

The cgen_slave routine is called at system boot to initialize the lower levels. The routine also checks the bounds for the unit number to ensure it is within the allowed range and sets the device-configured bit for the device at the specified bus, target, and LUN.


Return Value

PROBE_FAILURE
PROBE_SUCCESS


See Also

ccmn_close_unit , ccmn_init , ccmn_open_unit


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_strategy


Name

cgen_strategy - Handles all I/O requests for user processes


Syntax

int cgen_strategy (bp)
struct buf *bp;


Arguments

bp
A buf structure pointer, which is used for request mapping.


Description

The cgen_strategy routine handles all I/O requests for user processes. It performs specific checks, depending on whether the request is synchronous or asynchronous and on the SCSI device type. The cgen_strategy routine calls the ccmn_io_ccb_bld routine to obtain an initialized SCSI I/O CCB and to build either a read or a write command based on the information contained in the buf structure. The cgen_strategy routine then calls the ccmn_send_ccb to place the CCB on the active queue and to send it to the XPT layer.


Return Value

[EINVAL]    Device not ready.
[EIO]


See Also

ccmn_io_ccb_bld , ccmn_send_ccb , cgen_iodone


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cgen_write


Name

cgen_write - Handles synchronous write requests for user processes


Syntax

int cgen_write (dev, uio)
dev_t dev;
struct uio *uio;


Arguments

dev
The major/minor device number pair that identifies the bus number, target ID, and LUN associated with this SCSI device.

uio
Pointer to the device information contained in the uio I/O structure.


Description

The cgen_write routine handles synchronous write requests for user processes. The routine passes the user process requests to the cgen_strategy routine. The cgen_write routine calls the ccmn_get_bp routine to allocate a buf structure for the user process write request. When the I/O is complete, the cgen_write routine calls the ccmn_rel_bp routine to deallocate the buf structure.


Return Value

The cgen_write routine passes the return from the physio routine.


See Also

ccmn_get_bp , ccmn_rel_bp , cgen_strategy


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


sim_action


Name

sim_action - Initiates an I/O request from a SCSI/CAM peripheral device driver


Syntax

int sim_action (ccb_hdr)
CCB_HEADER *ccb_hdr;


Arguments

ccb_hdr
Address of the header for the ccb.


Description

The sim_action routine initiates an I/O request from a SCSI/CAM peripheral device driver. The XPT uses the routine for immediate as well as for queued operations. When the operation has completed, the SIM calls back directly to the peripheral driver by using the CCB callback address, if callbacks are enabled and the operation is not to be carried out immediately.

The SIM determines whether an operation is to be carried out immediately or to be queued according to the function code of the CCB structure. All queued operations, such as ``Execute SCSI I/O'' (reads or writes), are placed by the SIM on a nexus-specific queue and return with a CAM status of CAM_INPROG.

Some immediate operations, as described in the American National Standard for Information Systems, SCSI-2 Common Access Method: Transport and SCSI Interface Module, working draft, X3T9.2/90-186, may not be executed immediately. However, all CCBs to be carried out immediately return to the XPT layer immediately. For example, the ABORT CCB command does not always complete synchronously with its call; however, the CCB_ABORT is returned to the XPT immediately. An XPT_RESET_BUS CCB returns to the XPT following the reset of the bus.


Return Value

CAM_REQ_INPROG for queued commands
CAM_REQ_CMP for immediate commands
A valid CAM error value


See Also

American National Standard for Information Systems, SCSI-2 Common Access Method: Transport and SCSI Interface Module, working draft, X3T9.2/90-186


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


sim_init


Name

sim_init - Initializes the SIM


Syntax

int sim_init (pathid)
u_long pathid;


Arguments

pathid
SCSI target's bus controller number.


Description

The sim_init routine initializes the SIM. The SIM clears all its queues and releases all allocated resources in response to this call. This routine is called using the function address contained in the CAM_SIM_ENTRY structure. This routine can be called at any time; the SIM layer must ensure that data integrity is maintained.


Return Value

CAM_REQ_CMP


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


uagt_close


Name

uagt_close - Handles the close of the User Agent driver


Syntax

void uagt_close (dev, flag)
dev_t dev;
int flag;


Arguments

dev
The major/minor device number pair that identifies the User Agent.

flag

Unused.


Description

The uagt_close routine handles the close of the User Agent driver. For the last close operation for the driver, if any queues are frozen, a RELEASE SIM QUEUE CCB is sent to the XPT layer for each frozen queue detected by the User Agent.


Return Value

None


See Also

uagt_open, xpt_ccb_free


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


uagt_ioctl


Name

uagt_ioctl - Handles the ioctl system call for the User Agent driver


Syntax

int uagt_ioctl (dev, cmd, data, flag)
dev_t dev;
register int cmd;
caddr_t data;
int flag;


Arguments

dev
The major/minor device number pair that identifies the User Agent.

cmd
The ioctl command UAGT_CAM_IO.

data

Pointer to the UAGT_CAM_CCB structure passed by the user process.

flag

Unused.


Description

The uagt_ioctl routine handles the ioctl system call for the User Agent driver. The ioctl commands supported are: DEVIOCGET, to obtain the User Agent driver's SCSI device status; UAGT_CAM_IO, the ioctl define for calls to the User Agent driver; UAGT_CAM_SINGLE_SCAN, to scan a bus, target, and LUN; and UAGT_CAM_FULL_SCAN, to scan a bus.

For SCSI I/O CCB requests, the user data area is locked before passing the CCB to the XPT. The User Agent sleeps while waiting for the I/O to complete and issues an ABORT CCB if a signal is caught while sleeping.


Return Value

The uagt_ioctl routine returns a value of 0 (zero) upon successful completion.


Diagnostics

The uagt_ioctl routine fails under the following conditions:

[EFAULT]
Copy to or from user space failed.

[EINVAL]
An unsupported cmd value was passed to the ioctl. The CCB copied from the user process contained an invalid XPT function code or an invalid target or LUN.

[EBUSY]
The maximum allowable number of User Agent requests has been reached (MAX_UAGT_REQ).


See Also

ioctl(2), xpt_action, xpt_ccb_alloc


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


uagt_open


Name

uagt_open - Handles the open of the User Agent driver


Syntax

int uagt_open (dev, flag)
dev_t dev;
int flag;


Arguments

dev
The major/minor device number pair that identifies the User Agent.

flag

Unused.


Description

The uagt_open routine handles the open of the User Agent driver.

The character device special file name used for the open is /dev/cam.


Return Value

The uagt_open routine returns a value of 0 (zero) upon successful completion.


See Also

uagt_close, xpt_init


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


xpt_action


Name

xpt_action - Calls the appropriate XPT/SIM routine


Syntax

I32 xpt_action (ch)
CCB_HEADER *ch;


Arguments

ch
Specifies a pointer to the CAM control block (CCB) on which to act.


Description

The xpt_action routine calls the appropriate XPT/SIM routine. The routine routes the specified CCB to the appropriate SIM module or to the Configuration driver, depending on the CCB type and on the path ID specified in the CCB. Vendor-unique CCBs are also supported. Those CCBs are passed to the appropriate SIM module according to the path ID specified in the CCB.


Return Value

Upon completion, the xpt_action routine returns a valid CAM status value.


See Also

xpt_ccb_alloc, xpt_ccb_free


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


xpt_ccb_alloc


Name

xpt_ccb_alloc - Allocates a CAM control block (CCB)


Syntax

CCB_HEADER * xpt_ccb_alloc()


Arguments

None


Description

The xpt_ccb_alloc routine allocates a CAM control block (CCB) for use by a SCSI/CAM peripheral device driver. The xpt_ccb_alloc routine returns a pointer to a preallocated data buffer large enough to contain any CCB structure. The peripheral device driver uses this structure for its XPT/SIM requests. The routine also ensures that the SIM private data space and peripheral device driver pointer, cam_pdrv_ptr, are set up.


Return Value

Upon successful completion, xpt_ccb_alloc returns a pointer to a preallocated data buffer. The data buffer returned by xpt_ccb_alloc is initialized to be a SCSI I/O CCB. For other types of CCBs, some fields may have to be reinitialized for the specific CCB.


See Also

xpt_ccb_free


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


xpt_ccb_free


Name

xpt_ccb_free - Frees a previously allocated CCB


Syntax

I32 xpt_ccb_free (ch)
CCB_HEADER *ch;


Arguments

ch
Specifies a pointer to the CCB to be freed. This CCB was allocated in a call to xpt_ccb_alloc.


Description

The xpt_ccb_free routine frees a previously allocated CCB. The routine returns a CCB, previously allocated by a peripheral device driver, to the CCB pool.


Return Value

XPT_CCB_INVALID or CAM_SUCCESS


See Also

xpt_ccb_alloc


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


xpt_init


Name

xpt_init - Validates the initialized state of the CAM subsystem


Syntax

long xpt_init()


Arguments

None


Description

The xpt_init routine validates the initialized state of the CAM subsystem. The routine initializes all global and internal variables that the CAM subsystem uses through a call to the Configuration driver. Peripheral device drivers must call this routine either during or prior to their own initialization. The xpt_init routine simply returns to the calling SCSI/CAM peripheral device driver if the CAM subsystem was previously initialized.


Return Value

Upon completion, xpt_init returns one of the following values:

Return Value Meaning
CAM_SUCCESS The xpt_init routine initialized the CAM subsystem.
CAM_FAILURE The xpt_init routine did not initialize the CAM subsystem and the CAM subsystem cannot be used.