xref: /titanic_51/usr/src/uts/common/sys/dld_ioc.h (revision 1cfa752f4e24c34133009b0f6c139127a5c461de)
1eae72b5bSSebastien Roy /*
2eae72b5bSSebastien Roy  * CDDL HEADER START
3eae72b5bSSebastien Roy  *
4eae72b5bSSebastien Roy  * The contents of this file are subject to the terms of the
5eae72b5bSSebastien Roy  * Common Development and Distribution License (the "License").
6eae72b5bSSebastien Roy  * You may not use this file except in compliance with the License.
7eae72b5bSSebastien Roy  *
8eae72b5bSSebastien Roy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9eae72b5bSSebastien Roy  * or http://www.opensolaris.org/os/licensing.
10eae72b5bSSebastien Roy  * See the License for the specific language governing permissions
11eae72b5bSSebastien Roy  * and limitations under the License.
12eae72b5bSSebastien Roy  *
13eae72b5bSSebastien Roy  * When distributing Covered Code, include this CDDL HEADER in each
14eae72b5bSSebastien Roy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eae72b5bSSebastien Roy  * If applicable, add the following below this CDDL HEADER, with the
16eae72b5bSSebastien Roy  * fields enclosed by brackets "[]" replaced with your own identifying
17eae72b5bSSebastien Roy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eae72b5bSSebastien Roy  *
19eae72b5bSSebastien Roy  * CDDL HEADER END
20eae72b5bSSebastien Roy  */
21eae72b5bSSebastien Roy /*
22*1cfa752fSRamaswamy Tummala  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23eae72b5bSSebastien Roy  */
24eae72b5bSSebastien Roy 
25eae72b5bSSebastien Roy #ifndef	_SYS_DLD_IOC_H
26eae72b5bSSebastien Roy #define	_SYS_DLD_IOC_H
27eae72b5bSSebastien Roy 
28eae72b5bSSebastien Roy #include <sys/types.h>
29eae72b5bSSebastien Roy #include <sys/cred.h>
30eae72b5bSSebastien Roy 
31eae72b5bSSebastien Roy #ifdef	__cplusplus
32eae72b5bSSebastien Roy extern "C" {
33eae72b5bSSebastien Roy #endif
34eae72b5bSSebastien Roy 
35eae72b5bSSebastien Roy /*
36eae72b5bSSebastien Roy  * The name of the dld control device.  All GLDv3 control ioctls are
37eae72b5bSSebastien Roy  * performed on this device.
38eae72b5bSSebastien Roy  */
39eae72b5bSSebastien Roy #define	DLD_CONTROL_DEV		"/dev/dld"
40eae72b5bSSebastien Roy 
41eae72b5bSSebastien Roy /*
42eae72b5bSSebastien Roy  * GLDv3 ioctl values are structured as follows:
43eae72b5bSSebastien Roy  *
44eae72b5bSSebastien Roy  * |    16-bits     |     16-bits    |
45eae72b5bSSebastien Roy  * +----------------+----------------+
46eae72b5bSSebastien Roy  * |   module-id    |   command-id   |
47eae72b5bSSebastien Roy  * +----------------+----------------+
48eae72b5bSSebastien Roy  */
49eae72b5bSSebastien Roy #define	DLD_IOC_CMD(modid, cmdid)	(((uint_t)(modid) << 16) | (cmdid))
50eae72b5bSSebastien Roy #define	DLD_IOC_MODID(cmd)		(((cmd) & 0xffff0000) >> 16)
51eae72b5bSSebastien Roy /*
52eae72b5bSSebastien Roy  * GLDv3 module ids to be passed in as the first argument to
53eae72b5bSSebastien Roy  * dld_ioc_register() and dld_ioc_unregister().
54eae72b5bSSebastien Roy  */
55eae72b5bSSebastien Roy #define	DLD_IOC		0x0D1D
56eae72b5bSSebastien Roy #define	AGGR_IOC	0x0A66
57eae72b5bSSebastien Roy #define	VNIC_IOC	0x0171
58b509e89bSRishi Srivatsavai #define	SIMNET_IOC	0x5132
592b24ab6bSSebastien Roy #define	IPTUN_IOC	0x454A
604eaa4710SRishi Srivatsavai #define	BRIDGE_IOC	0xB81D
61*1cfa752fSRamaswamy Tummala #define	IBPART_IOC	0x6171
62eae72b5bSSebastien Roy 
63eae72b5bSSebastien Roy /* GLDv3 modules use these macros to generate unique ioctl commands */
64eae72b5bSSebastien Roy #define	DLDIOC(cmdid)		DLD_IOC_CMD(DLD_IOC, (cmdid))
65eae72b5bSSebastien Roy #define	AGGRIOC(cmdid)		DLD_IOC_CMD(AGGR_IOC, (cmdid))
66eae72b5bSSebastien Roy #define	VNICIOC(cmdid)		DLD_IOC_CMD(VNIC_IOC, (cmdid))
67b509e89bSRishi Srivatsavai #define	SIMNETIOC(cmdid)	DLD_IOC_CMD(SIMNET_IOC, (cmdid))
682b24ab6bSSebastien Roy #define	IPTUNIOC(cmdid)		DLD_IOC_CMD(IPTUN_IOC, (cmdid))
694eaa4710SRishi Srivatsavai #define	BRIDGEIOC(cmdid)	DLD_IOC_CMD(BRIDGE_IOC, (cmdid))
70*1cfa752fSRamaswamy Tummala #define	IBPARTIOC(cmdid)	DLD_IOC_CMD(IBPART_IOC, (cmdid))
71eae72b5bSSebastien Roy 
72eae72b5bSSebastien Roy #ifdef _KERNEL
73eae72b5bSSebastien Roy 
74eae72b5bSSebastien Roy /*
75eae72b5bSSebastien Roy  * GLDv3 modules register the ioctls they're interested in by passing
76eae72b5bSSebastien Roy  * in an array of dld_ioc_info_t to dld_ioc_register().  Modules
77eae72b5bSSebastien Roy  * should call dld_ioc_register() either in _init() or attach().  The
78eae72b5bSSebastien Roy  * dld module assumes that ddi_hold_devi_by_instance(<module>, 0, 0)
79eae72b5bSSebastien Roy  * will cause the module to load and call dld_ioc_register().
80eae72b5bSSebastien Roy  *
81eae72b5bSSebastien Roy  * The di_cmd field is an ioctl command generated using one of the
82eae72b5bSSebastien Roy  * macros above.  The di_argsize value is used by dld to copyin or
83eae72b5bSSebastien Roy  * copyout the correct amount of data depending on whether the
84eae72b5bSSebastien Roy  * DLDCOPYIN or DLDCOPYOUT flags are set so that every di_func()
85eae72b5bSSebastien Roy  * callback function does not need to copyin/out its own data.
86eae72b5bSSebastien Roy  */
87da14cebeSEric Cheng 
88da14cebeSEric Cheng typedef int (dld_ioc_func_t)(void *, intptr_t, int, cred_t *, int *);
892b24ab6bSSebastien Roy typedef int (dld_ioc_priv_func_t)(const cred_t *);
90eae72b5bSSebastien Roy typedef struct dld_ioc_info {
91eae72b5bSSebastien Roy 	uint_t		di_cmd;
92eae72b5bSSebastien Roy 	uint_t		di_flags;
93eae72b5bSSebastien Roy 	size_t		di_argsize;
94eae72b5bSSebastien Roy 	dld_ioc_func_t	*di_func;
952b24ab6bSSebastien Roy 	dld_ioc_priv_func_t *di_priv_func;
96eae72b5bSSebastien Roy } dld_ioc_info_t;
97eae72b5bSSebastien Roy 
98eae72b5bSSebastien Roy /* Values for di_flags */
99eae72b5bSSebastien Roy #define	DLDCOPYIN	0x00000001 /* copyin di_argsize amount of data */
100eae72b5bSSebastien Roy #define	DLDCOPYOUT	0x00000002 /* copyout di_argsize amount of data */
101eae72b5bSSebastien Roy #define	DLDCOPYINOUT	(DLDCOPYIN | DLDCOPYOUT)
102eae72b5bSSebastien Roy 
103eae72b5bSSebastien Roy #define	DLDIOCCNT(l)	(sizeof (l) / sizeof (dld_ioc_info_t))
104eae72b5bSSebastien Roy int	dld_ioc_register(uint16_t, dld_ioc_info_t *, uint_t);
105eae72b5bSSebastien Roy void	dld_ioc_unregister(uint16_t);
106eae72b5bSSebastien Roy 
107eae72b5bSSebastien Roy #endif /* _KERNEL */
108eae72b5bSSebastien Roy 
109eae72b5bSSebastien Roy #ifdef	__cplusplus
110eae72b5bSSebastien Roy }
111eae72b5bSSebastien Roy #endif
112eae72b5bSSebastien Roy 
113eae72b5bSSebastien Roy #endif	/* _SYS_DLD_IOC_H */
114