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 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
23
24
25 /*
26 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
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
1059 #define MUX_VISIT(X) ((X)->mn_flags |= VISITED)
1060 #define MUX_CLEAR(X) ((X)->mn_flags &= (~VISITED)); \
1061 ((X)->mn_originp = NULL)
1062 #define MUX_DIDVISIT(X) ((X)->mn_flags & VISITED)
1063
1064
1065 /*
1066 * Twisted stream macros
1067 */
1068 #define STRMATED(X) ((X)->sd_flag & STRMATE)
1069 #define STRLOCKMATES(X) if (&((X)->sd_lock) > &(((X)->sd_mate)->sd_lock)) { \
1070 mutex_enter(&((X)->sd_lock)); \
1071 mutex_enter(&(((X)->sd_mate)->sd_lock)); \
1072 } else { \
1073 mutex_enter(&(((X)->sd_mate)->sd_lock)); \
1074 mutex_enter(&((X)->sd_lock)); \
1075 }
1076 #define STRUNLOCKMATES(X) mutex_exit(&((X)->sd_lock)); \
1077 mutex_exit(&(((X)->sd_mate)->sd_lock))
1078
1079 #ifdef _KERNEL
1080
1081 extern void strinit(void);
1082 extern int strdoioctl(struct stdata *, struct strioctl *, int, int,
1083 cred_t *, int *);
1084 extern void strsendsig(struct strsig *, int, uchar_t, int);
1085 extern void str_sendsig(vnode_t *, int, uchar_t, int);
1086 extern void strhup(struct stdata *);
1087 extern int qattach(queue_t *, dev_t *, int, cred_t *, fmodsw_impl_t *,
1088 boolean_t);
1089 extern int qreopen(queue_t *, dev_t *, int, cred_t *);
1090 extern void qdetach(queue_t *, int, int, cred_t *, boolean_t);
1091 extern void enterq(queue_t *);
1092 extern void leaveq(queue_t *);
1093 extern int putiocd(mblk_t *, caddr_t, int, cred_t *);
1094 extern int getiocd(mblk_t *, caddr_t, int);
1095 extern struct linkinfo *alloclink(queue_t *, queue_t *, struct file *);
1096 extern void lbfree(struct linkinfo *);
1097 extern int linkcycle(stdata_t *, stdata_t *, str_stack_t *);
1098 extern struct linkinfo *findlinks(stdata_t *, int, int, str_stack_t *);
1099 extern queue_t *getendq(queue_t *);
1244 uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
1245 extern void lso_info_set(mblk_t *, uint32_t, uint32_t);
1246 extern void lso_info_cleanup(mblk_t *);
1247 extern unsigned int bcksum(uchar_t *, int, unsigned int);
1248 extern boolean_t is_vmloaned_mblk(mblk_t *, struct multidata_s *,
1249 struct pdesc_s *);
1250
1251 extern int fmodsw_register(const char *, struct streamtab *, int);
1252 extern int fmodsw_unregister(const char *);
1253 extern fmodsw_impl_t *fmodsw_find(const char *, fmodsw_flags_t);
1254 extern void fmodsw_rele(fmodsw_impl_t *);
1255
1256 extern void freemsgchain(mblk_t *);
1257 extern mblk_t *copymsgchain(mblk_t *);
1258
1259 extern mblk_t *mcopyinuio(struct stdata *, uio_t *, ssize_t, ssize_t, int *);
1260
1261 /*
1262 * shared or externally configured data structures
1263 */
1264 extern ssize_t strmsgsz; /* maximum stream message size */
1265 extern ssize_t strctlsz; /* maximum size of ctl message */
1266 extern int nstrpush; /* maximum number of pushes allowed */
1267
1268 /*
1269 * Bufcalls related variables.
1270 */
1271 extern struct bclist strbcalls; /* List of bufcalls */
1272 extern kmutex_t strbcall_lock; /* Protects the list of bufcalls */
1273 extern kcondvar_t strbcall_cv; /* Signaling when a bufcall is added */
1274 extern kcondvar_t bcall_cv; /* wait of executing bufcall completes */
1275
1276 extern frtn_t frnop;
1277
1278 extern struct kmem_cache *ciputctrl_cache;
1279 extern int n_ciputctrl;
1280 extern int max_n_ciputctrl;
1281 extern int min_n_ciputctrl;
1282
1283 extern cdevsw_impl_t *devimpl;
1284
1285 /*
1286 * esballoc queue for throttling
|
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 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
23
24 /*
25 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28 /*
29 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
30 */
31
32 #ifndef _SYS_STRSUBR_H
33 #define _SYS_STRSUBR_H
34
35 /*
36 * WARNING:
37 * Everything in this file is private, belonging to the
38 * STREAMS subsystem. The only guarantee made about the
39 * contents of this file is that if you include it, your
40 * code will not port to the next release.
41 */
42 #include <sys/stream.h>
43 #include <sys/stropts.h>
44 #include <sys/vnode.h>
45 #include <sys/kstat.h>
46 #include <sys/uio.h>
47 #include <sys/proc.h>
48 #include <sys/netstack.h>
49 #include <sys/modhash.h>
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 /*
56 * In general, the STREAMS locks are disjoint; they are only held
57 * locally, and not simultaneously by a thread. However, module
58 * code, including at the stream head, requires some locks to be
59 * acquired in order for its safety.
60 * 1. Stream level claim. This prevents the value of q_next
61 * from changing while module code is executing.
62 * 2. Queue level claim. This prevents the value of q_ptr
63 * from changing while put or service code is executing.
64 * In addition, it provides for queue single-threading
1062 #define MUX_VISIT(X) ((X)->mn_flags |= VISITED)
1063 #define MUX_CLEAR(X) ((X)->mn_flags &= (~VISITED)); \
1064 ((X)->mn_originp = NULL)
1065 #define MUX_DIDVISIT(X) ((X)->mn_flags & VISITED)
1066
1067
1068 /*
1069 * Twisted stream macros
1070 */
1071 #define STRMATED(X) ((X)->sd_flag & STRMATE)
1072 #define STRLOCKMATES(X) if (&((X)->sd_lock) > &(((X)->sd_mate)->sd_lock)) { \
1073 mutex_enter(&((X)->sd_lock)); \
1074 mutex_enter(&(((X)->sd_mate)->sd_lock)); \
1075 } else { \
1076 mutex_enter(&(((X)->sd_mate)->sd_lock)); \
1077 mutex_enter(&((X)->sd_lock)); \
1078 }
1079 #define STRUNLOCKMATES(X) mutex_exit(&((X)->sd_lock)); \
1080 mutex_exit(&(((X)->sd_mate)->sd_lock))
1081
1082 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
1083
1084 extern void strinit(void);
1085 extern int strdoioctl(struct stdata *, struct strioctl *, int, int,
1086 cred_t *, int *);
1087 extern void strsendsig(struct strsig *, int, uchar_t, int);
1088 extern void str_sendsig(vnode_t *, int, uchar_t, int);
1089 extern void strhup(struct stdata *);
1090 extern int qattach(queue_t *, dev_t *, int, cred_t *, fmodsw_impl_t *,
1091 boolean_t);
1092 extern int qreopen(queue_t *, dev_t *, int, cred_t *);
1093 extern void qdetach(queue_t *, int, int, cred_t *, boolean_t);
1094 extern void enterq(queue_t *);
1095 extern void leaveq(queue_t *);
1096 extern int putiocd(mblk_t *, caddr_t, int, cred_t *);
1097 extern int getiocd(mblk_t *, caddr_t, int);
1098 extern struct linkinfo *alloclink(queue_t *, queue_t *, struct file *);
1099 extern void lbfree(struct linkinfo *);
1100 extern int linkcycle(stdata_t *, stdata_t *, str_stack_t *);
1101 extern struct linkinfo *findlinks(stdata_t *, int, int, str_stack_t *);
1102 extern queue_t *getendq(queue_t *);
1247 uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
1248 extern void lso_info_set(mblk_t *, uint32_t, uint32_t);
1249 extern void lso_info_cleanup(mblk_t *);
1250 extern unsigned int bcksum(uchar_t *, int, unsigned int);
1251 extern boolean_t is_vmloaned_mblk(mblk_t *, struct multidata_s *,
1252 struct pdesc_s *);
1253
1254 extern int fmodsw_register(const char *, struct streamtab *, int);
1255 extern int fmodsw_unregister(const char *);
1256 extern fmodsw_impl_t *fmodsw_find(const char *, fmodsw_flags_t);
1257 extern void fmodsw_rele(fmodsw_impl_t *);
1258
1259 extern void freemsgchain(mblk_t *);
1260 extern mblk_t *copymsgchain(mblk_t *);
1261
1262 extern mblk_t *mcopyinuio(struct stdata *, uio_t *, ssize_t, ssize_t, int *);
1263
1264 /*
1265 * shared or externally configured data structures
1266 */
1267 extern volatile ssize_t strmsgsz; /* maximum stream message size */
1268 extern volatile ssize_t strctlsz; /* maximum size of ctl message */
1269 extern volatile int nstrpush; /* maximum number of pushes allowed */
1270
1271 /*
1272 * Bufcalls related variables.
1273 */
1274 extern struct bclist strbcalls; /* List of bufcalls */
1275 extern kmutex_t strbcall_lock; /* Protects the list of bufcalls */
1276 extern kcondvar_t strbcall_cv; /* Signaling when a bufcall is added */
1277 extern kcondvar_t bcall_cv; /* wait of executing bufcall completes */
1278
1279 extern frtn_t frnop;
1280
1281 extern struct kmem_cache *ciputctrl_cache;
1282 extern int n_ciputctrl;
1283 extern int max_n_ciputctrl;
1284 extern int min_n_ciputctrl;
1285
1286 extern cdevsw_impl_t *devimpl;
1287
1288 /*
1289 * esballoc queue for throttling
|