1 //============================================================================
5 // MAC Throughput Optimization for W89C33 802.11g WLAN STA.
7 // The following MIB attributes or internal variables will be affected
8 // while the MTO is being executed:
9 // dot11FragmentationThreshold,
11 // transmission rate and PLCP preamble type,
16 // --------------------------------------------------------------------------
17 // 20031227 UN20 Pete Chao
19 // 20031229 Turbo copy from PD43
20 // 20040210 Kevin revised
21 // Copyright (c) 2003 Winbond Electronics Corp. All rights reserved.
22 //============================================================================
24 // LA20040210_DTO kevin
30 // Declare SQ3 to rate and fragmentation threshold table
31 // Declare fragmentation thresholds table
32 #define MTO_MAX_FRAG_TH_LEVELS 5
33 #define MTO_MAX_DATA_RATE_LEVELS 12
35 u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] =
37 256, 384, 512, 768, 1536
40 // Declare data rate table
41 //The following table will be changed at anytime if the opration rate supported by AP don't
43 static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = {
44 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108
47 static int TotalTxPkt = 0;
48 static int TotalTxPktRetry = 0;
49 static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];//this record the retry rate at different data rate
51 static int PeriodTotalTxPkt = 0;
52 static int PeriodTotalTxPktRetry = 0;
54 static u8 boSparseTxTraffic = false;
56 void MTO_Init(struct wbsoft_priv *adapter);
57 void TxRateReductionCtrl(struct wbsoft_priv *adapter);
58 /** 1.1.31.1000 Turbo modify */
59 void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
60 void MTO_TxFailed(struct wbsoft_priv *adapter);
61 void hal_get_dto_para(struct wbsoft_priv *adapter, char *buffer);
63 //===========================================================================
67 // Initialize MTO parameters.
69 // This function should be invoked during system initialization.
72 // adapter - The pointer to the Miniport adapter Context
76 //============================================================================
77 void MTO_Init(struct wbsoft_priv *adapter)
80 //[WKCHEN]pMTOcore_data = pcore_data;
81 // 20040510 Turbo add for global variable
83 MTO_TOGGLE_STATE() = TOGGLE_STATE_IDLE;
84 MTO_TX_RATE_REDUCTION_STATE() = RATE_CHGSTATE_IDLE;
85 MTO_BACKOFF_TMR() = 0;
87 MTO_CO_EFFICENT() = 0;
89 //MTO_TH_FIXANT() = MTO_DEFAULT_TH_FIXANT;
90 MTO_TH_CNT() = MTO_DEFAULT_TH_CNT;
91 MTO_TH_SQ3() = MTO_DEFAULT_TH_SQ3;
92 MTO_TH_IDLE_SLOT() = MTO_DEFAULT_TH_IDLE_SLOT;
93 MTO_TH_PR_INTERF() = MTO_DEFAULT_TH_PR_INTERF;
95 MTO_TMR_AGING() = MTO_DEFAULT_TMR_AGING;
96 MTO_TMR_PERIODIC() = MTO_DEFAULT_TMR_PERIODIC;
98 //[WKCHEN]MTO_CCA_MODE_SETUP()= (u8) hal_get_cca_mode(MTO_HAL());
99 //[WKCHEN]MTO_CCA_MODE() = MTO_CCA_MODE_SETUP();
101 //MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_LONG;
102 MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; // for test
104 MTO_ANT_SEL() = hal_get_antenna_number(MTO_HAL());
105 MTO_ANT_MAC() = MTO_ANT_SEL();
110 MTO_ANT_DIVERSITY() = MTO_ANTENNA_DIVERSITY_ON;
111 //CardSet_AntennaDiversity(adapter, MTO_ANT_DIVERSITY());
112 //PLMESetAntennaDiversity( adapter, MTO_ANT_DIVERSITY());
114 MTO_AGING_TIMEOUT() = 0;//MTO_TMR_AGING() / MTO_TMR_PERIODIC();
116 // The following parameters should be initialized to the values set by user
118 //MTO_RATE_LEVEL() = 10;
119 MTO_RATE_LEVEL() = 0;
120 MTO_FRAG_TH_LEVEL() = 4;
121 /** 1.1.23.1000 Turbo modify from -1 to +1
122 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() - 1;
123 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() - 1;
125 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1;
126 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1;
127 // 1.1.23.1000 Turbo add for mto change preamble from 0 to 1
128 MTO_RATE_CHANGE_ENABLE() = 1;
129 MTO_FRAG_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
130 //The default valud of ANTDIV_DEFAULT_ON will be decided by EEPROM
131 //#ifdef ANTDIV_DEFAULT_ON
132 //MTO_ANT_DIVERSITY_ENABLE() = 1;
134 //MTO_ANT_DIVERSITY_ENABLE() = 0;
136 MTO_POWER_CHANGE_ENABLE() = 1;
137 MTO_PREAMBLE_CHANGE_ENABLE()= 1;
138 MTO_RTS_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
139 // 20040512 Turbo add
140 //old_antenna[0] = 1;
141 //old_antenna[1] = 0;
142 //old_antenna[2] = 1;
143 //old_antenna[3] = 0;
144 for (i=0;i<MTO_MAX_DATA_RATE_LEVELS;i++)
147 MTO_TXFLOWCOUNT() = 0;
148 //--------- DTO threshold parameters -------------
149 //MTOPARA_PERIODIC_CHECK_CYCLE() = 50;
150 MTOPARA_PERIODIC_CHECK_CYCLE() = 10;
151 MTOPARA_RSSI_TH_FOR_ANTDIV() = 10;
152 MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50;
153 MTOPARA_TXRATE_INC_TH() = 10;
154 MTOPARA_TXRATE_DEC_TH() = 30;
155 MTOPARA_TXRATE_EQ_TH() = 40;
156 MTOPARA_TXRATE_BACKOFF() = 12;
157 MTOPARA_TXRETRYRATE_REDUCE() = 6;
158 if ( MTO_TXPOWER_FROM_EEPROM == 0xff)
160 switch( MTO_HAL()->phy_type)
163 case RF_AIROHA_2230S: // 20060420 Add this
164 MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230
167 MTOPARA_TXPOWER_INDEX() = 49;
170 MTOPARA_TXPOWER_INDEX() = 10;
173 MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify
177 else //follow the setting from EEPROM
178 MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM;
179 hal_set_rf_power(MTO_HAL(), (u8)MTOPARA_TXPOWER_INDEX());
180 //------------------------------------------------
182 // For RSSI turning 20060808.4 Cancel load from EEPROM
183 MTO_DATA().RSSI_high = -41;
184 MTO_DATA().RSSI_low = -60;
187 //===========================================================================
189 // If we enable DTO, we will ignore the tx count with different tx rate from
190 // DTO rate. This is because when we adjust DTO tx rate, there could be some
191 // packets in the tx queue with previous tx rate
192 void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 tx_rate, u8 index)
195 if ((MTO_ENABLE==1) && (MTO_RATE_CHANGE_ENABLE()==1))
197 if(tx_rate == MTO_DATA_RATE())
201 if (boSparseTxTraffic)
202 MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE();
204 MTO_HAL()->dto_tx_frag_count += 1;
210 MTO_HAL()->dto_tx_retry_count += index;
211 MTO_HAL()->dto_tx_frag_count += (index+1);
215 MTO_HAL()->dto_tx_retry_count += 7;
216 MTO_HAL()->dto_tx_frag_count += 7;
220 else if(MTO_DATA_RATE()>48 && tx_rate ==48)
222 if (index<3) //for reduciing data rate scheme ,
223 //do not calcu different data rate
224 //3 is the reducing data rate at retry
226 MTO_HAL()->dto_tx_retry_count += index;
227 MTO_HAL()->dto_tx_frag_count += (index+1);
231 MTO_HAL()->dto_tx_retry_count += 3;
232 MTO_HAL()->dto_tx_frag_count += 3;
239 MTO_HAL()->dto_tx_retry_count += index;
240 MTO_HAL()->dto_tx_frag_count += (index+1);
243 TotalTxPktRetry += (index+1);
246 PeriodTotalTxPktRetry += (index+1);