| Current File : //usr/include/libdladm.h |
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _LIBDLADM_H
#define _LIBDLADM_H
#include <sys/dls_mgmt.h>
#include <sys/dld.h>
#include <sys/dlpi.h>
#include <libnvpair.h>
#include <kstat.h>
/*
* This file includes structures, macros and common routines shared by all
* data-link administration, and routines which do not directly administrate
* links. For example, dladm_status2str().
*/
#ifdef __cplusplus
extern "C" {
#endif
#define LINKID_STR_WIDTH 10
#define DLADM_STRSIZE 1024
/*
* option flags taken by the libdladm functions
*
* - DLADM_OPT_ACTIVE:
* The function requests to bringup some configuration that only take
* effect on active system (not persistent).
*
* - DLADM_OPT_PERSIST:
* The function requests to persist some configuration.
*
* - DLADM_OPT_CREATE:
* Today, only used by dladm_set_secobj() - requests to create a secobj.
*
* - DLADM_OPT_FORCE:
* The function requests to execute a specific operation forcefully.
*
* - DLADM_OPT_PREFIX:
* The function requests to generate a link name using the specified prefix.
*
* - DLADM_OPT_VLAN:
* Signifies VLAN creation code path
*
* - DLADM_OPT_NOREFRESH:
* Do not refresh the daemon after setting parameter (used by STP mcheck).
*
* - DLADM_OPT_BOOT:
* Bypass check functions during boot (used by pool property since pools
* can come up after link properties are set)
*
* - DLADM_OPT_ALLZONES:
* Bypass zone check and return results from all zones when requested from
* the global zone.
*
* - DLADM_OPT_ONLOAN:
* Signifies datalink was created in the global zone and is currently
* assigned to a non-global zone.
*
* - DLADM_OPT_ANET:
* Signifies an anet datalink. It can be created by zoneadmd or by using
* the <zonename>/<linkname> format with dladm(1M). anets have the special
* property of being created in the global zone but are not visible in the
* global zone (they are always assigned to a non-global zone). anets are
* distinguished by having "onloan = B_FALSE" and "owner_zoneid != zoneid"
* (also called target_zoneid).
*
* - DLADM_OPT_EFFECTIVE:
* Retrieve the effective value of a given property. In some cases this
* flag requests to change the effective value of a property, while leaving
* the current value of configuration as-is.
*
* - DLADM_OPT_ETHERSTUB:
* Signifies etherstub code path.
*
* - DLADM_OPT_EVSVNIC:
* Signifies that the VNIC is connected to an elastic virtual switch
*
* - DLADM_OPT_SYSLINK:
* Signifies that the datalink was created by the system, and users can't
* delete or manage this datalink like they do for their datalinks.
*
* - DLADM_OPT_NONAMECHECK:
* Skip the link name check when create the link - allow '-' in the link
* name even for the non-syslink.
*
* - DLADM_OPT_AUTO_ORIGIN:
* Signifies that the random/factory MAC address was originally generated
* from the auto type.
*/
#define DLADM_OPT_ACTIVE 0x00000001
#define DLADM_OPT_PERSIST 0x00000002
#define DLADM_OPT_CREATE 0x00000004
#define DLADM_OPT_FORCE 0x00000008
#define DLADM_OPT_PREFIX 0x00000010
#define DLADM_OPT_ANCHOR 0x00000020
#define DLADM_OPT_VLAN 0x00000040
#define DLADM_OPT_NOREFRESH 0x00000080
#define DLADM_OPT_BOOT 0x00000100
#define DLADM_OPT_ALLZONES 0x00000200
#define DLADM_OPT_ONLOAN 0x00000400
#define DLADM_OPT_ANET 0x00000800
#define DLADM_OPT_EFFECTIVE 0x00001000
#define DLADM_OPT_ETHERSTUB 0x00002000
#define DLADM_OPT_GUEST_OWNED 0x00004000
#define DLADM_OPT_EVSVNIC 0x00008000
#define DLADM_OPT_SYSLINK 0x00010000
#define DLADM_OPT_NONAMECHECK 0x00020000
#define DLADM_OPT_AUTO_ORIGIN 0x00040000
#define DLADM_OPT_VLAN_ATTR_V2 0x00080000
#define DLADM_OPT_PVANET 0x00100000
/*
* Following flags are remapping of DLADM_OPT_* flags.
* These are to be used by consumers of libdladm. Remapping
* allows us to expose selective flags to consumers.
* Current consumer(s) - PSARC/2012/380
*/
#define DLADM_OPT_S_ACTIVE 0x00000001
#define DLADM_OPT_S_PERSIST 0x00000002
#define DLADM_OPT_S_SYSLINK 0x00010000
#define DLADM_OPT_S_NONAMECHECK 0x00020000
#define DLADM_OPT_S_ALL (DLADM_OPT_S_ACTIVE | DLADM_OPT_S_PERSIST |\
DLADM_OPT_S_SYSLINK | DLADM_OPT_S_NONAMECHECK)
#define DLADM_WALK_TERMINATE 0
#define DLADM_WALK_CONTINUE -1
#define DLADM_MAX_ARG_CNT 32
#define DLADM_MAX_ARG_VALS 128
#define DLADM_AGGR_ATTR_V1 0x00000001
#define DLADM_AGGR_ATTR_VERSION DLADM_AGGR_ATTR_V1
typedef struct dladm_aggr_port_attr_simple {
int32_t dap_version;
char dap_linkname[MAXLINKNAMELEN];
uint64_t dap_speed;
link_duplex_t dap_duplex;
link_state_t dap_state;
boolean_t dap_attached;
} dladm_aggr_port_attr_simple_t;
/*
* Note: Any new status values should be added at the end of dladm_status_t.
*/
typedef enum {
DLADM_STATUS_OK = 0,
DLADM_STATUS_BADARG,
DLADM_STATUS_FAILED,
DLADM_STATUS_TOOSMALL,
DLADM_STATUS_NOTSUP,
DLADM_STATUS_NOTFOUND,
DLADM_STATUS_BADVAL,
DLADM_STATUS_NOMEM,
DLADM_STATUS_EXIST,
DLADM_STATUS_LINKINVAL,
DLADM_STATUS_PROPRDONLY,
DLADM_STATUS_BADVALCNT,
DLADM_STATUS_DBNOTFOUND,
DLADM_STATUS_DENIED,
DLADM_STATUS_IOERR,
DLADM_STATUS_TEMPONLY,
DLADM_STATUS_TEMPPROP,
DLADM_STATUS_TIMEDOUT,
DLADM_STATUS_ISCONN,
DLADM_STATUS_NOTCONN,
DLADM_STATUS_REPOSITORYINVAL,
DLADM_STATUS_MACADDRINVAL,
DLADM_STATUS_KEYINVAL,
DLADM_STATUS_INVALIDMACADDRLEN,
DLADM_STATUS_INVALIDMACADDRTYPE,
DLADM_STATUS_LINKBUSY,
DLADM_STATUS_VIDINVAL,
DLADM_STATUS_NONOTIF,
DLADM_STATUS_TRYAGAIN,
DLADM_STATUS_IPTUNTYPE,
DLADM_STATUS_IPTUNTYPEREQD,
DLADM_STATUS_BADIPTUNLADDR,
DLADM_STATUS_BADIPTUNRADDR,
DLADM_STATUS_ADDRINUSE,
DLADM_STATUS_BADTIMEVAL,
DLADM_STATUS_INVALIDMACADDR,
DLADM_STATUS_INVALIDMACADDRNIC,
DLADM_STATUS_INVALIDMACADDRINUSE,
DLADM_STATUS_MACFACTORYSLOTINVALID,
DLADM_STATUS_MACFACTORYSLOTUSED,
DLADM_STATUS_MACFACTORYSLOTALLUSED,
DLADM_STATUS_MACFACTORYNOTSUP,
DLADM_STATUS_INVALIDMACPREFIX,
DLADM_STATUS_INVALIDMACPREFIXLEN,
DLADM_STATUS_BADCPUID,
DLADM_STATUS_DUPCPUID,
DLADM_STATUS_CPUERR,
DLADM_STATUS_CPUNOTONLINE,
DLADM_STATUS_BADRANGE,
DLADM_STATUS_TOOMANYELEMENTS,
DLADM_STATUS_DB_PARSE_ERR,
DLADM_STATUS_PROP_PARSE_ERR,
DLADM_STATUS_ATTR_PARSE_ERR,
DLADM_STATUS_FLOW_DB_ERR,
DLADM_STATUS_FLOW_DB_OPEN_ERR,
DLADM_STATUS_FLOW_DB_PARSE_ERR,
DLADM_STATUS_FLOWPROP_DB_PARSE_ERR,
DLADM_STATUS_FLOW_ADD_ERR,
DLADM_STATUS_FLOW_WALK_ERR,
DLADM_STATUS_FLOW_IDENTICAL,
DLADM_STATUS_FLOW_DIRECTION_INCOMPATIBLE,
DLADM_STATUS_FLOW_INCOMPATIBLE,
DLADM_STATUS_FLOW_EXISTS,
DLADM_STATUS_PERSIST_FLOW_EXISTS,
DLADM_STATUS_FLOW_WRONG_ZONE,
DLADM_STATUS_ZONE_ERR,
DLADM_STATUS_INVALID_IP,
DLADM_STATUS_INVALID_PREFIXLEN,
DLADM_STATUS_INVALID_PROTOCOL,
DLADM_STATUS_INVALID_PORT,
DLADM_STATUS_INVALID_DIRECTION,
DLADM_STATUS_INVALID_DSF,
DLADM_STATUS_INVALID_DSFMASK,
DLADM_STATUS_INVALID_MACMARGIN,
DLADM_STATUS_NOTDEFINED,
DLADM_STATUS_BADPROP,
DLADM_STATUS_MINMAXBW,
DLADM_STATUS_NO_HWRINGS,
DLADM_STATUS_PERMONLY,
DLADM_STATUS_OPTMISSING,
DLADM_STATUS_POOLCPU,
DLADM_STATUS_INVALID_PORT_INSTANCE,
DLADM_STATUS_PORT_IS_DOWN,
DLADM_STATUS_PKEY_NOT_PRESENT,
DLADM_STATUS_PARTITION_EXISTS,
DLADM_STATUS_INVALID_PKEY,
DLADM_STATUS_NO_IB_HW_RESOURCE,
DLADM_STATUS_INVALID_PKEY_TBL_SIZE,
DLADM_STATUS_PARTITION_OPEN_FAIL,
DLADM_STATUS_PORT_DCB_ENABLED,
DLADM_STATUS_PORT_LLDP_ENABLED,
DLADM_STATUS_PORT_LLDP_NOT_ENABLED,
DLADM_STATUS_DB_LONGLINE,
DLADM_STATUS_ADDR_NOTAVAIL,
DLADM_STATUS_MINETSBW,
DLADM_STATUS_FLOW_ATTR_INVALID,
DLADM_STATUS_VID_IS_PVID,
DLADM_STATUS_EXCLUSIVE,
DLADM_STATUS_NOTDLMPMODE,
DLADM_STATUS_DLMPSVC,
DLADM_STATUS_MACAUTOSLOTALLUSED,
DLADM_STATUS_FLOW_IP_VERSION_CONFLICT,
DLADM_STATUS_FLOW_INVALID_FLOWNAME,
DLADM_STATUS_FLOW_SYSTEM_FLOW,
DLADM_STATUS_BADVXLANADDR,
DLADM_STATUS_BADVXLANIF,
DLADM_STATUS_NOUNICASTVLAN,
DLADM_STATUS_UNICASTSLOTALLUSED,
DLADM_STATUS_IOV_NOTSUP,
DLADM_STATUS_IOV_NOTOWNER,
DLADM_STATUS_IOV_DISABLED,
DLADM_STATUS_VF_UNAVAIL,
DLADM_STATUS_USE_EVSADM,
DLADM_STATUS_TOO_MANY_ENCAP_LEVELS,
DLADM_STATUS_PVLANNOTSUP,
DLADM_STATUS_PVLANINVALID,
DLADM_STATUS_PVLANSVIDINVAL,
DLADM_STATUS_PVLANTYPEINVAL,
DLADM_STATUS_PVLANVIDINUSECOMMUNITY,
DLADM_STATUS_PVLANVIDINUSEPRIMARY,
DLADM_STATUS_PVLANUNIQUESVID,
DLADM_STATUS_PVLANQNIQUEISOLATED,
DLADM_STATUS_PVLANVIDSVIDEQUAL,
DLADM_STATUS_VLAN_NOTSUP,
DLADM_STATUS_INVALID_LOWER_MEDIA,
DLADM_STATUS_MOD_LOWER_LINK_ONLY,
DLADM_STATUS_LINKBUSY_PERSISTENT,
DLADM_STATUS_FLOW_PEXISTS,
DLADM_STATUS_INVALID_LOWER_LINK,
DLADM_STATUS_PORTVLAN_EXCLUSIVE,
DLADM_STATUS_PORTVLAN_EXIST,
DLADM_STATUS_PORTVLAN_NOTSUP,
DLADM_STATUS_VLANID_NOTSUP
} dladm_status_t;
typedef enum {
DLADM_TYPE_INVALID = -1,
DLADM_TYPE_STR,
DLADM_TYPE_BOOLEAN,
DLADM_TYPE_UINT64
} dladm_datatype_t;
typedef enum {
DLADM_PROP_VAL_CURRENT = 1,
DLADM_PROP_VAL_DEFAULT,
DLADM_PROP_VAL_PERM,
DLADM_PROP_VAL_MODIFIABLE,
DLADM_PROP_VAL_PERSISTENT,
DLADM_PROP_VAL_EFFECTIVE
} dladm_prop_type_t;
typedef struct {
boolean_t ds_readonly;
union {
int dsu_confid;
nvlist_t *dsu_nvl;
} ds_u;
} dladm_conf_t;
#define ds_confid ds_u.dsu_confid
#define ds_nvl ds_u.dsu_nvl
#define DLADM_INVALID_CONF 0
/* opaque dladm handle to libdladm functions */
struct dladm_handle;
typedef struct dladm_handle *dladm_handle_t;
/* open/close handle */
extern dladm_status_t dladm_open(dladm_handle_t *, const char *);
extern void dladm_close(dladm_handle_t);
/*
* retrieve the dld file descriptor/kstat chain pointer from handle,
* only libdladm and dlmgmtd are given access to the door file
* descriptor.
*/
extern int dladm_dld_fd(dladm_handle_t);
extern kstat_ctl_t *dladm_kcp(dladm_handle_t);
typedef struct dladm_arg_info {
const char *ai_name;
char *ai_val[DLADM_MAX_ARG_VALS];
uint_t ai_count;
uint_t ai_flags;
} dladm_arg_info_t;
#define DLADM_ARG_BADARG 0x00000001
#define DLADM_ARG_BADVAL 0x00000002
typedef struct dladm_arg_list {
dladm_arg_info_t al_info[DLADM_MAX_ARG_CNT];
uint_t al_count;
char *al_buf;
} dladm_arg_list_t;
typedef enum {
DLADM_LOGTYPE_LINK = 1,
DLADM_LOGTYPE_FLOW
} dladm_logtype_t;
typedef enum dladm_hatype {
DLADM_HA_NONE = 0,
DLADM_HA_TRUNK,
DLADM_HA_DLMP
} dladm_ha_type_t;
typedef struct dladm_usage {
char du_name[MAXLINKNAMELEN];
uint64_t du_duration;
uint64_t du_stime;
uint64_t du_etime;
uint64_t du_ipackets;
uint64_t du_rbytes;
uint64_t du_opackets;
uint64_t du_obytes;
uint64_t du_bandwidth;
boolean_t du_last;
} dladm_usage_t;
extern const char *dladm_status2str(dladm_status_t, char *);
extern dladm_status_t dladm_set_rootdir(const char *);
extern const char *dladm_class2str(datalink_class_t, char *);
extern const char *dladm_media2str(uint32_t, char *);
extern uint32_t dladm_str2media(const char *);
extern boolean_t dladm_valid_linkname(const char *);
extern boolean_t dladm_str2posint(char *, uint32_t *);
extern boolean_t dladm_str2interval(char *, uint32_t *);
extern boolean_t dladm_str2count(char *, uint32_t *);
extern dladm_status_t dladm_str2bw(char *, uint64_t *);
extern const char *dladm_pvlantype2str(mac_pvlantype_t, char *, int);
extern dladm_status_t dladm_parse_vid(const char *, int *, int *,
mac_pvlantype_t *);
extern const char *dladm_bw2str(int64_t, char *);
extern const char *dladm_bw2str_compact(int64_t, char *);
extern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *);
extern const char *dladm_pri2str(mac_priority_level_t, char *);
extern dladm_status_t dladm_str2protect(char *, uint32_t *);
extern const char *dladm_protect2str(uint32_t, char *);
extern dladm_status_t dladm_str2ipv4addr(char *, void *);
extern const char *dladm_ipv4addr2str(void *, char *);
extern dladm_status_t dladm_str2ipv6addr(char *, void *);
extern const char *dladm_ipv6addr2str(void *, char *);
extern dladm_status_t dladm_str2cid(char *, mac_dhcpcid_t *);
extern dladm_status_t dladm_parse_flow_props(const char *,
dladm_arg_list_t **, boolean_t);
extern dladm_status_t dladm_parse_link_props(const char *,
dladm_arg_list_t **, boolean_t);
extern void dladm_free_props(dladm_arg_list_t *);
extern dladm_status_t dladm_parse_flow_attrs(const char *,
dladm_arg_list_t **, boolean_t);
extern void dladm_free_attrs(dladm_arg_list_t *);
extern dladm_status_t dladm_start_usagelog(dladm_handle_t, dladm_logtype_t,
uint_t);
extern dladm_status_t dladm_stop_usagelog(dladm_handle_t, dladm_logtype_t);
extern dladm_status_t dladm_walk_usage_res(int (*)(dladm_usage_t *, void *),
int, char *, char *, char *, char *, void *);
extern dladm_status_t dladm_walk_usage_time(int (*)(dladm_usage_t *, void *),
int, char *, char *, char *, void *);
extern dladm_status_t dladm_usage_summary(int (*)(dladm_usage_t *, void *),
int, char *, void *);
extern dladm_status_t dladm_usage_dates(int (*)(dladm_usage_t *, void *),
int, char *, char *, void *);
extern dladm_status_t dladm_zone_boot(dladm_handle_t, zoneid_t);
extern dladm_status_t dladm_zone_halt(dladm_handle_t, zoneid_t);
extern dladm_status_t dladm_zone_upgrade(dladm_handle_t, zoneid_t, int64_t);
extern dladm_status_t dladm_parse_args(const char *, dladm_arg_list_t **,
boolean_t);
extern dladm_status_t dladm_strs2range(char **, uint_t, mac_propval_type_t,
mac_propval_range_t **);
extern dladm_status_t dladm_range2list(mac_propval_range_t *, void*,
uint_t *);
extern int dladm_range2strs(mac_propval_range_t *, char **);
extern dladm_status_t dladm_list2range(void *, uint_t, mac_propval_type_t,
mac_propval_range_t **);
extern dladm_status_t dladm_parse_zonelist(char *, uint32_t *, zoneid_t **);
extern dladm_status_t dladm_apply_linknamefilters(dladm_handle_t,
const char *, datalink_id_t *, uint32_t, zoneid_t *,
uint32_t, zoneid_t, char *);
extern dladm_status_t dladm_get_etsbat(dladm_handle_t, datalink_id_t,
uint8_t *, uint32_t);
extern dladm_status_t dladm_set_etsbat(dladm_handle_t, datalink_id_t,
uint8_t *, uint_t, uint32_t);
extern dladm_status_t dladm_init_profile(dladm_handle_t);
extern dladm_status_t dladm_fini_profile(dladm_handle_t);
extern int dladm_create_fixed_ncp(const char *, zoneid_t);
extern dladm_status_t dladm_aggr_info_simple(const char *, uint32_t *,
dladm_aggr_port_attr_simple_t **);
extern dladm_status_t dladm_name2class_simple(const char *,
datalink_class_t *);
extern dladm_status_t dladm_get_link_hatype_simple(const char *,
dladm_ha_type_t *);
#ifdef __cplusplus
}
#endif
#endif /* _LIBDLADM_H */