wifi.h 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __RTL_WIFI_H__
  26. #define __RTL_WIFI_H__
  27. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  28. #include <linux/sched.h>
  29. #include <linux/firmware.h>
  30. #include <linux/etherdevice.h>
  31. #include <linux/vmalloc.h>
  32. #include <linux/usb.h>
  33. #include <net/mac80211.h>
  34. #include <linux/completion.h>
  35. #include "debug.h"
  36. #define MASKBYTE0 0xff
  37. #define MASKBYTE1 0xff00
  38. #define MASKBYTE2 0xff0000
  39. #define MASKBYTE3 0xff000000
  40. #define MASKHWORD 0xffff0000
  41. #define MASKLWORD 0x0000ffff
  42. #define MASKDWORD 0xffffffff
  43. #define MASK12BITS 0xfff
  44. #define MASKH4BITS 0xf0000000
  45. #define MASKOFDM_D 0xffc00000
  46. #define MASKCCK 0x3f3f3f3f
  47. #define MASK4BITS 0x0f
  48. #define MASK20BITS 0xfffff
  49. #define RFREG_OFFSET_MASK 0xfffff
  50. #define MASKBYTE0 0xff
  51. #define MASKBYTE1 0xff00
  52. #define MASKBYTE2 0xff0000
  53. #define MASKBYTE3 0xff000000
  54. #define MASKHWORD 0xffff0000
  55. #define MASKLWORD 0x0000ffff
  56. #define MASKDWORD 0xffffffff
  57. #define MASK12BITS 0xfff
  58. #define MASKH4BITS 0xf0000000
  59. #define MASKOFDM_D 0xffc00000
  60. #define MASKCCK 0x3f3f3f3f
  61. #define MASK4BITS 0x0f
  62. #define MASK20BITS 0xfffff
  63. #define RFREG_OFFSET_MASK 0xfffff
  64. #define RF_CHANGE_BY_INIT 0
  65. #define RF_CHANGE_BY_IPS BIT(28)
  66. #define RF_CHANGE_BY_PS BIT(29)
  67. #define RF_CHANGE_BY_HW BIT(30)
  68. #define RF_CHANGE_BY_SW BIT(31)
  69. #define IQK_ADDA_REG_NUM 16
  70. #define IQK_MAC_REG_NUM 4
  71. #define IQK_THRESHOLD 8
  72. #define MAX_KEY_LEN 61
  73. #define KEY_BUF_SIZE 5
  74. /* QoS related. */
  75. /*aci: 0x00 Best Effort*/
  76. /*aci: 0x01 Background*/
  77. /*aci: 0x10 Video*/
  78. /*aci: 0x11 Voice*/
  79. /*Max: define total number.*/
  80. #define AC0_BE 0
  81. #define AC1_BK 1
  82. #define AC2_VI 2
  83. #define AC3_VO 3
  84. #define AC_MAX 4
  85. #define QOS_QUEUE_NUM 4
  86. #define RTL_MAC80211_NUM_QUEUE 5
  87. #define REALTEK_USB_VENQT_MAX_BUF_SIZE 254
  88. #define RTL_USB_MAX_RX_COUNT 100
  89. #define QBSS_LOAD_SIZE 5
  90. #define MAX_WMMELE_LENGTH 64
  91. #define TOTAL_CAM_ENTRY 32
  92. /*slot time for 11g. */
  93. #define RTL_SLOT_TIME_9 9
  94. #define RTL_SLOT_TIME_20 20
  95. /*related to tcp/ip. */
  96. #define SNAP_SIZE 6
  97. #define PROTOC_TYPE_SIZE 2
  98. /*related with 802.11 frame*/
  99. #define MAC80211_3ADDR_LEN 24
  100. #define MAC80211_4ADDR_LEN 30
  101. #define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max channel no */
  102. #define CHANNEL_MAX_NUMBER_2G 14
  103. #define CHANNEL_MAX_NUMBER_5G 49 /* Please refer to
  104. *"phy_GetChnlGroup8812A" and
  105. * "Hal_ReadTxPowerInfo8812A"
  106. */
  107. #define CHANNEL_MAX_NUMBER_5G_80M 7
  108. #define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, 4~9, 10~14 = three groups */
  109. #define MAX_PG_GROUP 13
  110. #define CHANNEL_GROUP_MAX_2G 3
  111. #define CHANNEL_GROUP_IDX_5GL 3
  112. #define CHANNEL_GROUP_IDX_5GM 6
  113. #define CHANNEL_GROUP_IDX_5GH 9
  114. #define CHANNEL_GROUP_MAX_5G 9
  115. #define CHANNEL_MAX_NUMBER_2G 14
  116. #define AVG_THERMAL_NUM 8
  117. #define AVG_THERMAL_NUM_88E 4
  118. #define AVG_THERMAL_NUM_8723BE 4
  119. #define MAX_TID_COUNT 9
  120. /* for early mode */
  121. #define FCS_LEN 4
  122. #define EM_HDR_LEN 8
  123. enum rtl8192c_h2c_cmd {
  124. H2C_AP_OFFLOAD = 0,
  125. H2C_SETPWRMODE = 1,
  126. H2C_JOINBSSRPT = 2,
  127. H2C_RSVDPAGE = 3,
  128. H2C_RSSI_REPORT = 5,
  129. H2C_RA_MASK = 6,
  130. H2C_MACID_PS_MODE = 7,
  131. H2C_P2P_PS_OFFLOAD = 8,
  132. H2C_MAC_MODE_SEL = 9,
  133. H2C_PWRM = 15,
  134. H2C_P2P_PS_CTW_CMD = 24,
  135. MAX_H2CCMD
  136. };
  137. #define MAX_TX_COUNT 4
  138. #define MAX_REGULATION_NUM 4
  139. #define MAX_RF_PATH_NUM 4
  140. #define MAX_RATE_SECTION_NUM 6
  141. #define MAX_2_4G_BANDWIDTH_NUM 4
  142. #define MAX_5G_BANDWIDTH_NUM 4
  143. #define MAX_RF_PATH 4
  144. #define MAX_CHNL_GROUP_24G 6
  145. #define MAX_CHNL_GROUP_5G 14
  146. #define TX_PWR_BY_RATE_NUM_BAND 2
  147. #define TX_PWR_BY_RATE_NUM_RF 4
  148. #define TX_PWR_BY_RATE_NUM_SECTION 12
  149. #define MAX_BASE_NUM_IN_PHY_REG_PG_24G 6
  150. #define MAX_BASE_NUM_IN_PHY_REG_PG_5G 5
  151. #define RTL8192EE_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */
  152. #define DEL_SW_IDX_SZ 30
  153. #define BAND_NUM 3
  154. /* For now, it's just for 8192ee
  155. * but not OK yet, keep it 0
  156. */
  157. #define DMA_IS_64BIT 0
  158. #define RTL8192EE_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */
  159. enum rf_tx_num {
  160. RF_1TX = 0,
  161. RF_2TX,
  162. RF_MAX_TX_NUM,
  163. RF_TX_NUM_NONIMPLEMENT,
  164. };
  165. #define PACKET_NORMAL 0
  166. #define PACKET_DHCP 1
  167. #define PACKET_ARP 2
  168. #define PACKET_EAPOL 3
  169. #define MAX_SUPPORT_WOL_PATTERN_NUM 16
  170. #define RSVD_WOL_PATTERN_NUM 1
  171. #define WKFMCAM_ADDR_NUM 6
  172. #define WKFMCAM_SIZE 24
  173. #define MAX_WOL_BIT_MASK_SIZE 16
  174. /* MIN LEN keeps 13 here */
  175. #define MIN_WOL_PATTERN_SIZE 13
  176. #define MAX_WOL_PATTERN_SIZE 128
  177. #define WAKE_ON_MAGIC_PACKET BIT(0)
  178. #define WAKE_ON_PATTERN_MATCH BIT(1)
  179. #define WOL_REASON_PTK_UPDATE BIT(0)
  180. #define WOL_REASON_GTK_UPDATE BIT(1)
  181. #define WOL_REASON_DISASSOC BIT(2)
  182. #define WOL_REASON_DEAUTH BIT(3)
  183. #define WOL_REASON_AP_LOST BIT(4)
  184. #define WOL_REASON_MAGIC_PKT BIT(5)
  185. #define WOL_REASON_UNICAST_PKT BIT(6)
  186. #define WOL_REASON_PATTERN_PKT BIT(7)
  187. #define WOL_REASON_RTD3_SSID_MATCH BIT(8)
  188. #define WOL_REASON_REALWOW_V2_WAKEUPPKT BIT(9)
  189. #define WOL_REASON_REALWOW_V2_ACKLOST BIT(10)
  190. struct rtlwifi_firmware_header {
  191. __le16 signature;
  192. u8 category;
  193. u8 function;
  194. __le16 version;
  195. u8 subversion;
  196. u8 rsvd1;
  197. u8 month;
  198. u8 date;
  199. u8 hour;
  200. u8 minute;
  201. __le16 ramcodeSize;
  202. __le16 rsvd2;
  203. __le32 svnindex;
  204. __le32 rsvd3;
  205. __le32 rsvd4;
  206. __le32 rsvd5;
  207. };
  208. struct txpower_info_2g {
  209. u8 index_cck_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
  210. u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G];
  211. /*If only one tx, only BW20 and OFDM are used.*/
  212. u8 cck_diff[MAX_RF_PATH][MAX_TX_COUNT];
  213. u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
  214. u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
  215. u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
  216. u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
  217. u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
  218. };
  219. struct txpower_info_5g {
  220. u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_5G];
  221. /*If only one tx, only BW20, OFDM, BW80 and BW160 are used.*/
  222. u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT];
  223. u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT];
  224. u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT];
  225. u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT];
  226. u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT];
  227. };
  228. enum rate_section {
  229. CCK = 0,
  230. OFDM,
  231. HT_MCS0_MCS7,
  232. HT_MCS8_MCS15,
  233. VHT_1SSMCS0_1SSMCS9,
  234. VHT_2SSMCS0_2SSMCS9,
  235. };
  236. enum intf_type {
  237. INTF_PCI = 0,
  238. INTF_USB = 1,
  239. };
  240. enum radio_path {
  241. RF90_PATH_A = 0,
  242. RF90_PATH_B = 1,
  243. RF90_PATH_C = 2,
  244. RF90_PATH_D = 3,
  245. };
  246. enum regulation_txpwr_lmt {
  247. TXPWR_LMT_FCC = 0,
  248. TXPWR_LMT_MKK = 1,
  249. TXPWR_LMT_ETSI = 2,
  250. TXPWR_LMT_WW = 3,
  251. TXPWR_LMT_MAX_REGULATION_NUM = 4
  252. };
  253. enum rt_eeprom_type {
  254. EEPROM_93C46,
  255. EEPROM_93C56,
  256. EEPROM_BOOT_EFUSE,
  257. };
  258. enum ttl_status {
  259. RTL_STATUS_INTERFACE_START = 0,
  260. };
  261. enum hardware_type {
  262. HARDWARE_TYPE_RTL8192E,
  263. HARDWARE_TYPE_RTL8192U,
  264. HARDWARE_TYPE_RTL8192SE,
  265. HARDWARE_TYPE_RTL8192SU,
  266. HARDWARE_TYPE_RTL8192CE,
  267. HARDWARE_TYPE_RTL8192CU,
  268. HARDWARE_TYPE_RTL8192DE,
  269. HARDWARE_TYPE_RTL8192DU,
  270. HARDWARE_TYPE_RTL8723AE,
  271. HARDWARE_TYPE_RTL8723U,
  272. HARDWARE_TYPE_RTL8188EE,
  273. HARDWARE_TYPE_RTL8723BE,
  274. HARDWARE_TYPE_RTL8192EE,
  275. HARDWARE_TYPE_RTL8821AE,
  276. HARDWARE_TYPE_RTL8812AE,
  277. /* keep it last */
  278. HARDWARE_TYPE_NUM
  279. };
  280. #define IS_HARDWARE_TYPE_8192SU(rtlhal) \
  281. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SU)
  282. #define IS_HARDWARE_TYPE_8192SE(rtlhal) \
  283. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
  284. #define IS_HARDWARE_TYPE_8192CE(rtlhal) \
  285. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
  286. #define IS_HARDWARE_TYPE_8192CU(rtlhal) \
  287. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
  288. #define IS_HARDWARE_TYPE_8192DE(rtlhal) \
  289. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
  290. #define IS_HARDWARE_TYPE_8192DU(rtlhal) \
  291. (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DU)
  292. #define IS_HARDWARE_TYPE_8723E(rtlhal) \
  293. (rtlhal->hw_type == HARDWARE_TYPE_RTL8723E)
  294. #define IS_HARDWARE_TYPE_8723U(rtlhal) \
  295. (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
  296. #define IS_HARDWARE_TYPE_8192S(rtlhal) \
  297. (IS_HARDWARE_TYPE_8192SE(rtlhal) || IS_HARDWARE_TYPE_8192SU(rtlhal))
  298. #define IS_HARDWARE_TYPE_8192C(rtlhal) \
  299. (IS_HARDWARE_TYPE_8192CE(rtlhal) || IS_HARDWARE_TYPE_8192CU(rtlhal))
  300. #define IS_HARDWARE_TYPE_8192D(rtlhal) \
  301. (IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
  302. #define IS_HARDWARE_TYPE_8723(rtlhal) \
  303. (IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
  304. #define RX_HAL_IS_CCK_RATE(rxmcs) \
  305. ((rxmcs) == DESC_RATE1M || \
  306. (rxmcs) == DESC_RATE2M || \
  307. (rxmcs) == DESC_RATE5_5M || \
  308. (rxmcs) == DESC_RATE11M)
  309. enum scan_operation_backup_opt {
  310. SCAN_OPT_BACKUP = 0,
  311. SCAN_OPT_BACKUP_BAND0 = 0,
  312. SCAN_OPT_BACKUP_BAND1,
  313. SCAN_OPT_RESTORE,
  314. SCAN_OPT_MAX
  315. };
  316. /*RF state.*/
  317. enum rf_pwrstate {
  318. ERFON,
  319. ERFSLEEP,
  320. ERFOFF
  321. };
  322. struct bb_reg_def {
  323. u32 rfintfs;
  324. u32 rfintfi;
  325. u32 rfintfo;
  326. u32 rfintfe;
  327. u32 rf3wire_offset;
  328. u32 rflssi_select;
  329. u32 rftxgain_stage;
  330. u32 rfhssi_para1;
  331. u32 rfhssi_para2;
  332. u32 rfsw_ctrl;
  333. u32 rfagc_control1;
  334. u32 rfagc_control2;
  335. u32 rfrxiq_imbal;
  336. u32 rfrx_afe;
  337. u32 rftxiq_imbal;
  338. u32 rftx_afe;
  339. u32 rf_rb; /* rflssi_readback */
  340. u32 rf_rbpi; /* rflssi_readbackpi */
  341. };
  342. enum io_type {
  343. IO_CMD_PAUSE_DM_BY_SCAN = 0,
  344. IO_CMD_PAUSE_BAND0_DM_BY_SCAN = 0,
  345. IO_CMD_PAUSE_BAND1_DM_BY_SCAN = 1,
  346. IO_CMD_RESUME_DM_BY_SCAN = 2,
  347. };
  348. enum hw_variables {
  349. HW_VAR_ETHER_ADDR = 0x0,
  350. HW_VAR_MULTICAST_REG = 0x1,
  351. HW_VAR_BASIC_RATE = 0x2,
  352. HW_VAR_BSSID = 0x3,
  353. HW_VAR_MEDIA_STATUS= 0x4,
  354. HW_VAR_SECURITY_CONF= 0x5,
  355. HW_VAR_BEACON_INTERVAL = 0x6,
  356. HW_VAR_ATIM_WINDOW = 0x7,
  357. HW_VAR_LISTEN_INTERVAL = 0x8,
  358. HW_VAR_CS_COUNTER = 0x9,
  359. HW_VAR_DEFAULTKEY0 = 0xa,
  360. HW_VAR_DEFAULTKEY1 = 0xb,
  361. HW_VAR_DEFAULTKEY2 = 0xc,
  362. HW_VAR_DEFAULTKEY3 = 0xd,
  363. HW_VAR_SIFS = 0xe,
  364. HW_VAR_R2T_SIFS = 0xf,
  365. HW_VAR_DIFS = 0x10,
  366. HW_VAR_EIFS = 0x11,
  367. HW_VAR_SLOT_TIME = 0x12,
  368. HW_VAR_ACK_PREAMBLE = 0x13,
  369. HW_VAR_CW_CONFIG = 0x14,
  370. HW_VAR_CW_VALUES = 0x15,
  371. HW_VAR_RATE_FALLBACK_CONTROL= 0x16,
  372. HW_VAR_CONTENTION_WINDOW = 0x17,
  373. HW_VAR_RETRY_COUNT = 0x18,
  374. HW_VAR_TR_SWITCH = 0x19,
  375. HW_VAR_COMMAND = 0x1a,
  376. HW_VAR_WPA_CONFIG = 0x1b,
  377. HW_VAR_AMPDU_MIN_SPACE = 0x1c,
  378. HW_VAR_SHORTGI_DENSITY = 0x1d,
  379. HW_VAR_AMPDU_FACTOR = 0x1e,
  380. HW_VAR_MCS_RATE_AVAILABLE = 0x1f,
  381. HW_VAR_AC_PARAM = 0x20,
  382. HW_VAR_ACM_CTRL = 0x21,
  383. HW_VAR_DIS_Req_Qsize = 0x22,
  384. HW_VAR_CCX_CHNL_LOAD = 0x23,
  385. HW_VAR_CCX_NOISE_HISTOGRAM = 0x24,
  386. HW_VAR_CCX_CLM_NHM = 0x25,
  387. HW_VAR_TxOPLimit = 0x26,
  388. HW_VAR_TURBO_MODE = 0x27,
  389. HW_VAR_RF_STATE = 0x28,
  390. HW_VAR_RF_OFF_BY_HW = 0x29,
  391. HW_VAR_BUS_SPEED = 0x2a,
  392. HW_VAR_SET_DEV_POWER = 0x2b,
  393. HW_VAR_RCR = 0x2c,
  394. HW_VAR_RATR_0 = 0x2d,
  395. HW_VAR_RRSR = 0x2e,
  396. HW_VAR_CPU_RST = 0x2f,
  397. HW_VAR_CHECK_BSSID = 0x30,
  398. HW_VAR_LBK_MODE = 0x31,
  399. HW_VAR_AES_11N_FIX = 0x32,
  400. HW_VAR_USB_RX_AGGR = 0x33,
  401. HW_VAR_USER_CONTROL_TURBO_MODE = 0x34,
  402. HW_VAR_RETRY_LIMIT = 0x35,
  403. HW_VAR_INIT_TX_RATE = 0x36,
  404. HW_VAR_TX_RATE_REG = 0x37,
  405. HW_VAR_EFUSE_USAGE = 0x38,
  406. HW_VAR_EFUSE_BYTES = 0x39,
  407. HW_VAR_AUTOLOAD_STATUS = 0x3a,
  408. HW_VAR_RF_2R_DISABLE = 0x3b,
  409. HW_VAR_SET_RPWM = 0x3c,
  410. HW_VAR_H2C_FW_PWRMODE = 0x3d,
  411. HW_VAR_H2C_FW_JOINBSSRPT = 0x3e,
  412. HW_VAR_H2C_FW_MEDIASTATUSRPT = 0x3f,
  413. HW_VAR_H2C_FW_P2P_PS_OFFLOAD = 0x40,
  414. HW_VAR_FW_PSMODE_STATUS = 0x41,
  415. HW_VAR_INIT_RTS_RATE = 0x42,
  416. HW_VAR_RESUME_CLK_ON = 0x43,
  417. HW_VAR_FW_LPS_ACTION = 0x44,
  418. HW_VAR_1X1_RECV_COMBINE = 0x45,
  419. HW_VAR_STOP_SEND_BEACON = 0x46,
  420. HW_VAR_TSF_TIMER = 0x47,
  421. HW_VAR_IO_CMD = 0x48,
  422. HW_VAR_RF_RECOVERY = 0x49,
  423. HW_VAR_H2C_FW_UPDATE_GTK = 0x4a,
  424. HW_VAR_WF_MASK = 0x4b,
  425. HW_VAR_WF_CRC = 0x4c,
  426. HW_VAR_WF_IS_MAC_ADDR = 0x4d,
  427. HW_VAR_H2C_FW_OFFLOAD = 0x4e,
  428. HW_VAR_RESET_WFCRC = 0x4f,
  429. HW_VAR_HANDLE_FW_C2H = 0x50,
  430. HW_VAR_DL_FW_RSVD_PAGE = 0x51,
  431. HW_VAR_AID = 0x52,
  432. HW_VAR_HW_SEQ_ENABLE = 0x53,
  433. HW_VAR_CORRECT_TSF = 0x54,
  434. HW_VAR_BCN_VALID = 0x55,
  435. HW_VAR_FWLPS_RF_ON = 0x56,
  436. HW_VAR_DUAL_TSF_RST = 0x57,
  437. HW_VAR_SWITCH_EPHY_WoWLAN = 0x58,
  438. HW_VAR_INT_MIGRATION = 0x59,
  439. HW_VAR_INT_AC = 0x5a,
  440. HW_VAR_RF_TIMING = 0x5b,
  441. HAL_DEF_WOWLAN = 0x5c,
  442. HW_VAR_MRC = 0x5d,
  443. HW_VAR_KEEP_ALIVE = 0x5e,
  444. HW_VAR_NAV_UPPER = 0x5f,
  445. HW_VAR_MGT_FILTER = 0x60,
  446. HW_VAR_CTRL_FILTER = 0x61,
  447. HW_VAR_DATA_FILTER = 0x62,
  448. };
  449. enum rt_media_status {
  450. RT_MEDIA_DISCONNECT = 0,
  451. RT_MEDIA_CONNECT = 1
  452. };
  453. enum rt_oem_id {
  454. RT_CID_DEFAULT = 0,
  455. RT_CID_8187_ALPHA0 = 1,
  456. RT_CID_8187_SERCOMM_PS = 2,
  457. RT_CID_8187_HW_LED = 3,
  458. RT_CID_8187_NETGEAR = 4,
  459. RT_CID_WHQL = 5,
  460. RT_CID_819X_CAMEO = 6,
  461. RT_CID_819X_RUNTOP = 7,
  462. RT_CID_819X_SENAO = 8,
  463. RT_CID_TOSHIBA = 9,
  464. RT_CID_819X_NETCORE = 10,
  465. RT_CID_NETTRONIX = 11,
  466. RT_CID_DLINK = 12,
  467. RT_CID_PRONET = 13,
  468. RT_CID_COREGA = 14,
  469. RT_CID_819X_ALPHA = 15,
  470. RT_CID_819X_SITECOM = 16,
  471. RT_CID_CCX = 17,
  472. RT_CID_819X_LENOVO = 18,
  473. RT_CID_819X_QMI = 19,
  474. RT_CID_819X_EDIMAX_BELKIN = 20,
  475. RT_CID_819X_SERCOMM_BELKIN = 21,
  476. RT_CID_819X_CAMEO1 = 22,
  477. RT_CID_819X_MSI = 23,
  478. RT_CID_819X_ACER = 24,
  479. RT_CID_819X_HP = 27,
  480. RT_CID_819X_CLEVO = 28,
  481. RT_CID_819X_ARCADYAN_BELKIN = 29,
  482. RT_CID_819X_SAMSUNG = 30,
  483. RT_CID_819X_WNC_COREGA = 31,
  484. RT_CID_819X_FOXCOON = 32,
  485. RT_CID_819X_DELL = 33,
  486. RT_CID_819X_PRONETS = 34,
  487. RT_CID_819X_EDIMAX_ASUS = 35,
  488. RT_CID_NETGEAR = 36,
  489. RT_CID_PLANEX = 37,
  490. RT_CID_CC_C = 38,
  491. };
  492. enum hw_descs {
  493. HW_DESC_OWN,
  494. HW_DESC_RXOWN,
  495. HW_DESC_TX_NEXTDESC_ADDR,
  496. HW_DESC_TXBUFF_ADDR,
  497. HW_DESC_RXBUFF_ADDR,
  498. HW_DESC_RXPKT_LEN,
  499. HW_DESC_RXERO,
  500. HW_DESC_RX_PREPARE,
  501. };
  502. enum prime_sc {
  503. PRIME_CHNL_OFFSET_DONT_CARE = 0,
  504. PRIME_CHNL_OFFSET_LOWER = 1,
  505. PRIME_CHNL_OFFSET_UPPER = 2,
  506. };
  507. enum rf_type {
  508. RF_1T1R = 0,
  509. RF_1T2R = 1,
  510. RF_2T2R = 2,
  511. RF_2T2R_GREEN = 3,
  512. };
  513. enum ht_channel_width {
  514. HT_CHANNEL_WIDTH_20 = 0,
  515. HT_CHANNEL_WIDTH_20_40 = 1,
  516. HT_CHANNEL_WIDTH_80 = 2,
  517. };
  518. /* Ref: 802.11i sepc D10.0 7.3.2.25.1
  519. Cipher Suites Encryption Algorithms */
  520. enum rt_enc_alg {
  521. NO_ENCRYPTION = 0,
  522. WEP40_ENCRYPTION = 1,
  523. TKIP_ENCRYPTION = 2,
  524. RSERVED_ENCRYPTION = 3,
  525. AESCCMP_ENCRYPTION = 4,
  526. WEP104_ENCRYPTION = 5,
  527. AESCMAC_ENCRYPTION = 6, /*IEEE802.11w */
  528. };
  529. enum rtl_hal_state {
  530. _HAL_STATE_STOP = 0,
  531. _HAL_STATE_START = 1,
  532. };
  533. enum rtl_desc92_rate {
  534. DESC_RATE1M = 0x00,
  535. DESC_RATE2M = 0x01,
  536. DESC_RATE5_5M = 0x02,
  537. DESC_RATE11M = 0x03,
  538. DESC_RATE6M = 0x04,
  539. DESC_RATE9M = 0x05,
  540. DESC_RATE12M = 0x06,
  541. DESC_RATE18M = 0x07,
  542. DESC_RATE24M = 0x08,
  543. DESC_RATE36M = 0x09,
  544. DESC_RATE48M = 0x0a,
  545. DESC_RATE54M = 0x0b,
  546. DESC_RATEMCS0 = 0x0c,
  547. DESC_RATEMCS1 = 0x0d,
  548. DESC_RATEMCS2 = 0x0e,
  549. DESC_RATEMCS3 = 0x0f,
  550. DESC_RATEMCS4 = 0x10,
  551. DESC_RATEMCS5 = 0x11,
  552. DESC_RATEMCS6 = 0x12,
  553. DESC_RATEMCS7 = 0x13,
  554. DESC_RATEMCS8 = 0x14,
  555. DESC_RATEMCS9 = 0x15,
  556. DESC_RATEMCS10 = 0x16,
  557. DESC_RATEMCS11 = 0x17,
  558. DESC_RATEMCS12 = 0x18,
  559. DESC_RATEMCS13 = 0x19,
  560. DESC_RATEMCS14 = 0x1a,
  561. DESC_RATEMCS15 = 0x1b,
  562. DESC_RATEMCS15_SG = 0x1c,
  563. DESC_RATEMCS32 = 0x20,
  564. DESC_RATEVHT1SS_MCS0 = 0x2c,
  565. DESC_RATEVHT1SS_MCS1 = 0x2d,
  566. DESC_RATEVHT1SS_MCS2 = 0x2e,
  567. DESC_RATEVHT1SS_MCS3 = 0x2f,
  568. DESC_RATEVHT1SS_MCS4 = 0x30,
  569. DESC_RATEVHT1SS_MCS5 = 0x31,
  570. DESC_RATEVHT1SS_MCS6 = 0x32,
  571. DESC_RATEVHT1SS_MCS7 = 0x33,
  572. DESC_RATEVHT1SS_MCS8 = 0x34,
  573. DESC_RATEVHT1SS_MCS9 = 0x35,
  574. DESC_RATEVHT2SS_MCS0 = 0x36,
  575. DESC_RATEVHT2SS_MCS1 = 0x37,
  576. DESC_RATEVHT2SS_MCS2 = 0x38,
  577. DESC_RATEVHT2SS_MCS3 = 0x39,
  578. DESC_RATEVHT2SS_MCS4 = 0x3a,
  579. DESC_RATEVHT2SS_MCS5 = 0x3b,
  580. DESC_RATEVHT2SS_MCS6 = 0x3c,
  581. DESC_RATEVHT2SS_MCS7 = 0x3d,
  582. DESC_RATEVHT2SS_MCS8 = 0x3e,
  583. DESC_RATEVHT2SS_MCS9 = 0x3f,
  584. };
  585. enum rtl_var_map {
  586. /*reg map */
  587. SYS_ISO_CTRL = 0,
  588. SYS_FUNC_EN,
  589. SYS_CLK,
  590. MAC_RCR_AM,
  591. MAC_RCR_AB,
  592. MAC_RCR_ACRC32,
  593. MAC_RCR_ACF,
  594. MAC_RCR_AAP,
  595. MAC_HIMR,
  596. MAC_HIMRE,
  597. MAC_HSISR,
  598. /*efuse map */
  599. EFUSE_TEST,
  600. EFUSE_CTRL,
  601. EFUSE_CLK,
  602. EFUSE_CLK_CTRL,
  603. EFUSE_PWC_EV12V,
  604. EFUSE_FEN_ELDR,
  605. EFUSE_LOADER_CLK_EN,
  606. EFUSE_ANA8M,
  607. EFUSE_HWSET_MAX_SIZE,
  608. EFUSE_MAX_SECTION_MAP,
  609. EFUSE_REAL_CONTENT_SIZE,
  610. EFUSE_OOB_PROTECT_BYTES_LEN,
  611. EFUSE_ACCESS,
  612. /*CAM map */
  613. RWCAM,
  614. WCAMI,
  615. RCAMO,
  616. CAMDBG,
  617. SECR,
  618. SEC_CAM_NONE,
  619. SEC_CAM_WEP40,
  620. SEC_CAM_TKIP,
  621. SEC_CAM_AES,
  622. SEC_CAM_WEP104,
  623. /*IMR map */
  624. RTL_IMR_BCNDMAINT6, /*Beacon DMA Interrupt 6 */
  625. RTL_IMR_BCNDMAINT5, /*Beacon DMA Interrupt 5 */
  626. RTL_IMR_BCNDMAINT4, /*Beacon DMA Interrupt 4 */
  627. RTL_IMR_BCNDMAINT3, /*Beacon DMA Interrupt 3 */
  628. RTL_IMR_BCNDMAINT2, /*Beacon DMA Interrupt 2 */
  629. RTL_IMR_BCNDMAINT1, /*Beacon DMA Interrupt 1 */
  630. RTL_IMR_BCNDOK8, /*Beacon Queue DMA OK Interrup 8 */
  631. RTL_IMR_BCNDOK7, /*Beacon Queue DMA OK Interrup 7 */
  632. RTL_IMR_BCNDOK6, /*Beacon Queue DMA OK Interrup 6 */
  633. RTL_IMR_BCNDOK5, /*Beacon Queue DMA OK Interrup 5 */
  634. RTL_IMR_BCNDOK4, /*Beacon Queue DMA OK Interrup 4 */
  635. RTL_IMR_BCNDOK3, /*Beacon Queue DMA OK Interrup 3 */
  636. RTL_IMR_BCNDOK2, /*Beacon Queue DMA OK Interrup 2 */
  637. RTL_IMR_BCNDOK1, /*Beacon Queue DMA OK Interrup 1 */
  638. RTL_IMR_TIMEOUT2, /*Timeout interrupt 2 */
  639. RTL_IMR_TIMEOUT1, /*Timeout interrupt 1 */
  640. RTL_IMR_TXFOVW, /*Transmit FIFO Overflow */
  641. RTL_IMR_PSTIMEOUT, /*Power save time out interrupt */
  642. RTL_IMR_BCNINT, /*Beacon DMA Interrupt 0 */
  643. RTL_IMR_RXFOVW, /*Receive FIFO Overflow */
  644. RTL_IMR_RDU, /*Receive Descriptor Unavailable */
  645. RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */
  646. RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */
  647. RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */
  648. RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/
  649. RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */
  650. RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */
  651. RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */
  652. RTL_IMR_BKDOK, /*AC_BK DMA OK Interrupt */
  653. RTL_IMR_BEDOK, /*AC_BE DMA OK Interrupt */
  654. RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */
  655. RTL_IMR_VODOK, /*AC_VO DMA Interrupt */
  656. RTL_IMR_ROK, /*Receive DMA OK Interrupt */
  657. RTL_IMR_HSISR_IND, /*HSISR Interrupt*/
  658. RTL_IBSS_INT_MASKS, /*(RTL_IMR_BCNINT | RTL_IMR_TBDOK |
  659. * RTL_IMR_TBDER) */
  660. RTL_IMR_C2HCMD, /*fw interrupt*/
  661. /*CCK Rates, TxHT = 0 */
  662. RTL_RC_CCK_RATE1M,
  663. RTL_RC_CCK_RATE2M,
  664. RTL_RC_CCK_RATE5_5M,
  665. RTL_RC_CCK_RATE11M,
  666. /*OFDM Rates, TxHT = 0 */
  667. RTL_RC_OFDM_RATE6M,
  668. RTL_RC_OFDM_RATE9M,
  669. RTL_RC_OFDM_RATE12M,
  670. RTL_RC_OFDM_RATE18M,
  671. RTL_RC_OFDM_RATE24M,
  672. RTL_RC_OFDM_RATE36M,
  673. RTL_RC_OFDM_RATE48M,
  674. RTL_RC_OFDM_RATE54M,
  675. RTL_RC_HT_RATEMCS7,
  676. RTL_RC_HT_RATEMCS15,
  677. RTL_RC_VHT_RATE_1SS_MCS7,
  678. RTL_RC_VHT_RATE_1SS_MCS8,
  679. RTL_RC_VHT_RATE_1SS_MCS9,
  680. RTL_RC_VHT_RATE_2SS_MCS7,
  681. RTL_RC_VHT_RATE_2SS_MCS8,
  682. RTL_RC_VHT_RATE_2SS_MCS9,
  683. /*keep it last */
  684. RTL_VAR_MAP_MAX,
  685. };
  686. /*Firmware PS mode for control LPS.*/
  687. enum _fw_ps_mode {
  688. FW_PS_ACTIVE_MODE = 0,
  689. FW_PS_MIN_MODE = 1,
  690. FW_PS_MAX_MODE = 2,
  691. FW_PS_DTIM_MODE = 3,
  692. FW_PS_VOIP_MODE = 4,
  693. FW_PS_UAPSD_WMM_MODE = 5,
  694. FW_PS_UAPSD_MODE = 6,
  695. FW_PS_IBSS_MODE = 7,
  696. FW_PS_WWLAN_MODE = 8,
  697. FW_PS_PM_Radio_Off = 9,
  698. FW_PS_PM_Card_Disable = 10,
  699. };
  700. enum rt_psmode {
  701. EACTIVE, /*Active/Continuous access. */
  702. EMAXPS, /*Max power save mode. */
  703. EFASTPS, /*Fast power save mode. */
  704. EAUTOPS, /*Auto power save mode. */
  705. };
  706. /*LED related.*/
  707. enum led_ctl_mode {
  708. LED_CTL_POWER_ON = 1,
  709. LED_CTL_LINK = 2,
  710. LED_CTL_NO_LINK = 3,
  711. LED_CTL_TX = 4,
  712. LED_CTL_RX = 5,
  713. LED_CTL_SITE_SURVEY = 6,
  714. LED_CTL_POWER_OFF = 7,
  715. LED_CTL_START_TO_LINK = 8,
  716. LED_CTL_START_WPS = 9,
  717. LED_CTL_STOP_WPS = 10,
  718. };
  719. enum rtl_led_pin {
  720. LED_PIN_GPIO0,
  721. LED_PIN_LED0,
  722. LED_PIN_LED1,
  723. LED_PIN_LED2
  724. };
  725. /*QoS related.*/
  726. /*acm implementation method.*/
  727. enum acm_method {
  728. eAcmWay0_SwAndHw = 0,
  729. eAcmWay1_HW = 1,
  730. EACMWAY2_SW = 2,
  731. };
  732. enum macphy_mode {
  733. SINGLEMAC_SINGLEPHY = 0,
  734. DUALMAC_DUALPHY,
  735. DUALMAC_SINGLEPHY,
  736. };
  737. enum band_type {
  738. BAND_ON_2_4G = 0,
  739. BAND_ON_5G,
  740. BAND_ON_BOTH,
  741. BANDMAX
  742. };
  743. /*aci/aifsn Field.
  744. Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/
  745. union aci_aifsn {
  746. u8 char_data;
  747. struct {
  748. u8 aifsn:4;
  749. u8 acm:1;
  750. u8 aci:2;
  751. u8 reserved:1;
  752. } f; /* Field */
  753. };
  754. /*mlme related.*/
  755. enum wireless_mode {
  756. WIRELESS_MODE_UNKNOWN = 0x00,
  757. WIRELESS_MODE_A = 0x01,
  758. WIRELESS_MODE_B = 0x02,
  759. WIRELESS_MODE_G = 0x04,
  760. WIRELESS_MODE_AUTO = 0x08,
  761. WIRELESS_MODE_N_24G = 0x10,
  762. WIRELESS_MODE_N_5G = 0x20,
  763. WIRELESS_MODE_AC_5G = 0x40,
  764. WIRELESS_MODE_AC_24G = 0x80,
  765. WIRELESS_MODE_AC_ONLY = 0x100,
  766. WIRELESS_MODE_MAX = 0x800
  767. };
  768. #define IS_WIRELESS_MODE_A(wirelessmode) \
  769. (wirelessmode == WIRELESS_MODE_A)
  770. #define IS_WIRELESS_MODE_B(wirelessmode) \
  771. (wirelessmode == WIRELESS_MODE_B)
  772. #define IS_WIRELESS_MODE_G(wirelessmode) \
  773. (wirelessmode == WIRELESS_MODE_G)
  774. #define IS_WIRELESS_MODE_N_24G(wirelessmode) \
  775. (wirelessmode == WIRELESS_MODE_N_24G)
  776. #define IS_WIRELESS_MODE_N_5G(wirelessmode) \
  777. (wirelessmode == WIRELESS_MODE_N_5G)
  778. enum ratr_table_mode {
  779. RATR_INX_WIRELESS_NGB = 0,
  780. RATR_INX_WIRELESS_NG = 1,
  781. RATR_INX_WIRELESS_NB = 2,
  782. RATR_INX_WIRELESS_N = 3,
  783. RATR_INX_WIRELESS_GB = 4,
  784. RATR_INX_WIRELESS_G = 5,
  785. RATR_INX_WIRELESS_B = 6,
  786. RATR_INX_WIRELESS_MC = 7,
  787. RATR_INX_WIRELESS_A = 8,
  788. RATR_INX_WIRELESS_AC_5N = 8,
  789. RATR_INX_WIRELESS_AC_24N = 9,
  790. };
  791. enum rtl_link_state {
  792. MAC80211_NOLINK = 0,
  793. MAC80211_LINKING = 1,
  794. MAC80211_LINKED = 2,
  795. MAC80211_LINKED_SCANNING = 3,
  796. };
  797. enum act_category {
  798. ACT_CAT_QOS = 1,
  799. ACT_CAT_DLS = 2,
  800. ACT_CAT_BA = 3,
  801. ACT_CAT_HT = 7,
  802. ACT_CAT_WMM = 17,
  803. };
  804. enum ba_action {
  805. ACT_ADDBAREQ = 0,
  806. ACT_ADDBARSP = 1,
  807. ACT_DELBA = 2,
  808. };
  809. enum rt_polarity_ctl {
  810. RT_POLARITY_LOW_ACT = 0,
  811. RT_POLARITY_HIGH_ACT = 1,
  812. };
  813. /* After 8188E, we use V2 reason define. 88C/8723A use V1 reason. */
  814. enum fw_wow_reason_v2 {
  815. FW_WOW_V2_PTK_UPDATE_EVENT = 0x01,
  816. FW_WOW_V2_GTK_UPDATE_EVENT = 0x02,
  817. FW_WOW_V2_DISASSOC_EVENT = 0x04,
  818. FW_WOW_V2_DEAUTH_EVENT = 0x08,
  819. FW_WOW_V2_FW_DISCONNECT_EVENT = 0x10,
  820. FW_WOW_V2_MAGIC_PKT_EVENT = 0x21,
  821. FW_WOW_V2_UNICAST_PKT_EVENT = 0x22,
  822. FW_WOW_V2_PATTERN_PKT_EVENT = 0x23,
  823. FW_WOW_V2_RTD3_SSID_MATCH_EVENT = 0x24,
  824. FW_WOW_V2_REALWOW_V2_WAKEUPPKT = 0x30,
  825. FW_WOW_V2_REALWOW_V2_ACKLOST = 0x31,
  826. FW_WOW_V2_REASON_MAX = 0xff,
  827. };
  828. enum wolpattern_type {
  829. UNICAST_PATTERN = 0,
  830. MULTICAST_PATTERN = 1,
  831. BROADCAST_PATTERN = 2,
  832. DONT_CARE_DA = 3,
  833. UNKNOWN_TYPE = 4,
  834. };
  835. enum package_type {
  836. PACKAGE_DEFAULT,
  837. PACKAGE_QFN68,
  838. PACKAGE_TFBGA90,
  839. PACKAGE_TFBGA80,
  840. PACKAGE_TFBGA79
  841. };
  842. struct octet_string {
  843. u8 *octet;
  844. u16 length;
  845. };
  846. struct rtl_hdr_3addr {
  847. __le16 frame_ctl;
  848. __le16 duration_id;
  849. u8 addr1[ETH_ALEN];
  850. u8 addr2[ETH_ALEN];
  851. u8 addr3[ETH_ALEN];
  852. __le16 seq_ctl;
  853. u8 payload[0];
  854. } __packed;
  855. struct rtl_info_element {
  856. u8 id;
  857. u8 len;
  858. u8 data[0];
  859. } __packed;
  860. struct rtl_probe_rsp {
  861. struct rtl_hdr_3addr header;
  862. u32 time_stamp[2];
  863. __le16 beacon_interval;
  864. __le16 capability;
  865. /*SSID, supported rates, FH params, DS params,
  866. CF params, IBSS params, TIM (if beacon), RSN */
  867. struct rtl_info_element info_element[0];
  868. } __packed;
  869. /*LED related.*/
  870. /*ledpin Identify how to implement this SW led.*/
  871. struct rtl_led {
  872. void *hw;
  873. enum rtl_led_pin ledpin;
  874. bool ledon;
  875. };
  876. struct rtl_led_ctl {
  877. bool led_opendrain;
  878. struct rtl_led sw_led0;
  879. struct rtl_led sw_led1;
  880. };
  881. struct rtl_qos_parameters {
  882. __le16 cw_min;
  883. __le16 cw_max;
  884. u8 aifs;
  885. u8 flag;
  886. __le16 tx_op;
  887. } __packed;
  888. struct rt_smooth_data {
  889. u32 elements[100]; /*array to store values */
  890. u32 index; /*index to current array to store */
  891. u32 total_num; /*num of valid elements */
  892. u32 total_val; /*sum of valid elements */
  893. };
  894. struct false_alarm_statistics {
  895. u32 cnt_parity_fail;
  896. u32 cnt_rate_illegal;
  897. u32 cnt_crc8_fail;
  898. u32 cnt_mcs_fail;
  899. u32 cnt_fast_fsync_fail;
  900. u32 cnt_sb_search_fail;
  901. u32 cnt_ofdm_fail;
  902. u32 cnt_cck_fail;
  903. u32 cnt_all;
  904. u32 cnt_ofdm_cca;
  905. u32 cnt_cck_cca;
  906. u32 cnt_cca_all;
  907. u32 cnt_bw_usc;
  908. u32 cnt_bw_lsc;
  909. };
  910. struct init_gain {
  911. u8 xaagccore1;
  912. u8 xbagccore1;
  913. u8 xcagccore1;
  914. u8 xdagccore1;
  915. u8 cca;
  916. };
  917. struct wireless_stats {
  918. unsigned long txbytesunicast;
  919. unsigned long txbytesmulticast;
  920. unsigned long txbytesbroadcast;
  921. unsigned long rxbytesunicast;
  922. long rx_snr_db[4];
  923. /*Correct smoothed ss in Dbm, only used
  924. in driver to report real power now. */
  925. long recv_signal_power;
  926. long signal_quality;
  927. long last_sigstrength_inpercent;
  928. u32 rssi_calculate_cnt;
  929. u32 pwdb_all_cnt;
  930. /*Transformed, in dbm. Beautified signal
  931. strength for UI, not correct. */
  932. long signal_strength;
  933. u8 rx_rssi_percentage[4];
  934. u8 rx_evm_dbm[4];
  935. u8 rx_evm_percentage[2];
  936. u16 rx_cfo_short[4];
  937. u16 rx_cfo_tail[4];
  938. struct rt_smooth_data ui_rssi;
  939. struct rt_smooth_data ui_link_quality;
  940. };
  941. struct rate_adaptive {
  942. u8 rate_adaptive_disabled;
  943. u8 ratr_state;
  944. u16 reserve;
  945. u32 high_rssi_thresh_for_ra;
  946. u32 high2low_rssi_thresh_for_ra;
  947. u8 low2high_rssi_thresh_for_ra40m;
  948. u32 low_rssi_thresh_for_ra40m;
  949. u8 low2high_rssi_thresh_for_ra20m;
  950. u32 low_rssi_thresh_for_ra20m;
  951. u32 upper_rssi_threshold_ratr;
  952. u32 middleupper_rssi_threshold_ratr;
  953. u32 middle_rssi_threshold_ratr;
  954. u32 middlelow_rssi_threshold_ratr;
  955. u32 low_rssi_threshold_ratr;
  956. u32 ultralow_rssi_threshold_ratr;
  957. u32 low_rssi_threshold_ratr_40m;
  958. u32 low_rssi_threshold_ratr_20m;
  959. u8 ping_rssi_enable;
  960. u32 ping_rssi_ratr;
  961. u32 ping_rssi_thresh_for_ra;
  962. u32 last_ratr;
  963. u8 pre_ratr_state;
  964. u8 ldpc_thres;
  965. bool use_ldpc;
  966. bool lower_rts_rate;
  967. bool is_special_data;
  968. };
  969. struct regd_pair_mapping {
  970. u16 reg_dmnenum;
  971. u16 reg_5ghz_ctl;
  972. u16 reg_2ghz_ctl;
  973. };
  974. struct dynamic_primary_cca {
  975. u8 pricca_flag;
  976. u8 intf_flag;
  977. u8 intf_type;
  978. u8 dup_rts_flag;
  979. u8 monitor_flag;
  980. u8 ch_offset;
  981. u8 mf_state;
  982. };
  983. struct rtl_regulatory {
  984. s8 alpha2[2];
  985. u16 country_code;
  986. u16 max_power_level;
  987. u32 tp_scale;
  988. u16 current_rd;
  989. u16 current_rd_ext;
  990. int16_t power_limit;
  991. struct regd_pair_mapping *regpair;
  992. };
  993. struct rtl_rfkill {
  994. bool rfkill_state; /*0 is off, 1 is on */
  995. };
  996. /*for P2P PS**/
  997. #define P2P_MAX_NOA_NUM 2
  998. enum p2p_role {
  999. P2P_ROLE_DISABLE = 0,
  1000. P2P_ROLE_DEVICE = 1,
  1001. P2P_ROLE_CLIENT = 2,
  1002. P2P_ROLE_GO = 3
  1003. };
  1004. enum p2p_ps_state {
  1005. P2P_PS_DISABLE = 0,
  1006. P2P_PS_ENABLE = 1,
  1007. P2P_PS_SCAN = 2,
  1008. P2P_PS_SCAN_DONE = 3,
  1009. P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */
  1010. };
  1011. enum p2p_ps_mode {
  1012. P2P_PS_NONE = 0,
  1013. P2P_PS_CTWINDOW = 1,
  1014. P2P_PS_NOA = 2,
  1015. P2P_PS_MIX = 3, /* CTWindow and NoA */
  1016. };
  1017. struct rtl_p2p_ps_info {
  1018. enum p2p_ps_mode p2p_ps_mode; /* indicate p2p ps mode */
  1019. enum p2p_ps_state p2p_ps_state; /* indicate p2p ps state */
  1020. u8 noa_index; /* Identifies instance of Notice of Absence timing. */
  1021. /* Client traffic window. A period of time in TU after TBTT. */
  1022. u8 ctwindow;
  1023. u8 opp_ps; /* opportunistic power save. */
  1024. u8 noa_num; /* number of NoA descriptor in P2P IE. */
  1025. /* Count for owner, Type of client. */
  1026. u8 noa_count_type[P2P_MAX_NOA_NUM];
  1027. /* Max duration for owner, preferred or min acceptable duration
  1028. * for client.
  1029. */
  1030. u32 noa_duration[P2P_MAX_NOA_NUM];
  1031. /* Length of interval for owner, preferred or max acceptable intervali
  1032. * of client.
  1033. */
  1034. u32 noa_interval[P2P_MAX_NOA_NUM];
  1035. /* schedule in terms of the lower 4 bytes of the TSF timer. */
  1036. u32 noa_start_time[P2P_MAX_NOA_NUM];
  1037. };
  1038. struct p2p_ps_offload_t {
  1039. u8 offload_en:1;
  1040. u8 role:1; /* 1: Owner, 0: Client */
  1041. u8 ctwindow_en:1;
  1042. u8 noa0_en:1;
  1043. u8 noa1_en:1;
  1044. u8 allstasleep:1;
  1045. u8 discovery:1;
  1046. u8 reserved:1;
  1047. };
  1048. #define IQK_MATRIX_REG_NUM 8
  1049. #define IQK_MATRIX_SETTINGS_NUM (1 + 24 + 21)
  1050. struct iqk_matrix_regs {
  1051. bool iqk_done;
  1052. long value[1][IQK_MATRIX_REG_NUM];
  1053. };
  1054. struct phy_parameters {
  1055. u16 length;
  1056. u32 *pdata;
  1057. };
  1058. enum hw_param_tab_index {
  1059. PHY_REG_2T,
  1060. PHY_REG_1T,
  1061. PHY_REG_PG,
  1062. RADIOA_2T,
  1063. RADIOB_2T,
  1064. RADIOA_1T,
  1065. RADIOB_1T,
  1066. MAC_REG,
  1067. AGCTAB_2T,
  1068. AGCTAB_1T,
  1069. MAX_TAB
  1070. };
  1071. struct rtl_phy {
  1072. struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */
  1073. struct init_gain initgain_backup;
  1074. enum io_type current_io_type;
  1075. u8 rf_mode;
  1076. u8 rf_type;
  1077. u8 current_chan_bw;
  1078. u8 set_bwmode_inprogress;
  1079. u8 sw_chnl_inprogress;
  1080. u8 sw_chnl_stage;
  1081. u8 sw_chnl_step;
  1082. u8 current_channel;
  1083. u8 h2c_box_num;
  1084. u8 set_io_inprogress;
  1085. u8 lck_inprogress;
  1086. /* record for power tracking */
  1087. s32 reg_e94;
  1088. s32 reg_e9c;
  1089. s32 reg_ea4;
  1090. s32 reg_eac;
  1091. s32 reg_eb4;
  1092. s32 reg_ebc;
  1093. s32 reg_ec4;
  1094. s32 reg_ecc;
  1095. u8 rfpienable;
  1096. u8 reserve_0;
  1097. u16 reserve_1;
  1098. u32 reg_c04, reg_c08, reg_874;
  1099. u32 adda_backup[16];
  1100. u32 iqk_mac_backup[IQK_MAC_REG_NUM];
  1101. u32 iqk_bb_backup[10];
  1102. bool iqk_initialized;
  1103. bool rfpath_rx_enable[MAX_RF_PATH];
  1104. u8 reg_837;
  1105. /* Dual mac */
  1106. bool need_iqk;
  1107. struct iqk_matrix_regs iqk_matrix[IQK_MATRIX_SETTINGS_NUM];
  1108. bool rfpi_enable;
  1109. bool iqk_in_progress;
  1110. u8 pwrgroup_cnt;
  1111. u8 cck_high_power;
  1112. /* this is for 88E & 8723A */
  1113. u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16];
  1114. /* MAX_PG_GROUP groups of pwr diff by rates */
  1115. u32 mcs_offset[MAX_PG_GROUP][16];
  1116. u32 tx_power_by_rate_offset[TX_PWR_BY_RATE_NUM_BAND]
  1117. [TX_PWR_BY_RATE_NUM_RF]
  1118. [TX_PWR_BY_RATE_NUM_RF]
  1119. [TX_PWR_BY_RATE_NUM_SECTION];
  1120. u8 txpwr_by_rate_base_24g[TX_PWR_BY_RATE_NUM_RF]
  1121. [TX_PWR_BY_RATE_NUM_RF]
  1122. [MAX_BASE_NUM_IN_PHY_REG_PG_24G];
  1123. u8 txpwr_by_rate_base_5g[TX_PWR_BY_RATE_NUM_RF]
  1124. [TX_PWR_BY_RATE_NUM_RF]
  1125. [MAX_BASE_NUM_IN_PHY_REG_PG_5G];
  1126. u8 default_initialgain[4];
  1127. /* the current Tx power level */
  1128. u8 cur_cck_txpwridx;
  1129. u8 cur_ofdm24g_txpwridx;
  1130. u8 cur_bw20_txpwridx;
  1131. u8 cur_bw40_txpwridx;
  1132. s8 txpwr_limit_2_4g[MAX_REGULATION_NUM]
  1133. [MAX_2_4G_BANDWIDTH_NUM]
  1134. [MAX_RATE_SECTION_NUM]
  1135. [CHANNEL_MAX_NUMBER_2G]
  1136. [MAX_RF_PATH_NUM];
  1137. s8 txpwr_limit_5g[MAX_REGULATION_NUM]
  1138. [MAX_5G_BANDWIDTH_NUM]
  1139. [MAX_RATE_SECTION_NUM]
  1140. [CHANNEL_MAX_NUMBER_5G]
  1141. [MAX_RF_PATH_NUM];
  1142. u32 rfreg_chnlval[2];
  1143. bool apk_done;
  1144. u32 reg_rf3c[2]; /* pathA / pathB */
  1145. u32 backup_rf_0x1a;/*92ee*/
  1146. /* bfsync */
  1147. u8 framesync;
  1148. u32 framesync_c34;
  1149. u8 num_total_rfpath;
  1150. struct phy_parameters hwparam_tables[MAX_TAB];
  1151. u16 rf_pathmap;
  1152. u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/
  1153. enum rt_polarity_ctl polarity_ctl;
  1154. };
  1155. #define MAX_TID_COUNT 9
  1156. #define RTL_AGG_STOP 0
  1157. #define RTL_AGG_PROGRESS 1
  1158. #define RTL_AGG_START 2
  1159. #define RTL_AGG_OPERATIONAL 3
  1160. #define RTL_AGG_OFF 0
  1161. #define RTL_AGG_ON 1
  1162. #define RTL_RX_AGG_START 1
  1163. #define RTL_RX_AGG_STOP 0
  1164. #define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA 2
  1165. #define RTL_AGG_EMPTYING_HW_QUEUE_DELBA 3
  1166. struct rtl_ht_agg {
  1167. u16 txq_id;
  1168. u16 wait_for_ba;
  1169. u16 start_idx;
  1170. u64 bitmap;
  1171. u32 rate_n_flags;
  1172. u8 agg_state;
  1173. u8 rx_agg_state;
  1174. };
  1175. struct rssi_sta {
  1176. long undec_sm_pwdb;
  1177. long undec_sm_cck;
  1178. };
  1179. struct rtl_tid_data {
  1180. u16 seq_number;
  1181. struct rtl_ht_agg agg;
  1182. };
  1183. struct rtl_sta_info {
  1184. struct list_head list;
  1185. struct rtl_tid_data tids[MAX_TID_COUNT];
  1186. /* just used for ap adhoc or mesh*/
  1187. struct rssi_sta rssi_stat;
  1188. u16 wireless_mode;
  1189. u8 ratr_index;
  1190. u8 mimo_ps;
  1191. u8 mac_addr[ETH_ALEN];
  1192. } __packed;
  1193. struct rtl_priv;
  1194. struct rtl_io {
  1195. struct device *dev;
  1196. struct mutex bb_mutex;
  1197. /*PCI MEM map */
  1198. unsigned long pci_mem_end; /*shared mem end */
  1199. unsigned long pci_mem_start; /*shared mem start */
  1200. /*PCI IO map */
  1201. unsigned long pci_base_addr; /*device I/O address */
  1202. void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
  1203. void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
  1204. void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
  1205. void (*writeN_sync) (struct rtl_priv *rtlpriv, u32 addr, void *buf,
  1206. u16 len);
  1207. u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1208. u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1209. u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
  1210. };
  1211. struct rtl_mac {
  1212. u8 mac_addr[ETH_ALEN];
  1213. u8 mac80211_registered;
  1214. u8 beacon_enabled;
  1215. u32 tx_ss_num;
  1216. u32 rx_ss_num;
  1217. struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
  1218. struct ieee80211_hw *hw;
  1219. struct ieee80211_vif *vif;
  1220. enum nl80211_iftype opmode;
  1221. /*Probe Beacon management */
  1222. struct rtl_tid_data tids[MAX_TID_COUNT];
  1223. enum rtl_link_state link_state;
  1224. int n_channels;
  1225. int n_bitrates;
  1226. bool offchan_delay;
  1227. u8 p2p; /*using p2p role*/
  1228. bool p2p_in_use;
  1229. /*filters */
  1230. u32 rx_conf;
  1231. u16 rx_mgt_filter;
  1232. u16 rx_ctrl_filter;
  1233. u16 rx_data_filter;
  1234. bool act_scanning;
  1235. u8 cnt_after_linked;
  1236. bool skip_scan;
  1237. /* early mode */
  1238. /* skb wait queue */
  1239. struct sk_buff_head skb_waitq[MAX_TID_COUNT];
  1240. u8 ht_stbc_cap;
  1241. u8 ht_cur_stbc;
  1242. /*vht support*/
  1243. u8 vht_enable;
  1244. u8 bw_80;
  1245. u8 vht_cur_ldpc;
  1246. u8 vht_cur_stbc;
  1247. u8 vht_stbc_cap;
  1248. u8 vht_ldpc_cap;
  1249. /*RDG*/
  1250. bool rdg_en;
  1251. /*AP*/
  1252. u8 bssid[ETH_ALEN] __aligned(2);
  1253. u32 vendor;
  1254. u8 mcs[16]; /* 16 bytes mcs for HT rates. */
  1255. u32 basic_rates; /* b/g rates */
  1256. u8 ht_enable;
  1257. u8 sgi_40;
  1258. u8 sgi_20;
  1259. u8 bw_40;
  1260. u16 mode; /* wireless mode */
  1261. u8 slot_time;
  1262. u8 short_preamble;
  1263. u8 use_cts_protect;
  1264. u8 cur_40_prime_sc;
  1265. u8 cur_40_prime_sc_bk;
  1266. u8 cur_80_prime_sc;
  1267. u64 tsf;
  1268. u8 retry_short;
  1269. u8 retry_long;
  1270. u16 assoc_id;
  1271. bool hiddenssid;
  1272. /*IBSS*/
  1273. int beacon_interval;
  1274. /*AMPDU*/
  1275. u8 min_space_cfg; /*For Min spacing configurations */
  1276. u8 max_mss_density;
  1277. u8 current_ampdu_factor;
  1278. u8 current_ampdu_density;
  1279. /*QOS & EDCA */
  1280. struct ieee80211_tx_queue_params edca_param[RTL_MAC80211_NUM_QUEUE];
  1281. struct rtl_qos_parameters ac[AC_MAX];
  1282. /* counters */
  1283. u64 last_txok_cnt;
  1284. u64 last_rxok_cnt;
  1285. u32 last_bt_edca_ul;
  1286. u32 last_bt_edca_dl;
  1287. };
  1288. struct btdm_8723 {
  1289. bool all_off;
  1290. bool agc_table_en;
  1291. bool adc_back_off_on;
  1292. bool b2_ant_hid_en;
  1293. bool low_penalty_rate_adaptive;
  1294. bool rf_rx_lpf_shrink;
  1295. bool reject_aggre_pkt;
  1296. bool tra_tdma_on;
  1297. u8 tra_tdma_nav;
  1298. u8 tra_tdma_ant;
  1299. bool tdma_on;
  1300. u8 tdma_ant;
  1301. u8 tdma_nav;
  1302. u8 tdma_dac_swing;
  1303. u8 fw_dac_swing_lvl;
  1304. bool ps_tdma_on;
  1305. u8 ps_tdma_byte[5];
  1306. bool pta_on;
  1307. u32 val_0x6c0;
  1308. u32 val_0x6c8;
  1309. u32 val_0x6cc;
  1310. bool sw_dac_swing_on;
  1311. u32 sw_dac_swing_lvl;
  1312. u32 wlan_act_hi;
  1313. u32 wlan_act_lo;
  1314. u32 bt_retry_index;
  1315. bool dec_bt_pwr;
  1316. bool ignore_wlan_act;
  1317. };
  1318. struct bt_coexist_8723 {
  1319. u32 high_priority_tx;
  1320. u32 high_priority_rx;
  1321. u32 low_priority_tx;
  1322. u32 low_priority_rx;
  1323. u8 c2h_bt_info;
  1324. bool c2h_bt_info_req_sent;
  1325. bool c2h_bt_inquiry_page;
  1326. u32 bt_inq_page_start_time;
  1327. u8 bt_retry_cnt;
  1328. u8 c2h_bt_info_original;
  1329. u8 bt_inquiry_page_cnt;
  1330. struct btdm_8723 btdm;
  1331. };
  1332. struct rtl_hal {
  1333. struct ieee80211_hw *hw;
  1334. bool driver_is_goingto_unload;
  1335. bool up_first_time;
  1336. bool first_init;
  1337. bool being_init_adapter;
  1338. bool bbrf_ready;
  1339. bool mac_func_enable;
  1340. bool pre_edcca_enable;
  1341. struct bt_coexist_8723 hal_coex_8723;
  1342. enum intf_type interface;
  1343. u16 hw_type; /*92c or 92d or 92s and so on */
  1344. u8 ic_class;
  1345. u8 oem_id;
  1346. u32 version; /*version of chip */
  1347. u8 state; /*stop 0, start 1 */
  1348. u8 board_type;
  1349. u8 package_type;
  1350. u8 external_pa;
  1351. u8 pa_mode;
  1352. u8 pa_type_2g;
  1353. u8 pa_type_5g;
  1354. u8 lna_type_2g;
  1355. u8 lna_type_5g;
  1356. u8 external_pa_2g;
  1357. u8 external_lna_2g;
  1358. u8 external_pa_5g;
  1359. u8 external_lna_5g;
  1360. u8 type_glna;
  1361. u8 type_gpa;
  1362. u8 type_alna;
  1363. u8 type_apa;
  1364. u8 rfe_type;
  1365. /*firmware */
  1366. u32 fwsize;
  1367. u8 *pfirmware;
  1368. u16 fw_version;
  1369. u16 fw_subversion;
  1370. bool h2c_setinprogress;
  1371. u8 last_hmeboxnum;
  1372. bool fw_ready;
  1373. /*Reserve page start offset except beacon in TxQ. */
  1374. u8 fw_rsvdpage_startoffset;
  1375. u8 h2c_txcmd_seq;
  1376. u8 current_ra_rate;
  1377. /* FW Cmd IO related */
  1378. u16 fwcmd_iomap;
  1379. u32 fwcmd_ioparam;
  1380. bool set_fwcmd_inprogress;
  1381. u8 current_fwcmd_io;
  1382. struct p2p_ps_offload_t p2p_ps_offload;
  1383. bool fw_clk_change_in_progress;
  1384. bool allow_sw_to_change_hwclc;
  1385. u8 fw_ps_state;
  1386. /**/
  1387. bool driver_going2unload;
  1388. /*AMPDU init min space*/
  1389. u8 minspace_cfg; /*For Min spacing configurations */
  1390. /* Dual mac */
  1391. enum macphy_mode macphymode;
  1392. enum band_type current_bandtype; /* 0:2.4G, 1:5G */
  1393. enum band_type current_bandtypebackup;
  1394. enum band_type bandset;
  1395. /* dual MAC 0--Mac0 1--Mac1 */
  1396. u32 interfaceindex;
  1397. /* just for DualMac S3S4 */
  1398. u8 macphyctl_reg;
  1399. bool earlymode_enable;
  1400. u8 max_earlymode_num;
  1401. /* Dual mac*/
  1402. bool during_mac0init_radiob;
  1403. bool during_mac1init_radioa;
  1404. bool reloadtxpowerindex;
  1405. /* True if IMR or IQK have done
  1406. for 2.4G in scan progress */
  1407. bool load_imrandiqk_setting_for2g;
  1408. bool disable_amsdu_8k;
  1409. bool master_of_dmsp;
  1410. bool slave_of_dmsp;
  1411. u16 rx_tag;/*for 92ee*/
  1412. u8 rts_en;
  1413. /*for wowlan*/
  1414. bool wow_enable;
  1415. bool enter_pnp_sleep;
  1416. bool wake_from_pnp_sleep;
  1417. bool wow_enabled;
  1418. __kernel_time_t last_suspend_sec;
  1419. u32 wowlan_fwsize;
  1420. u8 *wowlan_firmware;
  1421. u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/
  1422. bool real_wow_v2_enable;
  1423. bool re_init_llt_table;
  1424. };
  1425. struct rtl_security {
  1426. /*default 0 */
  1427. bool use_sw_sec;
  1428. bool being_setkey;
  1429. bool use_defaultkey;
  1430. /*Encryption Algorithm for Unicast Packet */
  1431. enum rt_enc_alg pairwise_enc_algorithm;
  1432. /*Encryption Algorithm for Brocast/Multicast */
  1433. enum rt_enc_alg group_enc_algorithm;
  1434. /*Cam Entry Bitmap */
  1435. u32 hwsec_cam_bitmap;
  1436. u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN];
  1437. /*local Key buffer, indx 0 is for
  1438. pairwise key 1-4 is for agoup key. */
  1439. u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN];
  1440. u8 key_len[KEY_BUF_SIZE];
  1441. /*The pointer of Pairwise Key,
  1442. it always points to KeyBuf[4] */
  1443. u8 *pairwise_key;
  1444. };
  1445. #define ASSOCIATE_ENTRY_NUM 33
  1446. struct fast_ant_training {
  1447. u8 bssid[6];
  1448. u8 antsel_rx_keep_0;
  1449. u8 antsel_rx_keep_1;
  1450. u8 antsel_rx_keep_2;
  1451. u32 ant_sum[7];
  1452. u32 ant_cnt[7];
  1453. u32 ant_ave[7];
  1454. u8 fat_state;
  1455. u32 train_idx;
  1456. u8 antsel_a[ASSOCIATE_ENTRY_NUM];
  1457. u8 antsel_b[ASSOCIATE_ENTRY_NUM];
  1458. u8 antsel_c[ASSOCIATE_ENTRY_NUM];
  1459. u32 main_ant_sum[ASSOCIATE_ENTRY_NUM];
  1460. u32 aux_ant_sum[ASSOCIATE_ENTRY_NUM];
  1461. u32 main_ant_cnt[ASSOCIATE_ENTRY_NUM];
  1462. u32 aux_ant_cnt[ASSOCIATE_ENTRY_NUM];
  1463. u8 rx_idle_ant;
  1464. bool becomelinked;
  1465. };
  1466. struct dm_phy_dbg_info {
  1467. s8 rx_snrdb[4];
  1468. u64 num_qry_phy_status;
  1469. u64 num_qry_phy_status_cck;
  1470. u64 num_qry_phy_status_ofdm;
  1471. u16 num_qry_beacon_pkt;
  1472. u16 num_non_be_pkt;
  1473. s32 rx_evm[4];
  1474. };
  1475. struct rtl_dm {
  1476. /*PHY status for Dynamic Management */
  1477. long entry_min_undec_sm_pwdb;
  1478. long undec_sm_cck;
  1479. long undec_sm_pwdb; /*out dm */
  1480. long entry_max_undec_sm_pwdb;
  1481. s32 ofdm_pkt_cnt;
  1482. bool dm_initialgain_enable;
  1483. bool dynamic_txpower_enable;
  1484. bool current_turbo_edca;
  1485. bool is_any_nonbepkts; /*out dm */
  1486. bool is_cur_rdlstate;
  1487. bool txpower_trackinginit;
  1488. bool disable_framebursting;
  1489. bool cck_inch14;
  1490. bool txpower_tracking;
  1491. bool useramask;
  1492. bool rfpath_rxenable[4];
  1493. bool inform_fw_driverctrldm;
  1494. bool current_mrc_switch;
  1495. u8 txpowercount;
  1496. u8 powerindex_backup[6];
  1497. u8 thermalvalue_rxgain;
  1498. u8 thermalvalue_iqk;
  1499. u8 thermalvalue_lck;
  1500. u8 thermalvalue;
  1501. u8 last_dtp_lvl;
  1502. u8 thermalvalue_avg[AVG_THERMAL_NUM];
  1503. u8 thermalvalue_avg_index;
  1504. u8 tm_trigger;
  1505. bool done_txpower;
  1506. u8 dynamic_txhighpower_lvl; /*Tx high power level */
  1507. u8 dm_flag; /*Indicate each dynamic mechanism's status. */
  1508. u8 dm_flag_tmp;
  1509. u8 dm_type;
  1510. u8 dm_rssi_sel;
  1511. u8 txpower_track_control;
  1512. bool interrupt_migration;
  1513. bool disable_tx_int;
  1514. s8 ofdm_index[MAX_RF_PATH];
  1515. u8 default_ofdm_index;
  1516. u8 default_cck_index;
  1517. s8 cck_index;
  1518. s8 delta_power_index[MAX_RF_PATH];
  1519. s8 delta_power_index_last[MAX_RF_PATH];
  1520. s8 power_index_offset[MAX_RF_PATH];
  1521. s8 absolute_ofdm_swing_idx[MAX_RF_PATH];
  1522. s8 remnant_ofdm_swing_idx[MAX_RF_PATH];
  1523. s8 remnant_cck_idx;
  1524. bool modify_txagc_flag_path_a;
  1525. bool modify_txagc_flag_path_b;
  1526. bool one_entry_only;
  1527. struct dm_phy_dbg_info dbginfo;
  1528. /* Dynamic ATC switch */
  1529. bool atc_status;
  1530. bool large_cfo_hit;
  1531. bool is_freeze;
  1532. int cfo_tail[2];
  1533. int cfo_ave_pre;
  1534. int crystal_cap;
  1535. u8 cfo_threshold;
  1536. u32 packet_count;
  1537. u32 packet_count_pre;
  1538. u8 tx_rate;
  1539. /*88e tx power tracking*/
  1540. u8 swing_idx_ofdm[MAX_RF_PATH];
  1541. u8 swing_idx_ofdm_cur;
  1542. u8 swing_idx_ofdm_base[MAX_RF_PATH];
  1543. bool swing_flag_ofdm;
  1544. u8 swing_idx_cck;
  1545. u8 swing_idx_cck_cur;
  1546. u8 swing_idx_cck_base;
  1547. bool swing_flag_cck;
  1548. s8 swing_diff_2g;
  1549. s8 swing_diff_5g;
  1550. u8 delta_swing_table_idx_24gccka_p[DEL_SW_IDX_SZ];
  1551. u8 delta_swing_table_idx_24gccka_n[DEL_SW_IDX_SZ];
  1552. u8 delta_swing_table_idx_24gcckb_p[DEL_SW_IDX_SZ];
  1553. u8 delta_swing_table_idx_24gcckb_n[DEL_SW_IDX_SZ];
  1554. u8 delta_swing_table_idx_24ga_p[DEL_SW_IDX_SZ];
  1555. u8 delta_swing_table_idx_24ga_n[DEL_SW_IDX_SZ];
  1556. u8 delta_swing_table_idx_24gb_p[DEL_SW_IDX_SZ];
  1557. u8 delta_swing_table_idx_24gb_n[DEL_SW_IDX_SZ];
  1558. u8 delta_swing_table_idx_5ga_p[BAND_NUM][DEL_SW_IDX_SZ];
  1559. u8 delta_swing_table_idx_5ga_n[BAND_NUM][DEL_SW_IDX_SZ];
  1560. u8 delta_swing_table_idx_5gb_p[BAND_NUM][DEL_SW_IDX_SZ];
  1561. u8 delta_swing_table_idx_5gb_n[BAND_NUM][DEL_SW_IDX_SZ];
  1562. u8 delta_swing_table_idx_24ga_p_8188e[DEL_SW_IDX_SZ];
  1563. u8 delta_swing_table_idx_24ga_n_8188e[DEL_SW_IDX_SZ];
  1564. /* DMSP */
  1565. bool supp_phymode_switch;
  1566. /* DulMac */
  1567. struct fast_ant_training fat_table;
  1568. u8 resp_tx_path;
  1569. u8 path_sel;
  1570. u32 patha_sum;
  1571. u32 pathb_sum;
  1572. u32 patha_cnt;
  1573. u32 pathb_cnt;
  1574. u8 pre_channel;
  1575. u8 *p_channel;
  1576. u8 linked_interval;
  1577. u64 last_tx_ok_cnt;
  1578. u64 last_rx_ok_cnt;
  1579. };
  1580. #define EFUSE_MAX_LOGICAL_SIZE 512
  1581. struct rtl_efuse {
  1582. bool autoLoad_ok;
  1583. bool bootfromefuse;
  1584. u16 max_physical_size;
  1585. u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE];
  1586. u16 efuse_usedbytes;
  1587. u8 efuse_usedpercentage;
  1588. #ifdef EFUSE_REPG_WORKAROUND
  1589. bool efuse_re_pg_sec1flag;
  1590. u8 efuse_re_pg_data[8];
  1591. #endif
  1592. u8 autoload_failflag;
  1593. u8 autoload_status;
  1594. short epromtype;
  1595. u16 eeprom_vid;
  1596. u16 eeprom_did;
  1597. u16 eeprom_svid;
  1598. u16 eeprom_smid;
  1599. u8 eeprom_oemid;
  1600. u16 eeprom_channelplan;
  1601. u8 eeprom_version;
  1602. u8 board_type;
  1603. u8 external_pa;
  1604. u8 dev_addr[6];
  1605. u8 wowlan_enable;
  1606. u8 antenna_div_cfg;
  1607. u8 antenna_div_type;
  1608. bool txpwr_fromeprom;
  1609. u8 eeprom_crystalcap;
  1610. u8 eeprom_tssi[2];
  1611. u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */
  1612. u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX];
  1613. u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX];
  1614. u8 eeprom_chnlarea_txpwr_cck[MAX_RF_PATH][CHANNEL_GROUP_MAX_2G];
  1615. u8 eeprom_chnlarea_txpwr_ht40_1s[MAX_RF_PATH][CHANNEL_GROUP_MAX];
  1616. u8 eprom_chnl_txpwr_ht40_2sdf[MAX_RF_PATH][CHANNEL_GROUP_MAX];
  1617. u8 internal_pa_5g[2]; /* pathA / pathB */
  1618. u8 eeprom_c9;
  1619. u8 eeprom_cc;
  1620. /*For power group */
  1621. u8 eeprom_pwrgroup[2][3];
  1622. u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER];
  1623. u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER];
  1624. u8 txpwrlevel_cck[MAX_RF_PATH][CHANNEL_MAX_NUMBER_2G];
  1625. /*For HT 40MHZ pwr */
  1626. u8 txpwrlevel_ht40_1s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1627. /*For HT 40MHZ pwr */
  1628. u8 txpwrlevel_ht40_2s[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1629. /*--------------------------------------------------------*
  1630. * 8192CE\8192SE\8192DE\8723AE use the following 4 arrays,
  1631. * other ICs (8188EE\8723BE\8192EE\8812AE...)
  1632. * define new arrays in Windows code.
  1633. * BUT, in linux code, we use the same array for all ICs.
  1634. *
  1635. * The Correspondance relation between two arrays is:
  1636. * txpwr_cckdiff[][] == CCK_24G_Diff[][]
  1637. * txpwr_ht20diff[][] == BW20_24G_Diff[][]
  1638. * txpwr_ht40diff[][] == BW40_24G_Diff[][]
  1639. * txpwr_legacyhtdiff[][] == OFDM_24G_Diff[][]
  1640. *
  1641. * Sizes of these arrays are decided by the larger ones.
  1642. */
  1643. s8 txpwr_cckdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1644. s8 txpwr_ht20diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1645. s8 txpwr_ht40diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1646. s8 txpwr_legacyhtdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1647. u8 txpwr_5g_bw40base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
  1648. u8 txpwr_5g_bw80base[MAX_RF_PATH][CHANNEL_MAX_NUMBER_5G_80M];
  1649. s8 txpwr_5g_ofdmdiff[MAX_RF_PATH][MAX_TX_COUNT];
  1650. s8 txpwr_5g_bw20diff[MAX_RF_PATH][MAX_TX_COUNT];
  1651. s8 txpwr_5g_bw40diff[MAX_RF_PATH][MAX_TX_COUNT];
  1652. s8 txpwr_5g_bw80diff[MAX_RF_PATH][MAX_TX_COUNT];
  1653. u8 txpwr_safetyflag; /* Band edge enable flag */
  1654. u16 eeprom_txpowerdiff;
  1655. u8 legacy_httxpowerdiff; /* Legacy to HT rate power diff */
  1656. u8 antenna_txpwdiff[3];
  1657. u8 eeprom_regulatory;
  1658. u8 eeprom_thermalmeter;
  1659. u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */
  1660. u16 tssi_13dbm;
  1661. u8 crystalcap; /* CrystalCap. */
  1662. u8 delta_iqk;
  1663. u8 delta_lck;
  1664. u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */
  1665. bool apk_thermalmeterignore;
  1666. bool b1x1_recvcombine;
  1667. bool b1ss_support;
  1668. /*channel plan */
  1669. u8 channel_plan;
  1670. };
  1671. struct rtl_ps_ctl {
  1672. bool pwrdomain_protect;
  1673. bool in_powersavemode;
  1674. bool rfchange_inprogress;
  1675. bool swrf_processing;
  1676. bool hwradiooff;
  1677. /*
  1678. * just for PCIE ASPM
  1679. * If it supports ASPM, Offset[560h] = 0x40,
  1680. * otherwise Offset[560h] = 0x00.
  1681. * */
  1682. bool support_aspm;
  1683. bool support_backdoor;
  1684. /*for LPS */
  1685. enum rt_psmode dot11_psmode; /*Power save mode configured. */
  1686. bool swctrl_lps;
  1687. bool leisure_ps;
  1688. bool fwctrl_lps;
  1689. u8 fwctrl_psmode;
  1690. /*For Fw control LPS mode */
  1691. u8 reg_fwctrl_lps;
  1692. /*Record Fw PS mode status. */
  1693. bool fw_current_inpsmode;
  1694. u8 reg_max_lps_awakeintvl;
  1695. bool report_linked;
  1696. bool low_power_enable;/*for 32k*/
  1697. /*for IPS */
  1698. bool inactiveps;
  1699. u32 rfoff_reason;
  1700. /*RF OFF Level */
  1701. u32 cur_ps_level;
  1702. u32 reg_rfps_level;
  1703. /*just for PCIE ASPM */
  1704. u8 const_amdpci_aspm;
  1705. bool pwrdown_mode;
  1706. enum rf_pwrstate inactive_pwrstate;
  1707. enum rf_pwrstate rfpwr_state; /*cur power state */
  1708. /* for SW LPS*/
  1709. bool sw_ps_enabled;
  1710. bool state;
  1711. bool state_inap;
  1712. bool multi_buffered;
  1713. u16 nullfunc_seq;
  1714. unsigned int dtim_counter;
  1715. unsigned int sleep_ms;
  1716. unsigned long last_sleep_jiffies;
  1717. unsigned long last_awake_jiffies;
  1718. unsigned long last_delaylps_stamp_jiffies;
  1719. unsigned long last_dtim;
  1720. unsigned long last_beacon;
  1721. unsigned long last_action;
  1722. unsigned long last_slept;
  1723. /*For P2P PS */
  1724. struct rtl_p2p_ps_info p2p_ps_info;
  1725. u8 pwr_mode;
  1726. u8 smart_ps;
  1727. /* wake up on line */
  1728. u8 wo_wlan_mode;
  1729. u8 arp_offload_enable;
  1730. u8 gtk_offload_enable;
  1731. /* Used for WOL, indicates the reason for waking event.*/
  1732. u32 wakeup_reason;
  1733. /* Record the last waking time for comparison with setting key. */
  1734. u64 last_wakeup_time;
  1735. };
  1736. struct rtl_stats {
  1737. u8 psaddr[ETH_ALEN];
  1738. u32 mac_time[2];
  1739. s8 rssi;
  1740. u8 signal;
  1741. u8 noise;
  1742. u8 rate; /* hw desc rate */
  1743. u8 received_channel;
  1744. u8 control;
  1745. u8 mask;
  1746. u8 freq;
  1747. u16 len;
  1748. u64 tsf;
  1749. u32 beacon_time;
  1750. u8 nic_type;
  1751. u16 length;
  1752. u8 signalquality; /*in 0-100 index. */
  1753. /*
  1754. * Real power in dBm for this packet,
  1755. * no beautification and aggregation.
  1756. * */
  1757. s32 recvsignalpower;
  1758. s8 rxpower; /*in dBm Translate from PWdB */
  1759. u8 signalstrength; /*in 0-100 index. */
  1760. u16 hwerror:1;
  1761. u16 crc:1;
  1762. u16 icv:1;
  1763. u16 shortpreamble:1;
  1764. u16 antenna:1;
  1765. u16 decrypted:1;
  1766. u16 wakeup:1;
  1767. u32 timestamp_low;
  1768. u32 timestamp_high;
  1769. bool shift;
  1770. u8 rx_drvinfo_size;
  1771. u8 rx_bufshift;
  1772. bool isampdu;
  1773. bool isfirst_ampdu;
  1774. bool rx_is40Mhzpacket;
  1775. u8 rx_packet_bw;
  1776. u32 rx_pwdb_all;
  1777. u8 rx_mimo_signalstrength[4]; /*in 0~100 index */
  1778. s8 rx_mimo_signalquality[4];
  1779. u8 rx_mimo_evm_dbm[4];
  1780. u16 cfo_short[4]; /* per-path's Cfo_short */
  1781. u16 cfo_tail[4];
  1782. s8 rx_mimo_sig_qual[4];
  1783. u8 rx_pwr[4]; /* per-path's pwdb */
  1784. u8 rx_snr[4]; /* per-path's SNR */
  1785. u8 bandwidth;
  1786. u8 bt_coex_pwr_adjust;
  1787. bool packet_matchbssid;
  1788. bool is_cck;
  1789. bool is_ht;
  1790. bool packet_toself;
  1791. bool packet_beacon; /*for rssi */
  1792. s8 cck_adc_pwdb[4]; /*for rx path selection */
  1793. bool is_vht;
  1794. bool is_short_gi;
  1795. u8 vht_nss;
  1796. u8 packet_report_type;
  1797. u32 macid;
  1798. u8 wake_match;
  1799. u32 bt_rx_rssi_percentage;
  1800. u32 macid_valid_entry[2];
  1801. };
  1802. struct rt_link_detect {
  1803. /* count for roaming */
  1804. u32 bcn_rx_inperiod;
  1805. u32 roam_times;
  1806. u32 num_tx_in4period[4];
  1807. u32 num_rx_in4period[4];
  1808. u32 num_tx_inperiod;
  1809. u32 num_rx_inperiod;
  1810. bool busytraffic;
  1811. bool tx_busy_traffic;
  1812. bool rx_busy_traffic;
  1813. bool higher_busytraffic;
  1814. bool higher_busyrxtraffic;
  1815. u32 tidtx_in4period[MAX_TID_COUNT][4];
  1816. u32 tidtx_inperiod[MAX_TID_COUNT];
  1817. bool higher_busytxtraffic[MAX_TID_COUNT];
  1818. };
  1819. struct rtl_tcb_desc {
  1820. u8 packet_bw:2;
  1821. u8 multicast:1;
  1822. u8 broadcast:1;
  1823. u8 rts_stbc:1;
  1824. u8 rts_enable:1;
  1825. u8 cts_enable:1;
  1826. u8 rts_use_shortpreamble:1;
  1827. u8 rts_use_shortgi:1;
  1828. u8 rts_sc:1;
  1829. u8 rts_bw:1;
  1830. u8 rts_rate;
  1831. u8 use_shortgi:1;
  1832. u8 use_shortpreamble:1;
  1833. u8 use_driver_rate:1;
  1834. u8 disable_ratefallback:1;
  1835. u8 ratr_index;
  1836. u8 mac_id;
  1837. u8 hw_rate;
  1838. u8 last_inipkt:1;
  1839. u8 cmd_or_init:1;
  1840. u8 queue_index;
  1841. /* early mode */
  1842. u8 empkt_num;
  1843. /* The max value by HW */
  1844. u32 empkt_len[10];
  1845. bool tx_enable_sw_calc_duration;
  1846. };
  1847. struct rtl_wow_pattern {
  1848. u8 type;
  1849. u16 crc;
  1850. u32 mask[4];
  1851. };
  1852. struct rtl_hal_ops {
  1853. int (*init_sw_vars) (struct ieee80211_hw *hw);
  1854. void (*deinit_sw_vars) (struct ieee80211_hw *hw);
  1855. void (*read_chip_version)(struct ieee80211_hw *hw);
  1856. void (*read_eeprom_info) (struct ieee80211_hw *hw);
  1857. void (*interrupt_recognized) (struct ieee80211_hw *hw,
  1858. u32 *p_inta, u32 *p_intb);
  1859. int (*hw_init) (struct ieee80211_hw *hw);
  1860. void (*hw_disable) (struct ieee80211_hw *hw);
  1861. void (*hw_suspend) (struct ieee80211_hw *hw);
  1862. void (*hw_resume) (struct ieee80211_hw *hw);
  1863. void (*enable_interrupt) (struct ieee80211_hw *hw);
  1864. void (*disable_interrupt) (struct ieee80211_hw *hw);
  1865. int (*set_network_type) (struct ieee80211_hw *hw,
  1866. enum nl80211_iftype type);
  1867. void (*set_chk_bssid)(struct ieee80211_hw *hw,
  1868. bool check_bssid);
  1869. void (*set_bw_mode) (struct ieee80211_hw *hw,
  1870. enum nl80211_channel_type ch_type);
  1871. u8(*switch_channel) (struct ieee80211_hw *hw);
  1872. void (*set_qos) (struct ieee80211_hw *hw, int aci);
  1873. void (*set_bcn_reg) (struct ieee80211_hw *hw);
  1874. void (*set_bcn_intv) (struct ieee80211_hw *hw);
  1875. void (*update_interrupt_mask) (struct ieee80211_hw *hw,
  1876. u32 add_msr, u32 rm_msr);
  1877. void (*get_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
  1878. void (*set_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
  1879. void (*update_rate_tbl) (struct ieee80211_hw *hw,
  1880. struct ieee80211_sta *sta, u8 rssi_level);
  1881. void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc,
  1882. u8 *desc, u8 queue_index,
  1883. struct sk_buff *skb, dma_addr_t addr);
  1884. void (*update_rate_mask) (struct ieee80211_hw *hw, u8 rssi_level);
  1885. u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw,
  1886. u8 queue_index);
  1887. void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc,
  1888. u8 queue_index);
  1889. void (*fill_tx_desc) (struct ieee80211_hw *hw,
  1890. struct ieee80211_hdr *hdr, u8 *pdesc_tx,
  1891. u8 *pbd_desc_tx,
  1892. struct ieee80211_tx_info *info,
  1893. struct ieee80211_sta *sta,
  1894. struct sk_buff *skb, u8 hw_queue,
  1895. struct rtl_tcb_desc *ptcb_desc);
  1896. void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc,
  1897. u32 buffer_len, bool bIsPsPoll);
  1898. void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
  1899. bool firstseg, bool lastseg,
  1900. struct sk_buff *skb);
  1901. bool (*query_rx_desc) (struct ieee80211_hw *hw,
  1902. struct rtl_stats *stats,
  1903. struct ieee80211_rx_status *rx_status,
  1904. u8 *pdesc, struct sk_buff *skb);
  1905. void (*set_channel_access) (struct ieee80211_hw *hw);
  1906. bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
  1907. void (*dm_watchdog) (struct ieee80211_hw *hw);
  1908. void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
  1909. bool (*set_rf_power_state) (struct ieee80211_hw *hw,
  1910. enum rf_pwrstate rfpwr_state);
  1911. void (*led_control) (struct ieee80211_hw *hw,
  1912. enum led_ctl_mode ledaction);
  1913. void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
  1914. u8 desc_name, u8 *val);
  1915. u32 (*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
  1916. bool (*is_tx_desc_closed) (struct ieee80211_hw *hw,
  1917. u8 hw_queue, u16 index);
  1918. void (*tx_polling) (struct ieee80211_hw *hw, u8 hw_queue);
  1919. void (*enable_hw_sec) (struct ieee80211_hw *hw);
  1920. void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
  1921. u8 *macaddr, bool is_group, u8 enc_algo,
  1922. bool is_wepkey, bool clear_all);
  1923. void (*init_sw_leds) (struct ieee80211_hw *hw);
  1924. void (*deinit_sw_leds) (struct ieee80211_hw *hw);
  1925. u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
  1926. void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
  1927. u32 data);
  1928. u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
  1929. u32 regaddr, u32 bitmask);
  1930. void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
  1931. u32 regaddr, u32 bitmask, u32 data);
  1932. void (*linked_set_reg) (struct ieee80211_hw *hw);
  1933. void (*chk_switch_dmdp) (struct ieee80211_hw *hw);
  1934. void (*dualmac_easy_concurrent) (struct ieee80211_hw *hw);
  1935. void (*dualmac_switch_to_dmdp) (struct ieee80211_hw *hw);
  1936. bool (*phy_rf6052_config) (struct ieee80211_hw *hw);
  1937. void (*phy_rf6052_set_cck_txpower) (struct ieee80211_hw *hw,
  1938. u8 *powerlevel);
  1939. void (*phy_rf6052_set_ofdm_txpower) (struct ieee80211_hw *hw,
  1940. u8 *ppowerlevel, u8 channel);
  1941. bool (*config_bb_with_headerfile) (struct ieee80211_hw *hw,
  1942. u8 configtype);
  1943. bool (*config_bb_with_pgheaderfile) (struct ieee80211_hw *hw,
  1944. u8 configtype);
  1945. void (*phy_lc_calibrate) (struct ieee80211_hw *hw, bool is2t);
  1946. void (*phy_set_bw_mode_callback) (struct ieee80211_hw *hw);
  1947. void (*dm_dynamic_txpower) (struct ieee80211_hw *hw);
  1948. void (*c2h_command_handle) (struct ieee80211_hw *hw);
  1949. void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw,
  1950. bool mstate);
  1951. void (*bt_coex_off_before_lps) (struct ieee80211_hw *hw);
  1952. void (*fill_h2c_cmd) (struct ieee80211_hw *hw, u8 element_id,
  1953. u32 cmd_len, u8 *p_cmdbuffer);
  1954. bool (*get_btc_status) (void);
  1955. bool (*is_fw_header)(struct rtlwifi_firmware_header *hdr);
  1956. u32 (*rx_command_packet)(struct ieee80211_hw *hw,
  1957. const struct rtl_stats *status, struct sk_buff *skb);
  1958. void (*add_wowlan_pattern)(struct ieee80211_hw *hw,
  1959. struct rtl_wow_pattern *rtl_pattern,
  1960. u8 index);
  1961. u16 (*get_available_desc)(struct ieee80211_hw *hw, u8 q_idx);
  1962. void (*c2h_content_parsing)(struct ieee80211_hw *hw, u8 tag, u8 len,
  1963. u8 *val);
  1964. };
  1965. struct rtl_intf_ops {
  1966. /*com */
  1967. void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
  1968. int (*adapter_start) (struct ieee80211_hw *hw);
  1969. void (*adapter_stop) (struct ieee80211_hw *hw);
  1970. bool (*check_buddy_priv)(struct ieee80211_hw *hw,
  1971. struct rtl_priv **buddy_priv);
  1972. int (*adapter_tx) (struct ieee80211_hw *hw,
  1973. struct ieee80211_sta *sta,
  1974. struct sk_buff *skb,
  1975. struct rtl_tcb_desc *ptcb_desc);
  1976. void (*flush)(struct ieee80211_hw *hw, u32 queues, bool drop);
  1977. int (*reset_trx_ring) (struct ieee80211_hw *hw);
  1978. bool (*waitq_insert) (struct ieee80211_hw *hw,
  1979. struct ieee80211_sta *sta,
  1980. struct sk_buff *skb);
  1981. /*pci */
  1982. void (*disable_aspm) (struct ieee80211_hw *hw);
  1983. void (*enable_aspm) (struct ieee80211_hw *hw);
  1984. /*usb */
  1985. };
  1986. struct rtl_mod_params {
  1987. /* default: 0,0 */
  1988. u64 debug_mask;
  1989. /* default: 0 = using hardware encryption */
  1990. bool sw_crypto;
  1991. /* default: 0 = DBG_EMERG (0)*/
  1992. int debug_level;
  1993. /* default: 1 = using no linked power save */
  1994. bool inactiveps;
  1995. /* default: 1 = using linked sw power save */
  1996. bool swctrl_lps;
  1997. /* default: 1 = using linked fw power save */
  1998. bool fwctrl_lps;
  1999. /* default: 0 = not using MSI interrupts mode
  2000. * submodules should set their own default value
  2001. */
  2002. bool msi_support;
  2003. /* default 0: 1 means disable */
  2004. bool disable_watchdog;
  2005. /* default 0: 1 means do not disable interrupts */
  2006. bool int_clear;
  2007. /* select antenna */
  2008. int ant_sel;
  2009. };
  2010. struct rtl_hal_usbint_cfg {
  2011. /* data - rx */
  2012. u32 in_ep_num;
  2013. u32 rx_urb_num;
  2014. u32 rx_max_size;
  2015. /* op - rx */
  2016. void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
  2017. void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
  2018. struct sk_buff_head *);
  2019. /* tx */
  2020. void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
  2021. int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
  2022. struct sk_buff *);
  2023. struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
  2024. struct sk_buff_head *);
  2025. /* endpoint mapping */
  2026. int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
  2027. u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
  2028. };
  2029. struct rtl_hal_cfg {
  2030. u8 bar_id;
  2031. bool write_readback;
  2032. char *name;
  2033. char *alt_fw_name;
  2034. struct rtl_hal_ops *ops;
  2035. struct rtl_mod_params *mod_params;
  2036. struct rtl_hal_usbint_cfg *usb_interface_cfg;
  2037. /*this map used for some registers or vars
  2038. defined int HAL but used in MAIN */
  2039. u32 maps[RTL_VAR_MAP_MAX];
  2040. };
  2041. struct rtl_locks {
  2042. /* mutex */
  2043. struct mutex conf_mutex;
  2044. struct mutex ps_mutex;
  2045. /*spin lock */
  2046. spinlock_t ips_lock;
  2047. spinlock_t irq_th_lock;
  2048. spinlock_t irq_pci_lock;
  2049. spinlock_t tx_lock;
  2050. spinlock_t h2c_lock;
  2051. spinlock_t rf_ps_lock;
  2052. spinlock_t rf_lock;
  2053. spinlock_t lps_lock;
  2054. spinlock_t waitq_lock;
  2055. spinlock_t entry_list_lock;
  2056. spinlock_t usb_lock;
  2057. spinlock_t c2hcmd_lock;
  2058. /*FW clock change */
  2059. spinlock_t fw_ps_lock;
  2060. /*Dual mac*/
  2061. spinlock_t cck_and_rw_pagea_lock;
  2062. /*Easy concurrent*/
  2063. spinlock_t check_sendpkt_lock;
  2064. spinlock_t iqk_lock;
  2065. };
  2066. struct rtl_works {
  2067. struct ieee80211_hw *hw;
  2068. /*timer */
  2069. struct timer_list watchdog_timer;
  2070. struct timer_list dualmac_easyconcurrent_retrytimer;
  2071. struct timer_list fw_clockoff_timer;
  2072. struct timer_list fast_antenna_training_timer;
  2073. /*task */
  2074. struct tasklet_struct irq_tasklet;
  2075. struct tasklet_struct irq_prepare_bcn_tasklet;
  2076. /*work queue */
  2077. struct workqueue_struct *rtl_wq;
  2078. struct delayed_work watchdog_wq;
  2079. struct delayed_work ips_nic_off_wq;
  2080. struct delayed_work c2hcmd_wq;
  2081. /* For SW LPS */
  2082. struct delayed_work ps_work;
  2083. struct delayed_work ps_rfon_wq;
  2084. struct delayed_work fwevt_wq;
  2085. struct work_struct lps_change_work;
  2086. struct work_struct fill_h2c_cmd;
  2087. };
  2088. #define MIMO_PS_STATIC 0
  2089. #define MIMO_PS_DYNAMIC 1
  2090. #define MIMO_PS_NOLIMIT 3
  2091. struct rtl_dualmac_easy_concurrent_ctl {
  2092. enum band_type currentbandtype_backfordmdp;
  2093. bool close_bbandrf_for_dmsp;
  2094. bool change_to_dmdp;
  2095. bool change_to_dmsp;
  2096. bool switch_in_process;
  2097. };
  2098. struct rtl_dmsp_ctl {
  2099. bool activescan_for_slaveofdmsp;
  2100. bool scan_for_anothermac_fordmsp;
  2101. bool scan_for_itself_fordmsp;
  2102. bool writedig_for_anothermacofdmsp;
  2103. u32 curdigvalue_for_anothermacofdmsp;
  2104. bool changecckpdstate_for_anothermacofdmsp;
  2105. u8 curcckpdstate_for_anothermacofdmsp;
  2106. bool changetxhighpowerlvl_for_anothermacofdmsp;
  2107. u8 curtxhighlvl_for_anothermacofdmsp;
  2108. long rssivalmin_for_anothermacofdmsp;
  2109. };
  2110. struct ps_t {
  2111. u8 pre_ccastate;
  2112. u8 cur_ccasate;
  2113. u8 pre_rfstate;
  2114. u8 cur_rfstate;
  2115. u8 initialize;
  2116. long rssi_val_min;
  2117. };
  2118. struct dig_t {
  2119. u32 rssi_lowthresh;
  2120. u32 rssi_highthresh;
  2121. u32 fa_lowthresh;
  2122. u32 fa_highthresh;
  2123. long last_min_undec_pwdb_for_dm;
  2124. long rssi_highpower_lowthresh;
  2125. long rssi_highpower_highthresh;
  2126. u32 recover_cnt;
  2127. u32 pre_igvalue;
  2128. u32 cur_igvalue;
  2129. long rssi_val;
  2130. u8 dig_enable_flag;
  2131. u8 dig_ext_port_stage;
  2132. u8 dig_algorithm;
  2133. u8 dig_twoport_algorithm;
  2134. u8 dig_dbgmode;
  2135. u8 dig_slgorithm_switch;
  2136. u8 cursta_cstate;
  2137. u8 presta_cstate;
  2138. u8 curmultista_cstate;
  2139. u8 stop_dig;
  2140. s8 back_val;
  2141. s8 back_range_max;
  2142. s8 back_range_min;
  2143. u8 rx_gain_max;
  2144. u8 rx_gain_min;
  2145. u8 min_undec_pwdb_for_dm;
  2146. u8 rssi_val_min;
  2147. u8 pre_cck_cca_thres;
  2148. u8 cur_cck_cca_thres;
  2149. u8 pre_cck_pd_state;
  2150. u8 cur_cck_pd_state;
  2151. u8 pre_cck_fa_state;
  2152. u8 cur_cck_fa_state;
  2153. u8 pre_ccastate;
  2154. u8 cur_ccasate;
  2155. u8 large_fa_hit;
  2156. u8 forbidden_igi;
  2157. u8 dig_state;
  2158. u8 dig_highpwrstate;
  2159. u8 cur_sta_cstate;
  2160. u8 pre_sta_cstate;
  2161. u8 cur_ap_cstate;
  2162. u8 pre_ap_cstate;
  2163. u8 cur_pd_thstate;
  2164. u8 pre_pd_thstate;
  2165. u8 cur_cs_ratiostate;
  2166. u8 pre_cs_ratiostate;
  2167. u8 backoff_enable_flag;
  2168. s8 backoffval_range_max;
  2169. s8 backoffval_range_min;
  2170. u8 dig_min_0;
  2171. u8 dig_min_1;
  2172. u8 bt30_cur_igi;
  2173. bool media_connect_0;
  2174. bool media_connect_1;
  2175. u32 antdiv_rssi_max;
  2176. u32 rssi_max;
  2177. };
  2178. struct rtl_global_var {
  2179. /* from this list we can get
  2180. * other adapter's rtl_priv */
  2181. struct list_head glb_priv_list;
  2182. spinlock_t glb_list_lock;
  2183. };
  2184. struct rtl_btc_info {
  2185. u8 bt_type;
  2186. u8 btcoexist;
  2187. u8 ant_num;
  2188. u8 single_ant_path;
  2189. };
  2190. struct bt_coexist_info {
  2191. struct rtl_btc_ops *btc_ops;
  2192. struct rtl_btc_info btc_info;
  2193. /* EEPROM BT info. */
  2194. u8 eeprom_bt_coexist;
  2195. u8 eeprom_bt_type;
  2196. u8 eeprom_bt_ant_num;
  2197. u8 eeprom_bt_ant_isol;
  2198. u8 eeprom_bt_radio_shared;
  2199. u8 bt_coexistence;
  2200. u8 bt_ant_num;
  2201. u8 bt_coexist_type;
  2202. u8 bt_state;
  2203. u8 bt_cur_state; /* 0:on, 1:off */
  2204. u8 bt_ant_isolation; /* 0:good, 1:bad */
  2205. u8 bt_pape_ctrl; /* 0:SW, 1:SW/HW dynamic */
  2206. u8 bt_service;
  2207. u8 bt_radio_shared_type;
  2208. u8 bt_rfreg_origin_1e;
  2209. u8 bt_rfreg_origin_1f;
  2210. u8 bt_rssi_state;
  2211. u32 ratio_tx;
  2212. u32 ratio_pri;
  2213. u32 bt_edca_ul;
  2214. u32 bt_edca_dl;
  2215. bool init_set;
  2216. bool bt_busy_traffic;
  2217. bool bt_traffic_mode_set;
  2218. bool bt_non_traffic_mode_set;
  2219. bool fw_coexist_all_off;
  2220. bool sw_coexist_all_off;
  2221. bool hw_coexist_all_off;
  2222. u32 cstate;
  2223. u32 previous_state;
  2224. u32 cstate_h;
  2225. u32 previous_state_h;
  2226. u8 bt_pre_rssi_state;
  2227. u8 bt_pre_rssi_state1;
  2228. u8 reg_bt_iso;
  2229. u8 reg_bt_sco;
  2230. bool balance_on;
  2231. u8 bt_active_zero_cnt;
  2232. bool cur_bt_disabled;
  2233. bool pre_bt_disabled;
  2234. u8 bt_profile_case;
  2235. u8 bt_profile_action;
  2236. bool bt_busy;
  2237. bool hold_for_bt_operation;
  2238. u8 lps_counter;
  2239. };
  2240. struct rtl_btc_ops {
  2241. void (*btc_init_variables) (struct rtl_priv *rtlpriv);
  2242. void (*btc_init_hal_vars) (struct rtl_priv *rtlpriv);
  2243. void (*btc_init_hw_config) (struct rtl_priv *rtlpriv);
  2244. void (*btc_ips_notify) (struct rtl_priv *rtlpriv, u8 type);
  2245. void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type);
  2246. void (*btc_scan_notify) (struct rtl_priv *rtlpriv, u8 scantype);
  2247. void (*btc_connect_notify) (struct rtl_priv *rtlpriv, u8 action);
  2248. void (*btc_mediastatus_notify) (struct rtl_priv *rtlpriv,
  2249. enum rt_media_status mstatus);
  2250. void (*btc_periodical) (struct rtl_priv *rtlpriv);
  2251. void (*btc_halt_notify) (void);
  2252. void (*btc_btinfo_notify) (struct rtl_priv *rtlpriv,
  2253. u8 *tmp_buf, u8 length);
  2254. bool (*btc_is_limited_dig) (struct rtl_priv *rtlpriv);
  2255. bool (*btc_is_disable_edca_turbo) (struct rtl_priv *rtlpriv);
  2256. bool (*btc_is_bt_disabled) (struct rtl_priv *rtlpriv);
  2257. void (*btc_special_packet_notify)(struct rtl_priv *rtlpriv,
  2258. u8 pkt_type);
  2259. };
  2260. struct proxim {
  2261. bool proxim_on;
  2262. void *proximity_priv;
  2263. int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status,
  2264. struct sk_buff *skb);
  2265. u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type);
  2266. };
  2267. struct rtl_c2hcmd {
  2268. struct list_head list;
  2269. u8 tag;
  2270. u8 len;
  2271. u8 *val;
  2272. };
  2273. struct rtl_priv {
  2274. struct ieee80211_hw *hw;
  2275. struct completion firmware_loading_complete;
  2276. struct list_head list;
  2277. struct rtl_priv *buddy_priv;
  2278. struct rtl_global_var *glb_var;
  2279. struct rtl_dualmac_easy_concurrent_ctl easy_concurrent_ctl;
  2280. struct rtl_dmsp_ctl dmsp_ctl;
  2281. struct rtl_locks locks;
  2282. struct rtl_works works;
  2283. struct rtl_mac mac80211;
  2284. struct rtl_hal rtlhal;
  2285. struct rtl_regulatory regd;
  2286. struct rtl_rfkill rfkill;
  2287. struct rtl_io io;
  2288. struct rtl_phy phy;
  2289. struct rtl_dm dm;
  2290. struct rtl_security sec;
  2291. struct rtl_efuse efuse;
  2292. struct rtl_led_ctl ledctl;
  2293. struct rtl_ps_ctl psc;
  2294. struct rate_adaptive ra;
  2295. struct dynamic_primary_cca primarycca;
  2296. struct wireless_stats stats;
  2297. struct rt_link_detect link_info;
  2298. struct false_alarm_statistics falsealm_cnt;
  2299. struct rtl_rate_priv *rate_priv;
  2300. /* sta entry list for ap adhoc or mesh */
  2301. struct list_head entry_list;
  2302. /* c2hcmd list for kthread level access */
  2303. struct list_head c2hcmd_list;
  2304. int max_fw_size;
  2305. /*
  2306. *hal_cfg : for diff cards
  2307. *intf_ops : for diff interrface usb/pcie
  2308. */
  2309. struct rtl_hal_cfg *cfg;
  2310. const struct rtl_intf_ops *intf_ops;
  2311. /*this var will be set by set_bit,
  2312. and was used to indicate status of
  2313. interface or hardware */
  2314. unsigned long status;
  2315. /* tables for dm */
  2316. struct dig_t dm_digtable;
  2317. struct ps_t dm_pstable;
  2318. u32 reg_874;
  2319. u32 reg_c70;
  2320. u32 reg_85c;
  2321. u32 reg_a74;
  2322. bool reg_init; /* true if regs saved */
  2323. bool bt_operation_on;
  2324. __le32 *usb_data;
  2325. int usb_data_index;
  2326. bool initialized;
  2327. bool enter_ps; /* true when entering PS */
  2328. u8 rate_mask[5];
  2329. /* intel Proximity, should be alloc mem
  2330. * in intel Proximity module and can only
  2331. * be used in intel Proximity mode
  2332. */
  2333. struct proxim proximity;
  2334. /*for bt coexist use*/
  2335. struct bt_coexist_info btcoexist;
  2336. /* separate 92ee from other ICs,
  2337. * 92ee use new trx flow.
  2338. */
  2339. bool use_new_trx_flow;
  2340. #ifdef CONFIG_PM
  2341. struct wiphy_wowlan_support wowlan;
  2342. #endif
  2343. /*This must be the last item so
  2344. that it points to the data allocated
  2345. beyond this structure like:
  2346. rtl_pci_priv or rtl_usb_priv */
  2347. u8 priv[0] __aligned(sizeof(void *));
  2348. };
  2349. #define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv))
  2350. #define rtl_mac(rtlpriv) (&((rtlpriv)->mac80211))
  2351. #define rtl_hal(rtlpriv) (&((rtlpriv)->rtlhal))
  2352. #define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse))
  2353. #define rtl_psc(rtlpriv) (&((rtlpriv)->psc))
  2354. /***************************************
  2355. Bluetooth Co-existence Related
  2356. ****************************************/
  2357. enum bt_ant_num {
  2358. ANT_X2 = 0,
  2359. ANT_X1 = 1,
  2360. };
  2361. enum bt_co_type {
  2362. BT_2WIRE = 0,
  2363. BT_ISSC_3WIRE = 1,
  2364. BT_ACCEL = 2,
  2365. BT_CSR_BC4 = 3,
  2366. BT_CSR_BC8 = 4,
  2367. BT_RTL8756 = 5,
  2368. BT_RTL8723A = 6,
  2369. BT_RTL8821A = 7,
  2370. BT_RTL8723B = 8,
  2371. BT_RTL8192E = 9,
  2372. BT_RTL8812A = 11,
  2373. };
  2374. enum bt_total_ant_num {
  2375. ANT_TOTAL_X2 = 0,
  2376. ANT_TOTAL_X1 = 1
  2377. };
  2378. enum bt_cur_state {
  2379. BT_OFF = 0,
  2380. BT_ON = 1,
  2381. };
  2382. enum bt_service_type {
  2383. BT_SCO = 0,
  2384. BT_A2DP = 1,
  2385. BT_HID = 2,
  2386. BT_HID_IDLE = 3,
  2387. BT_SCAN = 4,
  2388. BT_IDLE = 5,
  2389. BT_OTHER_ACTION = 6,
  2390. BT_BUSY = 7,
  2391. BT_OTHERBUSY = 8,
  2392. BT_PAN = 9,
  2393. };
  2394. enum bt_radio_shared {
  2395. BT_RADIO_SHARED = 0,
  2396. BT_RADIO_INDIVIDUAL = 1,
  2397. };
  2398. /****************************************
  2399. mem access macro define start
  2400. Call endian free function when
  2401. 1. Read/write packet content.
  2402. 2. Before write integer to IO.
  2403. 3. After read integer from IO.
  2404. ****************************************/
  2405. /* Convert little data endian to host ordering */
  2406. #define EF1BYTE(_val) \
  2407. ((u8)(_val))
  2408. #define EF2BYTE(_val) \
  2409. (le16_to_cpu(_val))
  2410. #define EF4BYTE(_val) \
  2411. (le32_to_cpu(_val))
  2412. /* Read data from memory */
  2413. #define READEF1BYTE(_ptr) \
  2414. EF1BYTE(*((u8 *)(_ptr)))
  2415. /* Read le16 data from memory and convert to host ordering */
  2416. #define READEF2BYTE(_ptr) \
  2417. EF2BYTE(*(_ptr))
  2418. #define READEF4BYTE(_ptr) \
  2419. EF4BYTE(*(_ptr))
  2420. /* Create a bit mask
  2421. * Examples:
  2422. * BIT_LEN_MASK_32(0) => 0x00000000
  2423. * BIT_LEN_MASK_32(1) => 0x00000001
  2424. * BIT_LEN_MASK_32(2) => 0x00000003
  2425. * BIT_LEN_MASK_32(32) => 0xFFFFFFFF
  2426. */
  2427. #define BIT_LEN_MASK_32(__bitlen) \
  2428. (0xFFFFFFFF >> (32 - (__bitlen)))
  2429. #define BIT_LEN_MASK_16(__bitlen) \
  2430. (0xFFFF >> (16 - (__bitlen)))
  2431. #define BIT_LEN_MASK_8(__bitlen) \
  2432. (0xFF >> (8 - (__bitlen)))
  2433. /* Create an offset bit mask
  2434. * Examples:
  2435. * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
  2436. * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
  2437. */
  2438. #define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
  2439. (BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
  2440. #define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \
  2441. (BIT_LEN_MASK_16(__bitlen) << (__bitoffset))
  2442. #define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \
  2443. (BIT_LEN_MASK_8(__bitlen) << (__bitoffset))
  2444. /*Description:
  2445. * Return 4-byte value in host byte ordering from
  2446. * 4-byte pointer in little-endian system.
  2447. */
  2448. #define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \
  2449. (EF4BYTE(*((__le32 *)(__pstart))))
  2450. #define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \
  2451. (EF2BYTE(*((__le16 *)(__pstart))))
  2452. #define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \
  2453. (EF1BYTE(*((u8 *)(__pstart))))
  2454. /*Description:
  2455. Translate subfield (continuous bits in little-endian) of 4-byte
  2456. value to host byte ordering.*/
  2457. #define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
  2458. ( \
  2459. (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \
  2460. BIT_LEN_MASK_32(__bitlen) \
  2461. )
  2462. #define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
  2463. ( \
  2464. (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \
  2465. BIT_LEN_MASK_16(__bitlen) \
  2466. )
  2467. #define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
  2468. ( \
  2469. (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
  2470. BIT_LEN_MASK_8(__bitlen) \
  2471. )
  2472. /* Description:
  2473. * Mask subfield (continuous bits in little-endian) of 4-byte value
  2474. * and return the result in 4-byte value in host byte ordering.
  2475. */
  2476. #define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
  2477. ( \
  2478. LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \
  2479. (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \
  2480. )
  2481. #define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
  2482. ( \
  2483. LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \
  2484. (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \
  2485. )
  2486. #define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
  2487. ( \
  2488. LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \
  2489. (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \
  2490. )
  2491. /* Description:
  2492. * Set subfield of little-endian 4-byte value to specified value.
  2493. */
  2494. #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2495. *((__le32 *)(__pstart)) = \
  2496. cpu_to_le32( \
  2497. LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
  2498. ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
  2499. );
  2500. #define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2501. *((__le16 *)(__pstart)) = \
  2502. cpu_to_le16( \
  2503. LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
  2504. ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
  2505. );
  2506. #define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
  2507. *((u8 *)(__pstart)) = EF1BYTE \
  2508. ( \
  2509. LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \
  2510. ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
  2511. );
  2512. #define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \
  2513. (__value) : (((__value + __aligment - 1) / __aligment) * __aligment))
  2514. /****************************************
  2515. mem access macro define end
  2516. ****************************************/
  2517. #define byte(x, n) ((x >> (8 * n)) & 0xff)
  2518. #define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC)
  2519. #define RTL_WATCH_DOG_TIME 2000
  2520. #define MSECS(t) msecs_to_jiffies(t)
  2521. #define WLAN_FC_GET_VERS(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_VERS)
  2522. #define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE)
  2523. #define WLAN_FC_GET_STYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE)
  2524. #define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA)
  2525. #define rtl_dm(rtlpriv) (&((rtlpriv)->dm))
  2526. #define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */
  2527. #define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */
  2528. #define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /*PCI D3 mode */
  2529. /*NIC halt, re-initialize hw parameters*/
  2530. #define RT_RF_OFF_LEVL_HALT_NIC BIT(3)
  2531. #define RT_RF_OFF_LEVL_FREE_FW BIT(4) /*FW free, re-download the FW */
  2532. #define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */
  2533. /*Always enable ASPM and Clock Req in initialization.*/
  2534. #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6)
  2535. /* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/
  2536. #define RT_PS_LEVEL_ASPM BIT(7)
  2537. /*When LPS is on, disable 2R if no packet is received or transmittd.*/
  2538. #define RT_RF_LPS_DISALBE_2R BIT(30)
  2539. #define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */
  2540. #define RT_IN_PS_LEVEL(ppsc, _ps_flg) \
  2541. ((ppsc->cur_ps_level & _ps_flg) ? true : false)
  2542. #define RT_CLEAR_PS_LEVEL(ppsc, _ps_flg) \
  2543. (ppsc->cur_ps_level &= (~(_ps_flg)))
  2544. #define RT_SET_PS_LEVEL(ppsc, _ps_flg) \
  2545. (ppsc->cur_ps_level |= _ps_flg)
  2546. #define container_of_dwork_rtl(x, y, z) \
  2547. container_of(to_delayed_work(x), y, z)
  2548. #define FILL_OCTET_STRING(_os, _octet, _len) \
  2549. (_os).octet = (u8 *)(_octet); \
  2550. (_os).length = (_len);
  2551. #define CP_MACADDR(des, src) \
  2552. ((des)[0] = (src)[0], (des)[1] = (src)[1],\
  2553. (des)[2] = (src)[2], (des)[3] = (src)[3],\
  2554. (des)[4] = (src)[4], (des)[5] = (src)[5])
  2555. #define LDPC_HT_ENABLE_RX BIT(0)
  2556. #define LDPC_HT_ENABLE_TX BIT(1)
  2557. #define LDPC_HT_TEST_TX_ENABLE BIT(2)
  2558. #define LDPC_HT_CAP_TX BIT(3)
  2559. #define STBC_HT_ENABLE_RX BIT(0)
  2560. #define STBC_HT_ENABLE_TX BIT(1)
  2561. #define STBC_HT_TEST_TX_ENABLE BIT(2)
  2562. #define STBC_HT_CAP_TX BIT(3)
  2563. #define LDPC_VHT_ENABLE_RX BIT(0)
  2564. #define LDPC_VHT_ENABLE_TX BIT(1)
  2565. #define LDPC_VHT_TEST_TX_ENABLE BIT(2)
  2566. #define LDPC_VHT_CAP_TX BIT(3)
  2567. #define STBC_VHT_ENABLE_RX BIT(0)
  2568. #define STBC_VHT_ENABLE_TX BIT(1)
  2569. #define STBC_VHT_TEST_TX_ENABLE BIT(2)
  2570. #define STBC_VHT_CAP_TX BIT(3)
  2571. extern u8 channel5g[CHANNEL_MAX_NUMBER_5G];
  2572. extern u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M];
  2573. static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr)
  2574. {
  2575. return rtlpriv->io.read8_sync(rtlpriv, addr);
  2576. }
  2577. static inline u16 rtl_read_word(struct rtl_priv *rtlpriv, u32 addr)
  2578. {
  2579. return rtlpriv->io.read16_sync(rtlpriv, addr);
  2580. }
  2581. static inline u32 rtl_read_dword(struct rtl_priv *rtlpriv, u32 addr)
  2582. {
  2583. return rtlpriv->io.read32_sync(rtlpriv, addr);
  2584. }
  2585. static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8)
  2586. {
  2587. rtlpriv->io.write8_async(rtlpriv, addr, val8);
  2588. if (rtlpriv->cfg->write_readback)
  2589. rtlpriv->io.read8_sync(rtlpriv, addr);
  2590. }
  2591. static inline void rtl_write_byte_with_val32(struct ieee80211_hw *hw,
  2592. u32 addr, u32 val8)
  2593. {
  2594. struct rtl_priv *rtlpriv = rtl_priv(hw);
  2595. rtl_write_byte(rtlpriv, addr, (u8)val8);
  2596. }
  2597. static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16)
  2598. {
  2599. rtlpriv->io.write16_async(rtlpriv, addr, val16);
  2600. if (rtlpriv->cfg->write_readback)
  2601. rtlpriv->io.read16_sync(rtlpriv, addr);
  2602. }
  2603. static inline void rtl_write_dword(struct rtl_priv *rtlpriv,
  2604. u32 addr, u32 val32)
  2605. {
  2606. rtlpriv->io.write32_async(rtlpriv, addr, val32);
  2607. if (rtlpriv->cfg->write_readback)
  2608. rtlpriv->io.read32_sync(rtlpriv, addr);
  2609. }
  2610. static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw,
  2611. u32 regaddr, u32 bitmask)
  2612. {
  2613. struct rtl_priv *rtlpriv = hw->priv;
  2614. return rtlpriv->cfg->ops->get_bbreg(hw, regaddr, bitmask);
  2615. }
  2616. static inline void rtl_set_bbreg(struct ieee80211_hw *hw, u32 regaddr,
  2617. u32 bitmask, u32 data)
  2618. {
  2619. struct rtl_priv *rtlpriv = hw->priv;
  2620. rtlpriv->cfg->ops->set_bbreg(hw, regaddr, bitmask, data);
  2621. }
  2622. static inline void rtl_set_bbreg_with_dwmask(struct ieee80211_hw *hw,
  2623. u32 regaddr, u32 data)
  2624. {
  2625. rtl_set_bbreg(hw, regaddr, 0xffffffff, data);
  2626. }
  2627. static inline u32 rtl_get_rfreg(struct ieee80211_hw *hw,
  2628. enum radio_path rfpath, u32 regaddr,
  2629. u32 bitmask)
  2630. {
  2631. struct rtl_priv *rtlpriv = hw->priv;
  2632. return rtlpriv->cfg->ops->get_rfreg(hw, rfpath, regaddr, bitmask);
  2633. }
  2634. static inline void rtl_set_rfreg(struct ieee80211_hw *hw,
  2635. enum radio_path rfpath, u32 regaddr,
  2636. u32 bitmask, u32 data)
  2637. {
  2638. struct rtl_priv *rtlpriv = hw->priv;
  2639. rtlpriv->cfg->ops->set_rfreg(hw, rfpath, regaddr, bitmask, data);
  2640. }
  2641. static inline bool is_hal_stop(struct rtl_hal *rtlhal)
  2642. {
  2643. return (_HAL_STATE_STOP == rtlhal->state);
  2644. }
  2645. static inline void set_hal_start(struct rtl_hal *rtlhal)
  2646. {
  2647. rtlhal->state = _HAL_STATE_START;
  2648. }
  2649. static inline void set_hal_stop(struct rtl_hal *rtlhal)
  2650. {
  2651. rtlhal->state = _HAL_STATE_STOP;
  2652. }
  2653. static inline u8 get_rf_type(struct rtl_phy *rtlphy)
  2654. {
  2655. return rtlphy->rf_type;
  2656. }
  2657. static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb)
  2658. {
  2659. return (struct ieee80211_hdr *)(skb->data);
  2660. }
  2661. static inline __le16 rtl_get_fc(struct sk_buff *skb)
  2662. {
  2663. return rtl_get_hdr(skb)->frame_control;
  2664. }
  2665. static inline u16 rtl_get_tid_h(struct ieee80211_hdr *hdr)
  2666. {
  2667. return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
  2668. }
  2669. static inline u16 rtl_get_tid(struct sk_buff *skb)
  2670. {
  2671. return rtl_get_tid_h(rtl_get_hdr(skb));
  2672. }
  2673. static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw,
  2674. struct ieee80211_vif *vif,
  2675. const u8 *bssid)
  2676. {
  2677. return ieee80211_find_sta(vif, bssid);
  2678. }
  2679. static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw,
  2680. u8 *mac_addr)
  2681. {
  2682. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  2683. return ieee80211_find_sta(mac->vif, mac_addr);
  2684. }
  2685. #endif