Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004 Video54 Technologies, Inc. |
| 3 | * Copyright (c) 2004-2008 Atheros Communications, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 18 | #include "core.h" |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 19 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 20 | static struct ath_rate_table ar5416_11na_ratetable = { |
| 21 | 42, |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 22 | {0}, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 23 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 24 | { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 25 | 5400, 0x0b, 0x00, 12, |
| 26 | 0, 2, 1, 0, 0, 0, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 27 | { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 28 | 7800, 0x0f, 0x00, 18, |
| 29 | 0, 3, 1, 1, 1, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 30 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 31 | 10000, 0x0a, 0x00, 24, |
| 32 | 2, 4, 2, 2, 2, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 33 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 34 | 13900, 0x0e, 0x00, 36, |
| 35 | 2, 6, 2, 3, 3, 3, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 36 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 37 | 17300, 0x09, 0x00, 48, |
| 38 | 4, 10, 3, 4, 4, 4, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 39 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 40 | 23000, 0x0d, 0x00, 72, |
| 41 | 4, 14, 3, 5, 5, 5, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 42 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 43 | 27400, 0x08, 0x00, 96, |
| 44 | 4, 20, 3, 6, 6, 6, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 45 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 46 | 29300, 0x0c, 0x00, 108, |
| 47 | 4, 23, 3, 7, 7, 7, 7, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 48 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 49 | 6400, 0x80, 0x00, 0, |
| 50 | 0, 2, 3, 8, 24, 8, 24, 3216 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 51 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 52 | 12700, 0x81, 0x00, 1, |
| 53 | 2, 4, 3, 9, 25, 9, 25, 6434 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 54 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 55 | 18800, 0x82, 0x00, 2, |
| 56 | 2, 6, 3, 10, 26, 10, 26, 9650 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 57 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 58 | 25000, 0x83, 0x00, 3, |
| 59 | 4, 10, 3, 11, 27, 11, 27, 12868 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 60 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 61 | 36700, 0x84, 0x00, 4, |
| 62 | 4, 14, 3, 12, 28, 12, 28, 19304 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 63 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 64 | 48100, 0x85, 0x00, 5, |
| 65 | 4, 20, 3, 13, 29, 13, 29, 25740 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 66 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 67 | 53500, 0x86, 0x00, 6, |
| 68 | 4, 23, 3, 14, 30, 14, 30, 28956 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 69 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 70 | 59000, 0x87, 0x00, 7, |
| 71 | 4, 25, 3, 15, 31, 15, 32, 32180 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 72 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 73 | 12700, 0x88, 0x00, |
| 74 | 8, 0, 2, 3, 16, 33, 16, 33, 6430 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 75 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 76 | 24800, 0x89, 0x00, 9, |
| 77 | 2, 4, 3, 17, 34, 17, 34, 12860 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 78 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 79 | 36600, 0x8a, 0x00, 10, |
| 80 | 2, 6, 3, 18, 35, 18, 35, 19300 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 81 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 82 | 48100, 0x8b, 0x00, 11, |
| 83 | 4, 10, 3, 19, 36, 19, 36, 25736 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 84 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 85 | 69500, 0x8c, 0x00, 12, |
| 86 | 4, 14, 3, 20, 37, 20, 37, 38600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 87 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 88 | 89500, 0x8d, 0x00, 13, |
| 89 | 4, 20, 3, 21, 38, 21, 38, 51472 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 90 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 91 | 98900, 0x8e, 0x00, 14, |
| 92 | 4, 23, 3, 22, 39, 22, 39, 57890 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 93 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 94 | 108300, 0x8f, 0x00, 15, |
| 95 | 4, 25, 3, 23, 40, 23, 41, 64320 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 96 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 97 | 13200, 0x80, 0x00, 0, |
| 98 | 0, 2, 3, 8, 24, 24, 24, 6684 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 99 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 100 | 25900, 0x81, 0x00, 1, |
| 101 | 2, 4, 3, 9, 25, 25, 25, 13368 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 102 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 103 | 38600, 0x82, 0x00, 2, |
| 104 | 2, 6, 3, 10, 26, 26, 26, 20052 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 105 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 106 | 49800, 0x83, 0x00, 3, |
| 107 | 4, 10, 3, 11, 27, 27, 27, 26738 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 108 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 109 | 72200, 0x84, 0x00, 4, |
| 110 | 4, 14, 3, 12, 28, 28, 28, 40104 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 111 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 112 | 92900, 0x85, 0x00, 5, |
| 113 | 4, 20, 3, 13, 29, 29, 29, 53476 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 114 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 115 | 102700, 0x86, 0x00, 6, |
| 116 | 4, 23, 3, 14, 30, 30, 30, 60156 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 117 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 118 | 112000, 0x87, 0x00, 7, |
| 119 | 4, 25, 3, 15, 31, 32, 32, 66840 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 120 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 121 | 122000, 0x87, 0x00, 7, |
| 122 | 4, 25, 3, 15, 31, 32, 32, 74200 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 123 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 124 | 25800, 0x88, 0x00, 8, |
| 125 | 0, 2, 3, 16, 33, 33, 33, 13360 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 126 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 127 | 49800, 0x89, 0x00, 9, |
| 128 | 2, 4, 3, 17, 34, 34, 34, 26720 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 129 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 130 | 71900, 0x8a, 0x00, 10, |
| 131 | 2, 6, 3, 18, 35, 35, 35, 40080 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 132 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 133 | 92500, 0x8b, 0x00, 11, |
| 134 | 4, 10, 3, 19, 36, 36, 36, 53440 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 135 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 136 | 130300, 0x8c, 0x00, 12, |
| 137 | 4, 14, 3, 20, 37, 37, 37, 80160 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 138 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 139 | 162800, 0x8d, 0x00, 13, |
| 140 | 4, 20, 3, 21, 38, 38, 38, 106880 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 141 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 142 | 178200, 0x8e, 0x00, 14, |
| 143 | 4, 23, 3, 22, 39, 39, 39, 120240 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 144 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 145 | 192100, 0x8f, 0x00, 15, |
| 146 | 4, 25, 3, 23, 40, 41, 41, 133600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 147 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 148 | 207000, 0x8f, 0x00, 15, |
| 149 | 4, 25, 3, 23, 40, 41, 41, 148400 }, |
| 150 | }, |
| 151 | 50, /* probe interval */ |
| 152 | 50, /* rssi reduce interval */ |
| 153 | WLAN_RC_HT_FLAG, /* Phy rates allowed initially */ |
| 154 | }; |
| 155 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 156 | /* VALID_ALL - valid for 20/40/Legacy, |
| 157 | * VALID - Legacy only, |
| 158 | * VALID_20 - HT 20 only, |
| 159 | * VALID_40 - HT 40 only */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 160 | |
| 161 | /* 4ms frame limit not used for NG mode. The values filled |
| 162 | * for HT are the 64K max aggregate limit */ |
| 163 | |
| 164 | static struct ath_rate_table ar5416_11ng_ratetable = { |
| 165 | 46, |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 166 | {0}, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 167 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 168 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 169 | 900, 0x1b, 0x00, 2, |
| 170 | 0, 0, 1, 0, 0, 0, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 171 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 172 | 1900, 0x1a, 0x04, 4, |
| 173 | 1, 1, 1, 1, 1, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 174 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 175 | 4900, 0x19, 0x04, 11, |
| 176 | 2, 2, 2, 2, 2, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 177 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 178 | 8100, 0x18, 0x04, 22, |
| 179 | 3, 3, 2, 3, 3, 3, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 180 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 181 | 5400, 0x0b, 0x00, 12, |
| 182 | 4, 2, 1, 4, 4, 4, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 183 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 184 | 7800, 0x0f, 0x00, 18, |
| 185 | 4, 3, 1, 5, 5, 5, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 186 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 187 | 10100, 0x0a, 0x00, 24, |
| 188 | 6, 4, 1, 6, 6, 6, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 189 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 190 | 14100, 0x0e, 0x00, 36, |
| 191 | 6, 6, 2, 7, 7, 7, 7, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 192 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 193 | 17700, 0x09, 0x00, 48, |
| 194 | 8, 10, 3, 8, 8, 8, 8, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 195 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 196 | 23700, 0x0d, 0x00, 72, |
| 197 | 8, 14, 3, 9, 9, 9, 9, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 198 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 199 | 27400, 0x08, 0x00, 96, |
| 200 | 8, 20, 3, 10, 10, 10, 10, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 201 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 202 | 30900, 0x0c, 0x00, 108, |
| 203 | 8, 23, 3, 11, 11, 11, 11, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 204 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 205 | 6400, 0x80, 0x00, 0, |
| 206 | 4, 2, 3, 12, 28, 12, 28, 3216 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 207 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 208 | 12700, 0x81, 0x00, 1, |
| 209 | 6, 4, 3, 13, 29, 13, 29, 6434 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 210 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 211 | 18800, 0x82, 0x00, 2, |
| 212 | 6, 6, 3, 14, 30, 14, 30, 9650 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 213 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 214 | 25000, 0x83, 0x00, 3, |
| 215 | 8, 10, 3, 15, 31, 15, 31, 12868 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 216 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 217 | 36700, 0x84, 0x00, 4, |
| 218 | 8, 14, 3, 16, 32, 16, 32, 19304 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 219 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 220 | 48100, 0x85, 0x00, 5, |
| 221 | 8, 20, 3, 17, 33, 17, 33, 25740 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 222 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 223 | 53500, 0x86, 0x00, 6, |
| 224 | 8, 23, 3, 18, 34, 18, 34, 28956 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 225 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 226 | 59000, 0x87, 0x00, 7, |
| 227 | 8, 25, 3, 19, 35, 19, 36, 32180 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 228 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 229 | 12700, 0x88, 0x00, 8, |
| 230 | 4, 2, 3, 20, 37, 20, 37, 6430 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 231 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 232 | 24800, 0x89, 0x00, 9, |
| 233 | 6, 4, 3, 21, 38, 21, 38, 12860 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 234 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 235 | 36600, 0x8a, 0x00, 10, |
| 236 | 6, 6, 3, 22, 39, 22, 39, 19300 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 237 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 238 | 48100, 0x8b, 0x00, 11, |
| 239 | 8, 10, 3, 23, 40, 23, 40, 25736 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 240 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 241 | 69500, 0x8c, 0x00, 12, |
| 242 | 8, 14, 3, 24, 41, 24, 41, 38600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 243 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 244 | 89500, 0x8d, 0x00, 13, |
| 245 | 8, 20, 3, 25, 42, 25, 42, 51472 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 246 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 247 | 98900, 0x8e, 0x00, 14, |
| 248 | 8, 23, 3, 26, 43, 26, 44, 57890 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 249 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 250 | 108300, 0x8f, 0x00, 15, |
| 251 | 8, 25, 3, 27, 44, 27, 45, 64320 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 252 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 253 | 13200, 0x80, 0x00, 0, |
| 254 | 8, 2, 3, 12, 28, 28, 28, 6684 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 255 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 256 | 25900, 0x81, 0x00, 1, |
| 257 | 8, 4, 3, 13, 29, 29, 29, 13368 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 258 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 259 | 38600, 0x82, 0x00, 2, |
| 260 | 8, 6, 3, 14, 30, 30, 30, 20052 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 261 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 262 | 49800, 0x83, 0x00, 3, |
| 263 | 8, 10, 3, 15, 31, 31, 31, 26738 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 264 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 265 | 72200, 0x84, 0x00, 4, |
| 266 | 8, 14, 3, 16, 32, 32, 32, 40104 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 267 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 268 | 92900, 0x85, 0x00, 5, |
| 269 | 8, 20, 3, 17, 33, 33, 33, 53476 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 270 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 271 | 102700, 0x86, 0x00, 6, |
| 272 | 8, 23, 3, 18, 34, 34, 34, 60156 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 273 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 274 | 112000, 0x87, 0x00, 7, |
| 275 | 8, 23, 3, 19, 35, 36, 36, 66840 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 276 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 277 | 122000, 0x87, 0x00, 7, |
| 278 | 8, 25, 3, 19, 35, 36, 36, 74200 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 279 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 280 | 25800, 0x88, 0x00, 8, |
| 281 | 8, 2, 3, 20, 37, 37, 37, 13360 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 282 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 283 | 49800, 0x89, 0x00, 9, |
| 284 | 8, 4, 3, 21, 38, 38, 38, 26720 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 285 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 286 | 71900, 0x8a, 0x00, 10, |
| 287 | 8, 6, 3, 22, 39, 39, 39, 40080 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 288 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 289 | 92500, 0x8b, 0x00, 11, |
| 290 | 8, 10, 3, 23, 40, 40, 40, 53440 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 291 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 292 | 130300, 0x8c, 0x00, 12, |
| 293 | 8, 14, 3, 24, 41, 41, 41, 80160 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 294 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 295 | 162800, 0x8d, 0x00, 13, |
| 296 | 8, 20, 3, 25, 42, 42, 42, 106880 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 297 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 298 | 178200, 0x8e, 0x00, 14, |
| 299 | 8, 23, 3, 26, 43, 43, 43, 120240 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 300 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 301 | 192100, 0x8f, 0x00, 15, |
| 302 | 8, 23, 3, 27, 44, 45, 45, 133600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 303 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 304 | 207000, 0x8f, 0x00, 15, |
| 305 | 8, 25, 3, 27, 44, 45, 45, 148400 }, |
| 306 | }, |
| 307 | 50, /* probe interval */ |
| 308 | 50, /* rssi reduce interval */ |
| 309 | WLAN_RC_HT_FLAG, /* Phy rates allowed initially */ |
| 310 | }; |
| 311 | |
| 312 | static struct ath_rate_table ar5416_11a_ratetable = { |
| 313 | 8, |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 314 | {0}, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 315 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 316 | { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 317 | 5400, 0x0b, 0x00, (0x80|12), |
| 318 | 0, 2, 1, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 319 | { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 320 | 7800, 0x0f, 0x00, 18, |
| 321 | 0, 3, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 322 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 323 | 10000, 0x0a, 0x00, (0x80|24), |
| 324 | 2, 4, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 325 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 326 | 13900, 0x0e, 0x00, 36, |
| 327 | 2, 6, 2, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 328 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 329 | 17300, 0x09, 0x00, (0x80|48), |
| 330 | 4, 10, 3, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 331 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 332 | 23000, 0x0d, 0x00, 72, |
| 333 | 4, 14, 3, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 334 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 335 | 27400, 0x08, 0x00, 96, |
| 336 | 4, 19, 3, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 337 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 338 | 29300, 0x0c, 0x00, 108, |
| 339 | 4, 23, 3, 7, 0 }, |
| 340 | }, |
| 341 | 50, /* probe interval */ |
| 342 | 50, /* rssi reduce interval */ |
| 343 | 0, /* Phy rates allowed initially */ |
| 344 | }; |
| 345 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 346 | static struct ath_rate_table ar5416_11g_ratetable = { |
| 347 | 12, |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 348 | {0}, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 349 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 350 | { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 351 | 900, 0x1b, 0x00, 2, |
| 352 | 0, 0, 1, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 353 | { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 354 | 1900, 0x1a, 0x04, 4, |
| 355 | 1, 1, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 356 | { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 357 | 4900, 0x19, 0x04, 11, |
| 358 | 2, 2, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 359 | { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 360 | 8100, 0x18, 0x04, 22, |
| 361 | 3, 3, 2, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 362 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 363 | 5400, 0x0b, 0x00, 12, |
| 364 | 4, 2, 1, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 365 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 366 | 7800, 0x0f, 0x00, 18, |
| 367 | 4, 3, 1, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 368 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 369 | 10000, 0x0a, 0x00, 24, |
| 370 | 6, 4, 1, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 371 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 372 | 13900, 0x0e, 0x00, 36, |
| 373 | 6, 6, 2, 7, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 374 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 375 | 17300, 0x09, 0x00, 48, |
| 376 | 8, 10, 3, 8, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 377 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 378 | 23000, 0x0d, 0x00, 72, |
| 379 | 8, 14, 3, 9, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 380 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 381 | 27400, 0x08, 0x00, 96, |
| 382 | 8, 19, 3, 10, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 383 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 384 | 29300, 0x0c, 0x00, 108, |
| 385 | 8, 23, 3, 11, 0 }, |
| 386 | }, |
| 387 | 50, /* probe interval */ |
| 388 | 50, /* rssi reduce interval */ |
| 389 | 0, /* Phy rates allowed initially */ |
| 390 | }; |
| 391 | |
| 392 | static struct ath_rate_table ar5416_11b_ratetable = { |
| 393 | 4, |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 394 | {0}, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 395 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 396 | { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 397 | 900, 0x1b, 0x00, (0x80|2), |
| 398 | 0, 0, 1, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 399 | { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 400 | 1800, 0x1a, 0x04, (0x80|4), |
| 401 | 1, 1, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 402 | { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 403 | 4300, 0x19, 0x04, (0x80|11), |
| 404 | 1, 2, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 405 | { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 406 | 7100, 0x18, 0x04, (0x80|22), |
| 407 | 1, 4, 100, 3, 0 }, |
| 408 | }, |
| 409 | 100, /* probe interval */ |
| 410 | 100, /* rssi reduce interval */ |
| 411 | 0, /* Phy rates allowed initially */ |
| 412 | }; |
| 413 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 414 | static inline int8_t median(int8_t a, int8_t b, int8_t c) |
| 415 | { |
| 416 | if (a >= b) { |
| 417 | if (b >= c) |
| 418 | return b; |
| 419 | else if (a > c) |
| 420 | return c; |
| 421 | else |
| 422 | return a; |
| 423 | } else { |
| 424 | if (a >= c) |
| 425 | return a; |
| 426 | else if (b >= c) |
| 427 | return c; |
| 428 | else |
| 429 | return b; |
| 430 | } |
| 431 | } |
| 432 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 433 | static void ath_rc_sort_validrates(struct ath_rate_table *rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 434 | struct ath_rate_priv *ath_rc_priv) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 435 | { |
| 436 | u8 i, j, idx, idx_next; |
| 437 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 438 | for (i = ath_rc_priv->max_valid_rate - 1; i > 0; i--) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 439 | for (j = 0; j <= i-1; j++) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 440 | idx = ath_rc_priv->valid_rate_index[j]; |
| 441 | idx_next = ath_rc_priv->valid_rate_index[j+1]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 442 | |
| 443 | if (rate_table->info[idx].ratekbps > |
| 444 | rate_table->info[idx_next].ratekbps) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 445 | ath_rc_priv->valid_rate_index[j] = idx_next; |
| 446 | ath_rc_priv->valid_rate_index[j+1] = idx; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 447 | } |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 452 | static void ath_rc_init_valid_txmask(struct ath_rate_priv *ath_rc_priv) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 453 | { |
| 454 | u8 i; |
| 455 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 456 | for (i = 0; i < ath_rc_priv->rate_table_size; i++) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 457 | ath_rc_priv->valid_rate_index[i] = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 460 | static inline void ath_rc_set_valid_txmask(struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 461 | u8 index, int valid_tx_rate) |
| 462 | { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 463 | ASSERT(index <= ath_rc_priv->rate_table_size); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 464 | ath_rc_priv->valid_rate_index[index] = valid_tx_rate ? 1 : 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 465 | } |
| 466 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 467 | static inline int ath_rc_isvalid_txmask(struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 468 | u8 index) |
| 469 | { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 470 | ASSERT(index <= ath_rc_priv->rate_table_size); |
| 471 | return ath_rc_priv->valid_rate_index[index]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 472 | } |
| 473 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 474 | static inline int |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 475 | ath_rc_get_nextvalid_txrate(struct ath_rate_table *rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 476 | struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 477 | u8 cur_valid_txrate, |
| 478 | u8 *next_idx) |
| 479 | { |
| 480 | u8 i; |
| 481 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 482 | for (i = 0; i < ath_rc_priv->max_valid_rate - 1; i++) { |
| 483 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
| 484 | *next_idx = ath_rc_priv->valid_rate_index[i+1]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 485 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
| 489 | /* No more valid rates */ |
| 490 | *next_idx = 0; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 491 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | /* Return true only for single stream */ |
| 495 | |
| 496 | static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw) |
| 497 | { |
| 498 | if (WLAN_RC_PHY_HT(phy) & !(capflag & WLAN_RC_HT_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 499 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 500 | if (WLAN_RC_PHY_DS(phy) && !(capflag & WLAN_RC_DS_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 501 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 502 | if (WLAN_RC_PHY_SGI(phy) && !(capflag & WLAN_RC_SGI_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 503 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 504 | if (!ignore_cw && WLAN_RC_PHY_HT(phy)) |
| 505 | if (WLAN_RC_PHY_40(phy) && !(capflag & WLAN_RC_40_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 506 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 507 | if (!WLAN_RC_PHY_40(phy) && (capflag & WLAN_RC_40_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 508 | return 0; |
| 509 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | static inline int |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 513 | ath_rc_get_nextlowervalid_txrate(struct ath_rate_table *rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 514 | struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 515 | u8 cur_valid_txrate, u8 *next_idx) |
| 516 | { |
| 517 | int8_t i; |
| 518 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 519 | for (i = 1; i < ath_rc_priv->max_valid_rate ; i++) { |
| 520 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
| 521 | *next_idx = ath_rc_priv->valid_rate_index[i-1]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 522 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 523 | } |
| 524 | } |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 525 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 528 | static u8 |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 529 | ath_rc_sib_init_validrates(struct ath_rate_priv *ath_rc_priv, |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 530 | struct ath_rate_table *rate_table, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 531 | u32 capflag) |
| 532 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 533 | u8 i, hi = 0; |
| 534 | u32 valid; |
| 535 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 536 | for (i = 0; i < rate_table->rate_cnt; i++) { |
| 537 | valid = (ath_rc_priv->single_stream ? |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 538 | rate_table->info[i].valid_single_stream : |
| 539 | rate_table->info[i].valid); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 540 | if (valid == 1) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 541 | u32 phy = rate_table->info[i].phy; |
| 542 | u8 valid_rate_count = 0; |
| 543 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 544 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 545 | continue; |
| 546 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 547 | valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 548 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 549 | ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = i; |
| 550 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 551 | ath_rc_set_valid_txmask(ath_rc_priv, i, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 552 | hi = A_MAX(hi, i); |
| 553 | } |
| 554 | } |
| 555 | return hi; |
| 556 | } |
| 557 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 558 | static u8 |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 559 | ath_rc_sib_setvalid_rates(struct ath_rate_priv *ath_rc_priv, |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 560 | struct ath_rate_table *rate_table, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 561 | struct ath_rateset *rateset, |
| 562 | u32 capflag) |
| 563 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 564 | u8 i, j, hi = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 565 | |
| 566 | /* Use intersection of working rates and valid rates */ |
| 567 | for (i = 0; i < rateset->rs_nrates; i++) { |
| 568 | for (j = 0; j < rate_table->rate_cnt; j++) { |
| 569 | u32 phy = rate_table->info[j].phy; |
| 570 | u32 valid = (ath_rc_priv->single_stream ? |
| 571 | rate_table->info[j].valid_single_stream : |
| 572 | rate_table->info[j].valid); |
| 573 | |
| 574 | /* We allow a rate only if its valid and the |
| 575 | * capflag matches one of the validity |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 576 | * (VALID/VALID_20/VALID_40) flags */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 577 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 578 | if (((rateset->rs_rates[i] & 0x7F) == |
| 579 | (rate_table->info[j].dot11rate & 0x7F)) && |
| 580 | ((valid & WLAN_RC_CAP_MODE(capflag)) == |
| 581 | WLAN_RC_CAP_MODE(capflag)) && |
| 582 | !WLAN_RC_PHY_HT(phy)) { |
| 583 | |
| 584 | u8 valid_rate_count = 0; |
| 585 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 586 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 587 | continue; |
| 588 | |
| 589 | valid_rate_count = |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 590 | ath_rc_priv->valid_phy_ratecnt[phy]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 591 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 592 | ath_rc_priv->valid_phy_rateidx[phy] |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 593 | [valid_rate_count] = j; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 594 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 595 | ath_rc_set_valid_txmask(ath_rc_priv, j, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 596 | hi = A_MAX(hi, j); |
| 597 | } |
| 598 | } |
| 599 | } |
| 600 | return hi; |
| 601 | } |
| 602 | |
| 603 | static u8 |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 604 | ath_rc_sib_setvalid_htrates(struct ath_rate_priv *ath_rc_priv, |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 605 | struct ath_rate_table *rate_table, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 606 | u8 *mcs_set, u32 capflag) |
| 607 | { |
| 608 | u8 i, j, hi = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 609 | |
| 610 | /* Use intersection of working rates and valid rates */ |
| 611 | for (i = 0; i < ((struct ath_rateset *)mcs_set)->rs_nrates; i++) { |
| 612 | for (j = 0; j < rate_table->rate_cnt; j++) { |
| 613 | u32 phy = rate_table->info[j].phy; |
| 614 | u32 valid = (ath_rc_priv->single_stream ? |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 615 | rate_table->info[j].valid_single_stream : |
| 616 | rate_table->info[j].valid); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 617 | |
| 618 | if (((((struct ath_rateset *) |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 619 | mcs_set)->rs_rates[i] & 0x7F) != |
| 620 | (rate_table->info[j].dot11rate & 0x7F)) || |
| 621 | !WLAN_RC_PHY_HT(phy) || |
| 622 | !WLAN_RC_PHY_HT_VALID(valid, capflag)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 623 | continue; |
| 624 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 625 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 626 | continue; |
| 627 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 628 | ath_rc_priv->valid_phy_rateidx[phy] |
| 629 | [ath_rc_priv->valid_phy_ratecnt[phy]] = j; |
| 630 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 631 | ath_rc_set_valid_txmask(ath_rc_priv, j, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 632 | hi = A_MAX(hi, j); |
| 633 | } |
| 634 | } |
| 635 | return hi; |
| 636 | } |
| 637 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 638 | u8 ath_rate_findrateix(struct ath_softc *sc, |
Sujith | 102e057 | 2008-10-29 10:15:16 +0530 | [diff] [blame] | 639 | u8 dot11rate) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 640 | { |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 641 | struct ath_rate_table *ratetable; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 642 | int i; |
| 643 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 644 | ratetable = sc->hw_rate_table[sc->sc_curmode]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 645 | |
| 646 | if (WARN_ON(!ratetable)) |
| 647 | return 0; |
| 648 | |
| 649 | for (i = 0; i < ratetable->rate_cnt; i++) { |
| 650 | if ((ratetable->info[i].dot11rate & 0x7f) == (dot11rate & 0x7f)) |
| 651 | return i; |
| 652 | } |
| 653 | |
| 654 | return 0; |
| 655 | } |
| 656 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 657 | static u8 ath_rc_ratefind_ht(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 658 | struct ath_rate_priv *ath_rc_priv, |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 659 | struct ath_rate_table *rate_table, |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 660 | int probe_allowed, int *is_probing, |
| 661 | int is_retry) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 662 | { |
| 663 | u32 dt, best_thruput, this_thruput, now_msec; |
| 664 | u8 rate, next_rate, best_rate, maxindex, minindex; |
| 665 | int8_t rssi_last, rssi_reduce = 0, index = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 666 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 667 | *is_probing = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 668 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 669 | rssi_last = median(ath_rc_priv->rssi_last, |
| 670 | ath_rc_priv->rssi_last_prev, |
| 671 | ath_rc_priv->rssi_last_prev2); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 672 | |
| 673 | /* |
| 674 | * Age (reduce) last ack rssi based on how old it is. |
| 675 | * The bizarre numbers are so the delta is 160msec, |
| 676 | * meaning we divide by 16. |
| 677 | * 0msec <= dt <= 25msec: don't derate |
| 678 | * 25msec <= dt <= 185msec: derate linearly from 0 to 10dB |
| 679 | * 185msec <= dt: derate by 10dB |
| 680 | */ |
| 681 | |
| 682 | now_msec = jiffies_to_msecs(jiffies); |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 683 | dt = now_msec - ath_rc_priv->rssi_time; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 684 | |
| 685 | if (dt >= 185) |
| 686 | rssi_reduce = 10; |
| 687 | else if (dt >= 25) |
| 688 | rssi_reduce = (u8)((dt - 25) >> 4); |
| 689 | |
| 690 | /* Now reduce rssi_last by rssi_reduce */ |
| 691 | if (rssi_last < rssi_reduce) |
| 692 | rssi_last = 0; |
| 693 | else |
| 694 | rssi_last -= rssi_reduce; |
| 695 | |
| 696 | /* |
| 697 | * Now look up the rate in the rssi table and return it. |
| 698 | * If no rates match then we return 0 (lowest rate) |
| 699 | */ |
| 700 | |
| 701 | best_thruput = 0; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 702 | maxindex = ath_rc_priv->max_valid_rate-1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 703 | |
| 704 | minindex = 0; |
| 705 | best_rate = minindex; |
| 706 | |
| 707 | /* |
| 708 | * Try the higher rate first. It will reduce memory moving time |
| 709 | * if we have very good channel characteristics. |
| 710 | */ |
| 711 | for (index = maxindex; index >= minindex ; index--) { |
| 712 | u8 per_thres; |
| 713 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 714 | rate = ath_rc_priv->valid_rate_index[index]; |
| 715 | if (rate > ath_rc_priv->rate_max_phy) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 716 | continue; |
| 717 | |
| 718 | /* |
| 719 | * For TCP the average collision rate is around 11%, |
| 720 | * so we ignore PERs less than this. This is to |
| 721 | * prevent the rate we are currently using (whose |
| 722 | * PER might be in the 10-15 range because of TCP |
| 723 | * collisions) looking worse than the next lower |
| 724 | * rate whose PER has decayed close to 0. If we |
| 725 | * used to next lower rate, its PER would grow to |
| 726 | * 10-15 and we would be worse off then staying |
| 727 | * at the current rate. |
| 728 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 729 | per_thres = ath_rc_priv->state[rate].per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 730 | if (per_thres < 12) |
| 731 | per_thres = 12; |
| 732 | |
| 733 | this_thruput = rate_table->info[rate].user_ratekbps * |
| 734 | (100 - per_thres); |
| 735 | |
| 736 | if (best_thruput <= this_thruput) { |
| 737 | best_thruput = this_thruput; |
| 738 | best_rate = rate; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | rate = best_rate; |
| 743 | |
| 744 | /* if we are retrying for more than half the number |
| 745 | * of max retries, use the min rate for the next retry |
| 746 | */ |
| 747 | if (is_retry) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 748 | rate = ath_rc_priv->valid_rate_index[minindex]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 749 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 750 | ath_rc_priv->rssi_last_lookup = rssi_last; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 751 | |
| 752 | /* |
| 753 | * Must check the actual rate (ratekbps) to account for |
| 754 | * non-monoticity of 11g's rate table |
| 755 | */ |
| 756 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 757 | if (rate >= ath_rc_priv->rate_max_phy && probe_allowed) { |
| 758 | rate = ath_rc_priv->rate_max_phy; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 759 | |
| 760 | /* Probe the next allowed phy state */ |
| 761 | /* FIXME:XXXX Check to make sure ratMax is checked properly */ |
| 762 | if (ath_rc_get_nextvalid_txrate(rate_table, |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 763 | ath_rc_priv, rate, &next_rate) && |
| 764 | (now_msec - ath_rc_priv->probe_time > |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 765 | rate_table->probe_interval) && |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 766 | (ath_rc_priv->hw_maxretry_pktcnt >= 1)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 767 | rate = next_rate; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 768 | ath_rc_priv->probe_rate = rate; |
| 769 | ath_rc_priv->probe_time = now_msec; |
| 770 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 771 | *is_probing = 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 772 | } |
| 773 | } |
| 774 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 775 | if (rate > (ath_rc_priv->rate_table_size - 1)) |
| 776 | rate = ath_rc_priv->rate_table_size - 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 777 | |
| 778 | ASSERT((rate_table->info[rate].valid && !ath_rc_priv->single_stream) || |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 779 | (rate_table->info[rate].valid_single_stream && |
| 780 | ath_rc_priv->single_stream)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 781 | |
| 782 | return rate; |
| 783 | } |
| 784 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 785 | static void ath_rc_rate_set_series(struct ath_rate_table *rate_table , |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 786 | struct ieee80211_tx_rate *rate, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 787 | u8 tries, |
| 788 | u8 rix, |
| 789 | int rtsctsenable) |
| 790 | { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 791 | rate->count = tries; |
| 792 | rate->idx = rix; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 793 | |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 794 | if (rtsctsenable) |
| 795 | rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS; |
| 796 | if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) |
| 797 | rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; |
| 798 | if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy)) |
| 799 | rate->flags |= IEEE80211_TX_RC_SHORT_GI; |
| 800 | if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) |
| 801 | rate->flags |= IEEE80211_TX_RC_MCS; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | static u8 ath_rc_rate_getidx(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 805 | struct ath_rate_priv *ath_rc_priv, |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 806 | struct ath_rate_table *rate_table, |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 807 | u8 rix, u16 stepdown, |
| 808 | u16 min_rate) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 809 | { |
| 810 | u32 j; |
| 811 | u8 nextindex; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 812 | |
| 813 | if (min_rate) { |
| 814 | for (j = RATE_TABLE_SIZE; j > 0; j--) { |
| 815 | if (ath_rc_get_nextlowervalid_txrate(rate_table, |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 816 | ath_rc_priv, rix, &nextindex)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 817 | rix = nextindex; |
| 818 | else |
| 819 | break; |
| 820 | } |
| 821 | } else { |
| 822 | for (j = stepdown; j > 0; j--) { |
| 823 | if (ath_rc_get_nextlowervalid_txrate(rate_table, |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 824 | ath_rc_priv, rix, &nextindex)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 825 | rix = nextindex; |
| 826 | else |
| 827 | break; |
| 828 | } |
| 829 | } |
| 830 | return rix; |
| 831 | } |
| 832 | |
| 833 | static void ath_rc_ratefind(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 834 | struct ath_rate_priv *ath_rc_priv, |
| 835 | int num_tries, int num_rates, |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 836 | struct ieee80211_tx_info *tx_info, int *is_probe, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 837 | int is_retry) |
| 838 | { |
| 839 | u8 try_per_rate = 0, i = 0, rix, nrix; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 840 | struct ath_rate_table *rate_table; |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 841 | struct ieee80211_tx_rate *rates = tx_info->control.rates; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 842 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 843 | rate_table = sc->hw_rate_table[sc->sc_curmode]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 844 | rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, 1, |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 845 | is_probe, is_retry); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 846 | nrix = rix; |
| 847 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 848 | if (*is_probe) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 849 | /* set one try for probe rates. For the |
| 850 | * probes don't enable rts */ |
| 851 | ath_rc_rate_set_series(rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 852 | &rates[i++], 1, nrix, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 853 | |
| 854 | try_per_rate = (num_tries/num_rates); |
| 855 | /* Get the next tried/allowed rate. No RTS for the next series |
| 856 | * after the probe rate |
| 857 | */ |
| 858 | nrix = ath_rc_rate_getidx(sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 859 | ath_rc_priv, rate_table, nrix, 1, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 860 | ath_rc_rate_set_series(rate_table, |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 861 | &rates[i++], try_per_rate, nrix, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 862 | } else { |
| 863 | try_per_rate = (num_tries/num_rates); |
| 864 | /* Set the choosen rate. No RTS for first series entry. */ |
| 865 | ath_rc_rate_set_series(rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 866 | &rates[i++], try_per_rate, nrix, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | /* Fill in the other rates for multirate retry */ |
| 870 | for ( ; i < num_rates; i++) { |
| 871 | u8 try_num; |
| 872 | u8 min_rate; |
| 873 | |
| 874 | try_num = ((i + 1) == num_rates) ? |
| 875 | num_tries - (try_per_rate * i) : try_per_rate ; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 876 | min_rate = (((i + 1) == num_rates) && 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 877 | |
| 878 | nrix = ath_rc_rate_getidx(sc, ath_rc_priv, |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 879 | rate_table, nrix, 1, min_rate); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 880 | /* All other rates in the series have RTS enabled */ |
| 881 | ath_rc_rate_set_series(rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 882 | &rates[i], try_num, nrix, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | /* |
| 886 | * NB:Change rate series to enable aggregation when operating |
| 887 | * at lower MCS rates. When first rate in series is MCS2 |
| 888 | * in HT40 @ 2.4GHz, series should look like: |
| 889 | * |
| 890 | * {MCS2, MCS1, MCS0, MCS0}. |
| 891 | * |
| 892 | * When first rate in series is MCS3 in HT20 @ 2.4GHz, series should |
| 893 | * look like: |
| 894 | * |
| 895 | * {MCS3, MCS2, MCS1, MCS1} |
| 896 | * |
| 897 | * So, set fourth rate in series to be same as third one for |
| 898 | * above conditions. |
| 899 | */ |
Sujith | 86b89ee | 2008-08-07 10:54:57 +0530 | [diff] [blame] | 900 | if ((sc->sc_curmode == ATH9K_MODE_11NG_HT20) || |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 901 | (sc->sc_curmode == ATH9K_MODE_11NG_HT40PLUS) || |
| 902 | (sc->sc_curmode == ATH9K_MODE_11NG_HT40MINUS)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 903 | u8 dot11rate = rate_table->info[rix].dot11rate; |
| 904 | u8 phy = rate_table->info[rix].phy; |
| 905 | if (i == 4 && |
| 906 | ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) || |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 907 | (dot11rate == 3 && phy == WLAN_RC_PHY_HT_20_SS))) { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 908 | rates[3].idx = rates[2].idx; |
| 909 | rates[3].flags = rates[2].flags; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | } |
| 913 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 914 | static void ath_rc_update_ht(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 915 | struct ath_rate_priv *ath_rc_priv, |
| 916 | struct ath_tx_info_priv *tx_info_priv, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 917 | int tx_rate, int xretries, int retries) |
| 918 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 919 | u32 now_msec = jiffies_to_msecs(jiffies); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 920 | int state_change = 0, rate, count; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 921 | u8 last_per; |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 922 | struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 923 | static u32 nretry_to_per_lookup[10] = { |
| 924 | 100 * 0 / 1, |
| 925 | 100 * 1 / 4, |
| 926 | 100 * 1 / 2, |
| 927 | 100 * 3 / 4, |
| 928 | 100 * 4 / 5, |
| 929 | 100 * 5 / 6, |
| 930 | 100 * 6 / 7, |
| 931 | 100 * 7 / 8, |
| 932 | 100 * 8 / 9, |
| 933 | 100 * 9 / 10 |
| 934 | }; |
| 935 | |
| 936 | if (!ath_rc_priv) |
| 937 | return; |
| 938 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 939 | ASSERT(tx_rate >= 0); |
| 940 | if (tx_rate < 0) |
| 941 | return; |
| 942 | |
| 943 | /* To compensate for some imbalance between ctrl and ext. channel */ |
| 944 | |
| 945 | if (WLAN_RC_PHY_40(rate_table->info[tx_rate].phy)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 946 | tx_info_priv->tx.ts_rssi = |
| 947 | tx_info_priv->tx.ts_rssi < 3 ? 0 : |
| 948 | tx_info_priv->tx.ts_rssi - 3; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 949 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 950 | last_per = ath_rc_priv->state[tx_rate].per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 951 | |
| 952 | if (xretries) { |
| 953 | /* Update the PER. */ |
| 954 | if (xretries == 1) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 955 | ath_rc_priv->state[tx_rate].per += 30; |
| 956 | if (ath_rc_priv->state[tx_rate].per > 100) |
| 957 | ath_rc_priv->state[tx_rate].per = 100; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 958 | } else { |
| 959 | /* xretries == 2 */ |
Julia Lawall | 87c1687 | 2008-11-09 17:56:10 +0100 | [diff] [blame] | 960 | count = ARRAY_SIZE(nretry_to_per_lookup); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 961 | if (retries >= count) |
| 962 | retries = count - 1; |
| 963 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 964 | ath_rc_priv->state[tx_rate].per = |
| 965 | (u8)(ath_rc_priv->state[tx_rate].per - |
| 966 | (ath_rc_priv->state[tx_rate].per >> 3) + |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 967 | ((100) >> 3)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | /* xretries == 1 or 2 */ |
| 971 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 972 | if (ath_rc_priv->probe_rate == tx_rate) |
| 973 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 974 | |
| 975 | } else { /* xretries == 0 */ |
| 976 | /* Update the PER. */ |
| 977 | /* Make sure it doesn't index out of array's bounds. */ |
Julia Lawall | 87c1687 | 2008-11-09 17:56:10 +0100 | [diff] [blame] | 978 | count = ARRAY_SIZE(nretry_to_per_lookup); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 979 | if (retries >= count) |
| 980 | retries = count - 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 981 | if (tx_info_priv->n_bad_frames) { |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 982 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 983 | * Assuming that n_frames is not 0. The current PER |
| 984 | * from the retries is 100 * retries / (retries+1), |
| 985 | * since the first retries attempts failed, and the |
| 986 | * next one worked. For the one that worked, |
| 987 | * n_bad_frames subframes out of n_frames wored, |
| 988 | * so the PER for that part is |
| 989 | * 100 * n_bad_frames / n_frames, and it contributes |
| 990 | * 100 * n_bad_frames / (n_frames * (retries+1)) to |
| 991 | * the above PER. The expression below is a |
| 992 | * simplified version of the sum of these two terms. |
| 993 | */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 994 | if (tx_info_priv->n_frames > 0) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 995 | ath_rc_priv->state[tx_rate].per |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 996 | = (u8) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 997 | (ath_rc_priv->state[tx_rate].per - |
| 998 | (ath_rc_priv->state[tx_rate].per >> 3) + |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 999 | ((100*(retries*tx_info_priv->n_frames + |
| 1000 | tx_info_priv->n_bad_frames) / |
| 1001 | (tx_info_priv->n_frames * |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1002 | (retries+1))) >> 3)); |
| 1003 | } else { |
| 1004 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ |
| 1005 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1006 | ath_rc_priv->state[tx_rate].per = (u8) |
| 1007 | (ath_rc_priv->state[tx_rate].per - |
| 1008 | (ath_rc_priv->state[tx_rate].per >> 3) + |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1009 | (nretry_to_per_lookup[retries] >> 3)); |
| 1010 | } |
| 1011 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1012 | ath_rc_priv->rssi_last_prev2 = ath_rc_priv->rssi_last_prev; |
| 1013 | ath_rc_priv->rssi_last_prev = ath_rc_priv->rssi_last; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1014 | ath_rc_priv->rssi_last = tx_info_priv->tx.ts_rssi; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1015 | ath_rc_priv->rssi_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1016 | |
| 1017 | /* |
| 1018 | * If we got at most one retry then increase the max rate if |
| 1019 | * this was a probe. Otherwise, ignore the probe. |
| 1020 | */ |
| 1021 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1022 | if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1023 | if (retries > 0 || 2 * tx_info_priv->n_bad_frames > |
| 1024 | tx_info_priv->n_frames) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1025 | /* |
| 1026 | * Since we probed with just a single attempt, |
| 1027 | * any retries means the probe failed. Also, |
| 1028 | * if the attempt worked, but more than half |
| 1029 | * the subframes were bad then also consider |
| 1030 | * the probe a failure. |
| 1031 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1032 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1033 | } else { |
| 1034 | u8 probe_rate = 0; |
| 1035 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1036 | ath_rc_priv->rate_max_phy = ath_rc_priv->probe_rate; |
| 1037 | probe_rate = ath_rc_priv->probe_rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1038 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1039 | if (ath_rc_priv->state[probe_rate].per > 30) |
| 1040 | ath_rc_priv->state[probe_rate].per = 20; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1041 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1042 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1043 | |
| 1044 | /* |
| 1045 | * Since this probe succeeded, we allow the next |
| 1046 | * probe twice as soon. This allows the maxRate |
| 1047 | * to move up faster if the probes are |
| 1048 | * succesful. |
| 1049 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1050 | ath_rc_priv->probe_time = now_msec - |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1051 | rate_table->probe_interval / 2; |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | if (retries > 0) { |
| 1056 | /* |
| 1057 | * Don't update anything. We don't know if |
| 1058 | * this was because of collisions or poor signal. |
| 1059 | * |
| 1060 | * Later: if rssi_ack is close to |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1061 | * ath_rc_priv->state[txRate].rssi_thres and we see lots |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1062 | * of retries, then we could increase |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1063 | * ath_rc_priv->state[txRate].rssi_thres. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1064 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1065 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1066 | } else { |
| 1067 | /* |
| 1068 | * It worked with no retries. First ignore bogus (small) |
| 1069 | * rssi_ack values. |
| 1070 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1071 | if (tx_rate == ath_rc_priv->rate_max_phy && |
| 1072 | ath_rc_priv->hw_maxretry_pktcnt < 255) { |
| 1073 | ath_rc_priv->hw_maxretry_pktcnt++; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1076 | if (tx_info_priv->tx.ts_rssi >= |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1077 | rate_table->info[tx_rate].rssi_ack_validmin) { |
| 1078 | /* Average the rssi */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1079 | if (tx_rate != ath_rc_priv->rssi_sum_rate) { |
| 1080 | ath_rc_priv->rssi_sum_rate = tx_rate; |
| 1081 | ath_rc_priv->rssi_sum = |
| 1082 | ath_rc_priv->rssi_sum_cnt = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1085 | ath_rc_priv->rssi_sum += tx_info_priv->tx.ts_rssi; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1086 | ath_rc_priv->rssi_sum_cnt++; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1087 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1088 | if (ath_rc_priv->rssi_sum_cnt > 4) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1089 | int32_t rssi_ackAvg = |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1090 | (ath_rc_priv->rssi_sum + 2) / 4; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1091 | int8_t rssi_thres = |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1092 | ath_rc_priv->state[tx_rate]. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1093 | rssi_thres; |
| 1094 | int8_t rssi_ack_vmin = |
| 1095 | rate_table->info[tx_rate]. |
| 1096 | rssi_ack_validmin; |
| 1097 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1098 | ath_rc_priv->rssi_sum = |
| 1099 | ath_rc_priv->rssi_sum_cnt = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1100 | |
| 1101 | /* Now reduce the current |
| 1102 | * rssi threshold. */ |
| 1103 | if ((rssi_ackAvg < rssi_thres + 2) && |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1104 | (rssi_thres > rssi_ack_vmin)) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1105 | ath_rc_priv->state[tx_rate]. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1106 | rssi_thres--; |
| 1107 | } |
| 1108 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1109 | state_change = 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | /* For all cases */ |
| 1116 | |
| 1117 | /* |
| 1118 | * If this rate looks bad (high PER) then stop using it for |
| 1119 | * a while (except if we are probing). |
| 1120 | */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1121 | if (ath_rc_priv->state[tx_rate].per >= 55 && tx_rate > 0 && |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1122 | rate_table->info[tx_rate].ratekbps <= |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1123 | rate_table->info[ath_rc_priv->rate_max_phy].ratekbps) { |
| 1124 | ath_rc_get_nextlowervalid_txrate(rate_table, ath_rc_priv, |
| 1125 | (u8) tx_rate, &ath_rc_priv->rate_max_phy); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1126 | |
| 1127 | /* Don't probe for a little while. */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1128 | ath_rc_priv->probe_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | if (state_change) { |
| 1132 | /* |
| 1133 | * Make sure the rates above this have higher rssi thresholds. |
| 1134 | * (Note: Monotonicity is kept within the OFDM rates and |
| 1135 | * within the CCK rates. However, no adjustment is |
| 1136 | * made to keep the rssi thresholds monotonically |
| 1137 | * increasing between the CCK and OFDM rates.) |
| 1138 | */ |
| 1139 | for (rate = tx_rate; rate < |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1140 | ath_rc_priv->rate_table_size - 1; rate++) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1141 | if (rate_table->info[rate+1].phy != |
| 1142 | rate_table->info[tx_rate].phy) |
| 1143 | break; |
| 1144 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1145 | if (ath_rc_priv->state[rate].rssi_thres + |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1146 | rate_table->info[rate].rssi_ack_deltamin > |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1147 | ath_rc_priv->state[rate+1].rssi_thres) { |
| 1148 | ath_rc_priv->state[rate+1].rssi_thres = |
| 1149 | ath_rc_priv->state[rate]. |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1150 | rssi_thres + |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1151 | rate_table->info[rate]. |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1152 | rssi_ack_deltamin; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | /* Make sure the rates below this have lower rssi thresholds. */ |
| 1157 | for (rate = tx_rate - 1; rate >= 0; rate--) { |
| 1158 | if (rate_table->info[rate].phy != |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1159 | rate_table->info[tx_rate].phy) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1160 | break; |
| 1161 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1162 | if (ath_rc_priv->state[rate].rssi_thres + |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1163 | rate_table->info[rate].rssi_ack_deltamin > |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1164 | ath_rc_priv->state[rate+1].rssi_thres) { |
| 1165 | if (ath_rc_priv->state[rate+1].rssi_thres < |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1166 | rate_table->info[rate]. |
| 1167 | rssi_ack_deltamin) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1168 | ath_rc_priv->state[rate].rssi_thres = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1169 | else { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1170 | ath_rc_priv->state[rate].rssi_thres = |
| 1171 | ath_rc_priv->state[rate+1]. |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1172 | rssi_thres - |
| 1173 | rate_table->info[rate]. |
| 1174 | rssi_ack_deltamin; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1177 | if (ath_rc_priv->state[rate].rssi_thres < |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1178 | rate_table->info[rate]. |
| 1179 | rssi_ack_validmin) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1180 | ath_rc_priv->state[rate].rssi_thres = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1181 | rate_table->info[rate]. |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1182 | rssi_ack_validmin; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1183 | } |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | /* Make sure the rates below this have lower PER */ |
| 1189 | /* Monotonicity is kept only for rates below the current rate. */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1190 | if (ath_rc_priv->state[tx_rate].per < last_per) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1191 | for (rate = tx_rate - 1; rate >= 0; rate--) { |
| 1192 | if (rate_table->info[rate].phy != |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1193 | rate_table->info[tx_rate].phy) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1194 | break; |
| 1195 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1196 | if (ath_rc_priv->state[rate].per > |
| 1197 | ath_rc_priv->state[rate+1].per) { |
| 1198 | ath_rc_priv->state[rate].per = |
| 1199 | ath_rc_priv->state[rate+1].per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1200 | } |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | /* Maintain monotonicity for rates above the current rate */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1205 | for (rate = tx_rate; rate < ath_rc_priv->rate_table_size - 1; rate++) { |
| 1206 | if (ath_rc_priv->state[rate+1].per < ath_rc_priv->state[rate].per) |
| 1207 | ath_rc_priv->state[rate+1].per = |
| 1208 | ath_rc_priv->state[rate].per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | /* Every so often, we reduce the thresholds and |
| 1212 | * PER (different for CCK and OFDM). */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1213 | if (now_msec - ath_rc_priv->rssi_down_time >= |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1214 | rate_table->rssi_reduce_interval) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1215 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1216 | for (rate = 0; rate < ath_rc_priv->rate_table_size; rate++) { |
| 1217 | if (ath_rc_priv->state[rate].rssi_thres > |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1218 | rate_table->info[rate].rssi_ack_validmin) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1219 | ath_rc_priv->state[rate].rssi_thres -= 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1220 | } |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1221 | ath_rc_priv->rssi_down_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | /* Every so often, we reduce the thresholds |
| 1225 | * and PER (different for CCK and OFDM). */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1226 | if (now_msec - ath_rc_priv->per_down_time >= |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1227 | rate_table->rssi_reduce_interval) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1228 | for (rate = 0; rate < ath_rc_priv->rate_table_size; rate++) { |
| 1229 | ath_rc_priv->state[rate].per = |
| 1230 | 7 * ath_rc_priv->state[rate].per / 8; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1231 | } |
| 1232 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1233 | ath_rc_priv->per_down_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1234 | } |
| 1235 | } |
| 1236 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1237 | static void ath_rc_tx_status(struct ath_softc *sc, |
| 1238 | struct ath_rate_priv *ath_rc_priv, |
| 1239 | struct ieee80211_tx_info *tx_info, |
| 1240 | int final_ts_idx, int xretries, int long_retry) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1241 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1242 | struct ath_tx_info_priv *tx_info_priv = ATH_TX_INFO_PRIV(tx_info); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1243 | struct ath_rate_table *rate_table; |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1244 | struct ieee80211_tx_rate *rates = tx_info->status.rates; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1245 | u8 flags; |
| 1246 | u32 series = 0, rix; |
| 1247 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1248 | rate_table = sc->hw_rate_table[sc->sc_curmode]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1249 | |
| 1250 | /* |
| 1251 | * If the first rate is not the final index, there |
| 1252 | * are intermediate rate failures to be processed. |
| 1253 | */ |
| 1254 | if (final_ts_idx != 0) { |
| 1255 | /* Process intermediate rates that failed.*/ |
| 1256 | for (series = 0; series < final_ts_idx ; series++) { |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1257 | if (rates[series].count != 0 && (rates[series].idx >= 0)) { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1258 | flags = rates[series].flags; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1259 | /* If HT40 and we have switched mode from |
| 1260 | * 40 to 20 => don't update */ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1261 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1262 | (ath_rc_priv->rc_phy_mode != WLAN_RC_40_FLAG)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1263 | return; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1264 | |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1265 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
| 1266 | (flags & IEEE80211_TX_RC_SHORT_GI)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1267 | rix = rate_table->info[ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1268 | rates[series].idx].ht_index; |
| 1269 | else if (flags & IEEE80211_TX_RC_SHORT_GI) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1270 | rix = rate_table->info[ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1271 | rates[series].idx].sgi_index; |
| 1272 | else if (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1273 | rix = rate_table->info[ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1274 | rates[series].idx].cw40index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1275 | else |
| 1276 | rix = rate_table->info[ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1277 | rates[series].idx].base_index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1278 | ath_rc_update_ht(sc, ath_rc_priv, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1279 | tx_info_priv, rix, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1280 | xretries ? 1 : 2, |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1281 | rates[series].count); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1282 | } |
| 1283 | } |
| 1284 | } else { |
| 1285 | /* |
| 1286 | * Handle the special case of MIMO PS burst, where the second |
| 1287 | * aggregate is sent out with only one rate and one try. |
| 1288 | * Treating it as an excessive retry penalizes the rate |
| 1289 | * inordinately. |
| 1290 | */ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1291 | if (rates[0].count == 1 && xretries == 1) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1292 | xretries = 2; |
| 1293 | } |
| 1294 | |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1295 | flags = rates[series].flags; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1296 | /* If HT40 and we have switched mode from 40 to 20 => don't update */ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1297 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1298 | (ath_rc_priv->rc_phy_mode != WLAN_RC_40_FLAG)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1299 | return; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1300 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1301 | |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1302 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && (flags & IEEE80211_TX_RC_SHORT_GI)) |
| 1303 | rix = rate_table->info[rates[series].idx].ht_index; |
| 1304 | else if (flags & IEEE80211_TX_RC_SHORT_GI) |
| 1305 | rix = rate_table->info[rates[series].idx].sgi_index; |
| 1306 | else if (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 1307 | rix = rate_table->info[rates[series].idx].cw40index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1308 | else |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1309 | rix = rate_table->info[rates[series].idx].base_index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1310 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1311 | ath_rc_update_ht(sc, ath_rc_priv, tx_info_priv, rix, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1312 | xretries, long_retry); |
| 1313 | } |
| 1314 | |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1315 | static void ath_rc_init(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1316 | struct ath_rate_priv *ath_rc_priv, |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1317 | struct ieee80211_supported_band *sband, |
| 1318 | struct ieee80211_sta *sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1319 | { |
| 1320 | struct ath_rate_table *rate_table = NULL; |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1321 | struct ath_rateset *rateset = &ath_rc_priv->neg_rates; |
| 1322 | u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1323 | u8 i, j, k, hi = 0, hthi = 0; |
| 1324 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1325 | rate_table = sc->hw_rate_table[sc->sc_curmode]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1326 | |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1327 | if (sta->ht_cap.ht_supported) { |
| 1328 | if (sband->band == IEEE80211_BAND_2GHZ) |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1329 | rate_table = sc->hw_rate_table[ATH9K_MODE_11NG_HT20]; |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1330 | else |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1331 | rate_table = sc->hw_rate_table[ATH9K_MODE_11NA_HT20]; |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1332 | |
| 1333 | ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1334 | |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1335 | if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) |
| 1336 | ath_rc_priv->ht_cap |= WLAN_RC_40_FLAG; |
| 1337 | } |
| 1338 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1339 | /* Initial rate table size. Will change depending |
| 1340 | * on the working rate set */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1341 | ath_rc_priv->rate_table_size = RATE_TABLE_SIZE; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1342 | |
| 1343 | /* Initialize thresholds according to the global rate table */ |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1344 | for (i = 0 ; i < ath_rc_priv->rate_table_size; i++) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1345 | ath_rc_priv->state[i].rssi_thres = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1346 | rate_table->info[i].rssi_ack_validmin; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1347 | ath_rc_priv->state[i].per = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | /* Determine the valid rates */ |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1351 | ath_rc_init_valid_txmask(ath_rc_priv); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1352 | |
| 1353 | for (i = 0; i < WLAN_RC_PHY_MAX; i++) { |
| 1354 | for (j = 0; j < MAX_TX_RATE_PHY; j++) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1355 | ath_rc_priv->valid_phy_rateidx[i][j] = 0; |
| 1356 | ath_rc_priv->valid_phy_ratecnt[i] = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1357 | } |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1358 | ath_rc_priv->rc_phy_mode = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1359 | |
| 1360 | /* Set stream capability */ |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1361 | ath_rc_priv->single_stream = (ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ? 0 : 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1362 | |
| 1363 | if (!rateset->rs_nrates) { |
| 1364 | /* No working rate, just initialize valid rates */ |
| 1365 | hi = ath_rc_sib_init_validrates(ath_rc_priv, rate_table, |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1366 | ath_rc_priv->ht_cap); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1367 | } else { |
| 1368 | /* Use intersection of working rates and valid rates */ |
| 1369 | hi = ath_rc_sib_setvalid_rates(ath_rc_priv, rate_table, |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1370 | rateset, ath_rc_priv->ht_cap); |
| 1371 | if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1372 | hthi = ath_rc_sib_setvalid_htrates(ath_rc_priv, |
| 1373 | rate_table, |
| 1374 | ht_mcs, |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1375 | ath_rc_priv->ht_cap); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1376 | } |
| 1377 | hi = A_MAX(hi, hthi); |
| 1378 | } |
| 1379 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1380 | ath_rc_priv->rate_table_size = hi + 1; |
| 1381 | ath_rc_priv->rate_max_phy = 0; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1382 | ASSERT(ath_rc_priv->rate_table_size <= RATE_TABLE_SIZE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1383 | |
| 1384 | for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) { |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1385 | for (j = 0; j < ath_rc_priv->valid_phy_ratecnt[i]; j++) { |
| 1386 | ath_rc_priv->valid_rate_index[k++] = |
| 1387 | ath_rc_priv->valid_phy_rateidx[i][j]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1388 | } |
| 1389 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1390 | if (!ath_rc_valid_phyrate(i, rate_table->initial_ratemax, 1) |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1391 | || !ath_rc_priv->valid_phy_ratecnt[i]) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1392 | continue; |
| 1393 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1394 | ath_rc_priv->rate_max_phy = ath_rc_priv->valid_phy_rateidx[i][j-1]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1395 | } |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1396 | ASSERT(ath_rc_priv->rate_table_size <= RATE_TABLE_SIZE); |
| 1397 | ASSERT(k <= RATE_TABLE_SIZE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1398 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1399 | ath_rc_priv->max_valid_rate = k; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1400 | ath_rc_sort_validrates(rate_table, ath_rc_priv); |
| 1401 | ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1402 | } |
| 1403 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1404 | /* Rate Control callbacks */ |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1405 | static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, |
| 1406 | struct ieee80211_sta *sta, void *priv_sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1407 | struct sk_buff *skb) |
| 1408 | { |
| 1409 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1410 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
| 1411 | struct ath_tx_info_priv *tx_info_priv = NULL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1412 | struct ath_node *an; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1413 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
| 1414 | struct ieee80211_hdr *hdr; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1415 | int final_ts_idx, tx_status = 0, is_underrun = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1416 | __le16 fc; |
| 1417 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1418 | hdr = (struct ieee80211_hdr *)skb->data; |
| 1419 | fc = hdr->frame_control; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1420 | tx_info_priv = ATH_TX_INFO_PRIV(tx_info); |
Sujith | b5aa9bf | 2008-10-29 10:13:31 +0530 | [diff] [blame] | 1421 | an = (struct ath_node *)sta->drv_priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1422 | final_ts_idx = tx_info_priv->tx.ts_rateindex; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1423 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1424 | if (!an || !priv_sta || !ieee80211_is_data(fc)) |
| 1425 | goto exit; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1426 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1427 | if (tx_info_priv->tx.ts_status & ATH9K_TXERR_FILT) |
| 1428 | goto exit; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1429 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1430 | if (tx_info_priv->tx.ts_rssi > 0) { |
| 1431 | ATH_RSSI_LPF(an->an_chainmask_sel.tx_avgrssi, |
| 1432 | tx_info_priv->tx.ts_rssi); |
| 1433 | } |
| 1434 | |
| 1435 | /* |
| 1436 | * If underrun error is seen assume it as an excessive retry only |
| 1437 | * if prefetch trigger level have reached the max (0x3f for 5416) |
| 1438 | * Adjust the long retry as if the frame was tried ATH_11N_TXMAXTRY |
| 1439 | * times. This affects how ratectrl updates PER for the failed rate. |
| 1440 | */ |
| 1441 | if (tx_info_priv->tx.ts_flags & |
| 1442 | (ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) && |
| 1443 | ((sc->sc_ah->ah_txTrigLevel) >= ath_rc_priv->tx_triglevel_max)) { |
| 1444 | tx_status = 1; |
| 1445 | is_underrun = 1; |
| 1446 | } |
| 1447 | |
| 1448 | if ((tx_info_priv->tx.ts_status & ATH9K_TXERR_XRETRY) || |
| 1449 | (tx_info_priv->tx.ts_status & ATH9K_TXERR_FIFO)) |
| 1450 | tx_status = 1; |
| 1451 | |
| 1452 | ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status, |
| 1453 | (is_underrun) ? ATH_11N_TXMAXTRY : |
| 1454 | tx_info_priv->tx.ts_longretry); |
| 1455 | |
| 1456 | exit: |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1457 | kfree(tx_info_priv); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1458 | } |
| 1459 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1460 | static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, |
| 1461 | struct ieee80211_tx_rate_control *txrc) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1462 | { |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1463 | struct ieee80211_supported_band *sband = txrc->sband; |
| 1464 | struct sk_buff *skb = txrc->skb; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1465 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1466 | struct ath_softc *sc = priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1467 | struct ieee80211_hw *hw = sc->hw; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1468 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1469 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1470 | int is_probe = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1471 | __le16 fc = hdr->frame_control; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1472 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1473 | /* lowest rate for management and multicast/broadcast frames */ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1474 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) { |
| 1475 | tx_info->control.rates[0].idx = rate_lowest_index(sband, sta); |
| 1476 | tx_info->control.rates[0].count = |
| 1477 | is_multicast_ether_addr(hdr->addr1) ? 1 : ATH_MGT_TXMAXTRY; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1478 | return; |
| 1479 | } |
| 1480 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1481 | /* Find tx rate for unicast frames */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1482 | ath_rc_ratefind(sc, ath_rc_priv, ATH_11N_TXMAXTRY, 4, |
| 1483 | tx_info, &is_probe, false); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1484 | |
| 1485 | /* Check if aggregation has to be enabled for this tid */ |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1486 | if (hw->conf.ht.enabled) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1487 | if (ieee80211_is_data_qos(fc)) { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1488 | u8 *qc, tid; |
| 1489 | struct ath_node *an; |
| 1490 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1491 | qc = ieee80211_get_qos_ctl(hdr); |
| 1492 | tid = qc[0] & 0xf; |
Sujith | b5aa9bf | 2008-10-29 10:13:31 +0530 | [diff] [blame] | 1493 | an = (struct ath_node *)sta->drv_priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1494 | |
Sujith | ccc75c5 | 2008-10-29 10:18:14 +0530 | [diff] [blame] | 1495 | if(ath_tx_aggr_check(sc, an, tid)) |
| 1496 | ieee80211_start_tx_ba_session(hw, hdr->addr1, tid); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1497 | } |
| 1498 | } |
| 1499 | } |
| 1500 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1501 | static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, |
| 1502 | struct ieee80211_sta *sta, void *priv_sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1503 | { |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1504 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1505 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1506 | int i, j = 0; |
| 1507 | |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1508 | for (i = 0; i < sband->n_bitrates; i++) { |
| 1509 | if (sta->supp_rates[sband->band] & BIT(i)) { |
| 1510 | ath_rc_priv->neg_rates.rs_rates[j] |
| 1511 | = (sband->bitrates[i].bitrate * 2) / 10; |
| 1512 | j++; |
| 1513 | } |
| 1514 | } |
| 1515 | ath_rc_priv->neg_rates.rs_nrates = j; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1516 | |
Sujith | a4510bf | 2008-10-23 12:15:19 +0530 | [diff] [blame] | 1517 | if (sta->ht_cap.ht_supported) { |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1518 | for (i = 0, j = 0; i < 77; i++) { |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1519 | if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8))) |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1520 | ath_rc_priv->neg_ht_rates.rs_rates[j++] = i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1521 | if (j == ATH_RATE_MAX) |
| 1522 | break; |
| 1523 | } |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1524 | ath_rc_priv->neg_ht_rates.rs_nrates = j; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1525 | } |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1526 | |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1527 | ath_rc_init(sc, priv_sta, sband, sta); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1528 | } |
| 1529 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1530 | static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1531 | { |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1532 | return hw->priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | static void ath_rate_free(void *priv) |
| 1536 | { |
| 1537 | return; |
| 1538 | } |
| 1539 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1540 | static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1541 | { |
| 1542 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1543 | struct ath_rate_priv *rate_priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1544 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1545 | rate_priv = kzalloc(sizeof(struct ath_rate_priv), gfp); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1546 | if (!rate_priv) { |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1547 | DPRINTF(sc, ATH_DBG_FATAL, |
| 1548 | "%s: Unable to allocate private rc structure\n", |
| 1549 | __func__); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1550 | return NULL; |
| 1551 | } |
Sujith | fe60594 | 2008-11-18 09:03:36 +0530 | [diff] [blame] | 1552 | |
Sujith | fe60594 | 2008-11-18 09:03:36 +0530 | [diff] [blame] | 1553 | rate_priv->rssi_down_time = jiffies_to_msecs(jiffies); |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1554 | rate_priv->tx_triglevel_max = sc->sc_ah->ah_caps.tx_triglevel_max; |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1555 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1556 | return rate_priv; |
| 1557 | } |
| 1558 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1559 | static void ath_rate_free_sta(void *priv, struct ieee80211_sta *sta, |
| 1560 | void *priv_sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1561 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame^] | 1562 | struct ath_rate_priv *rate_priv = priv_sta; |
Sujith | fe60594 | 2008-11-18 09:03:36 +0530 | [diff] [blame] | 1563 | kfree(rate_priv); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
| 1566 | static struct rate_control_ops ath_rate_ops = { |
| 1567 | .module = NULL, |
| 1568 | .name = "ath9k_rate_control", |
| 1569 | .tx_status = ath_tx_status, |
| 1570 | .get_rate = ath_get_rate, |
| 1571 | .rate_init = ath_rate_init, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1572 | .alloc = ath_rate_alloc, |
| 1573 | .free = ath_rate_free, |
| 1574 | .alloc_sta = ath_rate_alloc_sta, |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1575 | .free_sta = ath_rate_free_sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1576 | }; |
| 1577 | |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1578 | static void ath_setup_rate_table(struct ath_softc *sc, |
| 1579 | struct ath_rate_table *rate_table) |
| 1580 | { |
| 1581 | int i; |
| 1582 | |
| 1583 | for (i = 0; i < 256; i++) |
| 1584 | rate_table->rateCodeToIndex[i] = (u8)-1; |
| 1585 | |
| 1586 | for (i = 0; i < rate_table->rate_cnt; i++) { |
| 1587 | u8 code = rate_table->info[i].ratecode; |
| 1588 | u8 cix = rate_table->info[i].ctrl_rate; |
| 1589 | u8 sh = rate_table->info[i].short_preamble; |
| 1590 | |
| 1591 | rate_table->rateCodeToIndex[code] = i; |
| 1592 | rate_table->rateCodeToIndex[code | sh] = i; |
| 1593 | |
| 1594 | rate_table->info[i].lpAckDuration = |
| 1595 | ath9k_hw_computetxtime(sc->sc_ah, rate_table, |
| 1596 | WLAN_CTRL_FRAME_SIZE, |
| 1597 | cix, |
| 1598 | false); |
| 1599 | rate_table->info[i].spAckDuration = |
| 1600 | ath9k_hw_computetxtime(sc->sc_ah, rate_table, |
| 1601 | WLAN_CTRL_FRAME_SIZE, |
| 1602 | cix, |
| 1603 | true); |
| 1604 | } |
| 1605 | } |
| 1606 | |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1607 | void ath_rate_attach(struct ath_softc *sc) |
| 1608 | { |
| 1609 | sc->hw_rate_table[ATH9K_MODE_11B] = |
| 1610 | &ar5416_11b_ratetable; |
| 1611 | sc->hw_rate_table[ATH9K_MODE_11A] = |
| 1612 | &ar5416_11a_ratetable; |
| 1613 | sc->hw_rate_table[ATH9K_MODE_11G] = |
| 1614 | &ar5416_11g_ratetable; |
| 1615 | sc->hw_rate_table[ATH9K_MODE_11NA_HT20] = |
| 1616 | &ar5416_11na_ratetable; |
| 1617 | sc->hw_rate_table[ATH9K_MODE_11NG_HT20] = |
| 1618 | &ar5416_11ng_ratetable; |
| 1619 | sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] = |
| 1620 | &ar5416_11na_ratetable; |
| 1621 | sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] = |
| 1622 | &ar5416_11na_ratetable; |
| 1623 | sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] = |
| 1624 | &ar5416_11ng_ratetable; |
| 1625 | sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] = |
| 1626 | &ar5416_11ng_ratetable; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1627 | |
| 1628 | ath_setup_rate_table(sc, &ar5416_11b_ratetable); |
| 1629 | ath_setup_rate_table(sc, &ar5416_11a_ratetable); |
| 1630 | ath_setup_rate_table(sc, &ar5416_11g_ratetable); |
| 1631 | ath_setup_rate_table(sc, &ar5416_11na_ratetable); |
| 1632 | ath_setup_rate_table(sc, &ar5416_11ng_ratetable); |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 1633 | } |
| 1634 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1635 | int ath_rate_control_register(void) |
| 1636 | { |
| 1637 | return ieee80211_rate_control_register(&ath_rate_ops); |
| 1638 | } |
| 1639 | |
| 1640 | void ath_rate_control_unregister(void) |
| 1641 | { |
| 1642 | ieee80211_rate_control_unregister(&ath_rate_ops); |
| 1643 | } |