[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.
This commit is contained in:
Adrian Chadd 2016-12-03 02:45:18 +00:00
parent 3d77b88dff
commit 4774b99992
2 changed files with 54 additions and 0 deletions

View File

@ -1169,6 +1169,53 @@ ieee80211_add_channel_ht40(struct ieee80211_channel chans[], int maxchans,
return (error);
}
/*
* 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.

View File

@ -668,6 +668,9 @@ int ieee80211_add_channel(struct ieee80211_channel[], int, int *,
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 ieee80211com *,
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,