Skip to contentSkip to conversation

wifi: b43: keep the N-PHY TX power control from drifting while idle

PATCH Superseded Rosen Penev 2 participants 2 messages Oct 17 – Oct 18 B43 wireless driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: b43: keep the N-PHY TX power control from drifting while idle

On N-PHY rev 3 and later, the hardware TX power control moves the base gain index of each core according to the power it estimates for the frames sent. CCK frames do not update the estimate, but the loop keeps stepping on them with the last one. An access point with no traffic only sends CCK beacons, and when the last estimate is below the target, each beacon adds gain.

On an ASUS RT-N16 (N-PHY rev 5, external PAs), both cores sit at base index 76-79 while OFDM frames go out, and walk down to index 0, maximum gain, within 20 s (core 2) and 60 s (core 1) after traffic stops, with the estimates frozen at 71 and 73 against a target of 74. The OFDM frames sent after that overdrive the PAs, so the higher rates fail until the loop has caught up: after 45 s of idle, only 2 of 8 pings to an 802.11g station got through.

Remember the base indices while OFDM frames are being sent, and when sending starts again after half a second without, load them back through the base index register. The loaded value only takes while the load bit is set as frames go out, so keep it set until OFDM frames have been sent for a while. Until then, the base indices stay where they were loaded instead of drifting. Forget the indices when the power control is set up again or the channel changes.

With this, the base indices stay at 75-79 over idle periods, and all pings after them get through. Throughput is unchanged.

Fixes c7d643103508 ("b43: N-PHY: determine various PHY params")
---
 drivers/net/wireless/broadcom/b43/main.c  | 20 +++++++
 drivers/net/wireless/broadcom/b43/phy_n.c | 64 +++++++++++++++++++++++
 drivers/net/wireless/broadcom/b43/phy_n.h | 12 +++++
 3 files changed, 96 insertions(+)
drivers/net/wireless/broadcom/b43/main.c +20 -0
index 3825b6ad9f4f..a205db22a07d 100644
@@ -3589,11 +3589,27 @@ static int b43_rng_init(struct b43_wl *wl)
 	return err;
 }
 
+/* Whether an N-PHY device sends @skb with OFDM or HT modulation */
+static bool b43_tx_is_ofdm(struct b43_wldev *dev, struct sk_buff *skb)
+{
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+	const struct ieee80211_rate *rate;
+
+	if (dev->phy.type != B43_PHYTYPE_N)
+		return false;
+	if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
+		return true;
+	rate = ieee80211_get_tx_rate(dev->wl->hw, info);
+
+	return rate && b43_is_ofdm_rate(rate->hw_value);
+}
+
 static void b43_tx_work(struct work_struct *work)
 {
 	struct b43_wl *wl = container_of(work, struct b43_wl, tx_work);
 	struct b43_wldev *dev;
 	struct sk_buff *skb;
+	bool ofdm_seen = false;
 	int queue_num;
 	int err = 0;
 
@@ -3607,6 +3623,10 @@ static void b43_tx_work(struct work_struct *work)
 	for (queue_num = 0; queue_num < B43_QOS_QUEUE_NUM; queue_num++) {
 		while (skb_queue_len(&wl->tx_queue[queue_num])) {
 			skb = skb_dequeue(&wl->tx_queue[queue_num]);
+			if (!ofdm_seen && b43_tx_is_ofdm(dev, skb)) {
+				b43_nphy_txpctl_ofdm_tx(dev);
+				ofdm_seen = true;
+			}
 			if (b43_using_pio_transfers(dev))
 				err = b43_pio_tx(dev, skb);
 			else
drivers/net/wireless/broadcom/b43/phy_n.c +64 -0

82 lines not on this page · raw message

drivers/net/wireless/broadcom/b43/phy_n.h +12 -0
index b96ded0ef539..787ad3e9b5ac 100644
@@ -973,6 +973,16 @@ struct b43_phy_n {
 	u16 tx_pwr_last_recalc_freq;
 	int tx_pwr_last_recalc_limit;
 
+	/*
+	 * Base indices of the hardware TX power control while OFDM frames
+	 * were sent, to restore them when sending starts again after idle.
+	 */
+	bool txpctl_bidx_valid;
+	bool txpctl_bidx_loaded;
+	u16 txpctl_bidx;
+	unsigned long txpctl_last_tx;
+	unsigned long txpctl_last_sample;
+
 	u8 txrx_chain;
 	u16 tx_rx_cal_phy_saveregs[11];
 	u16 tx_rx_cal_radio_saveregs[22];
@@ -1005,4 +1015,6 @@ struct b43_phy_n {
 struct b43_phy_operations;
 extern const struct b43_phy_operations b43_phyops_n;
 
+void b43_nphy_txpctl_ofdm_tx(struct b43_wldev *dev);
+
 #endif /* B43_NPHY_H_ */
Signature · 1 line
2.56.0
#1 lore raw
kernel test robot noticed the following build errors:

Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/wifi-b43-keep-the-N-PHY-TX-power-control-from-drifting-while-idle/20261016-175156
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git main
patch link:    https://lore.kernel.org/r/20261017005156.1260496-1-rosenp%40gmail.com
patch subject: [PATCH wireless] wifi: b43: keep the N-PHY TX power control from drifting while idle
config: x86_64-randconfig-1010-20261018 (https://download.01.org/0day-ci/archive/20261018/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261018/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: drivers/net/wireless/broadcom/b43/b43.ko: symbol 'b43_nphy_txpctl_ofdm_tx' undefined!

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki