1scsi_pktalloc(9F)        Kernel Functions for Drivers        scsi_pktalloc(9F)
2
3
4

NAME

6       scsi_pktalloc,  scsi_resalloc, scsi_pktfree, scsi_resfree - SCSI packet
7       utility routines
8

SYNOPSIS

10       #include <sys/scsi/scsi.h>
11
12       struct scsi_pkt *scsi_pktalloc (struct scsi_address* ap, int cmdlen,
13            int statuslen, int (*callback)(void));
14
15
16       struct scsi_pkt *scsi_resalloc (struct scsi_address* ap, int cmdlen,
17            int statuslen, opaque_t dmatoken, int (*callback)(void));
18
19
20       void scsi_pktfree (struct scsi_pkt* pkt);
21
22
23       void scsi_resfree (struct scsi_pkt* pkt);
24
25

INTERFACE LEVEL

27       The scsi_pktalloc(),  scsi_pktfree(),  scsi_resalloc(),  and  scsi_res‐
28       free()  functions are obsolete. The scsi_pktalloc() and scsi_resalloc()
29       functions have been replaced by scsi_init_pkt(9F).  The  scsi_pktfree()
30       and     scsi_resfree()     functions     have    been    replaced    by
31       scsi_destroy_pkt(9F).
32

PARAMETERS

34       ap           Pointer to a scsi_address structure.
35
36
37       cmdlen       The required length for the SCSI command descriptor  block
38                    (CDB) in bytes.
39
40
41       statuslen    The  required  length for the SCSI status completion block
42                    (SCB) in bytes.
43
44
45       dmatoken     Pointer to an implementation-dependent object.
46
47
48       callback     A  pointer  to  a  callback  function,  or  NULL_FUNC   or
49                    SLEEP_FUNC.
50
51
52       pkt          Pointer to a scsi_pkt(9S) structure.
53
54

DESCRIPTION

56       The  scsi_pktalloc() function requests the host adapter driver to allo‐
57       cate a command packet. For commands that have a data  transfer  associ‐
58       ated with them, scsi_resalloc() should be used.
59
60
61       ap  is a pointer to a scsi_address structure. Allocator routines use it
62       to determine the associated host adapter.
63
64
65       The cmdlen parameter is  the  required  length  for  the  SCSI  command
66       descriptor  block.  This  block is allocated such that a kernel virtual
67       address is established in the pkt_cdbp field of the allocated  scsi_pkt
68       structure.
69
70
71       statuslen  is the required length for the SCSI status completion block.
72       The address of the allocated block is placed into the pkt_scbp field of
73       the scsi_pkt structure.
74
75
76       The  dmatoken  parameter  is  a  pointer to an implementation dependent
77       object which defines the length, direction, and  address  of  the  data
78       transfer  associated with this SCSI packet (command). The dmatoken must
79       be a pointer to a buf(9S)  structure.  If  dmatoken  is  NULL,  no  DMA
80       resources  are  required  by  this SCSI command, so none are allocated.
81       Only one transfer direction is allowed per  command.  If  there  is  an
82       unexpected data transfer phase (either no data transfer phase expected,
83       or the wrong direction encountered), the command is terminated with the
84       pkt_reason  set  to  CMD_DMA_DERR. dmatoken provides the information to
85       determine if the transfer count is correct.
86
87
88       callback indicates what the allocator routines should do when resources
89       are not available:
90
91       NULL_FUNC       Do not wait for resources. Return a NULL pointer.
92
93
94       SLEEP_FUNC      Wait indefinitely for resources.
95
96
97       Other Values    callback  points  to  a  function  which is called when
98                       resources may  have  become  available.  callback  must
99                       return  either 0 (indicating that it attempted to allo‐
100                       cate resources but again failed to  do  so),  in  which
101                       case it is put back on a list to be called again later,
102                       or 1 indicating either success in allocating  resources
103                       or indicating that it no longer cares for a retry.
104
105
106
107       The scsi_pktfree() function frees the packet.
108
109
110       The  scsi_resfree()  function free all resources held by the packet and
111       the packet itself.
112

RETURN VALUES

114       Both allocation routines return a pointer to a  scsi_pkt  structure  on
115       success, or NULL on failure.
116

CONTEXT

118       If  callback  is  SLEEP_FUNC, then this routine can be called only from
119       user or kernel context. Otherwise, it can be called from user,  kernel,
120       or  interrupt context. The callback function may not block or call rou‐
121       tines that block. Both deallocation routines can be called  from  user,
122       kernel, or interrupt context.
123

ATTRIBUTES

125       See attributes(5) for a description of the following attributes:
126
127
128
129
130       ┌─────────────────────────────┬─────────────────────────────┐
131ATTRIBUTE TYPE         ATTRIBUTE VALUE        
132       ├─────────────────────────────┼─────────────────────────────┤
133       │Stability Level              │Obsolete                     │
134       └─────────────────────────────┴─────────────────────────────┘
135

SEE ALSO

137       attributes(5), scsi_dmafree(9F), scsi_dmaget(9F), buf(9S), scsi_pkt(9S)
138
139
140       Writing Device Drivers
141

NOTES

143       The  scsi_pktalloc(),  scsi_pktfree(),  scsi_resalloc(),  and scsi_res‐
144       free() functions are obsolete and will  be  discontinued  in  a  future
145       release.  The  scsi_pktalloc()  and scsi_resalloc() functions have been
146       replaced by scsi_init_pkt(9F). The  scsi_pktfree()  and  scsi_resfree()
147       functions have been replaced by scsi_destroy_pkt(9F).
148
149
150
151SunOS 5.11                        16 Jan 2006                scsi_pktalloc(9F)
Impressum