Date: Thu, 19 May 2016 22:28:46 +0000 (UTC) From: Andriy Voskoboinyk <avos@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300241 - head/sys/dev/mwl Message-ID: <201605192228.u4JMSkeV033984@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avos Date: Thu May 19 22:28:46 2016 New Revision: 300241 URL: https://svnweb.freebsd.org/changeset/base/300241 Log: mwl: switch to ieee80211_add_channel*(). Modified: head/sys/dev/mwl/if_mwl.c Modified: head/sys/dev/mwl/if_mwl.c ============================================================================== --- head/sys/dev/mwl/if_mwl.c Thu May 19 22:20:35 2016 (r300240) +++ head/sys/dev/mwl/if_mwl.c Thu May 19 22:28:46 2016 (r300241) @@ -4384,113 +4384,33 @@ mwl_setregdomain(struct ieee80211com *ic #define IEEE80211_CHAN_HTA (IEEE80211_CHAN_HT|IEEE80211_CHAN_A) static void -addchan(struct ieee80211_channel *c, int freq, int flags, int ieee, int txpow) -{ - c->ic_freq = freq; - c->ic_flags = flags; - c->ic_ieee = ieee; - c->ic_minpower = 0; - c->ic_maxpower = 2*txpow; - c->ic_maxregpower = txpow; -} - -static const struct ieee80211_channel * -findchannel(const struct ieee80211_channel chans[], int nchans, - int freq, int flags) -{ - const struct ieee80211_channel *c; - int i; - - for (i = 0; i < nchans; i++) { - c = &chans[i]; - if (c->ic_freq == freq && c->ic_flags == flags) - return c; - } - return NULL; -} - -static void addht40channels(struct ieee80211_channel chans[], int maxchans, int *nchans, const MWL_HAL_CHANNELINFO *ci, int flags) { - struct ieee80211_channel *c; - const struct ieee80211_channel *extc; - const struct mwl_hal_channel *hc; - int i; + int i, error; - c = &chans[*nchans]; - - flags &= ~IEEE80211_CHAN_HT; for (i = 0; i < ci->nchannels; i++) { - /* - * Each entry defines an HT40 channel pair; find the - * extension channel above and the insert the pair. - */ - hc = &ci->channels[i]; - extc = findchannel(chans, *nchans, hc->freq+20, - flags | IEEE80211_CHAN_HT20); - if (extc != NULL) { - if (*nchans >= maxchans) - break; - addchan(c, hc->freq, flags | IEEE80211_CHAN_HT40U, - hc->ieee, hc->maxTxPow); - c->ic_extieee = extc->ic_ieee; - c++, (*nchans)++; - if (*nchans >= maxchans) - break; - addchan(c, extc->ic_freq, flags | IEEE80211_CHAN_HT40D, - extc->ic_ieee, hc->maxTxPow); - c->ic_extieee = hc->ieee; - c++, (*nchans)++; - } + const struct mwl_hal_channel *hc = &ci->channels[i]; + + error = ieee80211_add_channel_ht40(chans, maxchans, nchans, + hc->ieee, hc->maxTxPow, flags); + if (error != 0 && error != ENOENT) + break; } } static void addchannels(struct ieee80211_channel chans[], int maxchans, int *nchans, - const MWL_HAL_CHANNELINFO *ci, int flags) + const MWL_HAL_CHANNELINFO *ci, const uint8_t bands[]) { - struct ieee80211_channel *c; - int i; - - c = &chans[*nchans]; + int i, error; - for (i = 0; i < ci->nchannels; i++) { - const struct mwl_hal_channel *hc; + error = 0; + for (i = 0; i < ci->nchannels && error == 0; i++) { + const struct mwl_hal_channel *hc = &ci->channels[i]; - hc = &ci->channels[i]; - if (*nchans >= maxchans) - break; - addchan(c, hc->freq, flags, hc->ieee, hc->maxTxPow); - c++, (*nchans)++; - if (flags == IEEE80211_CHAN_G || flags == IEEE80211_CHAN_HTG) { - /* g channel have a separate b-only entry */ - if (*nchans >= maxchans) - break; - c[0] = c[-1]; - c[-1].ic_flags = IEEE80211_CHAN_B; - c++, (*nchans)++; - } - if (flags == IEEE80211_CHAN_HTG) { - /* HT g channel have a separate g-only entry */ - if (*nchans >= maxchans) - break; - c[-1].ic_flags = IEEE80211_CHAN_G; - c[0] = c[-1]; - c[0].ic_flags &= ~IEEE80211_CHAN_HT; - c[0].ic_flags |= IEEE80211_CHAN_HT20; /* HT20 */ - c++, (*nchans)++; - } - if (flags == IEEE80211_CHAN_HTA) { - /* HT a channel have a separate a-only entry */ - if (*nchans >= maxchans) - break; - c[-1].ic_flags = IEEE80211_CHAN_A; - c[0] = c[-1]; - c[0].ic_flags &= ~IEEE80211_CHAN_HT; - c[0].ic_flags |= IEEE80211_CHAN_HT20; /* HT20 */ - c++, (*nchans)++; - } + error = ieee80211_add_channel(chans, maxchans, nchans, + hc->ieee, hc->freq, hc->maxTxPow, 0, bands); } } @@ -4499,6 +4419,7 @@ getchannels(struct mwl_softc *sc, int ma struct ieee80211_channel chans[]) { const MWL_HAL_CHANNELINFO *ci; + uint8_t bands[IEEE80211_MODE_BYTES]; /* * Use the channel info from the hal to craft the @@ -4508,11 +4429,20 @@ getchannels(struct mwl_softc *sc, int ma */ *nchans = 0; if (mwl_hal_getchannelinfo(sc->sc_mh, - MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) - addchannels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTG); + MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) { + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + setbit(bands, IEEE80211_MODE_11NG); + addchannels(chans, maxchans, nchans, ci, bands); + } if (mwl_hal_getchannelinfo(sc->sc_mh, - MWL_FREQ_BAND_5GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) - addchannels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTA); + MWL_FREQ_BAND_5GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) { + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11NA); + addchannels(chans, maxchans, nchans, ci, bands); + } if (mwl_hal_getchannelinfo(sc->sc_mh, MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_40_MHz_WIDTH, &ci) == 0) addht40channels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTG);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605192228.u4JMSkeV033984>