• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //==================================================================
2 // MTO.H
3 //
4 // Revision history
5 //=================================
6 //          20030110    UN20 Pete Chao
7 //                      Initial Release
8 //
9 // Copyright (c) 2003 Winbond Electronics Corp. All rights reserved.
10 //==================================================================
11 #ifndef __MTO_H__
12 #define __MTO_H__
13 
14 #include <linux/types.h>
15 
16 #define MTO_DEFAULT_TH_CNT              5
17 #define MTO_DEFAULT_TH_SQ3              112  //OLD IS 13 reference JohnXu
18 #define MTO_DEFAULT_TH_IDLE_SLOT        15
19 #define MTO_DEFAULT_TH_PR_INTERF        30
20 #define MTO_DEFAULT_TMR_AGING           25  // unit: slot time  10 reference JohnXu
21 #define MTO_DEFAULT_TMR_PERIODIC        5   // unit: slot time
22 
23 #define MTO_ANTENNA_DIVERSITY_OFF       0
24 #define MTO_ANTENNA_DIVERSITY_ON        1
25 
26 // LA20040210_DTO kevin
27 //#define MTO_PREAMBLE_LONG               0
28 //#define MTO_PREAMBLE_SHORT              1
29 #define MTO_PREAMBLE_LONG               WLAN_PREAMBLE_TYPE_LONG
30 #define MTO_PREAMBLE_SHORT              WLAN_PREAMBLE_TYPE_SHORT
31 
32 typedef enum {
33     TOGGLE_STATE_IDLE             = 0,
34     TOGGLE_STATE_WAIT0            = 1,
35     TOGGLE_STATE_WAIT1            = 2,
36     TOGGLE_STATE_MAKEDESISION     = 3,
37 	TOGGLE_STATE_BKOFF            = 4
38 } TOGGLE_STATE;
39 
40 typedef enum {
41     RATE_CHGSTATE_IDLE         = 0,
42     RATE_CHGSTATE_CALCULATE    = 1,
43     RATE_CHGSTATE_BACKOFF	   = 2
44 } TX_RATE_REDUCTION_STATE;
45 
46 //============================================================================
47 // struct _MTOParameters --
48 //
49 //   Defines the parameters used in the MAC Throughput Optimization algorithm
50 //============================================================================
51 typedef struct _MTO_PARAMETERS
52 {
53 	u8      Th_Fixant;
54 	u8      Th_Cnt;
55 	u8      Th_SQ3;
56 	u8      Th_IdleSlot;
57 
58 	u16     Tmr_Aging;
59 	u8      Th_PrInterf;
60 	u8      Tmr_Periodic;
61 
62 	//---------        wkchen added      -------------
63 	u32		TxFlowCount;	//to judge what kind the tx flow(sparse or busy) is
64 	//------------------------------------------------
65 
66 	//--------- DTO threshold parameters -------------
67 	u16		DTO_PeriodicCheckCycle;
68 	u16		DTO_RssiThForAntDiv;
69 
70 	u16		DTO_TxCountThForCalcNewRate;
71 	u16		DTO_TxRateIncTh;
72 
73 	u16		DTO_TxRateDecTh;
74 	u16		DTO_TxRateEqTh;
75 
76 	u16		DTO_TxRateBackOff;
77 	u16		DTO_TxRetryRateReduce;
78 
79 	u16		DTO_TxPowerIndex;	//0 ~ 31
80 	u16		reserved_1;
81 	//------------------------------------------------
82 
83 	u8      PowerChangeEnable;
84 	u8      AntDiversityEnable;
85 	u8      Ant_mac;
86 	u8      Ant_div;
87 
88 	u8      CCA_Mode;
89 	u8      CCA_Mode_Setup;
90 	u8      Preamble_Type;
91 	u8      PreambleChangeEnable;
92 
93 	u8      DataRateLevel;
94 	u8      DataRateChangeEnable;
95 	u8      FragThresholdLevel;
96 	u8      FragThresholdChangeEnable;
97 
98 	u16     RTSThreshold;
99 	u16     RTSThreshold_Setup;
100 
101 	u32     AvgIdleSlot;
102 	u32     Pr_Interf;
103 	u32     AvgGapBtwnInterf;
104 
105 	u8	   RTSChangeEnable;
106 	u8      Ant_sel;
107 	u8      aging_timeout;
108 	u8	   reserved_2;
109 
110 	u32     Cnt_Ant[2];
111 	u32     SQ_Ant[2];
112 
113 // 20040510 remove from globe vairable
114 	u32                     TmrCnt;
115 	u32                     BackoffTmr;
116 	TOGGLE_STATE            ToggleState;
117 	TX_RATE_REDUCTION_STATE TxRateReductionState;
118 
119 	u8                      Last_Rate;
120 	u8                      Co_efficent;
121 	u8		FallbackRateLevel;
122 	u8		OfdmRateLevel;
123 
124 	u8		RatePolicy;
125 	u8		reserved_3[3];
126 
127 	// For RSSI turning
128 	s32		RSSI_high;
129 	s32		RSSI_low;
130 
131 } MTO_PARAMETERS, *PMTO_PARAMETERS;
132 
133 
134 #define MTO_FUNC_INPUT              struct wbsoft_priv *	adapter
135 #define MTO_FUNC_INPUT_DATA         adapter
136 #define MTO_DATA()                  (adapter->sMtoPara)
137 #define MTO_HAL()                   (&adapter->sHwData)
138 #define MTO_SET_PREAMBLE_TYPE(x)    // 20040511 Turbo mark LM_PREAMBLE_TYPE(&pcore_data->lm_data) = (x)
139 #define MTO_ENABLE					(adapter->sLocalPara.TxRateMode == RATE_AUTO)
140 #define MTO_TXPOWER_FROM_EEPROM		(adapter->sHwData.PowerIndexFromEEPROM)
141 #define LOCAL_ANTENNA_NO()			(adapter->sLocalPara.bAntennaNo)
142 #define LOCAL_IS_CONNECTED()		(adapter->sLocalPara.wConnectedSTAindex != 0)
143 #define LOCAL_IS_IBSS_MODE()		(adapter->asBSSDescriptElement[adapter->sLocalPara.wConnectedSTAindex].bBssType == IBSS_NET)
144 #define MTO_INITTXRATE_MODE			(adapter->sHwData.SoftwareSet&0x2)	//bit 1
145 // 20040510 Turbo add
146 #define MTO_TMR_CNT()               MTO_DATA().TmrCnt
147 #define MTO_TOGGLE_STATE()          MTO_DATA().ToggleState
148 #define MTO_TX_RATE_REDUCTION_STATE() MTO_DATA().TxRateReductionState
149 #define MTO_BACKOFF_TMR()           MTO_DATA().BackoffTmr
150 #define MTO_LAST_RATE()             MTO_DATA().Last_Rate
151 #define MTO_CO_EFFICENT()           MTO_DATA().Co_efficent
152 
153 #define MTO_TH_CNT()                MTO_DATA().Th_Cnt
154 #define MTO_TH_SQ3()                MTO_DATA().Th_SQ3
155 #define MTO_TH_IDLE_SLOT()          MTO_DATA().Th_IdleSlot
156 #define MTO_TH_PR_INTERF()          MTO_DATA().Th_PrInterf
157 
158 #define MTO_TMR_AGING()             MTO_DATA().Tmr_Aging
159 #define MTO_TMR_PERIODIC()          MTO_DATA().Tmr_Periodic
160 
161 #define MTO_POWER_CHANGE_ENABLE()   MTO_DATA().PowerChangeEnable
162 #define MTO_ANT_DIVERSITY_ENABLE()  adapter->sLocalPara.boAntennaDiversity
163 #define MTO_ANT_MAC()               MTO_DATA().Ant_mac
164 #define MTO_ANT_DIVERSITY()         MTO_DATA().Ant_div
165 #define MTO_CCA_MODE()              MTO_DATA().CCA_Mode
166 #define MTO_CCA_MODE_SETUP()        MTO_DATA().CCA_Mode_Setup
167 #define MTO_PREAMBLE_TYPE()         MTO_DATA().Preamble_Type
168 #define MTO_PREAMBLE_CHANGE_ENABLE()         MTO_DATA().PreambleChangeEnable
169 
170 #define MTO_RATE_LEVEL()            MTO_DATA().DataRateLevel
171 #define MTO_OFDM_RATE_LEVEL()		MTO_DATA().OfdmRateLevel
172 #define MTO_RATE_CHANGE_ENABLE()    MTO_DATA().DataRateChangeEnable
173 #define MTO_FRAG_TH_LEVEL()         MTO_DATA().FragThresholdLevel
174 #define MTO_FRAG_CHANGE_ENABLE()    MTO_DATA().FragThresholdChangeEnable
175 #define MTO_RTS_THRESHOLD()         MTO_DATA().RTSThreshold
176 #define MTO_RTS_CHANGE_ENABLE()     MTO_DATA().RTSChangeEnable
177 #define MTO_RTS_THRESHOLD_SETUP()   MTO_DATA().RTSThreshold_Setup
178 
179 #define MTO_AVG_IDLE_SLOT()         MTO_DATA().AvgIdleSlot
180 #define MTO_PR_INTERF()             MTO_DATA().Pr_Interf
181 #define MTO_AVG_GAP_BTWN_INTERF()   MTO_DATA().AvgGapBtwnInterf
182 
183 #define MTO_ANT_SEL()               MTO_DATA().Ant_sel
184 #define MTO_CNT_ANT(x)              MTO_DATA().Cnt_Ant[(x)]
185 #define MTO_SQ_ANT(x)               MTO_DATA().SQ_Ant[(x)]
186 #define MTO_AGING_TIMEOUT()         MTO_DATA().aging_timeout
187 
188 
189 #define MTO_TXFLOWCOUNT()			MTO_DATA().TxFlowCount
190 //--------- DTO threshold parameters -------------
191 #define	MTOPARA_PERIODIC_CHECK_CYCLE()		MTO_DATA().DTO_PeriodicCheckCycle
192 #define	MTOPARA_RSSI_TH_FOR_ANTDIV()		MTO_DATA().DTO_RssiThForAntDiv
193 #define	MTOPARA_TXCOUNT_TH_FOR_CALC_RATE()	MTO_DATA().DTO_TxCountThForCalcNewRate
194 #define	MTOPARA_TXRATE_INC_TH()			MTO_DATA().DTO_TxRateIncTh
195 #define	MTOPARA_TXRATE_DEC_TH()			MTO_DATA().DTO_TxRateDecTh
196 #define MTOPARA_TXRATE_EQ_TH()			MTO_DATA().DTO_TxRateEqTh
197 #define	MTOPARA_TXRATE_BACKOFF()		MTO_DATA().DTO_TxRateBackOff
198 #define	MTOPARA_TXRETRYRATE_REDUCE()		MTO_DATA().DTO_TxRetryRateReduce
199 #define MTOPARA_TXPOWER_INDEX()			MTO_DATA().DTO_TxPowerIndex
200 //------------------------------------------------
201 
202 
203 extern u16  MTO_Frag_Th_Tbl[];
204 
205 #define MTO_DATA_RATE()          MTO_Data_Rate_Tbl[MTO_RATE_LEVEL()]
206 #define MTO_FRAG_TH()            MTO_Frag_Th_Tbl[MTO_FRAG_TH_LEVEL()]
207 
208 typedef struct {
209 	u8 tx_rate;
210 	u8 tx_retry_rate;
211 } TXRETRY_REC;
212 
213 typedef struct _STATISTICS_INFO {
214 	u32   Rate54M;
215 	u32   Rate48M;
216 	u32   Rate36M;
217 	u32   Rate24M;
218 	u32   Rate18M;
219 	u32   Rate12M;
220 	u32   Rate9M;
221 	u32   Rate6M;
222 	u32   Rate11MS;
223 	u32   Rate11ML;
224 	u32   Rate55MS;
225 	u32   Rate55ML;
226 	u32   Rate2MS;
227 	u32   Rate2ML;
228 	u32   Rate1M;
229 	u32   Rate54MOK;
230 	u32   Rate48MOK;
231 	u32   Rate36MOK;
232 	u32   Rate24MOK;
233 	u32   Rate18MOK;
234 	u32   Rate12MOK;
235 	u32   Rate9MOK;
236 	u32   Rate6MOK;
237 	u32   Rate11MSOK;
238 	u32   Rate11MLOK;
239 	u32   Rate55MSOK;
240 	u32   Rate55MLOK;
241 	u32   Rate2MSOK;
242 	u32   Rate2MLOK;
243 	u32   Rate1MOK;
244 	u32   SQ3;
245 	s32   RSSIAVG;
246 	s32   RSSIMAX;
247 	s32   TXRATE;
248 	s32   TxRetryRate;
249 	s32   BSS_PK_CNT;
250 	s32   NIDLESLOT;
251 	s32   SLOT_CNT;
252 	s32   INTERF_CNT;
253 	s32   GAP_CNT;
254 	s32   DS_EVM;
255 	s32   RcvBeaconNum;
256 	s32   RXRATE;
257 	s32   RxBytes;
258 	s32   TxBytes;
259 	s32   Antenna;
260 } STATISTICS_INFO, *PSTATISTICS_INFO;
261 
262 #endif //__MTO_H__
263 
264 
265