mvm.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  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 "sta.h"
  76. #include "fw-api.h"
  77. #include "constants.h"
  78. #define IWL_INVALID_MAC80211_QUEUE 0xff
  79. #define IWL_MVM_MAX_ADDRESSES 5
  80. /* RSSI offset for WkP */
  81. #define IWL_RSSI_OFFSET 50
  82. #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
  83. /* A TimeUnit is 1024 microsecond */
  84. #define MSEC_TO_TU(_msec) (_msec*1000/1024)
  85. /* For GO, this value represents the number of TUs before CSA "beacon
  86. * 0" TBTT when the CSA time-event needs to be scheduled to start. It
  87. * must be big enough to ensure that we switch in time.
  88. */
  89. #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40
  90. /* For client, this value represents the number of TUs before CSA
  91. * "beacon 1" TBTT, instead. This is because we don't know when the
  92. * GO/AP will be in the new channel, so we switch early enough.
  93. */
  94. #define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT 10
  95. /*
  96. * This value (in TUs) is used to fine tune the CSA NoA end time which should
  97. * be just before "beacon 0" TBTT.
  98. */
  99. #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
  100. /*
  101. * Number of beacons to transmit on a new channel until we unblock tx to
  102. * the stations, even if we didn't identify them on a new channel
  103. */
  104. #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
  105. extern const struct ieee80211_ops iwl_mvm_hw_ops;
  106. /**
  107. * struct iwl_mvm_mod_params - module parameters for iwlmvm
  108. * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
  109. * We will register to mac80211 to have testmode working. The NIC must not
  110. * be up'ed after the INIT fw asserted. This is useful to be able to use
  111. * proprietary tools over testmode to debug the INIT fw.
  112. * @power_scheme: CAM(Continuous Active Mode)-1, BPS(Balanced Power
  113. * Save)-2(default), LP(Low Power)-3
  114. */
  115. struct iwl_mvm_mod_params {
  116. bool init_dbg;
  117. int power_scheme;
  118. };
  119. extern struct iwl_mvm_mod_params iwlmvm_mod_params;
  120. /**
  121. * struct iwl_mvm_dump_ptrs - set of pointers needed for the fw-error-dump
  122. *
  123. * @op_mode_ptr: pointer to the buffer coming from the mvm op_mode
  124. * @trans_ptr: pointer to struct %iwl_trans_dump_data which contains the
  125. * transport's data.
  126. * @trans_len: length of the valid data in trans_ptr
  127. * @op_mode_len: length of the valid data in op_mode_ptr
  128. */
  129. struct iwl_mvm_dump_ptrs {
  130. struct iwl_trans_dump_data *trans_ptr;
  131. void *op_mode_ptr;
  132. u32 op_mode_len;
  133. };
  134. struct iwl_mvm_phy_ctxt {
  135. u16 id;
  136. u16 color;
  137. u32 ref;
  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_2
  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_P2P_CLIENT,
  238. IWL_MVM_REF_AP_IBSS,
  239. IWL_MVM_REF_USER,
  240. IWL_MVM_REF_TX,
  241. IWL_MVM_REF_TX_AGG,
  242. IWL_MVM_REF_ADD_IF,
  243. IWL_MVM_REF_START_AP,
  244. IWL_MVM_REF_BSS_CHANGED,
  245. IWL_MVM_REF_PREPARE_TX,
  246. IWL_MVM_REF_PROTECT_TDLS,
  247. IWL_MVM_REF_CHECK_CTKILL,
  248. IWL_MVM_REF_PRPH_READ,
  249. IWL_MVM_REF_PRPH_WRITE,
  250. IWL_MVM_REF_NMI,
  251. IWL_MVM_REF_TM_CMD,
  252. IWL_MVM_REF_EXIT_WORK,
  253. IWL_MVM_REF_PROTECT_CSA,
  254. /* update debugfs.c when changing this */
  255. IWL_MVM_REF_COUNT,
  256. };
  257. enum iwl_bt_force_ant_mode {
  258. BT_FORCE_ANT_DIS = 0,
  259. BT_FORCE_ANT_AUTO,
  260. BT_FORCE_ANT_BT,
  261. BT_FORCE_ANT_WIFI,
  262. BT_FORCE_ANT_MAX,
  263. };
  264. /**
  265. * struct iwl_mvm_vif_bf_data - beacon filtering related data
  266. * @bf_enabled: indicates if beacon filtering is enabled
  267. * @ba_enabled: indicated if beacon abort is enabled
  268. * @ave_beacon_signal: average beacon signal
  269. * @last_cqm_event: rssi of the last cqm event
  270. * @bt_coex_min_thold: minimum threshold for BT coex
  271. * @bt_coex_max_thold: maximum threshold for BT coex
  272. * @last_bt_coex_event: rssi of the last BT coex event
  273. */
  274. struct iwl_mvm_vif_bf_data {
  275. bool bf_enabled;
  276. bool ba_enabled;
  277. s8 ave_beacon_signal;
  278. s8 last_cqm_event;
  279. s8 bt_coex_min_thold;
  280. s8 bt_coex_max_thold;
  281. s8 last_bt_coex_event;
  282. };
  283. /**
  284. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  285. * @id: between 0 and 3
  286. * @color: to solve races upon MAC addition and removal
  287. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  288. * @bssid: BSSID for this (client) interface
  289. * @associated: indicates that we're currently associated, used only for
  290. * managing the firmware state in iwl_mvm_bss_info_changed_station()
  291. * @uploaded: indicates the MAC context has been added to the device
  292. * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
  293. * should get quota etc.
  294. * @pm_enabled - Indicate if MAC power management is allowed
  295. * @monitor_active: indicates that monitor context is configured, and that the
  296. * interface should get quota etc.
  297. * @low_latency: indicates that this interface is in low-latency mode
  298. * (VMACLowLatencyMode)
  299. * @ps_disabled: indicates that this interface requires PS to be disabled
  300. * @queue_params: QoS params for this MAC
  301. * @bcast_sta: station used for broadcast packets. Used by the following
  302. * vifs: P2P_DEVICE, GO and AP.
  303. * @beacon_skb: the skb used to hold the AP/GO beacon template
  304. * @smps_requests: the SMPS requests of differents parts of the driver,
  305. * combined on update to yield the overall request to mac80211.
  306. */
  307. struct iwl_mvm_vif {
  308. u16 id;
  309. u16 color;
  310. u8 ap_sta_id;
  311. u8 bssid[ETH_ALEN];
  312. bool associated;
  313. bool uploaded;
  314. bool ap_ibss_active;
  315. bool pm_enabled;
  316. bool monitor_active;
  317. bool low_latency;
  318. bool ps_disabled;
  319. struct iwl_mvm_vif_bf_data bf_data;
  320. u32 ap_beacon_time;
  321. enum iwl_tsf_id tsf_id;
  322. /*
  323. * QoS data from mac80211, need to store this here
  324. * as mac80211 has a separate callback but we need
  325. * to have the data for the MAC context
  326. */
  327. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  328. struct iwl_mvm_time_event_data time_event_data;
  329. struct iwl_mvm_time_event_data hs_time_event_data;
  330. struct iwl_mvm_int_sta bcast_sta;
  331. /*
  332. * Assigned while mac80211 has the interface in a channel context,
  333. * or, for P2P Device, while it exists.
  334. */
  335. struct iwl_mvm_phy_ctxt *phy_ctxt;
  336. #ifdef CONFIG_PM_SLEEP
  337. /* WoWLAN GTK rekey data */
  338. struct {
  339. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  340. __le64 replay_ctr;
  341. bool valid;
  342. } rekey_data;
  343. int tx_key_idx;
  344. bool seqno_valid;
  345. u16 seqno;
  346. #endif
  347. #if IS_ENABLED(CONFIG_IPV6)
  348. /* IPv6 addresses for WoWLAN */
  349. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  350. int num_target_ipv6_addrs;
  351. #endif
  352. #ifdef CONFIG_IWLWIFI_DEBUGFS
  353. struct iwl_mvm *mvm;
  354. struct dentry *dbgfs_dir;
  355. struct dentry *dbgfs_slink;
  356. struct iwl_dbgfs_pm dbgfs_pm;
  357. struct iwl_dbgfs_bf dbgfs_bf;
  358. struct iwl_mac_power_cmd mac_pwr_cmd;
  359. #endif
  360. enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
  361. /* FW identified misbehaving AP */
  362. u8 uapsd_misbehaving_bssid[ETH_ALEN];
  363. /* Indicates that CSA countdown may be started */
  364. bool csa_countdown;
  365. };
  366. static inline struct iwl_mvm_vif *
  367. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  368. {
  369. return (void *)vif->drv_priv;
  370. }
  371. extern const u8 tid_to_mac80211_ac[];
  372. enum iwl_scan_status {
  373. IWL_MVM_SCAN_NONE,
  374. IWL_MVM_SCAN_OS,
  375. IWL_MVM_SCAN_SCHED,
  376. };
  377. /**
  378. * struct iwl_nvm_section - describes an NVM section in memory.
  379. *
  380. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  381. * and saved for later use by the driver. Not all NVM sections are saved
  382. * this way, only the needed ones.
  383. */
  384. struct iwl_nvm_section {
  385. u16 length;
  386. const u8 *data;
  387. };
  388. /*
  389. * Tx-backoff threshold
  390. * @temperature: The threshold in Celsius
  391. * @backoff: The tx-backoff in uSec
  392. */
  393. struct iwl_tt_tx_backoff {
  394. s32 temperature;
  395. u32 backoff;
  396. };
  397. #define TT_TX_BACKOFF_SIZE 6
  398. /**
  399. * struct iwl_tt_params - thermal throttling parameters
  400. * @ct_kill_entry: CT Kill entry threshold
  401. * @ct_kill_exit: CT Kill exit threshold
  402. * @ct_kill_duration: The time intervals (in uSec) in which the driver needs
  403. * to checks whether to exit CT Kill.
  404. * @dynamic_smps_entry: Dynamic SMPS entry threshold
  405. * @dynamic_smps_exit: Dynamic SMPS exit threshold
  406. * @tx_protection_entry: TX protection entry threshold
  407. * @tx_protection_exit: TX protection exit threshold
  408. * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
  409. * @support_ct_kill: Support CT Kill?
  410. * @support_dynamic_smps: Support dynamic SMPS?
  411. * @support_tx_protection: Support tx protection?
  412. * @support_tx_backoff: Support tx-backoff?
  413. */
  414. struct iwl_tt_params {
  415. s32 ct_kill_entry;
  416. s32 ct_kill_exit;
  417. u32 ct_kill_duration;
  418. s32 dynamic_smps_entry;
  419. s32 dynamic_smps_exit;
  420. s32 tx_protection_entry;
  421. s32 tx_protection_exit;
  422. struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
  423. bool support_ct_kill;
  424. bool support_dynamic_smps;
  425. bool support_tx_protection;
  426. bool support_tx_backoff;
  427. };
  428. /**
  429. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  430. * @ct_kill_exit: worker to exit thermal kill
  431. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  432. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  433. * @min_backoff: The minimal tx backoff due to power restrictions
  434. * @params: Parameters to configure the thermal throttling algorithm.
  435. * @throttle: Is thermal throttling is active?
  436. */
  437. struct iwl_mvm_tt_mgmt {
  438. struct delayed_work ct_kill_exit;
  439. bool dynamic_smps;
  440. u32 tx_backoff;
  441. u32 min_backoff;
  442. const struct iwl_tt_params *params;
  443. bool throttle;
  444. };
  445. #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
  446. struct iwl_mvm_frame_stats {
  447. u32 legacy_frames;
  448. u32 ht_frames;
  449. u32 vht_frames;
  450. u32 bw_20_frames;
  451. u32 bw_40_frames;
  452. u32 bw_80_frames;
  453. u32 bw_160_frames;
  454. u32 sgi_frames;
  455. u32 ngi_frames;
  456. u32 siso_frames;
  457. u32 mimo2_frames;
  458. u32 agg_frames;
  459. u32 ampdu_count;
  460. u32 success_frames;
  461. u32 fail_frames;
  462. u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
  463. int last_frame_idx;
  464. };
  465. enum {
  466. D0I3_DEFER_WAKEUP,
  467. D0I3_PENDING_WAKEUP,
  468. };
  469. #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
  470. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
  471. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
  472. enum iwl_mvm_tdls_cs_state {
  473. IWL_MVM_TDLS_SW_IDLE = 0,
  474. IWL_MVM_TDLS_SW_REQ_SENT,
  475. IWL_MVM_TDLS_SW_REQ_RCVD,
  476. IWL_MVM_TDLS_SW_ACTIVE,
  477. };
  478. struct iwl_mvm {
  479. /* for logger access */
  480. struct device *dev;
  481. struct iwl_trans *trans;
  482. const struct iwl_fw *fw;
  483. const struct iwl_cfg *cfg;
  484. struct iwl_phy_db *phy_db;
  485. struct ieee80211_hw *hw;
  486. /* for protecting access to iwl_mvm */
  487. struct mutex mutex;
  488. struct list_head async_handlers_list;
  489. spinlock_t async_handlers_lock;
  490. struct work_struct async_handlers_wk;
  491. struct work_struct roc_done_wk;
  492. unsigned long status;
  493. /*
  494. * for beacon filtering -
  495. * currently only one interface can be supported
  496. */
  497. struct iwl_mvm_vif *bf_allowed_vif;
  498. enum iwl_ucode_type cur_ucode;
  499. bool ucode_loaded;
  500. bool init_ucode_complete;
  501. bool calibrating;
  502. u32 error_event_table;
  503. u32 log_event_table;
  504. u32 umac_error_event_table;
  505. bool support_umac_log;
  506. struct iwl_sf_region sf_space;
  507. u32 ampdu_ref;
  508. struct iwl_notif_wait_data notif_wait;
  509. struct mvm_statistics_rx rx_stats;
  510. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  511. atomic_t mac80211_queue_stop_count[IEEE80211_MAX_QUEUES];
  512. const char *nvm_file_name;
  513. struct iwl_nvm_data *nvm_data;
  514. /* NVM sections */
  515. struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
  516. /* EEPROM MAC addresses */
  517. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  518. /* data related to data path */
  519. struct iwl_rx_phy_info last_phy_info;
  520. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  521. struct work_struct sta_drained_wk;
  522. unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  523. atomic_t pending_frames[IWL_MVM_STATION_COUNT];
  524. u32 tfd_drained[IWL_MVM_STATION_COUNT];
  525. u8 rx_ba_sessions;
  526. /* configured by mac80211 */
  527. u32 rts_threshold;
  528. /* Scan status, cmd (pre-allocated) and auxiliary station */
  529. enum iwl_scan_status scan_status;
  530. void *scan_cmd;
  531. struct iwl_mcast_filter_cmd *mcast_filter_cmd;
  532. /* UMAC scan tracking */
  533. u32 scan_uid[IWL_MVM_MAX_SIMULTANEOUS_SCANS];
  534. u8 scan_seq_num, sched_scan_seq_num;
  535. /* rx chain antennas set through debugfs for the scan command */
  536. u8 scan_rx_ant;
  537. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  538. /* broadcast filters to configure for each associated station */
  539. const struct iwl_fw_bcast_filter *bcast_filters;
  540. #ifdef CONFIG_IWLWIFI_DEBUGFS
  541. struct {
  542. u32 override; /* u32 for debugfs_create_bool */
  543. struct iwl_bcast_filter_cmd cmd;
  544. } dbgfs_bcast_filtering;
  545. #endif
  546. #endif
  547. /* Internal station */
  548. struct iwl_mvm_int_sta aux_sta;
  549. bool last_ebs_successful;
  550. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  551. u8 mgmt_last_antenna_idx;
  552. /* last smart fifo state that was successfully sent to firmware */
  553. enum iwl_sf_state sf_state;
  554. #ifdef CONFIG_IWLWIFI_DEBUGFS
  555. struct dentry *debugfs_dir;
  556. u32 dbgfs_sram_offset, dbgfs_sram_len;
  557. u32 dbgfs_prph_reg_addr;
  558. bool disable_power_off;
  559. bool disable_power_off_d3;
  560. struct debugfs_blob_wrapper nvm_hw_blob;
  561. struct debugfs_blob_wrapper nvm_sw_blob;
  562. struct debugfs_blob_wrapper nvm_calib_blob;
  563. struct debugfs_blob_wrapper nvm_prod_blob;
  564. struct iwl_mvm_frame_stats drv_rx_stats;
  565. spinlock_t drv_stats_lock;
  566. #endif
  567. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  568. struct list_head time_event_list;
  569. spinlock_t time_event_lock;
  570. /*
  571. * A bitmap indicating the index of the key in use. The firmware
  572. * can hold 16 keys at most. Reflect this fact.
  573. */
  574. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  575. /* references taken by the driver and spinlock protecting them */
  576. spinlock_t refs_lock;
  577. u8 refs[IWL_MVM_REF_COUNT];
  578. u8 vif_count;
  579. /* -1 for always, 0 for never, >0 for that many times */
  580. s8 restart_fw;
  581. struct work_struct fw_error_dump_wk;
  582. enum iwl_fw_dbg_conf fw_dbg_conf;
  583. #ifdef CONFIG_IWLWIFI_LEDS
  584. struct led_classdev led;
  585. #endif
  586. struct ieee80211_vif *p2p_device_vif;
  587. #ifdef CONFIG_PM_SLEEP
  588. struct wiphy_wowlan_support wowlan;
  589. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  590. /* sched scan settings for net detect */
  591. struct cfg80211_sched_scan_request *nd_config;
  592. struct ieee80211_scan_ies nd_ies;
  593. struct cfg80211_match_set *nd_match_sets;
  594. int n_nd_match_sets;
  595. struct ieee80211_channel **nd_channels;
  596. int n_nd_channels;
  597. bool net_detect;
  598. #ifdef CONFIG_IWLWIFI_DEBUGFS
  599. u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */
  600. bool d3_test_active;
  601. bool store_d3_resume_sram;
  602. void *d3_resume_sram;
  603. u32 d3_test_pme_ptr;
  604. struct ieee80211_vif *keep_vif;
  605. #endif
  606. #endif
  607. /* d0i3 */
  608. u8 d0i3_ap_sta_id;
  609. bool d0i3_offloading;
  610. struct work_struct d0i3_exit_work;
  611. struct sk_buff_head d0i3_tx;
  612. /* protect d0i3_suspend_flags */
  613. struct mutex d0i3_suspend_mutex;
  614. unsigned long d0i3_suspend_flags;
  615. /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
  616. spinlock_t d0i3_tx_lock;
  617. wait_queue_head_t d0i3_exit_waitq;
  618. /* BT-Coex */
  619. u8 bt_ack_kill_msk[NUM_PHY_CTX];
  620. u8 bt_cts_kill_msk[NUM_PHY_CTX];
  621. struct iwl_bt_coex_profile_notif_old last_bt_notif_old;
  622. struct iwl_bt_coex_ci_cmd_old last_bt_ci_cmd_old;
  623. struct iwl_bt_coex_profile_notif last_bt_notif;
  624. struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
  625. u32 last_ant_isol;
  626. u8 last_corun_lut;
  627. u8 bt_tx_prio;
  628. enum iwl_bt_force_ant_mode bt_force_ant_mode;
  629. /* Aux ROC */
  630. struct list_head aux_roc_te_list;
  631. /* Thermal Throttling and CTkill */
  632. struct iwl_mvm_tt_mgmt thermal_throttle;
  633. s32 temperature; /* Celsius */
  634. /*
  635. * Debug option to set the NIC temperature. This option makes the
  636. * driver think this is the actual NIC temperature, and ignore the
  637. * real temperature that is received from the fw
  638. */
  639. bool temperature_test; /* Debug test temperature is enabled */
  640. struct iwl_time_quota_cmd last_quota_cmd;
  641. #ifdef CONFIG_NL80211_TESTMODE
  642. u32 noa_duration;
  643. struct ieee80211_vif *noa_vif;
  644. #endif
  645. /* Tx queues */
  646. u8 aux_queue;
  647. u8 first_agg_queue;
  648. u8 last_agg_queue;
  649. /* Indicate if device power save is allowed */
  650. u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
  651. struct ieee80211_vif __rcu *csa_vif;
  652. struct ieee80211_vif __rcu *csa_tx_blocked_vif;
  653. u8 csa_tx_block_bcn_timeout;
  654. /* system time of last beacon (for AP/GO interface) */
  655. u32 ap_last_beacon_gp2;
  656. u8 low_latency_agg_frame_limit;
  657. /* TDLS channel switch data */
  658. struct {
  659. struct delayed_work dwork;
  660. enum iwl_mvm_tdls_cs_state state;
  661. /*
  662. * Current cs sta - might be different from periodic cs peer
  663. * station. Value is meaningless when the cs-state is idle.
  664. */
  665. u8 cur_sta_id;
  666. /* TDLS periodic channel-switch peer */
  667. struct {
  668. u8 sta_id;
  669. u8 op_class;
  670. bool initiator; /* are we the link initiator */
  671. struct cfg80211_chan_def chandef;
  672. struct sk_buff *skb; /* ch sw template */
  673. u32 ch_sw_tm_ie;
  674. } peer;
  675. } tdls_cs;
  676. };
  677. /* Extract MVM priv from op_mode and _hw */
  678. #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
  679. ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
  680. #define IWL_MAC80211_GET_MVM(_hw) \
  681. IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
  682. enum iwl_mvm_status {
  683. IWL_MVM_STATUS_HW_RFKILL,
  684. IWL_MVM_STATUS_HW_CTKILL,
  685. IWL_MVM_STATUS_ROC_RUNNING,
  686. IWL_MVM_STATUS_IN_HW_RESTART,
  687. IWL_MVM_STATUS_IN_D0I3,
  688. IWL_MVM_STATUS_ROC_AUX_RUNNING,
  689. IWL_MVM_STATUS_D3_RECONFIG,
  690. };
  691. static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
  692. {
  693. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
  694. test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
  695. }
  696. /* Must be called with rcu_read_lock() held and it can only be
  697. * released when mvmsta is not needed anymore.
  698. */
  699. static inline struct iwl_mvm_sta *
  700. iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
  701. {
  702. struct ieee80211_sta *sta;
  703. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  704. return NULL;
  705. sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
  706. /* This can happen if the station has been removed right now */
  707. if (IS_ERR_OR_NULL(sta))
  708. return NULL;
  709. return iwl_mvm_sta_from_mac80211(sta);
  710. }
  711. static inline struct iwl_mvm_sta *
  712. iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
  713. {
  714. struct ieee80211_sta *sta;
  715. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  716. return NULL;
  717. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
  718. lockdep_is_held(&mvm->mutex));
  719. /* This can happen if the station has been removed right now */
  720. if (IS_ERR_OR_NULL(sta))
  721. return NULL;
  722. return iwl_mvm_sta_from_mac80211(sta);
  723. }
  724. static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
  725. {
  726. return mvm->trans->cfg->d0i3 &&
  727. (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_D0I3_SUPPORT);
  728. }
  729. static inline bool iwl_mvm_is_dqa_supported(struct iwl_mvm *mvm)
  730. {
  731. return mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_DQA_SUPPORT;
  732. }
  733. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  734. struct iwl_rate_info {
  735. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  736. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  737. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  738. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  739. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  740. };
  741. void __iwl_mvm_mac_stop(struct iwl_mvm *mvm);
  742. int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
  743. /******************
  744. * MVM Methods
  745. ******************/
  746. /* uCode */
  747. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  748. /* Utils */
  749. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  750. enum ieee80211_band band);
  751. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  752. enum ieee80211_band band,
  753. struct ieee80211_tx_rate *r);
  754. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  755. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  756. u8 first_antenna(u8 mask);
  757. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  758. /* Tx / Host Commands */
  759. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  760. struct iwl_host_cmd *cmd);
  761. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u8 id,
  762. u32 flags, u16 len, const void *data);
  763. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  764. struct iwl_host_cmd *cmd,
  765. u32 *status);
  766. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u8 id,
  767. u16 len, const void *data,
  768. u32 *status);
  769. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  770. struct ieee80211_sta *sta);
  771. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  772. void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
  773. struct iwl_tx_cmd *tx_cmd,
  774. struct ieee80211_tx_info *info, u8 sta_id);
  775. void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
  776. struct ieee80211_tx_info *info,
  777. struct iwl_tx_cmd *tx_cmd,
  778. struct sk_buff *skb_frag);
  779. void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm, struct iwl_tx_cmd *tx_cmd,
  780. struct ieee80211_tx_info *info,
  781. struct ieee80211_sta *sta, __le16 fc);
  782. #ifdef CONFIG_IWLWIFI_DEBUG
  783. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  784. #else
  785. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  786. #endif
  787. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync);
  788. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  789. static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
  790. {
  791. flush_work(&mvm->async_handlers_wk);
  792. }
  793. /* Statistics */
  794. int iwl_mvm_rx_reply_statistics(struct iwl_mvm *mvm,
  795. struct iwl_rx_cmd_buffer *rxb,
  796. struct iwl_device_cmd *cmd);
  797. int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  798. struct iwl_rx_cmd_buffer *rxb,
  799. struct iwl_device_cmd *cmd);
  800. /* NVM */
  801. int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic);
  802. int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
  803. int iwl_mvm_up(struct iwl_mvm *mvm);
  804. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  805. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  806. bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
  807. struct iwl_bcast_filter_cmd *cmd);
  808. /*
  809. * FW notifications / CMD responses handlers
  810. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  811. */
  812. int iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  813. struct iwl_device_cmd *cmd);
  814. int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  815. struct iwl_device_cmd *cmd);
  816. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  817. struct iwl_device_cmd *cmd);
  818. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  819. struct iwl_device_cmd *cmd);
  820. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  821. struct iwl_device_cmd *cmd);
  822. int iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
  823. struct iwl_rx_cmd_buffer *rxb,
  824. struct iwl_device_cmd *cmd);
  825. int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  826. struct iwl_device_cmd *cmd);
  827. int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  828. struct iwl_rx_cmd_buffer *rxb,
  829. struct iwl_device_cmd *cmd);
  830. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  831. struct iwl_device_cmd *cmd);
  832. int iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  833. struct iwl_device_cmd *cmd);
  834. /* MVM PHY */
  835. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  836. struct cfg80211_chan_def *chandef,
  837. u8 chains_static, u8 chains_dynamic);
  838. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  839. struct cfg80211_chan_def *chandef,
  840. u8 chains_static, u8 chains_dynamic);
  841. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  842. struct iwl_mvm_phy_ctxt *ctxt);
  843. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  844. struct iwl_mvm_phy_ctxt *ctxt);
  845. int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
  846. u8 iwl_mvm_get_channel_width(struct cfg80211_chan_def *chandef);
  847. u8 iwl_mvm_get_ctrl_pos(struct cfg80211_chan_def *chandef);
  848. /* MAC (virtual interface) programming */
  849. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  850. void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  851. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  852. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  853. bool force_assoc_off, const u8 *bssid_override);
  854. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  855. u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif);
  856. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  857. struct ieee80211_vif *vif);
  858. int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  859. struct iwl_rx_cmd_buffer *rxb,
  860. struct iwl_device_cmd *cmd);
  861. int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  862. struct iwl_rx_cmd_buffer *rxb,
  863. struct iwl_device_cmd *cmd);
  864. void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
  865. struct ieee80211_vif *vif);
  866. unsigned long iwl_mvm_get_used_hw_queues(struct iwl_mvm *mvm,
  867. struct ieee80211_vif *exclude_vif);
  868. /* Bindings */
  869. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  870. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  871. /* Quota management */
  872. int iwl_mvm_update_quotas(struct iwl_mvm *mvm,
  873. struct ieee80211_vif *disabled_vif);
  874. /* Scanning */
  875. int iwl_mvm_scan_size(struct iwl_mvm *mvm);
  876. int iwl_mvm_scan_request(struct iwl_mvm *mvm,
  877. struct ieee80211_vif *vif,
  878. struct cfg80211_scan_request *req);
  879. int iwl_mvm_rx_scan_response(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  880. struct iwl_device_cmd *cmd);
  881. int iwl_mvm_rx_scan_complete(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  882. struct iwl_device_cmd *cmd);
  883. int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
  884. int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan);
  885. /* Scheduled scan */
  886. int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
  887. struct iwl_rx_cmd_buffer *rxb,
  888. struct iwl_device_cmd *cmd);
  889. int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
  890. struct ieee80211_vif *vif,
  891. struct cfg80211_sched_scan_request *req,
  892. struct ieee80211_scan_ies *ies);
  893. int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
  894. struct cfg80211_sched_scan_request *req);
  895. int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
  896. struct cfg80211_sched_scan_request *req);
  897. int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
  898. struct ieee80211_vif *vif,
  899. struct cfg80211_sched_scan_request *req,
  900. struct ieee80211_scan_ies *ies);
  901. int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
  902. int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
  903. struct iwl_rx_cmd_buffer *rxb,
  904. struct iwl_device_cmd *cmd);
  905. /* Unified scan */
  906. int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
  907. struct ieee80211_vif *vif,
  908. struct ieee80211_scan_request *req);
  909. int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
  910. struct ieee80211_vif *vif,
  911. struct cfg80211_sched_scan_request *req,
  912. struct ieee80211_scan_ies *ies);
  913. /* UMAC scan */
  914. int iwl_mvm_config_scan(struct iwl_mvm *mvm);
  915. int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  916. struct ieee80211_scan_request *req);
  917. int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  918. struct cfg80211_sched_scan_request *req,
  919. struct ieee80211_scan_ies *ies);
  920. int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
  921. struct iwl_rx_cmd_buffer *rxb,
  922. struct iwl_device_cmd *cmd);
  923. /* MVM debugfs */
  924. #ifdef CONFIG_IWLWIFI_DEBUGFS
  925. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  926. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  927. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  928. #else
  929. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  930. struct dentry *dbgfs_dir)
  931. {
  932. return 0;
  933. }
  934. static inline void
  935. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  936. {
  937. }
  938. static inline void
  939. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  940. {
  941. }
  942. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  943. /* rate scaling */
  944. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init);
  945. void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm,
  946. struct iwl_mvm_frame_stats *stats,
  947. u32 rate, bool agg);
  948. int rs_pretty_print_rate(char *buf, const u32 rate);
  949. void rs_update_last_rssi(struct iwl_mvm *mvm,
  950. struct iwl_lq_sta *lq_sta,
  951. struct ieee80211_rx_status *rx_status);
  952. /* power management */
  953. int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
  954. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
  955. int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
  956. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  957. char *buf, int bufsz);
  958. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  959. int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  960. struct iwl_rx_cmd_buffer *rxb,
  961. struct iwl_device_cmd *cmd);
  962. #ifdef CONFIG_IWLWIFI_LEDS
  963. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  964. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  965. #else
  966. static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
  967. {
  968. return 0;
  969. }
  970. static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
  971. {
  972. }
  973. #endif
  974. /* D3 (WoWLAN, NetDetect) */
  975. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  976. int iwl_mvm_resume(struct ieee80211_hw *hw);
  977. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  978. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  979. struct ieee80211_vif *vif,
  980. struct cfg80211_gtk_rekey_data *data);
  981. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  982. struct ieee80211_vif *vif,
  983. struct inet6_dev *idev);
  984. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  985. struct ieee80211_vif *vif, int idx);
  986. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  987. #ifdef CONFIG_PM_SLEEP
  988. void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
  989. struct ieee80211_vif *vif);
  990. #else
  991. static inline void
  992. iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  993. {
  994. }
  995. #endif
  996. void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
  997. struct iwl_wowlan_config_cmd *cmd);
  998. int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
  999. struct ieee80211_vif *vif,
  1000. bool disable_offloading,
  1001. u32 cmd_flags);
  1002. /* D0i3 */
  1003. void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1004. void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1005. int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  1006. bool iwl_mvm_ref_taken(struct iwl_mvm *mvm);
  1007. void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
  1008. int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
  1009. /* BT Coex */
  1010. int iwl_send_bt_init_conf(struct iwl_mvm *mvm);
  1011. int iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  1012. struct iwl_rx_cmd_buffer *rxb,
  1013. struct iwl_device_cmd *cmd);
  1014. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1015. enum ieee80211_rssi_event rssi_event);
  1016. void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
  1017. u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
  1018. struct ieee80211_sta *sta);
  1019. bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
  1020. struct ieee80211_sta *sta);
  1021. bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant);
  1022. bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
  1023. bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
  1024. enum ieee80211_band band);
  1025. u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  1026. struct ieee80211_tx_info *info, u8 ac);
  1027. bool iwl_mvm_bt_coex_is_ant_avail_old(struct iwl_mvm *mvm, u8 ant);
  1028. bool iwl_mvm_bt_coex_is_shared_ant_avail_old(struct iwl_mvm *mvm);
  1029. void iwl_mvm_bt_coex_vif_change_old(struct iwl_mvm *mvm);
  1030. int iwl_send_bt_init_conf_old(struct iwl_mvm *mvm);
  1031. int iwl_mvm_rx_bt_coex_notif_old(struct iwl_mvm *mvm,
  1032. struct iwl_rx_cmd_buffer *rxb,
  1033. struct iwl_device_cmd *cmd);
  1034. void iwl_mvm_bt_rssi_event_old(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1035. enum ieee80211_rssi_event rssi_event);
  1036. u16 iwl_mvm_coex_agg_time_limit_old(struct iwl_mvm *mvm,
  1037. struct ieee80211_sta *sta);
  1038. bool iwl_mvm_bt_coex_is_mimo_allowed_old(struct iwl_mvm *mvm,
  1039. struct ieee80211_sta *sta);
  1040. bool iwl_mvm_bt_coex_is_tpc_allowed_old(struct iwl_mvm *mvm,
  1041. enum ieee80211_band band);
  1042. int iwl_mvm_rx_ant_coupling_notif_old(struct iwl_mvm *mvm,
  1043. struct iwl_rx_cmd_buffer *rxb,
  1044. struct iwl_device_cmd *cmd);
  1045. enum iwl_bt_kill_msk {
  1046. BT_KILL_MSK_DEFAULT,
  1047. BT_KILL_MSK_NEVER,
  1048. BT_KILL_MSK_ALWAYS,
  1049. BT_KILL_MSK_MAX,
  1050. };
  1051. extern const u8 iwl_bt_ack_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  1052. extern const u8 iwl_bt_cts_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  1053. extern const u32 iwl_bt_ctl_kill_msk[BT_KILL_MSK_MAX];
  1054. /* beacon filtering */
  1055. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1056. void
  1057. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1058. struct iwl_beacon_filter_cmd *cmd);
  1059. #else
  1060. static inline void
  1061. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  1062. struct iwl_beacon_filter_cmd *cmd)
  1063. {}
  1064. #endif
  1065. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  1066. struct ieee80211_vif *vif,
  1067. bool enable, u32 flags);
  1068. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  1069. struct ieee80211_vif *vif,
  1070. u32 flags);
  1071. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  1072. struct ieee80211_vif *vif,
  1073. u32 flags);
  1074. /* SMPS */
  1075. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1076. enum iwl_mvm_smps_type_request req_type,
  1077. enum ieee80211_smps_mode smps_request);
  1078. bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm);
  1079. /* Low latency */
  1080. int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1081. bool value);
  1082. /* get SystemLowLatencyMode - only needed for beacon threshold? */
  1083. bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
  1084. /* get VMACLowLatencyMode */
  1085. static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
  1086. {
  1087. /*
  1088. * should this consider associated/active/... state?
  1089. *
  1090. * Normally low-latency should only be active on interfaces
  1091. * that are active, but at least with debugfs it can also be
  1092. * enabled on interfaces that aren't active. However, when
  1093. * interface aren't active then they aren't added into the
  1094. * binding, so this has no real impact. For now, just return
  1095. * the current desired low-latency state.
  1096. */
  1097. return mvmvif->low_latency;
  1098. }
  1099. /* hw scheduler queue config */
  1100. void iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, u16 ssn,
  1101. const struct iwl_trans_txq_scd_cfg *cfg);
  1102. void iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue);
  1103. static inline void iwl_mvm_enable_ac_txq(struct iwl_mvm *mvm, int queue,
  1104. u8 fifo)
  1105. {
  1106. struct iwl_trans_txq_scd_cfg cfg = {
  1107. .fifo = fifo,
  1108. .tid = IWL_MAX_TID_COUNT,
  1109. .aggregate = false,
  1110. .frame_limit = IWL_FRAME_LIMIT,
  1111. };
  1112. iwl_mvm_enable_txq(mvm, queue, 0, &cfg);
  1113. }
  1114. static inline void iwl_mvm_enable_agg_txq(struct iwl_mvm *mvm, int queue,
  1115. int fifo, int sta_id, int tid,
  1116. int frame_limit, u16 ssn)
  1117. {
  1118. struct iwl_trans_txq_scd_cfg cfg = {
  1119. .fifo = fifo,
  1120. .sta_id = sta_id,
  1121. .tid = tid,
  1122. .frame_limit = frame_limit,
  1123. .aggregate = true,
  1124. };
  1125. iwl_mvm_enable_txq(mvm, queue, ssn, &cfg);
  1126. }
  1127. /* Assoc status */
  1128. bool iwl_mvm_is_idle(struct iwl_mvm *mvm);
  1129. /* Thermal management and CT-kill */
  1130. void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
  1131. void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp);
  1132. int iwl_mvm_temp_notif(struct iwl_mvm *mvm,
  1133. struct iwl_rx_cmd_buffer *rxb,
  1134. struct iwl_device_cmd *cmd);
  1135. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  1136. void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
  1137. void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
  1138. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  1139. int iwl_mvm_get_temp(struct iwl_mvm *mvm);
  1140. /* smart fifo */
  1141. int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1142. bool added_vif);
  1143. /* TDLS */
  1144. /*
  1145. * We use TID 4 (VI) as a FW-used-only TID when TDLS connections are present.
  1146. * This TID is marked as used vs the AP and all connected TDLS peers.
  1147. */
  1148. #define IWL_MVM_TDLS_FW_TID 4
  1149. int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1150. void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
  1151. void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1152. bool sta_added);
  1153. void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
  1154. struct ieee80211_vif *vif);
  1155. int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
  1156. struct ieee80211_vif *vif,
  1157. struct ieee80211_sta *sta, u8 oper_class,
  1158. struct cfg80211_chan_def *chandef,
  1159. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
  1160. void iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
  1161. struct ieee80211_vif *vif,
  1162. struct ieee80211_tdls_ch_sw_params *params);
  1163. void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
  1164. struct ieee80211_vif *vif,
  1165. struct ieee80211_sta *sta);
  1166. int iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  1167. struct iwl_device_cmd *cmd);
  1168. void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
  1169. struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
  1170. void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
  1171. void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
  1172. #endif /* __IWL_MVM_H__ */