2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic.c#2 $
6 \brief Functions that provide operation in NIC's (Network Interface Card) point of view.
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.
18 * 07 17 2012 yuche.tsai
20 * Compile no error before trial run.
24 * Set the default value of AP StaRec index to "STA_REC_INDEX_NOT_FOUND" in update firmware bss command.
28 * Sync CFG80211 modification from branch 2,2.
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
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.
39 * 11 19 2011 yuche.tsai
41 * Update RSSI for P2P.
43 * 11 18 2011 yuche.tsai
45 * CONFIG P2P support RSSI query, default turned off.
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.
52 * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
53 * pre-check for NULL before calling MMPDU free function
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
59 * 11 01 2011 chinglan.wang
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..
66 * Rewrite Assert Dump Function for Portability.
69 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
70 * New CMD definition about RLM parameters
73 * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
74 * reuse firmware download logic of MT6620 for MT6628.
77 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
78 * Reply Probe Rsp in FW for Hotspot Mode.
83 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
84 * Reply Probe Rsp in FW for Hotspot Mode.
88 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
89 * Reply Probe Rsp in FW for Hotspot Mode.
92 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
93 * Reply Probe Rsp in FW for Hotspot Mode.
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.
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.
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.
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
110 * 2. replace only BSS-DESC which doesn't have a valid SSID.
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
116 * 05 12 2011 puff.wen
118 * FW Assert information dump to driver
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.
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.
128 * 04 14 2011 cm.chang
129 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
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.
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
143 * enable the p2p check the cipher to set the bssInfo auth mode.
147 * prepare the code for sync the auth mode and encryption status for P2P and BOW.
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.
153 * 04 10 2011 george.huang
154 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
155 * Fix compiler issue.
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
161 * 04 08 2011 eddie.chen
162 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
166 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
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.
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.
178 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
179 * portability improvement
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
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
190 * The windows part remained the same as before, but added similiar APIs to hide the difference.
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
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
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.
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.
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.
214 * 02 01 2011 terry.wu
215 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
218 * 02 01 2011 cm.chang
219 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
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
226 * 01 27 2011 tsaiyuan.hsu
227 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
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.
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
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
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
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
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
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
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
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
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.
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
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.
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
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.
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
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
300 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
301 * add HT (802.11n) fixed rate support.
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)
308 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
309 * add firmware download for MT5931.
312 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
313 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
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
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
325 * use static memory pool for storing IEs of scanning result.
329 * Androi/Linux: return current operating channel information
333 * HIFSYS Clock Source Workaround
335 * 08 26 2010 yuche.tsai
337 * Fix someones coding error while enable WIFI_DIRECT.
339 * 08 25 2010 george.huang
341 * update OID/ registry control path for PM related settings
343 * 08 24 2010 cm.chang
345 * Support RLM initail channel of Ad-hoc, P2P and BOW
347 * 08 24 2010 chinghwa.yu
349 * Update BOW for the 1st time.
351 * 08 23 2010 chinghwa.yu
355 * 08 20 2010 yuche.tsai
357 * Add state change indication.
359 * 08 16 2010 yuche.tsai
361 * Add support for P2P BSS update info.
365 * [removing debugging] not to dump beacon content.
369 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
373 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
374 * 2) extending scanning result to 64 instead of 48
376 * 08 04 2010 yarco.yang
378 * Add TX_AMPDU and ADDBA_REJECT command
382 * surpress compilation warning.
386 * Centralize mgmt/system service procedures into independent calls.
390 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
391 * 2) change nicMediaStateChange() API prototype
395 * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
399 * .support the Wi-Fi RSN
403 * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
405 * 07 22 2010 george.huang
409 * 07 22 2010 george.huang
411 * Update fgIsQoS information in BSS INFO by CMD
415 * [WPD00003833] [MT6620 and MT5931] Driver migration.
416 * Add Ad-Hoc support to AIS-FSM
418 * 07 14 2010 yarco.yang
420 * 1. Remove CFG_MQM_MIGRATION
421 * 2. Add CMD_UPDATE_WMM_PARMS command
425 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
428 * [WPD00003833][MT6620 and MT5931] Driver migration
429 * update prStaRecOfAP with BSS-INFO.
431 * 07 06 2010 george.huang
432 * [WPD00001556]Basic power managemenet function
433 * Update arguments for nicUpdateBeaconIETemplate()
436 * [WPD00003833][MT6620 and MT5931] Driver migration
437 * STA-REC is maintained by CNM only.
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
445 * 07 01 2010 cm.chang
446 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
447 * Support sync command of STA_REC
450 * [WPD00003833][MT6620 and MT5931] Driver migration
451 * sync. with CMD/EVENT document ver0.07.
454 * [WPD00003833][MT6620 and MT5931] Driver migration
455 * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
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
466 * 06 25 2010 george.huang
467 * [WPD00001556]Basic power managemenet function
468 * Create beacon update path, with expose bssUpdateBeaconContent()
471 * [WPD00003833][MT6620 and MT5931] Driver migration
472 * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
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.
481 * [WPD00003833][MT6620 and MT5931] Driver migration
482 * implement TX_DONE callback path.
485 * [WPD00003840][MT6620 5931] Security migration
486 * remove duplicate variable for migration.
489 * [WPD00003833][MT6620 and MT5931] Driver migration
490 * TX descriptors are now allocated once for reducing allocation overhead
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
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
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)
509 * 06 06 2010 kevin.huang
510 * [WPD00003832][MT6620 5931] Create driver base
511 * [MT6620 5931] Create driver base
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
519 * [WPD00001943]Create WiFi test driver framework on WinXP
520 * surpress compiler warning
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
530 * [WPD00001943]Create WiFi test driver framework on WinXP
531 * add channel frequency <-> number conversion
534 * [WPD00001943]Create WiFi test driver framework on WinXP
535 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
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
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
547 * [WPD00001943]Create WiFi test driver framework on WinXP
548 * always process TX interrupt first then RX interrupt.
551 * [WPD00001943]Create WiFi test driver framework on WinXP
552 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
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
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
574 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
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
610 /*******************************************************************************
611 * C O M P I L E R F L A G S
612 ********************************************************************************
615 /*******************************************************************************
616 * E X T E R N A L R E F E R E N C E S
617 ********************************************************************************
622 /*******************************************************************************
624 ********************************************************************************
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 */
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)
644 #define GATING_CONTROL_POLL_LIMIT 64
647 /*******************************************************************************
649 ********************************************************************************
652 /*******************************************************************************
653 * P U B L I C D A T A
654 ********************************************************************************
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
}
664 static const UINT_8 ucIntEventMapSize
= (sizeof(arIntEventMapTable
) / sizeof(INT_EVENT_MAP_T
));
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 */
673 /*******************************************************************************
674 * P R I V A T E D A T A
675 ********************************************************************************
678 /*******************************************************************************
680 ********************************************************************************
682 /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
683 * and also enhance the readability.
685 #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
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)); \
692 ASSERT(((UINT_32)pucMem % 4) == 0); \
693 DBGLOG(INIT, INFO, ("Virtual Address = %08lx for %s.\n", (UINT_32)pucMem, pucComment)); \
698 /*******************************************************************************
699 * F U N C T I O N D E C L A R A T I O N S
700 ********************************************************************************
703 /*******************************************************************************
705 ********************************************************************************
709 /*----------------------------------------------------------------------------*/
711 * @brief This routine is responsible for the allocation of the data structures
712 * inside the Adapter structure, include:
714 * 2. Common coalescing buffer for TX PATH.
716 * @param prAdapter Pointer of Adapter Data Structure
718 * @retval WLAN_STATUS_SUCCESS - Has enough memory.
719 * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
721 /*----------------------------------------------------------------------------*/
722 WLAN_STATUS
nicAllocateAdapterMemory(IN P_ADAPTER_T prAdapter
)
724 WLAN_STATUS status
= WLAN_STATUS_RESOURCES
;
725 P_RX_CTRL_T prRxCtrl
;
726 P_TX_CTRL_T prTxCtrl
;
728 DEBUGFUNC("nicAllocateAdapterMemory");
731 prRxCtrl
= &prAdapter
->rRxCtrl
;
732 prTxCtrl
= &prAdapter
->rTxCtrl
;
735 /* 4 <0> Reset all Memory Handler */
737 prAdapter
->u4MemFreeDynamicCount
= 0;
738 prAdapter
->u4MemAllocDynamicCount
= 0;
740 prAdapter
->pucMgtBufCached
= (PUINT_8
) NULL
;
741 prRxCtrl
->pucRxCached
= (PUINT_8
) NULL
;
742 prAdapter
->prSDIOCtrl
= (P_SDIO_CTRL_T
) NULL
;
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
;
749 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter
->pucMgtBufCached
,
750 prAdapter
->u4MgtBufCachedSize
,
751 VIR_MEM_TYPE
, "COMMON MGMT MEMORY POOL");
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.
758 /* Allocate memory for the SW receive structures. */
759 prRxCtrl
->u4RxCachedSize
= CFG_RX_MAX_PKT_NUM
* ALIGN_4(sizeof(SW_RFB_T
));
761 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl
->pucRxCached
,
762 prRxCtrl
->u4RxCachedSize
, VIR_MEM_TYPE
, "SW_RFB_T");
764 /* 4 <3> Memory for TX DEscriptor */
765 prTxCtrl
->u4TxCachedSize
= CFG_TX_MAX_PKT_NUM
* ALIGN_4(sizeof(MSDU_INFO_T
));
767 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl
->pucTxCached
,
768 prTxCtrl
->u4TxCachedSize
, VIR_MEM_TYPE
, "MSDU_INFO_T");
770 /* 4 <4> Memory for Common Coalescing Buffer */
771 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
772 prAdapter
->pucCoalescingBufCached
= (PUINT_8
) NULL
;
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
;
780 prAdapter
->pucCoalescingBufCached
=
781 kalAllocateIOBuffer(prAdapter
->u4CoalescingBufCachedSize
);
783 if (prAdapter
->pucCoalescingBufCached
== NULL
) {
785 ("Could not allocate %ld bytes for coalescing buffer.\n",
786 prAdapter
->u4CoalescingBufCachedSize
));
789 #endif /* CFG_COALESCING_BUFFER_SIZE */
791 /* 4 <5> Memory for enhanced interrupt response */
792 prAdapter
->prSDIOCtrl
= (P_SDIO_CTRL_T
)
793 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T
));
795 if (prAdapter
->prSDIOCtrl
== NULL
) {
797 ("Could not allocate %u bytes for interrupt response.\n",
798 sizeof(ENHANCE_MODE_DATA_STRUCT_T
)));
802 status
= WLAN_STATUS_SUCCESS
;
807 if (status
!= WLAN_STATUS_SUCCESS
) {
808 nicReleaseAdapterMemory(prAdapter
);
813 } /* end of nicAllocateAdapterMemory() */
816 /*----------------------------------------------------------------------------*/
818 * @brief This routine is responsible for releasing the allocated memory by
819 * nicAllocatedAdapterMemory().
821 * @param prAdapter Pointer of Adapter Data Structure
825 /*----------------------------------------------------------------------------*/
826 VOID
nicReleaseAdapterMemory(IN P_ADAPTER_T prAdapter
)
828 P_TX_CTRL_T prTxCtrl
;
829 P_RX_CTRL_T prRxCtrl
;
832 prTxCtrl
= &prAdapter
->rTxCtrl
;
833 prRxCtrl
= &prAdapter
->rRxCtrl
;
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
;
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
;
848 #endif /* CFG_COALESCING_BUFFER_SIZE */
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
;
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
;
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
;
867 /* Check if all allocated memories are free */
868 ASSERT(prAdapter
->u4MemFreeDynamicCount
== prAdapter
->u4MemAllocDynamicCount
);
875 /*----------------------------------------------------------------------------*/
877 * @brief disable global interrupt
879 * @param prAdapter pointer to the Adapter handler
883 /*----------------------------------------------------------------------------*/
884 VOID
nicDisableInterrupt(IN P_ADAPTER_T prAdapter
)
888 HAL_BYTE_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_INT_EN_CLR
);
890 prAdapter
->fgIsIntEnable
= FALSE
;
893 /*----------------------------------------------------------------------------*/
895 * @brief enable global interrupt
897 * @param prAdapter pointer to the Adapter handler
901 /*----------------------------------------------------------------------------*/
902 VOID
nicEnableInterrupt(IN P_ADAPTER_T prAdapter
)
904 BOOLEAN fgIsIntEnableCache
;
908 fgIsIntEnableCache
= prAdapter
->fgIsIntEnable
;
910 prAdapter
->fgIsIntEnable
= TRUE
; /* NOTE(Kevin): It must be placed before MCR GINT write. */
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.
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
;
922 /* If INT was not enabled, enable it and also set LPOwn now */
924 HAL_MCR_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_FW_OWN_REQ_SET
|
926 prAdapter
->fgIsFwOwn
= TRUE
;
929 /* If INT was not enabled, enable it now */
930 else if (!fgIsIntEnableCache
) {
931 HAL_BYTE_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_INT_EN_SET
);
935 } /* end of nicEnableInterrupt() */
938 #if CFG_SDIO_INTR_ENHANCE
939 /*----------------------------------------------------------------------------*/
941 * @brief For SDIO enhance mode, set the max rx len and tx status
943 * @param prAdapter a pointer to adapter private data structure.
947 /*----------------------------------------------------------------------------*/
948 VOID
nicSDIOInit(IN P_ADAPTER_T prAdapter
)
954 /* 4 <1> Check STATUS Buffer is DW alignment. */
955 ASSERT(IS_ALIGN_4((UINT_32
) &prAdapter
->prSDIOCtrl
->u4WHISR
));
957 /* 4 <2> Setup STATUS count. */
959 HAL_MCR_RD(prAdapter
, MCR_WHCR
, &u4Value
);
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
));
965 /* 4 <2.2> Setup RX enhancement mode */
966 #if CFG_SDIO_RX_ENHANCE
967 u4Value
|= WHCR_RX_ENHANCE_MODE_EN
;
969 u4Value
&= ~WHCR_RX_ENHANCE_MODE_EN
;
970 #endif /* CFG_SDIO_RX_AGG */
972 HAL_MCR_WR(prAdapter
, MCR_WHCR
, u4Value
);
977 } /* end of nicSDIOInit() */
979 /*----------------------------------------------------------------------------*/
981 * @brief Read interrupt status from hardware
983 * @param prAdapter pointer to the Adapter handler
984 * @param the interrupts
989 /*----------------------------------------------------------------------------*/
990 VOID
nicSDIOReadIntStatus(IN P_ADAPTER_T prAdapter
, OUT PUINT_32 pu4IntStatus
)
992 P_SDIO_CTRL_T prSDIOCtrl
;
994 DEBUGFUNC("nicSDIOReadIntStatus");
997 ASSERT(pu4IntStatus
);
999 prSDIOCtrl
= prAdapter
->prSDIOCtrl
;
1002 HAL_PORT_RD(prAdapter
,
1004 sizeof(ENHANCE_MODE_DATA_STRUCT_T
),
1005 (PUINT_8
) prSDIOCtrl
, sizeof(ENHANCE_MODE_DATA_STRUCT_T
));
1007 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
|| fgIsBusAccessFailed
== TRUE
) {
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
;
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);
1024 *pu4IntStatus
= prSDIOCtrl
->u4WHISR
;
1027 } /* end of nicSDIOReadIntStatus() */
1030 /*----------------------------------------------------------------------------*/
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
1036 * @param prAdapter pointer to the Adapter handler
1038 * @retval WLAN_STATUS_SUCCESS
1039 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1041 /*----------------------------------------------------------------------------*/
1042 WLAN_STATUS
nicProcessIST(IN P_ADAPTER_T prAdapter
)
1044 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1045 UINT_32 u4IntStatus
= 0;
1048 DEBUGFUNC("nicProcessIST");
1049 /* DBGLOG(INIT, LOUD, ("\n")); */
1053 if (prAdapter
->rAcpiState
== ACPI_STATE_D3
) {
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
;
1059 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1060 if (prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
1061 nicDisableClockGating(prAdapter
);
1065 for (i
= 0; i
< CFG_IST_LOOP_COUNT
; i
++) {
1067 #if CFG_SDIO_INTR_ENHANCE
1068 nicSDIOReadIntStatus(prAdapter
, &u4IntStatus
);
1070 HAL_MCR_RD(prAdapter
, MCR_WHISR
, &u4IntStatus
);
1071 #endif /* CFG_SDIO_INTR_ENHANCE */
1073 /* DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus)); */
1075 if (u4IntStatus
& ~(WHIER_DEFAULT
| WHIER_FW_OWN_BACK_INT_EN
)) {
1076 DBGLOG(INTR
, WARN
, ("Un-handled HISR %#lx, HISR = %#lx (HIER:0x%lx)\n",
1077 (u4IntStatus
& ~WHIER_DEFAULT
), u4IntStatus
,
1079 u4IntStatus
&= WHIER_DEFAULT
;
1082 nicProcessIST_impl(prAdapter
, u4IntStatus
);
1084 if (u4IntStatus
== 0) {
1086 u4Status
= WLAN_STATUS_NOT_INDICATING
;
1092 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1093 if (prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
1094 nicEnableClockGating(prAdapter
);
1099 } /* end of nicProcessIST() */
1102 /*----------------------------------------------------------------------------*/
1104 * @brief The function used to dispatch the appropriate functions for specific
1107 * @param prAdapter pointer to the Adapter handler
1108 * u4IntStatus interrupt status bits
1110 * @retval WLAN_STATUS_SUCCESS
1111 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1113 /*----------------------------------------------------------------------------*/
1114 WLAN_STATUS
nicProcessIST_impl(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4IntStatus
)
1116 UINT_32 u4IntCount
= 0;
1117 P_INT_EVENT_MAP_T prIntEventMap
= NULL
;
1121 prAdapter
->u4IntStatus
= u4IntStatus
;
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
) {
1130 } else if (apfnEventFuncTable
[prIntEventMap
->u4Event
] != NULL
) {
1131 apfnEventFuncTable
[prIntEventMap
->u4Event
] (prAdapter
);
1134 ("Empty INTR handler! ISAR bit#: %lu, event:%lu, func: %p\n",
1135 prIntEventMap
->u4Int
, prIntEventMap
->u4Event
,
1136 apfnEventFuncTable
[prIntEventMap
->u4Event
]));
1138 ASSERT(0); /* to trap any NULL interrupt handler */
1140 prAdapter
->u4IntStatus
&= ~prIntEventMap
->u4Int
;
1144 return WLAN_STATUS_SUCCESS
;
1145 } /* end of nicProcessIST_impl() */
1148 /*----------------------------------------------------------------------------*/
1150 * @brief Verify the CHIP ID
1152 * @param prAdapter a pointer to adapter private data structure.
1155 * @retval TRUE CHIP ID is the same as the setting compiled
1156 * @retval FALSE CHIP ID is different from the setting compiled
1158 /*----------------------------------------------------------------------------*/
1159 BOOL
nicVerifyChipID(IN P_ADAPTER_T prAdapter
)
1165 HAL_MCR_RD(prAdapter
, MCR_WCIR
, &u4CIR
);
1167 DBGLOG(INIT
, TRACE
, ("Chip ID: 0x%lx\n", u4CIR
& WCIR_CHIP_ID
));
1168 DBGLOG(INIT
, TRACE
, ("Revision ID: 0x%lx\n", ((u4CIR
& WCIR_REVISION_ID
) >> 16)));
1170 if ((u4CIR
& WCIR_CHIP_ID
) != MTK_CHIP_REV
) {
1174 prAdapter
->ucRevID
= (UINT_8
) (((u4CIR
& WCIR_REVISION_ID
) >> 16) & 0xF);
1179 /*----------------------------------------------------------------------------*/
1181 * @brief Initialize the MCR to the appropriate init value, and verify the init
1184 * @param prAdapter a pointer to adapter private data structure.
1188 /*----------------------------------------------------------------------------*/
1189 VOID
nicMCRInit(IN P_ADAPTER_T prAdapter
)
1194 /* 4 <0> Initial value */
1197 VOID
nicHifInit(IN P_ADAPTER_T prAdapter
)
1203 nicPutMailbox(prAdapter
, 0, 0x52455345); /* RESE */
1204 nicPutMailbox(prAdapter
, 1, 0x545F5746); /* T_WF */
1205 nicSetSwIntr(prAdapter
, BIT(16));
1210 /*----------------------------------------------------------------------------*/
1212 * @brief Initialize the Adapter soft variable
1214 * @param prAdapter pointer to the Adapter handler
1219 /*----------------------------------------------------------------------------*/
1220 WLAN_STATUS
nicInitializeAdapter(IN P_ADAPTER_T prAdapter
)
1222 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1226 prAdapter
->fgIsIntEnableWithLPOwnSet
= FALSE
;
1229 if (!nicVerifyChipID(prAdapter
)) {
1230 u4Status
= WLAN_STATUS_FAILURE
;
1233 /* 4 <1> MCR init */
1234 nicMCRInit(prAdapter
);
1236 #if CFG_SDIO_INTR_ENHANCE
1237 nicSDIOInit(prAdapter
);
1238 #endif /* CFG_SDIO_INTR_ENHANCE */
1240 HAL_MCR_WR(prAdapter
, MCR_WHIER
, WHIER_DEFAULT
);
1243 /* 4 <2> init FW HIF */
1244 nicHifInit(prAdapter
);
1253 #if defined(_HIF_SPI)
1254 /*----------------------------------------------------------------------------*/
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
1260 * \param[in] prAdapter a pointer to adapter private data structure.
1261 * \param[in] eGPIO2_Mode GPIO2 operation mode
1265 /*----------------------------------------------------------------------------*/
1266 void nicRestoreSpiDefMode(IN P_ADAPTER_T prAdapter
)
1270 HAL_MCR_WR(prAdapter
, MCR_WCSR
, SPICSR_8BIT_MODE_DATA
);
1275 /*----------------------------------------------------------------------------*/
1277 * @brief Process rx interrupt. When the rx
1278 * Interrupt is asserted, it means there are frames in queue.
1280 * @param prAdapter Pointer to the Adapter structure.
1284 /*----------------------------------------------------------------------------*/
1285 VOID
nicProcessAbnormalInterrupt(IN P_ADAPTER_T prAdapter
)
1289 HAL_MCR_RD(prAdapter
, MCR_WASR
, &u4Value
);
1290 DBGLOG(REQ
, WARN
, ("MCR_WASR: 0x%lx\n", u4Value
));
1293 /*----------------------------------------------------------------------------*/
1297 * @param prAdapter Pointer to the Adapter structure.
1301 /*----------------------------------------------------------------------------*/
1302 VOID
nicProcessFwOwnBackInterrupt(IN P_ADAPTER_T prAdapter
)
1306 } /* end of nicProcessFwOwnBackInterrupt() */
1308 /*----------------------------------------------------------------------------*/
1312 * @param prAdapter Pointer to the Adapter structure.
1316 /*----------------------------------------------------------------------------*/
1317 VOID
nicProcessSoftwareInterrupt(IN P_ADAPTER_T prAdapter
)
1323 u4IntrBits
= prAdapter
->u4IntStatus
& BITS(8, 31);
1325 if ((u4IntrBits
& WHISR_D2H_SW_ASSERT_INFO_INT
) != 0) {
1326 nicPrintFirmwareAssertInfo(prAdapter
);
1327 #if CFG_CHIP_RESET_SUPPORT
1328 glSendResetRequest();
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
));
1335 if (u4IntrBits
& ACK_GATING_ENABLE_D2H_INT
) {
1336 prAdapter
->fgIsClockGatingEnabled
= TRUE
;
1339 if (u4IntrBits
& ACK_GATING_DISABLE_D2H_INT
) {
1340 prAdapter
->fgIsClockGatingEnabled
= FALSE
;
1342 /* Indicate Service Thread for TX */
1343 if (kalGetTxPendingCmdCount(prAdapter
->prGlueInfo
) > 0
1344 || wlanGetTxPendingFrameCount(prAdapter
) > 0) {
1345 kalSetEvent(prAdapter
->prGlueInfo
);
1350 DBGLOG(REQ
, WARN
, ("u4IntrBits: 0x%lx\n", u4IntrBits
));
1353 } /* end of nicProcessSoftwareInterrupt() */
1355 VOID
nicPutMailbox(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4MailboxNum
, IN UINT_32 u4Data
)
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
);
1366 VOID
nicGetMailbox(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4MailboxNum
, OUT PUINT_32 pu4Data
)
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
);
1377 VOID
nicSetSwIntr(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4SwIntrBitmap
)
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
1383 ASSERT((u4SwIntrBitmap
& BITS(0, 15)) == 0);
1384 /* DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap)); */
1386 HAL_MCR_WR(prAdapter
, MCR_WSICR
, u4SwIntrBitmap
);
1390 /*----------------------------------------------------------------------------*/
1392 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1393 * with specified sequential number
1395 * @param prAdapter Pointer of ADAPTER_T
1396 * ucSeqNum Sequential Number
1398 * @retval - P_CMD_INFO_T
1400 /*----------------------------------------------------------------------------*/
1401 P_CMD_INFO_T
nicGetPendingCmdInfo(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucSeqNum
)
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
;
1409 GLUE_SPIN_LOCK_DECLARATION();
1413 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
1415 prCmdQue
= &prAdapter
->rPendingCmdQueue
;
1416 QUEUE_MOVE_ALL(prTempCmdQue
, prCmdQue
);
1418 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1419 while (prQueueEntry
) {
1420 prCmdInfo
= (P_CMD_INFO_T
) prQueueEntry
;
1422 if (prCmdInfo
->ucCmdSeqNum
== ucSeqNum
)
1425 QUEUE_INSERT_TAIL(prCmdQue
, prQueueEntry
);
1430 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1432 QUEUE_CONCATENATE_QUEUES(prCmdQue
, prTempCmdQue
);
1434 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
1440 /*----------------------------------------------------------------------------*/
1442 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1443 * with specified sequential number
1445 * @param prAdapter Pointer of ADAPTER_T
1446 * ucSeqNum Sequential Number
1448 * @retval - P_MSDU_INFO_T
1450 /*----------------------------------------------------------------------------*/
1451 P_MSDU_INFO_T
nicGetPendingTxMsduInfo(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucSeqNum
)
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
;
1459 GLUE_SPIN_LOCK_DECLARATION();
1463 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1465 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1466 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1468 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1469 while (prQueueEntry
) {
1470 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1472 if (prMsduInfo
->ucTxSeqNum
== ucSeqNum
)
1475 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1480 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1482 QUEUE_CONCATENATE_QUEUES(prTxingQue
, prTempQue
);
1484 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1489 P_MSDU_INFO_T
nicGetPendingStaMMPDU(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucStaRecIdx
)
1491 P_MSDU_INFO_T prMsduInfoListHead
= (P_MSDU_INFO_T
) NULL
;
1492 P_QUE_T prTxingQue
= (P_QUE_T
) NULL
;
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
;
1498 GLUE_SPIN_LOCK_DECLARATION();
1500 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1502 if (prAdapter
== NULL
) {
1508 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1509 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1511 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1512 while (prQueueEntry
) {
1513 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1515 if ((prMsduInfo
->ucStaRecIndex
== ucStaRecIdx
)
1516 && (prMsduInfo
->pfTxDoneHandler
!= NULL
)) {
1517 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo
, prMsduInfoListHead
);
1518 prMsduInfoListHead
= prMsduInfo
;
1520 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1526 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1530 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1533 return prMsduInfoListHead
;
1534 } /* nicGetPendingStaMMPDU */
1538 nicFreePendingTxMsduInfoByNetwork(IN P_ADAPTER_T prAdapter
,
1539 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
)
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
;
1549 GLUE_SPIN_LOCK_DECLARATION();
1553 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1555 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1556 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1558 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1559 while (prQueueEntry
) {
1560 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1562 if ((ENUM_NETWORK_TYPE_INDEX_T
) (prMsduInfo
->ucNetworkType
) == eNetworkType
) {
1563 if (prMsduInfoListHead
== NULL
) {
1564 prMsduInfoListHead
= prMsduInfoListTail
= prMsduInfo
;
1566 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail
, prMsduInfo
);
1567 prMsduInfoListTail
= prMsduInfo
;
1570 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1575 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1577 QUEUE_CONCATENATE_QUEUES(prTxingQue
, prTempQue
);
1579 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1582 if (prMsduInfoListHead
) {
1583 nicTxFreeMsduInfoPacket(prAdapter
, prMsduInfoListHead
);
1588 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1592 /*----------------------------------------------------------------------------*/
1594 * @brief This procedure is used to retrieve a CMD sequence number atomically
1596 * @param prAdapter Pointer of ADAPTER_T
1600 /*----------------------------------------------------------------------------*/
1601 UINT_8
nicIncreaseCmdSeqNum(IN P_ADAPTER_T prAdapter
)
1605 KAL_SPIN_LOCK_DECLARATION();
1609 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_SEQ_NUM
);
1611 prAdapter
->ucCmdSeqNum
++;
1612 ucRetval
= prAdapter
->ucCmdSeqNum
;
1614 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_SEQ_NUM
);
1620 /*----------------------------------------------------------------------------*/
1622 * @brief This procedure is used to retrieve a TX sequence number atomically
1624 * @param prAdapter Pointer of ADAPTER_T
1628 /*----------------------------------------------------------------------------*/
1629 UINT_8
nicIncreaseTxSeqNum(IN P_ADAPTER_T prAdapter
)
1633 KAL_SPIN_LOCK_DECLARATION();
1637 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_SEQ_NUM
);
1639 prAdapter
->ucTxSeqNum
++;
1640 ucRetval
= prAdapter
->ucTxSeqNum
;
1642 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_SEQ_NUM
);
1649 /*----------------------------------------------------------------------------*/
1651 * @brief This utility function is used to handle
1652 * media state change event
1658 /*----------------------------------------------------------------------------*/
1660 nicMediaStateChange(IN P_ADAPTER_T prAdapter
,
1661 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
,
1662 IN P_EVENT_CONNECTION_STATUS prConnectionStatus
)
1664 P_GLUE_INFO_T prGlueInfo
;
1667 prGlueInfo
= prAdapter
->prGlueInfo
;
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
) {
1674 kalIndicateStatusAndComplete(prGlueInfo
,
1675 WLAN_STATUS_MEDIA_DISCONNECT
, NULL
, 0);
1677 prAdapter
->rWlanInfo
.u4SysTime
= kalGetTimeTick();
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();
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
;
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);
1711 /* connected -> connected : roaming ? */
1712 kalIndicateStatusAndComplete(prGlueInfo
,
1713 WLAN_STATUS_ROAM_OUT_FIND_BEST
,
1719 #if CFG_ENABLE_BT_OVER_WIFI
1720 case NETWORK_TYPE_BOW_INDEX
:
1724 #if CFG_ENABLE_WIFI_DIRECT
1725 case NETWORK_TYPE_P2P_INDEX
:
1732 return WLAN_STATUS_SUCCESS
;
1733 } /* nicMediaStateChange */
1735 /*----------------------------------------------------------------------------*/
1737 * @brief This utility function is used to convert between
1738 * frequency and channel number
1740 * @param u4ChannelNum
1742 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1744 /*----------------------------------------------------------------------------*/
1745 UINT_32
nicChannelNum2Freq(UINT_32 u4ChannelNum
)
1747 UINT_32 u4ChannelInMHz
;
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;
1765 return 1000 * u4ChannelInMHz
;
1769 /*----------------------------------------------------------------------------*/
1771 * @brief This utility function is used to convert between
1772 * frequency and channel number
1774 * @param u4FreqInKHz
1776 * @retval - Frequency Number, 0 for invalid freqency
1778 /*----------------------------------------------------------------------------*/
1779 UINT_32
nicFreq2ChannelNum(UINT_32 u4FreqInKHz
)
1781 switch (u4FreqInKHz
) {
1811 return 133; /* 802.11y */
1813 return 137; /* 802.11y */
1900 /* firmware command wrapper */
1901 /* NETWORK (WIFISYS) */
1902 /*----------------------------------------------------------------------------*/
1904 * @brief This utility function is used to activate WIFISYS for specified network
1906 * @param prAdapter Pointer of ADAPTER_T
1907 * eNetworkTypeIdx Index of network type
1911 /*----------------------------------------------------------------------------*/
1913 nicActivateNetwork(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1915 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl
;
1916 P_BSS_INFO_T prBssInfo
;
1919 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
1921 rCmdActivateCtrl
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
1922 rCmdActivateCtrl
.ucActive
= 1;
1924 if (((UINT_8
) eNetworkTypeIdx
) < NETWORK_TYPE_INDEX_NUM
) {
1925 prBssInfo
= &prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
];
1926 prBssInfo
->fg40mBwAllowed
= FALSE
;
1927 prBssInfo
->fgAssoc40mBwAllowed
= FALSE
;
1930 return wlanSendSetQueryCmd(prAdapter
,
1931 CMD_ID_BSS_ACTIVATE_CTRL
,
1937 sizeof(CMD_BSS_ACTIVATE_CTRL
),
1938 (PUINT_8
) & rCmdActivateCtrl
, NULL
, 0);
1942 /*----------------------------------------------------------------------------*/
1944 * @brief This utility function is used to deactivate WIFISYS for specified network
1946 * @param prAdapter Pointer of ADAPTER_T
1947 * eNetworkTypeIdx Index of network type
1951 /*----------------------------------------------------------------------------*/
1953 nicDeactivateNetwork(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1955 WLAN_STATUS u4Status
;
1956 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl
;
1959 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
1961 rCmdActivateCtrl
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
1962 rCmdActivateCtrl
.ucActive
= 0;
1964 u4Status
= wlanSendSetQueryCmd(prAdapter
,
1965 CMD_ID_BSS_ACTIVATE_CTRL
,
1971 sizeof(CMD_BSS_ACTIVATE_CTRL
),
1972 (PUINT_8
) & rCmdActivateCtrl
, NULL
, 0);
1974 /* free all correlated station records */
1975 cnmStaFreeAllStaByNetType(prAdapter
, eNetworkTypeIdx
, FALSE
);
1976 qmFreeAllByNetType(prAdapter
, eNetworkTypeIdx
);
1977 nicFreePendingTxMsduInfoByNetwork(prAdapter
, eNetworkTypeIdx
);
1978 kalClearSecurityFramesByNetType(prAdapter
->prGlueInfo
, eNetworkTypeIdx
);
1985 /*----------------------------------------------------------------------------*/
1987 * @brief This utility function is used to sync bss info with firmware
1988 * when a new BSS has been connected or disconnected
1990 * @param prAdapter Pointer of ADAPTER_T
1991 * eNetworkTypeIdx Index of BSS-INFO type
1995 /*----------------------------------------------------------------------------*/
1996 WLAN_STATUS
nicUpdateBss(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1998 WLAN_STATUS u4Status
;
1999 P_BSS_INFO_T prBssInfo
;
2000 CMD_SET_BSS_INFO rCmdSetBssInfo
;
2003 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2005 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2007 kalMemZero(&rCmdSetBssInfo
, sizeof(CMD_SET_BSS_INFO
));
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
);
2027 rlmFillSyncCmdParam(&rCmdSetBssInfo
.rBssRlmParam
, prBssInfo
);
2029 rCmdSetBssInfo
.fgWapiMode
= (UINT_8
) FALSE
;
2031 if (rCmdSetBssInfo
.ucNetTypeIndex
== NETWORK_TYPE_AIS_INDEX
) {
2032 P_CONNECTION_SETTINGS_T prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2034 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) prConnSettings
->eAuthMode
;
2035 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) prConnSettings
->eEncStatus
;
2036 rCmdSetBssInfo
.fgWapiMode
= (UINT_8
) prConnSettings
->fgWapiMode
;
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
;
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
;
2052 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_OPEN
;
2053 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION_DISABLED
;
2055 /* Need the probe response to detect the PBC overlap */
2056 rCmdSetBssInfo
.fgIsApMode
=
2057 p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
);
2060 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_WPA2_PSK
;
2061 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION3_KEY_ABSENT
;
2065 if (eNetworkTypeIdx
== NETWORK_TYPE_AIS_INDEX
&&
2066 prBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
&&
2067 prBssInfo
->prStaRecOfAP
!= NULL
) {
2068 rCmdSetBssInfo
.ucStaRecIdxOfAP
= prBssInfo
->prStaRecOfAP
->ucIndex
;
2070 cnmAisInfraConnectNotify(prAdapter
);
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
;
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
;
2088 rCmdSetBssInfo
.ucStaRecIdxOfAP
= STA_REC_INDEX_NOT_FOUND
;
2091 u4Status
= wlanSendSetQueryCmd(prAdapter
,
2092 CMD_ID_SET_BSS_INFO
,
2098 sizeof(CMD_SET_BSS_INFO
),
2099 (PUINT_8
) & rCmdSetBssInfo
, NULL
, 0);
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
);
2106 /* free all correlated station records */
2107 cnmStaFreeAllStaByNetType(prAdapter
, eNetworkTypeIdx
, FALSE
);
2108 qmFreeAllByNetType(prAdapter
, eNetworkTypeIdx
);
2109 kalClearSecurityFramesByNetType(prAdapter
->prGlueInfo
, eNetworkTypeIdx
);
2116 /* BSS-INFO Indication (PM) */
2117 /*----------------------------------------------------------------------------*/
2119 * @brief This utility function is used to indicate PM that
2120 * a BSS has been created. (for AdHoc / P2P-GO)
2122 * @param prAdapter Pointer of ADAPTER_T
2123 * eNetworkTypeIdx Index of BSS-INFO
2127 /*----------------------------------------------------------------------------*/
2129 nicPmIndicateBssCreated(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2131 P_BSS_INFO_T prBssInfo
;
2132 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated
;
2135 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2137 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2139 rCmdIndicatePmBssCreated
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2140 rCmdIndicatePmBssCreated
.ucDtimPeriod
= prBssInfo
->ucDTIMPeriod
;
2141 rCmdIndicatePmBssCreated
.u2BeaconInterval
= prBssInfo
->u2BeaconInterval
;
2142 rCmdIndicatePmBssCreated
.u2AtimWindow
= prBssInfo
->u2ATIMWindow
;
2144 return wlanSendSetQueryCmd(prAdapter
,
2145 CMD_ID_INDICATE_PM_BSS_CREATED
,
2151 sizeof(CMD_INDICATE_PM_BSS_CREATED
),
2152 (PUINT_8
) & rCmdIndicatePmBssCreated
, NULL
, 0);
2156 /*----------------------------------------------------------------------------*/
2158 * @brief This utility function is used to indicate PM that
2159 * a BSS has been connected
2161 * @param prAdapter Pointer of ADAPTER_T
2162 * eNetworkTypeIdx Index of BSS-INFO
2166 /*----------------------------------------------------------------------------*/
2168 nicPmIndicateBssConnected(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2170 P_BSS_INFO_T prBssInfo
;
2171 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected
;
2174 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2176 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
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
;
2184 rCmdIndicatePmBssConnected
.ucBmpDeliveryAC
= prBssInfo
->rPmProfSetupInfo
.ucBmpDeliveryAC
;
2185 rCmdIndicatePmBssConnected
.ucBmpTriggerAC
= prBssInfo
->rPmProfSetupInfo
.ucBmpTriggerAC
;
2187 /* DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x", */
2188 /* rCmdIndicatePmBssConnected.ucBmpDeliveryAC, */
2189 /* rCmdIndicatePmBssConnected.ucBmpTriggerAC); */
2191 if ((eNetworkTypeIdx
== NETWORK_TYPE_AIS_INDEX
)
2192 #if CFG_ENABLE_WIFI_DIRECT
2193 || ((eNetworkTypeIdx
== NETWORK_TYPE_P2P_INDEX
) && (prAdapter
->fgIsP2PRegistered
))
2196 if (prBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
) {
2197 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
=
2198 (UINT_8
) prBssInfo
->prStaRecOfAP
->fgIsUapsdSupported
;
2200 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
= 0; /* @FIXME */
2203 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
= 0;
2206 return wlanSendSetQueryCmd(prAdapter
,
2207 CMD_ID_INDICATE_PM_BSS_CONNECTED
,
2213 sizeof(CMD_INDICATE_PM_BSS_CONNECTED
),
2214 (PUINT_8
) & rCmdIndicatePmBssConnected
, NULL
, 0);
2218 /*----------------------------------------------------------------------------*/
2220 * @brief This utility function is used to indicate PM that
2221 * a BSS has been disconnected
2223 * @param prAdapter Pointer of ADAPTER_T
2224 * eNetworkTypeIdx Index of BSS-INFO
2228 /*----------------------------------------------------------------------------*/
2230 nicPmIndicateBssAbort(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2232 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort
;
2235 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2237 rCmdIndicatePmBssAbort
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2239 return wlanSendSetQueryCmd(prAdapter
,
2240 CMD_ID_INDICATE_PM_BSS_ABORT
,
2246 sizeof(CMD_INDICATE_PM_BSS_ABORT
),
2247 (PUINT_8
) & rCmdIndicatePmBssAbort
, NULL
, 0);
2251 nicConfigPowerSaveProfile(IN P_ADAPTER_T prAdapter
,
2252 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
2253 PARAM_POWER_MODE ePwrMode
, BOOLEAN fgEnCmdEvent
)
2255 DEBUGFUNC("nicConfigPowerSaveProfile");
2256 DBGLOG(INIT
, TRACE
, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2257 eNetTypeIndex
, ePwrMode
, fgEnCmdEvent
));
2261 if (eNetTypeIndex
>= NETWORK_TYPE_INDEX_NUM
) {
2263 return WLAN_STATUS_NOT_SUPPORTED
;
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
;
2270 return wlanSendSetQueryCmd(prAdapter
,
2271 CMD_ID_POWER_SAVE_MODE
,
2274 (fgEnCmdEvent
? TRUE
: FALSE
),
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
)
2283 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2285 WLAN_STATUS
nicEnterCtiaMode(IN P_ADAPTER_T prAdapter
, BOOLEAN fgEnterCtia
, BOOLEAN fgEnCmdEvent
)
2287 CMD_SW_DBG_CTRL_T rCmdSwCtrl
;
2288 CMD_ACCESS_REG rCmdAccessReg
;
2289 WLAN_STATUS rWlanStatus
;
2291 DEBUGFUNC("nicEnterCtiaMode");
2292 DBGLOG(INIT
, TRACE
, ("nicEnterCtiaMode: %d\n", fgEnterCtia
));
2296 rWlanStatus
= WLAN_STATUS_SUCCESS
;
2299 /* 1. Disable On-Lin Scan */
2300 prAdapter
->fgEnOnlineScan
= FALSE
;
2302 /* 3. Disable FIFO FULL no ack */
2303 rCmdAccessReg
.u4Address
= 0x60140028;
2304 rCmdAccessReg
.u4Data
= 0x904;
2305 wlanSendSetQueryCmd(prAdapter
, CMD_ID_ACCESS_REG
, TRUE
, /* FALSE, */
2310 sizeof(CMD_ACCESS_REG
), (PUINT_8
) & rCmdAccessReg
, NULL
, 0);
2312 /* 4. Disable Roaming */
2313 rCmdSwCtrl
.u4Id
= 0x90000204;
2314 rCmdSwCtrl
.u4Data
= 0x0;
2315 wlanSendSetQueryCmd(prAdapter
,
2322 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2324 rCmdSwCtrl
.u4Id
= 0x90000200;
2325 rCmdSwCtrl
.u4Data
= 0x820000;
2326 wlanSendSetQueryCmd(prAdapter
,
2333 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2335 /* Disalbe auto tx power */
2336 rCmdSwCtrl
.u4Id
= 0xa0100003;
2337 rCmdSwCtrl
.u4Data
= 0x0;
2338 wlanSendSetQueryCmd(prAdapter
,
2345 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2347 /* 2. Keep at CAM mode */
2349 PARAM_POWER_MODE ePowerMode
;
2351 prAdapter
->u4CtiaPowerMode
= 0;
2352 prAdapter
->fgEnCtiaPowerMode
= TRUE
;
2354 ePowerMode
= Param_PowerModeCAM
;
2355 rWlanStatus
= nicConfigPowerSaveProfile(prAdapter
,
2356 NETWORK_TYPE_AIS_INDEX
,
2357 ePowerMode
, fgEnCmdEvent
);
2360 /* 5. Disable Beacon Timeout Detection */
2361 prAdapter
->fgDisBcnLostDetection
= TRUE
;
2363 /* 1. Enaable On-Lin Scan */
2364 prAdapter
->fgEnOnlineScan
= TRUE
;
2366 /* 3. Enable FIFO FULL no ack */
2367 rCmdAccessReg
.u4Address
= 0x60140028;
2368 rCmdAccessReg
.u4Data
= 0x905;
2369 wlanSendSetQueryCmd(prAdapter
, CMD_ID_ACCESS_REG
, TRUE
, /* FALSE, */
2374 sizeof(CMD_ACCESS_REG
), (PUINT_8
) & rCmdAccessReg
, NULL
, 0);
2376 /* 4. Enable Roaming */
2377 rCmdSwCtrl
.u4Id
= 0x90000204;
2378 rCmdSwCtrl
.u4Data
= 0x1;
2379 wlanSendSetQueryCmd(prAdapter
,
2386 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2388 rCmdSwCtrl
.u4Id
= 0x90000200;
2389 rCmdSwCtrl
.u4Data
= 0x820000;
2390 wlanSendSetQueryCmd(prAdapter
,
2397 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2399 /* Enable auto tx power */
2402 rCmdSwCtrl
.u4Id
= 0xa0100003;
2403 rCmdSwCtrl
.u4Data
= 0x1;
2404 wlanSendSetQueryCmd(prAdapter
,
2411 sizeof(CMD_SW_DBG_CTRL_T
), (PUINT_8
) & rCmdSwCtrl
, NULL
, 0);
2414 /* 2. Keep at Fast PS */
2416 PARAM_POWER_MODE ePowerMode
;
2418 prAdapter
->u4CtiaPowerMode
= 2;
2419 prAdapter
->fgEnCtiaPowerMode
= TRUE
;
2421 ePowerMode
= Param_PowerModeFast_PSP
;
2422 rWlanStatus
= nicConfigPowerSaveProfile(prAdapter
,
2423 NETWORK_TYPE_AIS_INDEX
,
2424 ePowerMode
, fgEnCmdEvent
);
2427 /* 5. Enable Beacon Timeout Detection */
2428 prAdapter
->fgDisBcnLostDetection
= FALSE
;
2433 } /* end of nicEnterCtiaMode() */
2435 /*----------------------------------------------------------------------------*/
2437 * @brief This utility function is used to indicate firmware domain
2438 * for beacon generation parameters
2440 * @param prAdapter Pointer of ADAPTER_T
2441 * eIeUpdMethod, Update Method
2442 * eNetTypeIndex Index of Network
2443 * u2Capability Capability
2444 * aucIe Pointer to buffer of IEs
2445 * u2IELen Length of IEs
2447 * @retval - WLAN_STATUS_SUCCESS
2448 * WLAN_STATUS_FAILURE
2449 * WLAN_STATUS_PENDING
2450 * WLAN_STATUS_INVALID_DATA
2452 /*----------------------------------------------------------------------------*/
2454 nicUpdateBeaconIETemplate(IN P_ADAPTER_T prAdapter
,
2455 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod
,
2456 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
2457 IN UINT_16 u2Capability
, IN PUINT_8 aucIe
, IN UINT_16 u2IELen
)
2459 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate
;
2460 UINT_16 u2CmdBufLen
= 0;
2461 P_GLUE_INFO_T prGlueInfo
;
2462 P_CMD_INFO_T prCmdInfo
;
2463 P_WIFI_CMD_T prWifiCmd
;
2466 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2467 DBGLOG(INIT
, LOUD
, ("\n"));
2469 printk("nicUpdateBeaconIETemplate\n");
2472 prGlueInfo
= prAdapter
->prGlueInfo
;
2474 if (u2IELen
> MAX_IE_LENGTH
) {
2475 return WLAN_STATUS_INVALID_DATA
;
2478 if (eIeUpdMethod
== IE_UPD_METHOD_UPDATE_RANDOM
|| eIeUpdMethod
== IE_UPD_METHOD_UPDATE_ALL
) {
2479 u2CmdBufLen
= OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE
, aucIE
) + u2IELen
;
2480 } else if (eIeUpdMethod
== IE_UPD_METHOD_DELETE_ALL
) {
2481 u2CmdBufLen
= OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE
, u2IELen
);
2484 return WLAN_STATUS_FAILURE
;
2487 /* prepare command info */
2488 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, (CMD_HDR_SIZE
+ u2CmdBufLen
));
2490 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2491 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2492 return WLAN_STATUS_FAILURE
;
2494 /* increase command sequence number */
2495 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
2496 DBGLOG(REQ
, TRACE
, ("ucCmdSeqNum =%d\n", ucCmdSeqNum
));
2498 /* Setup common CMD Info Packet */
2499 prCmdInfo
->eCmdType
= COMMAND_TYPE_NETWORK_IOCTL
;
2500 prCmdInfo
->eNetworkType
= eNetTypeIndex
;
2501 prCmdInfo
->u2InfoBufLen
= (UINT_16
) (CMD_HDR_SIZE
+ u2CmdBufLen
);
2502 prCmdInfo
->pfCmdDoneHandler
= NULL
; /* @FIXME */
2503 prCmdInfo
->pfCmdTimeoutHandler
= NULL
; /* @FIXME */
2504 prCmdInfo
->fgIsOid
= FALSE
;
2505 prCmdInfo
->ucCID
= CMD_ID_UPDATE_BEACON_CONTENT
;
2506 prCmdInfo
->fgSetQuery
= TRUE
;
2507 prCmdInfo
->fgNeedResp
= FALSE
;
2508 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
2509 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
2510 prCmdInfo
->u4SetInfoLen
= u2CmdBufLen
;
2511 prCmdInfo
->pvInformationBuffer
= NULL
;
2512 prCmdInfo
->u4InformationBufferLength
= 0;
2514 /* Setup WIFI_CMD_T (no payload) */
2515 prWifiCmd
= (P_WIFI_CMD_T
) (prCmdInfo
->pucInfoBuffer
);
2516 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
2517 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
2518 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
2519 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
2521 prCmdBcnUpdate
= (P_CMD_BEACON_TEMPLATE_UPDATE
) (prWifiCmd
->aucBuffer
);
2523 /* fill beacon updating command */
2524 prCmdBcnUpdate
->ucUpdateMethod
= (UINT_8
) eIeUpdMethod
;
2525 prCmdBcnUpdate
->ucNetTypeIndex
= (UINT_8
) eNetTypeIndex
;
2526 prCmdBcnUpdate
->u2Capability
= u2Capability
;
2527 prCmdBcnUpdate
->u2IELen
= u2IELen
;
2529 kalMemCopy(prCmdBcnUpdate
->aucIE
, aucIe
, u2IELen
);
2531 /* insert into prCmdQueue */
2532 kalEnqueueCommand(prGlueInfo
, (P_QUE_ENTRY_T
) prCmdInfo
);
2534 /* wakeup txServiceThread later */
2535 GLUE_SET_EVENT(prGlueInfo
);
2536 return WLAN_STATUS_PENDING
;
2540 /*----------------------------------------------------------------------------*/
2542 * @brief This utility function is used to initialization PHY related
2545 * @param prAdapter Pointer of ADAPTER_T
2549 /*----------------------------------------------------------------------------*/
2550 VOID
nicSetAvailablePhyTypeSet(IN P_ADAPTER_T prAdapter
)
2552 P_CONNECTION_SETTINGS_T prConnSettings
;
2556 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2558 if (prConnSettings
->eDesiredPhyConfig
>= PHY_CONFIG_NUM
) {
2563 prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
=
2564 aucPhyCfg2PhyTypeSet
[prConnSettings
->eDesiredPhyConfig
];
2566 if (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_BIT_ERP
) {
2567 prAdapter
->rWifiVar
.eNonHTBasicPhyType2G4
= PHY_TYPE_ERP_INDEX
;
2569 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2570 else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
2572 prAdapter
->rWifiVar
.eNonHTBasicPhyType2G4
= PHY_TYPE_HR_DSSS_INDEX
;
2579 /*----------------------------------------------------------------------------*/
2581 * @brief This utility function is used to update WMM Parms
2583 * @param prAdapter Pointer of ADAPTER_T
2584 * eNetworkTypeIdx Index of BSS-INFO
2588 /*----------------------------------------------------------------------------*/
2590 nicQmUpdateWmmParms(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2592 P_BSS_INFO_T prBssInfo
;
2593 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms
;
2596 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2598 DBGLOG(QM
, EVENT
, ("sizeof(AC_QUE_PARMS_T): %d\n", sizeof(AC_QUE_PARMS_T
)));
2599 DBGLOG(QM
, EVENT
, ("sizeof(CMD_UPDATE_WMM_PARMS): %d\n", sizeof(CMD_UPDATE_WMM_PARMS_T
)));
2600 DBGLOG(QM
, EVENT
, ("sizeof(WIFI_CMD_T): %d\n", sizeof(WIFI_CMD_T
)));
2602 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2603 rCmdUpdateWmmParms
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2604 kalMemCopy(&rCmdUpdateWmmParms
.arACQueParms
[0], &prBssInfo
->arACQueParms
[0],
2605 (sizeof(AC_QUE_PARMS_T
) * AC_NUM
));
2607 rCmdUpdateWmmParms
.fgIsQBSS
= prBssInfo
->fgIsQBSS
;
2609 return wlanSendSetQueryCmd(prAdapter
,
2610 CMD_ID_UPDATE_WMM_PARMS
,
2616 sizeof(CMD_UPDATE_WMM_PARMS_T
),
2617 (PUINT_8
) & rCmdUpdateWmmParms
, NULL
, 0);
2621 /*----------------------------------------------------------------------------*/
2623 * @brief This utility function is used to update TX power gain corresponding to
2624 * each band/modulation combination
2626 * @param prAdapter Pointer of ADAPTER_T
2627 * prTxPwrParam Pointer of TX power parameters
2629 * @retval WLAN_STATUS_PENDING
2630 * WLAN_STATUS_FAILURE
2632 /*----------------------------------------------------------------------------*/
2633 WLAN_STATUS
nicUpdateTxPower(IN P_ADAPTER_T prAdapter
, IN P_CMD_TX_PWR_T prTxPwrParam
)
2635 DEBUGFUNC("nicUpdateTxPower");
2639 return wlanSendSetQueryCmd(prAdapter
,
2645 NULL
, sizeof(CMD_TX_PWR_T
), (PUINT_8
) prTxPwrParam
, NULL
, 0);
2648 /*----------------------------------------------------------------------------*/
2650 * @brief This utility function is used to set auto tx power parameter
2652 * @param prAdapter Pointer of ADAPTER_T
2653 * prTxPwrParam Pointer of Auto TX power parameters
2655 * @retval WLAN_STATUS_PENDING
2656 * WLAN_STATUS_FAILURE
2658 /*----------------------------------------------------------------------------*/
2659 WLAN_STATUS
nicSetAutoTxPower(IN P_ADAPTER_T prAdapter
, IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam
)
2661 DEBUGFUNC("nicSetAutoTxPower");
2665 return wlanSendSetQueryCmd(prAdapter
,
2666 CMD_ID_SET_AUTOPWR_CTRL
,
2672 sizeof(CMD_AUTO_POWER_PARAM_T
),
2673 (PUINT_8
) prAutoPwrParam
, NULL
, 0);
2677 /*----------------------------------------------------------------------------*/
2679 * @brief This utility function is used to update TX power gain corresponding to
2680 * each band/modulation combination
2682 * @param prAdapter Pointer of ADAPTER_T
2683 * prTxPwrParam Pointer of TX power parameters
2685 * @retval WLAN_STATUS_PENDING
2686 * WLAN_STATUS_FAILURE
2688 /*----------------------------------------------------------------------------*/
2689 WLAN_STATUS
nicSetAutoTxPowerControl(IN P_ADAPTER_T prAdapter
, IN P_CMD_TX_PWR_T prTxPwrParam
)
2691 DEBUGFUNC("nicUpdateTxPower");
2695 return wlanSendSetQueryCmd(prAdapter
,
2701 NULL
, sizeof(CMD_TX_PWR_T
), (PUINT_8
) prTxPwrParam
, NULL
, 0);
2705 /*----------------------------------------------------------------------------*/
2707 * @brief This utility function is used to update power offset around 5GHz band
2709 * @param prAdapter Pointer of ADAPTER_T
2710 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2712 * @retval WLAN_STATUS_PENDING
2713 * WLAN_STATUS_FAILURE
2715 /*----------------------------------------------------------------------------*/
2716 WLAN_STATUS
nicUpdate5GOffset(IN P_ADAPTER_T prAdapter
, IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset
)
2718 DEBUGFUNC("nicUpdate5GOffset");
2722 return wlanSendSetQueryCmd(prAdapter
,
2723 CMD_ID_SET_5G_PWR_OFFSET
,
2729 sizeof(CMD_5G_PWR_OFFSET_T
), (PUINT_8
) pr5GPwrOffset
, NULL
, 0);
2733 /*----------------------------------------------------------------------------*/
2735 * @brief This utility function is used to update DPD calibration result
2737 * @param prAdapter Pointer of ADAPTER_T
2738 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2740 * @retval WLAN_STATUS_PENDING
2741 * WLAN_STATUS_FAILURE
2743 /*----------------------------------------------------------------------------*/
2744 WLAN_STATUS
nicUpdateDPD(IN P_ADAPTER_T prAdapter
, IN P_CMD_PWR_PARAM_T prDpdCalResult
)
2746 DEBUGFUNC("nicUpdateDPD");
2750 return wlanSendSetQueryCmd(prAdapter
,
2751 CMD_ID_SET_PWR_PARAM
,
2757 sizeof(CMD_PWR_PARAM_T
), (PUINT_8
) prDpdCalResult
, NULL
, 0);
2761 /*----------------------------------------------------------------------------*/
2763 * @brief This utility function starts system service such as timer and
2766 * @param prAdapter Pointer of ADAPTER_T
2770 /*----------------------------------------------------------------------------*/
2771 VOID
nicInitSystemService(IN P_ADAPTER_T prAdapter
)
2775 /* <1> Initialize MGMT Memory pool and STA_REC */
2776 cnmMemInit(prAdapter
);
2777 cnmStaRecInit(prAdapter
);
2778 cmdBufInitialize(prAdapter
);
2780 /* <2> Mailbox Initialization */
2781 mboxInitialize(prAdapter
);
2783 /* <3> Timer Initialization */
2784 cnmTimerInitialize(prAdapter
);
2790 /*----------------------------------------------------------------------------*/
2792 * @brief This utility function reset some specific system service,
2795 * @param prAdapter Pointer of ADAPTER_T
2799 /*----------------------------------------------------------------------------*/
2800 VOID
nicResetSystemService(IN P_ADAPTER_T prAdapter
)
2806 /*----------------------------------------------------------------------------*/
2808 * @brief This utility function is used to update WMM Parms
2810 * @param prAdapter Pointer of ADAPTER_T
2814 /*----------------------------------------------------------------------------*/
2815 VOID
nicUninitSystemService(IN P_ADAPTER_T prAdapter
)
2819 /* Timer Destruction */
2820 cnmTimerDestroy(prAdapter
);
2822 /* Mailbox Destruction */
2823 mboxDestroy(prAdapter
);
2829 /*----------------------------------------------------------------------------*/
2831 * @brief This utility function is used to update WMM Parms
2833 * @param prAdapter Pointer of ADAPTER_T
2837 /*----------------------------------------------------------------------------*/
2838 VOID
nicInitMGMT(IN P_ADAPTER_T prAdapter
, IN P_REG_INFO_T prRegInfo
)
2842 /* CNM Module - initialization */
2845 /* RLM Module - initialization */
2846 rlmFsmEventInit(prAdapter
);
2848 /* SCN Module - initialization */
2851 /* AIS Module - intiailization */
2852 aisInitializeConnectionSettings(prAdapter
, prRegInfo
);
2853 aisFsmInit(prAdapter
);
2855 #if CFG_SUPPORT_ROAMING
2856 /* Roaming Module - intiailization */
2857 roamingFsmInit(prAdapter
);
2858 #endif /* CFG_SUPPORT_ROAMING */
2860 #if CFG_SUPPORT_SWCR
2861 swCrDebugInit(prAdapter
);
2862 #endif /* CFG_SUPPORT_SWCR */
2868 /*----------------------------------------------------------------------------*/
2870 * @brief This utility function is used to update WMM Parms
2872 * @param prAdapter Pointer of ADAPTER_T
2876 /*----------------------------------------------------------------------------*/
2877 VOID
nicUninitMGMT(IN P_ADAPTER_T prAdapter
)
2881 #if CFG_SUPPORT_SWCR
2882 swCrDebugUninit(prAdapter
);
2883 #endif /* CFG_SUPPORT_SWCR */
2885 #if CFG_SUPPORT_ROAMING
2886 /* Roaming Module - unintiailization */
2887 roamingFsmUninit(prAdapter
);
2888 #endif /* CFG_SUPPORT_ROAMING */
2890 /* AIS Module - unintiailization */
2891 aisFsmUninit(prAdapter
);
2893 /* SCN Module - unintiailization */
2894 scnUninit(prAdapter
);
2896 /* RLM Module - uninitialization */
2897 rlmFsmEventUninit(prAdapter
);
2899 /* CNM Module - uninitialization */
2900 cnmUninit(prAdapter
);
2906 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2907 /*----------------------------------------------------------------------------*/
2909 * @brief This utility function is to inform firmware to enable MCU clock gating
2911 * @param prAdapter Pointer of ADAPTER_T
2915 /*----------------------------------------------------------------------------*/
2916 WLAN_STATUS
nicEnableClockGating(IN P_ADAPTER_T prAdapter
)
2918 UINT_32 i
, u4WHISR
= 0;
2922 if (prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
2923 return WLAN_STATUS_SUCCESS
;
2925 nicSetSwIntr(prAdapter
, REQ_GATING_ENABLE_H2D_INT
);
2928 while (i
< GATING_CONTROL_POLL_LIMIT
) {
2929 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2930 || fgIsBusAccessFailed
== TRUE
) {
2931 return WLAN_STATUS_FAILURE
;
2934 HAL_READ_INTR_STATUS(prAdapter
, sizeof(UINT_32
), (PUINT_8
) & u4WHISR
);
2936 if (u4WHISR
& ACK_GATING_ENABLE_D2H_INT
) {
2937 prAdapter
->fgIsClockGatingEnabled
= TRUE
;
2938 return WLAN_STATUS_SUCCESS
;
2943 return WLAN_STATUS_PENDING
;
2948 /*----------------------------------------------------------------------------*/
2950 * @brief This utility function is to inform firmware to disable MCU clock gating
2952 * @param prAdapter Pointer of ADAPTER_T
2956 /*----------------------------------------------------------------------------*/
2957 WLAN_STATUS
nicDisableClockGating(IN P_ADAPTER_T prAdapter
)
2959 UINT_32 i
, u4WHISR
= 0;
2963 if (prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
2964 return WLAN_STATUS_SUCCESS
;
2966 nicSetSwIntr(prAdapter
, REQ_GATING_DISABLE_H2D_INT
);
2969 while (i
< GATING_CONTROL_POLL_LIMIT
) {
2970 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2971 || fgIsBusAccessFailed
== TRUE
) {
2972 return WLAN_STATUS_FAILURE
;
2975 HAL_READ_INTR_STATUS(prAdapter
, sizeof(UINT_32
), (PUINT_8
) & u4WHISR
);
2977 if (u4WHISR
& ACK_GATING_DISABLE_D2H_INT
) {
2978 prAdapter
->fgIsClockGatingEnabled
= FALSE
;
2979 return WLAN_STATUS_SUCCESS
;
2984 return WLAN_STATUS_PENDING
;
2990 /*----------------------------------------------------------------------------*/
2992 * @brief This function is invoked to buffer scan result
2994 * @param prAdapter Pointer to the Adapter structure.
2995 * @param rMacAddr BSSID
2996 * @param prSsid Pointer to SSID
2997 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
2998 * @param rRssi Received Strength (-10 ~ -200 dBm)
2999 * @param eNetworkType Network Type (a/b/g)
3000 * @param prConfiguration Network Parameter
3001 * @param eOpMode Infra/Ad-Hoc
3002 * @param rSupportedRates Supported basic rates
3003 * @param u2IELength IE Length
3004 * @param pucIEBuf Pointer to Information Elements(IEs)
3008 /*----------------------------------------------------------------------------*/
3010 nicAddScanResult(IN P_ADAPTER_T prAdapter
,
3011 IN PARAM_MAC_ADDRESS rMacAddr
,
3012 IN P_PARAM_SSID_T prSsid
,
3013 IN UINT_32 u4Privacy
,
3014 IN PARAM_RSSI rRssi
,
3015 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType
,
3016 IN P_PARAM_802_11_CONFIG_T prConfiguration
,
3017 IN ENUM_PARAM_OP_MODE_T eOpMode
,
3018 IN PARAM_RATES_EX rSupportedRates
, IN UINT_16 u2IELength
, IN PUINT_8 pucIEBuf
)
3022 UINT_32 u4IdxWeakest
= 0;
3023 PARAM_RSSI rWeakestRssi
;
3024 UINT_32 u4BufferSize
;
3028 rWeakestRssi
= (PARAM_RSSI
) INT_MAX
;
3030 sizeof(prAdapter
->rWlanInfo
.aucScanIEBuf
) /
3031 sizeof(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]);
3035 /* decide to replace or add */
3036 for (i
= 0; i
< prAdapter
->rWlanInfo
.u4ScanResultNum
; i
++) {
3037 /* find weakest entry && not connected one */
3038 if (UNEQUAL_MAC_ADDR
3039 (prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
,
3040 prAdapter
->rWlanInfo
.rCurrBssId
.arMacAddress
)
3041 && prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
< rWeakestRssi
) {
3043 rWeakestRssi
= prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
;
3046 if (prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
== eOpMode
&&
3047 EQUAL_MAC_ADDR(&(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
), rMacAddr
)
3050 (prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
3051 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
, prSsid
->aucSsid
,
3053 || prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
== 0)) {
3057 /* free IE buffer then zero */
3058 nicFreeScanResultIE(prAdapter
, i
);
3059 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
3060 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
3062 /* then fill buffer */
3063 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
3064 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
3065 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
3066 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
3067 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
3068 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
3069 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
3070 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
3071 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
3072 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
3073 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
3074 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
3075 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
3076 rSupportedRates
, sizeof(PARAM_RATES_EX
));
3077 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
3079 /* IE - allocate buffer and update pointer */
3080 if (u2IELength
> 0) {
3081 if (ALIGN_4(u2IELength
) +
3082 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
3084 (prAdapter
->rWlanInfo
.
3085 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3086 u4ScanIEBufferUsage
]), pucIEBuf
,
3089 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3090 &(prAdapter
->rWlanInfo
.
3091 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3092 u4ScanIEBufferUsage
]);
3094 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
3095 ALIGN_4(u2IELength
);
3097 /* buffer is not enough */
3098 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
3099 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
3100 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3103 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3110 if (bReplace
== FALSE
) {
3111 if (prAdapter
->rWlanInfo
.u4ScanResultNum
< (CFG_MAX_NUM_BSS_LIST
- 1)) {
3112 i
= prAdapter
->rWlanInfo
.u4ScanResultNum
;
3115 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
3116 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
3118 /* then fill buffer */
3119 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
3120 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
3121 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
3122 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
3123 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
3124 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
3125 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
3126 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
3127 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
3128 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
3129 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
3130 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
3131 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
3132 rSupportedRates
, sizeof(PARAM_RATES_EX
));
3133 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
3135 /* IE - allocate buffer and update pointer */
3136 if (u2IELength
> 0) {
3137 if (ALIGN_4(u2IELength
) +
3138 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
3140 (prAdapter
->rWlanInfo
.
3141 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3142 u4ScanIEBufferUsage
]), pucIEBuf
,
3145 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3146 &(prAdapter
->rWlanInfo
.
3147 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3148 u4ScanIEBufferUsage
]);
3150 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
3151 ALIGN_4(u2IELength
);
3153 /* buffer is not enough */
3154 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
3155 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
3156 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3159 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3162 prAdapter
->rWlanInfo
.u4ScanResultNum
++;
3163 } else if (rWeakestRssi
!= (PARAM_RSSI
) INT_MAX
) {
3164 /* replace weakest one */
3167 /* free IE buffer then zero */
3168 nicFreeScanResultIE(prAdapter
, i
);
3169 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
3170 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
3172 /* then fill buffer */
3173 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
3174 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
3175 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
3176 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
3177 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
3178 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
3179 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
3180 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
3181 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
3182 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
3183 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
3184 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
3185 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
3186 rSupportedRates
, sizeof(PARAM_RATES_EX
));
3187 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
3189 if (u2IELength
> 0) {
3190 /* IE - allocate buffer and update pointer */
3191 if (ALIGN_4(u2IELength
) +
3192 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
3194 (prAdapter
->rWlanInfo
.
3195 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3196 u4ScanIEBufferUsage
]), pucIEBuf
,
3199 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3200 &(prAdapter
->rWlanInfo
.
3201 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3202 u4ScanIEBufferUsage
]);
3204 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
3205 ALIGN_4(u2IELength
);
3207 /* buffer is not enough */
3208 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
3209 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
3210 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3213 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3220 /*----------------------------------------------------------------------------*/
3222 * @brief This function is invoked to free IE buffer for dedicated scan result
3224 * @param prAdapter Pointer to the Adapter structure.
3225 * @param u4Idx Index of Scan Result
3229 /*----------------------------------------------------------------------------*/
3230 VOID
nicFreeScanResultIE(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4Idx
)
3233 PUINT_8 pucPivot
, pucMovePivot
;
3234 UINT_32 u4MoveSize
, u4FreeSize
, u4ReserveSize
;
3237 ASSERT(u4Idx
< CFG_MAX_NUM_BSS_LIST
);
3239 if (prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
== 0
3240 || prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
] == NULL
) {
3244 u4FreeSize
= ALIGN_4(prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
);
3246 pucPivot
= prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
];
3248 (PUINT_8
) ((UINT_32
) (prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
]) + u4FreeSize
);
3250 u4ReserveSize
= ((UINT_32
) pucPivot
) - (UINT_32
) (&(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]));
3251 u4MoveSize
= prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
- u4ReserveSize
- u4FreeSize
;
3253 /* 1. rest of buffer to move forward */
3254 kalMemCopy(pucPivot
, pucMovePivot
, u4MoveSize
);
3256 /* 1.1 modify pointers */
3257 for (i
= 0; i
< prAdapter
->rWlanInfo
.u4ScanResultNum
; i
++) {
3259 if (prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] >= pucMovePivot
) {
3260 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3261 (PUINT_8
) ((UINT_32
) (prAdapter
->rWlanInfo
.apucScanResultIEs
[i
])
3267 /* 1.2 reset the freed one */
3268 prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
= 0;
3269 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3271 /* 2. reduce IE buffer usage */
3272 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
-= u4FreeSize
;
3278 /*----------------------------------------------------------------------------*/
3280 * @brief This function is to hack parameters for WLAN TABLE for
3281 * fixed rate settings
3283 * @param prAdapter Pointer to the Adapter structure.
3284 * @param eRateSetting
3285 * @param pu2DesiredNonHTRateSet,
3286 * @param pu2BSSBasicRateSet,
3288 * @param pucSupMcs32
3289 * @param pu2HtCapInfo
3291 * @return WLAN_STATUS_SUCCESS
3293 /*----------------------------------------------------------------------------*/
3295 nicUpdateRateParams(IN P_ADAPTER_T prAdapter
,
3296 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting
,
3297 IN PUINT_8 pucDesiredPhyTypeSet
,
3298 IN PUINT_16 pu2DesiredNonHTRateSet
,
3299 IN PUINT_16 pu2BSSBasicRateSet
,
3300 IN PUINT_8 pucMcsSet
, IN PUINT_8 pucSupMcs32
, IN PUINT_16 pu2HtCapInfo
)
3303 ASSERT(eRateSetting
> FIXED_RATE_NONE
&& eRateSetting
< FIXED_RATE_NUM
);
3305 switch (prAdapter
->rWifiVar
.eRateSetting
) {
3307 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3308 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_1M
;
3309 *pu2BSSBasicRateSet
= RATE_SET_BIT_1M
;
3316 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3317 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_2M
;
3318 *pu2BSSBasicRateSet
= RATE_SET_BIT_2M
;
3324 case FIXED_RATE_5_5M
:
3325 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3326 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_5_5M
;
3327 *pu2BSSBasicRateSet
= RATE_SET_BIT_5_5M
;
3333 case FIXED_RATE_11M
:
3334 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3335 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_11M
;
3336 *pu2BSSBasicRateSet
= RATE_SET_BIT_11M
;
3343 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3344 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3345 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3346 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3349 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_6M
;
3350 *pu2BSSBasicRateSet
= RATE_SET_BIT_6M
;
3357 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3358 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3359 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3360 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3363 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_9M
;
3364 *pu2BSSBasicRateSet
= RATE_SET_BIT_9M
;
3370 case FIXED_RATE_12M
:
3371 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3372 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3373 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3374 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3377 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_12M
;
3378 *pu2BSSBasicRateSet
= RATE_SET_BIT_12M
;
3384 case FIXED_RATE_18M
:
3385 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3386 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3387 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3388 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3391 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_18M
;
3392 *pu2BSSBasicRateSet
= RATE_SET_BIT_18M
;
3398 case FIXED_RATE_24M
:
3399 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3400 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3401 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3402 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3405 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_24M
;
3406 *pu2BSSBasicRateSet
= RATE_SET_BIT_24M
;
3412 case FIXED_RATE_36M
:
3413 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3414 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3415 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3416 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3419 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_36M
;
3420 *pu2BSSBasicRateSet
= RATE_SET_BIT_36M
;
3426 case FIXED_RATE_48M
:
3427 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3428 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3429 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3430 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3433 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_48M
;
3434 *pu2BSSBasicRateSet
= RATE_SET_BIT_48M
;
3440 case FIXED_RATE_54M
:
3441 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3442 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3443 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3444 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3447 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_54M
;
3448 *pu2BSSBasicRateSet
= RATE_SET_BIT_54M
;
3454 case FIXED_RATE_MCS0_20M_800NS
:
3455 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3456 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3457 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3458 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3460 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3461 | HT_CAP_INFO_SHORT_GI_20M
3462 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3465 case FIXED_RATE_MCS1_20M_800NS
:
3466 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3467 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3468 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3469 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3471 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3472 | HT_CAP_INFO_SHORT_GI_20M
3473 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3476 case FIXED_RATE_MCS2_20M_800NS
:
3477 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3478 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3479 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3480 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3482 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3483 | HT_CAP_INFO_SHORT_GI_20M
3484 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3487 case FIXED_RATE_MCS3_20M_800NS
:
3488 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3489 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3490 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3491 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3493 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3494 | HT_CAP_INFO_SHORT_GI_20M
3495 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3498 case FIXED_RATE_MCS4_20M_800NS
:
3499 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3500 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3501 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3502 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3504 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3505 | HT_CAP_INFO_SHORT_GI_20M
3506 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3509 case FIXED_RATE_MCS5_20M_800NS
:
3510 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3511 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3512 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3513 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3515 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3516 | HT_CAP_INFO_SHORT_GI_20M
3517 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3520 case FIXED_RATE_MCS6_20M_800NS
:
3521 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3522 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3523 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3524 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3526 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3527 | HT_CAP_INFO_SHORT_GI_20M
3528 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3531 case FIXED_RATE_MCS7_20M_800NS
:
3532 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3533 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3534 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3535 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3537 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3538 | HT_CAP_INFO_SHORT_GI_20M
3539 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3542 case FIXED_RATE_MCS0_20M_400NS
:
3543 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3544 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3545 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3546 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3548 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3549 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3550 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3553 case FIXED_RATE_MCS1_20M_400NS
:
3554 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3555 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3556 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3557 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3559 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3560 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3561 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3564 case FIXED_RATE_MCS2_20M_400NS
:
3565 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3566 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3567 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3568 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3570 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3571 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3572 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3575 case FIXED_RATE_MCS3_20M_400NS
:
3576 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3577 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3578 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3579 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3581 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3582 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3583 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3586 case FIXED_RATE_MCS4_20M_400NS
:
3587 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3588 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3589 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3590 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3592 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3593 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3594 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3597 case FIXED_RATE_MCS5_20M_400NS
:
3598 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3599 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3600 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3601 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3603 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3604 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3605 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3608 case FIXED_RATE_MCS6_20M_400NS
:
3609 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3610 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3611 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3612 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3614 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3615 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3616 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3619 case FIXED_RATE_MCS7_20M_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_MCS7_INDEX
;
3625 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3626 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3627 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3630 case FIXED_RATE_MCS0_40M_800NS
:
3631 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3632 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3633 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3634 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3636 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3637 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3638 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3641 case FIXED_RATE_MCS1_40M_800NS
:
3642 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3643 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3644 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3645 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3647 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3648 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3649 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3652 case FIXED_RATE_MCS2_40M_800NS
:
3653 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3654 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3655 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3656 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3658 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3659 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3660 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3663 case FIXED_RATE_MCS3_40M_800NS
:
3664 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3665 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3666 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3667 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3669 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3670 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3671 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3674 case FIXED_RATE_MCS4_40M_800NS
:
3675 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3676 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3677 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3678 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3680 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3681 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3682 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3685 case FIXED_RATE_MCS5_40M_800NS
:
3686 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3687 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3688 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3689 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3691 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3692 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3693 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3696 case FIXED_RATE_MCS6_40M_800NS
:
3697 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3698 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3699 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3700 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3702 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3703 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3704 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3707 case FIXED_RATE_MCS7_40M_800NS
:
3708 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3709 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3710 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3711 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3713 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3714 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3715 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3718 case FIXED_RATE_MCS32_800NS
:
3719 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3720 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3721 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3722 *pucMcsSet
= HT_RATE_MCS32_INDEX
;
3724 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3725 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3726 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3729 case FIXED_RATE_MCS0_40M_400NS
:
3730 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3731 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3732 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3733 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3735 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3736 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3739 case FIXED_RATE_MCS1_40M_400NS
:
3740 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3741 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3742 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3743 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3745 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3746 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3749 case FIXED_RATE_MCS2_40M_400NS
:
3750 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3751 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3752 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3753 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3755 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3756 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3759 case FIXED_RATE_MCS3_40M_400NS
:
3760 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3761 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3762 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3763 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3765 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3766 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3769 case FIXED_RATE_MCS4_40M_400NS
:
3770 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3771 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3772 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3773 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3775 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3776 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3779 case FIXED_RATE_MCS5_40M_400NS
:
3780 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3781 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3782 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3783 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3785 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3786 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3789 case FIXED_RATE_MCS6_40M_400NS
:
3790 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3791 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3792 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3793 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3795 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3796 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3799 case FIXED_RATE_MCS7_40M_400NS
:
3800 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3801 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3802 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3803 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3805 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3806 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3809 case FIXED_RATE_MCS32_400NS
:
3810 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3811 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3812 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3813 *pucMcsSet
= HT_RATE_MCS32_INDEX
;
3815 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3816 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3823 return WLAN_STATUS_SUCCESS
;
3826 /*----------------------------------------------------------------------------*/
3828 * @brief This utility function is used to write the register
3830 * @param u4Address Register address
3831 * u4Value the value to be written
3833 * @retval WLAN_STATUS_SUCCESS
3834 * WLAN_STATUS_FAILURE
3836 /*----------------------------------------------------------------------------*/
3838 WLAN_STATUS
nicWriteMcr(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4Address
, IN UINT_32 u4Value
)
3840 CMD_ACCESS_REG rCmdAccessReg
;
3842 rCmdAccessReg
.u4Address
= u4Address
;
3843 rCmdAccessReg
.u4Data
= u4Value
;
3845 return wlanSendSetQueryCmd(prAdapter
,
3852 sizeof(CMD_ACCESS_REG
), (PUINT_8
) &rCmdAccessReg
, NULL
, 0);
3856 /*----------------------------------------------------------------------------*/
3858 * @brief This utility function is used to modify the auto rate parameters
3860 * @param u4ArSysParam0 see description below
3866 * @retval WLAN_STATUS_SUCCESS
3867 * WLAN_STATUS_FAILURE
3870 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
3871 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
3872 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
3873 * ArSysParam0[8:15]-> HT rate clear mask
3874 * ArSysParam0[16:31]-> Legacy rate clear mask
3875 * ArSysParam1[0:7]-> Auto Rate check weighting window
3876 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
3877 * ArSysParam1[16:23]-> Auto Rate v1 PerH
3878 * ArSysParam1[24:31]-> Auto Rate v1 PerL
3882 * Enable auto rate version 1
3884 * ArSysParam0 = 983041,
3885 * Enable auto rate version 1
3886 * Remove CCK 1M, 2M, 5.5M, 11M
3888 * ArSysParam0 = 786433
3889 * Enable auto rate version 1
3890 * Remove CCK 5.5M 11M
3892 /*----------------------------------------------------------------------------*/
3896 nicRlmArUpdateParms(IN P_ADAPTER_T prAdapter
,
3897 IN UINT_32 u4ArSysParam0
,
3898 IN UINT_32 u4ArSysParam1
, IN UINT_32 u4ArSysParam2
, IN UINT_32 u4ArSysParam3
)
3900 UINT_8 ucArVer
, ucAbwVer
, ucAgiVer
;
3901 UINT_16 u2HtClrMask
;
3902 UINT_16 u2LegacyClrMask
;
3903 UINT_8 ucArCheckWindow
;
3906 UINT_8 ucArPerForceRateDownPer
;
3908 ucArVer
= (UINT_8
) (u4ArSysParam0
& BITS(0, 3));
3909 ucAbwVer
= (UINT_8
) ((u4ArSysParam0
& BITS(4, 5)) >> 4);
3910 ucAgiVer
= (UINT_8
) ((u4ArSysParam0
& BITS(6, 7)) >> 6);
3911 u2HtClrMask
= (UINT_16
) ((u4ArSysParam0
& BITS(8, 15)) >> 8);
3912 u2LegacyClrMask
= (UINT_16
) ((u4ArSysParam0
& BITS(16, 31)) >> 16);
3915 ucArCheckWindow
= (UINT_8
) (u4ArSysParam1
& BITS(0, 7));
3916 ucArPerForceRateDownPer
= (UINT_8
) ((u4ArSysParam1
& BITS(8, 15) >> 8));
3917 ucArPerH
= (UINT_8
) ((u4ArSysParam1
& BITS(16, 23)) >> 16);
3918 ucArPerL
= (UINT_8
) ((u4ArSysParam1
& BITS(24, 31)) >> 24);
3921 ucArCheckWindow
= (UINT_8
) (u4ArSysParam1
& BITS(0, 7));
3922 ucArPerForceRateDownPer
= (UINT_8
) (((u4ArSysParam1
>> 8) & BITS(0, 7)));
3923 ucArPerH
= (UINT_8
) (((u4ArSysParam1
>> 16) & BITS(0, 7)));
3924 ucArPerL
= (UINT_8
) (((u4ArSysParam1
>> 24) & BITS(0, 7)));
3928 ("ArParam %lu %lu %lu %lu\n", u4ArSysParam0
, u4ArSysParam1
, u4ArSysParam2
,
3930 DBGLOG(INIT
, INFO
, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer
, ucAbwVer
, ucAgiVer
));
3931 DBGLOG(INIT
, INFO
, ("HtMask %x LegacyMask %x\n", u2HtClrMask
, u2LegacyClrMask
));
3933 ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow
,
3934 ucArPerForceRateDownPer
, ucArPerH
, ucArPerL
));
3936 #define SWCR_DATA_ADDR(MOD, ADDR) (0x90000000+(MOD<<8)+(ADDR))
3937 #define SWCR_DATA_CMD(CATE, WRITE, INDEX, OPT0, OPT1) ((CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 << 8) | OPT1)
3938 #define SWCR_DATA0 0x0
3939 #define SWCR_DATA1 0x4
3940 #define SWCR_DATA2 0x8
3941 #define SWCR_DATA3 0xC
3942 #define SWCR_DATA4 0x10
3943 #define SWCR_WRITE 1
3947 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
3948 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000) */
3950 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), 1);
3951 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3952 SWCR_DATA_CMD(0, SWCR_WRITE
, 5, 0, 0));
3954 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), 0);
3955 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3956 SWCR_DATA_CMD(0, SWCR_WRITE
, 5, 0, 0));
3959 /* ucArVer 0: none 1:PER 2:Rcpi */
3960 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArVer
);
3961 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3962 SWCR_DATA_CMD(0, SWCR_WRITE
, 7, 0, 0));
3964 /* Candidate rate Ht mask */
3965 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), u2HtClrMask
);
3966 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3967 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1c, 0, 0));
3969 /* Candidate rate legacy mask */
3970 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), u2LegacyClrMask
);
3971 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3972 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1d, 0, 0));
3975 if (ucArCheckWindow
!= 0) {
3976 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
3977 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArCheckWindow
);
3978 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3979 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x14, 0, 0));
3980 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArCheckWindow
);
3981 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3982 SWCR_DATA_CMD(0, SWCR_WRITE
, 0xc, 0, 0));
3985 if (ucArPerForceRateDownPer
!= 0) {
3986 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
),
3987 ucArPerForceRateDownPer
);
3988 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3989 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x18, 0, 0));
3991 if (ucArPerH
!= 0) {
3992 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArPerH
);
3993 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3994 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1, 0, 0));
3996 if (ucArPerL
!= 0) {
3997 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArPerL
);
3998 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3999 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x2, 0, 0));
4005 return WLAN_STATUS_SUCCESS
;
4008 /*----------------------------------------------------------------------------*/
4010 * @brief This utility function is used to enable roaming
4012 * @param u4EnableRoaming
4015 * @retval WLAN_STATUS_SUCCESS
4016 * WLAN_STATUS_FAILURE
4019 * u4EnableRoaming -> Enable Romaing
4022 /*----------------------------------------------------------------------------*/
4023 WLAN_STATUS
nicRoamingUpdateParams(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4EnableRoaming
)
4025 P_CONNECTION_SETTINGS_T prConnSettings
;
4027 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
4028 prConnSettings
->fgIsEnableRoaming
= ((u4EnableRoaming
> 0) ? (TRUE
) : (FALSE
));
4030 return WLAN_STATUS_SUCCESS
;
4033 /*----------------------------------------------------------------------------*/
4035 * \brief dump firmware Assert message
4044 /*----------------------------------------------------------------------------*/
4045 VOID
nicPrintFirmwareAssertInfo(IN P_ADAPTER_T prAdapter
)
4047 UINT_32 u4MailBox0
, u4MailBox1
;
4049 UINT_8 aucAssertFile
[7];
4052 #if CFG_SDIO_INTR_ENHANCE
4053 u4MailBox0
= prAdapter
->prSDIOCtrl
->u4RcvMailbox0
;
4054 u4MailBox1
= prAdapter
->prSDIOCtrl
->u4RcvMailbox1
;
4056 nicGetMailbox(prAdapter
, 0, &u4MailBox0
);
4057 nicGetMailbox(prAdapter
, 1, &u4MailBox1
);
4060 line
= u4MailBox0
& 0x0000FFFF;
4062 u4MailBox0
= ((u4MailBox0
>> 16) & 0x0000FFFF);
4064 kalMemCopy(&aucAssertFile
[0], &u4MailBox0
, 2);
4065 kalMemCopy(&aucAssertFile
[2], &u4MailBox1
, 4);
4067 aucAssertFile
[6] = '\0';
4071 #elif defined(MT5931)
4073 #elif defined(MT6628)
4077 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
4078 u4ChipId
, aucAssertFile
, line
);
4083 /*----------------------------------------------------------------------------*/
4085 * @brief This function is called to update Link Quality information
4087 * @param prAdapter Pointer of Adapter Data Structure
4089 * prEventLinkQuality
4095 /*----------------------------------------------------------------------------*/
4097 nicUpdateLinkQuality(IN P_ADAPTER_T prAdapter
,
4098 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
,
4099 IN P_EVENT_LINK_QUALITY prEventLinkQuality
)
4102 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
4103 ASSERT(prEventLinkQuality
);
4105 switch (eNetTypeIdx
) {
4106 case NETWORK_TYPE_AIS_INDEX
:
4107 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
4108 PARAM_MEDIA_STATE_CONNECTED
) {
4109 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
4110 /* buffer statistics for further query */
4111 if (prAdapter
->fgIsLinkQualityValid
== FALSE
4112 || (kalGetTimeTick() - prAdapter
->rLinkQualityUpdateTime
) >
4113 CFG_LINK_QUALITY_VALID_PERIOD
) {
4114 nicUpdateRSSI(prAdapter
, eNetTypeIdx
, prEventLinkQuality
->cRssi
,
4115 prEventLinkQuality
->cLinkQuality
);
4118 if (prAdapter
->fgIsLinkRateValid
== FALSE
4119 || (kalGetTimeTick() - prAdapter
->rLinkRateUpdateTime
) >
4120 CFG_LINK_QUALITY_VALID_PERIOD
) {
4121 nicUpdateLinkSpeed(prAdapter
, eNetTypeIdx
,
4122 prEventLinkQuality
->u2LinkSpeed
);
4126 #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
4127 case NETWORK_TYPE_P2P_INDEX
:
4128 if (prAdapter
->fgIsP2pLinkQualityValid
== FALSE
4129 || (kalGetTimeTick() - prAdapter
->rP2pLinkQualityUpdateTime
) >
4130 CFG_LINK_QUALITY_VALID_PERIOD
) {
4131 P_EVENT_LINK_QUALITY_EX prEventLQEx
=
4132 (P_EVENT_LINK_QUALITY_EX
) prEventLinkQuality
;
4134 nicUpdateRSSI(prAdapter
, NETWORK_TYPE_P2P_INDEX
, prEventLQEx
->cRssiP2P
,
4135 prEventLQEx
->cLinkQualityP2P
);
4148 /*----------------------------------------------------------------------------*/
4150 * @brief This function is called to update RSSI and Link Quality information
4152 * @param prAdapter Pointer of Adapter Data Structure
4159 /*----------------------------------------------------------------------------*/
4161 nicUpdateRSSI(IN P_ADAPTER_T prAdapter
,
4162 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
, IN INT_8 cRssi
, IN INT_8 cLinkQuality
)
4165 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
4167 switch (eNetTypeIdx
) {
4168 case NETWORK_TYPE_AIS_INDEX
:
4169 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
4170 PARAM_MEDIA_STATE_CONNECTED
) {
4171 prAdapter
->fgIsLinkQualityValid
= TRUE
;
4172 prAdapter
->rLinkQualityUpdateTime
= kalGetTimeTick();
4174 prAdapter
->rLinkQuality
.cRssi
= cRssi
;
4175 prAdapter
->rLinkQuality
.cLinkQuality
= cLinkQuality
;
4177 /* indicate to glue layer */
4178 kalUpdateRSSI(prAdapter
->prGlueInfo
,
4179 KAL_NETWORK_TYPE_AIS_INDEX
,
4180 prAdapter
->rLinkQuality
.cRssi
,
4181 prAdapter
->rLinkQuality
.cLinkQuality
);
4185 #if CFG_ENABLE_WIFI_DIRECT
4186 #if CFG_SUPPORT_P2P_RSSI_QUERY
4187 case NETWORK_TYPE_P2P_INDEX
:
4188 prAdapter
->fgIsP2pLinkQualityValid
= TRUE
;
4189 prAdapter
->rP2pLinkQualityUpdateTime
= kalGetTimeTick();
4191 prAdapter
->rP2pLinkQuality
.cRssi
= cRssi
;
4192 prAdapter
->rP2pLinkQuality
.cLinkQuality
= cLinkQuality
;
4194 kalUpdateRSSI(prAdapter
->prGlueInfo
,
4195 KAL_NETWORK_TYPE_P2P_INDEX
, cRssi
, cLinkQuality
);
4208 /*----------------------------------------------------------------------------*/
4210 * @brief This function is called to update Link Quality information
4212 * @param prAdapter Pointer of Adapter Data Structure
4214 * prEventLinkQuality
4220 /*----------------------------------------------------------------------------*/
4222 nicUpdateLinkSpeed(IN P_ADAPTER_T prAdapter
,
4223 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
, IN UINT_16 u2LinkSpeed
)
4226 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
4228 switch (eNetTypeIdx
) {
4229 case NETWORK_TYPE_AIS_INDEX
:
4230 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
4231 PARAM_MEDIA_STATE_CONNECTED
) {
4232 /* buffer statistics for further query */
4233 prAdapter
->fgIsLinkRateValid
= TRUE
;
4234 prAdapter
->rLinkRateUpdateTime
= kalGetTimeTick();
4236 prAdapter
->rLinkQuality
.u2LinkSpeed
= u2LinkSpeed
;
4248 #if CFG_SUPPORT_RDD_TEST_MODE
4249 WLAN_STATUS
nicUpdateRddTestMode(IN P_ADAPTER_T prAdapter
, IN P_CMD_RDD_CH_T prRddChParam
)
4251 DEBUGFUNC("nicUpdateRddTestMode.\n");
4255 /* aisFsmScanRequest(prAdapter, NULL); */
4257 return wlanSendSetQueryCmd(prAdapter
,
4263 NULL
, sizeof(CMD_RDD_CH_T
), (PUINT_8
) prRddChParam
, NULL
, 0);