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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
28 #include <sys/dls_mgmt.h>
31 #include <libnvpair.h>
34 * This file includes structures, macros and common routines shared by all
35 * data-link administration, and routines which do not directly administrate
36 * links. For example, dladm_status2str().
43 #define LINKID_STR_WIDTH 10
44 #define DLADM_STRSIZE 256
47 * option flags taken by the libdladm functions
50 * The function requests to bringup some configuration that only take
51 * effect on active system (not persistent).
53 * - DLADM_OPT_PERSIST:
54 * The function requests to persist some configuration.
57 * Today, only used by dladm_set_secobj() - requests to create a secobj.
60 * The function requests to execute a specific operation forcefully.
63 * The function requests to generate a link name using the specified prefix.
66 * Signifies VLAN creation code path
68 * - DLADM_OPT_NOREFRESH:
69 * Do not refresh the daemon after setting parameter (used by STP mcheck).
72 * Bypass check functions during boot (used by pool property since pools
73 * can come up after link properties are set)
75 #define DLADM_OPT_ACTIVE 0x00000001
76 #define DLADM_OPT_PERSIST 0x00000002
77 #define DLADM_OPT_CREATE 0x00000004
78 #define DLADM_OPT_FORCE 0x00000008
79 #define DLADM_OPT_PREFIX 0x00000010
80 #define DLADM_OPT_ANCHOR 0x00000020
81 #define DLADM_OPT_VLAN 0x00000040
82 #define DLADM_OPT_NOREFRESH 0x00000080
83 #define DLADM_OPT_BOOT 0x00000100
85 #define DLADM_WALK_TERMINATE 0
86 #define DLADM_WALK_CONTINUE -1
88 #define DLADM_MAX_ARG_CNT 32
89 #define DLADM_MAX_ARG_VALS 64
95 DLADM_STATUS_TOOSMALL
,
97 DLADM_STATUS_NOTFOUND
,
101 DLADM_STATUS_LINKINVAL
,
102 DLADM_STATUS_PROPRDONLY
,
103 DLADM_STATUS_BADVALCNT
,
104 DLADM_STATUS_DBNOTFOUND
,
107 DLADM_STATUS_TEMPONLY
,
108 DLADM_STATUS_TIMEDOUT
,
110 DLADM_STATUS_NOTCONN
,
111 DLADM_STATUS_REPOSITORYINVAL
,
112 DLADM_STATUS_MACADDRINVAL
,
113 DLADM_STATUS_KEYINVAL
,
114 DLADM_STATUS_INVALIDMACADDRLEN
,
115 DLADM_STATUS_INVALIDMACADDRTYPE
,
116 DLADM_STATUS_LINKBUSY
,
117 DLADM_STATUS_VIDINVAL
,
118 DLADM_STATUS_NONOTIF
,
119 DLADM_STATUS_TRYAGAIN
,
120 DLADM_STATUS_IPTUNTYPE
,
121 DLADM_STATUS_IPTUNTYPEREQD
,
122 DLADM_STATUS_BADIPTUNLADDR
,
123 DLADM_STATUS_BADIPTUNRADDR
,
124 DLADM_STATUS_ADDRINUSE
,
125 DLADM_STATUS_BADTIMEVAL
,
126 DLADM_STATUS_INVALIDMACADDR
,
127 DLADM_STATUS_INVALIDMACADDRNIC
,
128 DLADM_STATUS_INVALIDMACADDRINUSE
,
129 DLADM_STATUS_MACFACTORYSLOTINVALID
,
130 DLADM_STATUS_MACFACTORYSLOTUSED
,
131 DLADM_STATUS_MACFACTORYSLOTALLUSED
,
132 DLADM_STATUS_MACFACTORYNOTSUP
,
133 DLADM_STATUS_INVALIDMACPREFIX
,
134 DLADM_STATUS_INVALIDMACPREFIXLEN
,
135 DLADM_STATUS_BADCPUID
,
137 DLADM_STATUS_CPUNOTONLINE
,
138 DLADM_STATUS_BADRANGE
,
139 DLADM_STATUS_TOOMANYELEMENTS
,
140 DLADM_STATUS_DB_NOTFOUND
,
141 DLADM_STATUS_DB_PARSE_ERR
,
142 DLADM_STATUS_PROP_PARSE_ERR
,
143 DLADM_STATUS_ATTR_PARSE_ERR
,
144 DLADM_STATUS_FLOW_DB_ERR
,
145 DLADM_STATUS_FLOW_DB_OPEN_ERR
,
146 DLADM_STATUS_FLOW_DB_PARSE_ERR
,
147 DLADM_STATUS_FLOWPROP_DB_PARSE_ERR
,
148 DLADM_STATUS_FLOW_ADD_ERR
,
149 DLADM_STATUS_FLOW_WALK_ERR
,
150 DLADM_STATUS_FLOW_IDENTICAL
,
151 DLADM_STATUS_FLOW_INCOMPATIBLE
,
152 DLADM_STATUS_FLOW_EXISTS
,
153 DLADM_STATUS_PERSIST_FLOW_EXISTS
,
154 DLADM_STATUS_INVALID_IP
,
155 DLADM_STATUS_INVALID_PREFIXLEN
,
156 DLADM_STATUS_INVALID_PROTOCOL
,
157 DLADM_STATUS_INVALID_PORT
,
158 DLADM_STATUS_INVALID_DSF
,
159 DLADM_STATUS_INVALID_DSFMASK
,
160 DLADM_STATUS_INVALID_MACMARGIN
,
161 DLADM_STATUS_NOTDEFINED
,
162 DLADM_STATUS_BADPROP
,
163 DLADM_STATUS_MINMAXBW
,
164 DLADM_STATUS_NO_HWRINGS
,
165 DLADM_STATUS_PERMONLY
,
166 DLADM_STATUS_OPTMISSING
,
167 DLADM_STATUS_POOLCPU
,
168 DLADM_STATUS_INVALID_PORT_INSTANCE
,
169 DLADM_STATUS_PORT_IS_DOWN
,
170 DLADM_STATUS_PKEY_NOT_PRESENT
,
171 DLADM_STATUS_PARTITION_EXISTS
,
172 DLADM_STATUS_INVALID_PKEY
,
173 DLADM_STATUS_NO_IB_HW_RESOURCE
,
174 DLADM_STATUS_INVALID_PKEY_TBL_SIZE
,
175 DLADM_STATUS_PORT_NOPROTO
,
176 DLADM_STATUS_INVALID_MTU
186 boolean_t ds_readonly
;
193 #define ds_confid ds_u.dsu_confid
194 #define ds_nvl ds_u.dsu_nvl
196 #define DLADM_INVALID_CONF 0
198 /* opaque dladm handle to libdladm functions */
200 typedef struct dladm_handle
*dladm_handle_t
;
202 /* open/close handle */
203 extern dladm_status_t
dladm_open(dladm_handle_t
*);
204 extern void dladm_close(dladm_handle_t
);
207 * retrieve the dld file descriptor from handle, only libdladm and
208 * dlmgmtd are given access to the door file descriptor.
210 extern int dladm_dld_fd(dladm_handle_t
);
212 typedef struct dladm_arg_info
{
214 char *ai_val
[DLADM_MAX_ARG_VALS
];
218 typedef struct dladm_arg_list
{
219 dladm_arg_info_t al_info
[DLADM_MAX_ARG_CNT
];
225 DLADM_LOGTYPE_LINK
= 1,
229 typedef struct dladm_usage
{
230 char du_name
[MAXLINKNAMELEN
];
231 uint64_t du_duration
;
234 uint64_t du_ipackets
;
236 uint64_t du_opackets
;
238 uint64_t du_bandwidth
;
242 extern const char *dladm_status2str(dladm_status_t
, char *);
243 extern dladm_status_t
dladm_set_rootdir(const char *);
244 extern const char *dladm_class2str(datalink_class_t
, char *);
245 extern const char *dladm_media2str(uint32_t, char *);
246 extern uint32_t dladm_str2media(const char *);
247 extern boolean_t
dladm_valid_linkname(const char *);
248 extern boolean_t
dladm_str2interval(char *, uint32_t *);
249 extern dladm_status_t
dladm_str2bw(char *, uint64_t *);
250 extern const char *dladm_bw2str(int64_t, char *);
251 extern dladm_status_t
dladm_str2pri(char *, mac_priority_level_t
*);
252 extern const char *dladm_pri2str(mac_priority_level_t
, char *);
253 extern dladm_status_t
dladm_str2protect(char *, uint32_t *);
254 extern const char *dladm_protect2str(uint32_t, char *);
255 extern dladm_status_t
dladm_str2ipv4addr(char *, void *);
256 extern const char *dladm_ipv4addr2str(void *, char *);
257 extern dladm_status_t
dladm_str2ipv6addr(char *, void *);
258 extern const char *dladm_ipv6addr2str(void *, char *);
260 extern dladm_status_t
dladm_parse_flow_props(char *, dladm_arg_list_t
**,
262 extern dladm_status_t
dladm_parse_link_props(char *, dladm_arg_list_t
**,
264 extern void dladm_free_props(dladm_arg_list_t
*);
265 extern dladm_status_t
dladm_parse_flow_attrs(char *, dladm_arg_list_t
**,
267 extern void dladm_free_attrs(dladm_arg_list_t
*);
269 extern dladm_status_t
dladm_start_usagelog(dladm_handle_t
, dladm_logtype_t
,
271 extern dladm_status_t
dladm_stop_usagelog(dladm_handle_t
, dladm_logtype_t
);
272 extern dladm_status_t
dladm_walk_usage_res(int (*)(dladm_usage_t
*, void *),
273 int, char *, char *, char *, char *, void *);
274 extern dladm_status_t
dladm_walk_usage_time(int (*)(dladm_usage_t
*, void *),
275 int, char *, char *, char *, void *);
276 extern dladm_status_t
dladm_usage_summary(int (*)(dladm_usage_t
*, void *),
277 int, char *, void *);
278 extern dladm_status_t
dladm_usage_dates(int (*)(dladm_usage_t
*, void *),
279 int, char *, char *, void *);
280 extern dladm_status_t
dladm_zone_boot(dladm_handle_t
, zoneid_t
);
281 extern dladm_status_t
dladm_zone_halt(dladm_handle_t
, zoneid_t
);
283 extern dladm_status_t
dladm_strs2range(char **, uint_t
, mac_propval_type_t
,
284 mac_propval_range_t
**);
285 extern dladm_status_t
dladm_range2list(mac_propval_range_t
*, void*,
287 extern int dladm_range2strs(mac_propval_range_t
*, char **);
288 extern dladm_status_t
dladm_list2range(void *, uint_t
, mac_propval_type_t
,
289 mac_propval_range_t
**);
295 #endif /* _LIBDLADM_H */