wil6210.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  4. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef __WIL6210_H__
  7. #define __WIL6210_H__
  8. #include <linux/etherdevice.h>
  9. #include <linux/netdevice.h>
  10. #include <linux/wireless.h>
  11. #include <net/cfg80211.h>
  12. #include <linux/timex.h>
  13. #include <linux/types.h>
  14. #include <linux/irqreturn.h>
  15. #include "wmi.h"
  16. #include "wil_platform.h"
  17. #include "fw.h"
  18. extern bool no_fw_recovery;
  19. extern unsigned int mtu_max;
  20. extern unsigned short rx_ring_overflow_thrsh;
  21. extern int agg_wsize;
  22. extern bool rx_align_2;
  23. extern bool rx_large_buf;
  24. extern bool debug_fw;
  25. extern bool disable_ap_sme;
  26. extern bool ftm_mode;
  27. extern bool drop_if_ring_full;
  28. extern uint max_assoc_sta;
  29. struct wil6210_priv;
  30. struct wil6210_vif;
  31. union wil_tx_desc;
  32. #define WIL_NAME "wil6210"
  33. #define WIL_FW_NAME_DEFAULT "wil6210.fw"
  34. #define WIL_FW_NAME_FTM_DEFAULT "wil6210_ftm.fw"
  35. #define WIL_FW_NAME_SPARROW_PLUS "wil6210_sparrow_plus.fw"
  36. #define WIL_FW_NAME_FTM_SPARROW_PLUS "wil6210_sparrow_plus_ftm.fw"
  37. #define WIL_FW_NAME_TALYN "wil6436.fw"
  38. #define WIL_FW_NAME_FTM_TALYN "wil6436_ftm.fw"
  39. #define WIL_BRD_NAME_TALYN "wil6436.brd"
  40. #define WIL_BOARD_FILE_NAME "wil6210.brd" /* board & radio parameters */
  41. #define WIL_DEFAULT_BUS_REQUEST_KBPS 128000 /* ~1Gbps */
  42. #define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */
  43. #define WIL_NUM_LATENCY_BINS 200
  44. /* maximum number of virtual interfaces the driver supports
  45. * (including the main interface)
  46. */
  47. #define WIL_MAX_VIFS 4
  48. /**
  49. * extract bits [@b0:@b1] (inclusive) from the value @x
  50. * it should be @b0 <= @b1, or result is incorrect
  51. */
  52. static inline u32 WIL_GET_BITS(u32 x, int b0, int b1)
  53. {
  54. return (x >> b0) & ((1 << (b1 - b0 + 1)) - 1);
  55. }
  56. #define WIL6210_MIN_MEM_SIZE (2 * 1024 * 1024UL)
  57. #define WIL6210_MAX_MEM_SIZE (4 * 1024 * 1024UL)
  58. #define WIL_TX_Q_LEN_DEFAULT (4000)
  59. #define WIL_RX_RING_SIZE_ORDER_DEFAULT (10)
  60. #define WIL_RX_RING_SIZE_ORDER_TALYN_DEFAULT (11)
  61. #define WIL_TX_RING_SIZE_ORDER_DEFAULT (12)
  62. #define WIL_BCAST_RING_SIZE_ORDER_DEFAULT (7)
  63. #define WIL_BCAST_MCS0_LIMIT (1024) /* limit for MCS0 frame size */
  64. /* limit ring size in range [32..32k] */
  65. #define WIL_RING_SIZE_ORDER_MIN (5)
  66. #define WIL_RING_SIZE_ORDER_MAX (15)
  67. #define WIL6210_MAX_TX_RINGS (24) /* HW limit */
  68. #define WIL6210_MAX_CID (20) /* max number of stations */
  69. #define WIL6210_RX_DESC_MAX_CID (8) /* HW limit */
  70. #define WIL_MAX_AMPDU_SIZE (64 * 1024) /* FW/HW limit */
  71. #define WIL_MAX_AGG_WSIZE (32) /* FW/HW limit */
  72. #define WIL_MAX_AMPDU_SIZE_128 (128 * 1024) /* FW/HW limit */
  73. #define WIL_MAX_AGG_WSIZE_64 (64) /* FW/HW limit */
  74. #define WIL6210_MAX_STATUS_RINGS (8)
  75. #define WIL_WMI_CALL_GENERAL_TO_MS 100
  76. #define WIL_EXTENDED_MCS_26 (26) /* FW reports MCS 12.1 to driver as "26" */
  77. #define WIL_BASE_MCS_FOR_EXTENDED_26 (7) /* MCS 7 is base MCS for MCS 12.1 */
  78. #define WIL_EXTENDED_MCS_CHECK(x) (((x) == WIL_EXTENDED_MCS_26) ? "12.1" : #x)
  79. /* Hardware offload block adds the following:
  80. * 26 bytes - 3-address QoS data header
  81. * 8 bytes - IV + EIV (for GCMP)
  82. * 8 bytes - SNAP
  83. * 16 bytes - MIC (for GCMP)
  84. * 4 bytes - CRC
  85. */
  86. #define WIL_MAX_MPDU_OVERHEAD (62)
  87. struct wil_suspend_count_stats {
  88. unsigned long successful_suspends;
  89. unsigned long successful_resumes;
  90. unsigned long failed_suspends;
  91. unsigned long failed_resumes;
  92. };
  93. struct wil_suspend_stats {
  94. struct wil_suspend_count_stats r_off;
  95. struct wil_suspend_count_stats r_on;
  96. unsigned long rejected_by_device; /* only radio on */
  97. unsigned long rejected_by_host;
  98. };
  99. /* Calculate MAC buffer size for the firmware. It includes all overhead,
  100. * as it will go over the air, and need to be 8 byte aligned
  101. */
  102. static inline u32 wil_mtu2macbuf(u32 mtu)
  103. {
  104. return ALIGN(mtu + WIL_MAX_MPDU_OVERHEAD, 8);
  105. }
  106. /* MTU for Ethernet need to take into account 8-byte SNAP header
  107. * to be added when encapsulating Ethernet frame into 802.11
  108. */
  109. #define WIL_MAX_ETH_MTU (IEEE80211_MAX_DATA_LEN_DMG - 8)
  110. /* Max supported by wil6210 value for interrupt threshold is 5sec. */
  111. #define WIL6210_ITR_TRSH_MAX (5000000)
  112. #define WIL6210_ITR_TX_INTERFRAME_TIMEOUT_DEFAULT (13) /* usec */
  113. #define WIL6210_ITR_RX_INTERFRAME_TIMEOUT_DEFAULT (13) /* usec */
  114. #define WIL6210_ITR_TX_MAX_BURST_DURATION_DEFAULT (500) /* usec */
  115. #define WIL6210_ITR_RX_MAX_BURST_DURATION_DEFAULT (500) /* usec */
  116. #define WIL6210_FW_RECOVERY_RETRIES (5) /* try to recover this many times */
  117. #define WIL6210_FW_RECOVERY_TO msecs_to_jiffies(5000)
  118. #define WIL6210_SCAN_TO msecs_to_jiffies(10000)
  119. #define WIL6210_DISCONNECT_TO_MS (2000)
  120. #define WIL6210_RX_HIGH_TRSH_INIT (0)
  121. #define WIL6210_RX_HIGH_TRSH_DEFAULT \
  122. (1 << (WIL_RX_RING_SIZE_ORDER_DEFAULT - 3))
  123. #define WIL_MAX_DMG_AID 254 /* for DMG only 1-254 allowed (see
  124. * 802.11REVmc/D5.0, section 9.4.1.8)
  125. */
  126. /* Hardware definitions begin */
  127. /*
  128. * Mapping
  129. * RGF File | Host addr | FW addr
  130. * | |
  131. * user_rgf | 0x000000 | 0x880000
  132. * dma_rgf | 0x001000 | 0x881000
  133. * pcie_rgf | 0x002000 | 0x882000
  134. * | |
  135. */
  136. /* Where various structures placed in host address space */
  137. #define WIL6210_FW_HOST_OFF (0x880000UL)
  138. #define HOSTADDR(fwaddr) (fwaddr - WIL6210_FW_HOST_OFF)
  139. /*
  140. * Interrupt control registers block
  141. *
  142. * each interrupt controlled by the same bit in all registers
  143. */
  144. struct RGF_ICR {
  145. u32 ICC; /* Cause Control, RW: 0 - W1C, 1 - COR */
  146. u32 ICR; /* Cause, W1C/COR depending on ICC */
  147. u32 ICM; /* Cause masked (ICR & ~IMV), W1C/COR depending on ICC */
  148. u32 ICS; /* Cause Set, WO */
  149. u32 IMV; /* Mask, RW+S/C */
  150. u32 IMS; /* Mask Set, write 1 to set */
  151. u32 IMC; /* Mask Clear, write 1 to clear */
  152. } __packed;
  153. /* registers - FW addresses */
  154. #define RGF_USER_USAGE_1 (0x880004)
  155. #define RGF_USER_USAGE_2 (0x880008)
  156. #define RGF_USER_USAGE_6 (0x880018)
  157. #define BIT_USER_OOB_MODE BIT(31)
  158. #define BIT_USER_OOB_R2_MODE BIT(30)
  159. #define RGF_USER_USAGE_8 (0x880020)
  160. #define BIT_USER_PREVENT_DEEP_SLEEP BIT(0)
  161. #define BIT_USER_SUPPORT_T_POWER_ON_0 BIT(1)
  162. #define BIT_USER_EXT_CLK BIT(2)
  163. #define RGF_USER_HW_MACHINE_STATE (0x8801dc)
  164. #define HW_MACHINE_BOOT_DONE (0x3fffffd)
  165. #define RGF_USER_USER_CPU_0 (0x8801e0)
  166. #define BIT_USER_USER_CPU_MAN_RST BIT(1) /* user_cpu_man_rst */
  167. #define RGF_USER_CPU_PC (0x8801e8)
  168. #define RGF_USER_MAC_CPU_0 (0x8801fc)
  169. #define BIT_USER_MAC_CPU_MAN_RST BIT(1) /* mac_cpu_man_rst */
  170. #define RGF_USER_USER_SCRATCH_PAD (0x8802bc)
  171. #define RGF_USER_BL (0x880A3C) /* Boot Loader */
  172. #define RGF_USER_FW_REV_ID (0x880a8c) /* chip revision */
  173. #define RGF_USER_FW_CALIB_RESULT (0x880a90) /* b0-7:result
  174. * b8-15:signature
  175. */
  176. #define CALIB_RESULT_SIGNATURE (0x11)
  177. #define RGF_USER_CLKS_CTL_0 (0x880abc)
  178. #define BIT_USER_CLKS_CAR_AHB_SW_SEL BIT(1) /* ref clk/PLL */
  179. #define BIT_USER_CLKS_RST_PWGD BIT(11) /* reset on "power good" */
  180. #define RGF_USER_CLKS_CTL_SW_RST_VEC_0 (0x880b04)
  181. #define RGF_USER_CLKS_CTL_SW_RST_VEC_1 (0x880b08)
  182. #define RGF_USER_CLKS_CTL_SW_RST_VEC_2 (0x880b0c)
  183. #define RGF_USER_CLKS_CTL_SW_RST_VEC_3 (0x880b10)
  184. #define RGF_USER_CLKS_CTL_SW_RST_MASK_0 (0x880b14)
  185. #define BIT_HPAL_PERST_FROM_PAD BIT(6)
  186. #define BIT_CAR_PERST_RST BIT(7)
  187. #define RGF_USER_USER_ICR (0x880b4c) /* struct RGF_ICR */
  188. #define BIT_USER_USER_ICR_SW_INT_2 BIT(18)
  189. #define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0 (0x880c18)
  190. #define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1 (0x880c2c)
  191. #define RGF_USER_SPARROW_M_4 (0x880c50) /* Sparrow */
  192. #define BIT_SPARROW_M_4_SEL_SLEEP_OR_REF BIT(2)
  193. #define RGF_USER_OTP_HW_RD_MACHINE_1 (0x880ce0)
  194. #define BIT_OTP_SIGNATURE_ERR_TALYN_MB BIT(0)
  195. #define BIT_OTP_HW_SECTION_DONE_TALYN_MB BIT(2)
  196. #define BIT_NO_FLASH_INDICATION BIT(8)
  197. #define RGF_USER_XPM_IFC_RD_TIME1 (0x880cec)
  198. #define RGF_USER_XPM_IFC_RD_TIME2 (0x880cf0)
  199. #define RGF_USER_XPM_IFC_RD_TIME3 (0x880cf4)
  200. #define RGF_USER_XPM_IFC_RD_TIME4 (0x880cf8)
  201. #define RGF_USER_XPM_IFC_RD_TIME5 (0x880cfc)
  202. #define RGF_USER_XPM_IFC_RD_TIME6 (0x880d00)
  203. #define RGF_USER_XPM_IFC_RD_TIME7 (0x880d04)
  204. #define RGF_USER_XPM_IFC_RD_TIME8 (0x880d08)
  205. #define RGF_USER_XPM_IFC_RD_TIME9 (0x880d0c)
  206. #define RGF_USER_XPM_IFC_RD_TIME10 (0x880d10)
  207. #define RGF_USER_XPM_RD_DOUT_SAMPLE_TIME (0x880d64)
  208. #define RGF_DMA_EP_TX_ICR (0x881bb4) /* struct RGF_ICR */
  209. #define BIT_DMA_EP_TX_ICR_TX_DONE BIT(0)
  210. #define BIT_DMA_EP_TX_ICR_TX_DONE_N(n) BIT(n+1) /* n = [0..23] */
  211. #define RGF_DMA_EP_RX_ICR (0x881bd0) /* struct RGF_ICR */
  212. #define BIT_DMA_EP_RX_ICR_RX_DONE BIT(0)
  213. #define BIT_DMA_EP_RX_ICR_RX_HTRSH BIT(1)
  214. #define RGF_DMA_EP_MISC_ICR (0x881bec) /* struct RGF_ICR */
  215. #define BIT_DMA_EP_MISC_ICR_RX_HTRSH BIT(0)
  216. #define BIT_DMA_EP_MISC_ICR_TX_NO_ACT BIT(1)
  217. #define BIT_DMA_EP_MISC_ICR_HALP BIT(27)
  218. #define BIT_DMA_EP_MISC_ICR_FW_INT(n) BIT(28+n) /* n = [0..3] */
  219. /* Legacy interrupt moderation control (before Sparrow v2)*/
  220. #define RGF_DMA_ITR_CNT_TRSH (0x881c5c)
  221. #define RGF_DMA_ITR_CNT_DATA (0x881c60)
  222. #define RGF_DMA_ITR_CNT_CRL (0x881c64)
  223. #define BIT_DMA_ITR_CNT_CRL_EN BIT(0)
  224. #define BIT_DMA_ITR_CNT_CRL_EXT_TICK BIT(1)
  225. #define BIT_DMA_ITR_CNT_CRL_FOREVER BIT(2)
  226. #define BIT_DMA_ITR_CNT_CRL_CLR BIT(3)
  227. #define BIT_DMA_ITR_CNT_CRL_REACH_TRSH BIT(4)
  228. /* Offload control (Sparrow B0+) */
  229. #define RGF_DMA_OFUL_NID_0 (0x881cd4)
  230. #define BIT_DMA_OFUL_NID_0_RX_EXT_TR_EN BIT(0)
  231. #define BIT_DMA_OFUL_NID_0_TX_EXT_TR_EN BIT(1)
  232. #define BIT_DMA_OFUL_NID_0_RX_EXT_A3_SRC BIT(2)
  233. #define BIT_DMA_OFUL_NID_0_TX_EXT_A3_SRC BIT(3)
  234. /* New (sparrow v2+) interrupt moderation control */
  235. #define RGF_DMA_ITR_TX_DESQ_NO_MOD (0x881d40)
  236. #define RGF_DMA_ITR_TX_CNT_TRSH (0x881d34)
  237. #define RGF_DMA_ITR_TX_CNT_DATA (0x881d38)
  238. #define RGF_DMA_ITR_TX_CNT_CTL (0x881d3c)
  239. #define BIT_DMA_ITR_TX_CNT_CTL_EN BIT(0)
  240. #define BIT_DMA_ITR_TX_CNT_CTL_EXT_TIC_SEL BIT(1)
  241. #define BIT_DMA_ITR_TX_CNT_CTL_FOREVER BIT(2)
  242. #define BIT_DMA_ITR_TX_CNT_CTL_CLR BIT(3)
  243. #define BIT_DMA_ITR_TX_CNT_CTL_REACHED_TRESH BIT(4)
  244. #define BIT_DMA_ITR_TX_CNT_CTL_CROSS_EN BIT(5)
  245. #define BIT_DMA_ITR_TX_CNT_CTL_FREE_RUNNIG BIT(6)
  246. #define RGF_DMA_ITR_TX_IDL_CNT_TRSH (0x881d60)
  247. #define RGF_DMA_ITR_TX_IDL_CNT_DATA (0x881d64)
  248. #define RGF_DMA_ITR_TX_IDL_CNT_CTL (0x881d68)
  249. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_EN BIT(0)
  250. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_EXT_TIC_SEL BIT(1)
  251. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_FOREVER BIT(2)
  252. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_CLR BIT(3)
  253. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_REACHED_TRESH BIT(4)
  254. #define RGF_DMA_ITR_RX_DESQ_NO_MOD (0x881d50)
  255. #define RGF_DMA_ITR_RX_CNT_TRSH (0x881d44)
  256. #define RGF_DMA_ITR_RX_CNT_DATA (0x881d48)
  257. #define RGF_DMA_ITR_RX_CNT_CTL (0x881d4c)
  258. #define BIT_DMA_ITR_RX_CNT_CTL_EN BIT(0)
  259. #define BIT_DMA_ITR_RX_CNT_CTL_EXT_TIC_SEL BIT(1)
  260. #define BIT_DMA_ITR_RX_CNT_CTL_FOREVER BIT(2)
  261. #define BIT_DMA_ITR_RX_CNT_CTL_CLR BIT(3)
  262. #define BIT_DMA_ITR_RX_CNT_CTL_REACHED_TRESH BIT(4)
  263. #define BIT_DMA_ITR_RX_CNT_CTL_CROSS_EN BIT(5)
  264. #define BIT_DMA_ITR_RX_CNT_CTL_FREE_RUNNIG BIT(6)
  265. #define RGF_DMA_ITR_RX_IDL_CNT_TRSH (0x881d54)
  266. #define RGF_DMA_ITR_RX_IDL_CNT_DATA (0x881d58)
  267. #define RGF_DMA_ITR_RX_IDL_CNT_CTL (0x881d5c)
  268. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_EN BIT(0)
  269. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_EXT_TIC_SEL BIT(1)
  270. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_FOREVER BIT(2)
  271. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_CLR BIT(3)
  272. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_REACHED_TRESH BIT(4)
  273. #define RGF_DMA_MISC_CTL (0x881d6c)
  274. #define BIT_OFUL34_RDY_VALID_BUG_FIX_EN BIT(7)
  275. #define RGF_DMA_PSEUDO_CAUSE (0x881c68)
  276. #define RGF_DMA_PSEUDO_CAUSE_MASK_SW (0x881c6c)
  277. #define RGF_DMA_PSEUDO_CAUSE_MASK_FW (0x881c70)
  278. #define BIT_DMA_PSEUDO_CAUSE_RX BIT(0)
  279. #define BIT_DMA_PSEUDO_CAUSE_TX BIT(1)
  280. #define BIT_DMA_PSEUDO_CAUSE_MISC BIT(2)
  281. #define RGF_HP_CTRL (0x88265c)
  282. #define RGF_PAL_UNIT_ICR (0x88266c) /* struct RGF_ICR */
  283. #define RGF_PCIE_LOS_COUNTER_CTL (0x882dc4)
  284. /* MAC timer, usec, for packet lifetime */
  285. #define RGF_MAC_MTRL_COUNTER_0 (0x886aa8)
  286. #define RGF_CAF_ICR_TALYN_MB (0x8893d4) /* struct RGF_ICR */
  287. #define RGF_CAF_ICR (0x88946c) /* struct RGF_ICR */
  288. #define RGF_CAF_OSC_CONTROL (0x88afa4)
  289. #define BIT_CAF_OSC_XTAL_EN BIT(0)
  290. #define RGF_CAF_PLL_LOCK_STATUS (0x88afec)
  291. #define BIT_CAF_OSC_DIG_XTAL_STABLE BIT(0)
  292. #define RGF_OTP_QC_SECURED (0x8a0038)
  293. #define BIT_BOOT_FROM_ROM BIT(31)
  294. /* eDMA */
  295. #define RGF_SCM_PTRS_SUBQ_RD_PTR (0x8b4000)
  296. #define RGF_SCM_PTRS_COMPQ_RD_PTR (0x8b4100)
  297. #define RGF_DMA_SCM_SUBQ_CONS (0x8b60ec)
  298. #define RGF_DMA_SCM_COMPQ_PROD (0x8b616c)
  299. #define RGF_INT_COUNT_ON_SPECIAL_EVT (0x8b62d8)
  300. #define RGF_INT_CTRL_INT_GEN_CFG_0 (0x8bc000)
  301. #define RGF_INT_CTRL_INT_GEN_CFG_1 (0x8bc004)
  302. #define RGF_INT_GEN_TIME_UNIT_LIMIT (0x8bc0c8)
  303. #define RGF_INT_GEN_CTRL (0x8bc0ec)
  304. #define BIT_CONTROL_0 BIT(0)
  305. /* eDMA status interrupts */
  306. #define RGF_INT_GEN_RX_ICR (0x8bc0f4)
  307. #define BIT_RX_STATUS_IRQ BIT(WIL_RX_STATUS_IRQ_IDX)
  308. #define RGF_INT_GEN_TX_ICR (0x8bc110)
  309. #define BIT_TX_STATUS_IRQ BIT(WIL_TX_STATUS_IRQ_IDX)
  310. #define RGF_INT_CTRL_RX_INT_MASK (0x8bc12c)
  311. #define RGF_INT_CTRL_TX_INT_MASK (0x8bc130)
  312. #define RGF_INT_GEN_IDLE_TIME_LIMIT (0x8bc134)
  313. #define USER_EXT_USER_PMU_3 (0x88d00c)
  314. #define BIT_PMU_DEVICE_RDY BIT(0)
  315. #define RGF_USER_JTAG_DEV_ID (0x880b34) /* device ID */
  316. #define JTAG_DEV_ID_SPARROW (0x2632072f)
  317. #define JTAG_DEV_ID_TALYN (0x7e0e1)
  318. #define JTAG_DEV_ID_TALYN_MB (0x1007e0e1)
  319. #define RGF_USER_REVISION_ID (0x88afe4)
  320. #define RGF_USER_REVISION_ID_MASK (3)
  321. #define REVISION_ID_SPARROW_B0 (0x0)
  322. #define REVISION_ID_SPARROW_D0 (0x3)
  323. #define RGF_OTP_MAC_TALYN_MB (0x8a0304)
  324. #define RGF_OTP_OEM_MAC (0x8a0334)
  325. #define RGF_OTP_MAC (0x8a0620)
  326. /* Talyn-MB */
  327. #define RGF_USER_USER_CPU_0_TALYN_MB (0x8c0138)
  328. #define RGF_USER_MAC_CPU_0_TALYN_MB (0x8c0154)
  329. /* crash codes for FW/Ucode stored here */
  330. /* ASSERT RGFs */
  331. #define SPARROW_RGF_FW_ASSERT_CODE (0x91f020)
  332. #define SPARROW_RGF_UCODE_ASSERT_CODE (0x91f028)
  333. #define TALYN_RGF_FW_ASSERT_CODE (0xa37020)
  334. #define TALYN_RGF_UCODE_ASSERT_CODE (0xa37028)
  335. enum {
  336. HW_VER_UNKNOWN,
  337. HW_VER_SPARROW_B0, /* REVISION_ID_SPARROW_B0 */
  338. HW_VER_SPARROW_D0, /* REVISION_ID_SPARROW_D0 */
  339. HW_VER_TALYN, /* JTAG_DEV_ID_TALYN */
  340. HW_VER_TALYN_MB /* JTAG_DEV_ID_TALYN_MB */
  341. };
  342. /* popular locations */
  343. #define RGF_MBOX RGF_USER_USER_SCRATCH_PAD
  344. #define HOST_MBOX HOSTADDR(RGF_MBOX)
  345. #define SW_INT_MBOX BIT_USER_USER_ICR_SW_INT_2
  346. /* ISR register bits */
  347. #define ISR_MISC_FW_READY BIT_DMA_EP_MISC_ICR_FW_INT(0)
  348. #define ISR_MISC_MBOX_EVT BIT_DMA_EP_MISC_ICR_FW_INT(1)
  349. #define ISR_MISC_FW_ERROR BIT_DMA_EP_MISC_ICR_FW_INT(3)
  350. #define WIL_DATA_COMPLETION_TO_MS 200
  351. /* Hardware definitions end */
  352. #define SPARROW_FW_MAPPING_TABLE_SIZE 10
  353. #define TALYN_FW_MAPPING_TABLE_SIZE 13
  354. #define TALYN_MB_FW_MAPPING_TABLE_SIZE 19
  355. #define MAX_FW_MAPPING_TABLE_SIZE 19
  356. /* Common representation of physical address in wil ring */
  357. struct wil_ring_dma_addr {
  358. __le32 addr_low;
  359. __le16 addr_high;
  360. } __packed;
  361. struct fw_map {
  362. u32 from; /* linker address - from, inclusive */
  363. u32 to; /* linker address - to, exclusive */
  364. u32 host; /* PCI/Host address - BAR0 + 0x880000 */
  365. const char *name; /* for debugfs */
  366. bool fw; /* true if FW mapping, false if UCODE mapping */
  367. bool crash_dump; /* true if should be dumped during crash dump */
  368. };
  369. /* array size should be in sync with actual definition in the wmi.c */
  370. extern const struct fw_map sparrow_fw_mapping[SPARROW_FW_MAPPING_TABLE_SIZE];
  371. extern const struct fw_map sparrow_d0_mac_rgf_ext;
  372. extern const struct fw_map talyn_fw_mapping[TALYN_FW_MAPPING_TABLE_SIZE];
  373. extern const struct fw_map talyn_mb_fw_mapping[TALYN_MB_FW_MAPPING_TABLE_SIZE];
  374. extern struct fw_map fw_mapping[MAX_FW_MAPPING_TABLE_SIZE];
  375. /**
  376. * mk_cidxtid - construct @cidxtid field
  377. * @cid: CID value
  378. * @tid: TID value
  379. *
  380. * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
  381. */
  382. static inline u8 mk_cidxtid(u8 cid, u8 tid)
  383. {
  384. return ((tid & 0xf) << 4) | (cid & 0xf);
  385. }
  386. /**
  387. * parse_cidxtid - parse @cidxtid field
  388. * @cid: store CID value here
  389. * @tid: store TID value here
  390. *
  391. * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
  392. */
  393. static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
  394. {
  395. *cid = cidxtid & 0xf;
  396. *tid = (cidxtid >> 4) & 0xf;
  397. }
  398. struct wil6210_mbox_ring {
  399. u32 base;
  400. u16 entry_size; /* max. size of mbox entry, incl. all headers */
  401. u16 size;
  402. u32 tail;
  403. u32 head;
  404. } __packed;
  405. struct wil6210_mbox_ring_desc {
  406. __le32 sync;
  407. __le32 addr;
  408. } __packed;
  409. /* at HOST_OFF_WIL6210_MBOX_CTL */
  410. struct wil6210_mbox_ctl {
  411. struct wil6210_mbox_ring tx;
  412. struct wil6210_mbox_ring rx;
  413. } __packed;
  414. struct wil6210_mbox_hdr {
  415. __le16 seq;
  416. __le16 len; /* payload, bytes after this header */
  417. __le16 type;
  418. u8 flags;
  419. u8 reserved;
  420. } __packed;
  421. #define WIL_MBOX_HDR_TYPE_WMI (0)
  422. /* max. value for wil6210_mbox_hdr.len */
  423. #define MAX_MBOXITEM_SIZE (240)
  424. struct pending_wmi_event {
  425. struct list_head list;
  426. struct {
  427. struct wil6210_mbox_hdr hdr;
  428. struct wmi_cmd_hdr wmi;
  429. u8 data[0];
  430. } __packed event;
  431. };
  432. enum { /* for wil_ctx.mapped_as */
  433. wil_mapped_as_none = 0,
  434. wil_mapped_as_single = 1,
  435. wil_mapped_as_page = 2,
  436. };
  437. /**
  438. * struct wil_ctx - software context for ring descriptor
  439. */
  440. struct wil_ctx {
  441. struct sk_buff *skb;
  442. u8 nr_frags;
  443. u8 mapped_as;
  444. };
  445. struct wil_desc_ring_rx_swtail { /* relevant for enhanced DMA only */
  446. u32 *va;
  447. dma_addr_t pa;
  448. };
  449. /**
  450. * A general ring structure, used for RX and TX.
  451. * In legacy DMA it represents the vring,
  452. * In enahnced DMA it represents the descriptor ring (vrings are handled by FW)
  453. */
  454. struct wil_ring {
  455. dma_addr_t pa;
  456. volatile union wil_ring_desc *va;
  457. u16 size; /* number of wil_ring_desc elements */
  458. u32 swtail;
  459. u32 swhead;
  460. u32 hwtail; /* write here to inform hw */
  461. struct wil_ctx *ctx; /* ctx[size] - software context */
  462. struct wil_desc_ring_rx_swtail edma_rx_swtail;
  463. bool is_rx;
  464. };
  465. /**
  466. * Additional data for Rx ring.
  467. * Used for enhanced DMA RX chaining.
  468. */
  469. struct wil_ring_rx_data {
  470. /* the skb being assembled */
  471. struct sk_buff *skb;
  472. /* true if we are skipping a bad fragmented packet */
  473. bool skipping;
  474. u16 buff_size;
  475. };
  476. /**
  477. * Status ring structure, used for enhanced DMA completions for RX and TX.
  478. */
  479. struct wil_status_ring {
  480. dma_addr_t pa;
  481. void *va; /* pointer to ring_[tr]x_status elements */
  482. u16 size; /* number of status elements */
  483. size_t elem_size; /* status element size in bytes */
  484. u32 swhead;
  485. u32 hwtail; /* write here to inform hw */
  486. bool is_rx;
  487. u8 desc_rdy_pol; /* Expected descriptor ready bit polarity */
  488. struct wil_ring_rx_data rx_data;
  489. u32 invalid_buff_id_cnt; /* relevant only for RX */
  490. };
  491. #define WIL_STA_TID_NUM (16)
  492. #define WIL_MCS_MAX (15) /* Maximum MCS supported */
  493. struct wil_net_stats {
  494. unsigned long rx_packets;
  495. unsigned long tx_packets;
  496. unsigned long rx_bytes;
  497. unsigned long tx_bytes;
  498. unsigned long tx_errors;
  499. u32 tx_latency_min_us;
  500. u32 tx_latency_max_us;
  501. u64 tx_latency_total_us;
  502. unsigned long rx_dropped;
  503. unsigned long rx_non_data_frame;
  504. unsigned long rx_short_frame;
  505. unsigned long rx_large_frame;
  506. unsigned long rx_replay;
  507. unsigned long rx_mic_error;
  508. unsigned long rx_key_error; /* eDMA specific */
  509. unsigned long rx_amsdu_error; /* eDMA specific */
  510. unsigned long rx_csum_err;
  511. u16 last_mcs_rx;
  512. u8 last_cb_mode_rx;
  513. u64 rx_per_mcs[WIL_MCS_MAX + 1];
  514. u32 ft_roams; /* relevant in STA mode */
  515. };
  516. /**
  517. * struct tx_rx_ops - different TX/RX ops for legacy and enhanced
  518. * DMA flow
  519. */
  520. struct wil_txrx_ops {
  521. void (*configure_interrupt_moderation)(struct wil6210_priv *wil);
  522. /* TX ops */
  523. int (*ring_init_tx)(struct wil6210_vif *vif, int ring_id,
  524. int size, int cid, int tid);
  525. void (*ring_fini_tx)(struct wil6210_priv *wil, struct wil_ring *ring);
  526. int (*ring_init_bcast)(struct wil6210_vif *vif, int id, int size);
  527. int (*tx_init)(struct wil6210_priv *wil);
  528. void (*tx_fini)(struct wil6210_priv *wil);
  529. int (*tx_desc_map)(union wil_tx_desc *desc, dma_addr_t pa,
  530. u32 len, int ring_index);
  531. void (*tx_desc_unmap)(struct device *dev,
  532. union wil_tx_desc *desc,
  533. struct wil_ctx *ctx);
  534. int (*tx_ring_tso)(struct wil6210_priv *wil, struct wil6210_vif *vif,
  535. struct wil_ring *ring, struct sk_buff *skb);
  536. int (*tx_ring_modify)(struct wil6210_vif *vif, int ring_id,
  537. int cid, int tid);
  538. irqreturn_t (*irq_tx)(int irq, void *cookie);
  539. /* RX ops */
  540. int (*rx_init)(struct wil6210_priv *wil, uint ring_order);
  541. void (*rx_fini)(struct wil6210_priv *wil);
  542. int (*wmi_addba_rx_resp)(struct wil6210_priv *wil, u8 mid, u8 cid,
  543. u8 tid, u8 token, u16 status, bool amsdu,
  544. u16 agg_wsize, u16 timeout);
  545. void (*get_reorder_params)(struct wil6210_priv *wil,
  546. struct sk_buff *skb, int *tid, int *cid,
  547. int *mid, u16 *seq, int *mcast, int *retry);
  548. void (*get_netif_rx_params)(struct sk_buff *skb,
  549. int *cid, int *security);
  550. int (*rx_crypto_check)(struct wil6210_priv *wil, struct sk_buff *skb);
  551. int (*rx_error_check)(struct wil6210_priv *wil, struct sk_buff *skb,
  552. struct wil_net_stats *stats);
  553. bool (*is_rx_idle)(struct wil6210_priv *wil);
  554. irqreturn_t (*irq_rx)(int irq, void *cookie);
  555. };
  556. /**
  557. * Additional data for Tx ring
  558. */
  559. struct wil_ring_tx_data {
  560. bool dot1x_open;
  561. int enabled;
  562. cycles_t idle, last_idle, begin;
  563. u8 agg_wsize; /* agreed aggregation window, 0 - no agg */
  564. u16 agg_timeout;
  565. u8 agg_amsdu;
  566. bool addba_in_progress; /* if set, agg_xxx is for request in progress */
  567. u8 mid;
  568. spinlock_t lock;
  569. };
  570. enum { /* for wil6210_priv.status */
  571. wil_status_fwready = 0, /* FW operational */
  572. wil_status_dontscan,
  573. wil_status_mbox_ready, /* MBOX structures ready */
  574. wil_status_irqen, /* interrupts enabled - for debug */
  575. wil_status_napi_en, /* NAPI enabled protected by wil->mutex */
  576. wil_status_resetting, /* reset in progress */
  577. wil_status_suspending, /* suspend in progress */
  578. wil_status_suspended, /* suspend completed, device is suspended */
  579. wil_status_resuming, /* resume in progress */
  580. wil_status_last /* keep last */
  581. };
  582. struct pci_dev;
  583. /**
  584. * struct tid_ampdu_rx - TID aggregation information (Rx).
  585. *
  586. * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  587. * @last_rx: jiffies of last rx activity
  588. * @head_seq_num: head sequence number in reordering buffer.
  589. * @stored_mpdu_num: number of MPDUs in reordering buffer
  590. * @ssn: Starting Sequence Number expected to be aggregated.
  591. * @buf_size: buffer size for incoming A-MPDUs
  592. * @ssn_last_drop: SSN of the last dropped frame
  593. * @total: total number of processed incoming frames
  594. * @drop_dup: duplicate frames dropped for this reorder buffer
  595. * @drop_old: old frames dropped for this reorder buffer
  596. * @first_time: true when this buffer used 1-st time
  597. * @mcast_last_seq: sequence number (SN) of last received multicast packet
  598. * @drop_dup_mcast: duplicate multicast frames dropped for this reorder buffer
  599. */
  600. struct wil_tid_ampdu_rx {
  601. struct sk_buff **reorder_buf;
  602. unsigned long last_rx;
  603. u16 head_seq_num;
  604. u16 stored_mpdu_num;
  605. u16 ssn;
  606. u16 buf_size;
  607. u16 ssn_last_drop;
  608. unsigned long long total; /* frames processed */
  609. unsigned long long drop_dup;
  610. unsigned long long drop_old;
  611. bool first_time; /* is it 1-st time this buffer used? */
  612. u16 mcast_last_seq; /* multicast dup detection */
  613. unsigned long long drop_dup_mcast;
  614. };
  615. /**
  616. * struct wil_tid_crypto_rx_single - TID crypto information (Rx).
  617. *
  618. * @pn: GCMP PN for the session
  619. * @key_set: valid key present
  620. */
  621. struct wil_tid_crypto_rx_single {
  622. u8 pn[IEEE80211_GCMP_PN_LEN];
  623. bool key_set;
  624. };
  625. struct wil_tid_crypto_rx {
  626. struct wil_tid_crypto_rx_single key_id[4];
  627. };
  628. struct wil_p2p_info {
  629. struct ieee80211_channel listen_chan;
  630. u8 discovery_started;
  631. u64 cookie;
  632. struct wireless_dev *pending_listen_wdev;
  633. unsigned int listen_duration;
  634. struct timer_list discovery_timer; /* listen/search duration */
  635. struct work_struct discovery_expired_work; /* listen/search expire */
  636. struct work_struct delayed_listen_work; /* listen after scan done */
  637. };
  638. enum wil_sta_status {
  639. wil_sta_unused = 0,
  640. wil_sta_conn_pending = 1,
  641. wil_sta_connected = 2,
  642. };
  643. enum wil_rekey_state {
  644. WIL_REKEY_IDLE = 0,
  645. WIL_REKEY_M3_RECEIVED = 1,
  646. WIL_REKEY_WAIT_M4_SENT = 2,
  647. };
  648. /**
  649. * struct wil_sta_info - data for peer
  650. *
  651. * Peer identified by its CID (connection ID)
  652. * NIC performs beam forming for each peer;
  653. * if no beam forming done, frame exchange is not
  654. * possible.
  655. */
  656. struct wil_sta_info {
  657. u8 addr[ETH_ALEN];
  658. u8 mid;
  659. enum wil_sta_status status;
  660. struct wil_net_stats stats;
  661. /**
  662. * 20 latency bins. 1st bin counts packets with latency
  663. * of 0..tx_latency_res, last bin counts packets with latency
  664. * of 19*tx_latency_res and above.
  665. * tx_latency_res is configured from "tx_latency" debug-fs.
  666. */
  667. u64 *tx_latency_bins;
  668. struct wmi_link_stats_basic fw_stats_basic;
  669. /* Rx BACK */
  670. struct wil_tid_ampdu_rx *tid_rx[WIL_STA_TID_NUM];
  671. spinlock_t tid_rx_lock; /* guarding tid_rx array */
  672. unsigned long tid_rx_timer_expired[BITS_TO_LONGS(WIL_STA_TID_NUM)];
  673. unsigned long tid_rx_stop_requested[BITS_TO_LONGS(WIL_STA_TID_NUM)];
  674. struct wil_tid_crypto_rx tid_crypto_rx[WIL_STA_TID_NUM];
  675. struct wil_tid_crypto_rx group_crypto_rx;
  676. u8 aid; /* 1-254; 0 if unknown/not reported */
  677. /* amsdu frame related info to check if the frame is valid */
  678. int amsdu_drop_sn;
  679. int amsdu_drop_tid;
  680. u8 amsdu_drop;
  681. };
  682. enum {
  683. fw_recovery_idle = 0,
  684. fw_recovery_pending = 1,
  685. fw_recovery_running = 2,
  686. };
  687. enum {
  688. hw_capa_no_flash,
  689. hw_capa_last
  690. };
  691. struct wil_probe_client_req {
  692. struct list_head list;
  693. u64 cookie;
  694. u8 cid;
  695. };
  696. struct pmc_ctx {
  697. /* alloc, free, and read operations must own the lock */
  698. struct mutex lock;
  699. struct vring_tx_desc *pring_va;
  700. dma_addr_t pring_pa;
  701. struct desc_alloc_info *descriptors;
  702. int last_cmd_status;
  703. int num_descriptors;
  704. int descriptor_size;
  705. };
  706. struct wil_halp {
  707. struct mutex lock; /* protect halp ref_cnt */
  708. unsigned int ref_cnt;
  709. struct completion comp;
  710. u8 handle_icr;
  711. };
  712. struct wil_blob_wrapper {
  713. struct wil6210_priv *wil;
  714. struct debugfs_blob_wrapper blob;
  715. };
  716. #define WIL_LED_MAX_ID (2)
  717. #define WIL_LED_INVALID_ID (0xF)
  718. #define WIL_LED_BLINK_ON_SLOW_MS (300)
  719. #define WIL_LED_BLINK_OFF_SLOW_MS (300)
  720. #define WIL_LED_BLINK_ON_MED_MS (200)
  721. #define WIL_LED_BLINK_OFF_MED_MS (200)
  722. #define WIL_LED_BLINK_ON_FAST_MS (100)
  723. #define WIL_LED_BLINK_OFF_FAST_MS (100)
  724. enum {
  725. WIL_LED_TIME_SLOW = 0,
  726. WIL_LED_TIME_MED,
  727. WIL_LED_TIME_FAST,
  728. WIL_LED_TIME_LAST,
  729. };
  730. struct blink_on_off_time {
  731. u32 on_ms;
  732. u32 off_ms;
  733. };
  734. struct wil_debugfs_iomem_data {
  735. void *offset;
  736. struct wil6210_priv *wil;
  737. };
  738. struct wil_debugfs_data {
  739. struct wil_debugfs_iomem_data *data_arr;
  740. int iomem_data_count;
  741. };
  742. extern struct blink_on_off_time led_blink_time[WIL_LED_TIME_LAST];
  743. extern u8 led_id;
  744. extern u8 led_polarity;
  745. enum wil6210_vif_status {
  746. wil_vif_fwconnecting,
  747. wil_vif_fwconnected,
  748. wil_vif_ft_roam,
  749. wil_vif_status_last /* keep last */
  750. };
  751. struct wil6210_vif {
  752. struct wireless_dev wdev;
  753. struct net_device *ndev;
  754. struct wil6210_priv *wil;
  755. u8 mid;
  756. DECLARE_BITMAP(status, wil_vif_status_last);
  757. u32 privacy; /* secure connection? */
  758. u16 channel; /* relevant in AP mode */
  759. u8 wmi_edmg_channel; /* relevant in AP mode */
  760. u8 hidden_ssid; /* relevant in AP mode */
  761. u32 ap_isolate; /* no intra-BSS communication */
  762. bool pbss;
  763. int bi;
  764. u8 *proberesp, *proberesp_ies, *assocresp_ies;
  765. size_t proberesp_len, proberesp_ies_len, assocresp_ies_len;
  766. u8 ssid[IEEE80211_MAX_SSID_LEN];
  767. size_t ssid_len;
  768. u8 gtk_index;
  769. u8 gtk[WMI_MAX_KEY_LEN];
  770. size_t gtk_len;
  771. int bcast_ring;
  772. struct cfg80211_bss *bss; /* connected bss, relevant in STA mode */
  773. int locally_generated_disc; /* relevant in STA mode */
  774. struct timer_list connect_timer;
  775. struct work_struct disconnect_worker;
  776. /* scan */
  777. struct cfg80211_scan_request *scan_request;
  778. struct timer_list scan_timer; /* detect scan timeout */
  779. struct wil_p2p_info p2p;
  780. /* keep alive */
  781. struct list_head probe_client_pending;
  782. struct mutex probe_client_mutex; /* protect @probe_client_pending */
  783. struct work_struct probe_client_worker;
  784. int net_queue_stopped; /* netif_tx_stop_all_queues invoked */
  785. bool fw_stats_ready; /* per-cid statistics are ready inside sta_info */
  786. u64 fw_stats_tsf; /* measurement timestamp */
  787. /* PTK rekey race prevention, this is relevant to station mode only */
  788. enum wil_rekey_state ptk_rekey_state;
  789. struct work_struct enable_tx_key_worker;
  790. };
  791. /**
  792. * RX buffer allocated for enhanced DMA RX descriptors
  793. */
  794. struct wil_rx_buff {
  795. struct sk_buff *skb;
  796. struct list_head list;
  797. int id;
  798. };
  799. /**
  800. * During Rx completion processing, the driver extracts a buffer ID which
  801. * is used as an index to the rx_buff_mgmt.buff_arr array and then the SKB
  802. * is given to the network stack and the buffer is moved from the 'active'
  803. * list to the 'free' list.
  804. * During Rx refill, SKBs are attached to free buffers and moved to the
  805. * 'active' list.
  806. */
  807. struct wil_rx_buff_mgmt {
  808. struct wil_rx_buff *buff_arr;
  809. size_t size; /* number of items in buff_arr */
  810. struct list_head active;
  811. struct list_head free;
  812. unsigned long free_list_empty_cnt; /* statistics */
  813. };
  814. struct wil_fw_stats_global {
  815. bool ready;
  816. u64 tsf; /* measurement timestamp */
  817. struct wmi_link_stats_global stats;
  818. };
  819. struct wil_brd_info {
  820. u32 file_addr;
  821. u32 file_max_size;
  822. };
  823. struct wil6210_priv {
  824. struct pci_dev *pdev;
  825. u32 bar_size;
  826. struct wiphy *wiphy;
  827. struct net_device *main_ndev;
  828. int n_msi;
  829. void __iomem *csr;
  830. DECLARE_BITMAP(status, wil_status_last);
  831. u8 fw_version[ETHTOOL_FWVERS_LEN];
  832. u32 hw_version;
  833. u8 chip_revision;
  834. const char *hw_name;
  835. const char *wil_fw_name;
  836. char *board_file;
  837. u32 num_of_brd_entries;
  838. struct wil_brd_info *brd_info;
  839. DECLARE_BITMAP(hw_capa, hw_capa_last);
  840. DECLARE_BITMAP(fw_capabilities, WMI_FW_CAPABILITY_MAX);
  841. DECLARE_BITMAP(platform_capa, WIL_PLATFORM_CAPA_MAX);
  842. u32 recovery_count; /* num of FW recovery attempts in a short time */
  843. u32 recovery_state; /* FW recovery state machine */
  844. unsigned long last_fw_recovery; /* jiffies of last fw recovery */
  845. wait_queue_head_t wq; /* for all wait_event() use */
  846. u8 max_vifs; /* maximum number of interfaces, including main */
  847. struct wil6210_vif *vifs[WIL_MAX_VIFS];
  848. struct mutex vif_mutex; /* protects access to VIF entries */
  849. atomic_t connected_vifs;
  850. u32 max_assoc_sta; /* max sta's supported by the driver and the FW */
  851. /* profile */
  852. struct cfg80211_chan_def monitor_chandef;
  853. u32 monitor_flags;
  854. int sinfo_gen;
  855. /* interrupt moderation */
  856. u32 tx_max_burst_duration;
  857. u32 tx_interframe_timeout;
  858. u32 rx_max_burst_duration;
  859. u32 rx_interframe_timeout;
  860. /* cached ISR registers */
  861. u32 isr_misc;
  862. /* mailbox related */
  863. struct mutex wmi_mutex;
  864. struct wil6210_mbox_ctl mbox_ctl;
  865. struct completion wmi_ready;
  866. struct completion wmi_call;
  867. u16 wmi_seq;
  868. u16 reply_id; /**< wait for this WMI event */
  869. u8 reply_mid;
  870. void *reply_buf;
  871. u16 reply_size;
  872. struct workqueue_struct *wmi_wq; /* for deferred calls */
  873. struct work_struct wmi_event_worker;
  874. struct workqueue_struct *wq_service;
  875. struct work_struct fw_error_worker; /* for FW error recovery */
  876. struct list_head pending_wmi_ev;
  877. /*
  878. * protect pending_wmi_ev
  879. * - fill in IRQ from wil6210_irq_misc,
  880. * - consumed in thread by wmi_event_worker
  881. */
  882. spinlock_t wmi_ev_lock;
  883. spinlock_t net_queue_lock; /* guarding stop/wake netif queue */
  884. spinlock_t eap_lock; /* guarding access to eap rekey fields */
  885. struct napi_struct napi_rx;
  886. struct napi_struct napi_tx;
  887. struct net_device napi_ndev; /* dummy net_device serving all VIFs */
  888. /* DMA related */
  889. struct wil_ring ring_rx;
  890. unsigned int rx_buf_len;
  891. struct wil_ring ring_tx[WIL6210_MAX_TX_RINGS];
  892. struct wil_ring_tx_data ring_tx_data[WIL6210_MAX_TX_RINGS];
  893. struct wil_status_ring srings[WIL6210_MAX_STATUS_RINGS];
  894. u8 num_rx_status_rings;
  895. int tx_sring_idx;
  896. u8 ring2cid_tid[WIL6210_MAX_TX_RINGS][2]; /* [0] - CID, [1] - TID */
  897. struct wil_sta_info sta[WIL6210_MAX_CID];
  898. u32 ring_idle_trsh; /* HW fetches up to 16 descriptors at once */
  899. u32 dma_addr_size; /* indicates dma addr size */
  900. struct wil_rx_buff_mgmt rx_buff_mgmt;
  901. bool use_enhanced_dma_hw;
  902. struct wil_txrx_ops txrx_ops;
  903. struct mutex mutex; /* for wil6210_priv access in wil_{up|down} */
  904. /* for synchronizing device memory access while reset or suspend */
  905. struct rw_semaphore mem_lock;
  906. /* statistics */
  907. atomic_t isr_count_rx, isr_count_tx;
  908. /* debugfs */
  909. struct dentry *debug;
  910. struct wil_blob_wrapper blobs[MAX_FW_MAPPING_TABLE_SIZE];
  911. u8 discovery_mode;
  912. u8 abft_len;
  913. u8 wakeup_trigger;
  914. struct wil_suspend_stats suspend_stats;
  915. struct wil_debugfs_data dbg_data;
  916. bool tx_latency; /* collect TX latency measurements */
  917. size_t tx_latency_res; /* bin resolution in usec */
  918. void *platform_handle;
  919. struct wil_platform_ops platform_ops;
  920. bool keep_radio_on_during_sleep;
  921. struct pmc_ctx pmc;
  922. u8 p2p_dev_started;
  923. /* P2P_DEVICE vif */
  924. struct wireless_dev *p2p_wdev;
  925. struct wireless_dev *radio_wdev;
  926. /* High Access Latency Policy voting */
  927. struct wil_halp halp;
  928. enum wmi_ps_profile_type ps_profile;
  929. int fw_calib_result;
  930. struct notifier_block pm_notify;
  931. bool suspend_resp_rcvd;
  932. bool suspend_resp_comp;
  933. u32 bus_request_kbps;
  934. u32 bus_request_kbps_pre_suspend;
  935. u32 rgf_fw_assert_code_addr;
  936. u32 rgf_ucode_assert_code_addr;
  937. u32 iccm_base;
  938. /* relevant only for eDMA */
  939. bool use_compressed_rx_status;
  940. u32 rx_status_ring_order;
  941. u32 tx_status_ring_order;
  942. u32 rx_buff_id_count;
  943. bool amsdu_en;
  944. bool use_rx_hw_reordering;
  945. bool secured_boot;
  946. u8 boot_config;
  947. struct wil_fw_stats_global fw_stats_global;
  948. u32 max_agg_wsize;
  949. u32 max_ampdu_size;
  950. u8 multicast_to_unicast;
  951. s32 cqm_rssi_thold;
  952. };
  953. #define wil_to_wiphy(i) (i->wiphy)
  954. #define wil_to_dev(i) (wiphy_dev(wil_to_wiphy(i)))
  955. #define wiphy_to_wil(w) (struct wil6210_priv *)(wiphy_priv(w))
  956. #define wdev_to_wil(w) (struct wil6210_priv *)(wdev_priv(w))
  957. #define ndev_to_wil(n) (wdev_to_wil(n->ieee80211_ptr))
  958. #define ndev_to_vif(n) (struct wil6210_vif *)(netdev_priv(n))
  959. #define vif_to_wil(v) (v->wil)
  960. #define vif_to_ndev(v) (v->ndev)
  961. #define vif_to_wdev(v) (&v->wdev)
  962. #define GET_MAX_VIFS(wil) min_t(int, (wil)->max_vifs, WIL_MAX_VIFS)
  963. static inline struct wil6210_vif *wdev_to_vif(struct wil6210_priv *wil,
  964. struct wireless_dev *wdev)
  965. {
  966. /* main interface is shared with P2P device */
  967. if (wdev == wil->p2p_wdev)
  968. return ndev_to_vif(wil->main_ndev);
  969. else
  970. return container_of(wdev, struct wil6210_vif, wdev);
  971. }
  972. static inline struct wireless_dev *
  973. vif_to_radio_wdev(struct wil6210_priv *wil, struct wil6210_vif *vif)
  974. {
  975. /* main interface is shared with P2P device */
  976. if (vif->mid)
  977. return vif_to_wdev(vif);
  978. else
  979. return wil->radio_wdev;
  980. }
  981. __printf(2, 3)
  982. void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...);
  983. __printf(2, 3)
  984. void __wil_err(struct wil6210_priv *wil, const char *fmt, ...);
  985. __printf(2, 3)
  986. void __wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...);
  987. __printf(2, 3)
  988. void __wil_info(struct wil6210_priv *wil, const char *fmt, ...);
  989. __printf(2, 3)
  990. void wil_dbg_ratelimited(const struct wil6210_priv *wil, const char *fmt, ...);
  991. #define wil_dbg(wil, fmt, arg...) do { \
  992. netdev_dbg(wil->main_ndev, fmt, ##arg); \
  993. wil_dbg_trace(wil, fmt, ##arg); \
  994. } while (0)
  995. #define wil_dbg_irq(wil, fmt, arg...) wil_dbg(wil, "DBG[ IRQ]" fmt, ##arg)
  996. #define wil_dbg_txrx(wil, fmt, arg...) wil_dbg(wil, "DBG[TXRX]" fmt, ##arg)
  997. #define wil_dbg_wmi(wil, fmt, arg...) wil_dbg(wil, "DBG[ WMI]" fmt, ##arg)
  998. #define wil_dbg_misc(wil, fmt, arg...) wil_dbg(wil, "DBG[MISC]" fmt, ##arg)
  999. #define wil_dbg_pm(wil, fmt, arg...) wil_dbg(wil, "DBG[ PM ]" fmt, ##arg)
  1000. #define wil_err(wil, fmt, arg...) __wil_err(wil, "%s: " fmt, __func__, ##arg)
  1001. #define wil_info(wil, fmt, arg...) __wil_info(wil, "%s: " fmt, __func__, ##arg)
  1002. #define wil_err_ratelimited(wil, fmt, arg...) \
  1003. __wil_err_ratelimited(wil, "%s: " fmt, __func__, ##arg)
  1004. /* target operations */
  1005. /* register read */
  1006. static inline u32 wil_r(struct wil6210_priv *wil, u32 reg)
  1007. {
  1008. return readl(wil->csr + HOSTADDR(reg));
  1009. }
  1010. /* register write. wmb() to make sure it is completed */
  1011. static inline void wil_w(struct wil6210_priv *wil, u32 reg, u32 val)
  1012. {
  1013. writel(val, wil->csr + HOSTADDR(reg));
  1014. wmb(); /* wait for write to propagate to the HW */
  1015. }
  1016. /* register set = read, OR, write */
  1017. static inline void wil_s(struct wil6210_priv *wil, u32 reg, u32 val)
  1018. {
  1019. wil_w(wil, reg, wil_r(wil, reg) | val);
  1020. }
  1021. /* register clear = read, AND with inverted, write */
  1022. static inline void wil_c(struct wil6210_priv *wil, u32 reg, u32 val)
  1023. {
  1024. wil_w(wil, reg, wil_r(wil, reg) & ~val);
  1025. }
  1026. /**
  1027. * wil_cid_valid - check cid is valid
  1028. */
  1029. static inline bool wil_cid_valid(struct wil6210_priv *wil, int cid)
  1030. {
  1031. return (cid >= 0 && cid < wil->max_assoc_sta && cid < WIL6210_MAX_CID);
  1032. }
  1033. void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len);
  1034. #if defined(CONFIG_DYNAMIC_DEBUG)
  1035. #define wil_hex_dump_txrx(prefix_str, prefix_type, rowsize, \
  1036. groupsize, buf, len, ascii) \
  1037. print_hex_dump_debug("DBG[TXRX]" prefix_str,\
  1038. prefix_type, rowsize, \
  1039. groupsize, buf, len, ascii)
  1040. #define wil_hex_dump_wmi(prefix_str, prefix_type, rowsize, \
  1041. groupsize, buf, len, ascii) \
  1042. print_hex_dump_debug("DBG[ WMI]" prefix_str,\
  1043. prefix_type, rowsize, \
  1044. groupsize, buf, len, ascii)
  1045. #define wil_hex_dump_misc(prefix_str, prefix_type, rowsize, \
  1046. groupsize, buf, len, ascii) \
  1047. print_hex_dump_debug("DBG[MISC]" prefix_str,\
  1048. prefix_type, rowsize, \
  1049. groupsize, buf, len, ascii)
  1050. #else /* defined(CONFIG_DYNAMIC_DEBUG) */
  1051. static inline
  1052. void wil_hex_dump_txrx(const char *prefix_str, int prefix_type, int rowsize,
  1053. int groupsize, const void *buf, size_t len, bool ascii)
  1054. {
  1055. }
  1056. static inline
  1057. void wil_hex_dump_wmi(const char *prefix_str, int prefix_type, int rowsize,
  1058. int groupsize, const void *buf, size_t len, bool ascii)
  1059. {
  1060. }
  1061. static inline
  1062. void wil_hex_dump_misc(const char *prefix_str, int prefix_type, int rowsize,
  1063. int groupsize, const void *buf, size_t len, bool ascii)
  1064. {
  1065. }
  1066. #endif /* defined(CONFIG_DYNAMIC_DEBUG) */
  1067. void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
  1068. size_t count);
  1069. void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
  1070. size_t count);
  1071. int wil_mem_access_lock(struct wil6210_priv *wil);
  1072. void wil_mem_access_unlock(struct wil6210_priv *wil);
  1073. struct wil6210_vif *
  1074. wil_vif_alloc(struct wil6210_priv *wil, const char *name,
  1075. unsigned char name_assign_type, enum nl80211_iftype iftype);
  1076. void wil_vif_free(struct wil6210_vif *vif);
  1077. void *wil_if_alloc(struct device *dev);
  1078. bool wil_has_other_active_ifaces(struct wil6210_priv *wil,
  1079. struct net_device *ndev, bool up, bool ok);
  1080. bool wil_has_active_ifaces(struct wil6210_priv *wil, bool up, bool ok);
  1081. void wil_if_free(struct wil6210_priv *wil);
  1082. int wil_vif_add(struct wil6210_priv *wil, struct wil6210_vif *vif);
  1083. int wil_if_add(struct wil6210_priv *wil);
  1084. void wil_vif_remove(struct wil6210_priv *wil, u8 mid);
  1085. void wil_if_remove(struct wil6210_priv *wil);
  1086. int wil_priv_init(struct wil6210_priv *wil);
  1087. void wil_priv_deinit(struct wil6210_priv *wil);
  1088. int wil_ps_update(struct wil6210_priv *wil,
  1089. enum wmi_ps_profile_type ps_profile);
  1090. int wil_reset(struct wil6210_priv *wil, bool no_fw);
  1091. void wil_fw_error_recovery(struct wil6210_priv *wil);
  1092. void wil_set_recovery_state(struct wil6210_priv *wil, int state);
  1093. bool wil_is_recovery_blocked(struct wil6210_priv *wil);
  1094. int wil_up(struct wil6210_priv *wil);
  1095. int __wil_up(struct wil6210_priv *wil);
  1096. int wil_down(struct wil6210_priv *wil);
  1097. int __wil_down(struct wil6210_priv *wil);
  1098. void wil_refresh_fw_capabilities(struct wil6210_priv *wil);
  1099. void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
  1100. int wil_find_cid(struct wil6210_priv *wil, u8 mid, const u8 *mac);
  1101. int wil_find_cid_by_idx(struct wil6210_priv *wil, u8 mid, int idx);
  1102. void wil_set_ethtoolops(struct net_device *ndev);
  1103. struct fw_map *wil_find_fw_mapping(const char *section);
  1104. void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr, u32 size);
  1105. void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr);
  1106. void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr);
  1107. int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,
  1108. struct wil6210_mbox_hdr *hdr);
  1109. int wmi_send(struct wil6210_priv *wil, u16 cmdid, u8 mid, void *buf, u16 len);
  1110. void wmi_recv_cmd(struct wil6210_priv *wil);
  1111. int wmi_call(struct wil6210_priv *wil, u16 cmdid, u8 mid, void *buf, u16 len,
  1112. u16 reply_id, void *reply, u16 reply_size, int to_msec);
  1113. void wmi_event_worker(struct work_struct *work);
  1114. void wmi_event_flush(struct wil6210_priv *wil);
  1115. int wmi_set_ssid(struct wil6210_vif *vif, u8 ssid_len, const void *ssid);
  1116. int wmi_get_ssid(struct wil6210_vif *vif, u8 *ssid_len, void *ssid);
  1117. int wmi_set_channel(struct wil6210_priv *wil, int channel);
  1118. int wmi_get_channel(struct wil6210_priv *wil, int *channel);
  1119. int wmi_del_cipher_key(struct wil6210_vif *vif, u8 key_index,
  1120. const void *mac_addr, int key_usage);
  1121. int wmi_add_cipher_key(struct wil6210_vif *vif, u8 key_index,
  1122. const void *mac_addr, int key_len, const void *key,
  1123. int key_usage);
  1124. int wmi_echo(struct wil6210_priv *wil);
  1125. int wmi_set_ie(struct wil6210_vif *vif, u8 type, u16 ie_len, const void *ie);
  1126. int wmi_rx_chain_add(struct wil6210_priv *wil, struct wil_ring *vring);
  1127. int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie);
  1128. int wmi_rxon(struct wil6210_priv *wil, bool on);
  1129. int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
  1130. int wmi_get_all_temperatures(struct wil6210_priv *wil,
  1131. struct wmi_temp_sense_all_done_event
  1132. *sense_all_evt);
  1133. int wmi_disconnect_sta(struct wil6210_vif *vif, const u8 *mac, u16 reason,
  1134. bool del_sta);
  1135. int wmi_addba(struct wil6210_priv *wil, u8 mid,
  1136. u8 ringid, u8 size, u16 timeout);
  1137. int wmi_delba_tx(struct wil6210_priv *wil, u8 mid, u8 ringid, u16 reason);
  1138. int wmi_delba_rx(struct wil6210_priv *wil, u8 mid, u8 cid, u8 tid, u16 reason);
  1139. int wmi_addba_rx_resp(struct wil6210_priv *wil,
  1140. u8 mid, u8 cid, u8 tid, u8 token,
  1141. u16 status, bool amsdu, u16 agg_wsize, u16 timeout);
  1142. int wmi_ps_dev_profile_cfg(struct wil6210_priv *wil,
  1143. enum wmi_ps_profile_type ps_profile);
  1144. int wmi_set_mgmt_retry(struct wil6210_priv *wil, u8 retry_short);
  1145. int wmi_get_mgmt_retry(struct wil6210_priv *wil, u8 *retry_short);
  1146. int wmi_new_sta(struct wil6210_vif *vif, const u8 *mac, u8 aid);
  1147. int wmi_port_allocate(struct wil6210_priv *wil, u8 mid,
  1148. const u8 *mac, enum nl80211_iftype iftype);
  1149. int wmi_port_delete(struct wil6210_priv *wil, u8 mid);
  1150. int wmi_link_stats_cfg(struct wil6210_vif *vif, u32 type, u8 cid, u32 interval);
  1151. int wil_addba_rx_request(struct wil6210_priv *wil, u8 mid, u8 cid, u8 tid,
  1152. u8 dialog_token, __le16 ba_param_set,
  1153. __le16 ba_timeout, __le16 ba_seq_ctrl);
  1154. int wil_addba_tx_request(struct wil6210_priv *wil, u8 ringid, u16 wsize);
  1155. void wil6210_clear_irq(struct wil6210_priv *wil);
  1156. int wil6210_init_irq(struct wil6210_priv *wil, int irq);
  1157. void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
  1158. void wil_mask_irq(struct wil6210_priv *wil);
  1159. void wil_unmask_irq(struct wil6210_priv *wil);
  1160. void wil_configure_interrupt_moderation(struct wil6210_priv *wil);
  1161. void wil_disable_irq(struct wil6210_priv *wil);
  1162. void wil_enable_irq(struct wil6210_priv *wil);
  1163. void wil6210_mask_halp(struct wil6210_priv *wil);
  1164. /* P2P */
  1165. bool wil_p2p_is_social_scan(struct cfg80211_scan_request *request);
  1166. int wil_p2p_search(struct wil6210_vif *vif,
  1167. struct cfg80211_scan_request *request);
  1168. int wil_p2p_listen(struct wil6210_priv *wil, struct wireless_dev *wdev,
  1169. unsigned int duration, struct ieee80211_channel *chan,
  1170. u64 *cookie);
  1171. u8 wil_p2p_stop_discovery(struct wil6210_vif *vif);
  1172. int wil_p2p_cancel_listen(struct wil6210_vif *vif, u64 cookie);
  1173. void wil_p2p_listen_expired(struct work_struct *work);
  1174. void wil_p2p_search_expired(struct work_struct *work);
  1175. void wil_p2p_stop_radio_operations(struct wil6210_priv *wil);
  1176. void wil_p2p_delayed_listen_work(struct work_struct *work);
  1177. /* WMI for P2P */
  1178. int wmi_p2p_cfg(struct wil6210_vif *vif, int channel, int bi);
  1179. int wmi_start_listen(struct wil6210_vif *vif);
  1180. int wmi_start_search(struct wil6210_vif *vif);
  1181. int wmi_stop_discovery(struct wil6210_vif *vif);
  1182. int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
  1183. struct cfg80211_mgmt_tx_params *params,
  1184. u64 *cookie);
  1185. void wil_cfg80211_ap_recovery(struct wil6210_priv *wil);
  1186. int wil_cfg80211_iface_combinations_from_fw(
  1187. struct wil6210_priv *wil,
  1188. const struct wil_fw_record_concurrency *conc);
  1189. int wil_vif_prepare_stop(struct wil6210_vif *vif);
  1190. #if defined(CONFIG_WIL6210_DEBUGFS)
  1191. int wil6210_debugfs_init(struct wil6210_priv *wil);
  1192. void wil6210_debugfs_remove(struct wil6210_priv *wil);
  1193. #else
  1194. static inline int wil6210_debugfs_init(struct wil6210_priv *wil) { return 0; }
  1195. static inline void wil6210_debugfs_remove(struct wil6210_priv *wil) {}
  1196. #endif
  1197. int wil_cid_fill_sinfo(struct wil6210_vif *vif, int cid,
  1198. struct station_info *sinfo);
  1199. struct wil6210_priv *wil_cfg80211_init(struct device *dev);
  1200. void wil_cfg80211_deinit(struct wil6210_priv *wil);
  1201. void wil_p2p_wdev_free(struct wil6210_priv *wil);
  1202. int wmi_set_mac_address(struct wil6210_priv *wil, const void *addr);
  1203. int wmi_pcp_start(struct wil6210_vif *vif, int bi, u8 wmi_nettype, u8 chan,
  1204. u8 edmg_chan, u8 hidden_ssid, u8 is_go);
  1205. int wmi_pcp_stop(struct wil6210_vif *vif);
  1206. int wmi_led_cfg(struct wil6210_priv *wil, bool enable);
  1207. int wmi_abort_scan(struct wil6210_vif *vif);
  1208. void wil_abort_scan(struct wil6210_vif *vif, bool sync);
  1209. void wil_abort_scan_all_vifs(struct wil6210_priv *wil, bool sync);
  1210. void wil6210_bus_request(struct wil6210_priv *wil, u32 kbps);
  1211. void wil6210_disconnect(struct wil6210_vif *vif, const u8 *bssid,
  1212. u16 reason_code);
  1213. void wil6210_disconnect_complete(struct wil6210_vif *vif, const u8 *bssid,
  1214. u16 reason_code);
  1215. void wil_probe_client_flush(struct wil6210_vif *vif);
  1216. void wil_probe_client_worker(struct work_struct *work);
  1217. void wil_disconnect_worker(struct work_struct *work);
  1218. void wil_enable_tx_key_worker(struct work_struct *work);
  1219. void wil_init_txrx_ops(struct wil6210_priv *wil);
  1220. /* TX API */
  1221. int wil_ring_init_tx(struct wil6210_vif *vif, int cid);
  1222. int wil_vring_init_bcast(struct wil6210_vif *vif, int id, int size);
  1223. int wil_bcast_init(struct wil6210_vif *vif);
  1224. void wil_bcast_fini(struct wil6210_vif *vif);
  1225. void wil_bcast_fini_all(struct wil6210_priv *wil);
  1226. void wil_update_net_queues(struct wil6210_priv *wil, struct wil6210_vif *vif,
  1227. struct wil_ring *ring, bool should_stop);
  1228. void wil_update_net_queues_bh(struct wil6210_priv *wil, struct wil6210_vif *vif,
  1229. struct wil_ring *ring, bool check_stop);
  1230. netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev);
  1231. int wil_tx_complete(struct wil6210_vif *vif, int ringid);
  1232. void wil_tx_complete_handle_eapol(struct wil6210_vif *vif,
  1233. struct sk_buff *skb);
  1234. void wil6210_unmask_irq_tx(struct wil6210_priv *wil);
  1235. void wil6210_unmask_irq_tx_edma(struct wil6210_priv *wil);
  1236. /* RX API */
  1237. void wil_rx_handle(struct wil6210_priv *wil, int *quota);
  1238. void wil6210_unmask_irq_rx(struct wil6210_priv *wil);
  1239. void wil6210_unmask_irq_rx_edma(struct wil6210_priv *wil);
  1240. void wil_set_crypto_rx(u8 key_index, enum wmi_key_usage key_usage,
  1241. struct wil_sta_info *cs,
  1242. struct key_params *params);
  1243. int wil_iftype_nl2wmi(enum nl80211_iftype type);
  1244. int wil_request_firmware(struct wil6210_priv *wil, const char *name,
  1245. bool load);
  1246. int wil_request_board(struct wil6210_priv *wil, const char *name);
  1247. bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);
  1248. void wil_pm_runtime_allow(struct wil6210_priv *wil);
  1249. void wil_pm_runtime_forbid(struct wil6210_priv *wil);
  1250. int wil_pm_runtime_get(struct wil6210_priv *wil);
  1251. void wil_pm_runtime_put(struct wil6210_priv *wil);
  1252. int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
  1253. int wil_suspend(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
  1254. int wil_resume(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
  1255. bool wil_is_wmi_idle(struct wil6210_priv *wil);
  1256. int wmi_resume(struct wil6210_priv *wil);
  1257. int wmi_suspend(struct wil6210_priv *wil);
  1258. bool wil_is_tx_idle(struct wil6210_priv *wil);
  1259. int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size);
  1260. void wil_fw_core_dump(struct wil6210_priv *wil);
  1261. void wil_halp_vote(struct wil6210_priv *wil);
  1262. void wil_halp_unvote(struct wil6210_priv *wil);
  1263. void wil6210_set_halp(struct wil6210_priv *wil);
  1264. void wil6210_clear_halp(struct wil6210_priv *wil);
  1265. int wmi_start_sched_scan(struct wil6210_priv *wil,
  1266. struct cfg80211_sched_scan_request *request);
  1267. int wmi_stop_sched_scan(struct wil6210_priv *wil);
  1268. int wmi_mgmt_tx(struct wil6210_vif *vif, const u8 *buf, size_t len);
  1269. int wmi_mgmt_tx_ext(struct wil6210_vif *vif, const u8 *buf, size_t len,
  1270. u8 channel, u16 duration_ms);
  1271. int wmi_rbufcap_cfg(struct wil6210_priv *wil, bool enable, u16 threshold);
  1272. int wil_wmi2spec_ch(u8 wmi_ch, u8 *spec_ch);
  1273. int wil_spec2wmi_ch(u8 spec_ch, u8 *wmi_ch);
  1274. void wil_update_supported_bands(struct wil6210_priv *wil);
  1275. int reverse_memcmp(const void *cs, const void *ct, size_t count);
  1276. /* WMI for enhanced DMA */
  1277. int wil_wmi_tx_sring_cfg(struct wil6210_priv *wil, int ring_id);
  1278. int wil_wmi_cfg_def_rx_offload(struct wil6210_priv *wil,
  1279. u16 max_rx_pl_per_desc);
  1280. int wil_wmi_rx_sring_add(struct wil6210_priv *wil, u16 ring_id);
  1281. int wil_wmi_rx_desc_ring_add(struct wil6210_priv *wil, int status_ring_id);
  1282. int wil_wmi_tx_desc_ring_add(struct wil6210_vif *vif, int ring_id, int cid,
  1283. int tid);
  1284. int wil_wmi_bcast_desc_ring_add(struct wil6210_vif *vif, int ring_id);
  1285. int wmi_addba_rx_resp_edma(struct wil6210_priv *wil, u8 mid, u8 cid,
  1286. u8 tid, u8 token, u16 status, bool amsdu,
  1287. u16 agg_wsize, u16 timeout);
  1288. void update_supported_bands(struct wil6210_priv *wil);
  1289. void wil_clear_fw_log_addr(struct wil6210_priv *wil);
  1290. int wmi_set_cqm_rssi_config(struct wil6210_priv *wil,
  1291. s32 rssi_thold, u32 rssi_hyst);
  1292. void wil_sta_info_amsdu_init(struct wil_sta_info *sta);
  1293. #endif /* __WIL6210_H__ */