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