From owner-svn-src-head@freebsd.org Thu May 26 16:15:11 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 69335B4B218; Thu, 26 May 2016 16:15:11 +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 4332611E8; Thu, 26 May 2016 16:15:11 +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 u4QGFAuT014612; Thu, 26 May 2016 16:15:10 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QGFAfA014609; Thu, 26 May 2016 16:15:10 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605261615.u4QGFAfA014609@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:15:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300753 - head/sys/dev/usb/wlan 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:15:11 -0000 Author: avos Date: Thu May 26 16:15:10 2016 New Revision: 300753 URL: https://svnweb.freebsd.org/changeset/base/300753 Log: urtw: switch to ieee80211_add_channel_list_2ghz(). - Use device's channel list instead of default one (from ieee80211_init_channels()). - Add ic_getradiocaps() method. Modified: head/sys/dev/usb/wlan/if_urtw.c head/sys/dev/usb/wlan/if_urtwreg.h Modified: head/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- head/sys/dev/usb/wlan/if_urtw.c Thu May 26 16:05:19 2016 (r300752) +++ head/sys/dev/usb/wlan/if_urtw.c Thu May 26 16:15:10 2016 (r300753) @@ -206,6 +206,9 @@ static uint8_t urtw_8225z2_agc[] = { 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31 }; +static const uint8_t urtw_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static uint32_t urtw_8225_channel[] = { 0x0000, /* dummy channel 0 */ 0x085c, /* 1 */ @@ -662,6 +665,8 @@ static int urtw_raw_xmit(struct ieee802 const struct ieee80211_bpf_params *); static void urtw_scan_start(struct ieee80211com *); static void urtw_scan_end(struct ieee80211com *); +static void urtw_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void urtw_set_channel(struct ieee80211com *); static void urtw_update_mcast(struct ieee80211com *); static int urtw_tx_start(struct urtw_softc *, @@ -785,7 +790,6 @@ urtw_attach(device_t dev) struct urtw_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands[IEEE80211_MODE_BYTES]; uint8_t iface_index = URTW_IFACE_INDEX; /* XXX */ uint16_t n_setup; uint32_t data; @@ -877,15 +881,16 @@ urtw_attach(device_t dev) IEEE80211_C_BGSCAN | /* capable of bg scanning */ IEEE80211_C_WPA; /* 802.11i */ - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - ieee80211_init_channels(ic, NULL, bands); + /* XXX TODO: setup regdomain if URTW_EPROM_CHANPLAN_BY_HW bit is set.*/ + + urtw_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtw_raw_xmit; ic->ic_scan_start = urtw_scan_start; ic->ic_scan_end = urtw_scan_end; + ic->ic_getradiocaps = urtw_getradiocaps; ic->ic_set_channel = urtw_set_channel; ic->ic_updateslot = urtw_updateslot; ic->ic_vap_create = urtw_vap_create; @@ -1564,6 +1569,19 @@ urtw_scan_end(struct ieee80211com *ic) } static void +urtw_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + uint8_t bands[IEEE80211_MODE_BYTES]; + + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + urtw_chan_2ghz, nitems(urtw_chan_2ghz), bands, 0); +} + +static void urtw_set_channel(struct ieee80211com *ic) { struct urtw_softc *sc = ic->ic_softc; Modified: head/sys/dev/usb/wlan/if_urtwreg.h ============================================================================== --- head/sys/dev/usb/wlan/if_urtwreg.h Thu May 26 16:05:19 2016 (r300752) +++ head/sys/dev/usb/wlan/if_urtwreg.h Thu May 26 16:15:10 2016 (r300753) @@ -253,6 +253,7 @@ /* for EEPROM */ #define URTW_EPROM_CHANPLAN 0x03 +#define URTW_EPROM_CHANPLAN_BY_HW (0x80) #define URTW_EPROM_TXPW_BASE 0x05 #define URTW_EPROM_RFCHIPID 0x06 #define URTW_EPROM_RFCHIPID_RTL8225U (5)