xref: /illumos-gate/usr/src/lib/libdladm/common/libdlstat.h (revision da14cebe459d3275048785f25bd869cb09b5307f)
1*da14cebeSEric Cheng /*
2*da14cebeSEric Cheng  * CDDL HEADER START
3*da14cebeSEric Cheng  *
4*da14cebeSEric Cheng  * The contents of this file are subject to the terms of the
5*da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6*da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
7*da14cebeSEric Cheng  *
8*da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
10*da14cebeSEric Cheng  * See the License for the specific language governing permissions
11*da14cebeSEric Cheng  * and limitations under the License.
12*da14cebeSEric Cheng  *
13*da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14*da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*da14cebeSEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
16*da14cebeSEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
17*da14cebeSEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
18*da14cebeSEric Cheng  *
19*da14cebeSEric Cheng  * CDDL HEADER END
20*da14cebeSEric Cheng  */
21*da14cebeSEric Cheng /*
22*da14cebeSEric Cheng  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*da14cebeSEric Cheng  * Use is subject to license terms.
24*da14cebeSEric Cheng  */
25*da14cebeSEric Cheng 
26*da14cebeSEric Cheng #ifndef _LIBDLSTAT_H
27*da14cebeSEric Cheng #define	_LIBDLSTAT_H
28*da14cebeSEric Cheng 
29*da14cebeSEric Cheng /*
30*da14cebeSEric Cheng  * This file includes structures, macros and common routines shared by all
31*da14cebeSEric Cheng  * data-link administration, and routines which are used to retrieve and
32*da14cebeSEric Cheng  * display statistics.
33*da14cebeSEric Cheng  */
34*da14cebeSEric Cheng 
35*da14cebeSEric Cheng #include <kstat.h>
36*da14cebeSEric Cheng 
37*da14cebeSEric Cheng #ifdef	__cplusplus
38*da14cebeSEric Cheng extern "C" {
39*da14cebeSEric Cheng #endif
40*da14cebeSEric Cheng 
41*da14cebeSEric Cheng #define	LINK_REPORT	1
42*da14cebeSEric Cheng #define	FLOW_REPORT	2
43*da14cebeSEric Cheng 
44*da14cebeSEric Cheng typedef struct pktsum_s {
45*da14cebeSEric Cheng 	hrtime_t	snaptime;
46*da14cebeSEric Cheng 	uint64_t	ipackets;
47*da14cebeSEric Cheng 	uint64_t	opackets;
48*da14cebeSEric Cheng 	uint64_t	rbytes;
49*da14cebeSEric Cheng 	uint64_t	obytes;
50*da14cebeSEric Cheng 	uint64_t	ierrors;
51*da14cebeSEric Cheng 	uint64_t	oerrors;
52*da14cebeSEric Cheng } pktsum_t;
53*da14cebeSEric Cheng 
54*da14cebeSEric Cheng extern void		dladm_continuous(datalink_id_t, const char *, int, int);
55*da14cebeSEric Cheng 
56*da14cebeSEric Cheng extern kstat_t		*dladm_kstat_lookup(kstat_ctl_t *, const char *, int,
57*da14cebeSEric Cheng 			    const char *, const char *);
58*da14cebeSEric Cheng extern void		dladm_get_stats(kstat_ctl_t *, kstat_t *, pktsum_t *);
59*da14cebeSEric Cheng extern int		dladm_kstat_value(kstat_t *, const char *, uint8_t,
60*da14cebeSEric Cheng 			    void *);
61*da14cebeSEric Cheng extern dladm_status_t	dladm_get_single_mac_stat(datalink_id_t, const char *,
62*da14cebeSEric Cheng 			    uint8_t, void *);
63*da14cebeSEric Cheng 
64*da14cebeSEric Cheng extern void		dladm_stats_total(pktsum_t *, pktsum_t *, pktsum_t *);
65*da14cebeSEric Cheng extern void		dladm_stats_diff(pktsum_t *, pktsum_t *, pktsum_t *);
66*da14cebeSEric Cheng 
67*da14cebeSEric Cheng #ifdef	__cplusplus
68*da14cebeSEric Cheng }
69*da14cebeSEric Cheng #endif
70*da14cebeSEric Cheng 
71*da14cebeSEric Cheng #endif	/* _LIBDLSTAT_H */
72