Skip to content

Commit

Permalink
mac80211: rewrite HT handling
Browse files Browse the repository at this point in the history
The HT handling has the following deficiencies, which I've
(partially) fixed:
 * it always uses the AP info even if there is no AP,
   hence has no chance of working as an AP
 * it pretends to be HW config, but really is per-BSS
 * channel sanity checking is left to the drivers
 * it generally lets the driver control too much

HT enabling is still wrong with this patch if you have more than
one virtual STA mode interface, but that never happens currently.
Once WDS, IBSS or AP/VLAN gets HT capabilities, it will also be
wrong, see the comment in ieee80211_enable_ht().

Additionally, this fixes a number of bugs:
 * mac80211: ieee80211_set_disassoc doesn't notify the driver any
             more since the refactoring
 * iwl-agn-rs: always uses the HT capabilities from the wrong stuff
               mac80211 gives it rather than the actual peer STA
 * ath9k: a number of bugs resulting from the broken HT API

I'm not entirely happy with putting the HT capabilities into
struct ieee80211_sta as restricted to our own HT TX capabilities,
but I see no cleaner solution for now.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Oct 31, 2008
1 parent bda3933 commit ae5eb02
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 274 deletions.
6 changes: 3 additions & 3 deletions drivers/net/wireless/ath9k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ void ath_rx_cleanup(struct ath_softc *sc);
int ath_rx_tasklet(struct ath_softc *sc, int flush);
int ath_rx_input(struct ath_softc *sc,
struct ath_node *node,
int is_ampdu,
struct sk_buff *skb,
struct ath_recv_status *rx_status,
enum ATH_RX_TYPE *status);
Expand Down Expand Up @@ -650,6 +649,9 @@ struct ath_node {
u8 an_smmode; /* SM Power save mode */
u8 an_flags;
u8 an_addr[ETH_ALEN];

u16 maxampdu;
u8 mpdudensity;
};

void ath_tx_resume_tid(struct ath_softc *sc,
Expand Down Expand Up @@ -919,8 +921,6 @@ enum RATE_TYPE {

struct ath_ht_info {
enum ath9k_ht_macmode tx_chan_width;
u16 maxampdu;
u8 mpdudensity;
u8 ext_chan_offset;
};

Expand Down
41 changes: 20 additions & 21 deletions drivers/net/wireless/ath9k/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,25 +330,15 @@ static void ath9k_ht_conf(struct ath_softc *sc,
{
struct ath_ht_info *ht_info = &sc->sc_ht_info;

if (bss_conf->assoc_ht) {
ht_info->ext_chan_offset =
bss_conf->ht_bss_conf->bss_cap &
IEEE80211_HT_PARAM_CHA_SEC_OFFSET;

if (!(bss_conf->ht_cap->cap &
IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
(bss_conf->ht_bss_conf->bss_cap &
IEEE80211_HT_PARAM_CHAN_WIDTH_ANY))
if (sc->hw->conf.ht.enabled) {
ht_info->ext_chan_offset = bss_conf->ht.secondary_channel_offset;

if (bss_conf->ht.width_40_ok)
ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040;
else
ht_info->tx_chan_width = ATH9K_HT_MACMODE_20;

ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
bss_conf->ht_cap->ampdu_factor);
ht_info->mpdudensity =
parse_mpdudensity(bss_conf->ht_cap->ampdu_density);

}
}

Expand Down Expand Up @@ -390,7 +380,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;

/* Update chainmask */
ath_update_chainmask(sc, bss_conf->assoc_ht);
ath_update_chainmask(sc, hw->conf.ht.enabled);

DPRINTF(sc, ATH_DBG_CONFIG,
"%s: bssid %pM aid 0x%x\n",
Expand All @@ -408,7 +398,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
return;
}

if (hw->conf.ht_cap.ht_supported)
if (hw->conf.ht.enabled)
sc->sc_ah->ah_channels[pos].chanmode =
ath_get_extchanmode(sc, curchan);
else
Expand Down Expand Up @@ -531,7 +521,6 @@ int _ath_rx_indicate(struct ath_softc *sc,

if (an) {
ath_rx_input(sc, an,
hw->conf.ht_cap.ht_supported,
skb, status, &st);
}
if (!an || (st != ATH_RX_CONSUMED))
Expand Down Expand Up @@ -1241,6 +1230,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
__func__,
curchan->center_freq);

/* Update chainmask */
ath_update_chainmask(sc, conf->ht.enabled);

pos = ath_get_channel(sc, curchan);
if (pos == -1) {
DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid channel\n", __func__);
Expand All @@ -1251,7 +1243,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
(curchan->band == IEEE80211_BAND_2GHZ) ?
CHANNEL_G : CHANNEL_A;

if (sc->sc_curaid && hw->conf.ht_cap.ht_supported)
if (sc->sc_curaid && hw->conf.ht.enabled)
sc->sc_ah->ah_channels[pos].chanmode =
ath_get_extchanmode(sc, curchan);

Expand Down Expand Up @@ -1434,6 +1426,14 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
} else {
ath_node_get(sc, sta->addr);
}

/* XXX: Is this right? Can the capabilities change? */
an = ath_node_find(sc, sta->addr);
an->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
sta->ht_cap.ampdu_factor);
an->mpdudensity =
parse_mpdudensity(sta->ht_cap.ampdu_density);

spin_unlock_irqrestore(&sc->node_lock, flags);
break;
case STA_NOTIFY_REMOVE:
Expand Down Expand Up @@ -1552,9 +1552,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
}

if (changed & BSS_CHANGED_HT) {
DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed HT %d\n",
__func__,
bss_conf->assoc_ht);
DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed HT\n",
__func__);
ath9k_ht_conf(sc, bss_conf);
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ath9k/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv)
struct ath_softc *sc = hw->priv;
u32 capflag = 0;

if (hw->conf.ht_cap.ht_supported) {
if (hw->conf.ht.enabled) {
capflag |= ATH_RC_HT_FLAG | ATH_RC_DS_FLAG;
if (sc->sc_ht_info.tx_chan_width == ATH9K_HT_MACMODE_2040)
capflag |= ATH_RC_CW40_FLAG;
Expand Down Expand Up @@ -1979,7 +1979,7 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,

/* Check if aggregation has to be enabled for this tid */

if (hw->conf.ht_cap.ht_supported) {
if (hw->conf.ht.enabled) {
if (ieee80211_is_data_qos(fc)) {
qc = ieee80211_get_qos_ctl(hdr);
tid = qc[0] & 0xf;
Expand Down Expand Up @@ -2026,9 +2026,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);

ath_setup_rates(sc, sband, sta, ath_rc_priv);
if (sc->hw->conf.flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
if (sc->hw->conf.ht.enabled) {
for (i = 0; i < 77; i++) {
if (sc->hw->conf.ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
if (j == ATH_RATE_MAX)
break;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/ath9k/recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,11 @@ void ath_flushrecv(struct ath_softc *sc)

int ath_rx_input(struct ath_softc *sc,
struct ath_node *an,
int is_ampdu,
struct sk_buff *skb,
struct ath_recv_status *rx_status,
enum ATH_RX_TYPE *status)
{
if (is_ampdu && (sc->sc_flags & SC_OP_RXAGGR)) {
if (sc->sc_flags & SC_OP_RXAGGR) {
*status = ATH_RX_CONSUMED;
return ath_ampdu_input(sc, an, skb, rx_status);
} else {
Expand Down
17 changes: 10 additions & 7 deletions drivers/net/wireless/ath9k/xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ static int ath_tx_prepare(struct ath_softc *sc,
if (ieee80211_is_data(fc) && !txctl->use_minrate) {

/* Enable HT only for DATA frames and not for EAPOL */
txctl->ht = (hw->conf.ht_cap.ht_supported &&
/* XXX why AMPDU only?? */
txctl->ht = (hw->conf.ht.enabled &&
(tx_info->flags & IEEE80211_TX_CTL_AMPDU));

if (is_multicast_ether_addr(hdr->addr1)) {
Expand Down Expand Up @@ -1450,7 +1451,8 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
*/

static u32 ath_lookup_rate(struct ath_softc *sc,
struct ath_buf *bf)
struct ath_buf *bf,
struct ath_atx_tid *tid)
{
const struct ath9k_rate_table *rt = sc->sc_currates;
struct sk_buff *skb;
Expand Down Expand Up @@ -1504,7 +1506,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
* The IE, however can hold upto 65536, which shows up here
* as zero. Ignore 65536 since we are constrained by hw.
*/
maxampdu = sc->sc_ht_info.maxampdu;
maxampdu = tid->an->maxampdu;
if (maxampdu)
aggr_limit = min(aggr_limit, maxampdu);

Expand All @@ -1518,6 +1520,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
*/

static int ath_compute_num_delims(struct ath_softc *sc,
struct ath_atx_tid *tid,
struct ath_buf *bf,
u16 frmlen)
{
Expand Down Expand Up @@ -1545,7 +1548,7 @@ static int ath_compute_num_delims(struct ath_softc *sc,
* required minimum length for subframe. Take into account
* whether high rate is 20 or 40Mhz and half or full GI.
*/
mpdudensity = sc->sc_ht_info.mpdudensity;
mpdudensity = tid->an->mpdudensity;

/*
* If there is no mpdu density restriction, no further calculation
Expand Down Expand Up @@ -1619,7 +1622,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
}

if (!rl) {
aggr_limit = ath_lookup_rate(sc, bf);
aggr_limit = ath_lookup_rate(sc, bf, tid);
rl = 1;
/*
* Is rate dual stream
Expand Down Expand Up @@ -1657,7 +1660,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
* Get the delimiters needed to meet the MPDU
* density for this node.
*/
ndelim = ath_compute_num_delims(sc, bf_first, bf->bf_frmlen);
ndelim = ath_compute_num_delims(sc, tid, bf_first, bf->bf_frmlen);

bpad = PADBYTES(al_delta) + (ndelim << 2);

Expand Down Expand Up @@ -2629,7 +2632,7 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
struct ath_atx_ac *ac;
int tidno, acno;

sc->sc_ht_info.maxampdu = ATH_AMPDU_LIMIT_DEFAULT;
an->maxampdu = ATH_AMPDU_LIMIT_DEFAULT;

/*
* Init per tid tx state
Expand Down
23 changes: 10 additions & 13 deletions drivers/net/wireless/iwlwifi/iwl-agn-rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
s32 rate;
s8 is_green = lq_sta->is_green;

if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
!sta->ht_cap.ht_supported)
if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
return -1;

if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
Expand Down Expand Up @@ -1201,8 +1200,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
u8 is_green = lq_sta->is_green;
s32 rate;

if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
!sta->ht_cap.ht_supported)
if (!conf->ht.enabled || !sta->ht_cap.ht_supported)
return -1;

IWL_DEBUG_RATE("LQ: try to switch to SISO\n");
Expand Down Expand Up @@ -2001,9 +1999,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
* stay with best antenna legacy modulation for a while
* before next round of mode comparisons. */
tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
if (is_legacy(tbl1->lq_type) &&
(!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE)) &&
(lq_sta->action_counter >= 1)) {
if (is_legacy(tbl1->lq_type) && !conf->ht.enabled &&
lq_sta->action_counter >= 1) {
lq_sta->action_counter = 0;
IWL_DEBUG_RATE("LQ: STAY in legacy table\n");
rs_set_stay_in_table(priv, 1, lq_sta);
Expand Down Expand Up @@ -2238,19 +2235,19 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
* active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3),
* supp_rates[] does not; shift to convert format, force 9 MBits off.
*/
lq_sta->active_siso_rate = conf->ht_cap.mcs.rx_mask[0] << 1;
lq_sta->active_siso_rate |= conf->ht_cap.mcs.rx_mask[0] & 0x1;
lq_sta->active_siso_rate = sta->ht_cap.mcs.rx_mask[0] << 1;
lq_sta->active_siso_rate |= sta->ht_cap.mcs.rx_mask[0] & 0x1;
lq_sta->active_siso_rate &= ~((u16)0x2);
lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE;

/* Same here */
lq_sta->active_mimo2_rate = conf->ht_cap.mcs.rx_mask[1] << 1;
lq_sta->active_mimo2_rate |= conf->ht_cap.mcs.rx_mask[1] & 0x1;
lq_sta->active_mimo2_rate = sta->ht_cap.mcs.rx_mask[1] << 1;
lq_sta->active_mimo2_rate |= sta->ht_cap.mcs.rx_mask[1] & 0x1;
lq_sta->active_mimo2_rate &= ~((u16)0x2);
lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE;

lq_sta->active_mimo3_rate = conf->ht_cap.mcs.rx_mask[2] << 1;
lq_sta->active_mimo3_rate |= conf->ht_cap.mcs.rx_mask[2] & 0x1;
lq_sta->active_mimo3_rate = sta->ht_cap.mcs.rx_mask[2] << 1;
lq_sta->active_mimo3_rate |= sta->ht_cap.mcs.rx_mask[2] & 0x1;
lq_sta->active_mimo3_rate &= ~((u16)0x2);
lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE;

Expand Down
39 changes: 26 additions & 13 deletions drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,30 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv)
static void iwl4965_ht_conf(struct iwl_priv *priv,
struct ieee80211_bss_conf *bss_conf)
{
struct ieee80211_sta_ht_cap *ht_conf = bss_conf->ht_cap;
struct ieee80211_ht_bss_info *ht_bss_conf = bss_conf->ht_bss_conf;
struct ieee80211_sta_ht_cap *ht_conf;
struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
struct ieee80211_sta *sta;

IWL_DEBUG_MAC80211("enter: \n");

iwl_conf->is_ht = bss_conf->assoc_ht;

if (!iwl_conf->is_ht)
return;


/*
* It is totally wrong to base global information on something
* that is valid only when associated, alas, this driver works
* that way and I don't know how to fix it.
*/

rcu_read_lock();
sta = ieee80211_find_sta(priv->hw, priv->bssid);
if (!sta) {
rcu_read_unlock();
return;
}
ht_conf = &sta->ht_cap;

if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
Expand All @@ -574,8 +587,8 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,

iwl_conf->supported_chan_width =
!!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
iwl_conf->extension_chan_offset =
ht_bss_conf->bss_cap & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;

iwl_conf->extension_chan_offset = bss_conf->ht.secondary_channel_offset;
/* If no above or below channel supplied disable FAT channel */
if (iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_ABOVE &&
iwl_conf->extension_chan_offset != IEEE80211_HT_PARAM_CHA_SEC_BELOW) {
Expand All @@ -587,15 +600,14 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,

memcpy(&iwl_conf->mcs, &ht_conf->mcs, 16);

iwl_conf->control_channel = ht_bss_conf->primary_channel;
iwl_conf->tx_chan_width =
!!(ht_bss_conf->bss_cap & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY);
iwl_conf->tx_chan_width = bss_conf->ht.width_40_ok;
iwl_conf->ht_protection =
ht_bss_conf->bss_op_mode & IEEE80211_HT_OP_MODE_PROTECTION;
bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
iwl_conf->non_GF_STA_present =
!!(ht_bss_conf->bss_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
!!(bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);

rcu_read_unlock();

IWL_DEBUG_MAC80211("control channel %d\n", iwl_conf->control_channel);
IWL_DEBUG_MAC80211("leave\n");
}

Expand Down Expand Up @@ -2746,6 +2758,8 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, u32 changed)
mutex_lock(&priv->mutex);
IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value);

priv->current_ht_config.is_ht = conf->ht.enabled;

if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) {
IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n");
goto out;
Expand Down Expand Up @@ -3104,7 +3118,6 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
}

if (changes & BSS_CHANGED_HT) {
IWL_DEBUG_MAC80211("HT %d\n", bss_conf->assoc_ht);
iwl4965_ht_conf(priv, bss_conf);
iwl_set_rxon_chain(priv);
}
Expand Down
Loading

0 comments on commit ae5eb02

Please sign in to comment.