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 | /* VALID_ALL - valid for 20/40/Legacy, |
| 31 | * VALID - Legacy only, |
| 32 | * VALID_20 - HT 20 only, |
| 33 | * VALID_40 - HT 40 only */ |
| 34 | |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 35 | #define INVALID 0x0 |
| 36 | #define VALID 0x1 |
| 37 | #define VALID_20 0x2 |
| 38 | #define VALID_40 0x4 |
| 39 | #define VALID_2040 (VALID_20|VALID_40) |
| 40 | #define VALID_ALL (VALID_2040|VALID) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 41 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 42 | enum { |
| 43 | WLAN_RC_PHY_OFDM, |
| 44 | WLAN_RC_PHY_CCK, |
| 45 | WLAN_RC_PHY_HT_20_SS, |
| 46 | WLAN_RC_PHY_HT_20_DS, |
| 47 | WLAN_RC_PHY_HT_40_SS, |
| 48 | WLAN_RC_PHY_HT_40_DS, |
| 49 | WLAN_RC_PHY_HT_20_SS_HGI, |
| 50 | WLAN_RC_PHY_HT_20_DS_HGI, |
| 51 | WLAN_RC_PHY_HT_40_SS_HGI, |
| 52 | WLAN_RC_PHY_HT_40_DS_HGI, |
| 53 | WLAN_RC_PHY_MAX |
| 54 | }; |
| 55 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 56 | #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ |
| 57 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
| 58 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
| 59 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 60 | #define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \ |
| 61 | || (_phy == WLAN_RC_PHY_HT_20_DS) \ |
| 62 | || (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \ |
| 63 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI)) |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 64 | #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \ |
| 65 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
| 66 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
| 67 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 68 | #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] | 69 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
| 70 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
| 71 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 72 | |
| 73 | #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) |
| 74 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 75 | #define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 76 | (capflag & WLAN_RC_40_FLAG) ? VALID_40 : VALID_20 : VALID)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 77 | |
| 78 | /* Return TRUE if flag supports HT20 && client supports HT20 or |
| 79 | * return TRUE if flag supports HT40 && client supports HT40. |
| 80 | * This is used becos some rates overlap between HT20/HT40. |
| 81 | */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 82 | #define WLAN_RC_PHY_HT_VALID(flag, capflag) \ |
| 83 | (((flag & VALID_20) && !(capflag & WLAN_RC_40_FLAG)) || \ |
| 84 | ((flag & VALID_40) && (capflag & WLAN_RC_40_FLAG))) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 85 | |
| 86 | #define WLAN_RC_DS_FLAG (0x01) |
| 87 | #define WLAN_RC_40_FLAG (0x02) |
| 88 | #define WLAN_RC_SGI_FLAG (0x04) |
| 89 | #define WLAN_RC_HT_FLAG (0x08) |
| 90 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 91 | /** |
| 92 | * struct ath_rate_table - Rate Control table |
| 93 | * @valid: valid for use in rate control |
| 94 | * @valid_single_stream: valid for use in rate control for |
| 95 | * single stream operation |
| 96 | * @phy: CCK/OFDM |
| 97 | * @ratekbps: rate in Kbits per second |
| 98 | * @user_ratekbps: user rate in Kbits per second |
| 99 | * @ratecode: rate that goes into HW descriptors |
| 100 | * @short_preamble: Mask for enabling short preamble in ratecode for CCK |
| 101 | * @dot11rate: value that goes into supported |
| 102 | * rates info element of MLME |
| 103 | * @ctrl_rate: Index of next lower basic rate, used for duration computation |
| 104 | * @max_4ms_framelen: maximum frame length(bytes) for tx duration |
| 105 | * @probe_interval: interval for rate control to probe for other rates |
| 106 | * @rssi_reduce_interval: interval for rate control to reduce rssi |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 107 | * @initial_ratemax: initial ratemax value |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 108 | */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 109 | struct ath_rate_table { |
| 110 | int rate_cnt; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 111 | int mcs_start; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 112 | struct { |
Ming Lei | e21247c | 2010-03-01 23:13:29 +0800 | [diff] [blame] | 113 | u8 valid; |
| 114 | u8 valid_single_stream; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 115 | u8 phy; |
| 116 | u32 ratekbps; |
| 117 | u32 user_ratekbps; |
| 118 | u8 ratecode; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 119 | u8 dot11rate; |
| 120 | u8 ctrl_rate; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 121 | u8 base_index; |
| 122 | u8 cw40index; |
| 123 | u8 sgi_index; |
| 124 | u8 ht_index; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 125 | } info[RATE_TABLE_SIZE]; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 126 | u32 probe_interval; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 127 | u8 initial_ratemax; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 130 | struct ath_rateset { |
| 131 | u8 rs_nrates; |
| 132 | u8 rs_rates[ATH_RATE_MAX]; |
| 133 | }; |
| 134 | |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 135 | /** |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 136 | * struct ath_rate_priv - Rate Control priv data |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 137 | * @state: RC state |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 138 | * @probe_rate: rate we are probing at |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 139 | * @probe_time: msec timestamp for last probe |
| 140 | * @hw_maxretry_pktcnt: num of packets since we got HW max retry error |
| 141 | * @max_valid_rate: maximum number of valid rate |
| 142 | * @per_down_time: msec timestamp for last PER down step |
| 143 | * @valid_phy_ratecnt: valid rate count |
| 144 | * @rate_max_phy: phy index for the max rate |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 145 | * @per: PER for every valid rate in % |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 146 | * @probe_interval: interval for ratectrl to probe for other rates |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 147 | * @prev_data_rix: rate idx of last data frame |
| 148 | * @ht_cap: HT capabilities |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 149 | * @neg_rates: Negotatied rates |
| 150 | * @neg_ht_rates: Negotiated HT rates |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 151 | */ |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 152 | struct ath_rate_priv { |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 153 | u8 rate_table_size; |
| 154 | u8 probe_rate; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 155 | u8 hw_maxretry_pktcnt; |
| 156 | u8 max_valid_rate; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 157 | u8 valid_rate_index[RATE_TABLE_SIZE]; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 158 | u8 ht_cap; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 159 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 160 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE]; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 161 | u8 rate_max_phy; |
Vasanthakumar Thiagarajan | 922bac6 | 2009-07-14 20:14:13 -0400 | [diff] [blame] | 162 | u8 per[RATE_TABLE_SIZE]; |
Sujith | 256b775 | 2008-11-18 09:03:12 +0530 | [diff] [blame] | 163 | u32 probe_time; |
| 164 | u32 per_down_time; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 165 | u32 probe_interval; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 166 | u32 prev_data_rix; |
Sujith | fe7f4a7 | 2008-11-18 09:07:06 +0530 | [diff] [blame] | 167 | u32 tx_triglevel_max; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 168 | struct ath_rateset neg_rates; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 169 | struct ath_rateset neg_ht_rates; |
Sujith | 5701ed8 | 2008-08-26 08:11:26 +0530 | [diff] [blame] | 170 | struct ath_rate_softc *asc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 173 | #define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0) |
| 174 | #define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1) |
Felix Fietkau | 827e69b | 2009-11-15 23:09:25 +0100 | [diff] [blame] | 175 | #define ATH_TX_INFO_XRETRY (1 << 3) |
| 176 | #define ATH_TX_INFO_UNDERRUN (1 << 4) |
| 177 | |
Jouni Malinen | f0ed85c | 2009-03-03 19:23:31 +0200 | [diff] [blame] | 178 | enum ath9k_internal_frame_type { |
Pavel Roskin | c81494d | 2010-03-31 18:05:25 -0400 | [diff] [blame] | 179 | ATH9K_IFT_NOT_INTERNAL, |
| 180 | ATH9K_IFT_PAUSE, |
| 181 | ATH9K_IFT_UNPAUSE |
Jouni Malinen | f0ed85c | 2009-03-03 19:23:31 +0200 | [diff] [blame] | 182 | }; |
| 183 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 184 | int ath_rate_control_register(void); |
| 185 | void ath_rate_control_unregister(void); |
| 186 | |
| 187 | #endif /* RC_H */ |