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 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * This file includes structures, macros and common routines shared by all
31 * data-link administration, and routines which are used to retrieve and
44 #define DLSTAT_INVALID_ENTRY -1
45 #define MAXSTATNAMELEN 256
47 * Definitions common to all stats
49 typedef struct dladm_stat_chain_s
{
50 char dc_statheader
[MAXSTATNAMELEN
];
52 struct dladm_stat_chain_s
*dc_next
;
56 DLADM_STAT_RX_LANE
= 0, /* Per lane rx stats */
57 DLADM_STAT_TX_LANE
, /* Per lane tx stats */
58 DLADM_STAT_RX_LANE_TOTAL
, /* Stats summed across all rx lanes */
59 DLADM_STAT_TX_LANE_TOTAL
, /* Stats summed across all tx lanes */
60 DLADM_STAT_RX_LANE_FOUT
, /* Per fanout (rx lane) stats */
61 DLADM_STAT_RX_RING
, /* Per ring rx stats */
62 DLADM_STAT_TX_RING
, /* Per ring tx stats */
63 DLADM_STAT_RX_RING_TOTAL
, /* Stats summed across all rx rings */
64 DLADM_STAT_TX_RING_TOTAL
, /* Stats summed across all tx rings */
65 DLADM_STAT_TOTAL
, /* Summary view */
66 DLADM_STAT_AGGR_PORT
, /* Aggr port stats */
67 DLADM_STAT_MISC
, /* Misc stats */
68 DLADM_STAT_NUM_STATS
/* This must always be the last entry */
72 * Definitions for rx lane stats
74 typedef struct rx_lane_stat_s
{
77 uint64_t rl_lclpackets
;
80 uint64_t rl_intrbytes
;
81 uint64_t rl_pollbytes
;
98 typedef struct rx_lane_stat_entry_s
{
101 rx_lane_stat_t rle_stats
;
102 } rx_lane_stat_entry_t
;
105 * Definitions for tx lane stats
107 typedef struct tx_lane_stat_s
{
108 uint64_t tl_opackets
;
110 uint64_t tl_blockcnt
;
111 uint64_t tl_unblockcnt
;
115 typedef struct tx_lane_stat_entry_s
{
118 tx_lane_stat_t tle_stats
;
119 } tx_lane_stat_entry_t
;
122 * Definitions for tx/rx misc stats
124 typedef struct misc_stat_s
{
125 uint64_t ms_multircv
;
126 uint64_t ms_brdcstrcv
;
127 uint64_t ms_multixmt
;
128 uint64_t ms_brdcstxmt
;
129 uint64_t ms_multircvbytes
;
130 uint64_t ms_brdcstrcvbytes
;
131 uint64_t ms_multixmtbytes
;
132 uint64_t ms_brdcstxmtbytes
;
133 uint64_t ms_txerrors
;
134 uint64_t ms_macspoofed
;
135 uint64_t ms_ipspoofed
;
136 uint64_t ms_dhcpspoofed
;
137 uint64_t ms_restricted
;
138 uint64_t ms_dhcpdropped
;
139 uint64_t ms_ipackets
;
142 uint64_t ms_localbytes
;
144 uint64_t ms_intrbytes
;
146 uint64_t ms_pollbytes
;
147 uint64_t ms_rxsdrops
;
148 uint64_t ms_chainunder10
;
149 uint64_t ms_chain10to50
;
150 uint64_t ms_chainover50
;
152 uint64_t ms_opackets
;
153 uint64_t ms_blockcnt
;
154 uint64_t ms_unblockcnt
;
155 uint64_t ms_txsdrops
;
159 * To be consistent with other stat entries, misc stat
160 * is wrapped in stat entry
162 typedef struct misc_stat_entry_s
{
163 misc_stat_t mse_stats
;
167 * Definitions for ring stats: used by rx as well as tx
169 typedef struct ring_stat_s
{
174 typedef struct ring_stat_entry_s
{
176 ring_stat_t re_stats
;
180 * Definitions for fanout stats
182 typedef struct fanout_stat_s
{
187 typedef struct fanout_stat_entry_s
{
189 lane_type_t fe_id
; /* hw, sw, local */
190 int64_t fe_foutindex
; /* fanout index */
191 fanout_stat_t fe_stats
;
192 } fanout_stat_entry_t
;
195 * Definitions for total stats
197 typedef struct total_stat_s
{
198 uint64_t ts_ipackets
;
200 uint64_t ts_opackets
;
205 * To be consistent with other stat entries, total stat
206 * is wrapped in stat entry
208 typedef struct total_stat_entry_s
{
209 total_stat_t tse_stats
;
210 } total_stat_entry_t
;
213 * Definitions for aggr stats
215 typedef struct aggr_port_stat_s
{
216 uint64_t ap_ipackets
;
218 uint64_t ap_opackets
;
222 typedef struct aggr_port_stat_entry_s
{
223 datalink_id_t ape_portlinkid
;
224 aggr_port_stat_t ape_stats
;
225 } aggr_port_stat_entry_t
;
228 * Definitions for query all stats
230 typedef struct name_value_stat_s
{
231 char nv_statname
[MAXSTATNAMELEN
];
233 struct name_value_stat_s
*nv_nextstat
;
236 typedef struct name_value_stat_entry_s
{
237 char nve_header
[MAXSTATNAMELEN
];
238 name_value_stat_t
*nve_stats
;
239 } name_value_stat_entry_t
;
242 * Definitions for flow stats
244 typedef struct flow_stat_s
{
245 uint64_t fl_ipackets
;
248 uint64_t fl_opackets
;
254 typedef struct pktsum_s
{
264 extern kstat_t
*dladm_kstat_lookup(kstat_ctl_t
*, const char *, int,
265 const char *, const char *);
266 extern void dladm_get_stats(kstat_ctl_t
*, kstat_t
*, pktsum_t
*);
267 extern int dladm_kstat_value(kstat_t
*, const char *, uint8_t,
269 extern dladm_status_t
dladm_get_single_mac_stat(dladm_handle_t
, datalink_id_t
,
270 const char *, uint8_t, void *);
272 extern void dladm_stats_total(pktsum_t
*, pktsum_t
*, pktsum_t
*);
273 extern void dladm_stats_diff(pktsum_t
*, pktsum_t
*, pktsum_t
*);
275 extern dladm_stat_chain_t
*dladm_link_stat_query(dladm_handle_t
,
276 datalink_id_t
, dladm_stat_type_t
);
277 extern dladm_stat_chain_t
*dladm_link_stat_diffchain(dladm_stat_chain_t
*,
278 dladm_stat_chain_t
*, dladm_stat_type_t
);
279 extern dladm_stat_chain_t
*dladm_link_stat_query_all(dladm_handle_t
,
280 datalink_id_t
, dladm_stat_type_t
);
282 extern flow_stat_t
*dladm_flow_stat_query(const char *);
283 extern flow_stat_t
*dladm_flow_stat_diff(flow_stat_t
*,
285 extern name_value_stat_entry_t
*dladm_flow_stat_query_all(const char *);
291 #endif /* _LIBDLSTAT_H */