main.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2018-2019 Realtek Corporation
  3. */
  4. #ifndef __RTK_MAIN_H_
  5. #define __RTK_MAIN_H_
  6. #include <net/mac80211.h>
  7. #include <linux/vmalloc.h>
  8. #include <linux/firmware.h>
  9. #include <linux/average.h>
  10. #include <linux/bitops.h>
  11. #include <linux/bitfield.h>
  12. #include <linux/iopoll.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/workqueue.h>
  15. #include "util.h"
  16. #define RTW_MAX_MAC_ID_NUM 32
  17. #define RTW_MAX_SEC_CAM_NUM 32
  18. #define MAX_PG_CAM_BACKUP_NUM 8
  19. #define RTW_SCAN_MAX_SSIDS 4
  20. #define RTW_MAX_PATTERN_NUM 12
  21. #define RTW_MAX_PATTERN_MASK_SIZE 16
  22. #define RTW_MAX_PATTERN_SIZE 128
  23. #define RTW_WATCH_DOG_DELAY_TIME round_jiffies_relative(HZ * 2)
  24. #define RFREG_MASK 0xfffff
  25. #define INV_RF_DATA 0xffffffff
  26. #define TX_PAGE_SIZE_SHIFT 7
  27. #define TX_PAGE_SIZE (1 << TX_PAGE_SIZE_SHIFT)
  28. #define RTW_CHANNEL_WIDTH_MAX 3
  29. #define RTW_RF_PATH_MAX 4
  30. #define HW_FEATURE_LEN 13
  31. #define RTW_TP_SHIFT 18 /* bytes/2s --> Mbps */
  32. extern bool rtw_bf_support;
  33. extern bool rtw_disable_lps_deep_mode;
  34. extern unsigned int rtw_debug_mask;
  35. extern bool rtw_edcca_enabled;
  36. extern const struct ieee80211_ops rtw_ops;
  37. #define RTW_MAX_CHANNEL_NUM_2G 14
  38. #define RTW_MAX_CHANNEL_NUM_5G 49
  39. struct rtw_dev;
  40. struct rtw_debugfs;
  41. enum rtw_hci_type {
  42. RTW_HCI_TYPE_PCIE,
  43. RTW_HCI_TYPE_USB,
  44. RTW_HCI_TYPE_SDIO,
  45. RTW_HCI_TYPE_UNDEFINE,
  46. };
  47. struct rtw_hci {
  48. const struct rtw_hci_ops *ops;
  49. enum rtw_hci_type type;
  50. u32 rpwm_addr;
  51. u32 cpwm_addr;
  52. u8 bulkout_num;
  53. };
  54. #define IS_CH_5G_BAND_1(channel) ((channel) >= 36 && (channel <= 48))
  55. #define IS_CH_5G_BAND_2(channel) ((channel) >= 52 && (channel <= 64))
  56. #define IS_CH_5G_BAND_3(channel) ((channel) >= 100 && (channel <= 144))
  57. #define IS_CH_5G_BAND_4(channel) ((channel) >= 149 && (channel <= 177))
  58. #define IS_CH_5G_BAND_MID(channel) \
  59. (IS_CH_5G_BAND_2(channel) || IS_CH_5G_BAND_3(channel))
  60. #define IS_CH_2G_BAND(channel) ((channel) <= 14)
  61. #define IS_CH_5G_BAND(channel) \
  62. (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel) || \
  63. IS_CH_5G_BAND_3(channel) || IS_CH_5G_BAND_4(channel))
  64. enum rtw_supported_band {
  65. RTW_BAND_2G = BIT(NL80211_BAND_2GHZ),
  66. RTW_BAND_5G = BIT(NL80211_BAND_5GHZ),
  67. RTW_BAND_60G = BIT(NL80211_BAND_60GHZ),
  68. };
  69. /* now, support up to 80M bw */
  70. #define RTW_MAX_CHANNEL_WIDTH RTW_CHANNEL_WIDTH_80
  71. enum rtw_bandwidth {
  72. RTW_CHANNEL_WIDTH_20 = 0,
  73. RTW_CHANNEL_WIDTH_40 = 1,
  74. RTW_CHANNEL_WIDTH_80 = 2,
  75. RTW_CHANNEL_WIDTH_160 = 3,
  76. RTW_CHANNEL_WIDTH_80_80 = 4,
  77. RTW_CHANNEL_WIDTH_5 = 5,
  78. RTW_CHANNEL_WIDTH_10 = 6,
  79. };
  80. enum rtw_sc_offset {
  81. RTW_SC_DONT_CARE = 0,
  82. RTW_SC_20_UPPER = 1,
  83. RTW_SC_20_LOWER = 2,
  84. RTW_SC_20_UPMOST = 3,
  85. RTW_SC_20_LOWEST = 4,
  86. RTW_SC_40_UPPER = 9,
  87. RTW_SC_40_LOWER = 10,
  88. };
  89. enum rtw_net_type {
  90. RTW_NET_NO_LINK = 0,
  91. RTW_NET_AD_HOC = 1,
  92. RTW_NET_MGD_LINKED = 2,
  93. RTW_NET_AP_MODE = 3,
  94. };
  95. enum rtw_rf_type {
  96. RF_1T1R = 0,
  97. RF_1T2R = 1,
  98. RF_2T2R = 2,
  99. RF_2T3R = 3,
  100. RF_2T4R = 4,
  101. RF_3T3R = 5,
  102. RF_3T4R = 6,
  103. RF_4T4R = 7,
  104. RF_TYPE_MAX,
  105. };
  106. enum rtw_rf_path {
  107. RF_PATH_A = 0,
  108. RF_PATH_B = 1,
  109. RF_PATH_C = 2,
  110. RF_PATH_D = 3,
  111. };
  112. enum rtw_bb_path {
  113. BB_PATH_A = BIT(0),
  114. BB_PATH_B = BIT(1),
  115. BB_PATH_C = BIT(2),
  116. BB_PATH_D = BIT(3),
  117. BB_PATH_AB = (BB_PATH_A | BB_PATH_B),
  118. BB_PATH_AC = (BB_PATH_A | BB_PATH_C),
  119. BB_PATH_AD = (BB_PATH_A | BB_PATH_D),
  120. BB_PATH_BC = (BB_PATH_B | BB_PATH_C),
  121. BB_PATH_BD = (BB_PATH_B | BB_PATH_D),
  122. BB_PATH_CD = (BB_PATH_C | BB_PATH_D),
  123. BB_PATH_ABC = (BB_PATH_A | BB_PATH_B | BB_PATH_C),
  124. BB_PATH_ABD = (BB_PATH_A | BB_PATH_B | BB_PATH_D),
  125. BB_PATH_ACD = (BB_PATH_A | BB_PATH_C | BB_PATH_D),
  126. BB_PATH_BCD = (BB_PATH_B | BB_PATH_C | BB_PATH_D),
  127. BB_PATH_ABCD = (BB_PATH_A | BB_PATH_B | BB_PATH_C | BB_PATH_D),
  128. };
  129. enum rtw_rate_section {
  130. RTW_RATE_SECTION_CCK = 0,
  131. RTW_RATE_SECTION_OFDM,
  132. RTW_RATE_SECTION_HT_1S,
  133. RTW_RATE_SECTION_HT_2S,
  134. RTW_RATE_SECTION_VHT_1S,
  135. RTW_RATE_SECTION_VHT_2S,
  136. __RTW_RATE_SECTION_2SS_MAX = RTW_RATE_SECTION_VHT_2S,
  137. RTW_RATE_SECTION_HT_3S,
  138. RTW_RATE_SECTION_HT_4S,
  139. RTW_RATE_SECTION_VHT_3S,
  140. RTW_RATE_SECTION_VHT_4S,
  141. /* keep last */
  142. RTW_RATE_SECTION_NUM,
  143. };
  144. enum rtw_wireless_set {
  145. WIRELESS_CCK = 0x00000001,
  146. WIRELESS_OFDM = 0x00000002,
  147. WIRELESS_HT = 0x00000004,
  148. WIRELESS_VHT = 0x00000008,
  149. };
  150. #define HT_STBC_EN BIT(0)
  151. #define VHT_STBC_EN BIT(1)
  152. #define HT_LDPC_EN BIT(0)
  153. #define VHT_LDPC_EN BIT(1)
  154. enum rtw_chip_type {
  155. RTW_CHIP_TYPE_8822B,
  156. RTW_CHIP_TYPE_8822C,
  157. RTW_CHIP_TYPE_8723D,
  158. RTW_CHIP_TYPE_8821C,
  159. RTW_CHIP_TYPE_8703B,
  160. RTW_CHIP_TYPE_8821A,
  161. RTW_CHIP_TYPE_8812A,
  162. RTW_CHIP_TYPE_8814A,
  163. };
  164. enum rtw_tx_queue_type {
  165. /* the order of AC queues matters */
  166. RTW_TX_QUEUE_BK = 0x0,
  167. RTW_TX_QUEUE_BE = 0x1,
  168. RTW_TX_QUEUE_VI = 0x2,
  169. RTW_TX_QUEUE_VO = 0x3,
  170. RTW_TX_QUEUE_BCN = 0x4,
  171. RTW_TX_QUEUE_MGMT = 0x5,
  172. RTW_TX_QUEUE_HI0 = 0x6,
  173. RTW_TX_QUEUE_H2C = 0x7,
  174. /* keep it last */
  175. RTK_MAX_TX_QUEUE_NUM
  176. };
  177. enum rtw_rx_queue_type {
  178. RTW_RX_QUEUE_MPDU = 0x0,
  179. RTW_RX_QUEUE_C2H = 0x1,
  180. /* keep it last */
  181. RTK_MAX_RX_QUEUE_NUM
  182. };
  183. enum rtw_fw_type {
  184. RTW_NORMAL_FW = 0x0,
  185. RTW_WOWLAN_FW = 0x1,
  186. };
  187. enum rtw_rate_index {
  188. RTW_RATEID_BGN_40M_2SS = 0,
  189. RTW_RATEID_BGN_40M_1SS = 1,
  190. RTW_RATEID_BGN_20M_2SS = 2,
  191. RTW_RATEID_BGN_20M_1SS = 3,
  192. RTW_RATEID_GN_N2SS = 4,
  193. RTW_RATEID_GN_N1SS = 5,
  194. RTW_RATEID_BG = 6,
  195. RTW_RATEID_G = 7,
  196. RTW_RATEID_B_20M = 8,
  197. RTW_RATEID_ARFR0_AC_2SS = 9,
  198. RTW_RATEID_ARFR1_AC_1SS = 10,
  199. RTW_RATEID_ARFR2_AC_2G_1SS = 11,
  200. RTW_RATEID_ARFR3_AC_2G_2SS = 12,
  201. RTW_RATEID_ARFR4_AC_3SS = 13,
  202. RTW_RATEID_ARFR5_N_3SS = 14,
  203. RTW_RATEID_ARFR7_N_4SS = 15,
  204. RTW_RATEID_ARFR6_AC_4SS = 16
  205. };
  206. enum rtw_trx_desc_rate {
  207. DESC_RATE1M = 0x00,
  208. DESC_RATE2M = 0x01,
  209. DESC_RATE5_5M = 0x02,
  210. DESC_RATE11M = 0x03,
  211. DESC_RATE6M = 0x04,
  212. DESC_RATE9M = 0x05,
  213. DESC_RATE12M = 0x06,
  214. DESC_RATE18M = 0x07,
  215. DESC_RATE24M = 0x08,
  216. DESC_RATE36M = 0x09,
  217. DESC_RATE48M = 0x0a,
  218. DESC_RATE54M = 0x0b,
  219. DESC_RATEMCS0 = 0x0c,
  220. DESC_RATEMCS1 = 0x0d,
  221. DESC_RATEMCS2 = 0x0e,
  222. DESC_RATEMCS3 = 0x0f,
  223. DESC_RATEMCS4 = 0x10,
  224. DESC_RATEMCS5 = 0x11,
  225. DESC_RATEMCS6 = 0x12,
  226. DESC_RATEMCS7 = 0x13,
  227. DESC_RATEMCS8 = 0x14,
  228. DESC_RATEMCS9 = 0x15,
  229. DESC_RATEMCS10 = 0x16,
  230. DESC_RATEMCS11 = 0x17,
  231. DESC_RATEMCS12 = 0x18,
  232. DESC_RATEMCS13 = 0x19,
  233. DESC_RATEMCS14 = 0x1a,
  234. DESC_RATEMCS15 = 0x1b,
  235. DESC_RATEMCS16 = 0x1c,
  236. DESC_RATEMCS17 = 0x1d,
  237. DESC_RATEMCS18 = 0x1e,
  238. DESC_RATEMCS19 = 0x1f,
  239. DESC_RATEMCS20 = 0x20,
  240. DESC_RATEMCS21 = 0x21,
  241. DESC_RATEMCS22 = 0x22,
  242. DESC_RATEMCS23 = 0x23,
  243. DESC_RATEMCS24 = 0x24,
  244. DESC_RATEMCS25 = 0x25,
  245. DESC_RATEMCS26 = 0x26,
  246. DESC_RATEMCS27 = 0x27,
  247. DESC_RATEMCS28 = 0x28,
  248. DESC_RATEMCS29 = 0x29,
  249. DESC_RATEMCS30 = 0x2a,
  250. DESC_RATEMCS31 = 0x2b,
  251. DESC_RATEVHT1SS_MCS0 = 0x2c,
  252. DESC_RATEVHT1SS_MCS1 = 0x2d,
  253. DESC_RATEVHT1SS_MCS2 = 0x2e,
  254. DESC_RATEVHT1SS_MCS3 = 0x2f,
  255. DESC_RATEVHT1SS_MCS4 = 0x30,
  256. DESC_RATEVHT1SS_MCS5 = 0x31,
  257. DESC_RATEVHT1SS_MCS6 = 0x32,
  258. DESC_RATEVHT1SS_MCS7 = 0x33,
  259. DESC_RATEVHT1SS_MCS8 = 0x34,
  260. DESC_RATEVHT1SS_MCS9 = 0x35,
  261. DESC_RATEVHT2SS_MCS0 = 0x36,
  262. DESC_RATEVHT2SS_MCS1 = 0x37,
  263. DESC_RATEVHT2SS_MCS2 = 0x38,
  264. DESC_RATEVHT2SS_MCS3 = 0x39,
  265. DESC_RATEVHT2SS_MCS4 = 0x3a,
  266. DESC_RATEVHT2SS_MCS5 = 0x3b,
  267. DESC_RATEVHT2SS_MCS6 = 0x3c,
  268. DESC_RATEVHT2SS_MCS7 = 0x3d,
  269. DESC_RATEVHT2SS_MCS8 = 0x3e,
  270. DESC_RATEVHT2SS_MCS9 = 0x3f,
  271. DESC_RATEVHT3SS_MCS0 = 0x40,
  272. DESC_RATEVHT3SS_MCS1 = 0x41,
  273. DESC_RATEVHT3SS_MCS2 = 0x42,
  274. DESC_RATEVHT3SS_MCS3 = 0x43,
  275. DESC_RATEVHT3SS_MCS4 = 0x44,
  276. DESC_RATEVHT3SS_MCS5 = 0x45,
  277. DESC_RATEVHT3SS_MCS6 = 0x46,
  278. DESC_RATEVHT3SS_MCS7 = 0x47,
  279. DESC_RATEVHT3SS_MCS8 = 0x48,
  280. DESC_RATEVHT3SS_MCS9 = 0x49,
  281. DESC_RATEVHT4SS_MCS0 = 0x4a,
  282. DESC_RATEVHT4SS_MCS1 = 0x4b,
  283. DESC_RATEVHT4SS_MCS2 = 0x4c,
  284. DESC_RATEVHT4SS_MCS3 = 0x4d,
  285. DESC_RATEVHT4SS_MCS4 = 0x4e,
  286. DESC_RATEVHT4SS_MCS5 = 0x4f,
  287. DESC_RATEVHT4SS_MCS6 = 0x50,
  288. DESC_RATEVHT4SS_MCS7 = 0x51,
  289. DESC_RATEVHT4SS_MCS8 = 0x52,
  290. DESC_RATEVHT4SS_MCS9 = 0x53,
  291. DESC_RATE_MAX,
  292. };
  293. enum rtw_regulatory_domains {
  294. RTW_REGD_FCC = 0,
  295. RTW_REGD_MKK = 1,
  296. RTW_REGD_ETSI = 2,
  297. RTW_REGD_IC = 3,
  298. RTW_REGD_KCC = 4,
  299. RTW_REGD_ACMA = 5,
  300. RTW_REGD_CHILE = 6,
  301. RTW_REGD_UKRAINE = 7,
  302. RTW_REGD_MEXICO = 8,
  303. RTW_REGD_CN = 9,
  304. RTW_REGD_QATAR = 10,
  305. RTW_REGD_UK = 11,
  306. RTW_REGD_WW,
  307. RTW_REGD_MAX
  308. };
  309. enum rtw_txq_flags {
  310. RTW_TXQ_AMPDU,
  311. RTW_TXQ_BLOCK_BA,
  312. };
  313. enum rtw_flags {
  314. RTW_FLAG_RUNNING,
  315. RTW_FLAG_FW_RUNNING,
  316. RTW_FLAG_SCANNING,
  317. RTW_FLAG_POWERON,
  318. RTW_FLAG_LEISURE_PS,
  319. RTW_FLAG_LEISURE_PS_DEEP,
  320. RTW_FLAG_DIG_DISABLE,
  321. RTW_FLAG_BUSY_TRAFFIC,
  322. RTW_FLAG_WOWLAN,
  323. RTW_FLAG_RESTARTING,
  324. RTW_FLAG_RESTART_TRIGGERING,
  325. RTW_FLAG_FORCE_LOWEST_RATE,
  326. NUM_OF_RTW_FLAGS,
  327. };
  328. enum rtw_evm {
  329. RTW_EVM_OFDM = 0,
  330. RTW_EVM_1SS,
  331. RTW_EVM_2SS_A,
  332. RTW_EVM_2SS_B,
  333. RTW_EVM_3SS_A,
  334. RTW_EVM_3SS_B,
  335. RTW_EVM_3SS_C,
  336. /* keep it last */
  337. RTW_EVM_NUM
  338. };
  339. enum rtw_snr {
  340. RTW_SNR_OFDM_A = 0,
  341. RTW_SNR_OFDM_B,
  342. RTW_SNR_OFDM_C,
  343. RTW_SNR_OFDM_D,
  344. RTW_SNR_1SS_A,
  345. RTW_SNR_1SS_B,
  346. RTW_SNR_1SS_C,
  347. RTW_SNR_1SS_D,
  348. RTW_SNR_2SS_A,
  349. RTW_SNR_2SS_B,
  350. RTW_SNR_2SS_C,
  351. RTW_SNR_2SS_D,
  352. RTW_SNR_3SS_A,
  353. RTW_SNR_3SS_B,
  354. RTW_SNR_3SS_C,
  355. RTW_SNR_3SS_D,
  356. /* keep it last */
  357. RTW_SNR_NUM
  358. };
  359. enum rtw_port {
  360. RTW_PORT_0 = 0,
  361. RTW_PORT_1 = 1,
  362. RTW_PORT_2 = 2,
  363. RTW_PORT_3 = 3,
  364. RTW_PORT_4 = 4,
  365. RTW_PORT_NUM
  366. };
  367. enum rtw_wow_flags {
  368. RTW_WOW_FLAG_EN_MAGIC_PKT,
  369. RTW_WOW_FLAG_EN_REKEY_PKT,
  370. RTW_WOW_FLAG_EN_DISCONNECT,
  371. /* keep it last */
  372. RTW_WOW_FLAG_MAX,
  373. };
  374. /* the power index is represented by differences, which cck-1s & ht40-1s are
  375. * the base values, so for 1s's differences, there are only ht20 & ofdm
  376. */
  377. struct rtw_2g_1s_pwr_idx_diff {
  378. #ifdef __LITTLE_ENDIAN
  379. s8 ofdm:4;
  380. s8 bw20:4;
  381. #else
  382. s8 bw20:4;
  383. s8 ofdm:4;
  384. #endif
  385. } __packed;
  386. struct rtw_2g_ns_pwr_idx_diff {
  387. #ifdef __LITTLE_ENDIAN
  388. s8 bw20:4;
  389. s8 bw40:4;
  390. s8 cck:4;
  391. s8 ofdm:4;
  392. #else
  393. s8 ofdm:4;
  394. s8 cck:4;
  395. s8 bw40:4;
  396. s8 bw20:4;
  397. #endif
  398. } __packed;
  399. struct rtw_2g_txpwr_idx {
  400. u8 cck_base[6];
  401. u8 bw40_base[5];
  402. struct rtw_2g_1s_pwr_idx_diff ht_1s_diff;
  403. struct rtw_2g_ns_pwr_idx_diff ht_2s_diff;
  404. struct rtw_2g_ns_pwr_idx_diff ht_3s_diff;
  405. struct rtw_2g_ns_pwr_idx_diff ht_4s_diff;
  406. };
  407. struct rtw_5g_ht_1s_pwr_idx_diff {
  408. #ifdef __LITTLE_ENDIAN
  409. s8 ofdm:4;
  410. s8 bw20:4;
  411. #else
  412. s8 bw20:4;
  413. s8 ofdm:4;
  414. #endif
  415. } __packed;
  416. struct rtw_5g_ht_ns_pwr_idx_diff {
  417. #ifdef __LITTLE_ENDIAN
  418. s8 bw20:4;
  419. s8 bw40:4;
  420. #else
  421. s8 bw40:4;
  422. s8 bw20:4;
  423. #endif
  424. } __packed;
  425. struct rtw_5g_ofdm_ns_pwr_idx_diff {
  426. #ifdef __LITTLE_ENDIAN
  427. s8 ofdm_3s:4;
  428. s8 ofdm_2s:4;
  429. s8 ofdm_4s:4;
  430. s8 res:4;
  431. #else
  432. s8 res:4;
  433. s8 ofdm_4s:4;
  434. s8 ofdm_2s:4;
  435. s8 ofdm_3s:4;
  436. #endif
  437. } __packed;
  438. struct rtw_5g_vht_ns_pwr_idx_diff {
  439. #ifdef __LITTLE_ENDIAN
  440. s8 bw160:4;
  441. s8 bw80:4;
  442. #else
  443. s8 bw80:4;
  444. s8 bw160:4;
  445. #endif
  446. } __packed;
  447. struct rtw_5g_txpwr_idx {
  448. u8 bw40_base[14];
  449. struct rtw_5g_ht_1s_pwr_idx_diff ht_1s_diff;
  450. struct rtw_5g_ht_ns_pwr_idx_diff ht_2s_diff;
  451. struct rtw_5g_ht_ns_pwr_idx_diff ht_3s_diff;
  452. struct rtw_5g_ht_ns_pwr_idx_diff ht_4s_diff;
  453. struct rtw_5g_ofdm_ns_pwr_idx_diff ofdm_diff;
  454. struct rtw_5g_vht_ns_pwr_idx_diff vht_1s_diff;
  455. struct rtw_5g_vht_ns_pwr_idx_diff vht_2s_diff;
  456. struct rtw_5g_vht_ns_pwr_idx_diff vht_3s_diff;
  457. struct rtw_5g_vht_ns_pwr_idx_diff vht_4s_diff;
  458. } __packed;
  459. struct rtw_txpwr_idx {
  460. struct rtw_2g_txpwr_idx pwr_idx_2g;
  461. struct rtw_5g_txpwr_idx pwr_idx_5g;
  462. } __packed;
  463. struct rtw_channel_params {
  464. u8 center_chan;
  465. u8 primary_chan;
  466. u8 bandwidth;
  467. };
  468. struct rtw_hw_reg {
  469. u32 addr;
  470. u32 mask;
  471. };
  472. struct rtw_hw_reg_desc {
  473. u32 addr;
  474. u32 mask;
  475. const char *desc;
  476. };
  477. struct rtw_ltecoex_addr {
  478. u32 ctrl;
  479. u32 wdata;
  480. u32 rdata;
  481. };
  482. struct rtw_reg_domain {
  483. u32 addr;
  484. u32 mask;
  485. #define RTW_REG_DOMAIN_MAC32 0
  486. #define RTW_REG_DOMAIN_MAC16 1
  487. #define RTW_REG_DOMAIN_MAC8 2
  488. #define RTW_REG_DOMAIN_RF_A 3
  489. #define RTW_REG_DOMAIN_RF_B 4
  490. #define RTW_REG_DOMAIN_NL 0xFF
  491. u8 domain;
  492. };
  493. struct rtw_rf_sipi_addr {
  494. u32 hssi_1;
  495. u32 hssi_2;
  496. u32 lssi_read;
  497. u32 lssi_read_pi;
  498. };
  499. struct rtw_hw_reg_offset {
  500. struct rtw_hw_reg hw_reg;
  501. u8 offset;
  502. };
  503. struct rtw_backup_info {
  504. u8 len;
  505. u32 reg;
  506. u32 val;
  507. };
  508. enum rtw_vif_port_set {
  509. PORT_SET_MAC_ADDR = BIT(0),
  510. PORT_SET_BSSID = BIT(1),
  511. PORT_SET_NET_TYPE = BIT(2),
  512. PORT_SET_AID = BIT(3),
  513. PORT_SET_BCN_CTRL = BIT(4),
  514. };
  515. struct rtw_vif_port {
  516. struct rtw_hw_reg mac_addr;
  517. struct rtw_hw_reg bssid;
  518. struct rtw_hw_reg net_type;
  519. struct rtw_hw_reg aid;
  520. struct rtw_hw_reg bcn_ctrl;
  521. };
  522. struct rtw_tx_pkt_info {
  523. u32 tx_pkt_size;
  524. u8 offset;
  525. u8 pkt_offset;
  526. u8 tim_offset;
  527. u8 mac_id;
  528. u8 rate_id;
  529. u8 rate;
  530. u8 qsel;
  531. u8 bw;
  532. u8 sec_type;
  533. u8 sn;
  534. bool ampdu_en;
  535. u8 ampdu_factor;
  536. u8 ampdu_density;
  537. u16 seq;
  538. bool stbc;
  539. bool ldpc;
  540. bool dis_rate_fallback;
  541. bool bmc;
  542. bool use_rate;
  543. bool ls;
  544. bool fs;
  545. bool short_gi;
  546. bool report;
  547. bool rts;
  548. bool dis_qselseq;
  549. bool en_hwseq;
  550. u8 hw_ssn_sel;
  551. bool nav_use_hdr;
  552. bool bt_null;
  553. };
  554. struct rtw_rx_pkt_stat {
  555. bool phy_status;
  556. bool icv_err;
  557. bool crc_err;
  558. bool decrypted;
  559. bool is_c2h;
  560. bool channel_invalid;
  561. s32 signal_power;
  562. u16 pkt_len;
  563. u8 bw;
  564. u8 drv_info_sz;
  565. u8 shift;
  566. u8 rate;
  567. u8 mac_id;
  568. u8 cam_id;
  569. u8 ppdu_cnt;
  570. u32 tsf_low;
  571. s8 rx_power[RTW_RF_PATH_MAX];
  572. u8 rssi;
  573. u8 rxsc;
  574. s8 rx_snr[RTW_RF_PATH_MAX];
  575. u8 rx_evm[RTW_RF_PATH_MAX];
  576. s8 cfo_tail[RTW_RF_PATH_MAX];
  577. u16 freq;
  578. u8 band;
  579. struct rtw_sta_info *si;
  580. struct ieee80211_vif *vif;
  581. struct ieee80211_hdr *hdr;
  582. };
  583. DECLARE_EWMA(tp, 10, 2);
  584. struct rtw_traffic_stats {
  585. /* units in bytes */
  586. u64 tx_unicast;
  587. u64 rx_unicast;
  588. /* count for packets */
  589. u64 tx_cnt;
  590. u64 rx_cnt;
  591. /* units in Mbps */
  592. u32 tx_throughput;
  593. u32 rx_throughput;
  594. struct ewma_tp tx_ewma_tp;
  595. struct ewma_tp rx_ewma_tp;
  596. };
  597. enum rtw_lps_mode {
  598. RTW_MODE_ACTIVE = 0,
  599. RTW_MODE_LPS = 1,
  600. RTW_MODE_WMM_PS = 2,
  601. };
  602. enum rtw_lps_deep_mode {
  603. LPS_DEEP_MODE_NONE = 0,
  604. LPS_DEEP_MODE_LCLK = 1,
  605. LPS_DEEP_MODE_PG = 2,
  606. };
  607. enum rtw_pwr_state {
  608. RTW_RF_OFF = 0x0,
  609. RTW_RF_ON = 0x4,
  610. RTW_ALL_ON = 0xc,
  611. };
  612. struct rtw_lps_conf {
  613. enum rtw_lps_mode mode;
  614. enum rtw_lps_deep_mode deep_mode;
  615. enum rtw_lps_deep_mode wow_deep_mode;
  616. enum rtw_pwr_state state;
  617. u8 awake_interval;
  618. u8 rlbm;
  619. u8 smart_ps;
  620. u8 port_id;
  621. bool sec_cam_backup;
  622. bool pattern_cam_backup;
  623. };
  624. enum rtw_hw_key_type {
  625. RTW_CAM_NONE = 0,
  626. RTW_CAM_WEP40 = 1,
  627. RTW_CAM_TKIP = 2,
  628. RTW_CAM_AES = 4,
  629. RTW_CAM_WEP104 = 5,
  630. };
  631. struct rtw_cam_entry {
  632. bool valid;
  633. bool group;
  634. u8 addr[ETH_ALEN];
  635. u8 hw_key_type;
  636. struct ieee80211_key_conf *key;
  637. };
  638. struct rtw_sec_desc {
  639. /* search strategy */
  640. bool default_key_search;
  641. u32 total_cam_num;
  642. struct rtw_cam_entry cam_table[RTW_MAX_SEC_CAM_NUM];
  643. DECLARE_BITMAP(cam_map, RTW_MAX_SEC_CAM_NUM);
  644. };
  645. struct rtw_tx_report {
  646. /* protect the tx report queue */
  647. spinlock_t q_lock;
  648. struct sk_buff_head queue;
  649. atomic_t sn;
  650. struct timer_list purge_timer;
  651. };
  652. struct rtw_ra_report {
  653. struct rate_info txrate;
  654. u32 bit_rate;
  655. u8 desc_rate;
  656. };
  657. struct rtw_txq {
  658. struct list_head list;
  659. unsigned long flags;
  660. };
  661. DECLARE_EWMA(rssi, 10, 16);
  662. struct rtw_sta_info {
  663. struct rtw_dev *rtwdev;
  664. struct ieee80211_sta *sta;
  665. struct ieee80211_vif *vif;
  666. struct ewma_rssi avg_rssi;
  667. u8 rssi_level;
  668. u8 mac_id;
  669. u8 rate_id;
  670. enum rtw_bandwidth bw_mode;
  671. u8 stbc_en:2;
  672. u8 ldpc_en:2;
  673. bool sgi_enable;
  674. bool vht_enable;
  675. u8 init_ra_lv;
  676. u64 ra_mask;
  677. DECLARE_BITMAP(tid_ba, IEEE80211_NUM_TIDS);
  678. struct rtw_ra_report ra_report;
  679. bool use_cfg_mask;
  680. struct cfg80211_bitrate_mask *mask;
  681. struct work_struct rc_work;
  682. };
  683. enum rtw_bfee_role {
  684. RTW_BFEE_NONE,
  685. RTW_BFEE_SU,
  686. RTW_BFEE_MU
  687. };
  688. struct rtw_bfee {
  689. enum rtw_bfee_role role;
  690. u16 p_aid;
  691. u8 g_id;
  692. u8 mac_addr[ETH_ALEN];
  693. u8 sound_dim;
  694. /* SU-MIMO */
  695. u8 su_reg_index;
  696. /* MU-MIMO */
  697. u16 aid;
  698. };
  699. struct rtw_bf_info {
  700. u8 bfer_mu_cnt;
  701. u8 bfer_su_cnt;
  702. DECLARE_BITMAP(bfer_su_reg_maping, 2);
  703. u8 cur_csi_rpt_rate;
  704. };
  705. struct rtw_vif {
  706. enum rtw_net_type net_type;
  707. u16 aid;
  708. u8 mac_id;
  709. u8 mac_addr[ETH_ALEN];
  710. u8 bssid[ETH_ALEN];
  711. u8 port;
  712. u8 bcn_ctrl;
  713. struct list_head rsvd_page_list;
  714. struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
  715. const struct rtw_vif_port *conf;
  716. struct cfg80211_scan_request *scan_req;
  717. struct ieee80211_scan_ies *scan_ies;
  718. struct rtw_traffic_stats stats;
  719. struct rtw_bfee bfee;
  720. };
  721. struct rtw_regulatory {
  722. char alpha2[2] __nonstring;
  723. u8 txpwr_regd_2g;
  724. u8 txpwr_regd_5g;
  725. };
  726. enum rtw_regd_state {
  727. RTW_REGD_STATE_WORLDWIDE,
  728. RTW_REGD_STATE_PROGRAMMED,
  729. RTW_REGD_STATE_SETTING,
  730. RTW_REGD_STATE_NR,
  731. };
  732. struct rtw_regd {
  733. enum rtw_regd_state state;
  734. const struct rtw_regulatory *regulatory;
  735. enum nl80211_dfs_regions dfs_region;
  736. };
  737. struct rtw_chip_ops {
  738. int (*power_on)(struct rtw_dev *rtwdev);
  739. void (*power_off)(struct rtw_dev *rtwdev);
  740. int (*mac_init)(struct rtw_dev *rtwdev);
  741. int (*mac_postinit)(struct rtw_dev *rtwdev);
  742. int (*dump_fw_crash)(struct rtw_dev *rtwdev);
  743. void (*shutdown)(struct rtw_dev *rtwdev);
  744. int (*read_efuse)(struct rtw_dev *rtwdev, u8 *map);
  745. void (*phy_set_param)(struct rtw_dev *rtwdev);
  746. void (*set_channel)(struct rtw_dev *rtwdev, u8 channel,
  747. u8 bandwidth, u8 primary_chan_idx);
  748. void (*query_phy_status)(struct rtw_dev *rtwdev, u8 *phy_status,
  749. struct rtw_rx_pkt_stat *pkt_stat);
  750. u32 (*read_rf)(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
  751. u32 addr, u32 mask);
  752. bool (*write_rf)(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
  753. u32 addr, u32 mask, u32 data);
  754. void (*set_tx_power_index)(struct rtw_dev *rtwdev);
  755. int (*rsvd_page_dump)(struct rtw_dev *rtwdev, u8 *buf, u32 offset,
  756. u32 size);
  757. int (*set_antenna)(struct rtw_dev *rtwdev, int radio_idx,
  758. u32 antenna_tx,
  759. u32 antenna_rx);
  760. void (*cfg_ldo25)(struct rtw_dev *rtwdev, bool enable);
  761. void (*efuse_grant)(struct rtw_dev *rtwdev, bool enable);
  762. void (*set_ampdu_factor)(struct rtw_dev *rtwdev, u8 factor);
  763. void (*false_alarm_statistics)(struct rtw_dev *rtwdev);
  764. void (*phy_calibration)(struct rtw_dev *rtwdev);
  765. void (*dpk_track)(struct rtw_dev *rtwdev);
  766. void (*cck_pd_set)(struct rtw_dev *rtwdev, u8 level);
  767. void (*pwr_track)(struct rtw_dev *rtwdev);
  768. void (*config_bfee)(struct rtw_dev *rtwdev, struct rtw_vif *vif,
  769. struct rtw_bfee *bfee, bool enable);
  770. void (*set_gid_table)(struct rtw_dev *rtwdev,
  771. struct ieee80211_vif *vif,
  772. struct ieee80211_bss_conf *conf);
  773. void (*cfg_csi_rate)(struct rtw_dev *rtwdev, u8 rssi, u8 cur_rate,
  774. u8 fixrate_en, u8 *new_rate);
  775. void (*adaptivity_init)(struct rtw_dev *rtwdev);
  776. void (*adaptivity)(struct rtw_dev *rtwdev);
  777. void (*cfo_init)(struct rtw_dev *rtwdev);
  778. void (*cfo_track)(struct rtw_dev *rtwdev);
  779. void (*config_tx_path)(struct rtw_dev *rtwdev, u8 tx_path,
  780. enum rtw_bb_path tx_path_1ss,
  781. enum rtw_bb_path tx_path_cck,
  782. bool is_tx2_path);
  783. void (*config_txrx_mode)(struct rtw_dev *rtwdev, u8 tx_path,
  784. u8 rx_path, bool is_tx2_path);
  785. void (*led_set)(struct led_classdev *led, enum led_brightness brightness);
  786. /* for USB/SDIO only */
  787. void (*fill_txdesc_checksum)(struct rtw_dev *rtwdev,
  788. struct rtw_tx_pkt_info *pkt_info,
  789. u8 *txdesc);
  790. /* for coex */
  791. void (*coex_set_init)(struct rtw_dev *rtwdev);
  792. void (*coex_set_ant_switch)(struct rtw_dev *rtwdev,
  793. u8 ctrl_type, u8 pos_type);
  794. void (*coex_set_gnt_fix)(struct rtw_dev *rtwdev);
  795. void (*coex_set_gnt_debug)(struct rtw_dev *rtwdev);
  796. void (*coex_set_rfe_type)(struct rtw_dev *rtwdev);
  797. void (*coex_set_wl_tx_power)(struct rtw_dev *rtwdev, u8 wl_pwr);
  798. void (*coex_set_wl_rx_gain)(struct rtw_dev *rtwdev, bool low_gain);
  799. };
  800. #define RTW_PWR_POLLING_CNT 20000
  801. #define RTW_PWR_CMD_READ 0x00
  802. #define RTW_PWR_CMD_WRITE 0x01
  803. #define RTW_PWR_CMD_POLLING 0x02
  804. #define RTW_PWR_CMD_DELAY 0x03
  805. #define RTW_PWR_CMD_END 0x04
  806. /* define the base address of each block */
  807. #define RTW_PWR_ADDR_MAC 0x00
  808. #define RTW_PWR_ADDR_USB 0x01
  809. #define RTW_PWR_ADDR_PCIE 0x02
  810. #define RTW_PWR_ADDR_SDIO 0x03
  811. #define RTW_PWR_INTF_SDIO_MSK BIT(0)
  812. #define RTW_PWR_INTF_USB_MSK BIT(1)
  813. #define RTW_PWR_INTF_PCI_MSK BIT(2)
  814. #define RTW_PWR_INTF_ALL_MSK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  815. #define RTW_PWR_CUT_TEST_MSK BIT(0)
  816. #define RTW_PWR_CUT_A_MSK BIT(1)
  817. #define RTW_PWR_CUT_B_MSK BIT(2)
  818. #define RTW_PWR_CUT_C_MSK BIT(3)
  819. #define RTW_PWR_CUT_D_MSK BIT(4)
  820. #define RTW_PWR_CUT_E_MSK BIT(5)
  821. #define RTW_PWR_CUT_F_MSK BIT(6)
  822. #define RTW_PWR_CUT_G_MSK BIT(7)
  823. #define RTW_PWR_CUT_ALL_MSK 0xFF
  824. enum rtw_pwr_seq_cmd_delay_unit {
  825. RTW_PWR_DELAY_US,
  826. RTW_PWR_DELAY_MS,
  827. };
  828. struct rtw_pwr_seq_cmd {
  829. u16 offset;
  830. u8 cut_mask;
  831. u8 intf_mask;
  832. u8 base:4;
  833. u8 cmd:4;
  834. u8 mask;
  835. u8 value;
  836. };
  837. enum rtw_chip_ver {
  838. RTW_CHIP_VER_CUT_A = 0x00,
  839. RTW_CHIP_VER_CUT_B = 0x01,
  840. RTW_CHIP_VER_CUT_C = 0x02,
  841. RTW_CHIP_VER_CUT_D = 0x03,
  842. RTW_CHIP_VER_CUT_E = 0x04,
  843. RTW_CHIP_VER_CUT_F = 0x05,
  844. RTW_CHIP_VER_CUT_G = 0x06,
  845. };
  846. #define RTW_INTF_PHY_PLATFORM_ALL 0
  847. enum rtw_intf_phy_cut {
  848. RTW_INTF_PHY_CUT_A = BIT(0),
  849. RTW_INTF_PHY_CUT_B = BIT(1),
  850. RTW_INTF_PHY_CUT_C = BIT(2),
  851. RTW_INTF_PHY_CUT_D = BIT(3),
  852. RTW_INTF_PHY_CUT_E = BIT(4),
  853. RTW_INTF_PHY_CUT_F = BIT(5),
  854. RTW_INTF_PHY_CUT_G = BIT(6),
  855. RTW_INTF_PHY_CUT_ALL = 0xFFFF,
  856. };
  857. enum rtw_ip_sel {
  858. RTW_IP_SEL_PHY = 0,
  859. RTW_IP_SEL_MAC = 1,
  860. RTW_IP_SEL_DBI = 2,
  861. RTW_IP_SEL_UNDEF = 0xFFFF
  862. };
  863. enum rtw_pq_map_id {
  864. RTW_PQ_MAP_VO = 0x0,
  865. RTW_PQ_MAP_VI = 0x1,
  866. RTW_PQ_MAP_BE = 0x2,
  867. RTW_PQ_MAP_BK = 0x3,
  868. RTW_PQ_MAP_MG = 0x4,
  869. RTW_PQ_MAP_HI = 0x5,
  870. RTW_PQ_MAP_NUM = 0x6,
  871. RTW_PQ_MAP_UNDEF,
  872. };
  873. enum rtw_dma_mapping {
  874. RTW_DMA_MAPPING_EXTRA = 0,
  875. RTW_DMA_MAPPING_LOW = 1,
  876. RTW_DMA_MAPPING_NORMAL = 2,
  877. RTW_DMA_MAPPING_HIGH = 3,
  878. RTW_DMA_MAPPING_MAX,
  879. RTW_DMA_MAPPING_UNDEF,
  880. };
  881. struct rtw_rqpn {
  882. enum rtw_dma_mapping dma_map_vo;
  883. enum rtw_dma_mapping dma_map_vi;
  884. enum rtw_dma_mapping dma_map_be;
  885. enum rtw_dma_mapping dma_map_bk;
  886. enum rtw_dma_mapping dma_map_mg;
  887. enum rtw_dma_mapping dma_map_hi;
  888. };
  889. struct rtw_prioq_addr {
  890. u32 rsvd;
  891. u32 avail;
  892. };
  893. struct rtw_prioq_addrs {
  894. struct rtw_prioq_addr prio[RTW_DMA_MAPPING_MAX];
  895. bool wsize;
  896. };
  897. struct rtw_page_table {
  898. u16 hq_num;
  899. u16 nq_num;
  900. u16 lq_num;
  901. u16 exq_num;
  902. u16 gapq_num;
  903. };
  904. struct rtw_intf_phy_para {
  905. u16 offset;
  906. u16 value;
  907. u16 ip_sel;
  908. u16 cut_mask;
  909. u16 platform;
  910. };
  911. struct rtw_wow_pattern {
  912. u16 crc;
  913. u8 type;
  914. u8 valid;
  915. u8 mask[RTW_MAX_PATTERN_MASK_SIZE];
  916. };
  917. struct rtw_pno_request {
  918. bool inited;
  919. u32 match_set_cnt;
  920. struct cfg80211_match_set *match_sets;
  921. u8 channel_cnt;
  922. struct ieee80211_channel *channels;
  923. struct cfg80211_sched_scan_plan scan_plan;
  924. };
  925. struct rtw_wow_param {
  926. struct ieee80211_vif *wow_vif;
  927. DECLARE_BITMAP(flags, RTW_WOW_FLAG_MAX);
  928. u8 txpause;
  929. u8 pattern_cnt;
  930. struct rtw_wow_pattern patterns[RTW_MAX_PATTERN_NUM];
  931. bool ips_enabled;
  932. struct rtw_pno_request pno_req;
  933. };
  934. struct rtw_intf_phy_para_table {
  935. const struct rtw_intf_phy_para *usb2_para;
  936. const struct rtw_intf_phy_para *usb3_para;
  937. const struct rtw_intf_phy_para *gen1_para;
  938. const struct rtw_intf_phy_para *gen2_para;
  939. u8 n_usb2_para;
  940. u8 n_usb3_para;
  941. u8 n_gen1_para;
  942. u8 n_gen2_para;
  943. };
  944. struct rtw_table {
  945. const void *data;
  946. const u32 size;
  947. void (*parse)(struct rtw_dev *rtwdev, const struct rtw_table *tbl);
  948. void (*do_cfg)(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
  949. u32 addr, u32 data);
  950. enum rtw_rf_path rf_path;
  951. };
  952. static inline void rtw_load_table(struct rtw_dev *rtwdev,
  953. const struct rtw_table *tbl)
  954. {
  955. (*tbl->parse)(rtwdev, tbl);
  956. }
  957. enum rtw_rfe_fem {
  958. RTW_RFE_IFEM,
  959. RTW_RFE_EFEM,
  960. RTW_RFE_IFEM2G_EFEM5G,
  961. RTW_RFE_NUM,
  962. };
  963. struct rtw_rfe_def {
  964. const struct rtw_table *phy_pg_tbl;
  965. const struct rtw_table *txpwr_lmt_tbl;
  966. const struct rtw_pwr_track_tbl *pwr_track_tbl;
  967. const struct rtw_table *agc_btg_tbl;
  968. };
  969. #define RTW_DEF_RFE(chip, bb_pg, pwrlmt, track) { \
  970. .phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl, \
  971. .txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
  972. .pwr_track_tbl = &rtw ## chip ## _pwr_track_type ## track ## _tbl, \
  973. }
  974. #define RTW_DEF_RFE_EXT(chip, bb_pg, pwrlmt, track, btg) { \
  975. .phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl, \
  976. .txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
  977. .pwr_track_tbl = &rtw ## chip ## _pwr_track_type ## track ## _tbl, \
  978. .agc_btg_tbl = &rtw ## chip ## _agc_btg_type ## btg ## _tbl, \
  979. }
  980. #define RTW_PWR_TRK_5G_1 0
  981. #define RTW_PWR_TRK_5G_2 1
  982. #define RTW_PWR_TRK_5G_3 2
  983. #define RTW_PWR_TRK_5G_NUM 3
  984. #define RTW_PWR_TRK_TBL_SZ 30
  985. /* This table stores the values of TX power that will be adjusted by power
  986. * tracking.
  987. *
  988. * For 5G bands, there are 3 different settings.
  989. * For 2G there are cck rate and ofdm rate with different settings.
  990. */
  991. struct rtw_pwr_track_tbl {
  992. const u8 *pwrtrk_5gd_n[RTW_PWR_TRK_5G_NUM];
  993. const u8 *pwrtrk_5gd_p[RTW_PWR_TRK_5G_NUM];
  994. const u8 *pwrtrk_5gc_n[RTW_PWR_TRK_5G_NUM];
  995. const u8 *pwrtrk_5gc_p[RTW_PWR_TRK_5G_NUM];
  996. const u8 *pwrtrk_5gb_n[RTW_PWR_TRK_5G_NUM];
  997. const u8 *pwrtrk_5gb_p[RTW_PWR_TRK_5G_NUM];
  998. const u8 *pwrtrk_5ga_n[RTW_PWR_TRK_5G_NUM];
  999. const u8 *pwrtrk_5ga_p[RTW_PWR_TRK_5G_NUM];
  1000. const u8 *pwrtrk_2gd_n;
  1001. const u8 *pwrtrk_2gd_p;
  1002. const u8 *pwrtrk_2gc_n;
  1003. const u8 *pwrtrk_2gc_p;
  1004. const u8 *pwrtrk_2gb_n;
  1005. const u8 *pwrtrk_2gb_p;
  1006. const u8 *pwrtrk_2ga_n;
  1007. const u8 *pwrtrk_2ga_p;
  1008. const u8 *pwrtrk_2g_cckd_n;
  1009. const u8 *pwrtrk_2g_cckd_p;
  1010. const u8 *pwrtrk_2g_cckc_n;
  1011. const u8 *pwrtrk_2g_cckc_p;
  1012. const u8 *pwrtrk_2g_cckb_n;
  1013. const u8 *pwrtrk_2g_cckb_p;
  1014. const u8 *pwrtrk_2g_ccka_n;
  1015. const u8 *pwrtrk_2g_ccka_p;
  1016. const s8 *pwrtrk_xtal_n;
  1017. const s8 *pwrtrk_xtal_p;
  1018. };
  1019. enum rtw_wlan_cpu {
  1020. RTW_WCPU_3081,
  1021. RTW_WCPU_8051,
  1022. };
  1023. enum rtw_fw_fifo_sel {
  1024. RTW_FW_FIFO_SEL_TX,
  1025. RTW_FW_FIFO_SEL_RX,
  1026. RTW_FW_FIFO_SEL_RSVD_PAGE,
  1027. RTW_FW_FIFO_SEL_REPORT,
  1028. RTW_FW_FIFO_SEL_LLT,
  1029. RTW_FW_FIFO_SEL_RXBUF_FW,
  1030. RTW_FW_FIFO_MAX,
  1031. };
  1032. enum rtw_fwcd_item {
  1033. RTW_FWCD_TLV,
  1034. RTW_FWCD_REG,
  1035. RTW_FWCD_ROM,
  1036. RTW_FWCD_IMEM,
  1037. RTW_FWCD_DMEM,
  1038. RTW_FWCD_EMEM,
  1039. };
  1040. /* hardware configuration for each IC */
  1041. struct rtw_chip_info {
  1042. const struct rtw_chip_ops *ops;
  1043. u8 id;
  1044. const char *fw_name;
  1045. enum rtw_wlan_cpu wlan_cpu;
  1046. u8 tx_pkt_desc_sz;
  1047. u8 tx_buf_desc_sz;
  1048. u8 rx_pkt_desc_sz;
  1049. u8 rx_buf_desc_sz;
  1050. u32 phy_efuse_size;
  1051. u32 log_efuse_size;
  1052. u32 ptct_efuse_size;
  1053. u32 txff_size;
  1054. u32 rxff_size;
  1055. u32 fw_rxff_size;
  1056. u16 rsvd_drv_pg_num;
  1057. u8 band;
  1058. u16 page_size;
  1059. u8 csi_buf_pg_num;
  1060. u8 dig_max;
  1061. u8 dig_min;
  1062. u8 txgi_factor;
  1063. bool is_pwr_by_rate_dec;
  1064. bool rx_ldpc;
  1065. bool tx_stbc;
  1066. u8 max_power_index;
  1067. u8 ampdu_density;
  1068. u16 fw_fifo_addr[RTW_FW_FIFO_MAX];
  1069. const struct rtw_fwcd_segs *fwcd_segs;
  1070. bool amsdu_in_ampdu;
  1071. u8 usb_tx_agg_desc_num;
  1072. bool hw_feature_report;
  1073. u8 c2h_ra_report_size;
  1074. bool old_datarate_fb_limit;
  1075. u8 default_1ss_tx_path;
  1076. bool path_div_supported;
  1077. bool ht_supported;
  1078. bool vht_supported;
  1079. u8 lps_deep_mode_supported;
  1080. /* init values */
  1081. u8 sys_func_en;
  1082. const struct rtw_pwr_seq_cmd * const *pwr_on_seq;
  1083. const struct rtw_pwr_seq_cmd * const *pwr_off_seq;
  1084. const struct rtw_rqpn *rqpn_table;
  1085. const struct rtw_prioq_addrs *prioq_addrs;
  1086. const struct rtw_page_table *page_table;
  1087. const struct rtw_intf_phy_para_table *intf_table;
  1088. const struct rtw_hw_reg *dig;
  1089. const struct rtw_hw_reg *dig_cck;
  1090. u32 rf_base_addr[RTW_RF_PATH_MAX];
  1091. u32 rf_sipi_addr[RTW_RF_PATH_MAX];
  1092. const struct rtw_rf_sipi_addr *rf_sipi_read_addr;
  1093. u8 fix_rf_phy_num;
  1094. const struct rtw_ltecoex_addr *ltecoex_addr;
  1095. const struct rtw_table *mac_tbl;
  1096. const struct rtw_table *agc_tbl;
  1097. const struct rtw_table *bb_tbl;
  1098. const struct rtw_table *rf_tbl[RTW_RF_PATH_MAX];
  1099. const struct rtw_table *rfk_init_tbl;
  1100. const struct rtw_rfe_def *rfe_defs;
  1101. u32 rfe_defs_size;
  1102. bool en_dis_dpd;
  1103. u16 dpd_ratemask;
  1104. u8 iqk_threshold;
  1105. u8 lck_threshold;
  1106. u8 bfer_su_max_num;
  1107. u8 bfer_mu_max_num;
  1108. const struct rtw_hw_reg_offset *edcca_th;
  1109. s8 l2h_th_ini_cs;
  1110. s8 l2h_th_ini_ad;
  1111. const char *wow_fw_name;
  1112. const struct wiphy_wowlan_support *wowlan_stub;
  1113. const u8 max_sched_scan_ssids;
  1114. const u16 max_scan_ie_len;
  1115. /* coex paras */
  1116. u32 coex_para_ver;
  1117. u8 bt_desired_ver;
  1118. bool scbd_support;
  1119. bool new_scbd10_def; /* true: fix 2M(8822c) */
  1120. bool ble_hid_profile_support;
  1121. bool wl_mimo_ps_support;
  1122. u8 pstdma_type; /* 0: LPSoff, 1:LPSon */
  1123. u8 bt_rssi_type;
  1124. u8 ant_isolation;
  1125. u8 rssi_tolerance;
  1126. u8 table_sant_num;
  1127. u8 table_nsant_num;
  1128. u8 tdma_sant_num;
  1129. u8 tdma_nsant_num;
  1130. u8 bt_afh_span_bw20;
  1131. u8 bt_afh_span_bw40;
  1132. u8 afh_5g_num;
  1133. u8 wl_rf_para_num;
  1134. u8 coex_info_hw_regs_num;
  1135. const u8 *bt_rssi_step;
  1136. const u8 *wl_rssi_step;
  1137. const struct coex_table_para *table_nsant;
  1138. const struct coex_table_para *table_sant;
  1139. const struct coex_tdma_para *tdma_sant;
  1140. const struct coex_tdma_para *tdma_nsant;
  1141. const struct coex_rf_para *wl_rf_para_tx;
  1142. const struct coex_rf_para *wl_rf_para_rx;
  1143. const struct coex_5g_afh_map *afh_5g;
  1144. const struct rtw_hw_reg *btg_reg;
  1145. const struct rtw_reg_domain *coex_info_hw_regs;
  1146. u32 wl_fw_desired_ver;
  1147. };
  1148. enum rtw_coex_bt_state_cnt {
  1149. COEX_CNT_BT_RETRY,
  1150. COEX_CNT_BT_REINIT,
  1151. COEX_CNT_BT_REENABLE,
  1152. COEX_CNT_BT_POPEVENT,
  1153. COEX_CNT_BT_SETUPLINK,
  1154. COEX_CNT_BT_IGNWLANACT,
  1155. COEX_CNT_BT_INQ,
  1156. COEX_CNT_BT_PAGE,
  1157. COEX_CNT_BT_ROLESWITCH,
  1158. COEX_CNT_BT_AFHUPDATE,
  1159. COEX_CNT_BT_INFOUPDATE,
  1160. COEX_CNT_BT_IQK,
  1161. COEX_CNT_BT_IQKFAIL,
  1162. COEX_CNT_BT_MAX
  1163. };
  1164. enum rtw_coex_wl_state_cnt {
  1165. COEX_CNT_WL_SCANAP,
  1166. COEX_CNT_WL_CONNPKT,
  1167. COEX_CNT_WL_COEXRUN,
  1168. COEX_CNT_WL_NOISY0,
  1169. COEX_CNT_WL_NOISY1,
  1170. COEX_CNT_WL_NOISY2,
  1171. COEX_CNT_WL_5MS_NOEXTEND,
  1172. COEX_CNT_WL_FW_NOTIFY,
  1173. COEX_CNT_WL_MAX
  1174. };
  1175. struct rtw_coex_rfe {
  1176. bool ant_switch_exist;
  1177. bool ant_switch_diversity;
  1178. bool ant_switch_with_bt;
  1179. u8 rfe_module_type;
  1180. u8 ant_switch_polarity;
  1181. /* true if WLG at BTG, else at WLAG */
  1182. bool wlg_at_btg;
  1183. };
  1184. #define COEX_WL_TDMA_PARA_LENGTH 5
  1185. struct rtw_coex_dm {
  1186. bool cur_ps_tdma_on;
  1187. bool cur_wl_rx_low_gain_en;
  1188. bool ignore_wl_act;
  1189. u8 reason;
  1190. u8 bt_rssi_state[4];
  1191. u8 wl_rssi_state[4];
  1192. u8 wl_ch_info[3];
  1193. u8 cur_ps_tdma;
  1194. u8 cur_table;
  1195. u8 ps_tdma_para[5];
  1196. u8 cur_bt_pwr_lvl;
  1197. u8 cur_bt_lna_lvl;
  1198. u8 cur_wl_pwr_lvl;
  1199. u8 bt_status;
  1200. u32 cur_ant_pos_type;
  1201. u32 cur_switch_status;
  1202. u32 setting_tdma;
  1203. u8 fw_tdma_para[COEX_WL_TDMA_PARA_LENGTH];
  1204. };
  1205. #define COEX_BTINFO_SRC_WL_FW 0x0
  1206. #define COEX_BTINFO_SRC_BT_RSP 0x1
  1207. #define COEX_BTINFO_SRC_BT_ACT 0x2
  1208. #define COEX_BTINFO_SRC_BT_IQK 0x3
  1209. #define COEX_BTINFO_SRC_BT_SCBD 0x4
  1210. #define COEX_BTINFO_SRC_H2C60 0x5
  1211. #define COEX_BTINFO_SRC_MAX 0x6
  1212. #define COEX_INFO_FTP BIT(7)
  1213. #define COEX_INFO_A2DP BIT(6)
  1214. #define COEX_INFO_HID BIT(5)
  1215. #define COEX_INFO_SCO_BUSY BIT(4)
  1216. #define COEX_INFO_ACL_BUSY BIT(3)
  1217. #define COEX_INFO_INQ_PAGE BIT(2)
  1218. #define COEX_INFO_SCO_ESCO BIT(1)
  1219. #define COEX_INFO_CONNECTION BIT(0)
  1220. #define COEX_BTINFO_LENGTH_MAX 10
  1221. #define COEX_BTINFO_LENGTH 7
  1222. #define COEX_BT_HIDINFO_LIST 0x0
  1223. #define COEX_BT_HIDINFO_A 0x1
  1224. #define COEX_BT_HIDINFO_NAME 3
  1225. #define COEX_BT_HIDINFO_LENGTH 6
  1226. #define COEX_BT_HIDINFO_HANDLE_NUM 4
  1227. #define COEX_BT_HIDINFO_C2H_HANDLE 0
  1228. #define COEX_BT_HIDINFO_C2H_VENDOR 1
  1229. #define COEX_BT_BLE_HANDLE_THRS 0x10
  1230. #define COEX_BT_HIDINFO_NOTCON 0xff
  1231. struct rtw_coex_hid {
  1232. u8 hid_handle;
  1233. u8 hid_vendor;
  1234. u8 hid_name[COEX_BT_HIDINFO_NAME];
  1235. bool hid_info_completed;
  1236. bool is_game_hid;
  1237. };
  1238. struct rtw_coex_hid_handle_list {
  1239. u8 cmd_id;
  1240. u8 len;
  1241. u8 subid;
  1242. u8 handle_cnt;
  1243. u8 handle[COEX_BT_HIDINFO_HANDLE_NUM];
  1244. } __packed;
  1245. struct rtw_coex_hid_info_a {
  1246. u8 cmd_id;
  1247. u8 len;
  1248. u8 subid;
  1249. u8 handle;
  1250. u8 vendor;
  1251. u8 name[COEX_BT_HIDINFO_NAME];
  1252. } __packed;
  1253. struct rtw_coex_stat {
  1254. bool bt_disabled;
  1255. bool bt_disabled_pre;
  1256. bool bt_link_exist;
  1257. bool bt_whck_test;
  1258. bool bt_inq_page;
  1259. bool bt_inq_remain;
  1260. bool bt_inq;
  1261. bool bt_page;
  1262. bool bt_ble_voice;
  1263. bool bt_ble_exist;
  1264. bool bt_hfp_exist;
  1265. bool bt_a2dp_exist;
  1266. bool bt_hid_exist;
  1267. bool bt_pan_exist; /* PAN or OPP */
  1268. bool bt_opp_exist; /* OPP only */
  1269. bool bt_acl_busy;
  1270. bool bt_fix_2M;
  1271. bool bt_setup_link;
  1272. bool bt_multi_link;
  1273. bool bt_multi_link_pre;
  1274. bool bt_multi_link_remain;
  1275. bool bt_a2dp_sink;
  1276. bool bt_a2dp_active;
  1277. bool bt_reenable;
  1278. bool bt_ble_scan_en;
  1279. bool bt_init_scan;
  1280. bool bt_slave;
  1281. bool bt_418_hid_exist;
  1282. bool bt_ble_hid_exist;
  1283. bool bt_game_hid_exist;
  1284. bool bt_hid_handle_cnt;
  1285. bool bt_mailbox_reply;
  1286. bool wl_under_lps;
  1287. bool wl_under_ips;
  1288. bool wl_hi_pri_task1;
  1289. bool wl_hi_pri_task2;
  1290. bool wl_force_lps_ctrl;
  1291. bool wl_gl_busy;
  1292. bool wl_linkscan_proc;
  1293. bool wl_ps_state_fail;
  1294. bool wl_tx_limit_en;
  1295. bool wl_ampdu_limit_en;
  1296. bool wl_connected;
  1297. bool wl_slot_extend;
  1298. bool wl_cck_lock;
  1299. bool wl_cck_lock_pre;
  1300. bool wl_cck_lock_ever;
  1301. bool wl_connecting;
  1302. bool wl_slot_toggle;
  1303. bool wl_slot_toggle_change; /* if toggle to no-toggle */
  1304. bool wl_mimo_ps;
  1305. u32 bt_supported_version;
  1306. u32 bt_supported_feature;
  1307. u32 hi_pri_tx;
  1308. u32 hi_pri_rx;
  1309. u32 lo_pri_tx;
  1310. u32 lo_pri_rx;
  1311. u32 patch_ver;
  1312. u16 bt_reg_vendor_ae;
  1313. u16 bt_reg_vendor_ac;
  1314. s8 bt_rssi;
  1315. u8 kt_ver;
  1316. u8 gnt_workaround_state;
  1317. u8 tdma_timer_base;
  1318. u8 bt_profile_num;
  1319. u8 bt_info_c2h[COEX_BTINFO_SRC_MAX][COEX_BTINFO_LENGTH_MAX];
  1320. u8 bt_info_lb2;
  1321. u8 bt_info_lb3;
  1322. u8 bt_info_hb0;
  1323. u8 bt_info_hb1;
  1324. u8 bt_info_hb2;
  1325. u8 bt_info_hb3;
  1326. u8 bt_ble_scan_type;
  1327. u8 bt_hid_pair_num;
  1328. u8 bt_hid_slot;
  1329. u8 bt_a2dp_bitpool;
  1330. u8 bt_iqk_state;
  1331. u8 bt_disable_cnt;
  1332. u16 wl_beacon_interval;
  1333. u8 wl_noisy_level;
  1334. u8 wl_fw_dbg_info[10];
  1335. u8 wl_fw_dbg_info_pre[10];
  1336. u8 wl_rx_rate;
  1337. u8 wl_tx_rate;
  1338. u8 wl_rts_rx_rate;
  1339. u8 wl_coex_mode;
  1340. u8 wl_iot_peer;
  1341. u8 ampdu_max_time;
  1342. u8 wl_tput_dir;
  1343. u8 wl_toggle_para[6];
  1344. u8 wl_toggle_interval;
  1345. u16 score_board;
  1346. u16 retry_limit;
  1347. /* counters to record bt states */
  1348. u32 cnt_bt[COEX_CNT_BT_MAX];
  1349. /* counters to record wifi states */
  1350. u32 cnt_wl[COEX_CNT_WL_MAX];
  1351. /* counters to record bt c2h data */
  1352. u32 cnt_bt_info_c2h[COEX_BTINFO_SRC_MAX];
  1353. u32 darfrc;
  1354. u32 darfrch;
  1355. struct rtw_coex_hid hid_info[COEX_BT_HIDINFO_HANDLE_NUM];
  1356. struct rtw_coex_hid_handle_list hid_handle_list;
  1357. };
  1358. struct rtw_coex {
  1359. struct sk_buff_head queue;
  1360. wait_queue_head_t wait;
  1361. bool under_5g;
  1362. bool stop_dm;
  1363. bool freeze;
  1364. bool freerun;
  1365. bool wl_rf_off;
  1366. bool manual_control;
  1367. struct rtw_coex_stat stat;
  1368. struct rtw_coex_dm dm;
  1369. struct rtw_coex_rfe rfe;
  1370. struct delayed_work bt_relink_work;
  1371. struct delayed_work bt_reenable_work;
  1372. struct delayed_work defreeze_work;
  1373. struct delayed_work wl_remain_work;
  1374. struct delayed_work bt_remain_work;
  1375. struct delayed_work wl_connecting_work;
  1376. struct delayed_work bt_multi_link_remain_work;
  1377. struct delayed_work wl_ccklock_work;
  1378. };
  1379. #define DPK_RF_REG_NUM 7
  1380. #define DPK_RF_PATH_NUM 2
  1381. #define DPK_BB_REG_NUM 18
  1382. #define DPK_CHANNEL_WIDTH_80 1
  1383. DECLARE_EWMA(thermal, 10, 4);
  1384. struct rtw_dpk_info {
  1385. bool is_dpk_pwr_on;
  1386. bool is_reload;
  1387. DECLARE_BITMAP(dpk_path_ok, DPK_RF_PATH_NUM);
  1388. u8 thermal_dpk[DPK_RF_PATH_NUM];
  1389. struct ewma_thermal avg_thermal[DPK_RF_PATH_NUM];
  1390. u32 gnt_control;
  1391. u32 gnt_value;
  1392. u8 result[RTW_RF_PATH_MAX];
  1393. u8 dpk_txagc[RTW_RF_PATH_MAX];
  1394. u32 coef[RTW_RF_PATH_MAX][20];
  1395. u16 dpk_gs[RTW_RF_PATH_MAX];
  1396. u8 thermal_dpk_delta[RTW_RF_PATH_MAX];
  1397. u8 pre_pwsf[RTW_RF_PATH_MAX];
  1398. u8 dpk_band;
  1399. u8 dpk_ch;
  1400. u8 dpk_bw;
  1401. };
  1402. struct rtw_phy_cck_pd_reg {
  1403. u32 reg_pd;
  1404. u32 mask_pd;
  1405. u32 reg_cs;
  1406. u32 mask_cs;
  1407. };
  1408. #define DACK_MSBK_BACKUP_NUM 0xf
  1409. #define DACK_DCK_BACKUP_NUM 0x2
  1410. struct rtw_swing_table {
  1411. const u8 *p[RTW_RF_PATH_MAX];
  1412. const u8 *n[RTW_RF_PATH_MAX];
  1413. };
  1414. struct rtw_pkt_count {
  1415. u16 num_bcn_pkt;
  1416. u16 num_qry_pkt[DESC_RATE_MAX];
  1417. };
  1418. DECLARE_EWMA(evm, 10, 4);
  1419. DECLARE_EWMA(snr, 10, 4);
  1420. struct rtw_iqk_info {
  1421. bool done;
  1422. struct {
  1423. u32 s1_x;
  1424. u32 s1_y;
  1425. u32 s0_x;
  1426. u32 s0_y;
  1427. } result;
  1428. };
  1429. enum rtw_rf_band {
  1430. RF_BAND_2G_CCK,
  1431. RF_BAND_2G_OFDM,
  1432. RF_BAND_5G_L,
  1433. RF_BAND_5G_M,
  1434. RF_BAND_5G_H,
  1435. RF_BAND_MAX
  1436. };
  1437. #define RF_GAIN_NUM 11
  1438. #define RF_HW_OFFSET_NUM 10
  1439. struct rtw_gapk_info {
  1440. u32 rf3f_bp[RF_BAND_MAX][RF_GAIN_NUM][RTW_RF_PATH_MAX];
  1441. u32 rf3f_fs[RTW_RF_PATH_MAX][RF_GAIN_NUM];
  1442. bool txgapk_bp_done;
  1443. s8 offset[RF_GAIN_NUM][RTW_RF_PATH_MAX];
  1444. s8 fianl_offset[RF_GAIN_NUM][RTW_RF_PATH_MAX];
  1445. u8 read_txgain;
  1446. u8 channel;
  1447. };
  1448. #define EDCCA_TH_L2H_IDX 0
  1449. #define EDCCA_TH_H2L_IDX 1
  1450. #define EDCCA_TH_L2H_LB 48
  1451. #define EDCCA_ADC_BACKOFF 12
  1452. #define EDCCA_IGI_BASE 50
  1453. #define EDCCA_IGI_L2H_DIFF 8
  1454. #define EDCCA_L2H_H2L_DIFF 7
  1455. #define EDCCA_L2H_H2L_DIFF_NORMAL 8
  1456. enum rtw_edcca_mode {
  1457. RTW_EDCCA_NORMAL = 0,
  1458. RTW_EDCCA_ADAPTIVITY = 1,
  1459. };
  1460. struct rtw_cfo_track {
  1461. bool is_adjust;
  1462. u8 crystal_cap;
  1463. s32 cfo_tail[RTW_RF_PATH_MAX];
  1464. s32 cfo_cnt[RTW_RF_PATH_MAX];
  1465. u32 packet_count;
  1466. u32 packet_count_pre;
  1467. };
  1468. #define RRSR_INIT_2G 0x15f
  1469. #define RRSR_INIT_5G 0x150
  1470. enum rtw_dm_cap {
  1471. RTW_DM_CAP_NA,
  1472. RTW_DM_CAP_TXGAPK,
  1473. RTW_DM_CAP_NUM
  1474. };
  1475. struct rtw_dm_info {
  1476. u32 cck_fa_cnt;
  1477. u32 ofdm_fa_cnt;
  1478. u32 total_fa_cnt;
  1479. u32 cck_cca_cnt;
  1480. u32 ofdm_cca_cnt;
  1481. u32 total_cca_cnt;
  1482. u32 cck_ok_cnt;
  1483. u32 cck_err_cnt;
  1484. u32 ofdm_ok_cnt;
  1485. u32 ofdm_err_cnt;
  1486. u32 ht_ok_cnt;
  1487. u32 ht_err_cnt;
  1488. u32 vht_ok_cnt;
  1489. u32 vht_err_cnt;
  1490. u8 min_rssi;
  1491. u8 pre_min_rssi;
  1492. u16 fa_history[4];
  1493. u8 igi_history[4];
  1494. u8 igi_bitmap;
  1495. bool damping;
  1496. u8 damping_cnt;
  1497. u8 damping_rssi;
  1498. u8 cck_gi_u_bnd;
  1499. u8 cck_gi_l_bnd;
  1500. u8 fix_rate;
  1501. u8 tx_rate;
  1502. u32 rrsr_val_init;
  1503. u32 rrsr_mask_min;
  1504. u8 thermal_avg[RTW_RF_PATH_MAX];
  1505. u8 thermal_meter_k;
  1506. u8 thermal_meter_lck;
  1507. s8 delta_power_index[RTW_RF_PATH_MAX];
  1508. s8 delta_power_index_last[RTW_RF_PATH_MAX];
  1509. u8 default_ofdm_index;
  1510. u8 default_cck_index;
  1511. bool pwr_trk_triggered;
  1512. bool pwr_trk_init_trigger;
  1513. struct ewma_thermal avg_thermal[RTW_RF_PATH_MAX];
  1514. s8 txagc_remnant_cck;
  1515. s8 txagc_remnant_ofdm[RTW_RF_PATH_MAX];
  1516. u8 rx_cck_agc_report_type;
  1517. /* backup dack results for each path and I/Q */
  1518. u32 dack_adck[RTW_RF_PATH_MAX];
  1519. u16 dack_msbk[RTW_RF_PATH_MAX][2][DACK_MSBK_BACKUP_NUM];
  1520. u8 dack_dck[RTW_RF_PATH_MAX][2][DACK_DCK_BACKUP_NUM];
  1521. struct rtw_dpk_info dpk_info;
  1522. struct rtw_cfo_track cfo_track;
  1523. /* [bandwidth 0:20M/1:40M][number of path] */
  1524. u8 cck_pd_lv[2][RTW_RF_PATH_MAX];
  1525. u32 cck_fa_avg;
  1526. u8 cck_pd_default;
  1527. /* save the last rx phy status for debug */
  1528. s8 rx_snr[RTW_RF_PATH_MAX];
  1529. u8 rx_evm_dbm[RTW_RF_PATH_MAX];
  1530. s16 cfo_tail[RTW_RF_PATH_MAX];
  1531. u8 rssi[RTW_RF_PATH_MAX];
  1532. u8 curr_rx_rate;
  1533. struct rtw_pkt_count cur_pkt_count;
  1534. struct rtw_pkt_count last_pkt_count;
  1535. struct ewma_evm ewma_evm[RTW_EVM_NUM];
  1536. struct ewma_snr ewma_snr[RTW_SNR_NUM];
  1537. u32 dm_flags; /* enum rtw_dm_cap */
  1538. struct rtw_iqk_info iqk;
  1539. struct rtw_gapk_info gapk;
  1540. bool is_bt_iqk_timeout;
  1541. s8 l2h_th_ini;
  1542. enum rtw_edcca_mode edcca_mode;
  1543. u8 scan_density;
  1544. };
  1545. struct rtw_efuse {
  1546. u32 size;
  1547. u32 physical_size;
  1548. u32 logical_size;
  1549. u32 protect_size;
  1550. u8 addr[ETH_ALEN];
  1551. u8 channel_plan;
  1552. u8 country_code[2];
  1553. u8 rf_board_option;
  1554. u8 rfe_option;
  1555. u8 power_track_type;
  1556. u8 thermal_meter[RTW_RF_PATH_MAX];
  1557. u8 thermal_meter_k;
  1558. u8 crystal_cap;
  1559. u8 ant_div_cfg;
  1560. u8 ant_div_type;
  1561. u8 regd;
  1562. u8 afe;
  1563. u8 lna_type_2g;
  1564. u8 lna_type_5g;
  1565. u8 glna_type;
  1566. u8 alna_type;
  1567. bool ext_lna_2g;
  1568. bool ext_lna_5g;
  1569. u8 pa_type_2g;
  1570. u8 pa_type_5g;
  1571. u8 gpa_type;
  1572. u8 apa_type;
  1573. bool ext_pa_2g;
  1574. bool ext_pa_5g;
  1575. u8 tx_bb_swing_setting_2g;
  1576. u8 tx_bb_swing_setting_5g;
  1577. bool btcoex;
  1578. /* bt share antenna with wifi */
  1579. bool share_ant;
  1580. u8 bt_setting;
  1581. u8 usb_mode_switch;
  1582. struct {
  1583. u8 hci;
  1584. u8 bw;
  1585. u8 ptcl;
  1586. u8 nss;
  1587. u8 ant_num;
  1588. } hw_cap;
  1589. struct rtw_txpwr_idx txpwr_idx_table[4];
  1590. };
  1591. struct rtw_phy_cond {
  1592. #ifdef __LITTLE_ENDIAN
  1593. u32 rfe:8;
  1594. u32 intf:4;
  1595. u32 pkg:4;
  1596. u32 plat:4;
  1597. u32 intf_rsvd:4;
  1598. u32 cut:4;
  1599. u32 branch:2;
  1600. u32 neg:1;
  1601. u32 pos:1;
  1602. #else
  1603. u32 pos:1;
  1604. u32 neg:1;
  1605. u32 branch:2;
  1606. u32 cut:4;
  1607. u32 intf_rsvd:4;
  1608. u32 plat:4;
  1609. u32 pkg:4;
  1610. u32 intf:4;
  1611. u32 rfe:8;
  1612. #endif
  1613. /* for intf:4 */
  1614. #define INTF_PCIE BIT(0)
  1615. #define INTF_USB BIT(1)
  1616. #define INTF_SDIO BIT(2)
  1617. /* for branch:2 */
  1618. #define BRANCH_IF 0
  1619. #define BRANCH_ELIF 1
  1620. #define BRANCH_ELSE 2
  1621. #define BRANCH_ENDIF 3
  1622. };
  1623. struct rtw_phy_cond2 {
  1624. #ifdef __LITTLE_ENDIAN
  1625. u8 type_glna;
  1626. u8 type_gpa;
  1627. u8 type_alna;
  1628. u8 type_apa;
  1629. #else
  1630. u8 type_apa;
  1631. u8 type_alna;
  1632. u8 type_gpa;
  1633. u8 type_glna;
  1634. #endif
  1635. };
  1636. struct rtw_fifo_conf {
  1637. /* tx fifo information */
  1638. u16 rsvd_boundary;
  1639. u16 rsvd_pg_num;
  1640. u16 rsvd_drv_pg_num;
  1641. u16 txff_pg_num;
  1642. u16 acq_pg_num;
  1643. u16 rsvd_drv_addr;
  1644. u16 rsvd_h2c_info_addr;
  1645. u16 rsvd_h2c_sta_info_addr;
  1646. u16 rsvd_h2cq_addr;
  1647. u16 rsvd_cpu_instr_addr;
  1648. u16 rsvd_fw_txbuf_addr;
  1649. u16 rsvd_csibuf_addr;
  1650. const struct rtw_rqpn *rqpn;
  1651. };
  1652. struct rtw_fwcd_desc {
  1653. u32 size;
  1654. u8 *next;
  1655. u8 *data;
  1656. };
  1657. struct rtw_fwcd_segs {
  1658. const u32 *segs;
  1659. u8 num;
  1660. };
  1661. #define FW_CD_TYPE 0xffff
  1662. #define FW_CD_LEN 4
  1663. #define FW_CD_VAL 0xaabbccdd
  1664. struct rtw_fw_state {
  1665. const struct firmware *firmware;
  1666. struct rtw_dev *rtwdev;
  1667. struct completion completion;
  1668. struct rtw_fwcd_desc fwcd_desc;
  1669. u16 version;
  1670. u8 sub_version;
  1671. u8 sub_index;
  1672. u16 h2c_version;
  1673. u32 feature;
  1674. u32 feature_ext;
  1675. enum rtw_fw_type type;
  1676. };
  1677. enum rtw_sar_sources {
  1678. RTW_SAR_SOURCE_NONE,
  1679. RTW_SAR_SOURCE_COMMON,
  1680. };
  1681. enum rtw_sar_bands {
  1682. RTW_SAR_BAND_0,
  1683. RTW_SAR_BAND_1,
  1684. /* RTW_SAR_BAND_2, not used now */
  1685. RTW_SAR_BAND_3,
  1686. RTW_SAR_BAND_4,
  1687. RTW_SAR_BAND_NR,
  1688. };
  1689. /* the union is reserved for other kinds of SAR sources
  1690. * which might not re-use same format with array common.
  1691. */
  1692. union rtw_sar_cfg {
  1693. s8 common[RTW_SAR_BAND_NR];
  1694. };
  1695. struct rtw_sar {
  1696. enum rtw_sar_sources src;
  1697. union rtw_sar_cfg cfg[RTW_RF_PATH_MAX][RTW_RATE_SECTION_NUM];
  1698. };
  1699. struct rtw_hal {
  1700. u32 rcr;
  1701. u32 chip_version;
  1702. u8 cut_version;
  1703. u8 mp_chip;
  1704. u8 oem_id;
  1705. u8 pkg_type;
  1706. struct rtw_phy_cond phy_cond;
  1707. struct rtw_phy_cond2 phy_cond2;
  1708. bool rfe_btg;
  1709. u8 ps_mode;
  1710. u8 current_channel;
  1711. u8 current_primary_channel_index;
  1712. u8 current_band_width;
  1713. u8 current_band_type;
  1714. u8 primary_channel;
  1715. /* center channel for different available bandwidth,
  1716. * val of (bw > current_band_width) is invalid
  1717. */
  1718. u8 cch_by_bw[RTW_MAX_CHANNEL_WIDTH + 1];
  1719. u8 sec_ch_offset;
  1720. u8 rf_type;
  1721. u8 rf_path_num;
  1722. u8 rf_phy_num;
  1723. u32 antenna_tx;
  1724. u32 antenna_rx;
  1725. u8 bfee_sts_cap;
  1726. bool txrx_1ss;
  1727. bool cck_high_power;
  1728. /* protect tx power section */
  1729. struct mutex tx_power_mutex;
  1730. s8 tx_pwr_by_rate_offset_2g[RTW_RF_PATH_MAX]
  1731. [DESC_RATE_MAX];
  1732. s8 tx_pwr_by_rate_offset_5g[RTW_RF_PATH_MAX]
  1733. [DESC_RATE_MAX];
  1734. s8 tx_pwr_by_rate_base_2g[RTW_RF_PATH_MAX]
  1735. [RTW_RATE_SECTION_NUM];
  1736. s8 tx_pwr_by_rate_base_5g[RTW_RF_PATH_MAX]
  1737. [RTW_RATE_SECTION_NUM];
  1738. s8 tx_pwr_limit_2g[RTW_REGD_MAX]
  1739. [RTW_CHANNEL_WIDTH_MAX]
  1740. [RTW_RATE_SECTION_NUM]
  1741. [RTW_MAX_CHANNEL_NUM_2G];
  1742. s8 tx_pwr_limit_5g[RTW_REGD_MAX]
  1743. [RTW_CHANNEL_WIDTH_MAX]
  1744. [RTW_RATE_SECTION_NUM]
  1745. [RTW_MAX_CHANNEL_NUM_5G];
  1746. s8 tx_pwr_tbl[RTW_RF_PATH_MAX]
  1747. [DESC_RATE_MAX];
  1748. enum rtw_sar_bands sar_band;
  1749. struct rtw_sar sar;
  1750. /* for 8821c set channel */
  1751. u32 ch_param[3];
  1752. };
  1753. struct rtw_path_div {
  1754. enum rtw_bb_path current_tx_path;
  1755. u32 path_a_sum;
  1756. u32 path_b_sum;
  1757. u16 path_a_cnt;
  1758. u16 path_b_cnt;
  1759. };
  1760. struct rtw_chan_info {
  1761. int pri_ch_idx;
  1762. int action_id;
  1763. int bw;
  1764. u8 extra_info;
  1765. u8 channel;
  1766. u16 timeout;
  1767. };
  1768. struct rtw_chan_list {
  1769. u32 buf_size;
  1770. u32 ch_num;
  1771. u32 size;
  1772. u16 addr;
  1773. };
  1774. struct rtw_hw_scan_info {
  1775. struct ieee80211_vif *scanning_vif;
  1776. u8 probe_pg_size;
  1777. u8 op_pri_ch_idx;
  1778. u8 op_pri_ch;
  1779. u8 op_chan;
  1780. u8 op_bw;
  1781. };
  1782. struct rtw_dev {
  1783. struct ieee80211_hw *hw;
  1784. struct device *dev;
  1785. struct rtw_hci hci;
  1786. struct rtw_hw_scan_info scan_info;
  1787. const struct rtw_chip_info *chip;
  1788. struct rtw_hal hal;
  1789. struct rtw_fifo_conf fifo;
  1790. struct rtw_fw_state fw;
  1791. struct rtw_efuse efuse;
  1792. struct rtw_sec_desc sec;
  1793. struct rtw_traffic_stats stats;
  1794. struct rtw_regd regd;
  1795. struct rtw_bf_info bf_info;
  1796. struct rtw_dm_info dm_info;
  1797. struct rtw_coex coex;
  1798. /* ensures exclusive access from mac80211 callbacks */
  1799. struct mutex mutex;
  1800. /* watch dog every 2 sec */
  1801. struct delayed_work watch_dog_work;
  1802. u32 watch_dog_cnt;
  1803. struct list_head rsvd_page_list;
  1804. /* c2h cmd queue & handler work */
  1805. struct sk_buff_head c2h_queue;
  1806. struct work_struct c2h_work;
  1807. struct work_struct ips_work;
  1808. struct work_struct fw_recovery_work;
  1809. struct work_struct update_beacon_work;
  1810. /* used to protect txqs list */
  1811. spinlock_t txq_lock;
  1812. struct list_head txqs;
  1813. struct workqueue_struct *tx_wq;
  1814. struct work_struct tx_work;
  1815. struct work_struct ba_work;
  1816. struct rtw_tx_report tx_report;
  1817. struct {
  1818. /* indicate the mail box to use with fw */
  1819. u8 last_box_num;
  1820. u32 seq;
  1821. } h2c;
  1822. /* lps power state & handler work */
  1823. struct rtw_lps_conf lps_conf;
  1824. bool ps_enabled;
  1825. bool beacon_loss;
  1826. struct completion lps_leave_check;
  1827. struct rtw_debugfs *debugfs;
  1828. u8 sta_cnt;
  1829. u32 rts_threshold;
  1830. DECLARE_BITMAP(hw_port, RTW_PORT_NUM);
  1831. DECLARE_BITMAP(mac_id_map, RTW_MAX_MAC_ID_NUM);
  1832. DECLARE_BITMAP(flags, NUM_OF_RTW_FLAGS);
  1833. u8 mp_mode;
  1834. struct rtw_path_div dm_path_div;
  1835. struct rtw_fw_state wow_fw;
  1836. struct rtw_wow_param wow;
  1837. bool need_rfk;
  1838. struct completion fw_scan_density;
  1839. bool ap_active;
  1840. bool led_registered;
  1841. char led_name[32];
  1842. struct led_classdev led_cdev;
  1843. /* hci related data, must be last */
  1844. u8 priv[] __aligned(sizeof(void *));
  1845. };
  1846. #include "hci.h"
  1847. static inline bool rtw_is_assoc(struct rtw_dev *rtwdev)
  1848. {
  1849. return !!rtwdev->sta_cnt;
  1850. }
  1851. static inline struct ieee80211_txq *rtwtxq_to_txq(struct rtw_txq *rtwtxq)
  1852. {
  1853. void *p = rtwtxq;
  1854. return container_of(p, struct ieee80211_txq, drv_priv);
  1855. }
  1856. static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw_vif *rtwvif)
  1857. {
  1858. void *p = rtwvif;
  1859. return container_of(p, struct ieee80211_vif, drv_priv);
  1860. }
  1861. static inline void rtw_chip_efuse_grant_on(struct rtw_dev *rtwdev)
  1862. {
  1863. if (rtwdev->chip->ops->efuse_grant)
  1864. rtwdev->chip->ops->efuse_grant(rtwdev, true);
  1865. }
  1866. static inline void rtw_chip_efuse_grant_off(struct rtw_dev *rtwdev)
  1867. {
  1868. if (rtwdev->chip->ops->efuse_grant)
  1869. rtwdev->chip->ops->efuse_grant(rtwdev, false);
  1870. }
  1871. static inline bool rtw_chip_wcpu_8051(struct rtw_dev *rtwdev)
  1872. {
  1873. return rtwdev->chip->wlan_cpu == RTW_WCPU_8051;
  1874. }
  1875. static inline bool rtw_chip_wcpu_3081(struct rtw_dev *rtwdev)
  1876. {
  1877. return rtwdev->chip->wlan_cpu == RTW_WCPU_3081;
  1878. }
  1879. static inline bool rtw_chip_has_rx_ldpc(struct rtw_dev *rtwdev)
  1880. {
  1881. return rtwdev->chip->rx_ldpc;
  1882. }
  1883. static inline bool rtw_chip_has_tx_stbc(struct rtw_dev *rtwdev)
  1884. {
  1885. return rtwdev->chip->tx_stbc;
  1886. }
  1887. static inline u8 rtw_acquire_macid(struct rtw_dev *rtwdev)
  1888. {
  1889. unsigned long mac_id;
  1890. mac_id = find_first_zero_bit(rtwdev->mac_id_map, RTW_MAX_MAC_ID_NUM);
  1891. if (mac_id < RTW_MAX_MAC_ID_NUM)
  1892. set_bit(mac_id, rtwdev->mac_id_map);
  1893. return mac_id;
  1894. }
  1895. static inline void rtw_release_macid(struct rtw_dev *rtwdev, u8 mac_id)
  1896. {
  1897. clear_bit(mac_id, rtwdev->mac_id_map);
  1898. }
  1899. static inline int rtw_chip_dump_fw_crash(struct rtw_dev *rtwdev)
  1900. {
  1901. if (rtwdev->chip->ops->dump_fw_crash)
  1902. return rtwdev->chip->ops->dump_fw_crash(rtwdev);
  1903. return 0;
  1904. }
  1905. static inline
  1906. enum nl80211_band rtw_hw_to_nl80211_band(enum rtw_supported_band hw_band)
  1907. {
  1908. switch (hw_band) {
  1909. default:
  1910. case RTW_BAND_2G:
  1911. return NL80211_BAND_2GHZ;
  1912. case RTW_BAND_5G:
  1913. return NL80211_BAND_5GHZ;
  1914. case RTW_BAND_60G:
  1915. return NL80211_BAND_60GHZ;
  1916. }
  1917. }
  1918. void rtw_set_rx_freq_band(struct rtw_rx_pkt_stat *pkt_stat, u8 channel);
  1919. void rtw_set_dtim_period(struct rtw_dev *rtwdev, u8 dtim_period);
  1920. void rtw_get_channel_params(struct cfg80211_chan_def *chandef,
  1921. struct rtw_channel_params *ch_param);
  1922. bool check_hw_ready(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 target);
  1923. bool ltecoex_read_reg(struct rtw_dev *rtwdev, u16 offset, u32 *val);
  1924. bool ltecoex_reg_write(struct rtw_dev *rtwdev, u16 offset, u32 value);
  1925. void rtw_restore_reg(struct rtw_dev *rtwdev,
  1926. struct rtw_backup_info *bckp, u32 num);
  1927. void rtw_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss);
  1928. void rtw_set_channel(struct rtw_dev *rtwdev);
  1929. void rtw_chip_prepare_tx(struct rtw_dev *rtwdev);
  1930. void rtw_vif_port_config(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif,
  1931. u32 config);
  1932. void rtw_tx_report_purge_timer(struct timer_list *t);
  1933. void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
  1934. bool reset_ra_mask);
  1935. void rtw_core_scan_start(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif,
  1936. const u8 *mac_addr, bool hw_scan);
  1937. void rtw_core_scan_complete(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
  1938. bool hw_scan);
  1939. int rtw_core_start(struct rtw_dev *rtwdev);
  1940. void rtw_power_off(struct rtw_dev *rtwdev);
  1941. void rtw_core_stop(struct rtw_dev *rtwdev);
  1942. int rtw_chip_info_setup(struct rtw_dev *rtwdev);
  1943. int rtw_core_init(struct rtw_dev *rtwdev);
  1944. void rtw_core_deinit(struct rtw_dev *rtwdev);
  1945. int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw);
  1946. void rtw_unregister_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw);
  1947. u16 rtw_desc_to_bitrate(u8 desc_rate);
  1948. void rtw_vif_assoc_changed(struct rtw_vif *rtwvif,
  1949. struct ieee80211_bss_conf *conf);
  1950. int rtw_sta_add(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
  1951. struct ieee80211_vif *vif);
  1952. void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
  1953. bool fw_exist);
  1954. void rtw_fw_recovery(struct rtw_dev *rtwdev);
  1955. int rtw_wait_firmware_completion(struct rtw_dev *rtwdev);
  1956. int rtw_power_on(struct rtw_dev *rtwdev);
  1957. void rtw_core_fw_scan_notify(struct rtw_dev *rtwdev, bool start);
  1958. int rtw_dump_fw(struct rtw_dev *rtwdev, const u32 ocp_src, u32 size,
  1959. u32 fwcd_item);
  1960. int rtw_dump_reg(struct rtw_dev *rtwdev, const u32 addr, const u32 size);
  1961. void rtw_set_txrx_1ss(struct rtw_dev *rtwdev, bool config_1ss);
  1962. void rtw_update_channel(struct rtw_dev *rtwdev, u8 center_channel,
  1963. u8 primary_channel, enum rtw_supported_band band,
  1964. enum rtw_bandwidth bandwidth);
  1965. void rtw_core_port_switch(struct rtw_dev *rtwdev, struct ieee80211_vif *vif);
  1966. bool rtw_core_check_sta_active(struct rtw_dev *rtwdev);
  1967. void rtw_core_enable_beacon(struct rtw_dev *rtwdev, bool enable);
  1968. void rtw_set_ampdu_factor(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
  1969. struct ieee80211_bss_conf *bss_conf);
  1970. #endif