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.
30 * Data-Link Driver ioctl interfaces.
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.
38 #include <sys/types.h>
39 #include <sys/stream.h>
40 #include <sys/mac_flow.h>
50 * Data-Link Driver Information (text emitted by modinfo(1m))
52 #define DLD_INFO "Data-Link Driver"
55 * Options: To enable an option set the property name to a non-zero value
56 * in kernel/drv/dld.conf.
60 * Prevent use of the IP fast-path (direct M_DATA transmit).
62 #define DLD_PROP_NO_FASTPATH "no-fastpath"
65 * Prevent advertising of the DL_CAPAB_POLL capability.
67 #define DLD_PROP_NO_POLL "no-poll"
70 * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
72 #define DLD_PROP_NO_ZEROCOPY "no-zerocopy"
75 * Prevent advertising of the DL_CAPAB_SOFTRING capability.
77 #define DLD_PROP_NO_SOFTRING "no-softring"
80 * The name of the driver.
82 #define DLD_DRIVER_NAME "dld"
84 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
89 * IOCTL codes and data structures.
91 #define DLDIOC_ATTR DLDIOC(0x03)
93 typedef struct dld_ioc_attr
{
94 datalink_id_t dia_linkid
;
98 #define DLDIOC_VLAN_ATTR DLDIOC(0x04)
99 typedef struct dld_ioc_vlan_attr
{
100 datalink_id_t div_vlanid
;
102 datalink_id_t div_linkid
;
104 } dld_ioc_vlan_attr_t
;
106 #define DLDIOC_PHYS_ATTR DLDIOC(0x05)
107 #define DLPI_LINKNAME_MAX 32
109 typedef struct dld_ioc_phys_attr
{
110 datalink_id_t dip_linkid
;
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.
116 boolean_t dip_novanity
;
117 char dip_dev
[MAXLINKNAMELEN
];
118 } dld_ioc_phys_attr_t
;
121 * Secure objects ioctls
124 DLD_SECOBJ_CLASS_WEP
= 1,
126 } dld_secobj_class_t
;
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
];
138 #define DLDIOC_SECOBJ_SET DLDIOC(0x06)
139 typedef struct dld_ioc_secobj_set
{
142 } dld_ioc_secobj_set_t
;
144 #define DLDIOC_SECOBJ_GET DLDIOC(0x07)
145 typedef struct dld_ioc_secobj_get
{
149 } dld_ioc_secobj_get_t
;
152 * The following two slots were used outside of ON, so don't reuse them.
154 * #define DLDIOCHOLDVLAN DLDIOC(0x08)
155 * #define DLDIOCRELEVLAN DLDIOC(0x09)
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
;
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
;
169 } dld_ioc_create_vlan_t
;
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
;
177 * The following constants have been removed, and the slots are open:
179 * #define DLDIOC_SETAUTOPUSH DLDIOC(0x0d)
180 * #define DLDIOC_GETAUTOPUSH DLDIOC(0x0e)
181 * #define DLDIOC_CLRAUTOPUSH DLDIOC(0x0f)
184 #define DLDIOC_DOORSERVER DLDIOC(0x10)
185 typedef struct dld_ioc_door
{
186 boolean_t did_start_door
;
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
];
197 * The following constants have been removed, and the slots are open:
199 * #define DLDIOC_SETZID DLDIOC(0x12)
200 * #define DLDIOC_GETZID DLDIOC(0x13)
203 typedef struct dld_ioc_zid
{
205 datalink_id_t diz_linkid
;
209 * data-link autopush configuration.
214 char dap_aplist
[MAXAPUSH
][FMNAMESZ
+1];
217 #define DLDIOC_MACADDRGET DLDIOC(0x15)
218 typedef struct dld_ioc_macaddrget
{
219 datalink_id_t dig_linkid
;
222 } dld_ioc_macaddrget_t
;
224 /* possible flags for dmi_flags below */
225 #define DLDIOCMACADDR_USED 0x1 /* address slot used */
227 typedef struct dld_macaddrinfo
{
231 uchar_t dmi_addr
[MAXMACADDRLEN
];
232 char dmi_client_name
[MAXNAMELEN
];
233 datalink_id_t dma_client_linkid
;
237 * IOCTL codes and data structures for flowadm.
239 #define DLDIOC_ADDFLOW DLDIOC(0x16)
240 typedef struct dld_ioc_addflow
{
241 datalink_id_t af_linkid
;
242 flow_desc_t af_flow_desc
;
243 mac_resource_props_t af_resource_props
;
244 char af_name
[MAXFLOWNAMELEN
];
247 #define DLDIOC_REMOVEFLOW DLDIOC(0x17)
248 typedef struct dld_ioc_removeflow
{
249 char rf_name
[MAXFLOWNAMELEN
];
250 } dld_ioc_removeflow_t
;
252 #define DLDIOC_MODIFYFLOW DLDIOC(0x18)
253 typedef struct dld_ioc_modifyflow
{
254 char mf_name
[MAXFLOWNAMELEN
];
255 mac_resource_props_t mf_resource_props
;
256 } dld_ioc_modifyflow_t
;
258 #define DLDIOC_WALKFLOW DLDIOC(0x19)
259 typedef struct dld_ioc_walkflow
{
260 datalink_id_t wf_linkid
;
261 char wf_name
[MAXFLOWNAMELEN
];
264 } dld_ioc_walkflow_t
;
266 typedef struct dld_flowinfo
{
267 datalink_id_t fi_linkid
;
268 flow_desc_t fi_flow_desc
;
269 mac_resource_props_t fi_resource_props
;
270 char fi_flowname
[MAXFLOWNAMELEN
];
274 #define DLDIOC_USAGELOG DLDIOC(0x1a)
275 typedef struct dld_ioc_usagelog
{
276 mac_logtype_t ul_type
;
279 } dld_ioc_usagelog_t
;
281 #define DLDIOC_SETMACPROP DLDIOC(0x1b)
282 #define DLDIOC_GETMACPROP DLDIOC(0x1c)
284 /* pr_flags can be set to a combination of the following flags */
285 #define DLD_PROP_DEFAULT 0x0001
286 #define DLD_PROP_POSSIBLE 0x0002
288 typedef struct dld_ioc_macprop_s
{
290 datalink_id_t pr_linkid
;
291 mac_prop_id_t pr_num
;
292 uint_t pr_perm_flags
;
293 char pr_name
[MAXLINKPROPNAME
];
294 uint_t pr_valsize
; /* sizeof pr_val */
298 #define DLDIOC_GETHWGRP DLDIOC(0x1d)
300 typedef struct dld_ioc_hwgrpget
{
301 datalink_id_t dih_linkid
;
302 uint_t dih_n_groups
; /* number of groups included in ioc */
304 } dld_ioc_hwgrpget_t
;
306 #define MAXCLIENTNAMELEN 1024
307 typedef struct dld_hwgrpinfo
{
308 char dhi_link_name
[MAXLINKNAMELEN
];
313 uint_t dhi_rings
[MAX_RINGS_PER_GROUP
];
314 char dhi_clnts
[MAXCLIENTNAMELEN
];
317 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
323 #define DLD_CAPAB_DIRECT 0x00000001
324 #define DLD_CAPAB_POLL 0x00000002
325 #define DLD_CAPAB_PERIM 0x00000003
326 #define DLD_CAPAB_LSO 0x00000004
328 #define DLD_ENABLE 0x00000001
329 #define DLD_DISABLE 0x00000002
330 #define DLD_QUERY 0x00000003
333 * GLDv3 entry point for negotiating capabilities.
334 * This is exposed to IP after negotiation of DL_CAPAB_DLD.
336 * This function takes the following arguments:
337 * handle: used for identifying the interface to operate on (provided by dld).
338 * type: capability type.
339 * arg: points to a capability-specific structure.
340 * flags: used for indicating whether to enable or disable a capability.
342 * With this function, capability negotiation is reduced from a multi-step
343 * process to just one single function call.
344 * e.g. the following code would pass 'x' from IP to dld and obtain
345 * arg.output_arg from dld:
348 * rc = (*dld_capab)(handle, DLD_CAPAB_XXX, &arg, DLD_ENABLE);
349 * ill->info1 = arg.output_arg;
351 typedef int (*dld_capab_func_t
)(void *, uint_t
, void *, uint_t
);
354 * Direct Tx/Rx capability.
356 typedef struct dld_capab_direct_s
{
358 * Rx entry point and handle, owned by IP.
364 * Tx entry points and handle, owned by DLD.
366 /* Entry point for transmitting packets */
370 /* flow control notification callback */
371 uintptr_t di_tx_cb_df
; /* callback registration/de-registration */
374 /* flow control "can I put on a ring" callback */
375 uintptr_t di_tx_fctl_df
; /* canput-like callback */
377 } dld_capab_direct_t
;
380 * Polling/softring capability.
382 #define POLL_SOFTRING 0x00000001
383 typedef struct dld_capab_poll_s
{
384 uintptr_t poll_ring_add_cf
;
385 uintptr_t poll_ring_remove_cf
;
386 uintptr_t poll_ring_quiesce_cf
;
387 uintptr_t poll_ring_restart_cf
;
388 uintptr_t poll_ring_bind_cf
;
390 uintptr_t poll_mac_accept_df
;
398 * Currently supported flags for LSO.
400 #define DLD_LSO_BASIC_TCP_IPV4 0x01 /* TCP LSO over IPv4 capability */
401 #define DLD_LSO_BASIC_TCP_IPV6 0x02 /* TCP LSO over IPv6 capability */
403 typedef struct dld_capab_lso_s
{
404 uint_t lso_flags
; /* capability flags */
405 uint_t lso_max
; /* maximum payload */
408 int dld_getinfo(dev_info_t
*, ddi_info_cmd_t
, void *, void **);
409 int dld_devt_to_instance(dev_t
);
410 int dld_open(queue_t
*, dev_t
*, int, int, cred_t
*);
411 int dld_close(queue_t
*);
412 void dld_wput(queue_t
*, mblk_t
*);
413 void dld_wsrv(queue_t
*);
414 int dld_str_open(queue_t
*, dev_t
*, void *);
415 int dld_str_close(queue_t
*);
416 void *dld_str_private(queue_t
*);
417 void dld_init_ops(struct dev_ops
*, const char *);
418 void dld_fini_ops(struct dev_ops
*);
419 int dld_autopush(dev_t
*, struct dlautopush
*);
421 int dld_add_flow(datalink_id_t
, char *, flow_desc_t
*,
422 mac_resource_props_t
*);
423 int dld_remove_flow(char *);
424 int dld_modify_flow(char *, mac_resource_props_t
*);
425 int dld_walk_flow(dld_ioc_walkflow_t
*, intptr_t, cred_t
*);
433 #endif /* _SYS_DLD_H */