sched: don't allow setuid to succeed if the user does not have rt bandwidth
[linux-2.6/mini2440.git] / drivers / staging / winbond / mto.c
blobde11a05efae2a65a9f4513c26a49d56cb8fbff2a
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 "os_common.h"
26 #include "sme_api.h"
27 #include "gl_80211.h"
28 #include "wbhal_f.h"
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
42 //match the table
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 typedef struct
56 s32 RSSI;
57 u8 TxRate;
58 }RSSI2RATE;
60 static u8 boSparseTxTraffic = false;
62 void MTO_Init(MTO_FUNC_INPUT);
63 void TxRateReductionCtrl(MTO_FUNC_INPUT);
64 /** 1.1.31.1000 Turbo modify */
65 void MTO_SetTxCount(MTO_FUNC_INPUT, u8 t0, u8 index);
66 void MTO_TxFailed(MTO_FUNC_INPUT);
67 void hal_get_dto_para(MTO_FUNC_INPUT, char *buffer);
69 //===========================================================================
70 // MTO_Init --
72 // Description:
73 // Initialize MTO parameters.
75 // This function should be invoked during system initialization.
77 // Arguments:
78 // adapter - The pointer to the Miniport adapter Context
80 // Return Value:
81 // None
82 //============================================================================
83 void MTO_Init(MTO_FUNC_INPUT)
85 int i;
86 //WBDEBUG(("[MTO] -> MTO_Init()\n"));
87 //[WKCHEN]pMTOcore_data = pcore_data;
88 // 20040510 Turbo add for global variable
89 MTO_TMR_CNT() = 0;
90 MTO_TOGGLE_STATE() = TOGGLE_STATE_IDLE;
91 MTO_TX_RATE_REDUCTION_STATE() = RATE_CHGSTATE_IDLE;
92 MTO_BACKOFF_TMR() = 0;
93 MTO_LAST_RATE() = 11;
94 MTO_CO_EFFICENT() = 0;
96 //MTO_TH_FIXANT() = MTO_DEFAULT_TH_FIXANT;
97 MTO_TH_CNT() = MTO_DEFAULT_TH_CNT;
98 MTO_TH_SQ3() = MTO_DEFAULT_TH_SQ3;
99 MTO_TH_IDLE_SLOT() = MTO_DEFAULT_TH_IDLE_SLOT;
100 MTO_TH_PR_INTERF() = MTO_DEFAULT_TH_PR_INTERF;
102 MTO_TMR_AGING() = MTO_DEFAULT_TMR_AGING;
103 MTO_TMR_PERIODIC() = MTO_DEFAULT_TMR_PERIODIC;
105 //[WKCHEN]MTO_CCA_MODE_SETUP()= (u8) hal_get_cca_mode(MTO_HAL());
106 //[WKCHEN]MTO_CCA_MODE() = MTO_CCA_MODE_SETUP();
108 //MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_LONG;
109 MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; // for test
111 MTO_ANT_SEL() = hal_get_antenna_number(MTO_HAL());
112 MTO_ANT_MAC() = MTO_ANT_SEL();
113 MTO_CNT_ANT(0) = 0;
114 MTO_CNT_ANT(1) = 0;
115 MTO_SQ_ANT(0) = 0;
116 MTO_SQ_ANT(1) = 0;
117 MTO_ANT_DIVERSITY() = MTO_ANTENNA_DIVERSITY_ON;
118 //CardSet_AntennaDiversity(adapter, MTO_ANT_DIVERSITY());
119 //PLMESetAntennaDiversity( adapter, MTO_ANT_DIVERSITY());
121 MTO_AGING_TIMEOUT() = 0;//MTO_TMR_AGING() / MTO_TMR_PERIODIC();
123 // The following parameters should be initialized to the values set by user
125 //MTO_RATE_LEVEL() = 10;
126 MTO_RATE_LEVEL() = 0;
127 MTO_FRAG_TH_LEVEL() = 4;
128 /** 1.1.23.1000 Turbo modify from -1 to +1
129 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() - 1;
130 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() - 1;
132 MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1;
133 MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1;
134 // 1.1.23.1000 Turbo add for mto change preamble from 0 to 1
135 MTO_RATE_CHANGE_ENABLE() = 1;
136 MTO_FRAG_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
137 //The default valud of ANTDIV_DEFAULT_ON will be decided by EEPROM
138 //#ifdef ANTDIV_DEFAULT_ON
139 //MTO_ANT_DIVERSITY_ENABLE() = 1;
140 //#else
141 //MTO_ANT_DIVERSITY_ENABLE() = 0;
142 //#endif
143 MTO_POWER_CHANGE_ENABLE() = 1;
144 MTO_PREAMBLE_CHANGE_ENABLE()= 1;
145 MTO_RTS_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag
146 // 20040512 Turbo add
147 //old_antenna[0] = 1;
148 //old_antenna[1] = 0;
149 //old_antenna[2] = 1;
150 //old_antenna[3] = 0;
151 for (i=0;i<MTO_MAX_DATA_RATE_LEVELS;i++)
152 retryrate_rec[i]=5;
154 MTO_TXFLOWCOUNT() = 0;
155 //--------- DTO threshold parameters -------------
156 //MTOPARA_PERIODIC_CHECK_CYCLE() = 50;
157 MTOPARA_PERIODIC_CHECK_CYCLE() = 10;
158 MTOPARA_RSSI_TH_FOR_ANTDIV() = 10;
159 MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50;
160 MTOPARA_TXRATE_INC_TH() = 10;
161 MTOPARA_TXRATE_DEC_TH() = 30;
162 MTOPARA_TXRATE_EQ_TH() = 40;
163 MTOPARA_TXRATE_BACKOFF() = 12;
164 MTOPARA_TXRETRYRATE_REDUCE() = 6;
165 if ( MTO_TXPOWER_FROM_EEPROM == 0xff)
167 switch( MTO_HAL()->phy_type)
169 case RF_AIROHA_2230:
170 case RF_AIROHA_2230S: // 20060420 Add this
171 MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230
172 break;
173 case RF_AIROHA_7230:
174 MTOPARA_TXPOWER_INDEX() = 49;
175 break;
176 case RF_WB_242:
177 MTOPARA_TXPOWER_INDEX() = 10;
178 break;
179 case RF_WB_242_1:
180 MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify
181 break;
184 else //follow the setting from EEPROM
185 MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM;
186 hal_set_rf_power(MTO_HAL(), (u8)MTOPARA_TXPOWER_INDEX());
187 //------------------------------------------------
189 // For RSSI turning 20060808.4 Cancel load from EEPROM
190 MTO_DATA().RSSI_high = -41;
191 MTO_DATA().RSSI_low = -60;
194 //===========================================================================
195 // Description:
196 // If we enable DTO, we will ignore the tx count with different tx rate from
197 // DTO rate. This is because when we adjust DTO tx rate, there could be some
198 // packets in the tx queue with previous tx rate
199 void MTO_SetTxCount(MTO_FUNC_INPUT, u8 tx_rate, u8 index)
201 MTO_TXFLOWCOUNT()++;
202 if ((MTO_ENABLE==1) && (MTO_RATE_CHANGE_ENABLE()==1))
204 if(tx_rate == MTO_DATA_RATE())
206 if (index == 0)
208 if (boSparseTxTraffic)
209 MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE();
210 else
211 MTO_HAL()->dto_tx_frag_count += 1;
213 else
215 if (index<8)
217 MTO_HAL()->dto_tx_retry_count += index;
218 MTO_HAL()->dto_tx_frag_count += (index+1);
220 else
222 MTO_HAL()->dto_tx_retry_count += 7;
223 MTO_HAL()->dto_tx_frag_count += 7;
227 else if(MTO_DATA_RATE()>48 && tx_rate ==48)
228 {//ALFRED
229 if (index<3) //for reduciing data rate scheme ,
230 //do not calcu different data rate
231 //3 is the reducing data rate at retry
233 MTO_HAL()->dto_tx_retry_count += index;
234 MTO_HAL()->dto_tx_frag_count += (index+1);
236 else
238 MTO_HAL()->dto_tx_retry_count += 3;
239 MTO_HAL()->dto_tx_frag_count += 3;
244 else
246 MTO_HAL()->dto_tx_retry_count += index;
247 MTO_HAL()->dto_tx_frag_count += (index+1);
249 TotalTxPkt ++;
250 TotalTxPktRetry += (index+1);
252 PeriodTotalTxPkt ++;
253 PeriodTotalTxPktRetry += (index+1);