Commit e11602b7 authored by Sujith's avatar Sujith Committed by John W. Linville

ath9k: Handle channel initialization for AP mode

Hostapd now passes the HT parameters through the config()
callback, use these to set the appropriate channel in AP mode.
Signed-off-by: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent cb3da8cc
...@@ -622,35 +622,35 @@ static int ath_get_channel(struct ath_softc *sc, ...@@ -622,35 +622,35 @@ static int ath_get_channel(struct ath_softc *sc,
return -1; return -1;
} }
/* ext_chan_offset: (-1, 0, 1) (below, none, above) */
static u32 ath_get_extchanmode(struct ath_softc *sc, static u32 ath_get_extchanmode(struct ath_softc *sc,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
struct ieee80211_bss_conf *bss_conf) int ext_chan_offset,
enum ath9k_ht_macmode tx_chan_width)
{ {
u32 chanmode = 0; u32 chanmode = 0;
u8 ext_chan_offset = bss_conf->ht.secondary_channel_offset;
enum ath9k_ht_macmode tx_chan_width = (bss_conf->ht.width_40_ok) ?
ATH9K_HT_MACMODE_2040 : ATH9K_HT_MACMODE_20;
switch (chan->band) { switch (chan->band) {
case IEEE80211_BAND_2GHZ: case IEEE80211_BAND_2GHZ:
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) && if ((ext_chan_offset == 0) &&
(tx_chan_width == ATH9K_HT_MACMODE_20)) (tx_chan_width == ATH9K_HT_MACMODE_20))
chanmode = CHANNEL_G_HT20; chanmode = CHANNEL_G_HT20;
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) && if ((ext_chan_offset == 1) &&
(tx_chan_width == ATH9K_HT_MACMODE_2040)) (tx_chan_width == ATH9K_HT_MACMODE_2040))
chanmode = CHANNEL_G_HT40PLUS; chanmode = CHANNEL_G_HT40PLUS;
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) && if ((ext_chan_offset == -1) &&
(tx_chan_width == ATH9K_HT_MACMODE_2040)) (tx_chan_width == ATH9K_HT_MACMODE_2040))
chanmode = CHANNEL_G_HT40MINUS; chanmode = CHANNEL_G_HT40MINUS;
break; break;
case IEEE80211_BAND_5GHZ: case IEEE80211_BAND_5GHZ:
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) && if ((ext_chan_offset == 0) &&
(tx_chan_width == ATH9K_HT_MACMODE_20)) (tx_chan_width == ATH9K_HT_MACMODE_20))
chanmode = CHANNEL_A_HT20; chanmode = CHANNEL_A_HT20;
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) && if ((ext_chan_offset == 1) &&
(tx_chan_width == ATH9K_HT_MACMODE_2040)) (tx_chan_width == ATH9K_HT_MACMODE_2040))
chanmode = CHANNEL_A_HT40PLUS; chanmode = CHANNEL_A_HT40PLUS;
if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) && if ((ext_chan_offset == -1) &&
(tx_chan_width == ATH9K_HT_MACMODE_2040)) (tx_chan_width == ATH9K_HT_MACMODE_2040))
chanmode = CHANNEL_A_HT40MINUS; chanmode = CHANNEL_A_HT40MINUS;
break; break;
...@@ -841,6 +841,18 @@ static void ath9k_ht_conf(struct ath_softc *sc, ...@@ -841,6 +841,18 @@ static void ath9k_ht_conf(struct ath_softc *sc,
} }
} }
static inline int ath_sec_offset(u8 ext_offset)
{
if (ext_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE)
return 0;
else if (ext_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
return 1;
else if (ext_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW)
return -1;
return 0;
}
static void ath9k_bss_assoc_info(struct ath_softc *sc, static void ath9k_bss_assoc_info(struct ath_softc *sc,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *bss_conf) struct ieee80211_bss_conf *bss_conf)
...@@ -892,13 +904,14 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc, ...@@ -892,13 +904,14 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
} }
if (hw->conf.ht.enabled) { if (hw->conf.ht.enabled) {
sc->sc_ah->ah_channels[pos].chanmode = int offset =
ath_get_extchanmode(sc, curchan, bss_conf); ath_sec_offset(bss_conf->ht.secondary_channel_offset);
sc->tx_chan_width = (bss_conf->ht.width_40_ok) ?
ATH9K_HT_MACMODE_2040 : ATH9K_HT_MACMODE_20;
if (bss_conf->ht.width_40_ok) sc->sc_ah->ah_channels[pos].chanmode =
sc->tx_chan_width = ATH9K_HT_MACMODE_2040; ath_get_extchanmode(sc, curchan,
else offset, sc->tx_chan_width);
sc->tx_chan_width = ATH9K_HT_MACMODE_20;
} else { } else {
sc->sc_ah->ah_channels[pos].chanmode = sc->sc_ah->ah_channels[pos].chanmode =
(curchan->band == IEEE80211_BAND_2GHZ) ? (curchan->band == IEEE80211_BAND_2GHZ) ?
...@@ -2171,9 +2184,22 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -2171,9 +2184,22 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
(curchan->band == IEEE80211_BAND_2GHZ) ? (curchan->band == IEEE80211_BAND_2GHZ) ?
CHANNEL_G : CHANNEL_A; CHANNEL_G : CHANNEL_A;
if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) if ((sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) &&
(conf->ht.enabled)) {
sc->tx_chan_width = (!!conf->ht.sec_chan_offset) ?
ATH9K_HT_MACMODE_2040 : ATH9K_HT_MACMODE_20;
sc->sc_ah->ah_channels[pos].chanmode =
ath_get_extchanmode(sc, curchan,
conf->ht.sec_chan_offset,
sc->tx_chan_width);
}
if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) {
DPRINTF(sc, ATH_DBG_FATAL, DPRINTF(sc, ATH_DBG_FATAL,
"%s: Unable to set channel\n", __func__); "%s: Unable to set channel\n", __func__);
return -EINVAL;
}
} }
if (changed & IEEE80211_CONF_CHANGE_HT) if (changed & IEEE80211_CONF_CHANGE_HT)
......
...@@ -1304,6 +1304,38 @@ static void ath_rc_tx_status(struct ath_softc *sc, ...@@ -1304,6 +1304,38 @@ static void ath_rc_tx_status(struct ath_softc *sc,
xretries, long_retry); xretries, long_retry);
} }
static struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
enum ieee80211_band band,
bool is_ht, bool is_cw_40)
{
int mode = 0;
switch(band) {
case IEEE80211_BAND_2GHZ:
mode = ATH9K_MODE_11G;
if (is_ht)
mode = ATH9K_MODE_11NG_HT20;
if (is_cw_40)
mode = ATH9K_MODE_11NG_HT40PLUS;
break;
case IEEE80211_BAND_5GHZ:
mode = ATH9K_MODE_11A;
if (is_ht)
mode = ATH9K_MODE_11NA_HT20;
if (is_cw_40)
mode = ATH9K_MODE_11NA_HT40PLUS;
break;
default:
DPRINTF(sc, ATH_DBG_RATE, "Invalid band\n");
return NULL;
}
BUG_ON(mode >= ATH9K_MODE_MAX);
DPRINTF(sc, ATH_DBG_RATE, "Choosing rate table for mode: %d\n", mode);
return sc->hw_rate_table[mode];
}
static void ath_rc_init(struct ath_softc *sc, static void ath_rc_init(struct ath_softc *sc,
struct ath_rate_priv *ath_rc_priv, struct ath_rate_priv *ath_rc_priv,
struct ieee80211_supported_band *sband, struct ieee80211_supported_band *sband,
...@@ -1314,16 +1346,25 @@ static void ath_rc_init(struct ath_softc *sc, ...@@ -1314,16 +1346,25 @@ static void ath_rc_init(struct ath_softc *sc,
u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
u8 i, j, k, hi = 0, hthi = 0; u8 i, j, k, hi = 0, hthi = 0;
/* FIXME: Adhoc */
if ((sc->sc_ah->ah_opmode == ATH9K_M_STA) ||
(sc->sc_ah->ah_opmode == ATH9K_M_IBSS)) {
bool is_cw_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
rate_table = ath_choose_rate_table(sc, sband->band,
sta->ht_cap.ht_supported,
is_cw_40);
} else if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) {
/* sc_curmode would be set on init through config() */
rate_table = sc->hw_rate_table[sc->sc_curmode]; rate_table = sc->hw_rate_table[sc->sc_curmode];
}
if (sta->ht_cap.ht_supported) { if (!rate_table) {
if (sband->band == IEEE80211_BAND_2GHZ) DPRINTF(sc, ATH_DBG_FATAL, "Rate table not initialized\n");
rate_table = sc->hw_rate_table[ATH9K_MODE_11NG_HT20]; return;
else }
rate_table = sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
if (sta->ht_cap.ht_supported) {
ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG); ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG);
if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
ath_rc_priv->ht_cap |= WLAN_RC_40_FLAG; ath_rc_priv->ht_cap |= WLAN_RC_40_FLAG;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment