mvm.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  10. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of version 2 of the GNU General Public License as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  24. * USA
  25. *
  26. * The full GNU General Public License is included in this distribution
  27. * in the file called COPYING.
  28. *
  29. * Contact Information:
  30. * Intel Linux Wireless <linuxwifi@intel.com>
  31. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  32. *
  33. * BSD LICENSE
  34. *
  35. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  36. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  37. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  38. * All rights reserved.
  39. *
  40. * Redistribution and use in source and binary forms, with or without
  41. * modification, are permitted provided that the following conditions
  42. * are met:
  43. *
  44. * * Redistributions of source code must retain the above copyright
  45. * notice, this list of conditions and the following disclaimer.
  46. * * Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in
  48. * the documentation and/or other materials provided with the
  49. * distribution.
  50. * * Neither the name Intel Corporation nor the names of its
  51. * contributors may be used to endorse or promote products derived
  52. * from this software without specific prior written permission.
  53. *
  54. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  55. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  56. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  57. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  58. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  59. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  60. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  61. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  62. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  63. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  65. *
  66. *****************************************************************************/
  67. #ifndef __IWL_MVM_H__
  68. #define __IWL_MVM_H__
  69. #include <linux/list.h>
  70. #include <linux/spinlock.h>
  71. #include <linux/leds.h>
  72. #include <linux/in6.h>
  73. #ifdef CONFIG_THERMAL
  74. #include <linux/thermal.h>
  75. #endif
  76. #include "iwl-op-mode.h"
  77. #include "iwl-trans.h"
  78. #include "fw/notif-wait.h"
  79. #include "iwl-eeprom-parse.h"
  80. #include "fw/file.h"
  81. #include "iwl-config.h"
  82. #include "sta.h"
  83. #include "fw-api.h"
  84. #include "constants.h"
  85. #include "tof.h"
  86. #include "fw/runtime.h"
  87. #include "fw/dbg.h"
  88. #include "fw/acpi.h"
  89. #define IWL_MVM_MAX_ADDRESSES 5
  90. /* RSSI offset for WkP */
  91. #define IWL_RSSI_OFFSET 50
  92. #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
  93. /* A TimeUnit is 1024 microsecond */
  94. #define MSEC_TO_TU(_msec) (_msec*1000/1024)
  95. /* For GO, this value represents the number of TUs before CSA "beacon
  96. * 0" TBTT when the CSA time-event needs to be scheduled to start. It
  97. * must be big enough to ensure that we switch in time.
  98. */
  99. #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40
  100. /* For client, this value represents the number of TUs before CSA
  101. * "beacon 1" TBTT, instead. This is because we don't know when the
  102. * GO/AP will be in the new channel, so we switch early enough.
  103. */
  104. #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10
  105. /*
  106. * This value (in TUs) is used to fine tune the CSA NoA end time which should
  107. * be just before "beacon 0" TBTT.
  108. */
  109. #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
  110. /*
  111. * Number of beacons to transmit on a new channel until we unblock tx to
  112. * the stations, even if we didn't identify them on a new channel
  113. */
  114. #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
  115. /* offchannel queue towards mac80211 */
  116. #define IWL_MVM_OFFCHANNEL_QUEUE 0
  117. extern const struct ieee80211_ops iwl_mvm_hw_ops;
  118. /**
  119. * struct iwl_mvm_mod_params - module parameters for iwlmvm
  120. * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
  121. * We will register to mac80211 to have testmode working. The NIC must not
  122. * be up'ed after the INIT fw asserted. This is useful to be able to use
  123. * proprietary tools over testmode to debug the INIT fw.
  124. * @tfd_q_hang_detect: enabled the detection of hung transmit queues
  125. * @power_scheme: one of enum iwl_power_scheme
  126. */
  127. struct iwl_mvm_mod_params {
  128. bool init_dbg;
  129. bool tfd_q_hang_detect;
  130. int power_scheme;
  131. };
  132. extern struct iwl_mvm_mod_params iwlmvm_mod_params;
  133. struct iwl_mvm_phy_ctxt {
  134. u16 id;
  135. u16 color;
  136. u32 ref;
  137. enum nl80211_chan_width width;
  138. /*
  139. * TODO: This should probably be removed. Currently here only for rate
  140. * scaling algorithm
  141. */
  142. struct ieee80211_channel *channel;
  143. };
  144. struct iwl_mvm_time_event_data {
  145. struct ieee80211_vif *vif;
  146. struct list_head list;
  147. unsigned long end_jiffies;
  148. u32 duration;
  149. bool running;
  150. u32 uid;
  151. /*
  152. * The access to the 'id' field must be done when the
  153. * mvm->time_event_lock is held, as it value is used to indicate
  154. * if the te is in the time event list or not (when id == TE_MAX)
  155. */
  156. u32 id;
  157. };
  158. /* Power management */
  159. /**
  160. * enum iwl_power_scheme
  161. * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
  162. * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
  163. * @IWL_POWER_LEVEL_LP - Low Power
  164. */
  165. enum iwl_power_scheme {
  166. IWL_POWER_SCHEME_CAM = 1,
  167. IWL_POWER_SCHEME_BPS,
  168. IWL_POWER_SCHEME_LP
  169. };
  170. #define IWL_CONN_MAX_LISTEN_INTERVAL 10
  171. #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
  172. #ifdef CONFIG_IWLWIFI_DEBUGFS
  173. enum iwl_dbgfs_pm_mask {
  174. MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
  175. MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
  176. MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
  177. MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
  178. MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
  179. MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
  180. MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
  181. MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
  182. MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
  183. MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
  184. };
  185. struct iwl_dbgfs_pm {
  186. u16 keep_alive_seconds;
  187. u32 rx_data_timeout;
  188. u32 tx_data_timeout;
  189. bool skip_over_dtim;
  190. u8 skip_dtim_periods;
  191. bool lprx_ena;
  192. u32 lprx_rssi_threshold;
  193. bool snooze_ena;
  194. bool uapsd_misbehaving;
  195. bool use_ps_poll;
  196. int mask;
  197. };
  198. /* beacon filtering */
  199. enum iwl_dbgfs_bf_mask {
  200. MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
  201. MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
  202. MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
  203. MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
  204. MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
  205. MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
  206. MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
  207. MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
  208. MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
  209. MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
  210. MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
  211. };
  212. struct iwl_dbgfs_bf {
  213. u32 bf_energy_delta;
  214. u32 bf_roaming_energy_delta;
  215. u32 bf_roaming_state;
  216. u32 bf_temp_threshold;
  217. u32 bf_temp_fast_filter;
  218. u32 bf_temp_slow_filter;
  219. u32 bf_enable_beacon_filter;
  220. u32 bf_debug_flag;
  221. u32 bf_escape_timer;
  222. u32 ba_escape_timer;
  223. u32 ba_enable_beacon_abort;
  224. int mask;
  225. };
  226. #endif
  227. enum iwl_mvm_smps_type_request {
  228. IWL_MVM_SMPS_REQ_BT_COEX,
  229. IWL_MVM_SMPS_REQ_TT,
  230. IWL_MVM_SMPS_REQ_PROT,
  231. NUM_IWL_MVM_SMPS_REQ,
  232. };
  233. enum iwl_mvm_ref_type {
  234. IWL_MVM_REF_UCODE_DOWN,
  235. IWL_MVM_REF_SCAN,
  236. IWL_MVM_REF_ROC,
  237. IWL_MVM_REF_ROC_AUX,
  238. IWL_MVM_REF_P2P_CLIENT,
  239. IWL_MVM_REF_AP_IBSS,
  240. IWL_MVM_REF_USER,
  241. IWL_MVM_REF_TX,
  242. IWL_MVM_REF_TX_AGG,
  243. IWL_MVM_REF_ADD_IF,
  244. IWL_MVM_REF_START_AP,
  245. IWL_MVM_REF_BSS_CHANGED,
  246. IWL_MVM_REF_PREPARE_TX,
  247. IWL_MVM_REF_PROTECT_TDLS,
  248. IWL_MVM_REF_CHECK_CTKILL,
  249. IWL_MVM_REF_PRPH_READ,
  250. IWL_MVM_REF_PRPH_WRITE,
  251. IWL_MVM_REF_NMI,
  252. IWL_MVM_REF_TM_CMD,
  253. IWL_MVM_REF_EXIT_WORK,
  254. IWL_MVM_REF_PROTECT_CSA,
  255. IWL_MVM_REF_FW_DBG_COLLECT,
  256. IWL_MVM_REF_INIT_UCODE,
  257. IWL_MVM_REF_SENDING_CMD,
  258. IWL_MVM_REF_RX,
  259. /* update debugfs.c when changing this */
  260. IWL_MVM_REF_COUNT,
  261. };
  262. enum iwl_bt_force_ant_mode {
  263. BT_FORCE_ANT_DIS = 0,
  264. BT_FORCE_ANT_AUTO,
  265. BT_FORCE_ANT_BT,
  266. BT_FORCE_ANT_WIFI,
  267. BT_FORCE_ANT_MAX,
  268. };
  269. /**
  270. * struct iwl_mvm_vif_bf_data - beacon filtering related data
  271. * @bf_enabled: indicates if beacon filtering is enabled
  272. * @ba_enabled: indicated if beacon abort is enabled
  273. * @ave_beacon_signal: average beacon signal
  274. * @last_cqm_event: rssi of the last cqm event
  275. * @bt_coex_min_thold: minimum threshold for BT coex
  276. * @bt_coex_max_thold: maximum threshold for BT coex
  277. * @last_bt_coex_event: rssi of the last BT coex event
  278. */
  279. struct iwl_mvm_vif_bf_data {
  280. bool bf_enabled;
  281. bool ba_enabled;
  282. int ave_beacon_signal;
  283. int last_cqm_event;
  284. int bt_coex_min_thold;
  285. int bt_coex_max_thold;
  286. int last_bt_coex_event;
  287. };
  288. /**
  289. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  290. * @id: between 0 and 3
  291. * @color: to solve races upon MAC addition and removal
  292. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  293. * @bssid: BSSID for this (client) interface
  294. * @associated: indicates that we're currently associated, used only for
  295. * managing the firmware state in iwl_mvm_bss_info_changed_station()
  296. * @ap_assoc_sta_count: count of stations associated to us - valid only
  297. * if VIF type is AP
  298. * @uploaded: indicates the MAC context has been added to the device
  299. * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
  300. * should get quota etc.
  301. * @pm_enabled - Indicate if MAC power management is allowed
  302. * @monitor_active: indicates that monitor context is configured, and that the
  303. * interface should get quota etc.
  304. * @low_latency_traffic: indicates low latency traffic was detected
  305. * @low_latency_dbgfs: low latency mode set from debugfs
  306. * @low_latency_vcmd: low latency mode set from vendor command
  307. * @ps_disabled: indicates that this interface requires PS to be disabled
  308. * @queue_params: QoS params for this MAC
  309. * @bcast_sta: station used for broadcast packets. Used by the following
  310. * vifs: P2P_DEVICE, GO and AP.
  311. * @beacon_skb: the skb used to hold the AP/GO beacon template
  312. * @smps_requests: the SMPS requests of different parts of the driver,
  313. * combined on update to yield the overall request to mac80211.
  314. * @beacon_stats: beacon statistics, containing the # of received beacons,
  315. * # of received beacons accumulated over FW restart, and the current
  316. * average signal of beacons retrieved from the firmware
  317. * @csa_failed: CSA failed to schedule time event, report an error later
  318. * @features: hw features active for this vif
  319. */
  320. struct iwl_mvm_vif {
  321. struct iwl_mvm *mvm;
  322. u16 id;
  323. u16 color;
  324. u8 ap_sta_id;
  325. u8 bssid[ETH_ALEN];
  326. bool associated;
  327. u8 ap_assoc_sta_count;
  328. u16 cab_queue;
  329. bool uploaded;
  330. bool ap_ibss_active;
  331. bool pm_enabled;
  332. bool monitor_active;
  333. bool low_latency_traffic, low_latency_dbgfs, low_latency_vcmd;
  334. bool ps_disabled;
  335. struct iwl_mvm_vif_bf_data bf_data;
  336. struct {
  337. u32 num_beacons, accu_num_beacons;
  338. u8 avg_signal;
  339. } beacon_stats;
  340. u32 ap_beacon_time;
  341. enum iwl_tsf_id tsf_id;
  342. /*
  343. * QoS data from mac80211, need to store this here
  344. * as mac80211 has a separate callback but we need
  345. * to have the data for the MAC context
  346. */
  347. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  348. struct iwl_mvm_time_event_data time_event_data;
  349. struct iwl_mvm_time_event_data hs_time_event_data;
  350. struct iwl_mvm_int_sta bcast_sta;
  351. struct iwl_mvm_int_sta mcast_sta;
  352. /*
  353. * Assigned while mac80211 has the interface in a channel context,
  354. * or, for P2P Device, while it exists.
  355. */
  356. struct iwl_mvm_phy_ctxt *phy_ctxt;
  357. #ifdef CONFIG_PM
  358. /* WoWLAN GTK rekey data */
  359. struct {
  360. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  361. __le64 replay_ctr;
  362. bool valid;
  363. } rekey_data;
  364. int tx_key_idx;
  365. bool seqno_valid;
  366. u16 seqno;
  367. #endif
  368. #if IS_ENABLED(CONFIG_IPV6)
  369. /* IPv6 addresses for WoWLAN */
  370. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  371. unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)];
  372. int num_target_ipv6_addrs;
  373. #endif
  374. #ifdef CONFIG_IWLWIFI_DEBUGFS
  375. struct dentry *dbgfs_dir;
  376. struct dentry *dbgfs_slink;
  377. struct iwl_dbgfs_pm dbgfs_pm;
  378. struct iwl_dbgfs_bf dbgfs_bf;
  379. struct iwl_mac_power_cmd mac_pwr_cmd;
  380. int dbgfs_quota_min;
  381. #endif
  382. enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
  383. /* FW identified misbehaving AP */
  384. u8 uapsd_misbehaving_bssid[ETH_ALEN];
  385. /* Indicates that CSA countdown may be started */
  386. bool csa_countdown;
  387. bool csa_failed;
  388. u16 csa_target_freq;
  389. /* TCP Checksum Offload */
  390. netdev_features_t features;
  391. };
  392. static inline struct iwl_mvm_vif *
  393. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  394. {
  395. if (!vif)
  396. return NULL;
  397. return (void *)vif->drv_priv;
  398. }
  399. extern const u8 tid_to_mac80211_ac[];
  400. #define IWL_MVM_SCAN_STOPPING_SHIFT 8
  401. enum iwl_scan_status {
  402. IWL_MVM_SCAN_REGULAR = BIT(0),
  403. IWL_MVM_SCAN_SCHED = BIT(1),
  404. IWL_MVM_SCAN_NETDETECT = BIT(2),
  405. IWL_MVM_SCAN_STOPPING_REGULAR = BIT(8),
  406. IWL_MVM_SCAN_STOPPING_SCHED = BIT(9),
  407. IWL_MVM_SCAN_STOPPING_NETDETECT = BIT(10),
  408. IWL_MVM_SCAN_REGULAR_MASK = IWL_MVM_SCAN_REGULAR |
  409. IWL_MVM_SCAN_STOPPING_REGULAR,
  410. IWL_MVM_SCAN_SCHED_MASK = IWL_MVM_SCAN_SCHED |
  411. IWL_MVM_SCAN_STOPPING_SCHED,
  412. IWL_MVM_SCAN_NETDETECT_MASK = IWL_MVM_SCAN_NETDETECT |
  413. IWL_MVM_SCAN_STOPPING_NETDETECT,
  414. IWL_MVM_SCAN_STOPPING_MASK = 0xff << IWL_MVM_SCAN_STOPPING_SHIFT,
  415. IWL_MVM_SCAN_MASK = 0xff,
  416. };
  417. enum iwl_mvm_scan_type {
  418. IWL_SCAN_TYPE_NOT_SET,
  419. IWL_SCAN_TYPE_UNASSOC,
  420. IWL_SCAN_TYPE_WILD,
  421. IWL_SCAN_TYPE_MILD,
  422. IWL_SCAN_TYPE_FRAGMENTED,
  423. };
  424. enum iwl_mvm_sched_scan_pass_all_states {
  425. SCHED_SCAN_PASS_ALL_DISABLED,
  426. SCHED_SCAN_PASS_ALL_ENABLED,
  427. SCHED_SCAN_PASS_ALL_FOUND,
  428. };
  429. /**
  430. * struct iwl_nvm_section - describes an NVM section in memory.
  431. *
  432. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  433. * and saved for later use by the driver. Not all NVM sections are saved
  434. * this way, only the needed ones.
  435. */
  436. struct iwl_nvm_section {
  437. u16 length;
  438. const u8 *data;
  439. };
  440. /**
  441. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  442. * @ct_kill_exit: worker to exit thermal kill
  443. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  444. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  445. * @min_backoff: The minimal tx backoff due to power restrictions
  446. * @params: Parameters to configure the thermal throttling algorithm.
  447. * @throttle: Is thermal throttling is active?
  448. */
  449. struct iwl_mvm_tt_mgmt {
  450. struct delayed_work ct_kill_exit;
  451. bool dynamic_smps;
  452. u32 tx_backoff;
  453. u32 min_backoff;
  454. struct iwl_tt_params params;
  455. bool throttle;
  456. };
  457. #ifdef CONFIG_THERMAL
  458. /**
  459. *struct iwl_mvm_thermal_device - thermal zone related data
  460. * @temp_trips: temperature thresholds for report
  461. * @fw_trips_index: keep indexes to original array - temp_trips
  462. * @tzone: thermal zone device data
  463. */
  464. struct iwl_mvm_thermal_device {
  465. s16 temp_trips[IWL_MAX_DTS_TRIPS];
  466. u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
  467. struct thermal_zone_device *tzone;
  468. };
  469. /*
  470. * struct iwl_mvm_cooling_device
  471. * @cur_state: current state
  472. * @cdev: struct thermal cooling device
  473. */
  474. struct iwl_mvm_cooling_device {
  475. u32 cur_state;
  476. struct thermal_cooling_device *cdev;
  477. };
  478. #endif
  479. #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
  480. struct iwl_mvm_frame_stats {
  481. u32 legacy_frames;
  482. u32 ht_frames;
  483. u32 vht_frames;
  484. u32 bw_20_frames;
  485. u32 bw_40_frames;
  486. u32 bw_80_frames;
  487. u32 bw_160_frames;
  488. u32 sgi_frames;
  489. u32 ngi_frames;
  490. u32 siso_frames;
  491. u32 mimo2_frames;
  492. u32 agg_frames;
  493. u32 ampdu_count;
  494. u32 success_frames;
  495. u32 fail_frames;
  496. u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
  497. int last_frame_idx;
  498. };
  499. enum {
  500. D0I3_DEFER_WAKEUP,
  501. D0I3_PENDING_WAKEUP,
  502. };
  503. #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
  504. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
  505. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
  506. enum iwl_mvm_tdls_cs_state {
  507. IWL_MVM_TDLS_SW_IDLE = 0,
  508. IWL_MVM_TDLS_SW_REQ_SENT,
  509. IWL_MVM_TDLS_SW_RESP_RCVD,
  510. IWL_MVM_TDLS_SW_REQ_RCVD,
  511. IWL_MVM_TDLS_SW_ACTIVE,
  512. };
  513. /**
  514. * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer
  515. * @head_sn: reorder window head sn
  516. * @num_stored: number of mpdus stored in the buffer
  517. * @buf_size: the reorder buffer size as set by the last addba request
  518. * @queue: queue of this reorder buffer
  519. * @last_amsdu: track last ASMDU SN for duplication detection
  520. * @last_sub_index: track ASMDU sub frame index for duplication detection
  521. * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU
  522. * it is the time of last received sub-frame
  523. * @removed: prevent timer re-arming
  524. * @valid: reordering is valid for this queue
  525. * @lock: protect reorder buffer internal state
  526. * @mvm: mvm pointer, needed for frame timer context
  527. */
  528. struct iwl_mvm_reorder_buffer {
  529. u16 head_sn;
  530. u16 num_stored;
  531. u8 buf_size;
  532. int queue;
  533. u16 last_amsdu;
  534. u8 last_sub_index;
  535. struct timer_list reorder_timer;
  536. bool removed;
  537. bool valid;
  538. spinlock_t lock;
  539. struct iwl_mvm *mvm;
  540. } ____cacheline_aligned_in_smp;
  541. /**
  542. * struct _iwl_mvm_reorder_buf_entry - reorder buffer entry per-queue/per-seqno
  543. * @frames: list of skbs stored
  544. * @reorder_time: time the packet was stored in the reorder buffer
  545. */
  546. struct _iwl_mvm_reorder_buf_entry {
  547. struct sk_buff_head frames;
  548. unsigned long reorder_time;
  549. };
  550. /* make this indirection to get the aligned thing */
  551. struct iwl_mvm_reorder_buf_entry {
  552. struct _iwl_mvm_reorder_buf_entry e;
  553. }
  554. #ifndef __CHECKER__
  555. /* sparse doesn't like this construct: "bad integer constant expression" */
  556. __aligned(roundup_pow_of_two(sizeof(struct _iwl_mvm_reorder_buf_entry)))
  557. #endif
  558. ;
  559. /**
  560. * struct iwl_mvm_baid_data - BA session data
  561. * @sta_id: station id
  562. * @tid: tid of the session
  563. * @baid baid of the session
  564. * @timeout: the timeout set in the addba request
  565. * @entries_per_queue: # of buffers per queue, this actually gets
  566. * aligned up to avoid cache line sharing between queues
  567. * @last_rx: last rx jiffies, updated only if timeout passed from last update
  568. * @session_timer: timer to check if BA session expired, runs at 2 * timeout
  569. * @mvm: mvm pointer, needed for timer context
  570. * @reorder_buf: reorder buffer, allocated per queue
  571. * @reorder_buf_data: data
  572. */
  573. struct iwl_mvm_baid_data {
  574. struct rcu_head rcu_head;
  575. u8 sta_id;
  576. u8 tid;
  577. u8 baid;
  578. u16 timeout;
  579. u16 entries_per_queue;
  580. unsigned long last_rx;
  581. struct timer_list session_timer;
  582. struct iwl_mvm_baid_data __rcu **rcu_ptr;
  583. struct iwl_mvm *mvm;
  584. struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES];
  585. struct iwl_mvm_reorder_buf_entry entries[];
  586. };
  587. static inline struct iwl_mvm_baid_data *
  588. iwl_mvm_baid_data_from_reorder_buf(struct iwl_mvm_reorder_buffer *buf)
  589. {
  590. return (void *)((u8 *)buf -
  591. offsetof(struct iwl_mvm_baid_data, reorder_buf) -
  592. sizeof(*buf) * buf->queue);
  593. }
  594. /*
  595. * enum iwl_mvm_queue_status - queue status
  596. * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved
  597. * Basically, this means that this queue can be used for any purpose
  598. * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use
  599. * This is the state of a queue that has been dedicated for some RATID
  600. * (agg'd or not), but that hasn't yet gone through the actual enablement
  601. * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet.
  602. * Note that in this state there is no requirement to already know what TID
  603. * should be used with this queue, it is just marked as a queue that will
  604. * be used, and shouldn't be allocated to anyone else.
  605. * @IWL_MVM_QUEUE_READY: queue is ready to be used
  606. * This is the state of a queue that has been fully configured (including
  607. * SCD pointers, etc), has a specific RA/TID assigned to it, and can be
  608. * used to send traffic.
  609. * @IWL_MVM_QUEUE_SHARED: queue is shared, or in a process of becoming shared
  610. * This is a state in which a single queue serves more than one TID, all of
  611. * which are not aggregated. Note that the queue is only associated to one
  612. * RA.
  613. * @IWL_MVM_QUEUE_INACTIVE: queue is allocated but no traffic on it
  614. * This is a state of a queue that has had traffic on it, but during the
  615. * last %IWL_MVM_DQA_QUEUE_TIMEOUT time period there has been no traffic on
  616. * it. In this state, when a new queue is needed to be allocated but no
  617. * such free queue exists, an inactive queue might be freed and given to
  618. * the new RA/TID.
  619. * @IWL_MVM_QUEUE_RECONFIGURING: queue is being reconfigured
  620. * This is the state of a queue that has had traffic pass through it, but
  621. * needs to be reconfigured for some reason, e.g. the queue needs to
  622. * become unshared and aggregations re-enabled on.
  623. */
  624. enum iwl_mvm_queue_status {
  625. IWL_MVM_QUEUE_FREE,
  626. IWL_MVM_QUEUE_RESERVED,
  627. IWL_MVM_QUEUE_READY,
  628. IWL_MVM_QUEUE_SHARED,
  629. IWL_MVM_QUEUE_INACTIVE,
  630. IWL_MVM_QUEUE_RECONFIGURING,
  631. };
  632. #define IWL_MVM_DQA_QUEUE_TIMEOUT (5 * HZ)
  633. #define IWL_MVM_INVALID_QUEUE 0xFFFF
  634. #define IWL_MVM_NUM_CIPHERS 10
  635. struct iwl_mvm_sar_profile {
  636. bool enabled;
  637. u8 table[ACPI_SAR_TABLE_SIZE];
  638. };
  639. struct iwl_mvm_geo_profile {
  640. u8 values[ACPI_GEO_TABLE_SIZE];
  641. };
  642. struct iwl_mvm {
  643. /* for logger access */
  644. struct device *dev;
  645. struct iwl_trans *trans;
  646. const struct iwl_fw *fw;
  647. const struct iwl_cfg *cfg;
  648. struct iwl_phy_db *phy_db;
  649. struct ieee80211_hw *hw;
  650. /* for protecting access to iwl_mvm */
  651. struct mutex mutex;
  652. struct list_head async_handlers_list;
  653. spinlock_t async_handlers_lock;
  654. struct work_struct async_handlers_wk;
  655. struct work_struct roc_done_wk;
  656. unsigned long init_status;
  657. unsigned long status;
  658. u32 queue_sync_cookie;
  659. atomic_t queue_sync_counter;
  660. /*
  661. * for beacon filtering -
  662. * currently only one interface can be supported
  663. */
  664. struct iwl_mvm_vif *bf_allowed_vif;
  665. bool hw_registered;
  666. bool calibrating;
  667. u32 error_event_table[2];
  668. u32 log_event_table;
  669. u32 umac_error_event_table;
  670. bool support_umac_log;
  671. u32 ampdu_ref;
  672. bool ampdu_toggle;
  673. struct iwl_notif_wait_data notif_wait;
  674. union {
  675. struct mvm_statistics_rx_v3 rx_stats_v3;
  676. struct mvm_statistics_rx rx_stats;
  677. };
  678. struct {
  679. u64 rx_time;
  680. u64 tx_time;
  681. u64 on_time_rf;
  682. u64 on_time_scan;
  683. } radio_stats, accu_radio_stats;
  684. u16 hw_queue_to_mac80211[IWL_MAX_TVQM_QUEUES];
  685. struct {
  686. u8 hw_queue_refcount;
  687. u8 ra_sta_id; /* The RA this queue is mapped to, if exists */
  688. bool reserved; /* Is this the TXQ reserved for a STA */
  689. u8 mac80211_ac; /* The mac80211 AC this queue is mapped to */
  690. u8 txq_tid; /* The TID "owner" of this queue*/
  691. u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */
  692. /* Timestamp for inactivation per TID of this queue */
  693. unsigned long last_frame_time[IWL_MAX_TID_COUNT + 1];
  694. enum iwl_mvm_queue_status status;
  695. } queue_info[IWL_MAX_HW_QUEUES];
  696. spinlock_t queue_info_lock; /* For syncing queue mgmt operations */
  697. struct work_struct add_stream_wk; /* To add streams to queues */
  698. atomic_t mac80211_queue_stop_count[IEEE80211_MAX_QUEUES];
  699. const char *nvm_file_name;
  700. struct iwl_nvm_data *nvm_data;
  701. /* NVM sections */
  702. struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
  703. struct iwl_fw_runtime fwrt;
  704. /* EEPROM MAC addresses */
  705. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  706. /* data related to data path */
  707. struct iwl_rx_phy_info last_phy_info;
  708. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  709. unsigned long sta_deferred_frames[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  710. u8 rx_ba_sessions;
  711. /* configured by mac80211 */
  712. u32 rts_threshold;
  713. /* Scan status, cmd (pre-allocated) and auxiliary station */
  714. unsigned int scan_status;
  715. void *scan_cmd;
  716. struct iwl_mcast_filter_cmd *mcast_filter_cmd;
  717. enum iwl_mvm_scan_type scan_type;
  718. enum iwl_mvm_sched_scan_pass_all_states sched_scan_pass_all;
  719. struct delayed_work scan_timeout_dwork;
  720. /* max number of simultaneous scans the FW supports */
  721. unsigned int max_scans;
  722. /* UMAC scan tracking */
  723. u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS];
  724. /* start time of last scan in TSF of the mac that requested the scan */
  725. u64 scan_start;
  726. /* the vif that requested the current scan */
  727. struct iwl_mvm_vif *scan_vif;
  728. /* rx chain antennas set through debugfs for the scan command */
  729. u8 scan_rx_ant;
  730. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  731. /* broadcast filters to configure for each associated station */
  732. const struct iwl_fw_bcast_filter *bcast_filters;
  733. #ifdef CONFIG_IWLWIFI_DEBUGFS
  734. struct {
  735. bool override;
  736. struct iwl_bcast_filter_cmd cmd;
  737. } dbgfs_bcast_filtering;
  738. #endif
  739. #endif
  740. /* Internal station */
  741. struct iwl_mvm_int_sta aux_sta;
  742. struct iwl_mvm_int_sta snif_sta;
  743. bool last_ebs_successful;
  744. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  745. u8 mgmt_last_antenna_idx;
  746. /* last smart fifo state that was successfully sent to firmware */
  747. enum iwl_sf_state sf_state;
  748. #ifdef CONFIG_IWLWIFI_DEBUGFS
  749. struct dentry *debugfs_dir;
  750. u32 dbgfs_sram_offset, dbgfs_sram_len;
  751. u32 dbgfs_prph_reg_addr;
  752. bool disable_power_off;
  753. bool disable_power_off_d3;
  754. bool scan_iter_notif_enabled;
  755. struct debugfs_blob_wrapper nvm_hw_blob;
  756. struct debugfs_blob_wrapper nvm_sw_blob;
  757. struct debugfs_blob_wrapper nvm_calib_blob;
  758. struct debugfs_blob_wrapper nvm_prod_blob;
  759. struct debugfs_blob_wrapper nvm_phy_sku_blob;
  760. struct iwl_mvm_frame_stats drv_rx_stats;
  761. spinlock_t drv_stats_lock;
  762. u16 dbgfs_rx_phyinfo;
  763. #endif
  764. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  765. struct list_head time_event_list;
  766. spinlock_t time_event_lock;
  767. /*
  768. * A bitmap indicating the index of the key in use. The firmware
  769. * can hold 16 keys at most. Reflect this fact.
  770. */
  771. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  772. u8 fw_key_deleted[STA_KEY_MAX_NUM];
  773. /* references taken by the driver and spinlock protecting them */
  774. spinlock_t refs_lock;
  775. u8 refs[IWL_MVM_REF_COUNT];
  776. u8 vif_count;
  777. /* -1 for always, 0 for never, >0 for that many times */
  778. s8 fw_restart;
  779. #ifdef CONFIG_IWLWIFI_LEDS
  780. struct led_classdev led;
  781. #endif
  782. struct ieee80211_vif *p2p_device_vif;
  783. #ifdef CONFIG_PM
  784. struct wiphy_wowlan_support wowlan;
  785. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  786. /* sched scan settings for net detect */
  787. struct ieee80211_scan_ies nd_ies;
  788. struct cfg80211_match_set *nd_match_sets;
  789. int n_nd_match_sets;
  790. struct ieee80211_channel **nd_channels;
  791. int n_nd_channels;
  792. bool net_detect;
  793. #ifdef CONFIG_IWLWIFI_DEBUGFS
  794. bool d3_wake_sysassert;
  795. bool d3_test_active;
  796. bool store_d3_resume_sram;
  797. void *d3_resume_sram;
  798. u32 d3_test_pme_ptr;
  799. struct ieee80211_vif *keep_vif;
  800. u32 last_netdetect_scans; /* no. of scans in the last net-detect wake */
  801. #endif
  802. #endif
  803. /* d0i3 */
  804. u8 d0i3_ap_sta_id;
  805. bool d0i3_offloading;
  806. struct work_struct d0i3_exit_work;
  807. struct sk_buff_head d0i3_tx;
  808. /* protect d0i3_suspend_flags */
  809. struct mutex d0i3_suspend_mutex;
  810. unsigned long d0i3_suspend_flags;
  811. /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
  812. spinlock_t d0i3_tx_lock;
  813. wait_queue_head_t d0i3_exit_waitq;
  814. wait_queue_head_t rx_sync_waitq;
  815. /* BT-Coex */
  816. struct iwl_bt_coex_profile_notif last_bt_notif;
  817. struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
  818. u8 bt_tx_prio;
  819. enum iwl_bt_force_ant_mode bt_force_ant_mode;
  820. /* Aux ROC */
  821. struct list_head aux_roc_te_list;
  822. /* Thermal Throttling and CTkill */
  823. struct iwl_mvm_tt_mgmt thermal_throttle;
  824. #ifdef CONFIG_THERMAL
  825. struct iwl_mvm_thermal_device tz_device;
  826. struct iwl_mvm_cooling_device cooling_dev;
  827. #endif
  828. s32 temperature; /* Celsius */
  829. /*
  830. * Debug option to set the NIC temperature. This option makes the
  831. * driver think this is the actual NIC temperature, and ignore the
  832. * real temperature that is received from the fw
  833. */
  834. bool temperature_test; /* Debug test temperature is enabled */
  835. struct iwl_time_quota_cmd last_quota_cmd;
  836. #ifdef CONFIG_NL80211_TESTMODE
  837. u32 noa_duration;
  838. struct ieee80211_vif *noa_vif;
  839. #endif
  840. /* Tx queues */
  841. u16 aux_queue;
  842. u16 probe_queue;
  843. u16 p2p_dev_queue;
  844. /* Indicate if device power save is allowed */
  845. u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
  846. unsigned int max_amsdu_len; /* used for debugfs only */
  847. struct ieee80211_vif __rcu *csa_vif;
  848. struct ieee80211_vif __rcu *csa_tx_blocked_vif;
  849. u8 csa_tx_block_bcn_timeout;
  850. /* system time of last beacon (for AP/GO interface) */
  851. u32 ap_last_beacon_gp2;
  852. /* indicates that we transmitted the last beacon */
  853. bool ibss_manager;
  854. bool lar_regdom_set;
  855. enum iwl_mcc_source mcc_src;
  856. /* TDLS channel switch data */
  857. struct {
  858. struct delayed_work dwork;
  859. enum iwl_mvm_tdls_cs_state state;
  860. /*
  861. * Current cs sta - might be different from periodic cs peer
  862. * station. Value is meaningless when the cs-state is idle.
  863. */
  864. u8 cur_sta_id;
  865. /* TDLS periodic channel-switch peer */
  866. struct {
  867. u8 sta_id;
  868. u8 op_class;
  869. bool initiator; /* are we the link initiator */
  870. struct cfg80211_chan_def chandef;
  871. struct sk_buff *skb; /* ch sw template */
  872. u32 ch_sw_tm_ie;
  873. /* timestamp of last ch-sw request sent (GP2 time) */
  874. u32 sent_timestamp;
  875. } peer;
  876. } tdls_cs;
  877. u32 ciphers[IWL_MVM_NUM_CIPHERS];
  878. struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS];
  879. struct iwl_mvm_tof_data tof_data;
  880. struct ieee80211_vif *nan_vif;
  881. #define IWL_MAX_BAID 32
  882. struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID];
  883. /*
  884. * Drop beacons from other APs in AP mode when there are no connected
  885. * clients.
  886. */
  887. bool drop_bcn_ap_mode;
  888. struct delayed_work cs_tx_unblock_dwork;
  889. /* does a monitor vif exist (only one can exist hence bool) */
  890. bool monitor_on;
  891. #ifdef CONFIG_ACPI
  892. struct iwl_mvm_sar_profile sar_profiles[ACPI_SAR_PROFILE_NUM];
  893. struct iwl_mvm_geo_profile geo_profiles[ACPI_NUM_GEO_PROFILES];
  894. #endif
  895. };
  896. /* Extract MVM priv from op_mode and _hw */
  897. #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
  898. ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
  899. #define IWL_MAC80211_GET_MVM(_hw) \
  900. IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
  901. /**
  902. * enum iwl_mvm_status - MVM status bits
  903. * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
  904. * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active
  905. * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running
  906. * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested
  907. * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
  908. * @IWL_MVM_STATUS_IN_D0I3: NIC is in D0i3
  909. * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
  910. * @IWL_MVM_STATUS_D3_RECONFIG: D3 reconfiguration is being done
  911. * @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running
  912. */
  913. enum iwl_mvm_status {
  914. IWL_MVM_STATUS_HW_RFKILL,
  915. IWL_MVM_STATUS_HW_CTKILL,
  916. IWL_MVM_STATUS_ROC_RUNNING,
  917. IWL_MVM_STATUS_HW_RESTART_REQUESTED,
  918. IWL_MVM_STATUS_IN_HW_RESTART,
  919. IWL_MVM_STATUS_IN_D0I3,
  920. IWL_MVM_STATUS_ROC_AUX_RUNNING,
  921. IWL_MVM_STATUS_D3_RECONFIG,
  922. IWL_MVM_STATUS_FIRMWARE_RUNNING,
  923. };
  924. /* Keep track of completed init configuration */
  925. enum iwl_mvm_init_status {
  926. IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0),
  927. IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1),
  928. IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE = BIT(2),
  929. IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE = BIT(3),
  930. };
  931. static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
  932. {
  933. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
  934. test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
  935. }
  936. static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm)
  937. {
  938. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
  939. }
  940. static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm)
  941. {
  942. return test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
  943. }
  944. /* Must be called with rcu_read_lock() held and it can only be
  945. * released when mvmsta is not needed anymore.
  946. */
  947. static inline struct iwl_mvm_sta *
  948. iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
  949. {
  950. struct ieee80211_sta *sta;
  951. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  952. return NULL;
  953. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  954. /* This can happen if the station has been removed right now */
  955. if (IS_ERR_OR_NULL(sta))
  956. return NULL;
  957. return iwl_mvm_sta_from_mac80211(sta);
  958. }
  959. static inline struct iwl_mvm_sta *
  960. iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
  961. {
  962. struct ieee80211_sta *sta;
  963. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  964. return NULL;
  965. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
  966. lockdep_is_held(&mvm->mutex));
  967. /* This can happen if the station has been removed right now */
  968. if (IS_ERR_OR_NULL(sta))
  969. return NULL;
  970. return iwl_mvm_sta_from_mac80211(sta);
  971. }
  972. static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
  973. {
  974. return !iwlwifi_mod_params.d0i3_disable &&
  975. fw_has_capa(&mvm->fw->ucode_capa,
  976. IWL_UCODE_TLV_CAPA_D0I3_SUPPORT);
  977. }
  978. static inline bool iwl_mvm_is_adaptive_dwell_supported(struct iwl_mvm *mvm)
  979. {
  980. return fw_has_api(&mvm->fw->ucode_capa,
  981. IWL_UCODE_TLV_API_ADAPTIVE_DWELL);
  982. }
  983. static inline bool iwl_mvm_enter_d0i3_on_suspend(struct iwl_mvm *mvm)
  984. {
  985. /* For now we only use this mode to differentiate between
  986. * slave transports, which handle D0i3 entry in suspend by
  987. * themselves in conjunction with runtime PM D0i3. So, this
  988. * function is used to check whether we need to do anything
  989. * when entering suspend or if the transport layer has already
  990. * done it.
  991. */
  992. return (mvm->trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3) &&
  993. (mvm->trans->runtime_pm_mode != IWL_PLAT_PM_MODE_D0I3);
  994. }
  995. static inline bool iwl_mvm_is_dqa_data_queue(struct iwl_mvm *mvm, u8 queue)
  996. {
  997. return (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE) &&
  998. (queue <= IWL_MVM_DQA_MAX_DATA_QUEUE);
  999. }
  1000. static inline bool iwl_mvm_is_dqa_mgmt_queue(struct iwl_mvm *mvm, u8 queue)
  1001. {
  1002. return (queue >= IWL_MVM_DQA_MIN_MGMT_QUEUE) &&
  1003. (queue <= IWL_MVM_DQA_MAX_MGMT_QUEUE);
  1004. }
  1005. static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm)
  1006. {
  1007. bool nvm_lar = mvm->nvm_data->lar_enabled;
  1008. bool tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
  1009. IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
  1010. if (iwlwifi_mod_params.lar_disable)
  1011. return false;
  1012. /*
  1013. * Enable LAR only if it is supported by the FW (TLV) &&
  1014. * enabled in the NVM
  1015. */
  1016. if (mvm->cfg->nvm_type == IWL_NVM_EXT)
  1017. return nvm_lar && tlv_lar;
  1018. else
  1019. return tlv_lar;
  1020. }
  1021. static inline bool iwl_mvm_is_wifi_mcc_supported(struct iwl_mvm *mvm)
  1022. {
  1023. return fw_has_api(&mvm->fw->ucode_capa,
  1024. IWL_UCODE_TLV_API_WIFI_MCC_UPDATE) ||
  1025. fw_has_capa(&mvm->fw->ucode_capa,
  1026. IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC);
  1027. }
  1028. static inline bool iwl_mvm_bt_is_rrc_supported(struct iwl_mvm *mvm)
  1029. {
  1030. return fw_has_capa(&mvm->fw->ucode_capa,
  1031. IWL_UCODE_TLV_CAPA_BT_COEX_RRC) &&
  1032. IWL_MVM_BT_COEX_RRC;
  1033. }
  1034. static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm)
  1035. {
  1036. return fw_has_capa(&mvm->fw->ucode_capa,
  1037. IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) &&
  1038. !IWL_MVM_HW_CSUM_DISABLE;
  1039. }
  1040. static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm)
  1041. {
  1042. return fw_has_capa(&mvm->fw->ucode_capa,
  1043. IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT) &&
  1044. IWL_MVM_BT_COEX_MPLUT;
  1045. }
  1046. static inline
  1047. bool iwl_mvm_is_p2p_scm_uapsd_supported(struct iwl_mvm *mvm)
  1048. {
  1049. return fw_has_capa(&mvm->fw->ucode_capa,
  1050. IWL_UCODE_TLV_CAPA_P2P_SCM_UAPSD) &&
  1051. !(iwlwifi_mod_params.uapsd_disable &
  1052. IWL_DISABLE_UAPSD_P2P_CLIENT);
  1053. }
  1054. static inline bool iwl_mvm_has_new_rx_api(struct iwl_mvm *mvm)
  1055. {
  1056. return fw_has_capa(&mvm->fw->ucode_capa,
  1057. IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT);
  1058. }
  1059. static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm)
  1060. {
  1061. /* TODO - replace with TLV once defined */
  1062. return mvm->trans->cfg->use_tfh;
  1063. }
  1064. static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm)
  1065. {
  1066. /* TODO - better define this */
  1067. return mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_A000;
  1068. }
  1069. static inline bool iwl_mvm_is_cdb_supported(struct iwl_mvm *mvm)
  1070. {
  1071. /*
  1072. * TODO:
  1073. * The issue of how to determine CDB APIs and usage is still not fully
  1074. * defined.
  1075. * There is a compilation for CDB and non-CDB FW, but there may
  1076. * be also runtime check.
  1077. * For now there is a TLV for checking compilation mode, but a
  1078. * runtime check will also have to be here - once defined.
  1079. */
  1080. return fw_has_capa(&mvm->fw->ucode_capa,
  1081. IWL_UCODE_TLV_CAPA_CDB_SUPPORT);
  1082. }
  1083. static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)
  1084. {
  1085. return fw_has_api(&mvm->fw->ucode_capa,
  1086. IWL_UCODE_TLV_API_NEW_RX_STATS);
  1087. }
  1088. static inline bool iwl_mvm_has_new_ats_coex_api(struct iwl_mvm *mvm)
  1089. {
  1090. return fw_has_api(&mvm->fw->ucode_capa,
  1091. IWL_UCODE_TLV_API_COEX_ATS_EXTERNAL);
  1092. }
  1093. static inline bool iwl_mvm_has_quota_low_latency(struct iwl_mvm *mvm)
  1094. {
  1095. return fw_has_api(&mvm->fw->ucode_capa,
  1096. IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY);
  1097. }
  1098. static inline struct agg_tx_status *
  1099. iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp)
  1100. {
  1101. if (iwl_mvm_has_new_tx_api(mvm))
  1102. return &((struct iwl_mvm_tx_resp *)tx_resp)->status;
  1103. else
  1104. return ((struct iwl_mvm_tx_resp_v3 *)tx_resp)->status;
  1105. }
  1106. static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)
  1107. {
  1108. #ifdef CONFIG_THERMAL
  1109. /* these two TLV are redundant since the responsibility to CT-kill by
  1110. * FW happens only after we send at least one command of
  1111. * temperature THs report.
  1112. */
  1113. return fw_has_capa(&mvm->fw->ucode_capa,
  1114. IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) &&
  1115. fw_has_capa(&mvm->fw->ucode_capa,
  1116. IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT);
  1117. #else /* CONFIG_THERMAL */
  1118. return false;
  1119. #endif /* CONFIG_THERMAL */
  1120. }
  1121. static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm)
  1122. {
  1123. return fw_has_capa(&mvm->fw->ucode_capa,
  1124. IWL_UCODE_TLV_CAPA_CTDP_SUPPORT);
  1125. }
  1126. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  1127. extern const u8 iwl_mvm_ac_to_gen2_tx_fifo[];
  1128. static inline u8 iwl_mvm_mac_ac_to_tx_fifo(struct iwl_mvm *mvm,
  1129. enum ieee80211_ac_numbers ac)
  1130. {
  1131. return iwl_mvm_has_new_tx_api(mvm) ?
  1132. iwl_mvm_ac_to_gen2_tx_fifo[ac] : iwl_mvm_ac_to_tx_fifo[ac];
  1133. }
  1134. struct iwl_rate_info {
  1135. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  1136. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  1137. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  1138. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  1139. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  1140. };
  1141. void __iwl_mvm_mac_stop(struct iwl_mvm *mvm);
  1142. int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
  1143. /******************
  1144. * MVM Methods
  1145. ******************/
  1146. /* uCode */
  1147. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  1148. /* Utils */
  1149. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  1150. enum nl80211_band band);
  1151. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  1152. enum nl80211_band band,
  1153. struct ieee80211_tx_rate *r);
  1154. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  1155. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  1156. u8 first_antenna(u8 mask);
  1157. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  1158. void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime);
  1159. /* Tx / Host Commands */
  1160. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  1161. struct iwl_host_cmd *cmd);
  1162. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id,
  1163. u32 flags, u16 len, const void *data);
  1164. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  1165. struct iwl_host_cmd *cmd,
  1166. u32 *status);
  1167. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id,
  1168. u16 len, const void *data,
  1169. u32 *status);
  1170. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  1171. struct ieee80211_sta *sta);
  1172. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  1173. void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
  1174. struct iwl_tx_cmd *tx_cmd,
  1175. struct ieee80211_tx_info *info, u8 sta_id);
  1176. void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
  1177. struct ieee80211_tx_info *info,
  1178. struct ieee80211_sta *sta, __le16 fc);
  1179. #ifdef CONFIG_IWLWIFI_DEBUG
  1180. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  1181. #else
  1182. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  1183. #endif
  1184. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, u32 flags);
  1185. int iwl_mvm_flush_sta(struct iwl_mvm *mvm, void *sta, bool internal, u32 flags);
  1186. int iwl_mvm_flush_sta_tids(struct iwl_mvm *mvm, u32 sta_id,
  1187. u16 tids, u32 flags);
  1188. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  1189. static inline void iwl_mvm_set_tx_cmd_ccmp(struct ieee80211_tx_info *info,
  1190. struct iwl_tx_cmd *tx_cmd)
  1191. {
  1192. struct ieee80211_key_conf *keyconf = info->control.hw_key;
  1193. tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
  1194. memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
  1195. }
  1196. static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
  1197. {
  1198. flush_work(&mvm->async_handlers_wk);
  1199. }
  1200. /* Statistics */
  1201. void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
  1202. struct iwl_rx_packet *pkt);
  1203. void iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  1204. struct iwl_rx_cmd_buffer *rxb);
  1205. int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear);
  1206. void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm);
  1207. /* NVM */
  1208. int iwl_nvm_init(struct iwl_mvm *mvm);
  1209. int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
  1210. int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm);
  1211. static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm)
  1212. {
  1213. return mvm->nvm_data && mvm->nvm_data->valid_tx_ant ?
  1214. mvm->fw->valid_tx_ant & mvm->nvm_data->valid_tx_ant :
  1215. mvm->fw->valid_tx_ant;
  1216. }
  1217. static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
  1218. {
  1219. return mvm->nvm_data && mvm->nvm_data->valid_rx_ant ?
  1220. mvm->fw->valid_rx_ant & mvm->nvm_data->valid_rx_ant :
  1221. mvm->fw->valid_rx_ant;
  1222. }
  1223. static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
  1224. {
  1225. u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
  1226. FW_PHY_CFG_RX_CHAIN);
  1227. u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
  1228. u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
  1229. phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS |
  1230. valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS;
  1231. return mvm->fw->phy_config & phy_config;
  1232. }
  1233. int iwl_mvm_up(struct iwl_mvm *mvm);
  1234. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  1235. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  1236. bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
  1237. struct iwl_bcast_filter_cmd *cmd);
  1238. /*
  1239. * FW notifications / CMD responses handlers
  1240. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  1241. */
  1242. void iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1243. void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
  1244. struct iwl_rx_cmd_buffer *rxb);
  1245. void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
  1246. struct iwl_rx_cmd_buffer *rxb, int queue);
  1247. void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi,
  1248. struct iwl_rx_cmd_buffer *rxb, int queue);
  1249. int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask,
  1250. const u8 *data, u32 count);
  1251. void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  1252. int queue);
  1253. void iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1254. void iwl_mvm_mfu_assert_dump_notif(struct iwl_mvm *mvm,
  1255. struct iwl_rx_cmd_buffer *rxb);
  1256. void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1257. void iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
  1258. struct iwl_rx_cmd_buffer *rxb);
  1259. void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1260. void iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  1261. struct iwl_rx_cmd_buffer *rxb);
  1262. void iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
  1263. struct iwl_rx_cmd_buffer *rxb);
  1264. void iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
  1265. struct iwl_rx_cmd_buffer *rxb);
  1266. /* MVM PHY */
  1267. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  1268. struct cfg80211_chan_def *chandef,
  1269. u8 chains_static, u8 chains_dynamic);
  1270. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  1271. struct cfg80211_chan_def *chandef,
  1272. u8 chains_static, u8 chains_dynamic);
  1273. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  1274. struct iwl_mvm_phy_ctxt *ctxt);
  1275. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  1276. struct iwl_mvm_phy_ctxt *ctxt);
  1277. int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
  1278. u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef);
  1279. u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef);
  1280. /* MAC (virtual interface) programming */
  1281. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1282. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1283. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1284. bool force_assoc_off, const u8 *bssid_override);
  1285. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1286. u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif);
  1287. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  1288. struct ieee80211_vif *vif);
  1289. void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  1290. struct iwl_rx_cmd_buffer *rxb);
  1291. void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  1292. struct iwl_rx_cmd_buffer *rxb);
  1293. void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
  1294. struct iwl_rx_cmd_buffer *rxb);
  1295. void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm,
  1296. struct iwl_rx_cmd_buffer *rxb);
  1297. void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1298. void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,
  1299. struct iwl_rx_cmd_buffer *rxb);
  1300. void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
  1301. struct ieee80211_vif *vif);
  1302. unsigned long iwl_mvm_get_used_hw_queues(struct iwl_mvm *mvm,
  1303. struct ieee80211_vif *exclude_vif);
  1304. void iwl_mvm_channel_switch_noa_notif(struct iwl_mvm *mvm,
  1305. struct iwl_rx_cmd_buffer *rxb);
  1306. /* Bindings */
  1307. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1308. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1309. /* Quota management */
  1310. static inline size_t iwl_mvm_quota_cmd_size(struct iwl_mvm *mvm)
  1311. {
  1312. return iwl_mvm_has_quota_low_latency(mvm) ?
  1313. sizeof(struct iwl_time_quota_cmd) :
  1314. sizeof(struct iwl_time_quota_cmd_v1);
  1315. }
  1316. static inline struct iwl_time_quota_data
  1317. *iwl_mvm_quota_cmd_get_quota(struct iwl_mvm *mvm,
  1318. struct iwl_time_quota_cmd *cmd,
  1319. int i)
  1320. {
  1321. struct iwl_time_quota_data_v1 *quotas;
  1322. if (iwl_mvm_has_quota_low_latency(mvm))
  1323. return &cmd->quotas[i];
  1324. quotas = (struct iwl_time_quota_data_v1 *)cmd->quotas;
  1325. return (struct iwl_time_quota_data *)&quotas[i];
  1326. }
  1327. int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
  1328. struct ieee80211_vif *disabled_vif);
  1329. /* Scanning */
  1330. int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1331. struct cfg80211_scan_request *req,
  1332. struct ieee80211_scan_ies *ies);
  1333. int iwl_mvm_scan_size(struct iwl_mvm *mvm);
  1334. int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify);
  1335. int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm);
  1336. void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm);
  1337. void iwl_mvm_scan_timeout_wk(struct work_struct *work);
  1338. /* Scheduled scan */
  1339. void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm,
  1340. struct iwl_rx_cmd_buffer *rxb);
  1341. void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm,
  1342. struct iwl_rx_cmd_buffer *rxb);
  1343. int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
  1344. struct ieee80211_vif *vif,
  1345. struct cfg80211_sched_scan_request *req,
  1346. struct ieee80211_scan_ies *ies,
  1347. int type);
  1348. void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm,
  1349. struct iwl_rx_cmd_buffer *rxb);
  1350. /* UMAC scan */
  1351. int iwl_mvm_config_scan(struct iwl_mvm *mvm);
  1352. void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
  1353. struct iwl_rx_cmd_buffer *rxb);
  1354. void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
  1355. struct iwl_rx_cmd_buffer *rxb);
  1356. /* MVM debugfs */
  1357. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1358. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  1359. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1360. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1361. #else
  1362. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  1363. struct dentry *dbgfs_dir)
  1364. {
  1365. return 0;
  1366. }
  1367. static inline void
  1368. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1369. {
  1370. }
  1371. static inline void
  1372. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1373. {
  1374. }
  1375. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1376. /* rate scaling */
  1377. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init);
  1378. void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg);
  1379. int rs_pretty_print_rate(char *buf, const u32 rate);
  1380. void rs_update_last_rssi(struct iwl_mvm *mvm,
  1381. struct iwl_lq_sta *lq_sta,
  1382. struct ieee80211_rx_status *rx_status);
  1383. /* power management */
  1384. int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
  1385. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
  1386. int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
  1387. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1388. char *buf, int bufsz);
  1389. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1390. void iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  1391. struct iwl_rx_cmd_buffer *rxb);
  1392. #ifdef CONFIG_IWLWIFI_LEDS
  1393. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  1394. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  1395. void iwl_mvm_leds_sync(struct iwl_mvm *mvm);
  1396. #else
  1397. static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
  1398. {
  1399. return 0;
  1400. }
  1401. static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
  1402. {
  1403. }
  1404. static inline void iwl_mvm_leds_sync(struct iwl_mvm *mvm)
  1405. {
  1406. }
  1407. #endif
  1408. /* D3 (WoWLAN, NetDetect) */
  1409. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  1410. int iwl_mvm_resume(struct ieee80211_hw *hw);
  1411. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  1412. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  1413. struct ieee80211_vif *vif,
  1414. struct cfg80211_gtk_rekey_data *data);
  1415. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  1416. struct ieee80211_vif *vif,
  1417. struct inet6_dev *idev);
  1418. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  1419. struct ieee80211_vif *vif, int idx);
  1420. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  1421. #ifdef CONFIG_PM
  1422. int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
  1423. struct ieee80211_vif *vif,
  1424. bool host_awake,
  1425. u32 cmd_flags);
  1426. void iwl_mvm_d0i3_update_keys(struct iwl_mvm *mvm,
  1427. struct ieee80211_vif *vif,
  1428. struct iwl_wowlan_status *status);
  1429. void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
  1430. struct ieee80211_vif *vif);
  1431. #else
  1432. static inline int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
  1433. struct ieee80211_vif *vif,
  1434. bool host_awake,
  1435. u32 cmd_flags)
  1436. {
  1437. return 0;
  1438. }
  1439. static inline void iwl_mvm_d0i3_update_keys(struct iwl_mvm *mvm,
  1440. struct ieee80211_vif *vif,
  1441. struct iwl_wowlan_status *status)
  1442. {
  1443. }
  1444. static inline void
  1445. iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1446. {
  1447. }
  1448. #endif
  1449. void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
  1450. struct iwl_wowlan_config_cmd *cmd);
  1451. int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
  1452. struct ieee80211_vif *vif,
  1453. bool disable_offloading,
  1454. bool offload_ns,
  1455. u32 cmd_flags);
  1456. /* D0i3 */
  1457. void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1458. void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1459. int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1460. bool iwl_mvm_ref_taken(struct iwl_mvm *mvm);
  1461. void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
  1462. int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode);
  1463. int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode);
  1464. int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
  1465. /* BT Coex */
  1466. int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm);
  1467. void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  1468. struct iwl_rx_cmd_buffer *rxb);
  1469. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1470. enum ieee80211_rssi_event_data);
  1471. void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
  1472. u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
  1473. struct ieee80211_sta *sta);
  1474. bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
  1475. struct ieee80211_sta *sta);
  1476. bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
  1477. bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
  1478. bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
  1479. enum nl80211_band band);
  1480. u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  1481. struct ieee80211_tx_info *info, u8 ac);
  1482. /* beacon filtering */
  1483. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1484. void
  1485. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1486. struct iwl_beacon_filter_cmd *cmd);
  1487. #else
  1488. static inline void
  1489. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1490. struct iwl_beacon_filter_cmd *cmd)
  1491. {}
  1492. #endif
  1493. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  1494. struct ieee80211_vif *vif,
  1495. bool enable, u32 flags);
  1496. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  1497. struct ieee80211_vif *vif,
  1498. u32 flags);
  1499. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  1500. struct ieee80211_vif *vif,
  1501. u32 flags);
  1502. /* SMPS */
  1503. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1504. enum iwl_mvm_smps_type_request req_type,
  1505. enum ieee80211_smps_mode smps_request);
  1506. bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm);
  1507. /* Low latency */
  1508. int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1509. bool value);
  1510. /* get SystemLowLatencyMode - only needed for beacon threshold? */
  1511. bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
  1512. /* get VMACLowLatencyMode */
  1513. static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
  1514. {
  1515. /*
  1516. * should this consider associated/active/... state?
  1517. *
  1518. * Normally low-latency should only be active on interfaces
  1519. * that are active, but at least with debugfs it can also be
  1520. * enabled on interfaces that aren't active. However, when
  1521. * interface aren't active then they aren't added into the
  1522. * binding, so this has no real impact. For now, just return
  1523. * the current desired low-latency state.
  1524. */
  1525. return mvmvif->low_latency_dbgfs ||
  1526. mvmvif->low_latency_traffic ||
  1527. mvmvif->low_latency_vcmd;
  1528. }
  1529. /* hw scheduler queue config */
  1530. bool iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue,
  1531. u16 ssn, const struct iwl_trans_txq_scd_cfg *cfg,
  1532. unsigned int wdg_timeout);
  1533. int iwl_mvm_tvqm_enable_txq(struct iwl_mvm *mvm, int mac80211_queue,
  1534. u8 sta_id, u8 tid, unsigned int timeout);
  1535. int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue,
  1536. u8 tid, u8 flags);
  1537. int iwl_mvm_find_free_queue(struct iwl_mvm *mvm, u8 sta_id, u8 minq, u8 maxq);
  1538. /* Return a bitmask with all the hw supported queues, except for the
  1539. * command queue, which can't be flushed.
  1540. */
  1541. static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)
  1542. {
  1543. return ((BIT(mvm->cfg->base_params->num_of_queues) - 1) &
  1544. ~BIT(IWL_MVM_DQA_CMD_QUEUE));
  1545. }
  1546. static inline void iwl_mvm_stop_device(struct iwl_mvm *mvm)
  1547. {
  1548. iwl_free_fw_paging(&mvm->fwrt);
  1549. clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
  1550. iwl_fw_dump_conf_clear(&mvm->fwrt);
  1551. iwl_trans_stop_device(mvm->trans);
  1552. }
  1553. /* Stop/start all mac queues in a given bitmap */
  1554. void iwl_mvm_start_mac_queues(struct iwl_mvm *mvm, unsigned long mq);
  1555. void iwl_mvm_stop_mac_queues(struct iwl_mvm *mvm, unsigned long mq);
  1556. /* Re-configure the SCD for a queue that has already been configured */
  1557. int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id,
  1558. int tid, int frame_limit, u16 ssn);
  1559. /* Thermal management and CT-kill */
  1560. void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
  1561. void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp);
  1562. void iwl_mvm_temp_notif(struct iwl_mvm *mvm,
  1563. struct iwl_rx_cmd_buffer *rxb);
  1564. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  1565. void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff);
  1566. void iwl_mvm_thermal_exit(struct iwl_mvm *mvm);
  1567. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  1568. int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp);
  1569. void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1570. void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm);
  1571. int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);
  1572. int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);
  1573. /* Location Aware Regulatory */
  1574. struct iwl_mcc_update_resp *
  1575. iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
  1576. enum iwl_mcc_source src_id);
  1577. int iwl_mvm_init_mcc(struct iwl_mvm *mvm);
  1578. void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
  1579. struct iwl_rx_cmd_buffer *rxb);
  1580. struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
  1581. const char *alpha2,
  1582. enum iwl_mcc_source src_id,
  1583. bool *changed);
  1584. struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm,
  1585. bool *changed);
  1586. int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm);
  1587. void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm);
  1588. /* smart fifo */
  1589. int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1590. bool added_vif);
  1591. /* TDLS */
  1592. /*
  1593. * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
  1594. * This TID is marked as used vs the AP and all connected TDLS peers.
  1595. */
  1596. #define IWL_MVM_TDLS_FW_TID 4
  1597. int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1598. void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
  1599. void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1600. bool sta_added);
  1601. void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
  1602. struct ieee80211_vif *vif);
  1603. int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
  1604. struct ieee80211_vif *vif,
  1605. struct ieee80211_sta *sta, u8 oper_class,
  1606. struct cfg80211_chan_def *chandef,
  1607. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
  1608. void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
  1609. struct ieee80211_vif *vif,
  1610. struct ieee80211_tdls_ch_sw_params *params);
  1611. void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
  1612. struct ieee80211_vif *vif,
  1613. struct ieee80211_sta *sta);
  1614. void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb);
  1615. void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
  1616. void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
  1617. struct iwl_mvm_internal_rxq_notif *notif,
  1618. u32 size);
  1619. void iwl_mvm_reorder_timer_expired(struct timer_list *t);
  1620. struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
  1621. bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm);
  1622. void iwl_mvm_inactivity_check(struct iwl_mvm *mvm);
  1623. void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
  1624. unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
  1625. struct ieee80211_vif *vif,
  1626. bool tdls, bool cmd_q);
  1627. void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1628. const char *errmsg);
  1629. void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
  1630. struct ieee80211_vif *vif,
  1631. const struct ieee80211_sta *sta,
  1632. u16 tid);
  1633. int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b);
  1634. int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm);
  1635. #endif /* __IWL_MVM_H__ */