'\" te .\" Copyright (c) 2006, Sun Microsystems, Inc., All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH SCSI_HBA_PKT_ALLOC 9F "Dec 11, 2006" .SH NAME scsi_hba_pkt_alloc, scsi_hba_pkt_free \- allocate and free a scsi_pkt structure .SH SYNOPSIS .nf #include \fBstruct scsi_pkt *\fR\fBscsi_hba_pkt_alloc\fR(\fBdev_info_t *\fR\fIdip\fR, \fBstruct scsi_address *\fR\fIap\fR, \fBint\fR \fIcmdlen\fR, \fBint\fR \fIstatuslen\fR, \fBint\fR \fItgtlen\fR, \fBint\fR \fIhbalen\fR, \fBint\fR (*\fIcallback\fR)(\fBcaddr_t\fR \fIarg\fR), \fBcaddr_t\fR \fIarg\fR); .fi .LP .nf \fBvoid\fR \fBscsi_hba_pkt_free\fR(\fBstruct scsi_address *\fR\fIap\fR, \fBstruct scsi_pkt *\fR\fIpkt\fR); .fi .SH INTERFACE LEVEL illumos architecture specific (illumos DDI). .SH PARAMETERS .ne 2 .na \fB\fIdip\fR\fR .ad .RS 13n Pointer to a \fBdev_info_t\fR structure, defining the \fBHBA\fR driver instance. .RE .sp .ne 2 .na \fB\fIap\fR\fR .ad .RS 13n Pointer to a \fBscsi_address\fR(9S) structure, defining the target instance. .RE .sp .ne 2 .na \fB\fIcmdlen\fR\fR .ad .RS 13n Length in bytes to be allocated for the \fBSCSI\fR command descriptor block (\fBCDB\fR). .RE .sp .ne 2 .na \fB\fIstatuslen\fR\fR .ad .RS 13n Length in bytes to be allocated for the \fBSCSI\fR status completion block (\fBSCB\fR). .RE .sp .ne 2 .na \fB\fItgtlen\fR\fR .ad .RS 13n Length in bytes to be allocated for a private data area for the target driver's exclusive use. .RE .sp .ne 2 .na \fB\fIhbalen\fR\fR .ad .RS 13n Length in bytes to be allocated for a private data area for the \fBHBA\fR driver's exclusive use. .RE .sp .ne 2 .na \fB\fIcallback\fR\fR .ad .RS 13n Indicates what \fBscsi_hba_pkt_alloc()\fR should do when resources are not available: .sp .ne 2 .na \fB\fBNULL_FUNC\fR\fR .ad .RS 14n Do not wait for resources. Return a \fINULL\fR pointer. .RE .sp .ne 2 .na \fB\fBSLEEP_FUNC\fR\fR .ad .RS 14n Wait indefinitely for resources. .RE .RE .sp .ne 2 .na \fB\fIarg\fR\fR .ad .RS 13n Must be \fINULL.\fR .RE .sp .ne 2 .na \fB\fIpkt\fR\fR .ad .RS 13n A pointer to a \fBscsi_pkt\fR(9S) structure. .RE .SH DESCRIPTION For \fBscsi_hba_pkt_alloc()\fR: .sp .LP The \fBscsi_hba_pkt_alloc()\fR function allocates space for a \fBscsi_pkt\fR structure. \fBHBA\fR drivers must use this interface when allocating a \fBscsi_pkt\fR from their \fBtran_init_pkt\fR(9E) entry point. .sp .LP If \fIcallback\fR is \fBNULL_FUNC\fR, \fBscsi_hba_pkt_alloc()\fR may not sleep when allocating resources, and callers should be prepared to deal with allocation failures. .sp .LP The \fBscsi_hba_pkt_alloc()\fR function copies the \fBscsi_address\fR(9S) structure pointed to by \fIap\fR to the \fBpkt_address\fR field in the \fBscsi_pkt\fR(9S). .sp .LP The \fBscsi_hba_pkt_alloc()\fR function also allocates memory for these \fBscsi_pkt\fR(9S) data areas, and sets these fields to point to the allocated memory: .sp .ne 2 .na \fB\fBpkt_ha_private\fR\fR .ad .RS 18n \fBHBA\fR private data area. .RE .sp .ne 2 .na \fB\fBpkt_private\fR\fR .ad .RS 18n Target driver private data area. .RE .sp .ne 2 .na \fB\fBpkt_scbp\fR\fR .ad .RS 18n \fBSCSI\fR status completion block. .RE .sp .ne 2 .na \fB\fBpkt_cdbp\fR\fR .ad .RS 18n \fBSCSI\fR command descriptor block. .RE .sp .LP For \fBscsi_hba_pkt_free()\fR: .sp .LP The \fBscsi_hba_pkt_free()\fR function frees the space allocated for the \fBscsi_pkt\fR(9S) structure. .SH RETURN VALUES The \fBscsi_hba_pkt_alloc()\fR function returns a pointer to the \fBscsi_pkt\fR structure, or \fINULL\fR if no space is available. .SH CONTEXT The \fBscsi_hba_pkt_alloc()\fR function can be called from user, interrupt, or kernel context. Drivers must not allow \fBscsi_hba_pkt_alloc()\fR to sleep if called from an interrupt routine. .sp .LP The \fBscsi_hba_pkt_free()\fR function can be called from user, interrupt, or kernel context. .SH SEE ALSO \fBtran_init_pkt\fR(9E), \fBscsi_address\fR(9S), \fBscsi_pkt\fR(9S) .sp .LP \fIWriting Device Drivers\fR