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
)
80 //[WKCHEN]MTO_CCA_MODE_SETUP()= (u8) hal_get_cca_mode(MTO_HAL());
81 //[WKCHEN]MTO_CCA_MODE() = MTO_CCA_MODE_SETUP();
83 //MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_LONG;
84 MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT
; // for test
91 MTO_AGING_TIMEOUT() = 0;
93 // The following parameters should be initialized to the values set by user
95 //MTO_RATE_LEVEL() = 10;
97 MTO_FRAG_TH_LEVEL() = 4;
98 /** 1.1.23.1000 Turbo modify from -1 to +1
99 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() - 1;
100 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() - 1;
102 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1;
103 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1;
104 // 1.1.23.1000 Turbo add for mto change preamble from 0 to 1
105 MTO_RATE_CHANGE_ENABLE() = 1;
106 MTO_FRAG_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
107 //The default valud of ANTDIV_DEFAULT_ON will be decided by EEPROM
108 //#ifdef ANTDIV_DEFAULT_ON
111 MTO_POWER_CHANGE_ENABLE() = 1;
112 MTO_PREAMBLE_CHANGE_ENABLE()= 1;
113 MTO_RTS_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
114 // 20040512 Turbo add
115 //old_antenna[0] = 1;
116 //old_antenna[1] = 0;
117 //old_antenna[2] = 1;
118 //old_antenna[3] = 0;
119 for (i
=0;i
<MTO_MAX_DATA_RATE_LEVELS
;i
++)
122 MTO_TXFLOWCOUNT() = 0;
123 //--------- DTO threshold parameters -------------
124 //MTOPARA_PERIODIC_CHECK_CYCLE() = 50;
125 MTOPARA_PERIODIC_CHECK_CYCLE() = 10;
126 MTOPARA_RSSI_TH_FOR_ANTDIV() = 10;
127 MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50;
128 MTOPARA_TXRATE_INC_TH() = 10;
129 MTOPARA_TXRATE_DEC_TH() = 30;
130 MTOPARA_TXRATE_EQ_TH() = 40;
131 MTOPARA_TXRATE_BACKOFF() = 12;
132 MTOPARA_TXRETRYRATE_REDUCE() = 6;
133 if ( MTO_TXPOWER_FROM_EEPROM
== 0xff)
135 switch( MTO_HAL()->phy_type
)
138 case RF_AIROHA_2230S
: // 20060420 Add this
139 MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230
142 MTOPARA_TXPOWER_INDEX() = 49;
145 MTOPARA_TXPOWER_INDEX() = 10;
148 MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify
152 else //follow the setting from EEPROM
153 MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM
;
154 RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8
)MTOPARA_TXPOWER_INDEX());
155 //------------------------------------------------
157 // For RSSI turning 20060808.4 Cancel load from EEPROM
158 MTO_DATA().RSSI_high
= -41;
159 MTO_DATA().RSSI_low
= -60;
162 //===========================================================================
164 // If we enable DTO, we will ignore the tx count with different tx rate from
165 // DTO rate. This is because when we adjust DTO tx rate, there could be some
166 // packets in the tx queue with previous tx rate
167 void MTO_SetTxCount(struct wbsoft_priv
*adapter
, u8 tx_rate
, u8 index
)
170 if ((MTO_ENABLE
==1) && (MTO_RATE_CHANGE_ENABLE()==1))
172 if(tx_rate
== MTO_DATA_RATE())
176 if (boSparseTxTraffic
)
177 MTO_HAL()->dto_tx_frag_count
+= MTOPARA_PERIODIC_CHECK_CYCLE();
179 MTO_HAL()->dto_tx_frag_count
+= 1;
185 MTO_HAL()->dto_tx_retry_count
+= index
;
186 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
190 MTO_HAL()->dto_tx_retry_count
+= 7;
191 MTO_HAL()->dto_tx_frag_count
+= 7;
195 else if(MTO_DATA_RATE()>48 && tx_rate
==48)
197 if (index
<3) //for reduciing data rate scheme ,
198 //do not calcu different data rate
199 //3 is the reducing data rate at retry
201 MTO_HAL()->dto_tx_retry_count
+= index
;
202 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
206 MTO_HAL()->dto_tx_retry_count
+= 3;
207 MTO_HAL()->dto_tx_frag_count
+= 3;
214 MTO_HAL()->dto_tx_retry_count
+= index
;
215 MTO_HAL()->dto_tx_frag_count
+= (index
+1);
218 TotalTxPktRetry
+= (index
+1);
221 PeriodTotalTxPktRetry
+= (index
+1);