xref: /titanic_51/usr/src/uts/common/sys/squeue.h (revision 9ee3959a9e59422575d29f2ec8ffb62ce0918ac8)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*9ee3959aSAnders Persson  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_SYS_SQUEUE_H
267c478bd9Sstevel@tonic-gate #define	_SYS_SQUEUE_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
297c478bd9Sstevel@tonic-gate extern "C" {
307c478bd9Sstevel@tonic-gate #endif
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate #include <sys/processor.h>
347c478bd9Sstevel@tonic-gate #include <sys/stream.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate struct squeue_s;
377c478bd9Sstevel@tonic-gate typedef struct squeue_s squeue_t;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	SET_SQUEUE(mp, proc, arg) {				\
407c478bd9Sstevel@tonic-gate 	ASSERT((mp)->b_prev == NULL);				\
417c478bd9Sstevel@tonic-gate 	ASSERT((mp)->b_next == NULL);				\
427c478bd9Sstevel@tonic-gate 	(mp)->b_queue = (queue_t *)(proc);			\
437c478bd9Sstevel@tonic-gate 	(mp)->b_prev = (mblk_t *)(arg);				\
447c478bd9Sstevel@tonic-gate }
457c478bd9Sstevel@tonic-gate 
46da14cebeSEric Cheng #define	SQ_FILL		0x0001
47da14cebeSEric Cheng #define	SQ_NODRAIN	0x0002
48da14cebeSEric Cheng #define	SQ_PROCESS	0x0004
49da14cebeSEric Cheng 
50bd670b35SErik Nordmark #define	SQUEUE_ENTER(sqp, head, tail, cnt, ira, flag, tag) {	\
51bd670b35SErik Nordmark 	sqp->sq_enter(sqp, head, tail, cnt, ira, flag, tag);	\
52da14cebeSEric Cheng }
53da14cebeSEric Cheng 
54bd670b35SErik Nordmark #define	SQUEUE_ENTER_ONE(sqp, mp, proc, arg, ira, flag, tag) {	\
55da14cebeSEric Cheng 	ASSERT(mp->b_next == NULL);				\
56da14cebeSEric Cheng 	ASSERT(mp->b_prev == NULL);				\
57da14cebeSEric Cheng 	SET_SQUEUE(mp, proc, arg);				\
58bd670b35SErik Nordmark 	SQUEUE_ENTER(sqp, mp, mp, 1, ira, flag, tag);		\
59da14cebeSEric Cheng }
60da14cebeSEric Cheng 
61da14cebeSEric Cheng /*
62da14cebeSEric Cheng  * May be called only by a thread executing in the squeue. The thread must
63da14cebeSEric Cheng  * not continue to execute any code needing squeue protection after calling
64da14cebeSEric Cheng  * this macro. Please see the comments in squeue.c for more details.
65da14cebeSEric Cheng  */
66da14cebeSEric Cheng #define	SQUEUE_SWITCH(connp, new_sqp)				\
67da14cebeSEric Cheng 	(connp)->conn_sqp = new_sqp;
68da14cebeSEric Cheng 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * Facility-special private data in squeues.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate typedef enum {
737c478bd9Sstevel@tonic-gate 	SQPRIVATE_TCP,
747c478bd9Sstevel@tonic-gate 	SQPRIVATE_MAX
757c478bd9Sstevel@tonic-gate } sqprivate_t;
767c478bd9Sstevel@tonic-gate 
77bd670b35SErik Nordmark struct ip_recv_attr_s;
787c478bd9Sstevel@tonic-gate extern void squeue_init(void);
79da14cebeSEric Cheng extern squeue_t *squeue_create(clock_t, pri_t);
807c478bd9Sstevel@tonic-gate extern void squeue_bind(squeue_t *, processorid_t);
817c478bd9Sstevel@tonic-gate extern void squeue_unbind(squeue_t *);
82da14cebeSEric Cheng extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *,
83bd670b35SErik Nordmark     uint32_t, struct ip_recv_attr_s *, int, uint8_t);
847c478bd9Sstevel@tonic-gate extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t);
857c478bd9Sstevel@tonic-gate 
86f3124163SAnders Persson struct conn_s;
87*9ee3959aSAnders Persson extern int squeue_synch_enter(struct conn_s *, mblk_t *);
88*9ee3959aSAnders Persson extern void squeue_synch_exit(struct conn_s *);
890f1702c5SYu Xiangning 
907c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate #endif
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #endif	/* _SYS_SQUEUE_H */
95