import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6620 / wlan / nic / nic.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic.c#2 $
3 */
4
5 /*! \file nic.c
6 \brief Functions that provide operation in NIC's (Network Interface Card) point of view.
7
8 This file includes functions which unite multiple hal(Hardware) operations
9 and also take the responsibility of Software Resource Management in order
10 to keep the synchronization with Hardware Manipulation.
11 */
12
13
14
15 /*
16 ** $Log: nic.c $
17 *
18 * 07 17 2012 yuche.tsai
19 * NULL
20 * Compile no error before trial run.
21 *
22 * 05 02 2012 terry.wu
23 * NULL
24 * Set the default value of AP StaRec index to "STA_REC_INDEX_NOT_FOUND" in update firmware bss command.
25 *
26 * 03 02 2012 terry.wu
27 * NULL
28 * Sync CFG80211 modification from branch 2,2.
29 *
30 * 11 28 2011 cp.wu
31 * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment when returining to ROM code
32 * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
33 * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
34 *
35 * 11 22 2011 tsaiyuan.hsu
36 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
37 * keep debug counter setting after wake up.
38 *
39 * 11 19 2011 yuche.tsai
40 * NULL
41 * Update RSSI for P2P.
42 *
43 * 11 18 2011 yuche.tsai
44 * NULL
45 * CONFIG P2P support RSSI query, default turned off.
46 *
47 * 11 07 2011 tsaiyuan.hsu
48 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
49 * add debug counters and periodically dump counters for debugging.
50 *
51 * 11 04 2011 cp.wu
52 * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
53 * pre-check for NULL before calling MMPDU free function
54 *
55 * 11 03 2011 wh.su
56 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
57 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
58 *
59 * 11 01 2011 chinglan.wang
60 * NULL
61 * Modify the Wi-Fi method of the flush TX queue when disconnect the AP.
62 * If disconnect the AP and flush all the data frame in the TX queue, WPS cannot do the 4-way handshake to connect to the AP..
63 *
64 * 10 11 2011 terry.wu
65 * NULL
66 * Rewrite Assert Dump Function for Portability.
67 *
68 * 09 20 2011 cm.chang
69 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
70 * New CMD definition about RLM parameters
71 *
72 * 08 15 2011 cp.wu
73 * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
74 * reuse firmware download logic of MT6620 for MT6628.
75 *
76 * 08 03 2011 terry.wu
77 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
78 * Reply Probe Rsp in FW for Hotspot Mode.
79 *
80 *
81 *
82 * 08 03 2011 terry.wu
83 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
84 * Reply Probe Rsp in FW for Hotspot Mode.
85 *
86 *
87 * 08 03 2011 terry.wu
88 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
89 * Reply Probe Rsp in FW for Hotspot Mode.
90 *
91 * 08 03 2011 terry.wu
92 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
93 * Reply Probe Rsp in FW for Hotspot Mode.
94 *
95 * 08 02 2011 yuche.tsai
96 * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting device issue.
97 * Fix GO send deauth frame issue.
98 *
99 * 07 18 2011 chinghwa.yu
100 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
101 * Add CMD/Event for RDD and BWCS.
102 *
103 * 07 11 2011 wh.su
104 * [WCXRP00000849] [MT6620 Wi-Fi][Driver] Remove some of the WAPI define for make sure the value is initialize, for customer not enable WAPI
105 * For make sure wapi initial value is set.
106 *
107 * 06 27 2011 cp.wu
108 * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
109 * 1. correct logic
110 * 2. replace only BSS-DESC which doesn't have a valid SSID.
111 *
112 * 06 27 2011 cp.wu
113 * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
114 * allow to have a single BSSID with multiple SSID to be presented in scanning result
115 *
116 * 05 12 2011 puff.wen
117 * NULL
118 * FW Assert information dump to driver
119 *
120 * 04 18 2011 terry.wu
121 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
122 * Remove flag CFG_WIFI_DIRECT_MOVED.
123 *
124 * 04 15 2011 cp.wu
125 * [WCXRP00000651] [MT6620 Wi-Fi][Driver] Refine RSSI buffering mechanism
126 * ROLLBACK due to the special design is to workaround incorrect initial RCPI value coming from firmware domain.
127 *
128 * 04 14 2011 cm.chang
129 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
130 * .
131 *
132 * 04 14 2011 cp.wu
133 * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
134 * 1. add code to put whole-chip resetting trigger when abnormal firmware assertion is detected
135 * 2. add dummy function for both Win32 and Linux part.
136 *
137 * 04 12 2011 cp.wu
138 * [WCXRP00000635] [MT6620 Wi-Fi][Driver] Clear pending security frames when QM clear pending data frames for dedicated network type
139 * clear pending security frames for dedicated network type when BSS is being deactivated/disconnected
140 *
141 * 04 12 2011 wh.su
142 * NULL
143 * enable the p2p check the cipher to set the bssInfo auth mode.
144 *
145 * 04 12 2011 wh.su
146 * NULL
147 * prepare the code for sync the auth mode and encryption status for P2P and BOW.
148 *
149 * 04 11 2011 yuche.tsai
150 * [WCXRP00000627] [Volunteer Patch][MT6620][Driver] Pending MMPUD of P2P Network may crash system issue.
151 * Fix kernel panic issue when MMPDU of P2P is pending in driver.
152 *
153 * 04 10 2011 george.huang
154 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
155 * Fix compiler issue.
156 *
157 * 04 08 2011 george.huang
158 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
159 * separate settings of P2P and AIS
160 *
161 * 04 08 2011 eddie.chen
162 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
163 * Fix for sigma
164 *
165 * 04 07 2011 cp.wu
166 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
167 * .
168 *
169 * 04 07 2011 cp.wu
170 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
171 * implementation of internal error handling of nicAllocateAdapterMemory.
172 *
173 * 03 31 2011 chinglan.wang
174 * [WCXRP00000613] [MT6620 Wi-Fi] [FW] [Driver] BssInfo can get the security mode which is WPA/WPA2/WAPI or not.
175 * .
176 *
177 * 03 21 2011 cp.wu
178 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
179 * portability improvement
180 *
181 * 03 17 2011 cp.wu
182 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
183 * use pre-allocated buffer for storing enhanced interrupt response as well
184 *
185 * 03 16 2011 cp.wu
186 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
187 * 1. pre-allocate physical continuous buffer while module is being loaded
188 * 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
189 *
190 * The windows part remained the same as before, but added similiar APIs to hide the difference.
191 *
192 * 03 15 2011 cp.wu
193 * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous memory consumption
194 * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
195 * 2. Use common coalescing buffer for both TX/RX directions
196 *
197 *
198 * 03 10 2011 cm.chang
199 * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
200 * Add some functions to let AIS/Tethering or AIS/BOW be the same channel
201 *
202 * 03 07 2011 terry.wu
203 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
204 * Toggle non-standard debug messages to comments.
205 *
206 * 03 02 2011 cp.wu
207 * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after connection is built.
208 * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
209 *
210 * 02 08 2011 terry.wu
211 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
212 * Use kalPrint to print firmware assert info.
213 *
214 * 02 01 2011 terry.wu
215 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
216 * .
217 *
218 * 02 01 2011 cm.chang
219 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
220 * .
221 *
222 * 01 31 2011 terry.wu
223 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
224 * Print firmware ASSERT info at Android kernel log, driver side
225 *
226 * 01 27 2011 tsaiyuan.hsu
227 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
228 * add roaming fsm
229 * 1. not support 11r, only use strength of signal to determine roaming.
230 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
231 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
232 * 4. assume that change of link quality in smooth way.
233 *
234 * 01 26 2011 cm.chang
235 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
236 * Allocate system RAM if fixed message or mgmt buffer is not available
237 *
238 * 01 24 2011 cp.wu
239 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
240 * 1. add an extra counter for tracking pending forward frames.
241 * 2. notify TX service thread as well when there is pending forward frame
242 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
243 *
244 * 01 19 2011 cp.wu
245 * [WCXRP00000372] [MT6620 Wi-Fi][Driver] Check bus access failure inside nicProcessIST()
246 * check bus error and/or card removal when retrieving interrupt status from HAL
247 *
248 * 01 04 2011 cp.wu
249 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
250 * 1) correct typo in scan.c
251 * 2) TX descriptors, RX descriptos and management buffer should use virtually continous buffer instead of physically contineous one
252 *
253 * 01 04 2011 cp.wu
254 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
255 * separate kalMemAlloc() into virtually-continous and physically-continous type to ease slab system pressure
256 *
257 * 12 30 2010 cp.wu
258 * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
259 * host driver not to set FW-own when there is still pending interrupts
260 *
261 * 12 17 2010 cp.wu
262 * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
263 * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
264 *
265 * 12 07 2010 cm.chang
266 * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
267 * 1. BSSINFO include RLM parameter
268 * 2. free all sta records when network is disconnected
269 *
270 * 12 02 2010 eddie.chen
271 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
272 * Add more control value but dont use it now.
273 *
274 * 11 30 2010 eddie.chen
275 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
276 * Add auto rate check window in registry
277 *
278 * 11 10 2010 eddie.chen
279 * [WCXRP00000156] [MT6620][FW] Change Auto rate window to 64 and add throughput swcr
280 * Use autorate parameter 1 as phy rate mask.
281 *
282 * 11 08 2010 cp.wu
283 * [WCXRP00000166] [MT6620 Wi-Fi][Driver] use SDIO CMD52 for enabling/disabling interrupt to reduce transaction period
284 * change to use CMD52 for enabling/disabling interrupt to reduce SDIO transaction time
285 *
286 * 10 26 2010 eddie.chen
287 * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
288 * Add auto rate parameter in registry.
289 *
290 * 10 18 2010 cp.wu
291 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
292 * 1. remove redundant variables in STA_REC structure
293 * 2. add STA-REC uninitialization routine for clearing pending events
294 *
295 * 10 18 2010 cp.wu
296 * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
297 * reset ptrs when IEs are going to be dropped
298 *
299 * 10 12 2010 cp.wu
300 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
301 * add HT (802.11n) fixed rate support.
302 *
303 * 10 08 2010 cp.wu
304 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
305 * adding fixed rate support for distance test. (from registry setting)
306 *
307 * 10 07 2010 cp.wu
308 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
309 * add firmware download for MT5931.
310 *
311 * 10 05 2010 cp.wu
312 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
313 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
314 *
315 * 10 04 2010 cp.wu
316 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
317 * remove ENUM_NETWORK_TYPE_T definitions
318 *
319 * 09 21 2010 cp.wu
320 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
321 * Do a complete reset with STA-REC null checking for RF test re-entry
322 *
323 * 09 08 2010 cp.wu
324 * NULL
325 * use static memory pool for storing IEs of scanning result.
326 *
327 * 09 06 2010 cp.wu
328 * NULL
329 * Androi/Linux: return current operating channel information
330 *
331 * 09 01 2010 cp.wu
332 * NULL
333 * HIFSYS Clock Source Workaround
334 *
335 * 08 26 2010 yuche.tsai
336 * NULL
337 * Fix someones coding error while enable WIFI_DIRECT.
338 *
339 * 08 25 2010 george.huang
340 * NULL
341 * update OID/ registry control path for PM related settings
342 *
343 * 08 24 2010 cm.chang
344 * NULL
345 * Support RLM initail channel of Ad-hoc, P2P and BOW
346 *
347 * 08 24 2010 chinghwa.yu
348 * NULL
349 * Update BOW for the 1st time.
350 *
351 * 08 23 2010 chinghwa.yu
352 * NULL
353 * Update for BOW.
354 *
355 * 08 20 2010 yuche.tsai
356 * NULL
357 * Add state change indication.
358 *
359 * 08 16 2010 yuche.tsai
360 * NULL
361 * Add support for P2P BSS update info.
362 *
363 * 08 12 2010 cp.wu
364 * NULL
365 * [removing debugging] not to dump beacon content.
366 *
367 * 08 12 2010 cp.wu
368 * NULL
369 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
370 *
371 * 08 11 2010 cp.wu
372 * NULL
373 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
374 * 2) extending scanning result to 64 instead of 48
375 *
376 * 08 04 2010 yarco.yang
377 * NULL
378 * Add TX_AMPDU and ADDBA_REJECT command
379 *
380 * 08 03 2010 cp.wu
381 * NULL
382 * surpress compilation warning.
383 *
384 * 08 03 2010 cp.wu
385 * NULL
386 * Centralize mgmt/system service procedures into independent calls.
387 *
388 * 07 28 2010 cp.wu
389 * NULL
390 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
391 * 2) change nicMediaStateChange() API prototype
392 *
393 * 07 28 2010 cp.wu
394 * NULL
395 * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
396 *
397 * 07 24 2010 wh.su
398 *
399 * .support the Wi-Fi RSN
400 *
401 * 07 23 2010 cp.wu
402 *
403 * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
404 *
405 * 07 22 2010 george.huang
406 *
407 * .
408 *
409 * 07 22 2010 george.huang
410 *
411 * Update fgIsQoS information in BSS INFO by CMD
412 *
413 * 07 19 2010 cp.wu
414 *
415 * [WPD00003833] [MT6620 and MT5931] Driver migration.
416 * Add Ad-Hoc support to AIS-FSM
417 *
418 * 07 14 2010 yarco.yang
419 *
420 * 1. Remove CFG_MQM_MIGRATION
421 * 2. Add CMD_UPDATE_WMM_PARMS command
422 *
423 * 07 08 2010 cp.wu
424 *
425 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
426 *
427 * 07 07 2010 cp.wu
428 * [WPD00003833][MT6620 and MT5931] Driver migration
429 * update prStaRecOfAP with BSS-INFO.
430 *
431 * 07 06 2010 george.huang
432 * [WPD00001556]Basic power managemenet function
433 * Update arguments for nicUpdateBeaconIETemplate()
434 *
435 * 07 06 2010 cp.wu
436 * [WPD00003833][MT6620 and MT5931] Driver migration
437 * STA-REC is maintained by CNM only.
438 *
439 * 07 05 2010 cp.wu
440 * [WPD00003833][MT6620 and MT5931] Driver migration
441 * 1) ignore RSN checking when RSN is not turned on.
442 * 2) set STA-REC deactivation callback as NULL
443 * 3) add variable initialization API based on PHY configuration
444 *
445 * 07 01 2010 cm.chang
446 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
447 * Support sync command of STA_REC
448 *
449 * 06 30 2010 cp.wu
450 * [WPD00003833][MT6620 and MT5931] Driver migration
451 * sync. with CMD/EVENT document ver0.07.
452 *
453 * 06 29 2010 cp.wu
454 * [WPD00003833][MT6620 and MT5931] Driver migration
455 * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
456 *
457 * 06 29 2010 cp.wu
458 * [WPD00003833][MT6620 and MT5931] Driver migration
459 * 1) sync to. CMD/EVENT document v0.03
460 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
461 * 3) send command packet to indicate FW-PM after
462 * a) 1st beacon is received after AIS has connected to an AP
463 * b) IBSS-ALONE has been created
464 * c) IBSS-MERGE has occured
465 *
466 * 06 25 2010 george.huang
467 * [WPD00001556]Basic power managemenet function
468 * Create beacon update path, with expose bssUpdateBeaconContent()
469 *
470 * 06 22 2010 cp.wu
471 * [WPD00003833][MT6620 and MT5931] Driver migration
472 * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
473 *
474 * 06 22 2010 cp.wu
475 * [WPD00003833][MT6620 and MT5931] Driver migration
476 * 1) add command warpper for STA-REC/BSS-INFO sync.
477 * 2) enhance command packet sending procedure for non-oid part
478 * 3) add command packet definitions for STA-REC/BSS-INFO sync.
479 *
480 * 06 21 2010 cp.wu
481 * [WPD00003833][MT6620 and MT5931] Driver migration
482 * implement TX_DONE callback path.
483 *
484 * 06 21 2010 wh.su
485 * [WPD00003840][MT6620 5931] Security migration
486 * remove duplicate variable for migration.
487 *
488 * 06 21 2010 cp.wu
489 * [WPD00003833][MT6620 and MT5931] Driver migration
490 * TX descriptors are now allocated once for reducing allocation overhead
491 *
492 * 06 18 2010 cm.chang
493 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
494 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
495 *
496 * 06 11 2010 cp.wu
497 * [WPD00003833][MT6620 and MT5931] Driver migration
498 * 1) migrate assoc.c.
499 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
500 * 3) add configuration options for CNM_MEM and RSN modules
501 * 4) add data path for management frames
502 * 5) eliminate rPacketInfo of MSDU_INFO_T
503 *
504 * 06 10 2010 cp.wu
505 * [WPD00003833][MT6620 and MT5931] Driver migration
506 * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
507 * 2) when disconnected, indicate nic directly (no event is needed)
508 *
509 * 06 06 2010 kevin.huang
510 * [WPD00003832][MT6620 5931] Create driver base
511 * [MT6620 5931] Create driver base
512 *
513 * 04 26 2010 cp.wu
514 * [WPD00001943]Create WiFi test driver framework on WinXP
515 * 1) surpress compiler warning
516 * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
517 *
518 * 04 23 2010 cp.wu
519 * [WPD00001943]Create WiFi test driver framework on WinXP
520 * surpress compiler warning
521 *
522 * 04 13 2010 cp.wu
523 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
524 * add framework for BT-over-Wi-Fi support.
525 * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
526 * * * * * * * * * * * * * 2) command sequence number is now increased atomically
527 * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
528 *
529 * 04 12 2010 cp.wu
530 * [WPD00001943]Create WiFi test driver framework on WinXP
531 * add channel frequency <-> number conversion
532 *
533 * 04 06 2010 cp.wu
534 * [WPD00001943]Create WiFi test driver framework on WinXP
535 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
536 *
537 * 04 06 2010 cp.wu
538 * [WPD00003827][MT6620 Wi-Fi] Chariot fail and following ping fail, no pkt send from driver
539 * correct nicProcessIST_impl() for interrupt status brought up by RX enhanced response
540 *
541 * 03 19 2010 cp.wu
542 * [WPD00001943]Create WiFi test driver framework on WinXP
543 * 1) add ACPI D0/D3 state switching support
544 * * * * * * * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
545 *
546 * 03 17 2010 cp.wu
547 * [WPD00001943]Create WiFi test driver framework on WinXP
548 * always process TX interrupt first then RX interrupt.
549 *
550 * 02 25 2010 cp.wu
551 * [WPD00001943]Create WiFi test driver framework on WinXP
552 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
553 *
554 * 02 23 2010 cp.wu
555 * [WPD00001943]Create WiFi test driver framework on WinXP
556 * add checksum offloading support.
557 ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-12-16 18:03:43 GMT mtk02752
558 ** handling enhanced response which fields are fetched at different moments
559 ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-12-15 17:00:29 GMT mtk02752
560 ** if RX enhanced response is used, D2H interrupt status should be coming from buffered result as well
561 ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-12-15 12:01:55 GMT mtk02752
562 ** if TX_DONE bit is not set but WTSR0/WTSR1 is non-zero, then set TX_DONE bit due to time latency of interrupt status enhanced response
563 ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:52:52 GMT mtk02752
564 ** code clean
565 ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-24 20:51:01 GMT mtk02752
566 ** integrate with SD1 by invoking qmHandleMailboxRxMessage()
567 ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-16 17:32:33 GMT mtk02752
568 ** prepare code for invoking rxHandleMailboxRxMessage()
569 ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:08 GMT mtk01084
570 ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-09 22:56:41 GMT mtk01084
571 ** modify HW access routines
572 ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:20 GMT mtk01084
573 ** prevent warning
574 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
575 ** init HIF
576 ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:30 GMT mtk01084
577 ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:12 GMT mtk01084
578 ** update for new HW design
579 ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-09-09 17:26:15 GMT mtk01084
580 ** modify for CFG_TEST_WITH_MT5921
581 ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-19 10:55:22 GMT mtk01461
582 ** Unmask the unused HISR
583 ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-18 15:59:13 GMT mtk01084
584 ** remove debug purpose code
585 ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 14:05:02 GMT mtk01084
586 ** update for WIFI ownback part on initial
587 ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-04 21:32:57 GMT mtk01084
588 ** add temporarily code to set driver own on adapter initialization
589 ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:35:41 GMT mtk01461
590 ** Add init of TX aggregation and fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode
591 ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-24 21:12:10 GMT mtk01104
592 ** Add function nicRestoreSpiDefMode()
593 ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-21 09:43:31 GMT mtk01461
594 ** Revise for MTK coding style - nicInitializeAdapter()
595 ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-17 19:52:47 GMT mtk01461
596 ** Update allocate Adapter Memory for MGMT Memory pool
597 ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:57:08 GMT mtk01461
598 ** Refine the order of release memory from pucRxCoalescingBufCached
599 ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-19 18:32:57 GMT mtk01084
600 ** update for basic power management functions
601 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:00:14 GMT mtk01426
602 ** Add CFG_SDIO_RX_ENHANCE support
603 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:10:27 GMT mtk01461
604 ** Update TX PATH API
605 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:25:59 GMT mtk01426
606 ** Init for develop
607 **
608 */
609
610 /*******************************************************************************
611 * C O M P I L E R F L A G S
612 ********************************************************************************
613 */
614
615 /*******************************************************************************
616 * E X T E R N A L R E F E R E N C E S
617 ********************************************************************************
618 */
619 #include "precomp.h"
620
621
622 /*******************************************************************************
623 * C O N S T A N T S
624 ********************************************************************************
625 */
626 const UINT_8 aucPhyCfg2PhyTypeSet[PHY_CONFIG_NUM] = {
627 PHY_TYPE_SET_802_11ABG, /* PHY_CONFIG_802_11ABG */
628 PHY_TYPE_SET_802_11BG, /* PHY_CONFIG_802_11BG */
629 PHY_TYPE_SET_802_11G, /* PHY_CONFIG_802_11G */
630 PHY_TYPE_SET_802_11A, /* PHY_CONFIG_802_11A */
631 PHY_TYPE_SET_802_11B, /* PHY_CONFIG_802_11B */
632 PHY_TYPE_SET_802_11ABGN, /* PHY_CONFIG_802_11ABGN */
633 PHY_TYPE_SET_802_11BGN, /* PHY_CONFIG_802_11BGN */
634 PHY_TYPE_SET_802_11AN, /* PHY_CONFIG_802_11AN */
635 PHY_TYPE_SET_802_11GN /* PHY_CONFIG_802_11GN */
636 };
637
638 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
639 #define REQ_GATING_ENABLE_H2D_INT BIT(31)
640 #define REQ_GATING_DISABLE_H2D_INT BIT(30)
641 #define ACK_GATING_ENABLE_D2H_INT BIT(31)
642 #define ACK_GATING_DISABLE_D2H_INT BIT(30)
643
644 #define GATING_CONTROL_POLL_LIMIT 64
645 #endif
646
647 /*******************************************************************************
648 * D A T A T Y P E S
649 ********************************************************************************
650 */
651
652 /*******************************************************************************
653 * P U B L I C D A T A
654 ********************************************************************************
655 */
656
657 static INT_EVENT_MAP_T arIntEventMapTable[] = {
658 {WHISR_ABNORMAL_INT, INT_EVENT_ABNORMAL},
659 {WHISR_D2H_SW_INT, INT_EVENT_SW_INT},
660 {WHISR_TX_DONE_INT, INT_EVENT_TX},
661 {(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT), INT_EVENT_RX}
662 };
663
664 static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
665
666 static IST_EVENT_FUNCTION apfnEventFuncTable[] = {
667 nicProcessAbnormalInterrupt, /*!< INT_EVENT_ABNORMAL */
668 nicProcessSoftwareInterrupt, /*!< INT_EVENT_SW_INT */
669 nicProcessTxInterrupt, /*!< INT_EVENT_TX */
670 nicProcessRxInterrupt, /*!< INT_EVENT_RX */
671 };
672
673 /*******************************************************************************
674 * P R I V A T E D A T A
675 ********************************************************************************
676 */
677
678 /*******************************************************************************
679 * M A C R O S
680 ********************************************************************************
681 */
682 /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
683 * and also enhance the readability.
684 */
685 #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
686 { \
687 DBGLOG(INIT, INFO, ("Allocating %ld bytes for %s.\n", u4Size, pucComment)); \
688 if ((pucMem = (PUINT_8)kalMemAlloc(u4Size, eMemType)) == (PUINT_8)NULL) { \
689 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for %s.\n", u4Size, pucComment)); \
690 break; \
691 } \
692 ASSERT(((UINT_32)pucMem % 4) == 0); \
693 DBGLOG(INIT, INFO, ("Virtual Address = %08lx for %s.\n", (UINT_32)pucMem, pucComment)); \
694 }
695
696
697
698 /*******************************************************************************
699 * F U N C T I O N D E C L A R A T I O N S
700 ********************************************************************************
701 */
702
703 /*******************************************************************************
704 * F U N C T I O N S
705 ********************************************************************************
706 */
707
708
709 /*----------------------------------------------------------------------------*/
710 /*!
711 * @brief This routine is responsible for the allocation of the data structures
712 * inside the Adapter structure, include:
713 * 1. SW_RFB_Ts
714 * 2. Common coalescing buffer for TX PATH.
715 *
716 * @param prAdapter Pointer of Adapter Data Structure
717 *
718 * @retval WLAN_STATUS_SUCCESS - Has enough memory.
719 * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
720 */
721 /*----------------------------------------------------------------------------*/
722 WLAN_STATUS nicAllocateAdapterMemory(IN P_ADAPTER_T prAdapter)
723 {
724 WLAN_STATUS status = WLAN_STATUS_RESOURCES;
725 P_RX_CTRL_T prRxCtrl;
726 P_TX_CTRL_T prTxCtrl;
727
728 DEBUGFUNC("nicAllocateAdapterMemory");
729
730 ASSERT(prAdapter);
731 prRxCtrl = &prAdapter->rRxCtrl;
732 prTxCtrl = &prAdapter->rTxCtrl;
733
734 do {
735 /* 4 <0> Reset all Memory Handler */
736 #if CFG_DBG_MGT_BUF
737 prAdapter->u4MemFreeDynamicCount = 0;
738 prAdapter->u4MemAllocDynamicCount = 0;
739 #endif
740 prAdapter->pucMgtBufCached = (PUINT_8) NULL;
741 prRxCtrl->pucRxCached = (PUINT_8) NULL;
742 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T) NULL;
743
744
745 /* 4 <1> Memory for Management Memory Pool and CMD_INFO_T */
746 /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
747 prAdapter->u4MgtBufCachedSize = MGT_BUFFER_SIZE;
748
749 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
750 prAdapter->u4MgtBufCachedSize,
751 VIR_MEM_TYPE, "COMMON MGMT MEMORY POOL");
752
753 /* 4 <2> Memory for RX Descriptor */
754 /* Initialize the number of rx buffers we will have in our queue. */
755 /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
756 * this variable directly.
757 */
758 /* Allocate memory for the SW receive structures. */
759 prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * ALIGN_4(sizeof(SW_RFB_T));
760
761 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached,
762 prRxCtrl->u4RxCachedSize, VIR_MEM_TYPE, "SW_RFB_T");
763
764 /* 4 <3> Memory for TX DEscriptor */
765 prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * ALIGN_4(sizeof(MSDU_INFO_T));
766
767 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached,
768 prTxCtrl->u4TxCachedSize, VIR_MEM_TYPE, "MSDU_INFO_T");
769
770 /* 4 <4> Memory for Common Coalescing Buffer */
771 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
772 prAdapter->pucCoalescingBufCached = (PUINT_8) NULL;
773
774 /* Allocate memory for the common coalescing buffer. */
775 prAdapter->u4CoalescingBufCachedSize =
776 CFG_COALESCING_BUFFER_SIZE >
777 CFG_RX_COALESCING_BUFFER_SIZE ? CFG_COALESCING_BUFFER_SIZE :
778 CFG_RX_COALESCING_BUFFER_SIZE;
779
780 prAdapter->pucCoalescingBufCached =
781 kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
782
783 if (prAdapter->pucCoalescingBufCached == NULL) {
784 DBGLOG(INIT, ERROR,
785 ("Could not allocate %ld bytes for coalescing buffer.\n",
786 prAdapter->u4CoalescingBufCachedSize));
787 break;
788 }
789 #endif /* CFG_COALESCING_BUFFER_SIZE */
790
791 /* 4 <5> Memory for enhanced interrupt response */
792 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
793 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
794
795 if (prAdapter->prSDIOCtrl == NULL) {
796 DBGLOG(INIT, ERROR,
797 ("Could not allocate %ld bytes for interrupt response.\n",
798 sizeof(ENHANCE_MODE_DATA_STRUCT_T)));
799 break;
800 }
801
802 status = WLAN_STATUS_SUCCESS;
803
804 }
805 while (FALSE);
806
807 if (status != WLAN_STATUS_SUCCESS) {
808 nicReleaseAdapterMemory(prAdapter);
809 }
810
811 return status;
812
813 } /* end of nicAllocateAdapterMemory() */
814
815
816 /*----------------------------------------------------------------------------*/
817 /*!
818 * @brief This routine is responsible for releasing the allocated memory by
819 * nicAllocatedAdapterMemory().
820 *
821 * @param prAdapter Pointer of Adapter Data Structure
822 *
823 * @return (none)
824 */
825 /*----------------------------------------------------------------------------*/
826 VOID nicReleaseAdapterMemory(IN P_ADAPTER_T prAdapter)
827 {
828 P_TX_CTRL_T prTxCtrl;
829 P_RX_CTRL_T prRxCtrl;
830
831 ASSERT(prAdapter);
832 prTxCtrl = &prAdapter->rTxCtrl;
833 prRxCtrl = &prAdapter->rRxCtrl;
834
835 /* 4 <5> Memory for enhanced interrupt response */
836 if (prAdapter->prSDIOCtrl) {
837 kalReleaseIOBuffer((PVOID) prAdapter->prSDIOCtrl,
838 sizeof(ENHANCE_MODE_DATA_STRUCT_T));
839 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T) NULL;
840 }
841 /* 4 <4> Memory for Common Coalescing Buffer */
842 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
843 if (prAdapter->pucCoalescingBufCached) {
844 kalReleaseIOBuffer((PVOID) prAdapter->pucCoalescingBufCached,
845 prAdapter->u4CoalescingBufCachedSize);
846 prAdapter->pucCoalescingBufCached = (PUINT_8) NULL;
847 }
848 #endif /* CFG_COALESCING_BUFFER_SIZE */
849
850 /* 4 <3> Memory for TX Descriptor */
851 if (prTxCtrl->pucTxCached) {
852 kalMemFree((PVOID) prTxCtrl->pucTxCached, VIR_MEM_TYPE, prTxCtrl->u4TxCachedSize);
853 prTxCtrl->pucTxCached = (PUINT_8) NULL;
854 }
855 /* 4 <2> Memory for RX Descriptor */
856 if (prRxCtrl->pucRxCached) {
857 kalMemFree((PVOID) prRxCtrl->pucRxCached, VIR_MEM_TYPE, prRxCtrl->u4RxCachedSize);
858 prRxCtrl->pucRxCached = (PUINT_8) NULL;
859 }
860 /* 4 <1> Memory for Management Memory Pool */
861 if (prAdapter->pucMgtBufCached) {
862 kalMemFree((PVOID) prAdapter->pucMgtBufCached,
863 VIR_MEM_TYPE, prAdapter->u4MgtBufCachedSize);
864 prAdapter->pucMgtBufCached = (PUINT_8) NULL;
865 }
866 #if CFG_DBG_MGT_BUF
867 /* Check if all allocated memories are free */
868 ASSERT(prAdapter->u4MemFreeDynamicCount == prAdapter->u4MemAllocDynamicCount);
869 #endif
870
871 return;
872 }
873
874
875 /*----------------------------------------------------------------------------*/
876 /*!
877 * @brief disable global interrupt
878 *
879 * @param prAdapter pointer to the Adapter handler
880 *
881 * @return (none)
882 */
883 /*----------------------------------------------------------------------------*/
884 VOID nicDisableInterrupt(IN P_ADAPTER_T prAdapter)
885 {
886 ASSERT(prAdapter);
887
888 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
889
890 prAdapter->fgIsIntEnable = FALSE;
891 }
892
893 /*----------------------------------------------------------------------------*/
894 /*!
895 * @brief enable global interrupt
896 *
897 * @param prAdapter pointer to the Adapter handler
898 *
899 * @return (none)
900 */
901 /*----------------------------------------------------------------------------*/
902 VOID nicEnableInterrupt(IN P_ADAPTER_T prAdapter)
903 {
904 BOOLEAN fgIsIntEnableCache;
905
906
907 ASSERT(prAdapter);
908 fgIsIntEnableCache = prAdapter->fgIsIntEnable;
909
910 prAdapter->fgIsIntEnable = TRUE; /* NOTE(Kevin): It must be placed before MCR GINT write. */
911
912 /* If need enable INT and also set LPOwn at the same time. */
913 if (prAdapter->fgIsIntEnableWithLPOwnSet) {
914 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE; /* NOTE(Kevin): It's better to place it
915 * before MCR GINT write.
916 */
917 /* If INT was enabled, only set LPOwn */
918 if (fgIsIntEnableCache) {
919 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
920 prAdapter->fgIsFwOwn = TRUE;
921 }
922 /* If INT was not enabled, enable it and also set LPOwn now */
923 else {
924 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET |
925 WHLPCR_INT_EN_SET);
926 prAdapter->fgIsFwOwn = TRUE;
927 }
928 }
929 /* If INT was not enabled, enable it now */
930 else if (!fgIsIntEnableCache) {
931 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
932 }
933
934 return;
935 } /* end of nicEnableInterrupt() */
936
937
938 #if CFG_SDIO_INTR_ENHANCE
939 /*----------------------------------------------------------------------------*/
940 /*!
941 * @brief For SDIO enhance mode, set the max rx len and tx status
942 *
943 * @param prAdapter a pointer to adapter private data structure.
944 *
945 * @return - none
946 */
947 /*----------------------------------------------------------------------------*/
948 VOID nicSDIOInit(IN P_ADAPTER_T prAdapter)
949 {
950 UINT_32 u4Value = 0;
951
952 ASSERT(prAdapter);
953
954 /* 4 <1> Check STATUS Buffer is DW alignment. */
955 ASSERT(IS_ALIGN_4((UINT_32) &prAdapter->prSDIOCtrl->u4WHISR));
956
957 /* 4 <2> Setup STATUS count. */
958 {
959 HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
960
961 /* 4 <2.1> Setup the number of maximum RX length to be report */
962 u4Value &= ~(WHCR_MAX_HIF_RX_LEN_NUM);
963 u4Value |= ((SDIO_MAXIMUM_RX_LEN_NUM << WHCR_OFFSET_MAX_HIF_RX_LEN_NUM));
964
965 /* 4 <2.2> Setup RX enhancement mode */
966 #if CFG_SDIO_RX_ENHANCE
967 u4Value |= WHCR_RX_ENHANCE_MODE_EN;
968 #else
969 u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
970 #endif /* CFG_SDIO_RX_AGG */
971
972 HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
973 }
974
975 return;
976
977 } /* end of nicSDIOInit() */
978
979 /*----------------------------------------------------------------------------*/
980 /*!
981 * @brief Read interrupt status from hardware
982 *
983 * @param prAdapter pointer to the Adapter handler
984 * @param the interrupts
985 *
986 * @return N/A
987 *
988 */
989 /*----------------------------------------------------------------------------*/
990 VOID nicSDIOReadIntStatus(IN P_ADAPTER_T prAdapter, OUT PUINT_32 pu4IntStatus)
991 {
992 P_SDIO_CTRL_T prSDIOCtrl;
993
994 DEBUGFUNC("nicSDIOReadIntStatus");
995
996 ASSERT(prAdapter);
997 ASSERT(pu4IntStatus);
998
999 prSDIOCtrl = prAdapter->prSDIOCtrl;
1000 ASSERT(prSDIOCtrl);
1001
1002 HAL_PORT_RD(prAdapter,
1003 MCR_WHISR,
1004 sizeof(ENHANCE_MODE_DATA_STRUCT_T),
1005 (PUINT_8) prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1006
1007 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
1008 *pu4IntStatus = 0;
1009 return;
1010 }
1011
1012 /* workaround */
1013 if ((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
1014 (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
1015 prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
1016 }
1017
1018 if ((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
1019 HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
1020 (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
1021 prSDIOCtrl->u4WHISR |= BIT(31);
1022 }
1023
1024 *pu4IntStatus = prSDIOCtrl->u4WHISR;
1025
1026 return;
1027 } /* end of nicSDIOReadIntStatus() */
1028 #endif
1029
1030 /*----------------------------------------------------------------------------*/
1031 /*!
1032 * @brief The function used to read interrupt status and then invoking
1033 * dispatching procedure for the appropriate functions
1034 * corresponding to specific interrupt bits
1035 *
1036 * @param prAdapter pointer to the Adapter handler
1037 *
1038 * @retval WLAN_STATUS_SUCCESS
1039 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1040 */
1041 /*----------------------------------------------------------------------------*/
1042 WLAN_STATUS nicProcessIST(IN P_ADAPTER_T prAdapter)
1043 {
1044 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1045 UINT_32 u4IntStatus = 0;
1046 UINT_32 i;
1047
1048 DEBUGFUNC("nicProcessIST");
1049 /* DBGLOG(INIT, LOUD, ("\n")); */
1050
1051 ASSERT(prAdapter);
1052
1053 if (prAdapter->rAcpiState == ACPI_STATE_D3) {
1054 DBGLOG(REQ, WARN,
1055 ("Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
1056 prAdapter->rAcpiState, prAdapter->fgIsRadioOff));
1057 return WLAN_STATUS_ADAPTER_NOT_READY;
1058 }
1059 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1060 if (prAdapter->fgIsClockGatingEnabled == TRUE) {
1061 nicDisableClockGating(prAdapter);
1062 }
1063 #endif
1064
1065 for (i = 0; i < CFG_IST_LOOP_COUNT; i++) {
1066
1067 #if CFG_SDIO_INTR_ENHANCE
1068 nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
1069 #else
1070 HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
1071 #endif /* CFG_SDIO_INTR_ENHANCE */
1072
1073 /* DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus)); */
1074
1075 if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
1076 DBGLOG(INTR, WARN, ("Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
1077 (u4IntStatus & ~WHIER_DEFAULT), u4IntStatus,
1078 WHIER_DEFAULT));
1079 u4IntStatus &= WHIER_DEFAULT;
1080 }
1081
1082 nicProcessIST_impl(prAdapter, u4IntStatus);
1083
1084 if (u4IntStatus == 0) {
1085 if (i == 0) {
1086 u4Status = WLAN_STATUS_NOT_INDICATING;
1087 }
1088 break;
1089 }
1090 }
1091
1092 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1093 if (prAdapter->fgIsClockGatingEnabled == FALSE) {
1094 nicEnableClockGating(prAdapter);
1095 }
1096 #endif
1097
1098 return u4Status;
1099 } /* end of nicProcessIST() */
1100
1101
1102 /*----------------------------------------------------------------------------*/
1103 /*!
1104 * @brief The function used to dispatch the appropriate functions for specific
1105 * interrupt bits
1106 *
1107 * @param prAdapter pointer to the Adapter handler
1108 * u4IntStatus interrupt status bits
1109 *
1110 * @retval WLAN_STATUS_SUCCESS
1111 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1112 */
1113 /*----------------------------------------------------------------------------*/
1114 WLAN_STATUS nicProcessIST_impl(IN P_ADAPTER_T prAdapter, IN UINT_32 u4IntStatus)
1115 {
1116 UINT_32 u4IntCount = 0;
1117 P_INT_EVENT_MAP_T prIntEventMap = NULL;
1118
1119 ASSERT(prAdapter);
1120
1121 prAdapter->u4IntStatus = u4IntStatus;
1122
1123 /* Process each of the interrupt status consequently */
1124 prIntEventMap = &arIntEventMapTable[0];
1125 for (u4IntCount = 0; u4IntCount < ucIntEventMapSize; prIntEventMap++, u4IntCount++) {
1126 if (prIntEventMap->u4Int & prAdapter->u4IntStatus) {
1127 if (prIntEventMap->u4Event == INT_EVENT_RX &&
1128 prAdapter->fgIsEnterD3ReqIssued == TRUE) {
1129 /* ignore */
1130 } else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
1131 apfnEventFuncTable[prIntEventMap->u4Event] (prAdapter);
1132 } else {
1133 DBGLOG(INTR, WARN,
1134 ("Empty INTR handler! ISAR bit#: %ld, event:%d, func: 0x%x\n",
1135 prIntEventMap->u4Int, prIntEventMap->u4Event,
1136 apfnEventFuncTable[prIntEventMap->u4Event]));
1137
1138 ASSERT(0); /* to trap any NULL interrupt handler */
1139 }
1140 prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
1141 }
1142 }
1143
1144 return WLAN_STATUS_SUCCESS;
1145 } /* end of nicProcessIST_impl() */
1146
1147
1148 /*----------------------------------------------------------------------------*/
1149 /*!
1150 * @brief Verify the CHIP ID
1151 *
1152 * @param prAdapter a pointer to adapter private data structure.
1153 *
1154 *
1155 * @retval TRUE CHIP ID is the same as the setting compiled
1156 * @retval FALSE CHIP ID is different from the setting compiled
1157 */
1158 /*----------------------------------------------------------------------------*/
1159 BOOL nicVerifyChipID(IN P_ADAPTER_T prAdapter)
1160 {
1161 UINT_32 u4CIR = 0;
1162
1163 ASSERT(prAdapter);
1164
1165 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR);
1166
1167 DBGLOG(INIT, TRACE, ("Chip ID: 0x%x\n", u4CIR & WCIR_CHIP_ID));
1168 DBGLOG(INIT, TRACE, ("Revision ID: 0x%x\n", ((u4CIR & WCIR_REVISION_ID) >> 16)));
1169
1170 if ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV) {
1171 return FALSE;
1172 }
1173
1174 prAdapter->ucRevID = (UINT_8) (((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF);
1175
1176 return TRUE;
1177 }
1178
1179 /*----------------------------------------------------------------------------*/
1180 /*!
1181 * @brief Initialize the MCR to the appropriate init value, and verify the init
1182 * value
1183 *
1184 * @param prAdapter a pointer to adapter private data structure.
1185 *
1186 * @return -
1187 */
1188 /*----------------------------------------------------------------------------*/
1189 VOID nicMCRInit(IN P_ADAPTER_T prAdapter)
1190 {
1191
1192 ASSERT(prAdapter);
1193
1194 /* 4 <0> Initial value */
1195 }
1196
1197 VOID nicHifInit(IN P_ADAPTER_T prAdapter)
1198 {
1199
1200 ASSERT(prAdapter);
1201 #if 0
1202 /* reset event */
1203 nicPutMailbox(prAdapter, 0, 0x52455345); /* RESE */
1204 nicPutMailbox(prAdapter, 1, 0x545F5746); /* T_WF */
1205 nicSetSwIntr(prAdapter, BIT(16));
1206 #endif
1207 }
1208
1209
1210 /*----------------------------------------------------------------------------*/
1211 /*!
1212 * @brief Initialize the Adapter soft variable
1213 *
1214 * @param prAdapter pointer to the Adapter handler
1215 *
1216 * @return (none)
1217 *
1218 */
1219 /*----------------------------------------------------------------------------*/
1220 WLAN_STATUS nicInitializeAdapter(IN P_ADAPTER_T prAdapter)
1221 {
1222 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1223
1224 ASSERT(prAdapter);
1225
1226 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
1227
1228 do {
1229 if (!nicVerifyChipID(prAdapter)) {
1230 u4Status = WLAN_STATUS_FAILURE;
1231 break;
1232 }
1233 /* 4 <1> MCR init */
1234 nicMCRInit(prAdapter);
1235
1236 #if CFG_SDIO_INTR_ENHANCE
1237 nicSDIOInit(prAdapter);
1238 #endif /* CFG_SDIO_INTR_ENHANCE */
1239
1240 HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
1241
1242
1243 /* 4 <2> init FW HIF */
1244 nicHifInit(prAdapter);
1245 }
1246 while (FALSE);
1247
1248
1249 return u4Status;
1250 }
1251
1252
1253 #if defined(_HIF_SPI)
1254 /*----------------------------------------------------------------------------*/
1255 /*!
1256 * \brief Restore the SPI Mode Select to default mode,
1257 * this is important while driver is unload, and this must be last mcr
1258 * since the operation will let the hif use 8bit mode access
1259 *
1260 * \param[in] prAdapter a pointer to adapter private data structure.
1261 * \param[in] eGPIO2_Mode GPIO2 operation mode
1262 *
1263 * \return (none)
1264 */
1265 /*----------------------------------------------------------------------------*/
1266 void nicRestoreSpiDefMode(IN P_ADAPTER_T prAdapter)
1267 {
1268 ASSERT(prAdapter);
1269
1270 HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
1271
1272 }
1273 #endif
1274
1275 /*----------------------------------------------------------------------------*/
1276 /*!
1277 * @brief Process rx interrupt. When the rx
1278 * Interrupt is asserted, it means there are frames in queue.
1279 *
1280 * @param prAdapter Pointer to the Adapter structure.
1281 *
1282 * @return (none)
1283 */
1284 /*----------------------------------------------------------------------------*/
1285 VOID nicProcessAbnormalInterrupt(IN P_ADAPTER_T prAdapter)
1286 {
1287 UINT_32 u4Value;
1288
1289 HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
1290 DBGLOG(REQ, WARN, ("MCR_WASR: 0x%x\n", u4Value));
1291 }
1292
1293 /*----------------------------------------------------------------------------*/
1294 /*!
1295 * @brief .
1296 *
1297 * @param prAdapter Pointer to the Adapter structure.
1298 *
1299 * @return (none)
1300 */
1301 /*----------------------------------------------------------------------------*/
1302 VOID nicProcessFwOwnBackInterrupt(IN P_ADAPTER_T prAdapter)
1303 {
1304
1305 return;
1306 } /* end of nicProcessFwOwnBackInterrupt() */
1307
1308 /*----------------------------------------------------------------------------*/
1309 /*!
1310 * @brief .
1311 *
1312 * @param prAdapter Pointer to the Adapter structure.
1313 *
1314 * @return (none)
1315 */
1316 /*----------------------------------------------------------------------------*/
1317 VOID nicProcessSoftwareInterrupt(IN P_ADAPTER_T prAdapter)
1318 {
1319 UINT_32 u4IntrBits;
1320
1321 ASSERT(prAdapter);
1322
1323 u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
1324
1325 if ((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
1326 nicPrintFirmwareAssertInfo(prAdapter);
1327 #if CFG_CHIP_RESET_SUPPORT
1328 glSendResetRequest();
1329 #endif
1330 }
1331 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1332 ASSERT((u4IntrBits & (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT))
1333 != (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT));
1334
1335 if (u4IntrBits & ACK_GATING_ENABLE_D2H_INT) {
1336 prAdapter->fgIsClockGatingEnabled = TRUE;
1337 }
1338
1339 if (u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
1340 prAdapter->fgIsClockGatingEnabled = FALSE;
1341
1342 /* Indicate Service Thread for TX */
1343 if (kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0
1344 || wlanGetTxPendingFrameCount(prAdapter) > 0) {
1345 kalSetEvent(prAdapter->prGlueInfo);
1346 }
1347 }
1348 #endif
1349
1350 DBGLOG(REQ, WARN, ("u4IntrBits: 0x%x\n", u4IntrBits));
1351
1352 return;
1353 } /* end of nicProcessSoftwareInterrupt() */
1354
1355 VOID nicPutMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, IN UINT_32 u4Data)
1356 {
1357 if (u4MailboxNum == 0) {
1358 HAL_MCR_WR(prAdapter, MCR_H2DSM0R, u4Data);
1359 } else if (u4MailboxNum == 1) {
1360 HAL_MCR_WR(prAdapter, MCR_H2DSM1R, u4Data);
1361 } else {
1362 ASSERT(0);
1363 }
1364 }
1365
1366 VOID nicGetMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, OUT PUINT_32 pu4Data)
1367 {
1368 if (u4MailboxNum == 0) {
1369 HAL_MCR_RD(prAdapter, MCR_D2HRM0R, pu4Data);
1370 } else if (u4MailboxNum == 1) {
1371 HAL_MCR_RD(prAdapter, MCR_D2HRM1R, pu4Data);
1372 } else {
1373 ASSERT(0);
1374 }
1375 }
1376
1377 VOID nicSetSwIntr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4SwIntrBitmap)
1378 {
1379 /* NOTE:
1380 * SW interrup in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
1381 * SW interrupt valid from b0~b15
1382 */
1383 ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
1384 /* DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap)); */
1385
1386 HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
1387 }
1388
1389
1390 /*----------------------------------------------------------------------------*/
1391 /*!
1392 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1393 * with specified sequential number
1394 *
1395 * @param prAdapter Pointer of ADAPTER_T
1396 * ucSeqNum Sequential Number
1397 *
1398 * @retval - P_CMD_INFO_T
1399 */
1400 /*----------------------------------------------------------------------------*/
1401 P_CMD_INFO_T nicGetPendingCmdInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
1402 {
1403 P_QUE_T prCmdQue;
1404 QUE_T rTempCmdQue;
1405 P_QUE_T prTempCmdQue = &rTempCmdQue;
1406 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
1407 P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
1408
1409 GLUE_SPIN_LOCK_DECLARATION();
1410
1411 ASSERT(prAdapter);
1412
1413 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1414
1415 prCmdQue = &prAdapter->rPendingCmdQueue;
1416 QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
1417
1418 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1419 while (prQueueEntry) {
1420 prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
1421
1422 if (prCmdInfo->ucCmdSeqNum == ucSeqNum)
1423 break;
1424 else {
1425 QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
1426
1427 prCmdInfo = NULL;
1428 }
1429
1430 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1431 }
1432 QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
1433
1434 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1435
1436 return prCmdInfo;
1437 }
1438
1439
1440 /*----------------------------------------------------------------------------*/
1441 /*!
1442 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1443 * with specified sequential number
1444 *
1445 * @param prAdapter Pointer of ADAPTER_T
1446 * ucSeqNum Sequential Number
1447 *
1448 * @retval - P_MSDU_INFO_T
1449 */
1450 /*----------------------------------------------------------------------------*/
1451 P_MSDU_INFO_T nicGetPendingTxMsduInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
1452 {
1453 P_QUE_T prTxingQue;
1454 QUE_T rTempQue;
1455 P_QUE_T prTempQue = &rTempQue;
1456 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
1457 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
1458
1459 GLUE_SPIN_LOCK_DECLARATION();
1460
1461 ASSERT(prAdapter);
1462
1463 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1464
1465 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1466 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1467
1468 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1469 while (prQueueEntry) {
1470 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1471
1472 if (prMsduInfo->ucTxSeqNum == ucSeqNum)
1473 break;
1474 else {
1475 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1476
1477 prMsduInfo = NULL;
1478 }
1479
1480 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1481 }
1482 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1483
1484 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1485
1486 return prMsduInfo;
1487 }
1488
1489 P_MSDU_INFO_T nicGetPendingStaMMPDU(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx)
1490 {
1491 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T) NULL;
1492 P_QUE_T prTxingQue = (P_QUE_T) NULL;
1493 QUE_T rTempQue;
1494 P_QUE_T prTempQue = &rTempQue;
1495 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
1496 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
1497
1498 GLUE_SPIN_LOCK_DECLARATION();
1499
1500 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1501 do {
1502 if (prAdapter == NULL) {
1503
1504 ASSERT(FALSE);
1505 break;
1506 }
1507
1508 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1509 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1510
1511 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1512 while (prQueueEntry) {
1513 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1514
1515 if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx)
1516 && (prMsduInfo->pfTxDoneHandler != NULL)) {
1517 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo, prMsduInfoListHead);
1518 prMsduInfoListHead = prMsduInfo;
1519 } else {
1520 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1521
1522 prMsduInfo = NULL;
1523 }
1524
1525
1526 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1527 }
1528
1529 } while (FALSE);
1530 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1531
1532
1533 return prMsduInfoListHead;
1534 } /* nicGetPendingStaMMPDU */
1535
1536
1537 VOID
1538 nicFreePendingTxMsduInfoByNetwork(IN P_ADAPTER_T prAdapter,
1539 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType)
1540 {
1541 P_QUE_T prTxingQue;
1542 QUE_T rTempQue;
1543 P_QUE_T prTempQue = &rTempQue;
1544 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
1545 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T) NULL;
1546 P_MSDU_INFO_T prMsduInfoListTail = (P_MSDU_INFO_T) NULL;
1547 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
1548
1549 GLUE_SPIN_LOCK_DECLARATION();
1550
1551 ASSERT(prAdapter);
1552
1553 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1554
1555 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1556 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1557
1558 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1559 while (prQueueEntry) {
1560 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1561
1562 if ((ENUM_NETWORK_TYPE_INDEX_T) (prMsduInfo->ucNetworkType) == eNetworkType) {
1563 if (prMsduInfoListHead == NULL) {
1564 prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
1565 } else {
1566 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
1567 prMsduInfoListTail = prMsduInfo;
1568 }
1569 } else {
1570 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1571
1572 prMsduInfo = NULL;
1573 }
1574
1575 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1576 }
1577 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1578
1579 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1580
1581 /* free */
1582 if (prMsduInfoListHead) {
1583 nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
1584 }
1585
1586 return;
1587
1588 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1589
1590
1591
1592 /*----------------------------------------------------------------------------*/
1593 /*!
1594 * @brief This procedure is used to retrieve a CMD sequence number atomically
1595 *
1596 * @param prAdapter Pointer of ADAPTER_T
1597 *
1598 * @retval - UINT_8
1599 */
1600 /*----------------------------------------------------------------------------*/
1601 UINT_8 nicIncreaseCmdSeqNum(IN P_ADAPTER_T prAdapter)
1602 {
1603 UINT_8 ucRetval;
1604
1605 KAL_SPIN_LOCK_DECLARATION();
1606
1607 ASSERT(prAdapter);
1608
1609 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1610
1611 prAdapter->ucCmdSeqNum++;
1612 ucRetval = prAdapter->ucCmdSeqNum;
1613
1614 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1615
1616 return ucRetval;
1617 }
1618
1619
1620 /*----------------------------------------------------------------------------*/
1621 /*!
1622 * @brief This procedure is used to retrieve a TX sequence number atomically
1623 *
1624 * @param prAdapter Pointer of ADAPTER_T
1625 *
1626 * @retval - UINT_8
1627 */
1628 /*----------------------------------------------------------------------------*/
1629 UINT_8 nicIncreaseTxSeqNum(IN P_ADAPTER_T prAdapter)
1630 {
1631 UINT_8 ucRetval;
1632
1633 KAL_SPIN_LOCK_DECLARATION();
1634
1635 ASSERT(prAdapter);
1636
1637 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1638
1639 prAdapter->ucTxSeqNum++;
1640 ucRetval = prAdapter->ucTxSeqNum;
1641
1642 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1643
1644 return ucRetval;
1645 }
1646
1647
1648
1649 /*----------------------------------------------------------------------------*/
1650 /*!
1651 * @brief This utility function is used to handle
1652 * media state change event
1653 *
1654 * @param
1655 *
1656 * @retval
1657 */
1658 /*----------------------------------------------------------------------------*/
1659 WLAN_STATUS
1660 nicMediaStateChange(IN P_ADAPTER_T prAdapter,
1661 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType,
1662 IN P_EVENT_CONNECTION_STATUS prConnectionStatus)
1663 {
1664 P_GLUE_INFO_T prGlueInfo;
1665
1666 ASSERT(prAdapter);
1667 prGlueInfo = prAdapter->prGlueInfo;
1668
1669 switch (eNetworkType) {
1670 case NETWORK_TYPE_AIS_INDEX:
1671 if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) { /* disconnected */
1672 if (kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
1673
1674 kalIndicateStatusAndComplete(prGlueInfo,
1675 WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
1676
1677 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1678 }
1679
1680 /* reset buffered link quality information */
1681 prAdapter->fgIsLinkQualityValid = FALSE;
1682 prAdapter->fgIsLinkRateValid = FALSE;
1683 } else if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) { /* connected */
1684 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1685
1686 /* fill information for association result */
1687 prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen
1688 = prConnectionStatus->ucSsidLen;
1689 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
1690 prConnectionStatus->aucSsid, prConnectionStatus->ucSsidLen);
1691 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
1692 prConnectionStatus->aucBssid, MAC_ADDR_LEN);
1693 prAdapter->rWlanInfo.rCurrBssId.u4Privacy = prConnectionStatus->ucEncryptStatus; /* @FIXME */
1694 prAdapter->rWlanInfo.rCurrBssId.rRssi = 0; /* @FIXME */
1695 prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse = PARAM_NETWORK_TYPE_AUTOMODE; /* @FIXME */
1696 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
1697 = prConnectionStatus->u2BeaconPeriod;
1698 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow
1699 = prConnectionStatus->u2ATIMWindow;
1700 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig
1701 = prConnectionStatus->u4FreqInKHz;
1702 prAdapter->rWlanInfo.ucNetworkType = prConnectionStatus->ucNetworkType;
1703 prAdapter->rWlanInfo.rCurrBssId.eOpMode
1704 = (ENUM_PARAM_OP_MODE_T) prConnectionStatus->ucInfraMode;
1705
1706 /* always indicate to OS according to MSDN (re-association/roaming) */
1707 if (kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_CONNECTED) {
1708 kalIndicateStatusAndComplete(prGlueInfo,
1709 WLAN_STATUS_MEDIA_CONNECT, NULL, 0);
1710 } else {
1711 /* connected -> connected : roaming ? */
1712 kalIndicateStatusAndComplete(prGlueInfo,
1713 WLAN_STATUS_ROAM_OUT_FIND_BEST,
1714 NULL, 0);
1715 }
1716 }
1717 break;
1718
1719 #if CFG_ENABLE_BT_OVER_WIFI
1720 case NETWORK_TYPE_BOW_INDEX:
1721 break;
1722 #endif
1723
1724 #if CFG_ENABLE_WIFI_DIRECT
1725 case NETWORK_TYPE_P2P_INDEX:
1726 break;
1727 #endif
1728 default:
1729 ASSERT(0);
1730 }
1731
1732 return WLAN_STATUS_SUCCESS;
1733 } /* nicMediaStateChange */
1734
1735 /*----------------------------------------------------------------------------*/
1736 /*!
1737 * @brief This utility function is used to convert between
1738 * frequency and channel number
1739 *
1740 * @param u4ChannelNum
1741 *
1742 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1743 */
1744 /*----------------------------------------------------------------------------*/
1745 UINT_32 nicChannelNum2Freq(UINT_32 u4ChannelNum)
1746 {
1747 UINT_32 u4ChannelInMHz;
1748
1749 if (u4ChannelNum >= 1 && u4ChannelNum <= 13) {
1750 u4ChannelInMHz = 2412 + (u4ChannelNum - 1) * 5;
1751 } else if (u4ChannelNum == 14) {
1752 u4ChannelInMHz = 2484;
1753 } else if (u4ChannelNum == 133) {
1754 u4ChannelInMHz = 3665; /* 802.11y */
1755 } else if (u4ChannelNum == 137) {
1756 u4ChannelInMHz = 3685; /* 802.11y */
1757 } else if (u4ChannelNum >= 34 && u4ChannelNum <= 165) {
1758 u4ChannelInMHz = 5000 + u4ChannelNum * 5;
1759 } else if (u4ChannelNum >= 183 && u4ChannelNum <= 196) {
1760 u4ChannelInMHz = 4000 + u4ChannelNum * 5;
1761 } else {
1762 u4ChannelInMHz = 0;
1763 }
1764
1765 return 1000 * u4ChannelInMHz;
1766 }
1767
1768
1769 /*----------------------------------------------------------------------------*/
1770 /*!
1771 * @brief This utility function is used to convert between
1772 * frequency and channel number
1773 *
1774 * @param u4FreqInKHz
1775 *
1776 * @retval - Frequency Number, 0 for invalid freqency
1777 */
1778 /*----------------------------------------------------------------------------*/
1779 UINT_32 nicFreq2ChannelNum(UINT_32 u4FreqInKHz)
1780 {
1781 switch (u4FreqInKHz) {
1782 case 2412000:
1783 return 1;
1784 case 2417000:
1785 return 2;
1786 case 2422000:
1787 return 3;
1788 case 2427000:
1789 return 4;
1790 case 2432000:
1791 return 5;
1792 case 2437000:
1793 return 6;
1794 case 2442000:
1795 return 7;
1796 case 2447000:
1797 return 8;
1798 case 2452000:
1799 return 9;
1800 case 2457000:
1801 return 10;
1802 case 2462000:
1803 return 11;
1804 case 2467000:
1805 return 12;
1806 case 2472000:
1807 return 13;
1808 case 2484000:
1809 return 14;
1810 case 3665000:
1811 return 133; /* 802.11y */
1812 case 3685000:
1813 return 137; /* 802.11y */
1814 case 4915000:
1815 return 183;
1816 case 4920000:
1817 return 184;
1818 case 4925000:
1819 return 185;
1820 case 4930000:
1821 return 186;
1822 case 4935000:
1823 return 187;
1824 case 4940000:
1825 return 188;
1826 case 4945000:
1827 return 189;
1828 case 4960000:
1829 return 192;
1830 case 4980000:
1831 return 196;
1832 case 5170000:
1833 return 34;
1834 case 5180000:
1835 return 36;
1836 case 5190000:
1837 return 38;
1838 case 5200000:
1839 return 40;
1840 case 5210000:
1841 return 42;
1842 case 5220000:
1843 return 44;
1844 case 5230000:
1845 return 46;
1846 case 5240000:
1847 return 48;
1848 case 5250000:
1849 return 50;
1850 case 5260000:
1851 return 52;
1852 case 5270000:
1853 return 54;
1854 case 5280000:
1855 return 56;
1856 case 5290000:
1857 return 58;
1858 case 5300000:
1859 return 60;
1860 case 5320000:
1861 return 64;
1862 case 5500000:
1863 return 100;
1864 case 5520000:
1865 return 104;
1866 case 5540000:
1867 return 108;
1868 case 5560000:
1869 return 112;
1870 case 5580000:
1871 return 116;
1872 case 5600000:
1873 return 120;
1874 case 5620000:
1875 return 124;
1876 case 5640000:
1877 return 128;
1878 case 5660000:
1879 return 132;
1880 case 5680000:
1881 return 136;
1882 case 5700000:
1883 return 140;
1884 case 5745000:
1885 return 149;
1886 case 5765000:
1887 return 153;
1888 case 5785000:
1889 return 157;
1890 case 5805000:
1891 return 161;
1892 case 5825000:
1893 return 165;
1894 default:
1895 return 0;
1896 }
1897 }
1898
1899
1900 /* firmware command wrapper */
1901 /* NETWORK (WIFISYS) */
1902 /*----------------------------------------------------------------------------*/
1903 /*!
1904 * @brief This utility function is used to activate WIFISYS for specified network
1905 *
1906 * @param prAdapter Pointer of ADAPTER_T
1907 * eNetworkTypeIdx Index of network type
1908 *
1909 * @retval -
1910 */
1911 /*----------------------------------------------------------------------------*/
1912 WLAN_STATUS
1913 nicActivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1914 {
1915 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
1916 P_BSS_INFO_T prBssInfo;
1917
1918 ASSERT(prAdapter);
1919 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
1920
1921 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
1922 rCmdActivateCtrl.ucActive = 1;
1923
1924 if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
1925 prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
1926 prBssInfo->fg40mBwAllowed = FALSE;
1927 prBssInfo->fgAssoc40mBwAllowed = FALSE;
1928 }
1929
1930 return wlanSendSetQueryCmd(prAdapter,
1931 CMD_ID_BSS_ACTIVATE_CTRL,
1932 TRUE,
1933 FALSE,
1934 FALSE,
1935 NULL,
1936 NULL,
1937 sizeof(CMD_BSS_ACTIVATE_CTRL),
1938 (PUINT_8) & rCmdActivateCtrl, NULL, 0);
1939 }
1940
1941
1942 /*----------------------------------------------------------------------------*/
1943 /*!
1944 * @brief This utility function is used to deactivate WIFISYS for specified network
1945 *
1946 * @param prAdapter Pointer of ADAPTER_T
1947 * eNetworkTypeIdx Index of network type
1948 *
1949 * @retval -
1950 */
1951 /*----------------------------------------------------------------------------*/
1952 WLAN_STATUS
1953 nicDeactivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1954 {
1955 WLAN_STATUS u4Status;
1956 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
1957
1958 ASSERT(prAdapter);
1959 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
1960
1961 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
1962 rCmdActivateCtrl.ucActive = 0;
1963
1964 u4Status = wlanSendSetQueryCmd(prAdapter,
1965 CMD_ID_BSS_ACTIVATE_CTRL,
1966 TRUE,
1967 FALSE,
1968 FALSE,
1969 NULL,
1970 NULL,
1971 sizeof(CMD_BSS_ACTIVATE_CTRL),
1972 (PUINT_8) & rCmdActivateCtrl, NULL, 0);
1973
1974 /* free all correlated station records */
1975 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
1976 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
1977 nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
1978 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
1979
1980 return u4Status;
1981 }
1982
1983
1984 /* BSS-INFO */
1985 /*----------------------------------------------------------------------------*/
1986 /*!
1987 * @brief This utility function is used to sync bss info with firmware
1988 * when a new BSS has been connected or disconnected
1989 *
1990 * @param prAdapter Pointer of ADAPTER_T
1991 * eNetworkTypeIdx Index of BSS-INFO type
1992 *
1993 * @retval -
1994 */
1995 /*----------------------------------------------------------------------------*/
1996 WLAN_STATUS nicUpdateBss(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1997 {
1998 WLAN_STATUS u4Status;
1999 P_BSS_INFO_T prBssInfo;
2000 CMD_SET_BSS_INFO rCmdSetBssInfo;
2001
2002 ASSERT(prAdapter);
2003 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2004
2005 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2006
2007 kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
2008
2009 rCmdSetBssInfo.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2010 rCmdSetBssInfo.ucConnectionState = (UINT_8) prBssInfo->eConnectionState;
2011 rCmdSetBssInfo.ucCurrentOPMode = (UINT_8) prBssInfo->eCurrentOPMode;
2012 rCmdSetBssInfo.ucSSIDLen = (UINT_8) prBssInfo->ucSSIDLen;
2013 kalMemCopy(rCmdSetBssInfo.aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
2014 COPY_MAC_ADDR(rCmdSetBssInfo.aucBSSID, prBssInfo->aucBSSID);
2015 rCmdSetBssInfo.ucIsQBSS = (UINT_8) prBssInfo->fgIsQBSS;
2016 rCmdSetBssInfo.ucNonHTBasicPhyType = prBssInfo->ucNonHTBasicPhyType;
2017 rCmdSetBssInfo.u2OperationalRateSet = prBssInfo->u2OperationalRateSet;
2018 rCmdSetBssInfo.u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
2019 rCmdSetBssInfo.ucPhyTypeSet = prBssInfo->ucPhyTypeSet;
2020 rCmdSetBssInfo.fgHiddenSsidMode = prBssInfo->eHiddenSsidType;
2021 #if CFG_ENABLE_WIFI_DIRECT
2022 if (prAdapter->fgIsP2PRegistered) {
2023 COPY_MAC_ADDR(rCmdSetBssInfo.aucOwnMac, prBssInfo->aucOwnMacAddr);
2024 }
2025 #endif
2026
2027 rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
2028
2029 rCmdSetBssInfo.fgWapiMode = (UINT_8) FALSE;
2030
2031 if (rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
2032 P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2033
2034 rCmdSetBssInfo.ucAuthMode = (UINT_8) prConnSettings->eAuthMode;
2035 rCmdSetBssInfo.ucEncStatus = (UINT_8) prConnSettings->eEncStatus;
2036 rCmdSetBssInfo.fgWapiMode = (UINT_8) prConnSettings->fgWapiMode;
2037 }
2038 #if CFG_ENABLE_BT_OVER_WIFI
2039 else if (rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX) {
2040 /* P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings); */
2041 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
2042 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
2043 }
2044 #endif
2045 else {
2046 #if CFG_ENABLE_WIFI_DIRECT
2047 if (prAdapter->fgIsP2PRegistered) {
2048 if (kalP2PGetCipher(prAdapter->prGlueInfo)) {
2049 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
2050 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
2051 } else {
2052 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_OPEN;
2053 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION_DISABLED;
2054 }
2055 /* Need the probe response to detect the PBC overlap */
2056 rCmdSetBssInfo.fgIsApMode =
2057 p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo);
2058 }
2059 #else
2060 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
2061 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
2062 #endif
2063 }
2064
2065 if (eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
2066 prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
2067 prBssInfo->prStaRecOfAP != NULL) {
2068 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2069
2070 cnmAisInfraConnectNotify(prAdapter);
2071 }
2072 #if CFG_ENABLE_WIFI_DIRECT
2073 else if ((prAdapter->fgIsP2PRegistered) &&
2074 (eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) &&
2075 (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) &&
2076 (prBssInfo->prStaRecOfAP != NULL)) {
2077 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2078 }
2079 #endif
2080
2081 #if CFG_ENABLE_BT_OVER_WIFI
2082 else if (eNetworkTypeIdx == NETWORK_TYPE_BOW_INDEX &&
2083 prBssInfo->eCurrentOPMode == OP_MODE_BOW && prBssInfo->prStaRecOfAP != NULL) {
2084 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2085 }
2086 #endif
2087 else {
2088 rCmdSetBssInfo.ucStaRecIdxOfAP = STA_REC_INDEX_NOT_FOUND;
2089 }
2090
2091 u4Status = wlanSendSetQueryCmd(prAdapter,
2092 CMD_ID_SET_BSS_INFO,
2093 TRUE,
2094 FALSE,
2095 FALSE,
2096 NULL,
2097 NULL,
2098 sizeof(CMD_SET_BSS_INFO),
2099 (PUINT_8) & rCmdSetBssInfo, NULL, 0);
2100
2101 /* if BSS-INFO is going to be disconnected state, free all correlated station records */
2102 if (prBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
2103 /* clear client list */
2104 bssClearClientList(prAdapter, prBssInfo);
2105
2106 /* free all correlated station records */
2107 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2108 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2109 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2110 }
2111
2112 return u4Status;
2113 }
2114
2115
2116 /* BSS-INFO Indication (PM) */
2117 /*----------------------------------------------------------------------------*/
2118 /*!
2119 * @brief This utility function is used to indicate PM that
2120 * a BSS has been created. (for AdHoc / P2P-GO)
2121 *
2122 * @param prAdapter Pointer of ADAPTER_T
2123 * eNetworkTypeIdx Index of BSS-INFO
2124 *
2125 * @retval -
2126 */
2127 /*----------------------------------------------------------------------------*/
2128 WLAN_STATUS
2129 nicPmIndicateBssCreated(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2130 {
2131 P_BSS_INFO_T prBssInfo;
2132 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
2133
2134 ASSERT(prAdapter);
2135 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2136
2137 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2138
2139 rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2140 rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2141 rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2142 rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
2143
2144 return wlanSendSetQueryCmd(prAdapter,
2145 CMD_ID_INDICATE_PM_BSS_CREATED,
2146 TRUE,
2147 FALSE,
2148 FALSE,
2149 NULL,
2150 NULL,
2151 sizeof(CMD_INDICATE_PM_BSS_CREATED),
2152 (PUINT_8) & rCmdIndicatePmBssCreated, NULL, 0);
2153 }
2154
2155
2156 /*----------------------------------------------------------------------------*/
2157 /*!
2158 * @brief This utility function is used to indicate PM that
2159 * a BSS has been connected
2160 *
2161 * @param prAdapter Pointer of ADAPTER_T
2162 * eNetworkTypeIdx Index of BSS-INFO
2163 *
2164 * @retval -
2165 */
2166 /*----------------------------------------------------------------------------*/
2167 WLAN_STATUS
2168 nicPmIndicateBssConnected(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2169 {
2170 P_BSS_INFO_T prBssInfo;
2171 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
2172
2173 ASSERT(prAdapter);
2174 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2175
2176 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2177
2178 rCmdIndicatePmBssConnected.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2179 rCmdIndicatePmBssConnected.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2180 rCmdIndicatePmBssConnected.u2AssocId = prBssInfo->u2AssocId;
2181 rCmdIndicatePmBssConnected.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2182 rCmdIndicatePmBssConnected.u2AtimWindow = prBssInfo->u2ATIMWindow;
2183
2184 rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
2185 rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
2186
2187 /* DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x", */
2188 /* rCmdIndicatePmBssConnected.ucBmpDeliveryAC, */
2189 /* rCmdIndicatePmBssConnected.ucBmpTriggerAC); */
2190
2191 if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
2192 #if CFG_ENABLE_WIFI_DIRECT
2193 || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
2194 #endif
2195 ) {
2196 if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
2197 rCmdIndicatePmBssConnected.fgIsUapsdConnection =
2198 (UINT_8) prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
2199 } else {
2200 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; /* @FIXME */
2201 }
2202 } else {
2203 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
2204 }
2205
2206 return wlanSendSetQueryCmd(prAdapter,
2207 CMD_ID_INDICATE_PM_BSS_CONNECTED,
2208 TRUE,
2209 FALSE,
2210 FALSE,
2211 NULL,
2212 NULL,
2213 sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
2214 (PUINT_8) & rCmdIndicatePmBssConnected, NULL, 0);
2215 }
2216
2217
2218 /*----------------------------------------------------------------------------*/
2219 /*!
2220 * @brief This utility function is used to indicate PM that
2221 * a BSS has been disconnected
2222 *
2223 * @param prAdapter Pointer of ADAPTER_T
2224 * eNetworkTypeIdx Index of BSS-INFO
2225 *
2226 * @retval -
2227 */
2228 /*----------------------------------------------------------------------------*/
2229 WLAN_STATUS
2230 nicPmIndicateBssAbort(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2231 {
2232 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
2233
2234 ASSERT(prAdapter);
2235 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2236
2237 rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2238
2239 return wlanSendSetQueryCmd(prAdapter,
2240 CMD_ID_INDICATE_PM_BSS_ABORT,
2241 TRUE,
2242 FALSE,
2243 FALSE,
2244 NULL,
2245 NULL,
2246 sizeof(CMD_INDICATE_PM_BSS_ABORT),
2247 (PUINT_8) & rCmdIndicatePmBssAbort, NULL, 0);
2248 }
2249
2250 WLAN_STATUS
2251 nicConfigPowerSaveProfile(IN P_ADAPTER_T prAdapter,
2252 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2253 PARAM_POWER_MODE ePwrMode, BOOLEAN fgEnCmdEvent)
2254 {
2255 DEBUGFUNC("nicConfigPowerSaveProfile");
2256 DBGLOG(INIT, TRACE, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2257 eNetTypeIndex, ePwrMode, fgEnCmdEvent));
2258
2259 ASSERT(prAdapter);
2260
2261 if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
2262 ASSERT(0);
2263 return WLAN_STATUS_NOT_SUPPORTED;
2264 }
2265 /* prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex; */
2266 /* prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode; */
2267 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucNetTypeIndex = eNetTypeIndex;
2268 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucPsProfile = (UINT_8) ePwrMode;
2269
2270 return wlanSendSetQueryCmd(prAdapter,
2271 CMD_ID_POWER_SAVE_MODE,
2272 TRUE,
2273 FALSE,
2274 TRUE,
2275 (fgEnCmdEvent ? nicCmdEventSetCommon : NULL),
2276 (fgEnCmdEvent ? nicOidCmdTimeoutCommon : NULL),
2277 sizeof(CMD_PS_PROFILE_T),
2278 (PUINT_8) & (prAdapter->rWlanInfo.
2279 arPowerSaveMode[eNetTypeIndex]), NULL,
2280 sizeof(PARAM_POWER_MODE)
2281 );
2282
2283 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2284
2285 /*----------------------------------------------------------------------------*/
2286 /*!
2287 * @brief This utility function is used to indicate firmware domain
2288 * for beacon generation parameters
2289 *
2290 * @param prAdapter Pointer of ADAPTER_T
2291 * eIeUpdMethod, Update Method
2292 * eNetTypeIndex Index of Network
2293 * u2Capability Capability
2294 * aucIe Pointer to buffer of IEs
2295 * u2IELen Length of IEs
2296 *
2297 * @retval - WLAN_STATUS_SUCCESS
2298 * WLAN_STATUS_FAILURE
2299 * WLAN_STATUS_PENDING
2300 * WLAN_STATUS_INVALID_DATA
2301 */
2302 /*----------------------------------------------------------------------------*/
2303 WLAN_STATUS
2304 nicUpdateBeaconIETemplate(IN P_ADAPTER_T prAdapter,
2305 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
2306 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2307 IN UINT_16 u2Capability, IN PUINT_8 aucIe, IN UINT_16 u2IELen)
2308 {
2309 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
2310 UINT_16 u2CmdBufLen = 0;
2311 P_GLUE_INFO_T prGlueInfo;
2312 P_CMD_INFO_T prCmdInfo;
2313 P_WIFI_CMD_T prWifiCmd;
2314 UINT_8 ucCmdSeqNum;
2315
2316 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2317 DBGLOG(INIT, LOUD, ("\n"));
2318
2319 printk("nicUpdateBeaconIETemplate\n");
2320
2321 ASSERT(prAdapter);
2322 prGlueInfo = prAdapter->prGlueInfo;
2323
2324 if (u2IELen > MAX_IE_LENGTH) {
2325 return WLAN_STATUS_INVALID_DATA;
2326 }
2327
2328 if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
2329 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
2330 } else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
2331 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
2332 } else {
2333 ASSERT(0);
2334 return WLAN_STATUS_FAILURE;
2335 }
2336
2337 /* prepare command info */
2338 prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
2339 if (!prCmdInfo) {
2340 DBGLOG(INIT, ERROR, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2341 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2342 return WLAN_STATUS_FAILURE;
2343 }
2344 /* increase command sequence number */
2345 ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
2346 DBGLOG(REQ, TRACE, ("ucCmdSeqNum =%d\n", ucCmdSeqNum));
2347
2348 /* Setup common CMD Info Packet */
2349 prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
2350 prCmdInfo->eNetworkType = eNetTypeIndex;
2351 prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + u2CmdBufLen);
2352 prCmdInfo->pfCmdDoneHandler = NULL; /* @FIXME */
2353 prCmdInfo->pfCmdTimeoutHandler = NULL; /* @FIXME */
2354 prCmdInfo->fgIsOid = FALSE;
2355 prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
2356 prCmdInfo->fgSetQuery = TRUE;
2357 prCmdInfo->fgNeedResp = FALSE;
2358 prCmdInfo->fgDriverDomainMCR = FALSE;
2359 prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
2360 prCmdInfo->u4SetInfoLen = u2CmdBufLen;
2361 prCmdInfo->pvInformationBuffer = NULL;
2362 prCmdInfo->u4InformationBufferLength = 0;
2363
2364 /* Setup WIFI_CMD_T (no payload) */
2365 prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
2366 prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
2367 prWifiCmd->ucCID = prCmdInfo->ucCID;
2368 prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
2369 prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
2370
2371 prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE) (prWifiCmd->aucBuffer);
2372
2373 /* fill beacon updating command */
2374 prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
2375 prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
2376 prCmdBcnUpdate->u2Capability = u2Capability;
2377 prCmdBcnUpdate->u2IELen = u2IELen;
2378 if (u2IELen > 0) {
2379 kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
2380 }
2381 /* insert into prCmdQueue */
2382 kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
2383
2384 /* wakeup txServiceThread later */
2385 GLUE_SET_EVENT(prGlueInfo);
2386 return WLAN_STATUS_PENDING;
2387 }
2388
2389
2390 /*----------------------------------------------------------------------------*/
2391 /*!
2392 * @brief This utility function is used to initialization PHY related
2393 * varaibles
2394 *
2395 * @param prAdapter Pointer of ADAPTER_T
2396 *
2397 * @retval none
2398 */
2399 /*----------------------------------------------------------------------------*/
2400 VOID nicSetAvailablePhyTypeSet(IN P_ADAPTER_T prAdapter)
2401 {
2402 P_CONNECTION_SETTINGS_T prConnSettings;
2403
2404 ASSERT(prAdapter);
2405
2406 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2407
2408 if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
2409 ASSERT(0);
2410 return;
2411 }
2412
2413 prAdapter->rWifiVar.ucAvailablePhyTypeSet =
2414 aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
2415
2416 if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP) {
2417 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
2418 }
2419 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2420 else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
2421
2422 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
2423 }
2424
2425 return;
2426 }
2427
2428
2429 /*----------------------------------------------------------------------------*/
2430 /*!
2431 * @brief This utility function is used to update WMM Parms
2432 *
2433 * @param prAdapter Pointer of ADAPTER_T
2434 * eNetworkTypeIdx Index of BSS-INFO
2435 *
2436 * @retval -
2437 */
2438 /*----------------------------------------------------------------------------*/
2439 WLAN_STATUS
2440 nicQmUpdateWmmParms(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2441 {
2442 P_BSS_INFO_T prBssInfo;
2443 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
2444
2445 ASSERT(prAdapter);
2446 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2447
2448 DBGLOG(QM, EVENT, ("sizeof(AC_QUE_PARMS_T): %d\n", sizeof(AC_QUE_PARMS_T)));
2449 DBGLOG(QM, EVENT, ("sizeof(CMD_UPDATE_WMM_PARMS): %d\n", sizeof(CMD_UPDATE_WMM_PARMS_T)));
2450 DBGLOG(QM, EVENT, ("sizeof(WIFI_CMD_T): %d\n", sizeof(WIFI_CMD_T)));
2451
2452 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2453 rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2454 kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0],
2455 (sizeof(AC_QUE_PARMS_T) * AC_NUM));
2456
2457 rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
2458
2459 return wlanSendSetQueryCmd(prAdapter,
2460 CMD_ID_UPDATE_WMM_PARMS,
2461 TRUE,
2462 FALSE,
2463 FALSE,
2464 NULL,
2465 NULL,
2466 sizeof(CMD_UPDATE_WMM_PARMS_T),
2467 (PUINT_8) & rCmdUpdateWmmParms, NULL, 0);
2468 }
2469
2470
2471 /*----------------------------------------------------------------------------*/
2472 /*!
2473 * @brief This utility function is used to update TX power gain corresponding to
2474 * each band/modulation combination
2475 *
2476 * @param prAdapter Pointer of ADAPTER_T
2477 * prTxPwrParam Pointer of TX power parameters
2478 *
2479 * @retval WLAN_STATUS_PENDING
2480 * WLAN_STATUS_FAILURE
2481 */
2482 /*----------------------------------------------------------------------------*/
2483 WLAN_STATUS nicUpdateTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
2484 {
2485 DEBUGFUNC("nicUpdateTxPower");
2486
2487 ASSERT(prAdapter);
2488
2489 return wlanSendSetQueryCmd(prAdapter,
2490 CMD_ID_SET_TX_PWR,
2491 TRUE,
2492 FALSE,
2493 FALSE,
2494 NULL,
2495 NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
2496 }
2497
2498 /*----------------------------------------------------------------------------*/
2499 /*!
2500 * @brief This utility function is used to set auto tx power parameter
2501 *
2502 * @param prAdapter Pointer of ADAPTER_T
2503 * prTxPwrParam Pointer of Auto TX power parameters
2504 *
2505 * @retval WLAN_STATUS_PENDING
2506 * WLAN_STATUS_FAILURE
2507 */
2508 /*----------------------------------------------------------------------------*/
2509 WLAN_STATUS nicSetAutoTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam)
2510 {
2511 DEBUGFUNC("nicSetAutoTxPower");
2512
2513 ASSERT(prAdapter);
2514
2515 return wlanSendSetQueryCmd(prAdapter,
2516 CMD_ID_SET_AUTOPWR_CTRL,
2517 TRUE,
2518 FALSE,
2519 FALSE,
2520 NULL,
2521 NULL,
2522 sizeof(CMD_AUTO_POWER_PARAM_T),
2523 (PUINT_8) prAutoPwrParam, NULL, 0);
2524 }
2525
2526
2527 /*----------------------------------------------------------------------------*/
2528 /*!
2529 * @brief This utility function is used to update TX power gain corresponding to
2530 * each band/modulation combination
2531 *
2532 * @param prAdapter Pointer of ADAPTER_T
2533 * prTxPwrParam Pointer of TX power parameters
2534 *
2535 * @retval WLAN_STATUS_PENDING
2536 * WLAN_STATUS_FAILURE
2537 */
2538 /*----------------------------------------------------------------------------*/
2539 WLAN_STATUS nicSetAutoTxPowerControl(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
2540 {
2541 DEBUGFUNC("nicUpdateTxPower");
2542
2543 ASSERT(prAdapter);
2544
2545 return wlanSendSetQueryCmd(prAdapter,
2546 CMD_ID_SET_TX_PWR,
2547 TRUE,
2548 FALSE,
2549 FALSE,
2550 NULL,
2551 NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
2552 }
2553
2554
2555 /*----------------------------------------------------------------------------*/
2556 /*!
2557 * @brief This utility function is used to update power offset around 5GHz band
2558 *
2559 * @param prAdapter Pointer of ADAPTER_T
2560 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2561 *
2562 * @retval WLAN_STATUS_PENDING
2563 * WLAN_STATUS_FAILURE
2564 */
2565 /*----------------------------------------------------------------------------*/
2566 WLAN_STATUS nicUpdate5GOffset(IN P_ADAPTER_T prAdapter, IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset)
2567 {
2568 DEBUGFUNC("nicUpdate5GOffset");
2569
2570 ASSERT(prAdapter);
2571
2572 return wlanSendSetQueryCmd(prAdapter,
2573 CMD_ID_SET_5G_PWR_OFFSET,
2574 TRUE,
2575 FALSE,
2576 FALSE,
2577 NULL,
2578 NULL,
2579 sizeof(CMD_5G_PWR_OFFSET_T), (PUINT_8) pr5GPwrOffset, NULL, 0);
2580 }
2581
2582
2583 /*----------------------------------------------------------------------------*/
2584 /*!
2585 * @brief This utility function is used to update DPD calibration result
2586 *
2587 * @param prAdapter Pointer of ADAPTER_T
2588 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2589 *
2590 * @retval WLAN_STATUS_PENDING
2591 * WLAN_STATUS_FAILURE
2592 */
2593 /*----------------------------------------------------------------------------*/
2594 WLAN_STATUS nicUpdateDPD(IN P_ADAPTER_T prAdapter, IN P_CMD_PWR_PARAM_T prDpdCalResult)
2595 {
2596 DEBUGFUNC("nicUpdateDPD");
2597
2598 ASSERT(prAdapter);
2599
2600 return wlanSendSetQueryCmd(prAdapter,
2601 CMD_ID_SET_PWR_PARAM,
2602 TRUE,
2603 FALSE,
2604 FALSE,
2605 NULL,
2606 NULL,
2607 sizeof(CMD_PWR_PARAM_T), (PUINT_8) prDpdCalResult, NULL, 0);
2608 }
2609
2610
2611 /*----------------------------------------------------------------------------*/
2612 /*!
2613 * @brief This utility function starts system service such as timer and
2614 * memory pools
2615 *
2616 * @param prAdapter Pointer of ADAPTER_T
2617 *
2618 * @retval none
2619 */
2620 /*----------------------------------------------------------------------------*/
2621 VOID nicInitSystemService(IN P_ADAPTER_T prAdapter)
2622 {
2623 ASSERT(prAdapter);
2624
2625 /* <1> Initialize MGMT Memory pool and STA_REC */
2626 cnmMemInit(prAdapter);
2627 cnmStaRecInit(prAdapter);
2628 cmdBufInitialize(prAdapter);
2629
2630 /* <2> Mailbox Initialization */
2631 mboxInitialize(prAdapter);
2632
2633 /* <3> Timer Initialization */
2634 cnmTimerInitialize(prAdapter);
2635
2636 return;
2637 }
2638
2639
2640 /*----------------------------------------------------------------------------*/
2641 /*!
2642 * @brief This utility function reset some specific system service,
2643 * such as STA-REC
2644 *
2645 * @param prAdapter Pointer of ADAPTER_T
2646 *
2647 * @retval none
2648 */
2649 /*----------------------------------------------------------------------------*/
2650 VOID nicResetSystemService(IN P_ADAPTER_T prAdapter)
2651 {
2652 ASSERT(prAdapter);
2653 }
2654
2655
2656 /*----------------------------------------------------------------------------*/
2657 /*!
2658 * @brief This utility function is used to update WMM Parms
2659 *
2660 * @param prAdapter Pointer of ADAPTER_T
2661 *
2662 * @retval none
2663 */
2664 /*----------------------------------------------------------------------------*/
2665 VOID nicUninitSystemService(IN P_ADAPTER_T prAdapter)
2666 {
2667 ASSERT(prAdapter);
2668
2669 /* Timer Destruction */
2670 cnmTimerDestroy(prAdapter);
2671
2672 /* Mailbox Destruction */
2673 mboxDestroy(prAdapter);
2674
2675 return;
2676 }
2677
2678
2679 /*----------------------------------------------------------------------------*/
2680 /*!
2681 * @brief This utility function is used to update WMM Parms
2682 *
2683 * @param prAdapter Pointer of ADAPTER_T
2684 *
2685 * @retval none
2686 */
2687 /*----------------------------------------------------------------------------*/
2688 VOID nicInitMGMT(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
2689 {
2690 ASSERT(prAdapter);
2691
2692 /* CNM Module - initialization */
2693 cnmInit(prAdapter);
2694
2695 /* RLM Module - initialization */
2696 rlmFsmEventInit(prAdapter);
2697
2698 /* SCN Module - initialization */
2699 scnInit(prAdapter);
2700
2701 /* AIS Module - intiailization */
2702 aisInitializeConnectionSettings(prAdapter, prRegInfo);
2703 aisFsmInit(prAdapter);
2704
2705 #if CFG_SUPPORT_ROAMING
2706 /* Roaming Module - intiailization */
2707 roamingFsmInit(prAdapter);
2708 #endif /* CFG_SUPPORT_ROAMING */
2709
2710 #if CFG_SUPPORT_SWCR
2711 swCrDebugInit(prAdapter);
2712 #endif /* CFG_SUPPORT_SWCR */
2713
2714 return;
2715 }
2716
2717
2718 /*----------------------------------------------------------------------------*/
2719 /*!
2720 * @brief This utility function is used to update WMM Parms
2721 *
2722 * @param prAdapter Pointer of ADAPTER_T
2723 *
2724 * @retval none
2725 */
2726 /*----------------------------------------------------------------------------*/
2727 VOID nicUninitMGMT(IN P_ADAPTER_T prAdapter)
2728 {
2729 ASSERT(prAdapter);
2730
2731 #if CFG_SUPPORT_SWCR
2732 swCrDebugUninit(prAdapter);
2733 #endif /* CFG_SUPPORT_SWCR */
2734
2735 #if CFG_SUPPORT_ROAMING
2736 /* Roaming Module - unintiailization */
2737 roamingFsmUninit(prAdapter);
2738 #endif /* CFG_SUPPORT_ROAMING */
2739
2740 /* AIS Module - unintiailization */
2741 aisFsmUninit(prAdapter);
2742
2743 /* SCN Module - unintiailization */
2744 scnUninit(prAdapter);
2745
2746 /* RLM Module - uninitialization */
2747 rlmFsmEventUninit(prAdapter);
2748
2749 /* CNM Module - uninitialization */
2750 cnmUninit(prAdapter);
2751
2752 return;
2753 }
2754
2755
2756 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2757 /*----------------------------------------------------------------------------*/
2758 /*!
2759 * @brief This utility function is to inform firmware to enable MCU clock gating
2760 *
2761 * @param prAdapter Pointer of ADAPTER_T
2762 *
2763 * @retval none
2764 */
2765 /*----------------------------------------------------------------------------*/
2766 WLAN_STATUS nicEnableClockGating(IN P_ADAPTER_T prAdapter)
2767 {
2768 UINT_32 i, u4WHISR = 0;
2769
2770 ASSERT(prAdapter);
2771
2772 if (prAdapter->fgIsClockGatingEnabled == TRUE) {
2773 return WLAN_STATUS_SUCCESS;
2774 } else {
2775 nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
2776
2777 i = 0;
2778 while (i < GATING_CONTROL_POLL_LIMIT) {
2779 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
2780 || fgIsBusAccessFailed == TRUE) {
2781 return WLAN_STATUS_FAILURE;
2782 }
2783
2784 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8) & u4WHISR);
2785
2786 if (u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
2787 prAdapter->fgIsClockGatingEnabled = TRUE;
2788 return WLAN_STATUS_SUCCESS;
2789 }
2790 }
2791
2792 ASSERT(0);
2793 return WLAN_STATUS_PENDING;
2794 }
2795 }
2796
2797
2798 /*----------------------------------------------------------------------------*/
2799 /*!
2800 * @brief This utility function is to inform firmware to disable MCU clock gating
2801 *
2802 * @param prAdapter Pointer of ADAPTER_T
2803 *
2804 * @retval none
2805 */
2806 /*----------------------------------------------------------------------------*/
2807 WLAN_STATUS nicDisableClockGating(IN P_ADAPTER_T prAdapter)
2808 {
2809 UINT_32 i, u4WHISR = 0;
2810
2811 ASSERT(prAdapter);
2812
2813 if (prAdapter->fgIsClockGatingEnabled == FALSE) {
2814 return WLAN_STATUS_SUCCESS;
2815 } else {
2816 nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
2817
2818 i = 0;
2819 while (i < GATING_CONTROL_POLL_LIMIT) {
2820 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
2821 || fgIsBusAccessFailed == TRUE) {
2822 return WLAN_STATUS_FAILURE;
2823 }
2824
2825 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8) & u4WHISR);
2826
2827 if (u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
2828 prAdapter->fgIsClockGatingEnabled = FALSE;
2829 return WLAN_STATUS_SUCCESS;
2830 }
2831 }
2832
2833 ASSERT(0);
2834 return WLAN_STATUS_PENDING;
2835 }
2836 }
2837 #endif
2838
2839
2840 /*----------------------------------------------------------------------------*/
2841 /*!
2842 * @brief This function is invoked to buffer scan result
2843 *
2844 * @param prAdapter Pointer to the Adapter structure.
2845 * @param rMacAddr BSSID
2846 * @param prSsid Pointer to SSID
2847 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
2848 * @param rRssi Received Strength (-10 ~ -200 dBm)
2849 * @param eNetworkType Network Type (a/b/g)
2850 * @param prConfiguration Network Parameter
2851 * @param eOpMode Infra/Ad-Hoc
2852 * @param rSupportedRates Supported basic rates
2853 * @param u2IELength IE Length
2854 * @param pucIEBuf Pointer to Information Elements(IEs)
2855 *
2856 * @return (none)
2857 */
2858 /*----------------------------------------------------------------------------*/
2859 VOID
2860 nicAddScanResult(IN P_ADAPTER_T prAdapter,
2861 IN PARAM_MAC_ADDRESS rMacAddr,
2862 IN P_PARAM_SSID_T prSsid,
2863 IN UINT_32 u4Privacy,
2864 IN PARAM_RSSI rRssi,
2865 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
2866 IN P_PARAM_802_11_CONFIG_T prConfiguration,
2867 IN ENUM_PARAM_OP_MODE_T eOpMode,
2868 IN PARAM_RATES_EX rSupportedRates, IN UINT_16 u2IELength, IN PUINT_8 pucIEBuf)
2869 {
2870 BOOLEAN bReplace;
2871 UINT_32 i;
2872 UINT_32 u4IdxWeakest = 0;
2873 PARAM_RSSI rWeakestRssi;
2874 UINT_32 u4BufferSize;
2875
2876 ASSERT(prAdapter);
2877
2878 rWeakestRssi = (PARAM_RSSI) INT_MAX;
2879 u4BufferSize =
2880 sizeof(prAdapter->rWlanInfo.aucScanIEBuf) /
2881 sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
2882
2883 bReplace = FALSE;
2884
2885 /* decide to replace or add */
2886 for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
2887 /* find weakest entry && not connected one */
2888 if (UNEQUAL_MAC_ADDR
2889 (prAdapter->rWlanInfo.arScanResult[i].arMacAddress,
2890 prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
2891 && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
2892 u4IdxWeakest = i;
2893 rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
2894 }
2895
2896 if (prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
2897 EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr)
2898 &&
2899 (EQUAL_SSID
2900 (prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
2901 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen, prSsid->aucSsid,
2902 prSsid->u4SsidLen)
2903 || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
2904 /* replace entry */
2905 bReplace = TRUE;
2906
2907 /* free IE buffer then zero */
2908 nicFreeScanResultIE(prAdapter, i);
2909 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
2910 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
2911
2912 /* then fill buffer */
2913 prAdapter->rWlanInfo.arScanResult[i].u4Length =
2914 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
2915 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
2916 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
2917 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
2918 prSsid->aucSsid, prSsid->u4SsidLen);
2919 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
2920 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
2921 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
2922 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
2923 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
2924 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
2925 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
2926 rSupportedRates, sizeof(PARAM_RATES_EX));
2927 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
2928
2929 /* IE - allocate buffer and update pointer */
2930 if (u2IELength > 0) {
2931 if (ALIGN_4(u2IELength) +
2932 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
2933 kalMemCopy(&
2934 (prAdapter->rWlanInfo.
2935 aucScanIEBuf[prAdapter->rWlanInfo.
2936 u4ScanIEBufferUsage]), pucIEBuf,
2937 u2IELength);
2938
2939 prAdapter->rWlanInfo.apucScanResultIEs[i] =
2940 &(prAdapter->rWlanInfo.
2941 aucScanIEBuf[prAdapter->rWlanInfo.
2942 u4ScanIEBufferUsage]);
2943
2944 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
2945 ALIGN_4(u2IELength);
2946 } else {
2947 /* buffer is not enough */
2948 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
2949 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
2950 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
2951 }
2952 } else {
2953 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
2954 }
2955
2956 break;
2957 }
2958 }
2959
2960 if (bReplace == FALSE) {
2961 if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
2962 i = prAdapter->rWlanInfo.u4ScanResultNum;
2963
2964 /* zero */
2965 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
2966 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
2967
2968 /* then fill buffer */
2969 prAdapter->rWlanInfo.arScanResult[i].u4Length =
2970 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
2971 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
2972 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
2973 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
2974 prSsid->aucSsid, prSsid->u4SsidLen);
2975 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
2976 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
2977 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
2978 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
2979 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
2980 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
2981 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
2982 rSupportedRates, sizeof(PARAM_RATES_EX));
2983 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
2984
2985 /* IE - allocate buffer and update pointer */
2986 if (u2IELength > 0) {
2987 if (ALIGN_4(u2IELength) +
2988 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
2989 kalMemCopy(&
2990 (prAdapter->rWlanInfo.
2991 aucScanIEBuf[prAdapter->rWlanInfo.
2992 u4ScanIEBufferUsage]), pucIEBuf,
2993 u2IELength);
2994
2995 prAdapter->rWlanInfo.apucScanResultIEs[i] =
2996 &(prAdapter->rWlanInfo.
2997 aucScanIEBuf[prAdapter->rWlanInfo.
2998 u4ScanIEBufferUsage]);
2999
3000 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
3001 ALIGN_4(u2IELength);
3002 } else {
3003 /* buffer is not enough */
3004 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3005 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3006 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3007 }
3008 } else {
3009 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3010 }
3011
3012 prAdapter->rWlanInfo.u4ScanResultNum++;
3013 } else if (rWeakestRssi != (PARAM_RSSI) INT_MAX) {
3014 /* replace weakest one */
3015 i = u4IdxWeakest;
3016
3017 /* free IE buffer then zero */
3018 nicFreeScanResultIE(prAdapter, i);
3019 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3020 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3021
3022 /* then fill buffer */
3023 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3024 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3025 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3026 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3027 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3028 prSsid->aucSsid, prSsid->u4SsidLen);
3029 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3030 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3031 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3032 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3033 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
3034 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3035 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3036 rSupportedRates, sizeof(PARAM_RATES_EX));
3037 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
3038
3039 if (u2IELength > 0) {
3040 /* IE - allocate buffer and update pointer */
3041 if (ALIGN_4(u2IELength) +
3042 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3043 kalMemCopy(&
3044 (prAdapter->rWlanInfo.
3045 aucScanIEBuf[prAdapter->rWlanInfo.
3046 u4ScanIEBufferUsage]), pucIEBuf,
3047 u2IELength);
3048
3049 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3050 &(prAdapter->rWlanInfo.
3051 aucScanIEBuf[prAdapter->rWlanInfo.
3052 u4ScanIEBufferUsage]);
3053
3054 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
3055 ALIGN_4(u2IELength);
3056 } else {
3057 /* buffer is not enough */
3058 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3059 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3060 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3061 }
3062 } else {
3063 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3064 }
3065 }
3066 }
3067 }
3068
3069
3070 /*----------------------------------------------------------------------------*/
3071 /*!
3072 * @brief This function is invoked to free IE buffer for dedicated scan result
3073 *
3074 * @param prAdapter Pointer to the Adapter structure.
3075 * @param u4Idx Index of Scan Result
3076 *
3077 * @return (none)
3078 */
3079 /*----------------------------------------------------------------------------*/
3080 VOID nicFreeScanResultIE(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Idx)
3081 {
3082 UINT_32 i;
3083 PUINT_8 pucPivot, pucMovePivot;
3084 UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
3085
3086 ASSERT(prAdapter);
3087 ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
3088
3089 if (prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
3090 || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
3091 return;
3092 }
3093
3094 u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
3095
3096 pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
3097 pucMovePivot =
3098 (PUINT_8) ((UINT_32) (prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
3099
3100 u4ReserveSize = ((UINT_32) pucPivot) - (UINT_32) (&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
3101 u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
3102
3103 /* 1. rest of buffer to move forward */
3104 kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
3105
3106 /* 1.1 modify pointers */
3107 for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
3108 if (i != u4Idx) {
3109 if (prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
3110 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3111 (PUINT_8) ((UINT_32) (prAdapter->rWlanInfo.apucScanResultIEs[i])
3112 - u4FreeSize);
3113 }
3114 }
3115 }
3116
3117 /* 1.2 reset the freed one */
3118 prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
3119 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3120
3121 /* 2. reduce IE buffer usage */
3122 prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
3123
3124 return;
3125 }
3126
3127
3128 /*----------------------------------------------------------------------------*/
3129 /*!
3130 * @brief This function is to hack parameters for WLAN TABLE for
3131 * fixed rate settings
3132 *
3133 * @param prAdapter Pointer to the Adapter structure.
3134 * @param eRateSetting
3135 * @param pu2DesiredNonHTRateSet,
3136 * @param pu2BSSBasicRateSet,
3137 * @param pucMcsSet
3138 * @param pucSupMcs32
3139 * @param pu2HtCapInfo
3140 *
3141 * @return WLAN_STATUS_SUCCESS
3142 */
3143 /*----------------------------------------------------------------------------*/
3144 WLAN_STATUS
3145 nicUpdateRateParams(IN P_ADAPTER_T prAdapter,
3146 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
3147 IN PUINT_8 pucDesiredPhyTypeSet,
3148 IN PUINT_16 pu2DesiredNonHTRateSet,
3149 IN PUINT_16 pu2BSSBasicRateSet,
3150 IN PUINT_8 pucMcsSet, IN PUINT_8 pucSupMcs32, IN PUINT_16 pu2HtCapInfo)
3151 {
3152 ASSERT(prAdapter);
3153 ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
3154
3155 switch (prAdapter->rWifiVar.eRateSetting) {
3156 case FIXED_RATE_1M:
3157 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3158 *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
3159 *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
3160 *pucMcsSet = 0;
3161 *pucSupMcs32 = 0;
3162 *pu2HtCapInfo = 0;
3163 break;
3164
3165 case FIXED_RATE_2M:
3166 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3167 *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
3168 *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
3169 *pucMcsSet = 0;
3170 *pucSupMcs32 = 0;
3171 *pu2HtCapInfo = 0;
3172 break;
3173
3174 case FIXED_RATE_5_5M:
3175 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3176 *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
3177 *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
3178 *pucMcsSet = 0;
3179 *pucSupMcs32 = 0;
3180 *pu2HtCapInfo = 0;
3181 break;
3182
3183 case FIXED_RATE_11M:
3184 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3185 *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
3186 *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
3187 *pucMcsSet = 0;
3188 *pucSupMcs32 = 0;
3189 *pu2HtCapInfo = 0;
3190 break;
3191
3192 case FIXED_RATE_6M:
3193 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3194 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3195 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3196 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3197 }
3198
3199 *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
3200 *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
3201 *pucMcsSet = 0;
3202 *pucSupMcs32 = 0;
3203 *pu2HtCapInfo = 0;
3204 break;
3205
3206 case FIXED_RATE_9M:
3207 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3208 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3209 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3210 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3211 }
3212
3213 *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
3214 *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
3215 *pucMcsSet = 0;
3216 *pucSupMcs32 = 0;
3217 *pu2HtCapInfo = 0;
3218 break;
3219
3220 case FIXED_RATE_12M:
3221 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3222 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3223 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3224 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3225 }
3226
3227 *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
3228 *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
3229 *pucMcsSet = 0;
3230 *pucSupMcs32 = 0;
3231 *pu2HtCapInfo = 0;
3232 break;
3233
3234 case FIXED_RATE_18M:
3235 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3236 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3237 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3238 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3239 }
3240
3241 *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
3242 *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
3243 *pucMcsSet = 0;
3244 *pucSupMcs32 = 0;
3245 *pu2HtCapInfo = 0;
3246 break;
3247
3248 case FIXED_RATE_24M:
3249 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3250 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3251 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3252 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3253 }
3254
3255 *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
3256 *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
3257 *pucMcsSet = 0;
3258 *pucSupMcs32 = 0;
3259 *pu2HtCapInfo = 0;
3260 break;
3261
3262 case FIXED_RATE_36M:
3263 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3264 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3265 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3266 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3267 }
3268
3269 *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
3270 *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
3271 *pucMcsSet = 0;
3272 *pucSupMcs32 = 0;
3273 *pu2HtCapInfo = 0;
3274 break;
3275
3276 case FIXED_RATE_48M:
3277 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3278 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3279 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3280 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3281 }
3282
3283 *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
3284 *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
3285 *pucMcsSet = 0;
3286 *pucSupMcs32 = 0;
3287 *pu2HtCapInfo = 0;
3288 break;
3289
3290 case FIXED_RATE_54M:
3291 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3292 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3293 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3294 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3295 }
3296
3297 *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
3298 *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
3299 *pucMcsSet = 0;
3300 *pucSupMcs32 = 0;
3301 *pu2HtCapInfo = 0;
3302 break;
3303
3304 case FIXED_RATE_MCS0_20M_800NS:
3305 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3306 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3307 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3308 *pucMcsSet = HT_RATE_MCS0_INDEX;
3309 *pucSupMcs32 = 0;
3310 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3311 | HT_CAP_INFO_SHORT_GI_20M
3312 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3313 break;
3314
3315 case FIXED_RATE_MCS1_20M_800NS:
3316 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3317 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3318 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3319 *pucMcsSet = HT_RATE_MCS1_INDEX;
3320 *pucSupMcs32 = 0;
3321 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3322 | HT_CAP_INFO_SHORT_GI_20M
3323 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3324 break;
3325
3326 case FIXED_RATE_MCS2_20M_800NS:
3327 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3328 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3329 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3330 *pucMcsSet = HT_RATE_MCS2_INDEX;
3331 *pucSupMcs32 = 0;
3332 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3333 | HT_CAP_INFO_SHORT_GI_20M
3334 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3335 break;
3336
3337 case FIXED_RATE_MCS3_20M_800NS:
3338 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3339 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3340 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3341 *pucMcsSet = HT_RATE_MCS3_INDEX;
3342 *pucSupMcs32 = 0;
3343 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3344 | HT_CAP_INFO_SHORT_GI_20M
3345 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3346 break;
3347
3348 case FIXED_RATE_MCS4_20M_800NS:
3349 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3350 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3351 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3352 *pucMcsSet = HT_RATE_MCS4_INDEX;
3353 *pucSupMcs32 = 0;
3354 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3355 | HT_CAP_INFO_SHORT_GI_20M
3356 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3357 break;
3358
3359 case FIXED_RATE_MCS5_20M_800NS:
3360 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3361 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3362 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3363 *pucMcsSet = HT_RATE_MCS5_INDEX;
3364 *pucSupMcs32 = 0;
3365 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3366 | HT_CAP_INFO_SHORT_GI_20M
3367 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3368 break;
3369
3370 case FIXED_RATE_MCS6_20M_800NS:
3371 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3372 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3373 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3374 *pucMcsSet = HT_RATE_MCS6_INDEX;
3375 *pucSupMcs32 = 0;
3376 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3377 | HT_CAP_INFO_SHORT_GI_20M
3378 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3379 break;
3380
3381 case FIXED_RATE_MCS7_20M_800NS:
3382 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3383 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3384 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3385 *pucMcsSet = HT_RATE_MCS7_INDEX;
3386 *pucSupMcs32 = 0;
3387 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3388 | HT_CAP_INFO_SHORT_GI_20M
3389 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3390 break;
3391
3392 case FIXED_RATE_MCS0_20M_400NS:
3393 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3394 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3395 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3396 *pucMcsSet = HT_RATE_MCS0_INDEX;
3397 *pucSupMcs32 = 0;
3398 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3399 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3400 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3401 break;
3402
3403 case FIXED_RATE_MCS1_20M_400NS:
3404 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3405 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3406 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3407 *pucMcsSet = HT_RATE_MCS1_INDEX;
3408 *pucSupMcs32 = 0;
3409 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3410 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3411 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3412 break;
3413
3414 case FIXED_RATE_MCS2_20M_400NS:
3415 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3416 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3417 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3418 *pucMcsSet = HT_RATE_MCS2_INDEX;
3419 *pucSupMcs32 = 0;
3420 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3421 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3422 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3423 break;
3424
3425 case FIXED_RATE_MCS3_20M_400NS:
3426 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3427 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3428 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3429 *pucMcsSet = HT_RATE_MCS3_INDEX;
3430 *pucSupMcs32 = 0;
3431 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3432 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3433 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3434 break;
3435
3436 case FIXED_RATE_MCS4_20M_400NS:
3437 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3438 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3439 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3440 *pucMcsSet = HT_RATE_MCS4_INDEX;
3441 *pucSupMcs32 = 0;
3442 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3443 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3444 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3445 break;
3446
3447 case FIXED_RATE_MCS5_20M_400NS:
3448 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3449 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3450 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3451 *pucMcsSet = HT_RATE_MCS5_INDEX;
3452 *pucSupMcs32 = 0;
3453 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3454 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3455 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3456 break;
3457
3458 case FIXED_RATE_MCS6_20M_400NS:
3459 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3460 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3461 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3462 *pucMcsSet = HT_RATE_MCS6_INDEX;
3463 *pucSupMcs32 = 0;
3464 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3465 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3466 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3467 break;
3468
3469 case FIXED_RATE_MCS7_20M_400NS:
3470 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3471 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3472 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3473 *pucMcsSet = HT_RATE_MCS7_INDEX;
3474 *pucSupMcs32 = 0;
3475 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3476 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3477 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3478 break;
3479
3480 case FIXED_RATE_MCS0_40M_800NS:
3481 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3482 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3483 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3484 *pucMcsSet = HT_RATE_MCS0_INDEX;
3485 *pucSupMcs32 = 0;
3486 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3487 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3488 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3489 break;
3490
3491 case FIXED_RATE_MCS1_40M_800NS:
3492 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3493 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3494 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3495 *pucMcsSet = HT_RATE_MCS1_INDEX;
3496 *pucSupMcs32 = 0;
3497 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3498 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3499 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3500 break;
3501
3502 case FIXED_RATE_MCS2_40M_800NS:
3503 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3504 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3505 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3506 *pucMcsSet = HT_RATE_MCS2_INDEX;
3507 *pucSupMcs32 = 0;
3508 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3509 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3510 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3511 break;
3512
3513 case FIXED_RATE_MCS3_40M_800NS:
3514 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3515 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3516 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3517 *pucMcsSet = HT_RATE_MCS3_INDEX;
3518 *pucSupMcs32 = 0;
3519 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3520 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3521 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3522 break;
3523
3524 case FIXED_RATE_MCS4_40M_800NS:
3525 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3526 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3527 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3528 *pucMcsSet = HT_RATE_MCS4_INDEX;
3529 *pucSupMcs32 = 0;
3530 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3531 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3532 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3533 break;
3534
3535 case FIXED_RATE_MCS5_40M_800NS:
3536 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3537 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3538 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3539 *pucMcsSet = HT_RATE_MCS5_INDEX;
3540 *pucSupMcs32 = 0;
3541 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3542 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3543 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3544 break;
3545
3546 case FIXED_RATE_MCS6_40M_800NS:
3547 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3548 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3549 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3550 *pucMcsSet = HT_RATE_MCS6_INDEX;
3551 *pucSupMcs32 = 0;
3552 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3553 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3554 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3555 break;
3556
3557 case FIXED_RATE_MCS7_40M_800NS:
3558 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3559 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3560 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3561 *pucMcsSet = HT_RATE_MCS7_INDEX;
3562 *pucSupMcs32 = 0;
3563 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3564 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3565 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3566 break;
3567
3568 case FIXED_RATE_MCS32_800NS:
3569 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3570 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3571 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3572 *pucMcsSet = HT_RATE_MCS32_INDEX;
3573 *pucSupMcs32 = 1;
3574 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3575 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3576 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3577 break;
3578
3579 case FIXED_RATE_MCS0_40M_400NS:
3580 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3581 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3582 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3583 *pucMcsSet = HT_RATE_MCS0_INDEX;
3584 *pucSupMcs32 = 0;
3585 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3586 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3587 break;
3588
3589 case FIXED_RATE_MCS1_40M_400NS:
3590 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3591 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3592 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3593 *pucMcsSet = HT_RATE_MCS1_INDEX;
3594 *pucSupMcs32 = 0;
3595 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3596 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3597 break;
3598
3599 case FIXED_RATE_MCS2_40M_400NS:
3600 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3601 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3602 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3603 *pucMcsSet = HT_RATE_MCS2_INDEX;
3604 *pucSupMcs32 = 0;
3605 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3606 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3607 break;
3608
3609 case FIXED_RATE_MCS3_40M_400NS:
3610 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3611 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3612 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3613 *pucMcsSet = HT_RATE_MCS3_INDEX;
3614 *pucSupMcs32 = 0;
3615 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3616 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3617 break;
3618
3619 case FIXED_RATE_MCS4_40M_400NS:
3620 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3621 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3622 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3623 *pucMcsSet = HT_RATE_MCS4_INDEX;
3624 *pucSupMcs32 = 0;
3625 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3626 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3627 break;
3628
3629 case FIXED_RATE_MCS5_40M_400NS:
3630 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3631 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3632 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3633 *pucMcsSet = HT_RATE_MCS5_INDEX;
3634 *pucSupMcs32 = 0;
3635 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3636 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3637 break;
3638
3639 case FIXED_RATE_MCS6_40M_400NS:
3640 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3641 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3642 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3643 *pucMcsSet = HT_RATE_MCS6_INDEX;
3644 *pucSupMcs32 = 0;
3645 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3646 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3647 break;
3648
3649 case FIXED_RATE_MCS7_40M_400NS:
3650 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3651 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3652 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3653 *pucMcsSet = HT_RATE_MCS7_INDEX;
3654 *pucSupMcs32 = 0;
3655 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3656 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3657 break;
3658
3659 case FIXED_RATE_MCS32_400NS:
3660 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3661 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3662 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3663 *pucMcsSet = HT_RATE_MCS32_INDEX;
3664 *pucSupMcs32 = 1;
3665 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3666 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3667 break;
3668
3669 default:
3670 ASSERT(0);
3671 }
3672
3673 return WLAN_STATUS_SUCCESS;
3674 }
3675
3676 /*----------------------------------------------------------------------------*/
3677 /*!
3678 * @brief This utility function is used to write the register
3679 *
3680 * @param u4Address Register address
3681 * u4Value the value to be written
3682 *
3683 * @retval WLAN_STATUS_SUCCESS
3684 * WLAN_STATUS_FAILURE
3685 */
3686 /*----------------------------------------------------------------------------*/
3687
3688 WLAN_STATUS nicWriteMcr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Address, IN UINT_32 u4Value)
3689 {
3690 CMD_ACCESS_REG rCmdAccessReg;
3691
3692 rCmdAccessReg.u4Address = u4Address;
3693 rCmdAccessReg.u4Data = u4Value;
3694
3695 return wlanSendSetQueryCmd(prAdapter,
3696 CMD_ID_ACCESS_REG,
3697 TRUE,
3698 FALSE,
3699 FALSE,
3700 NULL,
3701 NULL,
3702 sizeof(CMD_ACCESS_REG), (PUINT_8) &rCmdAccessReg, NULL, 0);
3703
3704 }
3705
3706 /*----------------------------------------------------------------------------*/
3707 /*!
3708 * @brief This utility function is used to modify the auto rate parameters
3709 *
3710 * @param u4ArSysParam0 see description below
3711 * u4ArSysParam1
3712 * u4ArSysParam2
3713 * u4ArSysParam3
3714 *
3715 *
3716 * @retval WLAN_STATUS_SUCCESS
3717 * WLAN_STATUS_FAILURE
3718 *
3719 * @note
3720 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
3721 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
3722 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
3723 * ArSysParam0[8:15]-> HT rate clear mask
3724 * ArSysParam0[16:31]-> Legacy rate clear mask
3725 * ArSysParam1[0:7]-> Auto Rate check weighting window
3726 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
3727 * ArSysParam1[16:23]-> Auto Rate v1 PerH
3728 * ArSysParam1[24:31]-> Auto Rate v1 PerL
3729 *
3730 * Examples
3731 * ArSysParam0 = 1,
3732 * Enable auto rate version 1
3733 *
3734 * ArSysParam0 = 983041,
3735 * Enable auto rate version 1
3736 * Remove CCK 1M, 2M, 5.5M, 11M
3737 *
3738 * ArSysParam0 = 786433
3739 * Enable auto rate version 1
3740 * Remove CCK 5.5M 11M
3741 */
3742 /*----------------------------------------------------------------------------*/
3743
3744
3745 WLAN_STATUS
3746 nicRlmArUpdateParms(IN P_ADAPTER_T prAdapter,
3747 IN UINT_32 u4ArSysParam0,
3748 IN UINT_32 u4ArSysParam1, IN UINT_32 u4ArSysParam2, IN UINT_32 u4ArSysParam3)
3749 {
3750 UINT_8 ucArVer, ucAbwVer, ucAgiVer;
3751 UINT_16 u2HtClrMask;
3752 UINT_16 u2LegacyClrMask;
3753 UINT_8 ucArCheckWindow;
3754 UINT_8 ucArPerL;
3755 UINT_8 ucArPerH;
3756 UINT_8 ucArPerForceRateDownPer;
3757
3758 ucArVer = (UINT_8) (u4ArSysParam0 & BITS(0, 3));
3759 ucAbwVer = (UINT_8) ((u4ArSysParam0 & BITS(4, 5)) >> 4);
3760 ucAgiVer = (UINT_8) ((u4ArSysParam0 & BITS(6, 7)) >> 6);
3761 u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8, 15)) >> 8);
3762 u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16, 31)) >> 16);
3763
3764 #if 0
3765 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
3766 ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8, 15) >> 8));
3767 ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16, 23)) >> 16);
3768 ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24, 31)) >> 24);
3769 #endif
3770
3771 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
3772 ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1 >> 8) & BITS(0, 7)));
3773 ucArPerH = (UINT_8) (((u4ArSysParam1 >> 16) & BITS(0, 7)));
3774 ucArPerL = (UINT_8) (((u4ArSysParam1 >> 24) & BITS(0, 7)));
3775
3776
3777 DBGLOG(INIT, INFO,
3778 ("ArParam %u %u %u %u\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2,
3779 u4ArSysParam3));
3780 DBGLOG(INIT, INFO, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer));
3781 DBGLOG(INIT, INFO, ("HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask));
3782 DBGLOG(INIT, INFO,
3783 ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow,
3784 ucArPerForceRateDownPer, ucArPerH, ucArPerL));
3785
3786 #define SWCR_DATA_ADDR(MOD, ADDR) (0x90000000+(MOD<<8)+(ADDR))
3787 #define SWCR_DATA_CMD(CATE, WRITE, INDEX, OPT0, OPT1) ((CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 << 8) | OPT1)
3788 #define SWCR_DATA0 0x0
3789 #define SWCR_DATA1 0x4
3790 #define SWCR_DATA2 0x8
3791 #define SWCR_DATA3 0xC
3792 #define SWCR_DATA4 0x10
3793 #define SWCR_WRITE 1
3794 #define SWCR_READ 0
3795
3796 if (ucArVer > 0) {
3797 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
3798 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000) */
3799
3800 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 1);
3801 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3802 SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
3803 } else {
3804 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 0);
3805 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3806 SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
3807 }
3808
3809 /* ucArVer 0: none 1:PER 2:Rcpi */
3810 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArVer);
3811 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3812 SWCR_DATA_CMD(0, SWCR_WRITE, 7, 0, 0));
3813
3814 /* Candidate rate Ht mask */
3815 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2HtClrMask);
3816 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3817 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1c, 0, 0));
3818
3819 /* Candidate rate legacy mask */
3820 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2LegacyClrMask);
3821 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3822 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1d, 0, 0));
3823
3824 #if 0
3825 if (ucArCheckWindow != 0) {
3826 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
3827 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
3828 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3829 SWCR_DATA_CMD(0, SWCR_WRITE, 0x14, 0, 0));
3830 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
3831 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3832 SWCR_DATA_CMD(0, SWCR_WRITE, 0xc, 0, 0));
3833 }
3834
3835 if (ucArPerForceRateDownPer != 0) {
3836 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1),
3837 ucArPerForceRateDownPer);
3838 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3839 SWCR_DATA_CMD(0, SWCR_WRITE, 0x18, 0, 0));
3840 }
3841 if (ucArPerH != 0) {
3842 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerH);
3843 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3844 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1, 0, 0));
3845 }
3846 if (ucArPerL != 0) {
3847 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerL);
3848 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3849 SWCR_DATA_CMD(0, SWCR_WRITE, 0x2, 0, 0));
3850 }
3851 #endif
3852
3853
3854
3855 return WLAN_STATUS_SUCCESS;
3856 }
3857
3858 /*----------------------------------------------------------------------------*/
3859 /*!
3860 * @brief This utility function is used to enable roaming
3861 *
3862 * @param u4EnableRoaming
3863 *
3864 *
3865 * @retval WLAN_STATUS_SUCCESS
3866 * WLAN_STATUS_FAILURE
3867 *
3868 * @note
3869 * u4EnableRoaming -> Enable Romaing
3870 *
3871 */
3872 /*----------------------------------------------------------------------------*/
3873 WLAN_STATUS nicRoamingUpdateParams(IN P_ADAPTER_T prAdapter, IN UINT_32 u4EnableRoaming)
3874 {
3875 P_CONNECTION_SETTINGS_T prConnSettings;
3876
3877 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
3878 prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming > 0) ? (TRUE) : (FALSE));
3879
3880 return WLAN_STATUS_SUCCESS;
3881 }
3882
3883 /*----------------------------------------------------------------------------*/
3884 /*!
3885 * \brief dump firmware Assert message
3886 *
3887 * \param[in]
3888 * prAdapter
3889 *
3890 * \return
3891 * TRUE
3892 * FALSE
3893 */
3894 /*----------------------------------------------------------------------------*/
3895 VOID nicPrintFirmwareAssertInfo(IN P_ADAPTER_T prAdapter)
3896 {
3897 UINT_32 u4MailBox0, u4MailBox1;
3898 UINT_32 line = 0;
3899 UINT_8 aucAssertFile[7];
3900 UINT_32 u4ChipId;
3901
3902 #if CFG_SDIO_INTR_ENHANCE
3903 u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
3904 u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
3905 #else
3906 nicGetMailbox(prAdapter, 0, &u4MailBox0);
3907 nicGetMailbox(prAdapter, 1, &u4MailBox1);
3908 #endif
3909
3910 line = u4MailBox0 & 0x0000FFFF;
3911
3912 u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
3913
3914 kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
3915 kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
3916
3917 aucAssertFile[6] = '\0';
3918
3919 #if defined(MT6620)
3920 u4ChipId = 6620;
3921 #elif defined(MT5931)
3922 u4ChipId = 5931;
3923 #elif defined(MT6628)
3924 u4ChipId = 6628;
3925 #endif
3926
3927 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
3928 u4ChipId, aucAssertFile, line);
3929
3930 }
3931
3932
3933 /*----------------------------------------------------------------------------*/
3934 /*!
3935 * @brief This function is called to update Link Quality information
3936 *
3937 * @param prAdapter Pointer of Adapter Data Structure
3938 * eNetTypeIdx
3939 * prEventLinkQuality
3940 * cRssi
3941 * cLinkQuality
3942 *
3943 * @return none
3944 */
3945 /*----------------------------------------------------------------------------*/
3946 VOID
3947 nicUpdateLinkQuality(IN P_ADAPTER_T prAdapter,
3948 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
3949 IN P_EVENT_LINK_QUALITY prEventLinkQuality)
3950 {
3951 ASSERT(prAdapter);
3952 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
3953 ASSERT(prEventLinkQuality);
3954
3955 switch (eNetTypeIdx) {
3956 case NETWORK_TYPE_AIS_INDEX:
3957 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
3958 PARAM_MEDIA_STATE_CONNECTED) {
3959 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
3960 /* buffer statistics for further query */
3961 if (prAdapter->fgIsLinkQualityValid == FALSE
3962 || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) >
3963 CFG_LINK_QUALITY_VALID_PERIOD) {
3964 nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi,
3965 prEventLinkQuality->cLinkQuality);
3966 }
3967
3968 if (prAdapter->fgIsLinkRateValid == FALSE
3969 || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) >
3970 CFG_LINK_QUALITY_VALID_PERIOD) {
3971 nicUpdateLinkSpeed(prAdapter, eNetTypeIdx,
3972 prEventLinkQuality->u2LinkSpeed);
3973 }
3974 }
3975 break;
3976 #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
3977 case NETWORK_TYPE_P2P_INDEX:
3978 if (prAdapter->fgIsP2pLinkQualityValid == FALSE
3979 || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) >
3980 CFG_LINK_QUALITY_VALID_PERIOD) {
3981 P_EVENT_LINK_QUALITY_EX prEventLQEx =
3982 (P_EVENT_LINK_QUALITY_EX) prEventLinkQuality;
3983
3984 nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P,
3985 prEventLQEx->cLinkQualityP2P);
3986 }
3987 break;
3988 #endif
3989 default:
3990 break;
3991
3992 }
3993
3994 return;
3995 }
3996
3997
3998 /*----------------------------------------------------------------------------*/
3999 /*!
4000 * @brief This function is called to update RSSI and Link Quality information
4001 *
4002 * @param prAdapter Pointer of Adapter Data Structure
4003 * eNetTypeIdx
4004 * cRssi
4005 * cLinkQuality
4006 *
4007 * @return none
4008 */
4009 /*----------------------------------------------------------------------------*/
4010 VOID
4011 nicUpdateRSSI(IN P_ADAPTER_T prAdapter,
4012 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN INT_8 cRssi, IN INT_8 cLinkQuality)
4013 {
4014 ASSERT(prAdapter);
4015 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4016
4017 switch (eNetTypeIdx) {
4018 case NETWORK_TYPE_AIS_INDEX:
4019 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
4020 PARAM_MEDIA_STATE_CONNECTED) {
4021 prAdapter->fgIsLinkQualityValid = TRUE;
4022 prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
4023
4024 prAdapter->rLinkQuality.cRssi = cRssi;
4025 prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
4026
4027 /* indicate to glue layer */
4028 kalUpdateRSSI(prAdapter->prGlueInfo,
4029 KAL_NETWORK_TYPE_AIS_INDEX,
4030 prAdapter->rLinkQuality.cRssi,
4031 prAdapter->rLinkQuality.cLinkQuality);
4032 }
4033
4034 break;
4035 #if CFG_ENABLE_WIFI_DIRECT
4036 #if CFG_SUPPORT_P2P_RSSI_QUERY
4037 case NETWORK_TYPE_P2P_INDEX:
4038 prAdapter->fgIsP2pLinkQualityValid = TRUE;
4039 prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
4040
4041 prAdapter->rP2pLinkQuality.cRssi = cRssi;
4042 prAdapter->rP2pLinkQuality.cLinkQuality = cLinkQuality;
4043
4044 kalUpdateRSSI(prAdapter->prGlueInfo,
4045 KAL_NETWORK_TYPE_P2P_INDEX, cRssi, cLinkQuality);
4046 break;
4047 #endif
4048 #endif
4049 default:
4050 break;
4051
4052 }
4053
4054 return;
4055 }
4056
4057
4058 /*----------------------------------------------------------------------------*/
4059 /*!
4060 * @brief This function is called to update Link Quality information
4061 *
4062 * @param prAdapter Pointer of Adapter Data Structure
4063 * eNetTypeIdx
4064 * prEventLinkQuality
4065 * cRssi
4066 * cLinkQuality
4067 *
4068 * @return none
4069 */
4070 /*----------------------------------------------------------------------------*/
4071 VOID
4072 nicUpdateLinkSpeed(IN P_ADAPTER_T prAdapter,
4073 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN UINT_16 u2LinkSpeed)
4074 {
4075 ASSERT(prAdapter);
4076 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4077
4078 switch (eNetTypeIdx) {
4079 case NETWORK_TYPE_AIS_INDEX:
4080 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
4081 PARAM_MEDIA_STATE_CONNECTED) {
4082 /* buffer statistics for further query */
4083 prAdapter->fgIsLinkRateValid = TRUE;
4084 prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
4085
4086 prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
4087 }
4088 break;
4089
4090 default:
4091 break;
4092
4093 }
4094
4095 return;
4096 }
4097
4098 #if CFG_SUPPORT_RDD_TEST_MODE
4099 WLAN_STATUS nicUpdateRddTestMode(IN P_ADAPTER_T prAdapter, IN P_CMD_RDD_CH_T prRddChParam)
4100 {
4101 DEBUGFUNC("nicUpdateRddTestMode.\n");
4102
4103 ASSERT(prAdapter);
4104
4105 /* aisFsmScanRequest(prAdapter, NULL); */
4106
4107 return wlanSendSetQueryCmd(prAdapter,
4108 CMD_ID_SET_RDD_CH,
4109 TRUE,
4110 FALSE,
4111 FALSE,
4112 NULL,
4113 NULL, sizeof(CMD_RDD_CH_T), (PUINT_8) prRddChParam, NULL, 0);
4114 }
4115 #endif