wifi: b43: keep the N-PHY TX power control from drifting while idle
PATCH v2 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. Only sample them once OFDM frames have been sent without a break for 200 ms, so the loop has settled first, and suspend the MAC around the register accesses.
With this, the base indices stay at 75-79 over idle periods, and all pings after them get through. Throughput is unchanged.
---
v2: add stub to fix linking error.
drivers/net/wireless/broadcom/b43/main.c | 20 +++++ drivers/net/wireless/broadcom/b43/phy_n.c | 94 +++++++++++++++++++++++ drivers/net/wireless/broadcom/b43/phy_n.h | 18 +++++ 3 files changed, 132 insertions(+)
drivers/net/wireless/broadcom/b43/main.c +20 -0
@@ -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 +94 -0
118 lines not on this page · raw message
drivers/net/wireless/broadcom/b43/phy_n.h +18 -0
@@ -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,12 @@ struct b43_phy_n {struct b43_phy_operations ;extern const struct b43_phy_operations b43_phyops_n; +#ifdef CONFIG_B43_PHY_N +void b43_nphy_txpctl_ofdm_tx (struct b43_wldev *dev); +#else +static inline void b43_nphy_txpctl_ofdm_tx (struct b43_wldev *dev) +{ +} +#endif +#endif /* B43_NPHY_H_ */
Signature · 1 line
2.56.0