Questions of TX power get/set implementation for realtek WiFi driver

From: 邱名碩
Date: Wed Mar 03 2021 - 12:11:35 EST


Hi guys,
I'm planning to implement the get_txpower hook function of the
struct ieee80211_ops and handle the IEEE80211_CONF_CHANGE_POWER for
rtl8xxxu driver. So that users can get the information of the current
tx power limit and set a new limit value with iw commands.

I found there's phy_txpwr_idx_to_dbm() of each driver in
realtek/rtlwifi to translate the tx power index parsed from efuse to
tx power level in dBm. Does the power level translated represent the
current tx power limit in dBm? In my RTL8188CUS module, the power
index of CCK/OFDM from efuse for each channel is basically 36/38, thus
the translated txpower level is 11dBm. Is this the expected value for
the default txpower limit value? Or do I need some other formula to
compute?

And for the handler of IEEE80211_CONF_CHANGE_POWER, can I
translate the hw->conf.power_level with the phy_dbm_to_txpwr_idx
functions I found in some rtlwifi family drivers, then directly set
the txpower index with phy_set_txpower_index functions which write
power index to bbreg for different rates (CCK and OFDM)? Are there
some invalid values I should take care of because the TCP RX
performance seems to be extremely low when I write the power index
value translated from 20dBm to bbreg. Any suggestions for what I
should handle before writing the bbreg?

Chris