27 * Use is subject to license terms.
28 */
29
30 #ifndef _SYS_STRSUBR_H
31 #define _SYS_STRSUBR_H
32
33 /*
34 * WARNING:
35 * Everything in this file is private, belonging to the
36 * STREAMS subsystem. The only guarantee made about the
37 * contents of this file is that if you include it, your
38 * code will not port to the next release.
39 */
40 #include <sys/stream.h>
41 #include <sys/stropts.h>
42 #include <sys/kstat.h>
43 #include <sys/uio.h>
44 #include <sys/proc.h>
45 #include <sys/netstack.h>
46 #include <sys/modhash.h>
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 /*
53 * In general, the STREAMS locks are disjoint; they are only held
54 * locally, and not simultaneously by a thread. However, module
55 * code, including at the stream head, requires some locks to be
56 * acquired in order for its safety.
57 * 1. Stream level claim. This prevents the value of q_next
58 * from changing while module code is executing.
59 * 2. Queue level claim. This prevents the value of q_ptr
60 * from changing while put or service code is executing.
61 * In addition, it provides for queue single-threading
62 * for QPAIR and PERQ MT-safe modules.
63 * 3. Stream head lock. May be held by the stream head module
64 * to implement a read/write/open/close monitor.
65 * Note: that the only types of twisted stream supported are
66 * the pipe and transports which have read and write service
224 * support for low contention concurrent putnext.
225 */
226 ciputctrl_t *sd_ciputctrl;
227 uint_t sd_nciputctrl;
228
229 int sd_anchor; /* position of anchor in stream */
230 /*
231 * Service scheduling at the stream head.
232 */
233 kmutex_t sd_qlock;
234 struct queue *sd_qhead; /* Head of queues to be serviced. */
235 struct queue *sd_qtail; /* Tail of queues to be serviced. */
236 void *sd_servid; /* Service ID for bckgrnd schedule */
237 ushort_t sd_svcflags; /* Servicing flags */
238 short sd_nqueues; /* Number of queues in the list */
239 kcondvar_t sd_qcv; /* Waiters for qhead to become empty */
240 kcondvar_t sd_zcopy_wait;
241 uint_t sd_copyflag; /* copy-related flags */
242 zoneid_t sd_anchorzone; /* Allow removal from same zone only */
243 struct msgb *sd_cmdblk; /* reply from _I_CMD */
244 } stdata_t;
245
246 /*
247 * stdata servicing flags.
248 */
249 #define STRS_WILLSERVICE 0x01
250 #define STRS_SCHEDULED 0x02
251
252 #define STREAM_NEEDSERVICE(stp) ((stp)->sd_qhead != NULL)
253
254 /*
255 * stdata flag field defines
256 */
257 #define IOCWAIT 0x00000001 /* Someone is doing an ioctl */
258 #define RSLEEP 0x00000002 /* Someone wants to read/recv msg */
259 #define WSLEEP 0x00000004 /* Someone wants to write */
260 #define STRPRI 0x00000008 /* An M_PCPROTO is at stream head */
261 #define STRHUP 0x00000010 /* Device has vanished */
262 #define STWOPEN 0x00000020 /* waiting for 1st open */
263 #define STPLEX 0x00000040 /* stream is being multiplexed */
1123 extern int stropen(struct vnode *, dev_t *, int, cred_t *);
1124 extern int strclose(struct vnode *, int, cred_t *);
1125 extern int strpoll(register struct stdata *, short, int, short *,
1126 struct pollhead **);
1127 extern void strclean(struct vnode *);
1128 extern void str_cn_clean(); /* XXX hook for consoles signal cleanup */
1129 extern int strwrite(struct vnode *, struct uio *, cred_t *);
1130 extern int strwrite_common(struct vnode *, struct uio *, cred_t *, int);
1131 extern int strread(struct vnode *, struct uio *, cred_t *);
1132 extern int strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *);
1133 extern int strrput(queue_t *, mblk_t *);
1134 extern int strrput_nondata(queue_t *, mblk_t *);
1135 extern mblk_t *strrput_proto(vnode_t *, mblk_t *,
1136 strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *);
1137 extern mblk_t *strrput_misc(vnode_t *, mblk_t *,
1138 strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *);
1139 extern int getiocseqno(void);
1140 extern int strwaitbuf(size_t, int);
1141 extern int strwaitq(stdata_t *, int, ssize_t, int, clock_t, int *);
1142 extern struct stdata *shalloc(queue_t *);
1143 extern void shfree(struct stdata *s);
1144 extern queue_t *allocq(void);
1145 extern void freeq(queue_t *);
1146 extern qband_t *allocband(void);
1147 extern void freeband(qband_t *);
1148 extern void freebs_enqueue(mblk_t *, dblk_t *);
1149 extern void setqback(queue_t *, unsigned char);
1150 extern int strcopyin(void *, void *, size_t, int);
1151 extern int strcopyout(void *, void *, size_t, int);
1152 extern void strsignal(struct stdata *, int, int32_t);
1153 extern clock_t str_cv_wait(kcondvar_t *, kmutex_t *, clock_t, int);
1154 extern void disable_svc(queue_t *);
1155 extern void enable_svc(queue_t *);
1156 extern void remove_runlist(queue_t *);
1157 extern void wait_svc(queue_t *);
1158 extern void backenable(queue_t *, uchar_t);
1159 extern void set_qend(queue_t *);
1160 extern int strgeterr(stdata_t *, int32_t, int);
1161 extern void qenable_locked(queue_t *);
1162 extern mblk_t *getq_noenab(queue_t *, ssize_t);
|
27 * Use is subject to license terms.
28 */
29
30 #ifndef _SYS_STRSUBR_H
31 #define _SYS_STRSUBR_H
32
33 /*
34 * WARNING:
35 * Everything in this file is private, belonging to the
36 * STREAMS subsystem. The only guarantee made about the
37 * contents of this file is that if you include it, your
38 * code will not port to the next release.
39 */
40 #include <sys/stream.h>
41 #include <sys/stropts.h>
42 #include <sys/kstat.h>
43 #include <sys/uio.h>
44 #include <sys/proc.h>
45 #include <sys/netstack.h>
46 #include <sys/modhash.h>
47 #include <sys/pidnode.h>
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 /*
54 * In general, the STREAMS locks are disjoint; they are only held
55 * locally, and not simultaneously by a thread. However, module
56 * code, including at the stream head, requires some locks to be
57 * acquired in order for its safety.
58 * 1. Stream level claim. This prevents the value of q_next
59 * from changing while module code is executing.
60 * 2. Queue level claim. This prevents the value of q_ptr
61 * from changing while put or service code is executing.
62 * In addition, it provides for queue single-threading
63 * for QPAIR and PERQ MT-safe modules.
64 * 3. Stream head lock. May be held by the stream head module
65 * to implement a read/write/open/close monitor.
66 * Note: that the only types of twisted stream supported are
67 * the pipe and transports which have read and write service
225 * support for low contention concurrent putnext.
226 */
227 ciputctrl_t *sd_ciputctrl;
228 uint_t sd_nciputctrl;
229
230 int sd_anchor; /* position of anchor in stream */
231 /*
232 * Service scheduling at the stream head.
233 */
234 kmutex_t sd_qlock;
235 struct queue *sd_qhead; /* Head of queues to be serviced. */
236 struct queue *sd_qtail; /* Tail of queues to be serviced. */
237 void *sd_servid; /* Service ID for bckgrnd schedule */
238 ushort_t sd_svcflags; /* Servicing flags */
239 short sd_nqueues; /* Number of queues in the list */
240 kcondvar_t sd_qcv; /* Waiters for qhead to become empty */
241 kcondvar_t sd_zcopy_wait;
242 uint_t sd_copyflag; /* copy-related flags */
243 zoneid_t sd_anchorzone; /* Allow removal from same zone only */
244 struct msgb *sd_cmdblk; /* reply from _I_CMD */
245 /*
246 * pids associated with this stream head.
247 */
248 avl_tree_t sd_pid_tree;
249 kmutex_t sd_pid_tree_lock;
250 } stdata_t;
251
252 /*
253 * stdata servicing flags.
254 */
255 #define STRS_WILLSERVICE 0x01
256 #define STRS_SCHEDULED 0x02
257
258 #define STREAM_NEEDSERVICE(stp) ((stp)->sd_qhead != NULL)
259
260 /*
261 * stdata flag field defines
262 */
263 #define IOCWAIT 0x00000001 /* Someone is doing an ioctl */
264 #define RSLEEP 0x00000002 /* Someone wants to read/recv msg */
265 #define WSLEEP 0x00000004 /* Someone wants to write */
266 #define STRPRI 0x00000008 /* An M_PCPROTO is at stream head */
267 #define STRHUP 0x00000010 /* Device has vanished */
268 #define STWOPEN 0x00000020 /* waiting for 1st open */
269 #define STPLEX 0x00000040 /* stream is being multiplexed */
1129 extern int stropen(struct vnode *, dev_t *, int, cred_t *);
1130 extern int strclose(struct vnode *, int, cred_t *);
1131 extern int strpoll(register struct stdata *, short, int, short *,
1132 struct pollhead **);
1133 extern void strclean(struct vnode *);
1134 extern void str_cn_clean(); /* XXX hook for consoles signal cleanup */
1135 extern int strwrite(struct vnode *, struct uio *, cred_t *);
1136 extern int strwrite_common(struct vnode *, struct uio *, cred_t *, int);
1137 extern int strread(struct vnode *, struct uio *, cred_t *);
1138 extern int strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *);
1139 extern int strrput(queue_t *, mblk_t *);
1140 extern int strrput_nondata(queue_t *, mblk_t *);
1141 extern mblk_t *strrput_proto(vnode_t *, mblk_t *,
1142 strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *);
1143 extern mblk_t *strrput_misc(vnode_t *, mblk_t *,
1144 strwakeup_t *, strsigset_t *, strsigset_t *, strpollset_t *);
1145 extern int getiocseqno(void);
1146 extern int strwaitbuf(size_t, int);
1147 extern int strwaitq(stdata_t *, int, ssize_t, int, clock_t, int *);
1148 extern struct stdata *shalloc(queue_t *);
1149 extern void sh_insert_pid(struct stdata *, pid_t);
1150 extern void sh_remove_pid(struct stdata *, pid_t);
1151 extern mblk_t *sh_get_pid_mblk(struct stdata *);
1152 extern void shfree(struct stdata *s);
1153 extern queue_t *allocq(void);
1154 extern void freeq(queue_t *);
1155 extern qband_t *allocband(void);
1156 extern void freeband(qband_t *);
1157 extern void freebs_enqueue(mblk_t *, dblk_t *);
1158 extern void setqback(queue_t *, unsigned char);
1159 extern int strcopyin(void *, void *, size_t, int);
1160 extern int strcopyout(void *, void *, size_t, int);
1161 extern void strsignal(struct stdata *, int, int32_t);
1162 extern clock_t str_cv_wait(kcondvar_t *, kmutex_t *, clock_t, int);
1163 extern void disable_svc(queue_t *);
1164 extern void enable_svc(queue_t *);
1165 extern void remove_runlist(queue_t *);
1166 extern void wait_svc(queue_t *);
1167 extern void backenable(queue_t *, uchar_t);
1168 extern void set_qend(queue_t *);
1169 extern int strgeterr(stdata_t *, int32_t, int);
1170 extern void qenable_locked(queue_t *);
1171 extern mblk_t *getq_noenab(queue_t *, ssize_t);
|