xref: /illumos-gate/usr/src/uts/common/sys/dld.h (revision 150d2c5288c645a1c1a7d2bee61199a3729406c7)
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 2007 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/mac.h>
38 #include <sys/dls.h>
39 #include <net/if.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * Data-Link Driver Information (text emitted by modinfo(1m))
47  */
48 #define	DLD_INFO	"Data-Link Driver v%I%"
49 
50 #define	DLD_MAX_PPA	999
51 #define	DLD_MAX_MINOR	(DLD_MAX_PPA + 1)
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  * The name of the driver.
75  */
76 #define	DLD_DRIVER_NAME		"dld"
77 
78 /*
79  * The name of the control minor node of dld.
80  */
81 #define	DLD_CONTROL_MINOR_NAME	"ctl"
82 #define	DLD_CONTROL_MINOR	0
83 #define	DLD_CONTROL_DEV		"/devices/pseudo/" DLD_DRIVER_NAME "@0:" \
84 				DLD_CONTROL_MINOR_NAME
85 
86 /*
87  * IOCTL codes and data structures.
88  */
89 #define	DLDIOC		('D' << 24 | 'L' << 16 | 'D' << 8)
90 
91 #define	DLDIOCATTR	(DLDIOC | 0x03)
92 
93 typedef struct dld_ioc_attr {
94 	char		dia_name[IFNAMSIZ];
95 	char		dia_dev[MAXNAMELEN];
96 	uint_t		dia_max_sdu;
97 	uint16_t	dia_vid;
98 } dld_ioc_attr_t;
99 
100 #define	DLDIOCVLAN	(DLDIOC | 0x04)
101 
102 typedef struct dld_ioc_vlan {
103 	char		div_name[IFNAMSIZ];
104 	uint_t		div_count;
105 } dld_ioc_vlan_t;
106 
107 typedef struct dld_vlan_info {
108 	char		dvi_name[IFNAMSIZ];
109 } dld_vlan_info_t;
110 
111 typedef struct dld_hold_vlan {
112 	char		dhv_name[IFNAMSIZ];
113 	zoneid_t	dhv_zid;
114 	boolean_t	dhv_docheck;
115 } dld_hold_vlan_t;
116 
117 /*
118  * Secure objects ioctls
119  */
120 typedef enum {
121 	DLD_SECOBJ_CLASS_WEP = 1
122 } dld_secobj_class_t;
123 
124 #define	DLD_SECOBJ_OPT_CREATE	0x00000001
125 #define	DLD_SECOBJ_NAME_MAX	32
126 #define	DLD_SECOBJ_VAL_MAX	256
127 typedef struct dld_secobj {
128 	char			so_name[DLD_SECOBJ_NAME_MAX];
129 	dld_secobj_class_t	so_class;
130 	uint8_t			so_val[DLD_SECOBJ_VAL_MAX];
131 	uint_t			so_len;
132 } dld_secobj_t;
133 
134 #define	DLDIOCSECOBJSET		(DLDIOC | 0x05)
135 typedef struct dld_ioc_secobj_set {
136 	dld_secobj_t		ss_obj;
137 	uint_t			ss_flags;
138 } dld_ioc_secobj_set_t;
139 
140 #define	DLDIOCSECOBJGET		(DLDIOC | 0x06)
141 typedef struct dld_ioc_secobj_get {
142 	dld_secobj_t		sg_obj;
143 	uint_t			sg_count;
144 } dld_ioc_secobj_get_t;
145 
146 #define	DLDIOCSECOBJUNSET	(DLDIOC | 0x07)
147 typedef struct dld_ioc_secobj_unset {
148 	char			su_name[DLD_SECOBJ_NAME_MAX];
149 } dld_ioc_secobj_unset_t;
150 
151 /*
152  * DLDIOCHOLDVLAN/DLDIOCRELEVLAN are added to support a "hold/release"
153  * operation on a VLAN. A hold will cause a VLAN to be created or the
154  * reference count will be increased, release will do the reverse.
155  */
156 #define	DLDIOCHOLDVLAN  (DLDIOC | 0x08)
157 
158 #define	DLDIOCRELEVLAN  (DLDIOC | 0x09)
159 
160 #define	DLDIOCZIDGET	(DLDIOC | 0x0a)
161 
162 #ifdef _KERNEL
163 int	dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
164 int	dld_open(queue_t *, dev_t *, int, int, cred_t *);
165 int	dld_close(queue_t *);
166 void	dld_wput(queue_t *, mblk_t *);
167 void	dld_wsrv(queue_t *);
168 void	dld_init_ops(struct dev_ops *, const char *);
169 void	dld_fini_ops(struct dev_ops *);
170 #endif
171 
172 #ifdef	__cplusplus
173 }
174 #endif
175 
176 #endif	/* _SYS_DLD_H */
177