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.
27 * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
34 * This file includes structures, macros and common routines shared by all
35 * data-link administration, and routines which are used to retrieve and
48 #define DLSTAT_INVALID_ENTRY -1
49 #define MAXSTATNAMELEN 256
51 * Definitions common to all stats
53 typedef struct dladm_stat_chain_s
{
54 char dc_statheader
[MAXSTATNAMELEN
];
56 struct dladm_stat_chain_s
*dc_next
;
60 DLADM_STAT_RX_LANE
= 0, /* Per lane rx stats */
61 DLADM_STAT_TX_LANE
, /* Per lane tx stats */
62 DLADM_STAT_RX_LANE_TOTAL
, /* Stats summed across all rx lanes */
63 DLADM_STAT_TX_LANE_TOTAL
, /* Stats summed across all tx lanes */
64 DLADM_STAT_RX_LANE_FOUT
, /* Per fanout (rx lane) stats */
65 DLADM_STAT_RX_RING
, /* Per ring rx stats */
66 DLADM_STAT_TX_RING
, /* Per ring tx stats */
67 DLADM_STAT_RX_RING_TOTAL
, /* Stats summed across all rx rings */
68 DLADM_STAT_TX_RING_TOTAL
, /* Stats summed across all tx rings */
69 DLADM_STAT_TOTAL
, /* Summary view */
70 DLADM_STAT_AGGR_PORT
, /* Aggr port stats */
71 DLADM_STAT_MISC
, /* Misc stats */
72 DLADM_STAT_NUM_STATS
/* This must always be the last entry */
76 * Definitions for rx lane stats
78 typedef struct rx_lane_stat_s
{
81 uint64_t rl_lclpackets
;
84 uint64_t rl_intrbytes
;
85 uint64_t rl_pollbytes
;
102 typedef struct rx_lane_stat_entry_s
{
105 rx_lane_stat_t rle_stats
;
106 } rx_lane_stat_entry_t
;
109 * Definitions for tx lane stats
111 typedef struct tx_lane_stat_s
{
112 uint64_t tl_opackets
;
114 uint64_t tl_blockcnt
;
115 uint64_t tl_unblockcnt
;
119 typedef struct tx_lane_stat_entry_s
{
122 tx_lane_stat_t tle_stats
;
123 } tx_lane_stat_entry_t
;
126 * Definitions for tx/rx misc stats
128 typedef struct misc_stat_s
{
129 uint64_t ms_multircv
;
130 uint64_t ms_brdcstrcv
;
131 uint64_t ms_multixmt
;
132 uint64_t ms_brdcstxmt
;
133 uint64_t ms_multircvbytes
;
134 uint64_t ms_brdcstrcvbytes
;
135 uint64_t ms_multixmtbytes
;
136 uint64_t ms_brdcstxmtbytes
;
137 uint64_t ms_txerrors
;
138 uint64_t ms_macspoofed
;
139 uint64_t ms_ipspoofed
;
140 uint64_t ms_dhcpspoofed
;
141 uint64_t ms_restricted
;
142 uint64_t ms_dhcpdropped
;
143 uint64_t ms_ipackets
;
146 uint64_t ms_localbytes
;
148 uint64_t ms_intrbytes
;
150 uint64_t ms_pollbytes
;
151 uint64_t ms_rxsdrops
;
152 uint64_t ms_chainunder10
;
153 uint64_t ms_chain10to50
;
154 uint64_t ms_chainover50
;
156 uint64_t ms_opackets
;
157 uint64_t ms_blockcnt
;
158 uint64_t ms_unblockcnt
;
159 uint64_t ms_txsdrops
;
163 * To be consistent with other stat entries, misc stat
164 * is wrapped in stat entry
166 typedef struct misc_stat_entry_s
{
167 misc_stat_t mse_stats
;
171 * Definitions for ring stats: used by rx as well as tx
173 typedef struct ring_stat_s
{
178 typedef struct ring_stat_entry_s
{
180 ring_stat_t re_stats
;
184 * Definitions for fanout stats
186 typedef struct fanout_stat_s
{
191 typedef struct fanout_stat_entry_s
{
193 lane_type_t fe_id
; /* hw, sw, local */
194 int64_t fe_foutindex
; /* fanout index */
195 fanout_stat_t fe_stats
;
196 } fanout_stat_entry_t
;
199 * Definitions for total stats
201 typedef struct total_stat_s
{
202 uint64_t ts_ipackets
;
204 uint64_t ts_opackets
;
209 * To be consistent with other stat entries, total stat
210 * is wrapped in stat entry
212 typedef struct total_stat_entry_s
{
213 total_stat_t tse_stats
;
214 } total_stat_entry_t
;
217 * Definitions for aggr stats
219 typedef struct aggr_port_stat_s
{
220 uint64_t ap_ipackets
;
222 uint64_t ap_opackets
;
226 typedef struct aggr_port_stat_entry_s
{
227 datalink_id_t ape_portlinkid
;
228 aggr_port_stat_t ape_stats
;
229 } aggr_port_stat_entry_t
;
232 * Definitions for query all stats
234 typedef struct name_value_stat_s
{
235 char nv_statname
[MAXSTATNAMELEN
];
237 struct name_value_stat_s
*nv_nextstat
;
240 typedef struct name_value_stat_entry_s
{
241 char nve_header
[MAXSTATNAMELEN
];
242 name_value_stat_t
*nve_stats
;
243 } name_value_stat_entry_t
;
246 * Definitions for flow stats
248 typedef struct flow_stat_s
{
249 uint64_t fl_ipackets
;
252 uint64_t fl_opackets
;
258 typedef struct pktsum_s
{
268 extern kstat_t
*dladm_kstat_lookup(kstat_ctl_t
*, const char *, int,
269 const char *, const char *);
270 extern void dladm_get_stats(kstat_ctl_t
*, kstat_t
*, pktsum_t
*);
271 extern int dladm_kstat_value(kstat_t
*, const char *, uint8_t,
273 extern dladm_status_t
dladm_get_single_mac_stat(dladm_handle_t
, datalink_id_t
,
274 const char *, uint8_t, void *);
276 extern void dladm_stats_total(pktsum_t
*, pktsum_t
*, pktsum_t
*);
277 extern void dladm_stats_diff(pktsum_t
*, pktsum_t
*, pktsum_t
*);
279 extern dladm_stat_chain_t
*dladm_link_stat_query(dladm_handle_t
,
280 datalink_id_t
, dladm_stat_type_t
);
281 extern dladm_stat_chain_t
*dladm_link_stat_diffchain(dladm_stat_chain_t
*,
282 dladm_stat_chain_t
*, dladm_stat_type_t
);
283 extern dladm_stat_chain_t
*dladm_link_stat_query_all(dladm_handle_t
,
284 datalink_id_t
, dladm_stat_type_t
);
286 extern flow_stat_t
*dladm_flow_stat_query(dladm_handle_t
,
288 extern flow_stat_t
*dladm_flow_stat_diff(flow_stat_t
*,
290 extern name_value_stat_entry_t
*dladm_flow_stat_query_all(dladm_handle_t
,
297 #endif /* _LIBDLSTAT_H */