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 /* 22*12163SRamaswamy.Tummala@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 237408SSebastien.Roy@Sun.COM */ 247408SSebastien.Roy@Sun.COM 257408SSebastien.Roy@Sun.COM #ifndef _SYS_DLD_IOC_H 267408SSebastien.Roy@Sun.COM #define _SYS_DLD_IOC_H 277408SSebastien.Roy@Sun.COM 287408SSebastien.Roy@Sun.COM #include <sys/types.h> 297408SSebastien.Roy@Sun.COM #include <sys/cred.h> 307408SSebastien.Roy@Sun.COM 317408SSebastien.Roy@Sun.COM #ifdef __cplusplus 327408SSebastien.Roy@Sun.COM extern "C" { 337408SSebastien.Roy@Sun.COM #endif 347408SSebastien.Roy@Sun.COM 357408SSebastien.Roy@Sun.COM /* 367408SSebastien.Roy@Sun.COM * The name of the dld control device. All GLDv3 control ioctls are 377408SSebastien.Roy@Sun.COM * performed on this device. 387408SSebastien.Roy@Sun.COM */ 397408SSebastien.Roy@Sun.COM #define DLD_CONTROL_DEV "/dev/dld" 407408SSebastien.Roy@Sun.COM 417408SSebastien.Roy@Sun.COM /* 427408SSebastien.Roy@Sun.COM * GLDv3 ioctl values are structured as follows: 437408SSebastien.Roy@Sun.COM * 447408SSebastien.Roy@Sun.COM * | 16-bits | 16-bits | 457408SSebastien.Roy@Sun.COM * +----------------+----------------+ 467408SSebastien.Roy@Sun.COM * | module-id | command-id | 477408SSebastien.Roy@Sun.COM * +----------------+----------------+ 487408SSebastien.Roy@Sun.COM */ 497408SSebastien.Roy@Sun.COM #define DLD_IOC_CMD(modid, cmdid) (((uint_t)(modid) << 16) | (cmdid)) 507408SSebastien.Roy@Sun.COM #define DLD_IOC_MODID(cmd) (((cmd) & 0xffff0000) >> 16) 517408SSebastien.Roy@Sun.COM /* 527408SSebastien.Roy@Sun.COM * GLDv3 module ids to be passed in as the first argument to 537408SSebastien.Roy@Sun.COM * dld_ioc_register() and dld_ioc_unregister(). 547408SSebastien.Roy@Sun.COM */ 557408SSebastien.Roy@Sun.COM #define DLD_IOC 0x0D1D 567408SSebastien.Roy@Sun.COM #define AGGR_IOC 0x0A66 577408SSebastien.Roy@Sun.COM #define VNIC_IOC 0x0171 589815SRishi.Srivatsavai@Sun.COM #define SIMNET_IOC 0x5132 5910616SSebastien.Roy@Sun.COM #define IPTUN_IOC 0x454A 6010491SRishi.Srivatsavai@Sun.COM #define BRIDGE_IOC 0xB81D 61*12163SRamaswamy.Tummala@Sun.COM #define IBPART_IOC 0x6171 627408SSebastien.Roy@Sun.COM 637408SSebastien.Roy@Sun.COM /* GLDv3 modules use these macros to generate unique ioctl commands */ 649815SRishi.Srivatsavai@Sun.COM #define DLDIOC(cmdid) DLD_IOC_CMD(DLD_IOC, (cmdid)) 659815SRishi.Srivatsavai@Sun.COM #define AGGRIOC(cmdid) DLD_IOC_CMD(AGGR_IOC, (cmdid)) 669815SRishi.Srivatsavai@Sun.COM #define VNICIOC(cmdid) DLD_IOC_CMD(VNIC_IOC, (cmdid)) 679815SRishi.Srivatsavai@Sun.COM #define SIMNETIOC(cmdid) DLD_IOC_CMD(SIMNET_IOC, (cmdid)) 6810616SSebastien.Roy@Sun.COM #define IPTUNIOC(cmdid) DLD_IOC_CMD(IPTUN_IOC, (cmdid)) 6910491SRishi.Srivatsavai@Sun.COM #define BRIDGEIOC(cmdid) DLD_IOC_CMD(BRIDGE_IOC, (cmdid)) 70*12163SRamaswamy.Tummala@Sun.COM #define IBPARTIOC(cmdid) DLD_IOC_CMD(IBPART_IOC, (cmdid)) 717408SSebastien.Roy@Sun.COM 727408SSebastien.Roy@Sun.COM #ifdef _KERNEL 737408SSebastien.Roy@Sun.COM 747408SSebastien.Roy@Sun.COM /* 757408SSebastien.Roy@Sun.COM * GLDv3 modules register the ioctls they're interested in by passing 767408SSebastien.Roy@Sun.COM * in an array of dld_ioc_info_t to dld_ioc_register(). Modules 777408SSebastien.Roy@Sun.COM * should call dld_ioc_register() either in _init() or attach(). The 787408SSebastien.Roy@Sun.COM * dld module assumes that ddi_hold_devi_by_instance(<module>, 0, 0) 797408SSebastien.Roy@Sun.COM * will cause the module to load and call dld_ioc_register(). 807408SSebastien.Roy@Sun.COM * 817408SSebastien.Roy@Sun.COM * The di_cmd field is an ioctl command generated using one of the 827408SSebastien.Roy@Sun.COM * macros above. The di_argsize value is used by dld to copyin or 837408SSebastien.Roy@Sun.COM * copyout the correct amount of data depending on whether the 847408SSebastien.Roy@Sun.COM * DLDCOPYIN or DLDCOPYOUT flags are set so that every di_func() 857408SSebastien.Roy@Sun.COM * callback function does not need to copyin/out its own data. 867408SSebastien.Roy@Sun.COM */ 878275SEric Cheng 888275SEric Cheng typedef int (dld_ioc_func_t)(void *, intptr_t, int, cred_t *, int *); 8910616SSebastien.Roy@Sun.COM typedef int (dld_ioc_priv_func_t)(const cred_t *); 907408SSebastien.Roy@Sun.COM typedef struct dld_ioc_info { 917408SSebastien.Roy@Sun.COM uint_t di_cmd; 927408SSebastien.Roy@Sun.COM uint_t di_flags; 937408SSebastien.Roy@Sun.COM size_t di_argsize; 947408SSebastien.Roy@Sun.COM dld_ioc_func_t *di_func; 9510616SSebastien.Roy@Sun.COM dld_ioc_priv_func_t *di_priv_func; 967408SSebastien.Roy@Sun.COM } dld_ioc_info_t; 977408SSebastien.Roy@Sun.COM 987408SSebastien.Roy@Sun.COM /* Values for di_flags */ 997408SSebastien.Roy@Sun.COM #define DLDCOPYIN 0x00000001 /* copyin di_argsize amount of data */ 1007408SSebastien.Roy@Sun.COM #define DLDCOPYOUT 0x00000002 /* copyout di_argsize amount of data */ 1017408SSebastien.Roy@Sun.COM #define DLDCOPYINOUT (DLDCOPYIN | DLDCOPYOUT) 1027408SSebastien.Roy@Sun.COM 1037408SSebastien.Roy@Sun.COM #define DLDIOCCNT(l) (sizeof (l) / sizeof (dld_ioc_info_t)) 1047408SSebastien.Roy@Sun.COM int dld_ioc_register(uint16_t, dld_ioc_info_t *, uint_t); 1057408SSebastien.Roy@Sun.COM void dld_ioc_unregister(uint16_t); 1067408SSebastien.Roy@Sun.COM 1077408SSebastien.Roy@Sun.COM #endif /* _KERNEL */ 1087408SSebastien.Roy@Sun.COM 1097408SSebastien.Roy@Sun.COM #ifdef __cplusplus 1107408SSebastien.Roy@Sun.COM } 1117408SSebastien.Roy@Sun.COM #endif 1127408SSebastien.Roy@Sun.COM 1137408SSebastien.Roy@Sun.COM #endif /* _SYS_DLD_IOC_H */ 114