mvm.h 46 KB

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