mvm.h 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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. /* This value represents the number of TUs before CSA "beacon 0" TBTT
  86. * when the CSA time-event needs to be scheduled to start. It must be
  87. * big enough to ensure that we switch in time.
  88. */
  89. #define IWL_MVM_CHANNEL_SWITCH_TIME_GO 40
  90. /*
  91. * This value (in TUs) is used to fine tune the CSA NoA end time which should
  92. * be just before "beacon 0" TBTT.
  93. */
  94. #define IWL_MVM_CHANNEL_SWITCH_MARGIN 4
  95. /*
  96. * Number of beacons to transmit on a new channel until we unblock tx to
  97. * the stations, even if we didn't identify them on a new channel
  98. */
  99. #define IWL_MVM_CS_UNBLOCK_TX_TIMEOUT 3
  100. extern const struct ieee80211_ops iwl_mvm_hw_ops;
  101. /**
  102. * struct iwl_mvm_mod_params - module parameters for iwlmvm
  103. * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
  104. * We will register to mac80211 to have testmode working. The NIC must not
  105. * be up'ed after the INIT fw asserted. This is useful to be able to use
  106. * proprietary tools over testmode to debug the INIT fw.
  107. * @power_scheme: CAM(Continuous Active Mode)-1, BPS(Balanced Power
  108. * Save)-2(default), LP(Low Power)-3
  109. */
  110. struct iwl_mvm_mod_params {
  111. bool init_dbg;
  112. int power_scheme;
  113. };
  114. extern struct iwl_mvm_mod_params iwlmvm_mod_params;
  115. /**
  116. * struct iwl_mvm_dump_ptrs - set of pointers needed for the fw-error-dump
  117. *
  118. * @op_mode_ptr: pointer to the buffer coming from the mvm op_mode
  119. * @trans_ptr: pointer to struct %iwl_trans_dump_data which contains the
  120. * transport's data.
  121. * @trans_len: length of the valid data in trans_ptr
  122. * @op_mode_len: length of the valid data in op_mode_ptr
  123. */
  124. struct iwl_mvm_dump_ptrs {
  125. struct iwl_trans_dump_data *trans_ptr;
  126. void *op_mode_ptr;
  127. u32 op_mode_len;
  128. };
  129. struct iwl_mvm_phy_ctxt {
  130. u16 id;
  131. u16 color;
  132. u32 ref;
  133. /*
  134. * TODO: This should probably be removed. Currently here only for rate
  135. * scaling algorithm
  136. */
  137. struct ieee80211_channel *channel;
  138. };
  139. struct iwl_mvm_time_event_data {
  140. struct ieee80211_vif *vif;
  141. struct list_head list;
  142. unsigned long end_jiffies;
  143. u32 duration;
  144. bool running;
  145. u32 uid;
  146. /*
  147. * The access to the 'id' field must be done when the
  148. * mvm->time_event_lock is held, as it value is used to indicate
  149. * if the te is in the time event list or not (when id == TE_MAX)
  150. */
  151. u32 id;
  152. };
  153. /* Power management */
  154. /**
  155. * enum iwl_power_scheme
  156. * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
  157. * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
  158. * @IWL_POWER_LEVEL_LP - Low Power
  159. */
  160. enum iwl_power_scheme {
  161. IWL_POWER_SCHEME_CAM = 1,
  162. IWL_POWER_SCHEME_BPS,
  163. IWL_POWER_SCHEME_LP
  164. };
  165. #define IWL_CONN_MAX_LISTEN_INTERVAL 10
  166. #define IWL_UAPSD_MAX_SP IEEE80211_WMM_IE_STA_QOSINFO_SP_2
  167. #ifdef CONFIG_IWLWIFI_DEBUGFS
  168. enum iwl_dbgfs_pm_mask {
  169. MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
  170. MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
  171. MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
  172. MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
  173. MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
  174. MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
  175. MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
  176. MVM_DEBUGFS_PM_SNOOZE_ENABLE = BIT(8),
  177. MVM_DEBUGFS_PM_UAPSD_MISBEHAVING = BIT(9),
  178. MVM_DEBUGFS_PM_USE_PS_POLL = BIT(10),
  179. };
  180. struct iwl_dbgfs_pm {
  181. u16 keep_alive_seconds;
  182. u32 rx_data_timeout;
  183. u32 tx_data_timeout;
  184. bool skip_over_dtim;
  185. u8 skip_dtim_periods;
  186. bool lprx_ena;
  187. u32 lprx_rssi_threshold;
  188. bool snooze_ena;
  189. bool uapsd_misbehaving;
  190. bool use_ps_poll;
  191. int mask;
  192. };
  193. /* beacon filtering */
  194. enum iwl_dbgfs_bf_mask {
  195. MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
  196. MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
  197. MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
  198. MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
  199. MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
  200. MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
  201. MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
  202. MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
  203. MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
  204. MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
  205. MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
  206. };
  207. struct iwl_dbgfs_bf {
  208. u32 bf_energy_delta;
  209. u32 bf_roaming_energy_delta;
  210. u32 bf_roaming_state;
  211. u32 bf_temp_threshold;
  212. u32 bf_temp_fast_filter;
  213. u32 bf_temp_slow_filter;
  214. u32 bf_enable_beacon_filter;
  215. u32 bf_debug_flag;
  216. u32 bf_escape_timer;
  217. u32 ba_escape_timer;
  218. u32 ba_enable_beacon_abort;
  219. int mask;
  220. };
  221. #endif
  222. enum iwl_mvm_smps_type_request {
  223. IWL_MVM_SMPS_REQ_BT_COEX,
  224. IWL_MVM_SMPS_REQ_TT,
  225. IWL_MVM_SMPS_REQ_PROT,
  226. NUM_IWL_MVM_SMPS_REQ,
  227. };
  228. enum iwl_mvm_ref_type {
  229. IWL_MVM_REF_UCODE_DOWN,
  230. IWL_MVM_REF_SCAN,
  231. IWL_MVM_REF_ROC,
  232. IWL_MVM_REF_P2P_CLIENT,
  233. IWL_MVM_REF_AP_IBSS,
  234. IWL_MVM_REF_USER,
  235. IWL_MVM_REF_TX,
  236. IWL_MVM_REF_TX_AGG,
  237. IWL_MVM_REF_ADD_IF,
  238. IWL_MVM_REF_START_AP,
  239. IWL_MVM_REF_BSS_CHANGED,
  240. IWL_MVM_REF_PREPARE_TX,
  241. IWL_MVM_REF_PROTECT_TDLS,
  242. IWL_MVM_REF_CHECK_CTKILL,
  243. IWL_MVM_REF_PRPH_READ,
  244. IWL_MVM_REF_PRPH_WRITE,
  245. IWL_MVM_REF_NMI,
  246. IWL_MVM_REF_TM_CMD,
  247. IWL_MVM_REF_EXIT_WORK,
  248. /* update debugfs.c when changing this */
  249. IWL_MVM_REF_COUNT,
  250. };
  251. enum iwl_bt_force_ant_mode {
  252. BT_FORCE_ANT_DIS = 0,
  253. BT_FORCE_ANT_AUTO,
  254. BT_FORCE_ANT_BT,
  255. BT_FORCE_ANT_WIFI,
  256. BT_FORCE_ANT_MAX,
  257. };
  258. /**
  259. * struct iwl_mvm_vif_bf_data - beacon filtering related data
  260. * @bf_enabled: indicates if beacon filtering is enabled
  261. * @ba_enabled: indicated if beacon abort is enabled
  262. * @last_beacon_signal: last beacon rssi signal in dbm
  263. * @ave_beacon_signal: average beacon signal
  264. * @last_cqm_event: rssi of the last cqm event
  265. * @bt_coex_min_thold: minimum threshold for BT coex
  266. * @bt_coex_max_thold: maximum threshold for BT coex
  267. * @last_bt_coex_event: rssi of the last BT coex event
  268. */
  269. struct iwl_mvm_vif_bf_data {
  270. bool bf_enabled;
  271. bool ba_enabled;
  272. s8 ave_beacon_signal;
  273. s8 last_cqm_event;
  274. s8 bt_coex_min_thold;
  275. s8 bt_coex_max_thold;
  276. s8 last_bt_coex_event;
  277. };
  278. /**
  279. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  280. * @id: between 0 and 3
  281. * @color: to solve races upon MAC addition and removal
  282. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  283. * @bssid: BSSID for this (client) interface
  284. * @associated: indicates that we're currently associated, used only for
  285. * managing the firmware state in iwl_mvm_bss_info_changed_station()
  286. * @uploaded: indicates the MAC context has been added to the device
  287. * @ap_ibss_active: indicates that AP/IBSS is configured and that the interface
  288. * should get quota etc.
  289. * @pm_enabled - Indicate if MAC power management is allowed
  290. * @monitor_active: indicates that monitor context is configured, and that the
  291. * interface should get quota etc.
  292. * @low_latency: indicates that this interface is in low-latency mode
  293. * (VMACLowLatencyMode)
  294. * @ps_disabled: indicates that this interface requires PS to be disabled
  295. * @queue_params: QoS params for this MAC
  296. * @bcast_sta: station used for broadcast packets. Used by the following
  297. * vifs: P2P_DEVICE, GO and AP.
  298. * @beacon_skb: the skb used to hold the AP/GO beacon template
  299. * @smps_requests: the SMPS requests of differents parts of the driver,
  300. * combined on update to yield the overall request to mac80211.
  301. */
  302. struct iwl_mvm_vif {
  303. u16 id;
  304. u16 color;
  305. u8 ap_sta_id;
  306. u8 bssid[ETH_ALEN];
  307. bool associated;
  308. bool uploaded;
  309. bool ap_ibss_active;
  310. bool pm_enabled;
  311. bool monitor_active;
  312. bool low_latency;
  313. bool ps_disabled;
  314. struct iwl_mvm_vif_bf_data bf_data;
  315. u32 ap_beacon_time;
  316. enum iwl_tsf_id tsf_id;
  317. /*
  318. * QoS data from mac80211, need to store this here
  319. * as mac80211 has a separate callback but we need
  320. * to have the data for the MAC context
  321. */
  322. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  323. struct iwl_mvm_time_event_data time_event_data;
  324. struct iwl_mvm_time_event_data hs_time_event_data;
  325. struct iwl_mvm_int_sta bcast_sta;
  326. /*
  327. * Assigned while mac80211 has the interface in a channel context,
  328. * or, for P2P Device, while it exists.
  329. */
  330. struct iwl_mvm_phy_ctxt *phy_ctxt;
  331. #ifdef CONFIG_PM_SLEEP
  332. /* WoWLAN GTK rekey data */
  333. struct {
  334. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  335. __le64 replay_ctr;
  336. bool valid;
  337. } rekey_data;
  338. int tx_key_idx;
  339. bool seqno_valid;
  340. u16 seqno;
  341. #endif
  342. #if IS_ENABLED(CONFIG_IPV6)
  343. /* IPv6 addresses for WoWLAN */
  344. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  345. int num_target_ipv6_addrs;
  346. #endif
  347. #ifdef CONFIG_IWLWIFI_DEBUGFS
  348. struct iwl_mvm *mvm;
  349. struct dentry *dbgfs_dir;
  350. struct dentry *dbgfs_slink;
  351. struct iwl_dbgfs_pm dbgfs_pm;
  352. struct iwl_dbgfs_bf dbgfs_bf;
  353. struct iwl_mac_power_cmd mac_pwr_cmd;
  354. #endif
  355. enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
  356. /* FW identified misbehaving AP */
  357. u8 uapsd_misbehaving_bssid[ETH_ALEN];
  358. };
  359. static inline struct iwl_mvm_vif *
  360. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  361. {
  362. return (void *)vif->drv_priv;
  363. }
  364. extern const u8 tid_to_mac80211_ac[];
  365. enum iwl_scan_status {
  366. IWL_MVM_SCAN_NONE,
  367. IWL_MVM_SCAN_OS,
  368. IWL_MVM_SCAN_SCHED,
  369. };
  370. /**
  371. * struct iwl_nvm_section - describes an NVM section in memory.
  372. *
  373. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  374. * and saved for later use by the driver. Not all NVM sections are saved
  375. * this way, only the needed ones.
  376. */
  377. struct iwl_nvm_section {
  378. u16 length;
  379. const u8 *data;
  380. };
  381. /*
  382. * Tx-backoff threshold
  383. * @temperature: The threshold in Celsius
  384. * @backoff: The tx-backoff in uSec
  385. */
  386. struct iwl_tt_tx_backoff {
  387. s32 temperature;
  388. u32 backoff;
  389. };
  390. #define TT_TX_BACKOFF_SIZE 6
  391. /**
  392. * struct iwl_tt_params - thermal throttling parameters
  393. * @ct_kill_entry: CT Kill entry threshold
  394. * @ct_kill_exit: CT Kill exit threshold
  395. * @ct_kill_duration: The time intervals (in uSec) in which the driver needs
  396. * to checks whether to exit CT Kill.
  397. * @dynamic_smps_entry: Dynamic SMPS entry threshold
  398. * @dynamic_smps_exit: Dynamic SMPS exit threshold
  399. * @tx_protection_entry: TX protection entry threshold
  400. * @tx_protection_exit: TX protection exit threshold
  401. * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
  402. * @support_ct_kill: Support CT Kill?
  403. * @support_dynamic_smps: Support dynamic SMPS?
  404. * @support_tx_protection: Support tx protection?
  405. * @support_tx_backoff: Support tx-backoff?
  406. */
  407. struct iwl_tt_params {
  408. s32 ct_kill_entry;
  409. s32 ct_kill_exit;
  410. u32 ct_kill_duration;
  411. s32 dynamic_smps_entry;
  412. s32 dynamic_smps_exit;
  413. s32 tx_protection_entry;
  414. s32 tx_protection_exit;
  415. struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
  416. bool support_ct_kill;
  417. bool support_dynamic_smps;
  418. bool support_tx_protection;
  419. bool support_tx_backoff;
  420. };
  421. /**
  422. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  423. * @ct_kill_exit: worker to exit thermal kill
  424. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  425. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  426. * @min_backoff: The minimal tx backoff due to power restrictions
  427. * @params: Parameters to configure the thermal throttling algorithm.
  428. * @throttle: Is thermal throttling is active?
  429. */
  430. struct iwl_mvm_tt_mgmt {
  431. struct delayed_work ct_kill_exit;
  432. bool dynamic_smps;
  433. u32 tx_backoff;
  434. u32 min_backoff;
  435. const struct iwl_tt_params *params;
  436. bool throttle;
  437. };
  438. #define IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES 8
  439. struct iwl_mvm_frame_stats {
  440. u32 legacy_frames;
  441. u32 ht_frames;
  442. u32 vht_frames;
  443. u32 bw_20_frames;
  444. u32 bw_40_frames;
  445. u32 bw_80_frames;
  446. u32 bw_160_frames;
  447. u32 sgi_frames;
  448. u32 ngi_frames;
  449. u32 siso_frames;
  450. u32 mimo2_frames;
  451. u32 agg_frames;
  452. u32 ampdu_count;
  453. u32 success_frames;
  454. u32 fail_frames;
  455. u32 last_rates[IWL_MVM_NUM_LAST_FRAMES_UCODE_RATES];
  456. int last_frame_idx;
  457. };
  458. enum {
  459. D0I3_DEFER_WAKEUP,
  460. D0I3_PENDING_WAKEUP,
  461. };
  462. #define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
  463. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
  464. #define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
  465. struct iwl_mvm {
  466. /* for logger access */
  467. struct device *dev;
  468. struct iwl_trans *trans;
  469. const struct iwl_fw *fw;
  470. const struct iwl_cfg *cfg;
  471. struct iwl_phy_db *phy_db;
  472. struct ieee80211_hw *hw;
  473. /* for protecting access to iwl_mvm */
  474. struct mutex mutex;
  475. struct list_head async_handlers_list;
  476. spinlock_t async_handlers_lock;
  477. struct work_struct async_handlers_wk;
  478. struct work_struct roc_done_wk;
  479. unsigned long status;
  480. /*
  481. * for beacon filtering -
  482. * currently only one interface can be supported
  483. */
  484. struct iwl_mvm_vif *bf_allowed_vif;
  485. enum iwl_ucode_type cur_ucode;
  486. bool ucode_loaded;
  487. bool init_ucode_complete;
  488. u32 error_event_table;
  489. u32 log_event_table;
  490. u32 umac_error_event_table;
  491. bool support_umac_log;
  492. struct iwl_sf_region sf_space;
  493. u32 ampdu_ref;
  494. struct iwl_notif_wait_data notif_wait;
  495. struct mvm_statistics_rx rx_stats;
  496. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  497. atomic_t mac80211_queue_stop_count[IEEE80211_MAX_QUEUES];
  498. const char *nvm_file_name;
  499. struct iwl_nvm_data *nvm_data;
  500. /* NVM sections */
  501. struct iwl_nvm_section nvm_sections[NVM_MAX_NUM_SECTIONS];
  502. /* EEPROM MAC addresses */
  503. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  504. /* data related to data path */
  505. struct iwl_rx_phy_info last_phy_info;
  506. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  507. struct work_struct sta_drained_wk;
  508. unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  509. atomic_t pending_frames[IWL_MVM_STATION_COUNT];
  510. u8 rx_ba_sessions;
  511. /* configured by mac80211 */
  512. u32 rts_threshold;
  513. /* Scan status, cmd (pre-allocated) and auxiliary station */
  514. enum iwl_scan_status scan_status;
  515. void *scan_cmd;
  516. struct iwl_mcast_filter_cmd *mcast_filter_cmd;
  517. /* rx chain antennas set through debugfs for the scan command */
  518. u8 scan_rx_ant;
  519. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  520. /* broadcast filters to configure for each associated station */
  521. const struct iwl_fw_bcast_filter *bcast_filters;
  522. #ifdef CONFIG_IWLWIFI_DEBUGFS
  523. struct {
  524. u32 override; /* u32 for debugfs_create_bool */
  525. struct iwl_bcast_filter_cmd cmd;
  526. } dbgfs_bcast_filtering;
  527. #endif
  528. #endif
  529. /* Internal station */
  530. struct iwl_mvm_int_sta aux_sta;
  531. bool last_ebs_successful;
  532. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  533. u8 mgmt_last_antenna_idx;
  534. /* last smart fifo state that was successfully sent to firmware */
  535. enum iwl_sf_state sf_state;
  536. #ifdef CONFIG_IWLWIFI_DEBUGFS
  537. struct dentry *debugfs_dir;
  538. u32 dbgfs_sram_offset, dbgfs_sram_len;
  539. u32 dbgfs_prph_reg_addr;
  540. bool disable_power_off;
  541. bool disable_power_off_d3;
  542. struct debugfs_blob_wrapper nvm_hw_blob;
  543. struct debugfs_blob_wrapper nvm_sw_blob;
  544. struct debugfs_blob_wrapper nvm_calib_blob;
  545. struct debugfs_blob_wrapper nvm_prod_blob;
  546. struct iwl_mvm_frame_stats drv_rx_stats;
  547. spinlock_t drv_stats_lock;
  548. #endif
  549. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  550. struct list_head time_event_list;
  551. spinlock_t time_event_lock;
  552. /*
  553. * A bitmap indicating the index of the key in use. The firmware
  554. * can hold 16 keys at most. Reflect this fact.
  555. */
  556. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  557. /* references taken by the driver and spinlock protecting them */
  558. spinlock_t refs_lock;
  559. u8 refs[IWL_MVM_REF_COUNT];
  560. u8 vif_count;
  561. /* -1 for always, 0 for never, >0 for that many times */
  562. s8 restart_fw;
  563. struct work_struct fw_error_dump_wk;
  564. #ifdef CONFIG_IWLWIFI_LEDS
  565. struct led_classdev led;
  566. #endif
  567. struct ieee80211_vif *p2p_device_vif;
  568. #ifdef CONFIG_PM_SLEEP
  569. struct wiphy_wowlan_support wowlan;
  570. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  571. /* sched scan settings for net detect */
  572. struct cfg80211_sched_scan_request *nd_config;
  573. struct ieee80211_scan_ies *nd_ies;
  574. #ifdef CONFIG_IWLWIFI_DEBUGFS
  575. u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */
  576. bool d3_test_active;
  577. bool store_d3_resume_sram;
  578. void *d3_resume_sram;
  579. u32 d3_test_pme_ptr;
  580. struct ieee80211_vif *keep_vif;
  581. #endif
  582. #endif
  583. /* d0i3 */
  584. u8 d0i3_ap_sta_id;
  585. bool d0i3_offloading;
  586. struct work_struct d0i3_exit_work;
  587. struct sk_buff_head d0i3_tx;
  588. /* protect d0i3_suspend_flags */
  589. struct mutex d0i3_suspend_mutex;
  590. unsigned long d0i3_suspend_flags;
  591. /* sync d0i3_tx queue and IWL_MVM_STATUS_IN_D0I3 status flag */
  592. spinlock_t d0i3_tx_lock;
  593. wait_queue_head_t d0i3_exit_waitq;
  594. /* BT-Coex */
  595. u8 bt_ack_kill_msk[NUM_PHY_CTX];
  596. u8 bt_cts_kill_msk[NUM_PHY_CTX];
  597. struct iwl_bt_coex_profile_notif_old last_bt_notif_old;
  598. struct iwl_bt_coex_ci_cmd_old last_bt_ci_cmd_old;
  599. struct iwl_bt_coex_profile_notif last_bt_notif;
  600. struct iwl_bt_coex_ci_cmd last_bt_ci_cmd;
  601. u32 last_ant_isol;
  602. u8 last_corun_lut;
  603. u8 bt_tx_prio;
  604. enum iwl_bt_force_ant_mode bt_force_ant_mode;
  605. /* Aux ROC */
  606. struct list_head aux_roc_te_list;
  607. /* Thermal Throttling and CTkill */
  608. struct iwl_mvm_tt_mgmt thermal_throttle;
  609. s32 temperature; /* Celsius */
  610. /*
  611. * Debug option to set the NIC temperature. This option makes the
  612. * driver think this is the actual NIC temperature, and ignore the
  613. * real temperature that is received from the fw
  614. */
  615. bool temperature_test; /* Debug test temperature is enabled */
  616. struct iwl_time_quota_cmd last_quota_cmd;
  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. static inline bool iwl_mvm_is_dqa_supported(struct iwl_mvm *mvm)
  671. {
  672. return mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_DQA_SUPPORT;
  673. }
  674. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  675. struct iwl_rate_info {
  676. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  677. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  678. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  679. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  680. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  681. };
  682. void __iwl_mvm_mac_stop(struct iwl_mvm *mvm);
  683. int __iwl_mvm_mac_start(struct iwl_mvm *mvm);
  684. /******************
  685. * MVM Methods
  686. ******************/
  687. /* uCode */
  688. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  689. /* Utils */
  690. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  691. enum ieee80211_band band);
  692. void iwl_mvm_hwrate_to_tx_rate(u32 rate_n_flags,
  693. enum ieee80211_band band,
  694. struct ieee80211_tx_rate *r);
  695. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  696. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  697. u8 first_antenna(u8 mask);
  698. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  699. /* Tx / Host Commands */
  700. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  701. struct iwl_host_cmd *cmd);
  702. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u8 id,
  703. u32 flags, u16 len, const void *data);
  704. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  705. struct iwl_host_cmd *cmd,
  706. u32 *status);
  707. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u8 id,
  708. u16 len, const void *data,
  709. u32 *status);
  710. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  711. struct ieee80211_sta *sta);
  712. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  713. #ifdef CONFIG_IWLWIFI_DEBUG
  714. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  715. #else
  716. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  717. #endif
  718. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync);
  719. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  720. static inline void iwl_mvm_wait_for_async_handlers(struct iwl_mvm *mvm)
  721. {
  722. flush_work(&mvm->async_handlers_wk);
  723. }
  724. /* Statistics */
  725. int iwl_mvm_rx_reply_statistics(struct iwl_mvm *mvm,
  726. struct iwl_rx_cmd_buffer *rxb,
  727. struct iwl_device_cmd *cmd);
  728. int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  729. struct iwl_rx_cmd_buffer *rxb,
  730. struct iwl_device_cmd *cmd);
  731. /* NVM */
  732. int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic);
  733. int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm);
  734. int iwl_mvm_up(struct iwl_mvm *mvm);
  735. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  736. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  737. bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
  738. struct iwl_bcast_filter_cmd *cmd);
  739. /*
  740. * FW notifications / CMD responses handlers
  741. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  742. */
  743. int iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  744. struct iwl_device_cmd *cmd);
  745. int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  746. struct iwl_device_cmd *cmd);
  747. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  748. struct iwl_device_cmd *cmd);
  749. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  750. struct iwl_device_cmd *cmd);
  751. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  752. struct iwl_device_cmd *cmd);
  753. int iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
  754. struct iwl_rx_cmd_buffer *rxb,
  755. struct iwl_device_cmd *cmd);
  756. int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  757. struct iwl_device_cmd *cmd);
  758. int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  759. struct iwl_rx_cmd_buffer *rxb,
  760. struct iwl_device_cmd *cmd);
  761. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  762. struct iwl_device_cmd *cmd);
  763. /* MVM PHY */
  764. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  765. struct cfg80211_chan_def *chandef,
  766. u8 chains_static, u8 chains_dynamic);
  767. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  768. struct cfg80211_chan_def *chandef,
  769. u8 chains_static, u8 chains_dynamic);
  770. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  771. struct iwl_mvm_phy_ctxt *ctxt);
  772. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  773. struct iwl_mvm_phy_ctxt *ctxt);
  774. int iwl_mvm_phy_ctx_count(struct iwl_mvm *mvm);
  775. /* MAC (virtual interface) programming */
  776. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  777. void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  778. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  779. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  780. bool force_assoc_off, const u8 *bssid_override);
  781. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  782. u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif);
  783. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  784. struct ieee80211_vif *vif);
  785. int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  786. struct iwl_rx_cmd_buffer *rxb,
  787. struct iwl_device_cmd *cmd);
  788. int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  789. struct iwl_rx_cmd_buffer *rxb,
  790. struct iwl_device_cmd *cmd);
  791. void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
  792. struct ieee80211_vif *vif);
  793. /* Bindings */
  794. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  795. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  796. /* Quota management */
  797. int iwl_mvm_update_quotas(struct iwl_mvm *mvm,
  798. struct ieee80211_vif *disabled_vif);
  799. /* Scanning */
  800. int iwl_mvm_scan_request(struct iwl_mvm *mvm,
  801. struct ieee80211_vif *vif,
  802. struct cfg80211_scan_request *req);
  803. int iwl_mvm_rx_scan_response(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  804. struct iwl_device_cmd *cmd);
  805. int iwl_mvm_rx_scan_complete(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  806. struct iwl_device_cmd *cmd);
  807. int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
  808. int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan);
  809. /* Scheduled scan */
  810. int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
  811. struct iwl_rx_cmd_buffer *rxb,
  812. struct iwl_device_cmd *cmd);
  813. int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm,
  814. struct ieee80211_vif *vif,
  815. struct cfg80211_sched_scan_request *req,
  816. struct ieee80211_scan_ies *ies);
  817. int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
  818. struct cfg80211_sched_scan_request *req);
  819. int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
  820. struct cfg80211_sched_scan_request *req);
  821. int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
  822. struct ieee80211_vif *vif,
  823. struct cfg80211_sched_scan_request *req,
  824. struct ieee80211_scan_ies *ies);
  825. int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
  826. int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
  827. struct iwl_rx_cmd_buffer *rxb,
  828. struct iwl_device_cmd *cmd);
  829. /* Unified scan */
  830. int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
  831. struct ieee80211_vif *vif,
  832. struct ieee80211_scan_request *req);
  833. int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
  834. struct ieee80211_vif *vif,
  835. struct cfg80211_sched_scan_request *req,
  836. struct ieee80211_scan_ies *ies);
  837. /* MVM debugfs */
  838. #ifdef CONFIG_IWLWIFI_DEBUGFS
  839. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  840. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  841. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  842. #else
  843. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  844. struct dentry *dbgfs_dir)
  845. {
  846. return 0;
  847. }
  848. static inline void
  849. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  850. {
  851. }
  852. static inline void
  853. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  854. {
  855. }
  856. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  857. /* rate scaling */
  858. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init);
  859. void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm,
  860. struct iwl_mvm_frame_stats *stats,
  861. u32 rate, bool agg);
  862. int rs_pretty_print_rate(char *buf, const u32 rate);
  863. void rs_update_last_rssi(struct iwl_mvm *mvm,
  864. struct iwl_lq_sta *lq_sta,
  865. struct ieee80211_rx_status *rx_status);
  866. /* power management */
  867. int iwl_mvm_power_update_device(struct iwl_mvm *mvm);
  868. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm);
  869. int iwl_mvm_power_update_ps(struct iwl_mvm *mvm);
  870. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  871. char *buf, int bufsz);
  872. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  873. int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  874. struct iwl_rx_cmd_buffer *rxb,
  875. struct iwl_device_cmd *cmd);
  876. #ifdef CONFIG_IWLWIFI_LEDS
  877. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  878. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  879. #else
  880. static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm)
  881. {
  882. return 0;
  883. }
  884. static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm)
  885. {
  886. }
  887. #endif
  888. /* D3 (WoWLAN, NetDetect) */
  889. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  890. int iwl_mvm_resume(struct ieee80211_hw *hw);
  891. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  892. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  893. struct ieee80211_vif *vif,
  894. struct cfg80211_gtk_rekey_data *data);
  895. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  896. struct ieee80211_vif *vif,
  897. struct inet6_dev *idev);
  898. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  899. struct ieee80211_vif *vif, int idx);
  900. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  901. #ifdef CONFIG_PM_SLEEP
  902. void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm,
  903. struct ieee80211_vif *vif);
  904. #else
  905. static inline void
  906. iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  907. {
  908. }
  909. #endif
  910. void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
  911. struct iwl_wowlan_config_cmd_v2 *cmd);
  912. int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
  913. struct ieee80211_vif *vif,
  914. bool disable_offloading,
  915. u32 cmd_flags);
  916. /* D0i3 */
  917. void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  918. void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  919. int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
  920. void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
  921. int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
  922. /* BT Coex */
  923. int iwl_send_bt_init_conf(struct iwl_mvm *mvm);
  924. int iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  925. struct iwl_rx_cmd_buffer *rxb,
  926. struct iwl_device_cmd *cmd);
  927. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  928. enum ieee80211_rssi_event rssi_event);
  929. void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm);
  930. u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
  931. struct ieee80211_sta *sta);
  932. bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
  933. struct ieee80211_sta *sta);
  934. bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm);
  935. bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
  936. enum ieee80211_band band);
  937. u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
  938. struct ieee80211_tx_info *info, u8 ac);
  939. bool iwl_mvm_bt_coex_is_shared_ant_avail_old(struct iwl_mvm *mvm);
  940. void iwl_mvm_bt_coex_vif_change_old(struct iwl_mvm *mvm);
  941. int iwl_send_bt_init_conf_old(struct iwl_mvm *mvm);
  942. int iwl_mvm_rx_bt_coex_notif_old(struct iwl_mvm *mvm,
  943. struct iwl_rx_cmd_buffer *rxb,
  944. struct iwl_device_cmd *cmd);
  945. void iwl_mvm_bt_rssi_event_old(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  946. enum ieee80211_rssi_event rssi_event);
  947. u16 iwl_mvm_coex_agg_time_limit_old(struct iwl_mvm *mvm,
  948. struct ieee80211_sta *sta);
  949. bool iwl_mvm_bt_coex_is_mimo_allowed_old(struct iwl_mvm *mvm,
  950. struct ieee80211_sta *sta);
  951. bool iwl_mvm_bt_coex_is_tpc_allowed_old(struct iwl_mvm *mvm,
  952. enum ieee80211_band band);
  953. int iwl_mvm_rx_ant_coupling_notif_old(struct iwl_mvm *mvm,
  954. struct iwl_rx_cmd_buffer *rxb,
  955. struct iwl_device_cmd *cmd);
  956. enum iwl_bt_kill_msk {
  957. BT_KILL_MSK_DEFAULT,
  958. BT_KILL_MSK_NEVER,
  959. BT_KILL_MSK_ALWAYS,
  960. BT_KILL_MSK_MAX,
  961. };
  962. extern const u8 iwl_bt_ack_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  963. extern const u8 iwl_bt_cts_kill_msk[BT_MAX_AG][BT_COEX_MAX_LUT];
  964. extern const u32 iwl_bt_ctl_kill_msk[BT_KILL_MSK_MAX];
  965. /* beacon filtering */
  966. #ifdef CONFIG_IWLWIFI_DEBUGFS
  967. void
  968. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  969. struct iwl_beacon_filter_cmd *cmd);
  970. #else
  971. static inline void
  972. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  973. struct iwl_beacon_filter_cmd *cmd)
  974. {}
  975. #endif
  976. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  977. struct ieee80211_vif *vif,
  978. bool enable, u32 flags);
  979. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  980. struct ieee80211_vif *vif,
  981. u32 flags);
  982. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  983. struct ieee80211_vif *vif,
  984. u32 flags);
  985. /* SMPS */
  986. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  987. enum iwl_mvm_smps_type_request req_type,
  988. enum ieee80211_smps_mode smps_request);
  989. bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm);
  990. /* Low latency */
  991. int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  992. bool value);
  993. /* get SystemLowLatencyMode - only needed for beacon threshold? */
  994. bool iwl_mvm_low_latency(struct iwl_mvm *mvm);
  995. /* get VMACLowLatencyMode */
  996. static inline bool iwl_mvm_vif_low_latency(struct iwl_mvm_vif *mvmvif)
  997. {
  998. /*
  999. * should this consider associated/active/... state?
  1000. *
  1001. * Normally low-latency should only be active on interfaces
  1002. * that are active, but at least with debugfs it can also be
  1003. * enabled on interfaces that aren't active. However, when
  1004. * interface aren't active then they aren't added into the
  1005. * binding, so this has no real impact. For now, just return
  1006. * the current desired low-latency state.
  1007. */
  1008. return mvmvif->low_latency;
  1009. }
  1010. /* hw scheduler queue config */
  1011. void iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, u16 ssn,
  1012. const struct iwl_trans_txq_scd_cfg *cfg);
  1013. void iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue);
  1014. static inline void iwl_mvm_enable_ac_txq(struct iwl_mvm *mvm, int queue,
  1015. u8 fifo)
  1016. {
  1017. struct iwl_trans_txq_scd_cfg cfg = {
  1018. .fifo = fifo,
  1019. .tid = IWL_MAX_TID_COUNT,
  1020. .aggregate = false,
  1021. .frame_limit = IWL_FRAME_LIMIT,
  1022. };
  1023. iwl_mvm_enable_txq(mvm, queue, 0, &cfg);
  1024. }
  1025. static inline void iwl_mvm_enable_agg_txq(struct iwl_mvm *mvm, int queue,
  1026. int fifo, int sta_id, int tid,
  1027. int frame_limit, u16 ssn)
  1028. {
  1029. struct iwl_trans_txq_scd_cfg cfg = {
  1030. .fifo = fifo,
  1031. .sta_id = sta_id,
  1032. .tid = tid,
  1033. .frame_limit = frame_limit,
  1034. .aggregate = true,
  1035. };
  1036. iwl_mvm_enable_txq(mvm, queue, ssn, &cfg);
  1037. }
  1038. /* Assoc status */
  1039. bool iwl_mvm_is_idle(struct iwl_mvm *mvm);
  1040. /* Thermal management and CT-kill */
  1041. void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
  1042. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  1043. void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
  1044. void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
  1045. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  1046. int iwl_mvm_get_temp(struct iwl_mvm *mvm);
  1047. /* smart fifo */
  1048. int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1049. bool added_vif);
  1050. /* TDLS */
  1051. int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  1052. void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
  1053. void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  1054. bool sta_added);
  1055. void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
  1056. struct ieee80211_vif *vif);
  1057. struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
  1058. void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
  1059. void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
  1060. #endif /* __IWL_MVM_H__ */