[OpenWrt-Devel] Fix TX power handling

Vincent Wiemann vincent.wiemann at ironai.com
Thu Apr 25 11:54:57 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

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:

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:
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:

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.


Vincent Wiemann

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

More information about the openwrt-devel mailing list