Staging: w35und: Remove some write-only struct members
[linux-2.6/cjktty.git] / drivers / staging / winbond / mto.c
blob5e7fa1cd0aeae190d73fcd12d62f727d082cec50
1 //============================================================================
2 // MTO.C -
3 //
4 // Description:
5 // MAC Throughput Optimization for W89C33 802.11g WLAN STA.
6 //
7 // The following MIB attributes or internal variables will be affected
8 // while the MTO is being executed:
9 // dot11FragmentationThreshold,
10 // dot11RTSThreshold,
11 // transmission rate and PLCP preamble type,
12 // CCA mode,
13 // antenna diversity.
15 // Revision history:
16 // --------------------------------------------------------------------------
17 // 20031227 UN20 Pete Chao
18 // First draft
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
25 #include "sysdef.h"
26 #include "sme_api.h"
27 #include "wbhal_f.h"
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
41 //match the table
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 //===========================================================================
63 // MTO_Init --
65 // Description:
66 // Initialize MTO parameters.
68 // This function should be invoked during system initialization.
70 // Arguments:
71 // adapter - The pointer to the Miniport adapter Context
73 // Return Value:
74 // None
75 //============================================================================
76 void MTO_Init(struct wbsoft_priv *adapter)
78 int i;
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
86 MTO_CNT_ANT(0) = 0;
87 MTO_CNT_ANT(1) = 0;
88 MTO_SQ_ANT(0) = 0;
89 MTO_SQ_ANT(1) = 0;
91 MTO_AGING_TIMEOUT() = 0;
93 // The following parameters should be initialized to the values set by user
95 //MTO_RATE_LEVEL() = 10;
96 MTO_RATE_LEVEL() = 0;
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
109 //#else
110 //#endif
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++)
120 retryrate_rec[i]=5;
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)
137 case RF_AIROHA_2230:
138 case RF_AIROHA_2230S: // 20060420 Add this
139 MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230
140 break;
141 case RF_AIROHA_7230:
142 MTOPARA_TXPOWER_INDEX() = 49;
143 break;
144 case RF_WB_242:
145 MTOPARA_TXPOWER_INDEX() = 10;
146 break;
147 case RF_WB_242_1:
148 MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify
149 break;
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 //===========================================================================
163 // Description:
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)
169 MTO_TXFLOWCOUNT()++;
170 if ((MTO_ENABLE==1) && (MTO_RATE_CHANGE_ENABLE()==1))
172 if(tx_rate == MTO_DATA_RATE())
174 if (index == 0)
176 if (boSparseTxTraffic)
177 MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE();
178 else
179 MTO_HAL()->dto_tx_frag_count += 1;
181 else
183 if (index<8)
185 MTO_HAL()->dto_tx_retry_count += index;
186 MTO_HAL()->dto_tx_frag_count += (index+1);
188 else
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)
196 {//ALFRED
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);
204 else
206 MTO_HAL()->dto_tx_retry_count += 3;
207 MTO_HAL()->dto_tx_frag_count += 3;
212 else
214 MTO_HAL()->dto_tx_retry_count += index;
215 MTO_HAL()->dto_tx_frag_count += (index+1);
217 TotalTxPkt ++;
218 TotalTxPktRetry += (index+1);
220 PeriodTotalTxPkt ++;
221 PeriodTotalTxPktRetry += (index+1);