mvm.h 62 KB

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