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