get_pktiopb(9F)
NAME
get_pktiopb, free_pktiopb − allocate/free a SCSI packet in the iopb map
SYNOPSIS
#include <sys/scsi/scsi.h>
struct scsi_pkt ∗get_pktiopb(struct scsi_address ∗ap, caddr_t ∗datap, int cdblen,
int statuslen, int datalen, int readflag, int (∗callback)(void));
void free_pktiopb(struct scsi_pkt ∗pkt, caddr_t datap, int datalen);
ARGUMENTS
ap Pointer to the target’s scsi_address structure.
datap Pointer to the address of the packet, set by this function.
cdblen Number of bytes required for the SCSI command descriptor block (CDB).
statuslen Number of bytes required for the SCSI status area.
datalen Number of bytes required for the data area of the SCSI command.
readflag If non-zero, data will be transferred from the SCSI target.
callback Pointer to a callback function, or NULL_FUNC or SLEEP_FUNC (refer to scsi_pktalloc(9F) for details on the usage of callback).
pkt Pointer to a scsi_pkt(9S) structure.
INTERFACE LEVEL
SPARC architecture specific (SPARC DDI).
DESCRIPTION
get_pktiopb() allocates a scsi_pkt structure that has a small data area allocated. It is used by some SCSI commands such as REQUEST_SENSE, which involve a small amount of data and require cache-consistent memory for proper operation. It uses ddi_iopb_alloc(9F) for allocating the data area and scsi_resalloc(9F) to allocate the packet and DMA resources.
callback indicates what get_pktiopb() should do when DMA resources are not available:
NULL_FUNC Do not wait for resources. Return a null pointer.
SLEEP_FUNC
Wait indefinitely for resources.
Other Values callback points to a function which is called when resources may become available. callback must return either 0 (indicating that it attempted to allocate a DMA mapping but failed to do so again), in which case it is put back on a list to be called again later, or 1 indicating either success in allocating DMA resources or indicating that it no longer cares for a retry.
free_pktiopb() is used for freeing the packet and its associated resources.
RETURN VALUES
get_pktiopb() returns a pointer to the newly allocated scsi_pkt or a NULL pointer.
CONTEXT
get_pktiopb() can be called from user or interrupt context except when callback is set to a value other than NULL_FUNC, in which case it can be called from user context only.
free_pktiopb() can be called from user or interrupt context.
SEE ALSO
ddi_iopb_alloc(9F), scsi_pktalloc(9F), scsi_resalloc(9F), scsi_pkt(9S)
SunOS 5.1 Writing Device Drivers
NOTES
get_pktiopb() uses scarce resources. Use it selectively.
SunOS 5.1/SPARC — Last change: 17 Sep 1992