mvm.h 58 KB

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