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 /* 22*12163SRamaswamy.Tummala@Sun.COM * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 233147Sxc151355 */ 243147Sxc151355 253147Sxc151355 #ifndef _LIBDLADM_IMPL_H 263147Sxc151355 #define _LIBDLADM_IMPL_H 273147Sxc151355 2810616SSebastien.Roy@Sun.COM #include <sys/types.h> 2910491SRishi.Srivatsavai@Sun.COM #include <sys/mac.h> 3010491SRishi.Srivatsavai@Sun.COM #include <sys/mac_flow.h> 313147Sxc151355 #include <libdladm.h> 323147Sxc151355 #include <stdio.h> 333147Sxc151355 343147Sxc151355 #ifdef __cplusplus 353147Sxc151355 extern "C" { 363147Sxc151355 #endif 373147Sxc151355 383147Sxc151355 #define MAXLINELEN 1024 393147Sxc151355 #define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0) 4011878SVenu.Iyer@Sun.COM #define V4_PART_OF_V6(v6) ((v6)._S6_un._S6_u32[3]) 413147Sxc151355 428453SAnurag.Maskey@Sun.COM /* 438453SAnurag.Maskey@Sun.COM * The handle contains file descriptors to DLD_CONTROL_DEV and 448453SAnurag.Maskey@Sun.COM * DLMGMT_DOOR. Rather than opening the file descriptor each time 458453SAnurag.Maskey@Sun.COM * it is required, the handle is opened by consumers of libdladm 468453SAnurag.Maskey@Sun.COM * (e.g., dladm) and then passed to libdladm. 478453SAnurag.Maskey@Sun.COM */ 488453SAnurag.Maskey@Sun.COM struct dladm_handle { 498453SAnurag.Maskey@Sun.COM int dld_fd; /* file descriptor to DLD_CONTROL_DEV */ 508453SAnurag.Maskey@Sun.COM int door_fd; /* file descriptor to DLMGMT_DOOR */ 518453SAnurag.Maskey@Sun.COM }; 528453SAnurag.Maskey@Sun.COM 538453SAnurag.Maskey@Sun.COM /* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */ 548453SAnurag.Maskey@Sun.COM extern dladm_status_t dladm_door_fd(dladm_handle_t, int *); 558453SAnurag.Maskey@Sun.COM 563147Sxc151355 extern dladm_status_t dladm_errno2status(int); 578453SAnurag.Maskey@Sun.COM extern dladm_status_t i_dladm_rw_db(dladm_handle_t, const char *, mode_t, 588453SAnurag.Maskey@Sun.COM dladm_status_t (*)(dladm_handle_t, void *, FILE *, 598453SAnurag.Maskey@Sun.COM FILE *), void *, boolean_t); 6011878SVenu.Iyer@Sun.COM extern dladm_status_t dladm_get_state(dladm_handle_t, datalink_id_t, 618453SAnurag.Maskey@Sun.COM link_state_t *); 6210734SEric Cheng extern void dladm_find_setbits32(uint32_t, uint32_t *, uint32_t *); 638275SEric Cheng extern dladm_status_t dladm_parse_args(char *, dladm_arg_list_t **, 648275SEric Cheng boolean_t); 658275SEric Cheng extern void dladm_free_args(dladm_arg_list_t *); 668275SEric Cheng 675895Syz147064 /* 685895Syz147064 * Link attributes persisted by dlmgmtd. 695895Syz147064 */ 705895Syz147064 /* 715895Syz147064 * Set for VLANs only 725895Syz147064 */ 735895Syz147064 #define FVLANID "vid" /* uint64_t */ 745895Syz147064 #define FLINKOVER "linkover" /* uint64_t */ 755895Syz147064 765895Syz147064 /* 775895Syz147064 * Set for AGGRs only 785895Syz147064 */ 795895Syz147064 #define FKEY "key" /* uint64_t */ 805895Syz147064 #define FNPORTS "nports" /* uint64_t */ 815895Syz147064 #define FPORTS "portnames" /* string */ 825895Syz147064 #define FPOLICY "policy" /* uint64_t */ 835895Syz147064 #define FFIXMACADDR "fix_macaddr" /* boolean_t */ 845895Syz147064 #define FFORCE "force" /* boolean_t */ 855895Syz147064 #define FLACPMODE "lacp_mode" /* uint64_t */ 865895Syz147064 #define FLACPTIMER "lacp_timer" /* uint64_t */ 875895Syz147064 888275SEric Cheng /* 898275SEric Cheng * Set for VNICs only 908275SEric Cheng */ 918275SEric Cheng #define FMADDRTYPE "maddrtype" /* uint64_t */ 928275SEric Cheng #define FMADDRLEN "maddrlen" /* uint64_t */ 938275SEric Cheng #define FMADDRSLOT "maddrslot" /* uint64_t */ 948275SEric Cheng #define FMADDRPREFIXLEN "maddrpreflen" /* uint64_t */ 9511076SCathy.Zhou@Sun.COM #define FVRID "vrid" /* uint64_t */ 9611076SCathy.Zhou@Sun.COM #define FVRAF "vraf" /* uint64_t */ 978275SEric Cheng 988275SEric Cheng /* 999815SRishi.Srivatsavai@Sun.COM * Set for simlinks only 1009815SRishi.Srivatsavai@Sun.COM */ 1019815SRishi.Srivatsavai@Sun.COM #define FSIMNETTYPE "simnettype" /* uint64_t */ 1029815SRishi.Srivatsavai@Sun.COM #define FSIMNETPEER "simnetpeer" /* uint64_t */ 1039815SRishi.Srivatsavai@Sun.COM 1049815SRishi.Srivatsavai@Sun.COM /* 105*12163SRamaswamy.Tummala@Sun.COM * Set for IB partitions only 106*12163SRamaswamy.Tummala@Sun.COM */ 107*12163SRamaswamy.Tummala@Sun.COM #define FPORTPKEY "pkey" /* uint64_t */ 108*12163SRamaswamy.Tummala@Sun.COM 109*12163SRamaswamy.Tummala@Sun.COM /* 1108275SEric Cheng * Common fields 1118275SEric Cheng */ 1128275SEric Cheng #define FMACADDR "macaddr" /* string */ 1138275SEric Cheng 1148275SEric Cheng /* 1158460SArtem.Kachitchkin@Sun.COM * List of all the above attributes. 1168460SArtem.Kachitchkin@Sun.COM */ 1178460SArtem.Kachitchkin@Sun.COM #define DLADM_ATTR_NAMES FVLANID, FLINKOVER, \ 1188460SArtem.Kachitchkin@Sun.COM FKEY, FNPORTS, FPORTS, FPOLICY, \ 1198460SArtem.Kachitchkin@Sun.COM FFIXMACADDR, FFORCE, FLACPMODE, FLACPTIMER, \ 1208460SArtem.Kachitchkin@Sun.COM FMADDRTYPE, FMADDRLEN, FMADDRSLOT, \ 12111878SVenu.Iyer@Sun.COM FMADDRPREFIXLEN, \ 1229815SRishi.Srivatsavai@Sun.COM FMACADDR, FSIMNETTYPE, FSIMNETPEER 1238460SArtem.Kachitchkin@Sun.COM 1248460SArtem.Kachitchkin@Sun.COM /* 1258275SEric Cheng * Data structures used for implementing temporary properties 1268275SEric Cheng */ 1278275SEric Cheng 1288275SEric Cheng typedef struct val_desc { 1298275SEric Cheng char *vd_name; 1308275SEric Cheng uintptr_t vd_val; 1318275SEric Cheng } val_desc_t; 1328275SEric Cheng 1338275SEric Cheng #define VALCNT(vals) (sizeof ((vals)) / sizeof (val_desc_t)) 1348275SEric Cheng 1358453SAnurag.Maskey@Sun.COM extern dladm_status_t dladm_link_proplist_extract(dladm_handle_t, 13611878SVenu.Iyer@Sun.COM dladm_arg_list_t *, mac_resource_props_t *, 13711878SVenu.Iyer@Sun.COM uint_t); 1388275SEric Cheng 1398275SEric Cheng extern dladm_status_t dladm_flow_proplist_extract(dladm_arg_list_t *, 1408275SEric Cheng mac_resource_props_t *); 1418275SEric Cheng 1428275SEric Cheng /* 1438275SEric Cheng * The prop extract() callback. 1448275SEric Cheng * 1458275SEric Cheng * rp_extract extracts the kernel structure from the val_desc_t created 1468275SEric Cheng * by the pd_check function. 1478275SEric Cheng */ 14810734SEric Cheng typedef dladm_status_t rp_extractf_t(val_desc_t *, uint_t, void *); 14911878SVenu.Iyer@Sun.COM extern rp_extractf_t extract_maxbw, extract_priority, 15011878SVenu.Iyer@Sun.COM extract_cpus, extract_protection, 15111878SVenu.Iyer@Sun.COM extract_allowedips, extract_allowedcids, 15211878SVenu.Iyer@Sun.COM extract_rxrings, extract_txrings, extract_pool; 1538275SEric Cheng 1548275SEric Cheng typedef struct resource_prop_s { 1558275SEric Cheng /* 1568275SEric Cheng * resource property name 1578275SEric Cheng */ 1588275SEric Cheng char *rp_name; 1598275SEric Cheng 1608275SEric Cheng /* 1618275SEric Cheng * callback to extract kernel structure 1628275SEric Cheng */ 1638275SEric Cheng rp_extractf_t *rp_extract; 1648275SEric Cheng } resource_prop_t; 1658275SEric Cheng 16610491SRishi.Srivatsavai@Sun.COM /* 16710491SRishi.Srivatsavai@Sun.COM * Set for bridged links only 16810491SRishi.Srivatsavai@Sun.COM */ 16910491SRishi.Srivatsavai@Sun.COM #define FBRIDGE "bridge" /* string */ 17010491SRishi.Srivatsavai@Sun.COM 1713147Sxc151355 #ifdef __cplusplus 1723147Sxc151355 } 1733147Sxc151355 #endif 1743147Sxc151355 1753147Sxc151355 #endif /* _LIBDLADM_IMPL_H */ 176