Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in the |
| 19 | * file called LICENSE. |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * James P. Ketrenos <ipw2100-admin@linux.intel.com> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | *****************************************************************************/ |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/skbuff.h> |
| 29 | #include <linux/wireless.h> |
| 30 | #include <net/mac80211.h> |
| 31 | #include <net/ieee80211.h> |
| 32 | |
| 33 | #include <linux/netdevice.h> |
| 34 | #include <linux/etherdevice.h> |
| 35 | #include <linux/delay.h> |
| 36 | |
| 37 | #include <linux/workqueue.h> |
| 38 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 39 | #include "../net/mac80211/ieee80211_rate.h" |
| 40 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 41 | #include "iwl-4965.h" |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 42 | #include "iwl-helpers.h" |
| 43 | |
| 44 | #define RS_NAME "iwl-4965-rs" |
| 45 | |
| 46 | #define NUM_TRY_BEFORE_ANTENNA_TOGGLE 1 |
| 47 | #define IWL_NUMBER_TRY 1 |
| 48 | #define IWL_HT_NUMBER_TRY 3 |
| 49 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 50 | #define IWL_RATE_MAX_WINDOW 62 /* # tx in history window */ |
| 51 | #define IWL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ |
| 52 | #define IWL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ |
| 53 | |
| 54 | /* max time to accum history 2 seconds */ |
| 55 | #define IWL_RATE_SCALE_FLUSH_INTVL (2*HZ) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 56 | |
| 57 | static u8 rs_ht_to_legacy[] = { |
| 58 | IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, |
| 59 | IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, |
| 60 | IWL_RATE_6M_INDEX, |
| 61 | IWL_RATE_6M_INDEX, IWL_RATE_9M_INDEX, |
| 62 | IWL_RATE_12M_INDEX, IWL_RATE_18M_INDEX, |
| 63 | IWL_RATE_24M_INDEX, IWL_RATE_36M_INDEX, |
| 64 | IWL_RATE_48M_INDEX, IWL_RATE_54M_INDEX |
| 65 | }; |
| 66 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 67 | struct iwl4965_rate { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 68 | u32 rate_n_flags; |
| 69 | } __attribute__ ((packed)); |
| 70 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 71 | /** |
| 72 | * struct iwl4965_rate_scale_data -- tx success history for one rate |
| 73 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 74 | struct iwl4965_rate_scale_data { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 75 | u64 data; /* bitmap of successful frames */ |
| 76 | s32 success_counter; /* number of frames successful */ |
| 77 | s32 success_ratio; /* per-cent * 128 */ |
| 78 | s32 counter; /* number of frames attempted */ |
| 79 | s32 average_tpt; /* success ratio * expected throughput */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 80 | unsigned long stamp; |
| 81 | }; |
| 82 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 83 | /** |
| 84 | * struct iwl4965_scale_tbl_info -- tx params and success history for all rates |
| 85 | * |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 86 | * There are two of these in struct iwl4965_lq_sta, |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 87 | * one for "active", and one for "search". |
| 88 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 89 | struct iwl4965_scale_tbl_info { |
| 90 | enum iwl4965_table_type lq_type; |
| 91 | enum iwl4965_antenna_type antenna_type; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 92 | u8 is_SGI; /* 1 = short guard interval */ |
| 93 | u8 is_fat; /* 1 = 40 MHz channel width */ |
| 94 | u8 is_dup; /* 1 = duplicated data streams */ |
| 95 | u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */ |
| 96 | s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ |
| 97 | struct iwl4965_rate current_rate; /* rate_n_flags, uCode API format */ |
| 98 | struct iwl4965_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 101 | #ifdef CONFIG_IWL4965_HT |
| 102 | |
| 103 | struct iwl4965_traffic_load { |
| 104 | unsigned long time_stamp; /* age of the oldest statistics */ |
| 105 | u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time |
| 106 | * slice */ |
| 107 | u32 total; /* total num of packets during the |
| 108 | * last TID_MAX_TIME_DIFF */ |
| 109 | u8 queue_count; /* number of queues that has |
| 110 | * been used since the last cleanup */ |
| 111 | u8 head; /* start of the circular buffer */ |
| 112 | }; |
| 113 | |
| 114 | #endif /* CONFIG_IWL4965_HT */ |
| 115 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 116 | /** |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 117 | * struct iwl4965_lq_sta -- driver's rate scaling private structure |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 118 | * |
| 119 | * Pointer to this gets passed back and forth between driver and mac80211. |
| 120 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 121 | struct iwl4965_lq_sta { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 122 | u8 active_tbl; /* index of active table, range 0-1 */ |
| 123 | u8 enable_counter; /* indicates HT mode */ |
| 124 | u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ |
| 125 | u8 search_better_tbl; /* 1: currently trying alternate mode */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 126 | s32 last_tpt; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 127 | |
| 128 | /* The following determine when to search for a new mode */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 129 | u32 table_count_limit; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 130 | u32 max_failure_limit; /* # failed frames before new search */ |
| 131 | u32 max_success_limit; /* # successful frames before new search */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 132 | u32 table_count; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 133 | u32 total_failed; /* total failed frames, any/all rates */ |
| 134 | u32 total_success; /* total successful frames, any/all rates */ |
| 135 | u32 flush_timer; /* time staying in mode before new search */ |
| 136 | |
| 137 | u8 action_counter; /* # mode-switch actions tried */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 138 | u8 antenna; |
| 139 | u8 valid_antenna; |
| 140 | u8 is_green; |
| 141 | u8 is_dup; |
| 142 | u8 phymode; |
| 143 | u8 ibss_sta_added; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 144 | |
| 145 | /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ |
Zhu Yi | 02dede0 | 2007-09-27 11:27:40 +0800 | [diff] [blame] | 146 | u32 supp_rates; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 147 | u16 active_rate; |
| 148 | u16 active_siso_rate; |
| 149 | u16 active_mimo_rate; |
| 150 | u16 active_rate_basic; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 151 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 152 | struct iwl4965_link_quality_cmd lq; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 153 | struct iwl4965_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 154 | #ifdef CONFIG_IWL4965_HT |
| 155 | struct iwl4965_traffic_load load[TID_MAX_LOAD_COUNT]; |
| 156 | u8 tx_agg_tid_en; |
| 157 | #endif |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 158 | #ifdef CONFIG_MAC80211_DEBUGFS |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 159 | struct dentry *rs_sta_dbgfs_scale_table_file; |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 160 | struct dentry *rs_sta_dbgfs_stats_table_file; |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 161 | #ifdef CONFIG_IWL4965_HT |
| 162 | struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; |
| 163 | #endif |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 164 | struct iwl4965_rate dbg_fixed; |
| 165 | struct iwl4965_priv *drv; |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 166 | #endif |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 169 | static void rs_rate_scale_perform(struct iwl4965_priv *priv, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 170 | struct net_device *dev, |
| 171 | struct ieee80211_hdr *hdr, |
| 172 | struct sta_info *sta); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 173 | static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 174 | struct iwl4965_rate *tx_mcs, |
| 175 | struct iwl4965_link_quality_cmd *tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 176 | |
| 177 | |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 178 | #ifdef CONFIG_MAC80211_DEBUGFS |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 179 | static void rs_dbgfs_set_mcs(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 180 | struct iwl4965_rate *mcs, int index); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 181 | #else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 182 | static void rs_dbgfs_set_mcs(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 183 | struct iwl4965_rate *mcs, int index) |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 184 | {} |
| 185 | #endif |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 186 | |
| 187 | /* |
| 188 | * Expected throughput metrics for following rates: |
| 189 | * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits |
| 190 | * "G" is the only table that supports CCK (the first 4 rates). |
| 191 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 192 | static s32 expected_tpt_A[IWL_RATE_COUNT] = { |
| 193 | 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186, 186 |
| 194 | }; |
| 195 | |
| 196 | static s32 expected_tpt_G[IWL_RATE_COUNT] = { |
| 197 | 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 186 |
| 198 | }; |
| 199 | |
| 200 | static s32 expected_tpt_siso20MHz[IWL_RATE_COUNT] = { |
| 201 | 0, 0, 0, 0, 42, 42, 76, 102, 124, 159, 183, 193, 202 |
| 202 | }; |
| 203 | |
| 204 | static s32 expected_tpt_siso20MHzSGI[IWL_RATE_COUNT] = { |
| 205 | 0, 0, 0, 0, 46, 46, 82, 110, 132, 168, 192, 202, 211 |
| 206 | }; |
| 207 | |
| 208 | static s32 expected_tpt_mimo20MHz[IWL_RATE_COUNT] = { |
| 209 | 0, 0, 0, 0, 74, 74, 123, 155, 179, 214, 236, 244, 251 |
| 210 | }; |
| 211 | |
| 212 | static s32 expected_tpt_mimo20MHzSGI[IWL_RATE_COUNT] = { |
| 213 | 0, 0, 0, 0, 81, 81, 131, 164, 188, 222, 243, 251, 257 |
| 214 | }; |
| 215 | |
| 216 | static s32 expected_tpt_siso40MHz[IWL_RATE_COUNT] = { |
| 217 | 0, 0, 0, 0, 77, 77, 127, 160, 184, 220, 242, 250, 257 |
| 218 | }; |
| 219 | |
| 220 | static s32 expected_tpt_siso40MHzSGI[IWL_RATE_COUNT] = { |
| 221 | 0, 0, 0, 0, 83, 83, 135, 169, 193, 229, 250, 257, 264 |
| 222 | }; |
| 223 | |
| 224 | static s32 expected_tpt_mimo40MHz[IWL_RATE_COUNT] = { |
| 225 | 0, 0, 0, 0, 123, 123, 182, 214, 235, 264, 279, 285, 289 |
| 226 | }; |
| 227 | |
| 228 | static s32 expected_tpt_mimo40MHzSGI[IWL_RATE_COUNT] = { |
| 229 | 0, 0, 0, 0, 131, 131, 191, 222, 242, 270, 284, 289, 293 |
| 230 | }; |
| 231 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 232 | static int iwl4965_lq_sync_callback(struct iwl4965_priv *priv, |
| 233 | struct iwl4965_cmd *cmd, struct sk_buff *skb) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 234 | { |
| 235 | /*We didn't cache the SKB; let the caller free it */ |
| 236 | return 1; |
| 237 | } |
| 238 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 239 | static inline u8 iwl4965_rate_get_rate(u32 rate_n_flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 240 | { |
| 241 | return (u8)(rate_n_flags & 0xFF); |
| 242 | } |
| 243 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 244 | static int rs_send_lq_cmd(struct iwl4965_priv *priv, |
| 245 | struct iwl4965_link_quality_cmd *lq, u8 flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 246 | { |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 247 | #ifdef CONFIG_IWL4965_DEBUG |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 248 | int i; |
| 249 | #endif |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 250 | struct iwl4965_host_cmd cmd = { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 251 | .id = REPLY_TX_LINK_QUALITY_CMD, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 252 | .len = sizeof(struct iwl4965_link_quality_cmd), |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 253 | .meta.flags = flags, |
| 254 | .data = lq, |
| 255 | }; |
| 256 | |
| 257 | if ((lq->sta_id == 0xFF) && |
| 258 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 259 | return -EINVAL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 260 | |
| 261 | if (lq->sta_id == 0xFF) |
| 262 | lq->sta_id = IWL_AP_ID; |
| 263 | |
| 264 | IWL_DEBUG_RATE("lq station id 0x%x\n", lq->sta_id); |
| 265 | IWL_DEBUG_RATE("lq dta 0x%X 0x%X\n", |
| 266 | lq->general_params.single_stream_ant_msk, |
| 267 | lq->general_params.dual_stream_ant_msk); |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 268 | #ifdef CONFIG_IWL4965_DEBUG |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 269 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) |
| 270 | IWL_DEBUG_RATE("lq index %d 0x%X\n", |
| 271 | i, lq->rs_table[i].rate_n_flags); |
| 272 | #endif |
| 273 | |
| 274 | if (flags & CMD_ASYNC) |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 275 | cmd.meta.u.callback = iwl4965_lq_sync_callback; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 276 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 277 | if (iwl4965_is_associated(priv) && priv->assoc_station_added && |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 278 | priv->lq_mngr.lq_ready) |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 279 | return iwl4965_send_cmd(priv, &cmd); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 280 | |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 281 | return 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 284 | static void rs_rate_scale_clear_window(struct iwl4965_rate_scale_data *window) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 285 | { |
| 286 | window->data = 0; |
| 287 | window->success_counter = 0; |
| 288 | window->success_ratio = IWL_INVALID_VALUE; |
| 289 | window->counter = 0; |
| 290 | window->average_tpt = IWL_INVALID_VALUE; |
| 291 | window->stamp = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 294 | #ifdef CONFIG_IWL4965_HT |
| 295 | /* |
| 296 | * removes the old data from the statistics. All data that is older than |
| 297 | * TID_MAX_TIME_DIFF, will be deleted. |
| 298 | */ |
| 299 | static void rs_tl_rm_old_stats(struct iwl4965_traffic_load *tl, u32 curr_time) |
| 300 | { |
| 301 | /* The oldest age we want to keep */ |
| 302 | u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; |
| 303 | |
| 304 | while (tl->queue_count && |
| 305 | (tl->time_stamp < oldest_time)) { |
| 306 | tl->total -= tl->packet_count[tl->head]; |
| 307 | tl->packet_count[tl->head] = 0; |
| 308 | tl->time_stamp += TID_QUEUE_CELL_SPACING; |
| 309 | tl->queue_count--; |
| 310 | tl->head++; |
| 311 | if (tl->head >= TID_QUEUE_MAX_SIZE) |
| 312 | tl->head = 0; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | /* |
| 317 | * increment traffic load value for tid and also remove |
| 318 | * any old values if passed the certain time period |
| 319 | */ |
| 320 | static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data, u8 tid) |
| 321 | { |
| 322 | u32 curr_time = jiffies_to_msecs(jiffies); |
| 323 | u32 time_diff; |
| 324 | s32 index; |
| 325 | struct iwl4965_traffic_load *tl = NULL; |
| 326 | |
| 327 | if (tid >= TID_MAX_LOAD_COUNT) |
| 328 | return; |
| 329 | |
| 330 | tl = &lq_data->load[tid]; |
| 331 | |
| 332 | curr_time -= curr_time % TID_ROUND_VALUE; |
| 333 | |
| 334 | /* Happens only for the first packet. Initialize the data */ |
| 335 | if (!(tl->queue_count)) { |
| 336 | tl->total = 1; |
| 337 | tl->time_stamp = curr_time; |
| 338 | tl->queue_count = 1; |
| 339 | tl->head = 0; |
| 340 | tl->packet_count[0] = 1; |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); |
| 345 | index = time_diff / TID_QUEUE_CELL_SPACING; |
| 346 | |
| 347 | /* The history is too long: remove data that is older than */ |
| 348 | /* TID_MAX_TIME_DIFF */ |
| 349 | if (index >= TID_QUEUE_MAX_SIZE) |
| 350 | rs_tl_rm_old_stats(tl, curr_time); |
| 351 | |
| 352 | index = (tl->head + index) % TID_QUEUE_MAX_SIZE; |
| 353 | tl->packet_count[index] = tl->packet_count[index] + 1; |
| 354 | tl->total = tl->total + 1; |
| 355 | |
| 356 | if ((index + 1) > tl->queue_count) |
| 357 | tl->queue_count = index + 1; |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | get the traffic load value for tid |
| 362 | */ |
| 363 | static u32 rs_tl_get_load(struct iwl4965_lq_sta *lq_data, u8 tid) |
| 364 | { |
| 365 | u32 curr_time = jiffies_to_msecs(jiffies); |
| 366 | u32 time_diff; |
| 367 | s32 index; |
| 368 | struct iwl4965_traffic_load *tl = NULL; |
| 369 | |
| 370 | if (tid >= TID_MAX_LOAD_COUNT) |
| 371 | return 0; |
| 372 | |
| 373 | tl = &(lq_data->load[tid]); |
| 374 | |
| 375 | curr_time -= curr_time % TID_ROUND_VALUE; |
| 376 | |
| 377 | if (!(tl->queue_count)) |
| 378 | return 0; |
| 379 | |
| 380 | time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); |
| 381 | index = time_diff / TID_QUEUE_CELL_SPACING; |
| 382 | |
| 383 | /* The history is too long: remove data that is older than */ |
| 384 | /* TID_MAX_TIME_DIFF */ |
| 385 | if (index >= TID_QUEUE_MAX_SIZE) |
| 386 | rs_tl_rm_old_stats(tl, curr_time); |
| 387 | |
| 388 | return tl->total; |
| 389 | } |
| 390 | |
| 391 | static void rs_tl_turn_on_agg_for_tid(struct iwl4965_priv *priv, |
| 392 | struct iwl4965_lq_sta *lq_data, u8 tid, |
| 393 | struct sta_info *sta) |
| 394 | { |
| 395 | unsigned long state; |
| 396 | DECLARE_MAC_BUF(mac); |
| 397 | |
| 398 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); |
| 399 | state = sta->ampdu_mlme.tid_tx[tid].state; |
| 400 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); |
| 401 | |
| 402 | if (state == HT_AGG_STATE_IDLE && |
| 403 | rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { |
| 404 | IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", |
| 405 | print_mac(mac, sta->addr), tid); |
| 406 | ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | static void rs_tl_turn_on_agg(struct iwl4965_priv *priv, u8 tid, |
| 411 | struct iwl4965_lq_sta *lq_data, |
| 412 | struct sta_info *sta) |
| 413 | { |
| 414 | if ((tid < TID_MAX_LOAD_COUNT)) |
| 415 | rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); |
| 416 | else if (tid == IWL_AGG_ALL_TID) |
| 417 | for (tid = 0; tid < TID_MAX_LOAD_COUNT; tid++) |
| 418 | rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); |
| 419 | } |
| 420 | |
| 421 | #endif /* CONFIG_IWLWIFI_HT */ |
| 422 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 423 | /** |
| 424 | * rs_collect_tx_data - Update the success/failure sliding window |
| 425 | * |
| 426 | * We keep a sliding window of the last 62 packets transmitted |
| 427 | * at this rate. window->data contains the bitmask of successful |
| 428 | * packets. |
| 429 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 430 | static int rs_collect_tx_data(struct iwl4965_rate_scale_data *windows, |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 431 | int scale_index, s32 tpt, int retries, |
| 432 | int successes) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 433 | { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 434 | struct iwl4965_rate_scale_data *window = NULL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 435 | u64 mask; |
| 436 | u8 win_size = IWL_RATE_MAX_WINDOW; |
| 437 | s32 fail_count; |
| 438 | |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 439 | if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) |
| 440 | return -EINVAL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 441 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 442 | /* Select data for current tx bit rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 443 | window = &(windows[scale_index]); |
| 444 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 445 | /* |
| 446 | * Keep track of only the latest 62 tx frame attempts in this rate's |
| 447 | * history window; anything older isn't really relevant any more. |
| 448 | * If we have filled up the sliding window, drop the oldest attempt; |
| 449 | * if the oldest attempt (highest bit in bitmap) shows "success", |
| 450 | * subtract "1" from the success counter (this is the main reason |
| 451 | * we keep these bitmaps!). |
| 452 | */ |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 453 | while (retries > 0) { |
| 454 | if (window->counter >= win_size) { |
| 455 | window->counter = win_size - 1; |
| 456 | mask = 1; |
| 457 | mask = (mask << (win_size - 1)); |
| 458 | if (window->data & mask) { |
| 459 | window->data &= ~mask; |
| 460 | window->success_counter = |
| 461 | window->success_counter - 1; |
| 462 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 463 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 464 | |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 465 | /* Increment frames-attempted counter */ |
| 466 | window->counter++; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 467 | |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 468 | /* Shift bitmap by one frame (throw away oldest history), |
| 469 | * OR in "1", and increment "success" if this |
| 470 | * frame was successful. */ |
| 471 | mask = window->data; |
| 472 | window->data = (mask << 1); |
| 473 | if (successes > 0) { |
| 474 | window->success_counter = window->success_counter + 1; |
| 475 | window->data |= 0x1; |
| 476 | successes--; |
| 477 | } |
| 478 | |
| 479 | retries--; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 482 | /* Calculate current success ratio, avoid divide-by-0! */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 483 | if (window->counter > 0) |
| 484 | window->success_ratio = 128 * (100 * window->success_counter) |
| 485 | / window->counter; |
| 486 | else |
| 487 | window->success_ratio = IWL_INVALID_VALUE; |
| 488 | |
| 489 | fail_count = window->counter - window->success_counter; |
| 490 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 491 | /* Calculate average throughput, if we have enough history. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 492 | if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) || |
| 493 | (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) |
| 494 | window->average_tpt = (window->success_ratio * tpt + 64) / 128; |
| 495 | else |
| 496 | window->average_tpt = IWL_INVALID_VALUE; |
| 497 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 498 | /* Tag this window as having been updated */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 499 | window->stamp = jiffies; |
| 500 | |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 501 | return 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 504 | /* |
| 505 | * Fill uCode API rate_n_flags field, based on "search" or "active" table. |
| 506 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 507 | static void rs_mcs_from_tbl(struct iwl4965_rate *mcs_rate, |
| 508 | struct iwl4965_scale_tbl_info *tbl, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 509 | int index, u8 use_green) |
| 510 | { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 511 | if (is_legacy(tbl->lq_type)) { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 512 | mcs_rate->rate_n_flags = iwl4965_rates[index].plcp; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 513 | if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) |
| 514 | mcs_rate->rate_n_flags |= RATE_MCS_CCK_MSK; |
| 515 | |
| 516 | } else if (is_siso(tbl->lq_type)) { |
| 517 | if (index > IWL_LAST_OFDM_RATE) |
| 518 | index = IWL_LAST_OFDM_RATE; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 519 | mcs_rate->rate_n_flags = iwl4965_rates[index].plcp_siso | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 520 | RATE_MCS_HT_MSK; |
| 521 | } else { |
| 522 | if (index > IWL_LAST_OFDM_RATE) |
| 523 | index = IWL_LAST_OFDM_RATE; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 524 | mcs_rate->rate_n_flags = iwl4965_rates[index].plcp_mimo | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 525 | RATE_MCS_HT_MSK; |
| 526 | } |
| 527 | |
| 528 | switch (tbl->antenna_type) { |
| 529 | case ANT_BOTH: |
| 530 | mcs_rate->rate_n_flags |= RATE_MCS_ANT_AB_MSK; |
| 531 | break; |
| 532 | case ANT_MAIN: |
| 533 | mcs_rate->rate_n_flags |= RATE_MCS_ANT_A_MSK; |
| 534 | break; |
| 535 | case ANT_AUX: |
| 536 | mcs_rate->rate_n_flags |= RATE_MCS_ANT_B_MSK; |
| 537 | break; |
| 538 | case ANT_NONE: |
| 539 | break; |
| 540 | } |
| 541 | |
| 542 | if (is_legacy(tbl->lq_type)) |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 543 | return; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 544 | |
| 545 | if (tbl->is_fat) { |
| 546 | if (tbl->is_dup) |
| 547 | mcs_rate->rate_n_flags |= RATE_MCS_DUP_MSK; |
| 548 | else |
| 549 | mcs_rate->rate_n_flags |= RATE_MCS_FAT_MSK; |
| 550 | } |
| 551 | if (tbl->is_SGI) |
| 552 | mcs_rate->rate_n_flags |= RATE_MCS_SGI_MSK; |
| 553 | |
| 554 | if (use_green) { |
| 555 | mcs_rate->rate_n_flags |= RATE_MCS_GF_MSK; |
| 556 | if (is_siso(tbl->lq_type)) |
| 557 | mcs_rate->rate_n_flags &= ~RATE_MCS_SGI_MSK; |
| 558 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 561 | /* |
| 562 | * Interpret uCode API's rate_n_flags format, |
| 563 | * fill "search" or "active" tx mode table. |
| 564 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 565 | static int rs_get_tbl_info_from_mcs(const struct iwl4965_rate *mcs_rate, |
| 566 | int phymode, struct iwl4965_scale_tbl_info *tbl, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 567 | int *rate_idx) |
| 568 | { |
| 569 | int index; |
| 570 | u32 ant_msk; |
| 571 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 572 | index = iwl4965_rate_index_from_plcp(mcs_rate->rate_n_flags); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 573 | |
| 574 | if (index == IWL_RATE_INVALID) { |
| 575 | *rate_idx = -1; |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 576 | return -EINVAL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 577 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 578 | tbl->is_SGI = 0; /* default legacy setup */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 579 | tbl->is_fat = 0; |
| 580 | tbl->is_dup = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 581 | tbl->antenna_type = ANT_BOTH; /* default MIMO setup */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 582 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 583 | /* legacy rate format */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 584 | if (!(mcs_rate->rate_n_flags & RATE_MCS_HT_MSK)) { |
| 585 | ant_msk = (mcs_rate->rate_n_flags & RATE_MCS_ANT_AB_MSK); |
| 586 | |
| 587 | if (ant_msk == RATE_MCS_ANT_AB_MSK) |
| 588 | tbl->lq_type = LQ_NONE; |
| 589 | else { |
| 590 | |
| 591 | if (phymode == MODE_IEEE80211A) |
| 592 | tbl->lq_type = LQ_A; |
| 593 | else |
| 594 | tbl->lq_type = LQ_G; |
| 595 | |
| 596 | if (mcs_rate->rate_n_flags & RATE_MCS_ANT_A_MSK) |
| 597 | tbl->antenna_type = ANT_MAIN; |
| 598 | else |
| 599 | tbl->antenna_type = ANT_AUX; |
| 600 | } |
| 601 | *rate_idx = index; |
| 602 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 603 | /* HT rate format, SISO (might be 20 MHz legacy or 40 MHz fat width) */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 604 | } else if (iwl4965_rate_get_rate(mcs_rate->rate_n_flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 605 | <= IWL_RATE_SISO_60M_PLCP) { |
| 606 | tbl->lq_type = LQ_SISO; |
| 607 | |
| 608 | ant_msk = (mcs_rate->rate_n_flags & RATE_MCS_ANT_AB_MSK); |
| 609 | if (ant_msk == RATE_MCS_ANT_AB_MSK) |
| 610 | tbl->lq_type = LQ_NONE; |
| 611 | else { |
| 612 | if (mcs_rate->rate_n_flags & RATE_MCS_ANT_A_MSK) |
| 613 | tbl->antenna_type = ANT_MAIN; |
| 614 | else |
| 615 | tbl->antenna_type = ANT_AUX; |
| 616 | } |
| 617 | if (mcs_rate->rate_n_flags & RATE_MCS_SGI_MSK) |
| 618 | tbl->is_SGI = 1; |
| 619 | |
| 620 | if ((mcs_rate->rate_n_flags & RATE_MCS_FAT_MSK) || |
| 621 | (mcs_rate->rate_n_flags & RATE_MCS_DUP_MSK)) |
| 622 | tbl->is_fat = 1; |
| 623 | |
| 624 | if (mcs_rate->rate_n_flags & RATE_MCS_DUP_MSK) |
| 625 | tbl->is_dup = 1; |
| 626 | |
| 627 | *rate_idx = index; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 628 | |
| 629 | /* HT rate format, MIMO (might be 20 MHz legacy or 40 MHz fat width) */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 630 | } else { |
| 631 | tbl->lq_type = LQ_MIMO; |
| 632 | if (mcs_rate->rate_n_flags & RATE_MCS_SGI_MSK) |
| 633 | tbl->is_SGI = 1; |
| 634 | |
| 635 | if ((mcs_rate->rate_n_flags & RATE_MCS_FAT_MSK) || |
| 636 | (mcs_rate->rate_n_flags & RATE_MCS_DUP_MSK)) |
| 637 | tbl->is_fat = 1; |
| 638 | |
| 639 | if (mcs_rate->rate_n_flags & RATE_MCS_DUP_MSK) |
| 640 | tbl->is_dup = 1; |
| 641 | *rate_idx = index; |
| 642 | } |
| 643 | return 0; |
| 644 | } |
| 645 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 646 | static inline void rs_toggle_antenna(struct iwl4965_rate *new_rate, |
| 647 | struct iwl4965_scale_tbl_info *tbl) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 648 | { |
| 649 | if (tbl->antenna_type == ANT_AUX) { |
| 650 | tbl->antenna_type = ANT_MAIN; |
| 651 | new_rate->rate_n_flags &= ~RATE_MCS_ANT_B_MSK; |
| 652 | new_rate->rate_n_flags |= RATE_MCS_ANT_A_MSK; |
| 653 | } else { |
| 654 | tbl->antenna_type = ANT_AUX; |
| 655 | new_rate->rate_n_flags &= ~RATE_MCS_ANT_A_MSK; |
| 656 | new_rate->rate_n_flags |= RATE_MCS_ANT_B_MSK; |
| 657 | } |
| 658 | } |
| 659 | |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 660 | static inline u8 rs_use_green(struct iwl4965_priv *priv, |
| 661 | struct ieee80211_conf *conf) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 662 | { |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 663 | #ifdef CONFIG_IWL4965_HT |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 664 | return ((conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && |
| 665 | priv->current_ht_config.is_green_field && |
| 666 | !priv->current_ht_config.non_GF_STA_present); |
| 667 | #endif /* CONFIG_IWL4965_HT */ |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 668 | return 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | /** |
| 672 | * rs_get_supported_rates - get the available rates |
| 673 | * |
| 674 | * if management frame or broadcast frame only return |
| 675 | * basic available rates. |
| 676 | * |
| 677 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 678 | static void rs_get_supported_rates(struct iwl4965_lq_sta *lq_sta, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 679 | struct ieee80211_hdr *hdr, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 680 | enum iwl4965_table_type rate_type, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 681 | u16 *data_rate) |
| 682 | { |
| 683 | if (is_legacy(rate_type)) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 684 | *data_rate = lq_sta->active_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 685 | else { |
| 686 | if (is_siso(rate_type)) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 687 | *data_rate = lq_sta->active_siso_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 688 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 689 | *data_rate = lq_sta->active_mimo_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | if (hdr && is_multicast_ether_addr(hdr->addr1) && |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 693 | lq_sta->active_rate_basic) { |
| 694 | *data_rate = lq_sta->active_rate_basic; |
| 695 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | static u16 rs_get_adjacent_rate(u8 index, u16 rate_mask, int rate_type) |
| 699 | { |
| 700 | u8 high = IWL_RATE_INVALID; |
| 701 | u8 low = IWL_RATE_INVALID; |
| 702 | |
Ian Schram | 01ebd06 | 2007-10-25 17:15:22 +0800 | [diff] [blame] | 703 | /* 802.11A or ht walks to the next literal adjacent rate in |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 704 | * the rate table */ |
| 705 | if (is_a_band(rate_type) || !is_legacy(rate_type)) { |
| 706 | int i; |
| 707 | u32 mask; |
| 708 | |
| 709 | /* Find the previous rate that is in the rate mask */ |
| 710 | i = index - 1; |
| 711 | for (mask = (1 << i); i >= 0; i--, mask >>= 1) { |
| 712 | if (rate_mask & mask) { |
| 713 | low = i; |
| 714 | break; |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | /* Find the next rate that is in the rate mask */ |
| 719 | i = index + 1; |
| 720 | for (mask = (1 << i); i < IWL_RATE_COUNT; i++, mask <<= 1) { |
| 721 | if (rate_mask & mask) { |
| 722 | high = i; |
| 723 | break; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | return (high << 8) | low; |
| 728 | } |
| 729 | |
| 730 | low = index; |
| 731 | while (low != IWL_RATE_INVALID) { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 732 | low = iwl4965_rates[low].prev_rs; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 733 | if (low == IWL_RATE_INVALID) |
| 734 | break; |
| 735 | if (rate_mask & (1 << low)) |
| 736 | break; |
| 737 | IWL_DEBUG_RATE("Skipping masked lower rate: %d\n", low); |
| 738 | } |
| 739 | |
| 740 | high = index; |
| 741 | while (high != IWL_RATE_INVALID) { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 742 | high = iwl4965_rates[high].next_rs; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 743 | if (high == IWL_RATE_INVALID) |
| 744 | break; |
| 745 | if (rate_mask & (1 << high)) |
| 746 | break; |
| 747 | IWL_DEBUG_RATE("Skipping masked higher rate: %d\n", high); |
| 748 | } |
| 749 | |
| 750 | return (high << 8) | low; |
| 751 | } |
| 752 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 753 | static void rs_get_lower_rate(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 754 | struct iwl4965_scale_tbl_info *tbl, u8 scale_index, |
| 755 | u8 ht_possible, struct iwl4965_rate *mcs_rate) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 756 | { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 757 | s32 low; |
| 758 | u16 rate_mask; |
| 759 | u16 high_low; |
| 760 | u8 switch_to_legacy = 0; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 761 | u8 is_green = lq_sta->is_green; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 762 | |
| 763 | /* check if we need to switch from HT to legacy rates. |
| 764 | * assumption is that mandatory rates (1Mbps or 6Mbps) |
| 765 | * are always supported (spec demand) */ |
| 766 | if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { |
| 767 | switch_to_legacy = 1; |
| 768 | scale_index = rs_ht_to_legacy[scale_index]; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 769 | if (lq_sta->phymode == MODE_IEEE80211A) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 770 | tbl->lq_type = LQ_A; |
| 771 | else |
| 772 | tbl->lq_type = LQ_G; |
| 773 | |
| 774 | if ((tbl->antenna_type == ANT_BOTH) || |
| 775 | (tbl->antenna_type == ANT_NONE)) |
| 776 | tbl->antenna_type = ANT_MAIN; |
| 777 | |
| 778 | tbl->is_fat = 0; |
| 779 | tbl->is_SGI = 0; |
| 780 | } |
| 781 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 782 | rs_get_supported_rates(lq_sta, NULL, tbl->lq_type, &rate_mask); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 783 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 784 | /* Mask with station rate restriction */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 785 | if (is_legacy(tbl->lq_type)) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 786 | /* supp_rates has no CCK bits in A mode */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 787 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 788 | rate_mask = (u16)(rate_mask & |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 789 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 790 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 791 | rate_mask = (u16)(rate_mask & lq_sta->supp_rates); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 792 | } |
| 793 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 794 | /* If we switched from HT to legacy, check current rate */ |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 795 | if (switch_to_legacy && (rate_mask & (1 << scale_index))) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 796 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 797 | return; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | high_low = rs_get_adjacent_rate(scale_index, rate_mask, tbl->lq_type); |
| 801 | low = high_low & 0xff; |
| 802 | |
| 803 | if (low != IWL_RATE_INVALID) |
| 804 | rs_mcs_from_tbl(mcs_rate, tbl, low, is_green); |
| 805 | else |
| 806 | rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 807 | } |
| 808 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 809 | /* |
| 810 | * mac80211 sends us Tx status |
| 811 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 812 | static void rs_tx_status(void *priv_rate, struct net_device *dev, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 813 | struct sk_buff *skb, |
| 814 | struct ieee80211_tx_status *tx_resp) |
| 815 | { |
| 816 | int status; |
| 817 | u8 retries; |
| 818 | int rs_index, index = 0; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 819 | struct iwl4965_lq_sta *lq_sta; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 820 | struct iwl4965_link_quality_cmd *table; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 821 | struct sta_info *sta; |
| 822 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 823 | struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 824 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 825 | struct iwl4965_rate_scale_data *window = NULL; |
| 826 | struct iwl4965_rate_scale_data *search_win = NULL; |
| 827 | struct iwl4965_rate tx_mcs; |
| 828 | struct iwl4965_scale_tbl_info tbl_type; |
| 829 | struct iwl4965_scale_tbl_info *curr_tbl, *search_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 830 | u8 active_index = 0; |
| 831 | u16 fc = le16_to_cpu(hdr->frame_control); |
| 832 | s32 tpt = 0; |
| 833 | |
Zhu Yi | 5882635 | 2007-09-27 11:27:39 +0800 | [diff] [blame] | 834 | IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 835 | |
| 836 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) |
| 837 | return; |
| 838 | |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 839 | /* This packet was aggregated but doesn't carry rate scale info */ |
| 840 | if ((tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) && |
| 841 | !(tx_resp->flags & IEEE80211_TX_STATUS_AMPDU)) |
| 842 | return; |
| 843 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 844 | retries = tx_resp->retry_count; |
| 845 | |
| 846 | if (retries > 15) |
| 847 | retries = 15; |
| 848 | |
| 849 | |
| 850 | sta = sta_info_get(local, hdr->addr1); |
| 851 | |
| 852 | if (!sta || !sta->rate_ctrl_priv) { |
| 853 | if (sta) |
| 854 | sta_info_put(sta); |
| 855 | return; |
| 856 | } |
| 857 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 858 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 859 | |
| 860 | if (!priv->lq_mngr.lq_ready) |
| 861 | return; |
| 862 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 863 | if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && |
| 864 | !lq_sta->ibss_sta_added) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 865 | return; |
| 866 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 867 | table = &lq_sta->lq; |
| 868 | active_index = lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 869 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 870 | /* Get mac80211 antenna info */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 871 | lq_sta->antenna = |
| 872 | (lq_sta->valid_antenna & local->hw.conf.antenna_sel_tx); |
| 873 | if (!lq_sta->antenna) |
| 874 | lq_sta->antenna = lq_sta->valid_antenna; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 875 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 876 | /* Ignore mac80211 antenna info for now */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 877 | lq_sta->antenna = lq_sta->valid_antenna; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 878 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 879 | curr_tbl = &(lq_sta->lq_info[active_index]); |
| 880 | search_tbl = &(lq_sta->lq_info[(1 - active_index)]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 881 | window = (struct iwl4965_rate_scale_data *) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 882 | &(curr_tbl->win[0]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 883 | search_win = (struct iwl4965_rate_scale_data *) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 884 | &(search_tbl->win[0]); |
| 885 | |
| 886 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate; |
| 887 | |
| 888 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, |
| 889 | &tbl_type, &rs_index); |
| 890 | if ((rs_index < 0) || (rs_index >= IWL_RATE_COUNT)) { |
| 891 | IWL_DEBUG_RATE("bad rate index at: %d rate 0x%X\n", |
| 892 | rs_index, tx_mcs.rate_n_flags); |
| 893 | sta_info_put(sta); |
| 894 | return; |
| 895 | } |
| 896 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 897 | /* |
| 898 | * Ignore this Tx frame response if its initial rate doesn't match |
| 899 | * that of latest Link Quality command. There may be stragglers |
| 900 | * from a previous Link Quality command, but we're no longer interested |
| 901 | * in those; they're either from the "active" mode while we're trying |
| 902 | * to check "search" mode, or a prior "search" mode after we've moved |
| 903 | * to a new "search" mode (which might become the new "active" mode). |
| 904 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 905 | if (retries && |
| 906 | (tx_mcs.rate_n_flags != |
| 907 | le32_to_cpu(table->rs_table[0].rate_n_flags))) { |
| 908 | IWL_DEBUG_RATE("initial rate does not match 0x%x 0x%x\n", |
| 909 | tx_mcs.rate_n_flags, |
| 910 | le32_to_cpu(table->rs_table[0].rate_n_flags)); |
| 911 | sta_info_put(sta); |
| 912 | return; |
| 913 | } |
| 914 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 915 | /* Update frame history window with "failure" for each Tx retry. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 916 | while (retries) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 917 | /* Look up the rate and other info used for each tx attempt. |
| 918 | * Each tx attempt steps one entry deeper in the rate table. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 919 | tx_mcs.rate_n_flags = |
| 920 | le32_to_cpu(table->rs_table[index].rate_n_flags); |
| 921 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, |
| 922 | &tbl_type, &rs_index); |
| 923 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 924 | /* If type matches "search" table, |
| 925 | * add failure to "search" history */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 926 | if ((tbl_type.lq_type == search_tbl->lq_type) && |
| 927 | (tbl_type.antenna_type == search_tbl->antenna_type) && |
| 928 | (tbl_type.is_SGI == search_tbl->is_SGI)) { |
| 929 | if (search_tbl->expected_tpt) |
| 930 | tpt = search_tbl->expected_tpt[rs_index]; |
| 931 | else |
| 932 | tpt = 0; |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 933 | rs_collect_tx_data(search_win, rs_index, tpt, 1, 0); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 934 | |
| 935 | /* Else if type matches "current/active" table, |
| 936 | * add failure to "current/active" history */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 937 | } else if ((tbl_type.lq_type == curr_tbl->lq_type) && |
| 938 | (tbl_type.antenna_type == curr_tbl->antenna_type) && |
| 939 | (tbl_type.is_SGI == curr_tbl->is_SGI)) { |
| 940 | if (curr_tbl->expected_tpt) |
| 941 | tpt = curr_tbl->expected_tpt[rs_index]; |
| 942 | else |
| 943 | tpt = 0; |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 944 | rs_collect_tx_data(window, rs_index, tpt, 1, 0); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 945 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 946 | |
| 947 | /* If not searching for a new mode, increment failed counter |
| 948 | * ... this helps determine when to start searching again */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 949 | if (lq_sta->stay_in_tbl) |
| 950 | lq_sta->total_failed++; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 951 | --retries; |
| 952 | index++; |
| 953 | |
| 954 | } |
| 955 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 956 | /* |
| 957 | * Find (by rate) the history window to update with final Tx attempt; |
| 958 | * if Tx was successful first try, use original rate, |
| 959 | * else look up the rate that was, finally, successful. |
| 960 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 961 | if (!tx_resp->retry_count) |
| 962 | tx_mcs.rate_n_flags = tx_resp->control.tx_rate; |
| 963 | else |
| 964 | tx_mcs.rate_n_flags = |
| 965 | le32_to_cpu(table->rs_table[index].rate_n_flags); |
| 966 | |
| 967 | rs_get_tbl_info_from_mcs(&tx_mcs, priv->phymode, |
| 968 | &tbl_type, &rs_index); |
| 969 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 970 | /* Update frame history window with "success" if Tx got ACKed ... */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 971 | if (tx_resp->flags & IEEE80211_TX_STATUS_ACK) |
| 972 | status = 1; |
| 973 | else |
| 974 | status = 0; |
| 975 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 976 | /* If type matches "search" table, |
| 977 | * add final tx status to "search" history */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 978 | if ((tbl_type.lq_type == search_tbl->lq_type) && |
| 979 | (tbl_type.antenna_type == search_tbl->antenna_type) && |
| 980 | (tbl_type.is_SGI == search_tbl->is_SGI)) { |
| 981 | if (search_tbl->expected_tpt) |
| 982 | tpt = search_tbl->expected_tpt[rs_index]; |
| 983 | else |
| 984 | tpt = 0; |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 985 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) |
| 986 | rs_collect_tx_data(search_win, rs_index, tpt, |
| 987 | tx_resp->ampdu_ack_len, |
| 988 | tx_resp->ampdu_ack_map); |
| 989 | else |
| 990 | rs_collect_tx_data(search_win, rs_index, tpt, |
| 991 | 1, status); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 992 | /* Else if type matches "current/active" table, |
| 993 | * add final tx status to "current/active" history */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 994 | } else if ((tbl_type.lq_type == curr_tbl->lq_type) && |
| 995 | (tbl_type.antenna_type == curr_tbl->antenna_type) && |
| 996 | (tbl_type.is_SGI == curr_tbl->is_SGI)) { |
| 997 | if (curr_tbl->expected_tpt) |
| 998 | tpt = curr_tbl->expected_tpt[rs_index]; |
| 999 | else |
| 1000 | tpt = 0; |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 1001 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) |
| 1002 | rs_collect_tx_data(window, rs_index, tpt, |
| 1003 | tx_resp->ampdu_ack_len, |
| 1004 | tx_resp->ampdu_ack_map); |
| 1005 | else |
| 1006 | rs_collect_tx_data(window, rs_index, tpt, |
| 1007 | 1, status); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1010 | /* If not searching for new mode, increment success/failed counter |
| 1011 | * ... these help determine when to start searching again */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1012 | if (lq_sta->stay_in_tbl) { |
Ron Rindjunsky | 9955643 | 2008-01-28 14:07:25 +0200 | [diff] [blame] | 1013 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) { |
| 1014 | lq_sta->total_success += tx_resp->ampdu_ack_map; |
| 1015 | lq_sta->total_failed += |
| 1016 | (tx_resp->ampdu_ack_len - tx_resp->ampdu_ack_map); |
| 1017 | } else { |
| 1018 | if (status) |
| 1019 | lq_sta->total_success++; |
| 1020 | else |
| 1021 | lq_sta->total_failed++; |
| 1022 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1023 | } |
| 1024 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1025 | /* See if there's a better rate or modulation mode to try. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1026 | rs_rate_scale_perform(priv, dev, hdr, sta); |
| 1027 | sta_info_put(sta); |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | static u8 rs_is_ant_connected(u8 valid_antenna, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1032 | enum iwl4965_antenna_type antenna_type) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1033 | { |
| 1034 | if (antenna_type == ANT_AUX) |
| 1035 | return ((valid_antenna & 0x2) ? 1:0); |
| 1036 | else if (antenna_type == ANT_MAIN) |
| 1037 | return ((valid_antenna & 0x1) ? 1:0); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1038 | else if (antenna_type == ANT_BOTH) |
| 1039 | return ((valid_antenna & 0x3) == 0x3); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1040 | |
| 1041 | return 1; |
| 1042 | } |
| 1043 | |
| 1044 | static u8 rs_is_other_ant_connected(u8 valid_antenna, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1045 | enum iwl4965_antenna_type antenna_type) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1046 | { |
| 1047 | if (antenna_type == ANT_AUX) |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1048 | return rs_is_ant_connected(valid_antenna, ANT_MAIN); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1049 | else |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1050 | return rs_is_ant_connected(valid_antenna, ANT_AUX); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1051 | |
| 1052 | return 0; |
| 1053 | } |
| 1054 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1055 | /* |
| 1056 | * Begin a period of staying with a selected modulation mode. |
| 1057 | * Set "stay_in_tbl" flag to prevent any mode switches. |
| 1058 | * Set frame tx success limits according to legacy vs. high-throughput, |
| 1059 | * and reset overall (spanning all rates) tx success history statistics. |
| 1060 | * These control how long we stay using same modulation mode before |
| 1061 | * searching for a new mode. |
| 1062 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1063 | static void rs_set_stay_in_table(u8 is_legacy, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1064 | struct iwl4965_lq_sta *lq_sta) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1065 | { |
| 1066 | IWL_DEBUG_HT("we are staying in the same table\n"); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1067 | lq_sta->stay_in_tbl = 1; /* only place this gets set */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1068 | if (is_legacy) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1069 | lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; |
| 1070 | lq_sta->max_failure_limit = IWL_LEGACY_FAILURE_LIMIT; |
| 1071 | lq_sta->max_success_limit = IWL_LEGACY_SUCCESS_LIMIT; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1072 | } else { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1073 | lq_sta->table_count_limit = IWL_NONE_LEGACY_TABLE_COUNT; |
| 1074 | lq_sta->max_failure_limit = IWL_NONE_LEGACY_FAILURE_LIMIT; |
| 1075 | lq_sta->max_success_limit = IWL_NONE_LEGACY_SUCCESS_LIMIT; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1076 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1077 | lq_sta->table_count = 0; |
| 1078 | lq_sta->total_failed = 0; |
| 1079 | lq_sta->total_success = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1082 | /* |
| 1083 | * Find correct throughput table for given mode of modulation |
| 1084 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1085 | static void rs_get_expected_tpt_table(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1086 | struct iwl4965_scale_tbl_info *tbl) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1087 | { |
| 1088 | if (is_legacy(tbl->lq_type)) { |
| 1089 | if (!is_a_band(tbl->lq_type)) |
| 1090 | tbl->expected_tpt = expected_tpt_G; |
| 1091 | else |
| 1092 | tbl->expected_tpt = expected_tpt_A; |
| 1093 | } else if (is_siso(tbl->lq_type)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1094 | if (tbl->is_fat && !lq_sta->is_dup) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1095 | if (tbl->is_SGI) |
| 1096 | tbl->expected_tpt = expected_tpt_siso40MHzSGI; |
| 1097 | else |
| 1098 | tbl->expected_tpt = expected_tpt_siso40MHz; |
| 1099 | else if (tbl->is_SGI) |
| 1100 | tbl->expected_tpt = expected_tpt_siso20MHzSGI; |
| 1101 | else |
| 1102 | tbl->expected_tpt = expected_tpt_siso20MHz; |
| 1103 | |
| 1104 | } else if (is_mimo(tbl->lq_type)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1105 | if (tbl->is_fat && !lq_sta->is_dup) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1106 | if (tbl->is_SGI) |
| 1107 | tbl->expected_tpt = expected_tpt_mimo40MHzSGI; |
| 1108 | else |
| 1109 | tbl->expected_tpt = expected_tpt_mimo40MHz; |
| 1110 | else if (tbl->is_SGI) |
| 1111 | tbl->expected_tpt = expected_tpt_mimo20MHzSGI; |
| 1112 | else |
| 1113 | tbl->expected_tpt = expected_tpt_mimo20MHz; |
| 1114 | } else |
| 1115 | tbl->expected_tpt = expected_tpt_G; |
| 1116 | } |
| 1117 | |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 1118 | #ifdef CONFIG_IWL4965_HT |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1119 | /* |
| 1120 | * Find starting rate for new "search" high-throughput mode of modulation. |
| 1121 | * Goal is to find lowest expected rate (under perfect conditions) that is |
| 1122 | * above the current measured throughput of "active" mode, to give new mode |
| 1123 | * a fair chance to prove itself without too many challenges. |
| 1124 | * |
| 1125 | * This gets called when transitioning to more aggressive modulation |
| 1126 | * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive |
| 1127 | * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need |
| 1128 | * to decrease to match "active" throughput. When moving from MIMO to SISO, |
| 1129 | * bit rate will typically need to increase, but not if performance was bad. |
| 1130 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1131 | static s32 rs_get_best_rate(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1132 | struct iwl4965_lq_sta *lq_sta, |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1133 | struct iwl4965_scale_tbl_info *tbl, /* "search" */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1134 | u16 rate_mask, s8 index, s8 rate) |
| 1135 | { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1136 | /* "active" values */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1137 | struct iwl4965_scale_tbl_info *active_tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1138 | &(lq_sta->lq_info[lq_sta->active_tbl]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1139 | s32 active_sr = active_tbl->win[index].success_ratio; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1140 | s32 active_tpt = active_tbl->expected_tpt[index]; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1141 | |
| 1142 | /* expected "search" throughput */ |
| 1143 | s32 *tpt_tbl = tbl->expected_tpt; |
| 1144 | |
| 1145 | s32 new_rate, high, low, start_hi; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1146 | u16 high_low; |
| 1147 | |
| 1148 | new_rate = high = low = start_hi = IWL_RATE_INVALID; |
| 1149 | |
| 1150 | for (; ;) { |
| 1151 | high_low = rs_get_adjacent_rate(rate, rate_mask, tbl->lq_type); |
| 1152 | |
| 1153 | low = high_low & 0xff; |
| 1154 | high = (high_low >> 8) & 0xff; |
| 1155 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1156 | /* |
| 1157 | * Lower the "search" bit rate, to give new "search" mode |
| 1158 | * approximately the same throughput as "active" if: |
| 1159 | * |
| 1160 | * 1) "Active" mode has been working modestly well (but not |
| 1161 | * great), and expected "search" throughput (under perfect |
| 1162 | * conditions) at candidate rate is above the actual |
| 1163 | * measured "active" throughput (but less than expected |
| 1164 | * "active" throughput under perfect conditions). |
| 1165 | * OR |
| 1166 | * 2) "Active" mode has been working perfectly or very well |
| 1167 | * and expected "search" throughput (under perfect |
| 1168 | * conditions) at candidate rate is above expected |
| 1169 | * "active" throughput (under perfect conditions). |
| 1170 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1171 | if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1172 | ((active_sr > IWL_RATE_DECREASE_TH) && |
| 1173 | (active_sr <= IWL_RATE_HIGH_TH) && |
| 1174 | (tpt_tbl[rate] <= active_tpt))) || |
| 1175 | ((active_sr >= IWL_RATE_SCALE_SWITCH) && |
| 1176 | (tpt_tbl[rate] > active_tpt))) { |
| 1177 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1178 | /* (2nd or later pass) |
| 1179 | * If we've already tried to raise the rate, and are |
| 1180 | * now trying to lower it, use the higher rate. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1181 | if (start_hi != IWL_RATE_INVALID) { |
| 1182 | new_rate = start_hi; |
| 1183 | break; |
| 1184 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1185 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1186 | new_rate = rate; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1187 | |
| 1188 | /* Loop again with lower rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1189 | if (low != IWL_RATE_INVALID) |
| 1190 | rate = low; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1191 | |
| 1192 | /* Lower rate not available, use the original */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1193 | else |
| 1194 | break; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1195 | |
| 1196 | /* Else try to raise the "search" rate to match "active" */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1197 | } else { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1198 | /* (2nd or later pass) |
| 1199 | * If we've already tried to lower the rate, and are |
| 1200 | * now trying to raise it, use the lower rate. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1201 | if (new_rate != IWL_RATE_INVALID) |
| 1202 | break; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1203 | |
| 1204 | /* Loop again with higher rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1205 | else if (high != IWL_RATE_INVALID) { |
| 1206 | start_hi = high; |
| 1207 | rate = high; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1208 | |
| 1209 | /* Higher rate not available, use the original */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1210 | } else { |
| 1211 | new_rate = rate; |
| 1212 | break; |
| 1213 | } |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | return new_rate; |
| 1218 | } |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 1219 | #endif /* CONFIG_IWL4965_HT */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1220 | |
| 1221 | static inline u8 rs_is_both_ant_supp(u8 valid_antenna) |
| 1222 | { |
| 1223 | return (rs_is_ant_connected(valid_antenna, ANT_BOTH)); |
| 1224 | } |
| 1225 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1226 | /* |
| 1227 | * Set up search table for MIMO |
| 1228 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1229 | static int rs_switch_to_mimo(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1230 | struct iwl4965_lq_sta *lq_sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1231 | struct ieee80211_conf *conf, |
| 1232 | struct sta_info *sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1233 | struct iwl4965_scale_tbl_info *tbl, int index) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1234 | { |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 1235 | #ifdef CONFIG_IWL4965_HT |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1236 | u16 rate_mask; |
| 1237 | s32 rate; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1238 | s8 is_green = lq_sta->is_green; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1239 | |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1240 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || |
| 1241 | !sta->ht_info.ht_supported) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1242 | return -1; |
| 1243 | |
| 1244 | IWL_DEBUG_HT("LQ: try to switch to MIMO\n"); |
| 1245 | tbl->lq_type = LQ_MIMO; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1246 | rs_get_supported_rates(lq_sta, NULL, tbl->lq_type, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1247 | &rate_mask); |
| 1248 | |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1249 | if (priv->current_ht_config.tx_mimo_ps_mode == IWL_MIMO_PS_STATIC) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1250 | return -1; |
| 1251 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1252 | /* Need both Tx chains/antennas to support MIMO */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1253 | if (!rs_is_both_ant_supp(lq_sta->antenna)) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1254 | return -1; |
| 1255 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1256 | tbl->is_dup = lq_sta->is_dup; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1257 | tbl->action = 0; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1258 | if (priv->current_ht_config.supported_chan_width |
| 1259 | == IWL_CHANNEL_WIDTH_40MHZ) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1260 | tbl->is_fat = 1; |
| 1261 | else |
| 1262 | tbl->is_fat = 0; |
| 1263 | |
| 1264 | if (tbl->is_fat) { |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1265 | if (priv->current_ht_config.sgf & HT_SHORT_GI_40MHZ_ONLY) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1266 | tbl->is_SGI = 1; |
| 1267 | else |
| 1268 | tbl->is_SGI = 0; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1269 | } else if (priv->current_ht_config.sgf & HT_SHORT_GI_20MHZ_ONLY) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1270 | tbl->is_SGI = 1; |
| 1271 | else |
| 1272 | tbl->is_SGI = 0; |
| 1273 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1274 | rs_get_expected_tpt_table(lq_sta, tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1275 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1276 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index, index); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1277 | |
| 1278 | IWL_DEBUG_HT("LQ: MIMO best rate %d mask %X\n", rate, rate_mask); |
| 1279 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) |
| 1280 | return -1; |
| 1281 | rs_mcs_from_tbl(&tbl->current_rate, tbl, rate, is_green); |
| 1282 | |
| 1283 | IWL_DEBUG_HT("LQ: Switch to new mcs %X index is green %X\n", |
| 1284 | tbl->current_rate.rate_n_flags, is_green); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1285 | return 0; |
Mohamed Abbas | 403ab56 | 2007-11-06 22:06:25 -0800 | [diff] [blame] | 1286 | #else |
| 1287 | return -1; |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1288 | #endif /*CONFIG_IWL4965_HT */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1291 | /* |
| 1292 | * Set up search table for SISO |
| 1293 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1294 | static int rs_switch_to_siso(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1295 | struct iwl4965_lq_sta *lq_sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1296 | struct ieee80211_conf *conf, |
| 1297 | struct sta_info *sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1298 | struct iwl4965_scale_tbl_info *tbl, int index) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1299 | { |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 1300 | #ifdef CONFIG_IWL4965_HT |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1301 | u16 rate_mask; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1302 | u8 is_green = lq_sta->is_green; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1303 | s32 rate; |
| 1304 | |
| 1305 | IWL_DEBUG_HT("LQ: try to switch to SISO\n"); |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1306 | if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || |
| 1307 | !sta->ht_info.ht_supported) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1308 | return -1; |
| 1309 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1310 | tbl->is_dup = lq_sta->is_dup; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1311 | tbl->lq_type = LQ_SISO; |
| 1312 | tbl->action = 0; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1313 | rs_get_supported_rates(lq_sta, NULL, tbl->lq_type, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1314 | &rate_mask); |
| 1315 | |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1316 | if (priv->current_ht_config.supported_chan_width |
| 1317 | == IWL_CHANNEL_WIDTH_40MHZ) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1318 | tbl->is_fat = 1; |
| 1319 | else |
| 1320 | tbl->is_fat = 0; |
| 1321 | |
| 1322 | if (tbl->is_fat) { |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1323 | if (priv->current_ht_config.sgf & HT_SHORT_GI_40MHZ_ONLY) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1324 | tbl->is_SGI = 1; |
| 1325 | else |
| 1326 | tbl->is_SGI = 0; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1327 | } else if (priv->current_ht_config.sgf & HT_SHORT_GI_20MHZ_ONLY) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1328 | tbl->is_SGI = 1; |
| 1329 | else |
| 1330 | tbl->is_SGI = 0; |
| 1331 | |
| 1332 | if (is_green) |
| 1333 | tbl->is_SGI = 0; |
| 1334 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1335 | rs_get_expected_tpt_table(lq_sta, tbl); |
| 1336 | rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index, index); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1337 | |
| 1338 | IWL_DEBUG_HT("LQ: get best rate %d mask %X\n", rate, rate_mask); |
| 1339 | if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { |
| 1340 | IWL_DEBUG_HT("can not switch with index %d rate mask %x\n", |
| 1341 | rate, rate_mask); |
| 1342 | return -1; |
| 1343 | } |
| 1344 | rs_mcs_from_tbl(&tbl->current_rate, tbl, rate, is_green); |
| 1345 | IWL_DEBUG_HT("LQ: Switch to new mcs %X index is green %X\n", |
| 1346 | tbl->current_rate.rate_n_flags, is_green); |
Mohamed Abbas | 403ab56 | 2007-11-06 22:06:25 -0800 | [diff] [blame] | 1347 | return 0; |
| 1348 | #else |
| 1349 | return -1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1350 | |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1351 | #endif /*CONFIG_IWL4965_HT */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1354 | /* |
| 1355 | * Try to switch to new modulation mode from legacy |
| 1356 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1357 | static int rs_move_legacy_other(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1358 | struct iwl4965_lq_sta *lq_sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1359 | struct ieee80211_conf *conf, |
| 1360 | struct sta_info *sta, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1361 | int index) |
| 1362 | { |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1363 | int ret = 0; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1364 | struct iwl4965_scale_tbl_info *tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1365 | &(lq_sta->lq_info[lq_sta->active_tbl]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1366 | struct iwl4965_scale_tbl_info *search_tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1367 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1368 | struct iwl4965_rate_scale_data *window = &(tbl->win[index]); |
| 1369 | u32 sz = (sizeof(struct iwl4965_scale_tbl_info) - |
| 1370 | (sizeof(struct iwl4965_rate_scale_data) * IWL_RATE_COUNT)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1371 | u8 start_action = tbl->action; |
| 1372 | |
| 1373 | for (; ;) { |
| 1374 | switch (tbl->action) { |
| 1375 | case IWL_LEGACY_SWITCH_ANTENNA: |
| 1376 | IWL_DEBUG_HT("LQ Legacy switch Antenna\n"); |
| 1377 | |
| 1378 | search_tbl->lq_type = LQ_NONE; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1379 | lq_sta->action_counter++; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1380 | |
| 1381 | /* Don't change antenna if success has been great */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1382 | if (window->success_ratio >= IWL_RS_GOOD_RATIO) |
| 1383 | break; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1384 | |
| 1385 | /* Don't change antenna if other one is not connected */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1386 | if (!rs_is_other_ant_connected(lq_sta->antenna, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1387 | tbl->antenna_type)) |
| 1388 | break; |
| 1389 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1390 | /* Set up search table to try other antenna */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1391 | memcpy(search_tbl, tbl, sz); |
| 1392 | |
| 1393 | rs_toggle_antenna(&(search_tbl->current_rate), |
| 1394 | search_tbl); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1395 | rs_get_expected_tpt_table(lq_sta, search_tbl); |
| 1396 | lq_sta->search_better_tbl = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1397 | goto out; |
| 1398 | |
| 1399 | case IWL_LEGACY_SWITCH_SISO: |
| 1400 | IWL_DEBUG_HT("LQ: Legacy switch to SISO\n"); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1401 | |
| 1402 | /* Set up search table to try SISO */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1403 | memcpy(search_tbl, tbl, sz); |
| 1404 | search_tbl->lq_type = LQ_SISO; |
| 1405 | search_tbl->is_SGI = 0; |
| 1406 | search_tbl->is_fat = 0; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1407 | ret = rs_switch_to_siso(priv, lq_sta, conf, sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1408 | search_tbl, index); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1409 | if (!ret) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1410 | lq_sta->search_better_tbl = 1; |
| 1411 | lq_sta->action_counter = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1412 | goto out; |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1413 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1414 | |
| 1415 | break; |
| 1416 | case IWL_LEGACY_SWITCH_MIMO: |
| 1417 | IWL_DEBUG_HT("LQ: Legacy switch MIMO\n"); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1418 | |
| 1419 | /* Set up search table to try MIMO */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1420 | memcpy(search_tbl, tbl, sz); |
| 1421 | search_tbl->lq_type = LQ_MIMO; |
| 1422 | search_tbl->is_SGI = 0; |
| 1423 | search_tbl->is_fat = 0; |
| 1424 | search_tbl->antenna_type = ANT_BOTH; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1425 | ret = rs_switch_to_mimo(priv, lq_sta, conf, sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1426 | search_tbl, index); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1427 | if (!ret) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1428 | lq_sta->search_better_tbl = 1; |
| 1429 | lq_sta->action_counter = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1430 | goto out; |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1431 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1432 | break; |
| 1433 | } |
| 1434 | tbl->action++; |
| 1435 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO) |
| 1436 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA; |
| 1437 | |
| 1438 | if (tbl->action == start_action) |
| 1439 | break; |
| 1440 | |
| 1441 | } |
| 1442 | return 0; |
| 1443 | |
| 1444 | out: |
| 1445 | tbl->action++; |
| 1446 | if (tbl->action > IWL_LEGACY_SWITCH_MIMO) |
| 1447 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA; |
| 1448 | return 0; |
| 1449 | |
| 1450 | } |
| 1451 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1452 | /* |
| 1453 | * Try to switch to new modulation mode from SISO |
| 1454 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1455 | static int rs_move_siso_to_other(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1456 | struct iwl4965_lq_sta *lq_sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1457 | struct ieee80211_conf *conf, |
| 1458 | struct sta_info *sta, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1459 | int index) |
| 1460 | { |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1461 | int ret; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1462 | u8 is_green = lq_sta->is_green; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1463 | struct iwl4965_scale_tbl_info *tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1464 | &(lq_sta->lq_info[lq_sta->active_tbl]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1465 | struct iwl4965_scale_tbl_info *search_tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1466 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1467 | struct iwl4965_rate_scale_data *window = &(tbl->win[index]); |
| 1468 | u32 sz = (sizeof(struct iwl4965_scale_tbl_info) - |
| 1469 | (sizeof(struct iwl4965_rate_scale_data) * IWL_RATE_COUNT)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1470 | u8 start_action = tbl->action; |
| 1471 | |
| 1472 | for (;;) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1473 | lq_sta->action_counter++; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1474 | switch (tbl->action) { |
| 1475 | case IWL_SISO_SWITCH_ANTENNA: |
| 1476 | IWL_DEBUG_HT("LQ: SISO SWITCH ANTENNA SISO\n"); |
| 1477 | search_tbl->lq_type = LQ_NONE; |
| 1478 | if (window->success_ratio >= IWL_RS_GOOD_RATIO) |
| 1479 | break; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1480 | if (!rs_is_other_ant_connected(lq_sta->antenna, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1481 | tbl->antenna_type)) |
| 1482 | break; |
| 1483 | |
| 1484 | memcpy(search_tbl, tbl, sz); |
| 1485 | search_tbl->action = IWL_SISO_SWITCH_MIMO; |
| 1486 | rs_toggle_antenna(&(search_tbl->current_rate), |
| 1487 | search_tbl); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1488 | lq_sta->search_better_tbl = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1489 | |
| 1490 | goto out; |
| 1491 | |
| 1492 | case IWL_SISO_SWITCH_MIMO: |
| 1493 | IWL_DEBUG_HT("LQ: SISO SWITCH TO MIMO FROM SISO\n"); |
| 1494 | memcpy(search_tbl, tbl, sz); |
| 1495 | search_tbl->lq_type = LQ_MIMO; |
| 1496 | search_tbl->is_SGI = 0; |
| 1497 | search_tbl->is_fat = 0; |
| 1498 | search_tbl->antenna_type = ANT_BOTH; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1499 | ret = rs_switch_to_mimo(priv, lq_sta, conf, sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1500 | search_tbl, index); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1501 | if (!ret) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1502 | lq_sta->search_better_tbl = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1503 | goto out; |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1504 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1505 | break; |
| 1506 | case IWL_SISO_SWITCH_GI: |
| 1507 | IWL_DEBUG_HT("LQ: SISO SWITCH TO GI\n"); |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1508 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1509 | memcpy(search_tbl, tbl, sz); |
| 1510 | search_tbl->action = 0; |
| 1511 | if (search_tbl->is_SGI) |
| 1512 | search_tbl->is_SGI = 0; |
| 1513 | else if (!is_green) |
| 1514 | search_tbl->is_SGI = 1; |
| 1515 | else |
| 1516 | break; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1517 | lq_sta->search_better_tbl = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1518 | if ((tbl->lq_type == LQ_SISO) && |
| 1519 | (tbl->is_SGI)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1520 | s32 tpt = lq_sta->last_tpt / 100; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1521 | if (((!tbl->is_fat) && |
| 1522 | (tpt >= expected_tpt_siso20MHz[index])) || |
| 1523 | ((tbl->is_fat) && |
| 1524 | (tpt >= expected_tpt_siso40MHz[index]))) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1525 | lq_sta->search_better_tbl = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1526 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1527 | rs_get_expected_tpt_table(lq_sta, search_tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1528 | rs_mcs_from_tbl(&search_tbl->current_rate, |
| 1529 | search_tbl, index, is_green); |
| 1530 | goto out; |
| 1531 | } |
| 1532 | tbl->action++; |
| 1533 | if (tbl->action > IWL_SISO_SWITCH_GI) |
| 1534 | tbl->action = IWL_SISO_SWITCH_ANTENNA; |
| 1535 | |
| 1536 | if (tbl->action == start_action) |
| 1537 | break; |
| 1538 | } |
| 1539 | return 0; |
| 1540 | |
| 1541 | out: |
| 1542 | tbl->action++; |
| 1543 | if (tbl->action > IWL_SISO_SWITCH_GI) |
| 1544 | tbl->action = IWL_SISO_SWITCH_ANTENNA; |
| 1545 | return 0; |
| 1546 | } |
| 1547 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1548 | /* |
| 1549 | * Try to switch to new modulation mode from MIMO |
| 1550 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1551 | static int rs_move_mimo_to_other(struct iwl4965_priv *priv, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1552 | struct iwl4965_lq_sta *lq_sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1553 | struct ieee80211_conf *conf, |
| 1554 | struct sta_info *sta, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1555 | int index) |
| 1556 | { |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1557 | int ret; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1558 | s8 is_green = lq_sta->is_green; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1559 | struct iwl4965_scale_tbl_info *tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1560 | &(lq_sta->lq_info[lq_sta->active_tbl]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1561 | struct iwl4965_scale_tbl_info *search_tbl = |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1562 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1563 | u32 sz = (sizeof(struct iwl4965_scale_tbl_info) - |
| 1564 | (sizeof(struct iwl4965_rate_scale_data) * IWL_RATE_COUNT)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1565 | u8 start_action = tbl->action; |
| 1566 | |
| 1567 | for (;;) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1568 | lq_sta->action_counter++; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1569 | switch (tbl->action) { |
| 1570 | case IWL_MIMO_SWITCH_ANTENNA_A: |
| 1571 | case IWL_MIMO_SWITCH_ANTENNA_B: |
| 1572 | IWL_DEBUG_HT("LQ: MIMO SWITCH TO SISO\n"); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1573 | |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1574 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1575 | /* Set up new search table for SISO */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1576 | memcpy(search_tbl, tbl, sz); |
| 1577 | search_tbl->lq_type = LQ_SISO; |
| 1578 | search_tbl->is_SGI = 0; |
| 1579 | search_tbl->is_fat = 0; |
| 1580 | if (tbl->action == IWL_MIMO_SWITCH_ANTENNA_A) |
| 1581 | search_tbl->antenna_type = ANT_MAIN; |
| 1582 | else |
| 1583 | search_tbl->antenna_type = ANT_AUX; |
| 1584 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1585 | ret = rs_switch_to_siso(priv, lq_sta, conf, sta, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1586 | search_tbl, index); |
Tomas Winkler | dc2453ae | 2007-10-25 17:15:25 +0800 | [diff] [blame] | 1587 | if (!ret) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1588 | lq_sta->search_better_tbl = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1589 | goto out; |
| 1590 | } |
| 1591 | break; |
| 1592 | |
| 1593 | case IWL_MIMO_SWITCH_GI: |
| 1594 | IWL_DEBUG_HT("LQ: MIMO SWITCH TO GI\n"); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1595 | |
| 1596 | /* Set up new search table for MIMO */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1597 | memcpy(search_tbl, tbl, sz); |
| 1598 | search_tbl->lq_type = LQ_MIMO; |
| 1599 | search_tbl->antenna_type = ANT_BOTH; |
| 1600 | search_tbl->action = 0; |
| 1601 | if (search_tbl->is_SGI) |
| 1602 | search_tbl->is_SGI = 0; |
| 1603 | else |
| 1604 | search_tbl->is_SGI = 1; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1605 | lq_sta->search_better_tbl = 1; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1606 | |
| 1607 | /* |
| 1608 | * If active table already uses the fastest possible |
| 1609 | * modulation (dual stream with short guard interval), |
| 1610 | * and it's working well, there's no need to look |
| 1611 | * for a better type of modulation! |
| 1612 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1613 | if ((tbl->lq_type == LQ_MIMO) && |
| 1614 | (tbl->is_SGI)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1615 | s32 tpt = lq_sta->last_tpt / 100; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1616 | if (((!tbl->is_fat) && |
| 1617 | (tpt >= expected_tpt_mimo20MHz[index])) || |
| 1618 | ((tbl->is_fat) && |
| 1619 | (tpt >= expected_tpt_mimo40MHz[index]))) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1620 | lq_sta->search_better_tbl = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1621 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1622 | rs_get_expected_tpt_table(lq_sta, search_tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1623 | rs_mcs_from_tbl(&search_tbl->current_rate, |
| 1624 | search_tbl, index, is_green); |
| 1625 | goto out; |
| 1626 | |
| 1627 | } |
| 1628 | tbl->action++; |
| 1629 | if (tbl->action > IWL_MIMO_SWITCH_GI) |
| 1630 | tbl->action = IWL_MIMO_SWITCH_ANTENNA_A; |
| 1631 | |
| 1632 | if (tbl->action == start_action) |
| 1633 | break; |
| 1634 | } |
| 1635 | |
| 1636 | return 0; |
| 1637 | out: |
| 1638 | tbl->action++; |
| 1639 | if (tbl->action > IWL_MIMO_SWITCH_GI) |
| 1640 | tbl->action = IWL_MIMO_SWITCH_ANTENNA_A; |
| 1641 | return 0; |
| 1642 | |
| 1643 | } |
| 1644 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1645 | /* |
| 1646 | * Check whether we should continue using same modulation mode, or |
| 1647 | * begin search for a new mode, based on: |
| 1648 | * 1) # tx successes or failures while using this mode |
| 1649 | * 2) # times calling this function |
| 1650 | * 3) elapsed time in this mode (not used, for now) |
| 1651 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1652 | static void rs_stay_in_table(struct iwl4965_lq_sta *lq_sta) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1653 | { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1654 | struct iwl4965_scale_tbl_info *tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1655 | int i; |
| 1656 | int active_tbl; |
| 1657 | int flush_interval_passed = 0; |
| 1658 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1659 | active_tbl = lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1660 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1661 | tbl = &(lq_sta->lq_info[active_tbl]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1662 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1663 | /* If we've been disallowing search, see if we should now allow it */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1664 | if (lq_sta->stay_in_tbl) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1665 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1666 | /* Elapsed time using current modulation mode */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1667 | if (lq_sta->flush_timer) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1668 | flush_interval_passed = |
| 1669 | time_after(jiffies, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1670 | (unsigned long)(lq_sta->flush_timer + |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1671 | IWL_RATE_SCALE_FLUSH_INTVL)); |
| 1672 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1673 | /* For now, disable the elapsed time criterion */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1674 | flush_interval_passed = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1675 | |
| 1676 | /* |
| 1677 | * Check if we should allow search for new modulation mode. |
| 1678 | * If many frames have failed or succeeded, or we've used |
| 1679 | * this same modulation for a long time, allow search, and |
| 1680 | * reset history stats that keep track of whether we should |
| 1681 | * allow a new search. Also (below) reset all bitmaps and |
| 1682 | * stats in active history. |
| 1683 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1684 | if ((lq_sta->total_failed > lq_sta->max_failure_limit) || |
| 1685 | (lq_sta->total_success > lq_sta->max_success_limit) || |
| 1686 | ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1687 | && (flush_interval_passed))) { |
| 1688 | IWL_DEBUG_HT("LQ: stay is expired %d %d %d\n:", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1689 | lq_sta->total_failed, |
| 1690 | lq_sta->total_success, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1691 | flush_interval_passed); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1692 | |
| 1693 | /* Allow search for new mode */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1694 | lq_sta->stay_in_tbl = 0; /* only place reset */ |
| 1695 | lq_sta->total_failed = 0; |
| 1696 | lq_sta->total_success = 0; |
| 1697 | lq_sta->flush_timer = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1698 | |
| 1699 | /* |
| 1700 | * Else if we've used this modulation mode enough repetitions |
| 1701 | * (regardless of elapsed time or success/failure), reset |
| 1702 | * history bitmaps and rate-specific stats for all rates in |
| 1703 | * active table. |
| 1704 | */ |
Mohamed Abbas | 403ab56 | 2007-11-06 22:06:25 -0800 | [diff] [blame] | 1705 | } else { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1706 | lq_sta->table_count++; |
| 1707 | if (lq_sta->table_count >= |
| 1708 | lq_sta->table_count_limit) { |
| 1709 | lq_sta->table_count = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1710 | |
| 1711 | IWL_DEBUG_HT("LQ: stay in table clear win\n"); |
| 1712 | for (i = 0; i < IWL_RATE_COUNT; i++) |
| 1713 | rs_rate_scale_clear_window( |
| 1714 | &(tbl->win[i])); |
| 1715 | } |
| 1716 | } |
| 1717 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1718 | /* If transitioning to allow "search", reset all history |
| 1719 | * bitmaps and stats in active table (this will become the new |
| 1720 | * "search" table). */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1721 | if (!lq_sta->stay_in_tbl) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1722 | for (i = 0; i < IWL_RATE_COUNT; i++) |
| 1723 | rs_rate_scale_clear_window(&(tbl->win[i])); |
| 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1728 | /* |
| 1729 | * Do rate scaling and search for new modulation mode. |
| 1730 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1731 | static void rs_rate_scale_perform(struct iwl4965_priv *priv, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1732 | struct net_device *dev, |
| 1733 | struct ieee80211_hdr *hdr, |
| 1734 | struct sta_info *sta) |
| 1735 | { |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 1736 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1737 | struct ieee80211_hw *hw = local_to_hw(local); |
| 1738 | struct ieee80211_conf *conf = &hw->conf; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1739 | int low = IWL_RATE_INVALID; |
| 1740 | int high = IWL_RATE_INVALID; |
| 1741 | int index; |
| 1742 | int i; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1743 | struct iwl4965_rate_scale_data *window = NULL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1744 | int current_tpt = IWL_INVALID_VALUE; |
| 1745 | int low_tpt = IWL_INVALID_VALUE; |
| 1746 | int high_tpt = IWL_INVALID_VALUE; |
| 1747 | u32 fail_count; |
| 1748 | s8 scale_action = 0; |
| 1749 | u16 fc, rate_mask; |
| 1750 | u8 update_lq = 0; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1751 | struct iwl4965_lq_sta *lq_sta; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1752 | struct iwl4965_scale_tbl_info *tbl, *tbl1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1753 | u16 rate_scale_index_msk = 0; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1754 | struct iwl4965_rate mcs_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1755 | u8 is_green = 0; |
| 1756 | u8 active_tbl = 0; |
| 1757 | u8 done_search = 0; |
| 1758 | u16 high_low; |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1759 | #ifdef CONFIG_IWL4965_HT |
| 1760 | u8 tid = MAX_TID_COUNT; |
| 1761 | __le16 *qc; |
| 1762 | #endif |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1763 | |
| 1764 | IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); |
| 1765 | |
| 1766 | fc = le16_to_cpu(hdr->frame_control); |
| 1767 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) { |
| 1768 | /* Send management frames and broadcast/multicast data using |
| 1769 | * lowest rate. */ |
| 1770 | /* TODO: this could probably be improved.. */ |
| 1771 | return; |
| 1772 | } |
| 1773 | |
| 1774 | if (!sta || !sta->rate_ctrl_priv) |
| 1775 | return; |
| 1776 | |
| 1777 | if (!priv->lq_mngr.lq_ready) { |
| 1778 | IWL_DEBUG_RATE("still rate scaling not ready\n"); |
| 1779 | return; |
| 1780 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1781 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1782 | |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 1783 | #ifdef CONFIG_IWL4965_HT |
| 1784 | qc = ieee80211_get_qos_ctrl(hdr); |
| 1785 | if (qc) { |
| 1786 | tid = (u8)(le16_to_cpu(*qc) & 0xf); |
| 1787 | rs_tl_add_packet(lq_sta, tid); |
| 1788 | } |
| 1789 | #endif |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1790 | /* |
| 1791 | * Select rate-scale / modulation-mode table to work with in |
| 1792 | * the rest of this function: "search" if searching for better |
| 1793 | * modulation mode, or "active" if doing rate scaling within a mode. |
| 1794 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1795 | if (!lq_sta->search_better_tbl) |
| 1796 | active_tbl = lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1797 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1798 | active_tbl = 1 - lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1799 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1800 | tbl = &(lq_sta->lq_info[active_tbl]); |
| 1801 | is_green = lq_sta->is_green; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1802 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1803 | /* current tx rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1804 | index = sta->last_txrate; |
| 1805 | |
| 1806 | IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, |
| 1807 | tbl->lq_type); |
| 1808 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1809 | /* rates available for this association, and for modulation mode */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1810 | rs_get_supported_rates(lq_sta, hdr, tbl->lq_type, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1811 | &rate_mask); |
| 1812 | |
| 1813 | IWL_DEBUG_RATE("mask 0x%04X \n", rate_mask); |
| 1814 | |
| 1815 | /* mask with station rate restriction */ |
| 1816 | if (is_legacy(tbl->lq_type)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1817 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1818 | /* supp_rates has no CCK bits in A mode */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1819 | rate_scale_index_msk = (u16) (rate_mask & |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1820 | (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1821 | else |
| 1822 | rate_scale_index_msk = (u16) (rate_mask & |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1823 | lq_sta->supp_rates); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1824 | |
| 1825 | } else |
| 1826 | rate_scale_index_msk = rate_mask; |
| 1827 | |
| 1828 | if (!rate_scale_index_msk) |
| 1829 | rate_scale_index_msk = rate_mask; |
| 1830 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1831 | /* If current rate is no longer supported on current association, |
| 1832 | * or user changed preferences for rates, find a new supported rate. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1833 | if (index < 0 || !((1 << index) & rate_scale_index_msk)) { |
| 1834 | index = IWL_INVALID_VALUE; |
| 1835 | update_lq = 1; |
| 1836 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1837 | /* get the highest available rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1838 | for (i = 0; i <= IWL_RATE_COUNT; i++) { |
| 1839 | if ((1 << i) & rate_scale_index_msk) |
| 1840 | index = i; |
| 1841 | } |
| 1842 | |
| 1843 | if (index == IWL_INVALID_VALUE) { |
| 1844 | IWL_WARNING("Can not find a suitable rate\n"); |
| 1845 | return; |
| 1846 | } |
| 1847 | } |
| 1848 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1849 | /* Get expected throughput table and history window for current rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1850 | if (!tbl->expected_tpt) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1851 | rs_get_expected_tpt_table(lq_sta, tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1852 | |
| 1853 | window = &(tbl->win[index]); |
| 1854 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1855 | /* |
| 1856 | * If there is not enough history to calculate actual average |
| 1857 | * throughput, keep analyzing results of more tx frames, without |
| 1858 | * changing rate or mode (bypass most of the rest of this function). |
| 1859 | * Set up new rate table in uCode only if old rate is not supported |
| 1860 | * in current association (use new rate found above). |
| 1861 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1862 | fail_count = window->counter - window->success_counter; |
| 1863 | if (((fail_count < IWL_RATE_MIN_FAILURE_TH) && |
| 1864 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) |
| 1865 | || (tbl->expected_tpt == NULL)) { |
| 1866 | IWL_DEBUG_RATE("LQ: still below TH succ %d total %d " |
| 1867 | "for index %d\n", |
| 1868 | window->success_counter, window->counter, index); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1869 | |
| 1870 | /* Can't calculate this yet; not enough history */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1871 | window->average_tpt = IWL_INVALID_VALUE; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1872 | |
| 1873 | /* Should we stay with this modulation mode, |
| 1874 | * or search for a new one? */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1875 | rs_stay_in_table(lq_sta); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1876 | |
| 1877 | /* Set up new rate table in uCode, if needed */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1878 | if (update_lq) { |
| 1879 | rs_mcs_from_tbl(&mcs_rate, tbl, index, is_green); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1880 | rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); |
| 1881 | rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1882 | } |
| 1883 | goto out; |
| 1884 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1885 | /* Else we have enough samples; calculate estimate of |
| 1886 | * actual average throughput */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1887 | } else |
| 1888 | window->average_tpt = ((window->success_ratio * |
| 1889 | tbl->expected_tpt[index] + 64) / 128); |
| 1890 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1891 | /* If we are searching for better modulation mode, check success. */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1892 | if (lq_sta->search_better_tbl) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1893 | int success_limit = IWL_RATE_SCALE_SWITCH; |
| 1894 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1895 | /* If good success, continue using the "search" mode; |
| 1896 | * no need to send new link quality command, since we're |
| 1897 | * continuing to use the setup that we've been trying. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1898 | if ((window->success_ratio > success_limit) || |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1899 | (window->average_tpt > lq_sta->last_tpt)) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1900 | if (!is_legacy(tbl->lq_type)) { |
| 1901 | IWL_DEBUG_HT("LQ: we are switching to HT" |
| 1902 | " rate suc %d current tpt %d" |
| 1903 | " old tpt %d\n", |
| 1904 | window->success_ratio, |
| 1905 | window->average_tpt, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1906 | lq_sta->last_tpt); |
| 1907 | lq_sta->enable_counter = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1908 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1909 | /* Swap tables; "search" becomes "active" */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1910 | lq_sta->active_tbl = active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1911 | current_tpt = window->average_tpt; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1912 | |
| 1913 | /* Else poor success; go back to mode in "active" table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1914 | } else { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1915 | /* Nullify "search" table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1916 | tbl->lq_type = LQ_NONE; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1917 | |
| 1918 | /* Revert to "active" table */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1919 | active_tbl = lq_sta->active_tbl; |
| 1920 | tbl = &(lq_sta->lq_info[active_tbl]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1921 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1922 | /* Revert to "active" rate and throughput info */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1923 | index = iwl4965_rate_index_from_plcp( |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1924 | tbl->current_rate.rate_n_flags); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1925 | current_tpt = lq_sta->last_tpt; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1926 | |
| 1927 | /* Need to set up a new rate table in uCode */ |
| 1928 | update_lq = 1; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1929 | IWL_DEBUG_HT("XXY GO BACK TO OLD TABLE\n"); |
| 1930 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1931 | |
| 1932 | /* Either way, we've made a decision; modulation mode |
| 1933 | * search is done, allow rate adjustment next time. */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 1934 | lq_sta->search_better_tbl = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1935 | done_search = 1; /* Don't switch modes below! */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1936 | goto lq_update; |
| 1937 | } |
| 1938 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1939 | /* (Else) not in search of better modulation mode, try for better |
| 1940 | * starting rate, while staying in this mode. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1941 | high_low = rs_get_adjacent_rate(index, rate_scale_index_msk, |
| 1942 | tbl->lq_type); |
| 1943 | low = high_low & 0xff; |
| 1944 | high = (high_low >> 8) & 0xff; |
| 1945 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1946 | /* Collect measured throughputs for current and adjacent rates */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1947 | current_tpt = window->average_tpt; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1948 | if (low != IWL_RATE_INVALID) |
| 1949 | low_tpt = tbl->win[low].average_tpt; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1950 | if (high != IWL_RATE_INVALID) |
| 1951 | high_tpt = tbl->win[high].average_tpt; |
| 1952 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1953 | /* Assume rate increase */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1954 | scale_action = 1; |
| 1955 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1956 | /* Too many failures, decrease rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1957 | if ((window->success_ratio <= IWL_RATE_DECREASE_TH) || |
| 1958 | (current_tpt == 0)) { |
| 1959 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); |
| 1960 | scale_action = -1; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1961 | |
| 1962 | /* No throughput measured yet for adjacent rates; try increase. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1963 | } else if ((low_tpt == IWL_INVALID_VALUE) && |
| 1964 | (high_tpt == IWL_INVALID_VALUE)) |
| 1965 | scale_action = 1; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1966 | |
| 1967 | /* Both adjacent throughputs are measured, but neither one has better |
| 1968 | * throughput; we're using the best rate, don't change it! */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1969 | else if ((low_tpt != IWL_INVALID_VALUE) && |
| 1970 | (high_tpt != IWL_INVALID_VALUE) && |
| 1971 | (low_tpt < current_tpt) && |
| 1972 | (high_tpt < current_tpt)) |
| 1973 | scale_action = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1974 | |
| 1975 | /* At least one adjacent rate's throughput is measured, |
| 1976 | * and may have better performance. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1977 | else { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1978 | /* Higher adjacent rate's throughput is measured */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1979 | if (high_tpt != IWL_INVALID_VALUE) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1980 | /* Higher rate has better throughput */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1981 | if (high_tpt > current_tpt) |
| 1982 | scale_action = 1; |
| 1983 | else { |
| 1984 | IWL_DEBUG_RATE |
| 1985 | ("decrease rate because of high tpt\n"); |
| 1986 | scale_action = -1; |
| 1987 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1988 | |
| 1989 | /* Lower adjacent rate's throughput is measured */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1990 | } else if (low_tpt != IWL_INVALID_VALUE) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 1991 | /* Lower rate has better throughput */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1992 | if (low_tpt > current_tpt) { |
| 1993 | IWL_DEBUG_RATE |
| 1994 | ("decrease rate because of low tpt\n"); |
| 1995 | scale_action = -1; |
| 1996 | } else |
| 1997 | scale_action = 1; |
| 1998 | } |
| 1999 | } |
| 2000 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2001 | /* Sanity check; asked for decrease, but success rate or throughput |
| 2002 | * has been good at old rate. Don't change it. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2003 | if (scale_action == -1) { |
| 2004 | if ((low != IWL_RATE_INVALID) && |
| 2005 | ((window->success_ratio > IWL_RATE_HIGH_TH) || |
| 2006 | (current_tpt > (100 * tbl->expected_tpt[low])))) |
| 2007 | scale_action = 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2008 | |
| 2009 | /* Sanity check; asked for increase, but success rate has not been great |
| 2010 | * even at old rate, higher rate will be worse. Don't change it. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2011 | } else if ((scale_action == 1) && |
| 2012 | (window->success_ratio < IWL_RATE_INCREASE_TH)) |
| 2013 | scale_action = 0; |
| 2014 | |
| 2015 | switch (scale_action) { |
| 2016 | case -1: |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2017 | /* Decrease starting rate, update uCode's rate table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2018 | if (low != IWL_RATE_INVALID) { |
| 2019 | update_lq = 1; |
| 2020 | index = low; |
| 2021 | } |
| 2022 | break; |
| 2023 | case 1: |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2024 | /* Increase starting rate, update uCode's rate table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2025 | if (high != IWL_RATE_INVALID) { |
| 2026 | update_lq = 1; |
| 2027 | index = high; |
| 2028 | } |
| 2029 | |
| 2030 | break; |
| 2031 | case 0: |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2032 | /* No change */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2033 | default: |
| 2034 | break; |
| 2035 | } |
| 2036 | |
| 2037 | IWL_DEBUG_HT("choose rate scale index %d action %d low %d " |
| 2038 | "high %d type %d\n", |
| 2039 | index, scale_action, low, high, tbl->lq_type); |
| 2040 | |
| 2041 | lq_update: |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2042 | /* Replace uCode's rate table for the destination station. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2043 | if (update_lq) { |
| 2044 | rs_mcs_from_tbl(&mcs_rate, tbl, index, is_green); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2045 | rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); |
| 2046 | rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2047 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2048 | |
| 2049 | /* Should we stay with this modulation mode, or search for a new one? */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2050 | rs_stay_in_table(lq_sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2051 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2052 | /* |
| 2053 | * Search for new modulation mode if we're: |
| 2054 | * 1) Not changing rates right now |
| 2055 | * 2) Not just finishing up a search |
| 2056 | * 3) Allowing a new search |
| 2057 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2058 | if (!update_lq && !done_search && !lq_sta->stay_in_tbl) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2059 | /* Save current throughput to compare with "search" throughput*/ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2060 | lq_sta->last_tpt = current_tpt; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2061 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2062 | /* Select a new "search" modulation mode to try. |
| 2063 | * If one is found, set up the new "search" table. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2064 | if (is_legacy(tbl->lq_type)) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2065 | rs_move_legacy_other(priv, lq_sta, conf, sta, index); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2066 | else if (is_siso(tbl->lq_type)) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2067 | rs_move_siso_to_other(priv, lq_sta, conf, sta, index); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2068 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2069 | rs_move_mimo_to_other(priv, lq_sta, conf, sta, index); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2070 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2071 | /* If new "search" mode was selected, set up in uCode table */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2072 | if (lq_sta->search_better_tbl) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2073 | /* Access the "search" table, clear its history. */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2074 | tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2075 | for (i = 0; i < IWL_RATE_COUNT; i++) |
| 2076 | rs_rate_scale_clear_window(&(tbl->win[i])); |
| 2077 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2078 | /* Use new "search" start rate */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2079 | index = iwl4965_rate_index_from_plcp( |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2080 | tbl->current_rate.rate_n_flags); |
| 2081 | |
| 2082 | IWL_DEBUG_HT("Switch current mcs: %X index: %d\n", |
| 2083 | tbl->current_rate.rate_n_flags, index); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2084 | rs_fill_link_cmd(lq_sta, &tbl->current_rate, |
| 2085 | &lq_sta->lq); |
| 2086 | rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2087 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2088 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2089 | /* If the "active" (non-search) mode was legacy, |
| 2090 | * and we've tried switching antennas, |
| 2091 | * but we haven't been able to try HT modes (not available), |
| 2092 | * stay with best antenna legacy modulation for a while |
| 2093 | * before next round of mode comparisons. */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2094 | tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2095 | if (is_legacy(tbl1->lq_type) && |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 2096 | #ifdef CONFIG_IWL4965_HT |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2097 | (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE)) && |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2098 | #endif |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2099 | (lq_sta->action_counter >= 1)) { |
| 2100 | lq_sta->action_counter = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2101 | IWL_DEBUG_HT("LQ: STAY in legacy table\n"); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2102 | rs_set_stay_in_table(1, lq_sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2103 | } |
| 2104 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2105 | /* If we're in an HT mode, and all 3 mode switch actions |
| 2106 | * have been tried and compared, stay in this best modulation |
| 2107 | * mode for a while before next round of mode comparisons. */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2108 | if (lq_sta->enable_counter && |
| 2109 | (lq_sta->action_counter >= IWL_ACTION_LIMIT)) { |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 2110 | #ifdef CONFIG_IWL4965_HT |
| 2111 | if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && |
| 2112 | (lq_sta->tx_agg_tid_en & (1 << tid)) && |
| 2113 | (tid != MAX_TID_COUNT)) { |
| 2114 | IWL_DEBUG_HT("try to aggregate tid %d\n", tid); |
| 2115 | rs_tl_turn_on_agg(priv, tid, lq_sta, sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2116 | } |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 2117 | #endif /*CONFIG_IWL4965_HT */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2118 | lq_sta->action_counter = 0; |
| 2119 | rs_set_stay_in_table(0, lq_sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2120 | } |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2121 | |
| 2122 | /* |
| 2123 | * Else, don't search for a new modulation mode. |
| 2124 | * Put new timestamp in stay-in-modulation-mode flush timer if: |
| 2125 | * 1) Not changing rates right now |
| 2126 | * 2) Not just finishing up a search |
| 2127 | * 3) flush timer is empty |
| 2128 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2129 | } else { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2130 | if ((!update_lq) && (!done_search) && (!lq_sta->flush_timer)) |
| 2131 | lq_sta->flush_timer = jiffies; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2132 | } |
| 2133 | |
| 2134 | out: |
| 2135 | rs_mcs_from_tbl(&tbl->current_rate, tbl, index, is_green); |
| 2136 | i = index; |
| 2137 | sta->last_txrate = i; |
| 2138 | |
| 2139 | /* sta->txrate is an index to A mode rates which start |
| 2140 | * at IWL_FIRST_OFDM_RATE |
| 2141 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2142 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2143 | sta->txrate = i - IWL_FIRST_OFDM_RATE; |
| 2144 | else |
| 2145 | sta->txrate = i; |
| 2146 | |
| 2147 | return; |
| 2148 | } |
| 2149 | |
| 2150 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2151 | static void rs_initialize_lq(struct iwl4965_priv *priv, |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2152 | struct ieee80211_conf *conf, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2153 | struct sta_info *sta) |
| 2154 | { |
| 2155 | int i; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2156 | struct iwl4965_lq_sta *lq_sta; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2157 | struct iwl4965_scale_tbl_info *tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2158 | u8 active_tbl = 0; |
| 2159 | int rate_idx; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2160 | u8 use_green = rs_use_green(priv, conf); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2161 | struct iwl4965_rate mcs_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2162 | |
| 2163 | if (!sta || !sta->rate_ctrl_priv) |
| 2164 | goto out; |
| 2165 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2166 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2167 | i = sta->last_txrate; |
| 2168 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2169 | if ((lq_sta->lq.sta_id == 0xff) && |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2170 | (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)) |
| 2171 | goto out; |
| 2172 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2173 | if (!lq_sta->search_better_tbl) |
| 2174 | active_tbl = lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2175 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2176 | active_tbl = 1 - lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2177 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2178 | tbl = &(lq_sta->lq_info[active_tbl]); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2179 | |
| 2180 | if ((i < 0) || (i >= IWL_RATE_COUNT)) |
| 2181 | i = 0; |
| 2182 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2183 | mcs_rate.rate_n_flags = iwl4965_rates[i].plcp ; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2184 | mcs_rate.rate_n_flags |= RATE_MCS_ANT_B_MSK; |
| 2185 | mcs_rate.rate_n_flags &= ~RATE_MCS_ANT_A_MSK; |
| 2186 | |
| 2187 | if (i >= IWL_FIRST_CCK_RATE && i <= IWL_LAST_CCK_RATE) |
| 2188 | mcs_rate.rate_n_flags |= RATE_MCS_CCK_MSK; |
| 2189 | |
| 2190 | tbl->antenna_type = ANT_AUX; |
| 2191 | rs_get_tbl_info_from_mcs(&mcs_rate, priv->phymode, tbl, &rate_idx); |
| 2192 | if (!rs_is_ant_connected(priv->valid_antenna, tbl->antenna_type)) |
Zhu Yi | 46640a8 | 2007-09-27 11:27:34 +0800 | [diff] [blame] | 2193 | rs_toggle_antenna(&mcs_rate, tbl); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2194 | |
| 2195 | rs_mcs_from_tbl(&mcs_rate, tbl, rate_idx, use_green); |
| 2196 | tbl->current_rate.rate_n_flags = mcs_rate.rate_n_flags; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2197 | rs_get_expected_tpt_table(lq_sta, tbl); |
| 2198 | rs_fill_link_cmd(lq_sta, &mcs_rate, &lq_sta->lq); |
| 2199 | rs_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2200 | out: |
| 2201 | return; |
| 2202 | } |
| 2203 | |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 2204 | static void rs_get_rate(void *priv_rate, struct net_device *dev, |
| 2205 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, |
| 2206 | struct rate_selection *sel) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2207 | { |
| 2208 | |
| 2209 | int i; |
| 2210 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2211 | struct ieee80211_conf *conf = &local->hw.conf; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2212 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 2213 | struct sta_info *sta; |
Michael Wu | 2bc454b | 2007-12-25 19:33:16 -0500 | [diff] [blame] | 2214 | u16 fc; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2215 | struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2216 | struct iwl4965_lq_sta *lq_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2217 | |
Zhu Yi | 5882635 | 2007-09-27 11:27:39 +0800 | [diff] [blame] | 2218 | IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2219 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2220 | sta = sta_info_get(local, hdr->addr1); |
| 2221 | |
Michael Wu | 2bc454b | 2007-12-25 19:33:16 -0500 | [diff] [blame] | 2222 | /* Send management frames and broadcast/multicast data using lowest |
| 2223 | * rate. */ |
| 2224 | fc = le16_to_cpu(hdr->frame_control); |
| 2225 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || |
| 2226 | !sta || !sta->rate_ctrl_priv) { |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 2227 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2228 | if (sta) |
| 2229 | sta_info_put(sta); |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 2230 | return; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2231 | } |
| 2232 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2233 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2234 | i = sta->last_txrate; |
| 2235 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2236 | if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) && |
| 2237 | !lq_sta->ibss_sta_added) { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2238 | u8 sta_id = iwl4965_hw_find_station(priv, hdr->addr1); |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2239 | DECLARE_MAC_BUF(mac); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2240 | |
| 2241 | if (sta_id == IWL_INVALID_STATION) { |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2242 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
| 2243 | print_mac(mac, hdr->addr1)); |
Ron Rindjunsky | 67d6203 | 2007-11-26 16:14:40 +0200 | [diff] [blame] | 2244 | sta_id = iwl4965_add_station_flags(priv, hdr->addr1, |
| 2245 | 0, CMD_ASYNC, NULL); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2246 | } |
| 2247 | if ((sta_id != IWL_INVALID_STATION)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2248 | lq_sta->lq.sta_id = sta_id; |
| 2249 | lq_sta->lq.rs_table[0].rate_n_flags = 0; |
| 2250 | lq_sta->ibss_sta_added = 1; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2251 | rs_initialize_lq(priv, conf, sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2252 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2253 | if (!lq_sta->ibss_sta_added) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2254 | goto done; |
| 2255 | } |
| 2256 | |
| 2257 | done: |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 2258 | if ((i < 0) || (i > IWL_RATE_COUNT)) { |
| 2259 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); |
| 2260 | return; |
| 2261 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2262 | sta_info_put(sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2263 | |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 2264 | sel->rate = &priv->ieee_rates[i]; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | static void *rs_alloc_sta(void *priv, gfp_t gfp) |
| 2268 | { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2269 | struct iwl4965_lq_sta *lq_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2270 | int i, j; |
| 2271 | |
| 2272 | IWL_DEBUG_RATE("create station rate scale window\n"); |
| 2273 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2274 | lq_sta = kzalloc(sizeof(struct iwl4965_lq_sta), gfp); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2275 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2276 | if (lq_sta == NULL) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2277 | return NULL; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2278 | lq_sta->lq.sta_id = 0xff; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2279 | |
Zhu Yi | 63fddb9 | 2007-09-27 11:27:36 +0800 | [diff] [blame] | 2280 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2281 | for (j = 0; j < LQ_SIZE; j++) |
| 2282 | for (i = 0; i < IWL_RATE_COUNT; i++) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2283 | rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2284 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2285 | return lq_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2286 | } |
| 2287 | |
| 2288 | static void rs_rate_init(void *priv_rate, void *priv_sta, |
| 2289 | struct ieee80211_local *local, |
| 2290 | struct sta_info *sta) |
| 2291 | { |
| 2292 | int i, j; |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2293 | struct ieee80211_conf *conf = &local->hw.conf; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2294 | struct ieee80211_hw_mode *mode = local->oper_hw_mode; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2295 | struct iwl4965_priv *priv = (struct iwl4965_priv *)priv_rate; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2296 | struct iwl4965_lq_sta *lq_sta = priv_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2297 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2298 | lq_sta->flush_timer = 0; |
| 2299 | lq_sta->supp_rates = sta->supp_rates; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2300 | sta->txrate = 3; |
| 2301 | for (j = 0; j < LQ_SIZE; j++) |
| 2302 | for (i = 0; i < IWL_RATE_COUNT; i++) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2303 | rs_rate_scale_clear_window(&(lq_sta->lq_info[j].win[i])); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2304 | |
| 2305 | IWL_DEBUG_RATE("rate scale global init\n"); |
| 2306 | /* TODO: what is a good starting rate for STA? About middle? Maybe not |
| 2307 | * the lowest or the highest rate.. Could consider using RSSI from |
| 2308 | * previous packets? Need to have IEEE 802.1X auth succeed immediately |
| 2309 | * after assoc.. */ |
| 2310 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2311 | lq_sta->ibss_sta_added = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2312 | if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2313 | u8 sta_id = iwl4965_hw_find_station(priv, sta->addr); |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2314 | DECLARE_MAC_BUF(mac); |
| 2315 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2316 | /* for IBSS the call are from tasklet */ |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2317 | IWL_DEBUG_HT("LQ: ADD station %s\n", |
| 2318 | print_mac(mac, sta->addr)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2319 | |
| 2320 | if (sta_id == IWL_INVALID_STATION) { |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 2321 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
| 2322 | print_mac(mac, sta->addr)); |
Ron Rindjunsky | 67d6203 | 2007-11-26 16:14:40 +0200 | [diff] [blame] | 2323 | sta_id = iwl4965_add_station_flags(priv, sta->addr, |
| 2324 | 0, CMD_ASYNC, NULL); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2325 | } |
| 2326 | if ((sta_id != IWL_INVALID_STATION)) { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2327 | lq_sta->lq.sta_id = sta_id; |
| 2328 | lq_sta->lq.rs_table[0].rate_n_flags = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2329 | } |
| 2330 | /* FIXME: this is w/a remove it later */ |
| 2331 | priv->assoc_station_added = 1; |
| 2332 | } |
| 2333 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2334 | /* Find highest tx rate supported by hardware and destination station */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2335 | for (i = 0; i < mode->num_rates; i++) { |
| 2336 | if ((sta->supp_rates & BIT(i)) && |
| 2337 | (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) |
| 2338 | sta->txrate = i; |
| 2339 | } |
| 2340 | sta->last_txrate = sta->txrate; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2341 | /* For MODE_IEEE80211A, cck rates are at end of rate table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2342 | if (local->hw.conf.phymode == MODE_IEEE80211A) |
| 2343 | sta->last_txrate += IWL_FIRST_OFDM_RATE; |
| 2344 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2345 | lq_sta->is_dup = 0; |
| 2346 | lq_sta->valid_antenna = priv->valid_antenna; |
| 2347 | lq_sta->antenna = priv->antenna; |
| 2348 | lq_sta->is_green = rs_use_green(priv, conf); |
| 2349 | lq_sta->active_rate = priv->active_rate; |
| 2350 | lq_sta->active_rate &= ~(0x1000); |
| 2351 | lq_sta->active_rate_basic = priv->active_rate_basic; |
| 2352 | lq_sta->phymode = priv->phymode; |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 2353 | #ifdef CONFIG_IWL4965_HT |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2354 | /* |
| 2355 | * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), |
| 2356 | * supp_rates[] does not; shift to convert format, force 9 MBits off. |
| 2357 | */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2358 | lq_sta->active_siso_rate = (priv->current_ht_config.supp_mcs_set[0] << 1); |
| 2359 | lq_sta->active_siso_rate |= |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2360 | (priv->current_ht_config.supp_mcs_set[0] & 0x1); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2361 | lq_sta->active_siso_rate &= ~((u16)0x2); |
| 2362 | lq_sta->active_siso_rate = |
| 2363 | lq_sta->active_siso_rate << IWL_FIRST_OFDM_RATE; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2364 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2365 | /* Same here */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2366 | lq_sta->active_mimo_rate = (priv->current_ht_config.supp_mcs_set[1] << 1); |
| 2367 | lq_sta->active_mimo_rate |= |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2368 | (priv->current_ht_config.supp_mcs_set[1] & 0x1); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2369 | lq_sta->active_mimo_rate &= ~((u16)0x2); |
| 2370 | lq_sta->active_mimo_rate = |
| 2371 | lq_sta->active_mimo_rate << IWL_FIRST_OFDM_RATE; |
| 2372 | IWL_DEBUG_HT("SISO RATE 0x%X MIMO RATE 0x%X\n", |
| 2373 | lq_sta->active_siso_rate, |
| 2374 | lq_sta->active_mimo_rate); |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 2375 | /* as default allow aggregation for all tids */ |
| 2376 | lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; |
Christoph Hellwig | c8b0e6e | 2007-10-25 17:15:51 +0800 | [diff] [blame] | 2377 | #endif /*CONFIG_IWL4965_HT*/ |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2378 | #ifdef CONFIG_MAC80211_DEBUGFS |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2379 | lq_sta->drv = priv; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2380 | #endif |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2381 | |
| 2382 | if (priv->assoc_station_added) |
| 2383 | priv->lq_mngr.lq_ready = 1; |
| 2384 | |
Ron Rindjunsky | 270243a | 2007-11-26 16:14:41 +0200 | [diff] [blame] | 2385 | rs_initialize_lq(priv, conf, sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2386 | } |
| 2387 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2388 | static void rs_fill_link_cmd(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2389 | struct iwl4965_rate *tx_mcs, |
| 2390 | struct iwl4965_link_quality_cmd *lq_cmd) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2391 | { |
| 2392 | int index = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2393 | int rate_idx; |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2394 | int repeat_rate = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2395 | u8 ant_toggle_count = 0; |
| 2396 | u8 use_ht_possible = 1; |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2397 | struct iwl4965_rate new_rate; |
| 2398 | struct iwl4965_scale_tbl_info tbl_type = { 0 }; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2399 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2400 | /* Override starting rate (index 0) if needed for debug purposes */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2401 | rs_dbgfs_set_mcs(lq_sta, tx_mcs, index); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2402 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2403 | /* Interpret rate_n_flags */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2404 | rs_get_tbl_info_from_mcs(tx_mcs, lq_sta->phymode, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2405 | &tbl_type, &rate_idx); |
| 2406 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2407 | /* How many times should we repeat the initial rate? */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2408 | if (is_legacy(tbl_type.lq_type)) { |
| 2409 | ant_toggle_count = 1; |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2410 | repeat_rate = IWL_NUMBER_TRY; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2411 | } else |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2412 | repeat_rate = IWL_HT_NUMBER_TRY; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2413 | |
| 2414 | lq_cmd->general_params.mimo_delimiter = |
| 2415 | is_mimo(tbl_type.lq_type) ? 1 : 0; |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2416 | |
| 2417 | /* Fill 1st table entry (index 0) */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2418 | lq_cmd->rs_table[index].rate_n_flags = |
| 2419 | cpu_to_le32(tx_mcs->rate_n_flags); |
| 2420 | new_rate.rate_n_flags = tx_mcs->rate_n_flags; |
| 2421 | |
| 2422 | if (is_mimo(tbl_type.lq_type) || (tbl_type.antenna_type == ANT_MAIN)) |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2423 | lq_cmd->general_params.single_stream_ant_msk |
| 2424 | = LINK_QUAL_ANT_A_MSK; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2425 | else |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2426 | lq_cmd->general_params.single_stream_ant_msk |
| 2427 | = LINK_QUAL_ANT_B_MSK; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2428 | |
| 2429 | index++; |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2430 | repeat_rate--; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2431 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2432 | /* Fill rest of rate table */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2433 | while (index < LINK_QUAL_MAX_RETRY_NUM) { |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2434 | /* Repeat initial/next rate. |
| 2435 | * For legacy IWL_NUMBER_TRY == 1, this loop will not execute. |
| 2436 | * For HT IWL_HT_NUMBER_TRY == 3, this executes twice. */ |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2437 | while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2438 | if (is_legacy(tbl_type.lq_type)) { |
| 2439 | if (ant_toggle_count < |
| 2440 | NUM_TRY_BEFORE_ANTENNA_TOGGLE) |
| 2441 | ant_toggle_count++; |
| 2442 | else { |
| 2443 | rs_toggle_antenna(&new_rate, &tbl_type); |
| 2444 | ant_toggle_count = 1; |
| 2445 | } |
| 2446 | } |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2447 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2448 | /* Override next rate if needed for debug purposes */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2449 | rs_dbgfs_set_mcs(lq_sta, &new_rate, index); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2450 | |
| 2451 | /* Fill next table entry */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2452 | lq_cmd->rs_table[index].rate_n_flags = |
| 2453 | cpu_to_le32(new_rate.rate_n_flags); |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2454 | repeat_rate--; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2455 | index++; |
| 2456 | } |
| 2457 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2458 | rs_get_tbl_info_from_mcs(&new_rate, lq_sta->phymode, &tbl_type, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2459 | &rate_idx); |
| 2460 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2461 | /* Indicate to uCode which entries might be MIMO. |
| 2462 | * If initial rate was MIMO, this will finally end up |
| 2463 | * as (IWL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2464 | if (is_mimo(tbl_type.lq_type)) |
| 2465 | lq_cmd->general_params.mimo_delimiter = index; |
| 2466 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2467 | /* Get next rate */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2468 | rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, |
Zhu Yi | 02dede0 | 2007-09-27 11:27:40 +0800 | [diff] [blame] | 2469 | use_ht_possible, &new_rate); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2470 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2471 | /* How many times should we repeat the next rate? */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2472 | if (is_legacy(tbl_type.lq_type)) { |
| 2473 | if (ant_toggle_count < NUM_TRY_BEFORE_ANTENNA_TOGGLE) |
| 2474 | ant_toggle_count++; |
| 2475 | else { |
| 2476 | rs_toggle_antenna(&new_rate, &tbl_type); |
| 2477 | ant_toggle_count = 1; |
| 2478 | } |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2479 | repeat_rate = IWL_NUMBER_TRY; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2480 | } else |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2481 | repeat_rate = IWL_HT_NUMBER_TRY; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2482 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2483 | /* Don't allow HT rates after next pass. |
| 2484 | * rs_get_lower_rate() will change type to LQ_A or LQ_G. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2485 | use_ht_possible = 0; |
| 2486 | |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2487 | /* Override next rate if needed for debug purposes */ |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2488 | rs_dbgfs_set_mcs(lq_sta, &new_rate, index); |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2489 | |
| 2490 | /* Fill next table entry */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2491 | lq_cmd->rs_table[index].rate_n_flags = |
| 2492 | cpu_to_le32(new_rate.rate_n_flags); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2493 | |
| 2494 | index++; |
Zhu Yi | 1b696de | 2007-09-27 11:27:41 +0800 | [diff] [blame] | 2495 | repeat_rate--; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2496 | } |
| 2497 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2498 | lq_cmd->general_params.dual_stream_ant_msk = 3; |
| 2499 | lq_cmd->agg_params.agg_dis_start_th = 3; |
| 2500 | lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2501 | } |
| 2502 | |
| 2503 | static void *rs_alloc(struct ieee80211_local *local) |
| 2504 | { |
| 2505 | return local->hw.priv; |
| 2506 | } |
| 2507 | /* rate scale requires free function to be implemented */ |
| 2508 | static void rs_free(void *priv_rate) |
| 2509 | { |
| 2510 | return; |
| 2511 | } |
| 2512 | |
| 2513 | static void rs_clear(void *priv_rate) |
| 2514 | { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2515 | struct iwl4965_priv *priv = (struct iwl4965_priv *) priv_rate; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2516 | |
| 2517 | IWL_DEBUG_RATE("enter\n"); |
| 2518 | |
| 2519 | priv->lq_mngr.lq_ready = 0; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2520 | |
| 2521 | IWL_DEBUG_RATE("leave\n"); |
| 2522 | } |
| 2523 | |
| 2524 | static void rs_free_sta(void *priv, void *priv_sta) |
| 2525 | { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2526 | struct iwl4965_lq_sta *lq_sta = priv_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2527 | |
| 2528 | IWL_DEBUG_RATE("enter\n"); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2529 | kfree(lq_sta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2530 | IWL_DEBUG_RATE("leave\n"); |
| 2531 | } |
| 2532 | |
| 2533 | |
Zhu Yi | 93dc646 | 2007-09-27 11:27:37 +0800 | [diff] [blame] | 2534 | #ifdef CONFIG_MAC80211_DEBUGFS |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2535 | static int open_file_generic(struct inode *inode, struct file *file) |
| 2536 | { |
| 2537 | file->private_data = inode->i_private; |
| 2538 | return 0; |
| 2539 | } |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2540 | static void rs_dbgfs_set_mcs(struct iwl4965_lq_sta *lq_sta, |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2541 | struct iwl4965_rate *mcs, int index) |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2542 | { |
Ron Rindjunsky | 4457e1a | 2007-10-15 14:40:56 +0200 | [diff] [blame] | 2543 | u32 base_rate; |
| 2544 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2545 | if (lq_sta->phymode == (u8) MODE_IEEE80211A) |
Ron Rindjunsky | 4457e1a | 2007-10-15 14:40:56 +0200 | [diff] [blame] | 2546 | base_rate = 0x800D; |
| 2547 | else |
| 2548 | base_rate = 0x820A; |
| 2549 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2550 | if (lq_sta->dbg_fixed.rate_n_flags) { |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2551 | if (index < 12) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2552 | mcs->rate_n_flags = lq_sta->dbg_fixed.rate_n_flags; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2553 | else |
Ron Rindjunsky | 4457e1a | 2007-10-15 14:40:56 +0200 | [diff] [blame] | 2554 | mcs->rate_n_flags = base_rate; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2555 | IWL_DEBUG_RATE("Fixed rate ON\n"); |
| 2556 | return; |
| 2557 | } |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2558 | |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2559 | IWL_DEBUG_RATE("Fixed rate OFF\n"); |
| 2560 | } |
| 2561 | |
| 2562 | static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file, |
| 2563 | const char __user *user_buf, size_t count, loff_t *ppos) |
| 2564 | { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2565 | struct iwl4965_lq_sta *lq_sta = file->private_data; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2566 | char buf[64]; |
| 2567 | int buf_size; |
| 2568 | u32 parsed_rate; |
| 2569 | |
| 2570 | memset(buf, 0, sizeof(buf)); |
| 2571 | buf_size = min(count, sizeof(buf) - 1); |
| 2572 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2573 | return -EFAULT; |
| 2574 | |
| 2575 | if (sscanf(buf, "%x", &parsed_rate) == 1) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2576 | lq_sta->dbg_fixed.rate_n_flags = parsed_rate; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2577 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2578 | lq_sta->dbg_fixed.rate_n_flags = 0; |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2579 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2580 | lq_sta->active_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ |
| 2581 | lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
| 2582 | lq_sta->active_mimo_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2583 | |
| 2584 | IWL_DEBUG_RATE("sta_id %d rate 0x%X\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2585 | lq_sta->lq.sta_id, lq_sta->dbg_fixed.rate_n_flags); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2586 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2587 | if (lq_sta->dbg_fixed.rate_n_flags) { |
| 2588 | rs_fill_link_cmd(lq_sta, &lq_sta->dbg_fixed, &lq_sta->lq); |
| 2589 | rs_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2590 | } |
| 2591 | |
| 2592 | return count; |
| 2593 | } |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2594 | |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2595 | static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file, |
| 2596 | char __user *user_buf, size_t count, loff_t *ppos) |
| 2597 | { |
| 2598 | char buff[1024]; |
| 2599 | int desc = 0; |
| 2600 | int i = 0; |
| 2601 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2602 | struct iwl4965_lq_sta *lq_sta = file->private_data; |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2603 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2604 | desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2605 | desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2606 | lq_sta->total_failed, lq_sta->total_success, |
| 2607 | lq_sta->active_rate); |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2608 | desc += sprintf(buff+desc, "fixed rate 0x%X\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2609 | lq_sta->dbg_fixed.rate_n_flags); |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2610 | desc += sprintf(buff+desc, "general:" |
| 2611 | "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2612 | lq_sta->lq.general_params.flags, |
| 2613 | lq_sta->lq.general_params.mimo_delimiter, |
| 2614 | lq_sta->lq.general_params.single_stream_ant_msk, |
| 2615 | lq_sta->lq.general_params.dual_stream_ant_msk); |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2616 | |
| 2617 | desc += sprintf(buff+desc, "agg:" |
| 2618 | "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2619 | le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), |
| 2620 | lq_sta->lq.agg_params.agg_dis_start_th, |
| 2621 | lq_sta->lq.agg_params.agg_frame_cnt_limit); |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2622 | |
| 2623 | desc += sprintf(buff+desc, |
| 2624 | "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2625 | lq_sta->lq.general_params.start_rate_index[0], |
| 2626 | lq_sta->lq.general_params.start_rate_index[1], |
| 2627 | lq_sta->lq.general_params.start_rate_index[2], |
| 2628 | lq_sta->lq.general_params.start_rate_index[3]); |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2629 | |
| 2630 | |
| 2631 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) |
| 2632 | desc += sprintf(buff+desc, " rate[%d] 0x%X\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2633 | i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2634 | |
| 2635 | return simple_read_from_buffer(user_buf, count, ppos, buff, desc); |
| 2636 | } |
| 2637 | |
| 2638 | static const struct file_operations rs_sta_dbgfs_scale_table_ops = { |
Zhu Yi | 98d7e09 | 2007-09-27 11:27:42 +0800 | [diff] [blame] | 2639 | .write = rs_sta_dbgfs_scale_table_write, |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2640 | .read = rs_sta_dbgfs_scale_table_read, |
| 2641 | .open = open_file_generic, |
| 2642 | }; |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2643 | static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file, |
| 2644 | char __user *user_buf, size_t count, loff_t *ppos) |
| 2645 | { |
| 2646 | char buff[1024]; |
| 2647 | int desc = 0; |
| 2648 | int i, j; |
| 2649 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2650 | struct iwl4965_lq_sta *lq_sta = file->private_data; |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2651 | for (i = 0; i < LQ_SIZE; i++) { |
| 2652 | desc += sprintf(buff+desc, "%s type=%d SGI=%d FAT=%d DUP=%d\n" |
| 2653 | "rate=0x%X\n", |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2654 | lq_sta->active_tbl == i?"*":"x", |
| 2655 | lq_sta->lq_info[i].lq_type, |
| 2656 | lq_sta->lq_info[i].is_SGI, |
| 2657 | lq_sta->lq_info[i].is_fat, |
| 2658 | lq_sta->lq_info[i].is_dup, |
| 2659 | lq_sta->lq_info[i].current_rate.rate_n_flags); |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2660 | for (j = 0; j < IWL_RATE_COUNT; j++) { |
| 2661 | desc += sprintf(buff+desc, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2662 | "counter=%d success=%d %%=%d\n", |
| 2663 | lq_sta->lq_info[i].win[j].counter, |
| 2664 | lq_sta->lq_info[i].win[j].success_counter, |
| 2665 | lq_sta->lq_info[i].win[j].success_ratio); |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2666 | } |
| 2667 | } |
| 2668 | return simple_read_from_buffer(user_buf, count, ppos, buff, desc); |
| 2669 | } |
| 2670 | |
| 2671 | static const struct file_operations rs_sta_dbgfs_stats_table_ops = { |
| 2672 | .read = rs_sta_dbgfs_stats_table_read, |
| 2673 | .open = open_file_generic, |
| 2674 | }; |
Zhu Yi | 5ae212c | 2007-09-27 11:27:38 +0800 | [diff] [blame] | 2675 | |
Zhu Yi | 93dc646 | 2007-09-27 11:27:37 +0800 | [diff] [blame] | 2676 | static void rs_add_debugfs(void *priv, void *priv_sta, |
| 2677 | struct dentry *dir) |
| 2678 | { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2679 | struct iwl4965_lq_sta *lq_sta = priv_sta; |
| 2680 | lq_sta->rs_sta_dbgfs_scale_table_file = |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2681 | debugfs_create_file("rate_scale_table", 0600, dir, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2682 | lq_sta, &rs_sta_dbgfs_scale_table_ops); |
| 2683 | lq_sta->rs_sta_dbgfs_stats_table_file = |
Zhu Yi | 0209dc1 | 2007-09-27 11:27:43 +0800 | [diff] [blame] | 2684 | debugfs_create_file("rate_stats_table", 0600, dir, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2685 | lq_sta, &rs_sta_dbgfs_stats_table_ops); |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 2686 | #ifdef CONFIG_IWL4965_HT |
| 2687 | lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = |
| 2688 | debugfs_create_u8("tx_agg_tid_enable", 0600, dir, |
| 2689 | &lq_sta->tx_agg_tid_en); |
| 2690 | #endif |
| 2691 | |
Zhu Yi | 93dc646 | 2007-09-27 11:27:37 +0800 | [diff] [blame] | 2692 | } |
| 2693 | |
| 2694 | static void rs_remove_debugfs(void *priv, void *priv_sta) |
| 2695 | { |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2696 | struct iwl4965_lq_sta *lq_sta = priv_sta; |
| 2697 | debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); |
| 2698 | debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); |
Ron Rindjunsky | 0c11b4d | 2008-01-28 14:07:26 +0200 | [diff] [blame^] | 2699 | #ifdef CONFIG_IWL4965_HT |
| 2700 | debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); |
| 2701 | #endif |
Zhu Yi | 93dc646 | 2007-09-27 11:27:37 +0800 | [diff] [blame] | 2702 | } |
| 2703 | #endif |
| 2704 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2705 | static struct rate_control_ops rs_ops = { |
| 2706 | .module = NULL, |
| 2707 | .name = RS_NAME, |
| 2708 | .tx_status = rs_tx_status, |
| 2709 | .get_rate = rs_get_rate, |
| 2710 | .rate_init = rs_rate_init, |
| 2711 | .clear = rs_clear, |
| 2712 | .alloc = rs_alloc, |
| 2713 | .free = rs_free, |
| 2714 | .alloc_sta = rs_alloc_sta, |
| 2715 | .free_sta = rs_free_sta, |
Zhu Yi | 93dc646 | 2007-09-27 11:27:37 +0800 | [diff] [blame] | 2716 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 2717 | .add_sta_debugfs = rs_add_debugfs, |
| 2718 | .remove_sta_debugfs = rs_remove_debugfs, |
| 2719 | #endif |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2720 | }; |
| 2721 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2722 | int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2723 | { |
| 2724 | struct ieee80211_local *local = hw_to_local(hw); |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2725 | struct iwl4965_priv *priv = hw->priv; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2726 | struct iwl4965_lq_sta *lq_sta; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2727 | struct sta_info *sta; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2728 | int cnt = 0, i; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2729 | u32 samples = 0, success = 0, good = 0; |
| 2730 | unsigned long now = jiffies; |
| 2731 | u32 max_time = 0; |
| 2732 | u8 lq_type, antenna; |
| 2733 | |
| 2734 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); |
| 2735 | if (!sta || !sta->rate_ctrl_priv) { |
| 2736 | if (sta) { |
| 2737 | sta_info_put(sta); |
| 2738 | IWL_DEBUG_RATE("leave - no private rate data!\n"); |
| 2739 | } else |
| 2740 | IWL_DEBUG_RATE("leave - no station!\n"); |
| 2741 | return sprintf(buf, "station %d not found\n", sta_id); |
| 2742 | } |
| 2743 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2744 | lq_sta = (void *)sta->rate_ctrl_priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2745 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2746 | lq_type = lq_sta->lq_info[lq_sta->active_tbl].lq_type; |
| 2747 | antenna = lq_sta->lq_info[lq_sta->active_tbl].antenna_type; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2748 | |
| 2749 | if (is_legacy(lq_type)) |
| 2750 | i = IWL_RATE_54M_INDEX; |
| 2751 | else |
| 2752 | i = IWL_RATE_60M_INDEX; |
| 2753 | while (1) { |
| 2754 | u64 mask; |
| 2755 | int j; |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2756 | int active = lq_sta->active_tbl; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2757 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2758 | cnt += |
| 2759 | sprintf(&buf[cnt], " %2dMbs: ", iwl4965_rates[i].ieee / 2); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2760 | |
| 2761 | mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1)); |
| 2762 | for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2763 | buf[cnt++] = |
| 2764 | (lq_sta->lq_info[active].win[i].data & mask) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2765 | ? '1' : '0'; |
| 2766 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2767 | samples += lq_sta->lq_info[active].win[i].counter; |
| 2768 | good += lq_sta->lq_info[active].win[i].success_counter; |
| 2769 | success += lq_sta->lq_info[active].win[i].success_counter * |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2770 | iwl4965_rates[i].ieee; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2771 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2772 | if (lq_sta->lq_info[active].win[i].stamp) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2773 | int delta = |
| 2774 | jiffies_to_msecs(now - |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2775 | lq_sta->lq_info[active].win[i].stamp); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2776 | |
| 2777 | if (delta > max_time) |
| 2778 | max_time = delta; |
| 2779 | |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2780 | cnt += sprintf(&buf[cnt], "%5dms\n", delta); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2781 | } else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2782 | buf[cnt++] = '\n'; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2783 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2784 | j = iwl4965_get_prev_ieee_rate(i); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2785 | if (j == i) |
| 2786 | break; |
| 2787 | i = j; |
| 2788 | } |
| 2789 | |
| 2790 | /* Display the average rate of all samples taken. |
| 2791 | * |
Ben Cahill | 7762635 | 2007-11-29 11:09:44 +0800 | [diff] [blame] | 2792 | * NOTE: We multiply # of samples by 2 since the IEEE measurement |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2793 | * added from iwl4965_rates is actually 2X the rate */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2794 | if (samples) |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2795 | cnt += sprintf(&buf[cnt], |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2796 | "\nAverage rate is %3d.%02dMbs over last %4dms\n" |
| 2797 | "%3d%% success (%d good packets over %d tries)\n", |
| 2798 | success / (2 * samples), (success * 5 / samples) % 10, |
| 2799 | max_time, good * 100 / samples, good, samples); |
| 2800 | else |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2801 | cnt += sprintf(&buf[cnt], "\nAverage rate: 0Mbs\n"); |
| 2802 | |
| 2803 | cnt += sprintf(&buf[cnt], "\nrate scale type %d antenna %d " |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2804 | "active_search %d rate index %d\n", lq_type, antenna, |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2805 | lq_sta->search_better_tbl, sta->last_txrate); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2806 | |
| 2807 | sta_info_put(sta); |
Tomas Winkler | c33104f | 2008-01-14 17:46:21 -0800 | [diff] [blame] | 2808 | return cnt; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2809 | } |
| 2810 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2811 | void iwl4965_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2812 | { |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2813 | struct iwl4965_priv *priv = hw->priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2814 | |
| 2815 | priv->lq_mngr.lq_ready = 1; |
| 2816 | } |
| 2817 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2818 | void iwl4965_rate_control_register(struct ieee80211_hw *hw) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2819 | { |
| 2820 | ieee80211_rate_control_register(&rs_ops); |
| 2821 | } |
| 2822 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 2823 | void iwl4965_rate_control_unregister(struct ieee80211_hw *hw) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2824 | { |
| 2825 | ieee80211_rate_control_unregister(&rs_ops); |
| 2826 | } |
| 2827 | |