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.
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.
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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2017, Joyent, Inc.
31 * Data-Link Driver ioctl interfaces.
33 * Note that the data structures 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.
39 #include <sys/types.h>
40 #include <sys/stream.h>
41 #include <sys/mac_flow.h>
51 * Data-Link Driver Information (text emitted by modinfo(1m))
53 #define DLD_INFO "Data-Link Driver"
56 * Options: To enable an option set the property name to a non-zero value
57 * in kernel/drv/dld.conf.
61 * Prevent use of the IP fast-path (direct M_DATA transmit).
63 #define DLD_PROP_NO_FASTPATH "no-fastpath"
66 * Prevent advertising of the DL_CAPAB_POLL capability.
68 #define DLD_PROP_NO_POLL "no-poll"
71 * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
73 #define DLD_PROP_NO_ZEROCOPY "no-zerocopy"
76 * Prevent advertising of the DL_CAPAB_SOFTRING capability.
78 #define DLD_PROP_NO_SOFTRING "no-softring"
81 * The name of the driver.
83 #define DLD_DRIVER_NAME "dld"
85 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
90 * IOCTL codes and data structures.
92 #define DLDIOC_ATTR DLDIOC(0x03)
94 typedef struct dld_ioc_attr
{
95 datalink_id_t dia_linkid
;
99 #define DLDIOC_VLAN_ATTR DLDIOC(0x04)
100 typedef struct dld_ioc_vlan_attr
{
101 datalink_id_t div_vlanid
;
103 datalink_id_t div_linkid
;
105 } dld_ioc_vlan_attr_t
;
107 #define DLDIOC_PHYS_ATTR DLDIOC(0x05)
108 #define DLPI_LINKNAME_MAX 32
110 typedef struct dld_ioc_phys_attr
{
111 datalink_id_t dip_linkid
;
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.
117 boolean_t dip_novanity
;
118 char dip_dev
[MAXLINKNAMELEN
];
119 } dld_ioc_phys_attr_t
;
122 * Secure objects ioctls
125 DLD_SECOBJ_CLASS_WEP
= 1,
127 } dld_secobj_class_t
;
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
];
139 #define DLDIOC_SECOBJ_SET DLDIOC(0x06)
140 typedef struct dld_ioc_secobj_set
{
143 } dld_ioc_secobj_set_t
;
145 #define DLDIOC_SECOBJ_GET DLDIOC(0x07)
146 typedef struct dld_ioc_secobj_get
{
150 } dld_ioc_secobj_get_t
;
153 * The following two slots were used outside of ON, so don't reuse them.
155 * #define DLDIOCHOLDVLAN DLDIOC(0x08)
156 * #define DLDIOCRELEVLAN DLDIOC(0x09)
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
;
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
;
170 } dld_ioc_create_vlan_t
;
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
;
178 * The following constants have been removed, and the slots are open:
180 * #define DLDIOC_SETAUTOPUSH DLDIOC(0x0d)
181 * #define DLDIOC_GETAUTOPUSH DLDIOC(0x0e)
182 * #define DLDIOC_CLRAUTOPUSH DLDIOC(0x0f)
185 #define DLDIOC_DOORSERVER DLDIOC(0x10)
186 typedef struct dld_ioc_door
{
187 boolean_t did_start_door
;
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
];
198 * The following constants have been removed, and the slots are open:
200 * #define DLDIOC_SETZID DLDIOC(0x12)
201 * #define DLDIOC_GETZID DLDIOC(0x13)
204 typedef struct dld_ioc_zid
{
206 datalink_id_t diz_linkid
;
210 * data-link autopush configuration.
215 char dap_aplist
[MAXAPUSH
][FMNAMESZ
+1];
218 #define DLDIOC_MACADDRGET DLDIOC(0x15)
219 typedef struct dld_ioc_macaddrget
{
220 datalink_id_t dig_linkid
;
223 } dld_ioc_macaddrget_t
;
225 /* possible flags for dmi_flags below */
226 #define DLDIOCMACADDR_USED 0x1 /* address slot used */
228 typedef struct dld_macaddrinfo
{
232 uchar_t dmi_addr
[MAXMACADDRLEN
];
233 char dmi_client_name
[MAXNAMELEN
];
234 datalink_id_t dma_client_linkid
;
238 * IOCTL codes and data structures for flowadm.
240 #define DLDIOC_ADDFLOW DLDIOC(0x16)
241 typedef struct dld_ioc_addflow
{
242 datalink_id_t af_linkid
;
243 flow_desc_t af_flow_desc
;
244 mac_resource_props_t af_resource_props
;
245 char af_name
[MAXFLOWNAMELEN
];
248 #define DLDIOC_REMOVEFLOW DLDIOC(0x17)
249 typedef struct dld_ioc_removeflow
{
250 char rf_name
[MAXFLOWNAMELEN
];
251 } dld_ioc_removeflow_t
;
253 #define DLDIOC_MODIFYFLOW DLDIOC(0x18)
254 typedef struct dld_ioc_modifyflow
{
255 char mf_name
[MAXFLOWNAMELEN
];
256 mac_resource_props_t mf_resource_props
;
257 } dld_ioc_modifyflow_t
;
259 #define DLDIOC_WALKFLOW DLDIOC(0x19)
260 typedef struct dld_ioc_walkflow
{
261 datalink_id_t wf_linkid
;
262 char wf_name
[MAXFLOWNAMELEN
];
265 } dld_ioc_walkflow_t
;
267 typedef struct dld_flowinfo
{
268 datalink_id_t fi_linkid
;
269 flow_desc_t fi_flow_desc
;
270 mac_resource_props_t fi_resource_props
;
271 char fi_flowname
[MAXFLOWNAMELEN
];
275 #define DLDIOC_USAGELOG DLDIOC(0x1a)
276 typedef struct dld_ioc_usagelog
{
277 mac_logtype_t ul_type
;
280 } dld_ioc_usagelog_t
;
282 #define DLDIOC_SETMACPROP DLDIOC(0x1b)
283 #define DLDIOC_GETMACPROP DLDIOC(0x1c)
285 /* pr_flags can be set to a combination of the following flags */
286 #define DLD_PROP_DEFAULT 0x0001
287 #define DLD_PROP_POSSIBLE 0x0002
289 typedef struct dld_ioc_macprop_s
{
291 datalink_id_t pr_linkid
;
292 mac_prop_id_t pr_num
;
293 uint_t pr_perm_flags
;
294 char pr_name
[MAXLINKPROPNAME
];
295 uint_t pr_valsize
; /* sizeof pr_val */
299 #define DLDIOC_GETHWGRP DLDIOC(0x1d)
301 typedef struct dld_ioc_hwgrpget
{
302 datalink_id_t dih_linkid
;
303 uint_t dih_n_groups
; /* number of groups included in ioc */
305 } dld_ioc_hwgrpget_t
;
307 #define MAXCLIENTNAMELEN 1024
308 typedef struct dld_hwgrpinfo
{
309 char dhi_link_name
[MAXLINKNAMELEN
];
314 uint_t dhi_rings
[MAX_RINGS_PER_GROUP
];
315 char dhi_clnts
[MAXCLIENTNAMELEN
];
318 #define DLDIOC_GETTRAN DLDIOC(0x1e)
320 #define DLDIOC_GETTRAN_GETNTRAN UINT32_MAX
322 typedef struct dld_ioc_gettran
{
323 datalink_id_t dgt_linkid
;
325 boolean_t dgt_present
;
326 boolean_t dgt_usable
;
329 #define DLDIOC_READTRAN DLDIOC(0x1f)
330 typedef struct dld_ioc_tranio
{
331 datalink_id_t dti_linkid
;
339 #define DLDIOC_GETLED DLDIOC(0x20)
340 #define DLDIOC_SETLED DLDIOC(0x21)
342 typedef struct dld_ioc_led
{
343 datalink_id_t dil_linkid
;
344 mac_led_mode_t dil_supported
;
345 mac_led_mode_t dil_active
;
349 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
355 #define DLD_CAPAB_DIRECT 0x00000001
356 #define DLD_CAPAB_POLL 0x00000002
357 #define DLD_CAPAB_PERIM 0x00000003
358 #define DLD_CAPAB_LSO 0x00000004
360 #define DLD_ENABLE 0x00000001
361 #define DLD_DISABLE 0x00000002
362 #define DLD_QUERY 0x00000003
365 * GLDv3 entry point for negotiating capabilities.
366 * This is exposed to IP after negotiation of DL_CAPAB_DLD.
368 * This function takes the following arguments:
369 * handle: used for identifying the interface to operate on (provided by dld).
370 * type: capability type.
371 * arg: points to a capability-specific structure.
372 * flags: used for indicating whether to enable or disable a capability.
374 * With this function, capability negotiation is reduced from a multi-step
375 * process to just one single function call.
376 * e.g. the following code would pass 'x' from IP to dld and obtain
377 * arg.output_arg from dld:
380 * rc = (*dld_capab)(handle, DLD_CAPAB_XXX, &arg, DLD_ENABLE);
381 * ill->info1 = arg.output_arg;
383 typedef int (*dld_capab_func_t
)(void *, uint_t
, void *, uint_t
);
386 * Direct Tx/Rx capability.
388 typedef struct dld_capab_direct_s
{
390 * Rx entry point and handle, owned by IP.
396 * Tx entry points and handle, owned by DLD.
398 /* Entry point for transmitting packets */
402 /* flow control notification callback */
403 uintptr_t di_tx_cb_df
; /* callback registration/de-registration */
406 /* flow control "can I put on a ring" callback */
407 uintptr_t di_tx_fctl_df
; /* canput-like callback */
409 } dld_capab_direct_t
;
412 * Polling/softring capability.
414 #define POLL_SOFTRING 0x00000001
415 typedef struct dld_capab_poll_s
{
416 uintptr_t poll_ring_add_cf
;
417 uintptr_t poll_ring_remove_cf
;
418 uintptr_t poll_ring_quiesce_cf
;
419 uintptr_t poll_ring_restart_cf
;
420 uintptr_t poll_ring_bind_cf
;
422 uintptr_t poll_mac_accept_df
;
430 * Currently supported flags for LSO.
432 #define DLD_LSO_BASIC_TCP_IPV4 0x01 /* TCP LSO over IPv4 capability */
433 #define DLD_LSO_BASIC_TCP_IPV6 0x02 /* TCP LSO over IPv6 capability */
435 typedef struct dld_capab_lso_s
{
436 uint_t lso_flags
; /* capability flags */
437 uint_t lso_max
; /* maximum payload */
440 int dld_getinfo(dev_info_t
*, ddi_info_cmd_t
, void *, void **);
441 int dld_devt_to_instance(dev_t
);
442 int dld_open(queue_t
*, dev_t
*, int, int, cred_t
*);
443 int dld_close(queue_t
*);
444 void dld_wput(queue_t
*, mblk_t
*);
445 void dld_wsrv(queue_t
*);
446 int dld_str_open(queue_t
*, dev_t
*, void *);
447 int dld_str_close(queue_t
*);
448 void *dld_str_private(queue_t
*);
449 void dld_init_ops(struct dev_ops
*, const char *);
450 void dld_fini_ops(struct dev_ops
*);
451 int dld_autopush(dev_t
*, struct dlautopush
*);
453 int dld_add_flow(datalink_id_t
, char *, flow_desc_t
*,
454 mac_resource_props_t
*);
455 int dld_remove_flow(char *);
456 int dld_modify_flow(char *, mac_resource_props_t
*);
457 int dld_walk_flow(dld_ioc_walkflow_t
*, intptr_t, cred_t
*);
465 #endif /* _SYS_DLD_H */