diff options
author | ambrisko <ambrisko@FreeBSD.org> | 2003-02-02 22:49:31 +0000 |
---|---|---|
committer | ambrisko <ambrisko@FreeBSD.org> | 2003-02-02 22:49:31 +0000 |
commit | 3df9deadf20433b53f8cd89697e0c34c113d25db (patch) | |
tree | 7f5344b322781284fd556c26a34313b06f53a02d /sys/dev/an | |
parent | 9746fdfdd89eb0d13ed4ff4b85c546122151130b (diff) | |
download | FreeBSD-src-3df9deadf20433b53f8cd89697e0c34c113d25db.zip FreeBSD-src-3df9deadf20433b53f8cd89697e0c34c113d25db.tar.gz |
Some small enhancments
- Implement TX power control with hints to code in Linux driver
by Douglas S. J. De Couto <decouto@lcs.mit.edu>
- Update ifmedia support to use ieee80211_rate2media and
ieee80211_media2rate. Note doesn't work with stock ifconfig
since there seems to be an issue with the setmedia code.
"ancontrol -t" works now, before it did nothing.
- Fix spelling error in header.
Diffstat (limited to 'sys/dev/an')
-rw-r--r-- | sys/dev/an/if_an.c | 132 | ||||
-rw-r--r-- | sys/dev/an/if_anreg.h | 2 |
2 files changed, 70 insertions, 64 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 615a300..1197012 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -674,6 +674,8 @@ an_attach(sc, unit, flags) { struct ifnet *ifp = &sc->arpcom.ac_if; int error; + int i, nrate, mword; + u_int8_t r; mtx_init(&sc->an_mtx, device_get_nameunit(sc->an_dev), MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE); @@ -792,30 +794,28 @@ an_attach(sc, unit, flags) sc->an_tx_rate = 0; bzero((char *)&sc->an_stats, sizeof(sc->an_stats)); + nrate = 8; + ifmedia_init(&sc->an_ifmedia, 0, an_media_change, an_media_status); -#define ADD(m, c) ifmedia_add(&sc->an_ifmedia, (m), (c), NULL) - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, - IFM_IEEE80211_ADHOC, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, 0, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, - IFM_IEEE80211_ADHOC, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS2, 0, 0), 0); - if (sc->an_caps.an_rates[2] == AN_RATE_5_5MBPS) { - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, - IFM_IEEE80211_ADHOC, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS5, 0, 0), 0); - } - if (sc->an_caps.an_rates[3] == AN_RATE_11MBPS) { - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, - IFM_IEEE80211_ADHOC, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS11, 0, 0), 0); - } - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, - IFM_IEEE80211_ADHOC, 0), 0); - ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0), 0); -#undef ADD - ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, - 0, 0)); + if_printf(ifp, "supported rates: "); +#define ADD(s, o) ifmedia_add(&sc->an_ifmedia, \ + IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL) + ADD(IFM_AUTO, 0); + ADD(IFM_AUTO, IFM_IEEE80211_ADHOC); + for (i = 0; i < nrate; i++) { + r = sc->an_caps.an_rates[i]; + mword = ieee80211_rate2media(r, IEEE80211_T_DS); + if (mword == 0) + continue; + printf("%s%d%sMbps", (i != 0 ? " " : ""), + (r & IEEE80211_RATE_VAL) / 2, ((r & 0x1) != 0 ? ".5" : "")); + ADD(mword, 0); + ADD(mword, IFM_IEEE80211_ADHOC); + } + printf("\n"); + ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211, + IFM_AUTO, 0, 0)); +#undef ADD /* * Call MI attach routine. @@ -989,8 +989,8 @@ an_rxeof(sc) /* Receive packet. */ #ifdef ANCACHE an_cache_store(sc, eh, m, - rx_frame.an_rx_signal_strength, - rx_frame.an_rsvd0); + rx_frame.an_rx_signal_strength, + rx_frame.an_rsvd0); #endif (*ifp->if_input)(ifp, m); } @@ -1056,8 +1056,8 @@ an_rxeof(sc) #if 0 #ifdef ANCACHE an_cache_store(sc, eh, m, - rx_frame.an_rx_signal_strength, - rx_frame.an_rsvd0); + rx_frame.an_rx_signal_strength, + rx_frame.an_rsvd0); #endif #endif (*ifp->if_input)(ifp, m); @@ -1796,6 +1796,20 @@ an_setdef(sc, areq) case AN_RID_TX_SPEED: sp = (struct an_ltv_gen *)areq; sc->an_tx_rate = sp->an_val; + + /* Read the current configuration */ + sc->an_config.an_type = AN_RID_GENCONFIG; + sc->an_config.an_len = sizeof(struct an_ltv_genconfig); + an_read_record(sc, (struct an_ltv_gen *)&sc->an_config); + cfg = &sc->an_config; + + /* clear other rates and set the only one we want */ + bzero(cfg->an_rates, sizeof(cfg->an_rates)); + cfg->an_rates[0] = sc->an_tx_rate; + + /* Save the new rate */ + sc->an_config.an_type = AN_RID_GENCONFIG; + sc->an_config.an_len = sizeof(struct an_ltv_genconfig); break; case AN_RID_WEP_TEMP: case AN_RID_WEP_PERM: @@ -3038,6 +3052,7 @@ an_media_change(ifp) struct ifnet *ifp; { struct an_softc *sc = ifp->if_softc; + struct an_ltv_genconfig *cfg; int otype = sc->an_config.an_opmode; int orate = sc->an_tx_rate; @@ -3046,26 +3061,29 @@ an_media_change(ifp) else sc->an_config.an_opmode = AN_OPMODE_INFRASTRUCTURE_STATION; - switch (IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media)) { - case IFM_IEEE80211_DS1: - sc->an_tx_rate = AN_RATE_1MBPS; - break; - case IFM_IEEE80211_DS2: - sc->an_tx_rate = AN_RATE_2MBPS; - break; - case IFM_IEEE80211_DS5: - sc->an_tx_rate = AN_RATE_5_5MBPS; - break; - case IFM_IEEE80211_DS11: - sc->an_tx_rate = AN_RATE_11MBPS; - break; - case IFM_AUTO: - sc->an_tx_rate = 0; - break; + sc->an_tx_rate = + ieee80211_media2rate( + IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media), + IEEE80211_T_DS); + + if (orate != sc->an_tx_rate) { + /* Read the current configuration */ + sc->an_config.an_type = AN_RID_GENCONFIG; + sc->an_config.an_len = sizeof(struct an_ltv_genconfig); + an_read_record(sc, (struct an_ltv_gen *)&sc->an_config); + cfg = &sc->an_config; + + /* clear other rates and set the only one we want */ + bzero(cfg->an_rates, sizeof(cfg->an_rates)); + cfg->an_rates[0] = sc->an_tx_rate; + + /* Save the new rate */ + sc->an_config.an_type = AN_RID_GENCONFIG; + sc->an_config.an_len = sizeof(struct an_ltv_genconfig); } - if (otype != sc->an_config.an_opmode || - orate != sc->an_tx_rate) + if (otype != sc->an_config.an_opmode + || orate != sc->an_tx_rate) an_init(sc); return(0); @@ -3079,6 +3097,8 @@ an_media_status(ifp, imr) struct an_ltv_status status; struct an_softc *sc = ifp->if_softc; + imr->ifm_active = IFM_IEEE80211; + status.an_len = sizeof(status); status.an_type = AN_RID_STATUS; if (an_read_record(sc, (struct an_ltv_gen *)&status)) { @@ -3089,26 +3109,12 @@ an_media_status(ifp, imr) if (sc->an_tx_rate == 0) { imr->ifm_active = IFM_IEEE80211|IFM_AUTO; - if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC) - imr->ifm_active |= IFM_IEEE80211_ADHOC; - switch (status.an_current_tx_rate) { - case AN_RATE_1MBPS: - imr->ifm_active |= IFM_IEEE80211_DS1; - break; - case AN_RATE_2MBPS: - imr->ifm_active |= IFM_IEEE80211_DS2; - break; - case AN_RATE_5_5MBPS: - imr->ifm_active |= IFM_IEEE80211_DS5; - break; - case AN_RATE_11MBPS: - imr->ifm_active |= IFM_IEEE80211_DS11; - break; - } - } else { - imr->ifm_active = sc->an_ifmedia.ifm_cur->ifm_media; } + if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC) + imr->ifm_active |= IFM_IEEE80211_ADHOC; + imr->ifm_active |= ieee80211_rate2media(status.an_current_tx_rate, + IEEE80211_T_DS); imr->ifm_status = IFM_AVALID; if (status.an_opmode & AN_STATUS_OPMODE_ASSOCIATED) imr->ifm_status |= IFM_ACTIVE; diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h index c9bf1fc..20ed9bb 100644 --- a/sys/dev/an/if_anreg.h +++ b/sys/dev/an/if_anreg.h @@ -123,7 +123,7 @@ #define AN_CMD_ENABLE 0x0001 /* enable */ #define AN_CMD_DISABLE 0x0002 /* disable */ #define AN_CMD_FORCE_SYNCLOSS 0x0003 /* force loss of sync */ -#define AN_CMD_FW_RESTART 0x0004 /* firmware resrart */ +#define AN_CMD_FW_RESTART 0x0004 /* firmware restart */ #define AN_CMD_HOST_SLEEP 0x0005 #define AN_CMD_MAGIC_PKT 0x0006 #define AN_CMD_READCFG 0x0008 |