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