From owner-svn-src-all@freebsd.org Thu May 19 22:28:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC61AB42054; Thu, 19 May 2016 22:28:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F63012AD; Thu, 19 May 2016 22:28:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4JMSkCX033985; Thu, 19 May 2016 22:28:46 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4JMSkeV033984; Thu, 19 May 2016 22:28:46 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605192228.u4JMSkeV033984@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Thu, 19 May 2016 22:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300241 - head/sys/dev/mwl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 22:28:48 -0000 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);