mvm.h 57 KB

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