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.
cam_logger - Allocates a system error log buffer and fills in a uerf error log packet
u_long
cam_logger
(cam_err_hdr,
bus,
target,
lun)
CAM_ERR_HDR
*cam_err_hdr;
long
bus;
long
target;
long
lun;
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.
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
int
ccfg_attach
(attach)
struct device
*attach;
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.
0 = success
1 = failure
The return value is ignored by autoconfiguration code.
ccfg_edtscan - Issues SCSI INQUIRY commands to all possible SCSI targets and LUNs attached to a bus or a particular bus/target/lun
U32
ccfg_edtscan
(scan_type,
bus,
target,
lun)
long
scan_type;
long
bus;
long
target;
long
lun;
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.
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
int
ccfg_slave
(attach,
csr)
struct device
*attach;
caddr_t
csr;
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.
0 = slave is alive
1 = slave is not alive
ccmn_abort_ccb_bld - Creates an ABORT CCB and sends it to the XPT
CCB_ABORT *
ccmn_abort_ccb_bld
(dev,
cam_flags,
abort_ccb)
dev_t
dev;
u_long
cam_flags;
CCB_HEADER
*abort_ccb;
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. |
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.
CCB_ABORT pointer
ccmn_abort_que - Sends an ABORT CCB request for each SCSI I/O CCB on the active queue
void
ccmn_abort_que
(pd)
PDRV_DEVICE
*pd;
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.
None
ccmn_abort_ccb_bld, ccmn_rel_ccb, ccmn_send_ccb
ccmn_attach_device - Creates and attaches a device structure to the controller structure that corresponds to the SCSI controller
void
ccmn_attach_device
(dev,
dev_type,
dev_name)
dev_t
dev;
caddr_t
dev_type;
caddr_t
dev_name;
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.
None
ccmn_bdr_ccb_bld - Creates a BUS DEVICE RESET CCB and sends it to the XPT
CCB_RESETDEV *
ccmn_bdr_ccb_bld
(dev,
cam_flags)
dev_t
dev;
u_long
cam_flags;
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. |
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.
CCB_RESETDEV pointer
ccmn_br_ccb_bld - Creates a BUS RESET CCB and sends it to the XPT
CCB_RESETBUS *
ccmn_br_ccb_bld
(dev,
cam_flags)
dev_t
dev;
u_long
cam_flags;
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. |
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.
CCB_RESETBUS pointer
ccmn_ccb_status - Assigns individual CAM status values to generic categories
int
ccmn_ccb_status
(ccb)
CCB_HEADER
*ccb;
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 |
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. |
ccmn_check_idle - Checks that there are no opens against a device
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;
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.
None
ccmn_close_unit - Handles the common close for all SCSI/CAM peripheral device drivers
void
ccmn_close_unit
(dev)
dev_t
dev;
The ccmn_close_unit routine handles the common close for all SCSI/CAM peripheral device drivers. It sets the open count to zero.
None
ccmn_DoSpecialCmd - Provides a simplified interface to the special command routine
int
ccmn_DoSpecialCmd
(dev,
cmd,
data,
flags,
ccb,
sflags)
dev_t
dev;
int
cmd;
caddr_t
data;
int
flags;
CCB_SCSIIO
*ccb;
int
sflags;
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. |
The ccmn_DoSpecialCmd routine provides a simplified interface to the special command routine. The routine prepares for and issues special SCSI ioctl commands.
The ccmn_DoSpecialCmd routine returns a value of 0 (zero) upon successful completion. It returns the appropriate error code on failure.
ccmn_errlog - Reports error conditions for the SCSI/CAM peripheral device driver
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;
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.
ccmn_find_ctlr - Finds the controller structure that corresponds to the SCSI controller that the device must be attached to
struct controller *
ccmn_find_ctlr
(dev)
dev_t
dev;
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.
Controller for the device or NULL if no controller is found.
ccmn_gdev_ccb_bld - Creates a GET DEVICE TYPE CCB and sends it to the XPT
CCB_GETDEV *
ccmn_gdev_ccb_bld
(dev,
cam_flags,
inq_addr)
dev_t
dev;
u_long
cam_flags;
u_char
*inq_addr;
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. |
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.
CCB_GETDEV pointer
ccmn_get_bp - Allocates a buf structure
register struct buf *
ccmn_get_bp()
None
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.
Pointer to buf structure. This pointer may be NULL.
ccmn_get_ccb - Allocates a CCB and fills in the common portion of the CCB header
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;
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. |
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.
Pointer to newly allocated CCB header.
ccmn_get_dbuf - Allocates a data buffer area of the size specified by calling the kernel memory allocation routines
char *
ccmn_get_dbuf
(size)
u_long
size;
The ccmn_get_dbuf routine allocates a data buffer area of the size specified by calling the kernel memory allocation routines.
Pointer to kernel data space. If this is NULL, no data buffers are available and no more can be allocated.
ccmn_init - Initializes the XPT and the unit table lock structure
void
ccmn_init()
None
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.
None
ccmn_io_ccb_bld - Allocates a SCSI I/O CCB and fills it in
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;
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. |
CAM_SIMPLE_QTAG | Tag for simple queue |
CAM_HEAD_QTAG | Tag for head of queue |
CAM_ORDERED_QTAG | Tag for ordered queue |
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.
Pointer to a SCSI I/O CCB
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.
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;
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. |
CAM_SIMPLE_QTAG | Tag for simple queue |
CAM_HEAD_QTAG | Tag for head of queue |
CAM_ORDERED_QTAG | Tag for ordered queue |
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.
CCB_SCSIIO pointer
ccmn_io_ccb_bld, ccmn_send_ccb_wait
ccmn_open_unit - Handles the common open for all SCSI/CAM peripheral device drivers
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;
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.
The ccmn_open_unit routine returns a value of 0 (zero) upon successful completion.
The ccmn_open_unit routine fails under the following conditions:
ccmn_close_unit, ccmn_gdev_ccb_bld
ccmn_pinq_ccb_bld - Creates a PATH INQUIRY CCB and sends it to the XPT
CCB_PATHINQ *
ccmn_pinq_ccb_bld
(dev,
cam_flags)
dev_t
dev;
u_long
cam_flags;
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. |
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.
CCB_PATHINQ pointer
ccmn_rel_bp - Deallocates a buf structure
void
ccmn_rel_bp
(bp)
struct buf
*bp;
The ccmn_rel_bp routine deallocates a buf structure.
ccmn_rel_ccb - Releases a CCB and returns the sense data buffer for SCSI I/O CCBs, if allocated
void
ccmn_rel_ccb
(ccb)
CCB_HEADER
*ccb;
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.
None
ccmn_rel_dbuf - Deallocates a data buffer
void
ccmn_rel_dbuf
(addr,
size)
u_char
*addr;
U32
size;
The ccmn_rel_dbuf routine deallocates a data buffer.
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
void
ccmn_rem_ccb
(pd,
ccb)
PDRV_DEVICE
*pd;
CCB_SCSIIO
*ccb;
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.
None
ccmn_rsq_ccb_bld - Creates a RELEASE SIM QUEUE CCB and sends it to the XPT
CCB_RELSIM *
ccmn_rsq_ccb_bld
(dev,
cam_flags)
dev_t
dev;
u_long
cam_flags;
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. |
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.
CCB_RELSIM pointer
ccmn_sasy_ccb_bld - Creates a SET ASYNCHRONOUS CALLBACK CCB and sends it to the XPT
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;
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. |
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.
CCB_SETASYNC pointer
ccmn_sdev_ccb_bld - Creates a SET DEVICE TYPE CCB and sends it to the XPT
CCB_SETDEV *
ccmn_sdev_ccb_bld
(dev,
cam_flags,
scsi_dev_type)
dev_t
dev;
u_long
cam_flags;
u_char
scsi_dev_type;
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. |
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.
CCB_SETDEV pointer
ccmn_send_ccb - Sends CCBs to the XPT layer by calling the xpt_action routine
int
ccmn_send_ccb
(pd,
ccb,
retry)
PDRV_DEVICE
*pd;
CCB_HEADER
*ccb;
u_char
retry;
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.
Value returned from the xpt_action routine.
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.
int
ccmn_send_ccb_wait
(pd,
ccb,
retry,
sleep-pri)
PDRV_DEVICE
*pd;
CCB_HEADER
*ccb;
u_char
retry;
int
sleep-pri;
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.
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. |
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
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;
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. |
CAM_SIMPLE_QTAG | Tag for simple queue |
CAM_HEAD_QTAG | Tag for head of queue |
CAM_ORDERED_QTAG | Tag for ordered queue |
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.
CCB_SCSIIO pointer
ccmn_io_ccb_bld, ccmn_send_ccb_wait
ccmn_SysSpecialCmd - Lets a system request issue of SCSI I/O commands to the SCSI/CAM special I/O interface
ccmn_SysSpecialCmd
(dev,
cmd,
data,
flags,
ccb,
sflags)
dev_t
dev;
int
cmd;
caddr_t
data;
int
flags;
CCB_SCSIIO
*ccb;
int
sflags;
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. |
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.
ccmn_term_ccb_bld - Creates a TERMINATE I/O CCB and sends it to the XPT
CCB_TERMIO *
ccmn_term_ccb_bld
(dev,
cam_flags,
term_ccb)
dev_t
dev;
u_long
cam_flags;
CCB_HEADER
*term_ccb;
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. |
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.
CCB_TERMIO pointer
ccmn_term_que - Sends a TERMINATE I/O CCB request for each SCSI I/O CCB on the active queue
void
ccmn_term_que
(pd)
PDRV_DEVICE
*pd;
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.
None
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.
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;
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. |
CAM_SIMPLE_QTAG | Tag for simple queue |
CAM_HEAD_QTAG | Tag for head of queue |
CAM_ORDERED_QTAG | Tag for ordered queue |
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.
CCB_SCSIIO pointer
ccmn_io_ccb_bld, ccmn_send_ccb_wait
cdbg_CamFunction - Reports CAM XPT function codes
char *
cdbg_CamFunction
(cam_function,
report_format)
register u_char
cam_function;
int
report_format;
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.
Returns a pointer to a text string.
cdbg_CamStatus - Decodes CAM CCB status codes
char *
cdbg_CamStatus
(cam_status,
report_format)
register u_char
cam_status;
int
report_format;
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.
Returns a pointer to a text string.
cdbg_DumpABORT - Dumps the contents of an ABORT CCB
void
cdbg_DumpABORT
(ccb)
register CCB_ABORT
*ccb;
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.
cdbg_DumpBuffer - Dumps the contents of a data buffer in hexadecimal bytes
void
cdbg_DumpBuffer
(buffer,
size)
char
*buffer;
register int
size;
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.
cdbg_DumpCCBHeader - Dumps the contents of a CAM control block (CCB) header structure
void
cdbg_DumpCCBHeader
(ccb)
register CCB_HEADER
*ccb;
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.
cdbg_DumpCCBHeaderFlags - Dumps the contents of the cam_flags member of a CAM control block (CCB) header structure
void
cdbg_DumpCCBHeaderFlags
(cam_flags)
register u_long
cam_flags;
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. |
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.
cdbg_DumpInquiryData - Dumps the contents of an ALL_INQ_DATA structure
void
cdbg_DumpInquiryData
(inquiry)
register ALL_INQ_DATA
*inquiry;
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.
cdbg_DumpPDRVws - Dumps the contents of a SCSI/CAM Peripheral Device Driver Working Set structure
void
cdbg_DumpPDRVws
(pws)
register PDRV_WS
*pws;
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.
cdbg_DumpSCSIIO - Dumps the contents of a SCSI I/O CCB
void
cdbg_DumpSCSIIO
(ccb)
register CCB_SCSIIO
*ccb;
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.
cdbg_DumpTERMIO - Dumps the contents of a TERMINATE I/O CCB
void
cdbg_DumpTERMIO
(ccb)
register CCB_TERMIO
*ccb;
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.
cdbg_GetDeviceName - Returns a pointer to a character string that describes the dtype member of an ALL_INQ_DATA structure
char *
cdbg_GetDeviceName
(device_type)
register
device_type;
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.
Returns a pointer to a text string.
cdbg_ScsiStatus - Reports SCSI status codes
char *
cdbg_ScsiStatus
(scsi_status,
report_format)
register u_char
scsi_status;
int
report_format;
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.
Returns a pointer to a text string.
cdbg_SystemStatus - Reports system error codes
char *
cdbg_SystemStatus
(errno)
int
errno;
The cdbg_SystemStatus routine reports system error codes. The system error codes are defined in the /usr/sys/include/sys/errno.h file.
Returns a pointer to a text string.
cgen_async - Handles notification of asynchronous events
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;
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.
cgen_attach - Is called for each bus, target, and LUN after the cgen_slave routine returns SUCCESS
int
cgen_attach
(device)
struct device
*device;
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.
PROBE_FAILURE
PROBE_SUCCESS
ccmn_close_unit , ccmn_open_unit , cgen_slave
cgen_ccb_chkcond - Decodes the autosense data for a device driver
int
cgen_ccb_chkcond
(pdrv_dev,
ccb)
PDRV_DEVICE
*pdrv_dev;
CCB_SCSIIO
*ccb;
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.
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. |
cgen_close - Closes the device
int
cgen_close
(dev,
flags,
fmt)
dev_t
dev;
nt
flags;
int
fmt;
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.
The cgen_close routine returns GENERIC_SUCCESS upon successful completion.
The cgen_close routine fails under the following condition:
cgen_done - Serves as the entry point for all nonread and nonwrite I/O callbacks
void
cgen_done
(ccb)
CCB_SCSIIO
*ccb;
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.
cgen_ioctl - Handles user process requests for specific actions other than read, write, open, or close for SCSI tape devices
int
cgen_ioctl
(dev,
cmd,
data,
flags)
dev_t
dev;
int
cmd;
caddt_t
data;
int
flags;
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.
[EINVAL] Invalid command.
ccmn_rel_ccb , cgen_mode_sns , ioctl(2)
cgen_iodone - Serves as the entry point for all read and write I/O callbacks
int
cgen_iodone
(ccb)
CCB_SCSIIO
*ccb;
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.
None
cgen_minphys - Compares the b_bcount with the maximum transfer limit for the device
void
cgen_minphys
(bp)
register struct buf
*bp;
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.
cgen_mode_sns - Issues a SCSI_MODE_SENSE command to the unit defined
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;
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.
NULL - command could not be issued
CCB_SCSIIO pointer
cgen_open - Is called by the kernel when a user process requests an open of the device
int
cgen_open
(dev,
flags,
fmt)
dev_t
dev;
int
flags;
int
fmt;
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.
The cgen_open routine returns GENERIC_SUCCESS upon successful completion.
The cgen_open routine fails under the following conditions:
ccmn_close_unit , ccmn_open_unit , ccmn_rel_ccb , ccmn_sasy_ccb_bld , ccmn_tur , cgen_open_sel , cgen_close
cgen_open_sel - Issues a SCSI_MODE_SELECT command to the SCSI device
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;
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.
None
ccmn_ccb_status , ccmn_mode_select
cgen_read - Handles synchronous read requests for user processes
int
cgen_read
(dev,
uio)
dev_t
dev;
struct uio
*uio;
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.
The cgen_read routine passes the return from the physio routine.
ccmn_get_bp , ccmn_rel_bp , cgen_strategy
cgen_ready - Issues a TEST UNIT READY command to the unit defined
void
cgen_ready
(pdrv_dev,
action,
done,
sleep)
PDRV_DEVICE
*pdrv_dev;
CGEN_ACTION
*action;
void
(*done)();
u_long
sleep;
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.
None
cgen_slave - Is called at system boot to initialize the lower levels
int
cgen_slave
(device,
reg)
struct device
*device;
caddr_t
reg;
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.
PROBE_FAILURE
PROBE_SUCCESS
ccmn_close_unit , ccmn_init , ccmn_open_unit
cgen_strategy - Handles all I/O requests for user processes
int
cgen_strategy
(bp)
struct buf
*bp;
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.
[EINVAL] Device not ready.
[EIO]
ccmn_io_ccb_bld , ccmn_send_ccb , cgen_iodone
cgen_write - Handles synchronous write requests for user processes
int
cgen_write
(dev,
uio)
dev_t
dev;
struct uio
*uio;
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.
The cgen_write routine passes the return from the physio routine.
ccmn_get_bp , ccmn_rel_bp , cgen_strategy
sim_action - Initiates an I/O request from a SCSI/CAM peripheral device driver
int
sim_action
(ccb_hdr)
CCB_HEADER
*ccb_hdr;
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.
CAM_REQ_INPROG for queued commands
CAM_REQ_CMP for immediate commands
A valid CAM error value
American National Standard for Information Systems, SCSI-2 Common Access Method: Transport and SCSI Interface Module, working draft, X3T9.2/90-186
sim_init - Initializes the SIM
int
sim_init
(pathid)
u_long
pathid;
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.
uagt_close - Handles the close of the User Agent driver
void
uagt_close
(dev,
flag)
dev_t
dev;
int
flag;
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.
None
uagt_ioctl - Handles the ioctl system call for the User Agent driver
int
uagt_ioctl
(dev,
cmd,
data,
flag)
dev_t
dev;
register int
cmd;
caddr_t
data;
int
flag;
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.
The uagt_ioctl routine returns a value of 0 (zero) upon successful completion.
The uagt_ioctl routine fails under the following conditions:
ioctl(2), xpt_action, xpt_ccb_alloc
uagt_open - Handles the open of the User Agent driver
int
uagt_open
(dev,
flag)
dev_t
dev;
int
flag;
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.
The uagt_open routine returns a value of 0 (zero) upon successful completion.
xpt_action - Calls the appropriate XPT/SIM routine
I32
xpt_action
(ch)
CCB_HEADER
*ch;
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.
Upon completion, the xpt_action routine returns a valid CAM status value.
xpt_ccb_alloc - Allocates a CAM control block (CCB)
CCB_HEADER *
xpt_ccb_alloc()
None
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.
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.
xpt_ccb_free - Frees a previously allocated CCB
I32
xpt_ccb_free
(ch)
CCB_HEADER
*ch;
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.
XPT_CCB_INVALID or CAM_SUCCESS
xpt_init - Validates the initialized state of the CAM subsystem
long
xpt_init()
None
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.
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. |