1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Linux WiMax 3*4882a593Smuzhiyun * API for user space 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or without 9*4882a593Smuzhiyun * modification, are permitted provided that the following conditions 10*4882a593Smuzhiyun * are met: 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * * Redistributions of source code must retain the above copyright 13*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer. 14*4882a593Smuzhiyun * * Redistributions in binary form must reproduce the above copyright 15*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer in 16*4882a593Smuzhiyun * the documentation and/or other materials provided with the 17*4882a593Smuzhiyun * distribution. 18*4882a593Smuzhiyun * * Neither the name of Intel Corporation nor the names of its 19*4882a593Smuzhiyun * contributors may be used to endorse or promote products derived 20*4882a593Smuzhiyun * from this software without specific prior written permission. 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23*4882a593Smuzhiyun * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24*4882a593Smuzhiyun * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25*4882a593Smuzhiyun * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26*4882a593Smuzhiyun * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27*4882a593Smuzhiyun * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28*4882a593Smuzhiyun * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29*4882a593Smuzhiyun * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30*4882a593Smuzhiyun * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31*4882a593Smuzhiyun * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32*4882a593Smuzhiyun * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33*4882a593Smuzhiyun * 34*4882a593Smuzhiyun * 35*4882a593Smuzhiyun * Intel Corporation <linux-wimax@intel.com> 36*4882a593Smuzhiyun * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 37*4882a593Smuzhiyun * - Initial implementation 38*4882a593Smuzhiyun * 39*4882a593Smuzhiyun * 40*4882a593Smuzhiyun * This file declares the user/kernel protocol that is spoken over 41*4882a593Smuzhiyun * Generic Netlink, as well as any type declaration that is to be used 42*4882a593Smuzhiyun * by kernel and user space. 43*4882a593Smuzhiyun * 44*4882a593Smuzhiyun * It is intended for user space to clone it verbatim to use it as a 45*4882a593Smuzhiyun * primary reference for definitions. 46*4882a593Smuzhiyun * 47*4882a593Smuzhiyun * Stuff intended for kernel usage as well as full protocol and stack 48*4882a593Smuzhiyun * documentation is rooted in include/net/wimax.h. 49*4882a593Smuzhiyun */ 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun #ifndef __LINUX__WIMAX_H__ 52*4882a593Smuzhiyun #define __LINUX__WIMAX_H__ 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun #include <linux/types.h> 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun enum { 57*4882a593Smuzhiyun /** 58*4882a593Smuzhiyun * Version of the interface (unsigned decimal, MMm, max 25.5) 59*4882a593Smuzhiyun * M - Major: change if removing or modifying an existing call. 60*4882a593Smuzhiyun * m - minor: change when adding a new call 61*4882a593Smuzhiyun */ 62*4882a593Smuzhiyun WIMAX_GNL_VERSION = 01, 63*4882a593Smuzhiyun /* Generic NetLink attributes */ 64*4882a593Smuzhiyun WIMAX_GNL_ATTR_INVALID = 0x00, 65*4882a593Smuzhiyun WIMAX_GNL_ATTR_MAX = 10, 66*4882a593Smuzhiyun }; 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun /* 70*4882a593Smuzhiyun * Generic NetLink operations 71*4882a593Smuzhiyun * 72*4882a593Smuzhiyun * Most of these map to an API call; _OP_ stands for operation, _RP_ 73*4882a593Smuzhiyun * for reply and _RE_ for report (aka: signal). 74*4882a593Smuzhiyun */ 75*4882a593Smuzhiyun enum { 76*4882a593Smuzhiyun WIMAX_GNL_OP_MSG_FROM_USER, /* User to kernel message */ 77*4882a593Smuzhiyun WIMAX_GNL_OP_MSG_TO_USER, /* Kernel to user message */ 78*4882a593Smuzhiyun WIMAX_GNL_OP_RFKILL, /* Run wimax_rfkill() */ 79*4882a593Smuzhiyun WIMAX_GNL_OP_RESET, /* Run wimax_rfkill() */ 80*4882a593Smuzhiyun WIMAX_GNL_RE_STATE_CHANGE, /* Report: status change */ 81*4882a593Smuzhiyun WIMAX_GNL_OP_STATE_GET, /* Request for current state */ 82*4882a593Smuzhiyun }; 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* Message from user / to user */ 86*4882a593Smuzhiyun enum { 87*4882a593Smuzhiyun WIMAX_GNL_MSG_IFIDX = 1, 88*4882a593Smuzhiyun WIMAX_GNL_MSG_PIPE_NAME, 89*4882a593Smuzhiyun WIMAX_GNL_MSG_DATA, 90*4882a593Smuzhiyun }; 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun /* 94*4882a593Smuzhiyun * wimax_rfkill() 95*4882a593Smuzhiyun * 96*4882a593Smuzhiyun * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's 97*4882a593Smuzhiyun * switch state (DISABLED/ENABLED). 98*4882a593Smuzhiyun */ 99*4882a593Smuzhiyun enum wimax_rf_state { 100*4882a593Smuzhiyun WIMAX_RF_OFF = 0, /* Radio is off, rfkill on/enabled */ 101*4882a593Smuzhiyun WIMAX_RF_ON = 1, /* Radio is on, rfkill off/disabled */ 102*4882a593Smuzhiyun WIMAX_RF_QUERY = 2, 103*4882a593Smuzhiyun }; 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun /* Attributes */ 106*4882a593Smuzhiyun enum { 107*4882a593Smuzhiyun WIMAX_GNL_RFKILL_IFIDX = 1, 108*4882a593Smuzhiyun WIMAX_GNL_RFKILL_STATE, 109*4882a593Smuzhiyun }; 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* Attributes for wimax_reset() */ 113*4882a593Smuzhiyun enum { 114*4882a593Smuzhiyun WIMAX_GNL_RESET_IFIDX = 1, 115*4882a593Smuzhiyun }; 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun /* Attributes for wimax_state_get() */ 118*4882a593Smuzhiyun enum { 119*4882a593Smuzhiyun WIMAX_GNL_STGET_IFIDX = 1, 120*4882a593Smuzhiyun }; 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun /* 123*4882a593Smuzhiyun * Attributes for the Report State Change 124*4882a593Smuzhiyun * 125*4882a593Smuzhiyun * For now we just have the old and new states; new attributes might 126*4882a593Smuzhiyun * be added later on. 127*4882a593Smuzhiyun */ 128*4882a593Smuzhiyun enum { 129*4882a593Smuzhiyun WIMAX_GNL_STCH_IFIDX = 1, 130*4882a593Smuzhiyun WIMAX_GNL_STCH_STATE_OLD, 131*4882a593Smuzhiyun WIMAX_GNL_STCH_STATE_NEW, 132*4882a593Smuzhiyun }; 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun /** 136*4882a593Smuzhiyun * enum wimax_st - The different states of a WiMAX device 137*4882a593Smuzhiyun * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed, 138*4882a593Smuzhiyun * but still wimax_dev_add() hasn't been called. There is no state. 139*4882a593Smuzhiyun * 140*4882a593Smuzhiyun * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and 141*4882a593Smuzhiyun * networking stacks, but it is not initialized (normally that is 142*4882a593Smuzhiyun * done with 'ifconfig DEV up' [or equivalent], which can upload 143*4882a593Smuzhiyun * firmware and enable communications with the device). 144*4882a593Smuzhiyun * In this state, the device is powered down and using as less 145*4882a593Smuzhiyun * power as possible. 146*4882a593Smuzhiyun * This state is the default after a call to wimax_dev_add(). It 147*4882a593Smuzhiyun * is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED 148*4882a593Smuzhiyun * or %WIMAX_ST_RADIO_OFF in _probe() after the call to 149*4882a593Smuzhiyun * wimax_dev_add(). 150*4882a593Smuzhiyun * It is recommended that the driver leaves this state when 151*4882a593Smuzhiyun * calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV 152*4882a593Smuzhiyun * down'. 153*4882a593Smuzhiyun * 154*4882a593Smuzhiyun * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API 155*4882a593Smuzhiyun * operations are allowed to proceed except the ones needed to 156*4882a593Smuzhiyun * complete the device clean up process. 157*4882a593Smuzhiyun * 158*4882a593Smuzhiyun * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device 159*4882a593Smuzhiyun * is setup, but the device still requires some configuration 160*4882a593Smuzhiyun * before being operational. 161*4882a593Smuzhiyun * Some WiMAX API calls might work. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether 164*4882a593Smuzhiyun * by hardware or software switches). 165*4882a593Smuzhiyun * It is recommended to always leave the device in this state 166*4882a593Smuzhiyun * after initialization. 167*4882a593Smuzhiyun * 168*4882a593Smuzhiyun * @WIMAX_ST_READY: The device is fully up and radio is on. 169*4882a593Smuzhiyun * 170*4882a593Smuzhiyun * @WIMAX_ST_SCANNING: [optional] The device has been instructed to 171*4882a593Smuzhiyun * scan. In this state, the device cannot be actively connected to 172*4882a593Smuzhiyun * a network. 173*4882a593Smuzhiyun * 174*4882a593Smuzhiyun * @WIMAX_ST_CONNECTING: The device is connecting to a network. This 175*4882a593Smuzhiyun * state exists because in some devices, the connect process can 176*4882a593Smuzhiyun * include a number of negotiations between user space, kernel 177*4882a593Smuzhiyun * space and the device. User space needs to know what the device 178*4882a593Smuzhiyun * is doing. If the connect sequence in a device is atomic and 179*4882a593Smuzhiyun * fast, the device can transition directly to CONNECTED 180*4882a593Smuzhiyun * 181*4882a593Smuzhiyun * @WIMAX_ST_CONNECTED: The device is connected to a network. 182*4882a593Smuzhiyun * 183*4882a593Smuzhiyun * @__WIMAX_ST_INVALID: This is an invalid state used to mark the 184*4882a593Smuzhiyun * maximum numeric value of states. 185*4882a593Smuzhiyun * 186*4882a593Smuzhiyun * Description: 187*4882a593Smuzhiyun * 188*4882a593Smuzhiyun * Transitions from one state to another one are atomic and can only 189*4882a593Smuzhiyun * be caused in kernel space with wimax_state_change(). To read the 190*4882a593Smuzhiyun * state, use wimax_state_get(). 191*4882a593Smuzhiyun * 192*4882a593Smuzhiyun * States starting with __ are internal and shall not be used or 193*4882a593Smuzhiyun * referred to by drivers or userspace. They look ugly, but that's the 194*4882a593Smuzhiyun * point -- if any use is made non-internal to the stack, it is easier 195*4882a593Smuzhiyun * to catch on review. 196*4882a593Smuzhiyun * 197*4882a593Smuzhiyun * All API operations [with well defined exceptions] will take the 198*4882a593Smuzhiyun * device mutex before starting and then check the state. If the state 199*4882a593Smuzhiyun * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or 200*4882a593Smuzhiyun * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with 201*4882a593Smuzhiyun * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN. 202*4882a593Smuzhiyun * 203*4882a593Smuzhiyun * The order of the definitions is important, so we can do numerical 204*4882a593Smuzhiyun * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready 205*4882a593Smuzhiyun * to operate). 206*4882a593Smuzhiyun */ 207*4882a593Smuzhiyun /* 208*4882a593Smuzhiyun * The allowed state transitions are described in the table below 209*4882a593Smuzhiyun * (states in rows can go to states in columns where there is an X): 210*4882a593Smuzhiyun * 211*4882a593Smuzhiyun * UNINI RADIO READY SCAN CONNEC CONNEC 212*4882a593Smuzhiyun * NULL DOWN QUIESCING TIALIZED OFF NING TING TED 213*4882a593Smuzhiyun * NULL - x 214*4882a593Smuzhiyun * DOWN - x x x 215*4882a593Smuzhiyun * QUIESCING x - 216*4882a593Smuzhiyun * UNINITIALIZED x - x 217*4882a593Smuzhiyun * RADIO_OFF x - x 218*4882a593Smuzhiyun * READY x x - x x x 219*4882a593Smuzhiyun * SCANNING x x x - x x 220*4882a593Smuzhiyun * CONNECTING x x x x - x 221*4882a593Smuzhiyun * CONNECTED x x x - 222*4882a593Smuzhiyun * 223*4882a593Smuzhiyun * This table not available in kernel-doc because the formatting messes it up. 224*4882a593Smuzhiyun */ 225*4882a593Smuzhiyun enum wimax_st { 226*4882a593Smuzhiyun __WIMAX_ST_NULL = 0, 227*4882a593Smuzhiyun WIMAX_ST_DOWN, 228*4882a593Smuzhiyun __WIMAX_ST_QUIESCING, 229*4882a593Smuzhiyun WIMAX_ST_UNINITIALIZED, 230*4882a593Smuzhiyun WIMAX_ST_RADIO_OFF, 231*4882a593Smuzhiyun WIMAX_ST_READY, 232*4882a593Smuzhiyun WIMAX_ST_SCANNING, 233*4882a593Smuzhiyun WIMAX_ST_CONNECTING, 234*4882a593Smuzhiyun WIMAX_ST_CONNECTED, 235*4882a593Smuzhiyun __WIMAX_ST_INVALID /* Always keep last */ 236*4882a593Smuzhiyun }; 237*4882a593Smuzhiyun 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun #endif /* #ifndef __LINUX__WIMAX_H__ */ 240