1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */
29*7c478bd9Sstevel@tonic-gate
30*7c478bd9Sstevel@tonic-gate
31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* from S5R4 1.10 */
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate /*
34*7c478bd9Sstevel@tonic-gate * Description: The pckt module packetizes messages on
35*7c478bd9Sstevel@tonic-gate * its read queue by pre-fixing an M_PROTO
36*7c478bd9Sstevel@tonic-gate * message type to certain incoming messages.
37*7c478bd9Sstevel@tonic-gate */
38*7c478bd9Sstevel@tonic-gate
39*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
41*7c478bd9Sstevel@tonic-gate #include <sys/stream.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
45*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/debug.h>
48*7c478bd9Sstevel@tonic-gate
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate * This is the loadable module wrapper.
51*7c478bd9Sstevel@tonic-gate */
52*7c478bd9Sstevel@tonic-gate #include <sys/conf.h>
53*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
54*7c478bd9Sstevel@tonic-gate
55*7c478bd9Sstevel@tonic-gate static struct streamtab pcktinfo;
56*7c478bd9Sstevel@tonic-gate
57*7c478bd9Sstevel@tonic-gate /*
58*7c478bd9Sstevel@tonic-gate * Per queue instances are single-threaded since the q_ptr
59*7c478bd9Sstevel@tonic-gate * field of queues need to be shared among threads.
60*7c478bd9Sstevel@tonic-gate */
61*7c478bd9Sstevel@tonic-gate static struct fmodsw fsw = {
62*7c478bd9Sstevel@tonic-gate "pckt",
63*7c478bd9Sstevel@tonic-gate &pcktinfo,
64*7c478bd9Sstevel@tonic-gate D_NEW | D_MTPERQ | D_MP
65*7c478bd9Sstevel@tonic-gate };
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate * Module linkage information for the kernel.
69*7c478bd9Sstevel@tonic-gate */
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gate static struct modlstrmod modlstrmod = {
72*7c478bd9Sstevel@tonic-gate &mod_strmodops,
73*7c478bd9Sstevel@tonic-gate "pckt module",
74*7c478bd9Sstevel@tonic-gate &fsw
75*7c478bd9Sstevel@tonic-gate };
76*7c478bd9Sstevel@tonic-gate
77*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
78*7c478bd9Sstevel@tonic-gate MODREV_1, &modlstrmod, NULL
79*7c478bd9Sstevel@tonic-gate };
80*7c478bd9Sstevel@tonic-gate
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate int
_init(void)83*7c478bd9Sstevel@tonic-gate _init(void)
84*7c478bd9Sstevel@tonic-gate {
85*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage));
86*7c478bd9Sstevel@tonic-gate }
87*7c478bd9Sstevel@tonic-gate
88*7c478bd9Sstevel@tonic-gate int
_fini(void)89*7c478bd9Sstevel@tonic-gate _fini(void)
90*7c478bd9Sstevel@tonic-gate {
91*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage));
92*7c478bd9Sstevel@tonic-gate }
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)95*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
96*7c478bd9Sstevel@tonic-gate {
97*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
98*7c478bd9Sstevel@tonic-gate }
99*7c478bd9Sstevel@tonic-gate
100*7c478bd9Sstevel@tonic-gate static int pcktopen(queue_t *, dev_t *, int, int, cred_t *);
101*7c478bd9Sstevel@tonic-gate static int pcktclose(queue_t *, int, cred_t *);
102*7c478bd9Sstevel@tonic-gate static void pcktrput(queue_t *, mblk_t *);
103*7c478bd9Sstevel@tonic-gate static void pcktrsrv(queue_t *);
104*7c478bd9Sstevel@tonic-gate static void pcktwput(queue_t *, mblk_t *);
105*7c478bd9Sstevel@tonic-gate static mblk_t *add_ctl_info(queue_t *, mblk_t *);
106*7c478bd9Sstevel@tonic-gate static void add_ctl_wkup(void *);
107*7c478bd9Sstevel@tonic-gate
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate * Stream module data structure definitions.
111*7c478bd9Sstevel@tonic-gate * Sits over the ptm module generally.
112*7c478bd9Sstevel@tonic-gate *
113*7c478bd9Sstevel@tonic-gate * Read side flow control strategy: Since we may be putting messages on
114*7c478bd9Sstevel@tonic-gate * the read q due to allocb failures, these failures must get
115*7c478bd9Sstevel@tonic-gate * reflected fairly quickly to the module below us.
116*7c478bd9Sstevel@tonic-gate * No sense in piling on messages in times of memory shortage.
117*7c478bd9Sstevel@tonic-gate * Further, for the case of upper level flow control, there is no
118*7c478bd9Sstevel@tonic-gate * compelling reason to have more buffering in this module.
119*7c478bd9Sstevel@tonic-gate * Thus use a hi-water mark of one.
120*7c478bd9Sstevel@tonic-gate * This module imposes no max packet size, there is no inherent reason
121*7c478bd9Sstevel@tonic-gate * in the code to do so.
122*7c478bd9Sstevel@tonic-gate */
123*7c478bd9Sstevel@tonic-gate static struct module_info pcktiinfo = {
124*7c478bd9Sstevel@tonic-gate 0x9898, /* module id number */
125*7c478bd9Sstevel@tonic-gate "pckt", /* module name */
126*7c478bd9Sstevel@tonic-gate 0, /* minimum packet size */
127*7c478bd9Sstevel@tonic-gate INFPSZ, /* maximum packet size */
128*7c478bd9Sstevel@tonic-gate 1, /* hi-water mark */
129*7c478bd9Sstevel@tonic-gate 0 /* lo-water mark */
130*7c478bd9Sstevel@tonic-gate };
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate * Write side flow control strategy: There is no write service procedure.
134*7c478bd9Sstevel@tonic-gate * The write put function is pass thru, thus there is no reason to have any
135*7c478bd9Sstevel@tonic-gate * limits on the maximum packet size.
136*7c478bd9Sstevel@tonic-gate */
137*7c478bd9Sstevel@tonic-gate static struct module_info pcktoinfo = {
138*7c478bd9Sstevel@tonic-gate 0x9898, /* module id number */
139*7c478bd9Sstevel@tonic-gate "pckt", /* module name */
140*7c478bd9Sstevel@tonic-gate 0, /* minimum packet size */
141*7c478bd9Sstevel@tonic-gate INFPSZ, /* maximum packet size */
142*7c478bd9Sstevel@tonic-gate 0, /* hi-water mark */
143*7c478bd9Sstevel@tonic-gate 0 /* lo-water mark */
144*7c478bd9Sstevel@tonic-gate };
145*7c478bd9Sstevel@tonic-gate
146*7c478bd9Sstevel@tonic-gate static struct qinit pcktrinit = {
147*7c478bd9Sstevel@tonic-gate (int (*)())pcktrput,
148*7c478bd9Sstevel@tonic-gate (int (*)())pcktrsrv,
149*7c478bd9Sstevel@tonic-gate pcktopen,
150*7c478bd9Sstevel@tonic-gate pcktclose,
151*7c478bd9Sstevel@tonic-gate NULL,
152*7c478bd9Sstevel@tonic-gate &pcktiinfo,
153*7c478bd9Sstevel@tonic-gate NULL
154*7c478bd9Sstevel@tonic-gate };
155*7c478bd9Sstevel@tonic-gate
156*7c478bd9Sstevel@tonic-gate static struct qinit pcktwinit = {
157*7c478bd9Sstevel@tonic-gate (int (*)())pcktwput,
158*7c478bd9Sstevel@tonic-gate NULL,
159*7c478bd9Sstevel@tonic-gate NULL,
160*7c478bd9Sstevel@tonic-gate NULL,
161*7c478bd9Sstevel@tonic-gate NULL,
162*7c478bd9Sstevel@tonic-gate &pcktoinfo,
163*7c478bd9Sstevel@tonic-gate NULL
164*7c478bd9Sstevel@tonic-gate };
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gate static struct streamtab pcktinfo = {
167*7c478bd9Sstevel@tonic-gate &pcktrinit,
168*7c478bd9Sstevel@tonic-gate &pcktwinit,
169*7c478bd9Sstevel@tonic-gate NULL,
170*7c478bd9Sstevel@tonic-gate NULL
171*7c478bd9Sstevel@tonic-gate };
172*7c478bd9Sstevel@tonic-gate
173*7c478bd9Sstevel@tonic-gate
174*7c478bd9Sstevel@tonic-gate /*
175*7c478bd9Sstevel@tonic-gate * Per-instance state struct for the pckt module.
176*7c478bd9Sstevel@tonic-gate */
177*7c478bd9Sstevel@tonic-gate struct pckt_info {
178*7c478bd9Sstevel@tonic-gate queue_t *pi_qptr; /* back pointer to q */
179*7c478bd9Sstevel@tonic-gate bufcall_id_t pi_bufcall_id;
180*7c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL
181*7c478bd9Sstevel@tonic-gate model_t model;
182*7c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */
183*7c478bd9Sstevel@tonic-gate };
184*7c478bd9Sstevel@tonic-gate
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate * Dummy qbufcall callback routine used by open and close.
187*7c478bd9Sstevel@tonic-gate * The framework will wake up qwait_sig when we return from
188*7c478bd9Sstevel@tonic-gate * this routine (as part of leaving the perimeters.)
189*7c478bd9Sstevel@tonic-gate * (The framework enters the perimeters before calling the qbufcall() callback
190*7c478bd9Sstevel@tonic-gate * and leaves the perimeters after the callback routine has executed. The
191*7c478bd9Sstevel@tonic-gate * framework performs an implicit wakeup of any thread in qwait/qwait_sig
192*7c478bd9Sstevel@tonic-gate * when it leaves the perimeter. See qwait(9E).)
193*7c478bd9Sstevel@tonic-gate */
194*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
195*7c478bd9Sstevel@tonic-gate static void
dummy_callback(void * arg)196*7c478bd9Sstevel@tonic-gate dummy_callback(void *arg)
197*7c478bd9Sstevel@tonic-gate {}
198*7c478bd9Sstevel@tonic-gate
199*7c478bd9Sstevel@tonic-gate /*
200*7c478bd9Sstevel@tonic-gate * pcktopen - open routine gets called when the
201*7c478bd9Sstevel@tonic-gate * module gets pushed onto the stream.
202*7c478bd9Sstevel@tonic-gate */
203*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
204*7c478bd9Sstevel@tonic-gate static int
pcktopen(queue_t * q,dev_t * devp,int oflag,int sflag,cred_t * credp)205*7c478bd9Sstevel@tonic-gate pcktopen(
206*7c478bd9Sstevel@tonic-gate queue_t *q, /* pointer to the read side queue */
207*7c478bd9Sstevel@tonic-gate dev_t *devp, /* pointer to stream tail's dev */
208*7c478bd9Sstevel@tonic-gate int oflag, /* the user open(2) supplied flags */
209*7c478bd9Sstevel@tonic-gate int sflag, /* open state flag */
210*7c478bd9Sstevel@tonic-gate cred_t *credp) /* credentials */
211*7c478bd9Sstevel@tonic-gate {
212*7c478bd9Sstevel@tonic-gate struct pckt_info *pip;
213*7c478bd9Sstevel@tonic-gate mblk_t *mop; /* ptr to a setopts msg block */
214*7c478bd9Sstevel@tonic-gate struct stroptions *sop;
215*7c478bd9Sstevel@tonic-gate
216*7c478bd9Sstevel@tonic-gate if (sflag != MODOPEN)
217*7c478bd9Sstevel@tonic-gate return (EINVAL);
218*7c478bd9Sstevel@tonic-gate
219*7c478bd9Sstevel@tonic-gate if (q->q_ptr != NULL) {
220*7c478bd9Sstevel@tonic-gate /* It's already attached. */
221*7c478bd9Sstevel@tonic-gate return (0);
222*7c478bd9Sstevel@tonic-gate }
223*7c478bd9Sstevel@tonic-gate
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate * Allocate state structure.
226*7c478bd9Sstevel@tonic-gate */
227*7c478bd9Sstevel@tonic-gate pip = kmem_alloc(sizeof (*pip), KM_SLEEP);
228*7c478bd9Sstevel@tonic-gate bzero(pip, sizeof (*pip));
229*7c478bd9Sstevel@tonic-gate
230*7c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL
231*7c478bd9Sstevel@tonic-gate pip->model = ddi_model_convert_from(get_udatamodel());
232*7c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */
233*7c478bd9Sstevel@tonic-gate
234*7c478bd9Sstevel@tonic-gate /*
235*7c478bd9Sstevel@tonic-gate * Cross-link.
236*7c478bd9Sstevel@tonic-gate */
237*7c478bd9Sstevel@tonic-gate pip->pi_qptr = q;
238*7c478bd9Sstevel@tonic-gate q->q_ptr = pip;
239*7c478bd9Sstevel@tonic-gate WR(q)->q_ptr = pip;
240*7c478bd9Sstevel@tonic-gate
241*7c478bd9Sstevel@tonic-gate qprocson(q);
242*7c478bd9Sstevel@tonic-gate
243*7c478bd9Sstevel@tonic-gate /*
244*7c478bd9Sstevel@tonic-gate * Initialize an M_SETOPTS message to set up hi/lo water marks on
245*7c478bd9Sstevel@tonic-gate * stream head read queue.
246*7c478bd9Sstevel@tonic-gate */
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate while ((mop = allocb(sizeof (struct stroptions), BPRI_MED)) == NULL) {
249*7c478bd9Sstevel@tonic-gate bufcall_id_t id = qbufcall(q, sizeof (struct stroptions),
250*7c478bd9Sstevel@tonic-gate BPRI_MED, dummy_callback, NULL);
251*7c478bd9Sstevel@tonic-gate if (!qwait_sig(q)) {
252*7c478bd9Sstevel@tonic-gate qunbufcall(q, id);
253*7c478bd9Sstevel@tonic-gate kmem_free(pip, sizeof (*pip));
254*7c478bd9Sstevel@tonic-gate qprocsoff(q);
255*7c478bd9Sstevel@tonic-gate return (EINTR);
256*7c478bd9Sstevel@tonic-gate }
257*7c478bd9Sstevel@tonic-gate qunbufcall(q, id);
258*7c478bd9Sstevel@tonic-gate }
259*7c478bd9Sstevel@tonic-gate
260*7c478bd9Sstevel@tonic-gate
261*7c478bd9Sstevel@tonic-gate /*
262*7c478bd9Sstevel@tonic-gate * XXX: Should this module really control the hi/low water marks?
263*7c478bd9Sstevel@tonic-gate * Is there any reason in this code to do so?
264*7c478bd9Sstevel@tonic-gate */
265*7c478bd9Sstevel@tonic-gate mop->b_datap->db_type = M_SETOPTS;
266*7c478bd9Sstevel@tonic-gate mop->b_wptr += sizeof (struct stroptions);
267*7c478bd9Sstevel@tonic-gate sop = (struct stroptions *)mop->b_rptr;
268*7c478bd9Sstevel@tonic-gate sop->so_flags = SO_HIWAT | SO_LOWAT;
269*7c478bd9Sstevel@tonic-gate sop->so_hiwat = 512;
270*7c478bd9Sstevel@tonic-gate sop->so_lowat = 256;
271*7c478bd9Sstevel@tonic-gate
272*7c478bd9Sstevel@tonic-gate /*
273*7c478bd9Sstevel@tonic-gate * Commit to the open and send the M_SETOPTS off to the stream head.
274*7c478bd9Sstevel@tonic-gate */
275*7c478bd9Sstevel@tonic-gate putnext(q, mop);
276*7c478bd9Sstevel@tonic-gate
277*7c478bd9Sstevel@tonic-gate return (0);
278*7c478bd9Sstevel@tonic-gate }
279*7c478bd9Sstevel@tonic-gate
280*7c478bd9Sstevel@tonic-gate
281*7c478bd9Sstevel@tonic-gate /*
282*7c478bd9Sstevel@tonic-gate * pcktclose - This routine gets called when the module
283*7c478bd9Sstevel@tonic-gate * gets popped off of the stream.
284*7c478bd9Sstevel@tonic-gate */
285*7c478bd9Sstevel@tonic-gate
286*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
287*7c478bd9Sstevel@tonic-gate static int
pcktclose(queue_t * q,int flag,cred_t * credp)288*7c478bd9Sstevel@tonic-gate pcktclose(
289*7c478bd9Sstevel@tonic-gate queue_t *q, /* Pointer to the read queue */
290*7c478bd9Sstevel@tonic-gate int flag,
291*7c478bd9Sstevel@tonic-gate cred_t *credp)
292*7c478bd9Sstevel@tonic-gate {
293*7c478bd9Sstevel@tonic-gate struct pckt_info *pip = (struct pckt_info *)q->q_ptr;
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate qprocsoff(q);
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate * Cancel outstanding qbufcall
298*7c478bd9Sstevel@tonic-gate */
299*7c478bd9Sstevel@tonic-gate if (pip->pi_bufcall_id) {
300*7c478bd9Sstevel@tonic-gate qunbufcall(q, pip->pi_bufcall_id);
301*7c478bd9Sstevel@tonic-gate pip->pi_bufcall_id = 0;
302*7c478bd9Sstevel@tonic-gate }
303*7c478bd9Sstevel@tonic-gate /*
304*7c478bd9Sstevel@tonic-gate * Do not worry about msgs queued on the q, the framework
305*7c478bd9Sstevel@tonic-gate * will free them up.
306*7c478bd9Sstevel@tonic-gate */
307*7c478bd9Sstevel@tonic-gate kmem_free(q->q_ptr, sizeof (struct pckt_info));
308*7c478bd9Sstevel@tonic-gate q->q_ptr = WR(q)->q_ptr = NULL;
309*7c478bd9Sstevel@tonic-gate return (0);
310*7c478bd9Sstevel@tonic-gate }
311*7c478bd9Sstevel@tonic-gate
312*7c478bd9Sstevel@tonic-gate /*
313*7c478bd9Sstevel@tonic-gate * pcktrput - Module read queue put procedure.
314*7c478bd9Sstevel@tonic-gate * This is called from the module or
315*7c478bd9Sstevel@tonic-gate * driver downstream.
316*7c478bd9Sstevel@tonic-gate */
317*7c478bd9Sstevel@tonic-gate static void
pcktrput(queue_t * q,mblk_t * mp)318*7c478bd9Sstevel@tonic-gate pcktrput(
319*7c478bd9Sstevel@tonic-gate queue_t *q, /* Pointer to the read queue */
320*7c478bd9Sstevel@tonic-gate mblk_t *mp) /* Pointer to the current message block */
321*7c478bd9Sstevel@tonic-gate {
322*7c478bd9Sstevel@tonic-gate mblk_t *pckt_msgp;
323*7c478bd9Sstevel@tonic-gate
324*7c478bd9Sstevel@tonic-gate
325*7c478bd9Sstevel@tonic-gate switch (mp->b_datap->db_type) {
326*7c478bd9Sstevel@tonic-gate case M_FLUSH:
327*7c478bd9Sstevel@tonic-gate /*
328*7c478bd9Sstevel@tonic-gate * The PTS driver swaps the FLUSHR and FLUSHW flags
329*7c478bd9Sstevel@tonic-gate * we need to swap them back to reflect the actual
330*7c478bd9Sstevel@tonic-gate * slave side FLUSH mode.
331*7c478bd9Sstevel@tonic-gate */
332*7c478bd9Sstevel@tonic-gate if ((*mp->b_rptr & FLUSHRW) != FLUSHRW)
333*7c478bd9Sstevel@tonic-gate if ((*mp->b_rptr & FLUSHRW) == FLUSHR)
334*7c478bd9Sstevel@tonic-gate *mp->b_rptr = FLUSHW;
335*7c478bd9Sstevel@tonic-gate else if ((*mp->b_rptr & FLUSHRW) == FLUSHW)
336*7c478bd9Sstevel@tonic-gate *mp->b_rptr = FLUSHR;
337*7c478bd9Sstevel@tonic-gate
338*7c478bd9Sstevel@tonic-gate pckt_msgp = copymsg(mp);
339*7c478bd9Sstevel@tonic-gate if (*mp->b_rptr & FLUSHW) {
340*7c478bd9Sstevel@tonic-gate /*
341*7c478bd9Sstevel@tonic-gate * In the packet model we are not allowing
342*7c478bd9Sstevel@tonic-gate * flushes of the master's stream head read
343*7c478bd9Sstevel@tonic-gate * side queue. This is because all packet
344*7c478bd9Sstevel@tonic-gate * state information is stored there and
345*7c478bd9Sstevel@tonic-gate * a flush could destroy this data before
346*7c478bd9Sstevel@tonic-gate * it is read.
347*7c478bd9Sstevel@tonic-gate */
348*7c478bd9Sstevel@tonic-gate *mp->b_rptr = FLUSHW;
349*7c478bd9Sstevel@tonic-gate putnext(q, mp);
350*7c478bd9Sstevel@tonic-gate } else {
351*7c478bd9Sstevel@tonic-gate /*
352*7c478bd9Sstevel@tonic-gate * Free messages that only flush the
353*7c478bd9Sstevel@tonic-gate * master's read queue.
354*7c478bd9Sstevel@tonic-gate */
355*7c478bd9Sstevel@tonic-gate freemsg(mp);
356*7c478bd9Sstevel@tonic-gate }
357*7c478bd9Sstevel@tonic-gate
358*7c478bd9Sstevel@tonic-gate if (pckt_msgp == NULL)
359*7c478bd9Sstevel@tonic-gate break;
360*7c478bd9Sstevel@tonic-gate
361*7c478bd9Sstevel@tonic-gate mp = pckt_msgp;
362*7c478bd9Sstevel@tonic-gate /*
363*7c478bd9Sstevel@tonic-gate * Prefix M_PROTO and putnext.
364*7c478bd9Sstevel@tonic-gate */
365*7c478bd9Sstevel@tonic-gate goto prefix_head;
366*7c478bd9Sstevel@tonic-gate
367*7c478bd9Sstevel@tonic-gate case M_DATA:
368*7c478bd9Sstevel@tonic-gate case M_IOCTL:
369*7c478bd9Sstevel@tonic-gate case M_PROTO:
370*7c478bd9Sstevel@tonic-gate /*
371*7c478bd9Sstevel@tonic-gate * For non-priority messages, follow flow-control rules.
372*7c478bd9Sstevel@tonic-gate * Also, if there are messages on the q already, keep
373*7c478bd9Sstevel@tonic-gate * queueing them since they need to be processed in order.
374*7c478bd9Sstevel@tonic-gate */
375*7c478bd9Sstevel@tonic-gate if (!canputnext(q) || (qsize(q) > 0)) {
376*7c478bd9Sstevel@tonic-gate (void) putq(q, mp);
377*7c478bd9Sstevel@tonic-gate break;
378*7c478bd9Sstevel@tonic-gate }
379*7c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
380*7c478bd9Sstevel@tonic-gate
381*7c478bd9Sstevel@tonic-gate /*
382*7c478bd9Sstevel@tonic-gate * For high priority messages, skip flow control checks.
383*7c478bd9Sstevel@tonic-gate */
384*7c478bd9Sstevel@tonic-gate case M_PCPROTO:
385*7c478bd9Sstevel@tonic-gate case M_READ:
386*7c478bd9Sstevel@tonic-gate case M_STOP:
387*7c478bd9Sstevel@tonic-gate case M_START:
388*7c478bd9Sstevel@tonic-gate case M_STARTI:
389*7c478bd9Sstevel@tonic-gate case M_STOPI:
390*7c478bd9Sstevel@tonic-gate prefix_head:
391*7c478bd9Sstevel@tonic-gate /*
392*7c478bd9Sstevel@tonic-gate * Prefix an M_PROTO header to message and pass upstream.
393*7c478bd9Sstevel@tonic-gate */
394*7c478bd9Sstevel@tonic-gate if ((mp = add_ctl_info(q, mp)) != NULL)
395*7c478bd9Sstevel@tonic-gate putnext(q, mp);
396*7c478bd9Sstevel@tonic-gate break;
397*7c478bd9Sstevel@tonic-gate
398*7c478bd9Sstevel@tonic-gate default:
399*7c478bd9Sstevel@tonic-gate /*
400*7c478bd9Sstevel@tonic-gate * For data messages, queue them back on the queue if
401*7c478bd9Sstevel@tonic-gate * there are messages on the queue already. This is
402*7c478bd9Sstevel@tonic-gate * done to preserve the order of messages.
403*7c478bd9Sstevel@tonic-gate * For high priority messages or for no messages on the
404*7c478bd9Sstevel@tonic-gate * q, simply putnext() and pass it on.
405*7c478bd9Sstevel@tonic-gate */
406*7c478bd9Sstevel@tonic-gate if ((datamsg(mp->b_datap->db_type)) && (qsize(q) > 0))
407*7c478bd9Sstevel@tonic-gate (void) putq(q, mp);
408*7c478bd9Sstevel@tonic-gate else
409*7c478bd9Sstevel@tonic-gate putnext(q, mp);
410*7c478bd9Sstevel@tonic-gate break;
411*7c478bd9Sstevel@tonic-gate }
412*7c478bd9Sstevel@tonic-gate }
413*7c478bd9Sstevel@tonic-gate
414*7c478bd9Sstevel@tonic-gate /*
415*7c478bd9Sstevel@tonic-gate * pcktrsrv - module read service procedure
416*7c478bd9Sstevel@tonic-gate * This function deals with messages left in the queue due to
417*7c478bd9Sstevel@tonic-gate * (a) not enough memory to allocate the header M_PROTO message
418*7c478bd9Sstevel@tonic-gate * (b) flow control reasons
419*7c478bd9Sstevel@tonic-gate * The function will attempt to get the messages off the queue and
420*7c478bd9Sstevel@tonic-gate * process them.
421*7c478bd9Sstevel@tonic-gate */
422*7c478bd9Sstevel@tonic-gate static void
pcktrsrv(queue_t * q)423*7c478bd9Sstevel@tonic-gate pcktrsrv(queue_t *q)
424*7c478bd9Sstevel@tonic-gate {
425*7c478bd9Sstevel@tonic-gate mblk_t *mp;
426*7c478bd9Sstevel@tonic-gate
427*7c478bd9Sstevel@tonic-gate while ((mp = getq(q)) != NULL) {
428*7c478bd9Sstevel@tonic-gate if (!canputnext(q)) {
429*7c478bd9Sstevel@tonic-gate /*
430*7c478bd9Sstevel@tonic-gate * For high priority messages, make sure there is no
431*7c478bd9Sstevel@tonic-gate * infinite loop. Disable the queue for this case.
432*7c478bd9Sstevel@tonic-gate * High priority messages get here only for buffer
433*7c478bd9Sstevel@tonic-gate * allocation failures. Thus the bufcall callout
434*7c478bd9Sstevel@tonic-gate * will reenable the q.
435*7c478bd9Sstevel@tonic-gate * XXX bug alert - nooenable will *not* prevent
436*7c478bd9Sstevel@tonic-gate * putbq of a hipri messages frm enabling the queue.
437*7c478bd9Sstevel@tonic-gate */
438*7c478bd9Sstevel@tonic-gate if (!datamsg(mp->b_datap->db_type))
439*7c478bd9Sstevel@tonic-gate noenable(q);
440*7c478bd9Sstevel@tonic-gate (void) putbq(q, mp);
441*7c478bd9Sstevel@tonic-gate return;
442*7c478bd9Sstevel@tonic-gate }
443*7c478bd9Sstevel@tonic-gate
444*7c478bd9Sstevel@tonic-gate /*
445*7c478bd9Sstevel@tonic-gate * M_FLUSH msgs may also be here if there was a memory
446*7c478bd9Sstevel@tonic-gate * failure.
447*7c478bd9Sstevel@tonic-gate */
448*7c478bd9Sstevel@tonic-gate switch (mp->b_datap->db_type) {
449*7c478bd9Sstevel@tonic-gate case M_FLUSH:
450*7c478bd9Sstevel@tonic-gate case M_PROTO:
451*7c478bd9Sstevel@tonic-gate case M_PCPROTO:
452*7c478bd9Sstevel@tonic-gate case M_STOP:
453*7c478bd9Sstevel@tonic-gate case M_START:
454*7c478bd9Sstevel@tonic-gate case M_IOCTL:
455*7c478bd9Sstevel@tonic-gate case M_DATA:
456*7c478bd9Sstevel@tonic-gate case M_READ:
457*7c478bd9Sstevel@tonic-gate case M_STARTI:
458*7c478bd9Sstevel@tonic-gate case M_STOPI:
459*7c478bd9Sstevel@tonic-gate /*
460*7c478bd9Sstevel@tonic-gate * Prefix an M_PROTO header to msg and pass upstream.
461*7c478bd9Sstevel@tonic-gate */
462*7c478bd9Sstevel@tonic-gate if ((mp = add_ctl_info(q, mp)) == NULL) {
463*7c478bd9Sstevel@tonic-gate /*
464*7c478bd9Sstevel@tonic-gate * Running into memory or flow ctl problems.
465*7c478bd9Sstevel@tonic-gate */
466*7c478bd9Sstevel@tonic-gate return;
467*7c478bd9Sstevel@tonic-gate }
468*7c478bd9Sstevel@tonic-gate /* FALL THROUGH */
469*7c478bd9Sstevel@tonic-gate
470*7c478bd9Sstevel@tonic-gate default:
471*7c478bd9Sstevel@tonic-gate putnext(q, mp);
472*7c478bd9Sstevel@tonic-gate break;
473*7c478bd9Sstevel@tonic-gate }
474*7c478bd9Sstevel@tonic-gate }
475*7c478bd9Sstevel@tonic-gate }
476*7c478bd9Sstevel@tonic-gate
477*7c478bd9Sstevel@tonic-gate /*
478*7c478bd9Sstevel@tonic-gate * pcktwput - Module write queue put procedure.
479*7c478bd9Sstevel@tonic-gate * All messages are send downstream unchanged
480*7c478bd9Sstevel@tonic-gate */
481*7c478bd9Sstevel@tonic-gate
482*7c478bd9Sstevel@tonic-gate static void
pcktwput(queue_t * q,mblk_t * mp)483*7c478bd9Sstevel@tonic-gate pcktwput(
484*7c478bd9Sstevel@tonic-gate queue_t *q, /* Pointer to the read queue */
485*7c478bd9Sstevel@tonic-gate mblk_t *mp) /* Pointer to current message block */
486*7c478bd9Sstevel@tonic-gate {
487*7c478bd9Sstevel@tonic-gate putnext(q, mp);
488*7c478bd9Sstevel@tonic-gate }
489*7c478bd9Sstevel@tonic-gate
490*7c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL
491*7c478bd9Sstevel@tonic-gate /*
492*7c478bd9Sstevel@tonic-gate * reallocb - copy the data block from the given message block into a new block.
493*7c478bd9Sstevel@tonic-gate * This function is used in case data block had another message block
494*7c478bd9Sstevel@tonic-gate * pointing to it (and hence we just copy this one data block).
495*7c478bd9Sstevel@tonic-gate *
496*7c478bd9Sstevel@tonic-gate * Returns new message block if successful. On failure it returns NULL.
497*7c478bd9Sstevel@tonic-gate * It also tries to do a qbufcall and if that also fails,
498*7c478bd9Sstevel@tonic-gate * it frees the message block.
499*7c478bd9Sstevel@tonic-gate */
500*7c478bd9Sstevel@tonic-gate static mblk_t *
pckt_reallocb(queue_t * q,mblk_t * mp)501*7c478bd9Sstevel@tonic-gate pckt_reallocb(
502*7c478bd9Sstevel@tonic-gate queue_t *q, /* Pointer to the read queue */
503*7c478bd9Sstevel@tonic-gate mblk_t *mp /* Pointer to the message block to be changed */
504*7c478bd9Sstevel@tonic-gate )
505*7c478bd9Sstevel@tonic-gate {
506*7c478bd9Sstevel@tonic-gate mblk_t *nmp;
507*7c478bd9Sstevel@tonic-gate
508*7c478bd9Sstevel@tonic-gate ASSERT(mp->b_datap->db_ref >= 1);
509*7c478bd9Sstevel@tonic-gate
510*7c478bd9Sstevel@tonic-gate /*
511*7c478bd9Sstevel@tonic-gate * No reallocation is needed if there is only one reference
512*7c478bd9Sstevel@tonic-gate * to this data block.
513*7c478bd9Sstevel@tonic-gate */
514*7c478bd9Sstevel@tonic-gate if (mp->b_datap->db_ref == 1)
515*7c478bd9Sstevel@tonic-gate return (mp);
516*7c478bd9Sstevel@tonic-gate
517*7c478bd9Sstevel@tonic-gate if ((nmp = copyb(mp)) == NULL) {
518*7c478bd9Sstevel@tonic-gate struct pckt_info *pip = (struct pckt_info *)q->q_ptr;
519*7c478bd9Sstevel@tonic-gate
520*7c478bd9Sstevel@tonic-gate noenable(q);
521*7c478bd9Sstevel@tonic-gate if (pip->pi_bufcall_id = qbufcall(q, mp->b_wptr - mp->b_rptr,
522*7c478bd9Sstevel@tonic-gate BPRI_MED, add_ctl_wkup, q)) {
523*7c478bd9Sstevel@tonic-gate /*
524*7c478bd9Sstevel@tonic-gate * Put the message back onto the q.
525*7c478bd9Sstevel@tonic-gate */
526*7c478bd9Sstevel@tonic-gate (void) putq(q, mp);
527*7c478bd9Sstevel@tonic-gate } else {
528*7c478bd9Sstevel@tonic-gate /*
529*7c478bd9Sstevel@tonic-gate * Things are pretty bad and serious if bufcall fails!
530*7c478bd9Sstevel@tonic-gate * Drop the message in this case.
531*7c478bd9Sstevel@tonic-gate */
532*7c478bd9Sstevel@tonic-gate freemsg(mp);
533*7c478bd9Sstevel@tonic-gate }
534*7c478bd9Sstevel@tonic-gate return ((mblk_t *)0);
535*7c478bd9Sstevel@tonic-gate }
536*7c478bd9Sstevel@tonic-gate
537*7c478bd9Sstevel@tonic-gate nmp->b_cont = mp->b_cont;
538*7c478bd9Sstevel@tonic-gate freeb(mp);
539*7c478bd9Sstevel@tonic-gate return (nmp);
540*7c478bd9Sstevel@tonic-gate }
541*7c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */
542*7c478bd9Sstevel@tonic-gate
543*7c478bd9Sstevel@tonic-gate /*
544*7c478bd9Sstevel@tonic-gate * add_ctl_info: add message control information to in coming
545*7c478bd9Sstevel@tonic-gate * message.
546*7c478bd9Sstevel@tonic-gate */
547*7c478bd9Sstevel@tonic-gate static mblk_t *
add_ctl_info(queue_t * q,mblk_t * mp)548*7c478bd9Sstevel@tonic-gate add_ctl_info(
549*7c478bd9Sstevel@tonic-gate queue_t *q, /* pointer to the read queue */
550*7c478bd9Sstevel@tonic-gate mblk_t *mp) /* pointer to the raw data input message */
551*7c478bd9Sstevel@tonic-gate {
552*7c478bd9Sstevel@tonic-gate struct pckt_info *pip = (struct pckt_info *)q->q_ptr;
553*7c478bd9Sstevel@tonic-gate mblk_t *bp; /* pointer to the unmodified message block */
554*7c478bd9Sstevel@tonic-gate
555*7c478bd9Sstevel@tonic-gate /*
556*7c478bd9Sstevel@tonic-gate * Waiting on space for previous message?
557*7c478bd9Sstevel@tonic-gate */
558*7c478bd9Sstevel@tonic-gate if (pip->pi_bufcall_id) {
559*7c478bd9Sstevel@tonic-gate /*
560*7c478bd9Sstevel@tonic-gate * Chain this message on to q for later processing.
561*7c478bd9Sstevel@tonic-gate */
562*7c478bd9Sstevel@tonic-gate (void) putq(q, mp);
563*7c478bd9Sstevel@tonic-gate return (NULL);
564*7c478bd9Sstevel@tonic-gate }
565*7c478bd9Sstevel@tonic-gate
566*7c478bd9Sstevel@tonic-gate /*
567*7c478bd9Sstevel@tonic-gate * Need to add the message block header as
568*7c478bd9Sstevel@tonic-gate * an M_PROTO type message.
569*7c478bd9Sstevel@tonic-gate */
570*7c478bd9Sstevel@tonic-gate if ((bp = allocb(sizeof (char), BPRI_MED)) == (mblk_t *)NULL) {
571*7c478bd9Sstevel@tonic-gate
572*7c478bd9Sstevel@tonic-gate /*
573*7c478bd9Sstevel@tonic-gate * There are two reasons to disable the q:
574*7c478bd9Sstevel@tonic-gate * (1) Flow control reasons should not wake up the q.
575*7c478bd9Sstevel@tonic-gate * (2) High priority messages will wakeup the q
576*7c478bd9Sstevel@tonic-gate * immediately. Disallow this.
577*7c478bd9Sstevel@tonic-gate */
578*7c478bd9Sstevel@tonic-gate noenable(q);
579*7c478bd9Sstevel@tonic-gate if (pip->pi_bufcall_id = qbufcall(q, sizeof (char), BPRI_MED,
580*7c478bd9Sstevel@tonic-gate add_ctl_wkup, q)) {
581*7c478bd9Sstevel@tonic-gate /*
582*7c478bd9Sstevel@tonic-gate * Add the message to the q.
583*7c478bd9Sstevel@tonic-gate */
584*7c478bd9Sstevel@tonic-gate (void) putq(q, mp);
585*7c478bd9Sstevel@tonic-gate } else {
586*7c478bd9Sstevel@tonic-gate /*
587*7c478bd9Sstevel@tonic-gate * Things are pretty bad and serious if bufcall fails!
588*7c478bd9Sstevel@tonic-gate * Drop the message in this case.
589*7c478bd9Sstevel@tonic-gate */
590*7c478bd9Sstevel@tonic-gate freemsg(mp);
591*7c478bd9Sstevel@tonic-gate }
592*7c478bd9Sstevel@tonic-gate
593*7c478bd9Sstevel@tonic-gate return (NULL);
594*7c478bd9Sstevel@tonic-gate }
595*7c478bd9Sstevel@tonic-gate
596*7c478bd9Sstevel@tonic-gate /*
597*7c478bd9Sstevel@tonic-gate * Copy the message type information to this message.
598*7c478bd9Sstevel@tonic-gate */
599*7c478bd9Sstevel@tonic-gate bp->b_datap->db_type = M_PROTO;
600*7c478bd9Sstevel@tonic-gate *(unsigned char *)bp->b_rptr = mp->b_datap->db_type;
601*7c478bd9Sstevel@tonic-gate bp->b_wptr++;
602*7c478bd9Sstevel@tonic-gate
603*7c478bd9Sstevel@tonic-gate #ifdef _MULTI_DATAMODEL
604*7c478bd9Sstevel@tonic-gate /*
605*7c478bd9Sstevel@tonic-gate * Check the datamodel and if the calling program is
606*7c478bd9Sstevel@tonic-gate * an ILP32 application then we covert the M_IOCTLs and M_READs
607*7c478bd9Sstevel@tonic-gate * into the native ILP32 format before passing them upstream
608*7c478bd9Sstevel@tonic-gate * to user mode.
609*7c478bd9Sstevel@tonic-gate */
610*7c478bd9Sstevel@tonic-gate switch (pip->model) {
611*7c478bd9Sstevel@tonic-gate case DDI_MODEL_ILP32:
612*7c478bd9Sstevel@tonic-gate switch (mp->b_datap->db_type) {
613*7c478bd9Sstevel@tonic-gate /*
614*7c478bd9Sstevel@tonic-gate * This structure must have the same shape as
615*7c478bd9Sstevel@tonic-gate * the * ILP32 compilation of `struct iocblk'
616*7c478bd9Sstevel@tonic-gate * from <sys/stream.h>.
617*7c478bd9Sstevel@tonic-gate */
618*7c478bd9Sstevel@tonic-gate struct iocblk32 {
619*7c478bd9Sstevel@tonic-gate int32_t ioc_cmd;
620*7c478bd9Sstevel@tonic-gate caddr32_t ioc_cr;
621*7c478bd9Sstevel@tonic-gate uint32_t ioc_id;
622*7c478bd9Sstevel@tonic-gate int32_t ioc_count;
623*7c478bd9Sstevel@tonic-gate int32_t ioc_error;
624*7c478bd9Sstevel@tonic-gate int32_t ioc_rval;
625*7c478bd9Sstevel@tonic-gate int32_t ioc_fill1;
626*7c478bd9Sstevel@tonic-gate uint32_t ioc_flag;
627*7c478bd9Sstevel@tonic-gate int32_t ioc_filler[2];
628*7c478bd9Sstevel@tonic-gate } niocblk_32;
629*7c478bd9Sstevel@tonic-gate struct iocblk *iocblk_64;
630*7c478bd9Sstevel@tonic-gate
631*7c478bd9Sstevel@tonic-gate case M_IOCTL:
632*7c478bd9Sstevel@tonic-gate if ((mp = pckt_reallocb(q, mp)) == (mblk_t *)0)
633*7c478bd9Sstevel@tonic-gate return ((mblk_t *)0);
634*7c478bd9Sstevel@tonic-gate
635*7c478bd9Sstevel@tonic-gate bzero(&niocblk_32, sizeof (niocblk_32));
636*7c478bd9Sstevel@tonic-gate iocblk_64 = (struct iocblk *)mp->b_rptr;
637*7c478bd9Sstevel@tonic-gate
638*7c478bd9Sstevel@tonic-gate /* Leave the pointer to cred_t structure as it is. */
639*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_cmd = iocblk_64->ioc_cmd;
640*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_cr = (caddr32_t)(uintptr_t)
641*7c478bd9Sstevel@tonic-gate iocblk_64->ioc_cr;
642*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_id = iocblk_64->ioc_id;
643*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_count = iocblk_64->ioc_count;
644*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_error = iocblk_64->ioc_error;
645*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_rval = iocblk_64->ioc_rval;
646*7c478bd9Sstevel@tonic-gate niocblk_32.ioc_flag = iocblk_64->ioc_flag;
647*7c478bd9Sstevel@tonic-gate
648*7c478bd9Sstevel@tonic-gate /* Copy the iocblk structure for ILP32 back */
649*7c478bd9Sstevel@tonic-gate *(struct iocblk32 *)mp->b_rptr = niocblk_32;
650*7c478bd9Sstevel@tonic-gate mp->b_wptr = mp->b_rptr + sizeof (struct iocblk32);
651*7c478bd9Sstevel@tonic-gate break;
652*7c478bd9Sstevel@tonic-gate
653*7c478bd9Sstevel@tonic-gate case M_READ:
654*7c478bd9Sstevel@tonic-gate if ((mp = pckt_reallocb(q, mp)) == (mblk_t *)0)
655*7c478bd9Sstevel@tonic-gate return ((mblk_t *)0);
656*7c478bd9Sstevel@tonic-gate
657*7c478bd9Sstevel@tonic-gate /* change the size_t to size32_t for ILP32 */
658*7c478bd9Sstevel@tonic-gate *(size32_t *)mp->b_rptr = *(size_t *)mp->b_rptr;
659*7c478bd9Sstevel@tonic-gate mp->b_wptr = mp->b_rptr + sizeof (size32_t);
660*7c478bd9Sstevel@tonic-gate break;
661*7c478bd9Sstevel@tonic-gate }
662*7c478bd9Sstevel@tonic-gate break;
663*7c478bd9Sstevel@tonic-gate
664*7c478bd9Sstevel@tonic-gate case DATAMODEL_NONE:
665*7c478bd9Sstevel@tonic-gate break;
666*7c478bd9Sstevel@tonic-gate }
667*7c478bd9Sstevel@tonic-gate #endif /* _MULTI_DATAMODEL */
668*7c478bd9Sstevel@tonic-gate
669*7c478bd9Sstevel@tonic-gate /*
670*7c478bd9Sstevel@tonic-gate * Now change the orginal message type to M_DATA and tie them up.
671*7c478bd9Sstevel@tonic-gate */
672*7c478bd9Sstevel@tonic-gate mp->b_datap->db_type = M_DATA;
673*7c478bd9Sstevel@tonic-gate bp->b_cont = mp;
674*7c478bd9Sstevel@tonic-gate
675*7c478bd9Sstevel@tonic-gate return (bp);
676*7c478bd9Sstevel@tonic-gate }
677*7c478bd9Sstevel@tonic-gate
678*7c478bd9Sstevel@tonic-gate static void
add_ctl_wkup(void * arg)679*7c478bd9Sstevel@tonic-gate add_ctl_wkup(void *arg)
680*7c478bd9Sstevel@tonic-gate {
681*7c478bd9Sstevel@tonic-gate queue_t *q = arg; /* ptr to the read queue */
682*7c478bd9Sstevel@tonic-gate struct pckt_info *pip = (struct pckt_info *)q->q_ptr;
683*7c478bd9Sstevel@tonic-gate
684*7c478bd9Sstevel@tonic-gate pip->pi_bufcall_id = 0;
685*7c478bd9Sstevel@tonic-gate /*
686*7c478bd9Sstevel@tonic-gate * Allow enabling of the q to allow the service
687*7c478bd9Sstevel@tonic-gate * function to do its job.
688*7c478bd9Sstevel@tonic-gate *
689*7c478bd9Sstevel@tonic-gate * Also, qenable() to schedule the q immediately.
690*7c478bd9Sstevel@tonic-gate * This is to ensure timely processing of high priority
691*7c478bd9Sstevel@tonic-gate * messages if they are on the q.
692*7c478bd9Sstevel@tonic-gate */
693*7c478bd9Sstevel@tonic-gate enableok(q);
694*7c478bd9Sstevel@tonic-gate qenable(q);
695*7c478bd9Sstevel@tonic-gate }
696