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