xref: /titanic_51/usr/src/uts/common/sys/dls_mgmt.h (revision f689bed18bbb72c93b14a451e959b18f7ccfb7d1)
1da14cebeSEric Cheng /*
2da14cebeSEric Cheng  * CDDL HEADER START
3da14cebeSEric Cheng  *
4da14cebeSEric Cheng  * The contents of this file are subject to the terms of the
5da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
7da14cebeSEric Cheng  *
8da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
10da14cebeSEric Cheng  * See the License for the specific language governing permissions
11da14cebeSEric Cheng  * and limitations under the License.
12da14cebeSEric Cheng  *
13da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da14cebeSEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
16da14cebeSEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
17da14cebeSEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
18da14cebeSEric Cheng  *
19da14cebeSEric Cheng  * CDDL HEADER END
20da14cebeSEric Cheng  */
21da14cebeSEric Cheng /*
221cfa752fSRamaswamy Tummala  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23da14cebeSEric Cheng  */
24da14cebeSEric Cheng 
25da14cebeSEric Cheng #ifndef	_DLS_MGMT_H
26da14cebeSEric Cheng #define	_DLS_MGMT_H
27da14cebeSEric Cheng 
28da14cebeSEric Cheng #include <sys/types.h>
294eaa4710SRishi Srivatsavai #include <sys/param.h>
302b24ab6bSSebastien Roy #include <sys/zone.h>
31da14cebeSEric Cheng 
32da14cebeSEric Cheng /*
33da14cebeSEric Cheng  * Data-Link Services Module
34da14cebeSEric Cheng  */
35da14cebeSEric Cheng 
36da14cebeSEric Cheng #ifdef	__cplusplus
37da14cebeSEric Cheng extern "C" {
38da14cebeSEric Cheng #endif
39da14cebeSEric Cheng 
40da14cebeSEric Cheng typedef enum {
41da14cebeSEric Cheng 	DATALINK_CLASS_PHYS		= 0x01,
42da14cebeSEric Cheng 	DATALINK_CLASS_VLAN		= 0x02,
43da14cebeSEric Cheng 	DATALINK_CLASS_AGGR		= 0x04,
44da14cebeSEric Cheng 	DATALINK_CLASS_VNIC		= 0x08,
45b509e89bSRishi Srivatsavai 	DATALINK_CLASS_ETHERSTUB	= 0x10,
464eaa4710SRishi Srivatsavai 	DATALINK_CLASS_SIMNET		= 0x20,
472b24ab6bSSebastien Roy 	DATALINK_CLASS_BRIDGE		= 0x40,
48*f689bed1SRishi Srivatsavai 	DATALINK_CLASS_IPTUN		= 0x80,
491cfa752fSRamaswamy Tummala 	DATALINK_CLASS_PART		= 0x100
50da14cebeSEric Cheng } datalink_class_t;
51da14cebeSEric Cheng 
52da14cebeSEric Cheng #define	DATALINK_CLASS_ALL	(DATALINK_CLASS_PHYS |	\
53da14cebeSEric Cheng 	DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \
544eaa4710SRishi Srivatsavai 	DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET | \
551cfa752fSRamaswamy Tummala 	DATALINK_CLASS_BRIDGE | DATALINK_CLASS_IPTUN | DATALINK_CLASS_PART)
56da14cebeSEric Cheng 
57da14cebeSEric Cheng /*
58da14cebeSEric Cheng  * A combination of flags and media.
59da14cebeSEric Cheng  *   flags is the higher 32 bits, and if it is 0x01, it indicates all media
60da14cebeSEric Cheng  *   types can be accepted; otherwise, only the given media type (specified
61da14cebeSEric Cheng  *   in the lower 32 bits) is accepted.
62da14cebeSEric Cheng  */
63da14cebeSEric Cheng typedef uint64_t	datalink_media_t;
64da14cebeSEric Cheng 
65da14cebeSEric Cheng #define	DATALINK_ANY_MEDIATYPE		\
66da14cebeSEric Cheng 	((datalink_media_t)(((datalink_media_t)0x01) << 32))
67da14cebeSEric Cheng 
68da14cebeSEric Cheng #define	DATALINK_MEDIA_ACCEPTED(dmedia, media)				\
69da14cebeSEric Cheng 	(((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ?		\
70da14cebeSEric Cheng 	B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media)))
71da14cebeSEric Cheng 
72da14cebeSEric Cheng #define	MAXLINKATTRLEN		32
73da14cebeSEric Cheng #define	MAXLINKATTRVALLEN	1024
74da14cebeSEric Cheng 
75da14cebeSEric Cheng /*
76da14cebeSEric Cheng  * Link attributes used by the kernel.
77da14cebeSEric Cheng  */
78da14cebeSEric Cheng /*
79da14cebeSEric Cheng  * The major number and instance number of the underlying physical device
80da14cebeSEric Cheng  * are kept as FPHYMAJ and FPHYINST (major, instance + 1).
81da14cebeSEric Cheng  *
82da14cebeSEric Cheng  * Set for physical links only.
83da14cebeSEric Cheng  */
84da14cebeSEric Cheng #define	FPHYMAJ		"phymaj"	/* uint64_t */
85da14cebeSEric Cheng #define	FPHYINST	"phyinst"	/* uint64_t */
86da14cebeSEric Cheng 
87da14cebeSEric Cheng /*
88da14cebeSEric Cheng  * The devname of the physical link. For example, bge0, ce1. Set for physical
89da14cebeSEric Cheng  * links only.
90da14cebeSEric Cheng  */
91da14cebeSEric Cheng #define	FDEVNAME	"devname"	/* string */
92da14cebeSEric Cheng 
93da14cebeSEric Cheng /*
94da14cebeSEric Cheng  * The door file for the dlmgmtd (data-link management) daemon.
95da14cebeSEric Cheng  */
962b24ab6bSSebastien Roy #define	DLMGMT_TMPFS_DIR	"/etc/svc/volatile/dladm"
972b24ab6bSSebastien Roy #define	DLMGMT_DOOR		DLMGMT_TMPFS_DIR "/dlmgmt_door"
98da14cebeSEric Cheng 
99da14cebeSEric Cheng /*
100da14cebeSEric Cheng  * Door upcall commands.
101da14cebeSEric Cheng  */
102da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_CREATE		1
103da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_GETATTR		2
104da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_DESTROY		3
105da14cebeSEric Cheng #define	DLMGMT_CMD_GETNAME		4
106da14cebeSEric Cheng #define	DLMGMT_CMD_GETLINKID		5
107da14cebeSEric Cheng #define	DLMGMT_CMD_GETNEXT		6
108da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_UPDATE		7
109da14cebeSEric Cheng #define	DLMGMT_CMD_LINKPROP_INIT	8
1102b24ab6bSSebastien Roy #define	DLMGMT_CMD_SETZONEID		9
111da14cebeSEric Cheng #define	DLMGMT_CMD_BASE			128
112da14cebeSEric Cheng 
113da14cebeSEric Cheng /*
114da14cebeSEric Cheng  * Indicate the link mapping is active or persistent
115da14cebeSEric Cheng  */
116da14cebeSEric Cheng #define	DLMGMT_ACTIVE		0x01
117da14cebeSEric Cheng #define	DLMGMT_PERSIST		0x02
118da14cebeSEric Cheng 
119da14cebeSEric Cheng /* upcall argument */
120da14cebeSEric Cheng typedef struct dlmgmt_door_arg {
121da14cebeSEric Cheng 	uint_t			ld_cmd;
122da14cebeSEric Cheng } dlmgmt_door_arg_t;
123da14cebeSEric Cheng 
124da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_create {
125da14cebeSEric Cheng 	int			ld_cmd;
126da14cebeSEric Cheng 	datalink_class_t	ld_class;
127da14cebeSEric Cheng 	uint32_t		ld_media;
128da14cebeSEric Cheng 	boolean_t		ld_persist;
129da14cebeSEric Cheng 	uint64_t		ld_phymaj;
130da14cebeSEric Cheng 	uint64_t		ld_phyinst;
131da14cebeSEric Cheng 	char			ld_devname[MAXNAMELEN];
132da14cebeSEric Cheng } dlmgmt_upcall_arg_create_t;
133da14cebeSEric Cheng 
134da14cebeSEric Cheng /*
135da14cebeSEric Cheng  * Note: ld_padding is necessary to keep the size of the structure the
136da14cebeSEric Cheng  * same on amd64 and i386.  The same note applies to other ld_padding
137da14cebeSEric Cheng  * and lr_paddding fields in structures throughout this file.
138da14cebeSEric Cheng  */
139da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_destroy {
140da14cebeSEric Cheng 	int			ld_cmd;
141da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
142da14cebeSEric Cheng 	boolean_t		ld_persist;
143da14cebeSEric Cheng 	int			ld_padding;
144da14cebeSEric Cheng } dlmgmt_upcall_arg_destroy_t;
145da14cebeSEric Cheng 
146da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_update {
147da14cebeSEric Cheng 	int			ld_cmd;
148da14cebeSEric Cheng 	boolean_t		ld_novanity;
149da14cebeSEric Cheng 	uint32_t		ld_media;
150da14cebeSEric Cheng 	uint32_t		ld_padding;
151da14cebeSEric Cheng 	char			ld_devname[MAXNAMELEN];
152da14cebeSEric Cheng } dlmgmt_upcall_arg_update_t;
153da14cebeSEric Cheng 
154da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_getattr {
155da14cebeSEric Cheng 	int			ld_cmd;
156da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
157da14cebeSEric Cheng 	char			ld_attr[MAXLINKATTRLEN];
158da14cebeSEric Cheng } dlmgmt_upcall_arg_getattr_t;
159da14cebeSEric Cheng 
160da14cebeSEric Cheng typedef struct dlmgmt_door_getname {
161da14cebeSEric Cheng 	int			ld_cmd;
162da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
163da14cebeSEric Cheng } dlmgmt_door_getname_t;
164da14cebeSEric Cheng 
165da14cebeSEric Cheng typedef struct dlmgmt_door_getlinkid {
166da14cebeSEric Cheng 	int			ld_cmd;
167da14cebeSEric Cheng 	char			ld_link[MAXLINKNAMELEN];
168da14cebeSEric Cheng } dlmgmt_door_getlinkid_t;
169da14cebeSEric Cheng 
170da14cebeSEric Cheng typedef struct dlmgmt_door_getnext_s {
171da14cebeSEric Cheng 	int			ld_cmd;
172da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
173da14cebeSEric Cheng 	datalink_class_t	ld_class;
174da14cebeSEric Cheng 	uint32_t		ld_flags;
175da14cebeSEric Cheng 	datalink_media_t	ld_dmedia;
176da14cebeSEric Cheng } dlmgmt_door_getnext_t;
177da14cebeSEric Cheng 
178da14cebeSEric Cheng typedef struct dlmgmt_door_linkprop_init {
179da14cebeSEric Cheng 	int			ld_cmd;
180da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
181da14cebeSEric Cheng } dlmgmt_door_linkprop_init_t;
182da14cebeSEric Cheng 
1832b24ab6bSSebastien Roy typedef struct dlmgmt_door_setzoneid {
1842b24ab6bSSebastien Roy 	int			ld_cmd;
1852b24ab6bSSebastien Roy 	datalink_id_t		ld_linkid;
1862b24ab6bSSebastien Roy 	zoneid_t		ld_zoneid;
1872b24ab6bSSebastien Roy } dlmgmt_door_setzoneid_t;
1882b24ab6bSSebastien Roy 
189da14cebeSEric Cheng /* upcall return value */
190da14cebeSEric Cheng typedef struct dlmgmt_retval_s {
191da14cebeSEric Cheng 	uint_t			lr_err; /* return error code */
192da14cebeSEric Cheng } dlmgmt_retval_t;
193da14cebeSEric Cheng 
194da14cebeSEric Cheng typedef dlmgmt_retval_t	dlmgmt_destroy_retval_t,
1952b24ab6bSSebastien Roy 			dlmgmt_linkprop_init_retval_t,
1962b24ab6bSSebastien Roy 			dlmgmt_setzoneid_retval_t;
197da14cebeSEric Cheng 
198da14cebeSEric Cheng struct dlmgmt_linkid_retval_s {
199da14cebeSEric Cheng 	uint_t			lr_err;
200da14cebeSEric Cheng 	datalink_id_t		lr_linkid;
201da14cebeSEric Cheng 	uint32_t		lr_flags;
202da14cebeSEric Cheng 	datalink_class_t	lr_class;
203da14cebeSEric Cheng 	uint32_t		lr_media;
204da14cebeSEric Cheng 	uint32_t		lr_padding;
205da14cebeSEric Cheng };
206da14cebeSEric Cheng 
207da14cebeSEric Cheng typedef struct dlmgmt_linkid_retval_s	dlmgmt_create_retval_t,
208da14cebeSEric Cheng 					dlmgmt_update_retval_t,
209da14cebeSEric Cheng 					dlmgmt_getlinkid_retval_t,
210da14cebeSEric Cheng 					dlmgmt_getnext_retval_t;
211da14cebeSEric Cheng 
212da14cebeSEric Cheng typedef struct dlmgmt_getname_retval_s {
213da14cebeSEric Cheng 	uint_t			lr_err;
214da14cebeSEric Cheng 	char			lr_link[MAXLINKNAMELEN];
215da14cebeSEric Cheng 	datalink_class_t	lr_class;
216da14cebeSEric Cheng 	uint32_t		lr_media;
217da14cebeSEric Cheng 	uint32_t		lr_flags;
218da14cebeSEric Cheng } dlmgmt_getname_retval_t;
219da14cebeSEric Cheng 
220da14cebeSEric Cheng typedef struct dlmgmt_getattr_retval_s {
221da14cebeSEric Cheng 	uint_t			lr_err;
222da14cebeSEric Cheng 	uint_t			lr_type;
223da14cebeSEric Cheng 	uint_t			lr_attrsz;
224da14cebeSEric Cheng 	uint_t			lr_padding;
225da14cebeSEric Cheng 	char			lr_attrval[MAXLINKATTRVALLEN];
226da14cebeSEric Cheng } dlmgmt_getattr_retval_t;
227da14cebeSEric Cheng 
228da14cebeSEric Cheng #ifdef	__cplusplus
229da14cebeSEric Cheng }
230da14cebeSEric Cheng #endif
231da14cebeSEric Cheng 
232da14cebeSEric Cheng #endif	/* _DLS_MGMT_H */
233