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