rtllib.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341
  1. /*
  2. * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11
  3. * remains copyright by the original authors
  4. *
  5. * Portions of the merged code are based on Host AP (software wireless
  6. * LAN access point) driver for Intersil Prism2/2.5/3.
  7. *
  8. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  9. * <jkmaline@cc.hut.fi>
  10. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  11. *
  12. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  13. * <jketreno@linux.intel.com>
  14. * Copyright (c) 2004, Intel Corporation
  15. *
  16. * Modified for Realtek's wi-fi cards by Andrea Merello
  17. * <andrea.merello@gmail.com>
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License version 2 as
  21. * published by the Free Software Foundation. See README and COPYING for
  22. * more details.
  23. */
  24. #ifndef RTLLIB_H
  25. #define RTLLIB_H
  26. #include <linux/if_ether.h> /* ETH_ALEN */
  27. #include <linux/kernel.h> /* ARRAY_SIZE */
  28. #include <linux/module.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/jiffies.h>
  31. #include <linux/timer.h>
  32. #include <linux/sched.h>
  33. #include <linux/semaphore.h>
  34. #include <linux/delay.h>
  35. #include <linux/wireless.h>
  36. #include "rtllib_debug.h"
  37. #include "rtl819x_HT.h"
  38. #include "rtl819x_BA.h"
  39. #include "rtl819x_TS.h"
  40. #include <linux/netdevice.h>
  41. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  42. #include <net/lib80211.h>
  43. #define MAX_PRECMD_CNT 16
  44. #define MAX_RFDEPENDCMD_CNT 16
  45. #define MAX_POSTCMD_CNT 16
  46. #ifndef WIRELESS_SPY
  47. #define WIRELESS_SPY
  48. #endif
  49. #include <net/iw_handler.h>
  50. #ifndef IW_MODE_MONITOR
  51. #define IW_MODE_MONITOR 6
  52. #endif
  53. #ifndef IWEVCUSTOM
  54. #define IWEVCUSTOM 0x8c02
  55. #endif
  56. #ifndef IW_CUSTOM_MAX
  57. /* Max number of char in custom event - use multiple of them if needed */
  58. #define IW_CUSTOM_MAX 256 /* In bytes */
  59. #endif
  60. #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
  61. #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
  62. #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
  63. #define queue_work_rsl(x, y) queue_work(x, y)
  64. #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
  65. #define container_of_work_rsl(x, y, z) container_of(x, y, z)
  66. #define container_of_dwork_rsl(x, y, z) \
  67. container_of(container_of(x, struct delayed_work, work), y, z)
  68. #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
  69. iwe_stream_add_event(info, start, stop, iwe, len)
  70. #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
  71. iwe_stream_add_point(info, start, stop, iwe, p)
  72. #define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
  73. #define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
  74. static inline void *netdev_priv_rsl(struct net_device *dev)
  75. {
  76. return netdev_priv(dev);
  77. }
  78. #define KEY_TYPE_NA 0x0
  79. #define KEY_TYPE_WEP40 0x1
  80. #define KEY_TYPE_TKIP 0x2
  81. #define KEY_TYPE_CCMP 0x4
  82. #define KEY_TYPE_WEP104 0x5
  83. /* added for rtl819x tx procedure */
  84. #define MAX_QUEUE_SIZE 0x10
  85. #define BK_QUEUE 0
  86. #define BE_QUEUE 1
  87. #define VI_QUEUE 2
  88. #define VO_QUEUE 3
  89. #define HCCA_QUEUE 4
  90. #define TXCMD_QUEUE 5
  91. #define MGNT_QUEUE 6
  92. #define HIGH_QUEUE 7
  93. #define BEACON_QUEUE 8
  94. #define LOW_QUEUE BE_QUEUE
  95. #define NORMAL_QUEUE MGNT_QUEUE
  96. #ifndef IW_MODE_MESH
  97. #define IW_MODE_MESH 7
  98. #endif
  99. #define AMSDU_SUBHEADER_LEN 14
  100. #define SWRF_TIMEOUT 50
  101. #define IE_CISCO_FLAG_POSITION 0x08
  102. #define SUPPORT_CKIP_MIC 0x08
  103. #define SUPPORT_CKIP_PK 0x10
  104. #define RT_RF_OFF_LEVL_ASPM BIT0
  105. #define RT_RF_OFF_LEVL_CLK_REQ BIT1
  106. #define RT_RF_OFF_LEVL_PCI_D3 BIT2
  107. #define RT_RF_OFF_LEVL_HALT_NIC BIT3
  108. #define RT_RF_OFF_LEVL_FREE_FW BIT4
  109. #define RT_RF_OFF_LEVL_FW_32K BIT5
  110. #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
  111. #define RT_RF_LPS_DISALBE_2R BIT30
  112. #define RT_RF_LPS_LEVEL_ASPM BIT31
  113. #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \
  114. ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
  115. #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \
  116. (pPSC->CurPsLevel &= (~(_PS_FLAG)))
  117. #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
  118. /* defined for skb cb field */
  119. /* At most 28 byte */
  120. struct cb_desc {
  121. /* Tx Desc Related flags (8-9) */
  122. u8 bLastIniPkt:1;
  123. u8 bCmdOrInit:1;
  124. u8 bFirstSeg:1;
  125. u8 bLastSeg:1;
  126. u8 bEncrypt:1;
  127. u8 bTxDisableRateFallBack:1;
  128. u8 bTxUseDriverAssingedRate:1;
  129. u8 bHwSec:1;
  130. u8 nStuckCount;
  131. /* Tx Firmware Related flags (10-11)*/
  132. u8 bCTSEnable:1;
  133. u8 bRTSEnable:1;
  134. u8 bUseShortGI:1;
  135. u8 bUseShortPreamble:1;
  136. u8 bTxEnableFwCalcDur:1;
  137. u8 bAMPDUEnable:1;
  138. u8 bRTSSTBC:1;
  139. u8 RTSSC:1;
  140. u8 bRTSBW:1;
  141. u8 bPacketBW:1;
  142. u8 bRTSUseShortPreamble:1;
  143. u8 bRTSUseShortGI:1;
  144. u8 bMulticast:1;
  145. u8 bBroadcast:1;
  146. u8 drv_agg_enable:1;
  147. u8 reserved2:1;
  148. /* Tx Desc related element(12-19) */
  149. u8 rata_index;
  150. u8 queue_index;
  151. u16 txbuf_size;
  152. u8 RATRIndex;
  153. u8 bAMSDU:1;
  154. u8 bFromAggrQ:1;
  155. u8 reserved6:6;
  156. u8 macId;
  157. u8 priority;
  158. /* Tx firmware related element(20-27) */
  159. u8 data_rate;
  160. u8 rts_rate;
  161. u8 ampdu_factor;
  162. u8 ampdu_density;
  163. u8 DrvAggrNum;
  164. u8 bdhcp;
  165. u16 pkt_size;
  166. u8 bIsSpecialDataFrame;
  167. u8 bBTTxPacket;
  168. u8 bIsBTProbRsp;
  169. };
  170. enum sw_chnl_cmd_id {
  171. CmdID_End,
  172. CmdID_SetTxPowerLevel,
  173. CmdID_BBRegWrite10,
  174. CmdID_WritePortUlong,
  175. CmdID_WritePortUshort,
  176. CmdID_WritePortUchar,
  177. CmdID_RF_WriteReg,
  178. };
  179. struct sw_chnl_cmd {
  180. enum sw_chnl_cmd_id CmdID;
  181. u32 Para1;
  182. u32 Para2;
  183. u32 msDelay;
  184. } __packed;
  185. /*--------------------------Define -------------------------------------------*/
  186. #define MGN_1M 0x02
  187. #define MGN_2M 0x04
  188. #define MGN_5_5M 0x0b
  189. #define MGN_11M 0x16
  190. #define MGN_6M 0x0c
  191. #define MGN_9M 0x12
  192. #define MGN_12M 0x18
  193. #define MGN_18M 0x24
  194. #define MGN_24M 0x30
  195. #define MGN_36M 0x48
  196. #define MGN_48M 0x60
  197. #define MGN_54M 0x6c
  198. #define MGN_MCS0 0x80
  199. #define MGN_MCS1 0x81
  200. #define MGN_MCS2 0x82
  201. #define MGN_MCS3 0x83
  202. #define MGN_MCS4 0x84
  203. #define MGN_MCS5 0x85
  204. #define MGN_MCS6 0x86
  205. #define MGN_MCS7 0x87
  206. #define MGN_MCS8 0x88
  207. #define MGN_MCS9 0x89
  208. #define MGN_MCS10 0x8a
  209. #define MGN_MCS11 0x8b
  210. #define MGN_MCS12 0x8c
  211. #define MGN_MCS13 0x8d
  212. #define MGN_MCS14 0x8e
  213. #define MGN_MCS15 0x8f
  214. #define MGN_MCS0_SG 0x90
  215. #define MGN_MCS1_SG 0x91
  216. #define MGN_MCS2_SG 0x92
  217. #define MGN_MCS3_SG 0x93
  218. #define MGN_MCS4_SG 0x94
  219. #define MGN_MCS5_SG 0x95
  220. #define MGN_MCS6_SG 0x96
  221. #define MGN_MCS7_SG 0x97
  222. #define MGN_MCS8_SG 0x98
  223. #define MGN_MCS9_SG 0x99
  224. #define MGN_MCS10_SG 0x9a
  225. #define MGN_MCS11_SG 0x9b
  226. #define MGN_MCS12_SG 0x9c
  227. #define MGN_MCS13_SG 0x9d
  228. #define MGN_MCS14_SG 0x9e
  229. #define MGN_MCS15_SG 0x9f
  230. enum hw_variables {
  231. HW_VAR_ETHER_ADDR,
  232. HW_VAR_MULTICAST_REG,
  233. HW_VAR_BASIC_RATE,
  234. HW_VAR_BSSID,
  235. HW_VAR_MEDIA_STATUS,
  236. HW_VAR_SECURITY_CONF,
  237. HW_VAR_BEACON_INTERVAL,
  238. HW_VAR_ATIM_WINDOW,
  239. HW_VAR_LISTEN_INTERVAL,
  240. HW_VAR_CS_COUNTER,
  241. HW_VAR_DEFAULTKEY0,
  242. HW_VAR_DEFAULTKEY1,
  243. HW_VAR_DEFAULTKEY2,
  244. HW_VAR_DEFAULTKEY3,
  245. HW_VAR_SIFS,
  246. HW_VAR_DIFS,
  247. HW_VAR_EIFS,
  248. HW_VAR_SLOT_TIME,
  249. HW_VAR_ACK_PREAMBLE,
  250. HW_VAR_CW_CONFIG,
  251. HW_VAR_CW_VALUES,
  252. HW_VAR_RATE_FALLBACK_CONTROL,
  253. HW_VAR_CONTENTION_WINDOW,
  254. HW_VAR_RETRY_COUNT,
  255. HW_VAR_TR_SWITCH,
  256. HW_VAR_COMMAND,
  257. HW_VAR_WPA_CONFIG,
  258. HW_VAR_AMPDU_MIN_SPACE,
  259. HW_VAR_SHORTGI_DENSITY,
  260. HW_VAR_AMPDU_FACTOR,
  261. HW_VAR_MCS_RATE_AVAILABLE,
  262. HW_VAR_AC_PARAM,
  263. HW_VAR_ACM_CTRL,
  264. HW_VAR_DIS_Req_Qsize,
  265. HW_VAR_CCX_CHNL_LOAD,
  266. HW_VAR_CCX_NOISE_HISTOGRAM,
  267. HW_VAR_CCX_CLM_NHM,
  268. HW_VAR_TxOPLimit,
  269. HW_VAR_TURBO_MODE,
  270. HW_VAR_RF_STATE,
  271. HW_VAR_RF_OFF_BY_HW,
  272. HW_VAR_BUS_SPEED,
  273. HW_VAR_SET_DEV_POWER,
  274. HW_VAR_RCR,
  275. HW_VAR_RATR_0,
  276. HW_VAR_RRSR,
  277. HW_VAR_CPU_RST,
  278. HW_VAR_CECHK_BSSID,
  279. HW_VAR_LBK_MODE,
  280. HW_VAR_AES_11N_FIX,
  281. HW_VAR_USB_RX_AGGR,
  282. HW_VAR_USER_CONTROL_TURBO_MODE,
  283. HW_VAR_RETRY_LIMIT,
  284. HW_VAR_INIT_TX_RATE,
  285. HW_VAR_TX_RATE_REG,
  286. HW_VAR_EFUSE_USAGE,
  287. HW_VAR_EFUSE_BYTES,
  288. HW_VAR_AUTOLOAD_STATUS,
  289. HW_VAR_RF_2R_DISABLE,
  290. HW_VAR_SET_RPWM,
  291. HW_VAR_H2C_FW_PWRMODE,
  292. HW_VAR_H2C_FW_JOINBSSRPT,
  293. HW_VAR_1X1_RECV_COMBINE,
  294. HW_VAR_STOP_SEND_BEACON,
  295. HW_VAR_TSF_TIMER,
  296. HW_VAR_IO_CMD,
  297. HW_VAR_RF_RECOVERY,
  298. HW_VAR_H2C_FW_UPDATE_GTK,
  299. HW_VAR_WF_MASK,
  300. HW_VAR_WF_CRC,
  301. HW_VAR_WF_IS_MAC_ADDR,
  302. HW_VAR_H2C_FW_OFFLOAD,
  303. HW_VAR_RESET_WFCRC,
  304. HW_VAR_HANDLE_FW_C2H,
  305. HW_VAR_DL_FW_RSVD_PAGE,
  306. HW_VAR_AID,
  307. HW_VAR_HW_SEQ_ENABLE,
  308. HW_VAR_CORRECT_TSF,
  309. HW_VAR_BCN_VALID,
  310. HW_VAR_FWLPS_RF_ON,
  311. HW_VAR_DUAL_TSF_RST,
  312. HW_VAR_SWITCH_EPHY_WoWLAN,
  313. HW_VAR_INT_MIGRATION,
  314. HW_VAR_INT_AC,
  315. HW_VAR_RF_TIMING,
  316. };
  317. enum rt_op_mode {
  318. RT_OP_MODE_AP,
  319. RT_OP_MODE_INFRASTRUCTURE,
  320. RT_OP_MODE_IBSS,
  321. RT_OP_MODE_NO_LINK,
  322. };
  323. #define aSifsTime \
  324. (((priv->rtllib->current_network.mode == IEEE_A) \
  325. || (priv->rtllib->current_network.mode == IEEE_N_24G) \
  326. || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
  327. #define MGMT_QUEUE_NUM 5
  328. #define IEEE_CMD_SET_WPA_PARAM 1
  329. #define IEEE_CMD_SET_WPA_IE 2
  330. #define IEEE_CMD_SET_ENCRYPTION 3
  331. #define IEEE_CMD_MLME 4
  332. #define IEEE_PARAM_WPA_ENABLED 1
  333. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  334. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  335. #define IEEE_PARAM_PRIVACY_INVOKED 4
  336. #define IEEE_PARAM_AUTH_ALGS 5
  337. #define IEEE_PARAM_IEEE_802_1X 6
  338. #define IEEE_PARAM_WPAX_SELECT 7
  339. #define IEEE_MLME_STA_DEAUTH 1
  340. #define IEEE_MLME_STA_DISASSOC 2
  341. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  342. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  343. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  344. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  345. #define IEEE_CRYPT_ALG_NAME_LEN 16
  346. #define MAX_IE_LEN 0xff
  347. struct ieee_param {
  348. u32 cmd;
  349. u8 sta_addr[ETH_ALEN];
  350. union {
  351. struct {
  352. u8 name;
  353. u32 value;
  354. } wpa_param;
  355. struct {
  356. u32 len;
  357. u8 reserved[32];
  358. u8 data[0];
  359. } wpa_ie;
  360. struct {
  361. int command;
  362. int reason_code;
  363. } mlme;
  364. struct {
  365. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  366. u8 set_tx;
  367. u32 err;
  368. u8 idx;
  369. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  370. u16 key_len;
  371. u8 key[0];
  372. } crypt;
  373. } u;
  374. };
  375. #define msleep_interruptible_rsl msleep_interruptible
  376. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  377. * 6.2.1.1.2.
  378. *
  379. * The figure in section 7.1.2 suggests a body size of up to 2312
  380. * bytes is allowed, which is a bit confusing, I suspect this
  381. * represents the 2304 bytes of real data, plus a possible 8 bytes of
  382. * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
  383. */
  384. #define RTLLIB_1ADDR_LEN 10
  385. #define RTLLIB_2ADDR_LEN 16
  386. #define RTLLIB_3ADDR_LEN 24
  387. #define RTLLIB_4ADDR_LEN 30
  388. #define RTLLIB_FCS_LEN 4
  389. #define RTLLIB_SKBBUFFER_SIZE 2500
  390. #define MIN_FRAG_THRESHOLD 256U
  391. #define MAX_FRAG_THRESHOLD 2346U
  392. /* Frame control field constants */
  393. #define RTLLIB_FCTL_FTYPE 0x000c
  394. #define RTLLIB_FCTL_STYPE 0x00f0
  395. #define RTLLIB_FCTL_FRAMETYPE 0x00fc
  396. #define RTLLIB_FCTL_TODS 0x0100
  397. #define RTLLIB_FCTL_FROMDS 0x0200
  398. #define RTLLIB_FCTL_DSTODS 0x0300
  399. #define RTLLIB_FCTL_MOREFRAGS 0x0400
  400. #define RTLLIB_FCTL_RETRY 0x0800
  401. #define RTLLIB_FCTL_PM 0x1000
  402. #define RTLLIB_FCTL_MOREDATA 0x2000
  403. #define RTLLIB_FCTL_WEP 0x4000
  404. #define RTLLIB_FCTL_ORDER 0x8000
  405. #define RTLLIB_FTYPE_MGMT 0x0000
  406. #define RTLLIB_FTYPE_CTL 0x0004
  407. #define RTLLIB_FTYPE_DATA 0x0008
  408. /* management */
  409. #define RTLLIB_STYPE_ASSOC_REQ 0x0000
  410. #define RTLLIB_STYPE_ASSOC_RESP 0x0010
  411. #define RTLLIB_STYPE_REASSOC_REQ 0x0020
  412. #define RTLLIB_STYPE_REASSOC_RESP 0x0030
  413. #define RTLLIB_STYPE_PROBE_REQ 0x0040
  414. #define RTLLIB_STYPE_PROBE_RESP 0x0050
  415. #define RTLLIB_STYPE_BEACON 0x0080
  416. #define RTLLIB_STYPE_ATIM 0x0090
  417. #define RTLLIB_STYPE_DISASSOC 0x00A0
  418. #define RTLLIB_STYPE_AUTH 0x00B0
  419. #define RTLLIB_STYPE_DEAUTH 0x00C0
  420. #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
  421. /* control */
  422. #define RTLLIB_STYPE_PSPOLL 0x00A0
  423. #define RTLLIB_STYPE_RTS 0x00B0
  424. #define RTLLIB_STYPE_CTS 0x00C0
  425. #define RTLLIB_STYPE_ACK 0x00D0
  426. /* data */
  427. #define RTLLIB_STYPE_DATA 0x0000
  428. #define RTLLIB_STYPE_DATA_CFACK 0x0010
  429. #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
  430. #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
  431. #define RTLLIB_STYPE_NULLFUNC 0x0040
  432. #define RTLLIB_STYPE_QOS_DATA 0x0080
  433. #define RTLLIB_STYPE_QOS_NULL 0x00C0
  434. #define RTLLIB_SCTL_FRAG 0x000F
  435. #define RTLLIB_SCTL_SEQ 0xFFF0
  436. /* QOS control */
  437. #define RTLLIB_QCTL_TID 0x000F
  438. #define FC_QOS_BIT BIT7
  439. #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
  440. #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
  441. #define IsQoSDataFrame(pframe) \
  442. ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
  443. (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
  444. #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
  445. #define SN_LESS(a, b) (((a-b)&0x800) != 0)
  446. #define SN_EQUAL(a, b) (a == b)
  447. #define MAX_DEV_ADDR_SIZE 8
  448. enum act_category {
  449. ACT_CAT_QOS = 1,
  450. ACT_CAT_DLS = 2,
  451. ACT_CAT_BA = 3,
  452. ACT_CAT_HT = 7,
  453. ACT_CAT_WMM = 17,
  454. };
  455. enum ba_action {
  456. ACT_ADDBAREQ = 0,
  457. ACT_ADDBARSP = 1,
  458. ACT_DELBA = 2,
  459. };
  460. enum init_gain_op_type {
  461. IG_Backup = 0,
  462. IG_Restore,
  463. IG_Max
  464. };
  465. enum led_ctl_mode {
  466. LED_CTL_POWER_ON = 1,
  467. LED_CTL_LINK = 2,
  468. LED_CTL_NO_LINK = 3,
  469. LED_CTL_TX = 4,
  470. LED_CTL_RX = 5,
  471. LED_CTL_SITE_SURVEY = 6,
  472. LED_CTL_POWER_OFF = 7,
  473. LED_CTL_START_TO_LINK = 8,
  474. };
  475. enum rt_rf_type_def {
  476. RF_1T2R = 0,
  477. RF_2T4R,
  478. };
  479. enum wireless_mode {
  480. WIRELESS_MODE_UNKNOWN = 0x00,
  481. WIRELESS_MODE_A = 0x01,
  482. WIRELESS_MODE_B = 0x02,
  483. WIRELESS_MODE_G = 0x04,
  484. WIRELESS_MODE_AUTO = 0x08,
  485. WIRELESS_MODE_N_24G = 0x10,
  486. WIRELESS_MODE_N_5G = 0x20
  487. };
  488. #ifndef ETH_P_PAE
  489. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  490. #define ETH_P_IP 0x0800 /* Internet Protocol packet */
  491. #define ETH_P_ARP 0x0806 /* Address Resolution packet */
  492. #endif /* ETH_P_PAE */
  493. #ifndef ETH_P_80211_RAW
  494. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  495. #endif
  496. /* IEEE 802.11 defines */
  497. #define P80211_OUI_LEN 3
  498. struct rtllib_snap_hdr {
  499. u8 dsap; /* always 0xAA */
  500. u8 ssap; /* always 0xAA */
  501. u8 ctrl; /* always 0x03 */
  502. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  503. } __packed;
  504. enum _REG_PREAMBLE_MODE {
  505. PREAMBLE_LONG = 1,
  506. PREAMBLE_AUTO = 2,
  507. PREAMBLE_SHORT = 3,
  508. };
  509. #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
  510. #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
  511. #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
  512. #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
  513. #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
  514. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
  515. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
  516. /* Authentication algorithms */
  517. #define WLAN_AUTH_OPEN 0
  518. #define WLAN_AUTH_SHARED_KEY 1
  519. #define WLAN_AUTH_LEAP 128
  520. #define WLAN_CAPABILITY_ESS (1<<0)
  521. #define WLAN_CAPABILITY_IBSS (1<<1)
  522. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  523. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  524. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  525. #define RTLLIB_STATMASK_SIGNAL (1<<0)
  526. #define RTLLIB_STATMASK_RSSI (1<<1)
  527. #define RTLLIB_STATMASK_NOISE (1<<2)
  528. #define RTLLIB_STATMASK_WEMASK 0x7
  529. #define RTLLIB_CCK_MODULATION (1<<0)
  530. #define RTLLIB_OFDM_MODULATION (1<<1)
  531. #define RTLLIB_24GHZ_BAND (1<<0)
  532. #define RTLLIB_52GHZ_BAND (1<<1)
  533. #define RTLLIB_CCK_RATE_LEN 4
  534. #define RTLLIB_CCK_RATE_1MB 0x02
  535. #define RTLLIB_CCK_RATE_2MB 0x04
  536. #define RTLLIB_CCK_RATE_5MB 0x0B
  537. #define RTLLIB_CCK_RATE_11MB 0x16
  538. #define RTLLIB_OFDM_RATE_LEN 8
  539. #define RTLLIB_OFDM_RATE_6MB 0x0C
  540. #define RTLLIB_OFDM_RATE_9MB 0x12
  541. #define RTLLIB_OFDM_RATE_12MB 0x18
  542. #define RTLLIB_OFDM_RATE_18MB 0x24
  543. #define RTLLIB_OFDM_RATE_24MB 0x30
  544. #define RTLLIB_OFDM_RATE_36MB 0x48
  545. #define RTLLIB_OFDM_RATE_48MB 0x60
  546. #define RTLLIB_OFDM_RATE_54MB 0x6C
  547. #define RTLLIB_BASIC_RATE_MASK 0x80
  548. /* this is stolen and modified from the madwifi driver*/
  549. #define RTLLIB_FC0_TYPE_MASK 0x0c
  550. #define RTLLIB_FC0_TYPE_DATA 0x08
  551. #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
  552. #define RTLLIB_FC0_SUBTYPE_QOS 0x80
  553. #define RTLLIB_QOS_HAS_SEQ(fc) \
  554. (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
  555. (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
  556. /* this is stolen from ipw2200 driver */
  557. #define IEEE_IBSS_MAC_HASH_SIZE 31
  558. struct ieee_ibss_seq {
  559. u8 mac[ETH_ALEN];
  560. u16 seq_num[17];
  561. u16 frag_num[17];
  562. unsigned long packet_time[17];
  563. struct list_head list;
  564. };
  565. /* NOTE: This data is for statistical purposes; not all hardware provides this
  566. * information for frames received. Not setting these will not cause
  567. * any adverse affects. */
  568. struct rtllib_rx_stats {
  569. u64 mac_time;
  570. s8 rssi;
  571. u8 signal;
  572. u8 noise;
  573. u16 rate; /* in 100 kbps */
  574. u8 received_channel;
  575. u8 control;
  576. u8 mask;
  577. u8 freq;
  578. u16 len;
  579. u64 tsf;
  580. u32 beacon_time;
  581. u8 nic_type;
  582. u16 Length;
  583. u8 SignalQuality;
  584. s32 RecvSignalPower;
  585. s8 RxPower;
  586. u8 SignalStrength;
  587. u16 bHwError:1;
  588. u16 bCRC:1;
  589. u16 bICV:1;
  590. u16 bShortPreamble:1;
  591. u16 Antenna:1;
  592. u16 Decrypted:1;
  593. u16 Wakeup:1;
  594. u16 Reserved0:1;
  595. u8 AGC;
  596. u32 TimeStampLow;
  597. u32 TimeStampHigh;
  598. bool bShift;
  599. bool bIsQosData;
  600. u8 RxDrvInfoSize;
  601. u8 RxBufShift;
  602. bool bIsAMPDU;
  603. bool bFirstMPDU;
  604. bool bContainHTC;
  605. bool RxIs40MHzPacket;
  606. u32 RxPWDBAll;
  607. u8 RxMIMOSignalStrength[4];
  608. s8 RxMIMOSignalQuality[2];
  609. bool bPacketMatchBSSID;
  610. bool bIsCCK;
  611. bool bPacketToSelf;
  612. u16 packetlength;
  613. u16 fraglength;
  614. u16 fragoffset;
  615. u16 ntotalfrag;
  616. bool bPacketBeacon;
  617. bool bToSelfBA;
  618. u16 Seq_Num;
  619. };
  620. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  621. * three fragmented frames. This define can be increased to support more
  622. * concurrent frames, but it should be noted that each entry can consume about
  623. * 2 kB of RAM and increasing cache size will slow down frame reassembly.
  624. */
  625. #define RTLLIB_FRAG_CACHE_LEN 4
  626. struct rtllib_frag_entry {
  627. unsigned long first_frag_time;
  628. unsigned int seq;
  629. unsigned int last_frag;
  630. struct sk_buff *skb;
  631. u8 src_addr[ETH_ALEN];
  632. u8 dst_addr[ETH_ALEN];
  633. };
  634. struct rtllib_stats {
  635. unsigned int tx_unicast_frames;
  636. unsigned int tx_multicast_frames;
  637. unsigned int tx_fragments;
  638. unsigned int tx_unicast_octets;
  639. unsigned int tx_multicast_octets;
  640. unsigned int tx_deferred_transmissions;
  641. unsigned int tx_single_retry_frames;
  642. unsigned int tx_multiple_retry_frames;
  643. unsigned int tx_retry_limit_exceeded;
  644. unsigned int tx_discards;
  645. unsigned int rx_unicast_frames;
  646. unsigned int rx_multicast_frames;
  647. unsigned int rx_fragments;
  648. unsigned int rx_unicast_octets;
  649. unsigned int rx_multicast_octets;
  650. unsigned int rx_fcs_errors;
  651. unsigned int rx_discards_no_buffer;
  652. unsigned int tx_discards_wrong_sa;
  653. unsigned int rx_discards_undecryptable;
  654. unsigned int rx_message_in_msg_fragments;
  655. unsigned int rx_message_in_bad_msg_fragments;
  656. };
  657. struct rtllib_device;
  658. #define SEC_KEY_1 (1<<0)
  659. #define SEC_KEY_2 (1<<1)
  660. #define SEC_KEY_3 (1<<2)
  661. #define SEC_KEY_4 (1<<3)
  662. #define SEC_ACTIVE_KEY (1<<4)
  663. #define SEC_AUTH_MODE (1<<5)
  664. #define SEC_UNICAST_GROUP (1<<6)
  665. #define SEC_LEVEL (1<<7)
  666. #define SEC_ENABLED (1<<8)
  667. #define SEC_ENCRYPT (1<<9)
  668. #define SEC_LEVEL_0 0 /* None */
  669. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  670. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  671. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  672. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  673. #define SEC_ALG_NONE 0
  674. #define SEC_ALG_WEP 1
  675. #define SEC_ALG_TKIP 2
  676. #define SEC_ALG_CCMP 4
  677. #define WEP_KEY_LEN 13
  678. #define SCM_KEY_LEN 32
  679. #define SCM_TEMPORAL_KEY_LENGTH 16
  680. struct rtllib_security {
  681. u16 active_key:2,
  682. enabled:1,
  683. auth_mode:2,
  684. auth_algo:4,
  685. unicast_uses_group:1,
  686. encrypt:1;
  687. u8 key_sizes[NUM_WEP_KEYS];
  688. u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
  689. u8 level;
  690. u16 flags;
  691. } __packed;
  692. /* 802.11 data frame from AP
  693. * ,-------------------------------------------------------------------.
  694. * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  695. * |------|------|---------|---------|---------|------|---------|------|
  696. * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  697. * | | tion | (BSSID) | | | ence | data | |
  698. * `-------------------------------------------------------------------'
  699. * Total: 28-2340 bytes
  700. */
  701. /* Management Frame Information Element Types */
  702. enum rtllib_mfie {
  703. MFIE_TYPE_SSID = 0,
  704. MFIE_TYPE_RATES = 1,
  705. MFIE_TYPE_FH_SET = 2,
  706. MFIE_TYPE_DS_SET = 3,
  707. MFIE_TYPE_CF_SET = 4,
  708. MFIE_TYPE_TIM = 5,
  709. MFIE_TYPE_IBSS_SET = 6,
  710. MFIE_TYPE_COUNTRY = 7,
  711. MFIE_TYPE_HOP_PARAMS = 8,
  712. MFIE_TYPE_HOP_TABLE = 9,
  713. MFIE_TYPE_REQUEST = 10,
  714. MFIE_TYPE_CHALLENGE = 16,
  715. MFIE_TYPE_POWER_CONSTRAINT = 32,
  716. MFIE_TYPE_POWER_CAPABILITY = 33,
  717. MFIE_TYPE_TPC_REQUEST = 34,
  718. MFIE_TYPE_TPC_REPORT = 35,
  719. MFIE_TYPE_SUPP_CHANNELS = 36,
  720. MFIE_TYPE_CSA = 37,
  721. MFIE_TYPE_MEASURE_REQUEST = 38,
  722. MFIE_TYPE_MEASURE_REPORT = 39,
  723. MFIE_TYPE_QUIET = 40,
  724. MFIE_TYPE_IBSS_DFS = 41,
  725. MFIE_TYPE_ERP = 42,
  726. MFIE_TYPE_HT_CAP = 45,
  727. MFIE_TYPE_RSN = 48,
  728. MFIE_TYPE_RATES_EX = 50,
  729. MFIE_TYPE_HT_INFO = 61,
  730. MFIE_TYPE_AIRONET = 133,
  731. MFIE_TYPE_GENERIC = 221,
  732. MFIE_TYPE_QOS_PARAMETER = 222,
  733. };
  734. /* Minimal header; can be used for passing 802.11 frames with sufficient
  735. * information to determine what type of underlying data type is actually
  736. * stored in the data.
  737. */
  738. struct rtllib_pspoll_hdr {
  739. __le16 frame_ctl;
  740. __le16 aid;
  741. u8 bssid[ETH_ALEN];
  742. u8 ta[ETH_ALEN];
  743. } __packed;
  744. struct rtllib_hdr {
  745. __le16 frame_ctl;
  746. __le16 duration_id;
  747. u8 payload[0];
  748. } __packed;
  749. struct rtllib_hdr_1addr {
  750. __le16 frame_ctl;
  751. __le16 duration_id;
  752. u8 addr1[ETH_ALEN];
  753. u8 payload[0];
  754. } __packed;
  755. struct rtllib_hdr_2addr {
  756. __le16 frame_ctl;
  757. __le16 duration_id;
  758. u8 addr1[ETH_ALEN];
  759. u8 addr2[ETH_ALEN];
  760. u8 payload[0];
  761. } __packed;
  762. struct rtllib_hdr_3addr {
  763. __le16 frame_ctl;
  764. __le16 duration_id;
  765. u8 addr1[ETH_ALEN];
  766. u8 addr2[ETH_ALEN];
  767. u8 addr3[ETH_ALEN];
  768. __le16 seq_ctl;
  769. u8 payload[0];
  770. } __packed;
  771. struct rtllib_hdr_4addr {
  772. __le16 frame_ctl;
  773. __le16 duration_id;
  774. u8 addr1[ETH_ALEN];
  775. u8 addr2[ETH_ALEN];
  776. u8 addr3[ETH_ALEN];
  777. __le16 seq_ctl;
  778. u8 addr4[ETH_ALEN];
  779. u8 payload[0];
  780. } __packed;
  781. struct rtllib_hdr_3addrqos {
  782. __le16 frame_ctl;
  783. __le16 duration_id;
  784. u8 addr1[ETH_ALEN];
  785. u8 addr2[ETH_ALEN];
  786. u8 addr3[ETH_ALEN];
  787. __le16 seq_ctl;
  788. __le16 qos_ctl;
  789. u8 payload[0];
  790. } __packed;
  791. struct rtllib_hdr_4addrqos {
  792. __le16 frame_ctl;
  793. __le16 duration_id;
  794. u8 addr1[ETH_ALEN];
  795. u8 addr2[ETH_ALEN];
  796. u8 addr3[ETH_ALEN];
  797. __le16 seq_ctl;
  798. u8 addr4[ETH_ALEN];
  799. __le16 qos_ctl;
  800. u8 payload[0];
  801. } __packed;
  802. struct rtllib_info_element {
  803. u8 id;
  804. u8 len;
  805. u8 data[0];
  806. } __packed;
  807. struct rtllib_authentication {
  808. struct rtllib_hdr_3addr header;
  809. __le16 algorithm;
  810. __le16 transaction;
  811. __le16 status;
  812. /*challenge*/
  813. struct rtllib_info_element info_element[0];
  814. } __packed;
  815. struct rtllib_disauth {
  816. struct rtllib_hdr_3addr header;
  817. __le16 reason;
  818. } __packed;
  819. struct rtllib_disassoc {
  820. struct rtllib_hdr_3addr header;
  821. __le16 reason;
  822. } __packed;
  823. struct rtllib_probe_request {
  824. struct rtllib_hdr_3addr header;
  825. /* SSID, supported rates */
  826. struct rtllib_info_element info_element[0];
  827. } __packed;
  828. struct rtllib_probe_response {
  829. struct rtllib_hdr_3addr header;
  830. u32 time_stamp[2];
  831. __le16 beacon_interval;
  832. __le16 capability;
  833. /* SSID, supported rates, FH params, DS params,
  834. * CF params, IBSS params, TIM (if beacon), RSN
  835. */
  836. struct rtllib_info_element info_element[0];
  837. } __packed;
  838. /* Alias beacon for probe_response */
  839. #define rtllib_beacon rtllib_probe_response
  840. struct rtllib_assoc_request_frame {
  841. struct rtllib_hdr_3addr header;
  842. __le16 capability;
  843. __le16 listen_interval;
  844. /* SSID, supported rates, RSN */
  845. struct rtllib_info_element info_element[0];
  846. } __packed;
  847. struct rtllib_assoc_response_frame {
  848. struct rtllib_hdr_3addr header;
  849. __le16 capability;
  850. __le16 status;
  851. __le16 aid;
  852. struct rtllib_info_element info_element[0]; /* supported rates */
  853. } __packed;
  854. struct rtllib_txb {
  855. u8 nr_frags;
  856. u8 encrypted;
  857. u8 queue_index;
  858. u8 rts_included;
  859. u16 reserved;
  860. __le16 frag_size;
  861. __le16 payload_size;
  862. struct sk_buff *fragments[0];
  863. };
  864. #define MAX_SUBFRAME_COUNT 64
  865. struct rtllib_rxb {
  866. u8 nr_subframes;
  867. struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
  868. u8 dst[ETH_ALEN];
  869. u8 src[ETH_ALEN];
  870. } __packed;
  871. union frameqos {
  872. u16 shortdata;
  873. u8 chardata[2];
  874. struct {
  875. u16 tid:4;
  876. u16 eosp:1;
  877. u16 ack_policy:2;
  878. u16 reserved:1;
  879. u16 txop:8;
  880. } field;
  881. };
  882. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  883. * only use 8, and then use extended rates for the remaining supported
  884. * rates. Other APs, however, stick all of their supported rates on the
  885. * main rates information element...
  886. */
  887. #define MAX_RATES_LENGTH ((u8)12)
  888. #define MAX_RATES_EX_LENGTH ((u8)16)
  889. #define MAX_NETWORK_COUNT 96
  890. #define MAX_CHANNEL_NUMBER 161
  891. #define RTLLIB_SOFTMAC_SCAN_TIME 100
  892. #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  893. #define MAX_WPA_IE_LEN 64
  894. #define MAX_WZC_IE_LEN 256
  895. #define NETWORK_EMPTY_ESSID (1<<0)
  896. #define NETWORK_HAS_OFDM (1<<1)
  897. #define NETWORK_HAS_CCK (1<<2)
  898. /* QoS structure */
  899. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  900. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  901. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  902. NETWORK_HAS_QOS_INFORMATION)
  903. /* 802.11h */
  904. #define NETWORK_HAS_ERP_VALUE (1<<10)
  905. #define QOS_QUEUE_NUM 4
  906. #define QOS_OUI_LEN 3
  907. #define QOS_OUI_TYPE 2
  908. #define QOS_ELEMENT_ID 221
  909. #define QOS_OUI_INFO_SUB_TYPE 0
  910. #define QOS_OUI_PARAM_SUB_TYPE 1
  911. #define QOS_VERSION_1 1
  912. struct rtllib_qos_information_element {
  913. u8 elementID;
  914. u8 length;
  915. u8 qui[QOS_OUI_LEN];
  916. u8 qui_type;
  917. u8 qui_subtype;
  918. u8 version;
  919. u8 ac_info;
  920. } __packed;
  921. struct rtllib_qos_ac_parameter {
  922. u8 aci_aifsn;
  923. u8 ecw_min_max;
  924. __le16 tx_op_limit;
  925. } __packed;
  926. struct rtllib_qos_parameter_info {
  927. struct rtllib_qos_information_element info_element;
  928. u8 reserved;
  929. struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  930. } __packed;
  931. struct rtllib_qos_parameters {
  932. __le16 cw_min[QOS_QUEUE_NUM];
  933. __le16 cw_max[QOS_QUEUE_NUM];
  934. u8 aifs[QOS_QUEUE_NUM];
  935. u8 flag[QOS_QUEUE_NUM];
  936. __le16 tx_op_limit[QOS_QUEUE_NUM];
  937. } __packed;
  938. struct rtllib_qos_data {
  939. struct rtllib_qos_parameters parameters;
  940. unsigned int wmm_acm;
  941. int active;
  942. int supported;
  943. u8 param_count;
  944. u8 old_param_count;
  945. };
  946. struct rtllib_tim_parameters {
  947. u8 tim_count;
  948. u8 tim_period;
  949. } __packed;
  950. struct rtllib_wmm_ac_param {
  951. u8 ac_aci_acm_aifsn;
  952. u8 ac_ecwmin_ecwmax;
  953. u16 ac_txop_limit;
  954. };
  955. enum eap_type {
  956. EAP_PACKET = 0,
  957. EAPOL_START,
  958. EAPOL_LOGOFF,
  959. EAPOL_KEY,
  960. EAPOL_ENCAP_ASF_ALERT
  961. };
  962. static const char * const eap_types[] = {
  963. [EAP_PACKET] = "EAP-Packet",
  964. [EAPOL_START] = "EAPOL-Start",
  965. [EAPOL_LOGOFF] = "EAPOL-Logoff",
  966. [EAPOL_KEY] = "EAPOL-Key",
  967. [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
  968. };
  969. static inline const char *eap_get_type(int type)
  970. {
  971. return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
  972. eap_types[type];
  973. }
  974. static inline u8 Frame_QoSTID(u8 *buf)
  975. {
  976. struct rtllib_hdr_3addr *hdr;
  977. u16 fc;
  978. hdr = (struct rtllib_hdr_3addr *)buf;
  979. fc = le16_to_cpu(hdr->frame_ctl);
  980. return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
  981. (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
  982. }
  983. struct eapol {
  984. u8 snap[6];
  985. u16 ethertype;
  986. u8 version;
  987. u8 type;
  988. u16 length;
  989. } __packed;
  990. struct rtllib_softmac_stats {
  991. unsigned int rx_ass_ok;
  992. unsigned int rx_ass_err;
  993. unsigned int rx_probe_rq;
  994. unsigned int tx_probe_rs;
  995. unsigned int tx_beacons;
  996. unsigned int rx_auth_rq;
  997. unsigned int rx_auth_rs_ok;
  998. unsigned int rx_auth_rs_err;
  999. unsigned int tx_auth_rq;
  1000. unsigned int no_auth_rs;
  1001. unsigned int no_ass_rs;
  1002. unsigned int tx_ass_rq;
  1003. unsigned int rx_ass_rq;
  1004. unsigned int tx_probe_rq;
  1005. unsigned int reassoc;
  1006. unsigned int swtxstop;
  1007. unsigned int swtxawake;
  1008. unsigned char CurrentShowTxate;
  1009. unsigned char last_packet_rate;
  1010. unsigned int txretrycount;
  1011. };
  1012. /* These are the data types that can make up management packets
  1013. *
  1014. * u16 auth_algorithm;
  1015. * u16 auth_sequence;
  1016. * u16 beacon_interval;
  1017. * u16 capability;
  1018. * u8 current_ap[ETH_ALEN];
  1019. * u16 listen_interval;
  1020. * struct {
  1021. * u16 association_id:14, reserved:2;
  1022. * } __packed;
  1023. * u32 time_stamp[2];
  1024. * u16 reason;
  1025. * u16 status;
  1026. */
  1027. #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
  1028. #define RTLLIB_DEFAULT_BASIC_RATE 2
  1029. enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
  1030. #define MAX_SP_Len (WMM_all_frame << 4)
  1031. #define RTLLIB_QOS_TID 0x0f
  1032. #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
  1033. #define RTLLIB_DTIM_MBCAST 4
  1034. #define RTLLIB_DTIM_UCAST 2
  1035. #define RTLLIB_DTIM_VALID 1
  1036. #define RTLLIB_DTIM_INVALID 0
  1037. #define RTLLIB_PS_DISABLED 0
  1038. #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
  1039. #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
  1040. #define WME_AC_BK 0x00
  1041. #define WME_AC_BE 0x01
  1042. #define WME_AC_VI 0x02
  1043. #define WME_AC_VO 0x03
  1044. #define WME_ACI_MASK 0x03
  1045. #define WME_AIFSN_MASK 0x03
  1046. #define WME_AC_PRAM_LEN 16
  1047. #define MAX_RECEIVE_BUFFER_SIZE 9100
  1048. #define UP2AC(up) ( \
  1049. ((up) < 1) ? WME_AC_BE : \
  1050. ((up) < 3) ? WME_AC_BK : \
  1051. ((up) < 4) ? WME_AC_BE : \
  1052. ((up) < 6) ? WME_AC_VI : \
  1053. WME_AC_VO)
  1054. #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
  1055. #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
  1056. * plus ether type*/
  1057. struct ether_header {
  1058. u8 ether_dhost[ETHER_ADDR_LEN];
  1059. u8 ether_shost[ETHER_ADDR_LEN];
  1060. u16 ether_type;
  1061. } __packed;
  1062. enum erp_t {
  1063. ERP_NonERPpresent = 0x01,
  1064. ERP_UseProtection = 0x02,
  1065. ERP_BarkerPreambleMode = 0x04,
  1066. };
  1067. struct rtllib_network {
  1068. /* These entries are used to identify a unique network */
  1069. u8 bssid[ETH_ALEN];
  1070. u8 channel;
  1071. /* Ensure null-terminated for any debug msgs */
  1072. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  1073. u8 ssid_len;
  1074. u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
  1075. u8 hidden_ssid_len;
  1076. struct rtllib_qos_data qos_data;
  1077. bool bWithAironetIE;
  1078. bool bCkipSupported;
  1079. bool bCcxRmEnable;
  1080. u16 CcxRmState[2];
  1081. bool bMBssidValid;
  1082. u8 MBssidMask;
  1083. u8 MBssid[ETH_ALEN];
  1084. bool bWithCcxVerNum;
  1085. u8 BssCcxVerNumber;
  1086. /* These are network statistics */
  1087. struct rtllib_rx_stats stats;
  1088. u16 capability;
  1089. u8 rates[MAX_RATES_LENGTH];
  1090. u8 rates_len;
  1091. u8 rates_ex[MAX_RATES_EX_LENGTH];
  1092. u8 rates_ex_len;
  1093. unsigned long last_scanned;
  1094. u8 mode;
  1095. u32 flags;
  1096. u32 time_stamp[2];
  1097. u16 beacon_interval;
  1098. u16 listen_interval;
  1099. u16 atim_window;
  1100. u8 erp_value;
  1101. u8 wpa_ie[MAX_WPA_IE_LEN];
  1102. size_t wpa_ie_len;
  1103. u8 rsn_ie[MAX_WPA_IE_LEN];
  1104. size_t rsn_ie_len;
  1105. u8 wzc_ie[MAX_WZC_IE_LEN];
  1106. size_t wzc_ie_len;
  1107. struct rtllib_tim_parameters tim;
  1108. u8 dtim_period;
  1109. u8 dtim_data;
  1110. u64 last_dtim_sta_time;
  1111. u8 wmm_info;
  1112. struct rtllib_wmm_ac_param wmm_param[4];
  1113. u8 Turbo_Enable;
  1114. u16 CountryIeLen;
  1115. u8 CountryIeBuf[MAX_IE_LEN];
  1116. struct bss_ht bssht;
  1117. bool broadcom_cap_exist;
  1118. bool realtek_cap_exit;
  1119. bool marvell_cap_exist;
  1120. bool ralink_cap_exist;
  1121. bool atheros_cap_exist;
  1122. bool cisco_cap_exist;
  1123. bool airgo_cap_exist;
  1124. bool unknown_cap_exist;
  1125. bool berp_info_valid;
  1126. bool buseprotection;
  1127. u8 SignalStrength;
  1128. u8 RSSI;
  1129. struct list_head list;
  1130. };
  1131. enum rtllib_state {
  1132. /* the card is not linked at all */
  1133. RTLLIB_NOLINK = 0,
  1134. /* RTLLIB_ASSOCIATING* are for BSS client mode
  1135. * the driver shall not perform RX filtering unless
  1136. * the state is LINKED.
  1137. * The driver shall just check for the state LINKED and
  1138. * defaults to NOLINK for ALL the other states (including
  1139. * LINKED_SCANNING)
  1140. */
  1141. /* the association procedure will start (wq scheduling)*/
  1142. RTLLIB_ASSOCIATING,
  1143. RTLLIB_ASSOCIATING_RETRY,
  1144. /* the association procedure is sending AUTH request*/
  1145. RTLLIB_ASSOCIATING_AUTHENTICATING,
  1146. /* the association procedure has successfully authenticated
  1147. * and is sending association request
  1148. */
  1149. RTLLIB_ASSOCIATING_AUTHENTICATED,
  1150. /* the link is ok. the card associated to a BSS or linked
  1151. * to a ibss cell or acting as an AP and creating the bss
  1152. */
  1153. RTLLIB_LINKED,
  1154. /* same as LINKED, but the driver shall apply RX filter
  1155. * rules as we are in NO_LINK mode. As the card is still
  1156. * logically linked, but it is doing a syncro site survey
  1157. * then it will be back to LINKED state.
  1158. */
  1159. RTLLIB_LINKED_SCANNING,
  1160. };
  1161. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  1162. #define DEFAULT_FTS 2346
  1163. #define CFG_RTLLIB_RESERVE_FCS (1<<0)
  1164. #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
  1165. struct tx_pending {
  1166. int frag;
  1167. struct rtllib_txb *txb;
  1168. };
  1169. struct bandwidth_autoswitch {
  1170. long threshold_20Mhzto40Mhz;
  1171. long threshold_40Mhzto20Mhz;
  1172. bool bforced_tx20Mhz;
  1173. bool bautoswitch_enable;
  1174. };
  1175. #define REORDER_WIN_SIZE 128
  1176. #define REORDER_ENTRY_NUM 128
  1177. struct rx_reorder_entry {
  1178. struct list_head List;
  1179. u16 SeqNum;
  1180. struct rtllib_rxb *prxb;
  1181. };
  1182. enum fsync_state {
  1183. Default_Fsync,
  1184. HW_Fsync,
  1185. SW_Fsync
  1186. };
  1187. enum rt_ps_mode {
  1188. eActive,
  1189. eMaxPs,
  1190. eFastPs,
  1191. eAutoPs,
  1192. };
  1193. enum ips_callback_function {
  1194. IPS_CALLBACK_NONE = 0,
  1195. IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
  1196. IPS_CALLBACK_JOIN_REQUEST = 2,
  1197. };
  1198. enum rt_rf_power_state {
  1199. eRfOn,
  1200. eRfSleep,
  1201. eRfOff
  1202. };
  1203. struct rt_pwr_save_ctrl {
  1204. bool bInactivePs;
  1205. bool bIPSModeBackup;
  1206. bool bSwRfProcessing;
  1207. enum rt_rf_power_state eInactivePowerState;
  1208. enum ips_callback_function ReturnPoint;
  1209. bool bLeisurePs;
  1210. u8 LpsIdleCount;
  1211. u8 RegMaxLPSAwakeIntvl;
  1212. u8 LPSAwakeIntvl;
  1213. u32 CurPsLevel;
  1214. u32 RegRfPsLevel;
  1215. bool bFwCtrlLPS;
  1216. };
  1217. #define RT_RF_CHANGE_SOURCE u32
  1218. #define RF_CHANGE_BY_SW BIT31
  1219. #define RF_CHANGE_BY_HW BIT30
  1220. #define RF_CHANGE_BY_PS BIT29
  1221. #define RF_CHANGE_BY_IPS BIT28
  1222. #define RF_CHANGE_BY_INIT 0
  1223. enum country_code_type {
  1224. COUNTRY_CODE_FCC = 0,
  1225. COUNTRY_CODE_IC = 1,
  1226. COUNTRY_CODE_ETSI = 2,
  1227. COUNTRY_CODE_SPAIN = 3,
  1228. COUNTRY_CODE_FRANCE = 4,
  1229. COUNTRY_CODE_MKK = 5,
  1230. COUNTRY_CODE_MKK1 = 6,
  1231. COUNTRY_CODE_ISRAEL = 7,
  1232. COUNTRY_CODE_TELEC = 8,
  1233. COUNTRY_CODE_MIC = 9,
  1234. COUNTRY_CODE_GLOBAL_DOMAIN = 10,
  1235. COUNTRY_CODE_WORLD_WIDE_13 = 11,
  1236. COUNTRY_CODE_TELEC_NETGEAR = 12,
  1237. COUNTRY_CODE_MAX
  1238. };
  1239. enum scan_op_backup_opt {
  1240. SCAN_OPT_BACKUP = 0,
  1241. SCAN_OPT_RESTORE,
  1242. SCAN_OPT_MAX
  1243. };
  1244. enum fw_cmd_io_type {
  1245. FW_CMD_DIG_ENABLE = 0,
  1246. FW_CMD_DIG_DISABLE = 1,
  1247. FW_CMD_DIG_HALT = 2,
  1248. FW_CMD_DIG_RESUME = 3,
  1249. FW_CMD_HIGH_PWR_ENABLE = 4,
  1250. FW_CMD_HIGH_PWR_DISABLE = 5,
  1251. FW_CMD_RA_RESET = 6,
  1252. FW_CMD_RA_ACTIVE = 7,
  1253. FW_CMD_RA_REFRESH_N = 8,
  1254. FW_CMD_RA_REFRESH_BG = 9,
  1255. FW_CMD_RA_INIT = 10,
  1256. FW_CMD_IQK_ENABLE = 11,
  1257. FW_CMD_TXPWR_TRACK_ENABLE = 12,
  1258. FW_CMD_TXPWR_TRACK_DISABLE = 13,
  1259. FW_CMD_TXPWR_TRACK_THERMAL = 14,
  1260. FW_CMD_PAUSE_DM_BY_SCAN = 15,
  1261. FW_CMD_RESUME_DM_BY_SCAN = 16,
  1262. FW_CMD_RA_REFRESH_N_COMB = 17,
  1263. FW_CMD_RA_REFRESH_BG_COMB = 18,
  1264. FW_CMD_ANTENNA_SW_ENABLE = 19,
  1265. FW_CMD_ANTENNA_SW_DISABLE = 20,
  1266. FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
  1267. FW_CMD_LPS_ENTER = 22,
  1268. FW_CMD_LPS_LEAVE = 23,
  1269. };
  1270. #define RT_MAX_LD_SLOT_NUM 10
  1271. struct rt_link_detect {
  1272. u32 NumRecvBcnInPeriod;
  1273. u32 NumRecvDataInPeriod;
  1274. u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
  1275. u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
  1276. u16 SlotNum;
  1277. u16 SlotIndex;
  1278. u32 NumTxOkInPeriod;
  1279. u32 NumRxOkInPeriod;
  1280. u32 NumRxUnicastOkInPeriod;
  1281. bool bBusyTraffic;
  1282. bool bHigherBusyTraffic;
  1283. bool bHigherBusyRxTraffic;
  1284. };
  1285. struct sw_cam_table {
  1286. u8 macaddr[ETH_ALEN];
  1287. bool bused;
  1288. u8 key_buf[16];
  1289. u16 key_type;
  1290. u8 useDK;
  1291. u8 key_index;
  1292. };
  1293. #define TOTAL_CAM_ENTRY 32
  1294. struct rate_adaptive {
  1295. u8 rate_adaptive_disabled;
  1296. u8 ratr_state;
  1297. u16 reserve;
  1298. u32 high_rssi_thresh_for_ra;
  1299. u32 high2low_rssi_thresh_for_ra;
  1300. u8 low2high_rssi_thresh_for_ra40M;
  1301. u32 low_rssi_thresh_for_ra40M;
  1302. u8 low2high_rssi_thresh_for_ra20M;
  1303. u32 low_rssi_thresh_for_ra20M;
  1304. u32 upper_rssi_threshold_ratr;
  1305. u32 middle_rssi_threshold_ratr;
  1306. u32 low_rssi_threshold_ratr;
  1307. u32 low_rssi_threshold_ratr_40M;
  1308. u32 low_rssi_threshold_ratr_20M;
  1309. u8 ping_rssi_enable;
  1310. u32 ping_rssi_ratr;
  1311. u32 ping_rssi_thresh_for_ra;
  1312. u32 last_ratr;
  1313. u8 PreRATRState;
  1314. };
  1315. #define NUM_PMKID_CACHE 16
  1316. struct rt_pmkid_list {
  1317. u8 Bssid[ETH_ALEN];
  1318. u8 PMKID[16];
  1319. u8 SsidBuf[33];
  1320. u8 bUsed;
  1321. };
  1322. struct rt_intel_promisc_mode {
  1323. bool bPromiscuousOn;
  1324. bool bFilterSourceStationFrame;
  1325. };
  1326. /*************** DRIVER STATUS *****/
  1327. #define STATUS_SCANNING 0
  1328. /*************** DRIVER STATUS *****/
  1329. enum {
  1330. LPS_IS_WAKE = 0,
  1331. LPS_IS_SLEEP = 1,
  1332. LPS_WAIT_NULL_DATA_SEND = 2,
  1333. };
  1334. struct rtllib_device {
  1335. struct pci_dev *pdev;
  1336. struct net_device *dev;
  1337. struct rtllib_security sec;
  1338. bool disable_mgnt_queue;
  1339. unsigned long status;
  1340. u8 CntAfterLink;
  1341. enum rt_op_mode OpMode;
  1342. /* The last AssocReq/Resp IEs */
  1343. u8 *assocreq_ies, *assocresp_ies;
  1344. size_t assocreq_ies_len, assocresp_ies_len;
  1345. bool bForcedBgMode;
  1346. u8 RF_Type;
  1347. u8 hwsec_active;
  1348. bool is_silent_reset;
  1349. bool is_roaming;
  1350. bool ieee_up;
  1351. bool cannot_notify;
  1352. bool bSupportRemoteWakeUp;
  1353. bool actscanning;
  1354. bool FirstIe_InScan;
  1355. bool be_scan_inprogress;
  1356. bool beinretry;
  1357. enum rt_rf_power_state eRFPowerState;
  1358. RT_RF_CHANGE_SOURCE RfOffReason;
  1359. bool is_set_key;
  1360. bool wx_set_enc;
  1361. struct rt_hi_throughput *pHTInfo;
  1362. spinlock_t reorder_spinlock;
  1363. u8 Regdot11HTOperationalRateSet[16];
  1364. u8 Regdot11TxHTOperationalRateSet[16];
  1365. u8 dot11HTOperationalRateSet[16];
  1366. u8 RegHTSuppRateSet[16];
  1367. u8 HTCurrentOperaRate;
  1368. u8 HTHighestOperaRate;
  1369. u8 bTxDisableRateFallBack;
  1370. u8 bTxUseDriverAssingedRate;
  1371. u8 bTxEnableFwCalcDur;
  1372. atomic_t atm_swbw;
  1373. struct list_head Tx_TS_Admit_List;
  1374. struct list_head Tx_TS_Pending_List;
  1375. struct list_head Tx_TS_Unused_List;
  1376. struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
  1377. struct list_head Rx_TS_Admit_List;
  1378. struct list_head Rx_TS_Pending_List;
  1379. struct list_head Rx_TS_Unused_List;
  1380. struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
  1381. struct rx_reorder_entry RxReorderEntry[128];
  1382. struct list_head RxReorder_Unused_List;
  1383. /* Bookkeeping structures */
  1384. struct net_device_stats stats;
  1385. struct rtllib_stats ieee_stats;
  1386. struct rtllib_softmac_stats softmac_stats;
  1387. /* Probe / Beacon management */
  1388. struct list_head network_free_list;
  1389. struct list_head network_list;
  1390. struct rtllib_network *networks;
  1391. int scans;
  1392. int scan_age;
  1393. int iw_mode; /* operating mode (IW_MODE_*) */
  1394. bool bNetPromiscuousMode;
  1395. struct rt_intel_promisc_mode IntelPromiscuousModeInfo;
  1396. spinlock_t lock;
  1397. spinlock_t wpax_suitlist_lock;
  1398. int tx_headroom; /* Set to size of any additional room needed at front
  1399. * of allocated Tx SKBs
  1400. */
  1401. u32 config;
  1402. /* WEP and other encryption related settings at the device level */
  1403. int open_wep; /* Set to 1 to allow unencrypted frames */
  1404. int auth_mode;
  1405. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  1406. * WEP key changes
  1407. */
  1408. /* If the host performs {en,de}cryption, then set to 1 */
  1409. int host_encrypt;
  1410. int host_decrypt;
  1411. int ieee802_1x; /* is IEEE 802.1X used */
  1412. /* WPA data */
  1413. bool bHalfWirelessN24GMode;
  1414. int wpa_enabled;
  1415. int drop_unencrypted;
  1416. int tkip_countermeasures;
  1417. int privacy_invoked;
  1418. size_t wpa_ie_len;
  1419. u8 *wpa_ie;
  1420. size_t wps_ie_len;
  1421. u8 *wps_ie;
  1422. u8 ap_mac_addr[ETH_ALEN];
  1423. u16 pairwise_key_type;
  1424. u16 group_key_type;
  1425. struct lib80211_crypt_info crypt_info;
  1426. struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
  1427. struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
  1428. /* Fragmentation structures */
  1429. struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
  1430. unsigned int frag_next_idx[17];
  1431. u16 fts; /* Fragmentation Threshold */
  1432. #define DEFAULT_RTS_THRESHOLD 2346U
  1433. #define MIN_RTS_THRESHOLD 1
  1434. #define MAX_RTS_THRESHOLD 2346U
  1435. u16 rts; /* RTS threshold */
  1436. /* Association info */
  1437. u8 bssid[ETH_ALEN];
  1438. /* This stores infos for the current network.
  1439. * Either the network we are associated in INFRASTRUCTURE
  1440. * or the network that we are creating in MASTER mode.
  1441. * ad-hoc is a mixture ;-).
  1442. * Note that in infrastructure mode, even when not associated,
  1443. * fields bssid and essid may be valid (if wpa_set and essid_set
  1444. * are true) as thy carry the value set by the user via iwconfig
  1445. */
  1446. struct rtllib_network current_network;
  1447. enum rtllib_state state;
  1448. int short_slot;
  1449. int mode; /* A, B, G */
  1450. int modulation; /* CCK, OFDM */
  1451. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  1452. /* used for forcing the ibss workqueue to terminate
  1453. * without wait for the syncro scan to terminate
  1454. */
  1455. short sync_scan_hurryup;
  1456. u16 scan_watch_dog;
  1457. /* map of allowed channels. 0 is dummy */
  1458. void *pDot11dInfo;
  1459. bool bGlobalDomain;
  1460. u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
  1461. u8 IbssStartChnl;
  1462. u8 ibss_maxjoin_chal;
  1463. int rate; /* current rate */
  1464. int basic_rate;
  1465. short active_scan;
  1466. /* this contains flags for selectively enable softmac support */
  1467. u16 softmac_features;
  1468. /* if the sequence control field is not filled by HW */
  1469. u16 seq_ctrl[5];
  1470. /* association procedure transaction sequence number */
  1471. u16 associate_seq;
  1472. /* AID for RTXed association responses */
  1473. u16 assoc_id;
  1474. /* power save mode related*/
  1475. u8 ack_tx_to_ieee;
  1476. short ps;
  1477. short sta_sleep;
  1478. int ps_timeout;
  1479. int ps_period;
  1480. struct tasklet_struct ps_task;
  1481. u64 ps_time;
  1482. bool polling;
  1483. short raw_tx;
  1484. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  1485. short queue_stop;
  1486. short scanning_continue;
  1487. short proto_started;
  1488. short proto_stoppping;
  1489. struct semaphore wx_sem;
  1490. struct semaphore scan_sem;
  1491. struct semaphore ips_sem;
  1492. spinlock_t mgmt_tx_lock;
  1493. spinlock_t beacon_lock;
  1494. short beacon_txing;
  1495. short wap_set;
  1496. short ssid_set;
  1497. /* set on initialization */
  1498. unsigned int wmm_acm;
  1499. /* for discarding duplicated packets in IBSS */
  1500. struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
  1501. /* for discarding duplicated packets in BSS */
  1502. u16 last_rxseq_num[17]; /* rx seq previous per-tid */
  1503. u16 last_rxfrag_num[17];/* tx frag previous per-tid */
  1504. unsigned long last_packet_time[17];
  1505. /* for PS mode */
  1506. unsigned long last_rx_ps_time;
  1507. bool bAwakePktSent;
  1508. u8 LPSDelayCnt;
  1509. /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
  1510. struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
  1511. int mgmt_queue_head;
  1512. int mgmt_queue_tail;
  1513. u8 AsocRetryCount;
  1514. struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
  1515. struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
  1516. bool bdynamic_txpower_enable;
  1517. bool bCTSToSelfEnable;
  1518. u32 fsync_time_interval;
  1519. u32 fsync_rate_bitmap;
  1520. u8 fsync_rssi_threshold;
  1521. bool bfsync_enable;
  1522. u8 fsync_multiple_timeinterval;
  1523. u32 fsync_firstdiff_ratethreshold;
  1524. u32 fsync_seconddiff_ratethreshold;
  1525. enum fsync_state fsync_state;
  1526. bool bis_any_nonbepkts;
  1527. struct bandwidth_autoswitch bandwidth_auto_switch;
  1528. bool FwRWRF;
  1529. struct rt_link_detect LinkDetectInfo;
  1530. bool bIsAggregateFrame;
  1531. struct rt_pwr_save_ctrl PowerSaveControl;
  1532. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  1533. struct tx_pending tx_pending;
  1534. /* used if IEEE_SOFTMAC_ASSOCIATE is set */
  1535. struct timer_list associate_timer;
  1536. /* used if IEEE_SOFTMAC_BEACONS is set */
  1537. struct timer_list beacon_timer;
  1538. u8 need_sw_enc;
  1539. struct work_struct associate_complete_wq;
  1540. struct work_struct ips_leave_wq;
  1541. struct delayed_work associate_procedure_wq;
  1542. struct delayed_work softmac_scan_wq;
  1543. struct delayed_work associate_retry_wq;
  1544. struct delayed_work start_ibss_wq;
  1545. struct delayed_work hw_wakeup_wq;
  1546. struct delayed_work hw_sleep_wq;
  1547. struct delayed_work link_change_wq;
  1548. struct work_struct wx_sync_scan_wq;
  1549. struct workqueue_struct *wq;
  1550. union {
  1551. struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
  1552. struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
  1553. struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
  1554. struct {
  1555. struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
  1556. struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
  1557. struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
  1558. };
  1559. };
  1560. /* Callback functions */
  1561. void (*set_security)(struct net_device *dev,
  1562. struct rtllib_security *sec);
  1563. /* Used to TX data frame by using txb structs.
  1564. * this is not used if in the softmac_features
  1565. * is set the flag IEEE_SOFTMAC_TX_QUEUE
  1566. */
  1567. int (*hard_start_xmit)(struct rtllib_txb *txb,
  1568. struct net_device *dev);
  1569. int (*reset_port)(struct net_device *dev);
  1570. /* Softmac-generated frames (management) are TXed via this
  1571. * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
  1572. * not set. As some cards may have different HW queues that
  1573. * one might want to use for data and management frames
  1574. * the option to have two callbacks might be useful.
  1575. * This function can't sleep.
  1576. */
  1577. int (*softmac_hard_start_xmit)(struct sk_buff *skb,
  1578. struct net_device *dev);
  1579. /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
  1580. * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
  1581. * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
  1582. * then also management frames are sent via this callback.
  1583. * This function can't sleep.
  1584. */
  1585. void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
  1586. struct net_device *dev, int rate);
  1587. /* stops the HW queue for DATA frames. Useful to avoid
  1588. * waste time to TX data frame when we are reassociating
  1589. * This function can sleep.
  1590. */
  1591. void (*data_hard_stop)(struct net_device *dev);
  1592. /* OK this is complementing to data_poll_hard_stop */
  1593. void (*data_hard_resume)(struct net_device *dev);
  1594. /* ask to the driver to retune the radio.
  1595. * This function can sleep. the driver should ensure
  1596. * the radio has been switched before return.
  1597. */
  1598. void (*set_chan)(struct net_device *dev, short ch);
  1599. void (*rtllib_start_hw_scan)(struct net_device *dev);
  1600. void (*rtllib_stop_hw_scan)(struct net_device *dev);
  1601. /* indicate the driver that the link state is changed
  1602. * for example it may indicate the card is associated now.
  1603. * Driver might be interested in this to apply RX filter
  1604. * rules or simply light the LINK led
  1605. */
  1606. void (*link_change)(struct net_device *dev);
  1607. /* these two function indicates to the HW when to start
  1608. * and stop to send beacons. This is used when the
  1609. * IEEE_SOFTMAC_BEACONS is not set. For now the
  1610. * stop_send_bacons is NOT guaranteed to be called only
  1611. * after start_send_beacons.
  1612. */
  1613. void (*start_send_beacons)(struct net_device *dev);
  1614. void (*stop_send_beacons)(struct net_device *dev);
  1615. /* power save mode related */
  1616. void (*sta_wake_up)(struct net_device *dev);
  1617. void (*enter_sleep_state)(struct net_device *dev, u64 time);
  1618. short (*ps_is_queue_empty)(struct net_device *dev);
  1619. int (*handle_beacon)(struct net_device *dev,
  1620. struct rtllib_beacon *beacon,
  1621. struct rtllib_network *network);
  1622. int (*handle_assoc_response)(struct net_device *dev,
  1623. struct rtllib_assoc_response_frame *resp,
  1624. struct rtllib_network *network);
  1625. /* check whether Tx hw resource available */
  1626. short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
  1627. void (*SetBWModeHandler)(struct net_device *dev,
  1628. enum ht_channel_width Bandwidth,
  1629. enum ht_extchnl_offset Offset);
  1630. bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
  1631. void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
  1632. bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
  1633. u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
  1634. void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
  1635. bool (*SetFwCmdHandler)(struct net_device *dev,
  1636. enum fw_cmd_io_type FwCmdIO);
  1637. void (*UpdateBeaconInterruptHandler)(struct net_device *dev,
  1638. bool start);
  1639. void (*ScanOperationBackupHandler)(struct net_device *dev,
  1640. u8 Operation);
  1641. void (*LedControlHandler)(struct net_device *dev,
  1642. enum led_ctl_mode LedAction);
  1643. void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
  1644. void (*AllowAllDestAddrHandler)(struct net_device *dev,
  1645. bool bAllowAllDA, bool WriteIntoReg);
  1646. void (*rtllib_ips_leave_wq)(struct net_device *dev);
  1647. void (*rtllib_ips_leave)(struct net_device *dev);
  1648. void (*LeisurePSLeave)(struct net_device *dev);
  1649. /* This must be the last item so that it points to the data
  1650. * allocated beyond this structure by alloc_rtllib
  1651. */
  1652. u8 priv[0];
  1653. };
  1654. #define IEEE_A (1<<0)
  1655. #define IEEE_B (1<<1)
  1656. #define IEEE_G (1<<2)
  1657. #define IEEE_N_24G (1<<4)
  1658. #define IEEE_N_5G (1<<5)
  1659. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  1660. /* Generate a 802.11 header */
  1661. /* Uses the channel change callback directly
  1662. * instead of [start/stop] scan callbacks
  1663. */
  1664. #define IEEE_SOFTMAC_SCAN (1<<2)
  1665. /* Perform authentication and association handshake */
  1666. #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
  1667. /* Generate probe requests */
  1668. #define IEEE_SOFTMAC_PROBERQ (1<<4)
  1669. /* Generate response to probe requests */
  1670. #define IEEE_SOFTMAC_PROBERS (1<<5)
  1671. /* The ieee802.11 stack will manage the netif queue
  1672. * wake/stop for the driver, taking care of 802.11
  1673. * fragmentation. See softmac.c for details.
  1674. */
  1675. #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
  1676. /* Uses only the softmac_data_hard_start_xmit
  1677. * even for TX management frames.
  1678. */
  1679. #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
  1680. /* Generate beacons. The stack will enqueue beacons
  1681. * to the card
  1682. */
  1683. #define IEEE_SOFTMAC_BEACONS (1<<6)
  1684. static inline void *rtllib_priv(struct net_device *dev)
  1685. {
  1686. return ((struct rtllib_device *)netdev_priv(dev))->priv;
  1687. }
  1688. static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
  1689. {
  1690. /* Single white space is for Linksys APs */
  1691. if (essid_len == 1 && essid[0] == ' ')
  1692. return 1;
  1693. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  1694. while (essid_len) {
  1695. essid_len--;
  1696. if (essid[essid_len] != '\0')
  1697. return 0;
  1698. }
  1699. return 1;
  1700. }
  1701. static inline int rtllib_get_hdrlen(u16 fc)
  1702. {
  1703. int hdrlen = RTLLIB_3ADDR_LEN;
  1704. switch (WLAN_FC_GET_TYPE(fc)) {
  1705. case RTLLIB_FTYPE_DATA:
  1706. if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
  1707. hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
  1708. if (RTLLIB_QOS_HAS_SEQ(fc))
  1709. hdrlen += 2; /* QOS ctrl*/
  1710. break;
  1711. case RTLLIB_FTYPE_CTL:
  1712. switch (WLAN_FC_GET_STYPE(fc)) {
  1713. case RTLLIB_STYPE_CTS:
  1714. case RTLLIB_STYPE_ACK:
  1715. hdrlen = RTLLIB_1ADDR_LEN;
  1716. break;
  1717. default:
  1718. hdrlen = RTLLIB_2ADDR_LEN;
  1719. break;
  1720. }
  1721. break;
  1722. }
  1723. return hdrlen;
  1724. }
  1725. static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
  1726. {
  1727. switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
  1728. case RTLLIB_1ADDR_LEN:
  1729. return ((struct rtllib_hdr_1addr *)hdr)->payload;
  1730. case RTLLIB_2ADDR_LEN:
  1731. return ((struct rtllib_hdr_2addr *)hdr)->payload;
  1732. case RTLLIB_3ADDR_LEN:
  1733. return ((struct rtllib_hdr_3addr *)hdr)->payload;
  1734. case RTLLIB_4ADDR_LEN:
  1735. return ((struct rtllib_hdr_4addr *)hdr)->payload;
  1736. }
  1737. return NULL;
  1738. }
  1739. static inline int rtllib_is_ofdm_rate(u8 rate)
  1740. {
  1741. switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
  1742. case RTLLIB_OFDM_RATE_6MB:
  1743. case RTLLIB_OFDM_RATE_9MB:
  1744. case RTLLIB_OFDM_RATE_12MB:
  1745. case RTLLIB_OFDM_RATE_18MB:
  1746. case RTLLIB_OFDM_RATE_24MB:
  1747. case RTLLIB_OFDM_RATE_36MB:
  1748. case RTLLIB_OFDM_RATE_48MB:
  1749. case RTLLIB_OFDM_RATE_54MB:
  1750. return 1;
  1751. }
  1752. return 0;
  1753. }
  1754. static inline int rtllib_is_cck_rate(u8 rate)
  1755. {
  1756. switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
  1757. case RTLLIB_CCK_RATE_1MB:
  1758. case RTLLIB_CCK_RATE_2MB:
  1759. case RTLLIB_CCK_RATE_5MB:
  1760. case RTLLIB_CCK_RATE_11MB:
  1761. return 1;
  1762. }
  1763. return 0;
  1764. }
  1765. /* rtllib.c */
  1766. extern void free_rtllib(struct net_device *dev);
  1767. extern struct net_device *alloc_rtllib(int sizeof_priv);
  1768. /* rtllib_tx.c */
  1769. extern int rtllib_encrypt_fragment(
  1770. struct rtllib_device *ieee,
  1771. struct sk_buff *frag,
  1772. int hdr_len);
  1773. extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
  1774. extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
  1775. extern void rtllib_txb_free(struct rtllib_txb *);
  1776. /* rtllib_rx.c */
  1777. extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
  1778. struct rtllib_rx_stats *rx_stats);
  1779. extern void rtllib_rx_mgt(struct rtllib_device *ieee,
  1780. struct sk_buff *skb,
  1781. struct rtllib_rx_stats *stats);
  1782. extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
  1783. struct sk_buff *skb);
  1784. extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
  1785. /* rtllib_wx.c */
  1786. extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
  1787. struct iw_request_info *info,
  1788. union iwreq_data *wrqu, char *key);
  1789. extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
  1790. struct iw_request_info *info,
  1791. union iwreq_data *wrqu, char *key);
  1792. extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
  1793. struct iw_request_info *info,
  1794. union iwreq_data *wrqu, char *key);
  1795. extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
  1796. struct iw_request_info *info,
  1797. union iwreq_data *wrqu, char *extra);
  1798. extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
  1799. struct iw_request_info *info,
  1800. struct iw_param *data, char *extra);
  1801. extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
  1802. struct iw_request_info *info,
  1803. union iwreq_data *wrqu, char *extra);
  1804. extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
  1805. /* rtllib_softmac.c */
  1806. extern short rtllib_is_54g(struct rtllib_network *net);
  1807. extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
  1808. struct sk_buff *skb,
  1809. struct rtllib_rx_stats *rx_stats, u16 type,
  1810. u16 stype);
  1811. extern void rtllib_softmac_new_net(struct rtllib_device *ieee,
  1812. struct rtllib_network *net);
  1813. void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
  1814. extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
  1815. struct rtllib_device *ieee);
  1816. extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
  1817. extern void notify_wx_assoc_event(struct rtllib_device *ieee);
  1818. extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
  1819. extern void rtllib_start_bss(struct rtllib_device *ieee);
  1820. extern void rtllib_start_master_bss(struct rtllib_device *ieee);
  1821. extern void rtllib_start_ibss(struct rtllib_device *ieee);
  1822. extern void rtllib_softmac_init(struct rtllib_device *ieee);
  1823. extern void rtllib_softmac_free(struct rtllib_device *ieee);
  1824. extern void rtllib_associate_abort(struct rtllib_device *ieee);
  1825. extern void rtllib_disassociate(struct rtllib_device *ieee);
  1826. extern void rtllib_stop_scan(struct rtllib_device *ieee);
  1827. extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
  1828. extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
  1829. extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
  1830. extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
  1831. short pwr);
  1832. extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
  1833. extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
  1834. extern void rtllib_start_protocol(struct rtllib_device *ieee);
  1835. extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
  1836. extern void rtllib_EnableNetMonitorMode(struct net_device *dev,
  1837. bool bInitState);
  1838. extern void rtllib_DisableNetMonitorMode(struct net_device *dev,
  1839. bool bInitState);
  1840. extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
  1841. bool bInitState);
  1842. extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
  1843. bool bInitState);
  1844. extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
  1845. extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
  1846. u8 mesh_flag, u8 shutdown);
  1847. extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
  1848. u8 mesh_flag);
  1849. extern void rtllib_reset_queue(struct rtllib_device *ieee);
  1850. extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
  1851. extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
  1852. extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
  1853. extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
  1854. extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
  1855. extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee,
  1856. struct iw_point *p, u8 is_mesh);
  1857. extern void notify_wx_assoc_event(struct rtllib_device *ieee);
  1858. extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
  1859. extern void softmac_mgmt_xmit(struct sk_buff *skb,
  1860. struct rtllib_device *ieee);
  1861. extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
  1862. struct sk_buff *skb, u8 *dst);
  1863. extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
  1864. /* rtllib_softmac_wx.c */
  1865. extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
  1866. struct iw_request_info *info,
  1867. union iwreq_data *wrqu, char *ext);
  1868. extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
  1869. struct iw_request_info *info,
  1870. union iwreq_data *awrq,
  1871. char *extra);
  1872. extern int rtllib_wx_get_essid(struct rtllib_device *ieee,
  1873. struct iw_request_info *a,
  1874. union iwreq_data *wrqu, char *b);
  1875. extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
  1876. struct iw_request_info *info,
  1877. union iwreq_data *wrqu, char *extra);
  1878. extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
  1879. struct iw_request_info *info,
  1880. union iwreq_data *wrqu, char *extra);
  1881. extern int rtllib_wx_set_mode(struct rtllib_device *ieee,
  1882. struct iw_request_info *a,
  1883. union iwreq_data *wrqu, char *b);
  1884. extern int rtllib_wx_set_scan(struct rtllib_device *ieee,
  1885. struct iw_request_info *a,
  1886. union iwreq_data *wrqu, char *b);
  1887. extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
  1888. struct iw_request_info *a,
  1889. union iwreq_data *wrqu, char *extra);
  1890. extern int rtllib_wx_get_mode(struct rtllib_device *ieee,
  1891. struct iw_request_info *a,
  1892. union iwreq_data *wrqu, char *b);
  1893. extern int rtllib_wx_set_freq(struct rtllib_device *ieee,
  1894. struct iw_request_info *a,
  1895. union iwreq_data *wrqu, char *b);
  1896. extern int rtllib_wx_get_freq(struct rtllib_device *ieee,
  1897. struct iw_request_info *a,
  1898. union iwreq_data *wrqu, char *b);
  1899. extern void rtllib_wx_sync_scan_wq(void *data);
  1900. extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
  1901. struct iw_request_info *info,
  1902. union iwreq_data *wrqu, char *extra);
  1903. extern int rtllib_wx_get_name(struct rtllib_device *ieee,
  1904. struct iw_request_info *info,
  1905. union iwreq_data *wrqu, char *extra);
  1906. extern int rtllib_wx_set_power(struct rtllib_device *ieee,
  1907. struct iw_request_info *info,
  1908. union iwreq_data *wrqu, char *extra);
  1909. extern int rtllib_wx_get_power(struct rtllib_device *ieee,
  1910. struct iw_request_info *info,
  1911. union iwreq_data *wrqu, char *extra);
  1912. extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
  1913. struct iw_request_info *info,
  1914. union iwreq_data *wrqu, char *extra);
  1915. extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
  1916. struct iw_request_info *info,
  1917. union iwreq_data *wrqu, char *extra);
  1918. #define MAX_RECEIVE_BUFFER_SIZE 9100
  1919. void HTSetConnectBwMode(struct rtllib_device *ieee,
  1920. enum ht_channel_width Bandwidth,
  1921. enum ht_extchnl_offset Offset);
  1922. extern void HTUpdateDefaultSetting(struct rtllib_device *ieee);
  1923. extern void HTConstructCapabilityElement(struct rtllib_device *ieee,
  1924. u8 *posHTCap, u8 *len,
  1925. u8 isEncrypt, bool bAssoc);
  1926. extern void HTConstructInfoElement(struct rtllib_device *ieee,
  1927. u8 *posHTInfo, u8 *len, u8 isEncrypt);
  1928. extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
  1929. u8 *posRT2RTAgg, u8 *len);
  1930. extern void HTOnAssocRsp(struct rtllib_device *ieee);
  1931. extern void HTInitializeHTInfo(struct rtllib_device *ieee);
  1932. extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
  1933. extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
  1934. struct rtllib_network *pNetwork);
  1935. extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
  1936. struct rtllib_network *pNetwork);
  1937. extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
  1938. u8 *pMCSFilter);
  1939. extern u8 MCS_FILTER_ALL[];
  1940. extern u16 MCS_DATA_RATE[2][2][77];
  1941. extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
  1942. extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
  1943. extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
  1944. extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
  1945. extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
  1946. extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
  1947. extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
  1948. extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
  1949. extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
  1950. u8 Policy, u8 bOverwritePending);
  1951. extern void TsInitDelBA(struct rtllib_device *ieee,
  1952. struct ts_common_info *pTsCommonInfo,
  1953. enum tr_select TxRxSelect);
  1954. extern void BaSetupTimeOut(unsigned long data);
  1955. extern void TxBaInactTimeout(unsigned long data);
  1956. extern void RxBaInactTimeout(unsigned long data);
  1957. extern void ResetBaEntry(struct ba_record *pBA);
  1958. extern bool GetTs(
  1959. struct rtllib_device *ieee,
  1960. struct ts_common_info **ppTS,
  1961. u8 *Addr,
  1962. u8 TID,
  1963. enum tr_select TxRxSelect,
  1964. bool bAddNewTs
  1965. );
  1966. extern void TSInitialize(struct rtllib_device *ieee);
  1967. extern void TsStartAddBaProcess(struct rtllib_device *ieee,
  1968. struct tx_ts_record *pTxTS);
  1969. extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
  1970. extern void RemoveAllTS(struct rtllib_device *ieee);
  1971. void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
  1972. extern const long rtllib_wlan_frequencies[];
  1973. static inline const char *escape_essid(const char *essid, u8 essid_len)
  1974. {
  1975. static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
  1976. if (rtllib_is_empty_essid(essid, essid_len)) {
  1977. memcpy(escaped, "<hidden>", sizeof("<hidden>"));
  1978. return escaped;
  1979. }
  1980. snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
  1981. return escaped;
  1982. }
  1983. /* fun with the built-in rtllib stack... */
  1984. bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
  1985. /* For the function is more related to hardware setting, it's better to use the
  1986. * ieee handler to refer to it.
  1987. */
  1988. extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
  1989. extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
  1990. struct rx_ts_record *pTS);
  1991. extern int rtllib_parse_info_param(struct rtllib_device *ieee,
  1992. struct rtllib_info_element *info_element,
  1993. u16 length,
  1994. struct rtllib_network *network,
  1995. struct rtllib_rx_stats *stats);
  1996. void rtllib_indicate_packets(struct rtllib_device *ieee,
  1997. struct rtllib_rxb **prxbIndicateArray, u8 index);
  1998. extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
  1999. u8 *pOperateMCS);
  2000. extern void HTUseDefaultSetting(struct rtllib_device *ieee);
  2001. #define RT_ASOC_RETRY_LIMIT 5
  2002. u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
  2003. extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
  2004. #define SEM_DOWN_IEEE_WX(psem) down(psem)
  2005. #define SEM_UP_IEEE_WX(psem) up(psem)
  2006. #endif /* RTLLIB_H */