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