All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Jelonek <jelonek.jonas@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, nbd@nbd.name,
	Jonas Jelonek <jelonek.jonas@gmail.com>
Subject: [RFC v2 6/6] mac80211: minstrel_ht - add debugfs entry per sta for fixed tx-power
Date: Tue, 20 Sep 2022 12:40:32 +0200	[thread overview]
Message-ID: <20220920104032.496697-7-jelonek.jonas@gmail.com> (raw)
In-Reply-To: <20220920104032.496697-1-jelonek.jonas@gmail.com>

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;
+#endif
 };
 
 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index 25b8a67a63a4..d625d860d01a 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -329,8 +329,19 @@ static const struct file_operations minstrel_ht_stat_csv_fops = {
 void
 minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
 {
+	struct minstrel_priv *mp = priv;
+	struct minstrel_ht_sta *mi = priv_sta;
+
 	debugfs_create_file("rc_stats", 0444, dir, priv_sta,
 			    &minstrel_ht_stat_fops);
 	debugfs_create_file("rc_stats_csv", 0444, dir, priv_sta,
 			    &minstrel_ht_stat_csv_fops);
+
+	if (ieee80211_hw_check(mp->hw, SUPPORTS_TPC_PER_PACKET) ||
+	    ieee80211_hw_check(mp->hw, SUPPORTS_TPC_PER_MRR))
+	{
+		mi->fixed_txpower_idx = (u32)-1;
+		debugfs_create_u32("rc_fixed_txpower_idx", S_IRUGO | S_IWUGO,
+				   dir, &mi->fixed_txpower_idx);
+	}
 }
-- 
2.30.2


  parent reply	other threads:[~2022-09-20 10:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 10:40 [RFC v2 0/6] mac80211: add TPC support in control path Jonas Jelonek
2022-09-20 10:40 ` [RFC v2 1/6] mac80211: modify tx-power level annotation Jonas Jelonek
2022-09-21 14:54   ` Jeff Johnson
2023-01-12 10:24   ` Johannes Berg
2022-09-20 10:40 ` [RFC v2 2/6] mac80211: add tx-power annotation in control path Jonas Jelonek
2023-01-12 10:31   ` Johannes Berg
2022-09-20 10:40 ` [RFC v2 3/6] mac80211: add hardware flags for TPC support Jonas Jelonek
2022-09-20 10:40 ` [RFC v2 4/6] mac80211: add utility function for tx_rate - rate_info conversion Jonas Jelonek
2023-01-12 10:26   ` Johannes Berg
2023-01-19 11:31     ` Jonas Jelonek
2023-01-19 11:35       ` Johannes Berg
2023-01-19 14:34         ` Jonas Jelonek
2022-09-20 10:40 ` [RFC v2 5/6] mac80211_hwsim: add TPC per packet support Jonas Jelonek
2022-09-26  7:47   ` [mac80211_hwsim] 14f322748f: WARNING:at_include/net/mac80211.h:#mac80211_hwsim_monitor_rx[mac80211_hwsim] kernel test robot
2022-09-26  7:47     ` kernel test robot
2023-01-12 10:31   ` [RFC v2 5/6] mac80211_hwsim: add TPC per packet support Johannes Berg
2023-01-19 14:32     ` Jonas Jelonek
2023-01-19 15:09       ` Johannes Berg
2023-01-26 16:52         ` Jonas Jelonek
     [not found]         ` <195E1629-BC72-4968-8E61-860C80F58D8B@gmail.com>
     [not found]           ` <386f10e09c17b871df1c86ebc0c2af52938c6fb6.camel@sipsolutions.net>
2023-03-03  7:42             ` Jonas Jelonek
2023-01-26 16:53     ` Jonas Jelonek
2023-02-28 17:44       ` Johannes Berg
2023-03-03  7:46         ` Jonas Jelonek
2022-09-20 10:40 ` Jonas Jelonek [this message]
2023-01-12 10:32   ` [RFC v2 6/6] mac80211: minstrel_ht - add debugfs entry per sta for fixed tx-power Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220920104032.496697-7-jelonek.jonas@gmail.com \
    --to=jelonek.jonas@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.