2 * Copyright (c) 2004 Sam Leffler, Errno Consulting
3 * Copyright (c) 2004 Video54 Technologies, Inc.
4 * Copyright (c) 2008-2009 Atheros Communications Inc.
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.
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.
24 #define ATH_RATE_MAX 30
25 #define RATE_TABLE_SIZE 64
26 #define MAX_TX_RATE_PHY 48
28 /* VALID_ALL - valid for 20/40/Legacy,
29 * VALID - Legacy only,
30 * VALID_20 - HT 20 only,
31 * VALID_40 - HT 40 only */
37 #define VALID_2040 (VALID_20|VALID_40)
38 #define VALID_ALL (VALID_2040|VALID)
47 WLAN_RC_PHY_HT_20_SS_HGI
,
48 WLAN_RC_PHY_HT_20_DS_HGI
,
49 WLAN_RC_PHY_HT_40_SS_HGI
,
50 WLAN_RC_PHY_HT_40_DS_HGI
,
54 #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
55 || (_phy == WLAN_RC_PHY_HT_40_DS) \
56 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
57 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
58 #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \
59 || (_phy == WLAN_RC_PHY_HT_40_DS) \
60 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
61 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
62 #define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
63 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
64 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
65 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
67 #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
69 #define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
70 (capflag & WLAN_RC_40_FLAG) ? VALID_40 : VALID_20 : VALID))
72 /* Return TRUE if flag supports HT20 && client supports HT20 or
73 * return TRUE if flag supports HT40 && client supports HT40.
74 * This is used becos some rates overlap between HT20/HT40.
76 #define WLAN_RC_PHY_HT_VALID(flag, capflag) \
77 (((flag & VALID_20) && !(capflag & WLAN_RC_40_FLAG)) || \
78 ((flag & VALID_40) && (capflag & WLAN_RC_40_FLAG)))
80 #define WLAN_RC_DS_FLAG (0x01)
81 #define WLAN_RC_40_FLAG (0x02)
82 #define WLAN_RC_SGI_FLAG (0x04)
83 #define WLAN_RC_HT_FLAG (0x08)
86 * struct ath_rate_table - Rate Control table
87 * @valid: valid for use in rate control
88 * @valid_single_stream: valid for use in rate control for
89 * single stream operation
91 * @ratekbps: rate in Kbits per second
92 * @user_ratekbps: user rate in Kbits per second
93 * @ratecode: rate that goes into HW descriptors
94 * @short_preamble: Mask for enabling short preamble in ratecode for CCK
95 * @dot11rate: value that goes into supported
96 * rates info element of MLME
97 * @ctrl_rate: Index of next lower basic rate, used for duration computation
98 * @max_4ms_framelen: maximum frame length(bytes) for tx duration
99 * @probe_interval: interval for rate control to probe for other rates
100 * @rssi_reduce_interval: interval for rate control to reduce rssi
101 * @initial_ratemax: initial ratemax value
103 struct ath_rate_table
{
107 int valid_single_stream
;
115 int8_t rssi_ack_validmin
;
116 int8_t rssi_ack_deltamin
;
121 u32 max_4ms_framelen
;
122 } info
[RATE_TABLE_SIZE
];
124 u32 rssi_reduce_interval
;
128 struct ath_tx_ratectrl_state
{
129 int8_t rssi_thres
; /* required rssi for this rate (dB) */
130 u8 per
; /* recent estimate of packet error rate (%) */
135 u8 rs_rates
[ATH_RATE_MAX
];
139 * struct ath_rate_priv - Rate Control priv data
141 * @rssi_last: last ACK rssi
142 * @rssi_last_lookup: last ACK rssi used for lookup
143 * @rssi_last_prev: previous last ACK rssi
144 * @rssi_last_prev2: 2nd previous last ACK rssi
145 * @rssi_sum_cnt: count of rssi_sum for averaging
146 * @rssi_sum_rate: rate that we are averaging
147 * @rssi_sum: running sum of rssi for averaging
148 * @probe_rate: rate we are probing at
149 * @rssi_time: msec timestamp for last ack rssi
150 * @rssi_down_time: msec timestamp for last down step
151 * @probe_time: msec timestamp for last probe
152 * @hw_maxretry_pktcnt: num of packets since we got HW max retry error
153 * @max_valid_rate: maximum number of valid rate
154 * @per_down_time: msec timestamp for last PER down step
155 * @valid_phy_ratecnt: valid rate count
156 * @rate_max_phy: phy index for the max rate
157 * @probe_interval: interval for ratectrl to probe for other rates
158 * @prev_data_rix: rate idx of last data frame
159 * @ht_cap: HT capabilities
160 * @single_stream: When TRUE, only single TX stream possible
161 * @neg_rates: Negotatied rates
162 * @neg_ht_rates: Negotiated HT rates
164 struct ath_rate_priv
{
166 int8_t rssi_last_lookup
;
167 int8_t rssi_last_prev
;
168 int8_t rssi_last_prev2
;
169 int32_t rssi_sum_cnt
;
170 int32_t rssi_sum_rate
;
174 u8 hw_maxretry_pktcnt
;
176 u8 valid_rate_index
[RATE_TABLE_SIZE
];
179 u8 valid_phy_ratecnt
[WLAN_RC_PHY_MAX
];
180 u8 valid_phy_rateidx
[WLAN_RC_PHY_MAX
][RATE_TABLE_SIZE
];
189 u32 tx_triglevel_max
;
190 struct ath_tx_ratectrl_state state
[RATE_TABLE_SIZE
];
191 struct ath_rateset neg_rates
;
192 struct ath_rateset neg_ht_rates
;
193 struct ath_rate_softc
*asc
;
196 enum ath9k_internal_frame_type
{
202 struct ath_tx_info_priv
{
203 struct ath_wiphy
*aphy
;
204 struct ath_tx_status tx
;
208 enum ath9k_internal_frame_type frame_type
;
211 #define ATH_TX_INFO_PRIV(tx_info) \
212 ((struct ath_tx_info_priv *)((tx_info)->rate_driver_data[0]))
214 void ath_rate_attach(struct ath_softc
*sc
);
215 u8
ath_rate_findrateix(struct ath_softc
*sc
, u8 dot11_rate
);
216 int ath_rate_control_register(void);
217 void ath_rate_control_unregister(void);