On Mon, 2021-03-08 at 08:46 +0000, 邱名碩 wrote: > Pkshih <pkshih@xxxxxxxxxxx> 於 2021年3月6日 週六 下午1:09寫道: > > > > On Tue, 2021-03-02 at 10:21 +0000, 邱名碩 wrote: > > > 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? > > > > Basically, you can use a linear equation to translate power level in dBm to > > tx power index written to hardware registers. > > y = ax + b > > where, > > y: tx power index written to registers > > x: tx power level in dBm > > a: a constant, 2 > > b: a constant induced by the value programmed in efuse that is used to > > adapt modules differences of RF characters. > > > Thanks so much. So it means that the txpwr_idx_to_dbm and dbm_to_idx > functions in rtlwifi family driver are basically correct. Except they > use the constant > b -7 for CCK and -8 for OFDM instead of the value in efuse. I should have > this value from efuse. As I mentioned, the calibration value in efuse is used to output proper power that every hardware module must be the same (with little tolerance). I'm not sure why constant b isn't related to the value in efuse. Maybe, you can assume the functions are correct, and configure the power you desire. > > > > > > > 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? > > > > The power level you're going to set must be less or equal to original > > one, because it's the hard limit of hardware capability. If the power > > level is too large, the receiver can't understand the signal. Then, > > they can't exchange data that leads low performance as you see. > > I think the performance would be okay if you connect to a near AP and > > power level 10dBm is adapted. > > > > Thanks for clarification. So the power index from efuse is basically the > hard limit of the tx power for each channel (and rate)? That explains > my performance issue while I override it with higher value. Thanks > The value in efuse isn't limit but calibration value of target power. But, yes, you can seen it as hard limit as well. -- Ping-Ke