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