1scsi_alloc_consistent_buf(K9eFr)nel Functions for Drivsecrssi_alloc_consistent_buf(9F)
2
3
4

NAME

6       scsi_alloc_consistent_buf - allocate an I/O buffer for SCSI DMA
7

SYNOPSIS

9       #include <sys/scsi/scsi.h>
10
11
12
13       struct buf *scsi_alloc_consistent_buf(structscsi_address*ap,
14            struct buf *bp, size_t datalen, uint_t bflags,
15            int (*callback)(caddr_t), caddr_t arg);
16
17

INTERFACE LEVEL

19       Solaris DDI specific (Solaris DDI).
20

PARAMETERS

22       ap          Pointer to the scsi_address(9S) structure.
23
24
25       bp          Pointer to the buf(9S) structure.
26
27
28       datalen     Number of bytes for the data buffer.
29
30
31       bflags      Flags  setting for the allocated buffer header. This should
32                   either be B_READ or B_WRITE.
33
34
35       callback    A pointer to a callback function, NULL_FUNC or SLEEP_FUNC.
36
37
38       arg         The callback function argument.
39
40

DESCRIPTION

42       The scsi_alloc_consistent_buf() function  returns  allocates  a  buffer
43       header  and  the  associated data buffer for direct memory access (DMA)
44       transfer. This buffer is allocated from the iobp space, which  is  con‐
45       sidered  consistent memory. For more details, see ddi_dma_mem_alloc(9F)
46       and ddi_dma_sync(9F).
47
48
49       For buffers allocated via scsi_alloc_consistent_buf(), and marked  with
50       the  PKT_CONSISTENT  flag  via  scsi_init_pkt(9F),  the HBA driver must
51       ensure that the data transfer for the command is correctly synchronized
52       before the target driver's command completion callback is performed.
53
54
55       If bp is NULL, a new buffer header will be allocated using getrbuf(9F).
56       In addition, if datalen is non-zero, a new  buffer  will  be  allocated
57       using ddi_dma_mem_alloc(9F).
58
59
60       callback  indicates  what  the allocator routines should do when direct
61       memory access (DMA) resources are not available; the valid values are:
62
63       NULL_FUNC       Do not wait for resources. Return a NULL pointer.
64
65
66       SLEEP_FUNC      Wait indefinitely for resources.
67
68
69       Other Values    callback points to  a  function  that  is  called  when
70                       resources  may  become  available. callback must return
71                       either 0 (indicating  that  it  attempted  to  allocate
72                       resources but failed to do so), in which case it is put
73                       back on a list to be called again later, or 1  indicat‐
74                       ing  either success in allocating resources or indicat‐
75                       ing that it no longer cares for a retry. The last argu‐
76                       ment  arg  is supplied to the callback function when it
77                       is invoked.
78
79

RETURN VALUES

81       The scsi_alloc_consistent_buf() function returns a pointer to a buf(9S)
82       structure  on  success.  It returns NULL if resources are not available
83       even if waitfunc was not SLEEP_FUNC.
84

CONTEXT

86       If callback is SLEEP_FUNC, then this routine may be  called  only  from
87       user-level  code.  Otherwise,  it may be called fromuser, interrupt, or
88       kernel context. The callback function may not block  or  call  routines
89       that block.
90

EXAMPLES

92       Example 1 Allocate a request sense packet with consistent DMA resources
93       attached.
94
95            bp = scsi_alloc_consistent_buf(&devp->sd_address, NULL,
96                  SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL);
97             rqpkt = scsi_init_pkt(&devp->sd_address,
98                  NULL, bp, CDB_GROUP0, 1, 0,
99                  PKT_CONSISTENT, SLEEP_FUNC, NULL);
100
101
102       Example 2 Allocate an inquiry  packet  with  consistent  DMA  resources
103       attached.
104
105             bp = scsi_alloc_consistent_buf(&devp->sd_address, NULL,
106                  SUN_INQSIZE, B_READ, canwait, NULL);
107             if (bp) {
108              pkt = scsi_init_pkt(&devp->sd_address, NULL, bp,
109                   CDB_GROUP0, 1, PP_LEN, PKT_CONSISTENT,
110                   canwait, NULL);
111             }
112
113

SEE ALSO

115       ddi_dma_mem_alloc(9F),          ddi_dma_sync(9F),          getrbuf(9F),
116       scsi_destroy_pkt(9F), scsi_init_pkt(9F),  scsi_free_consistent_buf(9F),
117       buf(9S), scsi_address(9S)
118
119
120       Writing Device Drivers
121
122
123
124SunOS 5.11                        16 Jan 2006    scsi_alloc_consistent_buf(9F)
Impressum