xref: /titanic_41/usr/src/uts/common/sys/squeue.h (revision eb82ff87b34e625264561b2d267577cf9821dab0)
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 2009 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	SQ_FILL		0x0001
48 #define	SQ_NODRAIN	0x0002
49 #define	SQ_PROCESS	0x0004
50 
51 #define	SQUEUE_ENTER(sqp, head, tail, cnt, ira, flag, tag) {	\
52 	sqp->sq_enter(sqp, head, tail, cnt, ira, flag, tag);	\
53 }
54 
55 #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, ira, flag, tag) {	\
56 	ASSERT(mp->b_next == NULL);				\
57 	ASSERT(mp->b_prev == NULL);				\
58 	SET_SQUEUE(mp, proc, arg);				\
59 	SQUEUE_ENTER(sqp, mp, mp, 1, ira, flag, tag);		\
60 }
61 
62 /*
63  * May be called only by a thread executing in the squeue. The thread must
64  * not continue to execute any code needing squeue protection after calling
65  * this macro. Please see the comments in squeue.c for more details.
66  */
67 #define	SQUEUE_SWITCH(connp, new_sqp)				\
68 	(connp)->conn_sqp = new_sqp;
69 
70 /*
71  * Facility-special private data in squeues.
72  */
73 typedef enum {
74 	SQPRIVATE_TCP,
75 	SQPRIVATE_MAX
76 } sqprivate_t;
77 
78 struct ip_recv_attr_s;
79 extern void squeue_init(void);
80 extern squeue_t *squeue_create(clock_t, pri_t);
81 extern void squeue_bind(squeue_t *, processorid_t);
82 extern void squeue_unbind(squeue_t *);
83 extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
84     uint32_t, struct ip_recv_attr_s *, int, uint8_t);
85 extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
86 
87 struct conn_s;
88 extern int squeue_synch_enter(squeue_t *, struct conn_s *, mblk_t *);
89 extern void squeue_synch_exit(squeue_t *, struct conn_s *);
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _SYS_SQUEUE_H */
96