xref: /titanic_52/usr/src/uts/common/sys/dls_mgmt.h (revision 75ce41a57ff334bd8fe2cb9ed51eea835892f944)
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/dld.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_t;
48 
49 #define	DATALINK_CLASS_ALL	(DATALINK_CLASS_PHYS |	\
50 	DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \
51 	DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET)
52 
53 /*
54  * A combination of flags and media.
55  *   flags is the higher 32 bits, and if it is 0x01, it indicates all media
56  *   types can be accepted; otherwise, only the given media type (specified
57  *   in the lower 32 bits) is accepted.
58  */
59 typedef uint64_t	datalink_media_t;
60 
61 #define	DATALINK_ANY_MEDIATYPE		\
62 	((datalink_media_t)(((datalink_media_t)0x01) << 32))
63 
64 #define	DATALINK_MEDIA_ACCEPTED(dmedia, media)				\
65 	(((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ?		\
66 	B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media)))
67 
68 #define	MAXLINKATTRLEN		32
69 #define	MAXLINKATTRVALLEN	1024
70 
71 /*
72  * Link attributes used by the kernel.
73  */
74 /*
75  * The major number and instance number of the underlying physical device
76  * are kept as FPHYMAJ and FPHYINST (major, instance + 1).
77  *
78  * Set for physical links only.
79  */
80 #define	FPHYMAJ		"phymaj"	/* uint64_t */
81 #define	FPHYINST	"phyinst"	/* uint64_t */
82 
83 /*
84  * The devname of the physical link. For example, bge0, ce1. Set for physical
85  * links only.
86  */
87 #define	FDEVNAME	"devname"	/* string */
88 
89 /*
90  * The door file for the dlmgmtd (data-link management) daemon.
91  */
92 #define	DLMGMT_DOOR	"/etc/svc/volatile/dladm/dlmgmt_door"
93 
94 /*
95  * Door upcall commands.
96  */
97 #define	DLMGMT_CMD_DLS_CREATE		1
98 #define	DLMGMT_CMD_DLS_GETATTR		2
99 #define	DLMGMT_CMD_DLS_DESTROY		3
100 #define	DLMGMT_CMD_GETNAME		4
101 #define	DLMGMT_CMD_GETLINKID		5
102 #define	DLMGMT_CMD_GETNEXT		6
103 #define	DLMGMT_CMD_DLS_UPDATE		7
104 #define	DLMGMT_CMD_LINKPROP_INIT	8
105 #define	DLMGMT_CMD_BASE			128
106 
107 /*
108  * Indicate the link mapping is active or persistent
109  */
110 #define	DLMGMT_ACTIVE		0x01
111 #define	DLMGMT_PERSIST		0x02
112 
113 /* upcall argument */
114 typedef struct dlmgmt_door_arg {
115 	uint_t			ld_cmd;
116 } dlmgmt_door_arg_t;
117 
118 typedef struct dlmgmt_upcall_arg_create {
119 	int			ld_cmd;
120 	datalink_class_t	ld_class;
121 	uint32_t		ld_media;
122 	boolean_t		ld_persist;
123 	uint64_t		ld_phymaj;
124 	uint64_t		ld_phyinst;
125 	char			ld_devname[MAXNAMELEN];
126 } dlmgmt_upcall_arg_create_t;
127 
128 /*
129  * Note: ld_padding is necessary to keep the size of the structure the
130  * same on amd64 and i386.  The same note applies to other ld_padding
131  * and lr_paddding fields in structures throughout this file.
132  */
133 typedef struct dlmgmt_upcall_arg_destroy {
134 	int			ld_cmd;
135 	datalink_id_t		ld_linkid;
136 	boolean_t		ld_persist;
137 	int			ld_padding;
138 } dlmgmt_upcall_arg_destroy_t;
139 
140 typedef struct dlmgmt_upcall_arg_update {
141 	int			ld_cmd;
142 	boolean_t		ld_novanity;
143 	uint32_t		ld_media;
144 	uint32_t		ld_padding;
145 	char			ld_devname[MAXNAMELEN];
146 } dlmgmt_upcall_arg_update_t;
147 
148 typedef struct dlmgmt_upcall_arg_getattr {
149 	int			ld_cmd;
150 	datalink_id_t		ld_linkid;
151 	char			ld_attr[MAXLINKATTRLEN];
152 } dlmgmt_upcall_arg_getattr_t;
153 
154 typedef struct dlmgmt_door_getname {
155 	int			ld_cmd;
156 	datalink_id_t		ld_linkid;
157 } dlmgmt_door_getname_t;
158 
159 typedef struct dlmgmt_door_getlinkid {
160 	int			ld_cmd;
161 	char			ld_link[MAXLINKNAMELEN];
162 } dlmgmt_door_getlinkid_t;
163 
164 typedef struct dlmgmt_door_getnext_s {
165 	int			ld_cmd;
166 	datalink_id_t		ld_linkid;
167 	datalink_class_t	ld_class;
168 	uint32_t		ld_flags;
169 	datalink_media_t	ld_dmedia;
170 } dlmgmt_door_getnext_t;
171 
172 typedef struct dlmgmt_door_linkprop_init {
173 	int			ld_cmd;
174 	datalink_id_t		ld_linkid;
175 } dlmgmt_door_linkprop_init_t;
176 
177 /* upcall return value */
178 typedef struct dlmgmt_retval_s {
179 	uint_t			lr_err; /* return error code */
180 } dlmgmt_retval_t;
181 
182 typedef dlmgmt_retval_t	dlmgmt_destroy_retval_t,
183 			dlmgmt_linkprop_init_retval_t;
184 
185 struct dlmgmt_linkid_retval_s {
186 	uint_t			lr_err;
187 	datalink_id_t		lr_linkid;
188 	uint32_t		lr_flags;
189 	datalink_class_t	lr_class;
190 	uint32_t		lr_media;
191 	uint32_t		lr_padding;
192 };
193 
194 typedef struct dlmgmt_linkid_retval_s	dlmgmt_create_retval_t,
195 					dlmgmt_update_retval_t,
196 					dlmgmt_getlinkid_retval_t,
197 					dlmgmt_getnext_retval_t;
198 
199 typedef struct dlmgmt_getname_retval_s {
200 	uint_t			lr_err;
201 	char			lr_link[MAXLINKNAMELEN];
202 	datalink_class_t	lr_class;
203 	uint32_t		lr_media;
204 	uint32_t		lr_flags;
205 } dlmgmt_getname_retval_t;
206 
207 typedef struct dlmgmt_getattr_retval_s {
208 	uint_t			lr_err;
209 	uint_t			lr_type;
210 	uint_t			lr_attrsz;
211 	uint_t			lr_padding;
212 	char			lr_attrval[MAXLINKATTRVALLEN];
213 } dlmgmt_getattr_retval_t;
214 
215 #ifdef	__cplusplus
216 }
217 #endif
218 
219 #endif	/* _DLS_MGMT_H */
220