wifi.h 73 KB

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