mvm.h 55 KB

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