xref: /titanic_41/usr/src/uts/common/sys/squeue_impl.h (revision 23b5c241225a8ade2b6b9f06ebb891ee459e3b02)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SQUEUE_IMPL_H
27 #define	_SYS_SQUEUE_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/squeue.h>
36 
37 #define	SQ_NAMELEN 31
38 
39 /*
40  * SQUEUE_DEBUG: If defined as 1, special code is compiled in which records
41  *      additional information aiding debugging is recorded in squeue.
42  *
43  * SQUEUE_PROFILE: If defined as 1, special code is compiled in which collects
44  *      various squeue statistics and exports them as kstats.
45  *
46  * Ideally we would like both SQUEUE_DEBUG and SQUEUE_PROFILE to be always set,
47  * but it affects performance, so they are enabled on DEBUG kernels and disabled
48  * on non-DEBUG by default.
49  */
50 #ifdef DEBUG
51 #define	SQUEUE_DEBUG 1
52 #define	SQUEUE_PROFILE 1
53 #else
54 #define	SQUEUE_DEBUG 0
55 #define	SQUEUE_PROFILE 0
56 #endif
57 
58 typedef struct sqstat_s {
59 	uint_t		sq_max_qlen;
60 	uint_t		sq_npackets_worker;
61 	uint_t		sq_npackets_intr;
62 	uint_t		sq_npackets_other;
63 	uint_t		sq_nqueued_intr;
64 	uint_t		sq_nqueued_other;
65 	uint_t		sq_ndrains_worker;
66 	uint_t		sq_ndrains_intr;
67 	uint_t		sq_ndrains_other;
68 	hrtime_t	sq_time_worker;
69 	hrtime_t	sq_time_intr;
70 	hrtime_t	sq_time_other;
71 } sqstat_t;
72 
73 struct squeue_s {
74 	/* Keep the most used members 64bytes cache aligned */
75 	kmutex_t	sq_lock;	/* lock before using any member */
76 	uint32_t	sq_state;	/* state flags and message count */
77 	int		sq_count;	/* # of mblocks in squeue */
78 	mblk_t		*sq_first;	/* first mblk chain or NULL */
79 	mblk_t		*sq_last;	/* last mblk chain or NULL */
80 	clock_t		sq_awaken;	/* time async thread was awakened */
81 	kthread_t	*sq_run;	/* Current thread processing sq */
82 	void		*sq_rx_ring;
83 	clock_t		sq_avg_drain_time; /* Avg time to drain a pkt */
84 
85 	processorid_t	sq_bind;	/* processor to bind to */
86 	kcondvar_t	sq_async;	/* async thread blocks on */
87 	clock_t		sq_wait;	/* lbolts to wait after a fill() */
88 	uintptr_t	sq_private[SQPRIVATE_MAX];
89 	timeout_id_t	sq_tid;		/* timer id of pending timeout() */
90 	kthread_t	*sq_worker;	/* kernel thread id */
91 	char		sq_name[SQ_NAMELEN + 1];
92 
93 #if SQUEUE_DEBUG
94 	/* Debug-only fields */
95 	int		sq_isintr;	/* serviced by interrupt */
96 	mblk_t		*sq_curmp;
97 	void		(*sq_curproc)();
98 	conn_t		*sq_connp;
99 	uchar_t		sq_tag;
100 #endif
101 
102 #if SQUEUE_PROFILE
103 	/* Profiling fields */
104 	kstat_t		*sq_kstat;	/* exported statistics */
105 	sqstat_t	sq_stats;
106 #endif
107 };
108 
109 /*
110  * State flags.
111  * Note: The MDB IP module depends on the values of these flags.
112  */
113 #define	SQS_PROC	0x0001	/* being processed */
114 #define	SQS_WORKER	0x0002	/* worker thread */
115 #define	SQS_ENTER	0x0004	/* enter thread */
116 #define	SQS_FAST	0x0008	/* enter-fast thread */
117 #define	SQS_USER	0x0010	/* A non interrupt user */
118 #define	SQS_BOUND	0x0020	/* Worker thread is bound */
119 #define	SQS_PROFILE	0x0040	/* Enable profiling */
120 #define	SQS_REENTER	0x0080	/* Re entered thread */
121 #define	SQS_TMO_PROG	0x0100	/* Timeout is being set */
122 #define	SQS_POLL_CAPAB	0x0200	/* Squeue can control interrupts */
123 #define	SQS_NO_INTR	0x0400	/* Interrupts currently disabled */
124 #define	SQS_ILL_BOUND	0x0800	/* Squeue bound to an ill */
125 #define	SQS_GET_PKTS	0x1000	/* Moving pkts from NIC in progress */
126 #define	SQS_DEFAULT	0x2000	/* The default squeue for the CPU */
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif	/* _SYS_SQUEUE_IMPL_H */
133