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 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #ifndef _INET_TCP_STATS_H
27 #define _INET_TCP_STATS_H
28
29 /*
30 * TCP private kernel statistics declarations.
31 */
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifdef _KERNEL
38
39 /*
40 * TCP Statistics.
41 *
42 * How TCP statistics work.
43 *
188 uint64_t tcp_timermp_freed;
189 uint64_t tcp_push_timer_cnt;
190 uint64_t tcp_ack_timer_cnt;
191 #endif
192 } tcp_stat_counter_t;
193
194 typedef struct tcp_g_stat {
195 kstat_named_t tcp_timermp_alloced;
196 kstat_named_t tcp_timermp_allocfail;
197 kstat_named_t tcp_timermp_allocdblfail;
198 kstat_named_t tcp_freelist_cleanup;
199 } tcp_g_stat_t;
200
201 /* Per CPU stats: TCP MIB2, TCP kstat and connection counter. */
202 typedef struct {
203 int64_t tcp_sc_conn_cnt;
204 mib2_tcp_t tcp_sc_mib;
205 tcp_stat_counter_t tcp_sc_stats;
206 } tcp_stats_cpu_t;
207
208 #define TCPS_BUMP_MIB(tcps, x) \
209 BUMP_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x)
210
211 #define TCPS_UPDATE_MIB(tcps, x, y) \
212 UPDATE_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x, y)
213
214 #if TCP_DEBUG_COUNTER
215 #define TCP_DBGSTAT(tcps, x) \
216 atomic_inc_64( \
217 &((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x))
218 #define TCP_G_DBGSTAT(x) \
219 atomic_inc_64(&(tcp_g_statistics.x.value.ui64))
220 #else
221 #define TCP_DBGSTAT(tcps, x)
222 #define TCP_G_DBGSTAT(x)
223 #endif
224
225 #define TCP_G_STAT(x) (tcp_g_statistics.x.value.ui64++)
226
227 #define TCP_STAT(tcps, x) \
|
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 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2015 by Delphix. All rights reserved.
25 */
26
27 #ifndef _INET_TCP_STATS_H
28 #define _INET_TCP_STATS_H
29
30 /*
31 * TCP private kernel statistics declarations.
32 */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #ifdef _KERNEL
39
40 /*
41 * TCP Statistics.
42 *
43 * How TCP statistics work.
44 *
189 uint64_t tcp_timermp_freed;
190 uint64_t tcp_push_timer_cnt;
191 uint64_t tcp_ack_timer_cnt;
192 #endif
193 } tcp_stat_counter_t;
194
195 typedef struct tcp_g_stat {
196 kstat_named_t tcp_timermp_alloced;
197 kstat_named_t tcp_timermp_allocfail;
198 kstat_named_t tcp_timermp_allocdblfail;
199 kstat_named_t tcp_freelist_cleanup;
200 } tcp_g_stat_t;
201
202 /* Per CPU stats: TCP MIB2, TCP kstat and connection counter. */
203 typedef struct {
204 int64_t tcp_sc_conn_cnt;
205 mib2_tcp_t tcp_sc_mib;
206 tcp_stat_counter_t tcp_sc_stats;
207 } tcp_stats_cpu_t;
208
209 /*
210 * Per-connection statistics. Some of these are also kept globally in the
211 * per-cpu tcp_sc_mib entry (see tcp_stats_cpu_t above). We need not maintain
212 * per-cpu versions of these stats since a connection is typically processed
213 * on the same CPU.
214 */
215 typedef struct tcp_conn_stats {
216 uint64_t tcp_in_data_inorder_bytes;
217 uint64_t tcp_in_data_inorder_segs;
218 uint64_t tcp_in_data_unorder_bytes;
219 uint64_t tcp_in_data_unorder_segs;
220 uint64_t tcp_in_zwnd_probes;
221
222 uint64_t tcp_out_data_bytes;
223 uint64_t tcp_out_data_segs;
224 uint64_t tcp_out_retrans_bytes;
225 uint64_t tcp_out_retrans_segs;
226 uint64_t tcp_out_zwnd_probes;
227 } tcp_conn_stats_t;
228
229 #define TCPS_BUMP_MIB(tcps, x) \
230 BUMP_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x)
231
232 #define TCPS_UPDATE_MIB(tcps, x, y) \
233 UPDATE_MIB(&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_mib, x, y)
234
235 #if TCP_DEBUG_COUNTER
236 #define TCP_DBGSTAT(tcps, x) \
237 atomic_inc_64( \
238 &((tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_stats.x))
239 #define TCP_G_DBGSTAT(x) \
240 atomic_inc_64(&(tcp_g_statistics.x.value.ui64))
241 #else
242 #define TCP_DBGSTAT(tcps, x)
243 #define TCP_G_DBGSTAT(x)
244 #endif
245
246 #define TCP_G_STAT(x) (tcp_g_statistics.x.value.ui64++)
247
248 #define TCP_STAT(tcps, x) \
|