tcp_stats.h revision 5dd46ab5742d7db1cbb08dec7b64fa14930c02f7
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _INET_TCP_STATS_H
#define _INET_TCP_STATS_H
/*
* TCP private kernel statistics declarations.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* TCP Statistics.
*
* How TCP statistics work.
*
* There are two types of statistics invoked by two macros.
*
* TCP_STAT(name) does non-atomic increment of a named stat counter. It is
* supposed to be used in non MT-hot paths of the code.
*
* TCP_DBGSTAT(name) does atomic increment of a named stat counter. It is
* supposed to be used for DEBUG purposes and may be used on a hot path.
* These counters are only available in a debugged kerel. They are grouped
* under the TCP_DEBUG_COUNTER C pre-processor condition.
*
* Both TCP_STAT and TCP_DBGSTAT counters are available using kstat
* (use "kstat tcp" to get them).
*
* How to add new counters.
*
* 1) Add a field in the tcp_stat structure describing your counter.
* 2) Add a line in the template in tcp_kstat2_init() with the name
* of the counter.
* 3) Update tcp_clr_stats() and tcp_cp_stats() with the new counters.
* IMPORTANT!! - make sure that all the above functions are in sync !!
* 4) Use either TCP_STAT or TCP_DBGSTAT with the name.
*
* Please avoid using private counters which are not kstat-exported.
*
* Implementation note.
*
* Both the MIB2 and tcp_stat_t counters are kept per CPU in the array
* tcps_sc in tcp_stack_t. Each array element is a pointer to a
* tcp_stats_cpu_t struct. Once allocated, the tcp_stats_cpu_t struct is
* not freed until the tcp_stack_t is going away. So there is no need to
* acquire a lock before accessing the stats counters.
*/
#ifndef TCP_DEBUG_COUNTER
#ifdef DEBUG
#define TCP_DEBUG_COUNTER 1
#else
#define TCP_DEBUG_COUNTER 0
#endif
#endif
/* Kstats */
typedef struct tcp_stat {
#ifdef TCP_DEBUG_COUNTER
#endif
} tcp_stat_t;
/*
* This struct contains only the counter part of tcp_stat_t. It is used
* in tcp_stats_cpu_t instead of tcp_stat_t to save memory space.
*/
typedef struct tcp_stat_counter_s {
#ifdef TCP_DEBUG_COUNTER
#endif
typedef struct tcp_g_stat {
} tcp_g_stat_t;
/* Per CPU stats: TCP MIB2, TCP kstat and connection counter. */
typedef struct {
#define TCPS_BUMP_MIB(tcps, x) \
#define TCPS_UPDATE_MIB(tcps, x, y) \
#define TCP_DBGSTAT(tcps, x) \
#define TCP_G_DBGSTAT(x) \
#else
#define TCP_DBGSTAT(tcps, x)
#define TCP_G_DBGSTAT(x)
#endif
#define TCP_STAT_UPDATE(tcps, x, n) \
#define TCP_STAT_SET(tcps, x, n) \
/* Global TCP stats for all IP stacks. */
extern tcp_g_stat_t tcp_g_statistics;
extern kstat_t *tcp_g_kstat;
extern void *tcp_g_kstat_init(tcp_g_stat_t *);
extern void tcp_g_kstat_fini(kstat_t *);
extern void *tcp_kstat_init(netstackid_t);
extern void *tcp_kstat2_init(netstackid_t);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _INET_TCP_STATS_H */