2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH TRAN_SETUP_PKT 9E "Mar 13, 2016"
8 tran_setup_pkt, tran_teardown_pkt, tran_pkt_constructor, tran_pkt_destructor \-
9 SCSI HBA packet allocation and deallocation
13 #include <sys/scsi/scsi.h>
15 \fBint \fR\fBprefix_tran_setup_pkt\fR(\fBstruct scsi_pkt *\fR\fIpkt\fR,
16 \fBint (*\fR\fIcallback\fR) (\fIcaddr_t\fR), \fBcaddr_t\fR \fIarg\fR);
21 \fBvoid\fR \fBprefix_tran_teardown_pkt\fR(\fBstruct scsi_pkt *\fR\fIpkt\fR);
26 \fBint\fR \fBprefix_tran_pkt_constructor\fR(\fBstruct scsi_pkt *\fR\fIpkt\fR,
27 \fBscsi_hba_tran_t *\fR\fItranp\fR, \fBint\fR \fIkmflags\fR);
32 \fBvoid\fR \fBprefix_tran_pkt_destructor\fR(\fBstruct scsi_pkt *\fR\fIpkt\fR,
33 \fBstruct scsi_hba_tran_t *\fR\fItranp\fR);
38 Solaris architecture specific (Solaris DDI).
45 Pointer to the \fBscsi_pkt\fR(9S) structure.
54 Flags for associating DMA resources with the packet.
63 Pointer to either \fBNULL_FUNC\fR or \fBSLEEP_FUNC\fR.
81 Either \fBKM_SLEEP\fR or \fBKM_NOSLEEP\fR.
86 The \fBtran_setup_pkt()\fR and \fBtran_destroy_pkt()\fR vectors in the
87 \fBscsi_hba_tran\fR(9S) structure are alternatives to the \fBtran_init_pkt()\fR
88 and \fBtran_destroy_pkt()\fR entry points. They are initialized during the
89 \fBHBA\fR driver's \fBattach\fR(9E) and they are used when a target driver
90 calls \fBscsi_init_pkt\fR(9F) and \fBscsi_destroy_pkt\fR(9F).
91 .SS "tran_setup_pkt(\|)"
93 The \fBtran_setup_pkt()\fR vector is the entry point into the \fBHBA\fR which
94 is used to initialize \fBHBA\fR specific information in a \fBscsi_pkt\fR
95 structure on behalf of a SCSI target driver. All fields documented in
96 \fBscsi_pkt\fR(9S) are initialized.
99 If the \fBHBA\fR driver chose not to preallocate memory for \fBpkt_cdbp\fR
100 and/or \fBpkt_scbp\fR, it must allocate the requested memory at this time and
101 point \fBpkt_cdbp\fR and \fBpkt_scbp\fR to the allocated memory.
104 An \fBHBA\fR driver which provides a \fBtran_setup_pkt\fR entry point inspects
105 the \fBpkt_numcookies\fR and \fBpkt_cookies\fR fields at \fBtran_start\fR time
106 to set up the transfer. If \fBpkt_numcookies\fR is zero, there are no \fBDMA\fR
107 resources associated with this packet. If \fBpkt_numcookies\fR is not zero, it
108 indicates the number of \fBDMA\fR cookies that \fBpkt_cookies\fR points to.
111 The \fBpkt_tgtlen\fR field contains the length of the packet private area
112 pointed to by \fBpkt_private\fR, allocated on behalf of the SCSI target driver.
115 The \fBpkt_scblen\fR field contains the length of the SCSI status completion
116 block pointed to by \fBpkt_scbp\fR. If the status length is greater than or
117 equal to sizeof (\fBstruct\fR \fBscsi_arq_status\fR) and the
118 \fBauto-rqsense\fR capability has been set, automatic request sense (\fBARS\fR)
119 is enabled for this packet. If the status length is less than \fBsizeof\fR
120 (\fBstruct\fR \fBscsi_arq_status\fR), automatic request sense should be
121 disabled for this pkt if the \fBHBA\fR driver is capable of disabling \fBARQ\fR
122 on a per-packet basis.
125 The \fBpkt_cdblen\fR field contains the length of the SCSI command descriptor
129 The \fIcallback\fR argument indicates what the allocator routines should do
130 when resources are not available:
134 \fB\fBNULL_FUNC\fR\fR
137 Do not wait for resources. Return \fB-1\fR when resources are not available.
143 \fB\fBSLEEP_FUNC\fR\fR
146 Wait indefinitely for resources.
149 .SS "tran_teardown_pkt(\|)"
151 The \fBtran_teardown_pkt()\fR is the entry point into the \fBHBA\fR that must
152 free all of the resources that were allocated to the \fBscsi_pkt\fR(9S)
153 structure during \fBtran_setup_pkt()\fR.
154 .SS "tran_pkt_constructor(\|) tran_pkt_destructor(\|)"
156 When using \fBtran_pkt_setup()\fR and \fBtran_pkt_teardown()\fR,
157 \fBtran_pkt_constructor()\fR and \fBtran_pkt_destructor()\fR are additional
158 optional entry points that perform the actions of a constructor and destructor.
159 The constructor is called after the following fields in the \fBscsi_pkt\fR
160 structure have been initialized:
211 Allocating and freeing a \fBDMA\fR handle are examples of something that could
212 be done in the constructor and destructor. See \fBkmem_cache_create\fR(9F) for
213 additional restrictions on what actions can be performed in a constructor and
217 HBA drivers that implement \fBtran_setup_pkt()\fR must signal
218 \fBscsi_pkt\fR(9S) completion by calling \fBscsi_hba_pkt_comp\fR(9F). Direct
219 use of the \fBscsi_pkt\fR \fIpkt_comp\fR field is not permitted and results in
223 \fBtran_setup_pkt()\fR must return zero on success, and \fB-1\fR on failure.
226 \fBattach\fR(9E), \fBtran_sync_pkt\fR(9E), \fBbioerror\fR(9F),
227 \fBddi_dma_buf_bind_handle\fR(9F), \fBkmem_cache_create\fR(9F),
228 \fBscsi_alloc_consistent_buf\fR(9F), \fBscsi_destroy_pkt\fR(9F),
229 \fBscsi_hba_attach\fR(9F), \fBscsi_hba_pkt_alloc\fR(9F),
230 \fBscsi_hba_pkt_comp\fR(9F), \fBscsi_hba_pkt_free\fR(9F),
231 \fBscsi_init_pkt\fR(9F), \fBbuf\fR(9S), \fBscsi_address\fR(9S),
232 \fBscsi_hba_tran\fR(9S), \fBscsi_pkt\fR(9S)
235 \fIWriting Device Drivers\fR