From owner-svn-src-all@freebsd.org Sat Dec 3 02:45:19 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 DB26DC63314; Sat, 3 Dec 2016 02:45:19 +0000 (UTC) (envelope-from adrian@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 B5CE23F9; Sat, 3 Dec 2016 02:45:19 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB32jIhS059275; Sat, 3 Dec 2016 02:45:18 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB32jI4L059273; Sat, 3 Dec 2016 02:45:18 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201612030245.uB32jI4L059273@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 3 Dec 2016 02:45:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309465 - head/sys/net80211 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.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, 03 Dec 2016 02:45:20 -0000 Author: adrian Date: Sat Dec 3 02:45:18 2016 New Revision: 309465 URL: https://svnweb.freebsd.org/changeset/base/309465 Log: [net80211] prepare for 11ac aware NICs that want to know per-vdev channel and centre frequencies. * ic_freq is the centre of the primary channel, not the centre of the HT40/HT80/etc channel. Add a method to access that. * Add a method to access the centre of the primary channel, including knowing the centre of the 5/10/20/40/80, versus the primary channel. Ie, it's the centre of the 40, 80, 160MHz channel. * Add a method to access the centre frequency of the secondary 80MHz channel - we don't support VHT yet, but when we do. * Add methods to access the current channel and the per-dev desired channel. Ideally drivers that do full offload with a per-vap channel configuration should use the vap channel, NOT ic_curchan. Non-offload drivers that require net80211 to change the channel should be accessing ic_curchan. Modified: head/sys/net80211/ieee80211.c head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211.c ============================================================================== --- head/sys/net80211/ieee80211.c Sat Dec 3 02:24:15 2016 (r309464) +++ head/sys/net80211/ieee80211.c Sat Dec 3 02:45:18 2016 (r309465) @@ -1170,6 +1170,53 @@ ieee80211_add_channel_ht40(struct ieee80 } /* + * Fetch the center frequency for the primary channel. + */ +uint32_t +ieee80211_get_channel_center_freq(const struct ieee80211_channel *c) +{ + + return (c->ic_freq); +} + +/* + * Fetch the center frequency for the primary BAND channel. + * + * For 5, 10, 20MHz channels it'll be the normally configured channel + * frequency. + * + * For 40MHz, 80MHz, 160Mhz channels it'll the the centre of the + * wide channel, not the centre of the primary channel (that's ic_freq). + * + * For 80+80MHz channels this will be the centre of the primary + * 80MHz channel; the secondary 80MHz channel will be center_freq2(). + */ + +uint32_t +ieee80211_get_channel_center_freq1(const struct ieee80211_channel *c) +{ + + if (IEEE80211_IS_CHAN_HT40U(c)) { + return (c->ic_freq + 10); + } + if (IEEE80211_IS_CHAN_HT40D(c)) { + return (c->ic_freq - 10); + } + + return (c->ic_freq); +} + +/* + * For now, no 80+80 support; this is zero. + */ +uint32_t +ieee80211_get_channel_center_freq2(const struct ieee80211_channel *c) +{ + + return (0); +} + +/* * Adds channels into specified channel list (ieee[] array must be sorted). * Channels are already sorted. */ Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Sat Dec 3 02:24:15 2016 (r309464) +++ head/sys/net80211/ieee80211_var.h Sat Dec 3 02:45:18 2016 (r309465) @@ -668,6 +668,9 @@ int ieee80211_add_channel(struct ieee802 uint8_t, uint16_t, int8_t, uint32_t, const uint8_t[]); int ieee80211_add_channel_ht40(struct ieee80211_channel[], int, int *, uint8_t, int8_t, uint32_t); +uint32_t ieee80211_get_channel_center_freq(const struct ieee80211_channel *); +uint32_t ieee80211_get_channel_center_freq1(const struct ieee80211_channel *); +uint32_t ieee80211_get_channel_center_freq2(const struct ieee80211_channel *); int ieee80211_add_channel_list_2ghz(struct ieee80211_channel[], int, int *, const uint8_t[], int, const uint8_t[], int); int ieee80211_add_channel_list_5ghz(struct ieee80211_channel[], int, int *, @@ -684,6 +687,10 @@ uint32_t ieee80211_mac_hash(const struct const uint8_t addr[IEEE80211_ADDR_LEN]); char ieee80211_channel_type_char(const struct ieee80211_channel *c); +#define ieee80211_get_current_channel(_ic) ((_ic)->ic_curchan) +#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan) +#define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan) + void ieee80211_radiotap_attach(struct ieee80211com *, struct ieee80211_radiotap_header *th, int tlen, uint32_t tx_radiotap,