libdladm_impl.h revision 4ac67f0276a8313b5cefec38af347b94b7bfb526
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * CDDL HEADER START
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp *
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * The contents of this file are subject to the terms of the
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Common Development and Distribution License (the "License").
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * You may not use this file except in compliance with the License.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp *
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * or http://www.opensolaris.org/os/licensing.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * See the License for the specific language governing permissions
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * and limitations under the License.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp *
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * When distributing Covered Code, include this CDDL HEADER in each
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * If applicable, add the following below this CDDL HEADER, with the
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * fields enclosed by brackets "[]" replaced with your own identifying
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * information: Portions Copyright [yyyy] [name of copyright owner]
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp *
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * CDDL HEADER END
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Use is subject to license terms.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#ifndef _LIBDLADM_IMPL_H
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define _LIBDLADM_IMPL_H
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#include <libdladm.h>
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#include <stdio.h>
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#ifdef __cplusplus
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern "C" {
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#endif
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define MAXLINELEN 1024
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0)
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * The handle contains file descriptors to DLD_CONTROL_DEV and
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * DLMGMT_DOOR. Rather than opening the file descriptor each time
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * it is required, the handle is opened by consumers of libdladm
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * (e.g., dladm) and then passed to libdladm.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpstruct dladm_handle {
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp int dld_fd; /* file descriptor to DLD_CONTROL_DEV */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp int door_fd; /* file descriptor to DLMGMT_DOOR */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp};
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_door_fd(dladm_handle_t, int *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_errno2status(int);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t i_dladm_rw_db(dladm_handle_t, const char *, mode_t,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp dladm_status_t (*)(dladm_handle_t, void *, FILE *,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp FILE *), void *, boolean_t);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t i_dladm_get_state(dladm_handle_t, datalink_id_t,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp link_state_t *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern const char *dladm_pri2str(mac_priority_level_t, char *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_parse_args(char *, dladm_arg_list_t **,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp boolean_t);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern void dladm_free_args(dladm_arg_list_t *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Link attributes persisted by dlmgmtd.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Set for VLANs only
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FVLANID "vid" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FLINKOVER "linkover" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Set for AGGRs only
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FKEY "key" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FNPORTS "nports" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FPORTS "portnames" /* string */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FPOLICY "policy" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FFIXMACADDR "fix_macaddr" /* boolean_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FFORCE "force" /* boolean_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FLACPMODE "lacp_mode" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FLACPTIMER "lacp_timer" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Set for VNICs only
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FMADDRTYPE "maddrtype" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FMADDRLEN "maddrlen" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FMADDRSLOT "maddrslot" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FMADDRPREFIXLEN "maddrpreflen" /* uint64_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FHWRINGS "hwrings" /* boolean_t */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Common fields
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define FMACADDR "macaddr" /* string */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * Data structures used for implementing temporary properties
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcptypedef struct val_desc {
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp char *vd_name;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp uintptr_t vd_val;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp} val_desc_t;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#define VALCNT(vals) (sizeof ((vals)) / sizeof (val_desc_t))
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_link_proplist_extract(dladm_handle_t,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp dladm_arg_list_t *, mac_resource_props_t *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern dladm_status_t dladm_flow_proplist_extract(dladm_arg_list_t *,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp mac_resource_props_t *);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp/*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * The prop extract() callback.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp *
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * rp_extract extracts the kernel structure from the val_desc_t created
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * by the pd_check function.
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcptypedef dladm_status_t rp_extractf_t(val_desc_t *propval, void *arg,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp uint_t cnt);
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcpextern rp_extractf_t do_extract_maxbw, do_extract_priority,
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp do_extract_cpus;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcptypedef struct resource_prop_s {
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp /*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * resource property name
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp char *rp_name;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp /*
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp * callback to extract kernel structure
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp rp_extractf_t *rp_extract;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp} resource_prop_t;
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#ifdef __cplusplus
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp}
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#endif
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp#endif /* _LIBDLADM_IMPL_H */
5a7763bf3e9db4cfe6cb523b096cb74af71e3793jmcp