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