aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/cfg80211.h27
-rw-r--r--net/mac80211/iface.c2
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/mac80211/mlme.c3
4 files changed, 31 insertions, 3 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 88f15631701a..aeaf6dff6e05 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -461,6 +461,33 @@ ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
461} 461}
462 462
463/** 463/**
464 * ieee80211_chandef_max_power - maximum transmission power for the chandef
465 *
466 * In some regulations, the transmit power may depend on the configured channel
467 * bandwidth which may be defined as dBm/MHz. This function returns the actual
468 * max_power for non-standard (20 MHz) channels.
469 *
470 * @chandef: channel definition for the channel
471 *
472 * Returns: maximum allowed transmission power in dBm for the chandef
473 */
474static inline int
475ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
476{
477 switch (chandef->width) {
478 case NL80211_CHAN_WIDTH_5:
479 return min(chandef->chan->max_reg_power - 6,
480 chandef->chan->max_power);
481 case NL80211_CHAN_WIDTH_10:
482 return min(chandef->chan->max_reg_power - 3,
483 chandef->chan->max_power);
484 default:
485 break;
486 }
487 return chandef->chan->max_power;
488}
489
490/**
464 * enum survey_info_flags - survey information flags 491 * enum survey_info_flags - survey information flags
465 * 492 *
466 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in 493 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index cc117591f678..4c41c11958c8 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -54,7 +54,7 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
54 return false; 54 return false;
55 } 55 }
56 56
57 power = chanctx_conf->def.chan->max_power; 57 power = ieee80211_chandef_max_power(&chanctx_conf->def);
58 rcu_read_unlock(); 58 rcu_read_unlock();
59 59
60 if (sdata->user_power_level != IEEE80211_UNSET_POWER_LEVEL) 60 if (sdata->user_power_level != IEEE80211_UNSET_POWER_LEVEL)
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 091088ac7890..6da98c77496b 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -151,7 +151,7 @@ static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local)
151 changed |= IEEE80211_CONF_CHANGE_SMPS; 151 changed |= IEEE80211_CONF_CHANGE_SMPS;
152 } 152 }
153 153
154 power = chandef.chan->max_power; 154 power = ieee80211_chandef_max_power(&chandef);
155 155
156 rcu_read_lock(); 156 rcu_read_lock();
157 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 157 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index f7552c2b74eb..211246b46819 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -747,7 +747,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
747 *pos++ = WLAN_EID_PWR_CAPABILITY; 747 *pos++ = WLAN_EID_PWR_CAPABILITY;
748 *pos++ = 2; 748 *pos++ = 2;
749 *pos++ = 0; /* min tx power */ 749 *pos++ = 0; /* min tx power */
750 *pos++ = chan->max_power; /* max tx power */ 750 /* max tx power */
751 *pos++ = ieee80211_chandef_max_power(&chanctx_conf->def);
751 752
752 /* 2. supported channels */ 753 /* 2. supported channels */
753 /* TODO: get this in reg domain format */ 754 /* TODO: get this in reg domain format */