xref: /titanic_52/usr/src/lib/libdladm/common/libdladm_impl.h (revision 9056fceb0248aaa677b3a3ca8a9cabbf9a1a542d)
10ba2cbe9Sxc151355 /*
20ba2cbe9Sxc151355  * CDDL HEADER START
30ba2cbe9Sxc151355  *
40ba2cbe9Sxc151355  * The contents of this file are subject to the terms of the
50ba2cbe9Sxc151355  * Common Development and Distribution License (the "License").
60ba2cbe9Sxc151355  * You may not use this file except in compliance with the License.
70ba2cbe9Sxc151355  *
80ba2cbe9Sxc151355  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90ba2cbe9Sxc151355  * or http://www.opensolaris.org/os/licensing.
100ba2cbe9Sxc151355  * See the License for the specific language governing permissions
110ba2cbe9Sxc151355  * and limitations under the License.
120ba2cbe9Sxc151355  *
130ba2cbe9Sxc151355  * When distributing Covered Code, include this CDDL HEADER in each
140ba2cbe9Sxc151355  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150ba2cbe9Sxc151355  * If applicable, add the following below this CDDL HEADER, with the
160ba2cbe9Sxc151355  * fields enclosed by brackets "[]" replaced with your own identifying
170ba2cbe9Sxc151355  * information: Portions Copyright [yyyy] [name of copyright owner]
180ba2cbe9Sxc151355  *
190ba2cbe9Sxc151355  * CDDL HEADER END
200ba2cbe9Sxc151355  */
210ba2cbe9Sxc151355 /*
221cfa752fSRamaswamy Tummala  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
230ba2cbe9Sxc151355  */
240ba2cbe9Sxc151355 
250ba2cbe9Sxc151355 #ifndef _LIBDLADM_IMPL_H
260ba2cbe9Sxc151355 #define	_LIBDLADM_IMPL_H
270ba2cbe9Sxc151355 
282b24ab6bSSebastien Roy #include <sys/types.h>
294eaa4710SRishi Srivatsavai #include <sys/mac.h>
304eaa4710SRishi Srivatsavai #include <sys/mac_flow.h>
310ba2cbe9Sxc151355 #include <libdladm.h>
320ba2cbe9Sxc151355 #include <stdio.h>
330ba2cbe9Sxc151355 
340ba2cbe9Sxc151355 #ifdef	__cplusplus
350ba2cbe9Sxc151355 extern "C" {
360ba2cbe9Sxc151355 #endif
370ba2cbe9Sxc151355 
380ba2cbe9Sxc151355 #define	MAXLINELEN		1024
390ba2cbe9Sxc151355 #define	BUFLEN(lim, ptr)	(((lim) > (ptr)) ? ((lim) - (ptr)) : 0)
400dc2366fSVenugopal Iyer #define	V4_PART_OF_V6(v6)	((v6)._S6_un._S6_u32[3])
410ba2cbe9Sxc151355 
424ac67f02SAnurag S. Maskey /*
434ac67f02SAnurag S. Maskey  * The handle contains file descriptors to DLD_CONTROL_DEV and
444ac67f02SAnurag S. Maskey  * DLMGMT_DOOR.  Rather than opening the file descriptor each time
454ac67f02SAnurag S. Maskey  * it is required, the handle is opened by consumers of libdladm
464ac67f02SAnurag S. Maskey  * (e.g., dladm) and then passed to libdladm.
474ac67f02SAnurag S. Maskey  */
484ac67f02SAnurag S. Maskey struct dladm_handle {
494ac67f02SAnurag S. Maskey 	int dld_fd;	/* file descriptor to DLD_CONTROL_DEV */
504ac67f02SAnurag S. Maskey 	int door_fd;	/* file descriptor to DLMGMT_DOOR */
514ac67f02SAnurag S. Maskey };
524ac67f02SAnurag S. Maskey 
534ac67f02SAnurag S. Maskey /* DLMGMT_DOOR can only be accessed by libdladm and dlmgmtd */
544ac67f02SAnurag S. Maskey extern dladm_status_t	dladm_door_fd(dladm_handle_t, int *);
554ac67f02SAnurag S. Maskey 
560ba2cbe9Sxc151355 extern dladm_status_t	dladm_errno2status(int);
574ac67f02SAnurag S. Maskey extern dladm_status_t   i_dladm_rw_db(dladm_handle_t, const char *, mode_t,
584ac67f02SAnurag S. Maskey 			    dladm_status_t (*)(dladm_handle_t, void *, FILE *,
594ac67f02SAnurag S. Maskey 			    FILE *), void *, boolean_t);
600dc2366fSVenugopal Iyer extern dladm_status_t	dladm_get_state(dladm_handle_t, datalink_id_t,
614ac67f02SAnurag S. Maskey 			    link_state_t *);
6225ec3e3dSEric Cheng extern void		dladm_find_setbits32(uint32_t, uint32_t *, uint32_t *);
63da14cebeSEric Cheng extern dladm_status_t	dladm_parse_args(char *, dladm_arg_list_t **,
64da14cebeSEric Cheng 			    boolean_t);
65da14cebeSEric Cheng extern void		dladm_free_args(dladm_arg_list_t *);
66da14cebeSEric Cheng 
67d62bc4baSyz147064 /*
68d62bc4baSyz147064  * Link attributes persisted by dlmgmtd.
69d62bc4baSyz147064  */
70d62bc4baSyz147064 /*
71d62bc4baSyz147064  * Set for VLANs only
72d62bc4baSyz147064  */
73d62bc4baSyz147064 #define	FVLANID		"vid"		/* uint64_t */
74d62bc4baSyz147064 #define	FLINKOVER	"linkover"	/* uint64_t */
75d62bc4baSyz147064 
76d62bc4baSyz147064 /*
77d62bc4baSyz147064  * Set for AGGRs only
78d62bc4baSyz147064  */
79d62bc4baSyz147064 #define	FKEY		"key"		/* uint64_t */
80d62bc4baSyz147064 #define	FNPORTS		"nports"	/* uint64_t */
81d62bc4baSyz147064 #define	FPORTS		"portnames"	/* string */
82d62bc4baSyz147064 #define	FPOLICY		"policy"	/* uint64_t */
83d62bc4baSyz147064 #define	FFIXMACADDR	"fix_macaddr"	/* boolean_t */
84d62bc4baSyz147064 #define	FFORCE		"force"		/* boolean_t */
85d62bc4baSyz147064 #define	FLACPMODE	"lacp_mode"	/* uint64_t */
86d62bc4baSyz147064 #define	FLACPTIMER	"lacp_timer"	/* uint64_t */
87d62bc4baSyz147064 
88da14cebeSEric Cheng /*
89da14cebeSEric Cheng  * Set for VNICs only
90da14cebeSEric Cheng  */
91da14cebeSEric Cheng #define	FMADDRTYPE	"maddrtype"	/* uint64_t */
92da14cebeSEric Cheng #define	FMADDRLEN	"maddrlen"	/* uint64_t */
93da14cebeSEric Cheng #define	FMADDRSLOT	"maddrslot"	/* uint64_t */
94da14cebeSEric Cheng #define	FMADDRPREFIXLEN	"maddrpreflen"	/* uint64_t */
951cb875aeSCathy Zhou #define	FVRID		"vrid"		/* uint64_t */
961cb875aeSCathy Zhou #define	FVRAF		"vraf"		/* uint64_t */
97da14cebeSEric Cheng 
98da14cebeSEric Cheng /*
99b509e89bSRishi Srivatsavai  * Set for simlinks only
100b509e89bSRishi Srivatsavai  */
101b509e89bSRishi Srivatsavai #define	FSIMNETTYPE	"simnettype"	/* uint64_t */
102b509e89bSRishi Srivatsavai #define	FSIMNETPEER	"simnetpeer"	/* uint64_t */
103b509e89bSRishi Srivatsavai 
104b509e89bSRishi Srivatsavai /*
1051cfa752fSRamaswamy Tummala  * Set for IB partitions only
1061cfa752fSRamaswamy Tummala  */
1071cfa752fSRamaswamy Tummala #define	FPORTPKEY	"pkey"		/* uint64_t */
1081cfa752fSRamaswamy Tummala 
1091cfa752fSRamaswamy Tummala /*
110da14cebeSEric Cheng  * Common fields
111da14cebeSEric Cheng  */
112da14cebeSEric Cheng #define	FMACADDR	"macaddr"	/* string */
113da14cebeSEric Cheng 
114da14cebeSEric Cheng /*
11562ee1d25SArtem Kachitchkine  * List of all the above attributes.
11662ee1d25SArtem Kachitchkine  */
11762ee1d25SArtem Kachitchkine #define	DLADM_ATTR_NAMES	FVLANID, FLINKOVER, \
11862ee1d25SArtem Kachitchkine 				FKEY, FNPORTS, FPORTS, FPOLICY, \
11962ee1d25SArtem Kachitchkine 				FFIXMACADDR, FFORCE, FLACPMODE, FLACPTIMER, \
12062ee1d25SArtem Kachitchkine 				FMADDRTYPE, FMADDRLEN, FMADDRSLOT, \
121*9056fcebSCathy Zhou 				FMADDRPREFIXLEN, FVRID, FVRAF,	\
122b509e89bSRishi Srivatsavai 				FMACADDR, FSIMNETTYPE, FSIMNETPEER
12362ee1d25SArtem Kachitchkine 
12462ee1d25SArtem Kachitchkine /*
125da14cebeSEric Cheng  * Data structures used for implementing temporary properties
126da14cebeSEric Cheng  */
127da14cebeSEric Cheng 
128da14cebeSEric Cheng typedef struct val_desc {
129da14cebeSEric Cheng 	char		*vd_name;
130da14cebeSEric Cheng 	uintptr_t	vd_val;
131da14cebeSEric Cheng } val_desc_t;
132da14cebeSEric Cheng 
133da14cebeSEric Cheng #define	VALCNT(vals)	(sizeof ((vals)) / sizeof (val_desc_t))
134da14cebeSEric Cheng 
1354ac67f02SAnurag S. Maskey extern dladm_status_t	dladm_link_proplist_extract(dladm_handle_t,
1360dc2366fSVenugopal Iyer 			    dladm_arg_list_t *, mac_resource_props_t *,
1370dc2366fSVenugopal Iyer 			    uint_t);
138da14cebeSEric Cheng 
139da14cebeSEric Cheng extern dladm_status_t	dladm_flow_proplist_extract(dladm_arg_list_t *,
140da14cebeSEric Cheng 			    mac_resource_props_t *);
141da14cebeSEric Cheng 
142da14cebeSEric Cheng /*
143da14cebeSEric Cheng  * The prop extract() callback.
144da14cebeSEric Cheng  *
145da14cebeSEric Cheng  * rp_extract extracts the kernel structure from the val_desc_t created
146da14cebeSEric Cheng  * by the pd_check function.
147da14cebeSEric Cheng  */
14825ec3e3dSEric Cheng typedef	dladm_status_t	rp_extractf_t(val_desc_t *, uint_t, void *);
1490dc2366fSVenugopal Iyer extern rp_extractf_t	extract_maxbw, extract_priority,
1500dc2366fSVenugopal Iyer 			extract_cpus, extract_protection,
1510dc2366fSVenugopal Iyer 			extract_allowedips, extract_allowedcids,
1520dc2366fSVenugopal Iyer 			extract_rxrings, extract_txrings, extract_pool;
153da14cebeSEric Cheng 
154da14cebeSEric Cheng typedef struct resource_prop_s {
155da14cebeSEric Cheng 	/*
156da14cebeSEric Cheng 	 * resource property name
157da14cebeSEric Cheng 	 */
158da14cebeSEric Cheng 	char		*rp_name;
159da14cebeSEric Cheng 
160da14cebeSEric Cheng 	/*
161da14cebeSEric Cheng 	 * callback to extract kernel structure
162da14cebeSEric Cheng 	 */
163da14cebeSEric Cheng 	rp_extractf_t	*rp_extract;
164da14cebeSEric Cheng } resource_prop_t;
165da14cebeSEric Cheng 
1664eaa4710SRishi Srivatsavai /*
1674eaa4710SRishi Srivatsavai  * Set for bridged links only
1684eaa4710SRishi Srivatsavai  */
1694eaa4710SRishi Srivatsavai #define	FBRIDGE		"bridge"	/* string */
1704eaa4710SRishi Srivatsavai 
1710ba2cbe9Sxc151355 #ifdef	__cplusplus
1720ba2cbe9Sxc151355 }
1730ba2cbe9Sxc151355 #endif
1740ba2cbe9Sxc151355 
1750ba2cbe9Sxc151355 #endif	/* _LIBDLADM_IMPL_H */
176