xref: /onnv-gate/usr/src/uts/common/sys/squeue.h (revision 9534:bb9e21df7ad3)
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 /*
22*9534SAnders.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	GET_SQUEUE(mp)	((conn_t *)((mp)->b_prev))->conn_sqp
488275SEric Cheng 
498275SEric Cheng #define	SQ_FILL		0x0001
508275SEric Cheng #define	SQ_NODRAIN	0x0002
518275SEric Cheng #define	SQ_PROCESS	0x0004
528275SEric Cheng 
538275SEric Cheng #define	SQUEUE_ENTER(sqp, head, tail, cnt, flag, tag) {	\
548275SEric Cheng 	sqp->sq_enter(sqp, head, tail, cnt, flag, tag);	\
558275SEric Cheng }
568275SEric Cheng 
578275SEric Cheng #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, flag, tag) {	\
588275SEric Cheng 	ASSERT(mp->b_next == NULL);				\
598275SEric Cheng 	ASSERT(mp->b_prev == NULL);				\
608275SEric Cheng 	SET_SQUEUE(mp, proc, arg);				\
618275SEric Cheng 	SQUEUE_ENTER(sqp, mp, mp, 1, flag, tag);		\
628275SEric Cheng }
638275SEric Cheng 
648275SEric Cheng /*
658275SEric Cheng  * May be called only by a thread executing in the squeue. The thread must
668275SEric Cheng  * not continue to execute any code needing squeue protection after calling
678275SEric Cheng  * this macro. Please see the comments in squeue.c for more details.
688275SEric Cheng  */
698275SEric Cheng #define	SQUEUE_SWITCH(connp, new_sqp)				\
708275SEric Cheng 	(connp)->conn_sqp = new_sqp;
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * Facility-special private data in squeues.
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate typedef enum {
760Sstevel@tonic-gate 	SQPRIVATE_TCP,
770Sstevel@tonic-gate 	SQPRIVATE_MAX
780Sstevel@tonic-gate } sqprivate_t;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate extern void squeue_init(void);
818275SEric Cheng extern squeue_t *squeue_create(clock_t, pri_t);
820Sstevel@tonic-gate extern void squeue_bind(squeue_t *, processorid_t);
830Sstevel@tonic-gate extern void squeue_unbind(squeue_t *);
848275SEric Cheng extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
858275SEric Cheng     uint32_t, int, uint8_t);
860Sstevel@tonic-gate extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
870Sstevel@tonic-gate 
88*9534SAnders.Persson@Sun.COM struct conn_s;
89*9534SAnders.Persson@Sun.COM extern int squeue_synch_enter(squeue_t *, struct conn_s *, mblk_t *);
90*9534SAnders.Persson@Sun.COM extern void squeue_synch_exit(squeue_t *, struct conn_s *);
918348SEric.Yu@Sun.COM 
920Sstevel@tonic-gate #ifdef	__cplusplus
930Sstevel@tonic-gate }
940Sstevel@tonic-gate #endif
950Sstevel@tonic-gate 
960Sstevel@tonic-gate #endif	/* _SYS_SQUEUE_H */
97