[OpenWrt-Devel] Fix TX power handling

Joe Ayers joe at ayerscasa.com
Tue Apr 30 00:10:38 EDT 2019

> I've stumbled across problems with the transmission output power of OpenWrt
> routers quite often.
> E.g. https://bugs.openwrt.org/index.php?do=details&task_id=1289&pagenum=4
> which I still have to look into in greater detail.
> OpenWrt's handling of TX power, antenna and PA gains needs to be revised
> thoroughly.

> There is a iw patch in OpenWrt that is being used for setting the antenna gain.
> There was one try of nbd to upstream this change in 2013:
> https://www.spinics.net/lists/linux-wireless/msg111944.html

> I'd like to make some things clear here and hope that there will be a new
> attempt to getting this upstreamed.
> First EIRP is by definition ERP + antenna gain - cable loss.
> And ERP is radio chip output + PA chip gain - (board's signal path loss which is likely
> irrelevant due to golden device calibration).

> If there is a regulatory limit of the antenna gain that (whyever) means that no antennas
> with a higher gain are allowed - this does not really make sense.
> It certainly does not mean that you can exceed the EIRP
> by the antenna gain as this would reduce the definition of EIRP to absurdity.
> If the regulatory domain values aren't plausible (because why in the world should
> there be a limit to the antenna gain when there is a EIRP limit already?),
> we should not work around that, because otherwise nobody will see the mistake -
> It is a problem of the regdb then, which likely needs to introduce a new regulatory
> definition for maximum ERP and maximum antenna gain for affected regions, which
> would still don't really make sense, but maybe laws are just weird in this regions.

> Second e.g. most TP-Link routers don't use the ART's antenna gain field.
> Instead they use the TX gain field (which should have been used for defining an
> external PA chip's gain instead). I assume that they did it to circumvent problems
> with the regdb...

> Finally some device's (Ubiquiti XM/XW) external PA chip gain is defined in stock
> firmware depending on the subvendor device ID of the radio chip.
> These definitions are being defined in:
> https://git.openwrt.org/?p=project/iwinfo.git;a=blob;f=hardware.txt
> I've filed a patch which adds all PA gains of Ubiquiti XM/XW devices to iwinfo which
> I've extracted from the stock firmware, but it seems to be ignored until now:
> https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg46175.html

> AFAIK OpenWrt does not make use of these values, yet leading to a much higher
> EIRP than allowed if these values are not manually adjusted.

> Thus to my best knowledge what has to be done is:
> 1. add options for external PA gain in iw and nl80211 code
> 2. display antenna gain and PA gain in iw
> 3. check if ath9k code sets PA gain and antenna gain correctly and
>   if not, fix it
> 4. for devices whose PA gain does not seem to be defined in ART like
>   Ubiquiti XM/XWs, add a hotplug script to OpenWrt that sets
>    the correct PA gains from iwinfo using iw.
> 5. for devices whose antenna gain neither seems to be defined in ART's
>    antenna gain nor it's TX gain field, add a hotplug script to OpenWrt
>    that sets the correct antenna gains manually on a model basis using iw.
> 6. take measurements to check if the ERP meets expectations
> 7. upstream all these changes and make regdb developers aware

> I'd like to do this by myself, but I don't have time for it.
> Still I can help with the measurements etc.
> If someone feels capable of doing this, this would be a great improvement
> and help OpenWrt to keep a stand against vendor locking.

> Regards,

> Vincent Wiemann

A few discussion points, although I would have to learn a lot to be
capable of  implementing.  Not going to happen anytime soon.

1)  Here is a chart of the max xmit power permissible with US FCC part
15 regulations by channel.  This chart assumes negligible internal
antenna feed line loss:

2) The antenna array gain seems to be the reverse perspective?   Isn't
the power split based on the count of physical antennas -- there isn't
a power setting per xmit chain, correct?      2 antennas, the power is
split on the 2.  3 antennas, the power is always split on the 3, ...
For  MCS0, all antennas transmit same signal and add up to total power
radiated.   If the specs of a 2 antenna device say the max xmit power
is 25dBm, we set 25dBm with iw, then 22dBm is transmitted going to
each antenna.   (-3dB is half power).  Each antenna chain has its own
Power Amp (PA)?

3) Reduced power with increased MCS rates?  An inspection of the UBNT
specs show a decline in max xmit power as MCS rates increase.   I
understand this is due to keeping linearity in the PA.   To contain
hardware costs there is a sacrifice of dynamic range of the signal the
PA can amplify.  As rates go up, it needs more dynamic range and when
going out of linearity, we start seeing increasing out of channel
energy, splatter.  Signal quality degrades.  Going from MCS0 to MCS7
(and also MCS8 to MCS15) rates, e.g. the Rocket M5 data sheet,  shows
a reduction of 6dB -- to keep the signal clean.  Possibility of
exceeding the limits on out of channel energy if not doing this.

4) Reduced power with reduced channel width?   Same issue of PA
linearity.  As the channel is cut in half with the same energy, the
signal gets taller and needs more PA range.  Thus another power
reduction to keep a clean signal. Probably need 3dB reduction of xmit
power to cut channel width in half.


openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list