linux/include/net/iw_handler.h
<<
>>
Prefs
   1/*
   2 * This file define the new driver API for Wireless Extensions
   3 *
   4 * Version :    8       16.3.07
   5 *
   6 * Authors :    Jean Tourrilhes - HPL - <jt@hpl.hp.com>
   7 * Copyright (c) 2001-2007 Jean Tourrilhes, All Rights Reserved.
   8 */
   9
  10#ifndef _IW_HANDLER_H
  11#define _IW_HANDLER_H
  12
  13/************************** DOCUMENTATION **************************/
  14/*
  15 * Initial driver API (1996 -> onward) :
  16 * -----------------------------------
  17 * The initial API just sends the IOCTL request received from user space
  18 * to the driver (via the driver ioctl handler). The driver has to
  19 * handle all the rest...
  20 *
  21 * The initial API also defines a specific handler in struct net_device
  22 * to handle wireless statistics.
  23 *
  24 * The initial APIs served us well and has proven a reasonably good design.
  25 * However, there is a few shortcommings :
  26 *      o No events, everything is a request to the driver.
  27 *      o Large ioctl function in driver with gigantic switch statement
  28 *        (i.e. spaghetti code).
  29 *      o Driver has to mess up with copy_to/from_user, and in many cases
  30 *        does it unproperly. Common mistakes are :
  31 *              * buffer overflows (no checks or off by one checks)
  32 *              * call copy_to/from_user with irq disabled
  33 *      o The user space interface is tied to ioctl because of the use
  34 *        copy_to/from_user.
  35 *
  36 * New driver API (2002 -> onward) :
  37 * -------------------------------
  38 * The new driver API is just a bunch of standard functions (handlers),
  39 * each handling a specific Wireless Extension. The driver just export
  40 * the list of handler it supports, and those will be called apropriately.
  41 *
  42 * I tried to keep the main advantage of the previous API (simplicity,
  43 * efficiency and light weight), and also I provide a good dose of backward
  44 * compatibility (most structures are the same, driver can use both API
  45 * simultaneously, ...).
  46 * Hopefully, I've also addressed the shortcomming of the initial API.
  47 *
  48 * The advantage of the new API are :
  49 *      o Handling of Extensions in driver broken in small contained functions
  50 *      o Tighter checks of ioctl before calling the driver
  51 *      o Flexible commit strategy (at least, the start of it)
  52 *      o Backward compatibility (can be mixed with old API)
  53 *      o Driver doesn't have to worry about memory and user-space issues
  54 * The last point is important for the following reasons :
  55 *      o You are now able to call the new driver API from any API you
  56 *              want (including from within other parts of the kernel).
  57 *      o Common mistakes are avoided (buffer overflow, user space copy
  58 *              with irq disabled and so on).
  59 *
  60 * The Drawback of the new API are :
  61 *      o bloat (especially kernel)
  62 *      o need to migrate existing drivers to new API
  63 * My initial testing shows that the new API adds around 3kB to the kernel
  64 * and save between 0 and 5kB from a typical driver.
  65 * Also, as all structures and data types are unchanged, the migration is
  66 * quite straightforward (but tedious).
  67 *
  68 * ---
  69 *
  70 * The new driver API is defined below in this file. User space should
  71 * not be aware of what's happening down there...
  72 *
  73 * A new kernel wrapper is in charge of validating the IOCTLs and calling
  74 * the appropriate driver handler. This is implemented in :
  75 *      # net/core/wireless.c
  76 *
  77 * The driver export the list of handlers in :
  78 *      # include/linux/netdevice.h (one place)
  79 *
  80 * The new driver API is available for WIRELESS_EXT >= 13.
  81 * Good luck with migration to the new API ;-)
  82 */
  83
  84/* ---------------------- THE IMPLEMENTATION ---------------------- */
  85/*
  86 * Some of the choice I've made are pretty controversials. Defining an
  87 * API is very much weighting compromises. This goes into some of the
  88 * details and the thinking behind the implementation.
  89 *
  90 * Implementation goals :
  91 * --------------------
  92 * The implementation goals were as follow :
  93 *      o Obvious : you should not need a PhD to understand what's happening,
  94 *              the benefit is easier maintenance.
  95 *      o Flexible : it should accommodate a wide variety of driver
  96 *              implementations and be as flexible as the old API.
  97 *      o Lean : it should be efficient memory wise to minimise the impact
  98 *              on kernel footprint.
  99 *      o Transparent to user space : the large number of user space
 100 *              applications that use Wireless Extensions should not need
 101 *              any modifications.
 102 *
 103 * Array of functions versus Struct of functions
 104 * ---------------------------------------------
 105 * 1) Having an array of functions allow the kernel code to access the
 106 * handler in a single lookup, which is much more efficient (think hash
 107 * table here).
 108 * 2) The only drawback is that driver writer may put their handler in
 109 * the wrong slot. This is trivial to test (I set the frequency, the
 110 * bitrate changes). Once the handler is in the proper slot, it will be
 111 * there forever, because the array is only extended at the end.
 112 * 3) Backward/forward compatibility : adding new handler just require
 113 * extending the array, so you can put newer driver in older kernel
 114 * without having to patch the kernel code (and vice versa).
 115 *
 116 * All handler are of the same generic type
 117 * ----------------------------------------
 118 * That's a feature !!!
 119 * 1) Having a generic handler allow to have generic code, which is more
 120 * efficient. If each of the handler was individually typed I would need
 121 * to add a big switch in the kernel (== more bloat). This solution is
 122 * more scalable, adding new Wireless Extensions doesn't add new code.
 123 * 2) You can use the same handler in different slots of the array. For
 124 * hardware, it may be more efficient or logical to handle multiple
 125 * Wireless Extensions with a single function, and the API allow you to
 126 * do that. (An example would be a single record on the card to control
 127 * both bitrate and frequency, the handler would read the old record,
 128 * modify it according to info->cmd and rewrite it).
 129 *
 130 * Functions prototype uses union iwreq_data
 131 * -----------------------------------------
 132 * Some would have preferred functions defined this way :
 133 *      static int mydriver_ioctl_setrate(struct net_device *dev, 
 134 *                                        long rate, int auto)
 135 * 1) The kernel code doesn't "validate" the content of iwreq_data, and
 136 * can't do it (different hardware may have different notion of what a
 137 * valid frequency is), so we don't pretend that we do it.
 138 * 2) The above form is not extendable. If I want to add a flag (for
 139 * example to distinguish setting max rate and basic rate), I would
 140 * break the prototype. Using iwreq_data is more flexible.
 141 * 3) Also, the above form is not generic (see above).
 142 * 4) I don't expect driver developper using the wrong field of the
 143 * union (Doh !), so static typechecking doesn't add much value.
 144 * 5) Lastly, you can skip the union by doing :
 145 *      static int mydriver_ioctl_setrate(struct net_device *dev,
 146 *                                        struct iw_request_info *info,
 147 *                                        struct iw_param *rrq,
 148 *                                        char *extra)
 149 * And then adding the handler in the array like this :
 150 *        (iw_handler) mydriver_ioctl_setrate,             // SIOCSIWRATE
 151 *
 152 * Using functions and not a registry
 153 * ----------------------------------
 154 * Another implementation option would have been for every instance to
 155 * define a registry (a struct containing all the Wireless Extensions)
 156 * and only have a function to commit the registry to the hardware.
 157 * 1) This approach can be emulated by the current code, but not
 158 * vice versa.
 159 * 2) Some drivers don't keep any configuration in the driver, for them
 160 * adding such a registry would be a significant bloat.
 161 * 3) The code to translate from Wireless Extension to native format is
 162 * needed anyway, so it would not reduce significantely the amount of code.
 163 * 4) The current approach only selectively translate Wireless Extensions
 164 * to native format and only selectively set, whereas the registry approach
 165 * would require to translate all WE and set all parameters for any single
 166 * change.
 167 * 5) For many Wireless Extensions, the GET operation return the current
 168 * dynamic value, not the value that was set.
 169 *
 170 * This header is <net/iw_handler.h>
 171 * ---------------------------------
 172 * 1) This header is kernel space only and should not be exported to
 173 * user space. Headers in "include/linux/" are exported, headersver writer may put their handler in

  75  76 *ser-space issues
  77  78 *sclean, emuveloppel s---------
  79  80  81 * us* change.
  82 173  84r hay.mment"> * andchecking doesolvarray lgisbleab( *scent"> * (handlers),
  85 * Cdallave a ike this :
  86  87t the end.
  88 mo, t varres and savetrder ia memoryis kernhe arraydevic handler in the end.
  89 *fines a sookhandler ever, possmore flexible.
  90  91  92  93  94 * ---------------------------------
  95 * That's npropeass fwdrivers d*     ndle al hantyptrder ibinarropriately.
  96
  98/*********************INCLUDESMENTATION *****************************/
   9
 a hrefheade   9
  84 a hrefheade   9

  12
 103/*********************VERSOCUMENTATION *****************************/
 104/*
 105 *nt slot The new drivmment">/*
 106 * Ho defind thosemade arsment">unctio* bitratmment">/*
 107tthe rest...
 108 *vent"> he rest...
 109  11#define _IWVERSOCU id="L110" clas="sref">_IWVERSOCUL10"0000008*/

 112/*
 113 114  15  16 *ommings :
 117
 118 119 120
 121 122 *ommings :
 123="srEAD_IWTYPE_XXXriverap>="sPRIVWTYPE_XXXr bitratmment">/*
 124/*
 125/*
 126 *ommings :
  27 *spymndler itc          sspying iw&break the tmment">/*
 128/*
  29/*
 130 *ommings :
  31 safets---------
  32
 133/*
 134/*
  35 *
 136 *
  37 *mment"> *
 138
 139/*
 140/*
 141 *nt 7" clamacroylass="comment"-ruct.11>uncck/*
/*
 V7ment"8/*
 ------------
 *    - Pracroyl adkdling os kernel spac     snt"(20cclean,ons.
**/

/*********************VERSO CONSTANTION ****************************/

#define _Ir WIRELESSPY10" clas="sref">_Ir WIRELESSPY 9
#define _Ir WIRELESTHRSPY10" clas="sref">_Ir WIRELESTHRSPY 9

 d shouldo ato commiafei  n retur     e the/iw_ha2dll***/
#define 

#define _IREQUESTOMAX tCOMPAT10" clas="sref">_IREQUESTOMAX tCOMPAT0008*/0x0001
#define _ITYPE_XXXriveNULL10" clas="sref">_IWYPE_XXXriveNULL0008*/  84#define _ITYPE_XXXriveCHAR10" clas="sref">_IWYPE_XXXriveCHAR0008*/  84#define _ITYPE_XXXriveUINT10" clas="sref">_ITYPE_XXXriveUINT0008*/  84#define _ITYPE_XXXriveFREQ10" clas="sref">_ITYPE_XXXriveFREQ0008*/  84#define _ITYPE_XXXriveADDR10" clas="sref">_IWYPE_XXXriveADDR0008*/  84#define _ITYPE_XXXrivePOINT10" clas="sref">_ITYPE_XXXrivePOINT0008*/  84#define _ITYPE_XXXrivePARAM10" clas="sref">_ITYPE_XXXrivePARAM0008*/  84#define _ITYPE_XXXriveQUAL10" clas="sref">_IWYPE_XXXriveQUAL0008*/
 cool npropeaeruotmllaveooulqndledayPI ;im**/
#define _ILAG_NOMAX to NE10" clas="sref">_ILAG_NOMAX to NE0008*/#define _ILAG_NOMAX tDUMP10" clas="sref">_ILAG_NOMAX tDUMP0008*/#define _ILAG_NOMAX tEVENT10" clas="sref">_ILAG_NOMAX tEVENT0008*/#define _ILAG_NOMAX tRELTRICT10" clas="sref">_ILAG_NOMAX tRELTRICT0008*/0x0004
#define _ILAG_NOMAX to adr10" clas="sref">_ILAG_NOMAX to adr0008*/
#define _ILAG_NOMAX tWAIT10" clas="sref">_ILAG_NOMAX tWAIT0008*/
>/*********************VERSOCUXrivION ***************************m**/

/*
 Ale_API _ he handler ihnaccgura ha care functione thaller ey like a*/

/*
 es to worient.he hantyment"epcla Youote the/iw_ha2dle*/
 Mostsw_ha2dlsou canafivelign morw(That'ver, pose*/
  t vatcmdatng fielmllavecosame haelify, yoI want tn use the same handl*/
 t foe multipto coeamst...
 . This stublis arso myy m hard try iurstan. e.u cat add neg fiesle he..
 * withou* bredding ths prototypt of iw_handdlt...
**/

  84  8a>



/*
 "ment">rhn geha functioh_ha2UsinamW Wireless Extensiod shoulller/*
 y lik(* botspyia and s,ura ha cara anpriv rat...
)(s stuble 
)0n>

/*
 * is * define all the handlee thar thw drivme expo...


**/
10" clas="sref"icie handlnt">/*08*{n>



"> *    e 








"> *    e 

 , y*/


"> *   e 



 *dnt tn use hosndlg.. s**/
 * (*e )(s stuble 


/*
 Onet The nema   goalt The ned ne br  farraydero deci ent_Atay * wi/*
 * us* chan/s kernel spacmounlfromvi...
 Folee thde,ypooulquirion gs :
      olifyiciwrtepiguer br   oleThatthehe ne def q_data
      olenerii9;k thchanl The newworie tcop---
--
 F fopriv ra oryissde,ype uie the samruatscces t Yobyyicprivrin --
 s define     stublicioriv_arg ...
..
 F fora ha caroryissdee hnger; ar hay.md * changrin o,ypooulqui..
 e uie thettubpeaerbelow. Aubpaefind thoss stublis arso mohe..
 efficievaa buoee that'sd nhus* tnlflt...
**/

/*
 D  cribsshn gehra ha caroryisaller ey li...
**/

  84  84<  84<  84<  84<  80>  84<**/


 L rar. s**/

O--------------------- ENHANCED SPY SUPPORTO--------------------- s**/
/*
 Iveooulsrther anclud thoss stublinyitsopriv ra anrltais kerof the

/*
 addleleeosspieara anquabilitt for tme*/
 **/

O---uck ha carer itc      --- s**/

_IMAXSSPY79
_IMAXSSPY79
O---uEnhstandler itc      (mcroyurs**/
OLowor lelhoouls**/
_IMAXSSPY79


O--------------------- DEVICE r WIRELE DATAO--------------------- s**/
/*
re all the_API _ hwworia sookhanto att_devie;iinstan e th/*
rman> *dn yyl thc moroftW Wireless Extensi   for thuct.11>laydle*/
 e thaalw drivmys frethe
      chase tmcbetweenmy instans.he
 . This stubpea*d shoulbie;iitiabit Yobef morregisrivdding tht_devi...
 wwori(i."> vabidcces m haas   stubln net_devieexishnt" samloceddinruatst...
**/
OForw carden craoptios**/


OD drivmenhstandler itc      s**/




/*********************VERSO PROTOXrivION ****************************/
/*
 F functis anrlt The neW Wireless Extensi  (s define   e/nec mo/e_API _ .ct...




OH_hand /procde/nee_API _ ,etduaulq   e/nec ludt_d.c"***/







)0n>

OWe maylooulqeha functio    end n ttreamt Thmcroysaro * us* chang*/
 Momoronne thal rar... s**/




)0n>



)0n>



)0n>



)0n>


)0n>

>/*********************V INLINE FUNTATIION *************************/
/*

**/
































/*
 Wrapp   uotadara eW Wirelesscroylro n ttreamt Thmcroysg*/

















------------------------------------------------------------------>**/
/*
 ttreamt Thmcroysg*/

)n>











, e 





/*
 Wrapp   uotadara vabuelro n W Wirelesscroylin n ttreamt Thmcroysg*/
**/





**/





**/






**/



t voriginal LXR softwamor yyl th> LXR ="counili79 lxr.="lux.no kiha2y hostulq yy>