From owner-svn-src-all@freebsd.org Sat Feb 18 19:19:09 2017 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 B116FCE47E9; Sat, 18 Feb 2017 19:19:09 +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 88F811A67; Sat, 18 Feb 2017 19:19:09 +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 v1IJJ86A059795; Sat, 18 Feb 2017 19:19:08 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1IJJ89d059794; Sat, 18 Feb 2017 19:19:08 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201702181919.v1IJJ89d059794@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 18 Feb 2017 19:19:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r313921 - stable/11/sys/dev/iwi X-SVN-Group: stable-11 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.23 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: Sat, 18 Feb 2017 19:19:09 -0000 Author: avos Date: Sat Feb 18 19:19:08 2017 New Revision: 313921 URL: https://svnweb.freebsd.org/changeset/base/313921 Log: MFC r313694: iwi: add 12-14 2GHz channels into channel list. Return full channel list via iwi_getradiocaps() method (ieee80211_init_channels() was replaced with iwi_getradiocaps() to be consistent with other drivers). PR: 216923 Submitted and tested by: ds@ukrhub.net (original patch) Modified: stable/11/sys/dev/iwi/if_iwi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/iwi/if_iwi.c ============================================================================== --- stable/11/sys/dev/iwi/if_iwi.c Sat Feb 18 18:57:29 2017 (r313920) +++ stable/11/sys/dev/iwi/if_iwi.c Sat Feb 18 19:19:08 2017 (r313921) @@ -130,6 +130,15 @@ static const struct iwi_ident iwi_ident_ { 0, 0, NULL } }; +static const uint8_t def_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; +static const uint8_t def_chan_5ghz_band1[] = + { 36, 40, 44, 48, 52, 56, 60, 64 }; +static const uint8_t def_chan_5ghz_band2[] = + { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 }; +static const uint8_t def_chan_5ghz_band3[] = + { 149, 153, 157, 161, 165 }; + static struct ieee80211vap *iwi_vap_create(struct ieee80211com *, const char [IFNAMSIZ], int, enum ieee80211_opmode, int, const uint8_t [IEEE80211_ADDR_LEN], @@ -204,6 +213,9 @@ static void iwi_radio_off(void *, int); static void iwi_sysctlattach(struct iwi_softc *); static void iwi_led_event(struct iwi_softc *, int); static void iwi_ledattach(struct iwi_softc *); +static void iwi_collect_bands(struct ieee80211com *, uint8_t [], size_t); +static void iwi_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel []); static int iwi_probe(device_t); static int iwi_attach(device_t); @@ -271,7 +283,6 @@ iwi_attach(device_t dev) struct iwi_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint16_t val; - uint8_t bands[IEEE80211_MODE_BYTES]; int i, error; sc->sc_dev = dev; @@ -374,12 +385,8 @@ iwi_attach(device_t dev) ic->ic_macaddr[4] = val & 0xff; ic->ic_macaddr[5] = val >> 8; - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - if (pci_get_device(dev) >= 0x4223) - setbit(bands, IEEE80211_MODE_11A); - ieee80211_init_channels(ic, NULL, bands); + iwi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); /* override default methods */ @@ -399,6 +406,7 @@ iwi_attach(device_t dev) ic->ic_ioctl = iwi_ioctl; ic->ic_transmit = iwi_transmit; ic->ic_parent = iwi_parent; + ic->ic_getradiocaps = iwi_getradiocaps; ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), @@ -3569,3 +3577,40 @@ iwi_scan_end(struct ieee80211com *ic) iwi_cmd(sc, IWI_CMD_ABORT_SCAN, NULL, 0); IWI_UNLOCK(sc); } + +static void +iwi_collect_bands(struct ieee80211com *ic, uint8_t bands[], size_t bands_sz) +{ + struct iwi_softc *sc = ic->ic_softc; + device_t dev = sc->sc_dev; + + memset(bands, 0, bands_sz); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + if (pci_get_device(dev) >= 0x4223) + setbit(bands, IEEE80211_MODE_11A); +} + +static void +iwi_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + uint8_t bands[IEEE80211_MODE_BYTES]; + + iwi_collect_bands(ic, bands, sizeof(bands)); + *nchans = 0; + if (isset(bands, IEEE80211_MODE_11B) || isset(bands, IEEE80211_MODE_11G)) + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + def_chan_2ghz, nitems(def_chan_2ghz), bands, 0); + if (isset(bands, IEEE80211_MODE_11A)) { + ieee80211_add_channel_list_5ghz(chans, maxchans, nchans, + def_chan_5ghz_band1, nitems(def_chan_5ghz_band1), + bands, 0); + ieee80211_add_channel_list_5ghz(chans, maxchans, nchans, + def_chan_5ghz_band2, nitems(def_chan_5ghz_band2), + bands, 0); + ieee80211_add_channel_list_5ghz(chans, maxchans, nchans, + def_chan_5ghz_band3, nitems(def_chan_5ghz_band3), + bands, 0); + } +}