mvm.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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 - 2013 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #ifndef __IWL_MVM_H__
  64. #define __IWL_MVM_H__
  65. #include <linux/list.h>
  66. #include <linux/spinlock.h>
  67. #include <linux/leds.h>
  68. #include <linux/in6.h>
  69. #include "iwl-op-mode.h"
  70. #include "iwl-trans.h"
  71. #include "iwl-notif-wait.h"
  72. #include "iwl-eeprom-parse.h"
  73. #include "iwl-trans.h"
  74. #include "sta.h"
  75. #include "fw-api.h"
  76. #include "constants.h"
  77. #define IWL_INVALID_MAC80211_QUEUE 0xff
  78. #define IWL_MVM_MAX_ADDRESSES 5
  79. /* RSSI offset for WkP */
  80. #define IWL_RSSI_OFFSET 50
  81. enum iwl_mvm_tx_fifo {
  82. IWL_MVM_TX_FIFO_BK = 0,
  83. IWL_MVM_TX_FIFO_BE,
  84. IWL_MVM_TX_FIFO_VI,
  85. IWL_MVM_TX_FIFO_VO,
  86. IWL_MVM_TX_FIFO_MCAST = 5,
  87. };
  88. extern struct ieee80211_ops iwl_mvm_hw_ops;
  89. extern const struct iwl_mvm_power_ops pm_legacy_ops;
  90. extern const struct iwl_mvm_power_ops pm_mac_ops;
  91. /**
  92. * struct iwl_mvm_mod_params - module parameters for iwlmvm
  93. * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted.
  94. * We will register to mac80211 to have testmode working. The NIC must not
  95. * be up'ed after the INIT fw asserted. This is useful to be able to use
  96. * proprietary tools over testmode to debug the INIT fw.
  97. * @power_scheme: CAM(Continuous Active Mode)-1, BPS(Balanced Power
  98. * Save)-2(default), LP(Low Power)-3
  99. */
  100. struct iwl_mvm_mod_params {
  101. bool init_dbg;
  102. int power_scheme;
  103. };
  104. extern struct iwl_mvm_mod_params iwlmvm_mod_params;
  105. struct iwl_mvm_phy_ctxt {
  106. u16 id;
  107. u16 color;
  108. u32 ref;
  109. /*
  110. * TODO: This should probably be removed. Currently here only for rate
  111. * scaling algorithm
  112. */
  113. struct ieee80211_channel *channel;
  114. };
  115. struct iwl_mvm_time_event_data {
  116. struct ieee80211_vif *vif;
  117. struct list_head list;
  118. unsigned long end_jiffies;
  119. u32 duration;
  120. bool running;
  121. u32 uid;
  122. /*
  123. * The access to the 'id' field must be done when the
  124. * mvm->time_event_lock is held, as it value is used to indicate
  125. * if the te is in the time event list or not (when id == TE_MAX)
  126. */
  127. u32 id;
  128. };
  129. /* Power management */
  130. /**
  131. * enum iwl_power_scheme
  132. * @IWL_POWER_LEVEL_CAM - Continuously Active Mode
  133. * @IWL_POWER_LEVEL_BPS - Balanced Power Save (default)
  134. * @IWL_POWER_LEVEL_LP - Low Power
  135. */
  136. enum iwl_power_scheme {
  137. IWL_POWER_SCHEME_CAM = 1,
  138. IWL_POWER_SCHEME_BPS,
  139. IWL_POWER_SCHEME_LP
  140. };
  141. #define IWL_CONN_MAX_LISTEN_INTERVAL 70
  142. struct iwl_mvm_power_ops {
  143. int (*power_update_mode)(struct iwl_mvm *mvm,
  144. struct ieee80211_vif *vif);
  145. int (*power_disable)(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  146. #ifdef CONFIG_IWLWIFI_DEBUGFS
  147. int (*power_dbgfs_read)(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  148. char *buf, int bufsz);
  149. #endif
  150. };
  151. #ifdef CONFIG_IWLWIFI_DEBUGFS
  152. enum iwl_dbgfs_pm_mask {
  153. MVM_DEBUGFS_PM_KEEP_ALIVE = BIT(0),
  154. MVM_DEBUGFS_PM_SKIP_OVER_DTIM = BIT(1),
  155. MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS = BIT(2),
  156. MVM_DEBUGFS_PM_RX_DATA_TIMEOUT = BIT(3),
  157. MVM_DEBUGFS_PM_TX_DATA_TIMEOUT = BIT(4),
  158. MVM_DEBUGFS_PM_DISABLE_POWER_OFF = BIT(5),
  159. MVM_DEBUGFS_PM_LPRX_ENA = BIT(6),
  160. MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD = BIT(7),
  161. };
  162. struct iwl_dbgfs_pm {
  163. u16 keep_alive_seconds;
  164. u32 rx_data_timeout;
  165. u32 tx_data_timeout;
  166. bool skip_over_dtim;
  167. u8 skip_dtim_periods;
  168. bool disable_power_off;
  169. bool lprx_ena;
  170. u32 lprx_rssi_threshold;
  171. int mask;
  172. };
  173. /* beacon filtering */
  174. enum iwl_dbgfs_bf_mask {
  175. MVM_DEBUGFS_BF_ENERGY_DELTA = BIT(0),
  176. MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA = BIT(1),
  177. MVM_DEBUGFS_BF_ROAMING_STATE = BIT(2),
  178. MVM_DEBUGFS_BF_TEMP_THRESHOLD = BIT(3),
  179. MVM_DEBUGFS_BF_TEMP_FAST_FILTER = BIT(4),
  180. MVM_DEBUGFS_BF_TEMP_SLOW_FILTER = BIT(5),
  181. MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER = BIT(6),
  182. MVM_DEBUGFS_BF_DEBUG_FLAG = BIT(7),
  183. MVM_DEBUGFS_BF_ESCAPE_TIMER = BIT(8),
  184. MVM_DEBUGFS_BA_ESCAPE_TIMER = BIT(9),
  185. MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT = BIT(10),
  186. };
  187. struct iwl_dbgfs_bf {
  188. u32 bf_energy_delta;
  189. u32 bf_roaming_energy_delta;
  190. u32 bf_roaming_state;
  191. u32 bf_temp_threshold;
  192. u32 bf_temp_fast_filter;
  193. u32 bf_temp_slow_filter;
  194. u32 bf_enable_beacon_filter;
  195. u32 bf_debug_flag;
  196. u32 bf_escape_timer;
  197. u32 ba_escape_timer;
  198. u32 ba_enable_beacon_abort;
  199. int mask;
  200. };
  201. #endif
  202. enum iwl_mvm_smps_type_request {
  203. IWL_MVM_SMPS_REQ_BT_COEX,
  204. IWL_MVM_SMPS_REQ_TT,
  205. NUM_IWL_MVM_SMPS_REQ,
  206. };
  207. /**
  208. * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context
  209. * @id: between 0 and 3
  210. * @color: to solve races upon MAC addition and removal
  211. * @ap_sta_id: the sta_id of the AP - valid only if VIF type is STA
  212. * @uploaded: indicates the MAC context has been added to the device
  213. * @ap_active: indicates that ap context is configured, and that the interface
  214. * should get quota etc.
  215. * @monitor_active: indicates that monitor context is configured, and that the
  216. * interface should get quota etc.
  217. * @queue_params: QoS params for this MAC
  218. * @bcast_sta: station used for broadcast packets. Used by the following
  219. * vifs: P2P_DEVICE, GO and AP.
  220. * @beacon_skb: the skb used to hold the AP/GO beacon template
  221. * @smps_requests: the requests of of differents parts of the driver, regard
  222. the desired smps mode.
  223. */
  224. struct iwl_mvm_vif {
  225. u16 id;
  226. u16 color;
  227. u8 ap_sta_id;
  228. bool uploaded;
  229. bool ap_active;
  230. bool monitor_active;
  231. /* indicate whether beacon filtering is enabled */
  232. bool bf_enabled;
  233. u32 ap_beacon_time;
  234. enum iwl_tsf_id tsf_id;
  235. /*
  236. * QoS data from mac80211, need to store this here
  237. * as mac80211 has a separate callback but we need
  238. * to have the data for the MAC context
  239. */
  240. struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
  241. struct iwl_mvm_time_event_data time_event_data;
  242. struct iwl_mvm_int_sta bcast_sta;
  243. /*
  244. * Assigned while mac80211 has the interface in a channel context,
  245. * or, for P2P Device, while it exists.
  246. */
  247. struct iwl_mvm_phy_ctxt *phy_ctxt;
  248. #ifdef CONFIG_PM_SLEEP
  249. /* WoWLAN GTK rekey data */
  250. struct {
  251. u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
  252. __le64 replay_ctr;
  253. bool valid;
  254. } rekey_data;
  255. int tx_key_idx;
  256. #if IS_ENABLED(CONFIG_IPV6)
  257. /* IPv6 addresses for WoWLAN */
  258. struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
  259. int num_target_ipv6_addrs;
  260. #endif
  261. #endif
  262. #ifdef CONFIG_IWLWIFI_DEBUGFS
  263. struct dentry *dbgfs_dir;
  264. struct dentry *dbgfs_slink;
  265. void *dbgfs_data;
  266. struct iwl_dbgfs_pm dbgfs_pm;
  267. struct iwl_dbgfs_bf dbgfs_bf;
  268. #endif
  269. enum ieee80211_smps_mode smps_requests[NUM_IWL_MVM_SMPS_REQ];
  270. };
  271. static inline struct iwl_mvm_vif *
  272. iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
  273. {
  274. return (void *)vif->drv_priv;
  275. }
  276. enum iwl_scan_status {
  277. IWL_MVM_SCAN_NONE,
  278. IWL_MVM_SCAN_OS,
  279. };
  280. /**
  281. * struct iwl_nvm_section - describes an NVM section in memory.
  282. *
  283. * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD,
  284. * and saved for later use by the driver. Not all NVM sections are saved
  285. * this way, only the needed ones.
  286. */
  287. struct iwl_nvm_section {
  288. u16 length;
  289. const u8 *data;
  290. };
  291. /*
  292. * Tx-backoff threshold
  293. * @temperature: The threshold in Celsius
  294. * @backoff: The tx-backoff in uSec
  295. */
  296. struct iwl_tt_tx_backoff {
  297. s32 temperature;
  298. u32 backoff;
  299. };
  300. #define TT_TX_BACKOFF_SIZE 6
  301. /**
  302. * struct iwl_tt_params - thermal throttling parameters
  303. * @ct_kill_entry: CT Kill entry threshold
  304. * @ct_kill_exit: CT Kill exit threshold
  305. * @ct_kill_duration: The time intervals (in uSec) in which the driver needs
  306. * to checks whether to exit CT Kill.
  307. * @dynamic_smps_entry: Dynamic SMPS entry threshold
  308. * @dynamic_smps_exit: Dynamic SMPS exit threshold
  309. * @tx_protection_entry: TX protection entry threshold
  310. * @tx_protection_exit: TX protection exit threshold
  311. * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
  312. * @support_ct_kill: Support CT Kill?
  313. * @support_dynamic_smps: Support dynamic SMPS?
  314. * @support_tx_protection: Support tx protection?
  315. * @support_tx_backoff: Support tx-backoff?
  316. */
  317. struct iwl_tt_params {
  318. s32 ct_kill_entry;
  319. s32 ct_kill_exit;
  320. u32 ct_kill_duration;
  321. s32 dynamic_smps_entry;
  322. s32 dynamic_smps_exit;
  323. s32 tx_protection_entry;
  324. s32 tx_protection_exit;
  325. struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
  326. bool support_ct_kill;
  327. bool support_dynamic_smps;
  328. bool support_tx_protection;
  329. bool support_tx_backoff;
  330. };
  331. /**
  332. * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  333. * @ct_kill_exit: worker to exit thermal kill
  334. * @dynamic_smps: Is thermal throttling enabled dynamic_smps?
  335. * @tx_backoff: The current thremal throttling tx backoff in uSec.
  336. * @params: Parameters to configure the thermal throttling algorithm.
  337. * @throttle: Is thermal throttling is active?
  338. */
  339. struct iwl_mvm_tt_mgmt {
  340. struct delayed_work ct_kill_exit;
  341. bool dynamic_smps;
  342. u32 tx_backoff;
  343. const struct iwl_tt_params *params;
  344. bool throttle;
  345. };
  346. struct iwl_mvm {
  347. /* for logger access */
  348. struct device *dev;
  349. struct iwl_trans *trans;
  350. const struct iwl_fw *fw;
  351. const struct iwl_cfg *cfg;
  352. struct iwl_phy_db *phy_db;
  353. struct ieee80211_hw *hw;
  354. /* for protecting access to iwl_mvm */
  355. struct mutex mutex;
  356. struct list_head async_handlers_list;
  357. spinlock_t async_handlers_lock;
  358. struct work_struct async_handlers_wk;
  359. struct work_struct roc_done_wk;
  360. unsigned long status;
  361. /*
  362. * for beacon filtering -
  363. * currently only one interface can be supported
  364. */
  365. struct iwl_mvm_vif *bf_allowed_vif;
  366. enum iwl_ucode_type cur_ucode;
  367. bool ucode_loaded;
  368. bool init_ucode_run;
  369. u32 error_event_table;
  370. u32 log_event_table;
  371. u32 ampdu_ref;
  372. struct iwl_notif_wait_data notif_wait;
  373. struct mvm_statistics_rx rx_stats;
  374. unsigned long transport_queue_stop;
  375. u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
  376. atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
  377. struct iwl_nvm_data *nvm_data;
  378. /* NVM sections */
  379. struct iwl_nvm_section nvm_sections[NVM_NUM_OF_SECTIONS];
  380. /* EEPROM MAC addresses */
  381. struct mac_address addresses[IWL_MVM_MAX_ADDRESSES];
  382. /* data related to data path */
  383. struct iwl_rx_phy_info last_phy_info;
  384. struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_MVM_STATION_COUNT];
  385. struct work_struct sta_drained_wk;
  386. unsigned long sta_drained[BITS_TO_LONGS(IWL_MVM_STATION_COUNT)];
  387. atomic_t pending_frames[IWL_MVM_STATION_COUNT];
  388. u8 rx_ba_sessions;
  389. /* configured by mac80211 */
  390. u32 rts_threshold;
  391. /* Scan status, cmd (pre-allocated) and auxiliary station */
  392. enum iwl_scan_status scan_status;
  393. struct iwl_scan_cmd *scan_cmd;
  394. /* Internal station */
  395. struct iwl_mvm_int_sta aux_sta;
  396. u8 scan_last_antenna_idx; /* to toggle TX between antennas */
  397. u8 mgmt_last_antenna_idx;
  398. #ifdef CONFIG_IWLWIFI_DEBUGFS
  399. struct dentry *debugfs_dir;
  400. u32 dbgfs_sram_offset, dbgfs_sram_len;
  401. bool prevent_power_down_d3;
  402. #endif
  403. struct iwl_mvm_phy_ctxt phy_ctxts[NUM_PHY_CTX];
  404. struct list_head time_event_list;
  405. spinlock_t time_event_lock;
  406. /*
  407. * A bitmap indicating the index of the key in use. The firmware
  408. * can hold 16 keys at most. Reflect this fact.
  409. */
  410. unsigned long fw_key_table[BITS_TO_LONGS(STA_KEY_MAX_NUM)];
  411. /*
  412. * This counter of created interfaces is referenced only in conjunction
  413. * with FW limitation related to power management. Currently PM is
  414. * supported only on a single interface.
  415. * IMPORTANT: this variable counts all interfaces except P2P device.
  416. */
  417. u8 vif_count;
  418. /* -1 for always, 0 for never, >0 for that many times */
  419. s8 restart_fw;
  420. struct led_classdev led;
  421. struct ieee80211_vif *p2p_device_vif;
  422. #ifdef CONFIG_PM_SLEEP
  423. struct wiphy_wowlan_support wowlan;
  424. int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen;
  425. #ifdef CONFIG_IWLWIFI_DEBUGFS
  426. u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */
  427. bool d3_test_active;
  428. bool store_d3_resume_sram;
  429. void *d3_resume_sram;
  430. u32 d3_test_pme_ptr;
  431. #endif
  432. #endif
  433. /* BT-Coex */
  434. u8 bt_kill_msk;
  435. struct iwl_bt_coex_profile_notif last_bt_notif;
  436. /* Thermal Throttling and CTkill */
  437. struct iwl_mvm_tt_mgmt thermal_throttle;
  438. s32 temperature; /* Celsius */
  439. const struct iwl_mvm_power_ops *pm_ops;
  440. };
  441. /* Extract MVM priv from op_mode and _hw */
  442. #define IWL_OP_MODE_GET_MVM(_iwl_op_mode) \
  443. ((struct iwl_mvm *)(_iwl_op_mode)->op_mode_specific)
  444. #define IWL_MAC80211_GET_MVM(_hw) \
  445. IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
  446. enum iwl_mvm_status {
  447. IWL_MVM_STATUS_HW_RFKILL,
  448. IWL_MVM_STATUS_HW_CTKILL,
  449. IWL_MVM_STATUS_ROC_RUNNING,
  450. IWL_MVM_STATUS_IN_HW_RESTART,
  451. };
  452. static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
  453. {
  454. return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status) ||
  455. test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
  456. }
  457. extern const u8 iwl_mvm_ac_to_tx_fifo[];
  458. struct iwl_rate_info {
  459. u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
  460. u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
  461. u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */
  462. u8 plcp_mimo3; /* uCode API: IWL_RATE_MIMO3_6M_PLCP, etc. */
  463. u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
  464. };
  465. /******************
  466. * MVM Methods
  467. ******************/
  468. /* uCode */
  469. int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm);
  470. /* Utils */
  471. int iwl_mvm_legacy_rate_to_mac80211_idx(u32 rate_n_flags,
  472. enum ieee80211_band band);
  473. u8 iwl_mvm_mac80211_idx_to_hwrate(int rate_idx);
  474. void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm);
  475. void iwl_mvm_dump_sram(struct iwl_mvm *mvm);
  476. u8 first_antenna(u8 mask);
  477. u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx);
  478. /* Tx / Host Commands */
  479. int __must_check iwl_mvm_send_cmd(struct iwl_mvm *mvm,
  480. struct iwl_host_cmd *cmd);
  481. int __must_check iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u8 id,
  482. u32 flags, u16 len, const void *data);
  483. int __must_check iwl_mvm_send_cmd_status(struct iwl_mvm *mvm,
  484. struct iwl_host_cmd *cmd,
  485. u32 *status);
  486. int __must_check iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u8 id,
  487. u16 len, const void *data,
  488. u32 *status);
  489. int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
  490. struct ieee80211_sta *sta);
  491. int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb);
  492. #ifdef CONFIG_IWLWIFI_DEBUG
  493. const char *iwl_mvm_get_tx_fail_reason(u32 status);
  494. #else
  495. static inline const char *iwl_mvm_get_tx_fail_reason(u32 status) { return ""; }
  496. #endif
  497. int iwl_mvm_flush_tx_path(struct iwl_mvm *mvm, u32 tfd_msk, bool sync);
  498. void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm);
  499. /* Statistics */
  500. int iwl_mvm_rx_reply_statistics(struct iwl_mvm *mvm,
  501. struct iwl_rx_cmd_buffer *rxb,
  502. struct iwl_device_cmd *cmd);
  503. int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
  504. struct iwl_rx_cmd_buffer *rxb,
  505. struct iwl_device_cmd *cmd);
  506. /* NVM */
  507. int iwl_nvm_init(struct iwl_mvm *mvm);
  508. int iwl_mvm_up(struct iwl_mvm *mvm);
  509. int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
  510. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
  511. /*
  512. * FW notifications / CMD responses handlers
  513. * Convention: iwl_mvm_rx_<NAME OF THE CMD>
  514. */
  515. int iwl_mvm_rx_rx_phy_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  516. struct iwl_device_cmd *cmd);
  517. int iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  518. struct iwl_device_cmd *cmd);
  519. int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  520. struct iwl_device_cmd *cmd);
  521. int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  522. struct iwl_device_cmd *cmd);
  523. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  524. struct iwl_device_cmd *cmd);
  525. int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  526. struct iwl_device_cmd *cmd);
  527. int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
  528. struct iwl_rx_cmd_buffer *rxb,
  529. struct iwl_device_cmd *cmd);
  530. int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  531. struct iwl_device_cmd *cmd);
  532. /* MVM PHY */
  533. int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  534. struct cfg80211_chan_def *chandef,
  535. u8 chains_static, u8 chains_dynamic);
  536. int iwl_mvm_phy_ctxt_changed(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
  537. struct cfg80211_chan_def *chandef,
  538. u8 chains_static, u8 chains_dynamic);
  539. void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm,
  540. struct iwl_mvm_phy_ctxt *ctxt);
  541. void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm,
  542. struct iwl_mvm_phy_ctxt *ctxt);
  543. /* MAC (virtual interface) programming */
  544. int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  545. void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  546. int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  547. int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  548. int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  549. u32 iwl_mvm_mac_get_queues_mask(struct iwl_mvm *mvm,
  550. struct ieee80211_vif *vif);
  551. int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
  552. struct ieee80211_vif *vif);
  553. int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
  554. struct iwl_rx_cmd_buffer *rxb,
  555. struct iwl_device_cmd *cmd);
  556. int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
  557. struct iwl_rx_cmd_buffer *rxb,
  558. struct iwl_device_cmd *cmd);
  559. /* Bindings */
  560. int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  561. int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  562. /* Quota management */
  563. int iwl_mvm_update_quotas(struct iwl_mvm *mvm, struct ieee80211_vif *newvif);
  564. /* Scanning */
  565. int iwl_mvm_scan_request(struct iwl_mvm *mvm,
  566. struct ieee80211_vif *vif,
  567. struct cfg80211_scan_request *req);
  568. int iwl_mvm_rx_scan_response(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  569. struct iwl_device_cmd *cmd);
  570. int iwl_mvm_rx_scan_complete(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
  571. struct iwl_device_cmd *cmd);
  572. void iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
  573. /* MVM debugfs */
  574. #ifdef CONFIG_IWLWIFI_DEBUGFS
  575. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
  576. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  577. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  578. #else
  579. static inline int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm,
  580. struct dentry *dbgfs_dir)
  581. {
  582. return 0;
  583. }
  584. static inline void
  585. iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  586. {
  587. }
  588. static inline void
  589. iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  590. {
  591. }
  592. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  593. /* rate scaling */
  594. int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq,
  595. u8 flags, bool init);
  596. /* power managment */
  597. static inline int iwl_mvm_power_update_mode(struct iwl_mvm *mvm,
  598. struct ieee80211_vif *vif)
  599. {
  600. return mvm->pm_ops->power_update_mode(mvm, vif);
  601. }
  602. static inline int iwl_mvm_power_disable(struct iwl_mvm *mvm,
  603. struct ieee80211_vif *vif)
  604. {
  605. return mvm->pm_ops->power_disable(mvm, vif);
  606. }
  607. #ifdef CONFIG_IWLWIFI_DEBUGFS
  608. static inline int iwl_mvm_power_dbgfs_read(struct iwl_mvm *mvm,
  609. struct ieee80211_vif *vif,
  610. char *buf, int bufsz)
  611. {
  612. return mvm->pm_ops->power_dbgfs_read(mvm, vif, buf, bufsz);
  613. }
  614. #endif
  615. int iwl_mvm_leds_init(struct iwl_mvm *mvm);
  616. void iwl_mvm_leds_exit(struct iwl_mvm *mvm);
  617. /* D3 (WoWLAN, NetDetect) */
  618. int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  619. int iwl_mvm_resume(struct ieee80211_hw *hw);
  620. void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled);
  621. void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
  622. struct ieee80211_vif *vif,
  623. struct cfg80211_gtk_rekey_data *data);
  624. void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
  625. struct ieee80211_vif *vif,
  626. struct inet6_dev *idev);
  627. void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
  628. struct ieee80211_vif *vif, int idx);
  629. extern const struct file_operations iwl_dbgfs_d3_test_ops;
  630. /* BT Coex */
  631. int iwl_send_bt_prio_tbl(struct iwl_mvm *mvm);
  632. int iwl_send_bt_init_conf(struct iwl_mvm *mvm);
  633. int iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
  634. struct iwl_rx_cmd_buffer *rxb,
  635. struct iwl_device_cmd *cmd);
  636. void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  637. enum ieee80211_rssi_event rssi_event);
  638. void iwl_mvm_bt_coex_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
  639. /* beacon filtering */
  640. #ifdef CONFIG_IWLWIFI_DEBUGFS
  641. void
  642. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  643. struct iwl_beacon_filter_cmd *cmd);
  644. #else
  645. static inline void
  646. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  647. struct iwl_beacon_filter_cmd *cmd)
  648. {}
  649. #endif
  650. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  651. struct ieee80211_vif *vif);
  652. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  653. struct ieee80211_vif *vif);
  654. int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm,
  655. struct iwl_beacon_filter_cmd *cmd);
  656. int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm,
  657. struct ieee80211_vif *vif, bool enable);
  658. /* SMPS */
  659. void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  660. enum iwl_mvm_smps_type_request req_type,
  661. enum ieee80211_smps_mode smps_request);
  662. /* Thermal management and CT-kill */
  663. void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
  664. void iwl_mvm_tt_initialize(struct iwl_mvm *mvm);
  665. void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
  666. void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state);
  667. #endif /* __IWL_MVM_H__ */