2 .\" Copyright (c) 2006, Sun Microsystems, Inc.,
3 .\" All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH SCSI_PKTALLOC 9F "Jan 16, 2006"
9 scsi_pktalloc, scsi_resalloc, scsi_pktfree, scsi_resfree \- SCSI packet utility
14 #include <sys/scsi/scsi.h>
16 \fBstruct scsi_pkt *\fR\fBscsi_pktalloc\fR (\fBstruct scsi_address*\fR \fIap\fR, \fBint\fR \fIcmdlen\fR,
17 \fBint\fR \fIstatuslen\fR, \fBint\fR (\fI*callback\fR)(\fIvoid\fR));
22 \fBstruct scsi_pkt *\fR\fBscsi_resalloc\fR (\fBstruct scsi_address*\fR \fIap\fR, \fBint\fR \fIcmdlen\fR,
23 \fBint\fR \fIstatuslen\fR, \fBopaque_t\fR \fIdmatoken\fR, \fBint\fR (\fI*callback\fR)(\fIvoid\fR));
28 \fBvoid\fR \fBscsi_pktfree\fR (\fBstruct scsi_pkt*\fR \fIpkt\fR);
33 \fBvoid\fR \fBscsi_resfree\fR (\fBstruct scsi_pkt*\fR \fIpkt\fR);
39 The \fBscsi_pktalloc()\fR, \fBscsi_pktfree()\fR, \fBscsi_resalloc()\fR, and
40 \fBscsi_resfree()\fR functions are obsolete. The \fBscsi_pktalloc()\fR and
41 \fBscsi_resalloc()\fR functions have been replaced by \fBscsi_init_pkt\fR(9F).
42 The \fBscsi_pktfree()\fR and \fBscsi_resfree()\fR functions have been replaced
43 by \fBscsi_destroy_pkt\fR(9F).
51 Pointer to a \fBscsi_address\fR structure.
60 The required length for the \fBSCSI \fRcommand descriptor block (\fBCDB\fR) in
70 The required length for the \fBSCSI\fR status completion block (\fBSCB\fR) in
80 Pointer to an implementation-dependent object.
89 A pointer to a callback function, or \fBNULL_FUNC\fR or \fBSLEEP_FUNC\fR.
98 Pointer to a \fBscsi_pkt\fR(9S) structure.
104 The \fBscsi_pktalloc()\fR function requests the host adapter driver to allocate
105 a command packet. For commands that have a data transfer associated with them,
106 \fBscsi_resalloc()\fR should be used.
109 \fIap\fR is a pointer to a \fBscsi_address\fR structure. Allocator routines use
110 it to determine the associated host adapter.
113 The \fIcmdlen\fR parameter is the required length for the \fBSCSI \fRcommand
114 descriptor block. This block is allocated such that a kernel virtual address is
115 established in the \fBpkt_cdbp\fR field of the allocated \fBscsi_pkt\fR
119 \fIstatuslen\fR is the required length for the \fBSCSI \fRstatus completion
120 block. The address of the allocated block is placed into the \fBpkt_scbp\fR
121 field of the \fBscsi_pkt\fR structure.
124 The \fIdmatoken\fR parameter is a pointer to an implementation dependent object
125 which defines the length, direction, and address of the data transfer
126 associated with this \fBSCSI\fR packet (command). The \fIdmatoken\fR must be a
127 pointer to a \fBbuf\fR(9S) structure. If \fIdmatoken\fR is \fINULL\fR, no
128 \fBDMA\fR resources are required by this \fBSCSI\fR command, so none are
129 allocated. Only one transfer direction is allowed per command. If there is an
130 unexpected data transfer phase (either no data transfer phase expected, or the
131 wrong direction encountered), the command is terminated with the
132 \fBpkt_reason\fR set to \fBCMD_DMA_DERR\fR. \fIdmatoken\fR provides the
133 information to determine if the transfer count is correct.
136 \fIcallback\fR indicates what the allocator routines should do when resources
141 \fB\fBNULL_FUNC\fR\fR
144 Do not wait for resources. Return a \fINULL\fR pointer.
150 \fB\fBSLEEP_FUNC\fR\fR
153 Wait indefinitely for resources.
162 \fIcallback\fR points to a function which is called when resources may have
163 become available. \fIcallback\fR must return either \fB0\fR (indicating that it
164 attempted to allocate resources but again failed to do so), in which case it is
165 put back on a list to be called again later, or \fB1\fR indicating either
166 success in allocating resources or indicating that it no longer cares for a
172 The \fBscsi_pktfree()\fR function frees the packet.
175 The \fBscsi_resfree()\fR function free all resources held by the packet and the
180 Both allocation routines return a pointer to a \fBscsi_pkt\fR structure on
181 success, or \fINULL\fR on failure.
185 If \fIcallback\fR is \fBSLEEP_FUNC\fR, then this routine can be called only
186 from user or kernel context. Otherwise, it can be called from user, kernel, or
187 interrupt context. The \fIcallback\fR function may not block or call routines
188 that block. Both deallocation routines can be called from user, kernel, or
193 See \fBattributes\fR(5) for a description of the following attributes:
201 ATTRIBUTE TYPE ATTRIBUTE VALUE
203 Stability Level Obsolete
209 \fBattributes\fR(5), \fBscsi_dmafree\fR(9F), \fBscsi_dmaget\fR(9F),
210 \fBbuf\fR(9S), \fBscsi_pkt\fR(9S)
213 \fIWriting Device Drivers\fR
217 The \fBscsi_pktalloc()\fR, \fBscsi_pktfree()\fR, \fBscsi_resalloc()\fR, and
218 \fBscsi_resfree()\fR functions are obsolete and will be discontinued in a
219 future release. The \fBscsi_pktalloc()\fR and \fBscsi_resalloc()\fR functions
220 have been replaced by \fBscsi_init_pkt\fR(9F). The \fBscsi_pktfree()\fR and
221 \fBscsi_resfree()\fR functions have been replaced by
222 \fBscsi_destroy_pkt\fR(9F).