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 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2011 Joyent, Inc. All rights reserved.
25 */
26
27 #ifndef _SYS_DLD_H
28 #define _SYS_DLD_H
29
30 /*
31 * Data-Link Driver ioctl interfaces.
32 *
33 * Note that the datastructures defined here define an ioctl interface
34 * that is shared betwen user and kernel space. The dld driver thus
35 * assumes that the structures have identical layout and size when
36 * compiled in either IPL32 or LP64.
37 */
38
39 #include <sys/types.h>
40 #include <sys/stream.h>
41 #include <sys/mac_flow.h>
42 #include <sys/conf.h>
43 #include <sys/sad.h>
44 #include <sys/mac.h>
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /*
51 * Data-Link Driver Information (text emitted by modinfo(1m))
52 */
53 #define DLD_INFO "Data-Link Driver"
54
55 /*
56 * Options: To enable an option set the property name to a non-zero value
57 * in kernel/drv/dld.conf.
58 */
59
60 /*
61 * Prevent use of the IP fast-path (direct M_DATA transmit).
62 */
63 #define DLD_PROP_NO_FASTPATH "no-fastpath"
64
65 /*
66 * Prevent advertising of the DL_CAPAB_POLL capability.
67 */
68 #define DLD_PROP_NO_POLL "no-poll"
69
70 /*
71 * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
72 */
73 #define DLD_PROP_NO_ZEROCOPY "no-zerocopy"
74
75 /*
76 * Prevent advertising of the DL_CAPAB_SOFTRING capability.
77 */
78 #define DLD_PROP_NO_SOFTRING "no-softring"
79
80 /*
81 * The name of the driver.
82 */
83 #define DLD_DRIVER_NAME "dld"
84
85 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
86 #pragma pack(4)
87 #endif
88
89 /*
90 * IOCTL codes and data structures.
91 */
92 #define DLDIOC_ATTR DLDIOC(0x03)
93
94 typedef struct dld_ioc_attr {
95 datalink_id_t dia_linkid;
96 uint_t dia_max_sdu;
97 } dld_ioc_attr_t;
98
99 #define DLDIOC_VLAN_ATTR DLDIOC(0x04)
100 typedef struct dld_ioc_vlan_attr {
101 datalink_id_t div_vlanid;
102 uint16_t div_vid;
103 datalink_id_t div_linkid;
104 boolean_t div_force;
105 } dld_ioc_vlan_attr_t;
106
107 #define DLDIOC_PHYS_ATTR DLDIOC(0x05)
108 #define DLPI_LINKNAME_MAX 32
109
110 typedef struct dld_ioc_phys_attr {
111 datalink_id_t dip_linkid;
112 /*
113 * Whether this physical link supports vanity naming. Note that
114 * physical links whose media type is not supported by GLDv3
115 * can not support vanity naming.
116 */
117 boolean_t dip_novanity;
118 char dip_dev[MAXLINKNAMELEN];
119 } dld_ioc_phys_attr_t;
120
121 /*
122 * Secure objects ioctls
123 */
124 typedef enum {
125 DLD_SECOBJ_CLASS_WEP = 1,
126 DLD_SECOBJ_CLASS_WPA
127 } dld_secobj_class_t;
128
129 #define DLD_SECOBJ_OPT_CREATE 0x00000001
130 #define DLD_SECOBJ_NAME_MAX 32
131 #define DLD_SECOBJ_VAL_MAX 256
132 typedef struct dld_secobj {
133 char so_name[DLD_SECOBJ_NAME_MAX];
134 dld_secobj_class_t so_class;
135 uint8_t so_val[DLD_SECOBJ_VAL_MAX];
136 uint_t so_len;
137 } dld_secobj_t;
138
139 #define DLDIOC_SECOBJ_SET DLDIOC(0x06)
140 typedef struct dld_ioc_secobj_set {
141 dld_secobj_t ss_obj;
142 uint_t ss_flags;
143 } dld_ioc_secobj_set_t;
144
145 #define DLDIOC_SECOBJ_GET DLDIOC(0x07)
146 typedef struct dld_ioc_secobj_get {
147 dld_secobj_t sg_obj;
148 uint_t sg_count;
149 uint_t sg_size;
150 } dld_ioc_secobj_get_t;
151
152 /*
153 * The following two slots were used outside of ON, so don't reuse them.
154 *
155 * #define DLDIOCHOLDVLAN DLDIOC(0x08)
156 * #define DLDIOCRELEVLAN DLDIOC(0x09)
157 */
158
159 #define DLDIOC_SECOBJ_UNSET DLDIOC(0x0a)
160 typedef struct dld_ioc_secobj_unset {
161 char su_name[DLD_SECOBJ_NAME_MAX];
162 } dld_ioc_secobj_unset_t;
163
164 #define DLDIOC_CREATE_VLAN DLDIOC(0x0b)
165 typedef struct dld_ioc_create_vlan {
166 datalink_id_t dic_vlanid;
167 datalink_id_t dic_linkid;
168 uint16_t dic_vid;
169 boolean_t dic_force;
170 } dld_ioc_create_vlan_t;
171
172 #define DLDIOC_DELETE_VLAN DLDIOC(0x0c)
173 typedef struct dld_ioc_delete_vlan {
174 datalink_id_t did_linkid;
175 } dld_ioc_delete_vlan_t;
176
177 /*
178 * The following constants have been removed, and the slots are open:
179 *
180 * #define DLDIOC_SETAUTOPUSH DLDIOC(0x0d)
181 * #define DLDIOC_GETAUTOPUSH DLDIOC(0x0e)
182 * #define DLDIOC_CLRAUTOPUSH DLDIOC(0x0f)
183 */
184
185 #define DLDIOC_DOORSERVER DLDIOC(0x10)
186 typedef struct dld_ioc_door {
187 boolean_t did_start_door;
188 } dld_ioc_door_t;
189
190 #define DLDIOC_RENAME DLDIOC(0x11)
191 typedef struct dld_ioc_rename {
192 datalink_id_t dir_linkid1;
193 datalink_id_t dir_linkid2;
194 char dir_link[MAXLINKNAMELEN];
195 boolean_t dir_zoneinit;
196 } dld_ioc_rename_t;
197
198 /*
199 * The following constants have been removed, and the slots are open:
200 *
201 * #define DLDIOC_SETZID DLDIOC(0x12)
202 * #define DLDIOC_GETZID DLDIOC(0x13)
203 */
204
205 typedef struct dld_ioc_zid {
206 zoneid_t diz_zid;
207 datalink_id_t diz_linkid;
208 boolean_t diz_transient;
209 } dld_ioc_zid_t;
210
211 /*
212 * data-link autopush configuration.
213 */
214 struct dlautopush {
215 uint_t dap_anchor;
216 uint_t dap_npush;
217 char dap_aplist[MAXAPUSH][FMNAMESZ+1];
218 };
219
220 #define DLDIOC_MACADDRGET DLDIOC(0x15)
221 typedef struct dld_ioc_macaddrget {
222 datalink_id_t dig_linkid;
223 uint_t dig_count;
224 uint_t dig_size;
225 } dld_ioc_macaddrget_t;
226
227 /* possible flags for dmi_flags below */
228 #define DLDIOCMACADDR_USED 0x1 /* address slot used */
229
230 typedef struct dld_macaddrinfo {
231 uint_t dmi_slot;
232 uint_t dmi_flags;
233 uint_t dmi_addrlen;
234 uchar_t dmi_addr[MAXMACADDRLEN];
235 char dmi_client_name[MAXNAMELEN];
236 datalink_id_t dma_client_linkid;
237 } dld_macaddrinfo_t;
238
239 /*
240 * IOCTL codes and data structures for flowadm.
241 */
242 #define DLDIOC_ADDFLOW DLDIOC(0x16)
243 typedef struct dld_ioc_addflow {
244 datalink_id_t af_linkid;
245 flow_desc_t af_flow_desc;
246 mac_resource_props_t af_resource_props;
247 char af_name[MAXFLOWNAMELEN];
248 } dld_ioc_addflow_t;
249
250 #define DLDIOC_REMOVEFLOW DLDIOC(0x17)
251 typedef struct dld_ioc_removeflow {
252 char rf_name[MAXFLOWNAMELEN];
253 } dld_ioc_removeflow_t;
254
255 #define DLDIOC_MODIFYFLOW DLDIOC(0x18)
256 typedef struct dld_ioc_modifyflow {
257 char mf_name[MAXFLOWNAMELEN];
258 mac_resource_props_t mf_resource_props;
259 } dld_ioc_modifyflow_t;
260
261 #define DLDIOC_WALKFLOW DLDIOC(0x19)
262 typedef struct dld_ioc_walkflow {
263 datalink_id_t wf_linkid;
264 char wf_name[MAXFLOWNAMELEN];
265 uint32_t wf_nflows;
266 uint_t wf_len;
267 } dld_ioc_walkflow_t;
268
269 typedef struct dld_flowinfo {
270 datalink_id_t fi_linkid;
271 flow_desc_t fi_flow_desc;
272 mac_resource_props_t fi_resource_props;
273 char fi_flowname[MAXFLOWNAMELEN];
274 uint32_t fi_pad;
275 } dld_flowinfo_t;
276
277 #define DLDIOC_USAGELOG DLDIOC(0x1a)
278 typedef struct dld_ioc_usagelog {
279 mac_logtype_t ul_type;
280 boolean_t ul_onoff;
281 uint_t ul_interval;
282 } dld_ioc_usagelog_t;
283
284 #define DLDIOC_SETMACPROP DLDIOC(0x1b)
285 #define DLDIOC_GETMACPROP DLDIOC(0x1c)
286
287 /* pr_flags can be set to a combination of the following flags */
288 #define DLD_PROP_DEFAULT 0x0001
289 #define DLD_PROP_POSSIBLE 0x0002
290
291 typedef struct dld_ioc_macprop_s {
292 uint_t pr_flags;
293 datalink_id_t pr_linkid;
294 mac_prop_id_t pr_num;
295 uint_t pr_perm_flags;
296 char pr_name[MAXLINKPROPNAME];
297 uint_t pr_valsize; /* sizeof pr_val */
298 char pr_val[1];
299 } dld_ioc_macprop_t;
300
301 #define DLDIOC_GETHWGRP DLDIOC(0x1d)
302
303 typedef struct dld_ioc_hwgrpget {
304 datalink_id_t dih_linkid;
305 uint_t dih_n_groups; /* number of groups included in ioc */
306 uint_t dih_size;
307 } dld_ioc_hwgrpget_t;
308
309 #define MAXCLIENTNAMELEN 1024
310 typedef struct dld_hwgrpinfo {
311 char dhi_link_name[MAXLINKNAMELEN];
312 uint_t dhi_grp_num;
313 uint_t dhi_grp_type;
314 uint_t dhi_n_rings;
315 uint_t dhi_n_clnts;
316 uint_t dhi_rings[MAX_RINGS_PER_GROUP];
317 char dhi_clnts[MAXCLIENTNAMELEN];
318 } dld_hwgrpinfo_t;
319
320 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
321 #pragma pack()
322 #endif
323
324 #ifdef _KERNEL
325
326 #define DLD_CAPAB_DIRECT 0x00000001
327 #define DLD_CAPAB_POLL 0x00000002
328 #define DLD_CAPAB_PERIM 0x00000003
329 #define DLD_CAPAB_LSO 0x00000004
330
331 #define DLD_ENABLE 0x00000001
332 #define DLD_DISABLE 0x00000002
333 #define DLD_QUERY 0x00000003
334
335 /*
336 * GLDv3 entry point for negotiating capabilities.
337 * This is exposed to IP after negotiation of DL_CAPAB_DLD.
338 *
339 * This function takes the following arguments:
340 * handle: used for identifying the interface to operate on (provided by dld).
341 * type: capability type.
342 * arg: points to a capability-specific structure.
343 * flags: used for indicating whether to enable or disable a capability.
344 *
345 * With this function, capability negotiation is reduced from a multi-step
346 * process to just one single function call.
347 * e.g. the following code would pass 'x' from IP to dld and obtain
348 * arg.output_arg from dld:
349 *
350 * arg.input_arg = x;
351 * rc = (*dld_capab)(handle, DLD_CAPAB_XXX, &arg, DLD_ENABLE);
352 * ill->info1 = arg.output_arg;
353 */
354 typedef int (*dld_capab_func_t)(void *, uint_t, void *, uint_t);
355
356 /*
357 * Direct Tx/Rx capability.
358 */
359 typedef struct dld_capab_direct_s {
360 /*
361 * Rx entry point and handle, owned by IP.
362 */
363 uintptr_t di_rx_cf;
364 void *di_rx_ch;
365
366 /*
367 * Tx entry points and handle, owned by DLD.
368 */
369 /* Entry point for transmitting packets */
370 uintptr_t di_tx_df;
371 void *di_tx_dh;
372
373 /* flow control notification callback */
374 uintptr_t di_tx_cb_df; /* callback registration/de-registration */
375 void *di_tx_cb_dh;
376
377 /* flow control "can I put on a ring" callback */
378 uintptr_t di_tx_fctl_df; /* canput-like callback */
379 void *di_tx_fctl_dh;
380 } dld_capab_direct_t;
381
382 /*
383 * Polling/softring capability.
384 */
385 #define POLL_SOFTRING 0x00000001
386 typedef struct dld_capab_poll_s {
387 uintptr_t poll_ring_add_cf;
388 uintptr_t poll_ring_remove_cf;
389 uintptr_t poll_ring_quiesce_cf;
390 uintptr_t poll_ring_restart_cf;
391 uintptr_t poll_ring_bind_cf;
392 void *poll_ring_ch;
393 uintptr_t poll_mac_accept_df;
394 void *poll_mac_dh;
395 } dld_capab_poll_t;
396
397 /*
398 * LSO capability
399 */
400 /*
401 * Currently supported flags for LSO.
402 */
403 #define DLD_LSO_BASIC_TCP_IPV4 0x01 /* TCP LSO over IPv4 capability */
404 #define DLD_LSO_BASIC_TCP_IPV6 0x02 /* TCP LSO over IPv6 capability */
405
406 typedef struct dld_capab_lso_s {
407 uint_t lso_flags; /* capability flags */
408 uint_t lso_max; /* maximum payload */
409 } dld_capab_lso_t;
410
411 int dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
412 int dld_devt_to_instance(dev_t);
413 int dld_open(queue_t *, dev_t *, int, int, cred_t *);
414 int dld_close(queue_t *);
415 void dld_wput(queue_t *, mblk_t *);
416 void dld_wsrv(queue_t *);
417 int dld_str_open(queue_t *, dev_t *, void *);
418 int dld_str_close(queue_t *);
419 void *dld_str_private(queue_t *);
420 void dld_init_ops(struct dev_ops *, const char *);
421 void dld_fini_ops(struct dev_ops *);
422 int dld_autopush(dev_t *, struct dlautopush *);
423
424 int dld_add_flow(datalink_id_t, char *, flow_desc_t *,
425 mac_resource_props_t *);
426 int dld_remove_flow(char *);
427 int dld_modify_flow(char *, mac_resource_props_t *);
428 int dld_walk_flow(dld_ioc_walkflow_t *, intptr_t, cred_t *);
429
430 #endif
431
432 #ifdef __cplusplus
433 }
434 #endif
435
436 #endif /* _SYS_DLD_H */