2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBDLADM_IMPL_H
2N/A#define _LIBDLADM_IMPL_H
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/mac.h>
2N/A#include <sys/mac_flow.h>
2N/A#include <libdladm.h>
2N/A#include <stdio.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define MAXLINELEN 1024
2N/A#define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0)
2N/A#define V4_PART_OF_V6(v6) ((v6)._S6_un._S6_u32[3])
2N/A
2N/A/*
2N/A * The handle contains file descriptors to DLD_CONTROL_DEV and
2N/A * DLMGMT_DOOR. Rather than opening the file descriptor each time
2N/A * it is required, the handle is opened by consumers of libdladm
2N/A * (e.g., dladm) and then passed to libdladm. The handle also contains
2N/A * the profile to latch to so that read/writes are done from/to that
2N/A * profile-specific configuration.
2N/A */
2N/Astruct dladm_handle {
2N/A int dld_fd; /* file descriptor to DLD_CONTROL_DEV */
2N/A int door_fd; /* file descriptor to DLMGMT_DOOR */
2N/A char dh_profile[MAXNAMELEN]; /* profile to work on */
2N/A};
2N/A
2N/A/* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */
2N/Aextern dladm_status_t dladm_door_fd(dladm_handle_t, int *);
2N/A
2N/Aextern dladm_status_t dladm_errno2status(int);
2N/Aextern dladm_status_t i_dladm_rw_db(dladm_handle_t, const char *, mode_t,
2N/A dladm_status_t (*)(dladm_handle_t, void *, FILE *,
2N/A FILE *), void *, boolean_t);
2N/Aextern dladm_status_t dladm_get_state(dladm_handle_t, datalink_id_t,
2N/A link_state_t *);
2N/Aextern void dladm_find_setbits32(uint32_t, uint32_t *, uint32_t *);
2N/Aextern void dladm_free_args(dladm_arg_list_t *);
2N/Aextern dladm_status_t dladm_get_phys_prefix(dladm_handle_t, char *);
2N/A
2N/A/*
2N/A * Link attributes persisted by dlmgmtd.
2N/A */
2N/A/*
2N/A * Set for VLANs only
2N/A */
2N/A#define FVLANID "vid" /* uint64_t */
2N/A#define FLINKOVER "linkover" /* uint64_t */
2N/A
2N/A/*
2N/A * Set for AGGRs only
2N/A */
2N/A#define FKEY "key" /* uint64_t */
2N/A#define FNPORTS "nports" /* uint64_t */
2N/A#define FPORTS "portnames" /* string */
2N/A#define FAGGRMODE "aggr_mode" /* enum */
2N/A#define FPOLICY "policy" /* uint64_t */
2N/A#define FFIXMACADDR "fix_macaddr" /* boolean_t */
2N/A#define FFORCE "force" /* boolean_t */
2N/A#define FLACPMODE "lacp_mode" /* uint64_t */
2N/A#define FLACPTIMER "lacp_timer" /* uint64_t */
2N/A
2N/A/*
2N/A * Set for VNICs only
2N/A */
2N/A#define FMADDRTYPE "maddrtype" /* uint64_t */
2N/A#define FMADDRLEN "maddrlen" /* uint64_t */
2N/A#define FMADDRSLOT "maddrslot" /* uint64_t */
2N/A#define FMADDRPREFIXLEN "maddrpreflen" /* uint64_t */
2N/A#define FVRID "vrid" /* uint64_t */
2N/A#define FVRAF "vraf" /* uint64_t */
2N/A
2N/A/*
2N/A * Set for simlinks only
2N/A */
2N/A#define FSIMNETTYPE "simnettype" /* uint64_t */
2N/A#define FSIMNETPEER "simnetpeer" /* uint64_t */
2N/A
2N/A/*
2N/A * Set for IB partitions only
2N/A */
2N/A#define FPORTPKEY "pkey" /* uint64_t */
2N/A
2N/A/*
2N/A * Set for flows only
2N/A */
2N/A#define FMAXBW "maxbw" /* uint64_t */
2N/A#define FLOCAL_IP_ADDR "local_ip" /* string */
2N/A#define FREMOTE_IP_ADDR "remote_ip" /* string */
2N/A#define FTRANSPORT "transport" /* uint64_t */
2N/A#define FLOCAL_PORT "local_port" /* uint64_t */
2N/A#define FREMOTE_PORT "remote_port" /* uint64_t */
2N/A#define FDSFIELD "dsfield" /* uint64_t */
2N/A#define FDSFIELD_MASK "dsfield_mask" /* uint64_t */
2N/A
2N/A/*
2N/A * Common fields
2N/A */
2N/A#define FMACADDR "macaddr" /* string */
2N/A
2N/A/*
2N/A * List of all the above attributes.
2N/A */
2N/A#define DLADM_ATTR_NAMES FVLANID, FLINKOVER, \
2N/A FKEY, FNPORTS, FPORTS, FAGGRMODE, FPOLICY, \
2N/A FFIXMACADDR, FFORCE, FLACPMODE, FLACPTIMER, \
2N/A FMADDRTYPE, FMADDRLEN, FMADDRSLOT, \
2N/A FMADDRPREFIXLEN, FVRID, FVRAF, \
2N/A FMACADDR, FSIMNETTYPE, FSIMNETPEER, \
2N/A FLOCAL_IP_ADDR, FREMOTE_IP_ADDR, FTRANSPORT, \
2N/A FLOCAL_PORT, FREMOTE_PORT, FDSFIELD
2N/A
2N/A/*
2N/A * Data structures used for implementing temporary properties
2N/A */
2N/A
2N/Atypedef struct val_desc {
2N/A char *vd_name;
2N/A uintptr_t vd_val;
2N/A} val_desc_t;
2N/A
2N/A#define VALCNT(vals) (sizeof ((vals)) / sizeof (val_desc_t))
2N/A
2N/Aextern dladm_status_t dladm_link_proplist_extract(dladm_handle_t,
2N/A dladm_arg_list_t *, mac_resource_props_t *,
2N/A uint_t);
2N/A
2N/Aextern dladm_status_t dladm_flow_proplist_extract(dladm_arg_list_t *,
2N/A mac_resource_props_t *);
2N/A
2N/A/*
2N/A * The prop extract() callback.
2N/A *
2N/A * rp_extract extracts the kernel structure from the val_desc_t created
2N/A * by the pd_check function.
2N/A */
2N/Atypedef dladm_status_t rp_extractf_t(val_desc_t *, uint_t, void *);
2N/Aextern rp_extractf_t extract_maxbw, extract_priority,
2N/A extract_cpus, extract_protection,
2N/A extract_allowedips, extract_allowedcids,
2N/A extract_rxrings, extract_txrings, extract_pool,
2N/A extract_rxfanout, extract_profileid, extract_vsitypeid,
2N/A extract_vsiversion, extract_vsimgrid,
2N/A extract_vsimgrenc, extract_pfcmap, extract_cos,
2N/A extract_etsbw;
2N/A
2N/Atypedef struct resource_prop_s {
2N/A /*
2N/A * resource property name
2N/A */
2N/A char *rp_name;
2N/A
2N/A /*
2N/A * callback to extract kernel structure
2N/A */
2N/A rp_extractf_t *rp_extract;
2N/A} resource_prop_t;
2N/A
2N/A/*
2N/A * Set for bridged links only
2N/A */
2N/A#define FBRIDGE "bridge" /* string */
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBDLADM_IMPL_H */