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