Copyright (c) 2009, 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]
#include <sys/scsi/scsi.h> int prefix_tran_setup_pkt(struct scsi_pkt *pkt, int (*callback) (caddr_t), caddr_t arg);
void prefix_tran_teardown_pkt(struct scsi_pkt *pkt);
int prefix_tran_pkt_constructor(struct scsi_pkt *pkt, scsi_hba_tran_t *tranp, int kmflags);
void prefix_tran_pkt_destructor(struct scsi_pkt *pkt, struct scsi_hba_tran_t *tranp);
Pointer to the scsi_pkt(9S) structure.
Flags for associating DMA resources with the packet.
Pointer to either NULL_FUNC or SLEEP_FUNC.
Always NULL.
Either KM_SLEEP or KM_NOSLEEP.
If the HBA driver chose not to preallocate memory for pkt_cdbp and/or pkt_scbp, it must allocate the requested memory at this time and point pkt_cdbp and pkt_scbp to the allocated memory.
An HBA driver which provides a tran_setup_pkt entry point inspects the pkt_numcookies and pkt_cookies fields at tran_start time to set up the transfer. If pkt_numcookies is zero, there are no DMA resources associated with this packet. If pkt_numcookies is not zero, it indicates the number of DMA cookies that pkt_cookies points to.
The pkt_tgtlen field contains the length of the packet private area pointed to by pkt_private, allocated on behalf of the SCSI target driver.
The pkt_scblen field contains the length of the SCSI status completion block pointed to by pkt_scbp. If the status length is greater than or equal to sizeof (struct scsi_arq_status) and the auto-rqsense capability has been set, automatic request sense (ARS) is enabled for this packet. If the status length is less than sizeof (struct scsi_arq_status), automatic request sense should be disabled for this pkt if the HBA driver is capable of disabling ARQ on a per-packet basis.
The pkt_cdblen field contains the length of the SCSI command descriptor block.
The callback argument indicates what the allocator routines should do when resources are not available: NULL_FUNC
Do not wait for resources. Return -1 when resources are not available.
Wait indefinitely for resources.
pkt_address
pkt_ha_private
pkt_cdbp
pkt_private
pkt_scbp
pkt_cdblen
pkt_tgtlen
pkt_scblen
Allocating and freeing a DMA handle are examples of something that could be done in the constructor and destructor. See kmem_cache_create(9F) for additional restrictions on what actions can be performed in a constructor and destructor.
HBA drivers that implement tran_setup_pkt() must signal scsi_pkt(9S) completion by calling scsi_hba_pkt_comp(9F). Direct use of the scsi_pkt pkt_comp field is not permitted and results in undefined behavior.
Writing Device Drivers