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