Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / pullupmsg.9f
blobce7592e23f08f5a895d3652d29648c17016c64d2
1 '\" te
2 .\"  Copyright 1989 AT&T
3 .\"  Copyright (c) 2006, Sun Microsystems, Inc.,  All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH PULLUPMSG 9F "Jan 16, 2006"
8 .SH NAME
9 pullupmsg \- concatenate bytes in a message
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/stream.h>
17 \fBint\fR \fBpullupmsg\fR(\fBmblk_t *\fR\fImp\fR, \fBssize_t\fR \fIlen\fR);
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Architecture independent level 1 (DDI/DKI).
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fImp\fR\fR
29 .ad
30 .RS 7n
31 Pointer to the message whose blocks are to be concatenated. \fBmblk_t\fR is an
32 instance of the \fBmsgb\fR(9S) structure.
33 .RE
35 .sp
36 .ne 2
37 .na
38 \fB\fIlen\fR\fR
39 .ad
40 .RS 7n
41 Number of bytes to concatenate.
42 .RE
44 .SH DESCRIPTION
45 .sp
46 .LP
47 The \fBpullupmsg()\fR function tries to combine multiple data blocks into a
48 single block. \fBpullupmsg()\fR concatenates and aligns the first \fIlen\fR
49 data bytes of the message pointed to by \fImp\fR. If \fIlen\fR equals \fB-1\fR,
50 all data are concatenated. If \fIlen\fR bytes of the same message type cannot
51 be found, \fBpullupmsg()\fR fails and returns \fB0\fR.
52 .SH RETURN VALUES
53 .sp
54 .LP
55 On success, \fB1\fR is returned; on failure, \fB0\fR is returned.
56 .SH CONTEXT
57 .sp
58 .LP
59 The \fBpullupmsg()\fR function can be called from user, interrupt, or kernel
60 context.
61 .SH EXAMPLES
62 .LP
63 \fBExample 1 \fRUsing \fBpullupmsg()\fR
64 .sp
65 .LP
66 This is a driver write \fBsrv\fR(9E) (service) routine for a device that does
67 not support scatter/gather \fBDMA\fR. For all  \fBM_DATA\fR messages, the data
68 will be transferred to the device with \fBDMA\fR. First, try to pull up the
69 message into one message block with the \fBpullupmsg()\fR function (line 12).
70 If successful, the transfer can be accomplished in one \fBDMA \fRjob.
71 Otherwise, it must be done one message block at a time (lines 19-22). After the
72 data has been transferred to the device, free the message and continue
73 processing messages on the queue.
75 .sp
76 .in +2
77 .nf
79  1 xxxwsrv(q)
80  2    queue_t *q;
81  3 {
82  4          mblk_t *mp;
83  5          mblk_t *tmp;
84  6          caddr_t dma_addr;
85  7     ssize_t dma_len;
86  8
87  9          while ((mp = getq(q)) != NULL) {
88 10                  switch (mp->b_datap->db_type) {
89 11             case M_DATA:
90 12                         if (pullupmsg(mp, -1)) {
91 13                            dma_addr = vtop(mp->b_rptr);
92 14                                 dma_len = mp->b_wptr - mp->b_rptr;
93 15                                 xxx_do_dma(dma_addr, dma_len);
94 16                                 freemsg(mp);
95 17                                 break;
96 18                         }
97 19                         for (tmp = mp; tmp; tmp = tmp->b_cont) {
98 20                            dma_addr = vtop(tmp->b_rptr);
99 21                            dma_len = tmp->b_wptr - tmp->b_rptr;
100 22                            xxx_do_dma(dma_addr, dma_len);
101 23                    }
102 24                         freemsg(mp);
103 25                         break;
104                     ...
105 26                      }
106 27          }
107 28 }
109 .in -2
111 .SH SEE ALSO
114 \fBsrv\fR(9E), \fBallocb\fR(9F), \fBmsgpullup\fR(9F), \fBmsgb\fR(9S)
117 \fIWriting Device Drivers\fR
120 \fISTREAMS Programming Guide\fR
121 .SH NOTES
124 The \fBpullupmsg()\fR function is not included in the \fBDKI\fR and will be
125 removed from the system in a future release. Device driver writers are strongly
126 encouraged to use \fBmsgpullup\fR(9F) instead of \fBpullupmsg()\fR.