Fix TXPMGT handling:
o correct dBm<->mW conversion logic o set net80211 TXPMGT capability only if driver reports it is capable PR: kern/132342 Submitted by: "Paul B. Mahol" <onemda@gmail.com>
This commit is contained in:
parent
c30c187d60
commit
f11fe89814
@ -102,7 +102,7 @@ SYSCTL_INT(_hw_ndisusb, OID_AUTO, halt, CTLFLAG_RW, &ndisusb_halt, 0,
|
||||
"Halt NDIS USB driver when it's attached");
|
||||
|
||||
/* 0 - 30 dBm to mW conversion table */
|
||||
const uint16_t dBm2mW[] = {
|
||||
static const uint16_t dBm2mW[] = {
|
||||
1, 1, 1, 1, 2, 2, 2, 2, 3, 3,
|
||||
3, 4, 4, 4, 5, 6, 6, 7, 8, 9,
|
||||
10, 11, 13, 14, 16, 18, 20, 22, 25, 28,
|
||||
@ -749,7 +749,7 @@ ndis_attach(dev)
|
||||
ic->ic_ifp = ifp;
|
||||
ic->ic_opmode = IEEE80211_M_STA;
|
||||
ic->ic_phytype = IEEE80211_T_DS;
|
||||
ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_TXPMGT;
|
||||
ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS;
|
||||
setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
|
||||
len = 0;
|
||||
r = ndis_get_info(sc, OID_802_11_NETWORK_TYPES_SUPPORTED,
|
||||
@ -928,6 +928,11 @@ ndis_attach(dev)
|
||||
r = ndis_get_info(sc, OID_802_11_POWER_MODE, &arg, &i);
|
||||
if (r == 0)
|
||||
ic->ic_caps |= IEEE80211_C_PMGT;
|
||||
|
||||
r = ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &i);
|
||||
if (r == 0)
|
||||
ic->ic_caps |= IEEE80211_C_TXPMGT;
|
||||
|
||||
bcopy(eaddr, &ic->ic_myaddr, sizeof(eaddr));
|
||||
ieee80211_ifattach(ic);
|
||||
ic->ic_raw_xmit = ndis_raw_xmit;
|
||||
@ -2325,9 +2330,10 @@ ndis_setstate_80211(sc)
|
||||
ndis_set_info(sc, OID_802_11_POWER_MODE, &arg, &len);
|
||||
|
||||
/* Set TX power */
|
||||
if (ic->ic_txpowlimit < sizeof(dBm2mW)) {
|
||||
len = sizeof(arg);
|
||||
if ((ic->ic_caps & IEEE80211_C_TXPMGT) &&
|
||||
ic->ic_txpowlimit < (sizeof(dBm2mW) / sizeof(dBm2mW[0]))) {
|
||||
arg = dBm2mW[ic->ic_txpowlimit];
|
||||
len = sizeof(arg);
|
||||
ndis_set_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
|
||||
}
|
||||
|
||||
@ -2798,11 +2804,10 @@ ndis_getstate_80211(sc)
|
||||
}
|
||||
|
||||
/* Get TX power */
|
||||
len = sizeof(arg);
|
||||
rval = ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
|
||||
|
||||
if (!rval) {
|
||||
for (i = 0; i < sizeof(dBm2mW); i++)
|
||||
if (ic->ic_caps & IEEE80211_C_TXPMGT) {
|
||||
len = sizeof(arg);
|
||||
ndis_get_info(sc, OID_802_11_TX_POWER_LEVEL, &arg, &len);
|
||||
for (i = 0; i < (sizeof(dBm2mW) / sizeof(dBm2mW[0])); i++)
|
||||
if (dBm2mW[i] >= arg)
|
||||
break;
|
||||
ic->ic_txpowlimit = i;
|
||||
|
Loading…
Reference in New Issue
Block a user