xref: /onnv-gate/usr/src/uts/common/sys/squeue.h (revision 12504:46a3cfcacbb9)
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*12504SAnders.Persson@Sun.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_SYS_SQUEUE_H
260Sstevel@tonic-gate #define	_SYS_SQUEUE_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #include <sys/processor.h>
340Sstevel@tonic-gate #include <sys/stream.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate struct squeue_s;
370Sstevel@tonic-gate typedef struct squeue_s squeue_t;
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	SET_SQUEUE(mp, proc, arg) {				\
400Sstevel@tonic-gate 	ASSERT((mp)->b_prev == NULL);				\
410Sstevel@tonic-gate 	ASSERT((mp)->b_next == NULL);				\
420Sstevel@tonic-gate 	(mp)->b_queue = (queue_t *)(proc);			\
430Sstevel@tonic-gate 	(mp)->b_prev = (mblk_t *)(arg);				\
440Sstevel@tonic-gate }
450Sstevel@tonic-gate 
468275SEric Cheng #define	SQ_FILL		0x0001
478275SEric Cheng #define	SQ_NODRAIN	0x0002
488275SEric Cheng #define	SQ_PROCESS	0x0004
498275SEric Cheng 
5011042SErik.Nordmark@Sun.COM #define	SQUEUE_ENTER(sqp, head, tail, cnt, ira, flag, tag) {	\
5111042SErik.Nordmark@Sun.COM 	sqp->sq_enter(sqp, head, tail, cnt, ira, flag, tag);	\
528275SEric Cheng }
538275SEric Cheng 
5411042SErik.Nordmark@Sun.COM #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, ira, flag, tag) {	\
558275SEric Cheng 	ASSERT(mp->b_next == NULL);				\
568275SEric Cheng 	ASSERT(mp->b_prev == NULL);				\
578275SEric Cheng 	SET_SQUEUE(mp, proc, arg);				\
5811042SErik.Nordmark@Sun.COM 	SQUEUE_ENTER(sqp, mp, mp, 1, ira, flag, tag);		\
598275SEric Cheng }
608275SEric Cheng 
618275SEric Cheng /*
628275SEric Cheng  * May be called only by a thread executing in the squeue. The thread must
638275SEric Cheng  * not continue to execute any code needing squeue protection after calling
648275SEric Cheng  * this macro. Please see the comments in squeue.c for more details.
658275SEric Cheng  */
668275SEric Cheng #define	SQUEUE_SWITCH(connp, new_sqp)				\
678275SEric Cheng 	(connp)->conn_sqp = new_sqp;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /*
700Sstevel@tonic-gate  * Facility-special private data in squeues.
710Sstevel@tonic-gate  */
720Sstevel@tonic-gate typedef enum {
730Sstevel@tonic-gate 	SQPRIVATE_TCP,
740Sstevel@tonic-gate 	SQPRIVATE_MAX
750Sstevel@tonic-gate } sqprivate_t;
760Sstevel@tonic-gate 
7711042SErik.Nordmark@Sun.COM struct ip_recv_attr_s;
780Sstevel@tonic-gate extern void squeue_init(void);
798275SEric Cheng extern squeue_t *squeue_create(clock_t, pri_t);
800Sstevel@tonic-gate extern void squeue_bind(squeue_t *, processorid_t);
810Sstevel@tonic-gate extern void squeue_unbind(squeue_t *);
828275SEric Cheng extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
8311042SErik.Nordmark@Sun.COM     uint32_t, struct ip_recv_attr_s *, int, uint8_t);
840Sstevel@tonic-gate extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
850Sstevel@tonic-gate 
869534SAnders.Persson@Sun.COM struct conn_s;
87*12504SAnders.Persson@Sun.COM extern int squeue_synch_enter(struct conn_s *, mblk_t *);
88*12504SAnders.Persson@Sun.COM extern void squeue_synch_exit(struct conn_s *);
898348SEric.Yu@Sun.COM 
900Sstevel@tonic-gate #ifdef	__cplusplus
910Sstevel@tonic-gate }
920Sstevel@tonic-gate #endif
930Sstevel@tonic-gate 
940Sstevel@tonic-gate #endif	/* _SYS_SQUEUE_H */
95