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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_SQUEUE_IMPL_H
27 #define _SYS_SQUEUE_IMPL_H
34 #include <sys/types.h>
35 #include <sys/squeue.h>
41 * SQUEUE_DEBUG: If defined as 1, special code is compiled in which records
42 * additional information aiding debugging is recorded in squeue.
44 * SQUEUE_PROFILE: If defined as 1, special code is compiled in which collects
45 * various squeue statistics and exports them as kstats.
47 * Ideally we would like both SQUEUE_DEBUG and SQUEUE_PROFILE to be always set,
48 * but it affects performance, so they are enabled on DEBUG kernels and disabled
49 * on non-DEBUG by default.
52 #define SQUEUE_DEBUG 1
53 #define SQUEUE_PROFILE 1
55 #define SQUEUE_DEBUG 0
56 #define SQUEUE_PROFILE 0
59 #define SQUEUE_DEFAULT_PRIORITY MAXCLSYSPRI
61 typedef struct sqstat_s
{
63 uint_t sq_npackets_worker
;
64 uint_t sq_npackets_intr
;
65 uint_t sq_npackets_other
;
66 uint_t sq_nqueued_intr
;
67 uint_t sq_nqueued_other
;
68 uint_t sq_ndrains_worker
;
69 uint_t sq_ndrains_intr
;
70 uint_t sq_ndrains_other
;
71 hrtime_t sq_time_worker
;
72 hrtime_t sq_time_intr
;
73 hrtime_t sq_time_other
;
76 typedef struct squeue_set_s
{
78 squeue_t
*sqs_default
;
79 processorid_t sqs_cpuid
;
82 typedef void (*sqproc_t
)(void *, mblk_t
*, void *, struct ip_recv_attr_s
*);
83 typedef void (*sq_enter_proc_t
)(squeue_t
*, mblk_t
*, mblk_t
*, uint32_t,
84 struct ip_recv_attr_s
*, int, uint8_t);
85 typedef void (*sq_drain_proc_t
)(squeue_t
*, uint_t
, hrtime_t
);
87 extern void squeue_worker_wakeup(squeue_t
*);
88 extern int ip_squeue_flag
;
91 sq_enter_proc_t sq_enter
; /* sq_process function */
92 sq_drain_proc_t sq_drain
; /* sq_drain function */
93 kmutex_t sq_lock
; /* lock before using any member */
94 uint32_t sq_state
; /* state flags and message count */
95 int sq_count
; /* # of mblocks in squeue */
96 mblk_t
*sq_first
; /* first mblk chain or NULL */
97 mblk_t
*sq_last
; /* last mblk chain or NULL */
98 kthread_t
*sq_run
; /* Current thread processing sq */
99 ill_rx_ring_t
*sq_rx_ring
; /* The Rx ring tied to this sq */
100 ill_t
*sq_ill
; /* The ill this squeue is tied to */
102 clock_t sq_curr_time
; /* Current tick (lbolt) */
103 kcondvar_t sq_worker_cv
; /* cond var. worker thread blocks on */
104 kcondvar_t sq_poll_cv
; /* cond variable poll_thr waits on */
105 kcondvar_t sq_synch_cv
; /* cond var. synch thread waits on */
106 kcondvar_t sq_ctrlop_done_cv
; /* cond variable for ctrl ops */
107 clock_t sq_wait
; /* lbolts to wait after a fill() */
108 timeout_id_t sq_tid
; /* timer id of pending timeout() */
109 clock_t sq_awaken
; /* time async thread was awakened */
111 processorid_t sq_bind
; /* processor to bind to */
112 kthread_t
*sq_worker
; /* kernel thread id */
113 kthread_t
*sq_poll_thr
; /* polling thread */
114 uintptr_t sq_private
[SQPRIVATE_MAX
];
116 squeue_t
*sq_next
; /* managed by squeue creator */
117 squeue_set_t
*sq_set
; /* managed by squeue creator */
119 pri_t sq_priority
; /* squeue thread priority */
121 /* Keep the debug-only fields at the end of the structure */
123 int sq_isintr
; /* serviced by interrupt */
125 void (*sq_curproc
)();
133 * Note: The MDB IP module depends on the values of these flags.
135 #define SQS_PROC 0x00000001 /* being processed */
136 #define SQS_WORKER 0x00000002 /* worker thread */
137 #define SQS_ENTER 0x00000004 /* enter thread */
138 #define SQS_FAST 0x00000008 /* enter-fast thread */
140 #define SQS_USER 0x00000010 /* A non interrupt user */
141 #define SQS_BOUND 0x00000020 /* Worker thread is bound */
142 #define SQS_REENTER 0x00000040 /* Re entered thread */
143 #define SQS_TMO_PROG 0x00000080 /* Timeout is being set */
145 #define SQS_POLL_CAPAB 0x00000100 /* Squeue can control interrupts */
146 #define SQS_ILL_BOUND 0x00000200 /* Squeue bound to an ill */
147 #define SQS_GET_PKTS 0x00000400 /* Moving pkts from NIC in progress */
148 #define SQS_DEFAULT 0x00000800 /* The default squeue for the CPU */
150 #define SQS_POLLING 0x00001000 /* Squeue in polling mode */
151 #define SQS_INTR_BLANK 0x00002000 /* Interrupt blanking capability */
152 #define SQS_PROC_HELD 0x00004000 /* SQS_PROC is held by the caller */
153 #define SQS_FORCE_TIMER 0x00008000 /* Schedule worker due to B/W control */
155 #define SQS_POLL_CLEANUP 0x00010000
156 #define SQS_POLL_CLEANUP_DONE 0x00020000
157 #define SQS_POLL_QUIESCE 0x00040000
158 #define SQS_POLL_QUIESCE_DONE 0x00080000
160 #define SQS_POLL_RESTART 0x00100000
161 #define SQS_POLL_THR_QUIESCED 0x00200000
162 #define SQS_POLL_THR_RESTART 0x00400000
163 #define SQS_POLL_PROC 0x00800000 /* Poll thread processing the sq */
165 #define SQS_POLL_RESTART_DONE 0x01000000
166 #define SQS_POLL_THR_QUIESCE 0x02000000
167 #define SQS_PAUSE 0x04000000 /* The squeue has been paused */
169 #define SQS_WORKER_THR_CONTROL \
170 (SQS_POLL_QUIESCE | SQS_POLL_RESTART | SQS_POLL_CLEANUP)
172 #define SQS_POLL_THR_CONTROL \
173 (SQS_POLL_THR_QUIESCE | SQS_POLL_THR_RESTART)
179 #endif /* _SYS_SQUEUE_IMPL_H */