'\" 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_PKTALLOC 9F "Jan 16, 2006" .SH NAME scsi_pktalloc, scsi_resalloc, scsi_pktfree, scsi_resfree \- SCSI packet utility routines .SH SYNOPSIS .LP .nf #include \fBstruct scsi_pkt *\fR\fBscsi_pktalloc\fR (\fBstruct scsi_address*\fR \fIap\fR, \fBint\fR \fIcmdlen\fR, \fBint\fR \fIstatuslen\fR, \fBint\fR (\fI*callback\fR)(\fIvoid\fR)); .fi .LP .nf \fBstruct scsi_pkt *\fR\fBscsi_resalloc\fR (\fBstruct scsi_address*\fR \fIap\fR, \fBint\fR \fIcmdlen\fR, \fBint\fR \fIstatuslen\fR, \fBopaque_t\fR \fIdmatoken\fR, \fBint\fR (\fI*callback\fR)(\fIvoid\fR)); .fi .LP .nf \fBvoid\fR \fBscsi_pktfree\fR (\fBstruct scsi_pkt*\fR \fIpkt\fR); .fi .LP .nf \fBvoid\fR \fBscsi_resfree\fR (\fBstruct scsi_pkt*\fR \fIpkt\fR); .fi .SH INTERFACE LEVEL .sp .LP The \fBscsi_pktalloc()\fR, \fBscsi_pktfree()\fR, \fBscsi_resalloc()\fR, and \fBscsi_resfree()\fR functions are obsolete. The \fBscsi_pktalloc()\fR and \fBscsi_resalloc()\fR functions have been replaced by \fBscsi_init_pkt\fR(9F). The \fBscsi_pktfree()\fR and \fBscsi_resfree()\fR functions have been replaced by \fBscsi_destroy_pkt\fR(9F). .SH PARAMETERS .sp .ne 2 .na \fB\fIap\fR\fR .ad .RS 13n Pointer to a \fBscsi_address\fR structure. .RE .sp .ne 2 .na \fB\fIcmdlen\fR\fR .ad .RS 13n The required length for the \fBSCSI \fRcommand descriptor block (\fBCDB\fR) in bytes. .RE .sp .ne 2 .na \fB\fIstatuslen\fR\fR .ad .RS 13n The required length for the \fBSCSI\fR status completion block (\fBSCB\fR) in bytes. .RE .sp .ne 2 .na \fB\fIdmatoken\fR\fR .ad .RS 13n Pointer to an implementation-dependent object. .RE .sp .ne 2 .na \fB\fIcallback\fR\fR .ad .RS 13n A pointer to a callback function, or \fBNULL_FUNC\fR or \fBSLEEP_FUNC\fR. .RE .sp .ne 2 .na \fB\fIpkt\fR\fR .ad .RS 13n Pointer to a \fBscsi_pkt\fR(9S) structure. .RE .SH DESCRIPTION .sp .LP The \fBscsi_pktalloc()\fR function requests the host adapter driver to allocate a command packet. For commands that have a data transfer associated with them, \fBscsi_resalloc()\fR should be used. .sp .LP \fIap\fR is a pointer to a \fBscsi_address\fR structure. Allocator routines use it to determine the associated host adapter. .sp .LP The \fIcmdlen\fR parameter is the required length for the \fBSCSI \fRcommand descriptor block. This block is allocated such that a kernel virtual address is established in the \fBpkt_cdbp\fR field of the allocated \fBscsi_pkt\fR structure. .sp .LP \fIstatuslen\fR is the required length for the \fBSCSI \fRstatus completion block. The address of the allocated block is placed into the \fBpkt_scbp\fR field of the \fBscsi_pkt\fR structure. .sp .LP The \fIdmatoken\fR parameter is a pointer to an implementation dependent object which defines the length, direction, and address of the data transfer associated with this \fBSCSI\fR packet (command). The \fIdmatoken\fR must be a pointer to a \fBbuf\fR(9S) structure. If \fIdmatoken\fR is \fINULL\fR, no \fBDMA\fR resources are required by this \fBSCSI\fR command, so none are allocated. Only one transfer direction is allowed per command. If there is an unexpected data transfer phase (either no data transfer phase expected, or the wrong direction encountered), the command is terminated with the \fBpkt_reason\fR set to \fBCMD_DMA_DERR\fR. \fIdmatoken\fR provides the information to determine if the transfer count is correct. .sp .LP \fIcallback\fR indicates what the allocator routines should do when resources are not available: .sp .ne 2 .na \fB\fBNULL_FUNC\fR\fR .ad .RS 16n Do not wait for resources. Return a \fINULL\fR pointer. .RE .sp .ne 2 .na \fB\fBSLEEP_FUNC\fR\fR .ad .RS 16n Wait indefinitely for resources. .RE .sp .ne 2 .na \fBOther Values\fR .ad .RS 16n \fIcallback\fR points to a function which is called when resources may have become available. \fIcallback\fR must return either \fB0\fR (indicating that it attempted to allocate resources but again failed to do so), in which case it is put back on a list to be called again later, or \fB1\fR indicating either success in allocating resources or indicating that it no longer cares for a retry. .RE .sp .LP The \fBscsi_pktfree()\fR function frees the packet. .sp .LP The \fBscsi_resfree()\fR function free all resources held by the packet and the packet itself. .SH RETURN VALUES .sp .LP Both allocation routines return a pointer to a \fBscsi_pkt\fR structure on success, or \fINULL\fR on failure. .SH CONTEXT .sp .LP If \fIcallback\fR is \fBSLEEP_FUNC\fR, then this routine can be called only from user or kernel context. Otherwise, it can be called from user, kernel, or interrupt context. The \fIcallback\fR function may not block or call routines that block. Both deallocation routines can be called from user, kernel, or interrupt context. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for a description of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Stability Level Obsolete .TE .SH SEE ALSO .sp .LP .BR attributes (7), .BR scsi_dmafree (9F), .BR scsi_dmaget (9F), .BR buf (9S), .BR scsi_pkt (9S) .sp .LP \fIWriting Device Drivers\fR .SH NOTES .sp .LP The \fBscsi_pktalloc()\fR, \fBscsi_pktfree()\fR, \fBscsi_resalloc()\fR, and \fBscsi_resfree()\fR functions are obsolete and will be discontinued in a future release. The \fBscsi_pktalloc()\fR and \fBscsi_resalloc()\fR functions have been replaced by \fBscsi_init_pkt\fR(9F). The \fBscsi_pktfree()\fR and \fBscsi_resfree()\fR functions have been replaced by \fBscsi_destroy_pkt\fR(9F).