xref: /titanic_41/usr/src/uts/common/sys/dld.h (revision 75e21072b15921edb21066ef5eaa2e412b163266)
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 2009 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/mac_flow.h>
41 #include <sys/conf.h>
42 #include <sys/sad.h>
43 #include <sys/mac.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Data-Link Driver Information (text emitted by modinfo(1m))
51  */
52 #define	DLD_INFO	"Data-Link Driver"
53 
54 /*
55  * Options: To enable an option set the property name to a non-zero value
56  *	    in kernel/drv/dld.conf.
57  */
58 
59 /*
60  * Prevent use of the IP fast-path (direct M_DATA transmit).
61  */
62 #define	DLD_PROP_NO_FASTPATH	"no-fastpath"
63 
64 /*
65  * Prevent advertising of the DL_CAPAB_POLL capability.
66  */
67 #define	DLD_PROP_NO_POLL	"no-poll"
68 
69 /*
70  * Prevent advertising of the DL_CAPAB_ZEROCOPY capability.
71  */
72 #define	DLD_PROP_NO_ZEROCOPY	"no-zerocopy"
73 
74 /*
75  * Prevent advertising of the DL_CAPAB_SOFTRING capability.
76  */
77 #define	DLD_PROP_NO_SOFTRING	"no-softring"
78 
79 /*
80  * The name of the driver.
81  */
82 #define	DLD_DRIVER_NAME		"dld"
83 
84 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
85 #pragma pack(4)
86 #endif
87 
88 /*
89  * IOCTL codes and data structures.
90  */
91 #define	DLDIOC_ATTR	DLDIOC(0x03)
92 
93 typedef struct dld_ioc_attr {
94 	datalink_id_t		dia_linkid;
95 	uint_t			dia_max_sdu;
96 } dld_ioc_attr_t;
97 
98 #define	DLDIOC_VLAN_ATTR	DLDIOC(0x04)
99 typedef struct dld_ioc_vlan_attr {
100 	datalink_id_t	div_vlanid;
101 	uint16_t	div_vid;
102 	datalink_id_t	div_linkid;
103 	boolean_t	div_force;
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 } dld_ioc_zid_t;
207 
208 /*
209  * data-link autopush configuration.
210  */
211 struct dlautopush {
212 	uint_t	dap_anchor;
213 	uint_t	dap_npush;
214 	char	dap_aplist[MAXAPUSH][FMNAMESZ+1];
215 };
216 
217 #define	DLDIOC_MACADDRGET	DLDIOC(0x15)
218 typedef struct dld_ioc_macaddrget {
219 	datalink_id_t	dig_linkid;
220 	uint_t		dig_count;
221 	uint_t		dig_size;
222 } dld_ioc_macaddrget_t;
223 
224 /* possible flags for dmi_flags below */
225 #define	DLDIOCMACADDR_USED	0x1	/* address slot used */
226 
227 typedef struct dld_macaddrinfo {
228 	uint_t		dmi_slot;
229 	uint_t		dmi_flags;
230 	uint_t		dmi_addrlen;
231 	uchar_t		dmi_addr[MAXMACADDRLEN];
232 	char		dmi_client_name[MAXNAMELEN];
233 	datalink_id_t	dma_client_linkid;
234 } dld_macaddrinfo_t;
235 
236 /*
237  * IOCTL codes and data structures for flowadm.
238  */
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];
245 } dld_ioc_addflow_t;
246 
247 #define	DLDIOC_REMOVEFLOW	DLDIOC(0x17)
248 typedef struct dld_ioc_removeflow {
249 	char			rf_name[MAXFLOWNAMELEN];
250 } dld_ioc_removeflow_t;
251 
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;
257 
258 #define	DLDIOC_WALKFLOW		DLDIOC(0x19)
259 typedef struct dld_ioc_walkflow {
260 	datalink_id_t		wf_linkid;
261 	char			wf_name[MAXFLOWNAMELEN];
262 	uint32_t		wf_nflows;
263 	uint_t			wf_len;
264 } dld_ioc_walkflow_t;
265 
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];
271 	uint32_t		fi_pad;
272 } dld_flowinfo_t;
273 
274 #define	DLDIOC_USAGELOG		DLDIOC(0x1a)
275 typedef struct dld_ioc_usagelog {
276 	mac_logtype_t	ul_type;
277 	boolean_t	ul_onoff;
278 	uint_t		ul_interval;
279 } dld_ioc_usagelog_t;
280 
281 #define	DLDIOC_SETMACPROP	DLDIOC(0x1b)
282 #define	DLDIOC_GETMACPROP	DLDIOC(0x1c)
283 #define	MAC_PROP_VERSION	1
284 
285 typedef struct dld_ioc_macprop_s {
286 	int		pr_version;
287 	uint_t		pr_flags;
288 	datalink_id_t	pr_linkid;
289 	mac_prop_id_t	pr_num;
290 	uint_t		pr_perm_flags;
291 	char    	pr_name[MAXLINKPROPNAME];
292 	uint_t		pr_valsize;		/* sizeof pr_val */
293 	char		pr_val[1];
294 } dld_ioc_macprop_t;
295 
296 #define	DLDIOC_GETHWGRP		DLDIOC(0x1d)
297 
298 typedef struct dld_ioc_hwgrpget {
299 	datalink_id_t	dih_linkid;
300 	uint_t		dih_n_groups;	/* number of groups included in ioc */
301 	uint_t		dih_size;
302 } dld_ioc_hwgrpget_t;
303 
304 #define	MAXCLIENTNAMELEN	1024
305 typedef struct dld_hwgrpinfo {
306 	char	dhi_link_name[MAXLINKNAMELEN];
307 	uint_t	dhi_grp_num;
308 	uint_t	dhi_grp_type;
309 	uint_t	dhi_n_rings;
310 	uint_t	dhi_n_clnts;
311 	/* XXXX later we should use dhi_n_clnts * MAXNAMELEN for dhi_clnts */
312 	char	dhi_clnts[MAXCLIENTNAMELEN];
313 } dld_hwgrpinfo_t;
314 
315 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
316 #pragma pack()
317 #endif
318 
319 #ifdef _KERNEL
320 
321 #define	DLD_CAPAB_DIRECT	0x00000001
322 #define	DLD_CAPAB_POLL		0x00000002
323 #define	DLD_CAPAB_PERIM		0x00000003
324 #define	DLD_CAPAB_LSO		0x00000004
325 
326 #define	DLD_ENABLE		0x00000001
327 #define	DLD_DISABLE		0x00000002
328 #define	DLD_QUERY		0x00000003
329 
330 /*
331  * GLDv3 entry point for negotiating capabilities.
332  * This is exposed to IP after negotiation of DL_CAPAB_DLD.
333  *
334  * This function takes the following arguments:
335  * handle: used for identifying the interface to operate on (provided by dld).
336  * type: capability type.
337  * arg: points to a capability-specific structure.
338  * flags: used for indicating whether to enable or disable a capability.
339  *
340  * With this function, capability negotiation is reduced from a multi-step
341  * process to just one single function call.
342  * e.g. the following code would pass 'x' from IP to dld and obtain
343  * arg.output_arg from dld:
344  *
345  * arg.input_arg = x;
346  * rc = (*dld_capab)(handle, DLD_CAPAB_XXX, &arg, DLD_ENABLE);
347  * ill->info1 = arg.output_arg;
348  */
349 typedef	int	(*dld_capab_func_t)(void *, uint_t, void *, uint_t);
350 
351 /*
352  * Direct Tx/Rx capability.
353  */
354 typedef struct dld_capab_direct_s {
355 	/*
356 	 * Rx entry point and handle, owned by IP.
357 	 */
358 	uintptr_t	di_rx_cf;
359 	void		*di_rx_ch;
360 
361 	/*
362 	 * Tx entry points and handle, owned by DLD.
363 	 */
364 	/* Entry point for transmitting packets */
365 	uintptr_t	di_tx_df;
366 	void		*di_tx_dh;
367 
368 	/* flow control notification callback */
369 	uintptr_t	di_tx_cb_df; /* callback registration/de-registration */
370 	void		*di_tx_cb_dh;
371 
372 	/* flow control "can I put on a ring" callback */
373 	uintptr_t	di_tx_fctl_df; /* canput-like callback */
374 	void		*di_tx_fctl_dh;
375 } dld_capab_direct_t;
376 
377 /*
378  * Polling/softring capability.
379  */
380 #define	POLL_SOFTRING		0x00000001
381 typedef struct dld_capab_poll_s {
382 	uintptr_t	poll_ring_add_cf;
383 	uintptr_t	poll_ring_remove_cf;
384 	uintptr_t	poll_ring_quiesce_cf;
385 	uintptr_t	poll_ring_restart_cf;
386 	uintptr_t	poll_ring_bind_cf;
387 	void		*poll_ring_ch;
388 	uintptr_t	poll_mac_accept_df;
389 	void		*poll_mac_dh;
390 } dld_capab_poll_t;
391 
392 /*
393  * LSO capability
394  */
395 /*
396  * Currently supported flags for LSO.
397  */
398 #define	DLD_LSO_TX_BASIC_TCP_IPV4	0x01	/* TCP LSO capability */
399 
400 typedef struct dld_capab_lso_s {
401 	uint_t  lso_flags;	/* capability flags */
402 	uint_t  lso_max;	/* maximum payload */
403 } dld_capab_lso_t;
404 
405 int	dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
406 int	dld_open(queue_t *, dev_t *, int, int, cred_t *);
407 int	dld_close(queue_t *);
408 void	dld_wput(queue_t *, mblk_t *);
409 void	dld_wsrv(queue_t *);
410 int	dld_str_open(queue_t *, dev_t *, void *);
411 int	dld_str_close(queue_t *);
412 void	*dld_str_private(queue_t *);
413 void	dld_init_ops(struct dev_ops *, const char *);
414 void	dld_fini_ops(struct dev_ops *);
415 int	dld_autopush(dev_t *, struct dlautopush *);
416 
417 int	dld_add_flow(datalink_id_t, char *, flow_desc_t *,
418     mac_resource_props_t *);
419 int	dld_remove_flow(char *);
420 int	dld_modify_flow(char *, mac_resource_props_t *);
421 int	dld_walk_flow(dld_ioc_walkflow_t *, intptr_t);
422 
423 #endif
424 
425 #ifdef	__cplusplus
426 }
427 #endif
428 
429 #endif	/* _SYS_DLD_H */
430