xref: /titanic_51/usr/src/uts/common/sys/squeue.h (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
1 /*
2  * CDDL HEADER START
3  *
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SQUEUE_H
27 #define	_SYS_SQUEUE_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <sys/processor.h>
35 #include <sys/stream.h>
36 
37 struct squeue_s;
38 typedef struct squeue_s squeue_t;
39 
40 #define	SET_SQUEUE(mp, proc, arg) {				\
41 	ASSERT((mp)->b_prev == NULL);				\
42 	ASSERT((mp)->b_next == NULL);				\
43 	(mp)->b_queue = (queue_t *)(proc);			\
44 	(mp)->b_prev = (mblk_t *)(arg);				\
45 }
46 
47 #define	GET_SQUEUE(mp)	((conn_t *)((mp)->b_prev))->conn_sqp
48 
49 #define	SQ_FILL		0x0001
50 #define	SQ_NODRAIN	0x0002
51 #define	SQ_PROCESS	0x0004
52 
53 #define	SQUEUE_ENTER(sqp, head, tail, cnt, flag, tag) {	\
54 	sqp->sq_enter(sqp, head, tail, cnt, flag, tag);	\
55 }
56 
57 #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, flag, tag) {	\
58 	ASSERT(mp->b_next == NULL);				\
59 	ASSERT(mp->b_prev == NULL);				\
60 	SET_SQUEUE(mp, proc, arg);				\
61 	SQUEUE_ENTER(sqp, mp, mp, 1, flag, tag);		\
62 }
63 
64 /*
65  * May be called only by a thread executing in the squeue. The thread must
66  * not continue to execute any code needing squeue protection after calling
67  * this macro. Please see the comments in squeue.c for more details.
68  */
69 #define	SQUEUE_SWITCH(connp, new_sqp)				\
70 	(connp)->conn_sqp = new_sqp;
71 
72 /*
73  * Facility-special private data in squeues.
74  */
75 typedef enum {
76 	SQPRIVATE_TCP,
77 	SQPRIVATE_MAX
78 } sqprivate_t;
79 
80 extern void squeue_init(void);
81 extern squeue_t *squeue_create(clock_t, pri_t);
82 extern void squeue_bind(squeue_t *, processorid_t);
83 extern void squeue_unbind(squeue_t *);
84 extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
85     uint32_t, int, uint8_t);
86 extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
87 
88 extern int squeue_synch_enter(squeue_t *, void *, uint8_t);
89 extern void squeue_synch_exit(squeue_t *, void *);
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _SYS_SQUEUE_H */
96