xref: /onnv-gate/usr/src/uts/common/sys/squeue.h (revision 11042:2d6e217af1b4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58275SEric Cheng  * Common Development and Distribution License (the "License").
68275SEric Cheng  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
229534SAnders.Persson@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_SQUEUE_H
270Sstevel@tonic-gate #define	_SYS_SQUEUE_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <sys/processor.h>
350Sstevel@tonic-gate #include <sys/stream.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate struct squeue_s;
380Sstevel@tonic-gate typedef struct squeue_s squeue_t;
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #define	SET_SQUEUE(mp, proc, arg) {				\
410Sstevel@tonic-gate 	ASSERT((mp)->b_prev == NULL);				\
420Sstevel@tonic-gate 	ASSERT((mp)->b_next == NULL);				\
430Sstevel@tonic-gate 	(mp)->b_queue = (queue_t *)(proc);			\
440Sstevel@tonic-gate 	(mp)->b_prev = (mblk_t *)(arg);				\
450Sstevel@tonic-gate }
460Sstevel@tonic-gate 
478275SEric Cheng #define	SQ_FILL		0x0001
488275SEric Cheng #define	SQ_NODRAIN	0x0002
498275SEric Cheng #define	SQ_PROCESS	0x0004
508275SEric Cheng 
51*11042SErik.Nordmark@Sun.COM #define	SQUEUE_ENTER(sqp, head, tail, cnt, ira, flag, tag) {	\
52*11042SErik.Nordmark@Sun.COM 	sqp->sq_enter(sqp, head, tail, cnt, ira, flag, tag);	\
538275SEric Cheng }
548275SEric Cheng 
55*11042SErik.Nordmark@Sun.COM #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, ira, flag, tag) {	\
568275SEric Cheng 	ASSERT(mp->b_next == NULL);				\
578275SEric Cheng 	ASSERT(mp->b_prev == NULL);				\
588275SEric Cheng 	SET_SQUEUE(mp, proc, arg);				\
59*11042SErik.Nordmark@Sun.COM 	SQUEUE_ENTER(sqp, mp, mp, 1, ira, flag, tag);		\
608275SEric Cheng }
618275SEric Cheng 
628275SEric Cheng /*
638275SEric Cheng  * May be called only by a thread executing in the squeue. The thread must
648275SEric Cheng  * not continue to execute any code needing squeue protection after calling
658275SEric Cheng  * this macro. Please see the comments in squeue.c for more details.
668275SEric Cheng  */
678275SEric Cheng #define	SQUEUE_SWITCH(connp, new_sqp)				\
688275SEric Cheng 	(connp)->conn_sqp = new_sqp;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * Facility-special private data in squeues.
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate typedef enum {
740Sstevel@tonic-gate 	SQPRIVATE_TCP,
750Sstevel@tonic-gate 	SQPRIVATE_MAX
760Sstevel@tonic-gate } sqprivate_t;
770Sstevel@tonic-gate 
78*11042SErik.Nordmark@Sun.COM struct ip_recv_attr_s;
790Sstevel@tonic-gate extern void squeue_init(void);
808275SEric Cheng extern squeue_t *squeue_create(clock_t, pri_t);
810Sstevel@tonic-gate extern void squeue_bind(squeue_t *, processorid_t);
820Sstevel@tonic-gate extern void squeue_unbind(squeue_t *);
838275SEric Cheng extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
84*11042SErik.Nordmark@Sun.COM     uint32_t, struct ip_recv_attr_s *, int, uint8_t);
850Sstevel@tonic-gate extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
860Sstevel@tonic-gate 
879534SAnders.Persson@Sun.COM struct conn_s;
889534SAnders.Persson@Sun.COM extern int squeue_synch_enter(squeue_t *, struct conn_s *, mblk_t *);
899534SAnders.Persson@Sun.COM extern void squeue_synch_exit(squeue_t *, struct conn_s *);
908348SEric.Yu@Sun.COM 
910Sstevel@tonic-gate #ifdef	__cplusplus
920Sstevel@tonic-gate }
930Sstevel@tonic-gate #endif
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #endif	/* _SYS_SQUEUE_H */
96