1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*0Sstevel@tonic-gate /* All Rights Reserved */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /* 27*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 28*0Sstevel@tonic-gate * Use is subject to license terms. 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #ifndef _SYS_STRSUBR_H 32*0Sstevel@tonic-gate #define _SYS_STRSUBR_H 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.17 */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * WARNING: 38*0Sstevel@tonic-gate * Everything in this file is private, belonging to the 39*0Sstevel@tonic-gate * STREAMS subsystem. The only guarantee made about the 40*0Sstevel@tonic-gate * contents of this file is that if you include it, your 41*0Sstevel@tonic-gate * code will not port to the next release. 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate #include <sys/stream.h> 44*0Sstevel@tonic-gate #include <sys/stropts.h> 45*0Sstevel@tonic-gate #include <sys/session.h> 46*0Sstevel@tonic-gate #include <sys/kstat.h> 47*0Sstevel@tonic-gate #include <sys/uio.h> 48*0Sstevel@tonic-gate #include <sys/proc.h> 49*0Sstevel@tonic-gate #include <vm/as.h> 50*0Sstevel@tonic-gate #include <vm/page.h> 51*0Sstevel@tonic-gate #include <vm/anon.h> 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate #ifdef __cplusplus 54*0Sstevel@tonic-gate extern "C" { 55*0Sstevel@tonic-gate #endif 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate /* 58*0Sstevel@tonic-gate * In general, the STREAMS locks are disjoint; they are only held 59*0Sstevel@tonic-gate * locally, and not simultaneously by a thread. However, module 60*0Sstevel@tonic-gate * code, including at the stream head, requires some locks to be 61*0Sstevel@tonic-gate * acquired in order for its safety. 62*0Sstevel@tonic-gate * 1. Stream level claim. This prevents the value of q_next 63*0Sstevel@tonic-gate * from changing while module code is executing. 64*0Sstevel@tonic-gate * 2. Queue level claim. This prevents the value of q_ptr 65*0Sstevel@tonic-gate * from changing while put or service code is executing. 66*0Sstevel@tonic-gate * In addition, it provides for queue single-threading 67*0Sstevel@tonic-gate * for QPAIR and PERQ MT-safe modules. 68*0Sstevel@tonic-gate * 3. Stream head lock. May be held by the stream head module 69*0Sstevel@tonic-gate * to implement a read/write/open/close monitor. 70*0Sstevel@tonic-gate * Note: that the only types of twisted stream supported are 71*0Sstevel@tonic-gate * the pipe and transports which have read and write service 72*0Sstevel@tonic-gate * procedures on both sides of the twist. 73*0Sstevel@tonic-gate * 4. Queue lock. May be acquired by utility routines on 74*0Sstevel@tonic-gate * behalf of a module. 75*0Sstevel@tonic-gate */ 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate /* 78*0Sstevel@tonic-gate * In general, sd_lock protects the consistency of the stdata 79*0Sstevel@tonic-gate * structure. Additionally, it is used with sd_monitor 80*0Sstevel@tonic-gate * to implement an open/close monitor. In particular, it protects 81*0Sstevel@tonic-gate * the following fields: 82*0Sstevel@tonic-gate * sd_iocblk 83*0Sstevel@tonic-gate * sd_flag 84*0Sstevel@tonic-gate * sd_copyflag 85*0Sstevel@tonic-gate * sd_iocid 86*0Sstevel@tonic-gate * sd_iocwait 87*0Sstevel@tonic-gate * sd_sidp 88*0Sstevel@tonic-gate * sd_pgidp 89*0Sstevel@tonic-gate * sd_wroff 90*0Sstevel@tonic-gate * sd_rerror 91*0Sstevel@tonic-gate * sd_werror 92*0Sstevel@tonic-gate * sd_pushcnt 93*0Sstevel@tonic-gate * sd_sigflags 94*0Sstevel@tonic-gate * sd_siglist 95*0Sstevel@tonic-gate * sd_pollist 96*0Sstevel@tonic-gate * sd_mark 97*0Sstevel@tonic-gate * sd_closetime 98*0Sstevel@tonic-gate * sd_wakeq 99*0Sstevel@tonic-gate * sd_uiordq 100*0Sstevel@tonic-gate * sd_uiowrq 101*0Sstevel@tonic-gate * sd_maxblk 102*0Sstevel@tonic-gate * 103*0Sstevel@tonic-gate * The following fields are modified only by the allocator, which 104*0Sstevel@tonic-gate * has exclusive access to them at that time: 105*0Sstevel@tonic-gate * sd_wrq 106*0Sstevel@tonic-gate * sd_strtab 107*0Sstevel@tonic-gate * 108*0Sstevel@tonic-gate * The following field is protected by the overlying file system 109*0Sstevel@tonic-gate * code, guaranteeing single-threading of opens: 110*0Sstevel@tonic-gate * sd_vnode 111*0Sstevel@tonic-gate * 112*0Sstevel@tonic-gate * Stream-level locks should be acquired before any queue-level locks 113*0Sstevel@tonic-gate * are acquired. 114*0Sstevel@tonic-gate * 115*0Sstevel@tonic-gate * The stream head write queue lock(sd_wrq) is used to protect the 116*0Sstevel@tonic-gate * fields qn_maxpsz and qn_minpsz because freezestr() which is 117*0Sstevel@tonic-gate * necessary for strqset() only gets the queue lock. 118*0Sstevel@tonic-gate */ 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * Function types for the parameterized stream head. 122*0Sstevel@tonic-gate * The msgfunc_t takes the parameters: 123*0Sstevel@tonic-gate * msgfunc(vnode_t *vp, mblk_t *mp, strwakeup_t *wakeups, 124*0Sstevel@tonic-gate * strsigset_t *firstmsgsigs, strsigset_t *allmsgsigs, 125*0Sstevel@tonic-gate * strpollset_t *pollwakeups); 126*0Sstevel@tonic-gate * It returns an optional message to be processed by the stream head. 127*0Sstevel@tonic-gate * 128*0Sstevel@tonic-gate * The parameters for errfunc_t are: 129*0Sstevel@tonic-gate * errfunc(vnode *vp, int ispeek, int *clearerr); 130*0Sstevel@tonic-gate * It returns an errno and zero if there was no pending error. 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate typedef uint_t strwakeup_t; 133*0Sstevel@tonic-gate typedef uint_t strsigset_t; 134*0Sstevel@tonic-gate typedef short strpollset_t; 135*0Sstevel@tonic-gate typedef uintptr_t callbparams_id_t; 136*0Sstevel@tonic-gate typedef mblk_t *(*msgfunc_t)(vnode_t *, mblk_t *, strwakeup_t *, 137*0Sstevel@tonic-gate strsigset_t *, strsigset_t *, strpollset_t *); 138*0Sstevel@tonic-gate typedef int (*errfunc_t)(vnode_t *, int, int *); 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * Per stream sd_lock in putnext may be replaced by per cpu stream_putlocks 142*0Sstevel@tonic-gate * each living in a separate cache line. putnext/canputnext grabs only one of 143*0Sstevel@tonic-gate * stream_putlocks while strlock() (called on behalf of insertq()/removeq()) 144*0Sstevel@tonic-gate * acquires all stream_putlocks. Normally stream_putlocks are only employed 145*0Sstevel@tonic-gate * for highly contended streams that have SQ_CIPUT queues in the critical path 146*0Sstevel@tonic-gate * (e.g. NFS/UDP stream). 147*0Sstevel@tonic-gate * 148*0Sstevel@tonic-gate * stream_putlocks are dynamically assigned to stdata structure through 149*0Sstevel@tonic-gate * sd_ciputctrl pointer possibly when a stream is already in use. Since 150*0Sstevel@tonic-gate * strlock() uses stream_putlocks only under sd_lock acquiring sd_lock when 151*0Sstevel@tonic-gate * assigning stream_putlocks to the stream ensures synchronization with 152*0Sstevel@tonic-gate * strlock(). 153*0Sstevel@tonic-gate * 154*0Sstevel@tonic-gate * For lock ordering purposes stream_putlocks are treated as the extension of 155*0Sstevel@tonic-gate * sd_lock and are always grabbed right after grabbing sd_lock and released 156*0Sstevel@tonic-gate * right before releasing sd_lock except putnext/canputnext where only one of 157*0Sstevel@tonic-gate * stream_putlocks locks is used and where it is the first lock to grab. 158*0Sstevel@tonic-gate */ 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate typedef struct ciputctrl_str { 161*0Sstevel@tonic-gate union _ciput_un { 162*0Sstevel@tonic-gate uchar_t pad[64]; 163*0Sstevel@tonic-gate struct _ciput_str { 164*0Sstevel@tonic-gate kmutex_t ciput_lck; 165*0Sstevel@tonic-gate ushort_t ciput_cnt; 166*0Sstevel@tonic-gate } ciput_str; 167*0Sstevel@tonic-gate } ciput_un; 168*0Sstevel@tonic-gate } ciputctrl_t; 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate #define ciputctrl_lock ciput_un.ciput_str.ciput_lck 171*0Sstevel@tonic-gate #define ciputctrl_count ciput_un.ciput_str.ciput_cnt 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate /* 174*0Sstevel@tonic-gate * Header for a stream: interface to rest of system. 175*0Sstevel@tonic-gate */ 176*0Sstevel@tonic-gate typedef struct stdata { 177*0Sstevel@tonic-gate struct queue *sd_wrq; /* write queue */ 178*0Sstevel@tonic-gate struct msgb *sd_iocblk; /* return block for ioctl */ 179*0Sstevel@tonic-gate struct vnode *sd_vnode; /* pointer to associated vnode */ 180*0Sstevel@tonic-gate struct streamtab *sd_strtab; /* pointer to streamtab for stream */ 181*0Sstevel@tonic-gate uint_t sd_flag; /* state/flags */ 182*0Sstevel@tonic-gate uint_t sd_iocid; /* ioctl id */ 183*0Sstevel@tonic-gate struct pid *sd_sidp; /* controlling session info */ 184*0Sstevel@tonic-gate struct pid *sd_pgidp; /* controlling process group info */ 185*0Sstevel@tonic-gate ushort_t sd_unused; /* UNUSED, retained for binary */ 186*0Sstevel@tonic-gate /* compatibility */ 187*0Sstevel@tonic-gate ushort_t sd_wroff; /* write offset */ 188*0Sstevel@tonic-gate int sd_rerror; /* error to return on read ops */ 189*0Sstevel@tonic-gate int sd_werror; /* error to return on write ops */ 190*0Sstevel@tonic-gate int sd_pushcnt; /* number of pushes done on stream */ 191*0Sstevel@tonic-gate int sd_sigflags; /* logical OR of all siglist events */ 192*0Sstevel@tonic-gate struct strsig *sd_siglist; /* pid linked list to rcv SIGPOLL sig */ 193*0Sstevel@tonic-gate struct pollhead sd_pollist; /* list of all pollers to wake up */ 194*0Sstevel@tonic-gate struct msgb *sd_mark; /* "marked" message on read queue */ 195*0Sstevel@tonic-gate clock_t sd_closetime; /* time to wait to drain q in close */ 196*0Sstevel@tonic-gate kmutex_t sd_lock; /* protect head consistency */ 197*0Sstevel@tonic-gate kcondvar_t sd_monitor; /* open/close/push/pop monitor */ 198*0Sstevel@tonic-gate kcondvar_t sd_iocmonitor; /* ioctl single-threading */ 199*0Sstevel@tonic-gate ssize_t sd_qn_minpsz; /* These two fields are a performance */ 200*0Sstevel@tonic-gate ssize_t sd_qn_maxpsz; /* enhancements, cache the values in */ 201*0Sstevel@tonic-gate /* the stream head so we don't have */ 202*0Sstevel@tonic-gate /* to ask the module below the stream */ 203*0Sstevel@tonic-gate /* head to get this information. */ 204*0Sstevel@tonic-gate struct stdata *sd_mate; /* pointer to twisted stream mate */ 205*0Sstevel@tonic-gate kthread_id_t sd_freezer; /* thread that froze stream */ 206*0Sstevel@tonic-gate kmutex_t sd_reflock; /* Protects sd_refcnt */ 207*0Sstevel@tonic-gate int sd_refcnt; /* number of claimstr */ 208*0Sstevel@tonic-gate uint_t sd_wakeq; /* strwakeq()'s copy of sd_flag */ 209*0Sstevel@tonic-gate struct queue *sd_struiordq; /* sync barrier struio() read queue */ 210*0Sstevel@tonic-gate struct queue *sd_struiowrq; /* sync barrier struio() write queue */ 211*0Sstevel@tonic-gate char sd_struiodnak; /* defer NAK of M_IOCTL by rput() */ 212*0Sstevel@tonic-gate struct msgb *sd_struionak; /* pointer M_IOCTL mblk(s) to NAK */ 213*0Sstevel@tonic-gate caddr_t sd_t_audit_data; /* For audit purposes only */ 214*0Sstevel@tonic-gate ssize_t sd_maxblk; /* maximum message block size */ 215*0Sstevel@tonic-gate uint_t sd_rput_opt; /* options/flags for strrput */ 216*0Sstevel@tonic-gate uint_t sd_wput_opt; /* options/flags for write/putmsg */ 217*0Sstevel@tonic-gate uint_t sd_read_opt; /* options/flags for strread */ 218*0Sstevel@tonic-gate msgfunc_t sd_rprotofunc; /* rput M_*PROTO routine */ 219*0Sstevel@tonic-gate msgfunc_t sd_rmiscfunc; /* rput routine (non-data/proto) */ 220*0Sstevel@tonic-gate errfunc_t sd_rderrfunc; /* read side error callback */ 221*0Sstevel@tonic-gate errfunc_t sd_wrerrfunc; /* write side error callback */ 222*0Sstevel@tonic-gate /* 223*0Sstevel@tonic-gate * support for low contention concurrent putnext. 224*0Sstevel@tonic-gate */ 225*0Sstevel@tonic-gate ciputctrl_t *sd_ciputctrl; 226*0Sstevel@tonic-gate uint_t sd_nciputctrl; 227*0Sstevel@tonic-gate 228*0Sstevel@tonic-gate int sd_anchor; /* position of anchor in stream */ 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * Service scheduling at the stream head. 231*0Sstevel@tonic-gate */ 232*0Sstevel@tonic-gate kmutex_t sd_qlock; 233*0Sstevel@tonic-gate struct queue *sd_qhead; /* Head of queues to be serviced. */ 234*0Sstevel@tonic-gate struct queue *sd_qtail; /* Tail of queues to be serviced. */ 235*0Sstevel@tonic-gate void *sd_servid; /* Service ID for bckgrnd schedule */ 236*0Sstevel@tonic-gate ushort_t sd_svcflags; /* Servicing flags */ 237*0Sstevel@tonic-gate short sd_nqueues; /* Number of queues in the list */ 238*0Sstevel@tonic-gate kcondvar_t sd_qcv; /* Waiters for qhead to become empty */ 239*0Sstevel@tonic-gate kcondvar_t sd_zcopy_wait; 240*0Sstevel@tonic-gate uint_t sd_copyflag; /* copy-related flags */ 241*0Sstevel@tonic-gate } stdata_t; 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate /* 244*0Sstevel@tonic-gate * stdata servicing flags. 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate #define STRS_WILLSERVICE 0x01 247*0Sstevel@tonic-gate #define STRS_SCHEDULED 0x02 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate #define STREAM_NEEDSERVICE(stp) ((stp)->sd_qhead != NULL) 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate /* 252*0Sstevel@tonic-gate * stdata flag field defines 253*0Sstevel@tonic-gate */ 254*0Sstevel@tonic-gate #define IOCWAIT 0x00000001 /* Someone is doing an ioctl */ 255*0Sstevel@tonic-gate #define RSLEEP 0x00000002 /* Someone wants to read/recv msg */ 256*0Sstevel@tonic-gate #define WSLEEP 0x00000004 /* Someone wants to write */ 257*0Sstevel@tonic-gate #define STRPRI 0x00000008 /* An M_PCPROTO is at stream head */ 258*0Sstevel@tonic-gate #define STRHUP 0x00000010 /* Device has vanished */ 259*0Sstevel@tonic-gate #define STWOPEN 0x00000020 /* waiting for 1st open */ 260*0Sstevel@tonic-gate #define STPLEX 0x00000040 /* stream is being multiplexed */ 261*0Sstevel@tonic-gate #define STRISTTY 0x00000080 /* stream is a terminal */ 262*0Sstevel@tonic-gate #define STRGETINPROG 0x00000100 /* (k)strgetmsg is running */ 263*0Sstevel@tonic-gate #define IOCWAITNE 0x00000200 /* STR_NOERROR ioctl running */ 264*0Sstevel@tonic-gate #define STRDERR 0x00000400 /* fatal read error from M_ERROR */ 265*0Sstevel@tonic-gate #define STWRERR 0x00000800 /* fatal write error from M_ERROR */ 266*0Sstevel@tonic-gate #define STRDERRNONPERSIST 0x00001000 /* nonpersistent read errors */ 267*0Sstevel@tonic-gate #define STWRERRNONPERSIST 0x00002000 /* nonpersistent write errors */ 268*0Sstevel@tonic-gate #define STRCLOSE 0x00004000 /* wait for a close to complete */ 269*0Sstevel@tonic-gate #define SNDMREAD 0x00008000 /* used for read notification */ 270*0Sstevel@tonic-gate #define OLDNDELAY 0x00010000 /* use old TTY semantics for */ 271*0Sstevel@tonic-gate /* NDELAY reads and writes */ 272*0Sstevel@tonic-gate /* 0x00020000 unused */ 273*0Sstevel@tonic-gate /* 0x00040000 unused */ 274*0Sstevel@tonic-gate #define STRTOSTOP 0x00080000 /* block background writes */ 275*0Sstevel@tonic-gate /* 0x00100000 unused */ 276*0Sstevel@tonic-gate /* 0x00200000 unused */ 277*0Sstevel@tonic-gate #define STRMOUNT 0x00400000 /* stream is mounted */ 278*0Sstevel@tonic-gate #define STRNOTATMARK 0x00800000 /* Not at mark (when empty read q) */ 279*0Sstevel@tonic-gate #define STRDELIM 0x01000000 /* generate delimited messages */ 280*0Sstevel@tonic-gate #define STRATMARK 0x02000000 /* At mark (due to MSGMARKNEXT) */ 281*0Sstevel@tonic-gate #define STZCNOTIFY 0x04000000 /* wait for zerocopy mblk to be acked */ 282*0Sstevel@tonic-gate #define STRPLUMB 0x08000000 /* push/pop pending */ 283*0Sstevel@tonic-gate #define STREOF 0x10000000 /* End-of-file indication */ 284*0Sstevel@tonic-gate #define STREOPENFAIL 0x20000000 /* indicates if re-open has failed */ 285*0Sstevel@tonic-gate #define STRMATE 0x40000000 /* this stream is a mate */ 286*0Sstevel@tonic-gate #define STRHASLINKS 0x80000000 /* I_LINKs under this stream */ 287*0Sstevel@tonic-gate 288*0Sstevel@tonic-gate /* 289*0Sstevel@tonic-gate * Copy-related flags (sd_copyflag), set by SO_COPYOPT. 290*0Sstevel@tonic-gate */ 291*0Sstevel@tonic-gate #define STZCVMSAFE 0x00000001 /* safe to borrow file (segmapped) */ 292*0Sstevel@tonic-gate /* pages instead of bcopy */ 293*0Sstevel@tonic-gate #define STZCVMUNSAFE 0x00000002 /* unsafe to borrow file pages */ 294*0Sstevel@tonic-gate #define STRCOPYCACHED 0x00000004 /* copy should NOT bypass cache */ 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate /* 297*0Sstevel@tonic-gate * Options and flags for strrput (sd_rput_opt) 298*0Sstevel@tonic-gate */ 299*0Sstevel@tonic-gate #define SR_POLLIN 0x00000001 /* pollwakeup needed for band0 data */ 300*0Sstevel@tonic-gate #define SR_SIGALLDATA 0x00000002 /* Send SIGPOLL for all M_DATA */ 301*0Sstevel@tonic-gate #define SR_CONSOL_DATA 0x00000004 /* Consolidate M_DATA onto q_last */ 302*0Sstevel@tonic-gate #define SR_IGN_ZEROLEN 0x00000008 /* Ignore zero-length M_DATA */ 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate /* 305*0Sstevel@tonic-gate * Options and flags for strwrite/strputmsg (sd_wput_opt) 306*0Sstevel@tonic-gate */ 307*0Sstevel@tonic-gate #define SW_SIGPIPE 0x00000001 /* Send SIGPIPE for write error */ 308*0Sstevel@tonic-gate #define SW_RECHECK_ERR 0x00000002 /* Recheck errors in strwrite loop */ 309*0Sstevel@tonic-gate #define SW_SNDZERO 0x00000004 /* send 0-length msg down pipe/FIFO */ 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate /* 312*0Sstevel@tonic-gate * Options and flags for strread (sd_read_opt) 313*0Sstevel@tonic-gate */ 314*0Sstevel@tonic-gate #define RD_MSGDIS 0x00000001 /* read msg discard */ 315*0Sstevel@tonic-gate #define RD_MSGNODIS 0x00000002 /* read msg no discard */ 316*0Sstevel@tonic-gate #define RD_PROTDAT 0x00000004 /* read M_[PC]PROTO contents as data */ 317*0Sstevel@tonic-gate #define RD_PROTDIS 0x00000008 /* discard M_[PC]PROTO blocks and */ 318*0Sstevel@tonic-gate /* retain data blocks */ 319*0Sstevel@tonic-gate /* 320*0Sstevel@tonic-gate * Flags parameter for strsetrputhooks() and strsetwputhooks(). 321*0Sstevel@tonic-gate * These flags define the interface for setting the above internal 322*0Sstevel@tonic-gate * flags in sd_rput_opt and sd_wput_opt. 323*0Sstevel@tonic-gate */ 324*0Sstevel@tonic-gate #define SH_CONSOL_DATA 0x00000001 /* Consolidate M_DATA onto q_last */ 325*0Sstevel@tonic-gate #define SH_SIGALLDATA 0x00000002 /* Send SIGPOLL for all M_DATA */ 326*0Sstevel@tonic-gate #define SH_IGN_ZEROLEN 0x00000004 /* Drop zero-length M_DATA */ 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate #define SH_SIGPIPE 0x00000100 /* Send SIGPIPE for write error */ 329*0Sstevel@tonic-gate #define SH_RECHECK_ERR 0x00000200 /* Recheck errors in strwrite loop */ 330*0Sstevel@tonic-gate 331*0Sstevel@tonic-gate /* 332*0Sstevel@tonic-gate * Each queue points to a sync queue (the inner perimeter) which keeps 333*0Sstevel@tonic-gate * track of the number of threads that are inside a given queue (sq_count) 334*0Sstevel@tonic-gate * and also is used to implement the asynchronous putnext 335*0Sstevel@tonic-gate * (by queuing messages if the queue can not be entered.) 336*0Sstevel@tonic-gate * 337*0Sstevel@tonic-gate * Messages are queued on sq_head/sq_tail including deferred qwriter(INNER) 338*0Sstevel@tonic-gate * messages. The sq_head/sq_tail list is a singly-linked list with 339*0Sstevel@tonic-gate * b_queue recording the queue and b_prev recording the function to 340*0Sstevel@tonic-gate * be called (either the put procedure or a qwriter callback function.) 341*0Sstevel@tonic-gate * 342*0Sstevel@tonic-gate * The sq_count counter tracks the number of threads that are 343*0Sstevel@tonic-gate * executing inside the perimeter or (in the case of outer perimeters) 344*0Sstevel@tonic-gate * have some work queued for them relating to the perimeter. The sq_rmqcount 345*0Sstevel@tonic-gate * counter tracks the subset which are in removeq() (usually invoked from 346*0Sstevel@tonic-gate * qprocsoff(9F)). 347*0Sstevel@tonic-gate * 348*0Sstevel@tonic-gate * In addition a module writer can declare that the module has an outer 349*0Sstevel@tonic-gate * perimeter (by setting D_MTOUTPERIM) in which case all inner perimeter 350*0Sstevel@tonic-gate * syncq's for the module point (through sq_outer) to an outer perimeter 351*0Sstevel@tonic-gate * syncq. The outer perimeter consists of the doubly linked list (sq_onext and 352*0Sstevel@tonic-gate * sq_oprev) linking all the inner perimeter syncq's with out outer perimeter 353*0Sstevel@tonic-gate * syncq. This is used to implement qwriter(OUTER) (an asynchronous way of 354*0Sstevel@tonic-gate * getting exclusive access at the outer perimeter) and outer_enter/exit 355*0Sstevel@tonic-gate * which are used by the framework to acquire exclusive access to the outer 356*0Sstevel@tonic-gate * perimeter during open and close of modules that have set D_MTOUTPERIM. 357*0Sstevel@tonic-gate * 358*0Sstevel@tonic-gate * In the inner perimeter case sq_save is available for use by machine 359*0Sstevel@tonic-gate * dependent code. sq_head/sq_tail are used to queue deferred messages on 360*0Sstevel@tonic-gate * the inner perimeter syncqs and to queue become_writer requests on the 361*0Sstevel@tonic-gate * outer perimeter syncqs. 362*0Sstevel@tonic-gate * 363*0Sstevel@tonic-gate * Note: machine dependent optimized versions of putnext may depend 364*0Sstevel@tonic-gate * on the order of sq_flags and sq_count (so that they can e.g. 365*0Sstevel@tonic-gate * read these two fields in a single load instruction.) 366*0Sstevel@tonic-gate * 367*0Sstevel@tonic-gate * Per perimeter SQLOCK/sq_count in putnext/put may be replaced by per cpu 368*0Sstevel@tonic-gate * sq_putlocks/sq_putcounts each living in a separate cache line. Obviously 369*0Sstevel@tonic-gate * sq_putlock[x] protects sq_putcount[x]. putnext/put routine will grab only 1 370*0Sstevel@tonic-gate * of sq_putlocks and update only 1 of sq_putcounts. strlock() and many 371*0Sstevel@tonic-gate * other routines in strsubr.c and ddi.c will grab all sq_putlocks (as well as 372*0Sstevel@tonic-gate * SQLOCK) and figure out the count value as the sum of sq_count and all of 373*0Sstevel@tonic-gate * sq_putcounts. The idea is to make critical fast path -- putnext -- much 374*0Sstevel@tonic-gate * faster at the expense of much less often used slower path like 375*0Sstevel@tonic-gate * strlock(). One known case where entersq/strlock is executed pretty often is 376*0Sstevel@tonic-gate * SpecWeb but since IP is SQ_CIOC and socket TCP/IP stream is nextless 377*0Sstevel@tonic-gate * there's no need to grab multiple sq_putlocks and look at sq_putcounts. See 378*0Sstevel@tonic-gate * strsubr.c for more comments. 379*0Sstevel@tonic-gate * 380*0Sstevel@tonic-gate * Note regular SQLOCK and sq_count are still used in many routines 381*0Sstevel@tonic-gate * (e.g. entersq(), rwnext()) in the same way as before sq_putlocks were 382*0Sstevel@tonic-gate * introduced. 383*0Sstevel@tonic-gate * 384*0Sstevel@tonic-gate * To understand when all sq_putlocks need to be held and all sq_putcounts 385*0Sstevel@tonic-gate * need to be added up one needs to look closely at putnext code. Basically if 386*0Sstevel@tonic-gate * a routine like e.g. wait_syncq() needs to be sure that perimeter is empty 387*0Sstevel@tonic-gate * all sq_putlocks/sq_putcounts need to be held/added up. On the other hand 388*0Sstevel@tonic-gate * there's no need to hold all sq_putlocks and count all sq_putcounts in 389*0Sstevel@tonic-gate * routines like leavesq()/dropsq() and etc. since the are usually exit 390*0Sstevel@tonic-gate * counterparts of entersq/outer_enter() and etc. which have already either 391*0Sstevel@tonic-gate * prevented put entry poins from executing or did not care about put 392*0Sstevel@tonic-gate * entrypoints. entersq() doesn't need to care about sq_putlocks/sq_putcounts 393*0Sstevel@tonic-gate * if the entry point has a shared access since put has the highest degree of 394*0Sstevel@tonic-gate * concurrency and such entersq() does not intend to block out put 395*0Sstevel@tonic-gate * entrypoints. 396*0Sstevel@tonic-gate * 397*0Sstevel@tonic-gate * Before sq_putcounts were introduced the standard way to wait for perimeter 398*0Sstevel@tonic-gate * to become empty was: 399*0Sstevel@tonic-gate * 400*0Sstevel@tonic-gate * mutex_enter(SQLOCK(sq)); 401*0Sstevel@tonic-gate * while (sq->sq_count > 0) { 402*0Sstevel@tonic-gate * sq->sq_flags |= SQ_WANTWAKEUP; 403*0Sstevel@tonic-gate * cv_wait(&sq->sq_wait, SQLOCK(sq)); 404*0Sstevel@tonic-gate * } 405*0Sstevel@tonic-gate * mutex_exit(SQLOCK(sq)); 406*0Sstevel@tonic-gate * 407*0Sstevel@tonic-gate * The new way is: 408*0Sstevel@tonic-gate * 409*0Sstevel@tonic-gate * mutex_enter(SQLOCK(sq)); 410*0Sstevel@tonic-gate * count = sq->sq_count; 411*0Sstevel@tonic-gate * SQ_PUTLOCKS_ENTER(sq); 412*0Sstevel@tonic-gate * SUM_SQ_PUTCOUNTS(sq, count); 413*0Sstevel@tonic-gate * while (count != 0) { 414*0Sstevel@tonic-gate * sq->sq_flags |= SQ_WANTWAKEUP; 415*0Sstevel@tonic-gate * SQ_PUTLOCKS_EXIT(sq); 416*0Sstevel@tonic-gate * cv_wait(&sq->sq_wait, SQLOCK(sq)); 417*0Sstevel@tonic-gate * count = sq->sq_count; 418*0Sstevel@tonic-gate * SQ_PUTLOCKS_ENTER(sq); 419*0Sstevel@tonic-gate * SUM_SQ_PUTCOUNTS(sq, count); 420*0Sstevel@tonic-gate * } 421*0Sstevel@tonic-gate * SQ_PUTLOCKS_EXIT(sq); 422*0Sstevel@tonic-gate * mutex_exit(SQLOCK(sq)); 423*0Sstevel@tonic-gate * 424*0Sstevel@tonic-gate * Note that SQ_WANTWAKEUP is set before dropping SQ_PUTLOCKS. This makes sure 425*0Sstevel@tonic-gate * putnext won't skip a wakeup. 426*0Sstevel@tonic-gate * 427*0Sstevel@tonic-gate * sq_putlocks are treated as the extension of SQLOCK for lock ordering 428*0Sstevel@tonic-gate * purposes and are always grabbed right after grabbing SQLOCK and released 429*0Sstevel@tonic-gate * right before releasing SQLOCK. This also allows dynamic creation of 430*0Sstevel@tonic-gate * sq_putlocks while holding SQLOCK (by making sq_ciputctrl non null even when 431*0Sstevel@tonic-gate * the stream is already in use). Only in putnext one of sq_putlocks 432*0Sstevel@tonic-gate * is grabbed instead of SQLOCK. putnext return path remembers what counter it 433*0Sstevel@tonic-gate * incremented and decrements the right counter on its way out. 434*0Sstevel@tonic-gate */ 435*0Sstevel@tonic-gate 436*0Sstevel@tonic-gate struct syncq { 437*0Sstevel@tonic-gate kmutex_t sq_lock; /* atomic access to syncq */ 438*0Sstevel@tonic-gate uint16_t sq_count; /* # threads inside */ 439*0Sstevel@tonic-gate uint16_t sq_flags; /* state and some type info */ 440*0Sstevel@tonic-gate /* 441*0Sstevel@tonic-gate * Distributed syncq scheduling 442*0Sstevel@tonic-gate * The list of queue's is handled by sq_head and 443*0Sstevel@tonic-gate * sq_tail fields. 444*0Sstevel@tonic-gate * 445*0Sstevel@tonic-gate * The list of events is handled by the sq_evhead and sq_evtail 446*0Sstevel@tonic-gate * fields. 447*0Sstevel@tonic-gate */ 448*0Sstevel@tonic-gate queue_t *sq_head; /* queue of deferred messages */ 449*0Sstevel@tonic-gate queue_t *sq_tail; /* queue of deferred messages */ 450*0Sstevel@tonic-gate mblk_t *sq_evhead; /* Event message on the syncq */ 451*0Sstevel@tonic-gate mblk_t *sq_evtail; 452*0Sstevel@tonic-gate uint_t sq_nqueues; /* # of queues on this sq */ 453*0Sstevel@tonic-gate /* 454*0Sstevel@tonic-gate * Concurrency and condition variables 455*0Sstevel@tonic-gate */ 456*0Sstevel@tonic-gate uint16_t sq_type; /* type (concurrency) of syncq */ 457*0Sstevel@tonic-gate uint16_t sq_rmqcount; /* # threads inside removeq() */ 458*0Sstevel@tonic-gate kcondvar_t sq_wait; /* block on this sync queue */ 459*0Sstevel@tonic-gate kcondvar_t sq_exitwait; /* waiting for thread to leave the */ 460*0Sstevel@tonic-gate /* inner perimeter */ 461*0Sstevel@tonic-gate /* 462*0Sstevel@tonic-gate * Handling synchronous callbacks such as qtimeout and qbufcall 463*0Sstevel@tonic-gate */ 464*0Sstevel@tonic-gate ushort_t sq_callbflags; /* flags for callback synchronization */ 465*0Sstevel@tonic-gate callbparams_id_t sq_cancelid; /* id of callback being cancelled */ 466*0Sstevel@tonic-gate struct callbparams *sq_callbpend; /* Pending callbacks */ 467*0Sstevel@tonic-gate 468*0Sstevel@tonic-gate /* 469*0Sstevel@tonic-gate * Links forming an outer perimeter from one outer syncq and 470*0Sstevel@tonic-gate * a set of inner sync queues. 471*0Sstevel@tonic-gate */ 472*0Sstevel@tonic-gate struct syncq *sq_outer; /* Pointer to outer perimeter */ 473*0Sstevel@tonic-gate struct syncq *sq_onext; /* Linked list of syncq's making */ 474*0Sstevel@tonic-gate struct syncq *sq_oprev; /* up the outer perimeter. */ 475*0Sstevel@tonic-gate /* 476*0Sstevel@tonic-gate * support for low contention concurrent putnext. 477*0Sstevel@tonic-gate */ 478*0Sstevel@tonic-gate ciputctrl_t *sq_ciputctrl; 479*0Sstevel@tonic-gate uint_t sq_nciputctrl; 480*0Sstevel@tonic-gate /* 481*0Sstevel@tonic-gate * Counter for the number of threads wanting to become exclusive. 482*0Sstevel@tonic-gate */ 483*0Sstevel@tonic-gate uint_t sq_needexcl; 484*0Sstevel@tonic-gate /* 485*0Sstevel@tonic-gate * These two fields are used for scheduling a syncq for 486*0Sstevel@tonic-gate * background processing. The sq_svcflag is protected by 487*0Sstevel@tonic-gate * SQLOCK lock. 488*0Sstevel@tonic-gate */ 489*0Sstevel@tonic-gate struct syncq *sq_next; /* for syncq scheduling */ 490*0Sstevel@tonic-gate void * sq_servid; 491*0Sstevel@tonic-gate uint_t sq_servcount; /* # pending background threads */ 492*0Sstevel@tonic-gate uint_t sq_svcflags; /* Scheduling flags */ 493*0Sstevel@tonic-gate clock_t sq_tstamp; /* Time when was enabled */ 494*0Sstevel@tonic-gate /* 495*0Sstevel@tonic-gate * Maximum priority of the queues on this syncq. 496*0Sstevel@tonic-gate */ 497*0Sstevel@tonic-gate pri_t sq_pri; 498*0Sstevel@tonic-gate }; 499*0Sstevel@tonic-gate typedef struct syncq syncq_t; 500*0Sstevel@tonic-gate 501*0Sstevel@tonic-gate /* 502*0Sstevel@tonic-gate * sync queue scheduling flags (for sq_svcflags). 503*0Sstevel@tonic-gate */ 504*0Sstevel@tonic-gate #define SQ_SERVICE 0x1 /* being serviced */ 505*0Sstevel@tonic-gate #define SQ_BGTHREAD 0x2 /* awaiting service by bg thread */ 506*0Sstevel@tonic-gate #define SQ_DISABLED 0x4 /* don't put syncq in service list */ 507*0Sstevel@tonic-gate 508*0Sstevel@tonic-gate /* 509*0Sstevel@tonic-gate * FASTPUT bit in sd_count/putcount. 510*0Sstevel@tonic-gate */ 511*0Sstevel@tonic-gate #define SQ_FASTPUT 0x8000 512*0Sstevel@tonic-gate #define SQ_FASTMASK 0x7FFF 513*0Sstevel@tonic-gate 514*0Sstevel@tonic-gate /* 515*0Sstevel@tonic-gate * sync queue state flags 516*0Sstevel@tonic-gate */ 517*0Sstevel@tonic-gate #define SQ_EXCL 0x0001 /* exclusive access to inner */ 518*0Sstevel@tonic-gate /* perimeter */ 519*0Sstevel@tonic-gate #define SQ_BLOCKED 0x0002 /* qprocsoff */ 520*0Sstevel@tonic-gate #define SQ_FROZEN 0x0004 /* freezestr */ 521*0Sstevel@tonic-gate #define SQ_WRITER 0x0008 /* qwriter(OUTER) pending or running */ 522*0Sstevel@tonic-gate #define SQ_MESSAGES 0x0010 /* messages on syncq */ 523*0Sstevel@tonic-gate #define SQ_WANTWAKEUP 0x0020 /* do cv_broadcast on sq_wait */ 524*0Sstevel@tonic-gate #define SQ_WANTEXWAKEUP 0x0040 /* do cv_broadcast on sq_exitwait */ 525*0Sstevel@tonic-gate #define SQ_EVENTS 0x0080 /* Events pending */ 526*0Sstevel@tonic-gate #define SQ_QUEUED (SQ_MESSAGES | SQ_EVENTS) 527*0Sstevel@tonic-gate #define SQ_FLAGMASK 0x00FF 528*0Sstevel@tonic-gate 529*0Sstevel@tonic-gate /* 530*0Sstevel@tonic-gate * Test a queue to see if inner perimeter is exclusive. 531*0Sstevel@tonic-gate */ 532*0Sstevel@tonic-gate #define PERIM_EXCL(q) ((q)->q_syncq->sq_flags & SQ_EXCL) 533*0Sstevel@tonic-gate 534*0Sstevel@tonic-gate /* 535*0Sstevel@tonic-gate * If any of these flags are set it is not possible for a thread to 536*0Sstevel@tonic-gate * enter a put or service procedure. Instead it must either block 537*0Sstevel@tonic-gate * or put the message on the syncq. 538*0Sstevel@tonic-gate */ 539*0Sstevel@tonic-gate #define SQ_GOAWAY (SQ_EXCL|SQ_BLOCKED|SQ_FROZEN|SQ_WRITER|\ 540*0Sstevel@tonic-gate SQ_QUEUED) 541*0Sstevel@tonic-gate /* 542*0Sstevel@tonic-gate * If any of these flags are set it not possible to drain the syncq 543*0Sstevel@tonic-gate */ 544*0Sstevel@tonic-gate #define SQ_STAYAWAY (SQ_BLOCKED|SQ_FROZEN|SQ_WRITER) 545*0Sstevel@tonic-gate 546*0Sstevel@tonic-gate /* 547*0Sstevel@tonic-gate * Flags to trigger syncq tail processing. 548*0Sstevel@tonic-gate */ 549*0Sstevel@tonic-gate #define SQ_TAIL (SQ_QUEUED|SQ_WANTWAKEUP|SQ_WANTEXWAKEUP) 550*0Sstevel@tonic-gate 551*0Sstevel@tonic-gate /* 552*0Sstevel@tonic-gate * Syncq types (stored in sq_type) 553*0Sstevel@tonic-gate * The SQ_TYPES_IN_FLAGS (ciput) are also stored in sq_flags 554*0Sstevel@tonic-gate * for performance reasons. Thus these type values have to be in the low 555*0Sstevel@tonic-gate * 16 bits and not conflict with the sq_flags values above. 556*0Sstevel@tonic-gate * 557*0Sstevel@tonic-gate * Notes: 558*0Sstevel@tonic-gate * - putnext() and put() assume that the put procedures have the highest 559*0Sstevel@tonic-gate * degree of concurrency. Thus if any of the SQ_CI* are set then SQ_CIPUT 560*0Sstevel@tonic-gate * has to be set. This restriction can be lifted by adding code to putnext 561*0Sstevel@tonic-gate * and put that check that sq_count == 0 like entersq does. 562*0Sstevel@tonic-gate * - putnext() and put() does currently not handle !SQ_COPUT 563*0Sstevel@tonic-gate * - In order to implement !SQ_COCB outer_enter has to be fixed so that 564*0Sstevel@tonic-gate * the callback can be cancelled while cv_waiting in outer_enter. 565*0Sstevel@tonic-gate * - If SQ_CISVC needs to be implemented, qprocsoff() needs to wait 566*0Sstevel@tonic-gate * for the currently running services to stop (wait for QINSERVICE 567*0Sstevel@tonic-gate * to go off). disable_svc called from qprcosoff disables only 568*0Sstevel@tonic-gate * services that will be run in future. 569*0Sstevel@tonic-gate * 570*0Sstevel@tonic-gate * All the SQ_CO flags are set when there is no outer perimeter. 571*0Sstevel@tonic-gate */ 572*0Sstevel@tonic-gate #define SQ_CIPUT 0x0100 /* Concurrent inner put proc */ 573*0Sstevel@tonic-gate #define SQ_CISVC 0x0200 /* Concurrent inner svc proc */ 574*0Sstevel@tonic-gate #define SQ_CIOC 0x0400 /* Concurrent inner open/close */ 575*0Sstevel@tonic-gate #define SQ_CICB 0x0800 /* Concurrent inner callback */ 576*0Sstevel@tonic-gate #define SQ_COPUT 0x1000 /* Concurrent outer put proc */ 577*0Sstevel@tonic-gate #define SQ_COSVC 0x2000 /* Concurrent outer svc proc */ 578*0Sstevel@tonic-gate #define SQ_COOC 0x4000 /* Concurrent outer open/close */ 579*0Sstevel@tonic-gate #define SQ_COCB 0x8000 /* Concurrent outer callback */ 580*0Sstevel@tonic-gate 581*0Sstevel@tonic-gate /* Types also kept in sq_flags for performance */ 582*0Sstevel@tonic-gate #define SQ_TYPES_IN_FLAGS (SQ_CIPUT) 583*0Sstevel@tonic-gate 584*0Sstevel@tonic-gate #define SQ_CI (SQ_CIPUT|SQ_CISVC|SQ_CIOC|SQ_CICB) 585*0Sstevel@tonic-gate #define SQ_CO (SQ_COPUT|SQ_COSVC|SQ_COOC|SQ_COCB) 586*0Sstevel@tonic-gate #define SQ_TYPEMASK (SQ_CI|SQ_CO) 587*0Sstevel@tonic-gate 588*0Sstevel@tonic-gate /* 589*0Sstevel@tonic-gate * Flag combinations passed to entersq and leavesq to specify the type 590*0Sstevel@tonic-gate * of entry point. 591*0Sstevel@tonic-gate */ 592*0Sstevel@tonic-gate #define SQ_PUT (SQ_CIPUT|SQ_COPUT) 593*0Sstevel@tonic-gate #define SQ_SVC (SQ_CISVC|SQ_COSVC) 594*0Sstevel@tonic-gate #define SQ_OPENCLOSE (SQ_CIOC|SQ_COOC) 595*0Sstevel@tonic-gate #define SQ_CALLBACK (SQ_CICB|SQ_COCB) 596*0Sstevel@tonic-gate 597*0Sstevel@tonic-gate /* 598*0Sstevel@tonic-gate * Other syncq types which are not copied into flags. 599*0Sstevel@tonic-gate */ 600*0Sstevel@tonic-gate #define SQ_PERMOD 0x01 /* Syncq is PERMOD */ 601*0Sstevel@tonic-gate 602*0Sstevel@tonic-gate /* 603*0Sstevel@tonic-gate * Asynchronous callback qun*** flag. 604*0Sstevel@tonic-gate * The mechanism these flags are used in is one where callbacks enter 605*0Sstevel@tonic-gate * the perimeter thanks to framework support. To use this mechanism 606*0Sstevel@tonic-gate * the q* and qun* flavors of the callback routines must be used. 607*0Sstevel@tonic-gate * e.g. qtimeout and quntimeout. The synchronization provided by the flags 608*0Sstevel@tonic-gate * avoids deadlocks between blocking qun* routines and the perimeter 609*0Sstevel@tonic-gate * lock. 610*0Sstevel@tonic-gate */ 611*0Sstevel@tonic-gate #define SQ_CALLB_BYPASSED 0x01 /* bypassed callback fn */ 612*0Sstevel@tonic-gate 613*0Sstevel@tonic-gate /* 614*0Sstevel@tonic-gate * Cancel callback mask. 615*0Sstevel@tonic-gate * The mask expands as the number of cancelable callback types grows 616*0Sstevel@tonic-gate * Note - separate callback flag because different callbacks have 617*0Sstevel@tonic-gate * overlapping id space. 618*0Sstevel@tonic-gate */ 619*0Sstevel@tonic-gate #define SQ_CALLB_CANCEL_MASK (SQ_CANCEL_TOUT|SQ_CANCEL_BUFCALL) 620*0Sstevel@tonic-gate 621*0Sstevel@tonic-gate #define SQ_CANCEL_TOUT 0x02 /* cancel timeout request */ 622*0Sstevel@tonic-gate #define SQ_CANCEL_BUFCALL 0x04 /* cancel bufcall request */ 623*0Sstevel@tonic-gate 624*0Sstevel@tonic-gate typedef struct callbparams { 625*0Sstevel@tonic-gate syncq_t *cbp_sq; 626*0Sstevel@tonic-gate void (*cbp_func)(void *); 627*0Sstevel@tonic-gate void *cbp_arg; 628*0Sstevel@tonic-gate callbparams_id_t cbp_id; 629*0Sstevel@tonic-gate uint_t cbp_flags; 630*0Sstevel@tonic-gate struct callbparams *cbp_next; 631*0Sstevel@tonic-gate size_t cbp_size; 632*0Sstevel@tonic-gate } callbparams_t; 633*0Sstevel@tonic-gate 634*0Sstevel@tonic-gate typedef struct strbufcall { 635*0Sstevel@tonic-gate void (*bc_func)(void *); 636*0Sstevel@tonic-gate void *bc_arg; 637*0Sstevel@tonic-gate size_t bc_size; 638*0Sstevel@tonic-gate bufcall_id_t bc_id; 639*0Sstevel@tonic-gate struct strbufcall *bc_next; 640*0Sstevel@tonic-gate kthread_id_t bc_executor; 641*0Sstevel@tonic-gate } strbufcall_t; 642*0Sstevel@tonic-gate 643*0Sstevel@tonic-gate /* 644*0Sstevel@tonic-gate * Structure of list of processes to be sent SIGPOLL/SIGURG signal 645*0Sstevel@tonic-gate * on request. The valid S_* events are defined in stropts.h. 646*0Sstevel@tonic-gate */ 647*0Sstevel@tonic-gate typedef struct strsig { 648*0Sstevel@tonic-gate struct pid *ss_pidp; /* pid/pgrp pointer */ 649*0Sstevel@tonic-gate pid_t ss_pid; /* positive pid, negative pgrp */ 650*0Sstevel@tonic-gate int ss_events; /* S_* events */ 651*0Sstevel@tonic-gate struct strsig *ss_next; 652*0Sstevel@tonic-gate } strsig_t; 653*0Sstevel@tonic-gate 654*0Sstevel@tonic-gate /* 655*0Sstevel@tonic-gate * bufcall list 656*0Sstevel@tonic-gate */ 657*0Sstevel@tonic-gate struct bclist { 658*0Sstevel@tonic-gate strbufcall_t *bc_head; 659*0Sstevel@tonic-gate strbufcall_t *bc_tail; 660*0Sstevel@tonic-gate }; 661*0Sstevel@tonic-gate 662*0Sstevel@tonic-gate /* 663*0Sstevel@tonic-gate * Structure used to track mux links and unlinks. 664*0Sstevel@tonic-gate */ 665*0Sstevel@tonic-gate struct mux_node { 666*0Sstevel@tonic-gate major_t mn_imaj; /* internal major device number */ 667*0Sstevel@tonic-gate uint16_t mn_indegree; /* number of incoming edges */ 668*0Sstevel@tonic-gate struct mux_node *mn_originp; /* where we came from during search */ 669*0Sstevel@tonic-gate struct mux_edge *mn_startp; /* where search left off in mn_outp */ 670*0Sstevel@tonic-gate struct mux_edge *mn_outp; /* list of outgoing edges */ 671*0Sstevel@tonic-gate uint_t mn_flags; /* see below */ 672*0Sstevel@tonic-gate }; 673*0Sstevel@tonic-gate 674*0Sstevel@tonic-gate /* 675*0Sstevel@tonic-gate * Flags for mux_nodes. 676*0Sstevel@tonic-gate */ 677*0Sstevel@tonic-gate #define VISITED 1 678*0Sstevel@tonic-gate 679*0Sstevel@tonic-gate /* 680*0Sstevel@tonic-gate * Edge structure - a list of these is hung off the 681*0Sstevel@tonic-gate * mux_node to represent the outgoing edges. 682*0Sstevel@tonic-gate */ 683*0Sstevel@tonic-gate struct mux_edge { 684*0Sstevel@tonic-gate struct mux_node *me_nodep; /* edge leads to this node */ 685*0Sstevel@tonic-gate struct mux_edge *me_nextp; /* next edge */ 686*0Sstevel@tonic-gate int me_muxid; /* id of link */ 687*0Sstevel@tonic-gate }; 688*0Sstevel@tonic-gate 689*0Sstevel@tonic-gate /* 690*0Sstevel@tonic-gate * Queue info 691*0Sstevel@tonic-gate * 692*0Sstevel@tonic-gate * The syncq is included here to reduce memory fragmentation 693*0Sstevel@tonic-gate * for kernel memory allocators that only allocate in sizes that are 694*0Sstevel@tonic-gate * powers of two. If the kernel memory allocator changes this should 695*0Sstevel@tonic-gate * be revisited. 696*0Sstevel@tonic-gate */ 697*0Sstevel@tonic-gate typedef struct queinfo { 698*0Sstevel@tonic-gate struct queue qu_rqueue; /* read queue - must be first */ 699*0Sstevel@tonic-gate struct queue qu_wqueue; /* write queue - must be second */ 700*0Sstevel@tonic-gate struct syncq qu_syncq; /* syncq - must be third */ 701*0Sstevel@tonic-gate } queinfo_t; 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate /* 704*0Sstevel@tonic-gate * Multiplexed streams info 705*0Sstevel@tonic-gate */ 706*0Sstevel@tonic-gate typedef struct linkinfo { 707*0Sstevel@tonic-gate struct linkblk li_lblk; /* must be first */ 708*0Sstevel@tonic-gate struct file *li_fpdown; /* file pointer for lower stream */ 709*0Sstevel@tonic-gate struct linkinfo *li_next; /* next in list */ 710*0Sstevel@tonic-gate struct linkinfo *li_prev; /* previous in list */ 711*0Sstevel@tonic-gate } linkinfo_t; 712*0Sstevel@tonic-gate 713*0Sstevel@tonic-gate /* 714*0Sstevel@tonic-gate * List of syncq's used by freeezestr/unfreezestr 715*0Sstevel@tonic-gate */ 716*0Sstevel@tonic-gate typedef struct syncql { 717*0Sstevel@tonic-gate struct syncql *sql_next; 718*0Sstevel@tonic-gate syncq_t *sql_sq; 719*0Sstevel@tonic-gate } syncql_t; 720*0Sstevel@tonic-gate 721*0Sstevel@tonic-gate typedef struct sqlist { 722*0Sstevel@tonic-gate syncql_t *sqlist_head; 723*0Sstevel@tonic-gate size_t sqlist_size; /* structure size in bytes */ 724*0Sstevel@tonic-gate size_t sqlist_index; /* next free entry in array */ 725*0Sstevel@tonic-gate syncql_t sqlist_array[4]; /* 4 or more entries */ 726*0Sstevel@tonic-gate } sqlist_t; 727*0Sstevel@tonic-gate 728*0Sstevel@tonic-gate typedef struct perdm { 729*0Sstevel@tonic-gate struct perdm *dm_next; 730*0Sstevel@tonic-gate syncq_t *dm_sq; 731*0Sstevel@tonic-gate struct streamtab *dm_str; 732*0Sstevel@tonic-gate uint_t dm_ref; 733*0Sstevel@tonic-gate } perdm_t; 734*0Sstevel@tonic-gate 735*0Sstevel@tonic-gate #define NEED_DM(dmp, qflag) \ 736*0Sstevel@tonic-gate (dmp == NULL && (qflag & (QPERMOD | QMTOUTPERIM))) 737*0Sstevel@tonic-gate 738*0Sstevel@tonic-gate /* 739*0Sstevel@tonic-gate * fmodsw_impl_t is used within the kernel. fmodsw is used by 740*0Sstevel@tonic-gate * the modules/drivers. The information is copied from fmodsw 741*0Sstevel@tonic-gate * defined in the module/driver into the fmodsw_impl_t structure 742*0Sstevel@tonic-gate * during the module/driver initialization. 743*0Sstevel@tonic-gate */ 744*0Sstevel@tonic-gate typedef struct fmodsw_impl fmodsw_impl_t; 745*0Sstevel@tonic-gate 746*0Sstevel@tonic-gate struct fmodsw_impl { 747*0Sstevel@tonic-gate fmodsw_impl_t *f_next; 748*0Sstevel@tonic-gate char f_name[FMNAMESZ + 1]; 749*0Sstevel@tonic-gate struct streamtab *f_str; 750*0Sstevel@tonic-gate uint32_t f_qflag; 751*0Sstevel@tonic-gate uint32_t f_sqtype; 752*0Sstevel@tonic-gate perdm_t *f_dmp; 753*0Sstevel@tonic-gate uint32_t f_ref; 754*0Sstevel@tonic-gate uint32_t f_hits; 755*0Sstevel@tonic-gate }; 756*0Sstevel@tonic-gate 757*0Sstevel@tonic-gate typedef enum { 758*0Sstevel@tonic-gate FMODSW_HOLD = 0x00000001, 759*0Sstevel@tonic-gate FMODSW_LOAD = 0x00000002 760*0Sstevel@tonic-gate } fmodsw_flags_t; 761*0Sstevel@tonic-gate 762*0Sstevel@tonic-gate typedef struct cdevsw_impl { 763*0Sstevel@tonic-gate struct streamtab *d_str; 764*0Sstevel@tonic-gate uint32_t d_qflag; 765*0Sstevel@tonic-gate uint32_t d_sqtype; 766*0Sstevel@tonic-gate perdm_t *d_dmp; 767*0Sstevel@tonic-gate } cdevsw_impl_t; 768*0Sstevel@tonic-gate 769*0Sstevel@tonic-gate /* 770*0Sstevel@tonic-gate * Finding related queues 771*0Sstevel@tonic-gate */ 772*0Sstevel@tonic-gate #define STREAM(q) ((q)->q_stream) 773*0Sstevel@tonic-gate #define SQ(rq) ((syncq_t *)((rq) + 2)) 774*0Sstevel@tonic-gate 775*0Sstevel@tonic-gate /* 776*0Sstevel@tonic-gate * Locking macros 777*0Sstevel@tonic-gate */ 778*0Sstevel@tonic-gate #define QLOCK(q) (&(q)->q_lock) 779*0Sstevel@tonic-gate #define SQLOCK(sq) (&(sq)->sq_lock) 780*0Sstevel@tonic-gate 781*0Sstevel@tonic-gate #define STREAM_PUTLOCKS_ENTER(stp) { \ 782*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(&(stp)->sd_lock)); \ 783*0Sstevel@tonic-gate if ((stp)->sd_ciputctrl != NULL) { \ 784*0Sstevel@tonic-gate int i; \ 785*0Sstevel@tonic-gate int nlocks = (stp)->sd_nciputctrl; \ 786*0Sstevel@tonic-gate ciputctrl_t *cip = (stp)->sd_ciputctrl; \ 787*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 788*0Sstevel@tonic-gate mutex_enter(&cip[i].ciputctrl_lock); \ 789*0Sstevel@tonic-gate } \ 790*0Sstevel@tonic-gate } \ 791*0Sstevel@tonic-gate } 792*0Sstevel@tonic-gate 793*0Sstevel@tonic-gate #define STREAM_PUTLOCKS_EXIT(stp) { \ 794*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(&(stp)->sd_lock)); \ 795*0Sstevel@tonic-gate if ((stp)->sd_ciputctrl != NULL) { \ 796*0Sstevel@tonic-gate int i; \ 797*0Sstevel@tonic-gate int nlocks = (stp)->sd_nciputctrl; \ 798*0Sstevel@tonic-gate ciputctrl_t *cip = (stp)->sd_ciputctrl; \ 799*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 800*0Sstevel@tonic-gate mutex_exit(&cip[i].ciputctrl_lock); \ 801*0Sstevel@tonic-gate } \ 802*0Sstevel@tonic-gate } \ 803*0Sstevel@tonic-gate } 804*0Sstevel@tonic-gate 805*0Sstevel@tonic-gate #define SQ_PUTLOCKS_ENTER(sq) { \ 806*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(SQLOCK(sq))); \ 807*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 808*0Sstevel@tonic-gate int i; \ 809*0Sstevel@tonic-gate int nlocks = (sq)->sq_nciputctrl; \ 810*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 811*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 812*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 813*0Sstevel@tonic-gate mutex_enter(&cip[i].ciputctrl_lock); \ 814*0Sstevel@tonic-gate } \ 815*0Sstevel@tonic-gate } \ 816*0Sstevel@tonic-gate } 817*0Sstevel@tonic-gate 818*0Sstevel@tonic-gate #define SQ_PUTLOCKS_EXIT(sq) { \ 819*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(SQLOCK(sq))); \ 820*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 821*0Sstevel@tonic-gate int i; \ 822*0Sstevel@tonic-gate int nlocks = (sq)->sq_nciputctrl; \ 823*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 824*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 825*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 826*0Sstevel@tonic-gate mutex_exit(&cip[i].ciputctrl_lock); \ 827*0Sstevel@tonic-gate } \ 828*0Sstevel@tonic-gate } \ 829*0Sstevel@tonic-gate } 830*0Sstevel@tonic-gate 831*0Sstevel@tonic-gate #define SQ_PUTCOUNT_SETFAST(sq) { \ 832*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(SQLOCK(sq))); \ 833*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 834*0Sstevel@tonic-gate int i; \ 835*0Sstevel@tonic-gate int nlocks = (sq)->sq_nciputctrl; \ 836*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 837*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 838*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 839*0Sstevel@tonic-gate mutex_enter(&cip[i].ciputctrl_lock); \ 840*0Sstevel@tonic-gate cip[i].ciputctrl_count |= SQ_FASTPUT; \ 841*0Sstevel@tonic-gate mutex_exit(&cip[i].ciputctrl_lock); \ 842*0Sstevel@tonic-gate } \ 843*0Sstevel@tonic-gate } \ 844*0Sstevel@tonic-gate } 845*0Sstevel@tonic-gate 846*0Sstevel@tonic-gate #define SQ_PUTCOUNT_CLRFAST(sq) { \ 847*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(SQLOCK(sq))); \ 848*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 849*0Sstevel@tonic-gate int i; \ 850*0Sstevel@tonic-gate int nlocks = (sq)->sq_nciputctrl; \ 851*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 852*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 853*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 854*0Sstevel@tonic-gate mutex_enter(&cip[i].ciputctrl_lock); \ 855*0Sstevel@tonic-gate cip[i].ciputctrl_count &= ~SQ_FASTPUT; \ 856*0Sstevel@tonic-gate mutex_exit(&cip[i].ciputctrl_lock); \ 857*0Sstevel@tonic-gate } \ 858*0Sstevel@tonic-gate } \ 859*0Sstevel@tonic-gate } 860*0Sstevel@tonic-gate 861*0Sstevel@tonic-gate 862*0Sstevel@tonic-gate #ifdef DEBUG 863*0Sstevel@tonic-gate 864*0Sstevel@tonic-gate #define SQ_PUTLOCKS_HELD(sq) { \ 865*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(SQLOCK(sq))); \ 866*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 867*0Sstevel@tonic-gate int i; \ 868*0Sstevel@tonic-gate int nlocks = (sq)->sq_nciputctrl; \ 869*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 870*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 871*0Sstevel@tonic-gate for (i = 0; i <= nlocks; i++) { \ 872*0Sstevel@tonic-gate ASSERT(MUTEX_HELD(&cip[i].ciputctrl_lock)); \ 873*0Sstevel@tonic-gate } \ 874*0Sstevel@tonic-gate } \ 875*0Sstevel@tonic-gate } 876*0Sstevel@tonic-gate 877*0Sstevel@tonic-gate #define SUMCHECK_SQ_PUTCOUNTS(sq, countcheck) { \ 878*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 879*0Sstevel@tonic-gate int i; \ 880*0Sstevel@tonic-gate uint_t count = 0; \ 881*0Sstevel@tonic-gate int ncounts = (sq)->sq_nciputctrl; \ 882*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 883*0Sstevel@tonic-gate for (i = 0; i <= ncounts; i++) { \ 884*0Sstevel@tonic-gate count += \ 885*0Sstevel@tonic-gate (((sq)->sq_ciputctrl[i].ciputctrl_count) & \ 886*0Sstevel@tonic-gate SQ_FASTMASK); \ 887*0Sstevel@tonic-gate } \ 888*0Sstevel@tonic-gate ASSERT(count == (countcheck)); \ 889*0Sstevel@tonic-gate } \ 890*0Sstevel@tonic-gate } 891*0Sstevel@tonic-gate 892*0Sstevel@tonic-gate #define SUMCHECK_CIPUTCTRL_COUNTS(ciput, nciput, countcheck) { \ 893*0Sstevel@tonic-gate int i; \ 894*0Sstevel@tonic-gate uint_t count = 0; \ 895*0Sstevel@tonic-gate ASSERT((ciput) != NULL); \ 896*0Sstevel@tonic-gate for (i = 0; i <= (nciput); i++) { \ 897*0Sstevel@tonic-gate count += (((ciput)[i].ciputctrl_count) & \ 898*0Sstevel@tonic-gate SQ_FASTMASK); \ 899*0Sstevel@tonic-gate } \ 900*0Sstevel@tonic-gate ASSERT(count == (countcheck)); \ 901*0Sstevel@tonic-gate } 902*0Sstevel@tonic-gate 903*0Sstevel@tonic-gate #else /* DEBUG */ 904*0Sstevel@tonic-gate 905*0Sstevel@tonic-gate #define SQ_PUTLOCKS_HELD(sq) 906*0Sstevel@tonic-gate #define SUMCHECK_SQ_PUTCOUNTS(sq, countcheck) 907*0Sstevel@tonic-gate #define SUMCHECK_CIPUTCTRL_COUNTS(sq, nciput, countcheck) 908*0Sstevel@tonic-gate 909*0Sstevel@tonic-gate #endif /* DEBUG */ 910*0Sstevel@tonic-gate 911*0Sstevel@tonic-gate #define SUM_SQ_PUTCOUNTS(sq, count) { \ 912*0Sstevel@tonic-gate if ((sq)->sq_ciputctrl != NULL) { \ 913*0Sstevel@tonic-gate int i; \ 914*0Sstevel@tonic-gate int ncounts = (sq)->sq_nciputctrl; \ 915*0Sstevel@tonic-gate ciputctrl_t *cip = (sq)->sq_ciputctrl; \ 916*0Sstevel@tonic-gate ASSERT((sq)->sq_type & SQ_CIPUT); \ 917*0Sstevel@tonic-gate for (i = 0; i <= ncounts; i++) { \ 918*0Sstevel@tonic-gate (count) += ((cip[i].ciputctrl_count) & \ 919*0Sstevel@tonic-gate SQ_FASTMASK); \ 920*0Sstevel@tonic-gate } \ 921*0Sstevel@tonic-gate } \ 922*0Sstevel@tonic-gate } 923*0Sstevel@tonic-gate 924*0Sstevel@tonic-gate #define CLAIM_QNEXT_LOCK(stp) mutex_enter(&(stp)->sd_lock) 925*0Sstevel@tonic-gate #define RELEASE_QNEXT_LOCK(stp) mutex_exit(&(stp)->sd_lock) 926*0Sstevel@tonic-gate 927*0Sstevel@tonic-gate /* 928*0Sstevel@tonic-gate * syncq message manipulation macros. 929*0Sstevel@tonic-gate */ 930*0Sstevel@tonic-gate /* 931*0Sstevel@tonic-gate * Put a message on the queue syncq. 932*0Sstevel@tonic-gate * Assumes QLOCK held. 933*0Sstevel@tonic-gate */ 934*0Sstevel@tonic-gate #define SQPUT_MP(qp, mp) \ 935*0Sstevel@tonic-gate { \ 936*0Sstevel@tonic-gate qp->q_syncqmsgs++; \ 937*0Sstevel@tonic-gate if (qp->q_sqhead == NULL) { \ 938*0Sstevel@tonic-gate qp->q_sqhead = qp->q_sqtail = mp; \ 939*0Sstevel@tonic-gate } else { \ 940*0Sstevel@tonic-gate qp->q_sqtail->b_next = mp; \ 941*0Sstevel@tonic-gate qp->q_sqtail = mp; \ 942*0Sstevel@tonic-gate } \ 943*0Sstevel@tonic-gate } 944*0Sstevel@tonic-gate 945*0Sstevel@tonic-gate /* 946*0Sstevel@tonic-gate * Miscellaneous parameters and flags. 947*0Sstevel@tonic-gate */ 948*0Sstevel@tonic-gate 949*0Sstevel@tonic-gate /* 950*0Sstevel@tonic-gate * Default timeout in milliseconds for ioctls and close 951*0Sstevel@tonic-gate */ 952*0Sstevel@tonic-gate #define STRTIMOUT 15000 953*0Sstevel@tonic-gate 954*0Sstevel@tonic-gate /* 955*0Sstevel@tonic-gate * Flag values for stream io 956*0Sstevel@tonic-gate */ 957*0Sstevel@tonic-gate #define WRITEWAIT 0x1 /* waiting for write event */ 958*0Sstevel@tonic-gate #define READWAIT 0x2 /* waiting for read event */ 959*0Sstevel@tonic-gate #define NOINTR 0x4 /* error is not to be set for signal */ 960*0Sstevel@tonic-gate #define GETWAIT 0x8 /* waiting for getmsg event */ 961*0Sstevel@tonic-gate 962*0Sstevel@tonic-gate /* 963*0Sstevel@tonic-gate * These flags need to be unique for stream io name space 964*0Sstevel@tonic-gate * and copy modes name space. These flags allow strwaitq 965*0Sstevel@tonic-gate * and strdoioctl to proceed as if signals or errors on the stream 966*0Sstevel@tonic-gate * head have not occurred; i.e. they will be detected by some other 967*0Sstevel@tonic-gate * means. 968*0Sstevel@tonic-gate * STR_NOSIG does not allow signals to interrupt the call 969*0Sstevel@tonic-gate * STR_NOERROR does not allow stream head read, write or hup errors to 970*0Sstevel@tonic-gate * affect the call. When used with strdoioctl(), if a previous ioctl 971*0Sstevel@tonic-gate * is pending and times out, STR_NOERROR will cause strdoioctl() to not 972*0Sstevel@tonic-gate * return ETIME. If, however, the requested ioctl times out, ETIME 973*0Sstevel@tonic-gate * will be returned (use ic_timout instead) 974*0Sstevel@tonic-gate * STR_PEEK is used to inform strwaitq that the reader is peeking at data 975*0Sstevel@tonic-gate * and that a non-persistent error should not be cleared. 976*0Sstevel@tonic-gate * STR_DELAYERR is used to inform strwaitq that it should not check errors 977*0Sstevel@tonic-gate * after being awoken since, in addition to an error, there might also be 978*0Sstevel@tonic-gate * data queued on the stream head read queue. 979*0Sstevel@tonic-gate */ 980*0Sstevel@tonic-gate #define STR_NOSIG 0x10 /* Ignore signals during strdoioctl/strwaitq */ 981*0Sstevel@tonic-gate #define STR_NOERROR 0x20 /* Ignore errors during strdoioctl/strwaitq */ 982*0Sstevel@tonic-gate #define STR_PEEK 0x40 /* Peeking behavior on non-persistent errors */ 983*0Sstevel@tonic-gate #define STR_DELAYERR 0x80 /* Do not check errors on return */ 984*0Sstevel@tonic-gate 985*0Sstevel@tonic-gate /* 986*0Sstevel@tonic-gate * Copy modes for tty and I_STR ioctls 987*0Sstevel@tonic-gate */ 988*0Sstevel@tonic-gate #define U_TO_K 01 /* User to Kernel */ 989*0Sstevel@tonic-gate #define K_TO_K 02 /* Kernel to Kernel */ 990*0Sstevel@tonic-gate 991*0Sstevel@tonic-gate /* 992*0Sstevel@tonic-gate * Mux defines. 993*0Sstevel@tonic-gate */ 994*0Sstevel@tonic-gate #define LINKNORMAL 0x01 /* normal mux link */ 995*0Sstevel@tonic-gate #define LINKPERSIST 0x02 /* persistent mux link */ 996*0Sstevel@tonic-gate #define LINKTYPEMASK 0x03 /* bitmask of all link types */ 997*0Sstevel@tonic-gate #define LINKCLOSE 0x04 /* unlink from strclose */ 998*0Sstevel@tonic-gate 999*0Sstevel@tonic-gate /* 1000*0Sstevel@tonic-gate * Definitions of Streams macros and function interfaces. 1001*0Sstevel@tonic-gate */ 1002*0Sstevel@tonic-gate 1003*0Sstevel@tonic-gate /* 1004*0Sstevel@tonic-gate * Obsolete queue scheduling macros. They are not used anymore, but still kept 1005*0Sstevel@tonic-gate * here for 3-d party modules and drivers who might still use them. 1006*0Sstevel@tonic-gate */ 1007*0Sstevel@tonic-gate #define setqsched() 1008*0Sstevel@tonic-gate #define qready() 1 1009*0Sstevel@tonic-gate 1010*0Sstevel@tonic-gate #ifdef _KERNEL 1011*0Sstevel@tonic-gate #define runqueues() 1012*0Sstevel@tonic-gate #define queuerun() 1013*0Sstevel@tonic-gate #endif 1014*0Sstevel@tonic-gate 1015*0Sstevel@tonic-gate /* compatibility module for style 2 drivers with DR race condition */ 1016*0Sstevel@tonic-gate #define DRMODNAME "drcompat" 1017*0Sstevel@tonic-gate 1018*0Sstevel@tonic-gate /* 1019*0Sstevel@tonic-gate * Macros dealing with mux_nodes. 1020*0Sstevel@tonic-gate */ 1021*0Sstevel@tonic-gate #define MUX_VISIT(X) ((X)->mn_flags |= VISITED) 1022*0Sstevel@tonic-gate #define MUX_CLEAR(X) ((X)->mn_flags &= (~VISITED)); \ 1023*0Sstevel@tonic-gate ((X)->mn_originp = NULL) 1024*0Sstevel@tonic-gate #define MUX_DIDVISIT(X) ((X)->mn_flags & VISITED) 1025*0Sstevel@tonic-gate 1026*0Sstevel@tonic-gate 1027*0Sstevel@tonic-gate /* 1028*0Sstevel@tonic-gate * Twisted stream macros 1029*0Sstevel@tonic-gate */ 1030*0Sstevel@tonic-gate #define STRMATED(X) ((X)->sd_flag & STRMATE) 1031*0Sstevel@tonic-gate #define STRLOCKMATES(X) if (&((X)->sd_lock) > &(((X)->sd_mate)->sd_lock)) { \ 1032*0Sstevel@tonic-gate mutex_enter(&((X)->sd_lock)); \ 1033*0Sstevel@tonic-gate mutex_enter(&(((X)->sd_mate)->sd_lock)); \ 1034*0Sstevel@tonic-gate } else { \ 1035*0Sstevel@tonic-gate mutex_enter(&(((X)->sd_mate)->sd_lock)); \ 1036*0Sstevel@tonic-gate mutex_enter(&((X)->sd_lock)); \ 1037*0Sstevel@tonic-gate } 1038*0Sstevel@tonic-gate #define STRUNLOCKMATES(X) mutex_exit(&((X)->sd_lock)); \ 1039*0Sstevel@tonic-gate mutex_exit(&(((X)->sd_mate)->sd_lock)) 1040*0Sstevel@tonic-gate 1041*0Sstevel@tonic-gate #ifdef _KERNEL 1042*0Sstevel@tonic-gate 1043*0Sstevel@tonic-gate extern void strinit(void); 1044*0Sstevel@tonic-gate extern int strdoioctl(struct stdata *, struct strioctl *, int, int, 1045*0Sstevel@tonic-gate cred_t *, int *); 1046*0Sstevel@tonic-gate extern void strsendsig(struct strsig *, int, uchar_t, int); 1047*0Sstevel@tonic-gate extern void str_sendsig(vnode_t *, int, uchar_t, int); 1048*0Sstevel@tonic-gate extern void strhup(struct stdata *); 1049*0Sstevel@tonic-gate extern int qattach(queue_t *, dev_t *, int, cred_t *, fmodsw_impl_t *, 1050*0Sstevel@tonic-gate boolean_t); 1051*0Sstevel@tonic-gate extern int qreopen(queue_t *, dev_t *, int, cred_t *); 1052*0Sstevel@tonic-gate extern void qdetach(queue_t *, int, int, cred_t *, boolean_t); 1053*0Sstevel@tonic-gate extern void enterq(queue_t *); 1054*0Sstevel@tonic-gate extern void leaveq(queue_t *); 1055*0Sstevel@tonic-gate extern int putiocd(mblk_t *, caddr_t, int, cred_t *); 1056*0Sstevel@tonic-gate extern int getiocd(mblk_t *, caddr_t, int); 1057*0Sstevel@tonic-gate extern struct linkinfo *alloclink(queue_t *, queue_t *, struct file *); 1058*0Sstevel@tonic-gate extern void lbfree(struct linkinfo *); 1059*0Sstevel@tonic-gate extern int linkcycle(stdata_t *, stdata_t *); 1060*0Sstevel@tonic-gate extern struct linkinfo *findlinks(stdata_t *, int, int); 1061*0Sstevel@tonic-gate extern queue_t *getendq(queue_t *); 1062*0Sstevel@tonic-gate extern int mlink(vnode_t *, int, int, cred_t *, int *, int); 1063*0Sstevel@tonic-gate extern int mlink_file(vnode_t *, int, struct file *, cred_t *, int *, int); 1064*0Sstevel@tonic-gate extern int munlink(struct stdata *, struct linkinfo *, int, cred_t *, int *); 1065*0Sstevel@tonic-gate extern int munlinkall(struct stdata *, int, cred_t *, int *); 1066*0Sstevel@tonic-gate extern void mux_addedge(stdata_t *, stdata_t *, int); 1067*0Sstevel@tonic-gate extern void mux_rmvedge(stdata_t *, int); 1068*0Sstevel@tonic-gate extern int devflg_to_qflag(struct streamtab *, uint32_t, uint32_t *, 1069*0Sstevel@tonic-gate uint32_t *); 1070*0Sstevel@tonic-gate extern void setq(queue_t *, struct qinit *, struct qinit *, perdm_t *, 1071*0Sstevel@tonic-gate uint32_t, uint32_t, boolean_t); 1072*0Sstevel@tonic-gate extern perdm_t *hold_dm(struct streamtab *, uint32_t, uint32_t); 1073*0Sstevel@tonic-gate extern void rele_dm(perdm_t *); 1074*0Sstevel@tonic-gate extern int strmakectl(struct strbuf *, int32_t, int32_t, mblk_t **); 1075*0Sstevel@tonic-gate extern int strmakedata(ssize_t *, struct uio *, stdata_t *, int32_t, mblk_t **); 1076*0Sstevel@tonic-gate extern int strmakemsg(struct strbuf *, ssize_t *, struct uio *, 1077*0Sstevel@tonic-gate struct stdata *, int32_t, mblk_t **); 1078*0Sstevel@tonic-gate extern int strgetmsg(vnode_t *, struct strbuf *, struct strbuf *, uchar_t *, 1079*0Sstevel@tonic-gate int *, int, rval_t *); 1080*0Sstevel@tonic-gate extern int strputmsg(vnode_t *, struct strbuf *, struct strbuf *, uchar_t, 1081*0Sstevel@tonic-gate int flag, int fmode); 1082*0Sstevel@tonic-gate extern int strstartplumb(struct stdata *, int, int); 1083*0Sstevel@tonic-gate extern void strendplumb(struct stdata *); 1084*0Sstevel@tonic-gate extern struct streamtab *fifo_getinfo(void); 1085*0Sstevel@tonic-gate extern int stropen(struct vnode *, dev_t *, int, cred_t *); 1086*0Sstevel@tonic-gate extern int strclose(struct vnode *, int, cred_t *); 1087*0Sstevel@tonic-gate extern int strpoll(register struct stdata *, short, int, short *, 1088*0Sstevel@tonic-gate struct pollhead **); 1089*0Sstevel@tonic-gate extern void strclean(struct vnode *); 1090*0Sstevel@tonic-gate extern void str_cn_clean(); /* XXX hook for consoles signal cleanup */ 1091*0Sstevel@tonic-gate extern int strwrite(struct vnode *, struct uio *, cred_t *); 1092*0Sstevel@tonic-gate extern int strread(struct vnode *, struct uio *, cred_t *); 1093*0Sstevel@tonic-gate extern int strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *); 1094*0Sstevel@tonic-gate extern int strrput(queue_t *, mblk_t *); 1095*0Sstevel@tonic-gate extern int strrput_nondata(queue_t *, mblk_t *); 1096*0Sstevel@tonic-gate extern mblk_t *strrput_proto(vnode_t *, mblk_t *, 1097*0Sstevel@tonic-gate strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *); 1098*0Sstevel@tonic-gate extern mblk_t *strrput_misc(vnode_t *, mblk_t *, 1099*0Sstevel@tonic-gate strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *); 1100*0Sstevel@tonic-gate extern int getiocseqno(void); 1101*0Sstevel@tonic-gate extern int strwaitbuf(size_t, int); 1102*0Sstevel@tonic-gate extern int strwaitq(stdata_t *, int, ssize_t, int, clock_t, int *); 1103*0Sstevel@tonic-gate extern void strctty(struct stdata *); 1104*0Sstevel@tonic-gate extern void stralloctty(sess_t *, struct stdata *); 1105*0Sstevel@tonic-gate extern void strfreectty(struct stdata *); 1106*0Sstevel@tonic-gate extern struct stdata *shalloc(queue_t *); 1107*0Sstevel@tonic-gate extern void shfree(struct stdata *s); 1108*0Sstevel@tonic-gate extern queue_t *allocq(void); 1109*0Sstevel@tonic-gate extern void freeq(queue_t *); 1110*0Sstevel@tonic-gate extern qband_t *allocband(void); 1111*0Sstevel@tonic-gate extern void freeband(qband_t *); 1112*0Sstevel@tonic-gate extern void freebs_enqueue(mblk_t *, dblk_t *); 1113*0Sstevel@tonic-gate extern void setqback(queue_t *, unsigned char); 1114*0Sstevel@tonic-gate extern int strcopyin(void *, void *, size_t, int); 1115*0Sstevel@tonic-gate extern int strcopyout(void *, void *, size_t, int); 1116*0Sstevel@tonic-gate extern void strsignal(struct stdata *, int, int32_t); 1117*0Sstevel@tonic-gate extern clock_t str_cv_wait(kcondvar_t *, kmutex_t *, clock_t, int); 1118*0Sstevel@tonic-gate extern void runbuffcalls(void); 1119*0Sstevel@tonic-gate extern void disable_svc(queue_t *); 1120*0Sstevel@tonic-gate extern void remove_runlist(queue_t *); 1121*0Sstevel@tonic-gate extern void wait_svc(queue_t *); 1122*0Sstevel@tonic-gate extern void backenable(queue_t *, int); 1123*0Sstevel@tonic-gate extern void set_qend(queue_t *); 1124*0Sstevel@tonic-gate extern void set_qnexthot(queue_t *); 1125*0Sstevel@tonic-gate extern int strgeterr(stdata_t *, int32_t, int); 1126*0Sstevel@tonic-gate extern void qenable_locked(queue_t *); 1127*0Sstevel@tonic-gate extern mblk_t *getq_noenab(queue_t *); 1128*0Sstevel@tonic-gate extern void rmvq_noenab(queue_t *, mblk_t *); 1129*0Sstevel@tonic-gate extern void qbackenable(queue_t *, int); 1130*0Sstevel@tonic-gate 1131*0Sstevel@tonic-gate extern void strblock(queue_t *); 1132*0Sstevel@tonic-gate extern void strunblock(queue_t *); 1133*0Sstevel@tonic-gate extern int qclaimed(queue_t *); 1134*0Sstevel@tonic-gate extern int straccess(struct stdata *, enum jcaccess); 1135*0Sstevel@tonic-gate 1136*0Sstevel@tonic-gate extern void entersq(syncq_t *, int); 1137*0Sstevel@tonic-gate extern void leavesq(syncq_t *, int); 1138*0Sstevel@tonic-gate extern void claimq(queue_t *); 1139*0Sstevel@tonic-gate extern void releaseq(queue_t *); 1140*0Sstevel@tonic-gate extern void claimstr(queue_t *); 1141*0Sstevel@tonic-gate extern void releasestr(queue_t *); 1142*0Sstevel@tonic-gate extern void removeq(queue_t *); 1143*0Sstevel@tonic-gate extern void insertq(struct stdata *, queue_t *); 1144*0Sstevel@tonic-gate extern void fill_syncq(syncq_t *, queue_t *, mblk_t *, void (*)()); 1145*0Sstevel@tonic-gate extern void drain_syncq(syncq_t *); 1146*0Sstevel@tonic-gate extern void qfill_syncq(syncq_t *, queue_t *, mblk_t *); 1147*0Sstevel@tonic-gate extern void qdrain_syncq(syncq_t *, queue_t *); 1148*0Sstevel@tonic-gate extern int flush_syncq(syncq_t *, queue_t *); 1149*0Sstevel@tonic-gate extern void wait_sq_svc(syncq_t *); 1150*0Sstevel@tonic-gate 1151*0Sstevel@tonic-gate extern void outer_enter(syncq_t *, uint16_t); 1152*0Sstevel@tonic-gate extern void outer_exit(syncq_t *); 1153*0Sstevel@tonic-gate extern void qwriter_inner(queue_t *, mblk_t *, void (*)()); 1154*0Sstevel@tonic-gate extern void qwriter_outer(queue_t *, mblk_t *, void (*)()); 1155*0Sstevel@tonic-gate 1156*0Sstevel@tonic-gate extern callbparams_t *callbparams_alloc(syncq_t *, void (*)(void *), 1157*0Sstevel@tonic-gate void *, int); 1158*0Sstevel@tonic-gate extern void callbparams_free(syncq_t *, callbparams_t *); 1159*0Sstevel@tonic-gate extern void callbparams_free_id(syncq_t *, callbparams_id_t, int32_t); 1160*0Sstevel@tonic-gate extern void qcallbwrapper(void *); 1161*0Sstevel@tonic-gate 1162*0Sstevel@tonic-gate extern mblk_t *desballoc(unsigned char *, size_t, uint_t, frtn_t *); 1163*0Sstevel@tonic-gate extern mblk_t *esballoca(unsigned char *, size_t, uint_t, frtn_t *); 1164*0Sstevel@tonic-gate extern mblk_t *desballoca(unsigned char *, size_t, uint_t, frtn_t *); 1165*0Sstevel@tonic-gate extern int do_sendfp(struct stdata *, struct file *, struct cred *); 1166*0Sstevel@tonic-gate extern int frozenstr(queue_t *); 1167*0Sstevel@tonic-gate extern size_t xmsgsize(mblk_t *); 1168*0Sstevel@tonic-gate 1169*0Sstevel@tonic-gate extern void putnext_tail(syncq_t *, queue_t *, uint32_t); 1170*0Sstevel@tonic-gate extern void stream_willservice(stdata_t *); 1171*0Sstevel@tonic-gate extern void stream_runservice(stdata_t *); 1172*0Sstevel@tonic-gate 1173*0Sstevel@tonic-gate extern void strmate(vnode_t *, vnode_t *); 1174*0Sstevel@tonic-gate extern queue_t *strvp2wq(vnode_t *); 1175*0Sstevel@tonic-gate extern vnode_t *strq2vp(queue_t *); 1176*0Sstevel@tonic-gate extern mblk_t *allocb_wait(size_t, uint_t, uint_t, int *); 1177*0Sstevel@tonic-gate extern mblk_t *allocb_cred(size_t, cred_t *); 1178*0Sstevel@tonic-gate extern mblk_t *allocb_cred_wait(size_t, uint_t, int *, cred_t *); 1179*0Sstevel@tonic-gate extern mblk_t *allocb_tmpl(size_t, const mblk_t *); 1180*0Sstevel@tonic-gate extern void mblk_setcred(mblk_t *, cred_t *); 1181*0Sstevel@tonic-gate void strpollwakeup(vnode_t *, short); 1182*0Sstevel@tonic-gate extern int putnextctl_wait(queue_t *, int); 1183*0Sstevel@tonic-gate 1184*0Sstevel@tonic-gate int kstrputmsg(struct vnode *, mblk_t *, struct uio *, ssize_t, 1185*0Sstevel@tonic-gate unsigned char, int, int); 1186*0Sstevel@tonic-gate int kstrgetmsg(struct vnode *, mblk_t **, struct uio *, 1187*0Sstevel@tonic-gate unsigned char *, int *, clock_t, rval_t *); 1188*0Sstevel@tonic-gate extern int kstrwritemp(struct vnode *, mblk_t *, ushort_t); 1189*0Sstevel@tonic-gate 1190*0Sstevel@tonic-gate void strsetrerror(vnode_t *, int, int, errfunc_t); 1191*0Sstevel@tonic-gate void strsetwerror(vnode_t *, int, int, errfunc_t); 1192*0Sstevel@tonic-gate void strseteof(vnode_t *, int); 1193*0Sstevel@tonic-gate void strflushrq(vnode_t *, int); 1194*0Sstevel@tonic-gate void strsetrputhooks(vnode_t *, uint_t, msgfunc_t, msgfunc_t); 1195*0Sstevel@tonic-gate void strsetwputhooks(vnode_t *, uint_t, clock_t); 1196*0Sstevel@tonic-gate int strwaitmark(vnode_t *); 1197*0Sstevel@tonic-gate extern void strsignal_nolock(stdata_t *, int, int32_t); 1198*0Sstevel@tonic-gate 1199*0Sstevel@tonic-gate struct multidata_s; 1200*0Sstevel@tonic-gate struct pdesc_s; 1201*0Sstevel@tonic-gate extern int hcksum_assoc(mblk_t *, struct multidata_s *, struct pdesc_s *, 1202*0Sstevel@tonic-gate uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int); 1203*0Sstevel@tonic-gate extern void hcksum_retrieve(mblk_t *, struct multidata_s *, struct pdesc_s *, 1204*0Sstevel@tonic-gate uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *); 1205*0Sstevel@tonic-gate extern unsigned int bcksum(uchar_t *, int, unsigned int); 1206*0Sstevel@tonic-gate extern boolean_t is_vmloaned_mblk(mblk_t *, struct multidata_s *, 1207*0Sstevel@tonic-gate struct pdesc_s *); 1208*0Sstevel@tonic-gate 1209*0Sstevel@tonic-gate extern int fmodsw_register(const char *, struct streamtab *, int); 1210*0Sstevel@tonic-gate extern int fmodsw_unregister(const char *); 1211*0Sstevel@tonic-gate extern fmodsw_impl_t *fmodsw_find(const char *, fmodsw_flags_t); 1212*0Sstevel@tonic-gate extern void fmodsw_rele(fmodsw_impl_t *); 1213*0Sstevel@tonic-gate 1214*0Sstevel@tonic-gate extern void freemsgchain(mblk_t *); 1215*0Sstevel@tonic-gate extern mblk_t *copymsgchain(mblk_t *); 1216*0Sstevel@tonic-gate 1217*0Sstevel@tonic-gate /* 1218*0Sstevel@tonic-gate * shared or externally configured data structures 1219*0Sstevel@tonic-gate */ 1220*0Sstevel@tonic-gate extern ssize_t strmsgsz; /* maximum stream message size */ 1221*0Sstevel@tonic-gate extern ssize_t strctlsz; /* maximum size of ctl message */ 1222*0Sstevel@tonic-gate extern int nstrpush; /* maximum number of pushes allowed */ 1223*0Sstevel@tonic-gate 1224*0Sstevel@tonic-gate /* 1225*0Sstevel@tonic-gate * Bufcalls related variables. 1226*0Sstevel@tonic-gate */ 1227*0Sstevel@tonic-gate extern struct bclist strbcalls; /* List of bufcalls */ 1228*0Sstevel@tonic-gate extern kmutex_t strbcall_lock; /* Protects the list of bufcalls */ 1229*0Sstevel@tonic-gate extern kcondvar_t strbcall_cv; /* Signaling when a bufcall is added */ 1230*0Sstevel@tonic-gate extern kcondvar_t bcall_cv; /* wait of executing bufcall completes */ 1231*0Sstevel@tonic-gate 1232*0Sstevel@tonic-gate extern frtn_t frnop; 1233*0Sstevel@tonic-gate 1234*0Sstevel@tonic-gate extern struct kmem_cache *ciputctrl_cache; 1235*0Sstevel@tonic-gate extern int n_ciputctrl; 1236*0Sstevel@tonic-gate extern int max_n_ciputctrl; 1237*0Sstevel@tonic-gate extern int min_n_ciputctrl; 1238*0Sstevel@tonic-gate 1239*0Sstevel@tonic-gate extern cdevsw_impl_t *devimpl; 1240*0Sstevel@tonic-gate #endif /* _KERNEL */ 1241*0Sstevel@tonic-gate 1242*0Sstevel@tonic-gate /* 1243*0Sstevel@tonic-gate * Note: Use of these macros are restricted to kernel/unix and 1244*0Sstevel@tonic-gate * intended for the STREAMS framework. 1245*0Sstevel@tonic-gate * All modules/drivers should include sys/ddi.h. 1246*0Sstevel@tonic-gate * 1247*0Sstevel@tonic-gate * Finding related queues 1248*0Sstevel@tonic-gate */ 1249*0Sstevel@tonic-gate #define _OTHERQ(q) ((q)->q_flag&QREADR? (q)+1: (q)-1) 1250*0Sstevel@tonic-gate #define _WR(q) ((q)->q_flag&QREADR? (q)+1: (q)) 1251*0Sstevel@tonic-gate #define _RD(q) ((q)->q_flag&QREADR? (q): (q)-1) 1252*0Sstevel@tonic-gate #define _SAMESTR(q) (!((q)->q_flag & QEND)) 1253*0Sstevel@tonic-gate 1254*0Sstevel@tonic-gate /* 1255*0Sstevel@tonic-gate * These are also declared here for modules/drivers that erroneously 1256*0Sstevel@tonic-gate * include strsubr.h after ddi.h or fail to include ddi.h at all. 1257*0Sstevel@tonic-gate */ 1258*0Sstevel@tonic-gate extern struct queue *OTHERQ(queue_t *); /* stream.h */ 1259*0Sstevel@tonic-gate extern struct queue *RD(queue_t *); 1260*0Sstevel@tonic-gate extern struct queue *WR(queue_t *); 1261*0Sstevel@tonic-gate extern int SAMESTR(queue_t *); 1262*0Sstevel@tonic-gate 1263*0Sstevel@tonic-gate #ifdef __cplusplus 1264*0Sstevel@tonic-gate } 1265*0Sstevel@tonic-gate #endif 1266*0Sstevel@tonic-gate 1267*0Sstevel@tonic-gate 1268*0Sstevel@tonic-gate #endif /* _SYS_STRSUBR_H */ 1269