Print this page
10052 "dladm show-ether" should pick one kstat snapshot and stick with it
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gergo Doma <domag02@gmail.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdladm/common/libdlstat.h
+++ new/usr/src/lib/libdladm/common/libdlstat.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 +/*
27 + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
28 + */
29 +
26 30 #ifndef _LIBDLSTAT_H
27 31 #define _LIBDLSTAT_H
28 32
29 33 /*
30 34 * This file includes structures, macros and common routines shared by all
31 35 * data-link administration, and routines which are used to retrieve and
32 36 * display statistics.
33 37 */
34 38
35 39 #include <kstat.h>
36 40
37 41 #ifdef __cplusplus
38 42 extern "C" {
39 43 #endif
40 44
41 45 #define LINK_REPORT 1
42 46 #define FLOW_REPORT 2
43 47
44 48 #define DLSTAT_INVALID_ENTRY -1
45 49 #define MAXSTATNAMELEN 256
46 50 /*
47 51 * Definitions common to all stats
48 52 */
49 53 typedef struct dladm_stat_chain_s {
50 54 char dc_statheader[MAXSTATNAMELEN];
51 55 void *dc_statentry;
52 56 struct dladm_stat_chain_s *dc_next;
53 57 } dladm_stat_chain_t;
54 58
55 59 typedef enum {
56 60 DLADM_STAT_RX_LANE = 0, /* Per lane rx stats */
57 61 DLADM_STAT_TX_LANE, /* Per lane tx stats */
58 62 DLADM_STAT_RX_LANE_TOTAL, /* Stats summed across all rx lanes */
59 63 DLADM_STAT_TX_LANE_TOTAL, /* Stats summed across all tx lanes */
60 64 DLADM_STAT_RX_LANE_FOUT, /* Per fanout (rx lane) stats */
61 65 DLADM_STAT_RX_RING, /* Per ring rx stats */
62 66 DLADM_STAT_TX_RING, /* Per ring tx stats */
63 67 DLADM_STAT_RX_RING_TOTAL, /* Stats summed across all rx rings */
64 68 DLADM_STAT_TX_RING_TOTAL, /* Stats summed across all tx rings */
65 69 DLADM_STAT_TOTAL, /* Summary view */
66 70 DLADM_STAT_AGGR_PORT, /* Aggr port stats */
67 71 DLADM_STAT_MISC, /* Misc stats */
68 72 DLADM_STAT_NUM_STATS /* This must always be the last entry */
69 73 } dladm_stat_type_t;
70 74
71 75 /*
72 76 * Definitions for rx lane stats
73 77 */
74 78 typedef struct rx_lane_stat_s {
75 79 uint64_t rl_ipackets;
76 80 uint64_t rl_rbytes;
77 81 uint64_t rl_lclpackets;
78 82 uint64_t rl_lclbytes;
79 83 uint64_t rl_intrs;
80 84 uint64_t rl_intrbytes;
81 85 uint64_t rl_pollbytes;
82 86 uint64_t rl_polls;
83 87 uint64_t rl_sdrops;
84 88 uint64_t rl_chl10;
85 89 uint64_t rl_ch10_50;
86 90 uint64_t rl_chg50;
87 91 } rx_lane_stat_t;
88 92
89 93 typedef enum {
90 94 L_HWLANE,
91 95 L_SWLANE,
92 96 L_LOCAL,
93 97 L_LCLSWLANE,
94 98 L_BCAST,
95 99 L_DFNCT
96 100 } lane_type_t;
97 101
98 102 typedef struct rx_lane_stat_entry_s {
99 103 int64_t rle_index;
100 104 lane_type_t rle_id;
101 105 rx_lane_stat_t rle_stats;
102 106 } rx_lane_stat_entry_t;
103 107
104 108 /*
105 109 * Definitions for tx lane stats
106 110 */
107 111 typedef struct tx_lane_stat_s {
108 112 uint64_t tl_opackets;
109 113 uint64_t tl_obytes;
110 114 uint64_t tl_blockcnt;
111 115 uint64_t tl_unblockcnt;
112 116 uint64_t tl_sdrops;
113 117 } tx_lane_stat_t;
114 118
115 119 typedef struct tx_lane_stat_entry_s {
116 120 int64_t tle_index;
117 121 lane_type_t tle_id;
118 122 tx_lane_stat_t tle_stats;
119 123 } tx_lane_stat_entry_t;
120 124
121 125 /*
122 126 * Definitions for tx/rx misc stats
123 127 */
124 128 typedef struct misc_stat_s {
125 129 uint64_t ms_multircv;
126 130 uint64_t ms_brdcstrcv;
127 131 uint64_t ms_multixmt;
128 132 uint64_t ms_brdcstxmt;
129 133 uint64_t ms_multircvbytes;
130 134 uint64_t ms_brdcstrcvbytes;
131 135 uint64_t ms_multixmtbytes;
132 136 uint64_t ms_brdcstxmtbytes;
133 137 uint64_t ms_txerrors;
134 138 uint64_t ms_macspoofed;
135 139 uint64_t ms_ipspoofed;
136 140 uint64_t ms_dhcpspoofed;
137 141 uint64_t ms_restricted;
138 142 uint64_t ms_dhcpdropped;
139 143 uint64_t ms_ipackets;
140 144 uint64_t ms_rbytes;
141 145 uint64_t ms_local;
142 146 uint64_t ms_localbytes;
143 147 uint64_t ms_intrs;
144 148 uint64_t ms_intrbytes;
145 149 uint64_t ms_polls;
146 150 uint64_t ms_pollbytes;
147 151 uint64_t ms_rxsdrops;
148 152 uint64_t ms_chainunder10;
149 153 uint64_t ms_chain10to50;
150 154 uint64_t ms_chainover50;
151 155 uint64_t ms_obytes;
152 156 uint64_t ms_opackets;
153 157 uint64_t ms_blockcnt;
154 158 uint64_t ms_unblockcnt;
155 159 uint64_t ms_txsdrops;
156 160 } misc_stat_t;
157 161
158 162 /*
159 163 * To be consistent with other stat entries, misc stat
160 164 * is wrapped in stat entry
161 165 */
162 166 typedef struct misc_stat_entry_s {
163 167 misc_stat_t mse_stats;
164 168 } misc_stat_entry_t;
165 169
166 170 /*
167 171 * Definitions for ring stats: used by rx as well as tx
168 172 */
169 173 typedef struct ring_stat_s {
170 174 uint64_t r_packets;
171 175 uint64_t r_bytes;
172 176 } ring_stat_t;
173 177
174 178 typedef struct ring_stat_entry_s {
175 179 int64_t re_index;
176 180 ring_stat_t re_stats;
177 181 } ring_stat_entry_t;
178 182
179 183 /*
180 184 * Definitions for fanout stats
181 185 */
182 186 typedef struct fanout_stat_s {
183 187 uint64_t f_ipackets;
184 188 uint64_t f_rbytes;
185 189 } fanout_stat_t;
186 190
187 191 typedef struct fanout_stat_entry_s {
188 192 int64_t fe_index;
189 193 lane_type_t fe_id; /* hw, sw, local */
190 194 int64_t fe_foutindex; /* fanout index */
191 195 fanout_stat_t fe_stats;
192 196 } fanout_stat_entry_t;
193 197
194 198 /*
195 199 * Definitions for total stats
196 200 */
197 201 typedef struct total_stat_s {
198 202 uint64_t ts_ipackets;
199 203 uint64_t ts_rbytes;
200 204 uint64_t ts_opackets;
201 205 uint64_t ts_obytes;
202 206 } total_stat_t;
203 207
204 208 /*
205 209 * To be consistent with other stat entries, total stat
206 210 * is wrapped in stat entry
207 211 */
208 212 typedef struct total_stat_entry_s {
209 213 total_stat_t tse_stats;
210 214 } total_stat_entry_t;
211 215
212 216 /*
213 217 * Definitions for aggr stats
214 218 */
215 219 typedef struct aggr_port_stat_s {
216 220 uint64_t ap_ipackets;
217 221 uint64_t ap_rbytes;
218 222 uint64_t ap_opackets;
219 223 uint64_t ap_obytes;
220 224 } aggr_port_stat_t;
221 225
222 226 typedef struct aggr_port_stat_entry_s {
223 227 datalink_id_t ape_portlinkid;
224 228 aggr_port_stat_t ape_stats;
225 229 } aggr_port_stat_entry_t;
226 230
227 231 /*
228 232 * Definitions for query all stats
229 233 */
230 234 typedef struct name_value_stat_s {
231 235 char nv_statname[MAXSTATNAMELEN];
232 236 uint64_t nv_statval;
233 237 struct name_value_stat_s *nv_nextstat;
234 238 } name_value_stat_t;
235 239
236 240 typedef struct name_value_stat_entry_s {
237 241 char nve_header[MAXSTATNAMELEN];
238 242 name_value_stat_t *nve_stats;
239 243 } name_value_stat_entry_t;
240 244
241 245 /*
242 246 * Definitions for flow stats
243 247 */
244 248 typedef struct flow_stat_s {
245 249 uint64_t fl_ipackets;
246 250 uint64_t fl_rbytes;
247 251 uint64_t fl_ierrors;
248 252 uint64_t fl_opackets;
249 253 uint64_t fl_obytes;
250 254 uint64_t fl_oerrors;
251 255 uint64_t fl_sdrops;
252 256 } flow_stat_t;
253 257
254 258 typedef struct pktsum_s {
255 259 hrtime_t snaptime;
256 260 uint64_t ipackets;
257 261 uint64_t opackets;
258 262 uint64_t rbytes;
259 263 uint64_t obytes;
260 264 uint64_t ierrors;
261 265 uint64_t oerrors;
262 266 } pktsum_t;
263 267
264 268 extern kstat_t *dladm_kstat_lookup(kstat_ctl_t *, const char *, int,
265 269 const char *, const char *);
266 270 extern void dladm_get_stats(kstat_ctl_t *, kstat_t *, pktsum_t *);
267 271 extern int dladm_kstat_value(kstat_t *, const char *, uint8_t,
268 272 void *);
269 273 extern dladm_status_t dladm_get_single_mac_stat(dladm_handle_t, datalink_id_t,
270 274 const char *, uint8_t, void *);
271 275
↓ open down ↓ |
236 lines elided |
↑ open up ↑ |
272 276 extern void dladm_stats_total(pktsum_t *, pktsum_t *, pktsum_t *);
273 277 extern void dladm_stats_diff(pktsum_t *, pktsum_t *, pktsum_t *);
274 278
275 279 extern dladm_stat_chain_t *dladm_link_stat_query(dladm_handle_t,
276 280 datalink_id_t, dladm_stat_type_t);
277 281 extern dladm_stat_chain_t *dladm_link_stat_diffchain(dladm_stat_chain_t *,
278 282 dladm_stat_chain_t *, dladm_stat_type_t);
279 283 extern dladm_stat_chain_t *dladm_link_stat_query_all(dladm_handle_t,
280 284 datalink_id_t, dladm_stat_type_t);
281 285
282 -extern flow_stat_t *dladm_flow_stat_query(const char *);
286 +extern flow_stat_t *dladm_flow_stat_query(dladm_handle_t,
287 + const char *);
283 288 extern flow_stat_t *dladm_flow_stat_diff(flow_stat_t *,
284 289 flow_stat_t *);
285 -extern name_value_stat_entry_t *dladm_flow_stat_query_all(const char *);
290 +extern name_value_stat_entry_t *dladm_flow_stat_query_all(dladm_handle_t,
291 + const char *);
286 292
287 293 #ifdef __cplusplus
288 294 }
289 295 #endif
290 296
291 297 #endif /* _LIBDLSTAT_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX