wil6210.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. /*
  2. * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __WIL6210_H__
  17. #define __WIL6210_H__
  18. #include <linux/etherdevice.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/wireless.h>
  21. #include <net/cfg80211.h>
  22. #include <linux/timex.h>
  23. #include <linux/types.h>
  24. #include "wmi.h"
  25. #include "wil_platform.h"
  26. extern bool no_fw_recovery;
  27. extern unsigned int mtu_max;
  28. extern unsigned short rx_ring_overflow_thrsh;
  29. extern int agg_wsize;
  30. extern bool rx_align_2;
  31. extern bool rx_large_buf;
  32. extern bool debug_fw;
  33. extern bool disable_ap_sme;
  34. #define WIL_NAME "wil6210"
  35. #define WIL_FW_NAME_DEFAULT "wil6210.fw"
  36. #define WIL_FW_NAME_FTM_DEFAULT "wil6210_ftm.fw"
  37. #define WIL_FW_NAME_SPARROW_PLUS "wil6210_sparrow_plus.fw"
  38. #define WIL_FW_NAME_FTM_SPARROW_PLUS "wil6210_sparrow_plus_ftm.fw"
  39. #define WIL_BOARD_FILE_NAME "wil6210.brd" /* board & radio parameters */
  40. #define WIL_DEFAULT_BUS_REQUEST_KBPS 128000 /* ~1Gbps */
  41. #define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */
  42. /**
  43. * extract bits [@b0:@b1] (inclusive) from the value @x
  44. * it should be @b0 <= @b1, or result is incorrect
  45. */
  46. static inline u32 WIL_GET_BITS(u32 x, int b0, int b1)
  47. {
  48. return (x >> b0) & ((1 << (b1 - b0 + 1)) - 1);
  49. }
  50. #define WIL6210_MIN_MEM_SIZE (2 * 1024 * 1024UL)
  51. #define WIL6210_MAX_MEM_SIZE (4 * 1024 * 1024UL)
  52. #define WIL_TX_Q_LEN_DEFAULT (4000)
  53. #define WIL_RX_RING_SIZE_ORDER_DEFAULT (10)
  54. #define WIL_TX_RING_SIZE_ORDER_DEFAULT (12)
  55. #define WIL_BCAST_RING_SIZE_ORDER_DEFAULT (7)
  56. #define WIL_BCAST_MCS0_LIMIT (1024) /* limit for MCS0 frame size */
  57. /* limit ring size in range [32..32k] */
  58. #define WIL_RING_SIZE_ORDER_MIN (5)
  59. #define WIL_RING_SIZE_ORDER_MAX (15)
  60. #define WIL6210_MAX_TX_RINGS (24) /* HW limit */
  61. #define WIL6210_MAX_CID (8) /* HW limit */
  62. #define WIL6210_NAPI_BUDGET (16) /* arbitrary */
  63. #define WIL_MAX_AMPDU_SIZE (64 * 1024) /* FW/HW limit */
  64. #define WIL_MAX_AGG_WSIZE (32) /* FW/HW limit */
  65. /* Hardware offload block adds the following:
  66. * 26 bytes - 3-address QoS data header
  67. * 8 bytes - IV + EIV (for GCMP)
  68. * 8 bytes - SNAP
  69. * 16 bytes - MIC (for GCMP)
  70. * 4 bytes - CRC
  71. */
  72. #define WIL_MAX_MPDU_OVERHEAD (62)
  73. struct wil_suspend_stats {
  74. unsigned long successful_suspends;
  75. unsigned long failed_suspends;
  76. unsigned long successful_resumes;
  77. unsigned long failed_resumes;
  78. unsigned long rejected_by_device;
  79. unsigned long rejected_by_host;
  80. unsigned long long total_suspend_time;
  81. unsigned long long min_suspend_time;
  82. unsigned long long max_suspend_time;
  83. ktime_t collection_start;
  84. ktime_t suspend_start_time;
  85. };
  86. /* Calculate MAC buffer size for the firmware. It includes all overhead,
  87. * as it will go over the air, and need to be 8 byte aligned
  88. */
  89. static inline u32 wil_mtu2macbuf(u32 mtu)
  90. {
  91. return ALIGN(mtu + WIL_MAX_MPDU_OVERHEAD, 8);
  92. }
  93. /* MTU for Ethernet need to take into account 8-byte SNAP header
  94. * to be added when encapsulating Ethernet frame into 802.11
  95. */
  96. #define WIL_MAX_ETH_MTU (IEEE80211_MAX_DATA_LEN_DMG - 8)
  97. /* Max supported by wil6210 value for interrupt threshold is 5sec. */
  98. #define WIL6210_ITR_TRSH_MAX (5000000)
  99. #define WIL6210_ITR_TX_INTERFRAME_TIMEOUT_DEFAULT (13) /* usec */
  100. #define WIL6210_ITR_RX_INTERFRAME_TIMEOUT_DEFAULT (13) /* usec */
  101. #define WIL6210_ITR_TX_MAX_BURST_DURATION_DEFAULT (500) /* usec */
  102. #define WIL6210_ITR_RX_MAX_BURST_DURATION_DEFAULT (500) /* usec */
  103. #define WIL6210_FW_RECOVERY_RETRIES (5) /* try to recover this many times */
  104. #define WIL6210_FW_RECOVERY_TO msecs_to_jiffies(5000)
  105. #define WIL6210_SCAN_TO msecs_to_jiffies(10000)
  106. #define WIL6210_DISCONNECT_TO_MS (2000)
  107. #define WIL6210_RX_HIGH_TRSH_INIT (0)
  108. #define WIL6210_RX_HIGH_TRSH_DEFAULT \
  109. (1 << (WIL_RX_RING_SIZE_ORDER_DEFAULT - 3))
  110. #define WIL_MAX_DMG_AID 254 /* for DMG only 1-254 allowed (see
  111. * 802.11REVmc/D5.0, section 9.4.1.8)
  112. */
  113. /* Hardware definitions begin */
  114. /*
  115. * Mapping
  116. * RGF File | Host addr | FW addr
  117. * | |
  118. * user_rgf | 0x000000 | 0x880000
  119. * dma_rgf | 0x001000 | 0x881000
  120. * pcie_rgf | 0x002000 | 0x882000
  121. * | |
  122. */
  123. /* Where various structures placed in host address space */
  124. #define WIL6210_FW_HOST_OFF (0x880000UL)
  125. #define HOSTADDR(fwaddr) (fwaddr - WIL6210_FW_HOST_OFF)
  126. /*
  127. * Interrupt control registers block
  128. *
  129. * each interrupt controlled by the same bit in all registers
  130. */
  131. struct RGF_ICR {
  132. u32 ICC; /* Cause Control, RW: 0 - W1C, 1 - COR */
  133. u32 ICR; /* Cause, W1C/COR depending on ICC */
  134. u32 ICM; /* Cause masked (ICR & ~IMV), W1C/COR depending on ICC */
  135. u32 ICS; /* Cause Set, WO */
  136. u32 IMV; /* Mask, RW+S/C */
  137. u32 IMS; /* Mask Set, write 1 to set */
  138. u32 IMC; /* Mask Clear, write 1 to clear */
  139. } __packed;
  140. /* registers - FW addresses */
  141. #define RGF_USER_USAGE_1 (0x880004)
  142. #define RGF_USER_USAGE_6 (0x880018)
  143. #define BIT_USER_OOB_MODE BIT(31)
  144. #define BIT_USER_OOB_R2_MODE BIT(30)
  145. #define RGF_USER_HW_MACHINE_STATE (0x8801dc)
  146. #define HW_MACHINE_BOOT_DONE (0x3fffffd)
  147. #define RGF_USER_USER_CPU_0 (0x8801e0)
  148. #define BIT_USER_USER_CPU_MAN_RST BIT(1) /* user_cpu_man_rst */
  149. #define RGF_USER_MAC_CPU_0 (0x8801fc)
  150. #define BIT_USER_MAC_CPU_MAN_RST BIT(1) /* mac_cpu_man_rst */
  151. #define RGF_USER_USER_SCRATCH_PAD (0x8802bc)
  152. #define RGF_USER_BL (0x880A3C) /* Boot Loader */
  153. #define RGF_USER_FW_REV_ID (0x880a8c) /* chip revision */
  154. #define RGF_USER_FW_CALIB_RESULT (0x880a90) /* b0-7:result
  155. * b8-15:signature
  156. */
  157. #define CALIB_RESULT_SIGNATURE (0x11)
  158. #define RGF_USER_CLKS_CTL_0 (0x880abc)
  159. #define BIT_USER_CLKS_CAR_AHB_SW_SEL BIT(1) /* ref clk/PLL */
  160. #define BIT_USER_CLKS_RST_PWGD BIT(11) /* reset on "power good" */
  161. #define RGF_USER_CLKS_CTL_SW_RST_VEC_0 (0x880b04)
  162. #define RGF_USER_CLKS_CTL_SW_RST_VEC_1 (0x880b08)
  163. #define RGF_USER_CLKS_CTL_SW_RST_VEC_2 (0x880b0c)
  164. #define RGF_USER_CLKS_CTL_SW_RST_VEC_3 (0x880b10)
  165. #define RGF_USER_CLKS_CTL_SW_RST_MASK_0 (0x880b14)
  166. #define BIT_HPAL_PERST_FROM_PAD BIT(6)
  167. #define BIT_CAR_PERST_RST BIT(7)
  168. #define RGF_USER_USER_ICR (0x880b4c) /* struct RGF_ICR */
  169. #define BIT_USER_USER_ICR_SW_INT_2 BIT(18)
  170. #define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0 (0x880c18)
  171. #define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1 (0x880c2c)
  172. #define RGF_USER_SPARROW_M_4 (0x880c50) /* Sparrow */
  173. #define BIT_SPARROW_M_4_SEL_SLEEP_OR_REF BIT(2)
  174. #define RGF_DMA_EP_TX_ICR (0x881bb4) /* struct RGF_ICR */
  175. #define BIT_DMA_EP_TX_ICR_TX_DONE BIT(0)
  176. #define BIT_DMA_EP_TX_ICR_TX_DONE_N(n) BIT(n+1) /* n = [0..23] */
  177. #define RGF_DMA_EP_RX_ICR (0x881bd0) /* struct RGF_ICR */
  178. #define BIT_DMA_EP_RX_ICR_RX_DONE BIT(0)
  179. #define BIT_DMA_EP_RX_ICR_RX_HTRSH BIT(1)
  180. #define RGF_DMA_EP_MISC_ICR (0x881bec) /* struct RGF_ICR */
  181. #define BIT_DMA_EP_MISC_ICR_RX_HTRSH BIT(0)
  182. #define BIT_DMA_EP_MISC_ICR_TX_NO_ACT BIT(1)
  183. #define BIT_DMA_EP_MISC_ICR_HALP BIT(27)
  184. #define BIT_DMA_EP_MISC_ICR_FW_INT(n) BIT(28+n) /* n = [0..3] */
  185. /* Legacy interrupt moderation control (before Sparrow v2)*/
  186. #define RGF_DMA_ITR_CNT_TRSH (0x881c5c)
  187. #define RGF_DMA_ITR_CNT_DATA (0x881c60)
  188. #define RGF_DMA_ITR_CNT_CRL (0x881c64)
  189. #define BIT_DMA_ITR_CNT_CRL_EN BIT(0)
  190. #define BIT_DMA_ITR_CNT_CRL_EXT_TICK BIT(1)
  191. #define BIT_DMA_ITR_CNT_CRL_FOREVER BIT(2)
  192. #define BIT_DMA_ITR_CNT_CRL_CLR BIT(3)
  193. #define BIT_DMA_ITR_CNT_CRL_REACH_TRSH BIT(4)
  194. /* Offload control (Sparrow B0+) */
  195. #define RGF_DMA_OFUL_NID_0 (0x881cd4)
  196. #define BIT_DMA_OFUL_NID_0_RX_EXT_TR_EN BIT(0)
  197. #define BIT_DMA_OFUL_NID_0_TX_EXT_TR_EN BIT(1)
  198. #define BIT_DMA_OFUL_NID_0_RX_EXT_A3_SRC BIT(2)
  199. #define BIT_DMA_OFUL_NID_0_TX_EXT_A3_SRC BIT(3)
  200. /* New (sparrow v2+) interrupt moderation control */
  201. #define RGF_DMA_ITR_TX_DESQ_NO_MOD (0x881d40)
  202. #define RGF_DMA_ITR_TX_CNT_TRSH (0x881d34)
  203. #define RGF_DMA_ITR_TX_CNT_DATA (0x881d38)
  204. #define RGF_DMA_ITR_TX_CNT_CTL (0x881d3c)
  205. #define BIT_DMA_ITR_TX_CNT_CTL_EN BIT(0)
  206. #define BIT_DMA_ITR_TX_CNT_CTL_EXT_TIC_SEL BIT(1)
  207. #define BIT_DMA_ITR_TX_CNT_CTL_FOREVER BIT(2)
  208. #define BIT_DMA_ITR_TX_CNT_CTL_CLR BIT(3)
  209. #define BIT_DMA_ITR_TX_CNT_CTL_REACHED_TRESH BIT(4)
  210. #define BIT_DMA_ITR_TX_CNT_CTL_CROSS_EN BIT(5)
  211. #define BIT_DMA_ITR_TX_CNT_CTL_FREE_RUNNIG BIT(6)
  212. #define RGF_DMA_ITR_TX_IDL_CNT_TRSH (0x881d60)
  213. #define RGF_DMA_ITR_TX_IDL_CNT_DATA (0x881d64)
  214. #define RGF_DMA_ITR_TX_IDL_CNT_CTL (0x881d68)
  215. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_EN BIT(0)
  216. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_EXT_TIC_SEL BIT(1)
  217. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_FOREVER BIT(2)
  218. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_CLR BIT(3)
  219. #define BIT_DMA_ITR_TX_IDL_CNT_CTL_REACHED_TRESH BIT(4)
  220. #define RGF_DMA_ITR_RX_DESQ_NO_MOD (0x881d50)
  221. #define RGF_DMA_ITR_RX_CNT_TRSH (0x881d44)
  222. #define RGF_DMA_ITR_RX_CNT_DATA (0x881d48)
  223. #define RGF_DMA_ITR_RX_CNT_CTL (0x881d4c)
  224. #define BIT_DMA_ITR_RX_CNT_CTL_EN BIT(0)
  225. #define BIT_DMA_ITR_RX_CNT_CTL_EXT_TIC_SEL BIT(1)
  226. #define BIT_DMA_ITR_RX_CNT_CTL_FOREVER BIT(2)
  227. #define BIT_DMA_ITR_RX_CNT_CTL_CLR BIT(3)
  228. #define BIT_DMA_ITR_RX_CNT_CTL_REACHED_TRESH BIT(4)
  229. #define BIT_DMA_ITR_RX_CNT_CTL_CROSS_EN BIT(5)
  230. #define BIT_DMA_ITR_RX_CNT_CTL_FREE_RUNNIG BIT(6)
  231. #define RGF_DMA_ITR_RX_IDL_CNT_TRSH (0x881d54)
  232. #define RGF_DMA_ITR_RX_IDL_CNT_DATA (0x881d58)
  233. #define RGF_DMA_ITR_RX_IDL_CNT_CTL (0x881d5c)
  234. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_EN BIT(0)
  235. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_EXT_TIC_SEL BIT(1)
  236. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_FOREVER BIT(2)
  237. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_CLR BIT(3)
  238. #define BIT_DMA_ITR_RX_IDL_CNT_CTL_REACHED_TRESH BIT(4)
  239. #define RGF_DMA_PSEUDO_CAUSE (0x881c68)
  240. #define RGF_DMA_PSEUDO_CAUSE_MASK_SW (0x881c6c)
  241. #define RGF_DMA_PSEUDO_CAUSE_MASK_FW (0x881c70)
  242. #define BIT_DMA_PSEUDO_CAUSE_RX BIT(0)
  243. #define BIT_DMA_PSEUDO_CAUSE_TX BIT(1)
  244. #define BIT_DMA_PSEUDO_CAUSE_MISC BIT(2)
  245. #define RGF_HP_CTRL (0x88265c)
  246. #define RGF_PAL_UNIT_ICR (0x88266c) /* struct RGF_ICR */
  247. #define RGF_PCIE_LOS_COUNTER_CTL (0x882dc4)
  248. /* MAC timer, usec, for packet lifetime */
  249. #define RGF_MAC_MTRL_COUNTER_0 (0x886aa8)
  250. #define RGF_CAF_ICR (0x88946c) /* struct RGF_ICR */
  251. #define RGF_CAF_OSC_CONTROL (0x88afa4)
  252. #define BIT_CAF_OSC_XTAL_EN BIT(0)
  253. #define RGF_CAF_PLL_LOCK_STATUS (0x88afec)
  254. #define BIT_CAF_OSC_DIG_XTAL_STABLE BIT(0)
  255. #define RGF_USER_JTAG_DEV_ID (0x880b34) /* device ID */
  256. #define JTAG_DEV_ID_SPARROW (0x2632072f)
  257. #define RGF_USER_REVISION_ID (0x88afe4)
  258. #define RGF_USER_REVISION_ID_MASK (3)
  259. #define REVISION_ID_SPARROW_B0 (0x0)
  260. #define REVISION_ID_SPARROW_D0 (0x3)
  261. /* crash codes for FW/Ucode stored here */
  262. #define RGF_FW_ASSERT_CODE (0x91f020)
  263. #define RGF_UCODE_ASSERT_CODE (0x91f028)
  264. enum {
  265. HW_VER_UNKNOWN,
  266. HW_VER_SPARROW_B0, /* REVISION_ID_SPARROW_B0 */
  267. HW_VER_SPARROW_D0, /* REVISION_ID_SPARROW_D0 */
  268. };
  269. /* popular locations */
  270. #define RGF_MBOX RGF_USER_USER_SCRATCH_PAD
  271. #define HOST_MBOX HOSTADDR(RGF_MBOX)
  272. #define SW_INT_MBOX BIT_USER_USER_ICR_SW_INT_2
  273. /* ISR register bits */
  274. #define ISR_MISC_FW_READY BIT_DMA_EP_MISC_ICR_FW_INT(0)
  275. #define ISR_MISC_MBOX_EVT BIT_DMA_EP_MISC_ICR_FW_INT(1)
  276. #define ISR_MISC_FW_ERROR BIT_DMA_EP_MISC_ICR_FW_INT(3)
  277. #define WIL_DATA_COMPLETION_TO_MS 200
  278. /* Hardware definitions end */
  279. struct fw_map {
  280. u32 from; /* linker address - from, inclusive */
  281. u32 to; /* linker address - to, exclusive */
  282. u32 host; /* PCI/Host address - BAR0 + 0x880000 */
  283. const char *name; /* for debugfs */
  284. bool fw; /* true if FW mapping, false if UCODE mapping */
  285. };
  286. /* array size should be in sync with actual definition in the wmi.c */
  287. extern const struct fw_map fw_mapping[10];
  288. /**
  289. * mk_cidxtid - construct @cidxtid field
  290. * @cid: CID value
  291. * @tid: TID value
  292. *
  293. * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
  294. */
  295. static inline u8 mk_cidxtid(u8 cid, u8 tid)
  296. {
  297. return ((tid & 0xf) << 4) | (cid & 0xf);
  298. }
  299. /**
  300. * parse_cidxtid - parse @cidxtid field
  301. * @cid: store CID value here
  302. * @tid: store TID value here
  303. *
  304. * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
  305. */
  306. static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
  307. {
  308. *cid = cidxtid & 0xf;
  309. *tid = (cidxtid >> 4) & 0xf;
  310. }
  311. struct wil6210_mbox_ring {
  312. u32 base;
  313. u16 entry_size; /* max. size of mbox entry, incl. all headers */
  314. u16 size;
  315. u32 tail;
  316. u32 head;
  317. } __packed;
  318. struct wil6210_mbox_ring_desc {
  319. __le32 sync;
  320. __le32 addr;
  321. } __packed;
  322. /* at HOST_OFF_WIL6210_MBOX_CTL */
  323. struct wil6210_mbox_ctl {
  324. struct wil6210_mbox_ring tx;
  325. struct wil6210_mbox_ring rx;
  326. } __packed;
  327. struct wil6210_mbox_hdr {
  328. __le16 seq;
  329. __le16 len; /* payload, bytes after this header */
  330. __le16 type;
  331. u8 flags;
  332. u8 reserved;
  333. } __packed;
  334. #define WIL_MBOX_HDR_TYPE_WMI (0)
  335. /* max. value for wil6210_mbox_hdr.len */
  336. #define MAX_MBOXITEM_SIZE (240)
  337. struct pending_wmi_event {
  338. struct list_head list;
  339. struct {
  340. struct wil6210_mbox_hdr hdr;
  341. struct wmi_cmd_hdr wmi;
  342. u8 data[0];
  343. } __packed event;
  344. };
  345. enum { /* for wil_ctx.mapped_as */
  346. wil_mapped_as_none = 0,
  347. wil_mapped_as_single = 1,
  348. wil_mapped_as_page = 2,
  349. };
  350. /**
  351. * struct wil_ctx - software context for Vring descriptor
  352. */
  353. struct wil_ctx {
  354. struct sk_buff *skb;
  355. u8 nr_frags;
  356. u8 mapped_as;
  357. };
  358. union vring_desc;
  359. struct vring {
  360. dma_addr_t pa;
  361. volatile union vring_desc *va; /* vring_desc[size], WriteBack by DMA */
  362. u16 size; /* number of vring_desc elements */
  363. u32 swtail;
  364. u32 swhead;
  365. u32 hwtail; /* write here to inform hw */
  366. struct wil_ctx *ctx; /* ctx[size] - software context */
  367. };
  368. /**
  369. * Additional data for Tx Vring
  370. */
  371. struct vring_tx_data {
  372. bool dot1x_open;
  373. int enabled;
  374. cycles_t idle, last_idle, begin;
  375. u8 agg_wsize; /* agreed aggregation window, 0 - no agg */
  376. u16 agg_timeout;
  377. u8 agg_amsdu;
  378. bool addba_in_progress; /* if set, agg_xxx is for request in progress */
  379. spinlock_t lock;
  380. };
  381. enum { /* for wil6210_priv.status */
  382. wil_status_fwready = 0, /* FW operational */
  383. wil_status_fwconnecting,
  384. wil_status_fwconnected,
  385. wil_status_dontscan,
  386. wil_status_mbox_ready, /* MBOX structures ready */
  387. wil_status_irqen, /* FIXME: interrupts enabled - for debug */
  388. wil_status_napi_en, /* NAPI enabled protected by wil->mutex */
  389. wil_status_resetting, /* reset in progress */
  390. wil_status_suspending, /* suspend in progress */
  391. wil_status_suspended, /* suspend completed, device is suspended */
  392. wil_status_resuming, /* resume in progress */
  393. wil_status_last /* keep last */
  394. };
  395. struct pci_dev;
  396. /**
  397. * struct tid_ampdu_rx - TID aggregation information (Rx).
  398. *
  399. * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  400. * @reorder_time: jiffies when skb was added
  401. * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
  402. * @reorder_timer: releases expired frames from the reorder buffer.
  403. * @last_rx: jiffies of last rx activity
  404. * @head_seq_num: head sequence number in reordering buffer.
  405. * @stored_mpdu_num: number of MPDUs in reordering buffer
  406. * @ssn: Starting Sequence Number expected to be aggregated.
  407. * @buf_size: buffer size for incoming A-MPDUs
  408. * @timeout: reset timer value (in TUs).
  409. * @ssn_last_drop: SSN of the last dropped frame
  410. * @total: total number of processed incoming frames
  411. * @drop_dup: duplicate frames dropped for this reorder buffer
  412. * @drop_old: old frames dropped for this reorder buffer
  413. * @dialog_token: dialog token for aggregation session
  414. * @first_time: true when this buffer used 1-st time
  415. */
  416. struct wil_tid_ampdu_rx {
  417. struct sk_buff **reorder_buf;
  418. unsigned long *reorder_time;
  419. struct timer_list session_timer;
  420. struct timer_list reorder_timer;
  421. unsigned long last_rx;
  422. u16 head_seq_num;
  423. u16 stored_mpdu_num;
  424. u16 ssn;
  425. u16 buf_size;
  426. u16 timeout;
  427. u16 ssn_last_drop;
  428. unsigned long long total; /* frames processed */
  429. unsigned long long drop_dup;
  430. unsigned long long drop_old;
  431. u8 dialog_token;
  432. bool first_time; /* is it 1-st time this buffer used? */
  433. };
  434. /**
  435. * struct wil_tid_crypto_rx_single - TID crypto information (Rx).
  436. *
  437. * @pn: GCMP PN for the session
  438. * @key_set: valid key present
  439. */
  440. struct wil_tid_crypto_rx_single {
  441. u8 pn[IEEE80211_GCMP_PN_LEN];
  442. bool key_set;
  443. };
  444. struct wil_tid_crypto_rx {
  445. struct wil_tid_crypto_rx_single key_id[4];
  446. };
  447. struct wil_p2p_info {
  448. struct ieee80211_channel listen_chan;
  449. u8 discovery_started;
  450. u8 p2p_dev_started;
  451. u64 cookie;
  452. struct wireless_dev *pending_listen_wdev;
  453. unsigned int listen_duration;
  454. struct timer_list discovery_timer; /* listen/search duration */
  455. struct work_struct discovery_expired_work; /* listen/search expire */
  456. struct work_struct delayed_listen_work; /* listen after scan done */
  457. };
  458. enum wil_sta_status {
  459. wil_sta_unused = 0,
  460. wil_sta_conn_pending = 1,
  461. wil_sta_connected = 2,
  462. };
  463. #define WIL_STA_TID_NUM (16)
  464. #define WIL_MCS_MAX (12) /* Maximum MCS supported */
  465. struct wil_net_stats {
  466. unsigned long rx_packets;
  467. unsigned long tx_packets;
  468. unsigned long rx_bytes;
  469. unsigned long tx_bytes;
  470. unsigned long tx_errors;
  471. unsigned long rx_dropped;
  472. unsigned long rx_non_data_frame;
  473. unsigned long rx_short_frame;
  474. unsigned long rx_large_frame;
  475. unsigned long rx_replay;
  476. u16 last_mcs_rx;
  477. u64 rx_per_mcs[WIL_MCS_MAX + 1];
  478. };
  479. /**
  480. * struct wil_sta_info - data for peer
  481. *
  482. * Peer identified by its CID (connection ID)
  483. * NIC performs beam forming for each peer;
  484. * if no beam forming done, frame exchange is not
  485. * possible.
  486. */
  487. struct wil_sta_info {
  488. u8 addr[ETH_ALEN];
  489. enum wil_sta_status status;
  490. struct wil_net_stats stats;
  491. /* Rx BACK */
  492. struct wil_tid_ampdu_rx *tid_rx[WIL_STA_TID_NUM];
  493. spinlock_t tid_rx_lock; /* guarding tid_rx array */
  494. unsigned long tid_rx_timer_expired[BITS_TO_LONGS(WIL_STA_TID_NUM)];
  495. unsigned long tid_rx_stop_requested[BITS_TO_LONGS(WIL_STA_TID_NUM)];
  496. struct wil_tid_crypto_rx tid_crypto_rx[WIL_STA_TID_NUM];
  497. struct wil_tid_crypto_rx group_crypto_rx;
  498. u8 aid; /* 1-254; 0 if unknown/not reported */
  499. };
  500. enum {
  501. fw_recovery_idle = 0,
  502. fw_recovery_pending = 1,
  503. fw_recovery_running = 2,
  504. };
  505. enum {
  506. hw_capability_last
  507. };
  508. struct wil_probe_client_req {
  509. struct list_head list;
  510. u64 cookie;
  511. u8 cid;
  512. };
  513. struct pmc_ctx {
  514. /* alloc, free, and read operations must own the lock */
  515. struct mutex lock;
  516. struct vring_tx_desc *pring_va;
  517. dma_addr_t pring_pa;
  518. struct desc_alloc_info *descriptors;
  519. int last_cmd_status;
  520. int num_descriptors;
  521. int descriptor_size;
  522. };
  523. struct wil_halp {
  524. struct mutex lock; /* protect halp ref_cnt */
  525. unsigned int ref_cnt;
  526. struct completion comp;
  527. };
  528. struct wil_blob_wrapper {
  529. struct wil6210_priv *wil;
  530. struct debugfs_blob_wrapper blob;
  531. };
  532. #define WIL_LED_MAX_ID (2)
  533. #define WIL_LED_INVALID_ID (0xF)
  534. #define WIL_LED_BLINK_ON_SLOW_MS (300)
  535. #define WIL_LED_BLINK_OFF_SLOW_MS (300)
  536. #define WIL_LED_BLINK_ON_MED_MS (200)
  537. #define WIL_LED_BLINK_OFF_MED_MS (200)
  538. #define WIL_LED_BLINK_ON_FAST_MS (100)
  539. #define WIL_LED_BLINK_OFF_FAST_MS (100)
  540. enum {
  541. WIL_LED_TIME_SLOW = 0,
  542. WIL_LED_TIME_MED,
  543. WIL_LED_TIME_FAST,
  544. WIL_LED_TIME_LAST,
  545. };
  546. struct blink_on_off_time {
  547. u32 on_ms;
  548. u32 off_ms;
  549. };
  550. extern struct blink_on_off_time led_blink_time[WIL_LED_TIME_LAST];
  551. extern u8 led_id;
  552. extern u8 led_polarity;
  553. struct wil6210_priv {
  554. struct pci_dev *pdev;
  555. u32 bar_size;
  556. struct wireless_dev *wdev;
  557. void __iomem *csr;
  558. DECLARE_BITMAP(status, wil_status_last);
  559. u8 fw_version[ETHTOOL_FWVERS_LEN];
  560. u32 hw_version;
  561. u8 chip_revision;
  562. const char *hw_name;
  563. const char *wil_fw_name;
  564. DECLARE_BITMAP(hw_capabilities, hw_capability_last);
  565. DECLARE_BITMAP(fw_capabilities, WMI_FW_CAPABILITY_MAX);
  566. u8 n_mids; /* number of additional MIDs as reported by FW */
  567. u32 recovery_count; /* num of FW recovery attempts in a short time */
  568. u32 recovery_state; /* FW recovery state machine */
  569. unsigned long last_fw_recovery; /* jiffies of last fw recovery */
  570. wait_queue_head_t wq; /* for all wait_event() use */
  571. /* profile */
  572. u32 monitor_flags;
  573. u32 privacy; /* secure connection? */
  574. u8 hidden_ssid; /* relevant in AP mode */
  575. u16 channel; /* relevant in AP mode */
  576. int sinfo_gen;
  577. u32 ap_isolate; /* no intra-BSS communication */
  578. struct cfg80211_bss *bss; /* connected bss, relevant in STA mode */
  579. int locally_generated_disc; /* relevant in STA mode */
  580. /* interrupt moderation */
  581. u32 tx_max_burst_duration;
  582. u32 tx_interframe_timeout;
  583. u32 rx_max_burst_duration;
  584. u32 rx_interframe_timeout;
  585. /* cached ISR registers */
  586. u32 isr_misc;
  587. /* mailbox related */
  588. struct mutex wmi_mutex;
  589. struct wil6210_mbox_ctl mbox_ctl;
  590. struct completion wmi_ready;
  591. struct completion wmi_call;
  592. u16 wmi_seq;
  593. u16 reply_id; /**< wait for this WMI event */
  594. void *reply_buf;
  595. u16 reply_size;
  596. struct workqueue_struct *wmi_wq; /* for deferred calls */
  597. struct work_struct wmi_event_worker;
  598. struct workqueue_struct *wq_service;
  599. struct work_struct disconnect_worker;
  600. struct work_struct fw_error_worker; /* for FW error recovery */
  601. struct timer_list connect_timer;
  602. struct timer_list scan_timer; /* detect scan timeout */
  603. struct list_head pending_wmi_ev;
  604. /*
  605. * protect pending_wmi_ev
  606. * - fill in IRQ from wil6210_irq_misc,
  607. * - consumed in thread by wmi_event_worker
  608. */
  609. spinlock_t wmi_ev_lock;
  610. spinlock_t net_queue_lock; /* guarding stop/wake netif queue */
  611. int net_queue_stopped; /* netif_tx_stop_all_queues invoked */
  612. struct napi_struct napi_rx;
  613. struct napi_struct napi_tx;
  614. /* keep alive */
  615. struct list_head probe_client_pending;
  616. struct mutex probe_client_mutex; /* protect @probe_client_pending */
  617. struct work_struct probe_client_worker;
  618. /* DMA related */
  619. struct vring vring_rx;
  620. unsigned int rx_buf_len;
  621. struct vring vring_tx[WIL6210_MAX_TX_RINGS];
  622. struct vring_tx_data vring_tx_data[WIL6210_MAX_TX_RINGS];
  623. u8 vring2cid_tid[WIL6210_MAX_TX_RINGS][2]; /* [0] - CID, [1] - TID */
  624. struct wil_sta_info sta[WIL6210_MAX_CID];
  625. int bcast_vring;
  626. u32 vring_idle_trsh; /* HW fetches up to 16 descriptors at once */
  627. bool use_extended_dma_addr; /* indicates whether we are using 48 bits */
  628. /* scan */
  629. struct cfg80211_scan_request *scan_request;
  630. struct mutex mutex; /* for wil6210_priv access in wil_{up|down} */
  631. /* statistics */
  632. atomic_t isr_count_rx, isr_count_tx;
  633. /* debugfs */
  634. struct dentry *debug;
  635. struct wil_blob_wrapper blobs[ARRAY_SIZE(fw_mapping)];
  636. u8 discovery_mode;
  637. u8 abft_len;
  638. u8 wakeup_trigger;
  639. struct wil_suspend_stats suspend_stats;
  640. void *platform_handle;
  641. struct wil_platform_ops platform_ops;
  642. bool keep_radio_on_during_sleep;
  643. struct pmc_ctx pmc;
  644. bool pbss;
  645. struct wil_p2p_info p2p;
  646. /* P2P_DEVICE vif */
  647. struct wireless_dev *p2p_wdev;
  648. struct mutex p2p_wdev_mutex; /* protect @p2p_wdev and @scan_request */
  649. struct wireless_dev *radio_wdev;
  650. /* High Access Latency Policy voting */
  651. struct wil_halp halp;
  652. enum wmi_ps_profile_type ps_profile;
  653. int fw_calib_result;
  654. #ifdef CONFIG_PM
  655. #ifdef CONFIG_PM_SLEEP
  656. struct notifier_block pm_notify;
  657. #endif /* CONFIG_PM_SLEEP */
  658. #endif /* CONFIG_PM */
  659. bool suspend_resp_rcvd;
  660. bool suspend_resp_comp;
  661. u32 bus_request_kbps;
  662. u32 bus_request_kbps_pre_suspend;
  663. };
  664. #define wil_to_wiphy(i) (i->wdev->wiphy)
  665. #define wil_to_dev(i) (wiphy_dev(wil_to_wiphy(i)))
  666. #define wiphy_to_wil(w) (struct wil6210_priv *)(wiphy_priv(w))
  667. #define wil_to_wdev(i) (i->wdev)
  668. #define wdev_to_wil(w) (struct wil6210_priv *)(wdev_priv(w))
  669. #define wil_to_ndev(i) (wil_to_wdev(i)->netdev)
  670. #define ndev_to_wil(n) (wdev_to_wil(n->ieee80211_ptr))
  671. __printf(2, 3)
  672. void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...);
  673. __printf(2, 3)
  674. void __wil_err(struct wil6210_priv *wil, const char *fmt, ...);
  675. __printf(2, 3)
  676. void __wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...);
  677. __printf(2, 3)
  678. void __wil_info(struct wil6210_priv *wil, const char *fmt, ...);
  679. __printf(2, 3)
  680. void wil_dbg_ratelimited(const struct wil6210_priv *wil, const char *fmt, ...);
  681. #define wil_dbg(wil, fmt, arg...) do { \
  682. netdev_dbg(wil_to_ndev(wil), fmt, ##arg); \
  683. wil_dbg_trace(wil, fmt, ##arg); \
  684. } while (0)
  685. #define wil_dbg_irq(wil, fmt, arg...) wil_dbg(wil, "DBG[ IRQ]" fmt, ##arg)
  686. #define wil_dbg_txrx(wil, fmt, arg...) wil_dbg(wil, "DBG[TXRX]" fmt, ##arg)
  687. #define wil_dbg_wmi(wil, fmt, arg...) wil_dbg(wil, "DBG[ WMI]" fmt, ##arg)
  688. #define wil_dbg_misc(wil, fmt, arg...) wil_dbg(wil, "DBG[MISC]" fmt, ##arg)
  689. #define wil_dbg_pm(wil, fmt, arg...) wil_dbg(wil, "DBG[ PM ]" fmt, ##arg)
  690. #define wil_err(wil, fmt, arg...) __wil_err(wil, "%s: " fmt, __func__, ##arg)
  691. #define wil_info(wil, fmt, arg...) __wil_info(wil, "%s: " fmt, __func__, ##arg)
  692. #define wil_err_ratelimited(wil, fmt, arg...) \
  693. __wil_err_ratelimited(wil, "%s: " fmt, __func__, ##arg)
  694. /* target operations */
  695. /* register read */
  696. static inline u32 wil_r(struct wil6210_priv *wil, u32 reg)
  697. {
  698. return readl(wil->csr + HOSTADDR(reg));
  699. }
  700. /* register write. wmb() to make sure it is completed */
  701. static inline void wil_w(struct wil6210_priv *wil, u32 reg, u32 val)
  702. {
  703. writel(val, wil->csr + HOSTADDR(reg));
  704. wmb(); /* wait for write to propagate to the HW */
  705. }
  706. /* register set = read, OR, write */
  707. static inline void wil_s(struct wil6210_priv *wil, u32 reg, u32 val)
  708. {
  709. wil_w(wil, reg, wil_r(wil, reg) | val);
  710. }
  711. /* register clear = read, AND with inverted, write */
  712. static inline void wil_c(struct wil6210_priv *wil, u32 reg, u32 val)
  713. {
  714. wil_w(wil, reg, wil_r(wil, reg) & ~val);
  715. }
  716. #if defined(CONFIG_DYNAMIC_DEBUG)
  717. #define wil_hex_dump_txrx(prefix_str, prefix_type, rowsize, \
  718. groupsize, buf, len, ascii) \
  719. print_hex_dump_debug("DBG[TXRX]" prefix_str,\
  720. prefix_type, rowsize, \
  721. groupsize, buf, len, ascii)
  722. #define wil_hex_dump_wmi(prefix_str, prefix_type, rowsize, \
  723. groupsize, buf, len, ascii) \
  724. print_hex_dump_debug("DBG[ WMI]" prefix_str,\
  725. prefix_type, rowsize, \
  726. groupsize, buf, len, ascii)
  727. #define wil_hex_dump_misc(prefix_str, prefix_type, rowsize, \
  728. groupsize, buf, len, ascii) \
  729. print_hex_dump_debug("DBG[MISC]" prefix_str,\
  730. prefix_type, rowsize, \
  731. groupsize, buf, len, ascii)
  732. #else /* defined(CONFIG_DYNAMIC_DEBUG) */
  733. static inline
  734. void wil_hex_dump_txrx(const char *prefix_str, int prefix_type, int rowsize,
  735. int groupsize, const void *buf, size_t len, bool ascii)
  736. {
  737. }
  738. static inline
  739. void wil_hex_dump_wmi(const char *prefix_str, int prefix_type, int rowsize,
  740. int groupsize, const void *buf, size_t len, bool ascii)
  741. {
  742. }
  743. static inline
  744. void wil_hex_dump_misc(const char *prefix_str, int prefix_type, int rowsize,
  745. int groupsize, const void *buf, size_t len, bool ascii)
  746. {
  747. }
  748. #endif /* defined(CONFIG_DYNAMIC_DEBUG) */
  749. void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
  750. size_t count);
  751. void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
  752. size_t count);
  753. void *wil_if_alloc(struct device *dev);
  754. void wil_if_free(struct wil6210_priv *wil);
  755. int wil_if_add(struct wil6210_priv *wil);
  756. void wil_if_remove(struct wil6210_priv *wil);
  757. int wil_priv_init(struct wil6210_priv *wil);
  758. void wil_priv_deinit(struct wil6210_priv *wil);
  759. int wil_ps_update(struct wil6210_priv *wil,
  760. enum wmi_ps_profile_type ps_profile);
  761. int wil_reset(struct wil6210_priv *wil, bool no_fw);
  762. void wil_fw_error_recovery(struct wil6210_priv *wil);
  763. void wil_set_recovery_state(struct wil6210_priv *wil, int state);
  764. bool wil_is_recovery_blocked(struct wil6210_priv *wil);
  765. int wil_up(struct wil6210_priv *wil);
  766. int __wil_up(struct wil6210_priv *wil);
  767. int wil_down(struct wil6210_priv *wil);
  768. int __wil_down(struct wil6210_priv *wil);
  769. void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
  770. int wil_find_cid(struct wil6210_priv *wil, const u8 *mac);
  771. void wil_set_ethtoolops(struct net_device *ndev);
  772. void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr);
  773. void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr);
  774. int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,
  775. struct wil6210_mbox_hdr *hdr);
  776. int wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len);
  777. void wmi_recv_cmd(struct wil6210_priv *wil);
  778. int wmi_call(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len,
  779. u16 reply_id, void *reply, u8 reply_size, int to_msec);
  780. void wmi_event_worker(struct work_struct *work);
  781. void wmi_event_flush(struct wil6210_priv *wil);
  782. int wmi_set_ssid(struct wil6210_priv *wil, u8 ssid_len, const void *ssid);
  783. int wmi_get_ssid(struct wil6210_priv *wil, u8 *ssid_len, void *ssid);
  784. int wmi_set_channel(struct wil6210_priv *wil, int channel);
  785. int wmi_get_channel(struct wil6210_priv *wil, int *channel);
  786. int wmi_del_cipher_key(struct wil6210_priv *wil, u8 key_index,
  787. const void *mac_addr, int key_usage);
  788. int wmi_add_cipher_key(struct wil6210_priv *wil, u8 key_index,
  789. const void *mac_addr, int key_len, const void *key,
  790. int key_usage);
  791. int wmi_echo(struct wil6210_priv *wil);
  792. int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 ie_len, const void *ie);
  793. int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring);
  794. int wmi_rxon(struct wil6210_priv *wil, bool on);
  795. int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
  796. int wmi_disconnect_sta(struct wil6210_priv *wil, const u8 *mac,
  797. u16 reason, bool full_disconnect, bool del_sta);
  798. int wmi_addba(struct wil6210_priv *wil, u8 ringid, u8 size, u16 timeout);
  799. int wmi_delba_tx(struct wil6210_priv *wil, u8 ringid, u16 reason);
  800. int wmi_delba_rx(struct wil6210_priv *wil, u8 cidxtid, u16 reason);
  801. int wmi_addba_rx_resp(struct wil6210_priv *wil, u8 cid, u8 tid, u8 token,
  802. u16 status, bool amsdu, u16 agg_wsize, u16 timeout);
  803. int wmi_ps_dev_profile_cfg(struct wil6210_priv *wil,
  804. enum wmi_ps_profile_type ps_profile);
  805. int wmi_set_mgmt_retry(struct wil6210_priv *wil, u8 retry_short);
  806. int wmi_get_mgmt_retry(struct wil6210_priv *wil, u8 *retry_short);
  807. int wmi_new_sta(struct wil6210_priv *wil, const u8 *mac, u8 aid);
  808. int wil_addba_rx_request(struct wil6210_priv *wil, u8 cidxtid,
  809. u8 dialog_token, __le16 ba_param_set,
  810. __le16 ba_timeout, __le16 ba_seq_ctrl);
  811. int wil_addba_tx_request(struct wil6210_priv *wil, u8 ringid, u16 wsize);
  812. void wil6210_clear_irq(struct wil6210_priv *wil);
  813. int wil6210_init_irq(struct wil6210_priv *wil, int irq, bool use_msi);
  814. void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
  815. void wil_mask_irq(struct wil6210_priv *wil);
  816. void wil_unmask_irq(struct wil6210_priv *wil);
  817. void wil_configure_interrupt_moderation(struct wil6210_priv *wil);
  818. void wil_disable_irq(struct wil6210_priv *wil);
  819. void wil_enable_irq(struct wil6210_priv *wil);
  820. void wil6210_mask_halp(struct wil6210_priv *wil);
  821. /* P2P */
  822. bool wil_p2p_is_social_scan(struct cfg80211_scan_request *request);
  823. void wil_p2p_discovery_timer_fn(struct timer_list *t);
  824. int wil_p2p_search(struct wil6210_priv *wil,
  825. struct cfg80211_scan_request *request);
  826. int wil_p2p_listen(struct wil6210_priv *wil, struct wireless_dev *wdev,
  827. unsigned int duration, struct ieee80211_channel *chan,
  828. u64 *cookie);
  829. u8 wil_p2p_stop_discovery(struct wil6210_priv *wil);
  830. int wil_p2p_cancel_listen(struct wil6210_priv *wil, u64 cookie);
  831. void wil_p2p_listen_expired(struct work_struct *work);
  832. void wil_p2p_search_expired(struct work_struct *work);
  833. void wil_p2p_stop_radio_operations(struct wil6210_priv *wil);
  834. void wil_p2p_delayed_listen_work(struct work_struct *work);
  835. /* WMI for P2P */
  836. int wmi_p2p_cfg(struct wil6210_priv *wil, int channel, int bi);
  837. int wmi_start_listen(struct wil6210_priv *wil);
  838. int wmi_start_search(struct wil6210_priv *wil);
  839. int wmi_stop_discovery(struct wil6210_priv *wil);
  840. int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
  841. struct cfg80211_mgmt_tx_params *params,
  842. u64 *cookie);
  843. #if defined(CONFIG_WIL6210_DEBUGFS)
  844. int wil6210_debugfs_init(struct wil6210_priv *wil);
  845. void wil6210_debugfs_remove(struct wil6210_priv *wil);
  846. #else
  847. static inline int wil6210_debugfs_init(struct wil6210_priv *wil) { return 0; }
  848. static inline void wil6210_debugfs_remove(struct wil6210_priv *wil) {}
  849. #endif
  850. int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
  851. struct station_info *sinfo);
  852. struct wireless_dev *wil_cfg80211_init(struct device *dev);
  853. void wil_wdev_free(struct wil6210_priv *wil);
  854. void wil_p2p_wdev_free(struct wil6210_priv *wil);
  855. int wmi_set_mac_address(struct wil6210_priv *wil, void *addr);
  856. int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype,
  857. u8 chan, u8 hidden_ssid, u8 is_go);
  858. int wmi_pcp_stop(struct wil6210_priv *wil);
  859. int wmi_led_cfg(struct wil6210_priv *wil, bool enable);
  860. int wmi_abort_scan(struct wil6210_priv *wil);
  861. void wil_abort_scan(struct wil6210_priv *wil, bool sync);
  862. void wil6210_bus_request(struct wil6210_priv *wil, u32 kbps);
  863. void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
  864. u16 reason_code, bool from_event);
  865. void wil_probe_client_flush(struct wil6210_priv *wil);
  866. void wil_probe_client_worker(struct work_struct *work);
  867. int wil_rx_init(struct wil6210_priv *wil, u16 size);
  868. void wil_rx_fini(struct wil6210_priv *wil);
  869. /* TX API */
  870. int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
  871. int cid, int tid);
  872. void wil_vring_fini_tx(struct wil6210_priv *wil, int id);
  873. int wil_tx_init(struct wil6210_priv *wil, int cid);
  874. int wil_vring_init_bcast(struct wil6210_priv *wil, int id, int size);
  875. int wil_bcast_init(struct wil6210_priv *wil);
  876. void wil_bcast_fini(struct wil6210_priv *wil);
  877. void wil_update_net_queues(struct wil6210_priv *wil, struct vring *vring,
  878. bool should_stop);
  879. void wil_update_net_queues_bh(struct wil6210_priv *wil, struct vring *vring,
  880. bool check_stop);
  881. netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev);
  882. int wil_tx_complete(struct wil6210_priv *wil, int ringid);
  883. void wil6210_unmask_irq_tx(struct wil6210_priv *wil);
  884. /* RX API */
  885. void wil_rx_handle(struct wil6210_priv *wil, int *quota);
  886. void wil6210_unmask_irq_rx(struct wil6210_priv *wil);
  887. int wil_iftype_nl2wmi(enum nl80211_iftype type);
  888. int wil_request_firmware(struct wil6210_priv *wil, const char *name,
  889. bool load);
  890. bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);
  891. int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
  892. int wil_suspend(struct wil6210_priv *wil, bool is_runtime);
  893. int wil_resume(struct wil6210_priv *wil, bool is_runtime);
  894. bool wil_is_wmi_idle(struct wil6210_priv *wil);
  895. int wmi_resume(struct wil6210_priv *wil);
  896. int wmi_suspend(struct wil6210_priv *wil);
  897. bool wil_is_tx_idle(struct wil6210_priv *wil);
  898. bool wil_is_rx_idle(struct wil6210_priv *wil);
  899. int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size);
  900. void wil_fw_core_dump(struct wil6210_priv *wil);
  901. void wil_halp_vote(struct wil6210_priv *wil);
  902. void wil_halp_unvote(struct wil6210_priv *wil);
  903. void wil6210_set_halp(struct wil6210_priv *wil);
  904. void wil6210_clear_halp(struct wil6210_priv *wil);
  905. #endif /* __WIL6210_H__ */