net80211 keeps the rssi value in 0.5bm relative to the noise floor
internally (see comment in ieee80211_node.h). While in many places
there was an 'int' as function argument to pass the internal rssi
value, in other places including structs we used int8_t.
The problem with int8_t is:
assume a noise floor "nf" of -127, assume a signal level of -21,
and then do the net80211 internal maths:
int8_t rssi8 = -21; => nf -127 rssi -21
rssi8 -= -127; => nf -127 rssi 106
rssi8 *= 2; => nf -127 rssi -44
Now doing the reverse (rssi / 2) + nf: (-44 / 2) + -127
will depending on how you print it give 107 or -149 and neither
is -21. The problem is that we have a double wrap-around.
Use int16_t instead for the entire storage which will do the
right thing avoiding any double-wrap-arounds:
nf -127 rssi -21
nf -127 rssi 106
nf -127 rssi 212, which results in S:N -21:-127
as 212 / 2 = 106 + -127 = -21.
I have separate patches for iwx(4) and linuxkpi_wlan(4) as those
triggered me looking into this while looking at scan results.
And for the first time ifconfig would give me meaningful values.
TODO: given this breaks the user space reporting need to resort
the struct layouts as well as they are no longer dword packed.
TODO: should we have an internal type defined for rssi05?
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Fixes: ??? (was not correct for user space in ages/ever?)