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
29 // Declare SQ3 to rate and fragmentation threshold table
30 // Declare fragmentation thresholds table
31 #define MTO_MAX_FRAG_TH_LEVELS 5
32 #define MTO_MAX_DATA_RATE_LEVELS 12
34 u16 MTO_Frag_Th_Tbl
[MTO_MAX_FRAG_TH_LEVELS
] =
36 256, 384, 512, 768, 1536
39 // Declare data rate table
40 //The following table will be changed at anytime if the opration rate supported by AP don't
42 static u8 MTO_Data_Rate_Tbl
[MTO_MAX_DATA_RATE_LEVELS
] = {
43 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108
46 static int TotalTxPkt
= 0;
47 static int TotalTxPktRetry
= 0;
48 static int retryrate_rec
[MTO_MAX_DATA_RATE_LEVELS
];//this record the retry rate at different data rate
50 static int PeriodTotalTxPkt
= 0;
51 static int PeriodTotalTxPktRetry
= 0;
53 static u8 boSparseTxTraffic
= false;
55 void MTO_Init(struct wbsoft_priv
*adapter
);
56 void TxRateReductionCtrl(struct wbsoft_priv
*adapter
);
57 /** 1.1.31.1000 Turbo modify */
58 void MTO_SetTxCount(struct wbsoft_priv
*adapter
, u8 t0
, u8 index
);
59 void MTO_TxFailed(struct wbsoft_priv
*adapter
);
60 void hal_get_dto_para(struct wbsoft_priv
*adapter
, char *buffer
);
62 //===========================================================================
66 // Initialize MTO parameters.
68 // This function should be invoked during system initialization.
71 // adapter - The pointer to the Miniport adapter Context
75 //============================================================================
76 void MTO_Init(struct wbsoft_priv
*adapter
)
79 //[WKCHEN]pMTOcore_data = pcore_data;
80 // 20040510 Turbo add for global variable
82 MTO_TOGGLE_STATE() = TOGGLE_STATE_IDLE
;
83 MTO_TX_RATE_REDUCTION_STATE() = RATE_CHGSTATE_IDLE
;
84 MTO_BACKOFF_TMR() = 0;
86 MTO_CO_EFFICENT() = 0;
88 //MTO_TH_FIXANT() = MTO_DEFAULT_TH_FIXANT;
89 MTO_TH_CNT() = MTO_DEFAULT_TH_CNT
;
90 MTO_TH_SQ3() = MTO_DEFAULT_TH_SQ3
;
91 MTO_TH_IDLE_SLOT() = MTO_DEFAULT_TH_IDLE_SLOT
;
92 MTO_TH_PR_INTERF() = MTO_DEFAULT_TH_PR_INTERF
;
94 MTO_TMR_AGING() = MTO_DEFAULT_TMR_AGING
;
95 MTO_TMR_PERIODIC() = MTO_DEFAULT_TMR_PERIODIC
;
97 //[WKCHEN]MTO_CCA_MODE_SETUP()= (u8) hal_get_cca_mode(MTO_HAL());
98 //[WKCHEN]MTO_CCA_MODE() = MTO_CCA_MODE_SETUP();
100 //MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_LONG;
101 MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT
; // for test
103 MTO_ANT_SEL() = hal_get_antenna_number(MTO_HAL());
104 MTO_ANT_MAC() = MTO_ANT_SEL();
109 MTO_ANT_DIVERSITY() = MTO_ANTENNA_DIVERSITY_ON
;
110 //CardSet_AntennaDiversity(adapter, MTO_ANT_DIVERSITY());
111 //PLMESetAntennaDiversity( adapter, MTO_ANT_DIVERSITY());
113 MTO_AGING_TIMEOUT() = 0;//MTO_TMR_AGING() / MTO_TMR_PERIODIC();
115 // The following parameters should be initialized to the values set by user
117 //MTO_RATE_LEVEL() = 10;
118 MTO_RATE_LEVEL() = 0;
119 MTO_FRAG_TH_LEVEL() = 4;
120 /** 1.1.23.1000 Turbo modify from -1 to +1
121 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() - 1;
122 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() - 1;
124 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1;
125 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1;
126 // 1.1.23.1000 Turbo add for mto change preamble from 0 to 1
127 MTO_RATE_CHANGE_ENABLE() = 1;
128 MTO_FRAG_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
129 //The default valud of ANTDIV_DEFAULT_ON will be decided by EEPROM
130 //#ifdef ANTDIV_DEFAULT_ON
131 //MTO_ANT_DIVERSITY_ENABLE() = 1;
133 //MTO_ANT_DIVERSITY_ENABLE() = 0;
135 MTO_POWER_CHANGE_ENABLE() = 1;
136 MTO_PREAMBLE_CHANGE_ENABLE()= 1;
137 MTO_RTS_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
138 // 20040512 Turbo add
139 //old_antenna[0] = 1;
140 //old_antenna[1] = 0;
141 //old_antenna[2] = 1;
142 //old_antenna[3] = 0;
143 for (i
=0;i
<MTO_MAX_DATA_RATE_LEVELS
;i
++)
146 MTO_TXFLOWCOUNT() = 0;
147 //--------- DTO threshold parameters -------------
148 //MTOPARA_PERIODIC_CHECK_CYCLE() = 50;
149 MTOPARA_PERIODIC_CHECK_CYCLE() = 10;
150 MTOPARA_RSSI_TH_FOR_ANTDIV() = 10;
151 MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50;
152 MTOPARA_TXRATE_INC_TH() = 10;
153 MTOPARA_TXRATE_DEC_TH() = 30;
154 MTOPARA_TXRATE_EQ_TH() = 40;
155 MTOPARA_TXRATE_BACKOFF() = 12;
156 MTOPARA_TXRETRYRATE_REDUCE() = 6;
157 if ( MTO_TXPOWER_FROM_EEPROM
== 0xff)
159 switch( MTO_HAL()->phy_type
)
162 case RF_AIROHA_2230S
: // 20060420 Add this
163 MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230
166 MTOPARA_TXPOWER_INDEX() = 49;
169 MTOPARA_TXPOWER_INDEX() = 10;
172 MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify
176 else //follow the setting from EEPROM
177 MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM
;
178 RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8
)MTOPARA_TXPOWER_INDEX());
179 //------------------------------------------------
181 // For RSSI turning 20060808.4 Cancel load from EEPROM
182 MTO_DATA().RSSI_high
= -41;
183 MTO_DATA().RSSI_low
= -60;
186 //===========================================================================
188 // If we enable DTO, we will ignore the tx count with different tx rate from
189 // DTO rate. This is because when we adjust DTO tx rate, there could be some
190 // packets in the tx queue with previous tx rate
191 void MTO_SetTxCount(struct wbsoft_priv
*adapter
, u8 tx_rate
, u8 index
)
194 if ((MTO_ENABLE
==1) && (MTO_RATE_CHANGE_ENABLE()==1))
196 if(tx_rate
== MTO_DATA_RATE())
200 if (boSparseTxTraffic
)
201 MTO_HAL()->dto_tx_frag_count
+= MTOPARA_PERIODIC_CHECK_CYCLE();
203 MTO_HAL()->dto_tx_frag_count
+= 1;
209 MTO_HAL()->dto_tx_retry_count
+= index
;
210 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
214 MTO_HAL()->dto_tx_retry_count
+= 7;
215 MTO_HAL()->dto_tx_frag_count
+= 7;
219 else if(MTO_DATA_RATE()>48 && tx_rate
==48)
221 if (index
<3) //for reduciing data rate scheme ,
222 //do not calcu different data rate
223 //3 is the reducing data rate at retry
225 MTO_HAL()->dto_tx_retry_count
+= index
;
226 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
230 MTO_HAL()->dto_tx_retry_count
+= 3;
231 MTO_HAL()->dto_tx_frag_count
+= 3;
238 MTO_HAL()->dto_tx_retry_count
+= index
;
239 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
242 TotalTxPktRetry
+= (index
+1);
245 PeriodTotalTxPktRetry
+= (index
+1);