From owner-svn-src-all@freebsd.org Thu May 19 22:14:36 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 71AD6B42C72; Thu, 19 May 2016 22:14:36 +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 4935E178C; Thu, 19 May 2016 22:14:36 +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 u4JMEZpb030573; Thu, 19 May 2016 22:14:35 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4JMEZ4E030571; Thu, 19 May 2016 22:14:35 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605192214.u4JMEZ4E030571@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:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300238 - head/sys/dev/wi 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:14:36 -0000 Author: avos Date: Thu May 19 22:14:35 2016 New Revision: 300238 URL: https://svnweb.freebsd.org/changeset/base/300238 Log: wi: switch to ieee80211_add_channel() - Convert to ieee80211_add_channel(). - Add ic_getradiocaps() method. Differential Revision: https://reviews.freebsd.org/D6235 Modified: head/sys/dev/wi/if_wi.c head/sys/dev/wi/if_wivar.h Modified: head/sys/dev/wi/if_wi.c ============================================================================== --- head/sys/dev/wi/if_wi.c Thu May 19 22:02:03 2016 (r300237) +++ head/sys/dev/wi/if_wi.c Thu May 19 22:14:35 2016 (r300238) @@ -155,9 +155,12 @@ static int wi_mwrite_bap(struct wi_soft static int wi_read_rid(struct wi_softc *, int, void *, int *); static int wi_write_rid(struct wi_softc *, int, const void *, int); static int wi_write_appie(struct wi_softc *, int, const struct ieee80211_appie *); +static u_int16_t wi_read_chanmask(struct wi_softc *); static void wi_scan_start(struct ieee80211com *); static void wi_scan_end(struct ieee80211com *); +static void wi_getradiocaps(struct ieee80211com *, int, int *, + struct ieee80211_channel[]); static void wi_set_channel(struct ieee80211com *); static __inline int @@ -335,23 +338,9 @@ wi_attach(device_t dev) * Query the card for available channels and setup the * channel table. We assume these are all 11b channels. */ - buflen = sizeof(val); - if (wi_read_rid(sc, WI_RID_CHANNEL_LIST, &val, &buflen) != 0) - val = htole16(0x1fff); /* assume 1-13 */ - KASSERT(val != 0, ("wi_attach: no available channels listed!")); - - val <<= 1; /* shift for base 1 indices */ - for (i = 1; i < 16; i++) { - struct ieee80211_channel *c; - - if (!isset((u_int8_t*)&val, i)) - continue; - c = &ic->ic_channels[ic->ic_nchans++]; - c->ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_B); - c->ic_flags = IEEE80211_CHAN_B; - c->ic_ieee = i; - /* XXX txpowers? */ - } + sc->sc_chanmask = wi_read_chanmask(sc); + wi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, + ic->ic_channels); /* * Set flags based on firmware version. @@ -439,6 +428,7 @@ wi_attach(device_t dev) ic->ic_raw_xmit = wi_raw_xmit; ic->ic_scan_start = wi_scan_start; ic->ic_scan_end = wi_scan_end; + ic->ic_getradiocaps = wi_getradiocaps; ic->ic_set_channel = wi_set_channel; ic->ic_vap_create = wi_vap_create; ic->ic_vap_delete = wi_vap_delete; @@ -697,6 +687,26 @@ wi_stop(struct wi_softc *sc, int disable } static void +wi_getradiocaps(struct ieee80211com *ic, + int maxchans, int *nchans, struct ieee80211_channel chans[]) +{ + struct wi_softc *sc = ic->ic_softc; + u_int8_t bands[IEEE80211_MODE_MAX]; + int i; + + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + + for (i = 1; i < 16; i++) { + if (sc->sc_chanmask & (1 << i)) { + /* XXX txpowers? */ + ieee80211_add_channel(chans, maxchans, nchans, + i, 0, 0, 0, bands); + } + } +} + +static void wi_set_channel(struct ieee80211com *ic) { struct wi_softc *sc = ic->ic_softc; @@ -1988,6 +1998,22 @@ wi_write_appie(struct wi_softc *sc, int return wi_write_rid(sc, rid, buf, ie->ie_len + sizeof(uint16_t)); } +static u_int16_t +wi_read_chanmask(struct wi_softc *sc) +{ + u_int16_t val; + int buflen; + + buflen = sizeof(val); + if (wi_read_rid(sc, WI_RID_CHANNEL_LIST, &val, &buflen) != 0) + val = htole16(0x1fff); /* assume 1-13 */ + KASSERT(val != 0, ("%s: no available channels listed!", __func__)); + + val <<= 1; /* shift for base 1 indices */ + + return (val); +} + int wi_alloc(device_t dev, int rid) { Modified: head/sys/dev/wi/if_wivar.h ============================================================================== --- head/sys/dev/wi/if_wivar.h Thu May 19 22:02:03 2016 (r300237) +++ head/sys/dev/wi/if_wivar.h Thu May 19 22:14:35 2016 (r300238) @@ -114,6 +114,7 @@ struct wi_softc { u_int16_t sc_portnum; u_int16_t sc_encryption; u_int16_t sc_monitor_port; + u_int16_t sc_chanmask; /* RSSI interpretation */ u_int16_t sc_min_rssi; /* clamp sc_min_rssi < RSSI */