mvm.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  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. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #ifndef __IWL_MVM_H__
  64. #define __IWL_MVM_H__
  65. #include <linux/list.h>
  66. #include <linux/spinlock.h>
  67. #include <linux/leds.h>
  68. #include <linux/in6.h>
  69. #include "iwl-op-mode.h"
  70. #include "iwl-trans.h"
  71. #include "iwl-notif-wait.h"
  72. #include "iwl-eeprom-parse.h"
  73. #include "sta.h"
  74. #include "fw-api.h"
  75. #include "constants.h"
  76. #define IWL_INVALID_MAC80211_QUEUE 0xff
  77. #define IWL_MVM_MAX_ADDRESSES 5
  78. /* RSSI offset for WkP */
  79. #define IWL_RSSI_OFFSET 50
  80. #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
  81. /* A TimeUnit is 1024 microsecond */
  82. #define MSEC_TO_TU(_msec) (_msec*1000/1024)
  83. /*
  84. * The CSA NoA is scheduled IWL_MVM_CHANNEL_SWITCH_TIME TUs before "beacon 0"
  85. * TBTT. This value should be big enough to ensure that we switch in time.
  86. */
  87. #define IWL_MVM_CHANNEL_SWITCH_TIME 40
  88. /*
  89. * This value (in TUs) is used to fine tune the CSA NoA end time which should
  90. * be just before "beacon 0" TBTT.
  91. */
  92. #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
  93. /*
  94. * Number of beacons to transmit on a new channel until we unblock tx to
  95. * the stations, even if we didn't identify them on a new channel
  96. */
  97. #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
  98. enum iwl_mvm_tx_fifo {
  99. IWL_MVM_TX_FIFO_BK = 0,
  100. IWL_MVM_TX_FIFO_BE,
  101. IWL_MVM_TX_FIFO_VI,
  102. IWL_MVM_TX_FIFO_VO,
  103. IWL_MVM_TX_FIFO_MCAST = 5,
  104. };
  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_AC_INFO (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO |\
  172. IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |\
  173. IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |\
  174. IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
  175. #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_2
  176. #ifdef CONFIG_IWLWIFI_DEBUGFS
  177. enum iwl_dbgfs_pm_mask {
  178. MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
  179. MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
  180. MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
  181. MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
  182. MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
  183. MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
  184. MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
  185. MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
  186. MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
  187. MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
  188. };
  189. struct iwl_dbgfs_pm {
  190. u16 keep_alive_seconds;
  191. u32 rx_data_timeout;
  192. u32 tx_data_timeout;
  193. bool skip_over_dtim;
  194. u8 skip_dtim_periods;
  195. bool lprx_ena;
  196. u32 lprx_rssi_threshold;
  197. bool snooze_ena;
  198. bool uapsd_misbehaving;
  199. bool use_ps_poll;
  200. int mask;
  201. };
  202. /* beacon filtering */
  203. enum iwl_dbgfs_bf_mask {
  204. MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
  205. MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
  206. MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
  207. MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
  208. MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
  209. MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
  210. MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
  211. MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
  212. MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
  213. MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
  214. MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
  215. };
  216. struct iwl_dbgfs_bf {
  217. u32 bf_energy_delta;
  218. u32 bf_roaming_energy_delta;
  219. u32 bf_roaming_state;
  220. u32 bf_temp_threshold;
  221. u32 bf_temp_fast_filter;
  222. u32 bf_temp_slow_filter;
  223. u32 bf_enable_beacon_filter;
  224. u32 bf_debug_flag;
  225. u32 bf_escape_timer;
  226. u32 ba_escape_timer;
  227. u32 ba_enable_beacon_abort;
  228. int mask;
  229. };
  230. #endif
  231. enum iwl_mvm_smps_type_request {
  232. IWL_MVM_SMPS_REQ_BT_COEX,
  233. IWL_MVM_SMPS_REQ_TT,
  234. IWL_MVM_SMPS_REQ_PROT,
  235. NUM_IWL_MVM_SMPS_REQ,
  236. };
  237. enum iwl_mvm_ref_type {
  238. IWL_MVM_REF_UCODE_DOWN,
  239. IWL_MVM_REF_SCAN,
  240. IWL_MVM_REF_ROC,
  241. IWL_MVM_REF_P2P_CLIENT,
  242. IWL_MVM_REF_AP_IBSS,
  243. IWL_MVM_REF_USER,
  244. IWL_MVM_REF_TX,
  245. IWL_MVM_REF_TX_AGG,
  246. IWL_MVM_REF_ADD_IF,
  247. IWL_MVM_REF_START_AP,
  248. IWL_MVM_REF_BSS_CHANGED,
  249. IWL_MVM_REF_PREPARE_TX,
  250. IWL_MVM_REF_PROTECT_TDLS,
  251. IWL_MVM_REF_CHECK_CTKILL,
  252. IWL_MVM_REF_PRPH_READ,
  253. IWL_MVM_REF_PRPH_WRITE,
  254. IWL_MVM_REF_NMI,
  255. IWL_MVM_REF_TM_CMD,
  256. IWL_MVM_REF_EXIT_WORK,
  257. IWL_MVM_REF_COUNT,
  258. };
  259. enum iwl_bt_force_ant_mode {
  260. BT_FORCE_ANT_DIS = 0,
  261. BT_FORCE_ANT_AUTO,
  262. BT_FORCE_ANT_BT,
  263. BT_FORCE_ANT_WIFI,
  264. BT_FORCE_ANT_MAX,
  265. };
  266. /**
  267. * struct iwl_mvm_vif_bf_data - beacon filtering related data
  268. * @bf_enabled: indicates if beacon filtering is enabled
  269. * @ba_enabled: indicated if beacon abort is enabled
  270. * @last_beacon_signal: last beacon rssi signal in dbm
  271. * @ave_beacon_signal: average beacon signal
  272. * @last_cqm_event: rssi of the last cqm event
  273. * @bt_coex_min_thold: minimum threshold for BT coex
  274. * @bt_coex_max_thold: maximum threshold for BT coex
  275. * @last_bt_coex_event: rssi of the last BT coex event
  276. */
  277. struct iwl_mvm_vif_bf_data {
  278. bool bf_enabled;
  279. bool ba_enabled;
  280. s8 ave_beacon_signal;
  281. s8 last_cqm_event;
  282. s8 bt_coex_min_thold;
  283. s8 bt_coex_max_thold;
  284. s8 last_bt_coex_event;
  285. };
  286. /**
  287. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  288. * @id: between 0 and 3
  289. * @color: to solve races upon MAC addition and removal
  290. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  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. bool uploaded;
  312. bool ap_ibss_active;
  313. bool pm_enabled;
  314. bool monitor_active;
  315. bool low_latency;
  316. bool ps_disabled;
  317. struct iwl_mvm_vif_bf_data bf_data;
  318. u32 ap_beacon_time;
  319. enum iwl_tsf_id tsf_id;
  320. /*
  321. * QoS data from mac80211, need to store this here
  322. * as mac80211 has a separate callback but we need
  323. * to have the data for the MAC context
  324. */
  325. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  326. struct iwl_mvm_time_event_data time_event_data;
  327. struct iwl_mvm_time_event_data hs_time_event_data;
  328. struct iwl_mvm_int_sta bcast_sta;
  329. /*
  330. * Assigned while mac80211 has the interface in a channel context,
  331. * or, for P2P Device, while it exists.
  332. */
  333. struct iwl_mvm_phy_ctxt *phy_ctxt;
  334. #ifdef CONFIG_PM_SLEEP
  335. /* WoWLAN GTK rekey data */
  336. struct {
  337. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  338. __le64 replay_ctr;
  339. bool valid;
  340. } rekey_data;
  341. int tx_key_idx;
  342. bool seqno_valid;
  343. u16 seqno;
  344. #endif
  345. #if IS_ENABLED(CONFIG_IPV6)
  346. /* IPv6 addresses for WoWLAN */
  347. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  348. int num_target_ipv6_addrs;
  349. #endif
  350. #ifdef CONFIG_IWLWIFI_DEBUGFS
  351. struct iwl_mvm *mvm;
  352. struct dentry *dbgfs_dir;
  353. struct dentry *dbgfs_slink;
  354. struct iwl_dbgfs_pm dbgfs_pm;
  355. struct iwl_dbgfs_bf dbgfs_bf;
  356. struct iwl_mac_power_cmd mac_pwr_cmd;
  357. #endif
  358. enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
  359. /* FW identified misbehaving AP */
  360. u8 uapsd_misbehaving_bssid[ETH_ALEN];
  361. };
  362. static inline struct iwl_mvm_vif *
  363. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  364. {
  365. return (void *)vif->drv_priv;
  366. }
  367. extern const u8 tid_to_mac80211_ac[];
  368. enum iwl_scan_status {
  369. IWL_MVM_SCAN_NONE,
  370. IWL_MVM_SCAN_OS,
  371. IWL_MVM_SCAN_SCHED,
  372. };
  373. /**
  374. * struct iwl_nvm_section - describes an NVM section in memory.
  375. *
  376. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  377. * and saved for later use by the driver. Not all NVM sections are saved
  378. * this way, only the needed ones.
  379. */
  380. struct iwl_nvm_section {
  381. u16 length;
  382. const u8 *data;
  383. };
  384. /*
  385. * Tx-backoff threshold
  386. * @temperature: The threshold in Celsius
  387. * @backoff: The tx-backoff in uSec
  388. */
  389. struct iwl_tt_tx_backoff {
  390. s32 temperature;
  391. u32 backoff;
  392. };
  393. #define TT_TX_BACKOFF_SIZE 6
  394. /**
  395. * struct iwl_tt_params - thermal throttling parameters
  396. * @ct_kill_entry: CT Kill entry threshold
  397. * @ct_kill_exit: CT Kill exit threshold
  398. * @ct_kill_duration: The time intervals (in uSec) in which the driver needs
  399. * to checks whether to exit CT Kill.
  400. * @dynamic_smps_entry: Dynamic SMPS entry threshold
  401. * @dynamic_smps_exit: Dynamic SMPS exit threshold
  402. * @tx_protection_entry: TX protection entry threshold
  403. * @tx_protection_exit: TX protection exit threshold
  404. * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
  405. * @support_ct_kill: Support CT Kill?
  406. * @support_dynamic_smps: Support dynamic SMPS?
  407. * @support_tx_protection: Support tx protection?
  408. * @support_tx_backoff: Support tx-backoff?
  409. */
  410. struct iwl_tt_params {
  411. s32 ct_kill_entry;
  412. s32 ct_kill_exit;
  413. u32 ct_kill_duration;
  414. s32 dynamic_smps_entry;
  415. s32 dynamic_smps_exit;
  416. s32 tx_protection_entry;
  417. s32 tx_protection_exit;
  418. struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
  419. bool support_ct_kill;
  420. bool support_dynamic_smps;
  421. bool support_tx_protection;
  422. bool support_tx_backoff;
  423. };
  424. /**
  425. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  426. * @ct_kill_exit: worker to exit thermal kill
  427. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  428. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  429. * @min_backoff: The minimal tx backoff due to power restrictions
  430. * @params: Parameters to configure the thermal throttling algorithm.
  431. * @throttle: Is thermal throttling is active?
  432. */
  433. struct iwl_mvm_tt_mgmt {
  434. struct delayed_work ct_kill_exit;
  435. bool dynamic_smps;
  436. u32 tx_backoff;
  437. u32 min_backoff;
  438. const struct iwl_tt_params *params;
  439. bool throttle;
  440. };
  441. #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
  442. struct iwl_mvm_frame_stats {
  443. u32 legacy_frames;
  444. u32 ht_frames;
  445. u32 vht_frames;
  446. u32 bw_20_frames;
  447. u32 bw_40_frames;
  448. u32 bw_80_frames;
  449. u32 bw_160_frames;
  450. u32 sgi_frames;
  451. u32 ngi_frames;
  452. u32 siso_frames;
  453. u32 mimo2_frames;
  454. u32 agg_frames;
  455. u32 ampdu_count;
  456. u32 success_frames;
  457. u32 fail_frames;
  458. u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
  459. int last_frame_idx;
  460. };
  461. enum {
  462. D0I3_DEFER_WAKEUP,
  463. D0I3_PENDING_WAKEUP,
  464. };
  465. #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
  466. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
  467. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
  468. struct iwl_mvm {
  469. /* for logger access */
  470. struct device *dev;
  471. struct iwl_trans *trans;
  472. const struct iwl_fw *fw;
  473. const struct iwl_cfg *cfg;
  474. struct iwl_phy_db *phy_db;
  475. struct ieee80211_hw *hw;
  476. /* for protecting access to iwl_mvm */
  477. struct mutex mutex;
  478. struct list_head async_handlers_list;
  479. spinlock_t async_handlers_lock;
  480. struct work_struct async_handlers_wk;
  481. struct work_struct roc_done_wk;
  482. unsigned long status;
  483. /*
  484. * for beacon filtering -
  485. * currently only one interface can be supported
  486. */
  487. struct iwl_mvm_vif *bf_allowed_vif;
  488. enum iwl_ucode_type cur_ucode;
  489. bool ucode_loaded;
  490. bool init_ucode_complete;
  491. u32 error_event_table;
  492. u32 log_event_table;
  493. u32 umac_error_event_table;
  494. bool support_umac_log;
  495. struct iwl_sf_region sf_space;
  496. u32 ampdu_ref;
  497. struct iwl_notif_wait_data notif_wait;
  498. struct mvm_statistics_rx rx_stats;
  499. unsigned long transport_queue_stop;
  500. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  501. atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
  502. const char *nvm_file_name;
  503. struct iwl_nvm_data *nvm_data;
  504. /* NVM sections */
  505. struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
  506. /* EEPROM MAC addresses */
  507. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  508. /* data related to data path */
  509. struct iwl_rx_phy_info last_phy_info;
  510. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  511. struct work_struct sta_drained_wk;
  512. unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  513. atomic_t pending_frames[IWL_MVM_STATION_COUNT];
  514. u8 rx_ba_sessions;
  515. /* configured by mac80211 */
  516. u32 rts_threshold;
  517. /* Scan status, cmd (pre-allocated) and auxiliary station */
  518. enum iwl_scan_status scan_status;
  519. void *scan_cmd;
  520. struct iwl_mcast_filter_cmd *mcast_filter_cmd;
  521. /* rx chain antennas set through debugfs for the scan command */
  522. u8 scan_rx_ant;
  523. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  524. /* broadcast filters to configure for each associated station */
  525. const struct iwl_fw_bcast_filter *bcast_filters;
  526. #ifdef CONFIG_IWLWIFI_DEBUGFS
  527. struct {
  528. u32 override; /* u32 for debugfs_create_bool */
  529. struct iwl_bcast_filter_cmd cmd;
  530. } dbgfs_bcast_filtering;
  531. #endif
  532. #endif
  533. /* Internal station */
  534. struct iwl_mvm_int_sta aux_sta;
  535. bool last_ebs_successful;
  536. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  537. u8 mgmt_last_antenna_idx;
  538. /* last smart fifo state that was successfully sent to firmware */
  539. enum iwl_sf_state sf_state;
  540. #ifdef CONFIG_IWLWIFI_DEBUGFS
  541. struct dentry *debugfs_dir;
  542. u32 dbgfs_sram_offset, dbgfs_sram_len;
  543. u32 dbgfs_prph_reg_addr;
  544. bool disable_power_off;
  545. bool disable_power_off_d3;
  546. struct debugfs_blob_wrapper nvm_hw_blob;
  547. struct debugfs_blob_wrapper nvm_sw_blob;
  548. struct debugfs_blob_wrapper nvm_calib_blob;
  549. struct debugfs_blob_wrapper nvm_prod_blob;
  550. struct iwl_mvm_frame_stats drv_rx_stats;
  551. spinlock_t drv_stats_lock;
  552. #endif
  553. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  554. struct list_head time_event_list;
  555. spinlock_t time_event_lock;
  556. /*
  557. * A bitmap indicating the index of the key in use. The firmware
  558. * can hold 16 keys at most. Reflect this fact.
  559. */
  560. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  561. /* references taken by the driver and spinlock protecting them */
  562. spinlock_t refs_lock;
  563. u8 refs[IWL_MVM_REF_COUNT];
  564. u8 vif_count;
  565. /* -1 for always, 0 for never, >0 for that many times */
  566. s8 restart_fw;
  567. struct iwl_mvm_dump_ptrs *fw_error_dump;
  568. #ifdef CONFIG_IWLWIFI_LEDS
  569. struct led_classdev led;
  570. #endif
  571. struct ieee80211_vif *p2p_device_vif;
  572. #ifdef CONFIG_PM_SLEEP
  573. struct wiphy_wowlan_support wowlan;
  574. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  575. #ifdef CONFIG_IWLWIFI_DEBUGFS
  576. u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */
  577. bool d3_test_active;
  578. bool store_d3_resume_sram;
  579. void *d3_resume_sram;
  580. u32 d3_test_pme_ptr;
  581. struct ieee80211_vif *keep_vif;
  582. #endif
  583. #endif
  584. /* d0i3 */
  585. u8 d0i3_ap_sta_id;
  586. bool d0i3_offloading;
  587. struct work_struct d0i3_exit_work;
  588. struct sk_buff_head d0i3_tx;
  589. /* protect d0i3_suspend_flags */
  590. struct mutex d0i3_suspend_mutex;
  591. unsigned long d0i3_suspend_flags;
  592. /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
  593. spinlock_t d0i3_tx_lock;
  594. wait_queue_head_t d0i3_exit_waitq;
  595. /* BT-Coex */
  596. u8 bt_ack_kill_msk[NUM_PHY_CTX];
  597. u8 bt_cts_kill_msk[NUM_PHY_CTX];
  598. struct iwl_bt_coex_profile_notif_old last_bt_notif_old;
  599. struct iwl_bt_coex_ci_cmd_old last_bt_ci_cmd_old;
  600. struct iwl_bt_coex_profile_notif last_bt_notif;
  601. struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
  602. u32 last_ant_isol;
  603. u8 last_corun_lut;
  604. u8 bt_tx_prio;
  605. enum iwl_bt_force_ant_mode bt_force_ant_mode;
  606. /* Aux ROC */
  607. struct list_head aux_roc_te_list;
  608. /* Thermal Throttling and CTkill */
  609. struct iwl_mvm_tt_mgmt thermal_throttle;
  610. s32 temperature; /* Celsius */
  611. /*
  612. * Debug option to set the NIC temperature. This option makes the
  613. * driver think this is the actual NIC temperature, and ignore the
  614. * real temperature that is received from the fw
  615. */
  616. bool temperature_test; /* Debug test temperature is enabled */
  617. #ifdef CONFIG_NL80211_TESTMODE
  618. u32 noa_duration;
  619. struct ieee80211_vif *noa_vif;
  620. #endif
  621. /* Tx queues */
  622. u8 aux_queue;
  623. u8 first_agg_queue;
  624. u8 last_agg_queue;
  625. /* Indicate if device power save is allowed */
  626. u8 ps_disabled; /* u8 instead of bool to ease debugfs_create_* usage */
  627. struct ieee80211_vif __rcu *csa_vif;
  628. struct ieee80211_vif __rcu *csa_tx_blocked_vif;
  629. u8 csa_tx_block_bcn_timeout;
  630. /* system time of last beacon (for AP/GO interface) */
  631. u32 ap_last_beacon_gp2;
  632. u8 low_latency_agg_frame_limit;
  633. };
  634. /* Extract MVM priv from op_mode and _hw */
  635. #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
  636. ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
  637. #define IWL_MAC80211_GET_MVM(_hw) \
  638. IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
  639. enum iwl_mvm_status {
  640. IWL_MVM_STATUS_HW_RFKILL,
  641. IWL_MVM_STATUS_HW_CTKILL,
  642. IWL_MVM_STATUS_ROC_RUNNING,
  643. IWL_MVM_STATUS_IN_HW_RESTART,
  644. IWL_MVM_STATUS_IN_D0I3,
  645. IWL_MVM_STATUS_ROC_AUX_RUNNING,
  646. };
  647. static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
  648. {
  649. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
  650. test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
  651. }
  652. static inline struct iwl_mvm_sta *
  653. iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
  654. {
  655. struct ieee80211_sta *sta;
  656. if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
  657. return NULL;
  658. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
  659. lockdep_is_held(&mvm->mutex));
  660. /* This can happen if the station has been removed right now */
  661. if (IS_ERR_OR_NULL(sta))
  662. return NULL;
  663. return iwl_mvm_sta_from_mac80211(sta);
  664. }
  665. static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
  666. {
  667. return mvm->trans->cfg->d0i3 &&
  668. (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_D0I3_SUPPORT);
  669. }
  670. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  671. struct iwl_rate_info {
  672. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  673. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  674. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  675. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  676. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  677. };
  678. /******************
  679. * MVM Methods
  680. ******************/
  681. /* uCode */
  682. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  683. /* Utils */
  684. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  685. enum ieee80211_band band);
  686. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  687. enum ieee80211_band band,
  688. struct ieee80211_tx_rate *r);
  689. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  690. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  691. u8 first_antenna(u8 mask);
  692. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  693. /* Tx / Host Commands */
  694. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  695. struct iwl_host_cmd *cmd);
  696. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u8 id,
  697. u32 flags, u16 len, const void *data);
  698. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  699. struct iwl_host_cmd *cmd,
  700. u32 *status);
  701. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u8 id,
  702. u16 len, const void *data,
  703. u32 *status);
  704. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  705. struct ieee80211_sta *sta);
  706. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  707. #ifdef CONFIG_IWLWIFI_DEBUG
  708. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  709. #else
  710. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  711. #endif
  712. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync);
  713. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  714. static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
  715. {
  716. flush_work(&mvm->async_handlers_wk);
  717. }
  718. /* Statistics */
  719. int iwl_mvm_rx_reply_statistics(struct iwl_mvm *mvm,
  720. struct iwl_rx_cmd_buffer *rxb,
  721. struct iwl_device_cmd *cmd);
  722. int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  723. struct iwl_rx_cmd_buffer *rxb,
  724. struct iwl_device_cmd *cmd);
  725. /* NVM */
  726. int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic);
  727. int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
  728. int iwl_mvm_up(struct iwl_mvm *mvm);
  729. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  730. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  731. bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
  732. struct iwl_bcast_filter_cmd *cmd);
  733. /*
  734. * FW notifications / CMD responses handlers
  735. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  736. */
  737. int iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  738. struct iwl_device_cmd *cmd);
  739. int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  740. struct iwl_device_cmd *cmd);
  741. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  742. struct iwl_device_cmd *cmd);
  743. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  744. struct iwl_device_cmd *cmd);
  745. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  746. struct iwl_device_cmd *cmd);
  747. int iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
  748. struct iwl_rx_cmd_buffer *rxb,
  749. struct iwl_device_cmd *cmd);
  750. int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  751. struct iwl_device_cmd *cmd);
  752. int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  753. struct iwl_rx_cmd_buffer *rxb,
  754. struct iwl_device_cmd *cmd);
  755. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  756. struct iwl_device_cmd *cmd);
  757. /* MVM PHY */
  758. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  759. struct cfg80211_chan_def *chandef,
  760. u8 chains_static, u8 chains_dynamic);
  761. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  762. struct cfg80211_chan_def *chandef,
  763. u8 chains_static, u8 chains_dynamic);
  764. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  765. struct iwl_mvm_phy_ctxt *ctxt);
  766. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  767. struct iwl_mvm_phy_ctxt *ctxt);
  768. int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
  769. /* MAC (virtual interface) programming */
  770. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  771. void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  772. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  773. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  774. bool force_assoc_off);
  775. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  776. u32 iwl_mvm_mac_get_queues_mask(struct iwl_mvm *mvm,
  777. struct ieee80211_vif *vif);
  778. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  779. struct ieee80211_vif *vif);
  780. int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  781. struct iwl_rx_cmd_buffer *rxb,
  782. struct iwl_device_cmd *cmd);
  783. int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  784. struct iwl_rx_cmd_buffer *rxb,
  785. struct iwl_device_cmd *cmd);
  786. void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
  787. struct ieee80211_vif *vif);
  788. /* Bindings */
  789. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  790. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  791. /* Quota management */
  792. int iwl_mvm_update_quotas(struct iwl_mvm *mvm,
  793. struct ieee80211_vif *disabled_vif);
  794. /* Scanning */
  795. int iwl_mvm_scan_request(struct iwl_mvm *mvm,
  796. struct ieee80211_vif *vif,
  797. struct cfg80211_scan_request *req);
  798. int iwl_mvm_rx_scan_response(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  799. struct iwl_device_cmd *cmd);
  800. int iwl_mvm_rx_scan_complete(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  801. struct iwl_device_cmd *cmd);
  802. int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
  803. /* Scheduled scan */
  804. int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
  805. struct iwl_rx_cmd_buffer *rxb,
  806. struct iwl_device_cmd *cmd);
  807. int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
  808. struct ieee80211_vif *vif,
  809. struct cfg80211_sched_scan_request *req,
  810. struct ieee80211_scan_ies *ies);
  811. int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
  812. struct cfg80211_sched_scan_request *req);
  813. int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
  814. struct cfg80211_sched_scan_request *req);
  815. int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
  816. int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
  817. struct iwl_rx_cmd_buffer *rxb,
  818. struct iwl_device_cmd *cmd);
  819. /* Unified scan */
  820. int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
  821. struct ieee80211_vif *vif,
  822. struct ieee80211_scan_request *req);
  823. int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
  824. struct ieee80211_vif *vif,
  825. struct cfg80211_sched_scan_request *req,
  826. struct ieee80211_scan_ies *ies);
  827. /* MVM debugfs */
  828. #ifdef CONFIG_IWLWIFI_DEBUGFS
  829. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  830. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  831. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  832. #else
  833. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  834. struct dentry *dbgfs_dir)
  835. {
  836. return 0;
  837. }
  838. static inline void
  839. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  840. {
  841. }
  842. static inline void
  843. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  844. {
  845. }
  846. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  847. /* rate scaling */
  848. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init);
  849. void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm,
  850. struct iwl_mvm_frame_stats *stats,
  851. u32 rate, bool agg);
  852. int rs_pretty_print_rate(char *buf, const u32 rate);
  853. /* power management */
  854. int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
  855. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
  856. int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
  857. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  858. char *buf, int bufsz);
  859. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  860. int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  861. struct iwl_rx_cmd_buffer *rxb,
  862. struct iwl_device_cmd *cmd);
  863. #ifdef CONFIG_IWLWIFI_LEDS
  864. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  865. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  866. #else
  867. static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
  868. {
  869. return 0;
  870. }
  871. static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
  872. {
  873. }
  874. #endif
  875. /* D3 (WoWLAN, NetDetect) */
  876. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  877. int iwl_mvm_resume(struct ieee80211_hw *hw);
  878. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  879. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  880. struct ieee80211_vif *vif,
  881. struct cfg80211_gtk_rekey_data *data);
  882. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  883. struct ieee80211_vif *vif,
  884. struct inet6_dev *idev);
  885. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  886. struct ieee80211_vif *vif, int idx);
  887. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  888. #ifdef CONFIG_PM_SLEEP
  889. void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
  890. struct ieee80211_vif *vif);
  891. #else
  892. static inline void
  893. iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  894. {
  895. }
  896. #endif
  897. void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
  898. struct iwl_wowlan_config_cmd_v2 *cmd);
  899. int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
  900. struct ieee80211_vif *vif,
  901. bool disable_offloading,
  902. u32 cmd_flags);
  903. /* D0i3 */
  904. void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  905. void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  906. int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  907. void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
  908. int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
  909. /* BT Coex */
  910. int iwl_send_bt_init_conf(struct iwl_mvm *mvm);
  911. int iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  912. struct iwl_rx_cmd_buffer *rxb,
  913. struct iwl_device_cmd *cmd);
  914. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  915. enum ieee80211_rssi_event rssi_event);
  916. void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
  917. u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
  918. struct ieee80211_sta *sta);
  919. bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
  920. struct ieee80211_sta *sta);
  921. bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
  922. bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
  923. enum ieee80211_band band);
  924. u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  925. struct ieee80211_tx_info *info, u8 ac);
  926. bool iwl_mvm_bt_coex_is_shared_ant_avail_old(struct iwl_mvm *mvm);
  927. void iwl_mvm_bt_coex_vif_change_old(struct iwl_mvm *mvm);
  928. int iwl_send_bt_init_conf_old(struct iwl_mvm *mvm);
  929. int iwl_mvm_rx_bt_coex_notif_old(struct iwl_mvm *mvm,
  930. struct iwl_rx_cmd_buffer *rxb,
  931. struct iwl_device_cmd *cmd);
  932. void iwl_mvm_bt_rssi_event_old(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  933. enum ieee80211_rssi_event rssi_event);
  934. u16 iwl_mvm_coex_agg_time_limit_old(struct iwl_mvm *mvm,
  935. struct ieee80211_sta *sta);
  936. bool iwl_mvm_bt_coex_is_mimo_allowed_old(struct iwl_mvm *mvm,
  937. struct ieee80211_sta *sta);
  938. bool iwl_mvm_bt_coex_is_tpc_allowed_old(struct iwl_mvm *mvm,
  939. enum ieee80211_band band);
  940. int iwl_mvm_rx_ant_coupling_notif_old(struct iwl_mvm *mvm,
  941. struct iwl_rx_cmd_buffer *rxb,
  942. struct iwl_device_cmd *cmd);
  943. enum iwl_bt_kill_msk {
  944. BT_KILL_MSK_DEFAULT,
  945. BT_KILL_MSK_NEVER,
  946. BT_KILL_MSK_ALWAYS,
  947. BT_KILL_MSK_MAX,
  948. };
  949. extern const u8 iwl_bt_ack_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  950. extern const u8 iwl_bt_cts_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  951. extern const u32 iwl_bt_ctl_kill_msk[BT_KILL_MSK_MAX];
  952. /* beacon filtering */
  953. #ifdef CONFIG_IWLWIFI_DEBUGFS
  954. void
  955. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  956. struct iwl_beacon_filter_cmd *cmd);
  957. #else
  958. static inline void
  959. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  960. struct iwl_beacon_filter_cmd *cmd)
  961. {}
  962. #endif
  963. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  964. struct ieee80211_vif *vif,
  965. bool enable, u32 flags);
  966. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  967. struct ieee80211_vif *vif,
  968. u32 flags);
  969. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  970. struct ieee80211_vif *vif,
  971. u32 flags);
  972. /* SMPS */
  973. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  974. enum iwl_mvm_smps_type_request req_type,
  975. enum ieee80211_smps_mode smps_request);
  976. bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm);
  977. /* Low latency */
  978. int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  979. bool value);
  980. /* get SystemLowLatencyMode - only needed for beacon threshold? */
  981. bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
  982. /* get VMACLowLatencyMode */
  983. static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
  984. {
  985. /*
  986. * should this consider associated/active/... state?
  987. *
  988. * Normally low-latency should only be active on interfaces
  989. * that are active, but at least with debugfs it can also be
  990. * enabled on interfaces that aren't active. However, when
  991. * interface aren't active then they aren't added into the
  992. * binding, so this has no real impact. For now, just return
  993. * the current desired low-latency state.
  994. */
  995. return mvmvif->low_latency;
  996. }
  997. /* Assoc status */
  998. bool iwl_mvm_is_idle(struct iwl_mvm *mvm);
  999. /* Thermal management and CT-kill */
  1000. void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
  1001. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  1002. void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
  1003. void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
  1004. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  1005. /* smart fifo */
  1006. int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1007. bool added_vif);
  1008. /* TDLS */
  1009. int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1010. void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
  1011. #endif /* __IWL_MVM_H__ */