2 * Copyright (c) 2000-2002 Atheros Communications, Inc., All Rights Reserved
4 * Definitions for core driver
5 * This is a common header file for all platforms and operating systems.
10 #include <adf_os_types.h>
11 #include <adf_os_dma.h>
12 #include <adf_os_timer.h>
13 #include <adf_os_lock.h>
14 #include <adf_os_io.h>
15 #include <adf_os_mem.h>
16 #include <adf_os_util.h>
17 #include <adf_os_stdtypes.h>
18 #include <adf_os_defer.h>
19 #include <adf_os_atomic.h>
22 #include <adf_net_types.h>
23 #include <adf_net_wcmd.h>
25 #include <ieee80211_var.h>
27 #include "if_athrate.h"
28 #include "if_athvar.h"
33 typedef int8_t A_RSSI;
34 typedef int32_t A_RSSI32;
35 typedef u_int8_t WLAN_PHY;
38 #define INLINE __inline
42 #define A_MIN(a,b) ((a)<(b)?(a):(b))
46 #define A_MAX(a,b) ((a)>(b)?(a):(b))
50 * Use the hal os glue code to get ms time; we supply
51 * a null arg because we know it's not needed.
53 #define A_MS_TICKGET() OS_GETUPTIME(NULL)
54 #define A_MEM_ZERO(p,s) OS_MEMZERO(p,s)
56 #define WLAN_PHY_OFDM IEEE80211_T_OFDM
57 #define WLAN_PHY_TURBO IEEE80211_T_TURBO
58 #define WLAN_PHY_CCK IEEE80211_T_CCK
59 #define WLAN_PHY_XR (IEEE80211_T_TURBO+1)
70 WLAN_RC_PHY_HT_20_SS_HGI,
71 WLAN_RC_PHY_HT_20_DS_HGI,
72 WLAN_RC_PHY_HT_40_SS_HGI,
73 WLAN_RC_PHY_HT_40_DS_HGI,
77 #define IS_CHAN_TURBO(_c) (((_c)->channelFlags & CHANNEL_TURBO) != 0)
78 #define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0)
80 #define PKTLOG_RATE_CTL_FIND(_sc, log_data, flags) ath_log_rcfind(_sc, log_data, flags);
81 #define PKTLOG_RATE_CTL_UPDATE(_sc, log_data, flags) ath_log_rcupdate(_sc, log_data, flags);
82 #define ASSERT(condition)
84 #define WIRELESS_MODE_11NA IEEE80211_MODE_11NA
85 #define WIRELESS_MODE_11NG IEEE80211_MODE_11NG
86 #define WIRELESS_MODE_MAX IEEE80211_MODE_MAX
88 #define RX_FLIP_THRESHOLD 3 /* XXX */
91 #define MAX_TX_RATE_TBL 46
92 #define MAX_TX_RATE_PHY 48
94 #define MAX_TX_RATE_TBL 54//46
95 #define MAX_TX_RATE_PHY 56//48
99 * State structures for new rate adaptation code
101 * NOTE: Modifying these structures will impact
102 * the Perl script that parses packet logging data.
103 * See the packet logging module for more information.
105 typedef struct TxRateCrtlState_s {
106 A_UINT8 per; /* recent estimate of packet error rate (%) */
109 typedef struct TxRateCtrl_s {
110 TxRateCtrlState state[MAX_TX_RATE_TBL]; /* state for each rate */
111 A_UINT8 rateTableSize; /* rate table size */
112 A_UINT8 probeRate; /* rate we are probing at */
113 A_UINT32 rssiTime; /* msec timestamp for last ack rssi */
114 A_UINT32 probeTime; /* msec timestamp for last probe */
115 A_UINT8 hwMaxRetryPktCnt; /* num packets since we got HW max retry error */
116 A_UINT8 maxValidRate; /* maximum number of valid rate */
117 A_UINT8 validRateIndex[MAX_TX_RATE_TBL]; /* rc Index is valid for this Sib */
118 A_UINT32 perDownTime; /* msec timstamp for last PER down step */
120 A_UINT8 rateMaxPhy; /* Phy index for the max rate */
123 typedef struct phy_rate_ctrl {
125 A_UINT8 validPhyRateCount[WLAN_RC_PHY_MAX]; /* valid rate count */
126 A_UINT8 validPhyRateIndex[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; /* index */
130 struct atheros_node {
131 TX_RATE_CTRL txRateCtrl; /* rate control state proper */
132 A_UINT32 lastRateKbps; /* last rate in Kb/s */
133 A_UINT32 htcap; /* ht capabilites */
134 A_UINT8 singleStream :1, /* When TRUE, only single stream Tx possible */
135 stbc :2; /* Rx stbc capability */
139 #define ATH_NODE_ATHEROS(an) (an->an_rcnode)
142 * Rate Table structure for various modes - 'b', 'a', 'g', 'xr';
143 * order of fields in info structure is important because hardcoded
144 * structures are initialized within the hal for these
149 A_UINT8 rateCodeToIndex[RATE_TABLE_SIZE]; /* backward mapping */
151 int valid; /* Valid for use in rate control */
152 WLAN_PHY phy; /* CCK/OFDM/TURBO/XR */
153 A_UINT16 rateKbps; /* Rate in Kbits per second */
154 A_UINT16 userRateKbps; /* User rate in KBits per second */
155 A_UINT8 rateCode; /* rate that goes into hw descriptors */
156 A_UINT8 shortPreamble; /* Mask for enabling short preamble in rate code for CCK */
157 A_UINT8 dot11Rate; /* Value that goes into supported rates info element of MLME */
158 A_UINT8 controlRate; /* Index of next lower basic rate, used for duration computation */
159 A_RSSI rssiAckValidMin; /* Rate control related information */
160 A_RSSI rssiAckDeltaMin; /* Rate control related information */
161 A_UINT16 lpAckDuration; /* long preamble ACK duration */
162 A_UINT16 spAckDuration; /* short preamble ACK duration*/
163 A_UINT32 max4msFrameLen; /* Maximum frame length(bytes) for 4ms tx duration */
165 A_UINT32 word4Retries;
169 A_UINT32 word4Retries;
173 A_UINT32 word4Retries;
177 A_UINT32 word4Retries;
181 A_UINT32 word4Retries;
185 A_UINT32 word4Retries;
188 #ifdef ATH_REMOVE_5G_RATE_TABLE
189 #ifdef ATH_REMOVE_TURBO_RATE_TABLE
190 #ifdef ATH_REMOVE_XR_RATE_TABLE
201 A_UINT32 probeInterval; /* interval for ratectrl to probe for
203 A_UINT32 rssiReduceInterval; /* interval for ratectrl to reduce RSSI */
204 A_UINT8 regularToTurboThresh; /* upperbound on regular (11a or 11g)
205 mode's rate before switching to turbo*/
206 A_UINT8 turboToRegularThresh; /* lowerbound on turbo mode's rate before
207 switching to regular */
208 A_UINT8 pktCountThresh; /* mode switch recommendation criterion:
209 number of consecutive packets sent at
210 rate beyond the rate threshold */
211 A_UINT8 initialRateMax; /* the initial rateMax value used in
213 A_UINT8 numTurboRates; /* number of Turbo rates in the rateTable */
214 A_UINT8 xrToRegularThresh; /* threshold to switch to Normal mode */
217 /* per-device state */
218 struct atheros_softc {
219 struct ath_ratectrl arc;
220 /* phy tables that contain rate control data */
221 void *hwRateTable[WIRELESS_MODE_MAX];
222 A_UINT32 tx_chainmask;
223 A_UINT32 currentTxRateKbps;
224 A_UINT32 currentTxRateIndex;
228 * Update the SIB's rate control information
230 * This should be called when the supported rates change
231 * (e.g. SME operation, wireless mode change)
233 * It will determine which rates are valid for use.
236 rcSibUpdate(struct ath_softc_tgt *sc,
237 struct ath_node_target *an,
239 struct ieee80211_rateset *pRateSet);
242 * This routine is called to initialize the rate control parameters
243 * in the SIB. It is called initially during system initialization
244 * or when a station is associated with the AP.
246 void rcSibInit(struct ath_softc_tgt *, struct ath_node_target *);
249 * Determines and returns the new Tx rate index.
251 A_UINT16 rcRateFind(struct ath_softc_tgt *, struct atheros_node *,
252 A_UINT32 frameLen,const RATE_TABLE *pRateTable);
254 struct fusion_rate_info {
260 void ar5416AttachRateTables(struct atheros_softc *sc);
262 #endif /* _RATECTRL_H_ */