linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: enable TPC through mac80211 stack
@ 2014-11-27 13:39 Lorenzo Bianconi
  2014-11-27 14:48 ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2014-11-27 13:39 UTC (permalink / raw)
  To: johannes; +Cc: linville, linux-wireless, nbd, thomas, adrian

Configure per packet Transmit Power Control (TPC) in lower drivers checking
if user_power_level has been set to IEEE80211_UNSET_POWER_LEVEL

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
---
 include/net/mac80211.h | 5 +++++
 net/mac80211/iface.c   | 7 ++++++-
 net/mac80211/main.c    | 8 +++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cff3a26..233626d 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -376,6 +376,7 @@ enum ieee80211_rssi_event {
  * @ssid_len: Length of SSID given in @ssid.
  * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
  * @txpower: TX power in dBm
+ * @tpc_enabled: enable/disable per packet Transmit Power Control (TPC)
  * @p2p_noa_attr: P2P NoA attribute for P2P powersave
  */
 struct ieee80211_bss_conf {
@@ -411,6 +412,7 @@ struct ieee80211_bss_conf {
 	size_t ssid_len;
 	bool hidden_ssid;
 	int txpower;
+	bool tpc_enabled;
 	struct ieee80211_p2p_noa_attr p2p_noa_attr;
 };
 
@@ -1115,6 +1117,8 @@ enum ieee80211_smps_mode {
  *
  * @power_level: requested transmit power (in dBm), backward compatibility
  *	value only that is set to the minimum of all interfaces
+ * @tpc_enabled: enable/disable per packet Transmit Power Control (TPC) in
+ *	lower driver
  *
  * @chandef: the channel definition to tune to
  * @radar_enabled: whether radar detection is enabled
@@ -1135,6 +1139,7 @@ enum ieee80211_smps_mode {
 struct ieee80211_conf {
 	u32 flags;
 	int power_level, dynamic_ps_timeout;
+	bool tpc_enabled;
 	int max_sleep_period;
 
 	u16 listen_interval;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 538fe4e..70c94a3 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -47,6 +47,7 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_chanctx_conf *chanctx_conf;
 	int power;
+	bool tpc_enabled;
 
 	rcu_read_lock();
 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
@@ -64,8 +65,12 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
 	if (sdata->ap_power_level != IEEE80211_UNSET_POWER_LEVEL)
 		power = min(power, sdata->ap_power_level);
 
-	if (power != sdata->vif.bss_conf.txpower) {
+	tpc_enabled = (sdata->user_power_level == IEEE80211_UNSET_POWER_LEVEL);
+
+	if (power != sdata->vif.bss_conf.txpower ||
+	    tpc_enabled != sdata->vif.bss_conf.tpc_enabled) {
 		sdata->vif.bss_conf.txpower = power;
+		sdata->vif.bss_conf.tpc_enabled = tpc_enabled;
 		ieee80211_hw_config(sdata->local, 0);
 		return true;
 	}
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 6ab99da..bfcaeee 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -100,6 +100,7 @@ static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local)
 	u32 changed = 0;
 	int power;
 	u32 offchannel_flag;
+	bool tpc_enabled = false;
 
 	offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
 
@@ -152,12 +153,17 @@ static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local)
 		if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
 			continue;
 		power = min(power, sdata->vif.bss_conf.txpower);
+
+		if (!tpc_enabled && sdata->vif.bss_conf.tpc_enabled)
+			tpc_enabled = true;
 	}
 	rcu_read_unlock();
 
-	if (local->hw.conf.power_level != power) {
+	if (local->hw.conf.power_level != power ||
+	    local->hw.conf.tpc_enabled != tpc_enabled) {
 		changed |= IEEE80211_CONF_CHANGE_POWER;
 		local->hw.conf.power_level = power;
+		local->hw.conf.tpc_enabled = tpc_enabled;
 	}
 
 	return changed;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-27 13:39 [PATCH] mac80211: enable TPC through mac80211 stack Lorenzo Bianconi
@ 2014-11-27 14:48 ` Johannes Berg
  2014-11-27 15:00   ` Lorenzo Bianconi
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-11-27 14:48 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linville, linux-wireless, nbd, thomas, adrian

On Thu, 2014-11-27 at 14:39 +0100, Lorenzo Bianconi wrote:
> Configure per packet Transmit Power Control (TPC) in lower drivers checking
> if user_power_level has been set to IEEE80211_UNSET_POWER_LEVEL

Err, what? Why? how? what does this do?

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-27 14:48 ` Johannes Berg
@ 2014-11-27 15:00   ` Lorenzo Bianconi
  2014-11-28 13:23     ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2014-11-27 15:00 UTC (permalink / raw)
  To: Johannes Berg
  Cc: John Linville, linux-wireless, Felix Fietkau, Thomas Hühn, adrian

> On Thu, 2014-11-27 at 14:39 +0100, Lorenzo Bianconi wrote:
>> Configure per packet Transmit Power Control (TPC) in lower drivers checking
>> if user_power_level has been set to IEEE80211_UNSET_POWER_LEVEL
>
> Err, what? Why? how? what does this do?
>
> johannes
>

I would like to enable TPC in ath9k using iw command:

iw dev wlan0 set txpower auto

I knew user_power_level is set to IEEE80211_UNSET_POWER_LEVEL in that
case. Is there a better way than to check user_power_level?

Regards,
Lorenzo

-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-27 15:00   ` Lorenzo Bianconi
@ 2014-11-28 13:23     ` Johannes Berg
  2014-11-28 15:02       ` Lorenzo Bianconi
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-11-28 13:23 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: John Linville, linux-wireless, Felix Fietkau, Thomas Hühn, adrian


> I would like to enable TPC in ath9k using iw command:
> 
> iw dev wlan0 set txpower auto
> 
> I knew user_power_level is set to IEEE80211_UNSET_POWER_LEVEL in that
> case. Is there a better way than to check user_power_level?

But ... the API already allows for that flexibility? I think if anything
you should expose the "TX power type" that the nl80211 API has.

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-28 13:23     ` Johannes Berg
@ 2014-11-28 15:02       ` Lorenzo Bianconi
  2014-11-28 15:11         ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2014-11-28 15:02 UTC (permalink / raw)
  To: Johannes Berg
  Cc: John Linville, linux-wireless, Felix Fietkau, Thomas Hühn, adrian

>
>> I would like to enable TPC in ath9k using iw command:
>>
>> iw dev wlan0 set txpower auto
>>
>> I knew user_power_level is set to IEEE80211_UNSET_POWER_LEVEL in that
>> case. Is there a better way than to check user_power_level?
>
> But ... the API already allows for that flexibility? I think if anything
> you should expose the "TX power type" that the nl80211 API has.
>

I just need to notify lower driver (ath9k in my case) to setup TPC
registers in order to take into account TX power configured in frame
descriptors. For that purpose I added tpc_enabled flags in
ieee80211_bss_conf and in ieee80211_conf. Is there any other variables
I can use to notify that configuration?

Lorenzo

> johannes
>



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-28 15:02       ` Lorenzo Bianconi
@ 2014-11-28 15:11         ` Johannes Berg
  2014-11-29 14:13           ` Lorenzo Bianconi
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-11-28 15:11 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: John Linville, linux-wireless, Felix Fietkau, Thomas Hühn, adrian

On Fri, 2014-11-28 at 16:02 +0100, Lorenzo Bianconi wrote:

> I just need to notify lower driver (ath9k in my case) to setup TPC
> registers in order to take into account TX power configured in frame
> descriptors. For that purpose I added tpc_enabled flags in
> ieee80211_bss_conf and in ieee80211_conf. Is there any other variables
> I can use to notify that configuration?

Well, arguably, you can just do that unconditionally. If you want to do
it "right" according to the nl80211 API that we introduced due to wext
compatibility (IIRC), you'd have to look at the value passed in enum
nl80211_tx_power_setting. This can take

NL80211_TX_POWER_AUTOMATIC - no limit from userspace
NL80211_TX_POWER_LIMITED - limit, but allow using less than specified
NL80211_TX_POWER_FIXED - use exactly what userspace wanted

I don't think any driver really implements this today, but you could
take this as a hint and only enable TPC (with or without the user's
specified limit) in the first two cases.

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: enable TPC through mac80211 stack
  2014-11-28 15:11         ` Johannes Berg
@ 2014-11-29 14:13           ` Lorenzo Bianconi
  0 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2014-11-29 14:13 UTC (permalink / raw)
  To: Johannes Berg
  Cc: John Linville, linux-wireless, Felix Fietkau, Thomas Hühn, adrian

> On Fri, 2014-11-28 at 16:02 +0100, Lorenzo Bianconi wrote:
>
>> I just need to notify lower driver (ath9k in my case) to setup TPC
>> registers in order to take into account TX power configured in frame
>> descriptors. For that purpose I added tpc_enabled flags in
>> ieee80211_bss_conf and in ieee80211_conf. Is there any other variables
>> I can use to notify that configuration?
>
> Well, arguably, you can just do that unconditionally. If you want to do
> it "right" according to the nl80211 API that we introduced due to wext
> compatibility (IIRC), you'd have to look at the value passed in enum
> nl80211_tx_power_setting. This can take
>
> NL80211_TX_POWER_AUTOMATIC - no limit from userspace
> NL80211_TX_POWER_LIMITED - limit, but allow using less than specified
> NL80211_TX_POWER_FIXED - use exactly what userspace wanted
>
> I don't think any driver really implements this today, but you could
> take this as a hint and only enable TPC (with or without the user's
> specified limit) in the first two cases.

Sounds good to me. I will send a patch v2 where I will enable TPC if
tx_power_setting has been set to NL80211_TX_POWER_AUTOMATIC or
NL80211_TX_POWER_LIMITED. Right now ath9k computes maximum TX power
value per-rate as minimum between user TX power and channel/regulatory
constraints.

Best regards,
Lorenzo

>
> johannes
>



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-29 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-27 13:39 [PATCH] mac80211: enable TPC through mac80211 stack Lorenzo Bianconi
2014-11-27 14:48 ` Johannes Berg
2014-11-27 15:00   ` Lorenzo Bianconi
2014-11-28 13:23     ` Johannes Berg
2014-11-28 15:02       ` Lorenzo Bianconi
2014-11-28 15:11         ` Johannes Berg
2014-11-29 14:13           ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).