Merge ~canonical-hwe-team/ubuntu/+source/backport-iwlwifi-dkms/+git/backport-iwlwifi-dkms:for-hwe/merge-debian-7858 into ~canonical-hwe-team/ubuntu/+source/backport-iwlwifi-dkms/+git/backport-iwlwifi-dkms:ubuntu/master

Proposed by You-Sheng Yang
Status: Merged
Approved by: You-Sheng Yang
Approved revision: 92d6afda0f493ac467b041eeea9afe1a9af45478
Merged at revision: 92d6afda0f493ac467b041eeea9afe1a9af45478
Proposed branch: ~canonical-hwe-team/ubuntu/+source/backport-iwlwifi-dkms/+git/backport-iwlwifi-dkms:for-hwe/merge-debian-7858
Merge into: ~canonical-hwe-team/ubuntu/+source/backport-iwlwifi-dkms/+git/backport-iwlwifi-dkms:ubuntu/master
Diff against target: 5396 lines (+313/-2227)
44 files modified
debian/changelog (+6/-0)
defconfigs/iwlwifi-galileo (+0/-2)
defconfigs/iwlwifi-public (+0/-2)
defconfigs/iwlwifi-public-android (+0/-3)
defconfigs/prune-public (+0/-2)
defconfigs/soc_ip_hfpga (+0/-2)
dev/null (+0/-796)
drivers/net/wireless/intel/iwlwifi/Kconfig.noupstream (+0/-26)
drivers/net/wireless/intel/iwlwifi/fw/api/coex.h (+2/-122)
drivers/net/wireless/intel/iwlwifi/fw/api/commands.h (+2/-31)
drivers/net/wireless/intel/iwlwifi/fw/api/rs.h (+13/-5)
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h (+47/-8)
drivers/net/wireless/intel/iwlwifi/fw/file.h (+1/-3)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-cfg.h (+1/-6)
drivers/net/wireless/intel/iwlwifi/iwl-drv.c (+0/-8)
drivers/net/wireless/intel/iwlwifi/iwl-modparams.h (+2/-7)
drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h (+0/-23)
drivers/net/wireless/intel/iwlwifi/iwl-trans.c (+0/-14)
drivers/net/wireless/intel/iwlwifi/iwl-trans.h (+29/-73)
drivers/net/wireless/intel/iwlwifi/mvm/Makefile (+0/-2)
drivers/net/wireless/intel/iwlwifi/mvm/coex.c (+2/-158)
drivers/net/wireless/intel/iwlwifi/mvm/d3.c (+9/-0)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c (+2/-15)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c (+3/-19)
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c (+25/-1)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c (+10/-72)
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h (+7/-69)
drivers/net/wireless/intel/iwlwifi/mvm/ops.c (+0/-19)
drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c (+3/-7)
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c (+21/-8)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c (+63/-24)
drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c (+0/-405)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c (+0/-99)
drivers/net/wireless/intel/iwlwifi/pcie/internal.h (+3/-8)
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c (+3/-3)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c (+10/-61)
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c (+2/-40)
drivers/net/wireless/intel/iwlwifi/pcie/tx.c (+25/-65)
drivers/net/wireless/intel/iwlwifi/xvt/fw.c (+3/-6)
drivers/net/wireless/intel/iwlwifi/xvt/user-infc.c (+6/-5)
drivers/net/wireless/intel/iwlwifi/xvt/xvt.h (+3/-3)
local-symbols (+0/-3)
net/mac80211/vht.c (+9/-1)
versions (+1/-1)
Reviewer Review Type Date Requested Status
You-Sheng Yang Approve
Review via email: mp+369139@code.launchpad.net

Commit message

Sync with Debian version 7858.

To post a comment you must log in.
Revision history for this message
You-Sheng Yang (vicamo) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index bfbb1fa..f6dc7d4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
1backport-iwlwifi-dkms (7858-ubuntu1) UNRELEASED; urgency=low
2
3 * sync with debian 7858.
4
5 -- You-Sheng Yang <vicamo@gmail.com> Fri, 21 Jun 2019 15:27:31 +0800
6
1backport-iwlwifi-dkms (7841-ubuntu2) UNRELEASED; urgency=low7backport-iwlwifi-dkms (7841-ubuntu2) UNRELEASED; urgency=low
28
3 * add modalias support.9 * add modalias support.
diff --git a/defconfigs/iwlwifi-galileo b/defconfigs/iwlwifi-galileo
index 812014f..14e0b45 100644
--- a/defconfigs/iwlwifi-galileo
+++ b/defconfigs/iwlwifi-galileo
@@ -21,8 +21,6 @@ CPTCFG_IWLWIFI_DEVICE_TESTMODE=y
21# CPTCFG_MAC80211_HWSIM is not set21# CPTCFG_MAC80211_HWSIM is not set
22CPTCFG_IWLXVT=m22CPTCFG_IWLXVT=m
23CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES=y23CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES=y
24# CPTCFG_IWLWIFI_FRQ_MGR_TEST is not set
25# CPTCFG_IWLWIFI_FORCE_OFDM_RATE is not set24# CPTCFG_IWLWIFI_FORCE_OFDM_RATE is not set
26# CPTCFG_IWLWIFI_LTE_COEX is not set
27# CPTCFG_IWLMVM_P2P_UAPSD_STANDALONE is not set25# CPTCFG_IWLMVM_P2P_UAPSD_STANDALONE is not set
28CPTCFG_IWLWIFI_NUM_CHANNELS=126CPTCFG_IWLWIFI_NUM_CHANNELS=1
diff --git a/defconfigs/iwlwifi-public b/defconfigs/iwlwifi-public
index ef43e35..c457087 100644
--- a/defconfigs/iwlwifi-public
+++ b/defconfigs/iwlwifi-public
@@ -19,6 +19,4 @@ CPTCFG_IWLWIFI_DEVICE_TRACING=y
19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y
20# CPTCFG_MAC80211_HWSIM is not set20# CPTCFG_MAC80211_HWSIM is not set
21CPTCFG_IWLXVT=m21CPTCFG_IWLXVT=m
22CPTCFG_IWLWIFI_FRQ_MGR_TEST=y
23CPTCFG_IWLWIFI_OPMODE_MODULAR=y22CPTCFG_IWLWIFI_OPMODE_MODULAR=y
24CPTCFG_IWLWIFI_LTE_COEX=y
diff --git a/defconfigs/iwlwifi-public-android b/defconfigs/iwlwifi-public-android
index f430328..16114af 100644
--- a/defconfigs/iwlwifi-public-android
+++ b/defconfigs/iwlwifi-public-android
@@ -19,9 +19,6 @@ CPTCFG_IWLWIFI_DEVICE_TRACING=y
19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y
20# CPTCFG_MAC80211_HWSIM is not set20# CPTCFG_MAC80211_HWSIM is not set
21# CPTCFG_IWLXVT is not set21# CPTCFG_IWLXVT is not set
22# CPTCFG_IWLWIFI_FRQ_MGR_TEST is not set
23# CPTCFG_IWLWIFI_FRQ_MGR is not set
24CPTCFG_IWLWIFI_OPMODE_MODULAR=y22CPTCFG_IWLWIFI_OPMODE_MODULAR=y
25CPTCFG_IWLWIFI_LTE_COEX=y
26CPTCFG_IWLWIFI_BCAST_FILTERING=y23CPTCFG_IWLWIFI_BCAST_FILTERING=y
27# CPTCFG_IWLMVM_AX_SUPPORT is not set24# CPTCFG_IWLMVM_AX_SUPPORT is not set
diff --git a/defconfigs/prune-public b/defconfigs/prune-public
index 4076f6d..52e509d 100644
--- a/defconfigs/prune-public
+++ b/defconfigs/prune-public
@@ -17,6 +17,4 @@ CPTCFG_IWLWIFI_DEBUGFS=y
17CPTCFG_IWLWIFI_DEVICE_TRACING=y17CPTCFG_IWLWIFI_DEVICE_TRACING=y
18CPTCFG_IWLWIFI_DEVICE_TESTMODE=y18CPTCFG_IWLWIFI_DEVICE_TESTMODE=y
19CPTCFG_IWLXVT=m19CPTCFG_IWLXVT=m
20CPTCFG_IWLWIFI_FRQ_MGR_TEST=y
21CPTCFG_IWLWIFI_OPMODE_MODULAR=y20CPTCFG_IWLWIFI_OPMODE_MODULAR=y
22CPTCFG_IWLWIFI_LTE_COEX=y
diff --git a/defconfigs/soc_ip_hfpga b/defconfigs/soc_ip_hfpga
index 57aba4d..4485fbf 100644
--- a/defconfigs/soc_ip_hfpga
+++ b/defconfigs/soc_ip_hfpga
@@ -19,6 +19,4 @@ CPTCFG_IWLWIFI_DEVICE_TRACING=y
19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y19CPTCFG_IWLWIFI_DEVICE_TESTMODE=y
20CPTCFG_IWLXVT=m20CPTCFG_IWLXVT=m
21CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES=y21CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES=y
22# CPTCFG_IWLWIFI_FRQ_MGR_TEST is not set
23# CPTCFG_IWLWIFI_FORCE_OFDM_RATE is not set22# CPTCFG_IWLWIFI_FORCE_OFDM_RATE is not set
24# CPTCFG_IWLWIFI_LTE_COEX is not set
diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig.noupstream b/drivers/net/wireless/intel/iwlwifi/Kconfig.noupstream
index fb00937..434c115 100644
--- a/drivers/net/wireless/intel/iwlwifi/Kconfig.noupstream
+++ b/drivers/net/wireless/intel/iwlwifi/Kconfig.noupstream
@@ -38,26 +38,6 @@ config IWLWIFI_DEVICE_TESTMODE
38 default y if IWLMVM38 default y if IWLMVM
39 select IWLWIFI_SUPPORT_DEBUG_OVERRIDES39 select IWLWIFI_SUPPORT_DEBUG_OVERRIDES
4040
41config IWLWIFI_FRQ_MGR_TEST
42 bool "Enable Frequency Manager API - Test Mode"
43 depends on IWLMVM && IWLWIFI_SUPPORT_DEBUG_OVERRIDES
44 help
45 This option enables running The Frequency Manager API
46 in Debug Mode without having A Frequency Manager.
47 In this mode you can run the Frequency Manager on any Platform,
48 monitor the notifications that the driver send the Frequency Manager,
49 and initiate notifications from the Frequency Manager.
50
51config IWLWIFI_FRQ_MGR
52 bool "enable Frequency Manager API" if !IWLWIFI_FRQ_MGR_TEST
53 default y if IWLWIFI_FRQ_MGR_TEST
54 depends on IWLMVM && (IUI_FM || IWLWIFI_FRQ_MGR_TEST)
55 help
56 This option enables The Frequency Manager API.
57 Enabling this option allows the driver to receive and send
58 Frequency notification from and to the Frequency Manager.
59 The notification can involve Tx power, Rx gain, and ADC/DAC
60
61config IWLWIFI_SUPPORT_DEBUG_OVERRIDES41config IWLWIFI_SUPPORT_DEBUG_OVERRIDES
62 depends on IWLWIFI42 depends on IWLWIFI
63 bool "enable default value override (for debugging)"43 bool "enable default value override (for debugging)"
@@ -94,12 +74,6 @@ config IWLMVM_VENDOR_CMDS
94 This option mostly exists for non-upstream tagging, so best74 This option mostly exists for non-upstream tagging, so best
95 leave it set to Y.75 leave it set to Y.
9676
97config IWLWIFI_LTE_COEX
98 bool "enable lte coexistence support"
99 depends on IWLMVM_VENDOR_CMDS
100 help
101 This option enables LTE-Coexistence (vendor) commands
102
103config IWLMVM_TDLS_PEER_CACHE77config IWLMVM_TDLS_PEER_CACHE
104 bool "enable TDLS peer caching and traffic monitoring"78 bool "enable TDLS peer caching and traffic monitoring"
105 depends on IWLMVM_VENDOR_CMDS79 depends on IWLMVM_VENDOR_CMDS
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/coex.h b/drivers/net/wireless/intel/iwlwifi/fw/api/coex.h
index 33abd47..faf38ee 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/coex.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/coex.h
@@ -8,7 +8,7 @@
8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10 * Copyright(c) 2017 Intel Deutschland GmbH10 * Copyright(c) 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation11 * Copyright(c) 2018 - 2019 Intel Corporation
12 *12 *
13 * This program is free software; you can redistribute it and/or modify13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as14 * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
31 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.31 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH32 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
33 * Copyright(c) 2017 Intel Deutschland GmbH33 * Copyright(c) 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation34 * Copyright(c) 2018 - 2019 Intel Corporation
35 * All rights reserved.35 * All rights reserved.
36 *36 *
37 * Redistribution and use in source and binary forms, with or without37 * Redistribution and use in source and binary forms, with or without
@@ -242,124 +242,4 @@ struct iwl_bt_coex_profile_notif {
242 __le16 reserved;242 __le16 reserved;
243} __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_4 */243} __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_4 */
244244
245#ifdef CPTCFG_IWLWIFI_FRQ_MGR
246/*
247 * struct iwl_config_2g_coex_cmd - 2G Coex configuration command
248 * (CONFIG_2G_COEX_CMD = 0x71)
249 * @enabled: 2g coex is enabled/disabled
250 */
251struct iwl_config_2g_coex_cmd {
252 __le32 enabled;
253} __packed; /* CONFIG_2G_COEX_CMD_API_S_VER_1 */
254#endif
255
256#ifdef CPTCFG_IWLWIFI_LTE_COEX
257
258#define WIFI_BAND_24_NUM_CHANNELS 14
259#define LTE_COEX_MFUART_CONFIG_LENGTH 12
260#define LTE_COEX_FRAME_STRUCTURE_LENGTH 2
261
262/**
263 * struct iwl_lte_coex_config_cmd - LTE Coex configuration command
264 * @lte_state: lte modem state
265 * @lte_band: lte operating band
266 * @lte_chan: lte operating channel
267 * @lte_frame_structure: ?
268 * @tx_safe_freq_min: ?
269 * @tx_safe_freq_max: ?
270 * @rx_safe_freq_min: ?
271 * @rx_safe_freq_max: ?
272 * @max_tx_power: wifi static max tx output power per channel
273 *
274 * Used for LTE_COEX_CONFIG_CMD command
275 */
276struct iwl_lte_coex_config_cmd {
277 __le32 lte_state;
278 __le32 lte_band;
279 __le32 lte_chan;
280 __le32 lte_frame_structure[LTE_COEX_FRAME_STRUCTURE_LENGTH];
281 __le32 tx_safe_freq_min;
282 __le32 tx_safe_freq_max;
283 __le32 rx_safe_freq_min;
284 __le32 rx_safe_freq_max;
285 u8 max_tx_power[WIFI_BAND_24_NUM_CHANNELS];
286} __packed; /* LTE_COEX_CONFIG_CMD_API_S_VER_1 */
287
288/**
289 * struct iwl_lte_coex_static_params_cmd - LTE Coex static params configuration
290 * command
291 * @mfu_config: MFUART config and RT signals assert/de-assert timing
292 * @tx_power_in_dbm: Wifi safe power table
293 *
294 * Used for LTE_COEX_STATIC_PARAMS_CMD command
295 */
296struct iwl_lte_coex_static_params_cmd {
297 __le32 mfu_config[LTE_COEX_MFUART_CONFIG_LENGTH];
298 s8 tx_power_in_dbm[32];
299} __packed; /* LTE_COEX_STATIC_PARAMS_CMD_API_S_VER_1 */
300
301/**
302 * struct iwl_lte_coex_wifi_reported_channel_cmd - LTE Coex reported channels
303 * configuration command
304 * @channel: channel number (1-14)
305 * @bandwidth: bandwidth (0-3)
306 *
307 * Used for LTE_COEX_WIFI_REPORTED_CHANNEL_CMD command
308 */
309struct iwl_lte_coex_wifi_reported_channel_cmd {
310 __le32 channel;
311 __le32 bandwidth;
312} __packed; /* LTE_COEX_WIFI_REPORTED_CHANNEL_CMD_API_S_VER_1 */
313
314/**
315 * struct iwl_lte_coex_sps_cmd - LTE Coex semi persistent info command
316 *
317 * @lte_semi_persistent_info:
318 *
319 * Used for LTE_COEX_SPS_CMD command
320 */
321struct iwl_lte_coex_sps_cmd {
322 __le32 lte_semi_persistent_info;
323} __packed; /* LTE_COEX_WIFI_SPS_CMD_API_S_VER_1 */
324
325/**
326 * struct iwl_lte_coex_fine_tuning_params_cmd - LTE Coex fine tuning parameters
327 * @rx_protection_assert_timing: 802_RX_PRI request advance time
328 * @tx_protection_assert_timing: 802_TX_ON request advance time
329 * @rx_protection_timeout: Cancel Rx Protection request due to no Rx threshold
330 * @min_tx_power: Min-Tx-Power threshold for Data/Management frames
331 * @lte_ul_load_uapsd_threshold: 'LTE UL Load' counter thresholds
332 * for recommending Power-Manager to enter to UAPSD
333 * @rx_failure_during_ul_uapsd_threshold: 'Rx Failure due to UL' counter
334 * thresholds for recommending Power-Manager to enter to UAPSD
335 * @rx_failure_during_ul_sc_threshold: 'Rx Failure due to UL'
336 * counter threshold for recommending Scan-Manager to apply compensation
337 * @rx_duration_for_ack_protection_us: Tx Ack size for Tx Protection
338 * @beacon_failure_during_ul_counter: Failed Rx Beacon threshold
339 * @dtim_failure_during_ul_counter: Failed Rx DTIM threshold
340 *
341 * Used for LTE_COEX_FINE_TUNING_PARAMS_CMD command
342 */
343struct iwl_lte_coex_fine_tuning_params_cmd {
344 __le32 rx_protection_assert_timing;
345 __le32 tx_protection_assert_timing;
346 __le32 rx_protection_timeout;
347 __le32 min_tx_power;
348 __le32 lte_ul_load_uapsd_threshold;
349 __le32 rx_failure_during_ul_uapsd_threshold;
350 __le32 rx_failure_during_ul_sc_threshold;
351 __le32 rx_duration_for_ack_protection_us;
352 __le32 beacon_failure_during_ul_counter;
353 __le32 dtim_failure_during_ul_counter;
354} __packed; /* LTE_COEX_FINE_TUNING_PARAMS_CMD_API_S_VER_1 */
355
356/**
357 * struct iwl_lte_coex_statistic_ntfy - LTE Coex statistics notification
358 * @statistic_placeholder: placeholder
359 */
360struct iwl_lte_coex_statistic_ntfy {
361 __le32 statistic_placeholder;
362} __packed; /* LTE_COEX_STATISTIC_NTFY_API_S_VER_1 */
363#endif /* CPTCFG_IWLWIFI_LTE_COEX */
364
365#endif /* __iwl_fw_api_coex_h__ */245#endif /* __iwl_fw_api_coex_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
index e7eecb1..d665938 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
@@ -8,7 +8,7 @@
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation11 * Copyright(c) 2018 - 2019 Intel Corporation
12 *12 *
13 * This program is free software; you can redistribute it and/or modify13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as14 * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation34 * Copyright(c) 2018 - 2019 Intel Corporation
35 * All rights reserved.35 * All rights reserved.
36 *36 *
37 * Redistribution and use in source and binary forms, with or without37 * Redistribution and use in source and binary forms, with or without
@@ -540,35 +540,6 @@ enum iwl_legacy_cmds {
540 */540 */
541 BT_COEX_CI = 0x5d,541 BT_COEX_CI = 0x5d,
542542
543#ifdef CPTCFG_IWLWIFI_LTE_COEX
544 /**
545 * @LTE_COEX_CONFIG_CMD: &struct iwl_lte_coex_config_cmd
546 */
547 LTE_COEX_CONFIG_CMD = 0x4a,
548
549 /**
550 * @LTE_COEX_WIFI_REPORTED_CHANNEL_CMD:
551 * &struct iwl_lte_coex_wifi_reported_channel_cmd
552 */
553 LTE_COEX_WIFI_REPORTED_CHANNEL_CMD = 0X4b,
554
555 /**
556 * @LTE_COEX_STATIC_PARAMS_CMD: &struct iwl_lte_coex_static_params_cmd
557 */
558 LTE_COEX_STATIC_PARAMS_CMD = 0x4c,
559
560 /**
561 * @LTE_COEX_SPS_CMD: struct iwl_lte_coex_sps_cmd
562 */
563 LTE_COEX_SPS_CMD = 0x4d,
564
565 /**
566 * @LTE_COEX_FINE_TUNING_PARAMS_CMD:
567 * &struct iwl_lte_coex_fine_tuning_params_cmd
568 */
569 LTE_COEX_FINE_TUNING_PARAMS_CMD = 0x57,
570#endif
571
572 /**543 /**
573 * @REPLY_SF_CFG_CMD: &struct iwl_sf_cfg_cmd544 * @REPLY_SF_CFG_CMD: &struct iwl_sf_cfg_cmd
574 */545 */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rs.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rs.h
index 9eddc4d..4347be6 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rs.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rs.h
@@ -7,7 +7,7 @@
7 *7 *
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2017 Intel Deutschland GmbH9 * Copyright(c) 2017 Intel Deutschland GmbH
10 * Copyright(c) 2018 Intel Corporation10 * Copyright(c) 2018 - 2019 Intel Corporation
11 *11 *
12 * This program is free software; you can redistribute it and/or modify12 * 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 as13 * it under the terms of version 2 of the GNU General Public License as
@@ -29,7 +29,7 @@
29 *29 *
30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.30 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2017 Intel Deutschland GmbH31 * Copyright(c) 2017 Intel Deutschland GmbH
32 * Copyright(c) 2018 Intel Corporation32 * Copyright(c) 2018 - 2019 Intel Corporation
33 * All rights reserved.33 * All rights reserved.
34 *34 *
35 * Redistribution and use in source and binary forms, with or without35 * Redistribution and use in source and binary forms, with or without
@@ -166,8 +166,16 @@ enum iwl_tlc_mng_ht_rates {
166 IWL_TLC_MNG_HT_RATE_MAX = IWL_TLC_MNG_HT_RATE_MCS11,166 IWL_TLC_MNG_HT_RATE_MAX = IWL_TLC_MNG_HT_RATE_MCS11,
167};167};
168168
169/* Maximum supported tx antennas number */169enum IWL_TLC_MNG_NSS {
170#define MAX_NSS 2170 IWL_TLC_NSS_1,
171 IWL_TLC_NSS_2,
172 IWL_TLC_NSS_MAX
173};
174
175enum IWL_TLC_HT_BW_RATES {
176 IWL_TLC_HT_BW_NONE_160,
177 IWL_TLC_HT_BW_160,
178};
171179
172/**180/**
173 * struct tlc_config_cmd - TLC configuration181 * struct tlc_config_cmd - TLC configuration
@@ -195,7 +203,7 @@ struct iwl_tlc_config_cmd {
195 u8 amsdu;203 u8 amsdu;
196 __le16 flags;204 __le16 flags;
197 __le16 non_ht_rates;205 __le16 non_ht_rates;
198 __le16 ht_rates[MAX_NSS][2];206 __le16 ht_rates[IWL_TLC_NSS_MAX][2];
199 __le16 max_mpdu_len;207 __le16 max_mpdu_len;
200 u8 sgi_ch_width_supp;208 u8 sgi_ch_width_supp;
201 u8 reserved2[1];209 u8 reserved2[1];
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
index 1940a8c..8678b78 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
@@ -93,6 +93,8 @@ struct iwl_ssid_ie {
93#define IWL_SCAN_SHORT_BLACKLIST_LEN 1693#define IWL_SCAN_SHORT_BLACKLIST_LEN 16
94#define IWL_SCAN_MAX_PROFILES 1194#define IWL_SCAN_MAX_PROFILES 11
95#define SCAN_OFFLOAD_PROBE_REQ_SIZE 51295#define SCAN_OFFLOAD_PROBE_REQ_SIZE 512
96#define SCAN_NUM_BAND_PROBE_DATA_V_1 2
97#define SCAN_NUM_BAND_PROBE_DATA_V_2 3
9698
97/* Default watchdog (in MS) for scheduled scan iteration */99/* Default watchdog (in MS) for scheduled scan iteration */
98#define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)100#define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
@@ -252,9 +254,22 @@ struct iwl_scan_probe_segment {
252 * @common_data: last (and common) part of the probe254 * @common_data: last (and common) part of the probe
253 * @buf: raw data block255 * @buf: raw data block
254 */256 */
257struct iwl_scan_probe_req_v1 {
258 struct iwl_scan_probe_segment mac_header;
259 struct iwl_scan_probe_segment band_data[SCAN_NUM_BAND_PROBE_DATA_V_1];
260 struct iwl_scan_probe_segment common_data;
261 u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
262} __packed;
263
264/* iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_v2
265 * @mac_header: first (and common) part of the probe
266 * @band_data: band specific data
267 * @common_data: last (and common) part of the probe
268 * @buf: raw data block
269 */
255struct iwl_scan_probe_req {270struct iwl_scan_probe_req {
256 struct iwl_scan_probe_segment mac_header;271 struct iwl_scan_probe_segment mac_header;
257 struct iwl_scan_probe_segment band_data[2];272 struct iwl_scan_probe_segment band_data[SCAN_NUM_BAND_PROBE_DATA_V_2];
258 struct iwl_scan_probe_segment common_data;273 struct iwl_scan_probe_segment common_data;
259 u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];274 u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
260} __packed;275} __packed;
@@ -627,15 +642,29 @@ enum iwl_umac_scan_general_flags2 {
627 * struct iwl_scan_channel_cfg_umac642 * struct iwl_scan_channel_cfg_umac
628 * @flags: bitmap - 0-19: directed scan to i'th ssid.643 * @flags: bitmap - 0-19: directed scan to i'th ssid.
629 * @channel_num: channel number 1-13 etc.644 * @channel_num: channel number 1-13 etc.
645 * @band: band of channel: 0 for 2GHz, 1 for 5GHz
630 * @iter_count: repetition count for the channel.646 * @iter_count: repetition count for the channel.
631 * @iter_interval: interval between two scan iterations on one channel.647 * @iter_interval: interval between two scan iterations on one channel.
632 */648 */
633struct iwl_scan_channel_cfg_umac {649struct iwl_scan_channel_cfg_umac {
634 __le32 flags;650 __le32 flags;
635 u8 channel_num;651 /* Both versions are of the same size, so use a union without adjusting
636 u8 iter_count;652 * the command size later
637 __le16 iter_interval;653 */
638} __packed; /* SCAN_CHANNEL_CFG_S_VER2 */654 union {
655 struct {
656 u8 channel_num;
657 u8 iter_count;
658 __le16 iter_interval;
659 } v1; /* SCAN_CHANNEL_CFG_S_VER1 */
660 struct {
661 u8 channel_num;
662 u8 band;
663 u8 iter_count;
664 u8 iter_interval;
665 } v2; /* SCAN_CHANNEL_CFG_S_VER2 */
666 };
667} __packed;
639668
640/**669/**
641 * struct iwl_scan_umac_schedule670 * struct iwl_scan_umac_schedule
@@ -649,6 +678,16 @@ struct iwl_scan_umac_schedule {
649 u8 reserved;678 u8 reserved;
650} __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */679} __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
651680
681struct iwl_scan_req_umac_tail_v1 {
682 /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
683 struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
684 __le16 delay;
685 __le16 reserved;
686 /* SCAN_PROBE_PARAMS_API_S_VER_1 */
687 struct iwl_scan_probe_req_v1 preq;
688 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
689} __packed;
690
652/**691/**
653 * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command692 * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command
654 * parameters following channels configuration array.693 * parameters following channels configuration array.
@@ -658,12 +697,12 @@ struct iwl_scan_umac_schedule {
658 * @preq: probe request with IEs blocks697 * @preq: probe request with IEs blocks
659 * @direct_scan: list of SSIDs for directed active scan698 * @direct_scan: list of SSIDs for directed active scan
660 */699 */
661struct iwl_scan_req_umac_tail {700struct iwl_scan_req_umac_tail_v2 {
662 /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */701 /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
663 struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];702 struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
664 __le16 delay;703 __le16 delay;
665 __le16 reserved;704 __le16 reserved;
666 /* SCAN_PROBE_PARAMS_API_S_VER_1 */705 /* SCAN_PROBE_PARAMS_API_S_VER_2 */
667 struct iwl_scan_probe_req preq;706 struct iwl_scan_probe_req preq;
668 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];707 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
669} __packed;708} __packed;
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index b3f8e7f..a2b9299 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -248,9 +248,6 @@ enum iwl_ucode_tlv_flag {
248 IWL_UCODE_TLV_FLAGS_EBS_SUPPORT = BIT(25),248 IWL_UCODE_TLV_FLAGS_EBS_SUPPORT = BIT(25),
249 IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD = BIT(26),249 IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD = BIT(26),
250 IWL_UCODE_TLV_FLAGS_BCAST_FILTERING = BIT(29),250 IWL_UCODE_TLV_FLAGS_BCAST_FILTERING = BIT(29),
251#ifdef CPTCFG_IWLWIFI_LTE_COEX
252 IWL_UCODE_TLV_FLAGS_LTE_COEX = BIT(31),
253#endif
254};251};
255252
256typedef unsigned int __bitwise iwl_ucode_tlv_api_t;253typedef unsigned int __bitwise iwl_ucode_tlv_api_t;
@@ -335,6 +332,7 @@ enum iwl_ucode_tlv_api {
335 IWL_UCODE_TLV_API_SAR_TABLE_VER = (__force iwl_ucode_tlv_api_t)55,332 IWL_UCODE_TLV_API_SAR_TABLE_VER = (__force iwl_ucode_tlv_api_t)55,
336 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG = (__force iwl_ucode_tlv_api_t)56,333 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG = (__force iwl_ucode_tlv_api_t)56,
337 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = (__force iwl_ucode_tlv_api_t)57,334 IWL_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = (__force iwl_ucode_tlv_api_t)57,
335 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER = (__force iwl_ucode_tlv_api_t)58,
338336
339 NUM_IWL_UCODE_TLV_API337 NUM_IWL_UCODE_TLV_API
340#ifdef __CHECKER__338#ifdef __CHECKER__
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-cfg.h b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-cfg.h
index 75ceca4..f470ca4 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-cfg.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-cfg.h
@@ -204,9 +204,6 @@ struct iwl_dbg_cfg {
204 IWL_MVM_MOD_PARAM(bool, init_dbg)204 IWL_MVM_MOD_PARAM(bool, init_dbg)
205 IWL_MVM_MOD_PARAM(bool, tfd_q_hang_detect)205 IWL_MVM_MOD_PARAM(bool, tfd_q_hang_detect)
206#endif /* CPTCFG_IWLMVM */206#endif /* CPTCFG_IWLMVM */
207#ifdef CPTCFG_IWLWIFI_FRQ_MGR_TEST
208 IWL_DBG_CFG_NODEF(u8, fm_debug_mode)
209#endif
210#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE207#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE
211 IWL_DBG_CFG_NODEF(u32, dnt_out_mode)208 IWL_DBG_CFG_NODEF(u32, dnt_out_mode)
212 /* XXX: should be dbgm_ or dbg_mon_ for consistency? */209 /* XXX: should be dbgm_ or dbg_mon_ for consistency? */
@@ -262,18 +259,17 @@ struct iwl_dbg_cfg {
262 IWL_DBG_CFG_STR(fw_dbg_conf)259 IWL_DBG_CFG_STR(fw_dbg_conf)
263 IWL_DBG_CFG_STR(nvm_file)260 IWL_DBG_CFG_STR(nvm_file)
264 IWL_DBG_CFG_STR(fw_file_pre)261 IWL_DBG_CFG_STR(fw_file_pre)
265 IWL_DBG_CFG_NODEF(u32, d0i3_debug)
266 IWL_DBG_CFG_NODEF(u32, valid_ants)262 IWL_DBG_CFG_NODEF(u32, valid_ants)
267 IWL_DBG_CFG_NODEF(u32, no_ack_en)263 IWL_DBG_CFG_NODEF(u32, no_ack_en)
268 IWL_DBG_CFG_NODEF(bool, no_ldpc)264 IWL_DBG_CFG_NODEF(bool, no_ldpc)
269 IWL_DBG_CFG_NODEF(u16, rx_agg_subframes)265 IWL_DBG_CFG_NODEF(u16, rx_agg_subframes)
266 IWL_DBG_CFG_NODEF(bool, tx_siso_80bw_like_160bw)
270 IWL_DBG_CFG_NODEF(u16, rx_mcs_80)267 IWL_DBG_CFG_NODEF(u16, rx_mcs_80)
271 IWL_DBG_CFG_NODEF(u16, tx_mcs_80)268 IWL_DBG_CFG_NODEF(u16, tx_mcs_80)
272 IWL_DBG_CFG_NODEF(u16, rx_mcs_160)269 IWL_DBG_CFG_NODEF(u16, rx_mcs_160)
273 IWL_DBG_CFG_NODEF(u16, tx_mcs_160)270 IWL_DBG_CFG_NODEF(u16, tx_mcs_160)
274 IWL_DBG_CFG_NODEF(u32, secure_boot_cfg)271 IWL_DBG_CFG_NODEF(u32, secure_boot_cfg)
275 IWL_MOD_PARAM(u32, uapsd_disable)272 IWL_MOD_PARAM(u32, uapsd_disable)
276 IWL_MOD_PARAM(bool, d0i3_disable)
277 IWL_MOD_PARAM(bool, lar_disable)273 IWL_MOD_PARAM(bool, lar_disable)
278 IWL_MOD_PARAM(bool, fw_monitor)274 IWL_MOD_PARAM(bool, fw_monitor)
279 IWL_MOD_PARAM(bool, fw_restart)275 IWL_MOD_PARAM(bool, fw_restart)
@@ -285,7 +281,6 @@ struct iwl_dbg_cfg {
285 IWL_MOD_PARAM(int, amsdu_size)281 IWL_MOD_PARAM(int, amsdu_size)
286 IWL_MOD_PARAM(int, swcrypto)282 IWL_MOD_PARAM(int, swcrypto)
287 IWL_MOD_PARAM(uint, disable_11n)283 IWL_MOD_PARAM(uint, disable_11n)
288 IWL_MOD_PARAM(uint, d0i3_timeout)
289 IWL_DBG_CFG_BIN(he_ppe_thres)284 IWL_DBG_CFG_BIN(he_ppe_thres)
290 IWL_DBG_CFG_NODEF(u8, he_chan_width_dis)285 IWL_DBG_CFG_NODEF(u8, he_chan_width_dis)
291 IWL_DBG_CFG_NODEF(u32, vht_cap_flip)286 IWL_DBG_CFG_NODEF(u32, vht_cap_flip)
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 2308b4f..c4bfbb8 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -2048,8 +2048,6 @@ struct iwl_mod_params iwlwifi_mod_params = {
2048 .fw_restart = true,2048 .fw_restart = true,
2049 .bt_coex_active = true,2049 .bt_coex_active = true,
2050 .power_level = IWL_POWER_INDEX_1,2050 .power_level = IWL_POWER_INDEX_1,
2051 .d0i3_disable = true,
2052 .d0i3_timeout = 1000,
2053 .uapsd_disable = IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT,2051 .uapsd_disable = IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT,
2054 /* the rest are 0 by default */2052 /* the rest are 0 by default */
2055};2053};
@@ -2202,9 +2200,6 @@ MODULE_PARM_DESC(antenna_coupling,
2202module_param_named(nvm_file, iwlwifi_mod_params.nvm_file, charp, 0444);2200module_param_named(nvm_file, iwlwifi_mod_params.nvm_file, charp, 0444);
2203MODULE_PARM_DESC(nvm_file, "NVM file name");2201MODULE_PARM_DESC(nvm_file, "NVM file name");
22042202
2205module_param_named(d0i3_disable, iwlwifi_mod_params.d0i3_disable, bool, 0444);
2206MODULE_PARM_DESC(d0i3_disable, "disable d0i3 functionality (default: N)");
2207
2208module_param_named(lar_disable, iwlwifi_mod_params.lar_disable, bool, 0444);2203module_param_named(lar_disable, iwlwifi_mod_params.lar_disable, bool, 0444);
2209MODULE_PARM_DESC(lar_disable, "disable LAR functionality (default: N)");2204MODULE_PARM_DESC(lar_disable, "disable LAR functionality (default: N)");
22102205
@@ -2252,9 +2247,6 @@ module_param_named(fw_monitor, iwlwifi_mod_params.fw_monitor, bool, 0444);
2252MODULE_PARM_DESC(fw_monitor,2247MODULE_PARM_DESC(fw_monitor,
2253 "firmware monitor - to debug FW (default: false - needs lots of memory)");2248 "firmware monitor - to debug FW (default: false - needs lots of memory)");
22542249
2255module_param_named(d0i3_timeout, iwlwifi_mod_params.d0i3_timeout, uint, 0444);
2256MODULE_PARM_DESC(d0i3_timeout, "Timeout to D0i3 entry when idle (ms)");
2257
2258module_param_named(disable_11ac, iwlwifi_mod_params.disable_11ac, bool, 0444);2250module_param_named(disable_11ac, iwlwifi_mod_params.disable_11ac, bool, 0444);
2259MODULE_PARM_DESC(disable_11ac, "Disable VHT capabilities (default: false)");2251MODULE_PARM_DESC(disable_11ac, "Disable VHT capabilities (default: false)");
22602252
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
index d8d1202..27d2cb3 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-modparams.h
@@ -6,7 +6,7 @@
6 * GPL LICENSE SUMMARY6 * GPL LICENSE SUMMARY
7 *7 *
8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2018 Intel Corporation9 * Copyright(c) 2018 - 2019 Intel Corporation
10 *10 *
11 * This program is free software; you can redistribute it and/or modify11 * 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 as12 * it under the terms of version 2 of the GNU General Public License as
@@ -27,7 +27,7 @@
27 * BSD LICENSE27 * BSD LICENSE
28 *28 *
29 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.29 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2018 Intel Corporation30 * Copyright(c) 2018 - 2019 Intel Corporation
31 * All rights reserved.31 * All rights reserved.
32 *32 *
33 * Redistribution and use in source and binary forms, with or without33 * Redistribution and use in source and binary forms, with or without
@@ -116,9 +116,6 @@ enum iwl_uapsd_disable {
116 * @uapsd_disable: disable U-APSD, see &enum iwl_uapsd_disable, default =116 * @uapsd_disable: disable U-APSD, see &enum iwl_uapsd_disable, default =
117 * IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT117 * IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT
118 * @xvt_default_mode: xVT is the default operation mode, default = false118 * @xvt_default_mode: xVT is the default operation mode, default = false
119 * @d0i3_disable: disable d0i3, default = 1,
120 * @d0i3_timeout: time to wait after no refs are taken before
121 * entering D0i3 (in msecs)
122 * @lar_disable: disable LAR (regulatory), default = 0119 * @lar_disable: disable LAR (regulatory), default = 0
123 * @fw_monitor: allow to use firmware monitor120 * @fw_monitor: allow to use firmware monitor
124 * @disable_11ac: disable VHT capabilities, default = false.121 * @disable_11ac: disable VHT capabilities, default = false.
@@ -144,8 +141,6 @@ struct iwl_mod_params {
144#endif141#endif
145 char *nvm_file;142 char *nvm_file;
146 u32 uapsd_disable;143 u32 uapsd_disable;
147 bool d0i3_disable;
148 unsigned int d0i3_timeout;
149 bool lar_disable;144 bool lar_disable;
150 bool fw_monitor;145 bool fw_monitor;
151 bool disable_11ac;146 bool disable_11ac;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
index 2f4ecde..fcb0b69 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
@@ -166,9 +166,6 @@ struct iwl_test_ops {
166 * @nic_config: configure NIC, called before firmware is started.166 * @nic_config: configure NIC, called before firmware is started.
167 * May sleep167 * May sleep
168 * @wimax_active: invoked when WiMax becomes active. May sleep168 * @wimax_active: invoked when WiMax becomes active. May sleep
169 * @enter_d0i3: configure the fw to enter d0i3. return 1 to indicate d0i3
170 * entrance is aborted (e.g. due to held reference). May sleep.
171 * @exit_d0i3: configure the fw to exit d0i3. May sleep.
172 */169 */
173struct iwl_op_mode_ops {170struct iwl_op_mode_ops {
174 struct iwl_op_mode *(*start)(struct iwl_trans *trans,171 struct iwl_op_mode *(*start)(struct iwl_trans *trans,
@@ -193,8 +190,6 @@ struct iwl_op_mode_ops {
193#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE190#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE
194 struct iwl_test_ops test_ops;191 struct iwl_test_ops test_ops;
195#endif192#endif
196 int (*enter_d0i3)(struct iwl_op_mode *op_mode);
197 int (*exit_d0i3)(struct iwl_op_mode *op_mode);
198};193};
199194
200int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops);195int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops);
@@ -287,22 +282,4 @@ static inline void iwl_op_mode_wimax_active(struct iwl_op_mode *op_mode)
287 op_mode->ops->wimax_active(op_mode);282 op_mode->ops->wimax_active(op_mode);
288}283}
289284
290static inline int iwl_op_mode_enter_d0i3(struct iwl_op_mode *op_mode)
291{
292 might_sleep();
293
294 if (!op_mode->ops->enter_d0i3)
295 return 0;
296 return op_mode->ops->enter_d0i3(op_mode);
297}
298
299static inline int iwl_op_mode_exit_d0i3(struct iwl_op_mode *op_mode)
300{
301 might_sleep();
302
303 if (!op_mode->ops->exit_d0i3)
304 return 0;
305 return op_mode->ops->exit_d0i3(op_mode);
306}
307
308#endif /* __iwl_op_mode_h__ */285#endif /* __iwl_op_mode_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index 2c93164..7223469 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -205,17 +205,3 @@ int iwl_cmd_groups_verify_sorted(const struct iwl_trans_config *trans)
205 return 0;205 return 0;
206}206}
207IWL_EXPORT_SYMBOL(iwl_cmd_groups_verify_sorted);207IWL_EXPORT_SYMBOL(iwl_cmd_groups_verify_sorted);
208
209void iwl_trans_ref(struct iwl_trans *trans)
210{
211 if (trans->ops->ref)
212 trans->ops->ref(trans);
213}
214IWL_EXPORT_SYMBOL(iwl_trans_ref);
215
216void iwl_trans_unref(struct iwl_trans *trans)
217{
218 if (trans->ops->unref)
219 trans->ops->unref(trans);
220}
221IWL_EXPORT_SYMBOL(iwl_trans_unref);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 43cfa59..6d156ee 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -165,10 +165,6 @@ static inline u32 iwl_rx_packet_payload_len(const struct iwl_rx_packet *pkt)
165 * @CMD_ASYNC: Return right away and don't wait for the response165 * @CMD_ASYNC: Return right away and don't wait for the response
166 * @CMD_WANT_SKB: Not valid with CMD_ASYNC. The caller needs the buffer of166 * @CMD_WANT_SKB: Not valid with CMD_ASYNC. The caller needs the buffer of
167 * the response. The caller needs to call iwl_free_resp when done.167 * the response. The caller needs to call iwl_free_resp when done.
168 * @CMD_SEND_IN_IDLE: The command should be sent even when the trans is idle.
169 * @CMD_MAKE_TRANS_IDLE: The command response should mark the trans as idle.
170 * @CMD_WAKE_UP_TRANS: The command response should wake up the trans
171 * (i.e. mark it as non-idle).
172 * @CMD_WANT_ASYNC_CALLBACK: the op_mode's async callback function must be168 * @CMD_WANT_ASYNC_CALLBACK: the op_mode's async callback function must be
173 * called after this command completes. Valid only with CMD_ASYNC.169 * called after this command completes. Valid only with CMD_ASYNC.
174 */170 */
@@ -176,10 +172,7 @@ enum CMD_MODE {
176 CMD_ASYNC = BIT(0),172 CMD_ASYNC = BIT(0),
177 CMD_WANT_SKB = BIT(1),173 CMD_WANT_SKB = BIT(1),
178 CMD_SEND_IN_RFKILL = BIT(2),174 CMD_SEND_IN_RFKILL = BIT(2),
179 CMD_SEND_IN_IDLE = BIT(3),175 CMD_WANT_ASYNC_CALLBACK = BIT(3),
180 CMD_MAKE_TRANS_IDLE = BIT(4),
181 CMD_WAKE_UP_TRANS = BIT(5),
182 CMD_WANT_ASYNC_CALLBACK = BIT(6),
183};176};
184177
185#define DEF_CMD_PAYLOAD_SIZE 320178#define DEF_CMD_PAYLOAD_SIZE 320
@@ -467,9 +460,8 @@ struct iwl_trans_rxq_dma_data {
467 *460 *
468 * All the handlers MUST be implemented461 * All the handlers MUST be implemented
469 *462 *
470 * @start_hw: starts the HW. If low_power is true, the NIC needs to be taken463 * @start_hw: starts the HW. From that point on, the HW can send interrupts.
471 * out of a low power state. From that point on, the HW can send464 * May sleep.
472 * interrupts. May sleep.
473 * @op_mode_leave: Turn off the HW RF kill indication if on465 * @op_mode_leave: Turn off the HW RF kill indication if on
474 * May sleep466 * May sleep
475 * @start_fw: allocates and inits all the resources for the transport467 * @start_fw: allocates and inits all the resources for the transport
@@ -479,9 +471,8 @@ struct iwl_trans_rxq_dma_data {
479 * the SCD base address in SRAM, then provide it here, or 0 otherwise.471 * the SCD base address in SRAM, then provide it here, or 0 otherwise.
480 * May sleep472 * May sleep
481 * @stop_device: stops the whole device (embedded CPU put to reset) and stops473 * @stop_device: stops the whole device (embedded CPU put to reset) and stops
482 * the HW. If low_power is true, the NIC will be put in low power state.474 * the HW. From that point on, the HW will be stopped but will still issue
483 * From that point on, the HW will be stopped but will still issue an475 * an interrupt if the HW RF kill switch is triggered.
484 * interrupt if the HW RF kill switch is triggered.
485 * This callback must do the right thing and not crash even if %start_hw()476 * This callback must do the right thing and not crash even if %start_hw()
486 * was called but not &start_fw(). May sleep.477 * was called but not &start_fw(). May sleep.
487 * @d3_suspend: put the device into the correct mode for WoWLAN during478 * @d3_suspend: put the device into the correct mode for WoWLAN during
@@ -539,11 +530,6 @@ struct iwl_trans_rxq_dma_data {
539 * @release_nic_access: let the NIC go to sleep. The "flags" parameter530 * @release_nic_access: let the NIC go to sleep. The "flags" parameter
540 * must be the same one that was sent before to the grab_nic_access.531 * must be the same one that was sent before to the grab_nic_access.
541 * @set_bits_mask - set SRAM register according to value and mask.532 * @set_bits_mask - set SRAM register according to value and mask.
542 * @ref: grab a reference to the transport/FW layers, disallowing
543 * certain low power states
544 * @unref: release a reference previously taken with @ref. Note that
545 * initially the reference count is 1, making an initial @unref
546 * necessary to allow low power states.
547 * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing last533 * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing last
548 * TX'ed commands and similar. The buffer will be vfree'd by the caller.534 * TX'ed commands and similar. The buffer will be vfree'd by the caller.
549 * Note that the transport must fill in the proper file headers.535 * Note that the transport must fill in the proper file headers.
@@ -552,7 +538,7 @@ struct iwl_trans_rxq_dma_data {
552 */538 */
553struct iwl_trans_ops {539struct iwl_trans_ops {
554540
555 int (*start_hw)(struct iwl_trans *iwl_trans, bool low_power);541 int (*start_hw)(struct iwl_trans *iwl_trans);
556 void (*op_mode_leave)(struct iwl_trans *iwl_trans);542 void (*op_mode_leave)(struct iwl_trans *iwl_trans);
557#if IS_ENABLED(CPTCFG_IWLXVT)543#if IS_ENABLED(CPTCFG_IWLXVT)
558 int (*start_fw_dbg)(struct iwl_trans *trans, const struct fw_img *fw,544 int (*start_fw_dbg)(struct iwl_trans *trans, const struct fw_img *fw,
@@ -562,7 +548,7 @@ struct iwl_trans_ops {
562 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw,548 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw,
563 bool run_in_rfkill);549 bool run_in_rfkill);
564 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr);550 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr);
565 void (*stop_device)(struct iwl_trans *trans, bool low_power);551 void (*stop_device)(struct iwl_trans *trans);
566552
567 void (*d3_suspend)(struct iwl_trans *trans, bool test, bool reset);553 void (*d3_suspend)(struct iwl_trans *trans, bool test, bool reset);
568 int (*d3_resume)(struct iwl_trans *trans, enum iwl_d3_status *status,554 int (*d3_resume)(struct iwl_trans *trans, enum iwl_d3_status *status,
@@ -575,6 +561,8 @@ struct iwl_trans_ops {
575 void (*reclaim)(struct iwl_trans *trans, int queue, int ssn,561 void (*reclaim)(struct iwl_trans *trans, int queue, int ssn,
576 struct sk_buff_head *skbs);562 struct sk_buff_head *skbs);
577563
564 void (*set_q_ptrs)(struct iwl_trans *trans, int queue, int ptr);
565
578 bool (*txq_enable)(struct iwl_trans *trans, int queue, u16 ssn,566 bool (*txq_enable)(struct iwl_trans *trans, int queue, u16 ssn,
579 const struct iwl_trans_txq_scd_cfg *cfg,567 const struct iwl_trans_txq_scd_cfg *cfg,
580 unsigned int queue_wdg_timeout);568 unsigned int queue_wdg_timeout);
@@ -616,8 +604,6 @@ struct iwl_trans_ops {
616 unsigned long *flags);604 unsigned long *flags);
617 void (*set_bits_mask)(struct iwl_trans *trans, u32 reg, u32 mask,605 void (*set_bits_mask)(struct iwl_trans *trans, u32 reg, u32 mask,
618 u32 value);606 u32 value);
619 void (*ref)(struct iwl_trans *trans);
620 void (*unref)(struct iwl_trans *trans);
621 int (*suspend)(struct iwl_trans *trans);607 int (*suspend)(struct iwl_trans *trans);
622 void (*resume)(struct iwl_trans *trans);608 void (*resume)(struct iwl_trans *trans);
623609
@@ -641,9 +627,6 @@ enum iwl_trans_state {
641/**627/**
642 * DOC: Platform power management628 * DOC: Platform power management
643 *629 *
644 * There are two types of platform power management: system-wide
645 * (WoWLAN) and runtime.
646 *
647 * In system-wide power management the entire platform goes into a low630 * In system-wide power management the entire platform goes into a low
648 * power state (e.g. idle or suspend to RAM) at the same time and the631 * power state (e.g. idle or suspend to RAM) at the same time and the
649 * device is configured as a wakeup source for the entire platform.632 * device is configured as a wakeup source for the entire platform.
@@ -652,55 +635,34 @@ enum iwl_trans_state {
652 * put the platform in low power mode). The device's behavior in this635 * put the platform in low power mode). The device's behavior in this
653 * mode is dictated by the wake-on-WLAN configuration.636 * mode is dictated by the wake-on-WLAN configuration.
654 *637 *
655 * In runtime power management, only the devices which are themselves
656 * idle enter a low power state. This is done at runtime, which means
657 * that the entire system is still running normally. This mode is
658 * usually triggered automatically by the device driver and requires
659 * the ability to enter and exit the low power modes in a very short
660 * time, so there is not much impact in usability.
661 *
662 * The terms used for the device's behavior are as follows:638 * The terms used for the device's behavior are as follows:
663 *639 *
664 * - D0: the device is fully powered and the host is awake;640 * - D0: the device is fully powered and the host is awake;
665 * - D3: the device is in low power mode and only reacts to641 * - D3: the device is in low power mode and only reacts to
666 * specific events (e.g. magic-packet received or scan642 * specific events (e.g. magic-packet received or scan
667 * results found);643 * results found);
668 * - D0I3: the device is in low power mode and reacts to any
669 * activity (e.g. RX);
670 *644 *
671 * These terms reflect the power modes in the firmware and are not to645 * These terms reflect the power modes in the firmware and are not to
672 * be confused with the physical device power state. The NIC can be646 * be confused with the physical device power state.
673 * in D0I3 mode even if, for instance, the PCI device is in D3 state.
674 */647 */
675648
676/**649/**
677 * enum iwl_plat_pm_mode - platform power management mode650 * enum iwl_plat_pm_mode - platform power management mode
678 *651 *
679 * This enumeration describes the device's platform power management652 * This enumeration describes the device's platform power management
680 * behavior when in idle mode (i.e. runtime power management) or when653 * behavior when in system-wide suspend (i.e WoWLAN).
681 * in system-wide suspend (i.e WoWLAN).
682 *654 *
683 * @IWL_PLAT_PM_MODE_DISABLED: power management is disabled for this655 * @IWL_PLAT_PM_MODE_DISABLED: power management is disabled for this
684 * device. At runtime, this means that nothing happens and the656 * device. In system-wide suspend mode, it means that the all
685 * device always remains in active. In system-wide suspend mode,657 * connections will be closed automatically by mac80211 before
686 * it means that the all connections will be closed automatically658 * the platform is suspended.
687 * by mac80211 before the platform is suspended.
688 * @IWL_PLAT_PM_MODE_D3: the device goes into D3 mode (i.e. WoWLAN).659 * @IWL_PLAT_PM_MODE_D3: the device goes into D3 mode (i.e. WoWLAN).
689 * For runtime power management, this mode is not officially
690 * supported.
691 * @IWL_PLAT_PM_MODE_D0I3: the device goes into D0I3 mode.
692 */660 */
693enum iwl_plat_pm_mode {661enum iwl_plat_pm_mode {
694 IWL_PLAT_PM_MODE_DISABLED,662 IWL_PLAT_PM_MODE_DISABLED,
695 IWL_PLAT_PM_MODE_D3,663 IWL_PLAT_PM_MODE_D3,
696 IWL_PLAT_PM_MODE_D0I3,
697};664};
698665
699/* Max time to wait for trans to become idle/non-idle on d0i3
700 * enter/exit (in msecs).
701 */
702#define IWL_TRANS_IDLE_TIMEOUT (CPTCFG_IWL_TIMEOUT_FACTOR * 2000)
703
704/* Max time to wait for nmi interrupt */666/* Max time to wait for nmi interrupt */
705#define IWL_TRANS_NMI_TIMEOUT (HZ / 4 * CPTCFG_IWL_TIMEOUT_FACTOR)667#define IWL_TRANS_NMI_TIMEOUT (HZ / 4 * CPTCFG_IWL_TIMEOUT_FACTOR)
706668
@@ -806,9 +768,6 @@ struct iwl_trans_debug {
806 * @system_pm_mode: the system-wide power management mode in use.768 * @system_pm_mode: the system-wide power management mode in use.
807 * This mode is set dynamically, depending on the WoWLAN values769 * This mode is set dynamically, depending on the WoWLAN values
808 * configured from the userspace at runtime.770 * configured from the userspace at runtime.
809 * @runtime_pm_mode: the runtime power management mode in use. This
810 * mode is set during the initialization phase and is not
811 * supposed to change during runtime.
812 */771 */
813struct iwl_trans {772struct iwl_trans {
814 const struct iwl_trans_ops *ops;773 const struct iwl_trans_ops *ops;
@@ -857,7 +816,6 @@ struct iwl_trans {
857 struct iwl_self_init_dram init_dram;816 struct iwl_self_init_dram init_dram;
858817
859 enum iwl_plat_pm_mode system_pm_mode;818 enum iwl_plat_pm_mode system_pm_mode;
860 enum iwl_plat_pm_mode runtime_pm_mode;
861819
862#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE820#ifdef CPTCFG_IWLWIFI_DEVICE_TESTMODE
863 struct iwl_testmode testmode;821 struct iwl_testmode testmode;
@@ -880,16 +838,11 @@ static inline void iwl_trans_configure(struct iwl_trans *trans,
880 WARN_ON(iwl_cmd_groups_verify_sorted(trans_cfg));838 WARN_ON(iwl_cmd_groups_verify_sorted(trans_cfg));
881}839}
882840
883static inline int _iwl_trans_start_hw(struct iwl_trans *trans, bool low_power)841static inline int iwl_trans_start_hw(struct iwl_trans *trans)
884{842{
885 might_sleep();843 might_sleep();
886844
887 return trans->ops->start_hw(trans, low_power);845 return trans->ops->start_hw(trans);
888}
889
890static inline int iwl_trans_start_hw(struct iwl_trans *trans)
891{
892 return trans->ops->start_hw(trans, true);
893}846}
894847
895static inline void iwl_trans_op_mode_leave(struct iwl_trans *trans)848static inline void iwl_trans_op_mode_leave(struct iwl_trans *trans)
@@ -950,21 +903,15 @@ static inline int iwl_trans_start_fw_dbg(struct iwl_trans *trans,
950}903}
951#endif904#endif
952905
953static inline void _iwl_trans_stop_device(struct iwl_trans *trans,906static inline void iwl_trans_stop_device(struct iwl_trans *trans)
954 bool low_power)
955{907{
956 might_sleep();908 might_sleep();
957909
958 trans->ops->stop_device(trans, low_power);910 trans->ops->stop_device(trans);
959911
960 trans->state = IWL_TRANS_NO_FW;912 trans->state = IWL_TRANS_NO_FW;
961}913}
962914
963static inline void iwl_trans_stop_device(struct iwl_trans *trans)
964{
965 _iwl_trans_stop_device(trans, true);
966}
967
968static inline void iwl_trans_d3_suspend(struct iwl_trans *trans, bool test,915static inline void iwl_trans_d3_suspend(struct iwl_trans *trans, bool test,
969 bool reset)916 bool reset)
970{917{
@@ -1045,6 +992,17 @@ static inline void iwl_trans_reclaim(struct iwl_trans *trans, int queue,
1045 trans->ops->reclaim(trans, queue, ssn, skbs);992 trans->ops->reclaim(trans, queue, ssn, skbs);
1046}993}
1047994
995static inline void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue,
996 int ptr)
997{
998 if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) {
999 IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state);
1000 return;
1001 }
1002
1003 trans->ops->set_q_ptrs(trans, queue, ptr);
1004}
1005
1048static inline void iwl_trans_txq_disable(struct iwl_trans *trans, int queue,1006static inline void iwl_trans_txq_disable(struct iwl_trans *trans, int queue,
1049 bool configure_scd)1007 bool configure_scd)
1050{1008{
@@ -1324,8 +1282,6 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
1324 const struct iwl_cfg *cfg,1282 const struct iwl_cfg *cfg,
1325 const struct iwl_trans_ops *ops);1283 const struct iwl_trans_ops *ops);
1326void iwl_trans_free(struct iwl_trans *trans);1284void iwl_trans_free(struct iwl_trans *trans);
1327void iwl_trans_ref(struct iwl_trans *trans);
1328void iwl_trans_unref(struct iwl_trans *trans);
13291285
1330/*****************************************************1286/*****************************************************
1331* driver (transport) register/unregister functions1287* driver (transport) register/unregister functions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/Makefile b/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
index 8e43da7..256e08b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
@@ -16,5 +16,3 @@ ccflags-y += -I$(src)/../
1616
17# non-upstream things17# non-upstream things
18iwlmvm-$(CPTCFG_IWLMVM_VENDOR_CMDS) += vendor-cmd.o18iwlmvm-$(CPTCFG_IWLMVM_VENDOR_CMDS) += vendor-cmd.o
19iwlmvm-$(CPTCFG_IWLWIFI_FRQ_MGR) += fm-ops.o
20iwlmvm-$(CPTCFG_IWLWIFI_FRQ_MGR_TEST) += fm-test.o
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/coex.c b/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
index bd9c105..7fb4ac9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/coex.c
@@ -7,7 +7,7 @@
7 *7 *
8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2018 Intel Corporation10 * Copyright(c) 2018 - 2019 Intel Corporation
11 *11 *
12 * This program is free software; you can redistribute it and/or modify12 * 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 as13 * it under the terms of version 2 of the GNU General Public License as
@@ -29,7 +29,7 @@
29 *29 *
30 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.30 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH31 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32 * Copyright(c) 2018 Intel Corporation32 * Copyright(c) 2018 - 2019 Intel Corporation
33 * All rights reserved.33 * All rights reserved.
34 *34 *
35 * Redistribution and use in source and binary forms, with or without35 * Redistribution and use in source and binary forms, with or without
@@ -69,10 +69,6 @@
69#include "mvm.h"69#include "mvm.h"
70#include "iwl-debug.h"70#include "iwl-debug.h"
7171
72#ifdef CPTCFG_IWLWIFI_LTE_COEX
73#include "lte-coex.h"
74#endif
75
76/* 20MHz / 40MHz below / 40Mhz above*/72/* 20MHz / 40MHz below / 40Mhz above*/
77static const __le64 iwl_ci_mask[][3] = {73static const __le64 iwl_ci_mask[][3] = {
78 /* dummy entry for channel 0 */74 /* dummy entry for channel 0 */
@@ -622,11 +618,6 @@ u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
622 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))618 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))
623 return LINK_QUAL_AGG_TIME_LIMIT_DEF;619 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
624620
625#ifdef CPTCFG_IWLWIFI_FRQ_MGR
626 /* 2G coex */
627 if (mvm->coex_2g_enabled)
628 return LINK_QUAL_AGG_TIME_LIMIT_BT_ACT;
629#endif
630 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <621 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
631 BT_HIGH_TRAFFIC)622 BT_HIGH_TRAFFIC)
632 return LINK_QUAL_AGG_TIME_LIMIT_DEF;623 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
@@ -751,150 +742,3 @@ void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm)
751 iwl_mvm_bt_coex_notif_handle(mvm);742 iwl_mvm_bt_coex_notif_handle(mvm);
752}743}
753744
754#ifdef CPTCFG_IWLWIFI_LTE_COEX
755int iwl_mvm_send_lte_coex_config_cmd(struct iwl_mvm *mvm)
756{
757 const struct iwl_lte_coex_config_cmd *cmd = &mvm->lte_state.config;
758
759 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_LTE_COEX)) {
760 IWL_DEBUG_COEX(mvm, "LTE-Coex not supported!\n");
761 return -EOPNOTSUPP;
762 }
763
764 IWL_DEBUG_COEX(mvm, "LTE-Coex: lte_coex_config_cmd:\n"
765 "\tstate: %d\n\tband: %d\n\tchan: %d\n",
766 le32_to_cpu(cmd->lte_state), le32_to_cpu(cmd->lte_band),
767 le32_to_cpu(cmd->lte_chan));
768
769 IWL_DEBUG_COEX(mvm, "\ttx safe freq min: %d\n\ttx safe freq max: %d\n"
770 "\trx safe freq min: %d\n\trx safe freq max: %d\n",
771 le32_to_cpu(cmd->tx_safe_freq_min),
772 le32_to_cpu(cmd->tx_safe_freq_max),
773 le32_to_cpu(cmd->rx_safe_freq_min),
774 le32_to_cpu(cmd->rx_safe_freq_max));
775
776 return iwl_mvm_send_cmd_pdu(mvm, LTE_COEX_CONFIG_CMD, 0, sizeof(*cmd),
777 cmd);
778}
779
780int iwl_mvm_send_lte_coex_wifi_reported_channel_cmd(struct iwl_mvm *mvm)
781{
782 const struct iwl_lte_coex_wifi_reported_channel_cmd *cmd =
783 &mvm->lte_state.rprtd_chan;
784
785 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_LTE_COEX)) {
786 IWL_DEBUG_COEX(mvm, "LTE-Coex not supported!\n");
787 return -EOPNOTSUPP;
788 }
789
790 IWL_DEBUG_COEX(mvm, "LTE-COEX: lte_coex_wifi_reported_channel_cmd:\n"
791 "\tchannel: %d\n\tbandwidth: %d\n",
792 le32_to_cpu(cmd->channel), le32_to_cpu(cmd->bandwidth));
793
794 return iwl_mvm_send_cmd_pdu(mvm, LTE_COEX_WIFI_REPORTED_CHANNEL_CMD,
795 0, sizeof(*cmd), cmd);
796}
797
798int iwl_mvm_send_lte_coex_static_params_cmd(struct iwl_mvm *mvm)
799{
800 const struct iwl_lte_coex_static_params_cmd *cmd = &mvm->lte_state.stat;
801
802 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_LTE_COEX)) {
803 IWL_DEBUG_COEX(mvm, "LTE-Coex not supported!\n");
804 return -EOPNOTSUPP;
805 }
806
807 IWL_DEBUG_COEX(mvm, "LTE-COEX: lte_coex_static_params_cmd:\n"
808 "\tmfu config[0]: %d\n\ttx power[0]: %d\n",
809 le32_to_cpu(cmd->mfu_config[0]),
810 cmd->tx_power_in_dbm[0]);
811
812 return iwl_mvm_send_cmd_pdu(mvm, LTE_COEX_STATIC_PARAMS_CMD, 0,
813 sizeof(*cmd), cmd);
814}
815
816int iwl_mvm_send_lte_fine_tuning_params_cmd(struct iwl_mvm *mvm)
817{
818 const struct iwl_lte_coex_fine_tuning_params_cmd *cmd =
819 &mvm->lte_state.ft;
820
821 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_LTE_COEX)) {
822 IWL_DEBUG_COEX(mvm, "LTE-Coex not supported!\n");
823 return -EOPNOTSUPP;
824 }
825
826 IWL_DEBUG_COEX(mvm, "LTE-COEX: lte_fine_tuning_params_cmd:\n"
827 "\trx protection assert timing: %d\n",
828 le32_to_cpu(cmd->rx_protection_assert_timing));
829
830 IWL_DEBUG_COEX(mvm, "\ttx protection assert timing: %d\n"
831 "\trx protection timeout: %d\n\tmin tx power: %d\n",
832 le32_to_cpu(cmd->tx_protection_assert_timing),
833 le32_to_cpu(cmd->rx_protection_timeout),
834 le32_to_cpu(cmd->min_tx_power));
835
836 IWL_DEBUG_COEX(mvm, "\tul load uapsd threshold: %d\n"
837 "\trx failure during ul uapsd threshold: %d\n",
838 le32_to_cpu(cmd->lte_ul_load_uapsd_threshold),
839 le32_to_cpu(cmd->rx_failure_during_ul_uapsd_threshold));
840
841 IWL_DEBUG_COEX(mvm,
842 "\trx failure during ul scan compensation threshold: %d\n"
843 "\trx duration for ack protection: %d\n",
844 le32_to_cpu(cmd->rx_failure_during_ul_sc_threshold),
845 le32_to_cpu(cmd->rx_duration_for_ack_protection_us));
846
847 IWL_DEBUG_COEX(mvm, "\tbeacon failure during ul counter: %d\n"
848 "\tdtim failure during ul counter: %d\n",
849 le32_to_cpu(cmd->beacon_failure_during_ul_counter),
850 le32_to_cpu(cmd->dtim_failure_during_ul_counter));
851
852 return iwl_mvm_send_cmd_pdu(mvm, LTE_COEX_FINE_TUNING_PARAMS_CMD,
853 0, sizeof(*cmd), cmd);
854}
855
856int iwl_mvm_send_lte_sps_cmd(struct iwl_mvm *mvm)
857{
858 const struct iwl_lte_coex_sps_cmd *cmd = &mvm->lte_state.sps;
859
860 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_LTE_COEX)) {
861 IWL_DEBUG_COEX(mvm, "LTE-Coex not supported!\n");
862 return -EOPNOTSUPP;
863 }
864
865 IWL_DEBUG_COEX(mvm, "LTE-COEX: lte_sps_cmd:\n\tsps info: %d\n",
866 le32_to_cpu(cmd->lte_semi_persistent_info));
867
868 return iwl_mvm_send_cmd_pdu(mvm, LTE_COEX_SPS_CMD, 0, sizeof(*cmd),
869 cmd);
870}
871
872void iwl_mvm_reset_lte_state(struct iwl_mvm *mvm)
873{
874 struct lte_coex_state *lte_state = &mvm->lte_state;
875
876 lte_state->state = LTE_OFF;
877 lte_state->has_config = 0;
878 lte_state->has_rprtd_chan = 0;
879 lte_state->has_sps = 0;
880 lte_state->has_ft = 0;
881}
882
883void iwl_mvm_send_lte_commands(struct iwl_mvm *mvm)
884{
885 struct lte_coex_state *lte_state = &mvm->lte_state;
886
887 lockdep_assert_held(&mvm->mutex);
888
889 if (lte_state->has_static)
890 iwl_mvm_send_lte_coex_static_params_cmd(mvm);
891 if (lte_state->has_rprtd_chan)
892 iwl_mvm_send_lte_coex_wifi_reported_channel_cmd(mvm);
893 if (lte_state->state != LTE_OFF)
894 iwl_mvm_send_lte_coex_config_cmd(mvm);
895 if (lte_state->has_sps)
896 iwl_mvm_send_lte_sps_cmd(mvm);
897 if (lte_state->has_ft)
898 iwl_mvm_send_lte_fine_tuning_params_cmd(mvm);
899}
900#endif /* CPTCFG_IWLWIFI_LTE_COEX */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index 68814b9..5e6cd75 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -831,6 +831,8 @@ iwl_mvm_wowlan_config(struct iwl_mvm *mvm,
831 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa,831 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa,
832 IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);832 IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
833833
834 mvm->offload_tid = wowlan_config_cmd->offloading_tid;
835
834 if (!unified_image) {836 if (!unified_image) {
835 ret = iwl_mvm_switch_to_d3(mvm);837 ret = iwl_mvm_switch_to_d3(mvm);
836 if (ret)838 if (ret)
@@ -1656,6 +1658,13 @@ static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
1656 mvm_ap_sta->tid_data[i].seq_number = seq;1658 mvm_ap_sta->tid_data[i].seq_number = seq;
1657 }1659 }
16581660
1661 if (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22000) {
1662 i = mvm->offload_tid;
1663 iwl_trans_set_q_ptrs(mvm->trans,
1664 mvm_ap_sta->tid_data[i].txq_id,
1665 mvm_ap_sta->tid_data[i].seq_number >> 4);
1666 }
1667
1659 /* now we have all the data we need, unlock to avoid mac80211 issues */1668 /* now we have all the data we need, unlock to avoid mac80211 issues */
1660 mutex_unlock(&mvm->mutex);1669 mutex_unlock(&mvm->mutex);
16611670
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 02ff26d..222c4c8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -8,7 +8,7 @@
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation11 * Copyright(c) 2018 - 2019 Intel Corporation
12 *12 *
13 * This program is free software; you can redistribute it and/or modify13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as14 * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
34 * Copyright(c) 2018 Intel Corporation34 * Copyright(c) 2018 - 2019 Intel Corporation
35 * All rights reserved.35 * All rights reserved.
36 *36 *
37 * Redistribution and use in source and binary forms, with or without37 * Redistribution and use in source and binary forms, with or without
@@ -201,19 +201,6 @@ static ssize_t iwl_dbgfs_tx_pwr_lmt_read(struct file *file,
201 pos = scnprintf(buf, bufsz, "bss limit = %d\n",201 pos = scnprintf(buf, bufsz, "bss limit = %d\n",
202 vif->bss_conf.txpower);202 vif->bss_conf.txpower);
203203
204#ifdef CPTCFG_IWLWIFI_FRQ_MGR
205 {
206 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
207 struct iwl_mvm *mvm = mvmvif->mvm;
208
209 mutex_lock(&mvm->mutex);
210 if (mvmvif->phy_ctxt)
211 pos += scnprintf(buf + pos, bufsz - pos, "fm limit = %d\n",
212 mvmvif->phy_ctxt->fm_tx_power_limit);
213 mutex_unlock(&mvm->mutex);
214 }
215#endif
216
217 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);204 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
218}205}
219206
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fm-ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/fm-ops.c
220deleted file mode 100644207deleted file mode 100644
index f312f90..0000000
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fm-ops.c
+++ /dev/null
@@ -1,837 +0,0 @@
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) 2013 - 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 * The full GNU General Public License is included in this distribution
21 * in the file called COPYING.
22 *
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *
27 * BSD LICENSE
28 *
29 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 *
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
41 * the documentation and/or other materials provided with the
42 * distribution.
43 * * Neither the name Intel Corporation nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *
59 *****************************************************************************/
60#include <linux/fm/iui_fm.h>
61#include "mvm.h"
62
63/*
64 * Used in the FM callback and is declared here since according
65 * to the FM API, the callback does not receive an mvm pointer
66 */
67static struct iwl_mvm *g_mvm;
68
69/* If in debug mode use the fm-test module instead of the original fm API */
70static bool debug_mode;
71
72struct chan_ifaces {
73 struct iui_fm_wlan_channel_tx_power *chan_txpwr;
74 int num_of_vif; /* for statistics */
75};
76
77struct chan_list {
78 struct iui_fm_wlan_info *winfo;
79 enum iwl_fm_chan_change_action action;
80};
81
82/* last reported channel notification to the FM */
83static struct iui_fm_wlan_info last_chan_notif;
84/* last dcdc values requested by the FM */
85static int g_dcdc_div0;
86static int g_dcdc_div1;
87
88static struct work_struct fm_chan_notif_wk;
89
90/*
91 * Search for an interface with a given frequency
92 */
93static void iwl_mvm_fm_iface_iterator(void *_data, u8 *mac,
94 struct ieee80211_vif *vif)
95{
96 struct chan_ifaces *data = _data;
97 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
98 struct ieee80211_chanctx_conf *chanctx_conf;
99
100 /* P2P device or NAN are never assigned a channel */
101 if ((vif->type == NL80211_IFTYPE_P2P_DEVICE) ||
102 (vif->type == NL80211_IFTYPE_NAN))
103 return;
104
105 rcu_read_lock();
106
107 chanctx_conf = rcu_dereference(vif->chanctx_conf);
108 /* make sure the channel context is assigned */
109 if (!chanctx_conf) {
110 rcu_read_unlock();
111 return;
112 }
113
114 if (chanctx_conf->min_def.center_freq1 ==
115 KHZ_TO_MHZ(data->chan_txpwr->frequency)) {
116 mvmvif->phy_ctxt->fm_tx_power_limit =
117 data->chan_txpwr->max_tx_pwr;
118 data->num_of_vif++;
119 rcu_read_unlock();
120 /* FM requests to remove Tx power limitation */
121 if (data->chan_txpwr->max_tx_pwr == IUI_FM_WLAN_NO_TX_PWR_LIMIT)
122 data->chan_txpwr->max_tx_pwr =
123 IWL_DEFAULT_MAX_TX_POWER;
124
125 iwl_mvm_fm_set_tx_power(g_mvm, vif,
126 data->chan_txpwr->max_tx_pwr);
127 return;
128 }
129
130 rcu_read_unlock();
131}
132
133/*
134 * Search for an interface with a given frequency
135 */
136static void iwl_mvm_fm_chan_vldt_iter(void *_data, u8 *mac,
137 struct ieee80211_vif *vif)
138{
139 struct chan_ifaces *data = _data;
140 struct ieee80211_chanctx_conf *chanctx_conf;
141
142 rcu_read_lock();
143
144 chanctx_conf = rcu_dereference(vif->chanctx_conf);
145 /* make sure the channel context is assigned */
146 if (!chanctx_conf) {
147 rcu_read_unlock();
148 return;
149 }
150
151 if (chanctx_conf->min_def.center_freq1 ==
152 KHZ_TO_MHZ(data->chan_txpwr->frequency))
153 data->num_of_vif++;
154
155 rcu_read_unlock();
156}
157
158static enum iui_fm_wlan_bandwidth
159iwl_mvm_fm_get_bandwidth(enum nl80211_chan_width bandwidth)
160{
161 switch (bandwidth) {
162 case NL80211_CHAN_WIDTH_20_NOHT:
163 return IUI_FM_WLAN_BW_20MHZ;
164 case NL80211_CHAN_WIDTH_20:
165 return IUI_FM_WLAN_BW_20MHZ;
166 case NL80211_CHAN_WIDTH_40:
167 return IUI_FM_WLAN_BW_40MHZ;
168 case NL80211_CHAN_WIDTH_80:
169 return IUI_FM_WLAN_BW_80MHZ;
170 case NL80211_CHAN_WIDTH_160:
171 return IUI_FM_WLAN_BW_160MHZ;
172 default:
173 return IUI_FM_WLAN_BW_INVALID;
174 }
175}
176
177/*
178 * Search for all channels used by interfaces
179 */
180static void iwl_mvm_fm_chan_iterator(struct ieee80211_hw *hw,
181 struct ieee80211_chanctx_conf *ctx,
182 void *_data)
183{
184 int i;
185 enum nl80211_chan_width band;
186 u32 freq;
187 struct chan_list *data = _data;
188 struct iui_fm_wlan_info *winfo = data->winfo;
189
190 if (winfo->num_channels == IUI_FM_WLAN_MAX_CHANNELS)
191 return;
192
193 freq = MHZ_TO_KHZ(ctx->min_def.center_freq1);
194 band = ctx->min_def.width;
195
196 for (i = 0; i < winfo->num_channels; i++)
197 if (winfo->channel_info[i].frequency == freq) {
198 /*
199 * channel exists - but bandwidth maybe invalid since
200 * we are removing a ctx that operates on this channel
201 */
202 winfo->channel_info[winfo->num_channels].bandwidth =
203 iwl_mvm_fm_get_bandwidth(band);
204 return; /* channel already exists in list */
205 }
206
207 winfo->channel_info[winfo->num_channels].frequency = freq;
208 winfo->channel_info[winfo->num_channels].bandwidth =
209 iwl_mvm_fm_get_bandwidth(band);
210
211 winfo->num_channels++;
212}
213
214/*
215 * Handling Frequency Managers Tx power mitigation Request.
216 * Reducing the Tx power of all interfaces that use a specific channel.
217 */
218static enum iui_fm_mitigation_status
219iwl_mvm_fm_mitig_txpwr(struct iui_fm_wlan_mitigation *mit)
220{
221 int i;
222 struct chan_ifaces chan_ifaces;
223 struct iui_fm_wlan_channel_tx_power *chan_txpwr_list =
224 mit->channel_tx_pwr;
225 u32 num_channels = mit->num_channels;
226
227 /* Not required to mitigate tx power */
228 if (!(mit->bitmask & WLAN_MITI))
229 goto ret;
230
231 if (IUI_FM_WLAN_MAX_CHANNELS < num_channels)
232 return IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
233
234 for (i = 0; i < num_channels; i++) {
235 chan_ifaces.chan_txpwr = &chan_txpwr_list[i];
236 chan_ifaces.num_of_vif = 0;
237 /* find all interfaces that use this channel */
238 ieee80211_iterate_active_interfaces(g_mvm->hw,
239 IEEE80211_IFACE_ITER_NORMAL,
240 iwl_mvm_fm_iface_iterator,
241 &chan_ifaces);
242 IWL_DEBUG_EXTERNAL(g_mvm,
243 "FM: Changed Tx power to %d for %d"
244 " vifs on channel %d\n",
245 chan_ifaces.chan_txpwr->max_tx_pwr,
246 chan_ifaces.num_of_vif,
247 chan_ifaces.chan_txpwr->frequency);
248 }
249ret:
250 return IUI_FM_MITIGATION_COMPLETE_OK;
251}
252
253/*
254 * Handling Frequency Managers ADC/DAC mitigation Request
255 * TODO: implement
256 */
257static enum iui_fm_mitigation_status
258iwl_mvm_fm_mitig_adc_dac_freq(struct iui_fm_wlan_mitigation *mit)
259{
260 u32 adc_dac_freq = mit->wlan_adc_dac_freq;
261
262 /* Not required to mitigate adc dac */
263 if (!(mit->bitmask & WLAN_MITI))
264 goto ret;
265
266 if (adc_dac_freq != 0)
267 return IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
268
269 IWL_DEBUG_EXTERNAL(g_mvm, "FM: adc - dac mitigation\n");
270ret:
271 return IUI_FM_MITIGATION_COMPLETE_OK;
272}
273
274/*
275 * Handling Frequency Managers Rx Gain mitigation Request
276 * TODO: implement
277 */
278static enum iui_fm_mitigation_status
279iwl_mvm_fm_mitig_rxgain_behavior(struct iui_fm_wlan_mitigation *mit)
280{
281 enum iui_fm_wlan_rx_gain_behavior rx_gain = mit->rx_gain_behavior;
282
283 /* Not required to mitigate rx gain */
284 if (!(mit->bitmask & WLAN_MITI))
285 goto ret;
286
287 if (rx_gain != IUI_FM_WLAN_RX_GAIN_NORMAL)
288 return IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
289
290 IWL_DEBUG_EXTERNAL(g_mvm,
291 "FM: rxgain behaviour mitigation - not implemented\n");
292ret:
293 return IUI_FM_MITIGATION_COMPLETE_OK;
294}
295
296/*
297 * Enables/Disable 2G coex mode - aggregation limiting.
298 */
299static enum iui_fm_mitigation_status
300iwl_mvm_fm_2g_coex(struct iui_fm_wlan_mitigation *mit)
301{
302 enum iui_fm_mitigation_status ret = IUI_FM_MITIGATION_COMPLETE_OK;
303 struct iwl_config_2g_coex_cmd cmd = {};
304 int i;
305 struct iui_fm_wlan_channel_tx_power *chan;
306 struct iui_fm_wlan_channel_tx_power *chan_txpwr_list =
307 mit->channel_tx_pwr;
308 u32 num_channels = mit->num_channels;
309
310 /* Not required to mitigate 2g coex */
311 if (!(mit->bitmask & WLAN_MITI))
312 return ret;
313
314 /* fw does not support the 2g coex cmd */
315 if (!fw_has_capa(&g_mvm->fw->ucode_capa,
316 IWL_UCODE_TLV_CAPA_2G_COEX_SUPPORT))
317 goto sofia_xmm;
318
319 /* No need to change 2g coex state */
320 if (g_mvm->coex_2g_enabled == mit->wlan_2g_coex_enable)
321 return ret;
322
323 g_mvm->coex_2g_enabled = mit->wlan_2g_coex_enable;
324
325 cmd.enabled = cpu_to_le32(g_mvm->coex_2g_enabled);
326
327 mutex_lock(&g_mvm->mutex);
328 ret = iwl_mvm_send_cmd_pdu(g_mvm, CONFIG_2G_COEX_CMD, 0, sizeof(cmd),
329 &cmd);
330 mutex_unlock(&g_mvm->mutex);
331 if (ret) {
332 IWL_ERR(g_mvm, "Failed to send 2g coex command(%sabling)\n",
333 g_mvm->coex_2g_enabled ? "en" : "dis");
334 return IUI_FM_MITIGATION_ERROR;
335 }
336 IWL_DEBUG_EXTERNAL(g_mvm,
337 "FM 2G coex: %sabling 2G coex mode (sent fw cmd)\n",
338 g_mvm->coex_2g_enabled ? "en" : "dis");
339 return ret;
340
341sofia_xmm:
342 /* Flow for SOFIA 3G & XMM6321 - don't support the 2g coex cmd */
343 if (IUI_FM_WLAN_MAX_CHANNELS < num_channels)
344 return IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
345
346 for (i = 0; i < num_channels; i++) {
347 chan = &chan_txpwr_list[i];
348 if (chan->frequency == FM_2G_COEX_ENABLE_DISABLE) {
349 mutex_lock(&g_mvm->mutex);
350 if (chan->max_tx_pwr == FM_2G_COEX_ENABLE) {
351 g_mvm->coex_2g_enabled = true;
352 } else if (chan->max_tx_pwr == FM_2G_COEX_DISABLE) {
353 g_mvm->coex_2g_enabled = false;
354 } else {
355 IWL_DEBUG_EXTERNAL(g_mvm,
356 "FM 2G coex: ERROR: Invalid paramters for enable/disable(%d)\n",
357 chan->max_tx_pwr);
358 ret = IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
359 }
360 IWL_DEBUG_EXTERNAL(g_mvm,
361 "FM 2G coex: %sabling 2G coex mode\n",
362 g_mvm->coex_2g_enabled ?
363 "en" : "dis");
364 mutex_unlock(&g_mvm->mutex);
365 break;
366 }
367 }
368
369 return ret;
370}
371
372static int iwl_mvm_fm_send_dcdc_cmd(u32 div0, u32 div1, u32 flags)
373{
374 int ret;
375 struct iwl_dc2dc_config_resp *resp;
376 struct iwl_rx_packet *pkt;
377 struct iwl_dc2dc_config_cmd dcdc = {
378 .flags = cpu_to_le32(flags),
379 .dc2dc_freq_tune0 = cpu_to_le32(div0),
380 .dc2dc_freq_tune1 = cpu_to_le32(div1),
381 };
382 struct iwl_host_cmd cmd = {
383 .id = DC2DC_CONFIG_CMD,
384 .flags = CMD_WANT_SKB,
385 .data = { &dcdc },
386 .len = { sizeof(struct iwl_dc2dc_config_cmd) },
387 };
388
389 /* fw does not support the dcdc cmd */
390 if (!fw_has_capa(&g_mvm->fw->ucode_capa,
391 IWL_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT))
392 return -EINVAL;
393
394 ret = iwl_mvm_send_cmd(g_mvm, &cmd);
395
396 if (ret) {
397 IWL_ERR(g_mvm, "FM: Failed to send dcdc cmd (ret = %d)\n", ret);
398 return ret;
399 }
400
401 pkt = cmd.resp_pkt;
402 if (!pkt) {
403 IWL_ERR(g_mvm, "FM: Error DCDC cmd response is NULL\n");
404 return -EIO;
405 }
406 resp = (void *)pkt->data;
407
408 /* update the current dcdc values */
409 g_dcdc_div0 = le32_to_cpu(resp->dc2dc_freq_tune0);
410 g_dcdc_div1 = le32_to_cpu(resp->dc2dc_freq_tune1);
411
412 iwl_free_resp(&cmd);
413 return ret;
414}
415
416/*
417 * Enables/Disable DCDC mitigation
418 * In some scenarios, DCDC inserts noise to FMR due to its (DCDC's)
419 * internal clock rate. When WiFi is ON the noise level is very high,
420 * and therefore DCDC needs to change its clock rate.
421 */
422static enum iui_fm_mitigation_status
423iwl_mvm_fm_mitig_dcdc(struct iui_fm_wlan_mitigation *mit)
424{
425 enum iui_fm_mitigation_status ret = IUI_FM_MITIGATION_COMPLETE_OK;
426
427 /* Not required to mitigate dcdc */
428 if (!(mit->bitmask & DCDC_MITI))
429 return ret;
430
431 /* Current dcdc values match requested values */
432 if (mit->dcdc_div0 == g_dcdc_div0 && mit->dcdc_div1 == g_dcdc_div0) {
433 IWL_DEBUG_EXTERNAL(g_mvm,
434 "FM DCDC: Current dcdc values match requested values - not mitigating\n");
435 goto out;
436 }
437
438 mutex_lock(&g_mvm->mutex);
439 ret = iwl_mvm_fm_send_dcdc_cmd(mit->dcdc_div0, mit->dcdc_div1,
440 DCDC_FREQ_TUNE_SET);
441 mutex_unlock(&g_mvm->mutex);
442
443 if (ret)
444 ret = IUI_FM_MITIGATION_ERROR;
445
446out:
447 IWL_DEBUG_EXTERNAL(g_mvm,
448 "FM DCDC: mitigation %s (div0 = %d, div1 = %d)\n",
449 ret ? "failed" : "succeeded", g_dcdc_div0,
450 g_dcdc_div1);
451
452 return ret;
453}
454
455/*
456 * Send the FM the original DCDC values, so that FM can know when to activate
457 * the DCDC mitigation.
458 */
459void iwl_mvm_fm_notify_current_dcdc(void)
460{
461 int ret;
462 struct iui_fm_freq_notification notification;
463 struct iui_fm_wlan_info winfo;
464
465 if (!g_mvm)
466 return;
467
468 memset(&winfo, 0, sizeof(struct iui_fm_wlan_info));
469
470 /* Get current DCDC from the FW */
471 ret = iwl_mvm_fm_send_dcdc_cmd(0, 0, 0);
472 if (ret)
473 goto out;
474
475 winfo.dcdc_div0 = g_dcdc_div0;
476 winfo.dcdc_div1 = g_dcdc_div1;
477
478 /* mark the change that we are reporting */
479 winfo.bitmask |= DCDC_UPDATE;
480
481 notification.type = IUI_FM_FREQ_NOTIFICATION_TYPE_WLAN;
482 notification.info.wlan_info = &winfo;
483
484 ret = iwl_mvm_fm_notify_frequency(debug_mode, IUI_FM_MACRO_ID_WLAN,
485 &notification);
486
487out:
488 IWL_DEBUG_EXTERNAL(g_mvm,
489 "FM: notified fm about dcdc div0 = %d div1 = %d (fail = %d)\n",
490 winfo.dcdc_div0, winfo.dcdc_div1, ret);
491}
492
493/*
494 * Check if the list of channels that the FM supplied is valid
495 */
496static bool iwl_mvm_fm_invalid_channel_list(struct iui_fm_wlan_mitigation *mit)
497{
498 struct iui_fm_wlan_channel_tx_power *chan_txpwr_list =
499 mit->channel_tx_pwr;
500 u32 num_channels = mit->num_channels;
501 u8 i, j;
502
503 /* Check if the same frequency appears twice */
504 for (i = 0; i < num_channels; i++) {
505 for (j = 0; j < num_channels; j++) {
506 if (chan_txpwr_list[i].frequency ==
507 chan_txpwr_list[j].frequency && i != j) {
508 int freq;
509
510 freq = chan_txpwr_list[i].frequency;
511 IWL_DEBUG_EXTERNAL(g_mvm,
512 "FM: Invalid channel list: duplicated frequencies (freq = %d)\n",
513 freq);
514 return true;
515 }
516 }
517 }
518
519 /* Check that all of the channels are used */
520 for (i = 0; i < num_channels; i++) {
521 struct chan_ifaces chan_ifaces = {
522 .chan_txpwr = &chan_txpwr_list[i],
523 .num_of_vif = 0,
524 };
525 ieee80211_iterate_active_interfaces(g_mvm->hw,
526 IEEE80211_IFACE_ITER_NORMAL,
527 iwl_mvm_fm_chan_vldt_iter,
528 &chan_ifaces);
529 if (!chan_ifaces.num_of_vif) {
530 IWL_DEBUG_EXTERNAL(g_mvm,
531 "FM: Invalid channel list: frequency is not in use (freq = %d)\n",
532 chan_txpwr_list[i].frequency);
533 return true;
534 }
535 }
536
537 return false;
538}
539
540/*
541 * Frequency Mitigation Callback function implementation.
542 * Frequency Manager can ask to:
543 * 1. Limit Tx power on specific channels
544 * 2. Change ADC/DAC frequency - Currently not supported
545 * 3. Request Rx Gain behavior - Currently not supported
546 * 4. Enter 2G coex mode
547 * 5. Change dcdc clock values
548 */
549static enum iui_fm_mitigation_status
550iwl_mvm_fm_wlan_mitigation(const enum iui_fm_macro_id macro_id,
551 const struct iui_fm_mitigation *mitigation,
552 const uint32_t sequence)
553{
554 enum iui_fm_mitigation_status ret;
555 struct iui_fm_wlan_mitigation *mit;
556
557 if (WARN_ON(!g_mvm))
558 return IUI_FM_MITIGATION_ERROR;
559
560 if (macro_id != IUI_FM_MACRO_ID_WLAN ||
561 mitigation->type != IUI_FM_MITIGATION_TYPE_WLAN) {
562 ret = IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
563 goto end;
564 }
565
566 mit = mitigation->info.wlan_mitigation;
567
568 if (iwl_mvm_fm_invalid_channel_list(mit))
569 return IUI_FM_MITIGATION_ERROR_INVALID_PARAM;
570
571 IWL_DEBUG_EXTERNAL(g_mvm, "FM: fm mitigation callback bit mask 0x%x\n",
572 mit->bitmask);
573
574 ret = iwl_mvm_fm_mitig_dcdc(mit);
575 if (ret)
576 goto end;
577
578 /* Enable/Disable 2G coex mode */
579 ret = iwl_mvm_fm_2g_coex(mit);
580 if (ret)
581 goto end;
582
583 /*
584 * Going to mitigate the Tx power of all stations using the channels in
585 * the channel list mit->channel_tx_pwr received from the FM.
586 */
587 ret = iwl_mvm_fm_mitig_txpwr(mit);
588 if (ret)
589 goto end;
590
591 ret = iwl_mvm_fm_mitig_adc_dac_freq(mit);
592
593 if (ret)
594 goto end;
595
596 ret = iwl_mvm_fm_mitig_rxgain_behavior(mit);
597end:
598 IWL_DEBUG_EXTERNAL(g_mvm, "FM: fm mitigation callback %s\n",
599 ret ? "failed" : "succeeded");
600 return ret;
601}
602
603/*
604 * Check if the new list of active channels that the FM is going to be
605 * updated with differs from the old list.
606 * The check includes the channel frequency & BW.
607 */
608static bool iwl_mvm_fm_channel_changed(struct iui_fm_wlan_info *winfo)
609{
610 int i, j;
611 bool changed;
612
613 for (i = 0; i < winfo->num_channels; i++) {
614 changed = true;
615 for (j = 0; j < last_chan_notif.num_channels; j++) {
616 /* The channel was not updated */
617 if (winfo->channel_info[i].frequency ==
618 last_chan_notif.channel_info[j].frequency &&
619 winfo->channel_info[i].bandwidth ==
620 last_chan_notif.channel_info[j].bandwidth) {
621 changed = false;
622 break;
623 }
624 }
625 /* Channel was updated */
626 if (changed)
627 return true;
628 }
629
630 IWL_DEBUG_EXTERNAL(g_mvm,
631 "FM: Channel list has not changed - not reporting\n");
632 return false;
633}
634
635/*
636 * Check if the new list of channels being reported to the FM is missing
637 * channels that have been removed - but not reported as removed.
638 *
639 * The check is done by checking the old list of active channels that was
640 * reported to the FM, and making sure that the active channel is still in the
641 * new list. If the channel is absent from the list - it means that it is no
642 * longer in use, so report it invalid.
643 *
644 * For example in case of connecting to an AP on 80MHZ BW. At first the
645 * connection will be on the primary channel with 20MHZ, and then it will be
646 * modified to the center frequency with 80MHZ, but the primary channel will not
647 * be reported as removed. So we need to report this channel as invalid.
648 *
649 */
650static void iwl_mvm_fm_remove_channels(struct iui_fm_wlan_info *winfo)
651{
652 int i, j;
653 bool found;
654
655 for (i = 0; i < last_chan_notif.num_channels; i++) {
656 /* Can't report more channels since we are in the max */
657 if (winfo->num_channels == IUI_FM_WLAN_MAX_CHANNELS)
658 return;
659 found = false;
660
661 if (last_chan_notif.channel_info[i].bandwidth ==
662 IUI_FM_WLAN_BW_INVALID)
663 continue;
664 /*
665 * Search for the old reported channel in the new reported
666 * channels
667 */
668 for (j = 0; j < winfo->num_channels; j++) {
669 if (last_chan_notif.channel_info[i].frequency ==
670 winfo->channel_info[j].frequency) {
671 found = true;
672 break;
673 }
674 }
675 /*
676 * The old reported channel is not in the new ones (It was
677 * removed) - Adding it to the report.
678 */
679 if (!found) {
680 winfo->channel_info[winfo->num_channels].frequency =
681 last_chan_notif.channel_info[i].frequency;
682 winfo->channel_info[winfo->num_channels].bandwidth =
683 IUI_FM_WLAN_BW_INVALID;
684 winfo->num_channels++;
685 IWL_DEBUG_EXTERNAL(g_mvm,
686 "FM: reporting channel %d invalid\n",
687 last_chan_notif.channel_info[i].
688 frequency);
689 }
690 }
691}
692
693static void iwl_mvm_fm_notif_chan_change_wk(struct work_struct *wk)
694{
695 int ret;
696 struct iui_fm_freq_notification notification;
697
698 /* FM is enabled - but registration failed */
699 if (!g_mvm)
700 return;
701
702 mutex_lock(&g_mvm->mutex);
703
704 notification.type = IUI_FM_FREQ_NOTIFICATION_TYPE_WLAN;
705 notification.info.wlan_info = &last_chan_notif;
706 /* parameter not yet supported */
707 notification.info.wlan_info->wlan_adc_dac_freq = 0;
708
709 ret = iwl_mvm_fm_notify_frequency(debug_mode, IUI_FM_MACRO_ID_WLAN,
710 &notification);
711
712 IWL_DEBUG_EXTERNAL(g_mvm,
713 "FM: notified fm about channel change (fail = %d)\n",
714 ret);
715
716 mutex_unlock(&g_mvm->mutex);
717}
718
719/*
720 * Notify Frequency Manager that an interface changed a channel.
721 */
722void iwl_mvm_fm_notify_channel_change(struct ieee80211_chanctx_conf *ctx,
723 enum iwl_fm_chan_change_action action)
724{
725 int i;
726 struct iui_fm_wlan_info winfo = {
727 .num_channels = 0,
728 };
729 struct chan_list chan_info = {
730 .winfo = &winfo,
731 .action = action,
732 };
733
734 /* FM is enabled - but registration failed */
735 if (!g_mvm)
736 return;
737
738 lockdep_assert_held(&g_mvm->mutex);
739
740 /*
741 * if notifying the FM about adding/removing a channel ctx we
742 * need to add this channel to the list before iterating over
743 * the channel list since the list is updated only after this
744 * function is called.
745 */
746 if (action != IWL_FM_CHANGE_CHANCTX) {
747 winfo.channel_info[0].frequency =
748 MHZ_TO_KHZ(ctx->min_def.center_freq1);
749 winfo.channel_info[0].bandwidth =
750 iwl_mvm_fm_get_bandwidth(ctx->min_def.width);
751 /* when removing a channel - report the BW invalid */
752 winfo.num_channels++;
753 if (action == IWL_FM_REMOVE_CHANCTX)
754 winfo.channel_info[0].bandwidth =
755 IUI_FM_WLAN_BW_INVALID;
756 }
757
758 /* finding all bandwidths of used channels for FM notification */
759 ieee80211_iter_chan_contexts_atomic(g_mvm->hw,
760 iwl_mvm_fm_chan_iterator,
761 &chan_info);
762
763 iwl_mvm_fm_remove_channels(&winfo);
764
765 for (i = 0; i < winfo.num_channels; i++)
766 IWL_DEBUG_EXTERNAL(g_mvm,
767 "FM: notifying fm about: channel=%d bandwith=%d\n",
768 winfo.channel_info[i].frequency,
769 winfo.channel_info[i].bandwidth);
770
771 /* Do not report to FM if no change happened */
772 if (!iwl_mvm_fm_channel_changed(&winfo))
773 return;
774
775 /* mark the change that we are reporting */
776 winfo.bitmask = WLAN_UPDATE;
777 /* Update the last notification to the FM */
778 memcpy(&last_chan_notif, &winfo, sizeof(struct iui_fm_wlan_info));
779
780 schedule_work(&fm_chan_notif_wk);
781}
782
783/*
784 * Register the Frequency Mitigation Callback function implementation with
785 * Frequency Manager to receive Frequency Mitigation messages from Frequency
786 * Manager.
787 */
788int iwl_mvm_fm_register(struct iwl_mvm *mvm)
789{
790 int ret;
791
792 if (g_mvm)
793 return -EINVAL;
794
795 g_mvm = mvm;
796 INIT_WORK(&fm_chan_notif_wk, iwl_mvm_fm_notif_chan_change_wk);
797
798#ifdef CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES
799 debug_mode = g_mvm->trans->dbg_cfg.fm_debug_mode;
800#else
801 debug_mode = false;
802#endif
803
804 ret = iwl_mvm_fm_register_callback(debug_mode, IUI_FM_MACRO_ID_WLAN,
805 iwl_mvm_fm_wlan_mitigation);
806
807 IWL_DEBUG_EXTERNAL(g_mvm,
808 "FM: registering fm callback function (fail = %d)\n",
809 ret);
810 if (ret)
811 g_mvm = NULL;
812
813 return ret ? -EINVAL : ret;
814}
815
816/*
817 * Unregister the Frequency Mitigation Callback function implementation
818 */
819int iwl_mvm_fm_unregister(struct iwl_mvm *mvm)
820{
821 int ret;
822
823 if (g_mvm != mvm)
824 return 0;
825
826 ret = iwl_mvm_fm_register_callback(debug_mode, IUI_FM_MACRO_ID_WLAN,
827 NULL);
828
829 IWL_DEBUG_EXTERNAL(g_mvm,
830 "FM: unregistering fm callback function (fail = %d)\n",
831 ret);
832
833 cancel_work_sync(&fm_chan_notif_wk);
834 g_mvm = NULL;
835
836 return ret ? -EINVAL : ret;
837}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fm-test.c b/drivers/net/wireless/intel/iwlwifi/mvm/fm-test.c
838deleted file mode 1006440deleted file mode 100644
index 385c92f..0000000
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fm-test.c
+++ /dev/null
@@ -1,264 +0,0 @@
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) 2013 - 2015 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 * The full GNU General Public License is included in this distribution
21 * in the file called COPYING.
22 *
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *
27 * BSD LICENSE
28 *
29 * Copyright(c) 2013 - 2015 Intel Corporation. All rights reserved.
30 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 *
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
41 * the documentation and/or other materials provided with the
42 * distribution.
43 * * Neither the name Intel Corporation nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *
59 *****************************************************************************/
60#include <linux/fm/iui_fm.h>
61#include <linux/kernel.h>
62#include <linux/debugfs.h>
63#include <linux/netdevice.h>
64
65/*
66 * UT framework to debug Frequency Manager on any platform.
67 *
68 * The framework contains stub functions & debugfs entries so the iwlwifi driver
69 * can run the FM code without having an active FM in the background.
70 *
71 * FM--> iwlwifi driver API:
72 * Done via debugfs entry: request the driver to mitigate its activity.
73 * Through the debugfs the user can request driver to start tx power &
74 * 2g coex mitigation.
75 *
76 * Iwlwfi driver-->FM API
77 * Done via internal "stub" functions that will simulate the calls to the FM
78 * If the debug mode is set, the calls to the real API functions are ignored,
79 * and the stubs are called instead.
80 *
81 * To activate the FM debug mode you need to:
82 * 1. Enable the IWLWIFI_FRQ_MGR_TEST config (it will enable by default the
83 * IWLWIFI_FRQ_MGR config)
84 * 2. add fm_debug_mode=0x1 in the file iwl-dbg-cfg.ini
85 *
86 * NOTE: If the platform does not have a FM then the ut will use the
87 * include/linux/fm/iui_fm_test.h header file, otherwise it will use the
88 * platform header file.
89 */
90
91/* pointer to callback function in debug mode */
92static iui_fm_mitigation_cb fm_callback;
93static struct iui_fm_wlan_info fm_notif;
94static struct dentry *fm_debug_dir;
95
96static ssize_t
97iwl_mvm_fm_debug_mitigate_write(struct file *file,
98 const char __user *user_buf,
99 size_t count, loff_t *ppos)
100{
101 struct iui_fm_mitigation mitigation;
102 struct iui_fm_wlan_mitigation wm;
103 char buf[128];
104 size_t buf_size = sizeof(buf);
105 int mitigate_2g;
106 int ret;
107 int mitigate_dcdc;
108
109 mitigation.info.wlan_mitigation = &wm;
110 mitigation.type = IUI_FM_MITIGATION_TYPE_WLAN;
111
112 if (copy_from_user(buf, user_buf, buf_size))
113 return -EFAULT;
114
115 /* All platforms that are not xmm6321 & SOFIA 3G */
116 if (IUI_FM_WLAN_MAX_CHANNELS == 4) {
117 if (sscanf(buf, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
118 &wm.num_channels,
119 &wm.channel_tx_pwr[0].frequency,
120 &wm.channel_tx_pwr[0].max_tx_pwr,
121 &wm.channel_tx_pwr[1].frequency,
122 &wm.channel_tx_pwr[1].max_tx_pwr,
123 &wm.channel_tx_pwr[2].frequency,
124 &wm.channel_tx_pwr[2].max_tx_pwr,
125 &wm.channel_tx_pwr[3].frequency,
126 &wm.channel_tx_pwr[3].max_tx_pwr,
127 &mitigate_dcdc,
128 &wm.dcdc_div0,
129 &wm.dcdc_div1,
130 &mitigate_2g,
131 &wm.wlan_2g_coex_enable) != 14)
132 return -EINVAL;
133 } else if (sscanf(buf, "%d,%d,%d,%d,%d", &wm.num_channels,
134 &wm.channel_tx_pwr[0].frequency,
135 &wm.channel_tx_pwr[0].max_tx_pwr,
136 &wm.channel_tx_pwr[1].frequency,
137 &wm.channel_tx_pwr[1].max_tx_pwr) != 5) {
138 return -EINVAL;
139 }
140
141 if (IUI_FM_WLAN_MAX_CHANNELS < wm.num_channels)
142 return -EINVAL;
143
144 wm.wlan_adc_dac_freq = 0;
145 wm.rx_gain_behavior = IUI_FM_WLAN_RX_GAIN_NORMAL;
146
147 wm.bitmask = 0;
148
149 /* Set bit bitmask to indicate the required mitigations */
150 if (wm.num_channels || mitigate_2g)
151 wm.bitmask |= WLAN_MITI;
152 if (mitigate_dcdc)
153 wm.bitmask |= DCDC_MITI;
154
155 ret = fm_callback(IUI_FM_MACRO_ID_WLAN, &mitigation, 0);
156 pr_info("FM[test-mode]: mitigation callback %s (bitmask = 0x%x)\n",
157 ret ? "failed" : "succeeded", wm.bitmask);
158
159 return count;
160}
161
162static ssize_t
163iwl_mvm_fm_debug_notify_read(struct file *file, char __user *userbuf,
164 size_t count, loff_t *ppos)
165{
166 char buf[512];
167 int bufsz = sizeof(buf);
168 int pos = 0;
169 u8 i;
170
171 pos += scnprintf(buf + pos, bufsz - pos, "num_channels=%d\n",
172 fm_notif.num_channels);
173 for (i = 0; i < fm_notif.num_channels; i++)
174 pos += scnprintf(buf + pos, bufsz - pos,
175 "channel=%d, bandwidth=%d\n",
176 fm_notif.channel_info[i].frequency,
177 fm_notif.channel_info[i].bandwidth);
178
179 pos += scnprintf(buf + pos, bufsz - pos, "dcdc_div0=%d\n",
180 fm_notif.dcdc_div0);
181 pos += scnprintf(buf + pos, bufsz - pos, "dcdc_div1=%d\n",
182 fm_notif.dcdc_div1);
183
184 return simple_read_from_buffer(userbuf, count, ppos, buf, pos);
185}
186
187static const struct file_operations fm_debug_mitigate_ops = {
188 .write = iwl_mvm_fm_debug_mitigate_write,
189 .open = simple_open,
190 .llseek = generic_file_llseek,
191};
192
193static const struct file_operations fm_debug_notify_ops = {
194 .read = iwl_mvm_fm_debug_notify_read,
195 .open = simple_open,
196 .llseek = generic_file_llseek,
197};
198
199static int iwl_mvm_fm_create_debugfs(void)
200{
201 struct dentry *entry;
202
203 fm_debug_dir = debugfs_create_dir("frq_mgr", NULL);
204
205 if (!fm_debug_dir)
206 goto err;
207
208 entry = debugfs_create_file("mitigate", S_IWUSR, fm_debug_dir,
209 NULL, &fm_debug_mitigate_ops);
210 if (!entry)
211 goto err;
212
213 entry = debugfs_create_file("notify", S_IRUSR, fm_debug_dir,
214 NULL, &fm_debug_notify_ops);
215 if (!entry)
216 goto err;
217
218 return 0;
219err:
220 pr_info("FM: Could not create debugfs entries\n");
221 debugfs_remove_recursive(fm_debug_dir);
222 return -1;
223}
224
225int32_t
226iwl_mvm_fm_test_register_callback(const enum iui_fm_macro_id macro_id,
227 const iui_fm_mitigation_cb mitigation_cb)
228{
229 int ret = 0;
230
231 fm_callback = mitigation_cb;
232
233 /* Unregister fm callback */
234 if (!mitigation_cb) {
235 debugfs_remove_recursive(fm_debug_dir);
236 goto end;
237 }
238
239 /* Register fm callback */
240 if (iwl_mvm_fm_create_debugfs()) {
241 ret = -1;
242 goto end;
243 }
244
245end:
246 pr_info("FM[test-mode]: %sregistering fm callback function (fail = %d)\n",
247 ret ? "un" : "", ret);
248 return ret;
249}
250
251int32_t
252iwl_mvm_fm_test_notify_frequency(const enum iui_fm_macro_id macro_id,
253 const struct iui_fm_freq_notification *
254 const notification)
255{
256 /* Platform does not have a FM or test mode was requested */
257 memcpy(&fm_notif, notification->info.wlan_info,
258 sizeof(struct iui_fm_wlan_info));
259
260 pr_info("FM[test-mode]: notifying fm about change (mask = 0x%x)\n",
261 notification->info.wlan_info->bitmask);
262
263 return 0;
264}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 8ce91d4..bb2ad8b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -1244,13 +1244,8 @@ static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
1244 }1244 }
12451245
1246 iwl_fw_dbg_stop_sync(&mvm->fwrt);1246 iwl_fw_dbg_stop_sync(&mvm->fwrt);
1247 /*1247 iwl_trans_stop_device(mvm->trans);
1248 * Stop and start the transport without entering low power1248 ret = iwl_trans_start_hw(mvm->trans);
1249 * mode. This will save the state of other components on the
1250 * device that are triggered by the INIT firwmare (MFUART).
1251 */
1252 _iwl_trans_stop_device(mvm->trans, false);
1253 ret = _iwl_trans_start_hw(mvm->trans, false);
1254 if (ret)1249 if (ret)
1255 return ret;1250 return ret;
12561251
@@ -1422,7 +1417,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1422 goto error;1417 goto error;
1423 }1418 }
14241419
1425#ifdef CONFIG_THERMAL
1426 if (iwl_mvm_is_tt_in_fw(mvm)) {1420 if (iwl_mvm_is_tt_in_fw(mvm)) {
1427 /* in order to give the responsibility of ct-kill and1421 /* in order to give the responsibility of ct-kill and
1428 * TX backoff to FW we need to send empty temperature reporting1422 * TX backoff to FW we need to send empty temperature reporting
@@ -1434,6 +1428,7 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1434 iwl_mvm_tt_tx_backoff(mvm, 0);1428 iwl_mvm_tt_tx_backoff(mvm, 0);
1435 }1429 }
14361430
1431#ifdef CONFIG_THERMAL
1437 /* TODO: read the budget from BIOS / Platform NVM */1432 /* TODO: read the budget from BIOS / Platform NVM */
14381433
1439 /*1434 /*
@@ -1446,9 +1441,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1446 if (ret)1441 if (ret)
1447 goto error;1442 goto error;
1448 }1443 }
1449#else
1450 /* Initialize tx backoffs to the minimal possible */
1451 iwl_mvm_tt_tx_backoff(mvm, 0);
1452#endif1444#endif
14531445
1454 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2))1446 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2))
@@ -1479,10 +1471,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1479 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))1471 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1480 iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_UPDATE_DB);1472 iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_UPDATE_DB);
14811473
1482#ifdef CPTCFG_IWLWIFI_LTE_COEX
1483 iwl_mvm_send_lte_commands(mvm);
1484#endif
1485
1486#ifdef CPTCFG_IWLMVM_VENDOR_CMDS1474#ifdef CPTCFG_IWLMVM_VENDOR_CMDS
1487 /* set_mode must be IWL_TX_POWER_MODE_SET_DEVICE if this was1475 /* set_mode must be IWL_TX_POWER_MODE_SET_DEVICE if this was
1488 * ever initialized.1476 * ever initialized.
@@ -1506,10 +1494,6 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1506 }1494 }
1507#endif1495#endif
15081496
1509#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1510 iwl_mvm_fm_notify_current_dcdc();
1511#endif
1512
1513 if (iwl_acpi_get_eckv(mvm->dev, &mvm->ext_clock_valid))1497 if (iwl_acpi_get_eckv(mvm->dev, &mvm->ext_clock_valid))
1514 IWL_DEBUG_INFO(mvm, "ECKV table doesn't exist in BIOS\n");1498 IWL_DEBUG_INFO(mvm, "ECKV table doesn't exist in BIOS\n");
15151499
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/lte-coex.h b/drivers/net/wireless/intel/iwlwifi/mvm/lte-coex.h
1516deleted file mode 1006441500deleted file mode 100644
index 5bf99ee..0000000
--- a/drivers/net/wireless/intel/iwlwifi/mvm/lte-coex.h
+++ /dev/null
@@ -1,125 +0,0 @@
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) 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2014 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 * The full GNU General Public License is included in this distribution
21 * in the file called COPYING.
22 *
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *
27 * BSD LICENSE
28 *
29 * Copyright(c) 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2014 Intel Mobile Communications GmbH
31 * All rights reserved.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 *
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
41 * the documentation and/or other materials provided with the
42 * distribution.
43 * * Neither the name Intel Corporation nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *
59 *****************************************************************************/
60
61#ifndef __coex_h__
62#define __coex_h__
63
64#include <linux/types.h>
65
66/* LTE-Coex protocol user space commands */
67
68#define LTE_OFF 0
69#define LTE_IDLE 1
70#define LTE_CONNECTED 2
71
72/* LTE-Coex error codes */
73
74#define LTE_OK 0
75/* LTE state machine violation */
76#define LTE_STATE_ERR 1
77#define LTE_ILLEGAL_PARAMS 2
78#define LTE_INVALID_DATA 3
79#define LTE_OTHER_ERR 4
80
81
82struct lte_coex_state_cmd {
83 __u8 lte_state;
84} __packed;
85
86#define LTE_MWS_CONF_LENGTH 12
87#define LTE_SAFE_PT_LENGTH 32
88#define LTE_SAFE_PT_FIRST -128
89#define LTE_SAFE_PT_LAST 127
90struct lte_coex_config_info_cmd {
91 __u32 mws_conf_data[LTE_MWS_CONF_LENGTH];
92 __s8 safe_power_table[LTE_SAFE_PT_LENGTH];
93} __packed;
94
95#define LTE_CONNECTED_BANDS_LENGTH 8
96#define LTE_FRAME_STRUCT_LENGTH 2
97#define LTE_TX_POWER_LENGTH 14
98#define LTE_FRQ_MIN 2400
99#define LTE_FRQ_MAX 2500
100#define LTE_MAX_TX_MIN 0
101#define LTE_MAX_TX_MAX 31
102struct lte_coex_dynamic_info_cmd {
103 __u32 lte_connected_bands[LTE_CONNECTED_BANDS_LENGTH];
104 __u32 lte_frame_structure[LTE_FRAME_STRUCT_LENGTH];
105 __u16 wifi_tx_safe_freq_min;
106 __u16 wifi_tx_safe_freq_max;
107 __u16 wifi_rx_safe_freq_min;
108 __u16 wifi_rx_safe_freq_max;
109 __u8 wifi_max_tx_power[LTE_TX_POWER_LENGTH];
110} __packed;
111
112struct lte_coex_sps_info_cmd {
113 __u32 sps_info;
114} __packed;
115
116#define LTE_RC_CHAN_MIN 1
117#define LTE_RC_CHAN_MAX 14
118#define LTE_RC_BW_MIN 0
119#define LTE_RC_BW_MAX 3
120struct lte_coex_wifi_reported_chan_cmd {
121 __u8 chan;
122 __u8 bandwidth;
123} __packed;
124
125#endif /* __coex_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 9c26dd4..ebcacd1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -633,6 +633,8 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
633 /* We need the dtim_period to set the MAC as associated */633 /* We need the dtim_period to set the MAC as associated */
634 if (vif->bss_conf.assoc && vif->bss_conf.dtim_period &&634 if (vif->bss_conf.assoc && vif->bss_conf.dtim_period &&
635 !force_assoc_off) {635 !force_assoc_off) {
636 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
637 u8 ap_sta_id = mvmvif->ap_sta_id;
636 u32 dtim_offs;638 u32 dtim_offs;
637639
638 /*640 /*
@@ -668,7 +670,29 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
668 dtim_offs);670 dtim_offs);
669671
670 ctxt_sta->is_assoc = cpu_to_le32(1);672 ctxt_sta->is_assoc = cpu_to_le32(1);
671 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_ACCEPT_GRP);673
674 /*
675 * allow multicast data frames only as long as the station is
676 * authorized, i.e., GTK keys are already installed (if needed)
677 */
678 if (ap_sta_id < IWL_MVM_STATION_COUNT) {
679 struct ieee80211_sta *sta;
680
681 rcu_read_lock();
682
683 sta = rcu_dereference(mvm->fw_id_to_mac_id[ap_sta_id]);
684 if (!IS_ERR_OR_NULL(sta)) {
685 struct iwl_mvm_sta *mvmsta =
686 iwl_mvm_sta_from_mac80211(sta);
687
688 if (mvmsta->sta_state ==
689 IEEE80211_STA_AUTHORIZED)
690 cmd.filter_flags |=
691 cpu_to_le32(MAC_FILTER_ACCEPT_GRP);
692 }
693
694 rcu_read_unlock();
695 }
672 } else {696 } else {
673 ctxt_sta->is_assoc = cpu_to_le32(0);697 ctxt_sta->is_assoc = cpu_to_le32(0);
674698
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 60a345c..c610056 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1124,15 +1124,6 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
1124 mvm->ps_disabled = false;1124 mvm->ps_disabled = false;
1125 mvm->rfkill_safe_init_done = false;1125 mvm->rfkill_safe_init_done = false;
11261126
1127#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1128 /*
1129 * In case that 2g coex was enabled - and now the FW is being
1130 * restarted, we need to disable 2g coex mode in the driver as well
1131 * so that the fw & driver will be synced on the mode.
1132 */
1133 mvm->coex_2g_enabled = false;
1134#endif
1135
1136 /* just in case one was running */1127 /* just in case one was running */
1137 iwl_mvm_cleanup_roc_te(mvm);1128 iwl_mvm_cleanup_roc_te(mvm);
1138 ieee80211_remain_on_channel_expired(mvm->hw);1129 ieee80211_remain_on_channel_expired(mvm->hw);
@@ -1368,18 +1359,6 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1368 .v5.v3.pwr_restriction = cpu_to_le16(8 * tx_power),1359 .v5.v3.pwr_restriction = cpu_to_le16(8 * tx_power),
1369 };1360 };
13701361
1371#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1372 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1373
1374 /*
1375 * if set Tx power request did not come from Frequency Manager(FM)
1376 * Take minimum between wanted Tx power to FM Tx power limit
1377 */
1378 if (mvmvif->phy_ctxt && tx_power > mvmvif->phy_ctxt->fm_tx_power_limit)
1379 cmd.v5.v3.pwr_restriction =
1380 cpu_to_le16(mvmvif->phy_ctxt->fm_tx_power_limit);
1381#endif
1382
1383 if (tx_power == IWL_DEFAULT_MAX_TX_POWER)1362 if (tx_power == IWL_DEFAULT_MAX_TX_POWER)
1384 cmd.v5.v3.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER);1363 cmd.v5.v3.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER);
13851364
@@ -1395,35 +1374,6 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1395 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);1374 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
1396}1375}
13971376
1398#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1399int iwl_mvm_fm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1400 s8 txpower)
1401{
1402 int ret;
1403
1404 mutex_lock(&mvm->mutex);
1405 /* set Tx power to min between drivers limit and FM limit */
1406 ret = iwl_mvm_set_tx_power(mvm, vif, min_t(s8, txpower,
1407 vif->bss_conf.txpower));
1408 mutex_unlock(&mvm->mutex);
1409 return ret;
1410}
1411
1412/*
1413 * Updates Tx power limitation for the mac if FM has already limited
1414 * the Tx power on the channel that this mac is using.
1415 */
1416static void iwl_mvm_update_ctx_tx_power_limit(struct iwl_mvm *mvm,
1417 struct ieee80211_vif *vif,
1418 struct iwl_mvm_phy_ctxt *phy_ctxt)
1419{
1420 /* Tx power has not been limited by FM */
1421 if (phy_ctxt->fm_tx_power_limit == IWL_DEFAULT_MAX_TX_POWER)
1422 return;
1423 iwl_mvm_set_tx_power(mvm, vif, phy_ctxt->fm_tx_power_limit);
1424}
1425#endif
1426
1427static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,1377static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
1428 struct ieee80211_vif *vif)1378 struct ieee80211_vif *vif)
1429{1379{
@@ -1620,10 +1570,6 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1620 if (ret)1570 if (ret)
1621 goto out_unref_phy;1571 goto out_unref_phy;
16221572
1623#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1624 iwl_mvm_update_ctx_tx_power_limit(mvm, vif, mvmvif->phy_ctxt);
1625#endif
1626
1627 ret = iwl_mvm_add_p2p_bcast_sta(mvm, vif);1573 ret = iwl_mvm_add_p2p_bcast_sta(mvm, vif);
1628 if (ret)1574 if (ret)
1629 goto out_unbind;1575 goto out_unbind;
@@ -2647,10 +2593,6 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw,
2647 if (ret)2593 if (ret)
2648 goto out_remove;2594 goto out_remove;
26492595
2650#ifdef CPTCFG_IWLWIFI_FRQ_MGR
2651 iwl_mvm_update_ctx_tx_power_limit(mvm, vif, mvmvif->phy_ctxt);
2652#endif
2653
2654 /*2596 /*
2655 * This is not very nice, but the simplest:2597 * This is not very nice, but the simplest:
2656 * For older FWs adding the mcast sta before the bcast station may2598 * For older FWs adding the mcast sta before the bcast station may
@@ -3323,10 +3265,20 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
3323 /* enable beacon filtering */3265 /* enable beacon filtering */
3324 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0));3266 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0));
33253267
3268 /*
3269 * Now that the station is authorized, i.e., keys were already
3270 * installed, need to indicate to the FW that
3271 * multicast data frames can be forwarded to the driver
3272 */
3273 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
3274
3326 iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,3275 iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,
3327 true);3276 true);
3328 } else if (old_state == IEEE80211_STA_AUTHORIZED &&3277 } else if (old_state == IEEE80211_STA_AUTHORIZED &&
3329 new_state == IEEE80211_STA_ASSOC) {3278 new_state == IEEE80211_STA_ASSOC) {
3279 /* Multicast data frames are no longer allowed */
3280 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
3281
3330 /* disable beacon filtering */3282 /* disable beacon filtering */
3331 ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);3283 ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
3332 WARN_ON(ret &&3284 WARN_ON(ret &&
@@ -4083,10 +4035,6 @@ static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm,
4083 iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);4035 iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
4084 *phy_ctxt_id = phy_ctxt->id;4036 *phy_ctxt_id = phy_ctxt->id;
40854037
4086#ifdef CPTCFG_IWLWIFI_FRQ_MGR
4087 iwl_mvm_fm_notify_channel_change(ctx, IWL_FM_ADD_CHANCTX);
4088#endif
4089
4090out:4038out:
4091 return ret;4039 return ret;
4092}4040}
@@ -4113,9 +4061,6 @@ static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm,
4113 lockdep_assert_held(&mvm->mutex);4061 lockdep_assert_held(&mvm->mutex);
41144062
4115 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);4063 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
4116#ifdef CPTCFG_IWLWIFI_FRQ_MGR
4117 iwl_mvm_fm_notify_channel_change(ctx, IWL_FM_REMOVE_CHANCTX);
4118#endif
4119}4064}
41204065
4121static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,4066static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
@@ -4164,9 +4109,6 @@ static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
4164 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, def,4109 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, def,
4165 ctx->rx_chains_static,4110 ctx->rx_chains_static,
4166 ctx->rx_chains_dynamic);4111 ctx->rx_chains_dynamic);
4167#ifdef CPTCFG_IWLWIFI_FRQ_MGR
4168 iwl_mvm_fm_notify_channel_change(ctx, IWL_FM_CHANGE_CHANCTX);
4169#endif
41704112
4171out_unlock:4113out_unlock:
4172 mutex_unlock(&mvm->mutex);4114 mutex_unlock(&mvm->mutex);
@@ -4217,10 +4159,6 @@ static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
4217 if (ret)4159 if (ret)
4218 goto out;4160 goto out;
42194161
4220#ifdef CPTCFG_IWLWIFI_FRQ_MGR
4221 iwl_mvm_update_ctx_tx_power_limit(mvm, vif, mvmvif->phy_ctxt);
4222#endif
4223
4224 /*4162 /*
4225 * Power state must be updated before quotas,4163 * Power state must be updated before quotas,
4226 * otherwise fw will complain.4164 * otherwise fw will complain.
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 372e86e..e140a1f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -89,10 +89,6 @@
89#include "fw/acpi.h"89#include "fw/acpi.h"
90#include "iwl-nvm-parse.h"90#include "iwl-nvm-parse.h"
9191
92#ifdef CPTCFG_IWLWIFI_LTE_COEX
93#include "lte-coex.h"
94#endif
95
96#include <linux/average.h>92#include <linux/average.h>
9793
98#define IWL_MVM_MAX_ADDRESSES 594#define IWL_MVM_MAX_ADDRESSES 5
@@ -162,10 +158,6 @@ struct iwl_mvm_phy_ctxt {
162 */158 */
163 struct ieee80211_channel *channel;159 struct ieee80211_channel *channel;
164160
165#ifdef CPTCFG_IWLWIFI_FRQ_MGR
166 /* Frequency Manager tx power limit*/
167 s8 fm_tx_power_limit;
168#endif
169};161};
170162
171struct iwl_mvm_time_event_data {163struct iwl_mvm_time_event_data {
@@ -598,24 +590,6 @@ struct iwl_mvm_frame_stats {
598 int last_frame_idx;590 int last_frame_idx;
599};591};
600592
601#ifdef CPTCFG_IWLWIFI_LTE_COEX
602struct lte_coex_state {
603 u8 state;
604
605 bool has_static;
606 bool has_config;
607 bool has_sps;
608 bool has_rprtd_chan;
609 bool has_ft;
610
611 struct iwl_lte_coex_static_params_cmd stat;
612 struct iwl_lte_coex_config_cmd config;
613 struct iwl_lte_coex_sps_cmd sps;
614 struct iwl_lte_coex_wifi_reported_channel_cmd rprtd_chan;
615 struct iwl_lte_coex_fine_tuning_params_cmd ft;
616};
617#endif
618
619#define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff593#define IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE 0xff
620#define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100594#define IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -100
621#define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200595#define IWL_MVM_DEBUG_SET_TEMPERATURE_MAX 200
@@ -1062,6 +1036,7 @@ struct iwl_mvm {
1062 struct ieee80211_channel **nd_channels;1036 struct ieee80211_channel **nd_channels;
1063 int n_nd_channels;1037 int n_nd_channels;
1064 bool net_detect;1038 bool net_detect;
1039 u8 offload_tid;
1065#ifdef CPTCFG_IWLWIFI_DEBUGFS1040#ifdef CPTCFG_IWLWIFI_DEBUGFS
1066 bool d3_wake_sysassert;1041 bool d3_wake_sysassert;
1067 bool d3_test_active;1042 bool d3_test_active;
@@ -1080,17 +1055,9 @@ struct iwl_mvm {
1080 u8 bt_tx_prio;1055 u8 bt_tx_prio;
1081 enum iwl_bt_force_ant_mode bt_force_ant_mode;1056 enum iwl_bt_force_ant_mode bt_force_ant_mode;
10821057
1083#ifdef CPTCFG_IWLWIFI_LTE_COEX
1084 /* LTE-Coex */
1085 struct lte_coex_state lte_state;
1086#endif
1087 /* Aux ROC */1058 /* Aux ROC */
1088 struct list_head aux_roc_te_list;1059 struct list_head aux_roc_te_list;
10891060
1090#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1091 /* 2G-Coex */
1092 bool coex_2g_enabled;
1093#endif
1094 /* Thermal Throttling and CTkill */1061 /* Thermal Throttling and CTkill */
1095 struct iwl_mvm_tt_mgmt thermal_throttle;1062 struct iwl_mvm_tt_mgmt thermal_throttle;
1096#ifdef CONFIG_THERMAL1063#ifdef CONFIG_THERMAL
@@ -1519,6 +1486,12 @@ static inline bool iwl_mvm_is_reduced_config_scan_supported(struct iwl_mvm *mvm)
1519 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG);1486 IWL_UCODE_TLV_API_REDUCED_SCAN_CONFIG);
1520}1487}
15211488
1489static inline bool iwl_mvm_is_scan_ext_chan_supported(struct iwl_mvm *mvm)
1490{
1491 return fw_has_api(&mvm->fw->ucode_capa,
1492 IWL_UCODE_TLV_API_SCAN_EXT_CHAN_VER);
1493}
1494
1522static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)1495static inline bool iwl_mvm_has_new_rx_stats_api(struct iwl_mvm *mvm)
1523{1496{
1524 return fw_has_api(&mvm->fw->ucode_capa,1497 return fw_has_api(&mvm->fw->ucode_capa,
@@ -1548,7 +1521,6 @@ iwl_mvm_get_agg_status(struct iwl_mvm *mvm, void *tx_resp)
15481521
1549static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)1522static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)
1550{1523{
1551#ifdef CONFIG_THERMAL
1552 /* these two TLV are redundant since the responsibility to CT-kill by1524 /* these two TLV are redundant since the responsibility to CT-kill by
1553 * FW happens only after we send at least one command of1525 * FW happens only after we send at least one command of
1554 * temperature THs report.1526 * temperature THs report.
@@ -1557,9 +1529,6 @@ static inline bool iwl_mvm_is_tt_in_fw(struct iwl_mvm *mvm)
1557 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) &&1529 IWL_UCODE_TLV_CAPA_CT_KILL_BY_FW) &&
1558 fw_has_capa(&mvm->fw->ucode_capa,1530 fw_has_capa(&mvm->fw->ucode_capa,
1559 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT);1531 IWL_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT);
1560#else /* CONFIG_THERMAL */
1561 return false;
1562#endif /* CONFIG_THERMAL */
1563}1532}
15641533
1565static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm)1534static inline bool iwl_mvm_is_ctdp_supported(struct iwl_mvm *mvm)
@@ -2087,27 +2056,6 @@ void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm);
2087int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);2056int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm);
2088int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);2057int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 budget);
20892058
2090#ifdef CPTCFG_IWLWIFI_FRQ_MGR
2091/* Frequency Manager */
2092#define FM_2G_COEX_ENABLE_DISABLE 0xFFFFFFFF
2093#define FM_2G_COEX_ENABLE -100
2094#define FM_2G_COEX_DISABLE 25
2095
2096enum iwl_fm_chan_change_action {
2097 IWL_FM_ADD_CHANCTX = 0,
2098 IWL_FM_REMOVE_CHANCTX = 1,
2099 IWL_FM_CHANGE_CHANCTX = 2,
2100};
2101
2102int iwl_mvm_fm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2103 s8 txpower);
2104void iwl_mvm_fm_notify_channel_change(struct ieee80211_chanctx_conf *ctx,
2105 enum iwl_fm_chan_change_action action);
2106void iwl_mvm_fm_notify_current_dcdc(void);
2107int iwl_mvm_fm_register(struct iwl_mvm *mvm);
2108int iwl_mvm_fm_unregister(struct iwl_mvm *mvm);
2109#endif
2110
2111/* Location Aware Regulatory */2059/* Location Aware Regulatory */
2112struct iwl_mcc_update_resp *2060struct iwl_mcc_update_resp *
2113iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,2061iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
@@ -2205,16 +2153,6 @@ void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2205void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);2153void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
2206u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed);2154u8 iwl_mvm_tcm_load_percentage(u32 airtime, u32 elapsed);
22072155
2208#ifdef CPTCFG_IWLWIFI_LTE_COEX
2209int iwl_mvm_send_lte_coex_static_params_cmd(struct iwl_mvm *mvm);
2210int iwl_mvm_send_lte_coex_config_cmd(struct iwl_mvm *mvm);
2211int iwl_mvm_send_lte_coex_wifi_reported_channel_cmd(struct iwl_mvm *mvm);
2212int iwl_mvm_send_lte_sps_cmd(struct iwl_mvm *mvm);
2213int iwl_mvm_send_lte_fine_tuning_params_cmd(struct iwl_mvm *mvm);
2214void iwl_mvm_reset_lte_state(struct iwl_mvm *mvm);
2215void iwl_mvm_send_lte_commands(struct iwl_mvm *mvm);
2216#endif
2217
2218void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);2156void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
2219unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,2157unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
2220 struct ieee80211_vif *vif,2158 struct ieee80211_vif *vif,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 018d6e0..ca25c5c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -399,21 +399,12 @@ static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = {
399 HCMD_NAME(TIME_QUOTA_CMD),399 HCMD_NAME(TIME_QUOTA_CMD),
400 HCMD_NAME(NON_QOS_TX_COUNTER_CMD),400 HCMD_NAME(NON_QOS_TX_COUNTER_CMD),
401 HCMD_NAME(LEDS_CMD),401 HCMD_NAME(LEDS_CMD),
402#ifdef CPTCFG_IWLWIFI_LTE_COEX
403 HCMD_NAME(LTE_COEX_CONFIG_CMD),
404 HCMD_NAME(LTE_COEX_WIFI_REPORTED_CHANNEL_CMD),
405 HCMD_NAME(LTE_COEX_STATIC_PARAMS_CMD),
406 HCMD_NAME(LTE_COEX_SPS_CMD),
407#endif
408 HCMD_NAME(LQ_CMD),402 HCMD_NAME(LQ_CMD),
409 HCMD_NAME(FW_PAGING_BLOCK_CMD),403 HCMD_NAME(FW_PAGING_BLOCK_CMD),
410 HCMD_NAME(SCAN_OFFLOAD_REQUEST_CMD),404 HCMD_NAME(SCAN_OFFLOAD_REQUEST_CMD),
411 HCMD_NAME(SCAN_OFFLOAD_ABORT_CMD),405 HCMD_NAME(SCAN_OFFLOAD_ABORT_CMD),
412 HCMD_NAME(HOT_SPOT_CMD),406 HCMD_NAME(HOT_SPOT_CMD),
413 HCMD_NAME(SCAN_OFFLOAD_PROFILES_QUERY_CMD),407 HCMD_NAME(SCAN_OFFLOAD_PROFILES_QUERY_CMD),
414#ifdef CPTCFG_IWLWIFI_LTE_COEX
415 HCMD_NAME(LTE_COEX_FINE_TUNING_PARAMS_CMD),
416#endif
417 HCMD_NAME(BT_COEX_UPDATE_REDUCED_TXP),408 HCMD_NAME(BT_COEX_UPDATE_REDUCED_TXP),
418 HCMD_NAME(BT_COEX_CI),409 HCMD_NAME(BT_COEX_CI),
419 HCMD_NAME(PHY_CONFIGURATION_CMD),410 HCMD_NAME(PHY_CONFIGURATION_CMD),
@@ -1024,12 +1015,6 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
1024 else1015 else
1025 memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx));1016 memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx));
10261017
1027#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1028 err = iwl_mvm_fm_register(mvm);
1029 if (err)
1030 pr_err("Unable to register with Frequency Manager: %d\n", err);
1031#endif
1032
1033#ifdef CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES1018#ifdef CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES
1034 iwl_mvm_init_modparams(mvm);1019 iwl_mvm_init_modparams(mvm);
1035#endif1020#endif
@@ -1066,10 +1051,6 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
10661051
1067 ieee80211_unregister_hw(mvm->hw);1052 ieee80211_unregister_hw(mvm->hw);
10681053
1069#ifdef CPTCFG_IWLWIFI_FRQ_MGR
1070 iwl_mvm_fm_unregister(mvm);
1071#endif
1072
1073 kfree(mvm->scan_cmd);1054 kfree(mvm->scan_cmd);
1074 kfree(mvm->mcast_filter_cmd);1055 kfree(mvm->mcast_filter_cmd);
1075 mvm->mcast_filter_cmd = NULL;1056 mvm->mcast_filter_cmd = NULL;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
index cd5ff55..9925616 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c
@@ -7,8 +7,8 @@
7 *7 *
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10 * Copyright(c) 2017 Intel Deutschland GmbH10 * Copyright(c) 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation11 * Copyright(c) 2018 - 2019 Intel Corporation
12 *12 *
13 * This program is free software; you can redistribute it and/or modify13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as14 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 *30 *
31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH32 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
33 * Copyright(c) 2018 Intel Corporation33 * Copyright(c) 2018 - 2019 Intel Corporation
34 * All rights reserved.34 * All rights reserved.
35 *35 *
36 * Redistribution and use in source and binary forms, with or without36 * Redistribution and use in source and binary forms, with or without
@@ -221,10 +221,6 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt,
221221
222 ctxt->channel = chandef->chan;222 ctxt->channel = chandef->chan;
223223
224#ifdef CPTCFG_IWLWIFI_FRQ_MGR
225 ctxt->fm_tx_power_limit = IWL_DEFAULT_MAX_TX_POWER;
226#endif
227
228 return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef,224 return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef,
229 chains_static, chains_dynamic,225 chains_static, chains_dynamic,
230 FW_CTXT_ACTION_ADD, 0);226 FW_CTXT_ACTION_ADD, 0);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
index 4a7b1e6..761a3e6 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
@@ -193,7 +193,7 @@ rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
193 int i, highest_mcs;193 int i, highest_mcs;
194194
195 for (i = 0; i < sta->rx_nss; i++) {195 for (i = 0; i < sta->rx_nss; i++) {
196 if (i == MAX_NSS)196 if (i == IWL_TLC_NSS_MAX)
197 break;197 break;
198198
199 highest_mcs = rs_fw_vht_highest_rx_mcs_index(vht_cap, i + 1);199 highest_mcs = rs_fw_vht_highest_rx_mcs_index(vht_cap, i + 1);
@@ -204,9 +204,10 @@ rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
204 if (sta->bandwidth == IEEE80211_STA_RX_BW_20)204 if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
205 supp &= ~BIT(IWL_TLC_MNG_HT_RATE_MCS9);205 supp &= ~BIT(IWL_TLC_MNG_HT_RATE_MCS9);
206206
207 cmd->ht_rates[i][0] = cpu_to_le16(supp);207 cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] = cpu_to_le16(supp);
208 if (sta->bandwidth == IEEE80211_STA_RX_BW_160)208 if (sta->bandwidth == IEEE80211_STA_RX_BW_160)
209 cmd->ht_rates[i][1] = cmd->ht_rates[i][0];209 cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
210 cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160];
210 }211 }
211}212}
212213
@@ -241,7 +242,7 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
241 le16_to_cpu(sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_160);242 le16_to_cpu(sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_160);
242 int i;243 int i;
243244
244 for (i = 0; i < sta->rx_nss && i < MAX_NSS; i++) {245 for (i = 0; i < sta->rx_nss && i < IWL_TLC_NSS_MAX; i++) {
245 u16 _mcs_160 = (mcs_160 >> (2 * i)) & 0x3;246 u16 _mcs_160 = (mcs_160 >> (2 * i)) & 0x3;
246 u16 _mcs_80 = (mcs_80 >> (2 * i)) & 0x3;247 u16 _mcs_80 = (mcs_80 >> (2 * i)) & 0x3;
247 u16 _tx_mcs_160 = (tx_mcs_160 >> (2 * i)) & 0x3;248 u16 _tx_mcs_160 = (tx_mcs_160 >> (2 * i)) & 0x3;
@@ -255,7 +256,7 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
255 }256 }
256 if (_mcs_80 > _tx_mcs_80)257 if (_mcs_80 > _tx_mcs_80)
257 _mcs_80 = _tx_mcs_80;258 _mcs_80 = _tx_mcs_80;
258 cmd->ht_rates[i][0] =259 cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] =
259 cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_80));260 cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_80));
260261
261 /* If one side doesn't support - mark both as not supporting */262 /* If one side doesn't support - mark both as not supporting */
@@ -266,7 +267,7 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
266 }267 }
267 if (_mcs_160 > _tx_mcs_160)268 if (_mcs_160 > _tx_mcs_160)
268 _mcs_160 = _tx_mcs_160;269 _mcs_160 = _tx_mcs_160;
269 cmd->ht_rates[i][1] =270 cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
270 cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_160));271 cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_160));
271 }272 }
272}273}
@@ -300,8 +301,10 @@ static void rs_fw_set_supp_rates(struct ieee80211_sta *sta,
300 rs_fw_vht_set_enabled_rates(sta, vht_cap, cmd);301 rs_fw_vht_set_enabled_rates(sta, vht_cap, cmd);
301 } else if (ht_cap->ht_supported) {302 } else if (ht_cap->ht_supported) {
302 cmd->mode = IWL_TLC_MNG_MODE_HT;303 cmd->mode = IWL_TLC_MNG_MODE_HT;
303 cmd->ht_rates[0][0] = cpu_to_le16(ht_cap->mcs.rx_mask[0]);304 cmd->ht_rates[IWL_TLC_NSS_1][IWL_TLC_HT_BW_NONE_160] =
304 cmd->ht_rates[1][0] = cpu_to_le16(ht_cap->mcs.rx_mask[1]);305 cpu_to_le16(ht_cap->mcs.rx_mask[0]);
306 cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_HT_BW_NONE_160] =
307 cpu_to_le16(ht_cap->mcs.rx_mask[1]);
305 }308 }
306}309}
307310
@@ -433,6 +436,16 @@ void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
433 iwl_mvm_reset_frame_stats(mvm);436 iwl_mvm_reset_frame_stats(mvm);
434#endif437#endif
435 rs_fw_set_supp_rates(sta, sband, &cfg_cmd);438 rs_fw_set_supp_rates(sta, sband, &cfg_cmd);
439#ifdef CPTCFG_IWLWIFI_SUPPORT_DEBUG_OVERRIDES
440 /*
441 * if AP disables mimo on 160bw (cmd->ht_rates[1][1] == 0
442 * we disable mimo on 80bw cmd->ht_rates[1][0]
443 */
444 if (mvm->trans->dbg_cfg.tx_siso_80bw_like_160bw &&
445 !cfg_cmd.ht_rates[1][1])
446 cfg_cmd.ht_rates[1][0] = 0;
447
448#endif
436449
437 /*450 /*
438 * since TLC offload works with one mode we can assume451 * since TLC offload works with one mode we can assume
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
index 446d523..4acee82 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c
@@ -77,7 +77,10 @@
77#define IWL_SCAN_DWELL_FRAGMENTED 4477#define IWL_SCAN_DWELL_FRAGMENTED 44
78#define IWL_SCAN_DWELL_EXTENDED 9078#define IWL_SCAN_DWELL_EXTENDED 90
79#define IWL_SCAN_NUM_OF_FRAGS 379#define IWL_SCAN_NUM_OF_FRAGS 3
80#define IWL_SCAN_LAST_2_4_CHN 14
8081
82#define IWL_SCAN_BAND_5_2 0
83#define IWL_SCAN_BAND_2_4 1
8184
82/* adaptive dwell max budget time [TU] for full scan */85/* adaptive dwell max budget time [TU] for full scan */
83#define IWL_SCAN_ADWELL_MAX_BUDGET_FULL_SCAN 30086#define IWL_SCAN_ADWELL_MAX_BUDGET_FULL_SCAN 300
@@ -956,11 +959,24 @@ static int iwl_mvm_scan_lmac_flags(struct iwl_mvm *mvm,
956 return flags;959 return flags;
957}960}
958961
962static void
963iwl_mvm_scan_set_legacy_probe_req(struct iwl_scan_probe_req_v1 *p_req,
964 struct iwl_scan_probe_req *src_p_req)
965{
966 int i;
967
968 p_req->mac_header = src_p_req->mac_header;
969 for (i = 0; i < SCAN_NUM_BAND_PROBE_DATA_V_1; i++)
970 p_req->band_data[i] = src_p_req->band_data[i];
971 p_req->common_data = src_p_req->common_data;
972 memcpy(p_req->buf, src_p_req->buf, sizeof(p_req->buf));
973}
974
959static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,975static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
960 struct iwl_mvm_scan_params *params)976 struct iwl_mvm_scan_params *params)
961{977{
962 struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;978 struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
963 struct iwl_scan_probe_req *preq =979 struct iwl_scan_probe_req_v1 *preq =
964 (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *980 (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
965 mvm->fw->ucode_capa.n_scan_channels);981 mvm->fw->ucode_capa.n_scan_channels);
966 u32 ssid_bitmap = 0;982 u32 ssid_bitmap = 0;
@@ -1030,7 +1046,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1030 iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,1046 iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
1031 params->n_channels, ssid_bitmap, cmd);1047 params->n_channels, ssid_bitmap, cmd);
10321048
1033 *preq = params->preq;1049 iwl_mvm_scan_set_legacy_probe_req(preq, &params->preq);
10341050
1035 return 0;1051 return 0;
1036}1052}
@@ -1408,9 +1424,17 @@ iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm,
14081424
1409 for (i = 0; i < n_channels; i++) {1425 for (i = 0; i < n_channels; i++) {
1410 channel_cfg[i].flags = cpu_to_le32(ssid_bitmap);1426 channel_cfg[i].flags = cpu_to_le32(ssid_bitmap);
1411 channel_cfg[i].channel_num = channels[i]->hw_value;1427 channel_cfg[i].v1.channel_num = channels[i]->hw_value;
1412 channel_cfg[i].iter_count = 1;1428 if (iwl_mvm_is_scan_ext_chan_supported(mvm)) {
1413 channel_cfg[i].iter_interval = 0;1429 channel_cfg[i].v2.band =
1430 channels[i]->hw_value <= IWL_SCAN_LAST_2_4_CHN ?
1431 IWL_SCAN_BAND_2_4 : IWL_SCAN_BAND_5_2;
1432 channel_cfg[i].v2.iter_count = 1;
1433 channel_cfg[i].v2.iter_interval = 0;
1434 } else {
1435 channel_cfg[i].v1.iter_count = 1;
1436 channel_cfg[i].v1.iter_interval = 0;
1437 }
1414 }1438 }
1415}1439}
14161440
@@ -1500,9 +1524,12 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1500 struct iwl_scan_req_umac *cmd = mvm->scan_cmd;1524 struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
1501 struct iwl_scan_umac_chan_param *chan_param;1525 struct iwl_scan_umac_chan_param *chan_param;
1502 void *cmd_data = iwl_mvm_get_scan_req_umac_data(mvm);1526 void *cmd_data = iwl_mvm_get_scan_req_umac_data(mvm);
1503 struct iwl_scan_req_umac_tail *sec_part = cmd_data +1527 void *sec_part = cmd_data + sizeof(struct iwl_scan_channel_cfg_umac) *
1504 sizeof(struct iwl_scan_channel_cfg_umac) *1528 mvm->fw->ucode_capa.n_scan_channels;
1505 mvm->fw->ucode_capa.n_scan_channels;1529 struct iwl_scan_req_umac_tail_v2 *tail_v2 =
1530 (struct iwl_scan_req_umac_tail_v2 *)sec_part;
1531 struct iwl_scan_req_umac_tail_v1 *tail_v1;
1532 struct iwl_ssid_ie *direct_scan;
1506 int uid, i;1533 int uid, i;
1507 u32 ssid_bitmap = 0;1534 u32 ssid_bitmap = 0;
1508 u8 channel_flags = 0;1535 u8 channel_flags = 0;
@@ -1564,18 +1591,12 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1564 chan_param->flags = channel_flags;1591 chan_param->flags = channel_flags;
1565 chan_param->count = params->n_channels;1592 chan_param->count = params->n_channels;
15661593
1567 iwl_scan_build_ssids(params, sec_part->direct_scan, &ssid_bitmap);
1568
1569 iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
1570 params->n_channels, ssid_bitmap,
1571 cmd_data);
1572
1573 for (i = 0; i < params->n_scan_plans; i++) {1594 for (i = 0; i < params->n_scan_plans; i++) {
1574 struct cfg80211_sched_scan_plan *scan_plan =1595 struct cfg80211_sched_scan_plan *scan_plan =
1575 &params->scan_plans[i];1596 &params->scan_plans[i];
15761597
1577 sec_part->schedule[i].iter_count = scan_plan->iterations;1598 tail_v2->schedule[i].iter_count = scan_plan->iterations;
1578 sec_part->schedule[i].interval =1599 tail_v2->schedule[i].interval =
1579 cpu_to_le16(scan_plan->interval);1600 cpu_to_le16(scan_plan->interval);
1580 }1601 }
15811602
@@ -1585,12 +1606,24 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1585 * For example, when regular scan is requested the driver sets one scan1606 * For example, when regular scan is requested the driver sets one scan
1586 * plan with one iteration.1607 * plan with one iteration.
1587 */1608 */
1588 if (!sec_part->schedule[i - 1].iter_count)1609 if (!tail_v2->schedule[i - 1].iter_count)
1589 sec_part->schedule[i - 1].iter_count = 0xff;1610 tail_v2->schedule[i - 1].iter_count = 0xff;
15901611
1591 sec_part->delay = cpu_to_le16(params->delay);1612 tail_v2->delay = cpu_to_le16(params->delay);
1592 sec_part->preq = params->preq;
15931613
1614 if (iwl_mvm_is_scan_ext_chan_supported(mvm)) {
1615 tail_v2->preq = params->preq;
1616 direct_scan = tail_v2->direct_scan;
1617 } else {
1618 tail_v1 = (struct iwl_scan_req_umac_tail_v1 *)sec_part;
1619 iwl_mvm_scan_set_legacy_probe_req(&tail_v1->preq,
1620 &params->preq);
1621 direct_scan = tail_v1->direct_scan;
1622 }
1623 iwl_scan_build_ssids(params, direct_scan, &ssid_bitmap);
1624 iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
1625 params->n_channels, ssid_bitmap,
1626 cmd_data);
1594 return 0;1627 return 0;
1595}1628}
15961629
@@ -2020,6 +2053,7 @@ static int iwl_mvm_scan_stop_wait(struct iwl_mvm *mvm, int type)
2020int iwl_mvm_scan_size(struct iwl_mvm *mvm)2053int iwl_mvm_scan_size(struct iwl_mvm *mvm)
2021{2054{
2022 int base_size = IWL_SCAN_REQ_UMAC_SIZE_V1;2055 int base_size = IWL_SCAN_REQ_UMAC_SIZE_V1;
2056 int tail_size;
20232057
2024 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm))2058 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm))
2025 base_size = IWL_SCAN_REQ_UMAC_SIZE_V8;2059 base_size = IWL_SCAN_REQ_UMAC_SIZE_V8;
@@ -2028,16 +2062,21 @@ int iwl_mvm_scan_size(struct iwl_mvm *mvm)
2028 else if (iwl_mvm_cdb_scan_api(mvm))2062 else if (iwl_mvm_cdb_scan_api(mvm))
2029 base_size = IWL_SCAN_REQ_UMAC_SIZE_V6;2063 base_size = IWL_SCAN_REQ_UMAC_SIZE_V6;
20302064
2031 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN))2065 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
2066 if (iwl_mvm_is_scan_ext_chan_supported(mvm))
2067 tail_size = sizeof(struct iwl_scan_req_umac_tail_v2);
2068 else
2069 tail_size = sizeof(struct iwl_scan_req_umac_tail_v1);
2070
2032 return base_size +2071 return base_size +
2033 sizeof(struct iwl_scan_channel_cfg_umac) *2072 sizeof(struct iwl_scan_channel_cfg_umac) *
2034 mvm->fw->ucode_capa.n_scan_channels +2073 mvm->fw->ucode_capa.n_scan_channels +
2035 sizeof(struct iwl_scan_req_umac_tail);2074 tail_size;
20362075 }
2037 return sizeof(struct iwl_scan_req_lmac) +2076 return sizeof(struct iwl_scan_req_lmac) +
2038 sizeof(struct iwl_scan_channel_cfg_lmac) *2077 sizeof(struct iwl_scan_channel_cfg_lmac) *
2039 mvm->fw->ucode_capa.n_scan_channels +2078 mvm->fw->ucode_capa.n_scan_channels +
2040 sizeof(struct iwl_scan_probe_req);2079 sizeof(struct iwl_scan_probe_req_v1);
2041}2080}
20422081
2043/*2082/*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c b/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
index 7cf15d1..c3ab21b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
@@ -67,10 +67,6 @@
67#include "mvm.h"67#include "mvm.h"
68#include "iwl-vendor-cmd.h"68#include "iwl-vendor-cmd.h"
6969
70#ifdef CPTCFG_IWLWIFI_LTE_COEX
71#include "lte-coex.h"
72#endif
73
74#include "iwl-io.h"70#include "iwl-io.h"
75#include "iwl-prph.h"71#include "iwl-prph.h"
7672
@@ -267,360 +263,6 @@ free:
267 return retval;263 return retval;
268}264}
269265
270#ifdef CPTCFG_IWLWIFI_LTE_COEX
271static int iwl_vendor_lte_coex_state_cmd(struct wiphy *wiphy,
272 struct wireless_dev *wdev,
273 const void *data, int data_len)
274{
275 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
276 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
277 const struct lte_coex_state_cmd *cmd = data;
278 struct sk_buff *skb;
279 int err = LTE_OK;
280
281 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, 100);
282 if (!skb)
283 return -ENOMEM;
284
285 if (data_len != sizeof(*cmd)) {
286 err = LTE_INVALID_DATA;
287 goto out;
288 }
289
290 IWL_DEBUG_COEX(mvm, "LTE-COEX: state cmd:\n\tstate: %d\n",
291 cmd->lte_state);
292
293 switch (cmd->lte_state) {
294 case LTE_OFF:
295 if (mvm->lte_state.has_config &&
296 mvm->lte_state.state != LTE_CONNECTED) {
297 err = LTE_STATE_ERR;
298 goto out;
299 }
300 mvm->lte_state.state = LTE_OFF;
301 mvm->lte_state.has_config = 0;
302 mvm->lte_state.has_rprtd_chan = 0;
303 mvm->lte_state.has_sps = 0;
304 mvm->lte_state.has_ft = 0;
305 break;
306 case LTE_IDLE:
307 if (!mvm->lte_state.has_static ||
308 (mvm->lte_state.has_config &&
309 mvm->lte_state.state != LTE_CONNECTED)) {
310 err = LTE_STATE_ERR;
311 goto out;
312 }
313 mvm->lte_state.has_config = 0;
314 mvm->lte_state.has_sps = 0;
315 mvm->lte_state.state = LTE_IDLE;
316 break;
317 case LTE_CONNECTED:
318 if (!(mvm->lte_state.has_config)) {
319 err = LTE_STATE_ERR;
320 goto out;
321 }
322 mvm->lte_state.state = LTE_CONNECTED;
323 break;
324 default:
325 err = LTE_ILLEGAL_PARAMS;
326 goto out;
327 }
328
329 mvm->lte_state.config.lte_state = cpu_to_le32(mvm->lte_state.state);
330
331 mutex_lock(&mvm->mutex);
332 if (iwl_mvm_send_lte_coex_config_cmd(mvm))
333 err = LTE_OTHER_ERR;
334 mutex_unlock(&mvm->mutex);
335
336out:
337 if (err)
338 iwl_mvm_reset_lte_state(mvm);
339
340 if (nla_put_u8(skb, NLA_BINARY, err)) {
341 kfree_skb(skb);
342 return -ENOBUFS;
343 }
344
345 return cfg80211_vendor_cmd_reply(skb);
346}
347
348static int iwl_vendor_lte_coex_config_cmd(struct wiphy *wiphy,
349 struct wireless_dev *wdev,
350 const void *data, int data_len)
351{
352 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
353 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
354 const struct lte_coex_config_info_cmd *cmd = data;
355 struct iwl_lte_coex_static_params_cmd *stat = &mvm->lte_state.stat;
356 struct sk_buff *skb;
357 int err = LTE_OK;
358 int i, j;
359
360 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, 100);
361 if (!skb)
362 return -ENOMEM;
363
364 if (data_len != sizeof(*cmd)) {
365 err = LTE_INVALID_DATA;
366 goto out;
367 }
368
369 IWL_DEBUG_COEX(mvm, "LTE-COEX: config cmd:\n");
370
371 /* send static config only once in the FW life */
372 if (mvm->lte_state.has_static)
373 goto out;
374
375 for (i = 0; i < LTE_MWS_CONF_LENGTH; i++) {
376 IWL_DEBUG_COEX(mvm, "\tmws config data[%d]: %d\n", i,
377 cmd->mws_conf_data[i]);
378 stat->mfu_config[i] = cpu_to_le32(cmd->mws_conf_data[i]);
379 }
380
381 if (cmd->safe_power_table[0] != LTE_SAFE_PT_FIRST ||
382 cmd->safe_power_table[LTE_SAFE_PT_LENGTH - 1] !=
383 LTE_SAFE_PT_LAST) {
384 err = LTE_ILLEGAL_PARAMS;
385 goto out;
386 }
387
388 /* power table must be ascending ordered */
389 j = LTE_SAFE_PT_FIRST;
390 for (i = 0; i < LTE_SAFE_PT_LENGTH; i++) {
391 IWL_DEBUG_COEX(mvm, "\tsafe power table[%d]: %d\n", i,
392 cmd->safe_power_table[i]);
393 if (cmd->safe_power_table[i] < j) {
394 err = LTE_ILLEGAL_PARAMS;
395 goto out;
396 }
397 j = cmd->safe_power_table[i];
398 stat->tx_power_in_dbm[i] = cmd->safe_power_table[i];
399 }
400
401 mutex_lock(&mvm->mutex);
402 if (iwl_mvm_send_lte_coex_static_params_cmd(mvm))
403 err = LTE_OTHER_ERR;
404 else
405 mvm->lte_state.has_static = 1;
406 mutex_unlock(&mvm->mutex);
407
408out:
409 if (err)
410 iwl_mvm_reset_lte_state(mvm);
411
412 if (nla_put_u8(skb, NLA_BINARY, err)) {
413 kfree_skb(skb);
414 return -ENOBUFS;
415 }
416
417 return cfg80211_vendor_cmd_reply(skb);
418}
419
420static int in_range(int val, int min, int max)
421{
422 return (val >= min) && (val <= max);
423}
424
425static bool is_valid_lte_range(u16 min, u16 max)
426{
427 return (min == 0 && max == 0) ||
428 (max >= min &&
429 in_range(min, LTE_FRQ_MIN, LTE_FRQ_MAX) &&
430 in_range(max, LTE_FRQ_MIN, LTE_FRQ_MAX));
431}
432
433static int iwl_vendor_lte_coex_dynamic_info_cmd(struct wiphy *wiphy,
434 struct wireless_dev *wdev,
435 const void *data, int data_len)
436{
437 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
438 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
439 const struct lte_coex_dynamic_info_cmd *cmd = data;
440 struct iwl_lte_coex_config_cmd *config = &mvm->lte_state.config;
441 struct sk_buff *skb;
442 int err = LTE_OK;
443 int i;
444
445 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, 100);
446 if (!skb)
447 return -ENOMEM;
448
449 if (data_len != sizeof(*cmd)) {
450 err = LTE_INVALID_DATA;
451 goto out;
452 }
453
454 if (!mvm->lte_state.has_static ||
455 (mvm->lte_state.has_config &&
456 mvm->lte_state.state != LTE_CONNECTED)) {
457 err = LTE_STATE_ERR;
458 goto out;
459 }
460
461 IWL_DEBUG_COEX(mvm, "LTE-COEX: dynamic cmd:\n"
462 "\tlte band[0]: %d, chan[0]: %d\n\ttx range: %d - %d\n"
463 "\trx range: %d - %d\n", cmd->lte_connected_bands[0],
464 cmd->lte_connected_bands[1], cmd->wifi_tx_safe_freq_min,
465 cmd->wifi_tx_safe_freq_max, cmd->wifi_rx_safe_freq_min,
466 cmd->wifi_rx_safe_freq_max);
467
468 /* TODO: validate lte connected bands and channel, and frame struct */
469 config->lte_band = cpu_to_le32(cmd->lte_connected_bands[0]);
470 config->lte_chan = cpu_to_le32(cmd->lte_connected_bands[1]);
471 for (i = 0; i < LTE_FRAME_STRUCT_LENGTH; i++) {
472 IWL_DEBUG_COEX(mvm, "\tframe structure[%d]: %d\n", i,
473 cmd->lte_frame_structure[i]);
474 config->lte_frame_structure[i] =
475 cpu_to_le32(cmd->lte_frame_structure[i]);
476 }
477 if (!is_valid_lte_range(cmd->wifi_tx_safe_freq_min,
478 cmd->wifi_tx_safe_freq_max) ||
479 !is_valid_lte_range(cmd->wifi_rx_safe_freq_min,
480 cmd->wifi_rx_safe_freq_max)) {
481 err = LTE_ILLEGAL_PARAMS;
482 goto out;
483 }
484 config->tx_safe_freq_min = cpu_to_le32(cmd->wifi_tx_safe_freq_min);
485 config->tx_safe_freq_max = cpu_to_le32(cmd->wifi_tx_safe_freq_max);
486 config->rx_safe_freq_min = cpu_to_le32(cmd->wifi_rx_safe_freq_min);
487 config->rx_safe_freq_max = cpu_to_le32(cmd->wifi_rx_safe_freq_max);
488 for (i = 0; i < LTE_TX_POWER_LENGTH; i++) {
489 IWL_DEBUG_COEX(mvm, "\twifi max tx power[%d]: %d\n", i,
490 cmd->wifi_max_tx_power[i]);
491 if (!in_range(cmd->wifi_max_tx_power[i], LTE_MAX_TX_MIN,
492 LTE_MAX_TX_MAX)) {
493 err = LTE_ILLEGAL_PARAMS;
494 goto out;
495 }
496 config->max_tx_power[i] = cmd->wifi_max_tx_power[i];
497 }
498
499 mvm->lte_state.has_config = 1;
500
501 if (mvm->lte_state.state == LTE_CONNECTED) {
502 mutex_lock(&mvm->mutex);
503 if (iwl_mvm_send_lte_coex_config_cmd(mvm))
504 err = LTE_OTHER_ERR;
505 mutex_unlock(&mvm->mutex);
506 }
507out:
508 if (err)
509 iwl_mvm_reset_lte_state(mvm);
510
511 if (nla_put_u8(skb, NLA_BINARY, err)) {
512 kfree_skb(skb);
513 return -ENOBUFS;
514 }
515
516 return cfg80211_vendor_cmd_reply(skb);
517}
518
519static int iwl_vendor_lte_sps_cmd(struct wiphy *wiphy,
520 struct wireless_dev *wdev, const void *data,
521 int data_len)
522{
523 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
524 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
525 const struct lte_coex_sps_info_cmd *cmd = data;
526 struct iwl_lte_coex_sps_cmd *sps = &mvm->lte_state.sps;
527 struct sk_buff *skb;
528 int err = LTE_OK;
529
530 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, 100);
531 if (!skb)
532 return -ENOMEM;
533
534 if (data_len != sizeof(*cmd)) {
535 err = LTE_INVALID_DATA;
536 goto out;
537 }
538
539 IWL_DEBUG_COEX(mvm, "LTE-COEX: sps cmd:\n\tsps info: %d\n",
540 cmd->sps_info);
541
542 if (mvm->lte_state.state != LTE_CONNECTED) {
543 err = LTE_STATE_ERR;
544 goto out;
545 }
546
547 /* TODO: validate SPS */
548 sps->lte_semi_persistent_info = cpu_to_le32(cmd->sps_info);
549
550 mutex_lock(&mvm->mutex);
551 if (iwl_mvm_send_lte_sps_cmd(mvm))
552 err = LTE_OTHER_ERR;
553 else
554 mvm->lte_state.has_sps = 1;
555 mutex_unlock(&mvm->mutex);
556
557out:
558 if (err)
559 iwl_mvm_reset_lte_state(mvm);
560
561 if (nla_put_u8(skb, NLA_BINARY, err)) {
562 kfree_skb(skb);
563 return -ENOBUFS;
564 }
565
566 return cfg80211_vendor_cmd_reply(skb);
567}
568
569static int
570iwl_vendor_lte_coex_wifi_reported_channel_cmd(struct wiphy *wiphy,
571 struct wireless_dev *wdev,
572 const void *data, int data_len)
573{
574 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
575 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
576 const struct lte_coex_wifi_reported_chan_cmd *cmd = data;
577 struct iwl_lte_coex_wifi_reported_channel_cmd *rprtd_chan =
578 &mvm->lte_state.rprtd_chan;
579 struct sk_buff *skb;
580 int err = LTE_OK;
581
582 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, 100);
583 if (!skb)
584 return -ENOMEM;
585
586 if (data_len != sizeof(*cmd)) {
587 err = LTE_INVALID_DATA;
588 goto out;
589 }
590
591 IWL_DEBUG_COEX(mvm, "LTE-COEX: wifi reported channel cmd:\n"
592 "\tchannel: %d, bandwidth: %d\n", cmd->chan,
593 cmd->bandwidth);
594
595 if (!in_range(cmd->chan, LTE_RC_CHAN_MIN, LTE_RC_CHAN_MAX) ||
596 !in_range(cmd->bandwidth, LTE_RC_BW_MIN, LTE_RC_BW_MAX)) {
597 err = LTE_ILLEGAL_PARAMS;
598 goto out;
599 }
600
601 rprtd_chan->channel = cpu_to_le32(cmd->chan);
602 rprtd_chan->bandwidth = cpu_to_le32(cmd->bandwidth);
603
604 mutex_lock(&mvm->mutex);
605 if (iwl_mvm_send_lte_coex_wifi_reported_channel_cmd(mvm))
606 err = LTE_OTHER_ERR;
607 else
608 mvm->lte_state.has_rprtd_chan = 1;
609 mutex_unlock(&mvm->mutex);
610
611out:
612 if (err)
613 iwl_mvm_reset_lte_state(mvm);
614
615 if (nla_put_u8(skb, NLA_BINARY, err)) {
616 kfree_skb(skb);
617 return -ENOBUFS;
618 }
619
620 return cfg80211_vendor_cmd_reply(skb);
621}
622#endif /* CPTCFG_IWLWIFI_LTE_COEX */
623
624static int iwl_vendor_frame_filter_cmd(struct wiphy *wiphy,266static int iwl_vendor_frame_filter_cmd(struct wiphy *wiphy,
625 struct wireless_dev *wdev,267 struct wireless_dev *wdev,
626 const void *data, int data_len)268 const void *data, int data_len)
@@ -1563,53 +1205,6 @@ static const struct wiphy_vendor_command iwl_mvm_vendor_commands[] = {
1563 WIPHY_VENDOR_CMD_NEED_RUNNING,1205 WIPHY_VENDOR_CMD_NEED_RUNNING,
1564 .doit = iwl_mvm_get_low_latency,1206 .doit = iwl_mvm_get_low_latency,
1565 },1207 },
1566#ifdef CPTCFG_IWLWIFI_LTE_COEX
1567 {
1568 .info = {
1569 .vendor_id = INTEL_OUI,
1570 .subcmd = IWL_MVM_VENDOR_CMD_LTE_STATE,
1571 },
1572 .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1573 WIPHY_VENDOR_CMD_NEED_RUNNING,
1574 .doit = iwl_vendor_lte_coex_state_cmd,
1575 },
1576 {
1577 .info = {
1578 .vendor_id = INTEL_OUI,
1579 .subcmd = IWL_MVM_VENDOR_CMD_LTE_COEX_CONFIG_INFO,
1580 },
1581 .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1582 WIPHY_VENDOR_CMD_NEED_RUNNING,
1583 .doit = iwl_vendor_lte_coex_config_cmd,
1584 },
1585 {
1586 .info = {
1587 .vendor_id = INTEL_OUI,
1588 .subcmd = IWL_MVM_VENDOR_CMD_LTE_COEX_DYNAMIC_INFO,
1589 },
1590 .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1591 WIPHY_VENDOR_CMD_NEED_RUNNING,
1592 .doit = iwl_vendor_lte_coex_dynamic_info_cmd,
1593 },
1594 {
1595 .info = {
1596 .vendor_id = INTEL_OUI,
1597 .subcmd = IWL_MVM_VENDOR_CMD_LTE_COEX_SPS_INFO,
1598 },
1599 .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1600 WIPHY_VENDOR_CMD_NEED_RUNNING,
1601 .doit = iwl_vendor_lte_sps_cmd,
1602 },
1603 {
1604 .info = {
1605 .vendor_id = INTEL_OUI,
1606 .subcmd = IWL_MVM_VENDOR_CMD_LTE_COEX_WIFI_RPRTD_CHAN,
1607 },
1608 .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1609 WIPHY_VENDOR_CMD_NEED_RUNNING,
1610 .doit = iwl_vendor_lte_coex_wifi_reported_channel_cmd,
1611 },
1612#endif /* CPTCFG_IWLWIFI_LTE_COEX */
1613 {1208 {
1614 .info = {1209 .info = {
1615 .vendor_id = INTEL_OUI,1210 .vendor_id = INTEL_OUI,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 8b2364a..fee789b 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -65,7 +65,6 @@
65#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt65#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6666
67#include <linux/module.h>67#include <linux/module.h>
68#include <linux/pm_runtime.h>
69#include <linux/pci.h>68#include <linux/pci.h>
70#include <linux/acpi.h>69#include <linux/acpi.h>
7170
@@ -875,25 +874,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
875 /* register transport layer debugfs here */874 /* register transport layer debugfs here */
876 iwl_trans_pcie_dbgfs_register(iwl_trans);875 iwl_trans_pcie_dbgfs_register(iwl_trans);
877876
878 /* if RTPM is in use, enable it in our device */
879 if (iwl_trans->runtime_pm_mode != IWL_PLAT_PM_MODE_DISABLED) {
880 /* We explicitly set the device to active here to
881 * clear contingent errors.
882 */
883 pm_runtime_set_active(&pdev->dev);
884
885 pm_runtime_set_autosuspend_delay(&pdev->dev,
886 iwlwifi_mod_params.d0i3_timeout);
887 pm_runtime_use_autosuspend(&pdev->dev);
888
889 /* We are not supposed to call pm_runtime_allow() by
890 * ourselves, but let userspace enable runtime PM via
891 * sysfs. However, since we don't enable this from
892 * userspace yet, we need to allow/forbid() ourselves.
893 */
894 pm_runtime_allow(&pdev->dev);
895 }
896
897 /* The PCI device starts with a reference taken and we are877 /* The PCI device starts with a reference taken and we are
898 * supposed to release it here. But to simplify the878 * supposed to release it here. But to simplify the
899 * interaction with the opmode, we don't do it now, but let879 * interaction with the opmode, we don't do it now, but let
@@ -911,15 +891,6 @@ static void iwl_pci_remove(struct pci_dev *pdev)
911{891{
912 struct iwl_trans *trans = pci_get_drvdata(pdev);892 struct iwl_trans *trans = pci_get_drvdata(pdev);
913893
914 /* if RTPM was in use, restore it to the state before probe */
915 if (trans->runtime_pm_mode != IWL_PLAT_PM_MODE_DISABLED) {
916 /* We should not call forbid here, but we do for now.
917 * Check the comment to pm_runtime_allow() in
918 * iwl_pci_probe().
919 */
920 pm_runtime_forbid(trans->dev);
921 }
922
923 iwl_drv_stop(trans->drv);894 iwl_drv_stop(trans->drv);
924895
925 iwl_trans_pcie_free(trans);896 iwl_trans_pcie_free(trans);
@@ -977,76 +948,6 @@ static int iwl_pci_resume(struct device *device)
977 return 0;948 return 0;
978}949}
979950
980int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans)
981{
982 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
983 int ret;
984
985 if (test_bit(STATUS_FW_ERROR, &trans->status))
986 return 0;
987
988 set_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
989
990 /* config the fw */
991 ret = iwl_op_mode_enter_d0i3(trans->op_mode);
992 if (ret == 1) {
993 IWL_DEBUG_RPM(trans, "aborting d0i3 entrance\n");
994 clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
995 return -EBUSY;
996 }
997 if (ret)
998 goto err;
999
1000 ret = wait_event_timeout(trans_pcie->d0i3_waitq,
1001 test_bit(STATUS_TRANS_IDLE, &trans->status),
1002 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
1003 if (!ret) {
1004 IWL_ERR(trans, "Timeout entering D0i3\n");
1005 ret = -ETIMEDOUT;
1006 goto err;
1007 }
1008
1009 clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
1010
1011 return 0;
1012err:
1013 clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
1014 iwl_trans_fw_error(trans);
1015 return ret;
1016}
1017
1018int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans)
1019{
1020 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1021 int ret;
1022
1023 /* sometimes a D0i3 entry is not followed through */
1024 if (!test_bit(STATUS_TRANS_IDLE, &trans->status))
1025 return 0;
1026
1027 /* config the fw */
1028 ret = iwl_op_mode_exit_d0i3(trans->op_mode);
1029 if (ret)
1030 goto err;
1031
1032 /* we clear STATUS_TRANS_IDLE only when D0I3_END command is completed */
1033
1034 ret = wait_event_timeout(trans_pcie->d0i3_waitq,
1035 !test_bit(STATUS_TRANS_IDLE, &trans->status),
1036 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
1037 if (!ret) {
1038 IWL_ERR(trans, "Timeout exiting D0i3\n");
1039 ret = -ETIMEDOUT;
1040 goto err;
1041 }
1042
1043 return 0;
1044err:
1045 clear_bit(STATUS_TRANS_IDLE, &trans->status);
1046 iwl_trans_fw_error(trans);
1047 return ret;
1048}
1049
1050static const struct dev_pm_ops iwl_dev_pm_ops = {951static const struct dev_pm_ops iwl_dev_pm_ops = {
1051 SET_SYSTEM_SLEEP_PM_OPS(iwl_pci_suspend,952 SET_SYSTEM_SLEEP_PM_OPS(iwl_pci_suspend,
1052 iwl_pci_resume)953 iwl_pci_resume)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 1f8e9a6..48017cc 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -558,7 +558,6 @@ struct iwl_trans_pcie {
558 bool ucode_write_complete;558 bool ucode_write_complete;
559 wait_queue_head_t ucode_write_waitq;559 wait_queue_head_t ucode_write_waitq;
560 wait_queue_head_t wait_command_queue;560 wait_queue_head_t wait_command_queue;
561 wait_queue_head_t d0i3_waitq;
562561
563 u8 page_offs, dev_cmd_offs;562 u8 page_offs, dev_cmd_offs;
564563
@@ -581,7 +580,6 @@ struct iwl_trans_pcie {
581 /*protect hw register */580 /*protect hw register */
582 spinlock_t reg_lock;581 spinlock_t reg_lock;
583 bool cmd_hold_nic_awake;582 bool cmd_hold_nic_awake;
584 bool ref_cmd_in_flight;
585583
586#ifdef CPTCFG_IWLWIFI_DEBUGFS584#ifdef CPTCFG_IWLWIFI_DEBUGFS
587 struct cont_rec fw_mon_data;585 struct cont_rec fw_mon_data;
@@ -696,6 +694,7 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
696 struct iwl_rx_cmd_buffer *rxb);694 struct iwl_rx_cmd_buffer *rxb);
697void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,695void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
698 struct sk_buff_head *skbs);696 struct sk_buff_head *skbs);
697void iwl_trans_pcie_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr);
699void iwl_trans_pcie_tx_reset(struct iwl_trans *trans);698void iwl_trans_pcie_tx_reset(struct iwl_trans *trans);
700void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans_pcie *trans_pcie,699void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans_pcie *trans_pcie,
701 struct iwl_txq *txq, u16 byte_cnt,700 struct iwl_txq *txq, u16 byte_cnt,
@@ -1063,9 +1062,6 @@ void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans);
1063static inline void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans) { }1062static inline void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans) { }
1064#endif1063#endif
10651064
1066int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans);
1067int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans);
1068
1069void iwl_pcie_rx_allocator_work(struct work_struct *data);1065void iwl_pcie_rx_allocator_work(struct work_struct *data);
10701066
1071/* common functions that are used by gen2 transport */1067/* common functions that are used by gen2 transport */
@@ -1119,9 +1115,8 @@ int iwl_trans_pcie_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb,
1119 struct iwl_device_cmd *dev_cmd, int txq_id);1115 struct iwl_device_cmd *dev_cmd, int txq_id);
1120int iwl_trans_pcie_gen2_send_hcmd(struct iwl_trans *trans,1116int iwl_trans_pcie_gen2_send_hcmd(struct iwl_trans *trans,
1121 struct iwl_host_cmd *cmd);1117 struct iwl_host_cmd *cmd);
1122void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans,1118void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans);
1123 bool low_power);1119void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans);
1124void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power);
1125void iwl_pcie_gen2_txq_unmap(struct iwl_trans *trans, int txq_id);1120void iwl_pcie_gen2_txq_unmap(struct iwl_trans *trans, int txq_id);
1126void iwl_pcie_gen2_tx_free(struct iwl_trans *trans);1121void iwl_pcie_gen2_tx_free(struct iwl_trans *trans);
1127void iwl_pcie_gen2_tx_stop(struct iwl_trans *trans);1122void iwl_pcie_gen2_tx_stop(struct iwl_trans *trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
index 104b7cc..c099ad8 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
@@ -136,7 +136,7 @@ static void iwl_pcie_gen2_apm_stop(struct iwl_trans *trans, bool op_mode_leave)
136 BIT(trans->cfg->csr->flag_init_done));136 BIT(trans->cfg->csr->flag_init_done));
137}137}
138138
139void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power)139void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans)
140{140{
141 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);141 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
142142
@@ -215,7 +215,7 @@ void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power)
215 iwl_pcie_prepare_card_hw(trans);215 iwl_pcie_prepare_card_hw(trans);
216}216}
217217
218void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power)218void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans)
219{219{
220 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);220 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
221 bool was_in_rfkill;221 bool was_in_rfkill;
@@ -223,7 +223,7 @@ void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans, bool low_power)
223 mutex_lock(&trans_pcie->mutex);223 mutex_lock(&trans_pcie->mutex);
224 trans_pcie->opmode_down = true;224 trans_pcie->opmode_down = true;
225 was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status);225 was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status);
226 _iwl_trans_pcie_gen2_stop_device(trans, low_power);226 _iwl_trans_pcie_gen2_stop_device(trans);
227 iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill);227 iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill);
228 mutex_unlock(&trans_pcie->mutex);228 mutex_unlock(&trans_pcie->mutex);
229}229}
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 77e740d..1e63a59 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -69,7 +69,6 @@
69#include <linux/bitops.h>69#include <linux/bitops.h>
70#include <linux/gfp.h>70#include <linux/gfp.h>
71#include <linux/vmalloc.h>71#include <linux/vmalloc.h>
72#include <linux/pm_runtime.h>
73#include <linux/module.h>72#include <linux/module.h>
74#include <linux/wait.h>73#include <linux/wait.h>
7574
@@ -1279,7 +1278,7 @@ static void iwl_pcie_init_msix(struct iwl_trans_pcie *trans_pcie)
1279 trans_pcie->hw_mask = trans_pcie->hw_init_mask;1278 trans_pcie->hw_mask = trans_pcie->hw_init_mask;
1280}1279}
12811280
1282static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)1281static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1283{1282{
1284 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);1283 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
12851284
@@ -1495,7 +1494,7 @@ void iwl_trans_pcie_handle_stop_rfkill(struct iwl_trans *trans,
1495 iwl_trans_pcie_rf_kill(trans, hw_rfkill);1494 iwl_trans_pcie_rf_kill(trans, hw_rfkill);
1496}1495}
14971496
1498static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)1497static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1499{1498{
1500 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);1499 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1501 bool was_in_rfkill;1500 bool was_in_rfkill;
@@ -1503,7 +1502,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
1503 mutex_lock(&trans_pcie->mutex);1502 mutex_lock(&trans_pcie->mutex);
1504 trans_pcie->opmode_down = true;1503 trans_pcie->opmode_down = true;
1505 was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status);1504 was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status);
1506 _iwl_trans_pcie_stop_device(trans, low_power);1505 _iwl_trans_pcie_stop_device(trans);
1507 iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill);1506 iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill);
1508 mutex_unlock(&trans_pcie->mutex);1507 mutex_unlock(&trans_pcie->mutex);
1509}1508}
@@ -1519,9 +1518,9 @@ void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state)
1519 state ? "disabled" : "enabled");1518 state ? "disabled" : "enabled");
1520 if (iwl_op_mode_hw_rf_kill(trans->op_mode, state)) {1519 if (iwl_op_mode_hw_rf_kill(trans->op_mode, state)) {
1521 if (trans->cfg->gen2)1520 if (trans->cfg->gen2)
1522 _iwl_trans_pcie_gen2_stop_device(trans, true);1521 _iwl_trans_pcie_gen2_stop_device(trans);
1523 else1522 else
1524 _iwl_trans_pcie_stop_device(trans, true);1523 _iwl_trans_pcie_stop_device(trans);
1525 }1524 }
1526}1525}
15271526
@@ -1780,7 +1779,7 @@ static int iwl_trans_pcie_clear_persistence_bit(struct iwl_trans *trans)
1780 return 0;1779 return 0;
1781}1780}
17821781
1783static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)1782static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1784{1783{
1785 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);1784 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1786 int err;1785 int err;
@@ -1816,20 +1815,16 @@ static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)
1816 /* ...rfkill can call stop_device and set it false if needed */1815 /* ...rfkill can call stop_device and set it false if needed */
1817 iwl_pcie_check_hw_rf_kill(trans);1816 iwl_pcie_check_hw_rf_kill(trans);
18181817
1819 /* Make sure we sync here, because we'll need full access later */
1820 if (low_power)
1821 pm_runtime_resume(trans->dev);
1822
1823 return 0;1818 return 0;
1824}1819}
18251820
1826static int iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)1821static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1827{1822{
1828 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);1823 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1829 int ret;1824 int ret;
18301825
1831 mutex_lock(&trans_pcie->mutex);1826 mutex_lock(&trans_pcie->mutex);
1832 ret = _iwl_trans_pcie_start_hw(trans, low_power);1827 ret = _iwl_trans_pcie_start_hw(trans);
1833 mutex_unlock(&trans_pcie->mutex);1828 mutex_unlock(&trans_pcie->mutex);
18341829
1835 return ret;1830 return ret;
@@ -2413,41 +2408,6 @@ static void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg,
2413 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);2408 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
2414}2409}
24152410
2416static void iwl_trans_pcie_ref(struct iwl_trans *trans)
2417{
2418 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2419
2420 if (iwlwifi_mod_params.d0i3_disable)
2421 return;
2422
2423 pm_runtime_get(&trans_pcie->pci_dev->dev);
2424
2425#ifdef CONFIG_PM
2426#if (defined(CONFIG_PM_RUNTIME) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
2427 IWL_DEBUG_RPM(trans, "runtime usage count: %d\n",
2428 atomic_read(&trans_pcie->pci_dev->dev.power.usage_count));
2429#endif
2430#endif /* CONFIG_PM */
2431}
2432
2433static void iwl_trans_pcie_unref(struct iwl_trans *trans)
2434{
2435 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
2436
2437 if (iwlwifi_mod_params.d0i3_disable)
2438 return;
2439
2440 pm_runtime_mark_last_busy(&trans_pcie->pci_dev->dev);
2441 pm_runtime_put_autosuspend(&trans_pcie->pci_dev->dev);
2442
2443#ifdef CONFIG_PM
2444#if (defined(CONFIG_PM_RUNTIME) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
2445 IWL_DEBUG_RPM(trans, "runtime usage count: %d\n",
2446 atomic_read(&trans_pcie->pci_dev->dev.power.usage_count));
2447#endif
2448#endif /* CONFIG_PM */
2449}
2450
2451static const char *get_csr_string(int cmd)2411static const char *get_csr_string(int cmd)
2452{2412{
2453#define IWL_CMD(x) case x: return #x2413#define IWL_CMD(x) case x: return #x
@@ -3369,18 +3329,11 @@ static struct iwl_trans_dump_data
3369#ifdef CONFIG_PM_SLEEP3329#ifdef CONFIG_PM_SLEEP
3370static int iwl_trans_pcie_suspend(struct iwl_trans *trans)3330static int iwl_trans_pcie_suspend(struct iwl_trans *trans)
3371{3331{
3372 if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 &&
3373 (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3))
3374 return iwl_pci_fw_enter_d0i3(trans);
3375
3376 return 0;3332 return 0;
3377}3333}
33783334
3379static void iwl_trans_pcie_resume(struct iwl_trans *trans)3335static void iwl_trans_pcie_resume(struct iwl_trans *trans)
3380{3336{
3381 if (trans->runtime_pm_mode == IWL_PLAT_PM_MODE_D0I3 &&
3382 (trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3))
3383 iwl_pci_fw_exit_d0i3(trans);
3384}3337}
3385#endif /* CONFIG_PM_SLEEP */3338#endif /* CONFIG_PM_SLEEP */
33863339
@@ -3399,8 +3352,6 @@ static void iwl_trans_pcie_resume(struct iwl_trans *trans)
3399 .grab_nic_access = iwl_trans_pcie_grab_nic_access, \3352 .grab_nic_access = iwl_trans_pcie_grab_nic_access, \
3400 .release_nic_access = iwl_trans_pcie_release_nic_access, \3353 .release_nic_access = iwl_trans_pcie_release_nic_access, \
3401 .set_bits_mask = iwl_trans_pcie_set_bits_mask, \3354 .set_bits_mask = iwl_trans_pcie_set_bits_mask, \
3402 .ref = iwl_trans_pcie_ref, \
3403 .unref = iwl_trans_pcie_unref, \
3404 .dump_data = iwl_trans_pcie_dump_data, \3355 .dump_data = iwl_trans_pcie_dump_data, \
3405 .d3_suspend = iwl_trans_pcie_d3_suspend, \3356 .d3_suspend = iwl_trans_pcie_d3_suspend, \
3406 .d3_resume = iwl_trans_pcie_d3_resume, \3357 .d3_resume = iwl_trans_pcie_d3_resume, \
@@ -3454,6 +3405,8 @@ static const struct iwl_trans_ops trans_ops_pcie_gen2 = {
3454 .tx = iwl_trans_pcie_gen2_tx,3405 .tx = iwl_trans_pcie_gen2_tx,
3455 .reclaim = iwl_trans_pcie_reclaim,3406 .reclaim = iwl_trans_pcie_reclaim,
34563407
3408 .set_q_ptrs = iwl_trans_pcie_set_q_ptrs,
3409
3457 .txq_alloc = iwl_trans_pcie_dyn_txq_alloc,3410 .txq_alloc = iwl_trans_pcie_dyn_txq_alloc,
3458 .txq_free = iwl_trans_pcie_dyn_txq_free,3411 .txq_free = iwl_trans_pcie_dyn_txq_free,
3459 .wait_txq_empty = iwl_trans_pcie_wait_txq_empty,3412 .wait_txq_empty = iwl_trans_pcie_wait_txq_empty,
@@ -3722,8 +3675,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3722 /* Initialize the wait queue for commands */3675 /* Initialize the wait queue for commands */
3723 init_waitqueue_head(&trans_pcie->wait_command_queue);3676 init_waitqueue_head(&trans_pcie->wait_command_queue);
37243677
3725 init_waitqueue_head(&trans_pcie->d0i3_waitq);
3726
3727 if (trans_pcie->msix_enabled) {3678 if (trans_pcie->msix_enabled) {
3728 ret = iwl_pcie_init_msix_handler(pdev, trans_pcie);3679 ret = iwl_pcie_init_msix_handler(pdev, trans_pcie);
3729 if (ret)3680 if (ret)
@@ -3748,8 +3699,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
3748 WQ_HIGHPRI | WQ_UNBOUND, 1);3699 WQ_HIGHPRI | WQ_UNBOUND, 1);
3749 INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);3700 INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);
37503701
3751 trans->runtime_pm_mode = IWL_PLAT_PM_MODE_DISABLED;
3752
3753#ifdef CPTCFG_IWLWIFI_DEBUGFS3702#ifdef CPTCFG_IWLWIFI_DEBUGFS
3754 trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED;3703 trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_CLOSED;
3755 mutex_init(&trans_pcie->fw_mon_data.mutex);3704 mutex_init(&trans_pcie->fw_mon_data.mutex);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index af389f0..2740032 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -50,7 +50,6 @@
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 *51 *
52 *****************************************************************************/52 *****************************************************************************/
53#include <linux/pm_runtime.h>
54#include <net/tso.h>53#include <net/tso.h>
55#include <linux/tcp.h>54#include <linux/tcp.h>
5655
@@ -654,12 +653,8 @@ int iwl_trans_pcie_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb,
654 iwl_pcie_gen2_get_num_tbs(trans, tfd));653 iwl_pcie_gen2_get_num_tbs(trans, tfd));
655654
656 /* start timer if queue currently empty */655 /* start timer if queue currently empty */
657 if (txq->read_ptr == txq->write_ptr) {656 if (txq->read_ptr == txq->write_ptr && txq->wd_timeout)
658 if (txq->wd_timeout)657 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
659 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
660 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", txq->id);
661 iwl_trans_ref(trans);
662 }
663658
664 /* Tell device the write index *just past* this latest filled TFD */659 /* Tell device the write index *just past* this latest filled TFD */
665 txq->write_ptr = iwl_queue_inc_wrap(trans, txq->write_ptr);660 txq->write_ptr = iwl_queue_inc_wrap(trans, txq->write_ptr);
@@ -904,12 +899,6 @@ static int iwl_pcie_gen2_enqueue_hcmd(struct iwl_trans *trans,
904 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);899 mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout);
905900
906 spin_lock_irqsave(&trans_pcie->reg_lock, flags);901 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
907 if (!(cmd->flags & CMD_SEND_IN_IDLE) &&
908 !trans_pcie->ref_cmd_in_flight) {
909 trans_pcie->ref_cmd_in_flight = true;
910 IWL_DEBUG_RPM(trans, "set ref_cmd_in_flight - ref\n");
911 iwl_trans_ref(trans);
912 }
913 /* Increment and update queue's write index */902 /* Increment and update queue's write index */
914 txq->write_ptr = iwl_queue_inc_wrap(trans, txq->write_ptr);903 txq->write_ptr = iwl_queue_inc_wrap(trans, txq->write_ptr);
915 iwl_pcie_gen2_txq_inc_wr_ptr(trans, txq);904 iwl_pcie_gen2_txq_inc_wr_ptr(trans, txq);
@@ -943,16 +932,6 @@ static int iwl_pcie_gen2_send_hcmd_sync(struct iwl_trans *trans,
943932
944 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str);933 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str);
945934
946 if (pm_runtime_suspended(&trans_pcie->pci_dev->dev)) {
947 ret = wait_event_timeout(trans_pcie->d0i3_waitq,
948 pm_runtime_active(&trans_pcie->pci_dev->dev),
949 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
950 if (!ret) {
951 IWL_ERR(trans, "Timeout exiting D0i3 before hcmd\n");
952 return -ETIMEDOUT;
953 }
954 }
955
956 cmd_idx = iwl_pcie_gen2_enqueue_hcmd(trans, cmd);935 cmd_idx = iwl_pcie_gen2_enqueue_hcmd(trans, cmd);
957 if (cmd_idx < 0) {936 if (cmd_idx < 0) {
958 ret = cmd_idx;937 ret = cmd_idx;
@@ -1077,23 +1056,6 @@ void iwl_pcie_gen2_txq_unmap(struct iwl_trans *trans, int txq_id)
1077 }1056 }
1078 iwl_pcie_gen2_free_tfd(trans, txq);1057 iwl_pcie_gen2_free_tfd(trans, txq);
1079 txq->read_ptr = iwl_queue_inc_wrap(trans, txq->read_ptr);1058 txq->read_ptr = iwl_queue_inc_wrap(trans, txq->read_ptr);
1080
1081 if (txq->read_ptr == txq->write_ptr) {
1082 unsigned long flags;
1083
1084 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
1085 if (txq_id != trans_pcie->cmd_queue) {
1086 IWL_DEBUG_RPM(trans, "Q %d - last tx freed\n",
1087 txq->id);
1088 iwl_trans_unref(trans);
1089 } else if (trans_pcie->ref_cmd_in_flight) {
1090 trans_pcie->ref_cmd_in_flight = false;
1091 IWL_DEBUG_RPM(trans,
1092 "clear ref_cmd_in_flight\n");
1093 iwl_trans_unref(trans);
1094 }
1095 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
1096 }
1097 }1059 }
10981060
1099 while (!skb_queue_empty(&txq->overflow_q)) {1061 while (!skb_queue_empty(&txq->overflow_q)) {
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 7c601ac..a1e4835 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -65,7 +65,6 @@
65#include <linux/ieee80211.h>65#include <linux/ieee80211.h>
66#include <linux/slab.h>66#include <linux/slab.h>
67#include <linux/sched.h>67#include <linux/sched.h>
68#include <linux/pm_runtime.h>
69#include <net/ip6_checksum.h>68#include <net/ip6_checksum.h>
70#include <net/tso.h>69#include <net/tso.h>
7170
@@ -637,12 +636,6 @@ static void iwl_pcie_clear_cmd_in_flight(struct iwl_trans *trans)
637636
638 lockdep_assert_held(&trans_pcie->reg_lock);637 lockdep_assert_held(&trans_pcie->reg_lock);
639638
640 if (trans_pcie->ref_cmd_in_flight) {
641 trans_pcie->ref_cmd_in_flight = false;
642 IWL_DEBUG_RPM(trans, "clear ref_cmd_in_flight - unref\n");
643 iwl_trans_unref(trans);
644 }
645
646 if (!trans->cfg->base_params->apmg_wake_up_wa)639 if (!trans->cfg->base_params->apmg_wake_up_wa)
647 return;640 return;
648 if (WARN_ON(!trans_pcie->cmd_hold_nic_awake))641 if (WARN_ON(!trans_pcie->cmd_hold_nic_awake))
@@ -681,13 +674,8 @@ static void iwl_pcie_txq_unmap(struct iwl_trans *trans, int txq_id)
681 unsigned long flags;674 unsigned long flags;
682675
683 spin_lock_irqsave(&trans_pcie->reg_lock, flags);676 spin_lock_irqsave(&trans_pcie->reg_lock, flags);
684 if (txq_id != trans_pcie->cmd_queue) {677 if (txq_id == trans_pcie->cmd_queue)
685 IWL_DEBUG_RPM(trans, "Q %d - last tx freed\n",
686 txq->id);
687 iwl_trans_unref(trans);
688 } else {
689 iwl_pcie_clear_cmd_in_flight(trans);678 iwl_pcie_clear_cmd_in_flight(trans);
690 }
691 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);679 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
692 }680 }
693 }681 }
@@ -1223,15 +1211,22 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
1223 txq->overflow_tx = false;1211 txq->overflow_tx = false;
1224 }1212 }
12251213
1226 if (txq->read_ptr == txq->write_ptr) {
1227 IWL_DEBUG_RPM(trans, "Q %d - last tx reclaimed\n", txq->id);
1228 iwl_trans_unref(trans);
1229 }
1230
1231out:1214out:
1232 spin_unlock_bh(&txq->lock);1215 spin_unlock_bh(&txq->lock);
1233}1216}
12341217
1218/* Set wr_ptr of specific device and txq */
1219void iwl_trans_pcie_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr)
1220{
1221 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1222 struct iwl_txq *txq = trans_pcie->txq[txq_id];
1223
1224 lockdep_assert_held(&txq->lock);
1225
1226 txq->write_ptr = ptr;
1227 txq->read_ptr = txq->write_ptr;
1228}
1229
1235static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans,1230static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans,
1236 const struct iwl_host_cmd *cmd)1231 const struct iwl_host_cmd *cmd)
1237{1232{
@@ -1245,13 +1240,6 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans,
1245 if (test_bit(STATUS_TRANS_DEAD, &trans->status))1240 if (test_bit(STATUS_TRANS_DEAD, &trans->status))
1246 return -ENODEV;1241 return -ENODEV;
12471242
1248 if (!(cmd->flags & CMD_SEND_IN_IDLE) &&
1249 !trans_pcie->ref_cmd_in_flight) {
1250 trans_pcie->ref_cmd_in_flight = true;
1251 IWL_DEBUG_RPM(trans, "set ref_cmd_in_flight - ref\n");
1252 iwl_trans_ref(trans);
1253 }
1254
1255 /*1243 /*
1256 * wake up the NIC to make sure that the firmware will see the host1244 * wake up the NIC to make sure that the firmware will see the host
1257 * command - we will let the NIC sleep once all the host commands1245 * command - we will let the NIC sleep once all the host commands
@@ -1865,20 +1853,6 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
1865 wake_up(&trans_pcie->wait_command_queue);1853 wake_up(&trans_pcie->wait_command_queue);
1866 }1854 }
18671855
1868 if (meta->flags & CMD_MAKE_TRANS_IDLE) {
1869 IWL_DEBUG_INFO(trans, "complete %s - mark trans as idle\n",
1870 iwl_get_cmd_string(trans, cmd->hdr.cmd));
1871 set_bit(STATUS_TRANS_IDLE, &trans->status);
1872 wake_up(&trans_pcie->d0i3_waitq);
1873 }
1874
1875 if (meta->flags & CMD_WAKE_UP_TRANS) {
1876 IWL_DEBUG_INFO(trans, "complete %s - clear trans idle flag\n",
1877 iwl_get_cmd_string(trans, cmd->hdr.cmd));
1878 clear_bit(STATUS_TRANS_IDLE, &trans->status);
1879 wake_up(&trans_pcie->d0i3_waitq);
1880 }
1881
1882 meta->flags = 0;1856 meta->flags = 0;
18831857
1884 spin_unlock_bh(&txq->lock);1858 spin_unlock_bh(&txq->lock);
@@ -1925,16 +1899,6 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1925 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n",1899 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n",
1926 iwl_get_cmd_string(trans, cmd->id));1900 iwl_get_cmd_string(trans, cmd->id));
19271901
1928 if (pm_runtime_suspended(&trans_pcie->pci_dev->dev)) {
1929 ret = wait_event_timeout(trans_pcie->d0i3_waitq,
1930 pm_runtime_active(&trans_pcie->pci_dev->dev),
1931 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
1932 if (!ret) {
1933 IWL_ERR(trans, "Timeout exiting D0i3 before hcmd\n");
1934 return -ETIMEDOUT;
1935 }
1936 }
1937
1938 cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd);1902 cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd);
1939 if (cmd_idx < 0) {1903 if (cmd_idx < 0) {
1940 ret = cmd_idx;1904 ret = cmd_idx;
@@ -2517,22 +2481,18 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
2517 wait_write_ptr = ieee80211_has_morefrags(fc);2481 wait_write_ptr = ieee80211_has_morefrags(fc);
25182482
2519 /* start timer if queue currently empty */2483 /* start timer if queue currently empty */
2520 if (txq->read_ptr == txq->write_ptr) {2484 if (txq->read_ptr == txq->write_ptr && txq->wd_timeout) {
2521 if (txq->wd_timeout) {2485 /*
2522 /*2486 * If the TXQ is active, then set the timer, if not,
2523 * If the TXQ is active, then set the timer, if not,2487 * set the timer in remainder so that the timer will
2524 * set the timer in remainder so that the timer will2488 * be armed with the right value when the station will
2525 * be armed with the right value when the station will2489 * wake up.
2526 * wake up.2490 */
2527 */2491 if (!txq->frozen)
2528 if (!txq->frozen)2492 mod_timer(&txq->stuck_timer,
2529 mod_timer(&txq->stuck_timer,2493 jiffies + txq->wd_timeout);
2530 jiffies + txq->wd_timeout);2494 else
2531 else2495 txq->frozen_expiry_remainder = txq->wd_timeout;
2532 txq->frozen_expiry_remainder = txq->wd_timeout;
2533 }
2534 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", txq->id);
2535 iwl_trans_ref(trans);
2536 }2496 }
25372497
2538 /* Tell device the write index *just past* this latest filled TFD */2498 /* Tell device the write index *just past* this latest filled TFD */
diff --git a/drivers/net/wireless/intel/iwlwifi/xvt/fw.c b/drivers/net/wireless/intel/iwlwifi/xvt/fw.c
index 95a3eca..6755e7d 100644
--- a/drivers/net/wireless/intel/iwlwifi/xvt/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/xvt/fw.c
@@ -322,7 +322,7 @@ static int iwl_xvt_config_ltr(struct iwl_xvt *xvt)
322 return iwl_xvt_send_cmd_pdu(xvt, LTR_CONFIG, 0, sizeof(cmd), &cmd);322 return iwl_xvt_send_cmd_pdu(xvt, LTR_CONFIG, 0, sizeof(cmd), &cmd);
323}323}
324324
325int iwl_xvt_run_fw(struct iwl_xvt *xvt, u32 ucode_type, bool cont_run)325int iwl_xvt_run_fw(struct iwl_xvt *xvt, u32 ucode_type)
326{326{
327 int ret;327 int ret;
328328
@@ -338,13 +338,10 @@ int iwl_xvt_run_fw(struct iwl_xvt *xvt, u32 ucode_type, bool cont_run)
338 iwl_xvt_txq_disable(xvt);338 iwl_xvt_txq_disable(xvt);
339 }339 }
340 iwl_fw_dbg_stop_sync(&xvt->fwrt);340 iwl_fw_dbg_stop_sync(&xvt->fwrt);
341 _iwl_trans_stop_device(xvt->trans, !cont_run);341 iwl_trans_stop_device(xvt->trans);
342 }342 }
343343
344 if (cont_run)344 ret = iwl_trans_start_hw(xvt->trans);
345 ret = _iwl_trans_start_hw(xvt->trans, false);
346 else
347 ret = iwl_trans_start_hw(xvt->trans);
348 if (ret) {345 if (ret) {
349 IWL_ERR(xvt, "Failed to start HW\n");346 IWL_ERR(xvt, "Failed to start HW\n");
350 return ret;347 return ret;
diff --git a/drivers/net/wireless/intel/iwlwifi/xvt/user-infc.c b/drivers/net/wireless/intel/iwlwifi/xvt/user-infc.c
index 137fd8c..ee89d9a 100644
--- a/drivers/net/wireless/intel/iwlwifi/xvt/user-infc.c
+++ b/drivers/net/wireless/intel/iwlwifi/xvt/user-infc.c
@@ -482,11 +482,12 @@ init_error:
482 iwl_trans_stop_device(xvt->trans);482 iwl_trans_stop_device(xvt->trans);
483 return err;483 return err;
484}484}
485static int iwl_xvt_run_runtime_fw(struct iwl_xvt *xvt, bool cont_run)485
486static int iwl_xvt_run_runtime_fw(struct iwl_xvt *xvt)
486{487{
487 int err;488 int err;
488489
489 err = iwl_xvt_run_fw(xvt, IWL_UCODE_REGULAR, cont_run);490 err = iwl_xvt_run_fw(xvt, IWL_UCODE_REGULAR);
490 if (err)491 if (err)
491 goto fw_error;492 goto fw_error;
492493
@@ -557,7 +558,7 @@ static int iwl_xvt_start_op_mode(struct iwl_xvt *xvt)
557 */558 */
558 if (!(xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_INIT)) {559 if (!(xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_INIT)) {
559 if (xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_RUNTIME) {560 if (xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_RUNTIME) {
560 err = iwl_xvt_run_runtime_fw(xvt, false);561 err = iwl_xvt_run_runtime_fw(xvt);
561 } else {562 } else {
562 if (xvt->state != IWL_XVT_STATE_UNINITIALIZED) {563 if (xvt->state != IWL_XVT_STATE_UNINITIALIZED) {
563 xvt->fw_running = false;564 xvt->fw_running = false;
@@ -579,7 +580,7 @@ static int iwl_xvt_start_op_mode(struct iwl_xvt *xvt)
579 /* when fw image is unified, only regular ucode is loaded. */580 /* when fw image is unified, only regular ucode is loaded. */
580 if (iwl_xvt_is_unified_fw(xvt))581 if (iwl_xvt_is_unified_fw(xvt))
581 ucode_type = IWL_UCODE_REGULAR;582 ucode_type = IWL_UCODE_REGULAR;
582 err = iwl_xvt_run_fw(xvt, ucode_type, false);583 err = iwl_xvt_run_fw(xvt, ucode_type);
583 if (err)584 if (err)
584 return err;585 return err;
585586
@@ -665,7 +666,7 @@ static int iwl_xvt_continue_init(struct iwl_xvt *xvt)
665666
666 if (xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_RUNTIME)667 if (xvt->sw_stack_cfg.load_mask & IWL_XVT_LOAD_MASK_RUNTIME)
667 /* Run runtime FW stops the device by itself if error occurs */668 /* Run runtime FW stops the device by itself if error occurs */
668 err = iwl_xvt_run_runtime_fw(xvt, true);669 err = iwl_xvt_run_runtime_fw(xvt);
669670
670 goto cont_init_end;671 goto cont_init_end;
671672
diff --git a/drivers/net/wireless/intel/iwlwifi/xvt/xvt.h b/drivers/net/wireless/intel/iwlwifi/xvt/xvt.h
index 8ede75f..baae1bf 100644
--- a/drivers/net/wireless/intel/iwlwifi/xvt/xvt.h
+++ b/drivers/net/wireless/intel/iwlwifi/xvt/xvt.h
@@ -7,7 +7,7 @@
7 *7 *
8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH9 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
10 * Copyright(c) 2018 Intel Corporation10 * Copyright(c) 2018 - 2019 Intel Corporation
11 *11 *
12 * This program is free software; you can redistribute it and/or modify12 * 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 as13 * it under the terms of version 2 of the GNU General Public License as
@@ -29,7 +29,7 @@
29 *29 *
30 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.30 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
31 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH31 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
32 * Copyright(c) 2018 Intel Corporation32 * Copyright(c) 2018 - 2019 Intel Corporation
33 * All rights reserved.33 * All rights reserved.
34 *34 *
35 * Redistribution and use in source and binary forms, with or without35 * Redistribution and use in source and binary forms, with or without
@@ -443,7 +443,7 @@ int iwl_xvt_user_cmd_execute(struct iwl_testmode *testmode, u32 cmd,
443 struct iwl_tm_data *data_out, bool *supported_cmd);443 struct iwl_tm_data *data_out, bool *supported_cmd);
444444
445/* FW */445/* FW */
446int iwl_xvt_run_fw(struct iwl_xvt *xvt, u32 ucode_type, bool cont_run);446int iwl_xvt_run_fw(struct iwl_xvt *xvt, u32 ucode_type);
447447
448/* NVM */448/* NVM */
449int iwl_xvt_nvm_init(struct iwl_xvt *xvt);449int iwl_xvt_nvm_init(struct iwl_xvt *xvt);
diff --git a/include/linux/fm/iui_fm.h b/include/linux/fm/iui_fm.h
450deleted file mode 100644450deleted file mode 100644
index 1411a3b..0000000
--- a/include/linux/fm/iui_fm.h
+++ /dev/null
@@ -1,143 +0,0 @@
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 - 2015 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 <linuxwifi@intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
34 * Copyright(c) 2012 - 2015 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
66#ifndef __FM_TEST_IUI_H
67#define __FM_TEST_IUI_H
68
69#include <linux/errno.h>
70
71#if defined(CONFIG_IUI_FM) /* Use platform h file - NOT XMM6312/SOFIA-3G */
72#include <linux/fm/iui_fm_lte.h>
73#else /* Platform doesn't have FM - use test h file */
74#include "iui_fm_test.h"
75#endif /* CONFIG_IUI_FM */
76
77#ifdef CPTCFG_IWLWIFI_FRQ_MGR_TEST
78int32_t
79iwl_mvm_fm_test_register_callback(const enum iui_fm_macro_id macro_id,
80 const iui_fm_mitigation_cb mitigation_cb);
81int32_t
82iwl_mvm_fm_test_notify_frequency(const enum iui_fm_macro_id macro_id,
83 const struct iui_fm_freq_notification *
84 const notification);
85#endif /* CPTCFG_IWLWIFI_FRQ_MGR_TEST */
86
87/*
88 * If platform has FM then we have 2 modes:
89 * Regular mode: Call the FM register function
90 * Debug mode: Don't call the FM register function & use test mode
91 * implementation.
92 * If platform does not have FM then we use test mode implementation.
93 */
94static inline
95int32_t iwl_mvm_fm_register_callback(bool dbg_mode,
96 const enum iui_fm_macro_id macro_id,
97 const iui_fm_mitigation_cb mitigation_cb)
98{
99#ifdef CPTCFG_IWLWIFI_FRQ_MGR_TEST
100 /* Platform does not have a FM or test mode was requested */
101 if (dbg_mode)
102 return iwl_mvm_fm_test_register_callback(macro_id,
103 mitigation_cb);
104#endif /* CPTCFG_IWLWIFI_FRQ_MGR_TEST */
105
106#if defined(CONFIG_IUI_FM) /* Not XMM6321/Sofa-3G - Platform has a FM */
107 return iui_fm_register_mitigation_callback_lte(macro_id,
108 mitigation_cb);
109#else
110
111 return -EPERM; /* fm_debug_mode was not set */
112#endif /* CONFIG_IUI_FM */
113}
114
115/*
116 * If platform has FM then we have 2 modes:
117 * Regular mode: Call the FM notify function
118 * Debug mode: Don't call the FM notify function & use test mode
119 * implementation.
120 * If platfom does not have FM then we use test mode implementation.
121 */
122static inline
123int32_t iwl_mvm_fm_notify_frequency(bool dbg_mode,
124 const enum iui_fm_macro_id macro_id,
125 const struct iui_fm_freq_notification *
126 const notification)
127{
128#ifdef CPTCFG_IWLWIFI_FRQ_MGR_TEST
129 /* Platform does not have a FM or test mode was requested */
130 if (dbg_mode)
131 return iwl_mvm_fm_test_notify_frequency(macro_id,
132 notification);
133#endif /* CPTCFG_IWLWIFI_FRQ_MGR_TEST */
134
135#if defined(CONFIG_IUI_FM) /* Not XMM6312/Sofia-3G - Platform has a FM */
136 return iui_fm_notify_frequency_lte(macro_id, notification);
137#else
138 return -EPERM; /* fm_debug_mode was not set */
139#endif /*CONFIG_IUI_FM */
140}
141
142#endif /* __FM_IUI_H */
143
diff --git a/include/linux/fm/iui_fm_test.h b/include/linux/fm/iui_fm_test.h
144deleted file mode 1006440deleted file mode 100644
index e347a55..0000000
--- a/include/linux/fm/iui_fm_test.h
+++ /dev/null
@@ -1,796 +0,0 @@
1/*
2 * Copyright (C) 2013 Intel Mobile Communications GmbH
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef _IUI_FM_H
15#define _IUI_FM_H
16
17/**
18 * @file iui_fm.h
19 * @brief The IUI Frequency Manager interface exposes an RPC-compatible
20 * interface to pass frequency information between macros on the AP and
21 * the Frequency Manager component on the MEX.
22 *
23 * @addtogroup ISPEC_FREQ_MANAGER Frequency manager
24 * @{
25 */
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31/* Choose whether to use integer types defined in the Linux Kernel (for kernel
32 builds) or C Library (for Userspace/MEX builds). */
33#ifdef __KERNEL__
34#include <linux/types.h>
35#include <linux/kernel.h>
36#define INT32_MAX INT_MAX
37#else /* __KERNEL__ */
38#include <stdint.h>
39#endif /* __KERNEL__ */
40
41/**
42 * Zero-based enum of Frequency Manager Macro ID's.
43 * Identifies a Frequency Manager Macro in the IuiFm API's.
44 *
45 * @IUI_FM_MACRO_ID_INVALID: Invalid Macro ID
46 * @IUI_FM_MACRO_ID_EMMC: SD/eMMC Macro
47 * @IUI_FM_MACRO_ID_CLASS_D: Class D Amplifier Macro
48 * @IUI_FM_MACRO_ID_PMU_CP: PMU Charge Pump Macro
49 * @IUI_FM_MACRO_ID_MS_CP: MS Charge Pump Macro
50 * @IUI_FM_MACRO_ID_DCDC: DC to DC Converter Macro
51 * @IUI_FM_MACRO_ID_RESERVED: not in use
52 * @IUI_FM_MACRO_ID_WLAN: Wireless LAN Macro
53 * @IUI_FM_MACRO_ID_FMR: FM Radio Macro
54 * @IUI_FM_MACRO_ID_BT: Bluetooth Macro
55 * @IUI_FM_MACRO_ID_GNSS: Global Navigation Satellite System
56 * (GPS/GLONASS) Macro
57 * @IUI_FM_MACRO_ID_MAX: Number of Macro's defined, used
58 * internally for range checking
59 * @IUI_FM_MACRO_ID_FIRST: Point to the first macro ID, used internally
60 * for iteration and range checking
61 */
62enum iui_fm_macro_id {
63 IUI_FM_MACRO_ID_INVALID = -1,
64 IUI_FM_MACRO_ID_EMMC = 0,
65 IUI_FM_MACRO_ID_CLASS_D = 1,
66 IUI_FM_MACRO_ID_PMU_CP = 2,
67 IUI_FM_MACRO_ID_MS_CP = 3,
68 IUI_FM_MACRO_ID_DCDC = 4,
69 IUI_FM_MACRO_ID_RESERVED = 5,
70 IUI_FM_MACRO_ID_WLAN = 6,
71 IUI_FM_MACRO_ID_FMR = 7,
72 IUI_FM_MACRO_ID_BT = 8,
73 IUI_FM_MACRO_ID_GNSS = 9,
74 IUI_FM_MACRO_ID_MAX = 10,
75 IUI_FM_MACRO_ID_FIRST = IUI_FM_MACRO_ID_EMMC
76};
77
78/**
79 * Enum used to indicate the priority of a mitigation request.
80 *
81 * @IUI_FM_MITIGATION_PRIORITY_NORMAL: The priority value of a mitigation
82 * request when not in an emergency call
83 * or situation.
84 * @IUI_FM_MITIGATION_PRIORITY_EMERGENCY: Can be used during an emergency call
85 * to indicate that the mitigation
86 * request should be applied with more
87 * haste than usual, even if this causes
88 * a degredation in currently-running
89 * processes.
90 */
91enum iui_fm_mitigation_priority {
92 IUI_FM_MITIGATION_PRIORITY_NORMAL = 0,
93 IUI_FM_MITIGATION_PRIORITY_EMERGENCY = 1
94};
95
96/**
97 * Enum used to identify an SD/eMMC device.
98 *
99 * @IUI_FM_EMMC_DEVICE_ID_0: SD/eMMC Device 0
100 * @IUI_FM_EMMC_DEVICE_ID_1: SD/eMMC Device 1
101 * @IUI_FM_EMMC_DEVICE_ID_2: SD/eMMC Device 2
102 * @IUI_FM_EMMC_DEVICE_ID_MAX: Number of SD/eMMC Devices Defined, used
103 * internally for range checking and array sizing
104 */
105enum iui_fm_emmc_device_id {
106 IUI_FM_EMMC_DEVICE_ID_0 = 0,
107 IUI_FM_EMMC_DEVICE_ID_1 = 1,
108 IUI_FM_EMMC_DEVICE_ID_2 = 2,
109 IUI_FM_EMMC_DEVICE_ID_MAX = 3
110};
111
112/**
113 * Enum used to indicate from which main clock the operating frequency
114 * of an SD/eMMC device is derived.
115 *
116 * Possible SD/eMMC operating frequencies are derived by dividing the selected
117 * main clock frequency by powers of 2. The largest possible divisor is that
118 * which results in the lowest operating frequency greater than 200 KHz. Hence
119 * the possible operating frequencies are:
120 *
121 * Clock Source: 104 MHz:
122 * 2^0: 104 MHz
123 * 2^1: 52 MHz
124 * 2^2: 26 MHz
125 * 2^3: 13 MHz
126 * 2^4: 6.5 MHz
127 * 2^5: 3.25 MHz
128 * 2^6: 1.625 MHz
129 * 2^7: 812.5 KHz
130 * 2^8: 406.25 KHz
131 * 2^9: 203.125 KHz
132 *
133 * Clock Source: 96 MHz:
134 * 2^0: 96 MHz
135 * 2^1: 48 MHz
136 * 2^2: 24 MHz
137 * 2^3: 12 MHz
138 * 2^4: 6 MHz
139 * 2^5: 3 MHz
140 * 2^6: 1.5 MHz
141 * 2^7: 750 KHz
142 * 2^8: 375 KHz
143 *
144 * @IUI_FM_EMMC_CLOCK_SRC_104MHZ 104 MHz main clock source for SD/eMMC.
145 * @IUI_FM_EMMC_CLOCK_SRC_96MHZ 96 MHz main clock source for SD/eMMC.
146 */
147enum iui_fm_emmc_clock_src {
148 IUI_FM_EMMC_CLOCK_SRC_104MHZ = 0,
149 IUI_FM_EMMC_CLOCK_SRC_96MHZ = 1
150};
151
152/**
153 * @brief Bitfield structure of 32-bit width to store the operating frequency
154 * information for one SD/eMMC device.
155 *
156 * @frequency SD/eMMC Operating Frequency in KHz.
157 * @clk_src SD/eMMC Clock Source. Values in enum iui_fm_emmc_clock_src.
158 */
159struct iui_fm_emmc_freq_bitfield {
160 uint32_t frequency:28;
161 uint32_t clk_src:4;
162};
163
164/**
165 * @brief Contains operating frequency information for all of the SD/eMMC
166 * devices.
167 *
168 * @emmc_frequency Array of frequency information for each EMMC device.
169 */
170struct iui_fm_emmc_freq_info {
171 struct iui_fm_emmc_freq_bitfield
172 emmc_frequency[IUI_FM_EMMC_DEVICE_ID_MAX];
173};
174
175/**
176 * @brief Enum representing the possible channel bandwidths used by the WLAN
177 * macro.
178 *
179 * @IUI_FM_WLAN_BW_INVALID Used if WLAN channel is in disconnected state.
180 * @IUI_FM_WLAN_BW_20MHZ 20 MHz bandwidth.
181 * @IUI_FM_WLAN_BW_40MHZ 40 MHz bandwidth (NOT SUPPORTED).
182 * @IUI_FM_WLAN_BW_80MHZ 80 MHz bandwidth (NOT SUPPORTED).
183 */
184enum iui_fm_wlan_bandwidth {
185 IUI_FM_WLAN_BW_INVALID = -1,
186 IUI_FM_WLAN_BW_20MHZ = 0,
187 IUI_FM_WLAN_BW_40MHZ = 1,
188 IUI_FM_WLAN_BW_80MHZ = 2,
189 IUI_FM_WLAN_BW_160MHZ = 3
190};
191
192/**
193 * Structure used to store the frequency and bandwidth of a WLAN channel.
194 *
195 * @frequency Current WLAN channel center frequency in KHz if in
196 * transfer/receive mode, or an invalid value otherwise.
197 * Available values: 2412000-2484000, 3657500-3690000,
198 * 4915000-5825000 (KHz).
199 * @bandwadth Channel bandwidth enum. Set to IUI_FM_WLAN_BW_INVALID if WLAN
200 * channel is disconnected.
201 */
202struct iui_fm_wlan_channel_info {
203 uint32_t frequency;
204 enum iui_fm_wlan_bandwidth bandwidth;
205};
206
207/**
208 * Maximum number of channels that can be used by the WLAN macro at a time.
209 */
210#define IUI_FM_WLAN_MAX_CHANNELS 4
211#define DCDC_UPDATE 1
212#define WLAN_UPDATE 2
213#define DCDC_MITI DCDC_UPDATE
214#define WLAN_MITI WLAN_UPDATE
215
216/**
217 * @brief Structure used for Frequency Notification by the WLAN macro.
218 *
219 * @num_channels Number of valid elements in the channel_info array, set to
220 * the number of channels currently in use by the WLAN macro, or
221 * 0 if WLAN is not in transfer/receive mode.
222 * @channel_info Array of WLAN channel information structures. Only the first
223 * num_channels elements are valid.
224 * @wlan_adc_dac_freq Current WLAN ADC/DAC frequency in KHz. Available
225 * values: 0 (parameter not yet supported).
226 */
227struct iui_fm_wlan_info {
228 uint32_t num_channels;
229 struct iui_fm_wlan_channel_info channel_info[IUI_FM_WLAN_MAX_CHANNELS];
230 uint32_t wlan_adc_dac_freq;
231 uint32_t dcdc_div0;
232 uint32_t dcdc_div1;
233 uint32_t bitmask;
234};
235
236/**
237 * Special value for the max_tx_pwr field of struct
238 * iui_fm_wlan_channel_tx_power to clear a previously-set TX power limit.
239 */
240#define IUI_FM_WLAN_NO_TX_PWR_LIMIT INT32_MAX
241
242/**
243 * @brief Structure to store the maximum allowed transmit power for one WLAN
244 * channel.
245 *
246 * @frequency WLAN Channel Frequency in KHz.
247 * @max_tx_pwr Maximum allowed transmit power for the given channel frequency
248 * in dBm within the range 0 to +30, or
249 * IUI_FM_WLAN_NO_TX_PWR_LIMIT to cancel a previously-set transmit
250 * power limit.
251 */
252struct iui_fm_wlan_channel_tx_power {
253 uint32_t frequency;
254 int32_t max_tx_pwr;
255};
256
257/**
258 * @brief Enum defining mitigation actions for WLAN macro to implement for the
259 * WLAN RX Gain Stage behavior.
260 *
261 * @IUI_FM_WLAN_RX_GAIN_NORMAL RX Gain Stage should behave as
262 * normal with no reduction in gain.
263 * @IUI_FM_WLAN_RX_GAIN_REDUCE_AUTO RX Gain should be reduced by an
264 * unspecified amount. The WLAN macro
265 * is to determine the appropriate gain
266 * reduction amount internally.
267 * @IUI_FM_WLAN_RX_GAIN_REDUCE_SPECIFIED RX Gain should be reduced by the
268 * specified amount (NOT SUPPORTED).
269 */
270enum iui_fm_wlan_rx_gain_behavior {
271 IUI_FM_WLAN_RX_GAIN_NORMAL = 0,
272 IUI_FM_WLAN_RX_GAIN_REDUCE_AUTO = 1
273/* IUI_FM_WLAN_RX_GAIN_REDUCE_SPECIFIED = 2 */
274};
275
276/**
277 * @brief Mitigation information structure for the WLAN macro.
278 *
279 * @num_channels Number of valid elements in the channel_tx_pwr array,
280 * set to the number of channels for which the maximum
281 * allowed transmit power is being set.
282 * @channel_tx_pwr Array of maximum allowed transmit power for zero or more
283 * WLAN channels. Only the first num_channels elements are
284 * valid.
285 * @wlan_adc_dac_freq Requested WLAN ADC/DAC frequency in KHz. Available
286 * values: 0 (parameter not yet supported).
287 * @rx_gain_behavior Indicates the requested behavior of the WLAN RX Gain
288 * Stage (NOT SUPPORTED).
289 * @rx_gain_reduction Amount by which to reduce the WLAN RX Gain (in dB) if
290 * the rx_gain_bahavior field is set to
291 * IUI_FM_WLAN_RX_GAIN_REDUCE_SPECIFIED (NOT SUPPORTED).
292 */
293struct iui_fm_wlan_mitigation {
294 uint32_t num_channels;
295 struct iui_fm_wlan_channel_tx_power
296 channel_tx_pwr[IUI_FM_WLAN_MAX_CHANNELS];
297 uint32_t wlan_adc_dac_freq;
298 enum iui_fm_wlan_rx_gain_behavior rx_gain_behavior;
299/* uint32_t rx_gain_reduction; */
300 uint32_t wlan_2g_coex_enable;
301 uint32_t dcdc_div0;
302 uint32_t dcdc_div1;
303 uint32_t bitmask;
304};
305
306/**
307 * @brief Enum representing the injection side indicated by the FM Radio
308 * macro.
309 *
310 * @IUI_FM_FMR_INJECTION_SIDE_LOW FM Radio Low Side Injection.
311 * @IUI_FM_FMR_INJECTION_SIDE_HIGH FM Radio High Side Injection.
312 */
313enum iui_fm_fmr_injection_side {
314 IUI_FM_FMR_INJECTION_SIDE_LOW = 0,
315 IUI_FM_FMR_INJECTION_SIDE_HIGH = 1
316};
317
318/**
319 * @brief Structure containing the operating information for the FM Radio
320 * macro.
321 *
322 * @rx_freq Tuned frequency in KHz, or 0 if FM Radio is not in use.
323 * @inj_side Injection Side currently in use.
324 */
325struct iui_fm_fmr_info {
326 uint32_t rx_freq;
327 enum iui_fm_fmr_injection_side inj_side;
328};
329
330/**
331 * @brief Indicates the status of the Bluetooth module.
332 *
333 * @IUI_FM_BT_STATE_OFF Bluetooth module is turned off.
334 * @IUI_FM_BT_STATE_ON Bluetooth module is turned on.
335 */
336enum iui_fm_bt_state {
337 IUI_FM_BT_STATE_OFF = 0, /**< Bluetooth module is turned off. */
338 IUI_FM_BT_STATE_ON = 1 /**< Bluetooth module is turned on. */
339};
340
341/**
342 * @brief Structure containing the operating information for the Bluetooth
343 * macro.
344 *
345 * Passed by the Bluetooth macro to Frequency Manager as a Frequency
346 * Notification.
347 *
348 * @bt_state Current state of the Bluetooth macro.
349 */
350struct iui_fm_bt_info {
351 enum iui_fm_bt_state bt_state;
352};
353
354/**
355 * @brief Define the number of Bluetooth hopping channels available.
356 */
357#define IUI_FM_BT_NUM_CHANNELS 79
358
359/**
360 * @brief Number of bits in one word of the Bluetooth Channel Mask.
361 */
362#define IUI_FM_BT_CHANNEL_MASK_WORD_BITS 32
363
364/**
365 * @brief Number of words needed to contain the full Bluetooth Channel
366 * Bitmask.
367 *
368 * For 79 hopping channels, 3 32-bit words are needed.
369 */
370#define IUI_FM_BT_CHANNEL_MASK_WORDS 3
371
372/**
373 * @brief Bitfield structure representing a hopping channel mask for the
374 * Bluetooth Macro.
375 *
376 * A set bit indicates a Bluetooth hopping frequency that should be avoided in
377 * order to mitigate crosstalk with another macro.
378 *
379 * @bt_ch_mask Array of words containing the Bluetooth Channel Mask. Each bit
380 * represents one Bluetooth hopping frequency, with the least of
381 * the first word representing the lowest frequency Bluetooth
382 * Hopping Frequency. If the number of hopping frequencies
383 * available is not a multiple of the word width (in bits), then
384 * the remaining unused bits in the last word are ignored. If a
385 * bit is set, the Bluetooth Hopping Frequency corresponding to
386 * that bit should be avoided by the Bluetooth Macro in order to
387 * avoid crosstalk with another macro.
388 */
389struct iui_fm_bt_channel_mask {
390 uint32_t bt_ch_mask[IUI_FM_BT_CHANNEL_MASK_WORDS];
391};
392
393/**
394 * @brief GNSS Macro State enum indicating which (if any) of the GNSS
395 * technologies are being used.
396 *
397 * @IUI_FM_GNSS_STATE_OFF GNSS macro is switched off.
398 * @IUI_FM_GNSS_STATE_GPS_ACTIVE GNSS macro is on and in GPS mode.
399 * @IUI_FM_GNSS_STATE_GLONASS_ACTIVE GNSS macro is on and in GLONASS
400 * mode.
401 * @IUI_FM_GNSS_STATE_GPS_GLONASS_ACTIVE GNSS macro is on and in GPS+GLONASS
402 * mode.
403 */
404enum iui_fm_gnss_state {
405 IUI_FM_GNSS_STATE_OFF = 0,
406 IUI_FM_GNSS_STATE_GPS_ACTIVE = 1,
407 IUI_FM_GNSS_STATE_GLONASS_ACTIVE = 2,
408 IUI_FM_GNSS_STATE_GPS_GLONASS_ACTIVE = 3
409};
410
411/**
412 * @brief GNSS Frequency Information structure passed from GNSS macro to the FM
413 * module during a Frequency Indication.
414 *
415 * @state State of the GNSS module.
416 * @snr Current RX signal to noise ratio for the active GNSS
417 * technology (GPS or GLONASS), or the stronger of the two if
418 * both GPS and GLONASS are active. Valid range: 0..55 dB, or
419 * -1 if not available.
420 * @bus_frequency Bus Frequency used by the GNSS module in KHz, or 0 if GNSS
421 * is inactive/off. Available frequencies:
422 * 78000 KHz (currently not supported)
423 * 83200 KHz
424 * 96000 KHz
425 * @pll_frequency Current operating frequency of the GNSS PLL in KHz, or 0
426 * if the GNSS PLL is disabled. Available frequencies:
427 * 124800 KHz
428 * 104000 KHz
429 * 96000 KHz
430 * 89000 KHz(currently not supported)
431 * @adc_frequency Current operating frequency of the GNSS ADC output clock
432 * in KHz, or 0 if the GNSS ADC is disabled. Available
433 * frequencies:
434 * 44131 KHz
435 * 52957 KHz
436 * 66196 KHz
437 */
438struct iui_fm_gnss_info {
439 enum iui_fm_gnss_state state;
440 int32_t snr;
441 uint32_t bus_frequency;
442 uint32_t pll_frequency;
443 uint32_t adc_frequency;
444};
445
446/**
447 * @brief Mitigation information structure for the GNSS macro.
448 *
449 * @priority Indicates whether the ongoing processing of a previous
450 * mitigation request should be interrupted to fulfil this new
451 * request. Based on whether the phone is currently in an
452 * emergency call or other situation.
453 * @bus_frequency Requested GNSS bus clock frequency in KHz, or 0 if the
454 * GNSS bus is disabled. Available frequencies:
455 * 78000 KHz (currently not supported)
456 * 83200 KHz
457 * 96000 KHz
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches