4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29
30 #ifndef _SYS_STREAM_H
31 #define _SYS_STREAM_H
32
33 /*
34 * For source compatibility
35 */
36 #include <sys/isa_defs.h>
37 #ifdef _KERNEL
38 #include <sys/kmem.h>
39 #include <sys/uio.h>
40 #endif
41 #include <sys/poll.h>
42 #include <sys/strmdep.h>
43 #include <sys/cred.h>
44 #include <sys/t_lock.h>
45 #include <sys/model.h>
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /*
52 * Data queue.
53 *
54 * NOTE: The *only* public fields are documented in queue(9S).
55 * Everything else is implementation-private.
56 *
57 * The locking rules for the queue_t structure are extremely subtle and vary
172 #define QPERQ 0x00001000 /* per queue-instance syncq */
173 #define QPERMOD 0x00002000 /* per module syncq */
174 #define QMTSAFE 0x00004000 /* stream module is MT-safe */
175 #define QMTOUTPERIM 0x00008000 /* Has outer perimeter */
176 #define QMT_TYPEMASK (QPAIR|QPERQ|QPERMOD|QMTSAFE|QMTOUTPERIM)
177 /* all MT type flags */
178 #define QINSERVICE 0x00010000 /* service routine executing */
179 #define QWCLOSE 0x00020000 /* will not be enabled */
180 #define QEND 0x00040000 /* last queue in stream */
181 #define QWANTWSYNC 0x00080000 /* Streamhead wants to write Q */
182 #define QSYNCSTR 0x00100000 /* Q supports Synchronous STREAMS */
183 #define QISDRV 0x00200000 /* the Queue is attached to a driver */
184 /* UNUSED 0x00400000 was QHOT */
185 /* UNUSED 0x00800000 was QNEXTHOT */
186 /* UNUSED 0x01000000 was _QNEXTLESS */
187 #define _QINSERTING 0x04000000 /* Private, module is being inserted */
188 #define _QREMOVING 0x08000000 /* Private, module is being removed */
189 #define _QASSOCIATED 0x10000000 /* queue is associated with a device */
190 #define _QDIRECT 0x20000000 /* Private; transport module uses */
191 /* direct interface to/from sockfs */
192
193 /* queue sqflags (protected by SQLOCK). */
194 #define Q_SQQUEUED 0x01 /* Queue is in the syncq list */
195 #define Q_SQDRAINING 0x02 /* Servicing syncq msgs. */
196 /* This is also noted by the */
197 /* q_draining field, but this one is */
198 /* protected by SQLOCK */
199
200 /*
201 * Structure that describes the separate information
202 * for each priority band in the queue.
203 */
204 typedef struct qband {
205 struct qband *qb_next; /* next band's info */
206 size_t qb_count; /* number of bytes in band */
207 struct msgb *qb_first; /* beginning of band's data */
208 struct msgb *qb_last; /* end of band's data */
209 size_t qb_hiwat; /* high water mark for band */
210 size_t qb_lowat; /* low water mark for band */
211 uint_t qb_flag; /* see below */
607 #define SO_MAXPSZ 0x0008 /* set max packet size */
608 #define SO_HIWAT 0x0010 /* set high water mark */
609 #define SO_LOWAT 0x0020 /* set low water mark */
610 #define SO_MREADON 0x0040 /* set read notification ON */
611 #define SO_MREADOFF 0x0080 /* set read notification OFF */
612 #define SO_NDELON 0x0100 /* old TTY semantics for NDELAY reads/writes */
613 #define SO_NDELOFF 0x0200 /* STREAMS semantics for NDELAY reads/writes */
614 #define SO_ISTTY 0x0400 /* the stream is acting as a terminal */
615 #define SO_ISNTTY 0x0800 /* the stream is not acting as a terminal */
616 #define SO_TOSTOP 0x1000 /* stop on background writes to this stream */
617 #define SO_TONSTOP 0x2000 /* do not stop on background writes to stream */
618 #define SO_BAND 0x4000 /* water marks affect band */
619 #define SO_DELIM 0x8000 /* messages are delimited */
620 #define SO_NODELIM 0x010000 /* turn off delimiters */
621 #define SO_STRHOLD 0x020000 /* No longer implemented */
622 #define SO_ERROPT 0x040000 /* set error option */
623 #define SO_COPYOPT 0x080000 /* copy option(s) present */
624 #define SO_MAXBLK 0x100000 /* set maximum message block size */
625 #define SO_TAIL 0x200000 /* set the extra allocated space */
626
627 #ifdef _KERNEL
628 /*
629 * Structure for rw (read/write) procedure calls. A pointer
630 * to a struiod_t is passed as a parameter to the rwnext() call.
631 *
632 * Note: DEF_IOV_MAX is defined and used as it is in "fs/vncalls.c"
633 * as there isn't a formal definition of IOV_MAX ???
634 */
635 #define DEF_IOV_MAX 16
636
637 typedef struct struiod {
638 mblk_t *d_mp; /* pointer to mblk (chain) */
639 uio_t d_uio; /* uio info */
640 iovec_t d_iov[DEF_IOV_MAX]; /* iov referenced by uio */
641 } struiod_t;
642
643 /*
644 * Structure for information procedure calls.
645 */
646 typedef struct infod {
647 unsigned char d_cmd; /* info info request command */
735 (type) == M_MULTIDATA || \
736 (type) == M_PROTO || \
737 (type) == M_PCPROTO || \
738 (type) == M_DELAY)
739
740 /*
741 * Extract queue class of message block.
742 */
743 #define queclass(bp) (((bp)->b_datap->db_type >= QPCTL) ? QPCTL : QNORM)
744
745 /*
746 * Align address on next lower word boundary.
747 */
748 #define straln(a) (caddr_t)((intptr_t)(a) & -(sizeof (int)-1))
749
750 /*
751 * Find the max size of data block.
752 */
753 #define bpsize(bp) ((unsigned int)(bp->b_datap->db_lim - bp->b_datap->db_base))
754
755 #ifdef _KERNEL
756
757 /*
758 * For two-byte M_ERROR messages: indication that a side does not have an error
759 */
760 #define NOERROR ((unsigned char)-1)
761
762 /*
763 * declarations of common routines
764 */
765
766 extern mblk_t *allocb(size_t, uint_t);
767 extern mblk_t *desballoc(unsigned char *, size_t, uint_t, frtn_t *);
768 extern mblk_t *esballoc(unsigned char *, size_t, uint_t, frtn_t *);
769 extern bcache_t *bcache_create(char *, size_t, uint_t);
770 extern void bcache_destroy(bcache_t *);
771 extern mblk_t *bcache_allocb(bcache_t *, uint_t);
772 extern mblk_t *mkiocb(uint_t);
773 extern int testb(size_t, uint_t);
774 extern bufcall_id_t bufcall(size_t, uint_t, void (*)(void *), void *);
775 extern bufcall_id_t esbbcall(uint_t, void (*)(void *), void *);
822 extern void qwait(queue_t *);
823 extern int qwait_sig(queue_t *);
824 extern boolean_t qwait_rw(queue_t *);
825 extern void qwriter(queue_t *, mblk_t *, void (*func)(), int);
826 extern timeout_id_t qtimeout(queue_t *, void (*func)(void *), void *, clock_t);
827 extern bufcall_id_t qbufcall(queue_t *, size_t, uint_t,
828 void (*)(void *), void *);
829 extern clock_t quntimeout(queue_t *, timeout_id_t);
830 extern void qunbufcall(queue_t *, bufcall_id_t);
831 extern void strwakeq(queue_t *, int);
832 extern int struioget(queue_t *, mblk_t *, struiod_t *, int);
833 extern int rwnext(queue_t *, struiod_t *);
834 extern int infonext(queue_t *, infod_t *);
835 extern int isuioq(queue_t *);
836 extern void create_putlocks(queue_t *, int);
837 extern int mp_cont_len(mblk_t *, int *);
838
839 /*
840 * shared or externally configured data structures
841 */
842 extern int nstrpush; /* maximum number of pushes allowed */
843
844 #endif /* _KERNEL */
845
846 #ifdef __cplusplus
847 }
848 #endif
849
850 #endif /* _SYS_STREAM_H */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
25 */
26 /*
27 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
28 */
29
30 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
31 /* All Rights Reserved */
32
33
34 #ifndef _SYS_STREAM_H
35 #define _SYS_STREAM_H
36
37 /*
38 * For source compatibility
39 */
40 #include <sys/isa_defs.h>
41 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
42 #include <sys/kmem.h>
43 #include <sys/uio.h>
44 #endif
45 #include <sys/poll.h>
46 #include <sys/strmdep.h>
47 #include <sys/cred.h>
48 #include <sys/t_lock.h>
49 #include <sys/model.h>
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 /*
56 * Data queue.
57 *
58 * NOTE: The *only* public fields are documented in queue(9S).
59 * Everything else is implementation-private.
60 *
61 * The locking rules for the queue_t structure are extremely subtle and vary
176 #define QPERQ 0x00001000 /* per queue-instance syncq */
177 #define QPERMOD 0x00002000 /* per module syncq */
178 #define QMTSAFE 0x00004000 /* stream module is MT-safe */
179 #define QMTOUTPERIM 0x00008000 /* Has outer perimeter */
180 #define QMT_TYPEMASK (QPAIR|QPERQ|QPERMOD|QMTSAFE|QMTOUTPERIM)
181 /* all MT type flags */
182 #define QINSERVICE 0x00010000 /* service routine executing */
183 #define QWCLOSE 0x00020000 /* will not be enabled */
184 #define QEND 0x00040000 /* last queue in stream */
185 #define QWANTWSYNC 0x00080000 /* Streamhead wants to write Q */
186 #define QSYNCSTR 0x00100000 /* Q supports Synchronous STREAMS */
187 #define QISDRV 0x00200000 /* the Queue is attached to a driver */
188 /* UNUSED 0x00400000 was QHOT */
189 /* UNUSED 0x00800000 was QNEXTHOT */
190 /* UNUSED 0x01000000 was _QNEXTLESS */
191 #define _QINSERTING 0x04000000 /* Private, module is being inserted */
192 #define _QREMOVING 0x08000000 /* Private, module is being removed */
193 #define _QASSOCIATED 0x10000000 /* queue is associated with a device */
194 #define _QDIRECT 0x20000000 /* Private; transport module uses */
195 /* direct interface to/from sockfs */
196 #define _QSINGLE_INSTANCE 0x40000000 /* Private; module may only */
197 /* be pushed once */
198
199 /* queue sqflags (protected by SQLOCK). */
200 #define Q_SQQUEUED 0x01 /* Queue is in the syncq list */
201 #define Q_SQDRAINING 0x02 /* Servicing syncq msgs. */
202 /* This is also noted by the */
203 /* q_draining field, but this one is */
204 /* protected by SQLOCK */
205
206 /*
207 * Structure that describes the separate information
208 * for each priority band in the queue.
209 */
210 typedef struct qband {
211 struct qband *qb_next; /* next band's info */
212 size_t qb_count; /* number of bytes in band */
213 struct msgb *qb_first; /* beginning of band's data */
214 struct msgb *qb_last; /* end of band's data */
215 size_t qb_hiwat; /* high water mark for band */
216 size_t qb_lowat; /* low water mark for band */
217 uint_t qb_flag; /* see below */
613 #define SO_MAXPSZ 0x0008 /* set max packet size */
614 #define SO_HIWAT 0x0010 /* set high water mark */
615 #define SO_LOWAT 0x0020 /* set low water mark */
616 #define SO_MREADON 0x0040 /* set read notification ON */
617 #define SO_MREADOFF 0x0080 /* set read notification OFF */
618 #define SO_NDELON 0x0100 /* old TTY semantics for NDELAY reads/writes */
619 #define SO_NDELOFF 0x0200 /* STREAMS semantics for NDELAY reads/writes */
620 #define SO_ISTTY 0x0400 /* the stream is acting as a terminal */
621 #define SO_ISNTTY 0x0800 /* the stream is not acting as a terminal */
622 #define SO_TOSTOP 0x1000 /* stop on background writes to this stream */
623 #define SO_TONSTOP 0x2000 /* do not stop on background writes to stream */
624 #define SO_BAND 0x4000 /* water marks affect band */
625 #define SO_DELIM 0x8000 /* messages are delimited */
626 #define SO_NODELIM 0x010000 /* turn off delimiters */
627 #define SO_STRHOLD 0x020000 /* No longer implemented */
628 #define SO_ERROPT 0x040000 /* set error option */
629 #define SO_COPYOPT 0x080000 /* copy option(s) present */
630 #define SO_MAXBLK 0x100000 /* set maximum message block size */
631 #define SO_TAIL 0x200000 /* set the extra allocated space */
632
633 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
634 /*
635 * Structure for rw (read/write) procedure calls. A pointer
636 * to a struiod_t is passed as a parameter to the rwnext() call.
637 *
638 * Note: DEF_IOV_MAX is defined and used as it is in "fs/vncalls.c"
639 * as there isn't a formal definition of IOV_MAX ???
640 */
641 #define DEF_IOV_MAX 16
642
643 typedef struct struiod {
644 mblk_t *d_mp; /* pointer to mblk (chain) */
645 uio_t d_uio; /* uio info */
646 iovec_t d_iov[DEF_IOV_MAX]; /* iov referenced by uio */
647 } struiod_t;
648
649 /*
650 * Structure for information procedure calls.
651 */
652 typedef struct infod {
653 unsigned char d_cmd; /* info info request command */
741 (type) == M_MULTIDATA || \
742 (type) == M_PROTO || \
743 (type) == M_PCPROTO || \
744 (type) == M_DELAY)
745
746 /*
747 * Extract queue class of message block.
748 */
749 #define queclass(bp) (((bp)->b_datap->db_type >= QPCTL) ? QPCTL : QNORM)
750
751 /*
752 * Align address on next lower word boundary.
753 */
754 #define straln(a) (caddr_t)((intptr_t)(a) & -(sizeof (int)-1))
755
756 /*
757 * Find the max size of data block.
758 */
759 #define bpsize(bp) ((unsigned int)(bp->b_datap->db_lim - bp->b_datap->db_base))
760
761 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
762
763 /*
764 * For two-byte M_ERROR messages: indication that a side does not have an error
765 */
766 #define NOERROR ((unsigned char)-1)
767
768 /*
769 * declarations of common routines
770 */
771
772 extern mblk_t *allocb(size_t, uint_t);
773 extern mblk_t *desballoc(unsigned char *, size_t, uint_t, frtn_t *);
774 extern mblk_t *esballoc(unsigned char *, size_t, uint_t, frtn_t *);
775 extern bcache_t *bcache_create(char *, size_t, uint_t);
776 extern void bcache_destroy(bcache_t *);
777 extern mblk_t *bcache_allocb(bcache_t *, uint_t);
778 extern mblk_t *mkiocb(uint_t);
779 extern int testb(size_t, uint_t);
780 extern bufcall_id_t bufcall(size_t, uint_t, void (*)(void *), void *);
781 extern bufcall_id_t esbbcall(uint_t, void (*)(void *), void *);
828 extern void qwait(queue_t *);
829 extern int qwait_sig(queue_t *);
830 extern boolean_t qwait_rw(queue_t *);
831 extern void qwriter(queue_t *, mblk_t *, void (*func)(), int);
832 extern timeout_id_t qtimeout(queue_t *, void (*func)(void *), void *, clock_t);
833 extern bufcall_id_t qbufcall(queue_t *, size_t, uint_t,
834 void (*)(void *), void *);
835 extern clock_t quntimeout(queue_t *, timeout_id_t);
836 extern void qunbufcall(queue_t *, bufcall_id_t);
837 extern void strwakeq(queue_t *, int);
838 extern int struioget(queue_t *, mblk_t *, struiod_t *, int);
839 extern int rwnext(queue_t *, struiod_t *);
840 extern int infonext(queue_t *, infod_t *);
841 extern int isuioq(queue_t *);
842 extern void create_putlocks(queue_t *, int);
843 extern int mp_cont_len(mblk_t *, int *);
844
845 /*
846 * shared or externally configured data structures
847 */
848 extern volatile int nstrpush; /* maximum number of pushes allowed */
849
850 #endif /* _KERNEL */
851
852 #ifdef __cplusplus
853 }
854 #endif
855
856 #endif /* _SYS_STREAM_H */
|