1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
'\" 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 <sys/scsi/scsi.h>
\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(5) 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
\fBattributes\fR(5), \fBscsi_dmafree\fR(9F), \fBscsi_dmaget\fR(9F),
\fBbuf\fR(9S), \fBscsi_pkt\fR(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).
|