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*f3124163SAnders Persson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_SQUEUE_H 277c478bd9Sstevel@tonic-gate #define _SYS_SQUEUE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/types.h> 347c478bd9Sstevel@tonic-gate #include <sys/processor.h> 357c478bd9Sstevel@tonic-gate #include <sys/stream.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate struct squeue_s; 387c478bd9Sstevel@tonic-gate typedef struct squeue_s squeue_t; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #define SET_SQUEUE(mp, proc, arg) { \ 417c478bd9Sstevel@tonic-gate ASSERT((mp)->b_prev == NULL); \ 427c478bd9Sstevel@tonic-gate ASSERT((mp)->b_next == NULL); \ 437c478bd9Sstevel@tonic-gate (mp)->b_queue = (queue_t *)(proc); \ 447c478bd9Sstevel@tonic-gate (mp)->b_prev = (mblk_t *)(arg); \ 457c478bd9Sstevel@tonic-gate } 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define GET_SQUEUE(mp) ((conn_t *)((mp)->b_prev))->conn_sqp 487c478bd9Sstevel@tonic-gate 49da14cebeSEric Cheng #define SQ_FILL 0x0001 50da14cebeSEric Cheng #define SQ_NODRAIN 0x0002 51da14cebeSEric Cheng #define SQ_PROCESS 0x0004 52da14cebeSEric Cheng 53da14cebeSEric Cheng #define SQUEUE_ENTER(sqp, head, tail, cnt, flag, tag) { \ 54da14cebeSEric Cheng sqp->sq_enter(sqp, head, tail, cnt, flag, tag); \ 55da14cebeSEric Cheng } 56da14cebeSEric Cheng 57da14cebeSEric Cheng #define SQUEUE_ENTER_ONE(sqp, mp, proc, arg, flag, tag) { \ 58da14cebeSEric Cheng ASSERT(mp->b_next == NULL); \ 59da14cebeSEric Cheng ASSERT(mp->b_prev == NULL); \ 60da14cebeSEric Cheng SET_SQUEUE(mp, proc, arg); \ 61da14cebeSEric Cheng SQUEUE_ENTER(sqp, mp, mp, 1, flag, tag); \ 62da14cebeSEric Cheng } 63da14cebeSEric Cheng 64da14cebeSEric Cheng /* 65da14cebeSEric Cheng * May be called only by a thread executing in the squeue. The thread must 66da14cebeSEric Cheng * not continue to execute any code needing squeue protection after calling 67da14cebeSEric Cheng * this macro. Please see the comments in squeue.c for more details. 68da14cebeSEric Cheng */ 69da14cebeSEric Cheng #define SQUEUE_SWITCH(connp, new_sqp) \ 70da14cebeSEric Cheng (connp)->conn_sqp = new_sqp; 71da14cebeSEric Cheng 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Facility-special private data in squeues. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate typedef enum { 767c478bd9Sstevel@tonic-gate SQPRIVATE_TCP, 777c478bd9Sstevel@tonic-gate SQPRIVATE_MAX 787c478bd9Sstevel@tonic-gate } sqprivate_t; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate extern void squeue_init(void); 81da14cebeSEric Cheng extern squeue_t *squeue_create(clock_t, pri_t); 827c478bd9Sstevel@tonic-gate extern void squeue_bind(squeue_t *, processorid_t); 837c478bd9Sstevel@tonic-gate extern void squeue_unbind(squeue_t *); 84da14cebeSEric Cheng extern void squeue_enter(squeue_t *, mblk_t *, mblk_t *, 85da14cebeSEric Cheng uint32_t, int, uint8_t); 867c478bd9Sstevel@tonic-gate extern uintptr_t *squeue_getprivate(squeue_t *, sqprivate_t); 877c478bd9Sstevel@tonic-gate 88*f3124163SAnders Persson struct conn_s; 89*f3124163SAnders Persson extern int squeue_synch_enter(squeue_t *, struct conn_s *, mblk_t *); 90*f3124163SAnders Persson extern void squeue_synch_exit(squeue_t *, struct conn_s *); 910f1702c5SYu Xiangning 927c478bd9Sstevel@tonic-gate #ifdef __cplusplus 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate #endif 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #endif /* _SYS_SQUEUE_H */ 97