xref: /illumos-gate/usr/src/uts/common/sys/dls_mgmt.h (revision 36589d6b)
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.
23*36589d6bSRobert Mustacchi  * Copyright 2015, Joyent, Inc.
24da14cebeSEric Cheng  */
25da14cebeSEric Cheng 
26da14cebeSEric Cheng #ifndef	_DLS_MGMT_H
27da14cebeSEric Cheng #define	_DLS_MGMT_H
28da14cebeSEric Cheng 
29da14cebeSEric Cheng #include <sys/types.h>
304eaa4710SRishi Srivatsavai #include <sys/param.h>
312b24ab6bSSebastien Roy #include <sys/zone.h>
32da14cebeSEric Cheng 
33da14cebeSEric Cheng /*
34da14cebeSEric Cheng  * Data-Link Services Module
35da14cebeSEric Cheng  */
36da14cebeSEric Cheng 
37da14cebeSEric Cheng #ifdef	__cplusplus
38da14cebeSEric Cheng extern "C" {
39da14cebeSEric Cheng #endif
40da14cebeSEric Cheng 
41da14cebeSEric Cheng typedef enum {
42da14cebeSEric Cheng 	DATALINK_CLASS_PHYS		= 0x01,
43da14cebeSEric Cheng 	DATALINK_CLASS_VLAN		= 0x02,
44da14cebeSEric Cheng 	DATALINK_CLASS_AGGR		= 0x04,
45da14cebeSEric Cheng 	DATALINK_CLASS_VNIC		= 0x08,
46b509e89bSRishi Srivatsavai 	DATALINK_CLASS_ETHERSTUB	= 0x10,
474eaa4710SRishi Srivatsavai 	DATALINK_CLASS_SIMNET		= 0x20,
482b24ab6bSSebastien Roy 	DATALINK_CLASS_BRIDGE		= 0x40,
49f689bed1SRishi Srivatsavai 	DATALINK_CLASS_IPTUN		= 0x80,
50*36589d6bSRobert Mustacchi 	DATALINK_CLASS_PART		= 0x100,
51*36589d6bSRobert Mustacchi 	DATALINK_CLASS_OVERLAY		= 0x200
52da14cebeSEric Cheng } datalink_class_t;
53da14cebeSEric Cheng 
54da14cebeSEric Cheng #define	DATALINK_CLASS_ALL	(DATALINK_CLASS_PHYS |	\
55da14cebeSEric Cheng 	DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \
564eaa4710SRishi Srivatsavai 	DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET | \
57*36589d6bSRobert Mustacchi 	DATALINK_CLASS_BRIDGE | DATALINK_CLASS_IPTUN | DATALINK_CLASS_PART | \
58*36589d6bSRobert Mustacchi 	DATALINK_CLASS_OVERLAY)
59da14cebeSEric Cheng 
60da14cebeSEric Cheng /*
61da14cebeSEric Cheng  * A combination of flags and media.
62da14cebeSEric Cheng  *   flags is the higher 32 bits, and if it is 0x01, it indicates all media
63da14cebeSEric Cheng  *   types can be accepted; otherwise, only the given media type (specified
64da14cebeSEric Cheng  *   in the lower 32 bits) is accepted.
65da14cebeSEric Cheng  */
66da14cebeSEric Cheng typedef uint64_t	datalink_media_t;
67da14cebeSEric Cheng 
68da14cebeSEric Cheng #define	DATALINK_ANY_MEDIATYPE		\
69da14cebeSEric Cheng 	((datalink_media_t)(((datalink_media_t)0x01) << 32))
70da14cebeSEric Cheng 
71da14cebeSEric Cheng #define	DATALINK_MEDIA_ACCEPTED(dmedia, media)				\
72da14cebeSEric Cheng 	(((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ?		\
73da14cebeSEric Cheng 	B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media)))
74da14cebeSEric Cheng 
75da14cebeSEric Cheng #define	MAXLINKATTRLEN		32
76da14cebeSEric Cheng #define	MAXLINKATTRVALLEN	1024
77da14cebeSEric Cheng 
78da14cebeSEric Cheng /*
79da14cebeSEric Cheng  * Link attributes used by the kernel.
80da14cebeSEric Cheng  */
81da14cebeSEric Cheng /*
82da14cebeSEric Cheng  * The major number and instance number of the underlying physical device
83da14cebeSEric Cheng  * are kept as FPHYMAJ and FPHYINST (major, instance + 1).
84da14cebeSEric Cheng  *
85da14cebeSEric Cheng  * Set for physical links only.
86da14cebeSEric Cheng  */
87da14cebeSEric Cheng #define	FPHYMAJ		"phymaj"	/* uint64_t */
88da14cebeSEric Cheng #define	FPHYINST	"phyinst"	/* uint64_t */
89da14cebeSEric Cheng 
90da14cebeSEric Cheng /*
91da14cebeSEric Cheng  * The devname of the physical link. For example, bge0, ce1. Set for physical
92da14cebeSEric Cheng  * links only.
93da14cebeSEric Cheng  */
94da14cebeSEric Cheng #define	FDEVNAME	"devname"	/* string */
95da14cebeSEric Cheng 
96da14cebeSEric Cheng /*
97da14cebeSEric Cheng  * The door file for the dlmgmtd (data-link management) daemon.
98da14cebeSEric Cheng  */
992b24ab6bSSebastien Roy #define	DLMGMT_TMPFS_DIR	"/etc/svc/volatile/dladm"
1002b24ab6bSSebastien Roy #define	DLMGMT_DOOR		DLMGMT_TMPFS_DIR "/dlmgmt_door"
101da14cebeSEric Cheng 
102da14cebeSEric Cheng /*
103da14cebeSEric Cheng  * Door upcall commands.
104da14cebeSEric Cheng  */
105da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_CREATE		1
106da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_GETATTR		2
107da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_DESTROY		3
108da14cebeSEric Cheng #define	DLMGMT_CMD_GETNAME		4
109da14cebeSEric Cheng #define	DLMGMT_CMD_GETLINKID		5
110da14cebeSEric Cheng #define	DLMGMT_CMD_GETNEXT		6
111da14cebeSEric Cheng #define	DLMGMT_CMD_DLS_UPDATE		7
112da14cebeSEric Cheng #define	DLMGMT_CMD_LINKPROP_INIT	8
1132b24ab6bSSebastien Roy #define	DLMGMT_CMD_SETZONEID		9
114da14cebeSEric Cheng #define	DLMGMT_CMD_BASE			128
115da14cebeSEric Cheng 
116da14cebeSEric Cheng /*
117da14cebeSEric Cheng  * Indicate the link mapping is active or persistent
118da14cebeSEric Cheng  */
119da14cebeSEric Cheng #define	DLMGMT_ACTIVE		0x01
120da14cebeSEric Cheng #define	DLMGMT_PERSIST		0x02
121da14cebeSEric Cheng 
122da14cebeSEric Cheng /* upcall argument */
123da14cebeSEric Cheng typedef struct dlmgmt_door_arg {
124da14cebeSEric Cheng 	uint_t			ld_cmd;
125da14cebeSEric Cheng } dlmgmt_door_arg_t;
126da14cebeSEric Cheng 
127da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_create {
128da14cebeSEric Cheng 	int			ld_cmd;
129da14cebeSEric Cheng 	datalink_class_t	ld_class;
130da14cebeSEric Cheng 	uint32_t		ld_media;
131da14cebeSEric Cheng 	boolean_t		ld_persist;
132da14cebeSEric Cheng 	uint64_t		ld_phymaj;
133da14cebeSEric Cheng 	uint64_t		ld_phyinst;
134da14cebeSEric Cheng 	char			ld_devname[MAXNAMELEN];
135da14cebeSEric Cheng } dlmgmt_upcall_arg_create_t;
136da14cebeSEric Cheng 
137da14cebeSEric Cheng /*
138da14cebeSEric Cheng  * Note: ld_padding is necessary to keep the size of the structure the
139da14cebeSEric Cheng  * same on amd64 and i386.  The same note applies to other ld_padding
140da14cebeSEric Cheng  * and lr_paddding fields in structures throughout this file.
141da14cebeSEric Cheng  */
142da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_destroy {
143da14cebeSEric Cheng 	int			ld_cmd;
144da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
145da14cebeSEric Cheng 	boolean_t		ld_persist;
146da14cebeSEric Cheng 	int			ld_padding;
147da14cebeSEric Cheng } dlmgmt_upcall_arg_destroy_t;
148da14cebeSEric Cheng 
149da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_update {
150da14cebeSEric Cheng 	int			ld_cmd;
151da14cebeSEric Cheng 	boolean_t		ld_novanity;
152da14cebeSEric Cheng 	uint32_t		ld_media;
153da14cebeSEric Cheng 	uint32_t		ld_padding;
154da14cebeSEric Cheng 	char			ld_devname[MAXNAMELEN];
155da14cebeSEric Cheng } dlmgmt_upcall_arg_update_t;
156da14cebeSEric Cheng 
157da14cebeSEric Cheng typedef struct dlmgmt_upcall_arg_getattr {
158da14cebeSEric Cheng 	int			ld_cmd;
159da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
160da14cebeSEric Cheng 	char			ld_attr[MAXLINKATTRLEN];
161da14cebeSEric Cheng } dlmgmt_upcall_arg_getattr_t;
162da14cebeSEric Cheng 
163da14cebeSEric Cheng typedef struct dlmgmt_door_getname {
164da14cebeSEric Cheng 	int			ld_cmd;
165da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
166da14cebeSEric Cheng } dlmgmt_door_getname_t;
167da14cebeSEric Cheng 
168da14cebeSEric Cheng typedef struct dlmgmt_door_getlinkid {
169da14cebeSEric Cheng 	int			ld_cmd;
170da14cebeSEric Cheng 	char			ld_link[MAXLINKNAMELEN];
171da14cebeSEric Cheng } dlmgmt_door_getlinkid_t;
172da14cebeSEric Cheng 
173da14cebeSEric Cheng typedef struct dlmgmt_door_getnext_s {
174da14cebeSEric Cheng 	int			ld_cmd;
175da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
176da14cebeSEric Cheng 	datalink_class_t	ld_class;
177da14cebeSEric Cheng 	uint32_t		ld_flags;
178da14cebeSEric Cheng 	datalink_media_t	ld_dmedia;
179da14cebeSEric Cheng } dlmgmt_door_getnext_t;
180da14cebeSEric Cheng 
181da14cebeSEric Cheng typedef struct dlmgmt_door_linkprop_init {
182da14cebeSEric Cheng 	int			ld_cmd;
183da14cebeSEric Cheng 	datalink_id_t		ld_linkid;
184da14cebeSEric Cheng } dlmgmt_door_linkprop_init_t;
185da14cebeSEric Cheng 
1862b24ab6bSSebastien Roy typedef struct dlmgmt_door_setzoneid {
1872b24ab6bSSebastien Roy 	int			ld_cmd;
1882b24ab6bSSebastien Roy 	datalink_id_t		ld_linkid;
1892b24ab6bSSebastien Roy 	zoneid_t		ld_zoneid;
1902b24ab6bSSebastien Roy } dlmgmt_door_setzoneid_t;
1912b24ab6bSSebastien Roy 
192da14cebeSEric Cheng /* upcall return value */
193da14cebeSEric Cheng typedef struct dlmgmt_retval_s {
194da14cebeSEric Cheng 	uint_t			lr_err; /* return error code */
195da14cebeSEric Cheng } dlmgmt_retval_t;
196da14cebeSEric Cheng 
197da14cebeSEric Cheng typedef dlmgmt_retval_t	dlmgmt_destroy_retval_t,
1982b24ab6bSSebastien Roy 			dlmgmt_linkprop_init_retval_t,
1992b24ab6bSSebastien Roy 			dlmgmt_setzoneid_retval_t;
200da14cebeSEric Cheng 
201da14cebeSEric Cheng struct dlmgmt_linkid_retval_s {
202da14cebeSEric Cheng 	uint_t			lr_err;
203da14cebeSEric Cheng 	datalink_id_t		lr_linkid;
204da14cebeSEric Cheng 	uint32_t		lr_flags;
205da14cebeSEric Cheng 	datalink_class_t	lr_class;
206da14cebeSEric Cheng 	uint32_t		lr_media;
207da14cebeSEric Cheng 	uint32_t		lr_padding;
208da14cebeSEric Cheng };
209da14cebeSEric Cheng 
210da14cebeSEric Cheng typedef struct dlmgmt_linkid_retval_s	dlmgmt_create_retval_t,
211da14cebeSEric Cheng 					dlmgmt_update_retval_t,
212da14cebeSEric Cheng 					dlmgmt_getlinkid_retval_t,
213da14cebeSEric Cheng 					dlmgmt_getnext_retval_t;
214da14cebeSEric Cheng 
215da14cebeSEric Cheng typedef struct dlmgmt_getname_retval_s {
216da14cebeSEric Cheng 	uint_t			lr_err;
217da14cebeSEric Cheng 	char			lr_link[MAXLINKNAMELEN];
218da14cebeSEric Cheng 	datalink_class_t	lr_class;
219da14cebeSEric Cheng 	uint32_t		lr_media;
220da14cebeSEric Cheng 	uint32_t		lr_flags;
221da14cebeSEric Cheng } dlmgmt_getname_retval_t;
222da14cebeSEric Cheng 
223da14cebeSEric Cheng typedef struct dlmgmt_getattr_retval_s {
224da14cebeSEric Cheng 	uint_t			lr_err;
225da14cebeSEric Cheng 	uint_t			lr_type;
226da14cebeSEric Cheng 	uint_t			lr_attrsz;
227da14cebeSEric Cheng 	uint_t			lr_padding;
228da14cebeSEric Cheng 	char			lr_attrval[MAXLINKATTRVALLEN];
229da14cebeSEric Cheng } dlmgmt_getattr_retval_t;
230da14cebeSEric Cheng 
231a25df667SRobert Mustacchi 
232da14cebeSEric Cheng #ifdef	__cplusplus
233da14cebeSEric Cheng }
234da14cebeSEric Cheng #endif
235da14cebeSEric Cheng 
236da14cebeSEric Cheng #endif	/* _DLS_MGMT_H */
237