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,
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to