Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004 Video54 Technologies, Inc. |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 3 | * Copyright (c) 2004-2009 Atheros Communications, Inc. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 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 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 18 | #include "ath9k.h" |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 19 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 20 | static const struct ath_rate_table ar5416_11na_ratetable = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 21 | 42, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 22 | 8, /* MCS start */ |
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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 25 | 5400, 0, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 26 | 0, 0, 0, 0, 0, 0 }, |
Sujith | e832435 | 2009-01-16 21:38:42 +0530 | [diff] [blame] | 27 | { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 28 | 7800, 1, 0x00, 18, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 29 | 0, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 31 | 10000, 2, 0x00, 24, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 32 | 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 34 | 13900, 3, 0x00, 36, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 35 | 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 37 | 17300, 4, 0x00, 48, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 38 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 40 | 23000, 5, 0x00, 72, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 41 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 43 | 27400, 6, 0x00, 96, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 44 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 46 | 29300, 7, 0x00, 108, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 47 | 4, 7, 7, 7, 7, 0 }, |
Vasanthakumar Thiagarajan | 42e8856 | 2009-07-29 15:05:21 +0530 | [diff] [blame] | 48 | { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 49 | 6400, 0, 0x00, 0, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 50 | 0, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 52 | 12700, 1, 0x00, 1, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 53 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 55 | 18800, 2, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 56 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 58 | 25000, 3, 0x00, 3, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 59 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 61 | 36700, 4, 0x00, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 62 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 64 | 48100, 5, 0x00, 5, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 65 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 67 | 53500, 6, 0x00, 6, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 68 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 70 | 59000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 71 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 73 | 12700, 8, 0x00, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 74 | 8, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 76 | 24800, 9, 0x00, 9, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 77 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 79 | 36600, 10, 0x00, 10, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 80 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 82 | 48100, 11, 0x00, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 83 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 85 | 69500, 12, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 86 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 88 | 89500, 13, 0x00, 13, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 89 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 91 | 98900, 14, 0x00, 14, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 92 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 94 | 108300, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 95 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 97 | 13200, 0, 0x00, 0, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 98 | 0, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 100 | 25900, 1, 0x00, 1, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 101 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 103 | 38600, 2, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 104 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 106 | 49800, 3, 0x00, 3, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 107 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 109 | 72200, 4, 0x00, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 110 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 112 | 92900, 5, 0x00, 5, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 113 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 115 | 102700, 6, 0x00, 6, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 116 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 118 | 112000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 119 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 121 | 122000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 122 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 124 | 25800, 8, 0x00, 8, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 125 | 0, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 127 | 49800, 9, 0x00, 9, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 128 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 130 | 71900, 10, 0x00, 10, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 131 | 2, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 133 | 92500, 11, 0x00, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 134 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 136 | 130300, 12, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 137 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 139 | 162800, 13, 0x00, 13, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 140 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 142 | 178200, 14, 0x00, 14, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 143 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 145 | 192100, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 146 | 4, 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 */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 148 | 207000, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 149 | 4, 23, 40, 41, 41, 148400 }, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 150 | }, |
| 151 | 50, /* probe interval */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 152 | WLAN_RC_HT_FLAG, /* Phy rates allowed initially */ |
| 153 | }; |
| 154 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 155 | /* 4ms frame limit not used for NG mode. The values filled |
| 156 | * for HT are the 64K max aggregate limit */ |
| 157 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 158 | static const struct ath_rate_table ar5416_11ng_ratetable = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 159 | 46, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 160 | 12, /* MCS start */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 161 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 162 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 163 | 900, 0, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 164 | 0, 0, 0, 0, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 165 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 166 | 1900, 1, 0x04, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 167 | 1, 1, 1, 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 168 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 169 | 4900, 2, 0x04, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 170 | 2, 2, 2, 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 171 | { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 172 | 8100, 3, 0x04, 22, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 173 | 3, 3, 3, 3, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 174 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 175 | 5400, 4, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 176 | 4, 4, 4, 4, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 177 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 178 | 7800, 5, 0x00, 18, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 179 | 4, 5, 5, 5, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 180 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 181 | 10100, 6, 0x00, 24, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 182 | 6, 6, 6, 6, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 183 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 184 | 14100, 7, 0x00, 36, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 185 | 6, 7, 7, 7, 7, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 186 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 187 | 17700, 8, 0x00, 48, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 188 | 8, 8, 8, 8, 8, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 189 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 190 | 23700, 9, 0x00, 72, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 191 | 8, 9, 9, 9, 9, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 192 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 193 | 27400, 10, 0x00, 96, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 194 | 8, 10, 10, 10, 10, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 195 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 196 | 30900, 11, 0x00, 108, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 197 | 8, 11, 11, 11, 11, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 198 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 199 | 6400, 0, 0x00, 0, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 200 | 4, 12, 28, 12, 28, 3216 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 201 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 202 | 12700, 1, 0x00, 1, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 203 | 6, 13, 29, 13, 29, 6434 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 204 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 205 | 18800, 2, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 206 | 6, 14, 30, 14, 30, 9650 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 207 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 208 | 25000, 3, 0x00, 3, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 209 | 8, 15, 31, 15, 31, 12868 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 210 | { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 211 | 36700, 4, 0x00, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 212 | 8, 16, 32, 16, 32, 19304 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 213 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 214 | 48100, 5, 0x00, 5, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 215 | 8, 17, 33, 17, 33, 25740 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 216 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 217 | 53500, 6, 0x00, 6, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 218 | 8, 18, 34, 18, 34, 28956 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 219 | { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 220 | 59000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 221 | 8, 19, 35, 19, 36, 32180 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 222 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 223 | 12700, 8, 0x00, 8, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 224 | 4, 20, 37, 20, 37, 6430 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 225 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 226 | 24800, 9, 0x00, 9, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 227 | 6, 21, 38, 21, 38, 12860 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 228 | { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 229 | 36600, 10, 0x00, 10, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 230 | 6, 22, 39, 22, 39, 19300 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 231 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 232 | 48100, 11, 0x00, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 233 | 8, 23, 40, 23, 40, 25736 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 234 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 235 | 69500, 12, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 236 | 8, 24, 41, 24, 41, 38600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 237 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 238 | 89500, 13, 0x00, 13, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 239 | 8, 25, 42, 25, 42, 51472 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 240 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 241 | 98900, 14, 0x00, 14, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 242 | 8, 26, 43, 26, 44, 57890 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 243 | { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 244 | 108300, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 245 | 8, 27, 44, 27, 45, 64320 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 246 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 247 | 13200, 0, 0x00, 0, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 248 | 8, 12, 28, 28, 28, 6684 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 249 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 250 | 25900, 1, 0x00, 1, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 251 | 8, 13, 29, 29, 29, 13368 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 252 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 253 | 38600, 2, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 254 | 8, 14, 30, 30, 30, 20052 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 255 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 256 | 49800, 3, 0x00, 3, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 257 | 8, 15, 31, 31, 31, 26738 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 258 | { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 259 | 72200, 4, 0x00, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 260 | 8, 16, 32, 32, 32, 40104 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 261 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 262 | 92900, 5, 0x00, 5, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 263 | 8, 17, 33, 33, 33, 53476 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 264 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 265 | 102700, 6, 0x00, 6, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 266 | 8, 18, 34, 34, 34, 60156 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 267 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 268 | 112000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 269 | 8, 19, 35, 36, 36, 66840 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 270 | { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 271 | 122000, 7, 0x00, 7, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 272 | 8, 19, 35, 36, 36, 74200 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 273 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 274 | 25800, 8, 0x00, 8, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 275 | 8, 20, 37, 37, 37, 13360 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 276 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 277 | 49800, 9, 0x00, 9, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 278 | 8, 21, 38, 38, 38, 26720 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 279 | { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 280 | 71900, 10, 0x00, 10, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 281 | 8, 22, 39, 39, 39, 40080 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 282 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 283 | 92500, 11, 0x00, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 284 | 8, 23, 40, 40, 40, 53440 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 285 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 286 | 130300, 12, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 287 | 8, 24, 41, 41, 41, 80160 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 288 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 289 | 162800, 13, 0x00, 13, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 290 | 8, 25, 42, 42, 42, 106880 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 291 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 292 | 178200, 14, 0x00, 14, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 293 | 8, 26, 43, 43, 43, 120240 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 294 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 295 | 192100, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 296 | 8, 27, 44, 45, 45, 133600 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 297 | { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 298 | 207000, 15, 0x00, 15, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 299 | 8, 27, 44, 45, 45, 148400 }, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 300 | }, |
| 301 | 50, /* probe interval */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 302 | WLAN_RC_HT_FLAG, /* Phy rates allowed initially */ |
| 303 | }; |
| 304 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 305 | static const struct ath_rate_table ar5416_11a_ratetable = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 306 | 8, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 307 | 0, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 308 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 309 | { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 310 | 5400, 0, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 311 | 0, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 312 | { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 313 | 7800, 1, 0x00, 18, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 314 | 0, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 315 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 316 | 10000, 2, 0x00, 24, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 317 | 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 318 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 319 | 13900, 3, 0x00, 36, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 320 | 2, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 321 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 322 | 17300, 4, 0x00, 48, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 323 | 4, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 324 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 325 | 23000, 5, 0x00, 72, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 326 | 4, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 327 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 328 | 27400, 6, 0x00, 96, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 329 | 4, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 330 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 331 | 29300, 7, 0x00, 108, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 332 | 4, 7, 0 }, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 333 | }, |
| 334 | 50, /* probe interval */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 335 | 0, /* Phy rates allowed initially */ |
| 336 | }; |
| 337 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 338 | static const struct ath_rate_table ar5416_11g_ratetable = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 339 | 12, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 340 | 0, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 341 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 342 | { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 343 | 900, 0, 0x00, 2, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 344 | 0, 0, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 345 | { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 346 | 1900, 1, 0x04, 4, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 347 | 1, 1, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 348 | { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 349 | 4900, 2, 0x04, 11, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 350 | 2, 2, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 351 | { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 352 | 8100, 3, 0x04, 22, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 353 | 3, 3, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 354 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 355 | 5400, 4, 0x00, 12, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 356 | 4, 4, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 357 | { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 358 | 7800, 5, 0x00, 18, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 359 | 4, 5, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 360 | { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 361 | 10000, 6, 0x00, 24, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 362 | 6, 6, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 363 | { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 364 | 13900, 7, 0x00, 36, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 365 | 6, 7, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 366 | { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 367 | 17300, 8, 0x00, 48, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 368 | 8, 8, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 369 | { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 370 | 23000, 9, 0x00, 72, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 371 | 8, 9, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 372 | { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 373 | 27400, 10, 0x00, 96, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 374 | 8, 10, 0 }, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 375 | { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 376 | 29300, 11, 0x00, 108, |
Vasanthakumar Thiagarajan | ddf4a2d | 2009-07-14 20:14:11 -0400 | [diff] [blame] | 377 | 8, 11, 0 }, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 378 | }, |
| 379 | 50, /* probe interval */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 380 | 0, /* Phy rates allowed initially */ |
| 381 | }; |
| 382 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 383 | static const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX] = { |
| 384 | [ATH9K_MODE_11A] = &ar5416_11a_ratetable, |
| 385 | [ATH9K_MODE_11G] = &ar5416_11g_ratetable, |
| 386 | [ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable, |
| 387 | [ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable, |
| 388 | [ATH9K_MODE_11NA_HT40PLUS] = &ar5416_11na_ratetable, |
| 389 | [ATH9K_MODE_11NA_HT40MINUS] = &ar5416_11na_ratetable, |
| 390 | [ATH9K_MODE_11NG_HT40PLUS] = &ar5416_11ng_ratetable, |
| 391 | [ATH9K_MODE_11NG_HT40MINUS] = &ar5416_11ng_ratetable, |
| 392 | }; |
| 393 | |
| 394 | static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table, |
| 395 | struct ieee80211_tx_rate *rate); |
| 396 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 397 | static inline int8_t median(int8_t a, int8_t b, int8_t c) |
| 398 | { |
| 399 | if (a >= b) { |
| 400 | if (b >= c) |
| 401 | return b; |
| 402 | else if (a > c) |
| 403 | return c; |
| 404 | else |
| 405 | return a; |
| 406 | } else { |
| 407 | if (a >= c) |
| 408 | return a; |
| 409 | else if (b >= c) |
| 410 | return c; |
| 411 | else |
| 412 | return b; |
| 413 | } |
| 414 | } |
| 415 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 416 | static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 417 | struct ath_rate_priv *ath_rc_priv) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 418 | { |
| 419 | u8 i, j, idx, idx_next; |
| 420 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 421 | 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] | 422 | for (j = 0; j <= i-1; j++) { |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 423 | idx = ath_rc_priv->valid_rate_index[j]; |
| 424 | idx_next = ath_rc_priv->valid_rate_index[j+1]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 425 | |
| 426 | if (rate_table->info[idx].ratekbps > |
| 427 | rate_table->info[idx_next].ratekbps) { |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 428 | ath_rc_priv->valid_rate_index[j] = idx_next; |
| 429 | ath_rc_priv->valid_rate_index[j+1] = idx; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 435 | 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] | 436 | { |
| 437 | u8 i; |
| 438 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 439 | for (i = 0; i < ath_rc_priv->rate_table_size; i++) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 440 | ath_rc_priv->valid_rate_index[i] = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 443 | 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] | 444 | u8 index, int valid_tx_rate) |
| 445 | { |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 446 | BUG_ON(index > ath_rc_priv->rate_table_size); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 447 | 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] | 448 | } |
| 449 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 450 | static inline |
| 451 | int ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table, |
| 452 | struct ath_rate_priv *ath_rc_priv, |
| 453 | u8 cur_valid_txrate, |
| 454 | u8 *next_idx) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 455 | { |
| 456 | u8 i; |
| 457 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 458 | for (i = 0; i < ath_rc_priv->max_valid_rate - 1; i++) { |
| 459 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
| 460 | *next_idx = ath_rc_priv->valid_rate_index[i+1]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 461 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | |
| 465 | /* No more valid rates */ |
| 466 | *next_idx = 0; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 467 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 468 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | /* Return true only for single stream */ |
| 472 | |
| 473 | static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw) |
| 474 | { |
Jouni Malinen | b657ead | 2009-01-13 14:33:49 +0200 | [diff] [blame] | 475 | if (WLAN_RC_PHY_HT(phy) && !(capflag & WLAN_RC_HT_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 476 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 477 | if (WLAN_RC_PHY_DS(phy) && !(capflag & WLAN_RC_DS_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 478 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 479 | if (WLAN_RC_PHY_SGI(phy) && !(capflag & WLAN_RC_SGI_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 480 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 481 | if (!ignore_cw && WLAN_RC_PHY_HT(phy)) |
| 482 | if (WLAN_RC_PHY_40(phy) && !(capflag & WLAN_RC_40_FLAG)) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 483 | return 0; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 484 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | static inline int |
Luis R. Rodriguez | 39448b0 | 2009-07-14 20:14:00 -0400 | [diff] [blame] | 488 | ath_rc_get_lower_rix(const struct ath_rate_table *rate_table, |
| 489 | struct ath_rate_priv *ath_rc_priv, |
| 490 | u8 cur_valid_txrate, u8 *next_idx) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 491 | { |
| 492 | int8_t i; |
| 493 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 494 | for (i = 1; i < ath_rc_priv->max_valid_rate ; i++) { |
| 495 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
| 496 | *next_idx = ath_rc_priv->valid_rate_index[i-1]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 497 | return 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 498 | } |
| 499 | } |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 500 | |
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 | } |
| 503 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 504 | static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 505 | const struct ath_rate_table *rate_table, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 506 | u32 capflag) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 507 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 508 | u8 i, hi = 0; |
| 509 | u32 valid; |
| 510 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 511 | for (i = 0; i < rate_table->rate_cnt; i++) { |
Sujith | c6483cf | 2009-03-30 15:28:56 +0530 | [diff] [blame] | 512 | valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ? |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 513 | rate_table->info[i].valid_single_stream : |
| 514 | rate_table->info[i].valid); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 515 | if (valid == 1) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 516 | u32 phy = rate_table->info[i].phy; |
| 517 | u8 valid_rate_count = 0; |
| 518 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 519 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 520 | continue; |
| 521 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 522 | valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 523 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 524 | ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = i; |
| 525 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 526 | ath_rc_set_valid_txmask(ath_rc_priv, i, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 527 | hi = A_MAX(hi, i); |
| 528 | } |
| 529 | } |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 530 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 531 | return hi; |
| 532 | } |
| 533 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 534 | static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 535 | const struct ath_rate_table *rate_table, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 536 | struct ath_rateset *rateset, |
| 537 | u32 capflag) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 538 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 539 | u8 i, j, hi = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 540 | |
| 541 | /* Use intersection of working rates and valid rates */ |
| 542 | for (i = 0; i < rateset->rs_nrates; i++) { |
| 543 | for (j = 0; j < rate_table->rate_cnt; j++) { |
| 544 | u32 phy = rate_table->info[j].phy; |
Sujith | c6483cf | 2009-03-30 15:28:56 +0530 | [diff] [blame] | 545 | u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ? |
| 546 | rate_table->info[j].valid_single_stream : |
| 547 | rate_table->info[j].valid); |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 548 | u8 rate = rateset->rs_rates[i]; |
| 549 | u8 dot11rate = rate_table->info[j].dot11rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 550 | |
| 551 | /* We allow a rate only if its valid and the |
| 552 | * capflag matches one of the validity |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 553 | * (VALID/VALID_20/VALID_40) flags */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 554 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 555 | if ((rate == dot11rate) && |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 556 | ((valid & WLAN_RC_CAP_MODE(capflag)) == |
| 557 | WLAN_RC_CAP_MODE(capflag)) && |
| 558 | !WLAN_RC_PHY_HT(phy)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 559 | u8 valid_rate_count = 0; |
| 560 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 561 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 562 | continue; |
| 563 | |
| 564 | valid_rate_count = |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 565 | ath_rc_priv->valid_phy_ratecnt[phy]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 566 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 567 | ath_rc_priv->valid_phy_rateidx[phy] |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 568 | [valid_rate_count] = j; |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 569 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 570 | ath_rc_set_valid_txmask(ath_rc_priv, j, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 571 | hi = A_MAX(hi, j); |
| 572 | } |
| 573 | } |
| 574 | } |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 575 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 576 | return hi; |
| 577 | } |
| 578 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 579 | static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 580 | const struct ath_rate_table *rate_table, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 581 | u8 *mcs_set, u32 capflag) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 582 | { |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 583 | struct ath_rateset *rateset = (struct ath_rateset *)mcs_set; |
| 584 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 585 | u8 i, j, hi = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 586 | |
| 587 | /* Use intersection of working rates and valid rates */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 588 | for (i = 0; i < rateset->rs_nrates; i++) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 589 | for (j = 0; j < rate_table->rate_cnt; j++) { |
| 590 | u32 phy = rate_table->info[j].phy; |
Sujith | c6483cf | 2009-03-30 15:28:56 +0530 | [diff] [blame] | 591 | u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ? |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 592 | rate_table->info[j].valid_single_stream : |
| 593 | rate_table->info[j].valid); |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 594 | u8 rate = rateset->rs_rates[i]; |
| 595 | u8 dot11rate = rate_table->info[j].dot11rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 596 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 597 | if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) || |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 598 | !WLAN_RC_PHY_HT_VALID(valid, capflag)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 599 | continue; |
| 600 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 601 | if (!ath_rc_valid_phyrate(phy, capflag, 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 602 | continue; |
| 603 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 604 | ath_rc_priv->valid_phy_rateidx[phy] |
| 605 | [ath_rc_priv->valid_phy_ratecnt[phy]] = j; |
| 606 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 607 | ath_rc_set_valid_txmask(ath_rc_priv, j, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 608 | hi = A_MAX(hi, j); |
| 609 | } |
| 610 | } |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 611 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 612 | return hi; |
| 613 | } |
| 614 | |
Luis R. Rodriguez | 201c3b4 | 2009-07-14 20:14:04 -0400 | [diff] [blame] | 615 | /* Finds the highest rate index we can use */ |
| 616 | static u8 ath_rc_get_highest_rix(struct ath_softc *sc, |
| 617 | struct ath_rate_priv *ath_rc_priv, |
| 618 | const struct ath_rate_table *rate_table, |
| 619 | int *is_probing) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 620 | { |
Vasanthakumar Thiagarajan | 39a4caf | 2009-07-14 20:14:10 -0400 | [diff] [blame] | 621 | u32 best_thruput, this_thruput, now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 622 | u8 rate, next_rate, best_rate, maxindex, minindex; |
Vasanthakumar Thiagarajan | 39a4caf | 2009-07-14 20:14:10 -0400 | [diff] [blame] | 623 | int8_t index = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 624 | |
| 625 | now_msec = jiffies_to_msecs(jiffies); |
Vasanthakumar Thiagarajan | 39a4caf | 2009-07-14 20:14:10 -0400 | [diff] [blame] | 626 | *is_probing = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 627 | best_thruput = 0; |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 628 | maxindex = ath_rc_priv->max_valid_rate-1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 629 | minindex = 0; |
| 630 | best_rate = minindex; |
| 631 | |
| 632 | /* |
| 633 | * Try the higher rate first. It will reduce memory moving time |
| 634 | * if we have very good channel characteristics. |
| 635 | */ |
| 636 | for (index = maxindex; index >= minindex ; index--) { |
| 637 | u8 per_thres; |
| 638 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 639 | rate = ath_rc_priv->valid_rate_index[index]; |
| 640 | if (rate > ath_rc_priv->rate_max_phy) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 641 | continue; |
| 642 | |
| 643 | /* |
| 644 | * For TCP the average collision rate is around 11%, |
| 645 | * so we ignore PERs less than this. This is to |
| 646 | * prevent the rate we are currently using (whose |
| 647 | * PER might be in the 10-15 range because of TCP |
| 648 | * collisions) looking worse than the next lower |
| 649 | * rate whose PER has decayed close to 0. If we |
| 650 | * used to next lower rate, its PER would grow to |
| 651 | * 10-15 and we would be worse off then staying |
| 652 | * at the current rate. |
| 653 | */ |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 654 | per_thres = ath_rc_priv->per[rate]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 655 | if (per_thres < 12) |
| 656 | per_thres = 12; |
| 657 | |
| 658 | this_thruput = rate_table->info[rate].user_ratekbps * |
| 659 | (100 - per_thres); |
| 660 | |
| 661 | if (best_thruput <= this_thruput) { |
| 662 | best_thruput = this_thruput; |
| 663 | best_rate = rate; |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | rate = best_rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 668 | |
| 669 | /* |
| 670 | * Must check the actual rate (ratekbps) to account for |
| 671 | * non-monoticity of 11g's rate table |
| 672 | */ |
| 673 | |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 674 | if (rate >= ath_rc_priv->rate_max_phy) { |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 675 | rate = ath_rc_priv->rate_max_phy; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 676 | |
| 677 | /* Probe the next allowed phy state */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 678 | if (ath_rc_get_nextvalid_txrate(rate_table, |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 679 | ath_rc_priv, rate, &next_rate) && |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 680 | (now_msec - ath_rc_priv->probe_time > |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 681 | rate_table->probe_interval) && |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 682 | (ath_rc_priv->hw_maxretry_pktcnt >= 1)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 683 | rate = next_rate; |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 684 | ath_rc_priv->probe_rate = rate; |
| 685 | ath_rc_priv->probe_time = now_msec; |
| 686 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 687 | *is_probing = 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 688 | } |
| 689 | } |
| 690 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 691 | if (rate > (ath_rc_priv->rate_table_size - 1)) |
| 692 | rate = ath_rc_priv->rate_table_size - 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 693 | |
Luis R. Rodriguez | e43419f | 2009-07-14 20:13:54 -0400 | [diff] [blame] | 694 | if (rate_table->info[rate].valid && |
| 695 | (ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG)) |
| 696 | return rate; |
| 697 | |
| 698 | if (rate_table->info[rate].valid_single_stream && |
Luis R. Rodriguez | e55ea2b | 2009-10-28 20:19:06 -0400 | [diff] [blame] | 699 | !(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG)) |
Luis R. Rodriguez | e43419f | 2009-07-14 20:13:54 -0400 | [diff] [blame] | 700 | return rate; |
| 701 | |
| 702 | /* This should not happen */ |
| 703 | WARN_ON(1); |
| 704 | |
| 705 | rate = ath_rc_priv->valid_rate_index[0]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 706 | |
| 707 | return rate; |
| 708 | } |
| 709 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 710 | static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table, |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 711 | struct ieee80211_tx_rate *rate, |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 712 | struct ieee80211_tx_rate_control *txrc, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 713 | u8 tries, u8 rix, int rtsctsenable) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 714 | { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 715 | rate->count = tries; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 716 | rate->idx = rate_table->info[rix].ratecode; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 717 | |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 718 | if (txrc->short_preamble) |
| 719 | rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; |
| 720 | if (txrc->rts || rtsctsenable) |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 721 | rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 722 | |
| 723 | if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 724 | rate->flags |= IEEE80211_TX_RC_MCS; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 725 | if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) |
| 726 | rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; |
| 727 | if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy)) |
| 728 | rate->flags |= IEEE80211_TX_RC_SHORT_GI; |
| 729 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 730 | } |
| 731 | |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 732 | static void ath_rc_rate_set_rtscts(struct ath_softc *sc, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 733 | const struct ath_rate_table *rate_table, |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 734 | struct ieee80211_tx_info *tx_info) |
| 735 | { |
| 736 | struct ieee80211_tx_rate *rates = tx_info->control.rates; |
| 737 | int i = 0, rix = 0, cix, enable_g_protection = 0; |
| 738 | |
| 739 | /* get the cix for the lowest valid rix */ |
| 740 | for (i = 3; i >= 0; i--) { |
| 741 | if (rates[i].count && (rates[i].idx >= 0)) { |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 742 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 743 | break; |
| 744 | } |
| 745 | } |
| 746 | cix = rate_table->info[rix].ctrl_rate; |
| 747 | |
| 748 | /* All protection frames are transmited at 2Mb/s for 802.11g, |
| 749 | * otherwise we transmit them at 1Mb/s */ |
| 750 | if (sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ && |
| 751 | !conf_is_ht(&sc->hw->conf)) |
| 752 | enable_g_protection = 1; |
| 753 | |
| 754 | /* |
| 755 | * If 802.11g protection is enabled, determine whether to use RTS/CTS or |
| 756 | * just CTS. Note that this is only done for OFDM/HT unicast frames. |
| 757 | */ |
| 758 | if ((sc->sc_flags & SC_OP_PROTECT_ENABLE) && |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 759 | (rate_table->info[rix].phy == WLAN_RC_PHY_OFDM || |
| 760 | WLAN_RC_PHY_HT(rate_table->info[rix].phy))) { |
| 761 | rates[0].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT; |
| 762 | cix = rate_table->info[enable_g_protection].ctrl_rate; |
| 763 | } |
| 764 | |
| 765 | tx_info->control.rts_cts_rate_idx = cix; |
| 766 | } |
| 767 | |
Luis R. Rodriguez | e25739a | 2009-07-14 20:14:09 -0400 | [diff] [blame] | 768 | static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, |
| 769 | struct ieee80211_tx_rate_control *txrc) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 770 | { |
Luis R. Rodriguez | e25739a | 2009-07-14 20:14:09 -0400 | [diff] [blame] | 771 | struct ath_softc *sc = priv; |
| 772 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 773 | const struct ath_rate_table *rate_table; |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 774 | struct sk_buff *skb = txrc->skb; |
| 775 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 776 | struct ieee80211_tx_rate *rates = tx_info->control.rates; |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 777 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 778 | __le16 fc = hdr->frame_control; |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 779 | u8 try_per_rate, i = 0, rix, nrix; |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 780 | int is_probe = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 781 | |
Luis R. Rodriguez | e25739a | 2009-07-14 20:14:09 -0400 | [diff] [blame] | 782 | if (rate_control_send_low(sta, priv_sta, txrc)) |
| 783 | return; |
| 784 | |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 785 | /* |
| 786 | * For Multi Rate Retry we use a different number of |
| 787 | * retry attempt counts. This ends up looking like this: |
| 788 | * |
| 789 | * MRR[0] = 2 |
| 790 | * MRR[1] = 2 |
| 791 | * MRR[2] = 2 |
| 792 | * MRR[3] = 4 |
| 793 | * |
| 794 | */ |
| 795 | try_per_rate = sc->hw->max_rate_tries; |
| 796 | |
Sujith | 40990ec | 2008-12-07 21:41:37 +0530 | [diff] [blame] | 797 | rate_table = sc->cur_rate_table; |
Luis R. Rodriguez | 201c3b4 | 2009-07-14 20:14:04 -0400 | [diff] [blame] | 798 | rix = ath_rc_get_highest_rix(sc, ath_rc_priv, rate_table, &is_probe); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 799 | nrix = rix; |
| 800 | |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 801 | if (is_probe) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 802 | /* set one try for probe rates. For the |
| 803 | * probes don't enable rts */ |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 804 | ath_rc_rate_set_series(rate_table, &rates[i++], txrc, |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 805 | 1, nrix, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 806 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 807 | /* Get the next tried/allowed rate. No RTS for the next series |
| 808 | * after the probe rate |
| 809 | */ |
Luis R. Rodriguez | 39448b0 | 2009-07-14 20:14:00 -0400 | [diff] [blame] | 810 | ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &nrix); |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 811 | ath_rc_rate_set_series(rate_table, &rates[i++], txrc, |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 812 | try_per_rate, nrix, 0); |
Vasanthakumar Thiagarajan | 14587ce | 2009-03-12 15:32:54 +0530 | [diff] [blame] | 813 | |
| 814 | tx_info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 815 | } else { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 816 | /* Set the choosen rate. No RTS for first series entry. */ |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 817 | ath_rc_rate_set_series(rate_table, &rates[i++], txrc, |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 818 | try_per_rate, nrix, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* Fill in the other rates for multirate retry */ |
Sujith | 3900898 | 2009-01-30 14:29:15 +0530 | [diff] [blame] | 822 | for ( ; i < 4; i++) { |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 823 | /* Use twice the number of tries for the last MRR segment. */ |
| 824 | if (i + 1 == 4) |
| 825 | try_per_rate = 4; |
| 826 | |
Luis R. Rodriguez | 39448b0 | 2009-07-14 20:14:00 -0400 | [diff] [blame] | 827 | ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &nrix); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 828 | /* All other rates in the series have RTS enabled */ |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 829 | ath_rc_rate_set_series(rate_table, &rates[i], txrc, |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 830 | try_per_rate, nrix, 1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | /* |
| 834 | * NB:Change rate series to enable aggregation when operating |
| 835 | * at lower MCS rates. When first rate in series is MCS2 |
| 836 | * in HT40 @ 2.4GHz, series should look like: |
| 837 | * |
| 838 | * {MCS2, MCS1, MCS0, MCS0}. |
| 839 | * |
| 840 | * When first rate in series is MCS3 in HT20 @ 2.4GHz, series should |
| 841 | * look like: |
| 842 | * |
| 843 | * {MCS3, MCS2, MCS1, MCS1} |
| 844 | * |
| 845 | * So, set fourth rate in series to be same as third one for |
| 846 | * above conditions. |
| 847 | */ |
Sujith | 3706de6 | 2008-12-07 21:42:10 +0530 | [diff] [blame] | 848 | if ((sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ) && |
Luis R. Rodriguez | ecf7044 | 2008-12-23 15:58:43 -0800 | [diff] [blame] | 849 | (conf_is_ht(&sc->hw->conf))) { |
Sujith | 40990ec | 2008-12-07 21:41:37 +0530 | [diff] [blame] | 850 | u8 dot11rate = rate_table->info[rix].dot11rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 851 | u8 phy = rate_table->info[rix].phy; |
| 852 | if (i == 4 && |
| 853 | ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) || |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 854 | (dot11rate == 3 && phy == WLAN_RC_PHY_HT_20_SS))) { |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 855 | rates[3].idx = rates[2].idx; |
| 856 | rates[3].flags = rates[2].flags; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 857 | } |
| 858 | } |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 859 | |
| 860 | /* |
| 861 | * Force hardware to use computed duration for next |
| 862 | * fragment by disabling multi-rate retry, which |
| 863 | * updates duration based on the multi-rate duration table. |
| 864 | * |
| 865 | * FIXME: Fix duration |
| 866 | */ |
Luis R. Rodriguez | 7682a76 | 2009-07-14 20:14:05 -0400 | [diff] [blame] | 867 | if (ieee80211_has_morefrags(fc) || |
| 868 | (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) { |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 869 | rates[1].count = rates[2].count = rates[3].count = 0; |
| 870 | rates[1].idx = rates[2].idx = rates[3].idx = 0; |
| 871 | rates[0].count = ATH_TXMAXTRY; |
| 872 | } |
| 873 | |
| 874 | /* Setup RTS/CTS */ |
| 875 | ath_rc_rate_set_rtscts(sc, rate_table, tx_info); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 878 | static bool ath_rc_update_per(struct ath_softc *sc, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 879 | const struct ath_rate_table *rate_table, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 880 | struct ath_rate_priv *ath_rc_priv, |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 881 | struct ieee80211_tx_info *tx_info, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 882 | int tx_rate, int xretries, int retries, |
| 883 | u32 now_msec) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 884 | { |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 885 | bool state_change = false; |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 886 | int count, n_bad_frames; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 887 | u8 last_per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 888 | static u32 nretry_to_per_lookup[10] = { |
| 889 | 100 * 0 / 1, |
| 890 | 100 * 1 / 4, |
| 891 | 100 * 1 / 2, |
| 892 | 100 * 3 / 4, |
| 893 | 100 * 4 / 5, |
| 894 | 100 * 5 / 6, |
| 895 | 100 * 6 / 7, |
| 896 | 100 * 7 / 8, |
| 897 | 100 * 8 / 9, |
| 898 | 100 * 9 / 10 |
| 899 | }; |
| 900 | |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 901 | last_per = ath_rc_priv->per[tx_rate]; |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 902 | n_bad_frames = tx_info->status.ampdu_len - tx_info->status.ampdu_ack_len; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 903 | |
| 904 | if (xretries) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 905 | if (xretries == 1) { |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 906 | ath_rc_priv->per[tx_rate] += 30; |
| 907 | if (ath_rc_priv->per[tx_rate] > 100) |
| 908 | ath_rc_priv->per[tx_rate] = 100; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 909 | } else { |
| 910 | /* xretries == 2 */ |
Julia Lawall | 87c1687 | 2008-11-09 17:56:10 +0100 | [diff] [blame] | 911 | count = ARRAY_SIZE(nretry_to_per_lookup); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 912 | if (retries >= count) |
| 913 | retries = count - 1; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 914 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 915 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 916 | ath_rc_priv->per[tx_rate] = |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 917 | (u8)(last_per - (last_per >> 3) + (100 >> 3)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /* xretries == 1 or 2 */ |
| 921 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 922 | if (ath_rc_priv->probe_rate == tx_rate) |
| 923 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 924 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 925 | } else { /* xretries == 0 */ |
Julia Lawall | 87c1687 | 2008-11-09 17:56:10 +0100 | [diff] [blame] | 926 | count = ARRAY_SIZE(nretry_to_per_lookup); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 927 | if (retries >= count) |
| 928 | retries = count - 1; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 929 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 930 | if (n_bad_frames) { |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 931 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 932 | * Assuming that n_frames is not 0. The current PER |
| 933 | * from the retries is 100 * retries / (retries+1), |
| 934 | * since the first retries attempts failed, and the |
| 935 | * next one worked. For the one that worked, |
| 936 | * n_bad_frames subframes out of n_frames wored, |
| 937 | * so the PER for that part is |
| 938 | * 100 * n_bad_frames / n_frames, and it contributes |
| 939 | * 100 * n_bad_frames / (n_frames * (retries+1)) to |
| 940 | * the above PER. The expression below is a |
| 941 | * simplified version of the sum of these two terms. |
| 942 | */ |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 943 | if (tx_info->status.ampdu_len > 0) { |
| 944 | int n_frames, n_bad_tries; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 945 | u8 cur_per, new_per; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 946 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 947 | n_bad_tries = retries * tx_info->status.ampdu_len + |
| 948 | n_bad_frames; |
| 949 | n_frames = tx_info->status.ampdu_len * (retries + 1); |
| 950 | cur_per = (100 * n_bad_tries / n_frames) >> 3; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 951 | new_per = (u8)(last_per - (last_per >> 3) + cur_per); |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 952 | ath_rc_priv->per[tx_rate] = new_per; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 953 | } |
| 954 | } else { |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 955 | ath_rc_priv->per[tx_rate] = |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 956 | (u8)(last_per - (last_per >> 3) + |
| 957 | (nretry_to_per_lookup[retries] >> 3)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 958 | } |
| 959 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 960 | |
| 961 | /* |
| 962 | * If we got at most one retry then increase the max rate if |
| 963 | * this was a probe. Otherwise, ignore the probe. |
| 964 | */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 965 | if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) { |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 966 | if (retries > 0 || 2 * n_bad_frames > tx_info->status.ampdu_len) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 967 | /* |
| 968 | * Since we probed with just a single attempt, |
| 969 | * any retries means the probe failed. Also, |
| 970 | * if the attempt worked, but more than half |
| 971 | * the subframes were bad then also consider |
| 972 | * the probe a failure. |
| 973 | */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 974 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 975 | } else { |
| 976 | u8 probe_rate = 0; |
| 977 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 978 | ath_rc_priv->rate_max_phy = |
| 979 | ath_rc_priv->probe_rate; |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 980 | probe_rate = ath_rc_priv->probe_rate; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 981 | |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 982 | if (ath_rc_priv->per[probe_rate] > 30) |
| 983 | ath_rc_priv->per[probe_rate] = 20; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 984 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 985 | ath_rc_priv->probe_rate = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 986 | |
| 987 | /* |
| 988 | * Since this probe succeeded, we allow the next |
| 989 | * probe twice as soon. This allows the maxRate |
| 990 | * to move up faster if the probes are |
| 991 | * succesful. |
| 992 | */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 993 | ath_rc_priv->probe_time = |
| 994 | now_msec - rate_table->probe_interval / 2; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 995 | } |
| 996 | } |
| 997 | |
| 998 | if (retries > 0) { |
| 999 | /* |
| 1000 | * Don't update anything. We don't know if |
| 1001 | * this was because of collisions or poor signal. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1002 | */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1003 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1004 | } else { |
| 1005 | /* |
| 1006 | * It worked with no retries. First ignore bogus (small) |
| 1007 | * rssi_ack values. |
| 1008 | */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1009 | if (tx_rate == ath_rc_priv->rate_max_phy && |
| 1010 | ath_rc_priv->hw_maxretry_pktcnt < 255) { |
| 1011 | ath_rc_priv->hw_maxretry_pktcnt++; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1014 | } |
| 1015 | } |
Vasanthakumar Thiagarajan | 39a4caf | 2009-07-14 20:14:10 -0400 | [diff] [blame] | 1016 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1017 | return state_change; |
| 1018 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1019 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1020 | /* Update PER, RSSI and whatever else that the code thinks it is doing. |
| 1021 | If you can make sense of all this, you really need to go out more. */ |
| 1022 | |
| 1023 | static void ath_rc_update_ht(struct ath_softc *sc, |
| 1024 | struct ath_rate_priv *ath_rc_priv, |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1025 | struct ieee80211_tx_info *tx_info, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1026 | int tx_rate, int xretries, int retries) |
| 1027 | { |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1028 | u32 now_msec = jiffies_to_msecs(jiffies); |
| 1029 | int rate; |
| 1030 | u8 last_per; |
| 1031 | bool state_change = false; |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1032 | const struct ath_rate_table *rate_table = sc->cur_rate_table; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1033 | int size = ath_rc_priv->rate_table_size; |
| 1034 | |
| 1035 | if ((tx_rate < 0) || (tx_rate > rate_table->rate_cnt)) |
| 1036 | return; |
| 1037 | |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1038 | last_per = ath_rc_priv->per[tx_rate]; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1039 | |
| 1040 | /* Update PER first */ |
| 1041 | state_change = ath_rc_update_per(sc, rate_table, ath_rc_priv, |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1042 | tx_info, tx_rate, xretries, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1043 | retries, now_msec); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1044 | |
| 1045 | /* |
| 1046 | * If this rate looks bad (high PER) then stop using it for |
| 1047 | * a while (except if we are probing). |
| 1048 | */ |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1049 | if (ath_rc_priv->per[tx_rate] >= 55 && tx_rate > 0 && |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1050 | rate_table->info[tx_rate].ratekbps <= |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1051 | rate_table->info[ath_rc_priv->rate_max_phy].ratekbps) { |
Luis R. Rodriguez | 39448b0 | 2009-07-14 20:14:00 -0400 | [diff] [blame] | 1052 | ath_rc_get_lower_rix(rate_table, ath_rc_priv, |
| 1053 | (u8)tx_rate, &ath_rc_priv->rate_max_phy); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1054 | |
| 1055 | /* Don't probe for a little while. */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1056 | ath_rc_priv->probe_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1057 | } |
| 1058 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1059 | /* Make sure the rates below this have lower PER */ |
| 1060 | /* Monotonicity is kept only for rates below the current rate. */ |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1061 | if (ath_rc_priv->per[tx_rate] < last_per) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1062 | for (rate = tx_rate - 1; rate >= 0; rate--) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1063 | |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1064 | if (ath_rc_priv->per[rate] > |
| 1065 | ath_rc_priv->per[rate+1]) { |
| 1066 | ath_rc_priv->per[rate] = |
| 1067 | ath_rc_priv->per[rate+1]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | /* Maintain monotonicity for rates above the current rate */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1073 | for (rate = tx_rate; rate < size - 1; rate++) { |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1074 | if (ath_rc_priv->per[rate+1] < |
| 1075 | ath_rc_priv->per[rate]) |
| 1076 | ath_rc_priv->per[rate+1] = |
| 1077 | ath_rc_priv->per[rate]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1080 | /* Every so often, we reduce the thresholds |
| 1081 | * and PER (different for CCK and OFDM). */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1082 | if (now_msec - ath_rc_priv->per_down_time >= |
Vasanthakumar Thiagarajan | c413046 | 2009-07-14 20:14:12 -0400 | [diff] [blame] | 1083 | rate_table->probe_interval) { |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1084 | for (rate = 0; rate < size; rate++) { |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1085 | ath_rc_priv->per[rate] = |
| 1086 | 7 * ath_rc_priv->per[rate] / 8; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1089 | ath_rc_priv->per_down_time = now_msec; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1090 | } |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1091 | |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame] | 1092 | ath_debug_stat_retries(sc, tx_rate, xretries, retries, |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1093 | ath_rc_priv->per[tx_rate]); |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 1094 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1095 | } |
| 1096 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1097 | static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1098 | struct ieee80211_tx_rate *rate) |
| 1099 | { |
| 1100 | int rix; |
| 1101 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1102 | if (!(rate->flags & IEEE80211_TX_RC_MCS)) |
| 1103 | return rate->idx; |
| 1104 | |
| 1105 | rix = rate->idx + rate_table->mcs_start; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1106 | if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
| 1107 | (rate->flags & IEEE80211_TX_RC_SHORT_GI)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1108 | rix = rate_table->info[rix].ht_index; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1109 | else if (rate->flags & IEEE80211_TX_RC_SHORT_GI) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1110 | rix = rate_table->info[rix].sgi_index; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1111 | else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1112 | rix = rate_table->info[rix].cw40index; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1113 | else |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1114 | rix = rate_table->info[rix].base_index; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1115 | |
| 1116 | return rix; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1117 | } |
| 1118 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1119 | static void ath_rc_tx_status(struct ath_softc *sc, |
| 1120 | struct ath_rate_priv *ath_rc_priv, |
| 1121 | struct ieee80211_tx_info *tx_info, |
| 1122 | int final_ts_idx, int xretries, int long_retry) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1123 | { |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1124 | const struct ath_rate_table *rate_table; |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1125 | struct ieee80211_tx_rate *rates = tx_info->status.rates; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1126 | u8 flags; |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1127 | u32 i = 0, rix; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1128 | |
Sujith | 40990ec | 2008-12-07 21:41:37 +0530 | [diff] [blame] | 1129 | rate_table = sc->cur_rate_table; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1130 | |
| 1131 | /* |
| 1132 | * If the first rate is not the final index, there |
| 1133 | * are intermediate rate failures to be processed. |
| 1134 | */ |
| 1135 | if (final_ts_idx != 0) { |
| 1136 | /* Process intermediate rates that failed.*/ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1137 | for (i = 0; i < final_ts_idx ; i++) { |
| 1138 | if (rates[i].count != 0 && (rates[i].idx >= 0)) { |
| 1139 | flags = rates[i].flags; |
| 1140 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1141 | /* If HT40 and we have switched mode from |
| 1142 | * 40 to 20 => don't update */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1143 | |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1144 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
Sujith | f5c38ef | 2009-03-30 15:28:57 +0530 | [diff] [blame] | 1145 | !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1146 | return; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1147 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1148 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1149 | ath_rc_update_ht(sc, ath_rc_priv, tx_info, |
| 1150 | rix, xretries ? 1 : 2, |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1151 | rates[i].count); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1152 | } |
| 1153 | } |
| 1154 | } else { |
| 1155 | /* |
| 1156 | * Handle the special case of MIMO PS burst, where the second |
| 1157 | * aggregate is sent out with only one rate and one try. |
| 1158 | * Treating it as an excessive retry penalizes the rate |
| 1159 | * inordinately. |
| 1160 | */ |
Sujith | a8efee4 | 2008-11-18 09:07:30 +0530 | [diff] [blame] | 1161 | if (rates[0].count == 1 && xretries == 1) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1162 | xretries = 2; |
| 1163 | } |
| 1164 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1165 | flags = rates[i].flags; |
| 1166 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1167 | /* 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] | 1168 | if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && |
Sujith | f5c38ef | 2009-03-30 15:28:57 +0530 | [diff] [blame] | 1169 | !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1170 | return; |
| 1171 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1172 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1173 | ath_rc_update_ht(sc, ath_rc_priv, tx_info, rix, xretries, long_retry); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1176 | static const |
| 1177 | struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc, |
| 1178 | enum ieee80211_band band, |
| 1179 | bool is_ht, |
| 1180 | bool is_cw_40) |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 1181 | { |
| 1182 | int mode = 0; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1183 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 1184 | |
| 1185 | switch(band) { |
| 1186 | case IEEE80211_BAND_2GHZ: |
| 1187 | mode = ATH9K_MODE_11G; |
| 1188 | if (is_ht) |
| 1189 | mode = ATH9K_MODE_11NG_HT20; |
| 1190 | if (is_cw_40) |
| 1191 | mode = ATH9K_MODE_11NG_HT40PLUS; |
| 1192 | break; |
| 1193 | case IEEE80211_BAND_5GHZ: |
| 1194 | mode = ATH9K_MODE_11A; |
| 1195 | if (is_ht) |
| 1196 | mode = ATH9K_MODE_11NA_HT20; |
| 1197 | if (is_cw_40) |
| 1198 | mode = ATH9K_MODE_11NA_HT40PLUS; |
| 1199 | break; |
| 1200 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1201 | ath_print(common, ATH_DBG_CONFIG, "Invalid band\n"); |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 1202 | return NULL; |
| 1203 | } |
| 1204 | |
| 1205 | BUG_ON(mode >= ATH9K_MODE_MAX); |
| 1206 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1207 | ath_print(common, ATH_DBG_CONFIG, |
| 1208 | "Choosing rate table for mode: %d\n", mode); |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1209 | |
| 1210 | sc->cur_rate_mode = mode; |
| 1211 | return hw_rate_table[mode]; |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 1212 | } |
| 1213 | |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1214 | static void ath_rc_init(struct ath_softc *sc, |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1215 | struct ath_rate_priv *ath_rc_priv, |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1216 | struct ieee80211_supported_band *sband, |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1217 | struct ieee80211_sta *sta, |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1218 | const struct ath_rate_table *rate_table) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1219 | { |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1220 | struct ath_rateset *rateset = &ath_rc_priv->neg_rates; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1221 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1222 | u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1223 | u8 i, j, k, hi = 0, hthi = 0; |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 1224 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1225 | /* Initial rate table size. Will change depending |
| 1226 | * on the working rate set */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1227 | ath_rc_priv->rate_table_size = RATE_TABLE_SIZE; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1228 | |
| 1229 | /* Initialize thresholds according to the global rate table */ |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1230 | for (i = 0 ; i < ath_rc_priv->rate_table_size; i++) { |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 1231 | ath_rc_priv->per[i] = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /* Determine the valid rates */ |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1235 | ath_rc_init_valid_txmask(ath_rc_priv); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1236 | |
| 1237 | for (i = 0; i < WLAN_RC_PHY_MAX; i++) { |
| 1238 | for (j = 0; j < MAX_TX_RATE_PHY; j++) |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1239 | ath_rc_priv->valid_phy_rateidx[i][j] = 0; |
| 1240 | ath_rc_priv->valid_phy_ratecnt[i] = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1241 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1242 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1243 | if (!rateset->rs_nrates) { |
| 1244 | /* No working rate, just initialize valid rates */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1245 | hi = ath_rc_init_validrates(ath_rc_priv, rate_table, |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 1246 | ath_rc_priv->ht_cap); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1247 | } else { |
| 1248 | /* Use intersection of working rates and valid rates */ |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1249 | hi = ath_rc_setvalid_rates(ath_rc_priv, rate_table, |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 1250 | rateset, ath_rc_priv->ht_cap); |
Sujith | 5ddfac3 | 2008-11-18 09:06:44 +0530 | [diff] [blame] | 1251 | if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) { |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 1252 | hthi = ath_rc_setvalid_htrates(ath_rc_priv, |
Sujith | c89424d | 2009-01-30 14:29:28 +0530 | [diff] [blame] | 1253 | rate_table, |
| 1254 | ht_mcs, |
| 1255 | ath_rc_priv->ht_cap); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1256 | } |
| 1257 | hi = A_MAX(hi, hthi); |
| 1258 | } |
| 1259 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1260 | ath_rc_priv->rate_table_size = hi + 1; |
| 1261 | ath_rc_priv->rate_max_phy = 0; |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 1262 | BUG_ON(ath_rc_priv->rate_table_size > RATE_TABLE_SIZE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1263 | |
| 1264 | for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) { |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1265 | for (j = 0; j < ath_rc_priv->valid_phy_ratecnt[i]; j++) { |
| 1266 | ath_rc_priv->valid_rate_index[k++] = |
| 1267 | ath_rc_priv->valid_phy_rateidx[i][j]; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1268 | } |
| 1269 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1270 | if (!ath_rc_valid_phyrate(i, rate_table->initial_ratemax, 1) |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1271 | || !ath_rc_priv->valid_phy_ratecnt[i]) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1272 | continue; |
| 1273 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1274 | 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] | 1275 | } |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 1276 | BUG_ON(ath_rc_priv->rate_table_size > RATE_TABLE_SIZE); |
| 1277 | BUG_ON(k > RATE_TABLE_SIZE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1278 | |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1279 | ath_rc_priv->max_valid_rate = k; |
Sujith | 256b7759 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 1280 | ath_rc_sort_validrates(rate_table, ath_rc_priv); |
| 1281 | ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; |
Sujith | 40990ec | 2008-12-07 21:41:37 +0530 | [diff] [blame] | 1282 | sc->cur_rate_table = rate_table; |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1283 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1284 | ath_print(common, ATH_DBG_CONFIG, |
| 1285 | "RC Initialized with capabilities: 0x%x\n", |
| 1286 | ath_rc_priv->ht_cap); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
Sujith | c2da50e | 2009-03-13 08:56:11 +0530 | [diff] [blame] | 1289 | static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta, |
| 1290 | bool is_cw40, bool is_sgi40) |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1291 | { |
| 1292 | u8 caps = 0; |
| 1293 | |
Sujith | c2da50e | 2009-03-13 08:56:11 +0530 | [diff] [blame] | 1294 | if (sta->ht_cap.ht_supported) { |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1295 | caps = WLAN_RC_HT_FLAG; |
| 1296 | if (sc->sc_ah->caps.tx_chainmask != 1 && |
Sujith | c2da50e | 2009-03-13 08:56:11 +0530 | [diff] [blame] | 1297 | ath9k_hw_getcapability(sc->sc_ah, ATH9K_CAP_DS, 0, NULL)) { |
| 1298 | if (sta->ht_cap.mcs.rx_mask[1]) |
| 1299 | caps |= WLAN_RC_DS_FLAG; |
| 1300 | } |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1301 | if (is_cw40) |
| 1302 | caps |= WLAN_RC_40_FLAG; |
| 1303 | if (is_sgi40) |
| 1304 | caps |= WLAN_RC_SGI_FLAG; |
| 1305 | } |
| 1306 | |
| 1307 | return caps; |
| 1308 | } |
| 1309 | |
| 1310 | /***********************************/ |
| 1311 | /* mac80211 Rate Control callbacks */ |
| 1312 | /***********************************/ |
| 1313 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1314 | static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, |
| 1315 | struct ieee80211_sta *sta, void *priv_sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1316 | struct sk_buff *skb) |
| 1317 | { |
| 1318 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1319 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1320 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
| 1321 | struct ieee80211_hdr *hdr; |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1322 | int final_ts_idx = 0, tx_status = 0, is_underrun = 0; |
| 1323 | int long_retry = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1324 | __le16 fc; |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1325 | int i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1326 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1327 | hdr = (struct ieee80211_hdr *)skb->data; |
| 1328 | fc = hdr->frame_control; |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1329 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { |
| 1330 | struct ieee80211_tx_rate *rate = &tx_info->status.rates[i]; |
| 1331 | if (!rate->count) |
| 1332 | break; |
| 1333 | |
| 1334 | final_ts_idx = i; |
| 1335 | long_retry = rate->count - 1; |
| 1336 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1337 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1338 | if (!priv_sta || !ieee80211_is_data(fc) || |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1339 | !(tx_info->pad[0] & ATH_TX_INFO_UPDATE_RC)) |
| 1340 | return; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1341 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1342 | if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) |
| 1343 | return; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 1344 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1345 | /* |
| 1346 | * If underrun error is seen assume it as an excessive retry only |
| 1347 | * if prefetch trigger level have reached the max (0x3f for 5416) |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 1348 | * Adjust the long retry as if the frame was tried hw->max_rate_tries |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1349 | * times. This affects how ratectrl updates PER for the failed rate. |
| 1350 | */ |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1351 | if ((tx_info->pad[0] & ATH_TX_INFO_UNDERRUN) && |
| 1352 | (sc->sc_ah->tx_trig_level >= ath_rc_priv->tx_triglevel_max)) { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1353 | tx_status = 1; |
| 1354 | is_underrun = 1; |
| 1355 | } |
| 1356 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1357 | if (tx_info->pad[0] & ATH_TX_INFO_XRETRY) |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1358 | tx_status = 1; |
| 1359 | |
| 1360 | ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status, |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 1361 | (is_underrun) ? sc->hw->max_rate_tries : long_retry); |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1362 | |
Sujith | d22b002 | 2009-01-28 11:55:45 +0530 | [diff] [blame] | 1363 | /* Check if aggregation has to be enabled for this tid */ |
Vasanthakumar Thiagarajan | d5c232f | 2009-02-18 10:22:02 +0530 | [diff] [blame] | 1364 | if (conf_is_ht(&sc->hw->conf) && |
| 1365 | !(skb->protocol == cpu_to_be16(ETH_P_PAE))) { |
Sujith | d22b002 | 2009-01-28 11:55:45 +0530 | [diff] [blame] | 1366 | if (ieee80211_is_data_qos(fc)) { |
| 1367 | u8 *qc, tid; |
| 1368 | struct ath_node *an; |
| 1369 | |
| 1370 | qc = ieee80211_get_qos_ctl(hdr); |
| 1371 | tid = qc[0] & 0xf; |
| 1372 | an = (struct ath_node *)sta->drv_priv; |
| 1373 | |
| 1374 | if(ath_tx_aggr_check(sc, an, tid)) |
Johannes Berg | c951ad3 | 2009-11-16 12:00:38 +0100 | [diff] [blame] | 1375 | ieee80211_start_tx_ba_session(sta, tid); |
Sujith | d22b002 | 2009-01-28 11:55:45 +0530 | [diff] [blame] | 1376 | } |
| 1377 | } |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 1378 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1379 | ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table, |
| 1380 | &tx_info->status.rates[final_ts_idx])); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1383 | static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, |
| 1384 | struct ieee80211_sta *sta, void *priv_sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1385 | { |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1386 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1387 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1388 | const struct ath_rate_table *rate_table; |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1389 | bool is_cw40, is_sgi40; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1390 | int i, j = 0; |
| 1391 | |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1392 | for (i = 0; i < sband->n_bitrates; i++) { |
| 1393 | if (sta->supp_rates[sband->band] & BIT(i)) { |
| 1394 | ath_rc_priv->neg_rates.rs_rates[j] |
| 1395 | = (sband->bitrates[i].bitrate * 2) / 10; |
| 1396 | j++; |
| 1397 | } |
| 1398 | } |
| 1399 | ath_rc_priv->neg_rates.rs_nrates = j; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1400 | |
Sujith | a4510bf | 2008-10-23 12:15:19 +0530 | [diff] [blame] | 1401 | if (sta->ht_cap.ht_supported) { |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1402 | for (i = 0, j = 0; i < 77; i++) { |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1403 | if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8))) |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1404 | ath_rc_priv->neg_ht_rates.rs_rates[j++] = i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1405 | if (j == ATH_RATE_MAX) |
| 1406 | break; |
| 1407 | } |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1408 | ath_rc_priv->neg_ht_rates.rs_nrates = j; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1409 | } |
Sujith | 7b4d273 | 2008-11-18 09:04:00 +0530 | [diff] [blame] | 1410 | |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1411 | is_cw40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 1412 | is_sgi40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40; |
| 1413 | |
| 1414 | /* Choose rate table first */ |
| 1415 | |
| 1416 | if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) || |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 1417 | (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) || |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1418 | (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)) { |
| 1419 | rate_table = ath_choose_rate_table(sc, sband->band, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1420 | sta->ht_cap.ht_supported, is_cw40); |
| 1421 | } else { |
| 1422 | rate_table = hw_rate_table[sc->cur_rate_mode]; |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1423 | } |
| 1424 | |
Sujith | c2da50e | 2009-03-13 08:56:11 +0530 | [diff] [blame] | 1425 | ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40); |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1426 | ath_rc_init(sc, priv_sta, sband, sta, rate_table); |
| 1427 | } |
| 1428 | |
| 1429 | static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband, |
| 1430 | struct ieee80211_sta *sta, void *priv_sta, |
| 1431 | u32 changed) |
| 1432 | { |
| 1433 | struct ath_softc *sc = priv; |
| 1434 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
Luis R. Rodriguez | 4f0fc7c | 2009-05-06 02:20:00 -0400 | [diff] [blame] | 1435 | const struct ath_rate_table *rate_table = NULL; |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1436 | bool oper_cw40 = false, oper_sgi40; |
| 1437 | bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ? |
| 1438 | true : false; |
| 1439 | bool local_sgi40 = (ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG) ? |
| 1440 | true : false; |
| 1441 | |
| 1442 | /* FIXME: Handle AP mode later when we support CWM */ |
| 1443 | |
| 1444 | if (changed & IEEE80211_RC_HT_CHANGED) { |
| 1445 | if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION) |
| 1446 | return; |
| 1447 | |
| 1448 | if (sc->hw->conf.channel_type == NL80211_CHAN_HT40MINUS || |
| 1449 | sc->hw->conf.channel_type == NL80211_CHAN_HT40PLUS) |
| 1450 | oper_cw40 = true; |
| 1451 | |
| 1452 | oper_sgi40 = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? |
| 1453 | true : false; |
| 1454 | |
| 1455 | if ((local_cw40 != oper_cw40) || (local_sgi40 != oper_sgi40)) { |
| 1456 | rate_table = ath_choose_rate_table(sc, sband->band, |
| 1457 | sta->ht_cap.ht_supported, |
| 1458 | oper_cw40); |
Sujith | c2da50e | 2009-03-13 08:56:11 +0530 | [diff] [blame] | 1459 | ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1460 | oper_cw40, oper_sgi40); |
| 1461 | ath_rc_init(sc, priv_sta, sband, sta, rate_table); |
| 1462 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1463 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG, |
| 1464 | "Operating HT Bandwidth changed to: %d\n", |
| 1465 | sc->hw->conf.channel_type); |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame^] | 1466 | sc->cur_rate_table = hw_rate_table[sc->cur_rate_mode]; |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1467 | } |
| 1468 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1469 | } |
| 1470 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1471 | 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] | 1472 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 1473 | struct ath_wiphy *aphy = hw->priv; |
| 1474 | return aphy->sc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
| 1477 | static void ath_rate_free(void *priv) |
| 1478 | { |
| 1479 | return; |
| 1480 | } |
| 1481 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1482 | 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] | 1483 | { |
| 1484 | struct ath_softc *sc = priv; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1485 | struct ath_rate_priv *rate_priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1486 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1487 | rate_priv = kzalloc(sizeof(struct ath_rate_priv), gfp); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1488 | if (!rate_priv) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1489 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, |
| 1490 | "Unable to allocate private rc structure\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1491 | return NULL; |
| 1492 | } |
Sujith | fe60594 | 2008-11-18 09:03:36 +0530 | [diff] [blame] | 1493 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1494 | rate_priv->tx_triglevel_max = sc->sc_ah->caps.tx_triglevel_max; |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 1495 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1496 | return rate_priv; |
| 1497 | } |
| 1498 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1499 | static void ath_rate_free_sta(void *priv, struct ieee80211_sta *sta, |
| 1500 | void *priv_sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1501 | { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 1502 | struct ath_rate_priv *rate_priv = priv_sta; |
Sujith | fe60594 | 2008-11-18 09:03:36 +0530 | [diff] [blame] | 1503 | kfree(rate_priv); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | static struct rate_control_ops ath_rate_ops = { |
| 1507 | .module = NULL, |
| 1508 | .name = "ath9k_rate_control", |
| 1509 | .tx_status = ath_tx_status, |
| 1510 | .get_rate = ath_get_rate, |
| 1511 | .rate_init = ath_rate_init, |
Sujith | 9331ec8 | 2009-03-02 13:29:45 +0530 | [diff] [blame] | 1512 | .rate_update = ath_rate_update, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1513 | .alloc = ath_rate_alloc, |
| 1514 | .free = ath_rate_free, |
| 1515 | .alloc_sta = ath_rate_alloc_sta, |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 1516 | .free_sta = ath_rate_free_sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1517 | }; |
| 1518 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1519 | int ath_rate_control_register(void) |
| 1520 | { |
| 1521 | return ieee80211_rate_control_register(&ath_rate_ops); |
| 1522 | } |
| 1523 | |
| 1524 | void ath_rate_control_unregister(void) |
| 1525 | { |
| 1526 | ieee80211_rate_control_unregister(&ath_rate_ops); |
| 1527 | } |