wifi.h 72 KB

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