xref: /titanic_52/usr/src/uts/common/sys/dld.h (revision 10e6dadfe63181edabc58c8f42e3c56a1cd9ec95)
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 #include <sys/mac.h>
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * Data-Link Driver Information (text emitted by modinfo(1m))
50  */
51 #define	DLD_INFO	"Data-Link Driver"
52 
53 /*
54  * Options: To enable an option set the property name to a non-zero value
55  *	    in kernel/drv/dld.conf.
56  */
57 
58 /*
59  * Prevent use of the IP fast-path (direct M_DATA transmit).
60  */
61 #define	DLD_PROP_NO_FASTPATH	"no-fastpath"
62 
63 /*
64  * Prevent advertising of the DL_CAPAB_POLL capability.
65  */
66 #define	DLD_PROP_NO_POLL	"no-poll"
67 
68 /*
69  * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
70  */
71 #define	DLD_PROP_NO_ZEROCOPY	"no-zerocopy"
72 
73 /*
74  * Prevent advertising of the DL_CAPAB_SOFTRING capability.
75  */
76 #define	DLD_PROP_NO_SOFTRING	"no-softring"
77 
78 /*
79  * The name of the driver.
80  */
81 #define	DLD_DRIVER_NAME		"dld"
82 
83 /*
84  * The name of the control minor node of dld.
85  */
86 #define	DLD_CONTROL_MINOR_NAME	"ctl"
87 #define	DLD_CONTROL_MINOR	0
88 #define	DLD_CONTROL_DEV		"/devices/pseudo/" DLD_DRIVER_NAME "@0:" \
89 				DLD_CONTROL_MINOR_NAME
90 
91 /*
92  * IOCTL codes and data structures.
93  */
94 #define	DLDIOC		('D' << 24 | 'L' << 16 | 'D' << 8)
95 
96 #define	DLDIOC_ATTR	(DLDIOC | 0x03)
97 
98 typedef struct dld_ioc_attr {
99 	datalink_id_t	dia_linkid;
100 	uint_t		dia_max_sdu;
101 } dld_ioc_attr_t;
102 
103 #define	DLDIOC_VLAN_ATTR	(DLDIOC | 0x04)
104 typedef struct dld_ioc_vlan_attr {
105 	datalink_id_t	div_vlanid;
106 	uint16_t	div_vid;
107 	datalink_id_t	div_linkid;
108 	boolean_t	div_force;
109 	boolean_t	div_implicit;
110 } dld_ioc_vlan_attr_t;
111 
112 #define	DLDIOC_PHYS_ATTR	(DLDIOC | 0x05)
113 #define	DLPI_LINKNAME_MAX	32
114 
115 typedef struct dld_ioc_phys_attr {
116 	datalink_id_t	dip_linkid;
117 	/*
118 	 * Whether this physical link supports vanity naming. Note that
119 	 * physical links whose media type is not supported by GLDv3
120 	 * can not support vanity naming.
121 	 */
122 	boolean_t	dip_novanity;
123 	char		dip_dev[MAXLINKNAMELEN];
124 } dld_ioc_phys_attr_t;
125 
126 /*
127  * Secure objects ioctls
128  */
129 typedef enum {
130 	DLD_SECOBJ_CLASS_WEP = 1,
131 	DLD_SECOBJ_CLASS_WPA
132 } dld_secobj_class_t;
133 
134 #define	DLD_SECOBJ_OPT_CREATE	0x00000001
135 #define	DLD_SECOBJ_NAME_MAX	32
136 #define	DLD_SECOBJ_VAL_MAX	256
137 typedef struct dld_secobj {
138 	char			so_name[DLD_SECOBJ_NAME_MAX];
139 	dld_secobj_class_t	so_class;
140 	uint8_t			so_val[DLD_SECOBJ_VAL_MAX];
141 	uint_t			so_len;
142 } dld_secobj_t;
143 
144 #define	DLDIOC_SECOBJ_SET	(DLDIOC | 0x06)
145 typedef struct dld_ioc_secobj_set {
146 	dld_secobj_t		ss_obj;
147 	uint_t			ss_flags;
148 } dld_ioc_secobj_set_t;
149 
150 #define	DLDIOC_SECOBJ_GET	(DLDIOC | 0x07)
151 typedef struct dld_ioc_secobj_get {
152 	dld_secobj_t		sg_obj;
153 	uint_t			sg_count;
154 } dld_ioc_secobj_get_t;
155 
156 /*
157  * The following two slots were used outside of ON, so don't reuse them.
158  *
159  * #define DLDIOCHOLDVLAN (DLDIOC | 0x08)
160  * #define DLDIOCRELEVLAN (DLDIOC | 0x09)
161  */
162 
163 #define	DLDIOC_SECOBJ_UNSET	(DLDIOC | 0x0a)
164 typedef struct dld_ioc_secobj_unset {
165 	char			su_name[DLD_SECOBJ_NAME_MAX];
166 } dld_ioc_secobj_unset_t;
167 
168 #define	DLDIOC_CREATE_VLAN	(DLDIOC | 0x0b)
169 typedef struct dld_ioc_create_vlan {
170 	datalink_id_t	dic_vlanid;
171 	datalink_id_t	dic_linkid;
172 	uint16_t	dic_vid;
173 	boolean_t	dic_force;
174 } dld_ioc_create_vlan_t;
175 
176 #define	DLDIOC_DELETE_VLAN	(DLDIOC | 0x0c)
177 typedef struct dld_ioc_delete_vlan {
178 	datalink_id_t	did_linkid;
179 } dld_ioc_delete_vlan_t;
180 
181 #define	DLDIOC_SETAUTOPUSH	(DLDIOC | 0x0d)
182 #define	DLDIOC_GETAUTOPUSH	(DLDIOC | 0x0e)
183 #define	DLDIOC_CLRAUTOPUSH	(DLDIOC | 0x0f)
184 typedef struct dld_ioc_ap {
185 	datalink_id_t	dia_linkid;
186 	uint_t  	dia_anchor;
187 	uint_t		dia_npush;
188 	char		dia_aplist[MAXAPUSH][FMNAMESZ+1];
189 } dld_ioc_ap_t;
190 
191 #define	DLDIOC_DOORSERVER	(DLDIOC | 0x10)
192 typedef struct dld_ioc_door {
193 	boolean_t	did_start_door;
194 } dld_ioc_door_t;
195 
196 #define	DLDIOC_RENAME		(DLDIOC | 0x11)
197 typedef struct dld_ioc_rename {
198 	datalink_id_t	dir_linkid1;
199 	datalink_id_t	dir_linkid2;
200 	char		dir_link[MAXLINKNAMELEN];
201 } dld_ioc_rename_t;
202 
203 /*
204  * DLDIOC_SETZID sets the zoneid of a given link. It could cause a VLAN to be
205  * implicitly created.  Note that we will hold a reference for the given link
206  * whenever it has a zoneid other than the global zone.
207  */
208 #define	DLDIOC_SETZID		(DLDIOC | 0x12)
209 typedef struct dld_ioc_setzid {
210 	char		dis_link[MAXLINKNAMELEN];
211 	zoneid_t	dis_zid;
212 } dld_ioc_setzid_t;
213 
214 #define	DLDIOC_GETZID  		(DLDIOC | 0x13)
215 typedef struct dld_ioc_getzid {
216 	datalink_id_t	dig_linkid;
217 	zoneid_t	dig_zid;
218 } dld_ioc_getzid_t;
219 
220 /*
221  * data-link autopush configuration.
222  */
223 struct dlautopush {
224 	uint_t	dap_anchor;
225 	uint_t	dap_npush;
226 	char	dap_aplist[MAXAPUSH][FMNAMESZ+1];
227 };
228 
229 
230 
231 #define	DLDIOC_SETMACPROP		(DLDIOC | 0x14)
232 #define	DLDIOC_GETMACPROP		(DLDIOC | 0x15)
233 #define	MAC_PROP_VERSION	1
234 
235 typedef struct dld_ioc_macprop_s {
236 	int		pr_version;
237 	uint_t		pr_flags;
238 	datalink_id_t	pr_linkid;
239 	mac_prop_id_t	pr_num;
240 	char    	pr_name[MAXLINKPROPNAME];
241 	uint_t		pr_valsize;		/* sizeof pr_val */
242 	char		pr_val[1];
243 } dld_ioc_macprop_t;
244 
245 #ifdef _KERNEL
246 int	dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
247 int	dld_open(queue_t *, dev_t *, int, int, cred_t *);
248 int	dld_close(queue_t *);
249 void	dld_wput(queue_t *, mblk_t *);
250 void	dld_wsrv(queue_t *);
251 void	dld_init_ops(struct dev_ops *, const char *);
252 void	dld_fini_ops(struct dev_ops *);
253 int	dld_autopush(dev_t *, struct dlautopush *);
254 #endif
255 
256 #ifdef	__cplusplus
257 }
258 #endif
259 
260 #endif	/* _SYS_DLD_H */
261