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/libdladm.h
+++ new/usr/src/lib/libdladm/common/libdladm.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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 +/*
26 + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association
27 + */
28 +
25 29 #ifndef _LIBDLADM_H
26 30 #define _LIBDLADM_H
27 31
28 32 #include <sys/dls_mgmt.h>
29 33 #include <sys/dld.h>
30 34 #include <sys/dlpi.h>
31 35 #include <libnvpair.h>
36 +#include <kstat.h>
32 37
33 38 /*
34 39 * This file includes structures, macros and common routines shared by all
35 40 * data-link administration, and routines which do not directly administrate
36 41 * links. For example, dladm_status2str().
37 42 */
38 43
39 44 #ifdef __cplusplus
40 45 extern "C" {
41 46 #endif
42 47
43 48 #define LINKID_STR_WIDTH 10
44 49 #define DLADM_STRSIZE 256
45 50
46 51 /*
47 52 * option flags taken by the libdladm functions
48 53 *
49 54 * - DLADM_OPT_ACTIVE:
50 55 * The function requests to bringup some configuration that only take
51 56 * effect on active system (not persistent).
52 57 *
53 58 * - DLADM_OPT_PERSIST:
54 59 * The function requests to persist some configuration.
55 60 *
56 61 * - DLADM_OPT_CREATE:
57 62 * Today, only used by dladm_set_secobj() - requests to create a secobj.
58 63 *
59 64 * - DLADM_OPT_FORCE:
60 65 * The function requests to execute a specific operation forcefully.
61 66 *
62 67 * - DLADM_OPT_PREFIX:
63 68 * The function requests to generate a link name using the specified prefix.
64 69 *
65 70 * - DLADM_OPT_VLAN:
66 71 * Signifies VLAN creation code path
67 72 *
68 73 * - DLADM_OPT_NOREFRESH:
69 74 * Do not refresh the daemon after setting parameter (used by STP mcheck).
70 75 *
71 76 * - DLADM_OPT_BOOT:
72 77 * Bypass check functions during boot (used by pool property since pools
73 78 * can come up after link properties are set)
74 79 */
75 80 #define DLADM_OPT_ACTIVE 0x00000001
76 81 #define DLADM_OPT_PERSIST 0x00000002
77 82 #define DLADM_OPT_CREATE 0x00000004
78 83 #define DLADM_OPT_FORCE 0x00000008
79 84 #define DLADM_OPT_PREFIX 0x00000010
80 85 #define DLADM_OPT_ANCHOR 0x00000020
81 86 #define DLADM_OPT_VLAN 0x00000040
82 87 #define DLADM_OPT_NOREFRESH 0x00000080
83 88 #define DLADM_OPT_BOOT 0x00000100
84 89
85 90 #define DLADM_WALK_TERMINATE 0
86 91 #define DLADM_WALK_CONTINUE -1
87 92
88 93 #define DLADM_MAX_ARG_CNT 32
89 94 #define DLADM_MAX_ARG_VALS 64
90 95
91 96 typedef enum {
92 97 DLADM_STATUS_OK = 0,
93 98 DLADM_STATUS_BADARG,
94 99 DLADM_STATUS_FAILED,
95 100 DLADM_STATUS_TOOSMALL,
96 101 DLADM_STATUS_NOTSUP,
97 102 DLADM_STATUS_NOTFOUND,
98 103 DLADM_STATUS_BADVAL,
99 104 DLADM_STATUS_NOMEM,
100 105 DLADM_STATUS_EXIST,
101 106 DLADM_STATUS_LINKINVAL,
102 107 DLADM_STATUS_PROPRDONLY,
103 108 DLADM_STATUS_BADVALCNT,
104 109 DLADM_STATUS_DBNOTFOUND,
105 110 DLADM_STATUS_DENIED,
106 111 DLADM_STATUS_IOERR,
107 112 DLADM_STATUS_TEMPONLY,
108 113 DLADM_STATUS_TIMEDOUT,
109 114 DLADM_STATUS_ISCONN,
110 115 DLADM_STATUS_NOTCONN,
111 116 DLADM_STATUS_REPOSITORYINVAL,
112 117 DLADM_STATUS_MACADDRINVAL,
113 118 DLADM_STATUS_KEYINVAL,
114 119 DLADM_STATUS_INVALIDMACADDRLEN,
115 120 DLADM_STATUS_INVALIDMACADDRTYPE,
116 121 DLADM_STATUS_LINKBUSY,
117 122 DLADM_STATUS_VIDINVAL,
118 123 DLADM_STATUS_NONOTIF,
119 124 DLADM_STATUS_TRYAGAIN,
120 125 DLADM_STATUS_IPTUNTYPE,
121 126 DLADM_STATUS_IPTUNTYPEREQD,
122 127 DLADM_STATUS_BADIPTUNLADDR,
123 128 DLADM_STATUS_BADIPTUNRADDR,
124 129 DLADM_STATUS_ADDRINUSE,
125 130 DLADM_STATUS_BADTIMEVAL,
126 131 DLADM_STATUS_INVALIDMACADDR,
127 132 DLADM_STATUS_INVALIDMACADDRNIC,
128 133 DLADM_STATUS_INVALIDMACADDRINUSE,
129 134 DLADM_STATUS_MACFACTORYSLOTINVALID,
130 135 DLADM_STATUS_MACFACTORYSLOTUSED,
131 136 DLADM_STATUS_MACFACTORYSLOTALLUSED,
132 137 DLADM_STATUS_MACFACTORYNOTSUP,
133 138 DLADM_STATUS_INVALIDMACPREFIX,
134 139 DLADM_STATUS_INVALIDMACPREFIXLEN,
135 140 DLADM_STATUS_BADCPUID,
136 141 DLADM_STATUS_CPUERR,
137 142 DLADM_STATUS_CPUNOTONLINE,
138 143 DLADM_STATUS_BADRANGE,
139 144 DLADM_STATUS_TOOMANYELEMENTS,
140 145 DLADM_STATUS_DB_NOTFOUND,
141 146 DLADM_STATUS_DB_PARSE_ERR,
142 147 DLADM_STATUS_PROP_PARSE_ERR,
143 148 DLADM_STATUS_ATTR_PARSE_ERR,
144 149 DLADM_STATUS_FLOW_DB_ERR,
145 150 DLADM_STATUS_FLOW_DB_OPEN_ERR,
146 151 DLADM_STATUS_FLOW_DB_PARSE_ERR,
147 152 DLADM_STATUS_FLOWPROP_DB_PARSE_ERR,
148 153 DLADM_STATUS_FLOW_ADD_ERR,
149 154 DLADM_STATUS_FLOW_WALK_ERR,
150 155 DLADM_STATUS_FLOW_IDENTICAL,
151 156 DLADM_STATUS_FLOW_INCOMPATIBLE,
152 157 DLADM_STATUS_FLOW_EXISTS,
153 158 DLADM_STATUS_PERSIST_FLOW_EXISTS,
154 159 DLADM_STATUS_INVALID_IP,
155 160 DLADM_STATUS_INVALID_PREFIXLEN,
156 161 DLADM_STATUS_INVALID_PROTOCOL,
157 162 DLADM_STATUS_INVALID_PORT,
158 163 DLADM_STATUS_INVALID_DSF,
159 164 DLADM_STATUS_INVALID_DSFMASK,
160 165 DLADM_STATUS_INVALID_MACMARGIN,
161 166 DLADM_STATUS_NOTDEFINED,
162 167 DLADM_STATUS_BADPROP,
163 168 DLADM_STATUS_MINMAXBW,
164 169 DLADM_STATUS_NO_HWRINGS,
165 170 DLADM_STATUS_PERMONLY,
166 171 DLADM_STATUS_OPTMISSING,
167 172 DLADM_STATUS_POOLCPU,
168 173 DLADM_STATUS_INVALID_PORT_INSTANCE,
169 174 DLADM_STATUS_PORT_IS_DOWN,
170 175 DLADM_STATUS_PKEY_NOT_PRESENT,
171 176 DLADM_STATUS_PARTITION_EXISTS,
172 177 DLADM_STATUS_INVALID_PKEY,
173 178 DLADM_STATUS_NO_IB_HW_RESOURCE,
174 179 DLADM_STATUS_INVALID_PKEY_TBL_SIZE,
175 180 DLADM_STATUS_PORT_NOPROTO,
176 181 DLADM_STATUS_INVALID_MTU
177 182 } dladm_status_t;
178 183
179 184 typedef enum {
180 185 DLADM_TYPE_STR,
181 186 DLADM_TYPE_BOOLEAN,
182 187 DLADM_TYPE_UINT64
183 188 } dladm_datatype_t;
184 189
185 190 typedef struct {
186 191 boolean_t ds_readonly;
187 192 union {
188 193 int dsu_confid;
189 194 nvlist_t *dsu_nvl;
190 195 } ds_u;
191 196 } dladm_conf_t;
192 197
193 198 #define ds_confid ds_u.dsu_confid
194 199 #define ds_nvl ds_u.dsu_nvl
195 200
196 201 #define DLADM_INVALID_CONF 0
197 202
198 203 /* opaque dladm handle to libdladm functions */
199 204 struct dladm_handle;
200 205 typedef struct dladm_handle *dladm_handle_t;
↓ open down ↓ |
159 lines elided |
↑ open up ↑ |
201 206
202 207 /* open/close handle */
203 208 extern dladm_status_t dladm_open(dladm_handle_t *);
204 209 extern void dladm_close(dladm_handle_t);
205 210
206 211 /*
207 212 * retrieve the dld file descriptor from handle, only libdladm and
208 213 * dlmgmtd are given access to the door file descriptor.
209 214 */
210 215 extern int dladm_dld_fd(dladm_handle_t);
216 +/*
217 + * Retrieve kstat_ctl_t* from handle.The libkstat handle is opened
218 + * when the first caller needs it.This allows the library to share
219 + * the kstat handle.
220 + */
221 +extern kstat_ctl_t *dladm_dld_kcp(dladm_handle_t);
211 222
212 223 typedef struct dladm_arg_info {
213 224 const char *ai_name;
214 225 char *ai_val[DLADM_MAX_ARG_VALS];
215 226 uint_t ai_count;
216 227 } dladm_arg_info_t;
217 228
218 229 typedef struct dladm_arg_list {
219 230 dladm_arg_info_t al_info[DLADM_MAX_ARG_CNT];
220 231 uint_t al_count;
221 232 char *al_buf;
222 233 } dladm_arg_list_t;
223 234
224 235 typedef enum {
225 236 DLADM_LOGTYPE_LINK = 1,
226 237 DLADM_LOGTYPE_FLOW
227 238 } dladm_logtype_t;
228 239
229 240 typedef struct dladm_usage {
230 241 char du_name[MAXLINKNAMELEN];
231 242 uint64_t du_duration;
232 243 uint64_t du_stime;
233 244 uint64_t du_etime;
234 245 uint64_t du_ipackets;
235 246 uint64_t du_rbytes;
236 247 uint64_t du_opackets;
237 248 uint64_t du_obytes;
238 249 uint64_t du_bandwidth;
239 250 boolean_t du_last;
240 251 } dladm_usage_t;
241 252
242 253 extern const char *dladm_status2str(dladm_status_t, char *);
243 254 extern dladm_status_t dladm_set_rootdir(const char *);
244 255 extern const char *dladm_class2str(datalink_class_t, char *);
245 256 extern const char *dladm_media2str(uint32_t, char *);
246 257 extern uint32_t dladm_str2media(const char *);
247 258 extern boolean_t dladm_valid_linkname(const char *);
248 259 extern boolean_t dladm_str2interval(char *, uint32_t *);
249 260 extern dladm_status_t dladm_str2bw(char *, uint64_t *);
250 261 extern const char *dladm_bw2str(int64_t, char *);
251 262 extern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *);
252 263 extern const char *dladm_pri2str(mac_priority_level_t, char *);
253 264 extern dladm_status_t dladm_str2protect(char *, uint32_t *);
254 265 extern const char *dladm_protect2str(uint32_t, char *);
255 266 extern dladm_status_t dladm_str2ipv4addr(char *, void *);
256 267 extern const char *dladm_ipv4addr2str(void *, char *);
257 268 extern dladm_status_t dladm_str2ipv6addr(char *, void *);
258 269 extern const char *dladm_ipv6addr2str(void *, char *);
259 270
260 271 extern dladm_status_t dladm_parse_flow_props(char *, dladm_arg_list_t **,
261 272 boolean_t);
262 273 extern dladm_status_t dladm_parse_link_props(char *, dladm_arg_list_t **,
263 274 boolean_t);
264 275 extern void dladm_free_props(dladm_arg_list_t *);
265 276 extern dladm_status_t dladm_parse_flow_attrs(char *, dladm_arg_list_t **,
266 277 boolean_t);
267 278 extern void dladm_free_attrs(dladm_arg_list_t *);
268 279
269 280 extern dladm_status_t dladm_start_usagelog(dladm_handle_t, dladm_logtype_t,
270 281 uint_t);
271 282 extern dladm_status_t dladm_stop_usagelog(dladm_handle_t, dladm_logtype_t);
272 283 extern dladm_status_t dladm_walk_usage_res(int (*)(dladm_usage_t *, void *),
273 284 int, char *, char *, char *, char *, void *);
274 285 extern dladm_status_t dladm_walk_usage_time(int (*)(dladm_usage_t *, void *),
275 286 int, char *, char *, char *, void *);
276 287 extern dladm_status_t dladm_usage_summary(int (*)(dladm_usage_t *, void *),
277 288 int, char *, void *);
278 289 extern dladm_status_t dladm_usage_dates(int (*)(dladm_usage_t *, void *),
279 290 int, char *, char *, void *);
280 291 extern dladm_status_t dladm_zone_boot(dladm_handle_t, zoneid_t);
281 292 extern dladm_status_t dladm_zone_halt(dladm_handle_t, zoneid_t);
282 293
283 294 extern dladm_status_t dladm_strs2range(char **, uint_t, mac_propval_type_t,
284 295 mac_propval_range_t **);
285 296 extern dladm_status_t dladm_range2list(mac_propval_range_t *, void*,
286 297 uint_t *);
287 298 extern int dladm_range2strs(mac_propval_range_t *, char **);
288 299 extern dladm_status_t dladm_list2range(void *, uint_t, mac_propval_type_t,
289 300 mac_propval_range_t **);
290 301
291 302 #ifdef __cplusplus
292 303 }
293 304 #endif
294 305
295 306 #endif /* _LIBDLADM_H */
↓ open down ↓ |
75 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX