wifi.h 72 KB

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