13147Sxc151355 /* 23147Sxc151355 * CDDL HEADER START 33147Sxc151355 * 43147Sxc151355 * The contents of this file are subject to the terms of the 53147Sxc151355 * Common Development and Distribution License (the "License"). 63147Sxc151355 * You may not use this file except in compliance with the License. 73147Sxc151355 * 83147Sxc151355 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93147Sxc151355 * or http://www.opensolaris.org/os/licensing. 103147Sxc151355 * See the License for the specific language governing permissions 113147Sxc151355 * and limitations under the License. 123147Sxc151355 * 133147Sxc151355 * When distributing Covered Code, include this CDDL HEADER in each 143147Sxc151355 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153147Sxc151355 * If applicable, add the following below this CDDL HEADER, with the 163147Sxc151355 * fields enclosed by brackets "[]" replaced with your own identifying 173147Sxc151355 * information: Portions Copyright [yyyy] [name of copyright owner] 183147Sxc151355 * 193147Sxc151355 * CDDL HEADER END 203147Sxc151355 */ 213147Sxc151355 /* 225895Syz147064 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233147Sxc151355 * Use is subject to license terms. 243147Sxc151355 */ 253147Sxc151355 263147Sxc151355 #ifndef _LIBDLADM_IMPL_H 273147Sxc151355 #define _LIBDLADM_IMPL_H 283147Sxc151355 293147Sxc151355 #include <libdladm.h> 303147Sxc151355 #include <stdio.h> 313147Sxc151355 323147Sxc151355 #ifdef __cplusplus 333147Sxc151355 extern "C" { 343147Sxc151355 #endif 353147Sxc151355 363147Sxc151355 #define MAXLINELEN 1024 373147Sxc151355 #define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0) 383147Sxc151355 39*8453SAnurag.Maskey@Sun.COM /* 40*8453SAnurag.Maskey@Sun.COM * The handle contains file descriptors to DLD_CONTROL_DEV and 41*8453SAnurag.Maskey@Sun.COM * DLMGMT_DOOR. Rather than opening the file descriptor each time 42*8453SAnurag.Maskey@Sun.COM * it is required, the handle is opened by consumers of libdladm 43*8453SAnurag.Maskey@Sun.COM * (e.g., dladm) and then passed to libdladm. 44*8453SAnurag.Maskey@Sun.COM */ 45*8453SAnurag.Maskey@Sun.COM struct dladm_handle { 46*8453SAnurag.Maskey@Sun.COM int dld_fd; /* file descriptor to DLD_CONTROL_DEV */ 47*8453SAnurag.Maskey@Sun.COM int door_fd; /* file descriptor to DLMGMT_DOOR */ 48*8453SAnurag.Maskey@Sun.COM }; 49*8453SAnurag.Maskey@Sun.COM 50*8453SAnurag.Maskey@Sun.COM /* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */ 51*8453SAnurag.Maskey@Sun.COM extern dladm_status_t dladm_door_fd(dladm_handle_t, int *); 52*8453SAnurag.Maskey@Sun.COM 533147Sxc151355 extern dladm_status_t dladm_errno2status(int); 54*8453SAnurag.Maskey@Sun.COM extern dladm_status_t i_dladm_rw_db(dladm_handle_t, const char *, mode_t, 55*8453SAnurag.Maskey@Sun.COM dladm_status_t (*)(dladm_handle_t, void *, FILE *, 56*8453SAnurag.Maskey@Sun.COM FILE *), void *, boolean_t); 57*8453SAnurag.Maskey@Sun.COM extern dladm_status_t i_dladm_get_state(dladm_handle_t, datalink_id_t, 58*8453SAnurag.Maskey@Sun.COM link_state_t *); 593147Sxc151355 608275SEric Cheng extern const char *dladm_pri2str(mac_priority_level_t, char *); 618275SEric Cheng extern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *); 628275SEric Cheng extern dladm_status_t dladm_parse_args(char *, dladm_arg_list_t **, 638275SEric Cheng boolean_t); 648275SEric Cheng extern void dladm_free_args(dladm_arg_list_t *); 658275SEric Cheng 665895Syz147064 /* 675895Syz147064 * Link attributes persisted by dlmgmtd. 685895Syz147064 */ 695895Syz147064 /* 705895Syz147064 * Set for VLANs only 715895Syz147064 */ 725895Syz147064 #define FVLANID "vid" /* uint64_t */ 735895Syz147064 #define FLINKOVER "linkover" /* uint64_t */ 745895Syz147064 755895Syz147064 /* 765895Syz147064 * Set for AGGRs only 775895Syz147064 */ 785895Syz147064 #define FKEY "key" /* uint64_t */ 795895Syz147064 #define FNPORTS "nports" /* uint64_t */ 805895Syz147064 #define FPORTS "portnames" /* string */ 815895Syz147064 #define FPOLICY "policy" /* uint64_t */ 825895Syz147064 #define FFIXMACADDR "fix_macaddr" /* boolean_t */ 835895Syz147064 #define FFORCE "force" /* boolean_t */ 845895Syz147064 #define FLACPMODE "lacp_mode" /* uint64_t */ 855895Syz147064 #define FLACPTIMER "lacp_timer" /* uint64_t */ 865895Syz147064 878275SEric Cheng /* 888275SEric Cheng * Set for VNICs only 898275SEric Cheng */ 908275SEric Cheng #define FMADDRTYPE "maddrtype" /* uint64_t */ 918275SEric Cheng #define FMADDRLEN "maddrlen" /* uint64_t */ 928275SEric Cheng #define FMADDRSLOT "maddrslot" /* uint64_t */ 938275SEric Cheng #define FMADDRPREFIXLEN "maddrpreflen" /* uint64_t */ 948275SEric Cheng #define FHWRINGS "hwrings" /* boolean_t */ 958275SEric Cheng 968275SEric Cheng /* 978275SEric Cheng * Common fields 988275SEric Cheng */ 998275SEric Cheng #define FMACADDR "macaddr" /* string */ 1008275SEric Cheng 1018275SEric Cheng /* 1028275SEric Cheng * Data structures used for implementing temporary properties 1038275SEric Cheng */ 1048275SEric Cheng 1058275SEric Cheng typedef struct val_desc { 1068275SEric Cheng char *vd_name; 1078275SEric Cheng uintptr_t vd_val; 1088275SEric Cheng } val_desc_t; 1098275SEric Cheng 1108275SEric Cheng #define VALCNT(vals) (sizeof ((vals)) / sizeof (val_desc_t)) 1118275SEric Cheng 112*8453SAnurag.Maskey@Sun.COM extern dladm_status_t dladm_link_proplist_extract(dladm_handle_t, 113*8453SAnurag.Maskey@Sun.COM dladm_arg_list_t *, mac_resource_props_t *); 1148275SEric Cheng 1158275SEric Cheng extern dladm_status_t dladm_flow_proplist_extract(dladm_arg_list_t *, 1168275SEric Cheng mac_resource_props_t *); 1178275SEric Cheng 1188275SEric Cheng /* 1198275SEric Cheng * The prop extract() callback. 1208275SEric Cheng * 1218275SEric Cheng * rp_extract extracts the kernel structure from the val_desc_t created 1228275SEric Cheng * by the pd_check function. 1238275SEric Cheng */ 1248275SEric Cheng typedef dladm_status_t rp_extractf_t(val_desc_t *propval, void *arg, 1258275SEric Cheng uint_t cnt); 1268275SEric Cheng extern rp_extractf_t do_extract_maxbw, do_extract_priority, 1278275SEric Cheng do_extract_cpus; 1288275SEric Cheng 1298275SEric Cheng typedef struct resource_prop_s { 1308275SEric Cheng /* 1318275SEric Cheng * resource property name 1328275SEric Cheng */ 1338275SEric Cheng char *rp_name; 1348275SEric Cheng 1358275SEric Cheng /* 1368275SEric Cheng * callback to extract kernel structure 1378275SEric Cheng */ 1388275SEric Cheng rp_extractf_t *rp_extract; 1398275SEric Cheng } resource_prop_t; 1408275SEric Cheng 1413147Sxc151355 #ifdef __cplusplus 1423147Sxc151355 } 1433147Sxc151355 #endif 1443147Sxc151355 1453147Sxc151355 #endif /* _LIBDLADM_IMPL_H */ 146