wifi.h 82 KB

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