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