Hi!

With the wi(4) driver, is txpower output of ifconfig correct 
for cards which are capable of more than 100mW (20dBm) power?

In the stable OpenBSD 3.9 sources the maximum is _hardcoded_ to 20dBm.

There has been only one reference (providing the code below):
http://marc.theaimsgroup.com/?l=openbsd-misc&m=110841989007050&w=2
The patch posted there has already been merged.

/usr/src/sys/dev/ic/if_wi.c of 3.9-stable):

wi_set_txpower() {
        int8_t          tmp;
...
        /* Convert dBM to internal TX power value */
        if (sc->wi_txpower > 20)
                power = 128;
        else if (sc->wi_txpower < -43)
                power = 127;
        else {  
                tmp = sc->wi_txpower;
                tmp = -12 - tmp;
                tmp <<= 2;

                power = (u_int16_t)tmp;
        }
...
}

and

wi_get_txpower() {
...
        power = CSR_READ_2(sc, WI_RESP0);

        /* Convert internal TX power value to dBM */
        if (power > 255)
                txpower->i_val = 255;
        else {  
                tmp = power;
                tmp >>= 2;
                txpower->i_val = (u_int16_t)(-12 - tmp);
        }
}

Obviously the range [20,-43] (dBm) is mapped to an 8-bit integer 
using a "magic" constant of -12. This results in 128 as maximum value,
127 as lowest and 0 as the "middle" power setting, right?
Btw, 20dBm also matches the IEEE80211_TXPOWER_MAX define in
/usr/sys/net80211/ieee80211_var.h (set to 100 [mW]).

Now, what if the maximum internal value of 128 does _not_ correspond
to 100mW/20dBm?  

Say, if I have a 200mW capable card, is it correct to change the 
constant to -9 to have a mapping of [23,-40]? 
And what if the maximum power is 250mW or just 50mW? Always adjust
the constant and recompile?

So, how do I find the correct max/min values for txpower->i_val to 
adjust the above conversions? Perhaps in the firmware? 

Any references (e.g. to some driver documentation) are appreciated!

Thanks, Walter 

Reply via email to