diff options
author | Matti Gottlieb <matti.gottlieb@intel.com> | 2013-07-09 08:25:46 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-07-31 05:04:59 -0400 |
commit | 88f2fd7300da1b671255ef26469627206fe20a8e (patch) | |
tree | 2055e7df43ee07e0cb13e85e7e83aed19d628ccd | |
parent | ac1ed4163b5a523728fa0e8c27c1ff4d182f40fd (diff) |
iwlwifi: mvm: Enable user set TX power
Support Tx power limitations. These limitations can come from
mac80211 for various reasons.
Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-nvm-parse.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/fw-api.h | 14 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mac80211.c | 19 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/ops.c | 1 |
4 files changed, 40 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c index acd2665afb8c..b76a9a8fc0b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c +++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c | |||
@@ -118,6 +118,7 @@ static const u8 iwl_nvm_channels[] = { | |||
118 | #define LAST_2GHZ_HT_PLUS 9 | 118 | #define LAST_2GHZ_HT_PLUS 9 |
119 | #define LAST_5GHZ_HT 161 | 119 | #define LAST_5GHZ_HT 161 |
120 | 120 | ||
121 | #define DEFAULT_MAX_TX_POWER 16 | ||
121 | 122 | ||
122 | /* rate data (static) */ | 123 | /* rate data (static) */ |
123 | static struct ieee80211_rate iwl_cfg80211_rates[] = { | 124 | static struct ieee80211_rate iwl_cfg80211_rates[] = { |
@@ -232,8 +233,11 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, | |||
232 | 233 | ||
233 | /* Initialize regulatory-based run-time data */ | 234 | /* Initialize regulatory-based run-time data */ |
234 | 235 | ||
235 | /* TODO: read the real value from the NVM */ | 236 | /* |
236 | channel->max_power = 0; | 237 | * Default value - highest tx power value. max_power |
238 | * is not used in mvm, and is used for backwards compatibility | ||
239 | */ | ||
240 | channel->max_power = DEFAULT_MAX_TX_POWER; | ||
237 | is_5ghz = channel->band == IEEE80211_BAND_5GHZ; | 241 | is_5ghz = channel->band == IEEE80211_BAND_5GHZ; |
238 | IWL_DEBUG_EEPROM(dev, | 242 | IWL_DEBUG_EEPROM(dev, |
239 | "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", | 243 | "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h index 28cab821c9f4..55854a309f94 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h +++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h | |||
@@ -159,6 +159,7 @@ enum { | |||
159 | TX_ANT_CONFIGURATION_CMD = 0x98, | 159 | TX_ANT_CONFIGURATION_CMD = 0x98, |
160 | BT_CONFIG = 0x9b, | 160 | BT_CONFIG = 0x9b, |
161 | STATISTICS_NOTIFICATION = 0x9d, | 161 | STATISTICS_NOTIFICATION = 0x9d, |
162 | REDUCE_TX_POWER_CMD = 0x9f, | ||
162 | 163 | ||
163 | /* RF-KILL commands and notifications */ | 164 | /* RF-KILL commands and notifications */ |
164 | CARD_STATE_CMD = 0xa0, | 165 | CARD_STATE_CMD = 0xa0, |
@@ -226,6 +227,19 @@ struct iwl_tx_ant_cfg_cmd { | |||
226 | __le32 valid; | 227 | __le32 valid; |
227 | } __packed; | 228 | } __packed; |
228 | 229 | ||
230 | /** | ||
231 | * struct iwl_reduce_tx_power_cmd - TX power reduction command | ||
232 | * REDUCE_TX_POWER_CMD = 0x9f | ||
233 | * @flags: (reserved for future implementation) | ||
234 | * @mac_context_id: id of the mac ctx for which we are reducing TX power. | ||
235 | * @pwr_restriction: TX power restriction in dBms. | ||
236 | */ | ||
237 | struct iwl_reduce_tx_power_cmd { | ||
238 | u8 flags; | ||
239 | u8 mac_context_id; | ||
240 | __le16 pwr_restriction; | ||
241 | } __packed; /* TX_REDUCED_POWER_API_S_VER_1 */ | ||
242 | |||
229 | /* | 243 | /* |
230 | * Calibration control struct. | 244 | * Calibration control struct. |
231 | * Sent as part of the phy configuration command. | 245 | * Sent as part of the phy configuration command. |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index 30319e069f45..fbb8c2dc66e0 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
@@ -714,6 +714,20 @@ out_release: | |||
714 | mutex_unlock(&mvm->mutex); | 714 | mutex_unlock(&mvm->mutex); |
715 | } | 715 | } |
716 | 716 | ||
717 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | ||
718 | s8 tx_power) | ||
719 | { | ||
720 | /* FW is in charge of regulatory enforcement */ | ||
721 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { | ||
722 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, | ||
723 | .pwr_restriction = cpu_to_le16(tx_power), | ||
724 | }; | ||
725 | |||
726 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, | ||
727 | sizeof(reduce_txpwr_cmd), | ||
728 | &reduce_txpwr_cmd); | ||
729 | } | ||
730 | |||
717 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) | 731 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
718 | { | 732 | { |
719 | return 0; | 733 | return 0; |
@@ -794,6 +808,11 @@ static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, | |||
794 | if (ret) | 808 | if (ret) |
795 | IWL_ERR(mvm, "failed to update power mode\n"); | 809 | IWL_ERR(mvm, "failed to update power mode\n"); |
796 | } | 810 | } |
811 | if (changes & BSS_CHANGED_TXPOWER) { | ||
812 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | ||
813 | bss_conf->txpower); | ||
814 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | ||
815 | } | ||
797 | } | 816 | } |
798 | 817 | ||
799 | static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | 818 | static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c index 5d5dedddd2dc..70ac726c0265 100644 --- a/drivers/net/wireless/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c | |||
@@ -275,6 +275,7 @@ static const char *iwl_mvm_cmd_strings[REPLY_MAX] = { | |||
275 | CMD(BEACON_NOTIFICATION), | 275 | CMD(BEACON_NOTIFICATION), |
276 | CMD(BEACON_TEMPLATE_CMD), | 276 | CMD(BEACON_TEMPLATE_CMD), |
277 | CMD(STATISTICS_NOTIFICATION), | 277 | CMD(STATISTICS_NOTIFICATION), |
278 | CMD(REDUCE_TX_POWER_CMD), | ||
278 | CMD(TX_ANT_CONFIGURATION_CMD), | 279 | CMD(TX_ANT_CONFIGURATION_CMD), |
279 | CMD(D3_CONFIG_CMD), | 280 | CMD(D3_CONFIG_CMD), |
280 | CMD(PROT_OFFLOAD_CONFIG_CMD), | 281 | CMD(PROT_OFFLOAD_CONFIG_CMD), |