Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004 Sam Leffler, Errno Consulting |
| 3 | * Copyright (c) 2004 Video54 Technologies, Inc. |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 4 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 5 | * |
| 6 | * Permission to use, copy, modify, and/or distribute this software for any |
| 7 | * purpose with or without fee is hereby granted, provided that the above |
| 8 | * copyright notice and this permission notice appear in all copies. |
| 9 | * |
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
| 19 | #ifndef RC_H |
| 20 | #define RC_H |
| 21 | |
Luis R. Rodriguez | db86f07 | 2009-11-05 08:44:39 -0800 | [diff] [blame] | 22 | #include "hw.h" |
| 23 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 24 | struct ath_softc; |
| 25 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 26 | #define ATH_RATE_MAX 30 |
| 27 | #define RATE_TABLE_SIZE 64 |
| 28 | #define MAX_TX_RATE_PHY 48 |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 29 | |
Sujith | 2c5a744 | 2008-11-18 09:08:33 +0530 | [diff] [blame] | 30 | |
Senthil Balasubramanian | f63b340 | 2010-07-27 19:16:31 +0530 | [diff] [blame^] | 31 | #define RC_INVALID 0x0000 |
| 32 | #define RC_LEGACY 0x0001 |
| 33 | #define RC_SS 0x0002 |
| 34 | #define RC_DS 0x0004 |
| 35 | #define RC_TS 0x0008 |
| 36 | #define RC_HT_20 0x0010 |
| 37 | #define RC_HT_40 0x0020 |
| 38 | |
| 39 | #define RC_SS_OR_LEGACY(f) ((f) & (RC_SS | RC_LEGACY)) |
| 40 | |
| 41 | #define RC_HT_2040 (RC_HT_20 | RC_HT_40) |
| 42 | #define RC_ALL_STREAM (RC_SS | RC_DS) |
| 43 | #define RC_L_SD (RC_LEGACY | RC_SS | RC_DS) |
| 44 | #define RC_HT_SD_2040 (RC_HT_2040 | RC_SS | RC_DS) |
| 45 | #define RC_HT_S_20 (RC_HT_20 | RC_SS) |
| 46 | #define RC_HT_SD_20 (RC_HT_20 | RC_SS | RC_DS) |
| 47 | #define RC_HT_SD_40 (RC_HT_40 | RC_SS | RC_DS) |
| 48 | #define RC_HT_S_20 (RC_HT_20 | RC_SS) |
| 49 | #define RC_HT_S_40 (RC_HT_40 | RC_SS) |
| 50 | #define RC_HT_D_20 (RC_HT_20 | RC_DS) |
| 51 | #define RC_HT_D_40 (RC_HT_40 | RC_DS) |
| 52 | #define RC_ALL (RC_LEGACY | RC_HT_2040 | RC_ALL_STREAM) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 53 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 54 | enum { |
| 55 | WLAN_RC_PHY_OFDM, |
| 56 | WLAN_RC_PHY_CCK, |
| 57 | WLAN_RC_PHY_HT_20_SS, |
| 58 | WLAN_RC_PHY_HT_20_DS, |
| 59 | WLAN_RC_PHY_HT_40_SS, |
| 60 | WLAN_RC_PHY_HT_40_DS, |
| 61 | WLAN_RC_PHY_HT_20_SS_HGI, |
| 62 | WLAN_RC_PHY_HT_20_DS_HGI, |
| 63 | WLAN_RC_PHY_HT_40_SS_HGI, |
| 64 | WLAN_RC_PHY_HT_40_DS_HGI, |
| 65 | WLAN_RC_PHY_MAX |
| 66 | }; |
| 67 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 68 | #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ |
| 69 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
| 70 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
| 71 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 72 | #define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \ |
| 73 | || (_phy == WLAN_RC_PHY_HT_20_DS) \ |
| 74 | || (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \ |
| 75 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI)) |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 76 | #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \ |
| 77 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
| 78 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
| 79 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 80 | #define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \ |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 81 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
| 82 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
| 83 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 84 | |
| 85 | #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) |
| 86 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 87 | #define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \ |
Senthil Balasubramanian | f63b340 | 2010-07-27 19:16:31 +0530 | [diff] [blame^] | 88 | ((capflag & WLAN_RC_40_FLAG) ? RC_HT_40 : RC_HT_20) : RC_LEGACY)) |
| 89 | |
| 90 | #define WLAN_RC_CAP_STREAM(capflag) \ |
| 91 | (((capflag) & WLAN_RC_DS_FLAG) ? RC_DS : RC_SS) |
| 92 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 93 | |
| 94 | /* Return TRUE if flag supports HT20 && client supports HT20 or |
| 95 | * return TRUE if flag supports HT40 && client supports HT40. |
| 96 | * This is used becos some rates overlap between HT20/HT40. |
| 97 | */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 98 | #define WLAN_RC_PHY_HT_VALID(flag, capflag) \ |
Senthil Balasubramanian | f63b340 | 2010-07-27 19:16:31 +0530 | [diff] [blame^] | 99 | (((flag & RC_HT_20) && !(capflag & WLAN_RC_40_FLAG)) || \ |
| 100 | ((flag & RC_HT_40) && (capflag & WLAN_RC_40_FLAG))) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 101 | |
| 102 | #define WLAN_RC_DS_FLAG (0x01) |
| 103 | #define WLAN_RC_40_FLAG (0x02) |
| 104 | #define WLAN_RC_SGI_FLAG (0x04) |
| 105 | #define WLAN_RC_HT_FLAG (0x08) |
| 106 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 107 | /** |
| 108 | * struct ath_rate_table - Rate Control table |
| 109 | * @valid: valid for use in rate control |
| 110 | * @valid_single_stream: valid for use in rate control for |
| 111 | * single stream operation |
| 112 | * @phy: CCK/OFDM |
| 113 | * @ratekbps: rate in Kbits per second |
| 114 | * @user_ratekbps: user rate in Kbits per second |
| 115 | * @ratecode: rate that goes into HW descriptors |
| 116 | * @short_preamble: Mask for enabling short preamble in ratecode for CCK |
| 117 | * @dot11rate: value that goes into supported |
| 118 | * rates info element of MLME |
| 119 | * @ctrl_rate: Index of next lower basic rate, used for duration computation |
| 120 | * @max_4ms_framelen: maximum frame length(bytes) for tx duration |
| 121 | * @probe_interval: interval for rate control to probe for other rates |
| 122 | * @rssi_reduce_interval: interval for rate control to reduce rssi |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 123 | * @initial_ratemax: initial ratemax value |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 124 | */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 125 | struct ath_rate_table { |
| 126 | int rate_cnt; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 127 | int mcs_start; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 128 | struct { |
Senthil Balasubramanian | f63b340 | 2010-07-27 19:16:31 +0530 | [diff] [blame^] | 129 | u16 rate_flags; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 130 | u8 phy; |
| 131 | u32 ratekbps; |
| 132 | u32 user_ratekbps; |
| 133 | u8 ratecode; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 134 | u8 dot11rate; |
| 135 | u8 ctrl_rate; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 136 | u8 base_index; |
| 137 | u8 cw40index; |
| 138 | u8 sgi_index; |
| 139 | u8 ht_index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 140 | } info[RATE_TABLE_SIZE]; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 141 | u32 probe_interval; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 142 | u8 initial_ratemax; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 145 | struct ath_rateset { |
| 146 | u8 rs_nrates; |
| 147 | u8 rs_rates[ATH_RATE_MAX]; |
| 148 | }; |
| 149 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 150 | /** |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 151 | * struct ath_rate_priv - Rate Control priv data |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 152 | * @state: RC state |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 153 | * @probe_rate: rate we are probing at |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 154 | * @probe_time: msec timestamp for last probe |
| 155 | * @hw_maxretry_pktcnt: num of packets since we got HW max retry error |
| 156 | * @max_valid_rate: maximum number of valid rate |
| 157 | * @per_down_time: msec timestamp for last PER down step |
| 158 | * @valid_phy_ratecnt: valid rate count |
| 159 | * @rate_max_phy: phy index for the max rate |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 160 | * @per: PER for every valid rate in % |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 161 | * @probe_interval: interval for ratectrl to probe for other rates |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 162 | * @prev_data_rix: rate idx of last data frame |
| 163 | * @ht_cap: HT capabilities |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 164 | * @neg_rates: Negotatied rates |
| 165 | * @neg_ht_rates: Negotiated HT rates |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 166 | */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 167 | struct ath_rate_priv { |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 168 | u8 rate_table_size; |
| 169 | u8 probe_rate; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 170 | u8 hw_maxretry_pktcnt; |
| 171 | u8 max_valid_rate; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 172 | u8 valid_rate_index[RATE_TABLE_SIZE]; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 173 | u8 ht_cap; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 174 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 175 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE]; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 176 | u8 rate_max_phy; |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 177 | u8 per[RATE_TABLE_SIZE]; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 178 | u32 probe_time; |
| 179 | u32 per_down_time; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 180 | u32 probe_interval; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 181 | u32 prev_data_rix; |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 182 | u32 tx_triglevel_max; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 183 | struct ath_rateset neg_rates; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 184 | struct ath_rateset neg_ht_rates; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 185 | struct ath_rate_softc *asc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 186 | }; |
| 187 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 188 | #define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0) |
| 189 | #define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1) |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 190 | #define ATH_TX_INFO_XRETRY (1 << 3) |
| 191 | #define ATH_TX_INFO_UNDERRUN (1 << 4) |
| 192 | |
Jouni Malinen | f0ed85c | 2009-03-03 19:23:31 +0200 | [diff] [blame] | 193 | enum ath9k_internal_frame_type { |
Pavel Roskin | c81494d | 2010-03-31 18:05:25 -0400 | [diff] [blame] | 194 | ATH9K_IFT_NOT_INTERNAL, |
| 195 | ATH9K_IFT_PAUSE, |
| 196 | ATH9K_IFT_UNPAUSE |
Jouni Malinen | f0ed85c | 2009-03-03 19:23:31 +0200 | [diff] [blame] | 197 | }; |
| 198 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 199 | int ath_rate_control_register(void); |
| 200 | void ath_rate_control_unregister(void); |
| 201 | |
| 202 | #endif /* RC_H */ |