1
2
3
4
5
6
7
8#include "odm_precomp.h"
9
10
11
12u32 OFDMSwingTable[OFDM_TABLE_SIZE] = {
13 0x7f8001fe,
14 0x788001e2,
15 0x71c001c7,
16 0x6b8001ae,
17 0x65400195,
18 0x5fc0017f,
19 0x5a400169,
20 0x55400155,
21 0x50800142,
22 0x4c000130,
23 0x47c0011f,
24 0x43c0010f,
25 0x40000100,
26 0x3c8000f2,
27 0x390000e4,
28 0x35c000d7,
29 0x32c000cb,
30 0x300000c0,
31 0x2d4000b5,
32 0x2ac000ab,
33 0x288000a2,
34 0x26000098,
35 0x24000090,
36 0x22000088,
37 0x20000080,
38 0x1e400079,
39 0x1c800072,
40 0x1b00006c,
41 0x19800066,
42 0x18000060,
43 0x16c0005b,
44 0x15800056,
45 0x14400051,
46 0x1300004c,
47 0x12000048,
48 0x11000044,
49 0x10000040,
50};
51
52u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
53 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
54 {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
55 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
56 {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
57 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
58 {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
59 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
60 {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
61 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
62 {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
63 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
64 {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
65 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
66 {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
67 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
68 {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
69 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
70 {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
71 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
72 {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
73 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
74 {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
75 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
76 {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
77 {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
78 {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
79 {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
80 {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
81 {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
82 {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
83 {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
84 {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
85 {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}
86};
87
88u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = {
89 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
90 {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
91 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
92 {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
93 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
94 {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
95 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
96 {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
97 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
98 {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
99 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
100 {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
101 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
102 {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
103 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
104 {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
105 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
106 {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
107 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
108 {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
109 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
110 {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
111 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
112 {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
113 {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
114 {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
115 {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
116 {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
117 {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
118 {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
119 {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
120 {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
121 {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
122};
123
124u32 OFDMSwingTable_New[OFDM_TABLE_SIZE] = {
125 0x0b40002d,
126 0x0c000030,
127 0x0cc00033,
128 0x0d800036,
129 0x0e400039,
130 0x0f00003c,
131 0x10000040,
132 0x11000044,
133 0x12000048,
134 0x1300004c,
135 0x14400051,
136 0x15800056,
137 0x16c0005b,
138 0x18000060,
139 0x19800066,
140 0x1b00006c,
141 0x1c800072,
142 0x1e400079,
143 0x20000080,
144 0x22000088,
145 0x24000090,
146 0x26000098,
147 0x288000a2,
148 0x2ac000ab,
149 0x2d4000b5,
150 0x300000c0,
151 0x32c000cb,
152 0x35c000d7,
153 0x390000e4,
154 0x3c8000f2,
155 0x40000100,
156 0x43c0010f,
157 0x47c0011f,
158 0x4c000130,
159 0x50800142,
160 0x55400155,
161 0x5a400169,
162 0x5fc0017f,
163 0x65400195,
164 0x6b8001ae,
165 0x71c001c7,
166 0x788001e2,
167 0x7f8001fe
168};
169
170u8 CCKSwingTable_Ch1_Ch13_New[CCK_TABLE_SIZE][8] = {
171 {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01},
172 {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
173 {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
174 {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
175 {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
176 {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
177 {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
178 {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
179 {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
180 {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
181 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
182 {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
183 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
184 {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
185 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
186 {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
187 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
188 {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
189 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
190 {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
191 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
192 {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
193 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
194 {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
195 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
196 {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
197 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
198 {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
199 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
200 {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
201 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
202 {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
203 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}
204};
205
206u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8] = {
207 {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00},
208 {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
209 {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
210 {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
211 {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
212 {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
213 {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
214 {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
215 {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
216 {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
217 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
218 {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
219 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
220 {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
221 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
222 {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
223 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
224 {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
225 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
226 {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
227 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
228 {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
229 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
230 {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
231 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
232 {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
233 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
234 {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
235 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
236 {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
237 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
238 {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
239 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}
240};
241
242u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = {
243 0x081,
244 0x088,
245 0x090,
246 0x099,
247 0x0A2,
248 0x0AC,
249 0x0B6,
250 0x0C0,
251 0x0CC,
252 0x0D8,
253 0x0E5,
254 0x0F2,
255 0x101,
256 0x110,
257 0x120,
258 0x131,
259 0x143,
260 0x156,
261 0x16A,
262 0x180,
263 0x197,
264 0x1AF,
265 0x1C8,
266 0x1E3,
267 0x200,
268 0x21E,
269 0x23E,
270 0x261,
271 0x285,
272 0x2AB,
273 0x2D3,
274 0x2FE,
275 0x32B,
276 0x35C,
277 0x38E,
278 0x3C4,
279 0x3FE
280};
281
282
283
284static void odm_CommonInfoSelfInit(struct dm_odm_t *pDM_Odm)
285{
286 pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
287 pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
288
289 pDM_Odm->TxRate = 0xFF;
290}
291
292static void odm_CommonInfoSelfUpdate(struct dm_odm_t *pDM_Odm)
293{
294 u8 EntryCnt = 0;
295 u8 i;
296 PSTA_INFO_T pEntry;
297
298 if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
299 if (*(pDM_Odm->pSecChOffset) == 1)
300 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
301 else if (*(pDM_Odm->pSecChOffset) == 2)
302 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
303 } else
304 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
305
306 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
307 pEntry = pDM_Odm->pODM_StaInfo[i];
308 if (IS_STA_VALID(pEntry))
309 EntryCnt++;
310 }
311
312 if (EntryCnt == 1)
313 pDM_Odm->bOneEntryOnly = true;
314 else
315 pDM_Odm->bOneEntryOnly = false;
316}
317
318static void odm_CmnInfoInit_Debug(struct dm_odm_t *pDM_Odm)
319{
320}
321
322static void odm_BasicDbgMessage(struct dm_odm_t *pDM_Odm)
323{
324}
325
326
327
328
329
330
331
332
333static void odm_RateAdaptiveMaskInit(struct dm_odm_t *pDM_Odm)
334{
335 struct odm_rate_adaptive *pOdmRA = &pDM_Odm->RateAdaptive;
336
337 pOdmRA->Type = DM_Type_ByDriver;
338 if (pOdmRA->Type == DM_Type_ByDriver)
339 pDM_Odm->bUseRAMask = true;
340 else
341 pDM_Odm->bUseRAMask = false;
342
343 pOdmRA->RATRState = DM_RATR_STA_INIT;
344 pOdmRA->LdpcThres = 35;
345 pOdmRA->bUseLdpc = false;
346 pOdmRA->HighRSSIThresh = 50;
347 pOdmRA->LowRSSIThresh = 20;
348}
349
350u32 ODM_Get_Rate_Bitmap(
351 struct dm_odm_t *pDM_Odm,
352 u32 macid,
353 u32 ra_mask,
354 u8 rssi_level
355)
356{
357 PSTA_INFO_T pEntry;
358 u32 rate_bitmap = 0;
359 u8 WirelessMode;
360
361 pEntry = pDM_Odm->pODM_StaInfo[macid];
362 if (!IS_STA_VALID(pEntry))
363 return ra_mask;
364
365 WirelessMode = pEntry->wireless_mode;
366
367 switch (WirelessMode) {
368 case ODM_WM_B:
369 if (ra_mask & 0x0000000c)
370 rate_bitmap = 0x0000000d;
371 else
372 rate_bitmap = 0x0000000f;
373 break;
374
375 case (ODM_WM_G):
376 if (rssi_level == DM_RATR_STA_HIGH)
377 rate_bitmap = 0x00000f00;
378 else
379 rate_bitmap = 0x00000ff0;
380 break;
381
382 case (ODM_WM_B|ODM_WM_G):
383 if (rssi_level == DM_RATR_STA_HIGH)
384 rate_bitmap = 0x00000f00;
385 else if (rssi_level == DM_RATR_STA_MIDDLE)
386 rate_bitmap = 0x00000ff0;
387 else
388 rate_bitmap = 0x00000ff5;
389 break;
390
391 case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
392 case (ODM_WM_B|ODM_WM_N24G):
393 case (ODM_WM_G|ODM_WM_N24G):
394 if (rssi_level == DM_RATR_STA_HIGH)
395 rate_bitmap = 0x000f0000;
396 else if (rssi_level == DM_RATR_STA_MIDDLE)
397 rate_bitmap = 0x000ff000;
398 else {
399 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
400 rate_bitmap = 0x000ff015;
401 else
402 rate_bitmap = 0x000ff005;
403 }
404 break;
405
406 default:
407 rate_bitmap = 0x0fffffff;
408 break;
409 }
410
411 return ra_mask & rate_bitmap;
412
413}
414
415static void odm_RefreshRateAdaptiveMaskCE(struct dm_odm_t *pDM_Odm)
416{
417 u8 i;
418 struct adapter *padapter = pDM_Odm->Adapter;
419
420 if (padapter->bDriverStopped) {
421 return;
422 }
423
424 if (!pDM_Odm->bUseRAMask) {
425 return;
426 }
427
428 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
429 PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
430
431 if (IS_STA_VALID(pstat)) {
432 if (IS_MCAST(pstat->hwaddr))
433 continue;
434
435 if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
436
437 rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
438 }
439
440 }
441 }
442}
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm)
462{
463
464 if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
465 return;
466 }
467 odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
468}
469
470
471
472bool ODM_RAStateCheck(
473 struct dm_odm_t *pDM_Odm,
474 s32 RSSI,
475 bool bForceUpdate,
476 u8 *pRATRState
477)
478{
479 struct odm_rate_adaptive *pRA = &pDM_Odm->RateAdaptive;
480 const u8 GoUpGap = 5;
481 u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
482 u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
483 u8 RATRState;
484
485
486
487
488 switch (*pRATRState) {
489 case DM_RATR_STA_INIT:
490 case DM_RATR_STA_HIGH:
491 break;
492
493 case DM_RATR_STA_MIDDLE:
494 HighRSSIThreshForRA += GoUpGap;
495 break;
496
497 case DM_RATR_STA_LOW:
498 HighRSSIThreshForRA += GoUpGap;
499 LowRSSIThreshForRA += GoUpGap;
500 break;
501
502 default:
503 netdev_dbg(pDM_Odm->Adapter->pnetdev,
504 "wrong rssi level setting %d !", *pRATRState);
505 break;
506 }
507
508
509 if (RSSI > HighRSSIThreshForRA)
510 RATRState = DM_RATR_STA_HIGH;
511 else if (RSSI > LowRSSIThreshForRA)
512 RATRState = DM_RATR_STA_MIDDLE;
513 else
514 RATRState = DM_RATR_STA_LOW;
515
516
517 if (*pRATRState != RATRState || bForceUpdate) {
518 *pRATRState = RATRState;
519 return true;
520 }
521
522 return false;
523}
524
525
526
527
528
529
530
531static void odm_RSSIMonitorInit(struct dm_odm_t *pDM_Odm)
532{
533 struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
534
535 pRA_Table->firstconnect = false;
536
537}
538
539static void FindMinimumRSSI(struct adapter *padapter)
540{
541 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
542 struct dm_priv *pdmpriv = &pHalData->dmpriv;
543 struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
544
545
546
547 if (
548 (pDM_Odm->bLinked != true) &&
549 (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
550 ) {
551 pdmpriv->MinUndecoratedPWDBForDM = 0;
552 } else
553 pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
554}
555
556static void odm_RSSIMonitorCheckCE(struct dm_odm_t *pDM_Odm)
557{
558 struct adapter *Adapter = pDM_Odm->Adapter;
559 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
560 struct dm_priv *pdmpriv = &pHalData->dmpriv;
561 int i;
562 int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
563 u8 sta_cnt = 0;
564 u32 PWDB_rssi[NUM_STA] = {0};
565 struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
566
567 if (pDM_Odm->bLinked != true)
568 return;
569
570 pRA_Table->firstconnect = pDM_Odm->bLinked;
571
572
573 {
574 struct sta_info *psta;
575
576 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
577 psta = pDM_Odm->pODM_StaInfo[i];
578 if (IS_STA_VALID(psta)) {
579 if (IS_MCAST(psta->hwaddr))
580 continue;
581
582 if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
583 continue;
584
585 if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
586 tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
587
588 if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
589 tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
590
591 if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
592 PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
593 }
594 }
595
596
597
598 for (i = 0; i < sta_cnt; i++) {
599 if (PWDB_rssi[i] != (0)) {
600 if (pHalData->fw_ractrl == true)
601 rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
602 }
603 }
604 }
605
606
607
608 if (tmpEntryMaxPWDB != 0)
609 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
610 else
611 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
612
613 if (tmpEntryMinPWDB != 0xff)
614 pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
615 else
616 pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
617
618 FindMinimumRSSI(Adapter);
619
620 pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
621
622}
623
624static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm)
625{
626 if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
627 return;
628
629 odm_RSSIMonitorCheckCE(pDM_Odm);
630
631}
632
633
634
635
636static void odm_SwAntDetectInit(struct dm_odm_t *pDM_Odm)
637{
638 struct swat_t *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
639
640 pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
641 pDM_SWAT_Table->PreAntenna = MAIN_ANT;
642 pDM_SWAT_Table->CurAntenna = MAIN_ANT;
643 pDM_SWAT_Table->SWAS_NoLink_State = 0;
644}
645
646
647
648
649
650static u8 getSwingIndex(struct dm_odm_t *pDM_Odm)
651{
652 struct adapter *Adapter = pDM_Odm->Adapter;
653 u8 i = 0;
654 u32 bbSwing;
655 u32 swingTableSize;
656 u32 *pSwingTable;
657
658 bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
659
660 pSwingTable = OFDMSwingTable_New;
661 swingTableSize = OFDM_TABLE_SIZE;
662
663 for (i = 0; i < swingTableSize; ++i) {
664 u32 tableValue = pSwingTable[i];
665
666 if (tableValue >= 0x100000)
667 tableValue >>= 22;
668 if (bbSwing == tableValue)
669 break;
670 }
671 return i;
672}
673
674void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm)
675{
676 u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
677 u8 p = 0;
678 struct adapter *Adapter = pDM_Odm->Adapter;
679 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
680
681
682 struct dm_priv *pdmpriv = &pHalData->dmpriv;
683
684 pdmpriv->bTXPowerTracking = true;
685 pdmpriv->TXPowercount = 0;
686 pdmpriv->bTXPowerTrackingInit = false;
687
688 if (*(pDM_Odm->mp_mode) != 1)
689 pdmpriv->TxPowerTrackControl = true;
690 else
691 pdmpriv->TxPowerTrackControl = false;
692
693
694 pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
695 pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
696 pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
697
698
699 pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
700 pDM_Odm->DefaultCckIndex = 20;
701
702 pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
703 pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
704
705 for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) {
706 pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
707 pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
708 pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
709 pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
710 pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
711 }
712
713}
714
715void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm)
716{
717 struct adapter *Adapter = pDM_Odm->Adapter;
718
719 if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
720 return;
721
722 if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) {
723 PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
724
725 pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
726 return;
727 } else {
728 ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
729 pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
730 }
731}
732
733
734
735
736
737
738
739
740void ODM_DMInit(struct dm_odm_t *pDM_Odm)
741{
742
743 odm_CommonInfoSelfInit(pDM_Odm);
744 odm_CmnInfoInit_Debug(pDM_Odm);
745 odm_DIGInit(pDM_Odm);
746 odm_NHMCounterStatisticsInit(pDM_Odm);
747 odm_AdaptivityInit(pDM_Odm);
748 odm_RateAdaptiveMaskInit(pDM_Odm);
749 ODM_CfoTrackingInit(pDM_Odm);
750 ODM_EdcaTurboInit(pDM_Odm);
751 odm_RSSIMonitorInit(pDM_Odm);
752 odm_TXPowerTrackingInit(pDM_Odm);
753
754 ODM_ClearTxPowerTrackingState(pDM_Odm);
755
756 odm_DynamicBBPowerSavingInit(pDM_Odm);
757 odm_DynamicTxPowerInit(pDM_Odm);
758
759 odm_SwAntDetectInit(pDM_Odm);
760}
761
762
763
764
765
766
767void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)
768{
769 odm_CommonInfoSelfUpdate(pDM_Odm);
770 odm_BasicDbgMessage(pDM_Odm);
771 odm_FalseAlarmCounterStatistics(pDM_Odm);
772 odm_NHMCounterStatistics(pDM_Odm);
773
774 odm_RSSIMonitorCheck(pDM_Odm);
775
776
777
778
779
780 if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE)
781
782
783
784
785 ) {
786 odm_DIGbyRSSI_LPS(pDM_Odm);
787 } else
788 odm_DIG(pDM_Odm);
789
790 {
791 struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
792
793 odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
794 }
795 odm_CCKPacketDetectionThresh(pDM_Odm);
796
797 if (*(pDM_Odm->pbPowerSaving) == true)
798 return;
799
800
801 odm_RefreshRateAdaptiveMask(pDM_Odm);
802 odm_EdcaTurboCheck(pDM_Odm);
803 ODM_CfoTracking(pDM_Odm);
804
805 ODM_TXPowerTrackingCheck(pDM_Odm);
806
807
808
809
810
811 pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
812}
813
814
815
816
817
818void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 Value)
819{
820
821
822
823 switch (CmnInfo) {
824
825
826
827 case ODM_CMNINFO_ABILITY:
828 pDM_Odm->SupportAbility = (u32)Value;
829 break;
830
831 case ODM_CMNINFO_PLATFORM:
832 pDM_Odm->SupportPlatform = (u8)Value;
833 break;
834
835 case ODM_CMNINFO_INTERFACE:
836 pDM_Odm->SupportInterface = (u8)Value;
837 break;
838
839 case ODM_CMNINFO_IC_TYPE:
840 pDM_Odm->SupportICType = Value;
841 break;
842
843 case ODM_CMNINFO_CUT_VER:
844 pDM_Odm->CutVersion = (u8)Value;
845 break;
846
847 case ODM_CMNINFO_FAB_VER:
848 pDM_Odm->FabVersion = (u8)Value;
849 break;
850
851 case ODM_CMNINFO_RFE_TYPE:
852 pDM_Odm->RFEType = (u8)Value;
853 break;
854
855 case ODM_CMNINFO_RF_ANTENNA_TYPE:
856 pDM_Odm->AntDivType = (u8)Value;
857 break;
858
859 case ODM_CMNINFO_PACKAGE_TYPE:
860 pDM_Odm->PackageType = (u8)Value;
861 break;
862
863 case ODM_CMNINFO_EXT_LNA:
864 pDM_Odm->ExtLNA = (u8)Value;
865 break;
866
867 case ODM_CMNINFO_EXT_PA:
868 pDM_Odm->ExtPA = (u8)Value;
869 break;
870
871 case ODM_CMNINFO_GPA:
872 pDM_Odm->TypeGPA = (enum odm_type_gpa_e)Value;
873 break;
874 case ODM_CMNINFO_APA:
875 pDM_Odm->TypeAPA = (enum odm_type_apa_e)Value;
876 break;
877 case ODM_CMNINFO_GLNA:
878 pDM_Odm->TypeGLNA = (enum odm_type_glna_e)Value;
879 break;
880 case ODM_CMNINFO_ALNA:
881 pDM_Odm->TypeALNA = (enum odm_type_alna_e)Value;
882 break;
883
884 case ODM_CMNINFO_EXT_TRSW:
885 pDM_Odm->ExtTRSW = (u8)Value;
886 break;
887 case ODM_CMNINFO_PATCH_ID:
888 pDM_Odm->PatchID = (u8)Value;
889 break;
890 case ODM_CMNINFO_BINHCT_TEST:
891 pDM_Odm->bInHctTest = (bool)Value;
892 break;
893 case ODM_CMNINFO_BWIFI_TEST:
894 pDM_Odm->bWIFITest = (bool)Value;
895 break;
896
897 case ODM_CMNINFO_SMART_CONCURRENT:
898 pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
899 break;
900
901
902 default:
903
904 break;
905 }
906
907}
908
909
910void ODM_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, void *pValue)
911{
912
913
914
915 switch (CmnInfo) {
916
917
918
919 case ODM_CMNINFO_MAC_PHY_MODE:
920 pDM_Odm->pMacPhyMode = pValue;
921 break;
922
923 case ODM_CMNINFO_TX_UNI:
924 pDM_Odm->pNumTxBytesUnicast = pValue;
925 break;
926
927 case ODM_CMNINFO_RX_UNI:
928 pDM_Odm->pNumRxBytesUnicast = pValue;
929 break;
930
931 case ODM_CMNINFO_WM_MODE:
932 pDM_Odm->pwirelessmode = pValue;
933 break;
934
935 case ODM_CMNINFO_SEC_CHNL_OFFSET:
936 pDM_Odm->pSecChOffset = pValue;
937 break;
938
939 case ODM_CMNINFO_SEC_MODE:
940 pDM_Odm->pSecurity = pValue;
941 break;
942
943 case ODM_CMNINFO_BW:
944 pDM_Odm->pBandWidth = pValue;
945 break;
946
947 case ODM_CMNINFO_CHNL:
948 pDM_Odm->pChannel = pValue;
949 break;
950
951 case ODM_CMNINFO_DMSP_GET_VALUE:
952 pDM_Odm->pbGetValueFromOtherMac = pValue;
953 break;
954
955 case ODM_CMNINFO_BUDDY_ADAPTOR:
956 pDM_Odm->pBuddyAdapter = pValue;
957 break;
958
959 case ODM_CMNINFO_DMSP_IS_MASTER:
960 pDM_Odm->pbMasterOfDMSP = pValue;
961 break;
962
963 case ODM_CMNINFO_SCAN:
964 pDM_Odm->pbScanInProcess = pValue;
965 break;
966
967 case ODM_CMNINFO_POWER_SAVING:
968 pDM_Odm->pbPowerSaving = pValue;
969 break;
970
971 case ODM_CMNINFO_ONE_PATH_CCA:
972 pDM_Odm->pOnePathCCA = pValue;
973 break;
974
975 case ODM_CMNINFO_DRV_STOP:
976 pDM_Odm->pbDriverStopped = pValue;
977 break;
978
979 case ODM_CMNINFO_PNP_IN:
980 pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = pValue;
981 break;
982
983 case ODM_CMNINFO_INIT_ON:
984 pDM_Odm->pinit_adpt_in_progress = pValue;
985 break;
986
987 case ODM_CMNINFO_ANT_TEST:
988 pDM_Odm->pAntennaTest = pValue;
989 break;
990
991 case ODM_CMNINFO_NET_CLOSED:
992 pDM_Odm->pbNet_closed = pValue;
993 break;
994
995 case ODM_CMNINFO_FORCED_RATE:
996 pDM_Odm->pForcedDataRate = pValue;
997 break;
998
999 case ODM_CMNINFO_FORCED_IGI_LB:
1000 pDM_Odm->pu1ForcedIgiLb = pValue;
1001 break;
1002
1003 case ODM_CMNINFO_MP_MODE:
1004 pDM_Odm->mp_mode = pValue;
1005 break;
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026 default:
1027
1028 break;
1029 }
1030
1031}
1032
1033
1034void ODM_CmnInfoPtrArrayHook(
1035 struct dm_odm_t *pDM_Odm,
1036 enum odm_cmninfo_e CmnInfo,
1037 u16 Index,
1038 void *pValue
1039)
1040{
1041
1042
1043
1044 switch (CmnInfo) {
1045
1046
1047
1048 case ODM_CMNINFO_STA_STATUS:
1049 pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
1050 break;
1051
1052 default:
1053
1054 break;
1055 }
1056
1057}
1058
1059
1060
1061
1062
1063void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value)
1064{
1065
1066
1067
1068 switch (CmnInfo) {
1069 case ODM_CMNINFO_LINK_IN_PROGRESS:
1070 pDM_Odm->bLinkInProcess = (bool)Value;
1071 break;
1072
1073 case ODM_CMNINFO_ABILITY:
1074 pDM_Odm->SupportAbility = (u32)Value;
1075 break;
1076
1077 case ODM_CMNINFO_WIFI_DIRECT:
1078 pDM_Odm->bWIFI_Direct = (bool)Value;
1079 break;
1080
1081 case ODM_CMNINFO_WIFI_DISPLAY:
1082 pDM_Odm->bWIFI_Display = (bool)Value;
1083 break;
1084
1085 case ODM_CMNINFO_LINK:
1086 pDM_Odm->bLinked = (bool)Value;
1087 break;
1088
1089 case ODM_CMNINFO_STATION_STATE:
1090 pDM_Odm->bsta_state = (bool)Value;
1091 break;
1092
1093 case ODM_CMNINFO_RSSI_MIN:
1094 pDM_Odm->RSSI_Min = (u8)Value;
1095 break;
1096
1097 case ODM_CMNINFO_RA_THRESHOLD_HIGH:
1098 pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
1099 break;
1100
1101 case ODM_CMNINFO_RA_THRESHOLD_LOW:
1102 pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
1103 break;
1104
1105 case ODM_CMNINFO_BT_ENABLED:
1106 pDM_Odm->bBtEnabled = (bool)Value;
1107 break;
1108
1109 case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
1110 pDM_Odm->bBtConnectProcess = (bool)Value;
1111 break;
1112
1113 case ODM_CMNINFO_BT_HS_RSSI:
1114 pDM_Odm->btHsRssi = (u8)Value;
1115 break;
1116
1117 case ODM_CMNINFO_BT_OPERATION:
1118 pDM_Odm->bBtHsOperation = (bool)Value;
1119 break;
1120
1121 case ODM_CMNINFO_BT_LIMITED_DIG:
1122 pDM_Odm->bBtLimitedDig = (bool)Value;
1123 break;
1124
1125 case ODM_CMNINFO_BT_DISABLE_EDCA:
1126 pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
1127 break;
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154 default:
1155
1156 break;
1157 }
1158
1159
1160}
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198