Commit | Line | Data |
---|---|---|
f9a4191c LL |
1 | /* |
2 | * ============================================================================ | |
3 | * MTO.C - | |
4 | * | |
5 | * Description: | |
6 | * MAC Throughput Optimization for W89C33 802.11g WLAN STA. | |
7 | * | |
8 | * The following MIB attributes or internal variables will be affected | |
9 | * while the MTO is being executed: | |
10 | * dot11FragmentationThreshold, | |
11 | * dot11RTSThreshold, | |
12 | * transmission rate and PLCP preamble type, | |
13 | * CCA mode, | |
14 | * antenna diversity. | |
15 | * | |
16 | * Copyright (c) 2003 Winbond Electronics Corp. All rights reserved. | |
17 | * ============================================================================ | |
18 | */ | |
19 | ||
7e797abf | 20 | #include "sysdef.h" |
80aba536 | 21 | #include "sme_api.h" |
80aba536 | 22 | #include "wbhal_f.h" |
66101de1 | 23 | |
f9a4191c LL |
24 | /* Declare SQ3 to rate and fragmentation threshold table */ |
25 | /* Declare fragmentation thresholds table */ | |
26 | #define MTO_MAX_FRAG_TH_LEVELS 5 | |
27 | #define MTO_MAX_DATA_RATE_LEVELS 12 | |
66101de1 | 28 | |
f9a4191c LL |
29 | u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] = { |
30 | 256, 384, 512, 768, 1536 | |
66101de1 PM |
31 | }; |
32 | ||
f9a4191c LL |
33 | /* |
34 | * Declare data rate table: | |
35 | * The following table will be changed at anytime if the opration rate | |
36 | * supported by AP don't match the table | |
37 | */ | |
a22517fe | 38 | static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = { |
f9a4191c | 39 | 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 |
66101de1 PM |
40 | }; |
41 | ||
f9a4191c LL |
42 | static int TotalTxPkt; |
43 | static int TotalTxPktRetry; | |
44 | /* this record the retry rate at different data rate */ | |
45 | static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS]; | |
66101de1 | 46 | |
f9a4191c LL |
47 | static int PeriodTotalTxPkt; |
48 | static int PeriodTotalTxPktRetry; | |
66101de1 | 49 | |
f9a4191c | 50 | static u8 boSparseTxTraffic; |
66101de1 | 51 | |
57a94443 PE |
52 | void MTO_Init(struct wbsoft_priv *adapter); |
53 | void TxRateReductionCtrl(struct wbsoft_priv *adapter); | |
57a94443 PE |
54 | void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index); |
55 | void MTO_TxFailed(struct wbsoft_priv *adapter); | |
56 | void hal_get_dto_para(struct wbsoft_priv *adapter, char *buffer); | |
66101de1 | 57 | |
f9a4191c LL |
58 | /* |
59 | * =========================================================================== | |
60 | * MTO_Init -- | |
61 | * | |
62 | * Description: | |
63 | * Initialize MTO parameters. | |
64 | * | |
65 | * This function should be invoked during system initialization. | |
66 | * | |
67 | * Arguments: | |
68 | * adapter - The pointer to the Miniport adapter Context | |
69 | * =========================================================================== | |
70 | */ | |
57a94443 | 71 | void MTO_Init(struct wbsoft_priv *adapter) |
66101de1 | 72 | { |
f9a4191c LL |
73 | int i; |
74 | ||
75 | MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; /* for test */ | |
76 | ||
77 | MTO_CNT_ANT(0) = 0; | |
78 | MTO_CNT_ANT(1) = 0; | |
79 | MTO_SQ_ANT(0) = 0; | |
80 | MTO_SQ_ANT(1) = 0; | |
81 | ||
82 | MTO_AGING_TIMEOUT() = 0; | |
83 | ||
84 | /* The following parameters should be initialized to the values set by user */ | |
85 | MTO_RATE_LEVEL() = 0; | |
86 | MTO_FRAG_TH_LEVEL() = 4; | |
87 | MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1; | |
88 | MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1; | |
89 | MTO_RATE_CHANGE_ENABLE() = 1; | |
90 | MTO_FRAG_CHANGE_ENABLE() = 0; | |
91 | MTO_POWER_CHANGE_ENABLE() = 1; | |
92 | MTO_PREAMBLE_CHANGE_ENABLE() = 1; | |
93 | MTO_RTS_CHANGE_ENABLE() = 0; | |
94 | ||
95 | for (i = 0; i < MTO_MAX_DATA_RATE_LEVELS; i++) | |
96 | retryrate_rec[i] = 5; | |
66101de1 PM |
97 | |
98 | MTO_TXFLOWCOUNT() = 0; | |
f9a4191c LL |
99 | /* --------- DTO threshold parameters ------------- */ |
100 | MTOPARA_PERIODIC_CHECK_CYCLE() = 10; | |
101 | MTOPARA_RSSI_TH_FOR_ANTDIV() = 10; | |
102 | MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50; | |
103 | MTOPARA_TXRATE_INC_TH() = 10; | |
104 | MTOPARA_TXRATE_DEC_TH() = 30; | |
105 | MTOPARA_TXRATE_EQ_TH() = 40; | |
106 | MTOPARA_TXRATE_BACKOFF() = 12; | |
107 | MTOPARA_TXRETRYRATE_REDUCE() = 6; | |
108 | if (MTO_TXPOWER_FROM_EEPROM == 0xff) { | |
109 | switch (MTO_HAL()->phy_type) { | |
110 | case RF_AIROHA_2230: | |
111 | case RF_AIROHA_2230S: | |
112 | MTOPARA_TXPOWER_INDEX() = 46; /* MAX-8 @@ Only for AL 2230 */ | |
113 | break; | |
114 | case RF_AIROHA_7230: | |
115 | MTOPARA_TXPOWER_INDEX() = 49; | |
116 | break; | |
117 | case RF_WB_242: | |
118 | MTOPARA_TXPOWER_INDEX() = 10; | |
119 | break; | |
120 | case RF_WB_242_1: | |
121 | MTOPARA_TXPOWER_INDEX() = 24; | |
122 | break; | |
66101de1 | 123 | } |
f9a4191c | 124 | } else { /* follow the setting from EEPROM */ |
66101de1 | 125 | MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM; |
f9a4191c LL |
126 | } |
127 | RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8) MTOPARA_TXPOWER_INDEX()); | |
128 | /* ------------------------------------------------ */ | |
66101de1 | 129 | |
f9a4191c | 130 | /* For RSSI turning -- Cancel load from EEPROM */ |
66101de1 PM |
131 | MTO_DATA().RSSI_high = -41; |
132 | MTO_DATA().RSSI_low = -60; | |
133 | } | |
134 | ||
f9a4191c LL |
135 | /* =========================================================================== |
136 | * Description: | |
137 | * If we enable DTO, we will ignore the tx count with different tx rate | |
138 | * from DTO rate. This is because when we adjust DTO tx rate, there could | |
139 | * be some packets in the tx queue with previous tx rate | |
140 | */ | |
141 | ||
57a94443 | 142 | void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 tx_rate, u8 index) |
66101de1 PM |
143 | { |
144 | MTO_TXFLOWCOUNT()++; | |
f9a4191c LL |
145 | if ((MTO_ENABLE == 1) && (MTO_RATE_CHANGE_ENABLE() == 1)) { |
146 | if (tx_rate == MTO_DATA_RATE()) { | |
147 | if (index == 0) { | |
66101de1 PM |
148 | if (boSparseTxTraffic) |
149 | MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE(); | |
150 | else | |
151 | MTO_HAL()->dto_tx_frag_count += 1; | |
f9a4191c LL |
152 | } else { |
153 | if (index < 8) { | |
66101de1 | 154 | MTO_HAL()->dto_tx_retry_count += index; |
f9a4191c LL |
155 | MTO_HAL()->dto_tx_frag_count += (index + 1); |
156 | } else { | |
66101de1 PM |
157 | MTO_HAL()->dto_tx_retry_count += 7; |
158 | MTO_HAL()->dto_tx_frag_count += 7; | |
159 | } | |
160 | } | |
f9a4191c LL |
161 | } else if (MTO_DATA_RATE() > 48 && tx_rate == 48) { |
162 | /* for reducing data rate scheme, do not calculate different data rate. 3 is the reducing data rate at retry. */ | |
163 | if (index < 3) { | |
66101de1 | 164 | MTO_HAL()->dto_tx_retry_count += index; |
f9a4191c LL |
165 | MTO_HAL()->dto_tx_frag_count += (index + 1); |
166 | } else { | |
66101de1 PM |
167 | MTO_HAL()->dto_tx_retry_count += 3; |
168 | MTO_HAL()->dto_tx_frag_count += 3; | |
169 | } | |
170 | ||
171 | } | |
f9a4191c | 172 | } else { |
66101de1 | 173 | MTO_HAL()->dto_tx_retry_count += index; |
f9a4191c | 174 | MTO_HAL()->dto_tx_frag_count += (index + 1); |
66101de1 | 175 | } |
f9a4191c LL |
176 | TotalTxPkt++; |
177 | TotalTxPktRetry += (index + 1); | |
66101de1 | 178 | |
f9a4191c LL |
179 | PeriodTotalTxPkt++; |
180 | PeriodTotalTxPktRetry += (index + 1); | |
66101de1 | 181 | } |