mbox series

[RFC,v2,0/6] mac80211: add TPC support in control path

Message ID 20220920104032.496697-1-jelonek.jonas@gmail.com
Headers show
Series mac80211: add TPC support in control path | expand

Message

Jonas Jelonek Sept. 20, 2022, 10:40 a.m. UTC
Transmit power control (TPC) per packet hence per station can be used to
manage interference and increase overall spatial reuse and therefore
increases sum throughput in WiFi networks with multiple APs and STAs.
Although several of today's wifi chips, e.g., from QCA and from Mediatek
support fine-grained TPC per packet, the Linux mac80211 layer does not
provide support for this annotation nor control yet.

This series proposes several changes to introduce TPC support in
mac80211, in particular to annotate tx-power per packet/per mrr stage in
the tx control path.
The patches include new members in the tx control path structs, a
modified tx-power level support annotation, hardware flags, hwsim
support, debugfs support in minstrel_ht for fixed TPC and an utility
function for the convenient use of struct ieee80211_rate_status
(introduced by 44fa75f207d8a106bc75e6230db61e961fdbf8a8) for tx-power
status report in drivers.
An proof-of-concept ath9k support was implemented for testing these
changes on real ath9k hardware, this implementation is planned to be
brought upstream later.

Compile-Tested: current wireless-next tree with all flags on
Tested-on: PCEngines APU with ath9k WiFi device on OpenWrt Linux
	Kernel 5.15.68, AP<->STA setup with both ath9k and hwsim
	(used current OpenWrt testing kernel)

---
v2:
- added exemplary hwsim support
- added debugfs in minstrel_ht for fixed TPC
---

Signed-off-by: Thomas Huehn <thomas.huehn@hs-nordhausen.de>
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>

Jonas Jelonek (6):
  mac80211: modify tx-power level annotation
  mac80211: add tx-power annotation in control path
  mac80211: add hardware flags for TPC support
  mac80211: add utility function for tx_rate - rate_info conversion
  mac80211_hwsim: add TPC per packet support
  mac80211: minstrel_ht - add debugfs entry per sta for fixed tx-power

 drivers/net/wireless/mac80211_hwsim.c      | 175 ++++++++++++++++++++-
 drivers/net/wireless/mac80211_hwsim.h      |   1 +
 include/net/mac80211.h                     |  66 ++++++--
 net/mac80211/debugfs.c                     |   2 +
 net/mac80211/rc80211_minstrel_ht.c         |  14 ++
 net/mac80211/rc80211_minstrel_ht.h         |  11 ++
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  11 ++
 net/mac80211/util.c                        |  35 +++++
 8 files changed, 296 insertions(+), 19 deletions(-)

Comments

Johannes Berg Jan. 12, 2023, 10:24 a.m. UTC | #1
On Tue, 2022-09-20 at 12:40 +0200, Jonas Jelonek wrote:
>  
> +/**
> + * struct ieee80211_hw_txpower_range - Power range for transmit power
> + *
> + * This struct can be used by drivers to define multiple tx-power ranges with
> + * different scales according to the hardware capabilities. A tx-power range
> + * describe either absolute power levels or power offsets relative to a base
> + * power.
> + *
> + * @start_idx The starting idx of the range. @start_idx is always the lowest
> + * 	idx of the power range.
> + * @start_pwr The power level at idx @start_idx in 0.25 dBm units.
> + * @n_levels How many power levels this range has.
> + * @pwr_step The power step width in 0.25 dBm units.

Need colons for valid kernel-doc, I believe.

johannes
Johannes Berg Jan. 12, 2023, 10:32 a.m. UTC | #2
On Tue, 2022-09-20 at 12:40 +0200, Jonas Jelonek wrote:
> Create a new debugfs entry called 'rc_fixed_txpower_idx' in debugfs dir
> for each station. By writing a positive static tx-power idx into this
> file, minstrel_ht applies this tx-power idx to each packet or each mrr
> stage, depending on what the hardware supports. By writing (u32)-1 to
> the file, minstrel will return to automatic mode which currently just
> passes -1 as tx-power idx, indicating that the driver should use a
> default.
> The debugfs entry will only be created if either tpc per packet or per
> mrr is supported.
> 
> Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
> ---
>  net/mac80211/rc80211_minstrel_ht.c         | 14 ++++++++++++++
>  net/mac80211/rc80211_minstrel_ht.h         | 11 +++++++++++
>  net/mac80211/rc80211_minstrel_ht_debugfs.c | 11 +++++++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
> index 24c3c055db6d..222b51e7d9ee 100644
> --- a/net/mac80211/rc80211_minstrel_ht.c
> +++ b/net/mac80211/rc80211_minstrel_ht.c
> @@ -1486,6 +1486,14 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
>  
>  	ratetbl->rate[offset].idx = idx;
>  	ratetbl->rate[offset].flags = flags;
> +
> +#ifdef CONFIG_MAC80211_DEBUGFS
> +	if (mi->fixed_txpower_idx != -1) {
> +		ratetbl->rate[offset].txpower_idx = mi->fixed_txpower_idx;
> +		return;
> +	}
> +#endif
> +	ratetbl->rate[offset].txpower_idx = -1;
>  }
>  
>  static inline int
> @@ -1603,8 +1611,14 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
>  	info->flags |= mi->tx_flags;
>  
>  #ifdef CONFIG_MAC80211_DEBUGFS
> +	if (mi->fixed_txpower_idx != -1)
> +		info->control.txpower_idx = mi->fixed_txpower_idx;
> +
>  	if (mp->fixed_rate_idx != -1)
>  		return;
> +#else
> +	/* Pass -1 to indicate 'ignore txpower' or 'use default' */
> +	info->control.txpower_idx = -1;
>  #endif
>  
>  	/* Don't use EAPOL frames for sampling on non-mrr hw */
> diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h
> index 1766ff0c78d3..15222d66c4b8 100644
> --- a/net/mac80211/rc80211_minstrel_ht.h
> +++ b/net/mac80211/rc80211_minstrel_ht.h
> @@ -194,6 +194,17 @@ struct minstrel_ht_sta {
>  
>  	/* MCS rate group info and statistics */
>  	struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
> +
> +#ifdef CONFIG_MAC80211_DEBUGFS
> +	/*
> +	 * enable fixed tx-power processing per STA
> +	 *   - write static index to debugfs:ieee80211/phyX/netdev:wlanY
> +	 *   		/stations/<MAC>/rc_fixed_txpower_idx
> +	 *   - write -1 to enable automatic processing again
> +	 *   - setting will be applied on next update
> +	 */
> +	u32 fixed_txpower_idx;

Use s32? You don't need that large range anyway.

> +
> +	if (ieee80211_hw_check(mp->hw, SUPPORTS_TPC_PER_PACKET) ||
> +	    ieee80211_hw_check(mp->hw, SUPPORTS_TPC_PER_MRR))
> +	{

bad indentation

> +		mi->fixed_txpower_idx = (u32)-1;
> +		debugfs_create_u32("rc_fixed_txpower_idx", S_IRUGO | S_IWUGO,
> +				   dir, &mi->fixed_txpower_idx);
> 

Seems like that should be a function with some range check?

johannes