summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/dls_mgmt.h
blob: b60e53b267877c9215bd6aba2ed0f5d617da2fba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright 2015, Joyent, Inc.
 */

#ifndef	_DLS_MGMT_H
#define	_DLS_MGMT_H

#include <sys/types.h>
#include <sys/param.h>
#include <sys/zone.h>

/*
 * Data-Link Services Module
 */

#ifdef	__cplusplus
extern "C" {
#endif

typedef enum {
	DATALINK_CLASS_PHYS		= 0x01,
	DATALINK_CLASS_VLAN		= 0x02,
	DATALINK_CLASS_AGGR		= 0x04,
	DATALINK_CLASS_VNIC		= 0x08,
	DATALINK_CLASS_ETHERSTUB	= 0x10,
	DATALINK_CLASS_SIMNET		= 0x20,
	DATALINK_CLASS_BRIDGE		= 0x40,
	DATALINK_CLASS_IPTUN		= 0x80,
	DATALINK_CLASS_PART		= 0x100,
	DATALINK_CLASS_OVERLAY		= 0x200
} datalink_class_t;

#define	DATALINK_CLASS_ALL	(DATALINK_CLASS_PHYS |	\
	DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \
	DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET | \
	DATALINK_CLASS_BRIDGE | DATALINK_CLASS_IPTUN | DATALINK_CLASS_PART | \
	DATALINK_CLASS_OVERLAY)

/*
 * A combination of flags and media.
 *   flags is the higher 32 bits, and if it is 0x01, it indicates all media
 *   types can be accepted; otherwise, only the given media type (specified
 *   in the lower 32 bits) is accepted.
 */
typedef uint64_t	datalink_media_t;

#define	DATALINK_ANY_MEDIATYPE		\
	((datalink_media_t)(((datalink_media_t)0x01) << 32))

#define	DATALINK_MEDIA_ACCEPTED(dmedia, media)				\
	(((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ?		\
	B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media)))

#define	MAXLINKATTRLEN		32
#define	MAXLINKATTRVALLEN	1024

/*
 * Link attributes used by the kernel.
 */
/*
 * The major number and instance number of the underlying physical device
 * are kept as FPHYMAJ and FPHYINST (major, instance + 1).
 *
 * Set for physical links only.
 */
#define	FPHYMAJ		"phymaj"	/* uint64_t */
#define	FPHYINST	"phyinst"	/* uint64_t */

/*
 * The devname of the physical link. For example, bge0, ce1. Set for physical
 * links only.
 */
#define	FDEVNAME	"devname"	/* string */

/*
 * The door file for the dlmgmtd (data-link management) daemon.
 */
#define	DLMGMT_TMPFS_DIR	"/etc/svc/volatile/dladm"
#define	DLMGMT_DOOR		DLMGMT_TMPFS_DIR "/dlmgmt_door"

/*
 * Door upcall commands.
 */
#define	DLMGMT_CMD_DLS_CREATE		1
#define	DLMGMT_CMD_DLS_GETATTR		2
#define	DLMGMT_CMD_DLS_DESTROY		3
#define	DLMGMT_CMD_GETNAME		4
#define	DLMGMT_CMD_GETLINKID		5
#define	DLMGMT_CMD_GETNEXT		6
#define	DLMGMT_CMD_DLS_UPDATE		7
#define	DLMGMT_CMD_LINKPROP_INIT	8
#define	DLMGMT_CMD_SETZONEID		9
#define	DLMGMT_CMD_BASE			128

/*
 * Indicate the link mapping is active or persistent
 */
#define	DLMGMT_ACTIVE		0x01
#define	DLMGMT_PERSIST		0x02

/* upcall argument */
typedef struct dlmgmt_door_arg {
	uint_t			ld_cmd;
} dlmgmt_door_arg_t;

typedef struct dlmgmt_upcall_arg_create {
	int			ld_cmd;
	datalink_class_t	ld_class;
	uint32_t		ld_media;
	boolean_t		ld_persist;
	uint64_t		ld_phymaj;
	uint64_t		ld_phyinst;
	char			ld_devname[MAXNAMELEN];
} dlmgmt_upcall_arg_create_t;

/*
 * Note: ld_padding is necessary to keep the size of the structure the
 * same on amd64 and i386.  The same note applies to other ld_padding
 * and lr_paddding fields in structures throughout this file.
 */
typedef struct dlmgmt_upcall_arg_destroy {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
	boolean_t		ld_persist;
	int			ld_padding;
} dlmgmt_upcall_arg_destroy_t;

typedef struct dlmgmt_upcall_arg_update {
	int			ld_cmd;
	boolean_t		ld_novanity;
	uint32_t		ld_media;
	uint32_t		ld_padding;
	char			ld_devname[MAXNAMELEN];
} dlmgmt_upcall_arg_update_t;

typedef struct dlmgmt_upcall_arg_getattr {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
	char			ld_attr[MAXLINKATTRLEN];
} dlmgmt_upcall_arg_getattr_t;

typedef struct dlmgmt_door_getname {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
} dlmgmt_door_getname_t;

typedef struct dlmgmt_door_getlinkid {
	int			ld_cmd;
	char			ld_link[MAXLINKNAMELEN];
} dlmgmt_door_getlinkid_t;

typedef struct dlmgmt_door_getnext_s {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
	datalink_class_t	ld_class;
	uint32_t		ld_flags;
	datalink_media_t	ld_dmedia;
} dlmgmt_door_getnext_t;

typedef struct dlmgmt_door_linkprop_init {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
} dlmgmt_door_linkprop_init_t;

typedef struct dlmgmt_door_setzoneid {
	int			ld_cmd;
	datalink_id_t		ld_linkid;
	zoneid_t		ld_zoneid;
} dlmgmt_door_setzoneid_t;

/* upcall return value */
typedef struct dlmgmt_retval_s {
	uint_t			lr_err; /* return error code */
} dlmgmt_retval_t;

typedef dlmgmt_retval_t	dlmgmt_destroy_retval_t,
			dlmgmt_linkprop_init_retval_t,
			dlmgmt_setzoneid_retval_t;

struct dlmgmt_linkid_retval_s {
	uint_t			lr_err;
	datalink_id_t		lr_linkid;
	uint32_t		lr_flags;
	datalink_class_t	lr_class;
	uint32_t		lr_media;
	uint32_t		lr_padding;
};

typedef struct dlmgmt_linkid_retval_s	dlmgmt_create_retval_t,
					dlmgmt_update_retval_t,
					dlmgmt_getlinkid_retval_t,
					dlmgmt_getnext_retval_t;

typedef struct dlmgmt_getname_retval_s {
	uint_t			lr_err;
	char			lr_link[MAXLINKNAMELEN];
	datalink_class_t	lr_class;
	uint32_t		lr_media;
	uint32_t		lr_flags;
} dlmgmt_getname_retval_t;

typedef struct dlmgmt_getattr_retval_s {
	uint_t			lr_err;
	uint_t			lr_type;
	uint_t			lr_attrsz;
	uint_t			lr_padding;
	char			lr_attrval[MAXLINKATTRVALLEN];
} dlmgmt_getattr_retval_t;


#ifdef	__cplusplus
}
#endif

#endif	/* _DLS_MGMT_H */