From owner-svn-src-head@freebsd.org Thu May 26 16:39:13 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 3463AB4BBBB; Thu, 26 May 2016 16:39:13 +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 0BCB41437; Thu, 26 May 2016 16:39:12 +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 u4QGdCH2022611; Thu, 26 May 2016 16:39:12 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QGdBZY022606; Thu, 26 May 2016 16:39:11 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605261639.u4QGdBZY022606@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:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300754 - in head/sys/dev: rtwn urtwn 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:39:13 -0000 Author: avos Date: Thu May 26 16:39:11 2016 New Revision: 300754 URL: https://svnweb.freebsd.org/changeset/base/300754 Log: urtwn, rtwn, rsu: 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/rtwn/if_rtwn.c head/sys/dev/rtwn/if_rtwnreg.h head/sys/dev/urtwn/if_urtwn.c head/sys/dev/urtwn/if_urtwnreg.h head/sys/dev/usb/wlan/if_rsu.c Modified: head/sys/dev/rtwn/if_rtwn.c ============================================================================== --- head/sys/dev/rtwn/if_rtwn.c Thu May 26 16:15:10 2016 (r300753) +++ head/sys/dev/rtwn/if_rtwn.c Thu May 26 16:39:11 2016 (r300754) @@ -172,6 +172,8 @@ static void rtwn_set_rx_bssid_all(struct static void rtwn_set_gain(struct rtwn_softc *, uint8_t); static void rtwn_scan_start(struct ieee80211com *); static void rtwn_scan_end(struct ieee80211com *); +static void rtwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void rtwn_set_channel(struct ieee80211com *); static void rtwn_update_mcast(struct ieee80211com *); static void rtwn_set_chan(struct rtwn_softc *, @@ -230,6 +232,9 @@ MODULE_DEPEND(rtwn, pci, 1, 1, 1); MODULE_DEPEND(rtwn, wlan, 1, 1, 1); MODULE_DEPEND(rtwn, firmware, 1, 1, 1); +static const uint8_t rtwn_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static int rtwn_probe(device_t dev) { @@ -251,7 +256,6 @@ rtwn_attach(device_t dev) struct rtwn_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; uint32_t lcsr; - uint8_t bands[IEEE80211_MODE_BYTES]; int i, count, error, rid; sc->sc_dev = dev; @@ -352,17 +356,18 @@ rtwn_attach(device_t dev) | IEEE80211_C_WME /* 802.11e */ ; - 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 R92C_CHANNEL_PLAN_BY_HW bit is set. */ + + rtwn_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_wme.wme_update = rtwn_updateedca; ic->ic_update_mcast = rtwn_update_mcast; - ic->ic_scan_start =rtwn_scan_start; + ic->ic_scan_start = rtwn_scan_start; ic->ic_scan_end = rtwn_scan_end; + ic->ic_getradiocaps = rtwn_getradiocaps; ic->ic_set_channel = rtwn_set_channel; ic->ic_raw_xmit = rtwn_raw_xmit; ic->ic_transmit = rtwn_transmit; @@ -2717,6 +2722,19 @@ rtwn_scan_end(struct ieee80211com *ic) } static void +rtwn_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, + rtwn_chan_2ghz, nitems(rtwn_chan_2ghz), bands, 0); +} + +static void rtwn_set_channel(struct ieee80211com *ic) { struct rtwn_softc *sc = ic->ic_softc; Modified: head/sys/dev/rtwn/if_rtwnreg.h ============================================================================== --- head/sys/dev/rtwn/if_rtwnreg.h Thu May 26 16:15:10 2016 (r300753) +++ head/sys/dev/rtwn/if_rtwnreg.h Thu May 26 16:39:11 2016 (r300754) @@ -1014,6 +1014,8 @@ struct r92c_rom { uint8_t rf_opt3; uint8_t rf_opt4; uint8_t channel_plan; +#define R92C_CHANNEL_PLAN_BY_HW 0x80 + uint8_t version; uint8_t curstomer_id; } __packed; Modified: head/sys/dev/urtwn/if_urtwn.c ============================================================================== --- head/sys/dev/urtwn/if_urtwn.c Thu May 26 16:15:10 2016 (r300753) +++ head/sys/dev/urtwn/if_urtwn.c Thu May 26 16:39:11 2016 (r300754) @@ -350,6 +350,8 @@ static void urtwn_set_rx_bssid_all(stru static void urtwn_set_gain(struct urtwn_softc *, uint8_t); static void urtwn_scan_start(struct ieee80211com *); static void urtwn_scan_end(struct ieee80211com *); +static void urtwn_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void urtwn_set_channel(struct ieee80211com *); static int urtwn_wme_update(struct ieee80211com *); static void urtwn_update_slot(struct ieee80211com *); @@ -458,6 +460,9 @@ static const struct wme_to_queue { { R92C_EDCA_VO_PARAM, URTWN_BULK_TX_VO} }; +static const uint8_t urtwn_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static int urtwn_match(device_t self) { @@ -492,7 +497,6 @@ urtwn_attach(device_t self) struct usb_attach_arg *uaa = device_get_ivars(self); struct urtwn_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - uint8_t bands[IEEE80211_MODE_BYTES]; int error; device_set_usb_desc(self); @@ -608,17 +612,16 @@ urtwn_attach(device_t self) ic->ic_rxstream = sc->nrxchains; } - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - if (urtwn_enable_11n) - setbit(bands, IEEE80211_MODE_11NG); - ieee80211_init_channels(ic, NULL, bands); + /* XXX TODO: setup regdomain if R92C_CHANNEL_PLAN_BY_HW bit is set. */ + + urtwn_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = urtwn_raw_xmit; ic->ic_scan_start = urtwn_scan_start; ic->ic_scan_end = urtwn_scan_end; + ic->ic_getradiocaps = urtwn_getradiocaps; ic->ic_set_channel = urtwn_set_channel; ic->ic_transmit = urtwn_transmit; ic->ic_parent = urtwn_parent; @@ -4744,6 +4747,21 @@ urtwn_scan_end(struct ieee80211com *ic) } static void +urtwn_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); + if (urtwn_enable_11n) + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + urtwn_chan_2ghz, nitems(urtwn_chan_2ghz), bands, 0); +} + +static void urtwn_set_channel(struct ieee80211com *ic) { struct urtwn_softc *sc = ic->ic_softc; Modified: head/sys/dev/urtwn/if_urtwnreg.h ============================================================================== --- head/sys/dev/urtwn/if_urtwnreg.h Thu May 26 16:15:10 2016 (r300753) +++ head/sys/dev/urtwn/if_urtwnreg.h Thu May 26 16:39:11 2016 (r300754) @@ -1018,6 +1018,8 @@ struct r92c_rom { uint8_t rf_opt3; uint8_t rf_opt4; uint8_t channel_plan; +#define R92C_CHANNEL_PLAN_BY_HW 0x80 + uint8_t version; uint8_t customer_id; } __packed; Modified: head/sys/dev/usb/wlan/if_rsu.c ============================================================================== --- head/sys/dev/usb/wlan/if_rsu.c Thu May 26 16:15:10 2016 (r300753) +++ head/sys/dev/usb/wlan/if_rsu.c Thu May 26 16:39:11 2016 (r300754) @@ -170,6 +170,8 @@ static struct ieee80211vap * static void rsu_vap_delete(struct ieee80211vap *); static void rsu_scan_start(struct ieee80211com *); static void rsu_scan_end(struct ieee80211com *); +static void rsu_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void rsu_set_channel(struct ieee80211com *); static void rsu_update_mcast(struct ieee80211com *); static int rsu_alloc_rx_list(struct rsu_softc *); @@ -252,6 +254,9 @@ MODULE_DEPEND(rsu, firmware, 1, 1, 1); MODULE_VERSION(rsu, 1); USB_PNP_HOST_INFO(rsu_devs); +static const uint8_t rsu_chan_2ghz[] = + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + static uint8_t rsu_wme_ac_xfer_map[4] = { [WME_AC_BE] = RSU_BULK_TX_BE_BK, [WME_AC_BK] = RSU_BULK_TX_BE_BK, @@ -404,7 +409,6 @@ rsu_attach(device_t self) struct rsu_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; int error; - uint8_t bands[IEEE80211_MODE_BYTES]; uint8_t iface_index; struct usb_interface *iface; const char *rft; @@ -534,18 +538,14 @@ rsu_attach(device_t self) ic->ic_rxstream = sc->sc_nrxstream; } - /* Set supported .11b and .11g rates. */ - memset(bands, 0, sizeof(bands)); - setbit(bands, IEEE80211_MODE_11B); - setbit(bands, IEEE80211_MODE_11G); - if (sc->sc_ht) - setbit(bands, IEEE80211_MODE_11NG); - ieee80211_init_channels(ic, NULL, bands); + rsu_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); ieee80211_ifattach(ic); ic->ic_raw_xmit = rsu_raw_xmit; ic->ic_scan_start = rsu_scan_start; ic->ic_scan_end = rsu_scan_end; + ic->ic_getradiocaps = rsu_getradiocaps; ic->ic_set_channel = rsu_set_channel; ic->ic_vap_create = rsu_vap_create; ic->ic_vap_delete = rsu_vap_delete; @@ -699,6 +699,23 @@ rsu_scan_end(struct ieee80211com *ic) } static void +rsu_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct rsu_softc *sc = ic->ic_softc; + uint8_t bands[IEEE80211_MODE_BYTES]; + + /* Set supported .11b and .11g rates. */ + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + if (sc->sc_ht) + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_add_channel_list_2ghz(chans, maxchans, nchans, + rsu_chan_2ghz, nitems(rsu_chan_2ghz), bands, 0); +} + +static void rsu_set_channel(struct ieee80211com *ic __unused) { /* We are unable to switch channels, yet. */