xref: /onnv-gate/usr/src/uts/common/sys/dld_ioc.h (revision 10491:8893b747ecdf)
17408SSebastien.Roy@Sun.COM /*
27408SSebastien.Roy@Sun.COM  * CDDL HEADER START
37408SSebastien.Roy@Sun.COM  *
47408SSebastien.Roy@Sun.COM  * The contents of this file are subject to the terms of the
57408SSebastien.Roy@Sun.COM  * Common Development and Distribution License (the "License").
67408SSebastien.Roy@Sun.COM  * You may not use this file except in compliance with the License.
77408SSebastien.Roy@Sun.COM  *
87408SSebastien.Roy@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97408SSebastien.Roy@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107408SSebastien.Roy@Sun.COM  * See the License for the specific language governing permissions
117408SSebastien.Roy@Sun.COM  * and limitations under the License.
127408SSebastien.Roy@Sun.COM  *
137408SSebastien.Roy@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147408SSebastien.Roy@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157408SSebastien.Roy@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167408SSebastien.Roy@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177408SSebastien.Roy@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187408SSebastien.Roy@Sun.COM  *
197408SSebastien.Roy@Sun.COM  * CDDL HEADER END
207408SSebastien.Roy@Sun.COM  */
217408SSebastien.Roy@Sun.COM /*
229815SRishi.Srivatsavai@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237408SSebastien.Roy@Sun.COM  * Use is subject to license terms.
247408SSebastien.Roy@Sun.COM  */
257408SSebastien.Roy@Sun.COM 
267408SSebastien.Roy@Sun.COM #ifndef	_SYS_DLD_IOC_H
277408SSebastien.Roy@Sun.COM #define	_SYS_DLD_IOC_H
287408SSebastien.Roy@Sun.COM 
297408SSebastien.Roy@Sun.COM #include <sys/types.h>
307408SSebastien.Roy@Sun.COM #include <sys/cred.h>
317408SSebastien.Roy@Sun.COM 
327408SSebastien.Roy@Sun.COM #ifdef	__cplusplus
337408SSebastien.Roy@Sun.COM extern "C" {
347408SSebastien.Roy@Sun.COM #endif
357408SSebastien.Roy@Sun.COM 
367408SSebastien.Roy@Sun.COM /*
377408SSebastien.Roy@Sun.COM  * The name of the dld control device.  All GLDv3 control ioctls are
387408SSebastien.Roy@Sun.COM  * performed on this device.
397408SSebastien.Roy@Sun.COM  */
407408SSebastien.Roy@Sun.COM #define	DLD_CONTROL_DEV		"/dev/dld"
417408SSebastien.Roy@Sun.COM 
427408SSebastien.Roy@Sun.COM /*
437408SSebastien.Roy@Sun.COM  * GLDv3 ioctl values are structured as follows:
447408SSebastien.Roy@Sun.COM  *
457408SSebastien.Roy@Sun.COM  * |    16-bits     |     16-bits    |
467408SSebastien.Roy@Sun.COM  * +----------------+----------------+
477408SSebastien.Roy@Sun.COM  * |   module-id    |   command-id   |
487408SSebastien.Roy@Sun.COM  * +----------------+----------------+
497408SSebastien.Roy@Sun.COM  */
507408SSebastien.Roy@Sun.COM #define	DLD_IOC_CMD(modid, cmdid)	(((uint_t)(modid) << 16) | (cmdid))
517408SSebastien.Roy@Sun.COM #define	DLD_IOC_MODID(cmd)		(((cmd) & 0xffff0000) >> 16)
527408SSebastien.Roy@Sun.COM /*
537408SSebastien.Roy@Sun.COM  * GLDv3 module ids to be passed in as the first argument to
547408SSebastien.Roy@Sun.COM  * dld_ioc_register() and dld_ioc_unregister().
557408SSebastien.Roy@Sun.COM  */
567408SSebastien.Roy@Sun.COM #define	DLD_IOC		0x0D1D
577408SSebastien.Roy@Sun.COM #define	AGGR_IOC	0x0A66
587408SSebastien.Roy@Sun.COM #define	VNIC_IOC	0x0171
599815SRishi.Srivatsavai@Sun.COM #define	SIMNET_IOC	0x5132
60*10491SRishi.Srivatsavai@Sun.COM #define	BRIDGE_IOC	0xB81D
617408SSebastien.Roy@Sun.COM 
627408SSebastien.Roy@Sun.COM /* GLDv3 modules use these macros to generate unique ioctl commands */
639815SRishi.Srivatsavai@Sun.COM #define	DLDIOC(cmdid)		DLD_IOC_CMD(DLD_IOC, (cmdid))
649815SRishi.Srivatsavai@Sun.COM #define	AGGRIOC(cmdid)		DLD_IOC_CMD(AGGR_IOC, (cmdid))
659815SRishi.Srivatsavai@Sun.COM #define	VNICIOC(cmdid)		DLD_IOC_CMD(VNIC_IOC, (cmdid))
669815SRishi.Srivatsavai@Sun.COM #define	SIMNETIOC(cmdid)	DLD_IOC_CMD(SIMNET_IOC, (cmdid))
67*10491SRishi.Srivatsavai@Sun.COM #define	BRIDGEIOC(cmdid)	DLD_IOC_CMD(BRIDGE_IOC, (cmdid))
687408SSebastien.Roy@Sun.COM 
697408SSebastien.Roy@Sun.COM #ifdef _KERNEL
707408SSebastien.Roy@Sun.COM 
717408SSebastien.Roy@Sun.COM /*
727408SSebastien.Roy@Sun.COM  * GLDv3 modules register the ioctls they're interested in by passing
737408SSebastien.Roy@Sun.COM  * in an array of dld_ioc_info_t to dld_ioc_register().  Modules
747408SSebastien.Roy@Sun.COM  * should call dld_ioc_register() either in _init() or attach().  The
757408SSebastien.Roy@Sun.COM  * dld module assumes that ddi_hold_devi_by_instance(<module>, 0, 0)
767408SSebastien.Roy@Sun.COM  * will cause the module to load and call dld_ioc_register().
777408SSebastien.Roy@Sun.COM  *
787408SSebastien.Roy@Sun.COM  * The di_cmd field is an ioctl command generated using one of the
797408SSebastien.Roy@Sun.COM  * macros above.  The di_argsize value is used by dld to copyin or
807408SSebastien.Roy@Sun.COM  * copyout the correct amount of data depending on whether the
817408SSebastien.Roy@Sun.COM  * DLDCOPYIN or DLDCOPYOUT flags are set so that every di_func()
827408SSebastien.Roy@Sun.COM  * callback function does not need to copyin/out its own data.
837408SSebastien.Roy@Sun.COM  */
848275SEric Cheng 
858275SEric Cheng /* Maximum number of Privileges */
868275SEric Cheng #define	DLD_MAX_PRIV	16
878275SEric Cheng 
888275SEric Cheng typedef int (dld_ioc_func_t)(void *, intptr_t, int, cred_t *, int *);
897408SSebastien.Roy@Sun.COM typedef struct dld_ioc_info {
907408SSebastien.Roy@Sun.COM 	uint_t		di_cmd;
917408SSebastien.Roy@Sun.COM 	uint_t		di_flags;
927408SSebastien.Roy@Sun.COM 	size_t		di_argsize;
937408SSebastien.Roy@Sun.COM 	dld_ioc_func_t	*di_func;
948275SEric Cheng 	const char	*di_priv[DLD_MAX_PRIV];
957408SSebastien.Roy@Sun.COM } dld_ioc_info_t;
967408SSebastien.Roy@Sun.COM 
977408SSebastien.Roy@Sun.COM /* Values for di_flags */
987408SSebastien.Roy@Sun.COM #define	DLDCOPYIN	0x00000001 /* copyin di_argsize amount of data */
997408SSebastien.Roy@Sun.COM #define	DLDCOPYOUT	0x00000002 /* copyout di_argsize amount of data */
1007408SSebastien.Roy@Sun.COM #define	DLDCOPYINOUT	(DLDCOPYIN | DLDCOPYOUT)
1017408SSebastien.Roy@Sun.COM 
1027408SSebastien.Roy@Sun.COM #define	DLDIOCCNT(l)	(sizeof (l) / sizeof (dld_ioc_info_t))
1037408SSebastien.Roy@Sun.COM int	dld_ioc_register(uint16_t, dld_ioc_info_t *, uint_t);
1047408SSebastien.Roy@Sun.COM void	dld_ioc_unregister(uint16_t);
1057408SSebastien.Roy@Sun.COM 
1067408SSebastien.Roy@Sun.COM #endif /* _KERNEL */
1077408SSebastien.Roy@Sun.COM 
1087408SSebastien.Roy@Sun.COM #ifdef	__cplusplus
1097408SSebastien.Roy@Sun.COM }
1107408SSebastien.Roy@Sun.COM #endif
1117408SSebastien.Roy@Sun.COM 
1127408SSebastien.Roy@Sun.COM #endif	/* _SYS_DLD_IOC_H */
113