From owner-svn-src-head@freebsd.org Thu May 26 16:48:21 2016 Return-Path: Delivered-To: svn-src-head@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 8750FB4BD76; Thu, 26 May 2016 16:48:21 +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 5E52E1A52; Thu, 26 May 2016 16:48:21 +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 u4QGmKw5026150; Thu, 26 May 2016 16:48:20 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QGmKZ2026149; Thu, 26 May 2016 16:48:20 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605261648.u4QGmKZ2026149@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Thu, 26 May 2016 16:48:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300755 - head/sys/dev/bwi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 16:48:21 -0000 Author: avos Date: Thu May 26 16:48:20 2016 New Revision: 300755 URL: https://svnweb.freebsd.org/changeset/base/300755 Log: bwi: switch to ieee80211_add_channel_list_2ghz(). - Use device's channel list instead of default one (from ieee80211_init_channels()); adds 12 - 14 2GHz channels. - Add ic_getradiocaps() method. Modified: head/sys/dev/bwi/if_bwi.c Modified: head/sys/dev/bwi/if_bwi.c ============================================================================== --- head/sys/dev/bwi/if_bwi.c Thu May 26 16:39:11 2016 (r300754) +++ head/sys/dev/bwi/if_bwi.c Thu May 26 16:48:20 2016 (r300755) @@ -110,6 +110,8 @@ static int bwi_raw_xmit(struct ieee80211 const struct ieee80211_bpf_params *); static void bwi_watchdog(void *); static void bwi_scan_start(struct ieee80211com *); +static void bwi_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void bwi_set_channel(struct ieee80211com *); static void bwi_scan_end(struct ieee80211com *); static int bwi_newstate(struct ieee80211vap *, enum ieee80211_state, int); @@ -303,6 +305,9 @@ static const struct { [108] = { 7, 3 } }; +static const uint8_t bwi_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + #ifdef BWI_DEBUG #ifdef BWI_DEBUG_VERBOSE static uint32_t bwi_debug = BWI_DBG_ATTACH | BWI_DBG_INIT | BWI_DBG_TXPOWER; @@ -356,7 +361,6 @@ bwi_attach(struct bwi_softc *sc) device_t dev = sc->sc_dev; struct bwi_mac *mac; struct bwi_phy *phy; - uint8_t bands[IEEE80211_MODE_BYTES]; int i, error; BWI_LOCK_INIT(sc); @@ -453,15 +457,12 @@ bwi_attach(struct bwi_softc *sc) /* * Setup ratesets, phytype, channels and get MAC address */ - memset(bands, 0, sizeof(bands)); if (phy->phy_mode == IEEE80211_MODE_11B || phy->phy_mode == IEEE80211_MODE_11G) { - setbit(bands, IEEE80211_MODE_11B); if (phy->phy_mode == IEEE80211_MODE_11B) { ic->ic_phytype = IEEE80211_T_DS; } else { ic->ic_phytype = IEEE80211_T_OFDM; - setbit(bands, IEEE80211_MODE_11G); } bwi_get_eaddr(sc, BWI_SPROM_11BG_EADDR, ic->ic_macaddr); @@ -475,7 +476,6 @@ bwi_attach(struct bwi_softc *sc) } } else if (phy->phy_mode == IEEE80211_MODE_11A) { /* TODO:11A */ - setbit(bands, IEEE80211_MODE_11A); error = ENXIO; goto fail; } else { @@ -487,7 +487,8 @@ bwi_attach(struct bwi_softc *sc) BWI_SPROM_CARD_INFO_LOCALE); DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale); /* XXX use locale */ - ieee80211_init_channels(ic, NULL, bands); + bwi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ic->ic_softc = sc; ic->ic_name = device_get_nameunit(dev); @@ -509,6 +510,7 @@ bwi_attach(struct bwi_softc *sc) ic->ic_updateslot = bwi_updateslot; ic->ic_scan_start = bwi_scan_start; ic->ic_scan_end = bwi_scan_end; + ic->ic_getradiocaps = bwi_getradiocaps; ic->ic_set_channel = bwi_set_channel; ic->ic_transmit = bwi_transmit; ic->ic_parent = bwi_parent; @@ -1676,6 +1678,43 @@ bwi_scan_start(struct ieee80211com *ic) } static void +bwi_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct bwi_softc *sc = ic->ic_softc; + struct bwi_mac *mac; + struct bwi_phy *phy; + uint8_t bands[IEEE80211_MODE_BYTES]; + + /* + * XXX First MAC is known to exist + * TODO2 + */ + mac = &sc->sc_mac[0]; + phy = &mac->mac_phy; + + memset(bands, 0, sizeof(bands)); + switch (phy->phy_mode) { + case IEEE80211_MODE_11G: + setbit(bands, IEEE80211_MODE_11G); + /* FALLTHROUGH */ + case IEEE80211_MODE_11B: + setbit(bands, IEEE80211_MODE_11B); + break; + case IEEE80211_MODE_11A: + /* TODO:11A */ + setbit(bands, IEEE80211_MODE_11A); + device_printf(sc->sc_dev, "no 11a support\n"); + return; + default: + panic("unknown phymode %d\n", phy->phy_mode); + } + + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + bwi_chan_2ghz, nitems(bwi_chan_2ghz), bands, 0); +} + +static void bwi_set_channel(struct ieee80211com *ic) { struct bwi_softc *sc = ic->ic_softc;