xref: /onnv-gate/usr/src/uts/common/sys/squeue_impl.h (revision 2722:3846fae40902)
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
5*2722Sjohnlev  * Common Development and Distribution License (the "License").
6*2722Sjohnlev  * 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*2722Sjohnlev  * Copyright 2006 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_IMPL_H
270Sstevel@tonic-gate #define	_SYS_SQUEUE_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/squeue.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #define	SQ_NAMELEN 31
380Sstevel@tonic-gate 
39*2722Sjohnlev /*
40*2722Sjohnlev  * SQUEUE_DEBUG: If defined as 1, special code is compiled in which records
41*2722Sjohnlev  *      additional information aiding debugging is recorded in squeue.
42*2722Sjohnlev  *
43*2722Sjohnlev  * SQUEUE_PROFILE: If defined as 1, special code is compiled in which collects
44*2722Sjohnlev  *      various squeue statistics and exports them as kstats.
45*2722Sjohnlev  *
46*2722Sjohnlev  * Ideally we would like both SQUEUE_DEBUG and SQUEUE_PROFILE to be always set,
47*2722Sjohnlev  * but it affects performance, so they are enabled on DEBUG kernels and disabled
48*2722Sjohnlev  * on non-DEBUG by default.
49*2722Sjohnlev  */
50*2722Sjohnlev #ifdef DEBUG
51*2722Sjohnlev #define	SQUEUE_DEBUG 1
52*2722Sjohnlev #define	SQUEUE_PROFILE 1
53*2722Sjohnlev #else
54*2722Sjohnlev #define	SQUEUE_DEBUG 0
55*2722Sjohnlev #define	SQUEUE_PROFILE 0
56*2722Sjohnlev #endif
57*2722Sjohnlev 
580Sstevel@tonic-gate typedef struct sqstat_s {
590Sstevel@tonic-gate 	uint_t		sq_max_qlen;
600Sstevel@tonic-gate 	uint_t		sq_npackets_worker;
610Sstevel@tonic-gate 	uint_t		sq_npackets_intr;
620Sstevel@tonic-gate 	uint_t		sq_npackets_other;
630Sstevel@tonic-gate 	uint_t		sq_nqueued_intr;
640Sstevel@tonic-gate 	uint_t		sq_nqueued_other;
650Sstevel@tonic-gate 	uint_t		sq_ndrains_worker;
660Sstevel@tonic-gate 	uint_t		sq_ndrains_intr;
670Sstevel@tonic-gate 	uint_t		sq_ndrains_other;
680Sstevel@tonic-gate 	hrtime_t	sq_time_worker;
690Sstevel@tonic-gate 	hrtime_t	sq_time_intr;
700Sstevel@tonic-gate 	hrtime_t	sq_time_other;
710Sstevel@tonic-gate } sqstat_t;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate struct squeue_s {
740Sstevel@tonic-gate 	/* Keep the most used members 64bytes cache aligned */
750Sstevel@tonic-gate 	kmutex_t	sq_lock;	/* lock before using any member */
760Sstevel@tonic-gate 	uint32_t	sq_state;	/* state flags and message count */
770Sstevel@tonic-gate 	int		sq_count;	/* # of mblocks in squeue */
780Sstevel@tonic-gate 	mblk_t		*sq_first;	/* first mblk chain or NULL */
790Sstevel@tonic-gate 	mblk_t		*sq_last;	/* last mblk chain or NULL */
800Sstevel@tonic-gate 	clock_t		sq_awaken;	/* time async thread was awakened */
810Sstevel@tonic-gate 	kthread_t	*sq_run;	/* Current thread processing sq */
820Sstevel@tonic-gate 	void		*sq_rx_ring;
830Sstevel@tonic-gate 	clock_t		sq_avg_drain_time; /* Avg time to drain a pkt */
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	processorid_t	sq_bind;	/* processor to bind to */
860Sstevel@tonic-gate 	kcondvar_t	sq_async;	/* async thread blocks on */
870Sstevel@tonic-gate 	clock_t		sq_wait;	/* lbolts to wait after a fill() */
880Sstevel@tonic-gate 	uintptr_t	sq_private[SQPRIVATE_MAX];
890Sstevel@tonic-gate 	timeout_id_t	sq_tid;		/* timer id of pending timeout() */
900Sstevel@tonic-gate 	kthread_t	*sq_worker;	/* kernel thread id */
910Sstevel@tonic-gate 	char		sq_name[SQ_NAMELEN + 1];
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #if SQUEUE_DEBUG
940Sstevel@tonic-gate 	/* Debug-only fields */
950Sstevel@tonic-gate 	int		sq_isintr;	/* serviced by interrupt */
960Sstevel@tonic-gate 	mblk_t		*sq_curmp;
970Sstevel@tonic-gate 	void		(*sq_curproc)();
980Sstevel@tonic-gate 	conn_t		*sq_connp;
990Sstevel@tonic-gate 	uchar_t		sq_tag;
1000Sstevel@tonic-gate #endif
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate #if SQUEUE_PROFILE
1030Sstevel@tonic-gate 	/* Profiling fields */
1040Sstevel@tonic-gate 	kstat_t		*sq_kstat;	/* exported statistics */
1050Sstevel@tonic-gate 	sqstat_t	sq_stats;
1060Sstevel@tonic-gate #endif
1070Sstevel@tonic-gate };
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * State flags.
1110Sstevel@tonic-gate  * Note: The MDB IP module depends on the values of these flags.
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate #define	SQS_PROC	0x0001	/* being processed */
1140Sstevel@tonic-gate #define	SQS_WORKER	0x0002	/* worker thread */
1150Sstevel@tonic-gate #define	SQS_ENTER	0x0004	/* enter thread */
1160Sstevel@tonic-gate #define	SQS_FAST	0x0008	/* enter-fast thread */
1170Sstevel@tonic-gate #define	SQS_USER	0x0010	/* A non interrupt user */
1180Sstevel@tonic-gate #define	SQS_BOUND	0x0020	/* Worker thread is bound */
1190Sstevel@tonic-gate #define	SQS_PROFILE	0x0040	/* Enable profiling */
1200Sstevel@tonic-gate #define	SQS_REENTER	0x0080	/* Re entered thread */
1210Sstevel@tonic-gate #define	SQS_TMO_PROG	0x0100	/* Timeout is being set */
1220Sstevel@tonic-gate #define	SQS_POLL_CAPAB	0x0200	/* Squeue can control interrupts */
1230Sstevel@tonic-gate #define	SQS_NO_INTR	0x0400	/* Interrupts currently disabled */
1240Sstevel@tonic-gate #define	SQS_ILL_BOUND	0x0800	/* Squeue bound to an ill */
1250Sstevel@tonic-gate #define	SQS_GET_PKTS	0x1000	/* Moving pkts from NIC in progress */
1260Sstevel@tonic-gate #define	SQS_DEFAULT	0x2000	/* The default squeue for the CPU */
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate #ifdef	__cplusplus
1290Sstevel@tonic-gate }
1300Sstevel@tonic-gate #endif
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate #endif	/* _SYS_SQUEUE_IMPL_H */
133