X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Fwireless%2Fiwlwifi%2Fiwl-4965-rs.c;h=b608e1ca8b4062fdd101a7c56d2868bcce7cd9a6;hb=fb65f180e02dde224af256b43d3ab2c28b9689d7;hp=660671f17a3b119de44bd5e63180e7eb42570d44;hpb=0c11b4de5d81771ba0fdc8a5d13d59ed01d41252;p=linux-2.6-omap-h63xx.git diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index 660671f17a3..b608e1ca8b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -36,9 +36,10 @@ #include -#include "../net/mac80211/ieee80211_rate.h" +#include "../net/mac80211/rate.h" #include "iwl-4965.h" +#include "iwl-core.h" #include "iwl-helpers.h" #define RS_NAME "iwl-4965-rs" @@ -139,7 +140,7 @@ struct iwl4965_lq_sta { u8 valid_antenna; u8 is_green; u8 is_dup; - u8 phymode; + enum ieee80211_band band; u8 ibss_sta_added; /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ @@ -149,7 +150,7 @@ struct iwl4965_lq_sta { u16 active_mimo_rate; u16 active_rate_basic; - struct iwl4965_link_quality_cmd lq; + struct iwl_link_quality_cmd lq; struct iwl4965_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ #ifdef CONFIG_IWL4965_HT struct iwl4965_traffic_load load[TID_MAX_LOAD_COUNT]; @@ -162,17 +163,17 @@ struct iwl4965_lq_sta { struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; #endif struct iwl4965_rate dbg_fixed; - struct iwl4965_priv *drv; + struct iwl_priv *drv; #endif }; -static void rs_rate_scale_perform(struct iwl4965_priv *priv, +static void rs_rate_scale_perform(struct iwl_priv *priv, struct net_device *dev, struct ieee80211_hdr *hdr, struct sta_info *sta); static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, struct iwl4965_rate *tx_mcs, - struct iwl4965_link_quality_cmd *tbl); + struct iwl_link_quality_cmd *tbl); #ifdef CONFIG_MAC80211_DEBUGFS @@ -229,58 +230,11 @@ static s32 expected_tpt_mimo40MHzSGI[IWL_RATE_COUNT] = { 0, 0, 0, 0, 131, 131, 191, 222, 242, 270, 284, 289, 293 }; -static int iwl4965_lq_sync_callback(struct iwl4965_priv *priv, - struct iwl4965_cmd *cmd, struct sk_buff *skb) -{ - /*We didn't cache the SKB; let the caller free it */ - return 1; -} - static inline u8 iwl4965_rate_get_rate(u32 rate_n_flags) { return (u8)(rate_n_flags & 0xFF); } -static int rs_send_lq_cmd(struct iwl4965_priv *priv, - struct iwl4965_link_quality_cmd *lq, u8 flags) -{ -#ifdef CONFIG_IWL4965_DEBUG - int i; -#endif - struct iwl4965_host_cmd cmd = { - .id = REPLY_TX_LINK_QUALITY_CMD, - .len = sizeof(struct iwl4965_link_quality_cmd), - .meta.flags = flags, - .data = lq, - }; - - if ((lq->sta_id == 0xFF) && - (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) - return -EINVAL; - - if (lq->sta_id == 0xFF) - lq->sta_id = IWL_AP_ID; - - IWL_DEBUG_RATE("lq station id 0x%x\n", lq->sta_id); - IWL_DEBUG_RATE("lq dta 0x%X 0x%X\n", - lq->general_params.single_stream_ant_msk, - lq->general_params.dual_stream_ant_msk); -#ifdef CONFIG_IWL4965_DEBUG - for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IWL_DEBUG_RATE("lq index %d 0x%X\n", - i, lq->rs_table[i].rate_n_flags); -#endif - - if (flags & CMD_ASYNC) - cmd.meta.u.callback = iwl4965_lq_sync_callback; - - if (iwl4965_is_associated(priv) && priv->assoc_station_added && - priv->lq_mngr.lq_ready) - return iwl4965_send_cmd(priv, &cmd); - - return 0; -} - static void rs_rate_scale_clear_window(struct iwl4965_rate_scale_data *window) { window->data = 0; @@ -388,7 +342,7 @@ static u32 rs_tl_get_load(struct iwl4965_lq_sta *lq_data, u8 tid) return tl->total; } -static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv, +static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_data, u8 tid, struct sta_info *sta) { @@ -396,7 +350,7 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv, DECLARE_MAC_BUF(mac); spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); - state = sta->ampdu_mlme.tid_tx[tid].state; + state = sta->ampdu_mlme.tid_state_tx[tid]; spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); if (state == HT_AGG_STATE_IDLE && @@ -407,7 +361,7 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv, } } -static void rs_tl_turn_on_agg(struct iwl4965_priv *priv, u8 tid, +static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, struct iwl4965_lq_sta *lq_data, struct sta_info *sta) { @@ -563,13 +517,14 @@ static void rs_mcs_from_tbl(struct iwl4965_rate *mcs_rate, * fill "search" or "active" tx mode table. */ static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, - int phymode, struct iwl4965_scale_tbl_info *tbl, + enum ieee80211_band band, + struct iwl4965_scale_tbl_info *tbl, int *rate_idx) { int index; u32 ant_msk; - index = iwl4965_rate_index_from_plcp(mcs_rate->rate_n_flags); + index = iwl4965_hwrate_to_plcp_idx(mcs_rate->rate_n_flags); if (index == IWL_RATE_INVALID) { *rate_idx = -1; @@ -588,7 +543,7 @@ static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, tbl->lq_type = LQ_NONE; else { - if (phymode == MODE_IEEE80211A) + if (band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else tbl->lq_type = LQ_G; @@ -657,7 +612,7 @@ static inline void rs_toggle_antenna(struct iwl4965_rate *new_rate, } } -static inline u8 rs_use_green(struct iwl4965_priv *priv, +static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf) { #ifdef CONFIG_IWL4965_HT @@ -766,7 +721,7 @@ static void rs_get_lower_rate(struct iwl4965_lq_sta *lq_sta, if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { switch_to_legacy = 1; scale_index = rs_ht_to_legacy[scale_index]; - if (lq_sta->phymode == MODE_IEEE80211A) + if (lq_sta->band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else tbl->lq_type = LQ_G; @@ -784,7 +739,7 @@ static void rs_get_lower_rate(struct iwl4965_lq_sta *lq_sta, /* Mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { /* supp_rates has no CCK bits in A mode */ - if (lq_sta->phymode == (u8) MODE_IEEE80211A) + if (lq_sta->band == IEEE80211_BAND_5GHZ) rate_mask = (u16)(rate_mask & (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); else @@ -817,11 +772,12 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, u8 retries; int rs_index, index = 0; struct iwl4965_lq_sta *lq_sta; - struct iwl4965_link_quality_cmd *table; + struct iwl_link_quality_cmd *table; struct sta_info *sta; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; + struct iwl_priv *priv = (struct iwl_priv *)priv_rate; struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); + struct ieee80211_hw *hw = local_to_hw(local); struct iwl4965_rate_scale_data *window = NULL; struct iwl4965_rate_scale_data *search_win = NULL; struct iwl4965_rate tx_mcs; @@ -846,23 +802,22 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, if (retries > 15) retries = 15; + rcu_read_lock(); sta = sta_info_get(local, hdr->addr1); - if (!sta || !sta->rate_ctrl_priv) { - if (sta) - sta_info_put(sta); - return; - } + if (!sta || !sta->rate_ctrl_priv) + goto out; + lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; if (!priv->lq_mngr.lq_ready) - return; + goto out; if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && !lq_sta->ibss_sta_added) - return; + goto out; table = &lq_sta->lq; active_index = lq_sta->active_tbl; @@ -883,17 +838,6 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, search_win = (struct iwl4965_rate_scale_data *) &(search_tbl->win[0]); - tx_mcs.rate_n_flags = tx_resp->control.tx_rate; - - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, - &tbl_type, &rs_index); - if ((rs_index < 0) || (rs_index >= IWL_RATE_COUNT)) { - IWL_DEBUG_RATE("bad rate index at: %d rate 0x%X\n", - rs_index, tx_mcs.rate_n_flags); - sta_info_put(sta); - return; - } - /* * Ignore this Tx frame response if its initial rate doesn't match * that of latest Link Quality command. There may be stragglers @@ -902,14 +846,29 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, * to check "search" mode, or a prior "search" mode after we've moved * to a new "search" mode (which might become the new "active" mode). */ - if (retries && - (tx_mcs.rate_n_flags != - le32_to_cpu(table->rs_table[0].rate_n_flags))) { - IWL_DEBUG_RATE("initial rate does not match 0x%x 0x%x\n", - tx_mcs.rate_n_flags, - le32_to_cpu(table->rs_table[0].rate_n_flags)); - sta_info_put(sta); - return; + tx_mcs.rate_n_flags = le32_to_cpu(table->rs_table[0].rate_n_flags); + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, &tbl_type, &rs_index); + if (priv->band == IEEE80211_BAND_5GHZ) + rs_index -= IWL_FIRST_OFDM_RATE; + + if ((tx_resp->control.tx_rate == NULL) || + (tbl_type.is_SGI ^ + !!(tx_resp->control.flags & IEEE80211_TXCTL_SHORT_GI)) || + (tbl_type.is_fat ^ + !!(tx_resp->control.flags & IEEE80211_TXCTL_40_MHZ_WIDTH)) || + (tbl_type.is_dup ^ + !!(tx_resp->control.flags & IEEE80211_TXCTL_DUP_DATA)) || + (tbl_type.antenna_type ^ + tx_resp->control.antenna_sel_tx) || + (!!(tx_mcs.rate_n_flags & RATE_MCS_HT_MSK) ^ + !!(tx_resp->control.flags & IEEE80211_TXCTL_OFDM_HT)) || + (!!(tx_mcs.rate_n_flags & RATE_MCS_GF_MSK) ^ + !!(tx_resp->control.flags & IEEE80211_TXCTL_GREEN_FIELD)) || + (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != + tx_resp->control.tx_rate->bitrate)) { + IWL_DEBUG_RATE("initial rate does not match 0x%x\n", + tx_mcs.rate_n_flags); + goto out; } /* Update frame history window with "failure" for each Tx retry. */ @@ -918,7 +877,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, * Each tx attempt steps one entry deeper in the rate table. */ tx_mcs.rate_n_flags = le32_to_cpu(table->rs_table[index].rate_n_flags); - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, &tbl_type, &rs_index); /* If type matches "search" table, @@ -958,14 +917,8 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, * if Tx was successful first try, use original rate, * else look up the rate that was, finally, successful. */ - if (!tx_resp->retry_count) - tx_mcs.rate_n_flags = tx_resp->control.tx_rate; - else - tx_mcs.rate_n_flags = - le32_to_cpu(table->rs_table[index].rate_n_flags); - - rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, - &tbl_type, &rs_index); + tx_mcs.rate_n_flags = le32_to_cpu(table->rs_table[index].rate_n_flags); + rs_get_tbl_info_from_mcs(&tx_mcs, priv->band, &tbl_type, &rs_index); /* Update frame history window with "success" if Tx got ACKed ... */ if (tx_resp->flags & IEEE80211_TX_STATUS_ACK) @@ -1024,7 +977,8 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, /* See if there's a better rate or modulation mode to try. */ rs_rate_scale_perform(priv, dev, hdr, sta); - sta_info_put(sta); +out: + rcu_read_unlock(); return; } @@ -1128,7 +1082,7 @@ static void rs_get_expected_tpt_table(struct iwl4965_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 rs_get_best_rate(struct iwl4965_priv *priv, +static s32 rs_get_best_rate(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct iwl4965_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 index, s8 rate) @@ -1226,7 +1180,7 @@ static inline u8 rs_is_both_ant_supp(u8 valid_antenna) /* * Set up search table for MIMO */ -static int rs_switch_to_mimo(struct iwl4965_priv *priv, +static int rs_switch_to_mimo(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct ieee80211_conf *conf, struct sta_info *sta, @@ -1291,7 +1245,7 @@ static int rs_switch_to_mimo(struct iwl4965_priv *priv, /* * Set up search table for SISO */ -static int rs_switch_to_siso(struct iwl4965_priv *priv, +static int rs_switch_to_siso(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct ieee80211_conf *conf, struct sta_info *sta, @@ -1354,7 +1308,7 @@ static int rs_switch_to_siso(struct iwl4965_priv *priv, /* * Try to switch to new modulation mode from legacy */ -static int rs_move_legacy_other(struct iwl4965_priv *priv, +static int rs_move_legacy_other(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct ieee80211_conf *conf, struct sta_info *sta, @@ -1452,7 +1406,7 @@ static int rs_move_legacy_other(struct iwl4965_priv *priv, /* * Try to switch to new modulation mode from SISO */ -static int rs_move_siso_to_other(struct iwl4965_priv *priv, +static int rs_move_siso_to_other(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct ieee80211_conf *conf, struct sta_info *sta, @@ -1548,7 +1502,7 @@ static int rs_move_siso_to_other(struct iwl4965_priv *priv, /* * Try to switch to new modulation mode from MIMO */ -static int rs_move_mimo_to_other(struct iwl4965_priv *priv, +static int rs_move_mimo_to_other(struct iwl_priv *priv, struct iwl4965_lq_sta *lq_sta, struct ieee80211_conf *conf, struct sta_info *sta, @@ -1728,7 +1682,7 @@ static void rs_stay_in_table(struct iwl4965_lq_sta *lq_sta) /* * Do rate scaling and search for new modulation mode. */ -static void rs_rate_scale_perform(struct iwl4965_priv *priv, +static void rs_rate_scale_perform(struct iwl_priv *priv, struct net_device *dev, struct ieee80211_hdr *hdr, struct sta_info *sta) @@ -1801,7 +1755,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, is_green = lq_sta->is_green; /* current tx rate */ - index = sta->last_txrate; + index = sta->last_txrate_idx; IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, tbl->lq_type); @@ -1814,7 +1768,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { - if (lq_sta->phymode == (u8) MODE_IEEE80211A) + if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ rate_scale_index_msk = (u16) (rate_mask & (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); @@ -1878,7 +1832,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, if (update_lq) { rs_mcs_from_tbl(&mcs_rate, tbl, index, is_green); rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); - rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); + iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); } goto out; @@ -1920,7 +1874,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, tbl = &(lq_sta->lq_info[active_tbl]); /* Revert to "active" rate and throughput info */ - index = iwl4965_rate_index_from_plcp( + index = iwl4965_hwrate_to_plcp_idx( tbl->current_rate.rate_n_flags); current_tpt = lq_sta->last_tpt; @@ -2043,7 +1997,7 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, if (update_lq) { rs_mcs_from_tbl(&mcs_rate, tbl, index, is_green); rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); - rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); + iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); } /* Should we stay with this modulation mode, or search for a new one? */ @@ -2076,14 +2030,14 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, rs_rate_scale_clear_window(&(tbl->win[i])); /* Use new "search" start rate */ - index = iwl4965_rate_index_from_plcp( + index = iwl4965_hwrate_to_plcp_idx( tbl->current_rate.rate_n_flags); IWL_DEBUG_HT("Switch current mcs: %X index: %d\n", tbl->current_rate.rate_n_flags, index); rs_fill_link_cmd(lq_sta, &tbl->current_rate, &lq_sta->lq); - rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); + iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); } /* If the "active" (non-search) mode was legacy, @@ -2134,21 +2088,21 @@ static void rs_rate_scale_perform(struct iwl4965_priv *priv, out: rs_mcs_from_tbl(&tbl->current_rate, tbl, index, is_green); i = index; - sta->last_txrate = i; + sta->last_txrate_idx = i; - /* sta->txrate is an index to A mode rates which start + /* sta->txrate_idx is an index to A mode rates which start * at IWL_FIRST_OFDM_RATE */ - if (lq_sta->phymode == (u8) MODE_IEEE80211A) - sta->txrate = i - IWL_FIRST_OFDM_RATE; + if (lq_sta->band == IEEE80211_BAND_5GHZ) + sta->txrate_idx = i - IWL_FIRST_OFDM_RATE; else - sta->txrate = i; + sta->txrate_idx = i; return; } -static void rs_initialize_lq(struct iwl4965_priv *priv, +static void rs_initialize_lq(struct iwl_priv *priv, struct ieee80211_conf *conf, struct sta_info *sta) { @@ -2164,7 +2118,7 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, goto out; lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; - i = sta->last_txrate; + i = sta->last_txrate_idx; if ((lq_sta->lq.sta_id == 0xff) && (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) @@ -2188,7 +2142,7 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, mcs_rate.rate_n_flags |= RATE_MCS_CCK_MSK; tbl->antenna_type = ANT_AUX; - rs_get_tbl_info_from_mcs(&mcs_rate, priv->phymode, tbl, &rate_idx); + rs_get_tbl_info_from_mcs(&mcs_rate, priv->band, tbl, &rate_idx); if (!rs_is_ant_connected(priv->valid_antenna, tbl->antenna_type)) rs_toggle_antenna(&mcs_rate, tbl); @@ -2196,13 +2150,14 @@ static void rs_initialize_lq(struct iwl4965_priv *priv, tbl->current_rate.rate_n_flags = mcs_rate.rate_n_flags; rs_get_expected_tpt_table(lq_sta, tbl); rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); - rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); + iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); out: return; } static void rs_get_rate(void *priv_rate, struct net_device *dev, - struct ieee80211_hw_mode *mode, struct sk_buff *skb, + struct ieee80211_supported_band *sband, + struct sk_buff *skb, struct rate_selection *sel) { @@ -2212,11 +2167,13 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct sta_info *sta; u16 fc; - struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; + struct iwl_priv *priv = (struct iwl_priv *)priv_rate; struct iwl4965_lq_sta *lq_sta; IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); + rcu_read_lock(); + sta = sta_info_get(local, hdr->addr1); /* Send management frames and broadcast/multicast data using lowest @@ -2224,14 +2181,12 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, fc = le16_to_cpu(hdr->frame_control); if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || !sta || !sta->rate_ctrl_priv) { - sel->rate = rate_lowest(local, local->oper_hw_mode, sta); - if (sta) - sta_info_put(sta); - return; + sel->rate = rate_lowest(local, sband, sta); + goto out; } lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; - i = sta->last_txrate; + i = sta->last_txrate_idx; if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && !lq_sta->ibss_sta_added) { @@ -2254,14 +2209,15 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, goto done; } - done: +done: if ((i < 0) || (i > IWL_RATE_COUNT)) { - sel->rate = rate_lowest(local, local->oper_hw_mode, sta); - return; + sel->rate = rate_lowest(local, sband, sta); + goto out; } - sta_info_put(sta); sel->rate = &priv->ieee_rates[i]; +out: + rcu_read_unlock(); } static void *rs_alloc_sta(void *priv, gfp_t gfp) @@ -2291,13 +2247,15 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, { int i, j; struct ieee80211_conf *conf = &local->hw.conf; - struct ieee80211_hw_mode *mode = local->oper_hw_mode; - struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; + struct ieee80211_supported_band *sband; + struct iwl_priv *priv = (struct iwl_priv *)priv_rate; struct iwl4965_lq_sta *lq_sta = priv_sta; + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; + lq_sta->flush_timer = 0; - lq_sta->supp_rates = sta->supp_rates; - sta->txrate = 3; + lq_sta->supp_rates = sta->supp_rates[sband->band]; + sta->txrate_idx = 3; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < IWL_RATE_COUNT; i++) rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); @@ -2332,15 +2290,15 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, } /* Find highest tx rate supported by hardware and destination station */ - for (i = 0; i < mode->num_rates; i++) { - if ((sta->supp_rates & BIT(i)) && - (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) - sta->txrate = i; - } - sta->last_txrate = sta->txrate; + for (i = 0; i < sband->n_bitrates; i++) + if (sta->supp_rates[sband->band] & BIT(i)) + sta->txrate_idx = i; + + sta->last_txrate_idx = sta->txrate_idx; + /* WTF is with this bogus comment? A doesn't have cck rates */ /* For MODE_IEEE80211A, cck rates are at end of rate table */ - if (local->hw.conf.phymode == MODE_IEEE80211A) - sta->last_txrate += IWL_FIRST_OFDM_RATE; + if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) + sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; lq_sta->is_dup = 0; lq_sta->valid_antenna = priv->valid_antenna; @@ -2349,7 +2307,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, lq_sta->active_rate = priv->active_rate; lq_sta->active_rate &= ~(0x1000); lq_sta->active_rate_basic = priv->active_rate_basic; - lq_sta->phymode = priv->phymode; + lq_sta->band = priv->band; #ifdef CONFIG_IWL4965_HT /* * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), @@ -2387,7 +2345,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, struct iwl4965_rate *tx_mcs, - struct iwl4965_link_quality_cmd *lq_cmd) + struct iwl_link_quality_cmd *lq_cmd) { int index = 0; int rate_idx; @@ -2401,7 +2359,7 @@ static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, rs_dbgfs_set_mcs(lq_sta, tx_mcs, index); /* Interpret rate_n_flags */ - rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->phymode, + rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->band, &tbl_type, &rate_idx); /* How many times should we repeat the initial rate? */ @@ -2455,7 +2413,7 @@ static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, index++; } - rs_get_tbl_info_from_mcs(&new_rate, lq_sta->phymode, &tbl_type, + rs_get_tbl_info_from_mcs(&new_rate, lq_sta->band, &tbl_type, &rate_idx); /* Indicate to uCode which entries might be MIMO. @@ -2512,7 +2470,7 @@ static void rs_free(void *priv_rate) static void rs_clear(void *priv_rate) { - struct iwl4965_priv *priv = (struct iwl4965_priv *) priv_rate; + struct iwl_priv *priv = (struct iwl_priv *) priv_rate; IWL_DEBUG_RATE("enter\n"); @@ -2542,7 +2500,7 @@ static void rs_dbgfs_set_mcs(struct iwl4965_lq_sta *lq_sta, { u32 base_rate; - if (lq_sta->phymode == (u8) MODE_IEEE80211A) + if (lq_sta->band == IEEE80211_BAND_5GHZ) base_rate = 0x800D; else base_rate = 0x820A; @@ -2586,7 +2544,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file, if (lq_sta->dbg_fixed.rate_n_flags) { rs_fill_link_cmd(lq_sta, &lq_sta->dbg_fixed, &lq_sta->lq); - rs_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC); + iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC); } return count; @@ -2722,7 +2680,7 @@ static struct rate_control_ops rs_ops = { int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) { struct ieee80211_local *local = hw_to_local(hw); - struct iwl4965_priv *priv = hw->priv; + struct iwl_priv *priv = hw->priv; struct iwl4965_lq_sta *lq_sta; struct sta_info *sta; int cnt = 0, i; @@ -2731,13 +2689,15 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) u32 max_time = 0; u8 lq_type, antenna; + rcu_read_lock(); + sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); if (!sta || !sta->rate_ctrl_priv) { - if (sta) { - sta_info_put(sta); + if (sta) IWL_DEBUG_RATE("leave - no private rate data!\n"); - } else + else IWL_DEBUG_RATE("leave - no station!\n"); + rcu_read_unlock(); return sprintf(buf, "station %d not found\n", sta_id); } @@ -2802,25 +2762,25 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) cnt += sprintf(&buf[cnt], "\nrate scale type %d antenna %d " "active_search %d rate index %d\n", lq_type, antenna, - lq_sta->search_better_tbl, sta->last_txrate); + lq_sta->search_better_tbl, sta->last_txrate_idx); - sta_info_put(sta); + rcu_read_unlock(); return cnt; } void iwl4965_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { - struct iwl4965_priv *priv = hw->priv; + struct iwl_priv *priv = hw->priv; priv->lq_mngr.lq_ready = 1; } -void iwl4965_rate_control_register(struct ieee80211_hw *hw) +int iwl4965_rate_control_register(void) { - ieee80211_rate_control_register(&rs_ops); + return ieee80211_rate_control_register(&rs_ops); } -void iwl4965_rate_control_unregister(struct ieee80211_hw *hw) +void iwl4965_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_ops); }