aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo.bianconi83@gmail.com>2015-01-14 06:55:08 -0500
committerJohannes Berg <johannes.berg@intel.com>2015-01-23 04:28:51 -0500
commitdb82d8a966ded064bd4cf0e1fcca13442f50d0ae (patch)
tree1f88497368334a23af9afe6f2beb9def150238d9
parent4b681c82d2f9bef121c912ffcaac89a004af3f2c (diff)
mac80211: enable TPC through mac80211 stack
Control per packet Transmit Power Control (TPC) in lower drivers according to TX power settings configured by the user. In particular TPC is enabled if value passed in enum nl80211_tx_power_setting is NL80211_TX_POWER_LIMITED (allow using less than specified from userspace), whereas TPC is disabled if nl80211_tx_power_setting is set to NL80211_TX_POWER_FIXED (use value configured from userspace) Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/mac80211.h7
-rw-r--r--net/mac80211/cfg.c19
-rw-r--r--net/mac80211/chan.c4
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/iface.c5
5 files changed, 30 insertions, 8 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 33b87c50a4cf..866073e27ea2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -376,6 +376,12 @@ enum ieee80211_rssi_event {
376 * @ssid_len: Length of SSID given in @ssid. 376 * @ssid_len: Length of SSID given in @ssid.
377 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. 377 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
378 * @txpower: TX power in dBm 378 * @txpower: TX power in dBm
379 * @txpower_type: TX power adjustment used to control per packet Transmit
380 * Power Control (TPC) in lower driver for the current vif. In particular
381 * TPC is enabled if value passed in %txpower_type is
382 * NL80211_TX_POWER_LIMITED (allow using less than specified from
383 * userspace), whereas TPC is disabled if %txpower_type is set to
384 * NL80211_TX_POWER_FIXED (use value configured from userspace)
379 * @p2p_noa_attr: P2P NoA attribute for P2P powersave 385 * @p2p_noa_attr: P2P NoA attribute for P2P powersave
380 */ 386 */
381struct ieee80211_bss_conf { 387struct ieee80211_bss_conf {
@@ -411,6 +417,7 @@ struct ieee80211_bss_conf {
411 size_t ssid_len; 417 size_t ssid_len;
412 bool hidden_ssid; 418 bool hidden_ssid;
413 int txpower; 419 int txpower;
420 enum nl80211_tx_power_setting txpower_type;
414 struct ieee80211_p2p_noa_attr p2p_noa_attr; 421 struct ieee80211_p2p_noa_attr p2p_noa_attr;
415}; 422};
416 423
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ff090ef1ea2c..a777114d663b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2110,6 +2110,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
2110{ 2110{
2111 struct ieee80211_local *local = wiphy_priv(wiphy); 2111 struct ieee80211_local *local = wiphy_priv(wiphy);
2112 struct ieee80211_sub_if_data *sdata; 2112 struct ieee80211_sub_if_data *sdata;
2113 enum nl80211_tx_power_setting txp_type = type;
2114 bool update_txp_type = false;
2113 2115
2114 if (wdev) { 2116 if (wdev) {
2115 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2117 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
@@ -2117,6 +2119,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
2117 switch (type) { 2119 switch (type) {
2118 case NL80211_TX_POWER_AUTOMATIC: 2120 case NL80211_TX_POWER_AUTOMATIC:
2119 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL; 2121 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2122 txp_type = NL80211_TX_POWER_LIMITED;
2120 break; 2123 break;
2121 case NL80211_TX_POWER_LIMITED: 2124 case NL80211_TX_POWER_LIMITED:
2122 case NL80211_TX_POWER_FIXED: 2125 case NL80211_TX_POWER_FIXED:
@@ -2126,7 +2129,12 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
2126 break; 2129 break;
2127 } 2130 }
2128 2131
2129 ieee80211_recalc_txpower(sdata); 2132 if (txp_type != sdata->vif.bss_conf.txpower_type) {
2133 update_txp_type = true;
2134 sdata->vif.bss_conf.txpower_type = txp_type;
2135 }
2136
2137 ieee80211_recalc_txpower(sdata, update_txp_type);
2130 2138
2131 return 0; 2139 return 0;
2132 } 2140 }
@@ -2134,6 +2142,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
2134 switch (type) { 2142 switch (type) {
2135 case NL80211_TX_POWER_AUTOMATIC: 2143 case NL80211_TX_POWER_AUTOMATIC:
2136 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; 2144 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2145 txp_type = NL80211_TX_POWER_LIMITED;
2137 break; 2146 break;
2138 case NL80211_TX_POWER_LIMITED: 2147 case NL80211_TX_POWER_LIMITED:
2139 case NL80211_TX_POWER_FIXED: 2148 case NL80211_TX_POWER_FIXED:
@@ -2144,10 +2153,14 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
2144 } 2153 }
2145 2154
2146 mutex_lock(&local->iflist_mtx); 2155 mutex_lock(&local->iflist_mtx);
2147 list_for_each_entry(sdata, &local->interfaces, list) 2156 list_for_each_entry(sdata, &local->interfaces, list) {
2148 sdata->user_power_level = local->user_power_level; 2157 sdata->user_power_level = local->user_power_level;
2158 if (txp_type != sdata->vif.bss_conf.txpower_type)
2159 update_txp_type = true;
2160 sdata->vif.bss_conf.txpower_type = txp_type;
2161 }
2149 list_for_each_entry(sdata, &local->interfaces, list) 2162 list_for_each_entry(sdata, &local->interfaces, list)
2150 ieee80211_recalc_txpower(sdata); 2163 ieee80211_recalc_txpower(sdata, update_txp_type);
2151 mutex_unlock(&local->iflist_mtx); 2164 mutex_unlock(&local->iflist_mtx);
2152 2165
2153 return 0; 2166 return 0;
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 35b11e11e0c4..ff0d2db09df9 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -655,7 +655,7 @@ out:
655 } 655 }
656 656
657 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) { 657 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) {
658 ieee80211_recalc_txpower(sdata); 658 ieee80211_recalc_txpower(sdata, false);
659 ieee80211_recalc_chanctx_min_def(local, new_ctx); 659 ieee80211_recalc_chanctx_min_def(local, new_ctx);
660 } 660 }
661 661
@@ -1387,7 +1387,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
1387 ieee80211_bss_info_change_notify(sdata, 1387 ieee80211_bss_info_change_notify(sdata,
1388 changed); 1388 changed);
1389 1389
1390 ieee80211_recalc_txpower(sdata); 1390 ieee80211_recalc_txpower(sdata, false);
1391 } 1391 }
1392 1392
1393 ieee80211_recalc_chanctx_chantype(local, ctx); 1393 ieee80211_recalc_chanctx_chantype(local, ctx);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 156ea79e0157..6e1b184183fb 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1621,7 +1621,8 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
1621void ieee80211_del_virtual_monitor(struct ieee80211_local *local); 1621void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1622 1622
1623bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); 1623bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
1624void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); 1624void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
1625 bool update_bss);
1625 1626
1626static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) 1627static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
1627{ 1628{
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 677422e11e07..4371c123a95e 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -73,9 +73,10 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
73 return false; 73 return false;
74} 74}
75 75
76void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata) 76void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
77 bool update_bss)
77{ 78{
78 if (__ieee80211_recalc_txpower(sdata)) 79 if (__ieee80211_recalc_txpower(sdata) || update_bss)
79 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER); 80 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
80} 81}
81 82