-u_int32_t ath_chan2flags(struct ieee80211_channel *chan,
- struct ath_softc *sc)
-{
- struct ieee80211_hw *hw = sc->hw;
- struct ath_ht_info *ht_info = &sc->sc_ht_info;
-
- if (sc->sc_scanning) {
- if (chan->band == IEEE80211_BAND_5GHZ) {
- if (ath_check_chanflags(chan, CHANNEL_A_HT20, sc))
- return CHANNEL_A_HT20;
- else
- return CHANNEL_A;
- } else {
- if (ath_check_chanflags(chan, CHANNEL_G_HT20, sc))
- return CHANNEL_G_HT20;
- else if (ath_check_chanflags(chan, CHANNEL_G, sc))
- return CHANNEL_G;
- else
- return CHANNEL_B;
- }
- } else {
- if (chan->band == IEEE80211_BAND_2GHZ) {
- if (!hw->conf.ht_conf.ht_supported) {
- if (ath_check_chanflags(chan, CHANNEL_G, sc))
- return CHANNEL_G;
- else
- return CHANNEL_B;
- }
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_NONE) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_20))
- return CHANNEL_G_HT20;
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_ABOVE) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
- return CHANNEL_G_HT40PLUS;
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_BELOW) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
- return CHANNEL_G_HT40MINUS;
- return CHANNEL_B;
- } else {
- if (!hw->conf.ht_conf.ht_supported)
- return CHANNEL_A;
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_NONE) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_20))
- return CHANNEL_A_HT20;
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_ABOVE) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
- return CHANNEL_A_HT40PLUS;
- if ((ht_info->ext_chan_offset ==
- IEEE80211_HT_IE_CHA_SEC_BELOW) &&
- (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
- return CHANNEL_A_HT40MINUS;
- return CHANNEL_A;
- }
- }
-}
-
-void ath_setup_channel_list(struct ath_softc *sc,
- enum ieee80211_clist_cmd cmd,
- const struct hal_channel *chans,
- int nchan,
- const u_int8_t *regclassids,
- u_int nregclass,
- int countrycode)
-{
- const struct hal_channel *c;
- int i, a = 0, b = 0, flags;
-
- if (countrycode == CTRY_DEFAULT) {
- for (i = 0; i < nchan; i++) {
- c = &chans[i];
- flags = 0;
- /* XXX: Ah! make more readable, and
- * idententation friendly */
- if (IS_CHAN_2GHZ(c) &&
- !test_update_chan(IEEE80211_BAND_2GHZ, c, sc)) {
- sc->channels[IEEE80211_BAND_2GHZ][a].band =
- IEEE80211_BAND_2GHZ;
- sc->channels[IEEE80211_BAND_2GHZ][a].
- center_freq =
- c->channel;
- sc->channels[IEEE80211_BAND_2GHZ][a].max_power =
- c->maxTxPower;
- sc->channels[IEEE80211_BAND_2GHZ][a].hw_value =
- c->channelFlags;
-
- if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
- flags |= IEEE80211_CHAN_NO_IBSS;
- if (IS_CHAN_PASSIVE(c))
- flags |= IEEE80211_CHAN_PASSIVE_SCAN;
-
- sc->channels[IEEE80211_BAND_2GHZ][a].flags =
- flags;
- sc->sbands[IEEE80211_BAND_2GHZ].n_channels++;
- a++;
- DPRINTF(sc, ATH_DBG_CONFIG,
- "%s: 2MHz channel: %d, "
- "channelFlags: 0x%x\n",
- __func__,
- c->channel,
- c->channelFlags);
- } else if (IS_CHAN_5GHZ(c) &&
- !test_update_chan(IEEE80211_BAND_5GHZ, c, sc)) {
- sc->channels[IEEE80211_BAND_5GHZ][b].band =
- IEEE80211_BAND_5GHZ;
- sc->channels[IEEE80211_BAND_5GHZ][b].
- center_freq =
- c->channel;
- sc->channels[IEEE80211_BAND_5GHZ][b].max_power =
- c->maxTxPower;
- sc->channels[IEEE80211_BAND_5GHZ][b].hw_value =
- c->channelFlags;
-
- if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
- flags |= IEEE80211_CHAN_NO_IBSS;
- if (IS_CHAN_PASSIVE(c))
- flags |= IEEE80211_CHAN_PASSIVE_SCAN;
-
- sc->channels[IEEE80211_BAND_5GHZ][b].
- flags = flags;
- sc->sbands[IEEE80211_BAND_5GHZ].n_channels++;
- b++;
- DPRINTF(sc, ATH_DBG_CONFIG,
- "%s: 5MHz channel: %d, "
- "channelFlags: 0x%x\n",
- __func__,
- c->channel,
- c->channelFlags);
- }
- }
- }
-}
-