xref: /titanic_52/usr/src/uts/common/sys/dld.h (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DLD_H
27 #define	_SYS_DLD_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Data-Link Driver (public header).
33  */
34 
35 #include <sys/types.h>
36 #include <sys/stream.h>
37 #include <sys/conf.h>
38 #include <sys/sad.h>
39 #include <net/if.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Data-Link Driver Information (text emitted by modinfo(1m))
49  */
50 #define	DLD_INFO	"Data-Link Driver v%I%"
51 
52 /*
53  * Options: To enable an option set the property name to a non-zero value
54  *	    in kernel/drv/dld.conf.
55  */
56 
57 /*
58  * Prevent use of the IP fast-path (direct M_DATA transmit).
59  */
60 #define	DLD_PROP_NO_FASTPATH	"no-fastpath"
61 
62 /*
63  * Prevent advertising of the DL_CAPAB_POLL capability.
64  */
65 #define	DLD_PROP_NO_POLL	"no-poll"
66 
67 /*
68  * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
69  */
70 #define	DLD_PROP_NO_ZEROCOPY	"no-zerocopy"
71 
72 /*
73  * Prevent advertising of the DL_CAPAB_SOFTRING capability.
74  */
75 #define	DLD_PROP_NO_SOFTRING	"no-softring"
76 
77 /*
78  * The name of the driver.
79  */
80 #define	DLD_DRIVER_NAME		"dld"
81 
82 /*
83  * The name of the control minor node of dld.
84  */
85 #define	DLD_CONTROL_MINOR_NAME	"ctl"
86 #define	DLD_CONTROL_MINOR	0
87 #define	DLD_CONTROL_DEV		"/devices/pseudo/" DLD_DRIVER_NAME "@0:" \
88 				DLD_CONTROL_MINOR_NAME
89 
90 /*
91  * IOCTL codes and data structures.
92  */
93 #define	DLDIOC		('D' << 24 | 'L' << 16 | 'D' << 8)
94 
95 #define	DLDIOC_ATTR	(DLDIOC | 0x03)
96 
97 typedef uint32_t		datalink_id_t;
98 
99 typedef struct dld_ioc_attr {
100 	datalink_id_t	dia_linkid;
101 	uint_t		dia_max_sdu;
102 } dld_ioc_attr_t;
103 
104 #define	DLDIOC_VLAN_ATTR	(DLDIOC | 0x04)
105 typedef struct dld_ioc_vlan_attr {
106 	datalink_id_t	div_vlanid;
107 	uint16_t	div_vid;
108 	datalink_id_t	div_linkid;
109 	boolean_t	div_force;
110 	boolean_t	div_implicit;
111 } dld_ioc_vlan_attr_t;
112 
113 #define	DLDIOC_PHYS_ATTR	(DLDIOC | 0x05)
114 #define	DLPI_LINKNAME_MAX	32
115 
116 typedef struct dld_ioc_phys_attr {
117 	datalink_id_t	dip_linkid;
118 	/*
119 	 * Whether this physical link supports vanity naming. Note that
120 	 * physical links whose media type is not supported by GLDv3
121 	 * can not support vanity naming.
122 	 */
123 	boolean_t	dip_novanity;
124 	char		dip_dev[MAXLINKNAMELEN];
125 } dld_ioc_phys_attr_t;
126 
127 /*
128  * Secure objects ioctls
129  */
130 typedef enum {
131 	DLD_SECOBJ_CLASS_WEP = 1,
132 	DLD_SECOBJ_CLASS_WPA
133 } dld_secobj_class_t;
134 
135 #define	DLD_SECOBJ_OPT_CREATE	0x00000001
136 #define	DLD_SECOBJ_NAME_MAX	32
137 #define	DLD_SECOBJ_VAL_MAX	256
138 typedef struct dld_secobj {
139 	char			so_name[DLD_SECOBJ_NAME_MAX];
140 	dld_secobj_class_t	so_class;
141 	uint8_t			so_val[DLD_SECOBJ_VAL_MAX];
142 	uint_t			so_len;
143 } dld_secobj_t;
144 
145 #define	DLDIOC_SECOBJ_SET	(DLDIOC | 0x06)
146 typedef struct dld_ioc_secobj_set {
147 	dld_secobj_t		ss_obj;
148 	uint_t			ss_flags;
149 } dld_ioc_secobj_set_t;
150 
151 #define	DLDIOC_SECOBJ_GET	(DLDIOC | 0x07)
152 typedef struct dld_ioc_secobj_get {
153 	dld_secobj_t		sg_obj;
154 	uint_t			sg_count;
155 } dld_ioc_secobj_get_t;
156 
157 /*
158  * The following two slots were used outside of ON, so don't reuse them.
159  *
160  * #define DLDIOCHOLDVLAN (DLDIOC | 0x08)
161  * #define DLDIOCRELEVLAN (DLDIOC | 0x09)
162  */
163 
164 #define	DLDIOC_SECOBJ_UNSET	(DLDIOC | 0x0a)
165 typedef struct dld_ioc_secobj_unset {
166 	char			su_name[DLD_SECOBJ_NAME_MAX];
167 } dld_ioc_secobj_unset_t;
168 
169 #define	DLDIOC_CREATE_VLAN	(DLDIOC | 0x0b)
170 typedef struct dld_ioc_create_vlan {
171 	datalink_id_t	dic_vlanid;
172 	datalink_id_t	dic_linkid;
173 	uint16_t	dic_vid;
174 	boolean_t	dic_force;
175 } dld_ioc_create_vlan_t;
176 
177 #define	DLDIOC_DELETE_VLAN	(DLDIOC | 0x0c)
178 typedef struct dld_ioc_delete_vlan {
179 	datalink_id_t	did_linkid;
180 } dld_ioc_delete_vlan_t;
181 
182 #define	DLDIOC_SETAUTOPUSH	(DLDIOC | 0x0d)
183 #define	DLDIOC_GETAUTOPUSH	(DLDIOC | 0x0e)
184 #define	DLDIOC_CLRAUTOPUSH	(DLDIOC | 0x0f)
185 typedef struct dld_ioc_ap {
186 	datalink_id_t	dia_linkid;
187 	uint_t  	dia_anchor;
188 	uint_t		dia_npush;
189 	char		dia_aplist[MAXAPUSH][FMNAMESZ+1];
190 } dld_ioc_ap_t;
191 
192 #define	DLDIOC_DOORSERVER	(DLDIOC | 0x10)
193 typedef struct dld_ioc_door {
194 	boolean_t	did_start_door;
195 } dld_ioc_door_t;
196 
197 #define	DLDIOC_RENAME		(DLDIOC | 0x11)
198 typedef struct dld_ioc_rename {
199 	datalink_id_t	dir_linkid1;
200 	datalink_id_t	dir_linkid2;
201 	char		dir_link[MAXLINKNAMELEN];
202 } dld_ioc_rename_t;
203 
204 /*
205  * DLDIOC_SETZID sets the zoneid of a given link. It could cause a VLAN to be
206  * implicitly created.  Note that we will hold a reference for the given link
207  * whenever it has a zoneid other than the global zone.
208  */
209 #define	DLDIOC_SETZID		(DLDIOC | 0x12)
210 typedef struct dld_ioc_setzid {
211 	char		dis_link[MAXLINKNAMELEN];
212 	zoneid_t	dis_zid;
213 } dld_ioc_setzid_t;
214 
215 #define	DLDIOC_GETZID  		(DLDIOC | 0x13)
216 typedef struct dld_ioc_getzid {
217 	datalink_id_t	dig_linkid;
218 	zoneid_t	dig_zid;
219 } dld_ioc_getzid_t;
220 
221 /*
222  * data-link autopush configuration.
223  */
224 struct dlautopush {
225 	uint_t	dap_anchor;
226 	uint_t	dap_npush;
227 	char	dap_aplist[MAXAPUSH][FMNAMESZ+1];
228 };
229 
230 /*
231  * Encodings for public properties.
232  * A most significant bit value of 1 indicates private property, intended
233  * to allow private property implementations to use internal encodings
234  * if desired.
235  *
236  * Note that there are 2 sets of parameters: the *_EN_*
237  * values are those that the Administrator configures for autonegotiation.
238  * The _ADV_* values are those that are currently exposed over the wire.
239  */
240 typedef enum {
241 	DLD_PROP_DUPLEX = 0x00000001,
242 	DLD_PROP_SPEED,
243 	DLD_PROP_STATUS,
244 	DLD_PROP_AUTONEG,
245 	DLD_PROP_EN_AUTONEG,
246 	DLD_PROP_DEFMTU,
247 	DLD_PROP_NDD_LEGACY,
248 	DLD_PROP_FLOWCTRL,
249 	DLD_PROP_ADV_1000FDX_CAP,
250 	DLD_PROP_EN_1000FDX_CAP,
251 	DLD_PROP_ADV_1000HDX_CAP,
252 	DLD_PROP_EN_1000HDX_CAP,
253 	DLD_PROP_ADV_100FDX_CAP,
254 	DLD_PROP_EN_100FDX_CAP,
255 	DLD_PROP_ADV_100HDX_CAP,
256 	DLD_PROP_EN_100HDX_CAP,
257 	DLD_PROP_ADV_10FDX_CAP,
258 	DLD_PROP_EN_10FDX_CAP,
259 	DLD_PROP_ADV_10HDX_CAP,
260 	DLD_PROP_EN_10HDX_CAP,
261 	DLD_PROP_PRIVATE = -1
262 } dld_prop_id_t;
263 
264 /*
265  * to figure out r/w status of legacy ndd props.
266  */
267 #define	DLD_NDD_READ		0x01
268 #define	DLD_NDD_WRITE		0x10
269 
270 #define	DLDIOCSETPROP		(DLDIOC | 0x14)
271 #define	DLDIOCGETPROP		(DLDIOC | 0x15)
272 #define	DLD_LINKPROP_NAME_MAX	256
273 #define	DLD_PROP_VERSION	1
274 
275 typedef struct dld_ioc_prop_s {
276 	int		pr_version;
277 	uint_t		pr_flags;		/* private to libdladm */
278 	datalink_id_t	pr_linkid;
279 	dld_prop_id_t	pr_num;
280 	char    	pr_name[DLD_LINKPROP_NAME_MAX];
281 	uint_t		pr_valsize;		/* sizeof pr_val */
282 	char		pr_val[1];
283 } dld_ioc_prop_t;
284 
285 #ifdef _KERNEL
286 typedef	dld_prop_id_t	mac_prop_id_t;
287 int	dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
288 int	dld_open(queue_t *, dev_t *, int, int, cred_t *);
289 int	dld_close(queue_t *);
290 void	dld_wput(queue_t *, mblk_t *);
291 void	dld_wsrv(queue_t *);
292 void	dld_init_ops(struct dev_ops *, const char *);
293 void	dld_fini_ops(struct dev_ops *);
294 int	dld_autopush(dev_t *, struct dlautopush *);
295 #endif
296 
297 #ifdef	__cplusplus
298 }
299 #endif
300 
301 #endif	/* _SYS_DLD_H */
302