wifi.h 72 KB

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