mvm.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  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 - 2014 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #ifndef __IWL_MVM_H__
  66. #define __IWL_MVM_H__
  67. #include <linux/list.h>
  68. #include <linux/spinlock.h>
  69. #include <linux/leds.h>
  70. #include <linux/in6.h>
  71. #include "iwl-op-mode.h"
  72. #include "iwl-trans.h"
  73. #include "iwl-notif-wait.h"
  74. #include "iwl-eeprom-parse.h"
  75. #include "iwl-fw-file.h"
  76. #include "sta.h"
  77. #include "fw-api.h"
  78. #include "constants.h"
  79. #define IWL_INVALID_MAC80211_QUEUE 0xff
  80. #define IWL_MVM_MAX_ADDRESSES 5
  81. /* RSSI offset for WkP */
  82. #define IWL_RSSI_OFFSET 50
  83. #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
  84. /* A TimeUnit is 1024 microsecond */
  85. #define MSEC_TO_TU(_msec) (_msec*1000/1024)
  86. /* For GO, this value represents the number of TUs before CSA "beacon
  87. * 0" TBTT when the CSA time-event needs to be scheduled to start. It
  88. * must be big enough to ensure that we switch in time.
  89. */
  90. #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40
  91. /* For client, this value represents the number of TUs before CSA
  92. * "beacon 1" TBTT, instead. This is because we don't know when the
  93. * GO/AP will be in the new channel, so we switch early enough.
  94. */
  95. #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10
  96. /*
  97. * This value (in TUs) is used to fine tune the CSA NoA end time which should
  98. * be just before "beacon 0" TBTT.
  99. */
  100. #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
  101. /*
  102. * Number of beacons to transmit on a new channel until we unblock tx to
  103. * the stations, even if we didn't identify them on a new channel
  104. */
  105. #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
  106. extern const struct ieee80211_ops iwl_mvm_hw_ops;
  107. /**
  108. * struct iwl_mvm_mod_params - module parameters for iwlmvm
  109. * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
  110. * We will register to mac80211 to have testmode working. The NIC must not
  111. * be up'ed after the INIT fw asserted. This is useful to be able to use
  112. * proprietary tools over testmode to debug the INIT fw.
  113. * @tfd_q_hang_detect: enabled the detection of hung transmit queues
  114. * @power_scheme: CAM(Continuous Active Mode)-1, BPS(Balanced Power
  115. * Save)-2(default), LP(Low Power)-3
  116. */
  117. struct iwl_mvm_mod_params {
  118. bool init_dbg;
  119. bool tfd_q_hang_detect;
  120. int power_scheme;
  121. };
  122. extern struct iwl_mvm_mod_params iwlmvm_mod_params;
  123. /**
  124. * struct iwl_mvm_dump_ptrs - set of pointers needed for the fw-error-dump
  125. *
  126. * @op_mode_ptr: pointer to the buffer coming from the mvm op_mode
  127. * @trans_ptr: pointer to struct %iwl_trans_dump_data which contains the
  128. * transport's data.
  129. * @trans_len: length of the valid data in trans_ptr
  130. * @op_mode_len: length of the valid data in op_mode_ptr
  131. */
  132. struct iwl_mvm_dump_ptrs {
  133. struct iwl_trans_dump_data *trans_ptr;
  134. void *op_mode_ptr;
  135. u32 op_mode_len;
  136. };
  137. /**
  138. * struct iwl_mvm_dump_desc - describes the dump
  139. * @len: length of trig_desc->data
  140. * @trig_desc: the description of the dump
  141. */
  142. struct iwl_mvm_dump_desc {
  143. size_t len;
  144. /* must be last */
  145. struct iwl_fw_error_dump_trigger_desc trig_desc;
  146. };
  147. extern struct iwl_mvm_dump_desc iwl_mvm_dump_desc_assert;
  148. struct iwl_mvm_phy_ctxt {
  149. u16 id;
  150. u16 color;
  151. u32 ref;
  152. /*
  153. * TODO: This should probably be removed. Currently here only for rate
  154. * scaling algorithm
  155. */
  156. struct ieee80211_channel *channel;
  157. };
  158. struct iwl_mvm_time_event_data {
  159. struct ieee80211_vif *vif;
  160. struct list_head list;
  161. unsigned long end_jiffies;
  162. u32 duration;
  163. bool running;
  164. u32 uid;
  165. /*
  166. * The access to the 'id' field must be done when the
  167. * mvm->time_event_lock is held, as it value is used to indicate
  168. * if the te is in the time event list or not (when id == TE_MAX)
  169. */
  170. u32 id;
  171. };
  172. /* Power management */
  173. /**
  174. * enum iwl_power_scheme
  175. * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
  176. * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
  177. * @IWL_POWER_LEVEL_LP - Low Power
  178. */
  179. enum iwl_power_scheme {
  180. IWL_POWER_SCHEME_CAM = 1,
  181. IWL_POWER_SCHEME_BPS,
  182. IWL_POWER_SCHEME_LP
  183. };
  184. #define IWL_CONN_MAX_LISTEN_INTERVAL 10
  185. #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_2
  186. #ifdef CONFIG_IWLWIFI_DEBUGFS
  187. enum iwl_dbgfs_pm_mask {
  188. MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
  189. MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
  190. MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
  191. MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
  192. MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
  193. MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
  194. MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
  195. MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
  196. MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
  197. MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
  198. };
  199. struct iwl_dbgfs_pm {
  200. u16 keep_alive_seconds;
  201. u32 rx_data_timeout;
  202. u32 tx_data_timeout;
  203. bool skip_over_dtim;
  204. u8 skip_dtim_periods;
  205. bool lprx_ena;
  206. u32 lprx_rssi_threshold;
  207. bool snooze_ena;
  208. bool uapsd_misbehaving;
  209. bool use_ps_poll;
  210. int mask;
  211. };
  212. /* beacon filtering */
  213. enum iwl_dbgfs_bf_mask {
  214. MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
  215. MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
  216. MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
  217. MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
  218. MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
  219. MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
  220. MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
  221. MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
  222. MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
  223. MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
  224. MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
  225. };
  226. struct iwl_dbgfs_bf {
  227. u32 bf_energy_delta;
  228. u32 bf_roaming_energy_delta;
  229. u32 bf_roaming_state;
  230. u32 bf_temp_threshold;
  231. u32 bf_temp_fast_filter;
  232. u32 bf_temp_slow_filter;
  233. u32 bf_enable_beacon_filter;
  234. u32 bf_debug_flag;
  235. u32 bf_escape_timer;
  236. u32 ba_escape_timer;
  237. u32 ba_enable_beacon_abort;
  238. int mask;
  239. };
  240. #endif
  241. enum iwl_mvm_smps_type_request {
  242. IWL_MVM_SMPS_REQ_BT_COEX,
  243. IWL_MVM_SMPS_REQ_TT,
  244. IWL_MVM_SMPS_REQ_PROT,
  245. NUM_IWL_MVM_SMPS_REQ,
  246. };
  247. enum iwl_mvm_ref_type {
  248. IWL_MVM_REF_UCODE_DOWN,
  249. IWL_MVM_REF_SCAN,
  250. IWL_MVM_REF_ROC,
  251. IWL_MVM_REF_P2P_CLIENT,
  252. IWL_MVM_REF_AP_IBSS,
  253. IWL_MVM_REF_USER,
  254. IWL_MVM_REF_TX,
  255. IWL_MVM_REF_TX_AGG,
  256. IWL_MVM_REF_ADD_IF,
  257. IWL_MVM_REF_START_AP,
  258. IWL_MVM_REF_BSS_CHANGED,
  259. IWL_MVM_REF_PREPARE_TX,
  260. IWL_MVM_REF_PROTECT_TDLS,
  261. IWL_MVM_REF_CHECK_CTKILL,
  262. IWL_MVM_REF_PRPH_READ,
  263. IWL_MVM_REF_PRPH_WRITE,
  264. IWL_MVM_REF_NMI,
  265. IWL_MVM_REF_TM_CMD,
  266. IWL_MVM_REF_EXIT_WORK,
  267. IWL_MVM_REF_PROTECT_CSA,
  268. IWL_MVM_REF_FW_DBG_COLLECT,
  269. /* update debugfs.c when changing this */
  270. IWL_MVM_REF_COUNT,
  271. };
  272. enum iwl_bt_force_ant_mode {
  273. BT_FORCE_ANT_DIS = 0,
  274. BT_FORCE_ANT_AUTO,
  275. BT_FORCE_ANT_BT,
  276. BT_FORCE_ANT_WIFI,
  277. BT_FORCE_ANT_MAX,
  278. };
  279. /**
  280. * struct iwl_mvm_vif_bf_data - beacon filtering related data
  281. * @bf_enabled: indicates if beacon filtering is enabled
  282. * @ba_enabled: indicated if beacon abort is enabled
  283. * @ave_beacon_signal: average beacon signal
  284. * @last_cqm_event: rssi of the last cqm event
  285. * @bt_coex_min_thold: minimum threshold for BT coex
  286. * @bt_coex_max_thold: maximum threshold for BT coex
  287. * @last_bt_coex_event: rssi of the last BT coex event
  288. */
  289. struct iwl_mvm_vif_bf_data {
  290. bool bf_enabled;
  291. bool ba_enabled;
  292. s8 ave_beacon_signal;
  293. s8 last_cqm_event;
  294. s8 bt_coex_min_thold;
  295. s8 bt_coex_max_thold;
  296. s8 last_bt_coex_event;
  297. };
  298. /**
  299. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  300. * @id: between 0 and 3
  301. * @color: to solve races upon MAC addition and removal
  302. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  303. * @bssid: BSSID for this (client) interface
  304. * @associated: indicates that we're currently associated, used only for
  305. * managing the firmware state in iwl_mvm_bss_info_changed_station()
  306. * @uploaded: indicates the MAC context has been added to the device
  307. * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
  308. * should get quota etc.
  309. * @pm_enabled - Indicate if MAC power management is allowed
  310. * @monitor_active: indicates that monitor context is configured, and that the
  311. * interface should get quota etc.
  312. * @low_latency: indicates that this interface is in low-latency mode
  313. * (VMACLowLatencyMode)
  314. * @ps_disabled: indicates that this interface requires PS to be disabled
  315. * @queue_params: QoS params for this MAC
  316. * @bcast_sta: station used for broadcast packets. Used by the following
  317. * vifs: P2P_DEVICE, GO and AP.
  318. * @beacon_skb: the skb used to hold the AP/GO beacon template
  319. * @smps_requests: the SMPS requests of differents parts of the driver,
  320. * combined on update to yield the overall request to mac80211.
  321. * @beacon_stats: beacon statistics, containing the # of received beacons,
  322. * # of received beacons accumulated over FW restart, and the current
  323. * average signal of beacons retrieved from the firmware
  324. */
  325. struct iwl_mvm_vif {
  326. struct iwl_mvm *mvm;
  327. u16 id;
  328. u16 color;
  329. u8 ap_sta_id;
  330. u8 bssid[ETH_ALEN];
  331. bool associated;
  332. bool uploaded;
  333. bool ap_ibss_active;
  334. bool pm_enabled;
  335. bool monitor_active;
  336. bool low_latency;
  337. bool ps_disabled;
  338. struct iwl_mvm_vif_bf_data bf_data;
  339. struct {
  340. u32 num_beacons, accu_num_beacons;
  341. u8 avg_signal;
  342. } beacon_stats;
  343. u32 ap_beacon_time;
  344. enum iwl_tsf_id tsf_id;
  345. /*
  346. * QoS data from mac80211, need to store this here
  347. * as mac80211 has a separate callback but we need
  348. * to have the data for the MAC context
  349. */
  350. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  351. struct iwl_mvm_time_event_data time_event_data;
  352. struct iwl_mvm_time_event_data hs_time_event_data;
  353. struct iwl_mvm_int_sta bcast_sta;
  354. /*
  355. * Assigned while mac80211 has the interface in a channel context,
  356. * or, for P2P Device, while it exists.
  357. */
  358. struct iwl_mvm_phy_ctxt *phy_ctxt;
  359. #ifdef CONFIG_PM_SLEEP
  360. /* WoWLAN GTK rekey data */
  361. struct {
  362. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  363. __le64 replay_ctr;
  364. bool valid;
  365. } rekey_data;
  366. int tx_key_idx;
  367. bool seqno_valid;
  368. u16 seqno;
  369. #endif
  370. #if IS_ENABLED(CONFIG_IPV6)
  371. /* IPv6 addresses for WoWLAN */
  372. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  373. int num_target_ipv6_addrs;
  374. #endif
  375. #ifdef CONFIG_IWLWIFI_DEBUGFS
  376. struct dentry *dbgfs_dir;
  377. struct dentry *dbgfs_slink;
  378. struct iwl_dbgfs_pm dbgfs_pm;
  379. struct iwl_dbgfs_bf dbgfs_bf;
  380. struct iwl_mac_power_cmd mac_pwr_cmd;
  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. };
  388. static inline struct iwl_mvm_vif *
  389. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  390. {
  391. return (void *)vif->drv_priv;
  392. }
  393. extern const u8 tid_to_mac80211_ac[];
  394. enum iwl_scan_status {
  395. IWL_MVM_SCAN_NONE,
  396. IWL_MVM_SCAN_OS,
  397. IWL_MVM_SCAN_SCHED,
  398. };
  399. /**
  400. * struct iwl_nvm_section - describes an NVM section in memory.
  401. *
  402. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  403. * and saved for later use by the driver. Not all NVM sections are saved
  404. * this way, only the needed ones.
  405. */
  406. struct iwl_nvm_section {
  407. u16 length;
  408. const u8 *data;
  409. };
  410. /*
  411. * Tx-backoff threshold
  412. * @temperature: The threshold in Celsius
  413. * @backoff: The tx-backoff in uSec
  414. */
  415. struct iwl_tt_tx_backoff {
  416. s32 temperature;
  417. u32 backoff;
  418. };
  419. #define TT_TX_BACKOFF_SIZE 6
  420. /**
  421. * struct iwl_tt_params - thermal throttling parameters
  422. * @ct_kill_entry: CT Kill entry threshold
  423. * @ct_kill_exit: CT Kill exit threshold
  424. * @ct_kill_duration: The time intervals (in uSec) in which the driver needs
  425. * to checks whether to exit CT Kill.
  426. * @dynamic_smps_entry: Dynamic SMPS entry threshold
  427. * @dynamic_smps_exit: Dynamic SMPS exit threshold
  428. * @tx_protection_entry: TX protection entry threshold
  429. * @tx_protection_exit: TX protection exit threshold
  430. * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
  431. * @support_ct_kill: Support CT Kill?
  432. * @support_dynamic_smps: Support dynamic SMPS?
  433. * @support_tx_protection: Support tx protection?
  434. * @support_tx_backoff: Support tx-backoff?
  435. */
  436. struct iwl_tt_params {
  437. s32 ct_kill_entry;
  438. s32 ct_kill_exit;
  439. u32 ct_kill_duration;
  440. s32 dynamic_smps_entry;
  441. s32 dynamic_smps_exit;
  442. s32 tx_protection_entry;
  443. s32 tx_protection_exit;
  444. struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
  445. bool support_ct_kill;
  446. bool support_dynamic_smps;
  447. bool support_tx_protection;
  448. bool support_tx_backoff;
  449. };
  450. /**
  451. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  452. * @ct_kill_exit: worker to exit thermal kill
  453. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  454. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  455. * @min_backoff: The minimal tx backoff due to power restrictions
  456. * @params: Parameters to configure the thermal throttling algorithm.
  457. * @throttle: Is thermal throttling is active?
  458. */
  459. struct iwl_mvm_tt_mgmt {
  460. struct delayed_work ct_kill_exit;
  461. bool dynamic_smps;
  462. u32 tx_backoff;
  463. u32 min_backoff;
  464. const struct iwl_tt_params *params;
  465. bool throttle;
  466. };
  467. #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
  468. struct iwl_mvm_frame_stats {
  469. u32 legacy_frames;
  470. u32 ht_frames;
  471. u32 vht_frames;
  472. u32 bw_20_frames;
  473. u32 bw_40_frames;
  474. u32 bw_80_frames;
  475. u32 bw_160_frames;
  476. u32 sgi_frames;
  477. u32 ngi_frames;
  478. u32 siso_frames;
  479. u32 mimo2_frames;
  480. u32 agg_frames;
  481. u32 ampdu_count;
  482. u32 success_frames;
  483. u32 fail_frames;
  484. u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
  485. int last_frame_idx;
  486. };
  487. enum {
  488. D0I3_DEFER_WAKEUP,
  489. D0I3_PENDING_WAKEUP,
  490. };
  491. #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
  492. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
  493. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
  494. enum iwl_mvm_tdls_cs_state {
  495. IWL_MVM_TDLS_SW_IDLE = 0,
  496. IWL_MVM_TDLS_SW_REQ_SENT,
  497. IWL_MVM_TDLS_SW_RESP_RCVD,
  498. IWL_MVM_TDLS_SW_REQ_RCVD,
  499. IWL_MVM_TDLS_SW_ACTIVE,
  500. };
  501. struct iwl_mvm_shared_mem_cfg {
  502. u32 shared_mem_addr;
  503. u32 shared_mem_size;
  504. u32 sample_buff_addr;
  505. u32 sample_buff_size;
  506. u32 txfifo_addr;
  507. u32 txfifo_size[TX_FIFO_MAX_NUM];
  508. u32 rxfifo_size[RX_FIFO_MAX_NUM];
  509. u32 page_buff_addr;
  510. u32 page_buff_size;
  511. };
  512. struct iwl_mvm {
  513. /* for logger access */
  514. struct device *dev;
  515. struct iwl_trans *trans;
  516. const struct iwl_fw *fw;
  517. const struct iwl_cfg *cfg;
  518. struct iwl_phy_db *phy_db;
  519. struct ieee80211_hw *hw;
  520. /* for protecting access to iwl_mvm */
  521. struct mutex mutex;
  522. struct list_head async_handlers_list;
  523. spinlock_t async_handlers_lock;
  524. struct work_struct async_handlers_wk;
  525. struct work_struct roc_done_wk;
  526. unsigned long status;
  527. /*
  528. * for beacon filtering -
  529. * currently only one interface can be supported
  530. */
  531. struct iwl_mvm_vif *bf_allowed_vif;
  532. enum iwl_ucode_type cur_ucode;
  533. bool ucode_loaded;
  534. bool init_ucode_complete;
  535. bool calibrating;
  536. u32 error_event_table;
  537. u32 log_event_table;
  538. u32 umac_error_event_table;
  539. bool support_umac_log;
  540. struct iwl_sf_region sf_space;
  541. u32 ampdu_ref;
  542. struct iwl_notif_wait_data notif_wait;
  543. struct mvm_statistics_rx rx_stats;
  544. struct {
  545. u64 rx_time;
  546. u64 tx_time;
  547. u64 on_time_rf;
  548. u64 on_time_scan;
  549. } radio_stats, accu_radio_stats;
  550. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  551. atomic_t mac80211_queue_stop_count[IEEE80211_MAX_QUEUES];
  552. const char *nvm_file_name;
  553. struct iwl_nvm_data *nvm_data;
  554. /* NVM sections */
  555. struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
  556. /* EEPROM MAC addresses */
  557. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  558. /* data related to data path */
  559. struct iwl_rx_phy_info last_phy_info;
  560. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  561. struct work_struct sta_drained_wk;
  562. unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  563. atomic_t pending_frames[IWL_MVM_STATION_COUNT];
  564. u32 tfd_drained[IWL_MVM_STATION_COUNT];
  565. u8 rx_ba_sessions;
  566. /* configured by mac80211 */
  567. u32 rts_threshold;
  568. /* Scan status, cmd (pre-allocated) and auxiliary station */
  569. enum iwl_scan_status scan_status;
  570. void *scan_cmd;
  571. struct iwl_mcast_filter_cmd *mcast_filter_cmd;
  572. /* UMAC scan tracking */
  573. u32 scan_uid[IWL_MVM_MAX_SIMULTANEOUS_SCANS];
  574. u8 scan_seq_num, sched_scan_seq_num;
  575. /* rx chain antennas set through debugfs for the scan command */
  576. u8 scan_rx_ant;
  577. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  578. /* broadcast filters to configure for each associated station */
  579. const struct iwl_fw_bcast_filter *bcast_filters;
  580. #ifdef CONFIG_IWLWIFI_DEBUGFS
  581. struct {
  582. u32 override; /* u32 for debugfs_create_bool */
  583. struct iwl_bcast_filter_cmd cmd;
  584. } dbgfs_bcast_filtering;
  585. #endif
  586. #endif
  587. /* Internal station */
  588. struct iwl_mvm_int_sta aux_sta;
  589. bool last_ebs_successful;
  590. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  591. u8 mgmt_last_antenna_idx;
  592. /* last smart fifo state that was successfully sent to firmware */
  593. enum iwl_sf_state sf_state;
  594. #ifdef CONFIG_IWLWIFI_DEBUGFS
  595. struct dentry *debugfs_dir;
  596. u32 dbgfs_sram_offset, dbgfs_sram_len;
  597. u32 dbgfs_prph_reg_addr;
  598. bool disable_power_off;
  599. bool disable_power_off_d3;
  600. bool scan_iter_notif_enabled;
  601. struct debugfs_blob_wrapper nvm_hw_blob;
  602. struct debugfs_blob_wrapper nvm_sw_blob;
  603. struct debugfs_blob_wrapper nvm_calib_blob;
  604. struct debugfs_blob_wrapper nvm_prod_blob;
  605. struct iwl_mvm_frame_stats drv_rx_stats;
  606. spinlock_t drv_stats_lock;
  607. u16 dbgfs_rx_phyinfo;
  608. #endif
  609. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  610. struct list_head time_event_list;
  611. spinlock_t time_event_lock;
  612. /*
  613. * A bitmap indicating the index of the key in use. The firmware
  614. * can hold 16 keys at most. Reflect this fact.
  615. */
  616. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  617. /* references taken by the driver and spinlock protecting them */
  618. spinlock_t refs_lock;
  619. u8 refs[IWL_MVM_REF_COUNT];
  620. u8 vif_count;
  621. /* -1 for always, 0 for never, >0 for that many times */
  622. s8 restart_fw;
  623. u8 fw_dbg_conf;
  624. struct delayed_work fw_dump_wk;
  625. struct iwl_mvm_dump_desc *fw_dump_desc;
  626. #ifdef CONFIG_IWLWIFI_LEDS
  627. struct led_classdev led;
  628. #endif
  629. struct ieee80211_vif *p2p_device_vif;
  630. #ifdef CONFIG_PM_SLEEP
  631. struct wiphy_wowlan_support wowlan;
  632. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  633. /* sched scan settings for net detect */
  634. struct cfg80211_sched_scan_request *nd_config;
  635. struct ieee80211_scan_ies nd_ies;
  636. struct cfg80211_match_set *nd_match_sets;
  637. int n_nd_match_sets;
  638. struct ieee80211_channel **nd_channels;
  639. int n_nd_channels;
  640. bool net_detect;
  641. #ifdef CONFIG_IWLWIFI_DEBUGFS
  642. u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */
  643. bool d3_test_active;
  644. bool store_d3_resume_sram;
  645. void *d3_resume_sram;
  646. u32 d3_test_pme_ptr;
  647. struct ieee80211_vif *keep_vif;
  648. #endif
  649. #endif
  650. /* d0i3 */
  651. u8 d0i3_ap_sta_id;
  652. bool d0i3_offloading;
  653. struct work_struct d0i3_exit_work;
  654. struct sk_buff_head d0i3_tx;
  655. /* protect d0i3_suspend_flags */
  656. struct mutex d0i3_suspend_mutex;
  657. unsigned long d0i3_suspend_flags;
  658. /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
  659. spinlock_t d0i3_tx_lock;
  660. wait_queue_head_t d0i3_exit_waitq;
  661. /* BT-Coex */
  662. u8 bt_ack_kill_msk[NUM_PHY_CTX];
  663. u8 bt_cts_kill_msk[NUM_PHY_CTX];
  664. struct iwl_bt_coex_profile_notif_old last_bt_notif_old;
  665. struct iwl_bt_coex_ci_cmd_old last_bt_ci_cmd_old;
  666. struct iwl_bt_coex_profile_notif last_bt_notif;
  667. struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
  668. u32 last_ant_isol;
  669. u8 last_corun_lut;
  670. u8 bt_tx_prio;
  671. enum iwl_bt_force_ant_mode bt_force_ant_mode;
  672. /* Aux ROC */
  673. struct list_head aux_roc_te_list;
  674. /* Thermal Throttling and CTkill */
  675. struct iwl_mvm_tt_mgmt thermal_throttle;
  676. s32 temperature; /* Celsius */
  677. /*
  678. * Debug option to set the NIC temperature. This option makes the
  679. * driver think this is the actual NIC temperature, and ignore the
  680. * real temperature that is received from the fw
  681. */
  682. bool temperature_test; /* Debug test temperature is enabled */
  683. struct iwl_time_quota_cmd last_quota_cmd;
  684. #ifdef CONFIG_NL80211_TESTMODE
  685. u32 noa_duration;
  686. struct ieee80211_vif *noa_vif;
  687. #endif
  688. /* Tx queues */
  689. u8 aux_queue;
  690. u8 first_agg_queue;
  691. u8 last_agg_queue;
  692. /* Indicate if device power save is allowed */
  693. u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
  694. struct ieee80211_vif __rcu *csa_vif;
  695. struct ieee80211_vif __rcu *csa_tx_blocked_vif;
  696. u8 csa_tx_block_bcn_timeout;
  697. /* system time of last beacon (for AP/GO interface) */
  698. u32 ap_last_beacon_gp2;
  699. u8 low_latency_agg_frame_limit;
  700. /* TDLS channel switch data */
  701. struct {
  702. struct delayed_work dwork;
  703. enum iwl_mvm_tdls_cs_state state;
  704. /*
  705. * Current cs sta - might be different from periodic cs peer
  706. * station. Value is meaningless when the cs-state is idle.
  707. */
  708. u8 cur_sta_id;
  709. /* TDLS periodic channel-switch peer */
  710. struct {
  711. u8 sta_id;
  712. u8 op_class;
  713. bool initiator; /* are we the link initiator */
  714. struct cfg80211_chan_def chandef;
  715. struct sk_buff *skb; /* ch sw template */
  716. u32 ch_sw_tm_ie;
  717. /* timestamp of last ch-sw request sent (GP2 time) */
  718. u32 sent_timestamp;
  719. } peer;
  720. } tdls_cs;
  721. struct iwl_mvm_shared_mem_cfg shared_mem_cfg;
  722. };
  723. /* Extract MVM priv from op_mode and _hw */
  724. #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
  725. ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
  726. #define IWL_MAC80211_GET_MVM(_hw) \
  727. IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
  728. enum iwl_mvm_status {
  729. IWL_MVM_STATUS_HW_RFKILL,
  730. IWL_MVM_STATUS_HW_CTKILL,
  731. IWL_MVM_STATUS_ROC_RUNNING,
  732. IWL_MVM_STATUS_IN_HW_RESTART,
  733. IWL_MVM_STATUS_IN_D0I3,
  734. IWL_MVM_STATUS_ROC_AUX_RUNNING,
  735. IWL_MVM_STATUS_D3_RECONFIG,
  736. IWL_MVM_STATUS_DUMPING_FW_LOG,
  737. };
  738. static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
  739. {
  740. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
  741. test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
  742. }
  743. /* Must be called with rcu_read_lock() held and it can only be
  744. * released when mvmsta is not needed anymore.
  745. */
  746. static inline struct iwl_mvm_sta *
  747. iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
  748. {
  749. struct ieee80211_sta *sta;
  750. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  751. return NULL;
  752. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  753. /* This can happen if the station has been removed right now */
  754. if (IS_ERR_OR_NULL(sta))
  755. return NULL;
  756. return iwl_mvm_sta_from_mac80211(sta);
  757. }
  758. static inline struct iwl_mvm_sta *
  759. iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
  760. {
  761. struct ieee80211_sta *sta;
  762. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  763. return NULL;
  764. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
  765. lockdep_is_held(&mvm->mutex));
  766. /* This can happen if the station has been removed right now */
  767. if (IS_ERR_OR_NULL(sta))
  768. return NULL;
  769. return iwl_mvm_sta_from_mac80211(sta);
  770. }
  771. static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
  772. {
  773. return mvm->trans->cfg->d0i3 &&
  774. mvm->trans->d0i3_mode != IWL_D0I3_MODE_OFF &&
  775. !iwlwifi_mod_params.d0i3_disable &&
  776. (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_D0I3_SUPPORT);
  777. }
  778. static inline bool iwl_mvm_is_scd_cfg_supported(struct iwl_mvm *mvm)
  779. {
  780. return mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SCD_CFG;
  781. }
  782. static inline bool iwl_mvm_bt_is_plcr_supported(struct iwl_mvm *mvm)
  783. {
  784. return (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_BT_COEX_PLCR) &&
  785. IWL_MVM_BT_COEX_CORUNNING;
  786. }
  787. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  788. struct iwl_rate_info {
  789. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  790. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  791. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  792. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  793. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  794. };
  795. void __iwl_mvm_mac_stop(struct iwl_mvm *mvm);
  796. int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
  797. /******************
  798. * MVM Methods
  799. ******************/
  800. /* uCode */
  801. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  802. /* Utils */
  803. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  804. enum ieee80211_band band);
  805. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  806. enum ieee80211_band band,
  807. struct ieee80211_tx_rate *r);
  808. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  809. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  810. u8 first_antenna(u8 mask);
  811. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  812. /* Tx / Host Commands */
  813. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  814. struct iwl_host_cmd *cmd);
  815. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u8 id,
  816. u32 flags, u16 len, const void *data);
  817. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  818. struct iwl_host_cmd *cmd,
  819. u32 *status);
  820. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u8 id,
  821. u16 len, const void *data,
  822. u32 *status);
  823. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  824. struct ieee80211_sta *sta);
  825. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  826. void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
  827. struct iwl_tx_cmd *tx_cmd,
  828. struct ieee80211_tx_info *info, u8 sta_id);
  829. void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
  830. struct ieee80211_tx_info *info,
  831. struct iwl_tx_cmd *tx_cmd,
  832. struct sk_buff *skb_frag);
  833. void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
  834. struct ieee80211_tx_info *info,
  835. struct ieee80211_sta *sta, __le16 fc);
  836. #ifdef CONFIG_IWLWIFI_DEBUG
  837. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  838. #else
  839. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  840. #endif
  841. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync);
  842. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  843. static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
  844. {
  845. flush_work(&mvm->async_handlers_wk);
  846. }
  847. /* Statistics */
  848. void iwl_mvm_handle_rx_statistics(struct iwl_mvm *mvm,
  849. struct iwl_rx_packet *pkt);
  850. int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  851. struct iwl_rx_cmd_buffer *rxb,
  852. struct iwl_device_cmd *cmd);
  853. int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear);
  854. void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm);
  855. /* NVM */
  856. int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic);
  857. int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
  858. static inline u8 iwl_mvm_get_valid_tx_ant(struct iwl_mvm *mvm)
  859. {
  860. return mvm->nvm_data && mvm->nvm_data->valid_tx_ant ?
  861. mvm->fw->valid_tx_ant & mvm->nvm_data->valid_tx_ant :
  862. mvm->fw->valid_tx_ant;
  863. }
  864. static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm)
  865. {
  866. return mvm->nvm_data && mvm->nvm_data->valid_rx_ant ?
  867. mvm->fw->valid_rx_ant & mvm->nvm_data->valid_rx_ant :
  868. mvm->fw->valid_rx_ant;
  869. }
  870. static inline u32 iwl_mvm_get_phy_config(struct iwl_mvm *mvm)
  871. {
  872. u32 phy_config = ~(FW_PHY_CFG_TX_CHAIN |
  873. FW_PHY_CFG_RX_CHAIN);
  874. u32 valid_rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
  875. u32 valid_tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
  876. phy_config |= valid_tx_ant << FW_PHY_CFG_TX_CHAIN_POS |
  877. valid_rx_ant << FW_PHY_CFG_RX_CHAIN_POS;
  878. return mvm->fw->phy_config & phy_config;
  879. }
  880. int iwl_mvm_up(struct iwl_mvm *mvm);
  881. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  882. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  883. bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
  884. struct iwl_bcast_filter_cmd *cmd);
  885. /*
  886. * FW notifications / CMD responses handlers
  887. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  888. */
  889. int iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  890. struct iwl_device_cmd *cmd);
  891. int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  892. struct iwl_device_cmd *cmd);
  893. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  894. struct iwl_device_cmd *cmd);
  895. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  896. struct iwl_device_cmd *cmd);
  897. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  898. struct iwl_device_cmd *cmd);
  899. int iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
  900. struct iwl_rx_cmd_buffer *rxb,
  901. struct iwl_device_cmd *cmd);
  902. int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  903. struct iwl_device_cmd *cmd);
  904. int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  905. struct iwl_rx_cmd_buffer *rxb,
  906. struct iwl_device_cmd *cmd);
  907. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  908. struct iwl_device_cmd *cmd);
  909. int iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  910. struct iwl_device_cmd *cmd);
  911. int iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
  912. struct iwl_rx_cmd_buffer *rxb,
  913. struct iwl_device_cmd *cmd);
  914. /* MVM PHY */
  915. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  916. struct cfg80211_chan_def *chandef,
  917. u8 chains_static, u8 chains_dynamic);
  918. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  919. struct cfg80211_chan_def *chandef,
  920. u8 chains_static, u8 chains_dynamic);
  921. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  922. struct iwl_mvm_phy_ctxt *ctxt);
  923. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  924. struct iwl_mvm_phy_ctxt *ctxt);
  925. int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
  926. u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef);
  927. u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef);
  928. /* MAC (virtual interface) programming */
  929. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  930. void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  931. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  932. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  933. bool force_assoc_off, const u8 *bssid_override);
  934. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  935. u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif);
  936. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  937. struct ieee80211_vif *vif);
  938. int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  939. struct iwl_rx_cmd_buffer *rxb,
  940. struct iwl_device_cmd *cmd);
  941. int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  942. struct iwl_rx_cmd_buffer *rxb,
  943. struct iwl_device_cmd *cmd);
  944. void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
  945. struct ieee80211_vif *vif);
  946. unsigned long iwl_mvm_get_used_hw_queues(struct iwl_mvm *mvm,
  947. struct ieee80211_vif *exclude_vif);
  948. /* Bindings */
  949. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  950. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  951. /* Quota management */
  952. int iwl_mvm_update_quotas(struct iwl_mvm *mvm,
  953. struct ieee80211_vif *disabled_vif);
  954. /* Scanning */
  955. int iwl_mvm_scan_size(struct iwl_mvm *mvm);
  956. int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
  957. int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan);
  958. /* Scheduled scan */
  959. int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
  960. struct iwl_rx_cmd_buffer *rxb,
  961. struct iwl_device_cmd *cmd);
  962. int iwl_mvm_rx_scan_offload_iter_complete_notif(struct iwl_mvm *mvm,
  963. struct iwl_rx_cmd_buffer *rxb,
  964. struct iwl_device_cmd *cmd);
  965. int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
  966. struct cfg80211_sched_scan_request *req);
  967. int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
  968. struct ieee80211_vif *vif,
  969. struct cfg80211_sched_scan_request *req,
  970. struct ieee80211_scan_ies *ies);
  971. int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
  972. int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
  973. struct iwl_rx_cmd_buffer *rxb,
  974. struct iwl_device_cmd *cmd);
  975. /* Unified scan */
  976. int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
  977. struct ieee80211_vif *vif,
  978. struct ieee80211_scan_request *req);
  979. int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
  980. struct ieee80211_vif *vif,
  981. struct cfg80211_sched_scan_request *req,
  982. struct ieee80211_scan_ies *ies);
  983. /* UMAC scan */
  984. int iwl_mvm_config_scan(struct iwl_mvm *mvm);
  985. int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  986. struct ieee80211_scan_request *req);
  987. int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  988. struct cfg80211_sched_scan_request *req,
  989. struct ieee80211_scan_ies *ies);
  990. int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
  991. struct iwl_rx_cmd_buffer *rxb,
  992. struct iwl_device_cmd *cmd);
  993. /* MVM debugfs */
  994. #ifdef CONFIG_IWLWIFI_DEBUGFS
  995. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  996. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  997. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  998. #else
  999. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  1000. struct dentry *dbgfs_dir)
  1001. {
  1002. return 0;
  1003. }
  1004. static inline void
  1005. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1006. {
  1007. }
  1008. static inline void
  1009. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1010. {
  1011. }
  1012. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1013. /* rate scaling */
  1014. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init);
  1015. void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg);
  1016. int rs_pretty_print_rate(char *buf, const u32 rate);
  1017. void rs_update_last_rssi(struct iwl_mvm *mvm,
  1018. struct iwl_lq_sta *lq_sta,
  1019. struct ieee80211_rx_status *rx_status);
  1020. /* power management */
  1021. int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
  1022. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
  1023. int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
  1024. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1025. char *buf, int bufsz);
  1026. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1027. int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  1028. struct iwl_rx_cmd_buffer *rxb,
  1029. struct iwl_device_cmd *cmd);
  1030. #ifdef CONFIG_IWLWIFI_LEDS
  1031. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  1032. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  1033. #else
  1034. static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
  1035. {
  1036. return 0;
  1037. }
  1038. static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
  1039. {
  1040. }
  1041. #endif
  1042. /* D3 (WoWLAN, NetDetect) */
  1043. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  1044. int iwl_mvm_resume(struct ieee80211_hw *hw);
  1045. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  1046. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  1047. struct ieee80211_vif *vif,
  1048. struct cfg80211_gtk_rekey_data *data);
  1049. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  1050. struct ieee80211_vif *vif,
  1051. struct inet6_dev *idev);
  1052. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  1053. struct ieee80211_vif *vif, int idx);
  1054. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  1055. #ifdef CONFIG_PM_SLEEP
  1056. void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
  1057. struct ieee80211_vif *vif);
  1058. #else
  1059. static inline void
  1060. iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1061. {
  1062. }
  1063. #endif
  1064. void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
  1065. struct iwl_wowlan_config_cmd *cmd);
  1066. int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
  1067. struct ieee80211_vif *vif,
  1068. bool disable_offloading,
  1069. u32 cmd_flags);
  1070. /* D0i3 */
  1071. void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1072. void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1073. int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1074. bool iwl_mvm_ref_taken(struct iwl_mvm *mvm);
  1075. void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
  1076. int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode);
  1077. int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode);
  1078. int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
  1079. /* BT Coex */
  1080. int iwl_send_bt_init_conf(struct iwl_mvm *mvm);
  1081. int iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  1082. struct iwl_rx_cmd_buffer *rxb,
  1083. struct iwl_device_cmd *cmd);
  1084. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1085. enum ieee80211_rssi_event rssi_event);
  1086. void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
  1087. u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
  1088. struct ieee80211_sta *sta);
  1089. bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
  1090. struct ieee80211_sta *sta);
  1091. bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
  1092. bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
  1093. bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
  1094. enum ieee80211_band band);
  1095. u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  1096. struct ieee80211_tx_info *info, u8 ac);
  1097. bool iwl_mvm_bt_coex_is_shared_ant_avail_old(struct iwl_mvm *mvm);
  1098. void iwl_mvm_bt_coex_vif_change_old(struct iwl_mvm *mvm);
  1099. int iwl_send_bt_init_conf_old(struct iwl_mvm *mvm);
  1100. int iwl_mvm_rx_bt_coex_notif_old(struct iwl_mvm *mvm,
  1101. struct iwl_rx_cmd_buffer *rxb,
  1102. struct iwl_device_cmd *cmd);
  1103. void iwl_mvm_bt_rssi_event_old(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1104. enum ieee80211_rssi_event rssi_event);
  1105. u16 iwl_mvm_coex_agg_time_limit_old(struct iwl_mvm *mvm,
  1106. struct ieee80211_sta *sta);
  1107. bool iwl_mvm_bt_coex_is_mimo_allowed_old(struct iwl_mvm *mvm,
  1108. struct ieee80211_sta *sta);
  1109. bool iwl_mvm_bt_coex_is_tpc_allowed_old(struct iwl_mvm *mvm,
  1110. enum ieee80211_band band);
  1111. int iwl_mvm_rx_ant_coupling_notif_old(struct iwl_mvm *mvm,
  1112. struct iwl_rx_cmd_buffer *rxb,
  1113. struct iwl_device_cmd *cmd);
  1114. enum iwl_bt_kill_msk {
  1115. BT_KILL_MSK_DEFAULT,
  1116. BT_KILL_MSK_NEVER,
  1117. BT_KILL_MSK_ALWAYS,
  1118. BT_KILL_MSK_MAX,
  1119. };
  1120. extern const u8 iwl_bt_ack_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  1121. extern const u8 iwl_bt_cts_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  1122. extern const u32 iwl_bt_ctl_kill_msk[BT_KILL_MSK_MAX];
  1123. /* beacon filtering */
  1124. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1125. void
  1126. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1127. struct iwl_beacon_filter_cmd *cmd);
  1128. #else
  1129. static inline void
  1130. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1131. struct iwl_beacon_filter_cmd *cmd)
  1132. {}
  1133. #endif
  1134. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  1135. struct ieee80211_vif *vif,
  1136. bool enable, u32 flags);
  1137. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  1138. struct ieee80211_vif *vif,
  1139. u32 flags);
  1140. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  1141. struct ieee80211_vif *vif,
  1142. u32 flags);
  1143. /* SMPS */
  1144. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1145. enum iwl_mvm_smps_type_request req_type,
  1146. enum ieee80211_smps_mode smps_request);
  1147. bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm);
  1148. /* Low latency */
  1149. int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1150. bool value);
  1151. /* get SystemLowLatencyMode - only needed for beacon threshold? */
  1152. bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
  1153. /* get VMACLowLatencyMode */
  1154. static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
  1155. {
  1156. /*
  1157. * should this consider associated/active/... state?
  1158. *
  1159. * Normally low-latency should only be active on interfaces
  1160. * that are active, but at least with debugfs it can also be
  1161. * enabled on interfaces that aren't active. However, when
  1162. * interface aren't active then they aren't added into the
  1163. * binding, so this has no real impact. For now, just return
  1164. * the current desired low-latency state.
  1165. */
  1166. return mvmvif->low_latency;
  1167. }
  1168. /* hw scheduler queue config */
  1169. void iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, u16 ssn,
  1170. const struct iwl_trans_txq_scd_cfg *cfg,
  1171. unsigned int wdg_timeout);
  1172. void iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, u8 flags);
  1173. static inline
  1174. void iwl_mvm_enable_ac_txq(struct iwl_mvm *mvm, int queue,
  1175. u8 fifo, unsigned int wdg_timeout)
  1176. {
  1177. struct iwl_trans_txq_scd_cfg cfg = {
  1178. .fifo = fifo,
  1179. .tid = IWL_MAX_TID_COUNT,
  1180. .aggregate = false,
  1181. .frame_limit = IWL_FRAME_LIMIT,
  1182. };
  1183. iwl_mvm_enable_txq(mvm, queue, 0, &cfg, wdg_timeout);
  1184. }
  1185. static inline void iwl_mvm_enable_agg_txq(struct iwl_mvm *mvm, int queue,
  1186. int fifo, int sta_id, int tid,
  1187. int frame_limit, u16 ssn,
  1188. unsigned int wdg_timeout)
  1189. {
  1190. struct iwl_trans_txq_scd_cfg cfg = {
  1191. .fifo = fifo,
  1192. .sta_id = sta_id,
  1193. .tid = tid,
  1194. .frame_limit = frame_limit,
  1195. .aggregate = true,
  1196. };
  1197. iwl_mvm_enable_txq(mvm, queue, ssn, &cfg, wdg_timeout);
  1198. }
  1199. /* Thermal management and CT-kill */
  1200. void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
  1201. void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp);
  1202. int iwl_mvm_temp_notif(struct iwl_mvm *mvm,
  1203. struct iwl_rx_cmd_buffer *rxb,
  1204. struct iwl_device_cmd *cmd);
  1205. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  1206. void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
  1207. void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
  1208. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  1209. int iwl_mvm_get_temp(struct iwl_mvm *mvm);
  1210. /* smart fifo */
  1211. int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1212. bool added_vif);
  1213. /* TDLS */
  1214. /*
  1215. * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
  1216. * This TID is marked as used vs the AP and all connected TDLS peers.
  1217. */
  1218. #define IWL_MVM_TDLS_FW_TID 4
  1219. int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1220. void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
  1221. void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1222. bool sta_added);
  1223. void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
  1224. struct ieee80211_vif *vif);
  1225. int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
  1226. struct ieee80211_vif *vif,
  1227. struct ieee80211_sta *sta, u8 oper_class,
  1228. struct cfg80211_chan_def *chandef,
  1229. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
  1230. void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
  1231. struct ieee80211_vif *vif,
  1232. struct ieee80211_tdls_ch_sw_params *params);
  1233. void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
  1234. struct ieee80211_vif *vif,
  1235. struct ieee80211_sta *sta);
  1236. int iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  1237. struct iwl_device_cmd *cmd);
  1238. void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
  1239. struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
  1240. void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
  1241. void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
  1242. int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 id);
  1243. int iwl_mvm_fw_dbg_collect(struct iwl_mvm *mvm, enum iwl_fw_dbg_trigger trig,
  1244. const char *str, size_t len, unsigned int delay);
  1245. int iwl_mvm_fw_dbg_collect_desc(struct iwl_mvm *mvm,
  1246. struct iwl_mvm_dump_desc *desc,
  1247. unsigned int delay);
  1248. void iwl_mvm_free_fw_dump_desc(struct iwl_mvm *mvm);
  1249. int iwl_mvm_fw_dbg_collect_trig(struct iwl_mvm *mvm,
  1250. struct iwl_fw_dbg_trigger_tlv *trigger,
  1251. const char *str, size_t len);
  1252. static inline bool
  1253. iwl_fw_dbg_trigger_vif_match(struct iwl_fw_dbg_trigger_tlv *trig,
  1254. struct ieee80211_vif *vif)
  1255. {
  1256. u32 trig_vif = le32_to_cpu(trig->vif_type);
  1257. return trig_vif == IWL_FW_DBG_CONF_VIF_ANY || vif->type == trig_vif;
  1258. }
  1259. static inline bool
  1260. iwl_fw_dbg_trigger_stop_conf_match(struct iwl_mvm *mvm,
  1261. struct iwl_fw_dbg_trigger_tlv *trig)
  1262. {
  1263. return ((trig->mode & IWL_FW_DBG_TRIGGER_STOP) &&
  1264. (mvm->fw_dbg_conf == FW_DBG_INVALID ||
  1265. (BIT(mvm->fw_dbg_conf) & le32_to_cpu(trig->stop_conf_ids))));
  1266. }
  1267. static inline bool
  1268. iwl_fw_dbg_trigger_check_stop(struct iwl_mvm *mvm,
  1269. struct ieee80211_vif *vif,
  1270. struct iwl_fw_dbg_trigger_tlv *trig)
  1271. {
  1272. if (vif && !iwl_fw_dbg_trigger_vif_match(trig, vif))
  1273. return false;
  1274. return iwl_fw_dbg_trigger_stop_conf_match(mvm, trig);
  1275. }
  1276. static inline void
  1277. iwl_fw_dbg_trigger_simple_stop(struct iwl_mvm *mvm,
  1278. struct ieee80211_vif *vif,
  1279. enum iwl_fw_dbg_trigger trig,
  1280. const char *str, size_t len)
  1281. {
  1282. struct iwl_fw_dbg_trigger_tlv *trigger;
  1283. if (!iwl_fw_dbg_trigger_enabled(mvm->fw, trig))
  1284. return;
  1285. trigger = iwl_fw_dbg_get_trigger(mvm->fw, trig);
  1286. if (!iwl_fw_dbg_trigger_check_stop(mvm, vif, trigger))
  1287. return;
  1288. iwl_mvm_fw_dbg_collect_trig(mvm, trigger, str, len);
  1289. }
  1290. #endif /* __IWL_MVM_H__ */