2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/common/wlan_lib.c#2 $
5 \brief Internal driver stack will export the required procedures here for GLUE Layer.
7 This file contains all routines which are exported from MediaTek 802.11 Wireless
8 LAN driver stack to GLUE Layer.
15 ** 08 15 2012 eason.tsai
16 ** [ALPS00338170] [Need Patch] [Volunteer Patch] modify build warning
17 ** fix build waring for codechange
20 * [WCXRP00001259] [MT6620 Wi-Fi][Driver][Firmware] Send a signal to firmware for termination after SDIO error has happened
21 * [driver domain] add force reset by host-to-device interrupt mechanism
24 * [WCXRP00001252] [MT6620 Wi-Fi][Driver] Add debug message while encountering firmware response timeout
25 * output message while timeout event occurs
27 * 06 11 2012 eason.tsai
29 * change from binay to hex code
31 * 06 08 2012 eason.tsai
33 * Nvram context covert from 6620 to 6628 for old 6620 meta tool
36 * [WCXRP00001237] [MT6620 Wi-Fi][Driver] Show MAC address and MAC address source for ACS's convenience
37 * show MAC address & source while initiliazation
39 * 03 29 2012 eason.tsai
40 * [WCXRP00001216] [MT6628 Wi-Fi][Driver]add conditional define
41 * add conditional define.
43 * 03 04 2012 eason.tsai
45 * modify the cal fail report code.
49 * Sync CFG80211 modification from branch 2,2.
52 * [WCXRP00001169] [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with corresponding network configuration
53 * correct scan result removing policy.
56 * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with corresponding network configuration
57 * add wlanSetPreferBandByNetwork() for glue layer to invoke for setting preferred band configuration corresponding to network type.
60 * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
61 * Adding the related ioctl / wlan oid function to set the Tx power cfg.
64 * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment when returining to ROM code
65 * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
66 * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
69 * [WCXRP00001104] [All Wi-Fi][FW] Show init process by HW mail-box register
70 * Show FW initial ID when timeout to wait for ready bit
73 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
74 * modify the xlog related code.
77 * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
78 * when powering off, always clear pending interrupts, then wait for RDY to be de-asserted
81 * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
82 * shorten the packet length for firmware download if no more than 2048 bytes.
85 * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
86 * add firmware download path in divided scatters.
89 * [MT6628 Driver][Firmware Download] Add multi section independent download functionality
90 * add firmware downloading aggregated path.
93 * [WCXRP00001020] [MT6620 Wi-Fi][Driver] Handle secondary channel offset of AP in 5GHz band
97 * [WCXRP00000994] [MT6620 Wi-Fi][Driver] dump message for bus error and reset bus error flag while re-initialized
98 * 1. always show error message for SDIO bus errors.
99 * 2. reset bus error flag when re-initialization
101 * 08 26 2011 cm.chang
102 * [WCXRP00000952] [MT5931 Wi-Fi][FW] Handshake with BWCS before DPD/TX power calibration
103 * Fix compiling error for WinXP MT5931 driver
105 * 08 25 2011 chinghwa.yu
106 * [WCXRP00000063] Update BCM CoEx design and settings
107 * Add BWCS Sync ready for WinXP.
109 * 08 25 2011 chinghwa.yu
110 * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
113 * 08 24 2011 chinghwa.yu
114 * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
115 * Update RDD test mode cases.
118 * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
119 * escape from normal path if any error is occured.
122 * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
123 * reuse firmware download logic of MT6620 for MT6628.
126 * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
127 * support to load different firmware image for E3/E4/E5 and E6 ASIC on win32 platforms.
129 * 08 02 2011 yuche.tsai
130 * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting device issue.
131 * Fix GO send deauth frame issue.
133 * 07 22 2011 jeffrey.chang
134 * [WCXRP00000864] [MT5931] Add command to adjust OSC stable time
135 * modify driver to set OSC stable time after f/w download
137 * 07 18 2011 chinghwa.yu
138 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
139 * Add CMD/Event for RDD and BWCS.
142 * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
143 * if there is no valid address in chip, generate a new one from driver domain instead of firmware domain due to sufficient randomness
146 * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
147 * check with firmware for valid MAC address.
150 * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
151 * disable whole-chip resetting mechanism due to the need of further ECO to work as expected.
154 * [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
155 * changed to use non-zero checking for valid bit in NVRAM content
158 * [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
159 * invoke CMD_ID_SET_EDGE_TXPWR_LIMIT when there is valid data exist in NVRAM content.
162 * [WCXRP00000734] [MT6620 Wi-Fi][Driver] Pass PHY_PARAM in NVRAM to firmware domain
163 * pass PHY_PARAM in NVRAM from driver to firmware.
166 * [WCXRP00000718] [MT6620 Wi-Fi] modify the behavior of setting tx power
170 * [WCXRP00000718] [MT6620 Wi-Fi] modify the behavior of setting tx power
171 * ACPI APIs migrate to wlan_lib.c for glue layer to invoke.
173 * 05 11 2011 cm.chang
174 * [WCXRP00000717] [MT5931 Wi-Fi][Driver] Handle wrong NVRAM content about AP bandwidth setting
178 * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
179 * change delay from 100ms to 120ms upon DE's suggestion.
182 * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
183 * add delay after whole-chip resetting for MT5931 E1 ASIC.
186 * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
187 * skip power-off handshaking when RESET indication is received.
189 * 04 22 2011 george.huang
190 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
194 * [WCXRP00000636] [WHQL][MT5931 Driver] 2c_PMHibernate (hang on 2h)
195 * 1) add API for glue layer to query ACPI state
196 * 2) Windows glue should not access to hardware after switched into D3 state
199 * [WCXRP00000654] [MT6620 Wi-Fi][Driver] Add loop termination criterion for wlanAdapterStop().
200 * add loop termination criteria for wlanAdapterStop().
202 * 04 12 2011 eddie.chen
203 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
204 * Fix the sta index in processing security frame
205 * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
209 * [WCXRP00000631] [MT6620 Wi-Fi][Driver] Add an API for QM to retrieve current TC counter value and processing frame dropping cases for TC4 path
210 * 1. add nicTxGetResource() API for QM to make decisions.
211 * 2. if management frames is decided by QM for dropping, the call back is invoked to indicate such a case.
214 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
215 * invoke nicReleaseAdapterMemory() as failure handling in case wlanAdapterStart() failed unexpectedly
218 * [WCXRP00000248] [MT6620 Wi-Fi][FW]Fixed the Klockwork error
219 * fixed the kclocwork error.
222 * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous memory consumption
223 * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
224 * 2. Use common coalescing buffer for both TX/RX directions
228 * [WCXRP00000532] [MT6620 Wi-Fi][Driver] Migrate NVRAM configuration procedures from MT6620 E2 to MT6620 E3
229 * deprecate configuration used by MT6620 E2
231 * 03 07 2011 terry.wu
232 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
233 * Toggle non-standard debug messages to comments.
236 * [WCXRP00000496] [MT5931][Driver] Apply host-triggered chip reset before initializing firmware download procedures
237 * apply host-triggered chip reset mechanism before initializing firmware download procedures.
239 * 02 17 2011 eddie.chen
240 * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
241 * 1) Chnage GetFrameAction decision when BSS is absent.
242 * 2) Check channel and resource in processing ProbeRequest
244 * 02 16 2011 cm.chang
245 * [WCXRP00000447] [MT6620 Wi-Fi][FW] Support new NVRAM update mechanism
248 * 02 01 2011 george.huang
249 * [WCXRP00000333] [MT5931][FW] support SRAM power control drivers
250 * init variable for CTIA.
252 * 01 27 2011 george.huang
253 * [WCXRP00000355] [MT6620 Wi-Fi] Set WMM-PS related setting with qualifying AP capability
254 * Support current measure mode, assigned by registry (XP only).
257 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
258 * 1. add an extra counter for tracking pending forward frames.
259 * 2. notify TX service thread as well when there is pending forward frame
260 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
262 * 01 12 2011 cm.chang
263 * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
264 * User-defined bandwidth is for 2.4G and 5G individually
267 * [WCXRP00000351] [MT6620 Wi-Fi][Driver] remove from scanning result in OID handling layer when the corresponding BSS is disconnected due to beacon timeout
268 * remove from scanning result when the BSS is disconnected due to beacon timeout.
271 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
272 * separate kalMemAlloc() into virtually-continous and physically-continous type to ease slab system pressure
275 * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
276 * while being unloaded, clear all pending interrupt then set LP-own to firmware
279 * [WCXRP00000335] [MT6620 Wi-Fi][Driver] change to use milliseconds sleep instead of delay to avoid blocking to system scheduling
280 * change to use msleep() and shorten waiting interval to reduce blocking to other task while Wi-Fi driver is being loaded
283 * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
284 * report EEPROM used flag via NIC_CAPABILITY
287 * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
288 * integrate with 'EEPROM used' flag for reporting correct capability to Engineer Mode/META and other tools
290 * 12 22 2010 eddie.chen
291 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
292 * Remove controling auto rate from initial setting. The initial setting is defined by FW code.
296 * sync. with ALPS code by enabling interrupt just before leaving wlanAdapterStart()
298 * 12 08 2010 yuche.tsai
299 * [WCXRP00000245] [MT6620][Driver] Invitation & Provision Discovery Feature Check-in
300 * Change Param name for invitation connection.
302 * 12 07 2010 cm.chang
303 * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
304 * 1. Country code is from NVRAM or supplicant
305 * 2. Change band definition in CMD/EVENT.
308 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
309 * 1) use 8 buffers for MT5931 which is equipped with less memory
310 * 2) modify MT5931 debug level to TRACE when download is successful
313 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
314 * for MT5931, adapter initialization is done *after* firmware is downloaded.
317 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
318 * correct MT5931 firmware download procedure:
319 * MT5931 will download firmware first then acquire LP-OWN
322 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
323 * 1) update MT5931 firmware encryption tool. (using 64-bytes unit)
324 * 2) update MT5931 firmware download procedure
327 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate from firmware auto rate module
328 * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
329 * 2) Remove CNM CH-RECOVER event handling
330 * 3) cfg read/write API renamed with kal prefix for unified naming rules.
332 * 11 01 2010 yarco.yang
333 * [WCXRP00000149] [MT6620 WI-Fi][Driver]Fine tune performance on MT6516 platform
334 * Add code to run WlanIST in SDIO callback.
336 * 10 27 2010 george.huang
337 * [WCXRP00000127] [MT6620 Wi-Fi][Driver] Add a registry to disable Beacon Timeout function for SQA test by using E1 EVB
338 * Support registry option for disable beacon lost detection.
341 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW] Support NIC capability query command
342 * 1) update NVRAM content template to ver 1.02
343 * 2) add compile option for querying NIC capability (default: off)
344 * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
345 * 4) correct auto-rate compiler error under linux (treat warning as error)
346 * 5) simplify usage of NVRAM and REG_INFO_T
347 * 6) add version checking between driver and firmware
349 * 10 26 2010 eddie.chen
350 * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
351 * Add auto rate parameter in registry.
354 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
355 * add option for enable/disable TX PWR gain adjustment (default: off)
358 * [WCXRP00000117] [MT6620 Wi-Fi][Driver] Add logic for suspending driver when MT6620 is not responding anymore
359 * 1. when wlanAdapterStop() failed to send POWER CTRL command to firmware, do not poll for ready bit dis-assertion
360 * 2. shorten polling count for shorter response time
361 * 3. if bad I/O operation is detected during TX resource polling, then further operation is aborted as well
364 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
365 * complete implementation of Android NVRAM access
368 * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
369 * bugfix: always reset pointer to IEbuf to zero when keeping scanning result for the connected AP
372 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
373 * adding fixed rate support for distance test. (from registry setting)
376 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
377 * add firmware download for MT5931.
380 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
381 * divide a single function into 2 part to surpress a weird compiler warning from gcc-4.4.0
384 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
385 * code reorganization to improve isolation between GLUE and CORE layers.
388 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
389 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
392 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
393 * remove ENUM_NETWORK_TYPE_T definitions
396 * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
397 * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
400 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
401 * eliminate unused variables which lead gcc to argue
404 * [WCXRP00000057] [MT6620 Wi-Fi][Driver] Modify online scan to a run-time switchable feature
405 * Modify online scan as a run-time adjustable option (for Windows, in registry)
408 * [WCXRP00000051] [MT6620 Wi-Fi][Driver] WHQL test fail in MAC address changed item
409 * use firmware reported mac address right after wlanAdapterStart() as permanent address
412 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
413 * eliminate reference of CFG_RESPONSE_MAX_PKT_SIZE
416 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
417 * Do a complete reset with STA-REC null checking for RF test re-entry
419 * 09 21 2010 kevin.huang
420 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
421 * Eliminate Linux Compile Warning
425 * acquire & release power control in oid handing wrapper.
429 * move IE to buffer head when the IE pointer is not pointed at head.
433 * use static memory pool for storing IEs of scanning result.
437 * HIFSYS Clock Source Workaround
441 * adding the wapi support for integration test.
445 * move HIF CR initialization from where after sdioSetupCardFeature() to wlanAdapterStart()
449 * eliminate klockwork errors
451 * 08 26 2010 yuche.tsai
453 * Add AT GO test configure mode under WinXP.
454 * Please enable 1. CFG_ENABLE_WIFI_DIRECT, 2. CFG_TEST_WIFI_DIRECT_GO, 3. CFG_SUPPORT_AAA
456 * 08 25 2010 george.huang
458 * update OID/ registry control path for PM related settings
462 * 1) initialize variable for enabling short premable/short time slot.
463 * 2) add compile option for disabling online scan
467 * correction issue: desired phy type not initialized as ABGN mode.
471 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
473 * 08 10 2010 cm.chang
475 * Support EEPROM read/write in RF test mode
479 * surpress compilation warning.
483 * Centralize mgmt/system service procedures into independent calls.
487 * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
488 * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
489 * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
493 * eliminate u4FreqInKHz usage, combined into rConnections.ucAdHoc*
497 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
498 * 2) change nicMediaStateChange() API prototype
502 * 1) change BG_SCAN to ONLINE_SCAN for consistent term
503 * 2) only clear scanning result when scan is permitted to do
505 * 07 19 2010 cm.chang
507 * Set RLM parameters and enable CNM channel manager
509 * 07 19 2010 jeffrey.chang
511 * Linux port modification
515 * [WPD00003833] [MT6620 and MT5931] Driver migration.
516 * Reduce unnecessary type casting
520 * use multiple queues to keep 1x/MMPDU/CMD's strict order even when there is incoming 1x frames.
524 * 1) MMPDUs are now sent to MT6620 by CMD queue for keeping strict order of 1X/MMPDU/CMD packets
525 * 2) integrate with qmGetFrameAction() for deciding which MMPDU/1X could pass checking for sending
526 * 2) enhance CMD_INFO_T descriptor number from 10 to 32 to avoid descriptor underflow under concurrent network operation
530 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
533 * [WPD00003833][MT6620 and MT5931] Driver migration
534 * 1) ignore RSN checking when RSN is not turned on.
535 * 2) set STA-REC deactivation callback as NULL
536 * 3) add variable initialization API based on PHY configuration
539 * [WPD00003833][MT6620 and MT5931] Driver migration
540 * 1) for event packet, no need to fill RFB.
541 * 2) when wlanAdapterStart() failed, no need to initialize state machines
542 * 3) after Beacon/ProbeResp parsing, corresponding BSS_DESC_T should be marked as IE-parsed
544 * 07 01 2010 cm.chang
545 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
546 * Support sync command of STA_REC
549 * [WPD00003833][MT6620 and MT5931] Driver migration
550 * add scan uninitialization procedure
553 * [WPD00003833][MT6620 and MT5931] Driver migration
554 * add API in que_mgt to retrieve sta-rec index for security frames.
557 * [WPD00003833][MT6620 and MT5931] Driver migration
558 * 802.1x and bluetooth-over-Wi-Fi security frames are now delievered to firmware via command path instead of data path.
560 * 06 23 2010 yarco.yang
561 * [WPD00003837][MT6620]Data Path Refine
562 * Merge g_arStaRec[] into adapter->arStaRec[]
565 * [WPD00003833][MT6620 and MT5931] Driver migration
566 * initialize mbox & ais_fsm in wlanAdapterStart()
569 * [WPD00003833][MT6620 and MT5931] Driver migration
570 * change MAC address updating logic.
573 * [WPD00003833][MT6620 and MT5931] Driver migration
574 * simplify timer usage.
577 * [WPD00003833][MT6620 and MT5931] Driver migration
578 * 1) migrate assoc.c.
579 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
580 * 3) add configuration options for CNM_MEM and RSN modules
581 * 4) add data path for management frames
582 * 5) eliminate rPacketInfo of MSDU_INFO_T
585 * [WPD00003833][MT6620 and MT5931] Driver migration
586 * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
587 * 2) when disconnected, indicate nic directly (no event is needed)
590 * [WPD00003833][MT6620 and MT5931] Driver migration
591 * cnm_timer has been migrated.
593 * 06 06 2010 kevin.huang
594 * [WPD00003832][MT6620 5931] Create driver base
595 * [MT6620 5931] Create driver base
598 * [WPD00001943]Create WiFi test driver framework on WinXP
599 * disable interrupt then send power control command packet.
602 * [WPD00001943]Create WiFi test driver framework on WinXP
603 * 1) when stopping adapter, wait til RDY bit has been cleaerd.
604 * 2) set TASK_OFFLOAD as driver-core OIDs
607 * [WPD00001943]Create WiFi test driver framework on WinXP
608 * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
609 * 2) buffer statistics data for 2 seconds
610 * 3) use default value for adhoc parameters instead of 0
613 * [WPD00001943]Create WiFi test driver framework on WinXP
614 * 1) do not take timeout mechanism for power mode oids
615 * 2) retrieve network type from connection status
616 * 3) after disassciation, set radio state to off
617 * 4) TCP option over IPv6 is supported
620 * [WPD00001943]Create WiFi test driver framework on WinXP
621 * add CFG_STARTUP_DEBUG for debugging starting up issue.
624 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
625 * 1) add timeout handler mechanism for pending command packets
626 * 2) add p2p add/removal key
629 * [WPD00001943]Create WiFi test driver framework on WinXP
630 * surpress compiler warning
633 * [WPD00001943]Create WiFi test driver framework on WinXP
634 * roll-back to rev.60.
637 * [WPD00001943]Create WiFi test driver framework on WinXP
638 * 1) remove redundant firmware image unloading
639 * 2) use compile-time macros to separate logic related to accquiring own
642 * [WPD00001943]Create WiFi test driver framework on WinXP
643 * treat BUS access failure as kind of card removal.
646 * [WPD00001943]Create WiFi test driver framework on WinXP
647 * always set fw-own before driver is unloaded.
650 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
651 * add framework for BT-over-Wi-Fi support.
652 * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
653 * * * 2) command sequence number is now increased atomically
654 * * * 3) private data could be hold and taken use for other purpose
657 * [WPD00001943]Create WiFi test driver framework on WinXP
658 * finish non-glue layer access to glue variables
661 * [WPD00001943]Create WiFi test driver framework on WinXP
662 * rWlanInfo should be placed at adapter rather than glue due to most operations
663 * are done in adapter layer.
666 * [WPD00001943]Create WiFi test driver framework on WinXP
667 * ePowerCtrl is not necessary as a glue variable.
669 * 04 06 2010 jeffrey.chang
670 * [WPD00003826]Initial import for Linux port
671 * add timeout check in the kalOidComplete
673 * 04 06 2010 jeffrey.chang
674 * [WPD00003826]Initial import for Linux port
675 * improve none-glue code portability
677 * 04 06 2010 jeffrey.chang
678 * [WPD00003826]Initial import for Linux port
679 * improve none-glue code portability
682 * [WPD00001943]Create WiFi test driver framework on WinXP
683 * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
686 * [WPD00001943]Create WiFi test driver framework on WinXP
687 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
690 * [WPD00001943]Create WiFi test driver framework on WinXP
691 * 1) for some OID, never do timeout expiration
692 * 2) add 2 kal API for later integration
695 * [WPD00001943]Create WiFi test driver framework on WinXP
696 * 1) eliminate unused definitions
697 * 2) ready bit will be polled for limited iteration
699 * 04 06 2010 jeffrey.chang
700 * [WPD00003826]Initial import for Linux port
701 * kalOidComplete is not necessary in linux
704 * [WPD00001943]Create WiFi test driver framework on WinXP
705 * change to use pass-in prRegInfo instead of accessing prGlueInfo directly
708 * [WPD00001943]Create WiFi test driver framework on WinXP
709 * change to use WIFI_TCM_ALWAYS_ON as firmware image
712 * [WPD00001943]Create WiFi test driver framework on WinXP
716 * [WPD00003816][MT6620 Wi-Fi] Adding the security support
717 * modify the wapi related code for new driver's design.
719 * 03 30 2010 jeffrey.chang
720 * [WPD00003826]Initial import for Linux port
721 * adding none-glue code portability
723 * 03 30 2010 jeffrey.chang
724 * [WPD00003826]Initial import for Linux port
725 * adding non-glue code portability
727 * 03 29 2010 jeffrey.chang
728 * [WPD00003826]Initial import for Linux port
729 * improve non-glue code portability
732 * [WPD00001943]Create WiFi test driver framework on WinXP
733 * firmware download load adress & start address are now configured from config.h
734 * due to the different configurations on FPGA and ASIC
736 * 03 24 2010 jeffrey.chang
737 * [WPD00003826]Initial import for Linux port
738 * [WPD00003826] Initial import for Linux port
739 * initial import for Linux port
741 * 03 24 2010 jeffrey.chang
742 * [WPD00003826]Initial import for Linux port
743 * initial import for Linux port
746 * [WPD00001943]Create WiFi test driver framework on WinXP
747 * only send CMD_NIC_POWER_CTRL in wlanAdapterStop() when card is not removed and is not in D3 state
750 * [WPD00001943]Create WiFi test driver framework on WinXP
751 * always send CMD_NIC_POWER_CTRL packet when nic is being halted
754 * [WPD00001943]Create WiFi test driver framework on WinXP
755 * 1) add ACPI D0/D3 state switching support
756 * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
759 * [WPD00001943]Create WiFi test driver framework on WinXP
760 * add two option for ACK and ENCRYPTION for firmware download
763 * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
764 * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
767 * [WPD00001943]Create WiFi test driver framework on WinXP
768 * 1) add another spin-lock to protect MsduInfoList due to it might be accessed by different thread.
769 * 2) change own-back acquiring procedure to wait for up to 16.67 seconds
772 * [WPD00001943]Create WiFi test driver framework on WinXP
773 * when starting adapter, read local adminsitrated address from registry and send to firmware via CMD_BASIC_CONFIG.
776 * [WPD00001943]Create WiFi test driver framework on WinXP
777 * 1) the use of prPendingOid revised, all accessing are now protected by spin lock
778 * 2) ensure wlanReleasePendingOid will clear all command queues
781 * [WPD00001943]Create WiFi test driver framework on WinXP
782 * add mutex to avoid multiple access to qmTxQueue simultaneously.
785 * [WPD00001943]Create WiFi test driver framework on WinXP
786 * add command/event definitions for initial states
788 * 02 24 2010 tehuang.liu
789 * [WPD00001943]Create WiFi test driver framework on WinXP
790 * Added code for QM_TEST_MODE
793 * [WPD00001943]Create WiFi test driver framework on WinXP
794 * correct function name ..
797 * [WPD00001943]Create WiFi test driver framework on WinXP
798 * separate wlanProcesQueuePacket() into 2 APIs upon request
801 * [WPD00001943]Create WiFi test driver framework on WinXP
802 * add new API: wlanProcessQueuedPackets()
805 * [WPD00001943]Create WiFi test driver framework on WinXP
806 * correct wlanAdapterStart
809 * [WPD00001943]Create WiFi test driver framework on WinXP
810 * 1. add logic for firmware download
811 * 2. firmware image filename and start/load address are now retrieved from registry
814 * [WPD00001943]Create WiFi test driver framework on WinXP
815 * implement host-side firmware download logic
818 * [WPD00001943]Create WiFi test driver framework on WinXP
819 * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
820 * 2) firmware image length is now retrieved via NdisFileOpen
821 * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
822 * 4) nicRxWaitResponse() revised
823 * 5) another set of TQ counter default value is added for fw-download state
824 * 6) Wi-Fi load address is now retrieved from registry too
827 * [WPD00001943]Create WiFi test driver framework on WinXP
828 * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
829 * 2. follow MSDN defined behavior when associates to another AP
830 * 3. for firmware download, packet size could be up to 2048 bytes
833 * [WPD00001943]Create WiFi test driver framework on WinXP
834 * prepare for implementing fw download logic
837 * [WPD00001943]Create WiFi test driver framework on WinXP
838 * wlanoidSetFrequency is now implemented by RF test command.
841 * [WPD00001943]Create WiFi test driver framework on WinXP
842 * QueryRssi is no longer w/o hardware access, it is now implemented by command/event handling loop
845 * [WPD00001943]Create WiFi test driver framework on WinXP
846 * 1. clear prPendingCmdInfo properly
847 * 2. while allocating memory for cmdinfo, no need to add extra 4 bytes.
850 * [WPD00001943]Create WiFi test driver framework on WinXP
851 * allow MCR read/write OIDs in RF test mode
854 * [WPD00001943]Create WiFi test driver framework on WinXP
855 * 1) implement timeout mechanism when OID is pending for longer than 1 second
856 * 2) allow OID_802_11_CONFIGURATION to be executed when RF test mode is turned on
859 * [WPD00001943]Create WiFi test driver framework on WinXP
860 * 1. eliminate improper variable in rHifInfo
861 * 2. block TX/ordinary OID when RF test mode is engaged
862 * 3. wait until firmware finish operation when entering into and leaving from RF test mode
863 * 4. correct some HAL implementation
866 * [WPD00001943]Create WiFi test driver framework on WinXP
867 * Under WinXP with SDIO, use prGlueInfo->rHifInfo.pvInformationBuffer instead of prGlueInfo->pvInformationBuffer
868 ** \main\maintrunk.MT6620WiFiDriver_Prj\36 2009-12-10 16:54:36 GMT mtk02752
870 ** \main\maintrunk.MT6620WiFiDriver_Prj\35 2009-12-09 20:04:59 GMT mtk02752
871 ** only report as connected when CFG_HIF_EMULATION_TEST is set to 1
872 ** \main\maintrunk.MT6620WiFiDriver_Prj\34 2009-12-08 17:39:41 GMT mtk02752
873 ** wlanoidRftestQueryAutoTest could be executed without touching hardware
874 ** \main\maintrunk.MT6620WiFiDriver_Prj\33 2009-12-03 16:10:26 GMT mtk01461
876 ** \main\maintrunk.MT6620WiFiDriver_Prj\32 2009-12-02 22:05:33 GMT mtk02752
877 ** kalOidComplete() will decrease i4OidPendingCount
878 ** \main\maintrunk.MT6620WiFiDriver_Prj\31 2009-12-01 23:02:36 GMT mtk02752
879 ** remove unnecessary spinlock
880 ** \main\maintrunk.MT6620WiFiDriver_Prj\30 2009-12-01 22:50:38 GMT mtk02752
881 ** use TC4 for command, maintein i4OidPendingCount
882 ** \main\maintrunk.MT6620WiFiDriver_Prj\29 2009-11-27 12:45:34 GMT mtk02752
883 ** prCmdInfo should be freed when invoking wlanReleasePendingOid() to clear pending oid
884 ** \main\maintrunk.MT6620WiFiDriver_Prj\28 2009-11-24 19:55:51 GMT mtk02752
885 ** wlanSendPacket & wlanRetransmitOfPendingFrames is only used in old data path
886 ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-11-23 17:59:55 GMT mtk02752
887 ** clear prPendingOID inside wlanSendCommand() when the OID didn't need to be replied.
888 ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-11-23 14:45:29 GMT mtk02752
889 ** add another version of wlanSendCommand() for command-sending only without blocking for response
890 ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-11-17 22:40:44 GMT mtk01084
891 ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-11-11 10:14:56 GMT mtk01084
892 ** modify place to invoke wlanIst
893 ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-10-30 18:17:07 GMT mtk01084
894 ** fix compiler warning
895 ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-10-29 19:46:15 GMT mtk01084
896 ** invoke interrupt process routine
897 ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-10-13 21:58:24 GMT mtk01084
898 ** modify for new HW architecture
899 ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-09-09 17:26:01 GMT mtk01084
900 ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-05-20 12:21:27 GMT mtk01461
901 ** Add SeqNum check when process Event Packet
902 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-05-19 10:38:44 GMT mtk01461
903 ** Add wlanReleasePendingOid() for mpReset() if there is a pending OID and no available TX resource to send it.
904 ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-04-29 15:41:34 GMT mtk01461
905 ** Add handle of EVENT of CMD Result in wlanSendCommand()
906 ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-04-22 09:11:23 GMT mtk01461
907 ** Fix wlanSendCommand() for Driver Domain CR
908 ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-04-21 09:33:56 GMT mtk01461
909 ** Update wlanSendCommand() for Driver Domain Response and handle Event Packet, wlanQuery/SetInformation() for enqueue CMD_INFO_T
910 ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-04-17 20:00:08 GMT mtk01461
911 ** Update wlanImageSectionDownload for optimized CMD process
912 ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-04-14 20:50:51 GMT mtk01426
913 ** Fixed compile error
914 ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-04-13 16:38:40 GMT mtk01084
915 ** add wifi start function
916 ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-04-13 14:26:44 GMT mtk01084
917 ** modify a parameter about FW download length
918 ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-10 21:53:42 GMT mtk01461
919 ** Update wlanSendCommand()
920 ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-08 16:51:04 GMT mtk01084
921 ** Update for the image download part
922 ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-01 10:32:47 GMT mtk01461
923 ** Add wlanSendLeftClusteredFrames() for SDIO_TX_ENHANCE
924 ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-03-23 21:44:13 GMT mtk01461
925 ** Refine TC assignment for WmmAssoc flag
926 ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-03-23 16:51:57 GMT mtk01084
927 ** modify the input argument of caller to RECLAIM_POWER_CONTROL_TO_PM()
928 ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-23 00:27:13 GMT mtk01461
929 ** Add reference code of FW Image Download
930 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-19 18:32:37 GMT mtk01084
931 ** update for basic power management functions
932 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:09:08 GMT mtk01461
933 ** Update TX PATH API
934 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 16:28:45 GMT mtk01426
939 /*******************************************************************************
940 * C O M P I L E R F L A G S
941 ********************************************************************************
944 /*******************************************************************************
945 * E X T E R N A L R E F E R E N C E S
946 ********************************************************************************
949 #include "mgmt/ais_fsm.h"
951 /*******************************************************************************
953 ********************************************************************************
955 /* 6.1.1.2 Interpretation of priority parameter in MAC service primitives */
956 /* Static convert the Priority Parameter/TID(User Priority/TS Identifier) to Traffic Class */
957 const UINT_8 aucPriorityParam2TC
[] = {
969 extern QUE_MGT_T g_rQM
;
971 /*******************************************************************************
973 ********************************************************************************
975 typedef struct _CODE_MAPPING_T
{
976 UINT_32 u4RegisterValue
;
977 INT_32 i4TxpowerOffset
;
978 } CODE_MAPPING_T
, *P_CODE_MAPPING_T
;
980 /*******************************************************************************
981 * P U B L I C D A T A
982 ********************************************************************************
984 BOOLEAN fgIsBusAccessFailed
= FALSE
;
986 /*******************************************************************************
987 * P R I V A T E D A T A
988 ********************************************************************************
992 /*******************************************************************************
994 ********************************************************************************
996 #define SIGNED_EXTEND(n, _sValue) \
997 (((_sValue) & BIT((n)-1)) ? ((_sValue) | BITS(n,31)) : \
998 ((_sValue) & ~BITS(n,31)))
1001 /* OID set handlers without the need to access HW register */
1002 PFN_OID_HANDLER_FUNC apfnOidSetHandlerWOHwAccess
[] = {
1004 wlanoidSetBeaconInterval
,
1005 wlanoidSetAtimWindow
,
1006 wlanoidSetFrequency
,
1010 /* OID query handlers without the need to access HW register */
1011 PFN_OID_HANDLER_FUNC apfnOidQueryHandlerWOHwAccess
[] = {
1014 wlanoidQueryInfrastructureMode
,
1015 wlanoidQueryAuthMode
,
1016 wlanoidQueryEncryptionStatus
,
1018 wlanoidQueryNetworkTypeInUse
,
1019 wlanoidQueryBssidList
,
1020 wlanoidQueryAcpiDevicePowerState
,
1021 wlanoidQuerySupportedRates
,
1022 wlanoidQueryDesiredRates
,
1023 wlanoidQuery802dot11PowerSaveProfile
,
1024 wlanoidQueryBeaconInterval
,
1025 wlanoidQueryAtimWindow
,
1026 wlanoidQueryFrequency
,
1029 /* OID set handlers allowed in RF test mode */
1030 PFN_OID_HANDLER_FUNC apfnOidSetHandlerAllowedInRFTest
[] = {
1031 wlanoidRftestSetTestMode
,
1032 wlanoidRftestSetAbortTestMode
,
1033 wlanoidRftestSetAutoTest
,
1035 wlanoidSetEepromWrite
1038 /* OID query handlers allowed in RF test mode */
1039 PFN_OID_HANDLER_FUNC apfnOidQueryHandlerAllowedInRFTest
[] = {
1040 wlanoidRftestQueryAutoTest
,
1041 wlanoidQueryMcrRead
,
1042 wlanoidQueryEepromRead
1046 PFN_OID_HANDLER_FUNC apfnOidWOTimeoutCheck
[] = {
1047 wlanoidRftestSetTestMode
,
1048 wlanoidRftestSetAbortTestMode
,
1049 wlanoidSetAcpiDevicePowerState
,
1053 /*******************************************************************************
1055 ********************************************************************************
1058 /*******************************************************************************
1059 * F U N C T I O N D E C L A R A T I O N S
1060 ********************************************************************************
1063 /*******************************************************************************
1065 ********************************************************************************
1068 /*----------------------------------------------------------------------------*/
1070 * \brief This is a private routine, which is used to check if HW access is needed
1071 * for the OID query/ set handlers.
1073 * \param[IN] pfnOidHandler Pointer to the OID handler.
1074 * \param[IN] fgSetInfo It is a Set information handler.
1076 * \retval TRUE This function needs HW access
1077 * \retval FALSE This function does not need HW access
1079 /*----------------------------------------------------------------------------*/
1081 wlanIsHandlerNeedHwAccess (
1082 IN PFN_OID_HANDLER_FUNC pfnOidHandler
,
1083 IN BOOLEAN fgSetInfo
1086 PFN_OID_HANDLER_FUNC
* apfnOidHandlerWOHwAccess
;
1088 UINT_32 u4NumOfElem
;
1091 apfnOidHandlerWOHwAccess
= apfnOidSetHandlerWOHwAccess
;
1092 u4NumOfElem
= sizeof(apfnOidSetHandlerWOHwAccess
) / sizeof(PFN_OID_HANDLER_FUNC
);
1095 apfnOidHandlerWOHwAccess
= apfnOidQueryHandlerWOHwAccess
;
1096 u4NumOfElem
= sizeof(apfnOidQueryHandlerWOHwAccess
) / sizeof(PFN_OID_HANDLER_FUNC
);
1099 for (i
= 0; i
< u4NumOfElem
; i
++) {
1100 if (apfnOidHandlerWOHwAccess
[i
] == pfnOidHandler
) {
1106 } /* wlanIsHandlerNeedHwAccess */
1109 /*----------------------------------------------------------------------------*/
1111 * \brief This routine is called to set flag for later handling card
1114 * \param[in] prAdapter Pointer to the Adapter structure.
1118 * \note When surprised removal happens, Glue layer should invoke this
1119 * function to notify WPDD not to do any hw access.
1121 /*----------------------------------------------------------------------------*/
1124 IN P_ADAPTER_T prAdapter
1127 DEBUGFUNC("wlanCardEjected");
1132 /* mark that the card is being ejected, NDIS will shut us down soon */
1133 nicTxRelease(prAdapter
);
1135 } /* wlanCardEjected */
1139 /*----------------------------------------------------------------------------*/
1141 * \brief Create adapter object
1143 * \param prAdapter This routine is call to allocate the driver software objects.
1144 * If fails, return NULL.
1145 * \retval NULL If it fails, NULL is returned.
1146 * \retval NOT NULL If the adapter was initialized successfully.
1148 /*----------------------------------------------------------------------------*/
1151 IN P_GLUE_INFO_T prGlueInfo
1154 P_ADAPTER_T prAdpater
= (P_ADAPTER_T
)NULL
;
1156 DEBUGFUNC("wlanAdapterCreate");
1159 prAdpater
= (P_ADAPTER_T
) kalMemAlloc(sizeof(ADAPTER_T
), VIR_MEM_TYPE
);
1162 DBGLOG(INIT
, ERROR
, ("Allocate ADAPTER memory ==> FAILED\n"));
1167 g_rQM
.prAdapter
= prAdpater
;
1169 kalMemZero(prAdpater
, sizeof(ADAPTER_T
));
1170 prAdpater
->prGlueInfo
= prGlueInfo
;
1175 } /* wlanAdapterCreate */
1178 /*----------------------------------------------------------------------------*/
1180 * \brief Destroy adapter object
1182 * \param prAdapter This routine is call to destroy the driver software objects.
1183 * If fails, return NULL.
1186 /*----------------------------------------------------------------------------*/
1188 wlanAdapterDestroy (
1189 IN P_ADAPTER_T prAdapter
1197 kalMemFree(prAdapter
, VIR_MEM_TYPE
, sizeof(ADAPTER_T
));
1202 /*----------------------------------------------------------------------------*/
1204 * \brief Initialize the adapter. The sequence is
1205 * 1. Disable interrupt
1206 * 2. Read adapter configuration from EEPROM and registry, verify chip ID.
1207 * 3. Create NIC Tx/Rx resource.
1208 * 4. Initialize the chip
1209 * 5. Initialize the protocol
1210 * 6. Enable Interrupt
1212 * \param prAdapter Pointer of Adapter Data Structure
1214 * \retval WLAN_STATUS_SUCCESS: Success
1215 * \retval WLAN_STATUS_FAILURE: Failed
1217 /*----------------------------------------------------------------------------*/
1220 IN P_ADAPTER_T prAdapter
,
1221 IN P_REG_INFO_T prRegInfo
,
1222 IN PVOID pvFwImageMapFile
,
1223 IN UINT_32 u4FwImageFileLength
1226 extern BOOLEAN fgIsResetting
;
1227 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1228 UINT_32 i
, u4Value
= 0;
1229 UINT_32 u4WHISR
= 0;
1230 UINT_8 aucTxCount
[8];
1231 #if CFG_ENABLE_FW_DOWNLOAD
1232 UINT_32 u4FwLoadAddr
, u4ImgSecSize
;
1233 #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
1235 P_FIRMWARE_DIVIDED_DOWNLOAD_T prFwHead
;
1236 BOOLEAN fgValidHead
;
1237 const UINT_32 u4CRCOffset
= offsetof(FIRMWARE_DIVIDED_DOWNLOAD_T
, u4NumOfEntries
);
1240 #if (defined(MT5931) && (!CFG_SUPPORT_BCM_BWCS))
1241 PARAM_PTA_IPC_T rBwcsPta
;
1242 UINT_32 u4SetInfoLen
;
1245 enum Adapter_Start_Fail_Reason
{
1246 ALLOC_ADAPTER_MEM_FAIL
,
1249 RAM_CODE_DOWNLOAD_FAIL
,
1250 WAIT_FIRMWARE_READY_FAIL
,
1255 DEBUGFUNC("wlanAdapterStart");
1257 eFailReason
= FAIL_REASON_MAX
;
1258 //4 <0> Reset variables in ADAPTER_T
1259 prAdapter
->fgIsFwOwn
= TRUE
;
1260 prAdapter
->fgIsEnterD3ReqIssued
= FALSE
;
1262 QUEUE_INITIALIZE(&(prAdapter
->rPendingCmdQueue
));
1264 /* Initialize rWlanInfo */
1265 kalMemSet(&(prAdapter
->rWlanInfo
), 0, sizeof(WLAN_INFO_T
));
1267 //4 <0.1> reset fgIsBusAccessFailed
1268 fgIsBusAccessFailed
= FALSE
;
1271 if ( (u4Status
= nicAllocateAdapterMemory(prAdapter
)) != WLAN_STATUS_SUCCESS
) {
1272 DBGLOG(INIT
, ERROR
, ("nicAllocateAdapterMemory Error!\n"));
1273 u4Status
= WLAN_STATUS_FAILURE
;
1274 eFailReason
= ALLOC_ADAPTER_MEM_FAIL
;
1278 prAdapter
->u4OsPacketFilter
= PARAM_PACKET_FILTER_SUPPORTED
;
1280 #if defined(MT6620) || defined(MT6628)
1281 DBGLOG(INIT
, TRACE
, ("wlanAdapterStart(): Acquiring LP-OWN %d\n", fgIsResetting
));
1282 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
1284 #if !CFG_ENABLE_FULL_PM
1285 nicpmSetDriverOwn(prAdapter
);
1288 if(prAdapter
->fgIsFwOwn
== TRUE
) {
1289 DBGLOG(INIT
, ERROR
, ("nicpmSetDriverOwn() failed!\n"));
1290 u4Status
= WLAN_STATUS_FAILURE
;
1291 eFailReason
= DRIVER_OWN_FAIL
;
1295 //4 <1> Initialize the Adapter
1296 if ( (u4Status
= nicInitializeAdapter(prAdapter
)) != WLAN_STATUS_SUCCESS
) {
1297 DBGLOG(INIT
, ERROR
, ("nicInitializeAdapter failed!\n"));
1298 u4Status
= WLAN_STATUS_FAILURE
;
1299 eFailReason
= INIT_ADAPTER_FAIL
;
1304 /* init wake lock before interrupt enable and tx thread */
1305 KAL_WAKE_LOCK_INIT(prAdapter
, &prAdapter
->rTxThreadWakeLock
, "WLAN TX THREAD");
1307 //4 <2> Initialize System Service (MGMT Memory pool and STA_REC)
1308 nicInitSystemService(prAdapter
);
1310 //4 <3> Initialize Tx
1311 nicTxInitialize(prAdapter
);
1312 wlanDefTxPowerCfg(prAdapter
);
1314 //4 <4> Initialize Rx
1315 nicRxInitialize(prAdapter
);
1317 #if CFG_ENABLE_FW_DOWNLOAD
1318 #if defined(MT6620) || defined(MT6628)
1319 if (pvFwImageMapFile
) {
1320 /* 1. disable interrupt, download is done by polling mode only */
1321 nicDisableInterrupt(prAdapter
);
1323 /* 2. Initialize Tx Resource to fw download state */
1324 nicTxInitResetResource(prAdapter
);
1326 /* 3. FW download here */
1327 u4FwLoadAddr
= prRegInfo
->u4LoadAddress
;
1329 #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
1330 // 3a. parse file header for decision of divided firmware download or not
1331 prFwHead
= (P_FIRMWARE_DIVIDED_DOWNLOAD_T
)pvFwImageMapFile
;
1333 if(prFwHead
->u4Signature
== MTK_WIFI_SIGNATURE
&&
1334 prFwHead
->u4CRC
== wlanCRC32((PUINT_8
)pvFwImageMapFile
+ u4CRCOffset
, u4FwImageFileLength
- u4CRCOffset
)) {
1338 fgValidHead
= FALSE
;
1341 /* 3b. engage divided firmware downloading */
1342 if(fgValidHead
== TRUE
) {
1343 DBGLOG(INIT
, TRACE
, ("wlanAdapterStart(): fgValidHead == TRUE\n"));
1345 for(i
= 0 ; i
< prFwHead
->u4NumOfEntries
; i
++) {
1347 #if CFG_START_ADDRESS_IS_1ST_SECTION_ADDR
1349 prRegInfo
->u4StartAddress
= prFwHead
->arSection
[i
].u4DestAddr
;
1350 DBGLOG(INIT
, TRACE
, ("wlanAdapterStart(): FW start address 0x%08x\n", prRegInfo
->u4StartAddress
));
1354 #if CFG_ENABLE_FW_DOWNLOAD_AGGREGATION
1355 if(wlanImageSectionDownloadAggregated(prAdapter
,
1356 prFwHead
->arSection
[i
].u4DestAddr
,
1357 prFwHead
->arSection
[i
].u4Length
,
1358 (PUINT_8
)pvFwImageMapFile
+ prFwHead
->arSection
[i
].u4Offset
) != WLAN_STATUS_SUCCESS
) {
1359 DBGLOG(INIT
, ERROR
, ("Firmware scatter download failed!\n"));
1360 u4Status
= WLAN_STATUS_FAILURE
;
1363 for(j
= 0 ; j
< prFwHead
->arSection
[i
].u4Length
; j
+= CMD_PKT_SIZE_FOR_IMAGE
) {
1364 if(j
+ CMD_PKT_SIZE_FOR_IMAGE
< prFwHead
->arSection
[i
].u4Length
)
1365 u4ImgSecSize
= CMD_PKT_SIZE_FOR_IMAGE
;
1367 u4ImgSecSize
= prFwHead
->arSection
[i
].u4Length
- j
;
1369 if(wlanImageSectionDownload(prAdapter
,
1370 prFwHead
->arSection
[i
].u4DestAddr
+ j
,
1372 (PUINT_8
)pvFwImageMapFile
+ prFwHead
->arSection
[i
].u4Offset
+ j
) != WLAN_STATUS_SUCCESS
) {
1373 DBGLOG(INIT
, ERROR
, ("Firmware scatter download failed %d!\n", (int)i
));
1374 u4Status
= WLAN_STATUS_FAILURE
;
1380 /* escape from loop if any pending error occurs */
1381 if(u4Status
== WLAN_STATUS_FAILURE
) {
1388 #if CFG_ENABLE_FW_DOWNLOAD_AGGREGATION
1389 if(wlanImageSectionDownloadAggregated(prAdapter
,
1391 u4FwImageFileLength
,
1392 (PUINT_8
)pvFwImageMapFile
) != WLAN_STATUS_SUCCESS
) {
1393 DBGLOG(INIT
, ERROR
, ("Firmware scatter download failed!\n"));
1394 u4Status
= WLAN_STATUS_FAILURE
;
1397 for (i
= 0; i
< u4FwImageFileLength
; i
+= CMD_PKT_SIZE_FOR_IMAGE
) {
1398 if(i
+ CMD_PKT_SIZE_FOR_IMAGE
< u4FwImageFileLength
)
1399 u4ImgSecSize
= CMD_PKT_SIZE_FOR_IMAGE
;
1401 u4ImgSecSize
= u4FwImageFileLength
- i
;
1403 if(wlanImageSectionDownload(prAdapter
,
1406 (PUINT_8
)pvFwImageMapFile
+ i
) != WLAN_STATUS_SUCCESS
) {
1407 DBGLOG(INIT
, ERROR
, ("Firmware scatter download failed!\n"));
1408 u4Status
= WLAN_STATUS_FAILURE
;
1414 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1415 eFailReason
= RAM_CODE_DOWNLOAD_FAIL
;
1419 #if !CFG_ENABLE_FW_DOWNLOAD_ACK
1420 // Send INIT_CMD_ID_QUERY_PENDING_ERROR command and wait for response
1421 if(wlanImageQueryStatus(prAdapter
) != WLAN_STATUS_SUCCESS
) {
1422 DBGLOG(INIT
, ERROR
, ("Firmware download failed!\n"));
1423 u4Status
= WLAN_STATUS_FAILURE
;
1429 DBGLOG(INIT
, ERROR
, ("No Firmware found!\n"));
1430 u4Status
= WLAN_STATUS_FAILURE
;
1431 eFailReason
= RAM_CODE_DOWNLOAD_FAIL
;
1435 /* 4. send Wi-Fi Start command */
1436 printk("<wifi> send Wi-Fi Start command\n");
1437 #if CFG_OVERRIDE_FW_START_ADDRESS
1438 wlanConfigWifiFunc(prAdapter
,
1440 prRegInfo
->u4StartAddress
);
1442 wlanConfigWifiFunc(prAdapter
,
1446 #elif defined(MT5931)
1447 if (pvFwImageMapFile
) {
1448 DBGLOG(INIT
, TRACE
, ("Download Address: 0x%08X\n", prRegInfo
->u4LoadAddress
));
1449 DBGLOG(INIT
, TRACE
, ("Firmware Length: 0x%08X\n", u4FwImageFileLength
));
1452 #if CFG_SUPPORT_WHOLE_CHIP_RESET
1453 #define RESET_RDY_INTERVAL (120)
1455 /* 1.0 whole-chip reset except HIFSYS */
1456 HAL_MCR_WR(prAdapter
, MCR_WMCSR
, WMCSR_CHIP_RST
);
1457 HAL_MCR_WR(prAdapter
, MCR_WMCSR
, 0);
1459 /* 1.0.1 delay for EEIF ready */
1460 kalMsleep(RESET_RDY_INTERVAL
);
1463 /* 1.1 wait for INIT_RDY */
1466 HAL_MCR_RD(prAdapter
, MCR_WMCSR
, &u4Value
);
1468 if (u4Value
& WMCSR_INI_RDY
) {
1469 DBGLOG(INIT
, TRACE
, ("INIT-RDY detected\n"));
1472 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
1473 || fgIsBusAccessFailed
== TRUE
) {
1474 u4Status
= WLAN_STATUS_FAILURE
;
1477 else if(i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
1478 DBGLOG(INIT
, ERROR
, ("Waiting for Init Ready bit: Timeout\n"));
1479 u4Status
= WLAN_STATUS_FAILURE
;
1488 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1492 /* 1.2 set KSEL/FLEN */
1493 HAL_MCR_WR(prAdapter
, MCR_FWCFG
, u4FwImageFileLength
>> 6);
1495 /* 1.3 enable FWDL_EN */
1496 HAL_MCR_WR(prAdapter
, MCR_WMCSR
, WMCSR_FWDLEN
);
1498 /* 1.4 wait for PLL_RDY */
1501 HAL_MCR_RD(prAdapter
, MCR_WMCSR
, &u4Value
);
1503 if (u4Value
& WMCSR_PLLRDY
) {
1504 DBGLOG(INIT
, TRACE
, ("PLL-RDY detected\n"));
1507 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
1508 || fgIsBusAccessFailed
== TRUE
) {
1509 u4Status
= WLAN_STATUS_FAILURE
;
1512 else if(i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
1513 DBGLOG(INIT
, ERROR
, ("Waiting for PLL Ready bit: Timeout\n"));
1514 u4Status
= WLAN_STATUS_FAILURE
;
1523 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1527 /* 2.1 turn on HIFSYS firmware download mode */
1528 HAL_MCR_WR(prAdapter
, MCR_FWDLSR
, FWDLSR_FWDL_MODE
);
1530 /* 2.2 set starting address */
1531 u4FwLoadAddr
= prRegInfo
->u4LoadAddress
;
1532 HAL_MCR_WR(prAdapter
, MCR_FWDLDSAR
, u4FwLoadAddr
);
1534 /* 3. upload firmware */
1535 for (i
= 0; i
< u4FwImageFileLength
; i
+= CMD_PKT_SIZE_FOR_IMAGE
) {
1536 if(i
+ CMD_PKT_SIZE_FOR_IMAGE
< u4FwImageFileLength
)
1537 u4ImgSecSize
= CMD_PKT_SIZE_FOR_IMAGE
;
1539 u4ImgSecSize
= u4FwImageFileLength
- i
;
1541 if(wlanImageSectionDownload(prAdapter
,
1544 (PUINT_8
)pvFwImageMapFile
+ i
) != WLAN_STATUS_SUCCESS
) {
1545 DBGLOG(INIT
, ERROR
, ("Firmware scatter download failed!\n"));
1546 u4Status
= WLAN_STATUS_FAILURE
;
1551 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1555 /* 4.1 poll FWDL_OK & FWDL_FAIL bits */
1558 HAL_MCR_RD(prAdapter
, MCR_WMCSR
, &u4Value
);
1560 if (u4Value
& WMCSR_DL_OK
) {
1561 DBGLOG(INIT
, TRACE
, ("DL_OK detected\n"));
1564 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
1565 || fgIsBusAccessFailed
== TRUE
1566 || (u4Value
& WMCSR_DL_FAIL
)) {
1567 DBGLOG(INIT
, ERROR
, ("DL_FAIL detected: 0x%08X\n", u4Value
));
1568 u4Status
= WLAN_STATUS_FAILURE
;
1571 else if(i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
1572 DBGLOG(INIT
, ERROR
, ("Waiting for DL_OK/DL_FAIL bit: Timeout\n"));
1573 u4Status
= WLAN_STATUS_FAILURE
;
1582 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1586 /* 4.2 turn off HIFSYS download mode */
1587 HAL_MCR_WR(prAdapter
, MCR_FWDLSR
, 0);
1591 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1595 /* 5. disable interrupt */
1596 nicDisableInterrupt(prAdapter
);
1599 DBGLOG(INIT
, ERROR
, ("No Firmware found!\n"));
1600 u4Status
= WLAN_STATUS_FAILURE
;
1606 DBGLOG(INIT
, TRACE
, ("wlanAdapterStart(): Waiting for Ready bit..\n"));
1607 //4 <5> check Wi-Fi FW asserts ready bit
1610 HAL_MCR_RD(prAdapter
, MCR_WCIR
, &u4Value
);
1612 if (u4Value
& WCIR_WLAN_READY
) {
1613 DBGLOG(INIT
, TRACE
, ("Ready bit asserted\n"));
1616 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
1617 || fgIsBusAccessFailed
== TRUE
) {
1618 u4Status
= WLAN_STATUS_FAILURE
;
1619 eFailReason
= WAIT_FIRMWARE_READY_FAIL
;
1622 else if(i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
1625 nicGetMailbox(prAdapter
, 0, &u4MailBox0
);
1626 DBGLOG(INIT
, ERROR
, ("Waiting for Ready bit: Timeout, ID=%u\n",
1627 (u4MailBox0
& 0x0000FFFF)));
1628 u4Status
= WLAN_STATUS_FAILURE
;
1629 eFailReason
= WAIT_FIRMWARE_READY_FAIL
;
1640 DBGLOG(INIT
, TRACE
, ("wlanAdapterStart(): Acquiring LP-OWN\n"));
1641 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
1642 #if !CFG_ENABLE_FULL_PM
1643 nicpmSetDriverOwn(prAdapter
);
1646 if(prAdapter
->fgIsFwOwn
== TRUE
) {
1647 DBGLOG(INIT
, ERROR
, ("nicpmSetDriverOwn() failed!\n"));
1648 u4Status
= WLAN_STATUS_FAILURE
;
1652 //4 <1> Initialize the Adapter
1653 if ( (u4Status
= nicInitializeAdapter(prAdapter
)) != WLAN_STATUS_SUCCESS
) {
1654 DBGLOG(INIT
, ERROR
, ("nicInitializeAdapter failed!\n"));
1655 u4Status
= WLAN_STATUS_FAILURE
;
1659 /* post initialization for MT5931 due to some CR is only accessible after driver own */
1660 nicRxPostInitialize(prAdapter
);
1663 if(u4Status
== WLAN_STATUS_SUCCESS
) {
1664 // 1. reset interrupt status
1665 HAL_READ_INTR_STATUS(prAdapter
, 4, (PUINT_8
)&u4WHISR
);
1666 if(HAL_IS_TX_DONE_INTR(u4WHISR
)) {
1667 HAL_READ_TX_RELEASED_COUNT(prAdapter
, aucTxCount
);
1670 /* 2. reset TX Resource for normal operation */
1671 nicTxResetResource(prAdapter
);
1673 #if CFG_SUPPORT_OSC_SETTING && defined(MT5931)
1674 wlanSetMcuOscStableTime(prAdapter
, 0);
1677 /* 3. query for permanent address by polling */
1678 wlanQueryPermanentAddress(prAdapter
);
1680 #if (CFG_SUPPORT_NIC_CAPABILITY == 1)
1681 /* 4. query for NIC capability */
1682 wlanQueryNicCapability(prAdapter
);
1684 /* 4.1 query for compiler flags */
1685 wlanQueryCompileFlags(prAdapter
);
1687 /* 5. Override network address */
1688 wlanUpdateNetworkAddress(prAdapter
);
1690 /* 6. indicate disconnection as default status */
1691 kalIndicateStatusAndComplete(prAdapter
->prGlueInfo
,
1692 WLAN_STATUS_MEDIA_DISCONNECT
,
1697 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
1699 if(u4Status
!= WLAN_STATUS_SUCCESS
) {
1700 eFailReason
= WAIT_FIRMWARE_READY_FAIL
;
1704 /* OID timeout timer initialize */
1705 cnmTimerInitTimer(prAdapter
,
1706 &prAdapter
->rOidTimeoutTimer
,
1707 (PFN_MGMT_TIMEOUT_FUNC
)wlanReleasePendingOid
,
1710 /* Return Indicated Rfb list timer */
1711 cnmTimerInitTimer(prAdapter
,
1712 &prAdapter
->rReturnIndicatedRfbListTimer
,
1713 (PFN_MGMT_TIMEOUT_FUNC
)wlanReturnIndicatedPacketsTimeOut
,
1716 /* Power state initialization */
1717 prAdapter
->fgWiFiInSleepyState
= FALSE
;
1718 prAdapter
->rAcpiState
= ACPI_STATE_D0
;
1720 /* Online scan option */
1721 if(prRegInfo
->fgDisOnlineScan
== 0) {
1722 prAdapter
->fgEnOnlineScan
= TRUE
;
1725 prAdapter
->fgEnOnlineScan
= FALSE
;
1728 /* Beacon lost detection option */
1729 if(prRegInfo
->fgDisBcnLostDetection
!= 0) {
1730 prAdapter
->fgDisBcnLostDetection
= TRUE
;
1733 /* Load compile time constant */
1734 prAdapter
->rWlanInfo
.u2BeaconPeriod
= CFG_INIT_ADHOC_BEACON_INTERVAL
;
1735 prAdapter
->rWlanInfo
.u2AtimWindow
= CFG_INIT_ADHOC_ATIM_WINDOW
;
1737 #if 1// set PM parameters
1738 prAdapter
->fgEnArpFilter
= prRegInfo
->fgEnArpFilter
;
1739 prAdapter
->u4PsCurrentMeasureEn
= prRegInfo
->u4PsCurrentMeasureEn
;
1741 prAdapter
->u4UapsdAcBmp
= prRegInfo
->u4UapsdAcBmp
;
1743 prAdapter
->u4MaxSpLen
= prRegInfo
->u4MaxSpLen
;
1745 DBGLOG(INIT
, TRACE
, ("[1] fgEnArpFilter:0x%x, u4UapsdAcBmp:0x%x, u4MaxSpLen:0x%x",
1746 prAdapter
->fgEnArpFilter
,
1747 prAdapter
->u4UapsdAcBmp
,
1748 prAdapter
->u4MaxSpLen
));
1750 prAdapter
->fgEnCtiaPowerMode
= FALSE
;
1752 #if CFG_SUPPORT_DBG_POWERMODE
1753 prAdapter
->fgEnDbgPowerMode
= FALSE
;
1758 /* MGMT Initialization */
1759 nicInitMGMT(prAdapter
, prRegInfo
);
1761 /* Enable WZC Disassociation */
1762 prAdapter
->rWifiVar
.fgSupportWZCDisassociation
= TRUE
;
1764 /* Apply Rate Setting */
1765 if((ENUM_REGISTRY_FIXED_RATE_T
)(prRegInfo
->u4FixedRate
) < FIXED_RATE_NUM
) {
1766 prAdapter
->rWifiVar
.eRateSetting
= (ENUM_REGISTRY_FIXED_RATE_T
)(prRegInfo
->u4FixedRate
);
1769 prAdapter
->rWifiVar
.eRateSetting
= FIXED_RATE_NONE
;
1772 if(prAdapter
->rWifiVar
.eRateSetting
== FIXED_RATE_NONE
) {
1773 /* Enable Auto (Long/Short) Preamble */
1774 prAdapter
->rWifiVar
.ePreambleType
= PREAMBLE_TYPE_AUTO
;
1776 else if((prAdapter
->rWifiVar
.eRateSetting
>= FIXED_RATE_MCS0_20M_400NS
&&
1777 prAdapter
->rWifiVar
.eRateSetting
<= FIXED_RATE_MCS7_20M_400NS
)
1778 || (prAdapter
->rWifiVar
.eRateSetting
>= FIXED_RATE_MCS0_40M_400NS
&&
1779 prAdapter
->rWifiVar
.eRateSetting
<= FIXED_RATE_MCS32_400NS
)) {
1780 /* Force Short Preamble */
1781 prAdapter
->rWifiVar
.ePreambleType
= PREAMBLE_TYPE_SHORT
;
1784 /* Force Long Preamble */
1785 prAdapter
->rWifiVar
.ePreambleType
= PREAMBLE_TYPE_LONG
;
1788 /* Disable Hidden SSID Join */
1789 prAdapter
->rWifiVar
.fgEnableJoinToHiddenSSID
= FALSE
;
1791 /* Enable Short Slot Time */
1792 prAdapter
->rWifiVar
.fgIsShortSlotTimeOptionEnable
= TRUE
;
1794 /* configure available PHY type set */
1795 nicSetAvailablePhyTypeSet(prAdapter
);
1797 #if 1// set PM parameters
1799 #if CFG_SUPPORT_PWR_MGT
1800 prAdapter
->u4PowerMode
= prRegInfo
->u4PowerMode
;
1801 prAdapter
->rWlanInfo
.arPowerSaveMode
[NETWORK_TYPE_P2P_INDEX
].ucNetTypeIndex
= NETWORK_TYPE_P2P_INDEX
;
1802 prAdapter
->rWlanInfo
.arPowerSaveMode
[NETWORK_TYPE_P2P_INDEX
].ucPsProfile
= ENUM_PSP_FAST_SWITCH
;
1804 prAdapter
->u4PowerMode
= ENUM_PSP_CONTINUOUS_ACTIVE
;
1807 nicConfigPowerSaveProfile(
1809 NETWORK_TYPE_AIS_INDEX
, //FIXIT
1810 prAdapter
->u4PowerMode
,
1816 #if CFG_SUPPORT_NVRAM
1817 /* load manufacture data */
1818 wlanLoadManufactureData(prAdapter
, prRegInfo
);
1821 #ifdef CONFIG_MTK_TC1_FEATURE// 1 //keep alive packet time change from default 30secs to 20secs. //TC01//
1823 CMD_SW_DBG_CTRL_T rCmdSwCtrl
;
1824 rCmdSwCtrl
.u4Id
= 0x90100000;
1825 rCmdSwCtrl
.u4Data
= 30;
1826 printk( "wlanAdapterStart Keepaliveapcket 0x%x, %d\n", rCmdSwCtrl
.u4Id
, rCmdSwCtrl
.u4Data
);
1827 wlanSendSetQueryCmd(prAdapter
,
1834 sizeof(CMD_SW_DBG_CTRL_T
),
1835 (PUINT_8
)(&rCmdSwCtrl
),
1841 #if (defined(MT5931) && (!CFG_SUPPORT_BCM_BWCS))
1842 //Enable DPD calibration.
1843 rBwcsPta
.u
.aucBTPParams
[0] = 0x00;
1844 rBwcsPta
.u
.aucBTPParams
[1] = 0x01;
1845 rBwcsPta
.u
.aucBTPParams
[2] = 0x00;
1846 rBwcsPta
.u
.aucBTPParams
[3] = 0x80;
1848 wlanoidSetBT(prAdapter
,
1850 sizeof(PARAM_PTA_IPC_T
),
1855 /* Update Auto rate parameters in FW */
1856 nicRlmArUpdateParms(prAdapter
,
1857 prRegInfo
->u4ArSysParam0
,
1858 prRegInfo
->u4ArSysParam1
,
1859 prRegInfo
->u4ArSysParam2
,
1860 prRegInfo
->u4ArSysParam3
);
1864 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1865 /* clock gating workaround */
1866 prAdapter
->fgIsClockGatingEnabled
= FALSE
;
1871 if(u4Status
== WLAN_STATUS_SUCCESS
) {
1872 // restore to hardware default
1873 HAL_SET_INTR_STATUS_READ_CLEAR(prAdapter
);
1874 HAL_SET_MAILBOX_READ_CLEAR(prAdapter
, FALSE
);
1876 /* Enable interrupt */
1877 nicEnableInterrupt(prAdapter
);
1881 // release allocated memory
1882 switch (eFailReason
)
1884 case WAIT_FIRMWARE_READY_FAIL
:
1885 case RAM_CODE_DOWNLOAD_FAIL
:
1886 DBGLOG(INIT
, ERROR
, ("Wait firmware ready fail or ram code download fail, FailReason: %d\n",
1888 KAL_WAKE_LOCK_DESTROY(prAdapter
, &prAdapter
->rTxThreadWakeLock
);
1889 nicRxUninitialize(prAdapter
);
1890 nicTxRelease(prAdapter
);
1891 /* System Service Uninitialization */
1892 nicUninitSystemService(prAdapter
);
1893 case INIT_ADAPTER_FAIL
:
1894 case DRIVER_OWN_FAIL
:
1895 nicReleaseAdapterMemory(prAdapter
);
1896 case ALLOC_ADAPTER_MEM_FAIL
:
1904 } /* wlanAdapterStart */
1907 /*----------------------------------------------------------------------------*/
1909 * \brief Uninitialize the adapter
1911 * \param prAdapter Pointer of Adapter Data Structure
1913 * \retval WLAN_STATUS_SUCCESS: Success
1914 * \retval WLAN_STATUS_FAILURE: Failed
1916 /*----------------------------------------------------------------------------*/
1919 IN P_ADAPTER_T prAdapter
1922 UINT_32 i
, u4Value
= 0;
1923 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1927 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1928 if(prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
1929 nicDisableClockGating(prAdapter
);
1933 /* MGMT - unitialization */
1934 nicUninitMGMT(prAdapter
);
1936 if(prAdapter
->rAcpiState
== ACPI_STATE_D0
&&
1937 #if (CFG_CHIP_RESET_SUPPORT == 1)
1938 kalIsResetting() == FALSE
&&
1940 kalIsCardRemoved(prAdapter
->prGlueInfo
) == FALSE
) {
1942 /* 0. Disable interrupt, this can be done without Driver own */
1943 nicDisableInterrupt(prAdapter
);
1945 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
1947 /* 1. Set CMD to FW to tell WIFI to stop (enter power off state) */
1948 /* the command must be issue to firmware even in wlanRemove() */
1949 if(prAdapter
->fgIsFwOwn
== FALSE
&&
1950 wlanSendNicPowerCtrlCmd(prAdapter
, 1) == WLAN_STATUS_SUCCESS
) {
1951 /* 2. Clear pending interrupt */
1953 while(i
< CFG_IST_LOOP_COUNT
&& nicProcessIST(prAdapter
) != WLAN_STATUS_NOT_INDICATING
) {
1957 /* 3. Wait til RDY bit has been cleaerd */
1960 HAL_MCR_RD(prAdapter
, MCR_WCIR
, &u4Value
);
1962 if ((u4Value
& WCIR_WLAN_READY
) == 0)
1964 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
1965 || fgIsBusAccessFailed
== TRUE
1966 || i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
1976 /* 4. Set Onwership to F/W */
1977 nicpmSetFWOwn(prAdapter
, FALSE
);
1979 #if CFG_FORCE_RESET_UNDER_BUS_ERROR
1980 if(HAL_TEST_FLAG(prAdapter
, ADAPTER_FLAG_HW_ERR
) == TRUE
) {
1981 /* force acquire firmware own */
1982 kalDevRegWrite(prAdapter
->prGlueInfo
, MCR_WHLPCR
, WHLPCR_FW_OWN_REQ_CLR
);
1984 /* delay for 10ms */
1987 /* force firmware reset via software interrupt */
1988 kalDevRegWrite(prAdapter
->prGlueInfo
, MCR_WSICR
, WSICR_H2D_SW_INT_SET
);
1990 /* force release firmware own */
1991 kalDevRegWrite(prAdapter
->prGlueInfo
, MCR_WHLPCR
, WHLPCR_FW_OWN_REQ_SET
);
1995 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
1998 nicRxUninitialize(prAdapter
);
2000 nicTxRelease(prAdapter
);
2002 /* System Service Uninitialization */
2003 nicUninitSystemService(prAdapter
);
2005 nicReleaseAdapterMemory(prAdapter
);
2007 #if defined(_HIF_SPI)
2008 /* Note: restore the SPI Mode Select from 32 bit to default */
2009 nicRestoreSpiDefMode(prAdapter
);
2013 } /* wlanAdapterStop */
2017 /*----------------------------------------------------------------------------*/
2019 * \brief This function is called by ISR (interrupt).
2021 * \param prAdapter Pointer of Adapter Data Structure
2023 * \retval TRUE: NIC's interrupt
2024 * \retval FALSE: Not NIC's interrupt
2026 /*----------------------------------------------------------------------------*/
2029 IN P_ADAPTER_T prAdapter
,
2030 IN BOOLEAN fgGlobalIntrCtrl
2035 if (fgGlobalIntrCtrl
) {
2036 nicDisableInterrupt(prAdapter
);
2038 //wlanIST(prAdapter);
2045 /*----------------------------------------------------------------------------*/
2047 * \brief This function is called by IST (task_let).
2049 * \param prAdapter Pointer of Adapter Data Structure
2053 /*----------------------------------------------------------------------------*/
2056 IN P_ADAPTER_T prAdapter
2061 /* wake up CONNSYS */
2062 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
2064 /* handle interrupts */
2065 nicProcessIST(prAdapter
);
2067 /* re-enable HIF interrupts */
2068 nicEnableInterrupt(prAdapter
);
2070 /* CONNSYS can decide to sleep */
2071 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
2077 /*----------------------------------------------------------------------------*/
2079 * \brief This function will check command queue to find out if any could be dequeued
2080 * and/or send to HIF to MT6620
2082 * \param prAdapter Pointer of Adapter Data Structure
2083 * \param prCmdQue Pointer of Command Queue (in Glue Layer)
2085 * \retval WLAN_STATUS_SUCCESS
2087 /*----------------------------------------------------------------------------*/
2089 wlanProcessCommandQueue (
2090 IN P_ADAPTER_T prAdapter
,
2094 WLAN_STATUS rStatus
;
2095 QUE_T rTempCmdQue
, rMergeCmdQue
, rStandInCmdQue
;
2096 P_QUE_T prTempCmdQue
, prMergeCmdQue
, prStandInCmdQue
;
2097 P_QUE_ENTRY_T prQueueEntry
;
2098 P_CMD_INFO_T prCmdInfo
;
2099 P_MSDU_INFO_T prMsduInfo
;
2100 ENUM_FRAME_ACTION_T eFrameAction
= FRAME_ACTION_DROP_PKT
;
2102 KAL_SPIN_LOCK_DECLARATION();
2109 prTempCmdQue
= &rTempCmdQue
;
2110 prMergeCmdQue
= &rMergeCmdQue
;
2111 prStandInCmdQue
= &rStandInCmdQue
;
2113 QUEUE_INITIALIZE(prTempCmdQue
);
2114 QUEUE_INITIALIZE(prMergeCmdQue
);
2115 QUEUE_INITIALIZE(prStandInCmdQue
);
2117 //4 <1> Move whole list of CMD_INFO to the temp queue
2118 /* copy all commands to prTempCmdQue and empty prCmdQue */
2119 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_QUE
);
2120 QUEUE_MOVE_ALL(prTempCmdQue
, prCmdQue
);
2121 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_QUE
);
2123 //4 <2> Dequeue from head and check it is able to be sent
2124 /* remove the first one */
2125 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2127 while(prQueueEntry
) {
2128 prCmdInfo
= (P_CMD_INFO_T
)prQueueEntry
;
2130 /* check how to handle the command: drop, queue, or tx */
2131 switch(prCmdInfo
->eCmdType
) {
2132 case COMMAND_TYPE_GENERAL_IOCTL
:
2133 case COMMAND_TYPE_NETWORK_IOCTL
:
2134 /* command packet will be always sent */
2135 eFrameAction
= FRAME_ACTION_TX_PKT
;
2138 case COMMAND_TYPE_SECURITY_FRAME
:
2139 /* inquire with QM */
2140 eFrameAction
= qmGetFrameAction(prAdapter
,
2141 prCmdInfo
->eNetworkType
,
2142 prCmdInfo
->ucStaRecIndex
,
2147 case COMMAND_TYPE_MANAGEMENT_FRAME
:
2148 /* inquire with QM */
2149 prMsduInfo
= (P_MSDU_INFO_T
)(prCmdInfo
->prPacket
);
2151 eFrameAction
= qmGetFrameAction(prAdapter
,
2152 prMsduInfo
->ucNetworkType
,
2153 prMsduInfo
->ucStaRecIndex
,
2163 //4 <3> handling upon dequeue result
2164 if(eFrameAction
== FRAME_ACTION_DROP_PKT
) {
2165 wlanReleaseCommand(prAdapter
, prCmdInfo
);
2167 else if(eFrameAction
== FRAME_ACTION_QUEUE_PKT
) {
2168 QUEUE_INSERT_TAIL(prMergeCmdQue
, prQueueEntry
);
2170 else if(eFrameAction
== FRAME_ACTION_TX_PKT
) {
2171 //4 <4> Send the command
2172 rStatus
= wlanSendCommand(prAdapter
, prCmdInfo
);
2174 if(rStatus
== WLAN_STATUS_RESOURCES
) {
2175 // no more TC4 resource for further transmission
2176 QUEUE_INSERT_TAIL(prMergeCmdQue
, prQueueEntry
);
2179 else if(rStatus
== WLAN_STATUS_PENDING
) {
2180 // command packet which needs further handling upon response
2181 // i.e. we need to wait for FW's response
2182 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2183 QUEUE_INSERT_TAIL(&(prAdapter
->rPendingCmdQueue
), prQueueEntry
);
2184 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2187 /* send success or fail */
2188 P_CMD_INFO_T prCmdInfo
= (P_CMD_INFO_T
)prQueueEntry
;
2190 if (rStatus
== WLAN_STATUS_SUCCESS
) {
2192 if (prCmdInfo
->pfCmdDoneHandler
) {
2193 prCmdInfo
->pfCmdDoneHandler(prAdapter
, prCmdInfo
, prCmdInfo
->pucInfoBuffer
);
2198 if (prCmdInfo
->fgIsOid
) {
2199 kalOidComplete(prAdapter
->prGlueInfo
, prCmdInfo
->fgSetQuery
, prCmdInfo
->u4SetInfoLen
, rStatus
);
2203 /* free the command memory */
2204 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
2209 /* impossible, wrong eFrameAction */
2213 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2216 //4 <3> Merge back to original queue
2217 //4 <3.1> Merge prMergeCmdQue & prTempCmdQue
2218 QUEUE_CONCATENATE_QUEUES(prMergeCmdQue
, prTempCmdQue
);
2220 //4 <3.2> Move prCmdQue to prStandInQue, due to prCmdQue might differ due to incoming 802.1X frames
2221 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_QUE
);
2223 /* ??? here, prCmdQue shall be empty, why QUEUE_MOVE_ALL ??? */
2224 QUEUE_MOVE_ALL(prStandInCmdQue
, prCmdQue
);
2226 //4 <3.3> concatenate prStandInQue to prMergeCmdQue
2227 QUEUE_CONCATENATE_QUEUES(prMergeCmdQue
, prStandInCmdQue
);
2229 //4 <3.4> then move prMergeCmdQue to prCmdQue
2230 QUEUE_MOVE_ALL(prCmdQue
, prMergeCmdQue
);
2231 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_QUE
);
2233 return WLAN_STATUS_SUCCESS
;
2234 } /* end of wlanProcessCommandQueue() */
2237 /*----------------------------------------------------------------------------*/
2239 * \brief This function will take CMD_INFO_T which carry some informations of
2240 * incoming OID and notify the NIC_TX to send CMD.
2242 * \param prAdapter Pointer of Adapter Data Structure
2243 * \param prCmdInfo Pointer of P_CMD_INFO_T
2245 * \retval WLAN_STATUS_SUCCESS : CMD was written to HIF and be freed(CMD Done) immediately.
2246 * \retval WLAN_STATUS_RESOURCE : No resource for current command, need to wait for previous
2247 * frame finishing their transmission.
2248 * \retval WLAN_STATUS_FAILURE : Get failure while access HIF or been rejected.
2250 /*----------------------------------------------------------------------------*/
2253 IN P_ADAPTER_T prAdapter
,
2254 IN P_CMD_INFO_T prCmdInfo
2257 P_TX_CTRL_T prTxCtrl
;
2258 UINT_8 ucTC
; /* "Traffic Class" SW(Driver) resource classification */
2259 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
2266 prTxCtrl
= &prAdapter
->rTxCtrl
;
2268 //DbgPrint("wlanSendCommand()\n");
2272 LOG_FUNC("wlanSendCommand()\n");
2273 LOG_FUNC("CmdType %u NetworkType %u StaRecIndex %u Oid %u CID 0x%x SetQuery %u NeedResp %u CmdSeqNum %u\n",
2274 prCmdInfo
->eCmdType
,
2275 prCmdInfo
->eNetworkType
,
2276 prCmdInfo
->ucStaRecIndex
,
2279 prCmdInfo
->fgSetQuery
,
2280 prCmdInfo
->fgNeedResp
,
2281 prCmdInfo
->ucCmdSeqNum
);
2285 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2286 if(prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
2287 nicDisableClockGating(prAdapter
);
2292 // <0> card removal check
2293 if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2294 || fgIsBusAccessFailed
== TRUE
) {
2295 rStatus
= WLAN_STATUS_FAILURE
;
2299 // <1> Normal case of sending CMD Packet
2300 if (!prCmdInfo
->fgDriverDomainMCR
) {
2301 // <1.1> Assign Traffic Class(TC) = TC4.
2304 // <1.2> Check if pending packet or resource was exhausted
2305 if ((rStatus
= nicTxAcquireResource(prAdapter
, ucTC
)) == WLAN_STATUS_RESOURCES
) {
2306 DbgPrint("NO Resource:%d\n", ucTC
);
2310 // <1.3> Forward CMD_INFO_T to NIC Layer
2311 rStatus
= nicTxCmd(prAdapter
, prCmdInfo
, ucTC
);
2313 // <1.4> Set Pending in response to Query Command/Need Response
2314 if (rStatus
== WLAN_STATUS_SUCCESS
) {
2315 if ((!prCmdInfo
->fgSetQuery
) || (prCmdInfo
->fgNeedResp
)) {
2316 rStatus
= WLAN_STATUS_PENDING
;
2320 // <2> "Special case" for access Driver Domain MCR
2323 P_CMD_ACCESS_REG prCmdAccessReg
;
2324 prCmdAccessReg
= (P_CMD_ACCESS_REG
)(prCmdInfo
->pucInfoBuffer
+ CMD_HDR_SIZE
);
2326 if (prCmdInfo
->fgSetQuery
) {
2327 HAL_MCR_WR(prAdapter
,
2328 (prCmdAccessReg
->u4Address
& BITS(2,31)), //address is in DWORD unit
2329 prCmdAccessReg
->u4Data
);
2332 P_CMD_ACCESS_REG prEventAccessReg
;
2335 u4Address
= prCmdAccessReg
->u4Address
;
2336 prEventAccessReg
= (P_CMD_ACCESS_REG
)prCmdInfo
->pucInfoBuffer
;
2337 prEventAccessReg
->u4Address
= u4Address
;
2339 HAL_MCR_RD(prAdapter
,
2340 prEventAccessReg
->u4Address
& BITS(2,31), //address is in DWORD unit
2341 &prEventAccessReg
->u4Data
);
2348 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2349 if(prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
2350 nicEnableClockGating(prAdapter
);
2355 } /* end of wlanSendCommand() */
2358 /*----------------------------------------------------------------------------*/
2360 * \brief This function will release thd CMD_INFO upon its attribution
2362 * \param prAdapter Pointer of Adapter Data Structure
2363 * \param prCmdInfo Pointer of CMD_INFO_T
2367 /*----------------------------------------------------------------------------*/
2369 wlanReleaseCommand (
2370 IN P_ADAPTER_T prAdapter
,
2371 IN P_CMD_INFO_T prCmdInfo
2374 P_TX_CTRL_T prTxCtrl
;
2375 P_MSDU_INFO_T prMsduInfo
;
2380 prTxCtrl
= &prAdapter
->rTxCtrl
;
2382 switch(prCmdInfo
->eCmdType
) {
2383 case COMMAND_TYPE_GENERAL_IOCTL
:
2384 case COMMAND_TYPE_NETWORK_IOCTL
:
2385 if (prCmdInfo
->fgIsOid
) {
2386 /* for OID command, we need to do complete() to wake up kalIoctl() */
2387 kalOidComplete(prAdapter
->prGlueInfo
,
2388 prCmdInfo
->fgSetQuery
,
2389 prCmdInfo
->u4SetInfoLen
,
2390 WLAN_STATUS_FAILURE
);
2394 case COMMAND_TYPE_SECURITY_FRAME
:
2395 /* free packets in kalSecurityFrameSendComplete() */
2396 kalSecurityFrameSendComplete(prAdapter
->prGlueInfo
,
2397 prCmdInfo
->prPacket
,
2398 WLAN_STATUS_FAILURE
);
2401 case COMMAND_TYPE_MANAGEMENT_FRAME
:
2402 prMsduInfo
= (P_MSDU_INFO_T
)prCmdInfo
->prPacket
;
2404 /* invoke callbacks */
2405 if(prMsduInfo
->pfTxDoneHandler
!= NULL
) {
2406 prMsduInfo
->pfTxDoneHandler(prAdapter
, prMsduInfo
, TX_RESULT_DROPPED_IN_DRIVER
);
2409 GLUE_DEC_REF_CNT(prTxCtrl
->i4TxMgmtPendingNum
);
2410 cnmMgtPktFree(prAdapter
, prMsduInfo
);
2414 /* impossible, shall not be here */
2419 /* free command buffer and return the command header to command pool */
2420 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
2422 } /* end of wlanReleaseCommand() */
2425 /*----------------------------------------------------------------------------*/
2427 * \brief This function will search the CMD Queue to look for the pending OID and
2428 * compelete it immediately when system request a reset.
2430 * \param prAdapter ointer of Adapter Data Structure
2434 /*----------------------------------------------------------------------------*/
2436 wlanReleasePendingOid (
2437 IN P_ADAPTER_T prAdapter
,
2443 P_QUE_T prTempCmdQue
= &rTempCmdQue
;
2444 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
)NULL
;
2445 P_CMD_INFO_T prCmdInfo
= (P_CMD_INFO_T
)NULL
;
2447 KAL_SPIN_LOCK_DECLARATION();
2449 DEBUGFUNC("wlanReleasePendingOid");
2453 DBGLOG(INIT
, ERROR
, ("OID Timeout! Releasing pending OIDs ..\n"));
2456 // 1: Handle OID commands in pending queue
2457 /* Clear Pending OID in prAdapter->rPendingCmdQueue */
2458 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2460 /* move all pending commands to prTempCmdQue and empty prCmdQue */
2461 prCmdQue
= &prAdapter
->rPendingCmdQueue
;
2462 QUEUE_MOVE_ALL(prTempCmdQue
, prCmdQue
);
2464 /* get first pending command */
2465 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2467 while (prQueueEntry
) {
2468 prCmdInfo
= (P_CMD_INFO_T
)prQueueEntry
;
2470 if (prCmdInfo
->fgIsOid
) {
2471 if (prCmdInfo
->pfCmdTimeoutHandler
) {
2472 prCmdInfo
->pfCmdTimeoutHandler(prAdapter
, prCmdInfo
);
2476 /* send complete() to wake up kalIoctl() */
2477 kalOidComplete(prAdapter
->prGlueInfo
,
2478 prCmdInfo
->fgSetQuery
,
2480 WLAN_STATUS_FAILURE
);
2483 /* free command memory */
2484 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
2487 /* nothing to do so re-queue it to prCmdQue */
2488 QUEUE_INSERT_TAIL(prCmdQue
, prQueueEntry
);
2491 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2494 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2497 // 2: Clear pending OID staying in command queue
2498 kalOidCmdClearance(prAdapter
->prGlueInfo
);
2500 // 3: Do complete(), do we need this? because we have completed in kalOidComplete
2501 kalOidClearance(prAdapter
->prGlueInfo
);
2509 /*----------------------------------------------------------------------------*/
2511 * \brief This function will search the CMD Queue to look for the pending CMD/OID for specific
2512 * NETWORK TYPE and compelete it immediately when system request a reset.
2514 * \param prAdapter ointer of Adapter Data Structure
2518 /*----------------------------------------------------------------------------*/
2520 wlanReleasePendingCMDbyNetwork (
2521 IN P_ADAPTER_T prAdapter
,
2522 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
2527 P_QUE_T prTempCmdQue
= &rTempCmdQue
;
2528 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
)NULL
;
2529 P_CMD_INFO_T prCmdInfo
= (P_CMD_INFO_T
)NULL
;
2531 KAL_SPIN_LOCK_DECLARATION();
2535 /* only free commands from the network interface, AIS, P2P, or BOW */
2538 // 1: Clear Pending OID in prAdapter->rPendingCmdQueue
2539 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2541 prCmdQue
= &prAdapter
->rPendingCmdQueue
;
2542 QUEUE_MOVE_ALL(prTempCmdQue
, prCmdQue
);
2544 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2545 while (prQueueEntry
) {
2546 prCmdInfo
= (P_CMD_INFO_T
)prQueueEntry
;
2548 DBGLOG(P2P
, TRACE
, ("Pending CMD for Network Type:%d \n", prCmdInfo
->eNetworkType
));
2550 if (prCmdInfo
->eNetworkType
== eNetworkType
) {
2551 if (prCmdInfo
->pfCmdTimeoutHandler
) {
2552 prCmdInfo
->pfCmdTimeoutHandler(prAdapter
, prCmdInfo
);
2555 kalOidComplete(prAdapter
->prGlueInfo
,
2556 prCmdInfo
->fgSetQuery
,
2558 WLAN_STATUS_FAILURE
);
2560 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
2563 QUEUE_INSERT_TAIL(prCmdQue
, prQueueEntry
);
2566 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
2569 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
2575 } /* wlanReleasePendingCMDbyNetwork */
2579 /*----------------------------------------------------------------------------*/
2581 * \brief Return the packet buffer and reallocate one to the RFB
2583 * \param prAdapter Pointer of Adapter Data Structure
2584 * \param pvPacket Pointer of returned packet
2586 * \retval WLAN_STATUS_SUCCESS: Success
2587 * \retval WLAN_STATUS_FAILURE: Failed
2589 /*----------------------------------------------------------------------------*/
2592 IN P_ADAPTER_T prAdapter
,
2596 P_RX_CTRL_T prRxCtrl
;
2597 P_SW_RFB_T prSwRfb
= NULL
;
2598 KAL_SPIN_LOCK_DECLARATION();
2600 DEBUGFUNC("wlanReturnPacket");
2604 prRxCtrl
= &prAdapter
->rRxCtrl
;
2607 /* free the packet */
2609 kalPacketFree(prAdapter
->prGlueInfo
, pvPacket
);
2610 RX_ADD_CNT(prRxCtrl
, RX_DATA_RETURNED_COUNT
, 1);
2611 #if CFG_NATIVE_802_11
2612 if (GLUE_TEST_FLAG(prAdapter
->prGlueInfo
, GLUE_FLAG_HALT
)) {
2617 /* free the packet control block */
2618 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_RX_QUE
);
2619 QUEUE_REMOVE_HEAD(&prRxCtrl
->rIndicatedRfbList
, prSwRfb
, P_SW_RFB_T
);
2620 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_RX_QUE
);
2626 if (nicRxSetupRFB(prAdapter
, prSwRfb
)){
2628 //return; // Don't return here or it would lost SwRfb --kc
2629 if (!timerPendingTimer(&prAdapter
->rReturnIndicatedRfbListTimer
)) {
2630 DBGLOG(INIT
, WARN
, ("wlanReturnPacket, Start ReturnIndicatedRfbList Timer (%ds)\n", RX_RETURN_INDICATED_RFB_TIMEOUT_SEC
));
2631 cnmTimerStartTimer(prAdapter
,
2632 &prAdapter
->rReturnIndicatedRfbListTimer
,
2633 SEC_TO_MSEC(RX_RETURN_INDICATED_RFB_TIMEOUT_SEC
));
2636 nicRxReturnRFB(prAdapter
, prSwRfb
);
2639 /*----------------------------------------------------------------------------*/
2641 * \brief Return the indicated packet buffer and reallocate one to the RFB
2643 * \param prAdapter Pointer of Adapter Data Structure
2644 * \param pvPacket Pointer of returned packet
2646 * \retval WLAN_STATUS_SUCCESS: Success
2647 * \retval WLAN_STATUS_FAILURE: Failed
2649 /*----------------------------------------------------------------------------*/
2651 wlanReturnIndicatedPacketsTimeOut (
2652 IN P_ADAPTER_T prAdapter
,
2656 P_RX_CTRL_T prRxCtrl
;
2657 P_SW_RFB_T prSwRfb
= NULL
;
2658 KAL_SPIN_LOCK_DECLARATION();
2659 WLAN_STATUS status
= WLAN_STATUS_SUCCESS
;
2662 DEBUGFUNC("wlanReturnIndicatedPacketsTimeOut");
2663 DBGLOG(INIT
, WARN
, ("wlanReturnIndicatedPacketsTimeOut"));
2667 prRxCtrl
= &prAdapter
->rRxCtrl
;
2670 prQueList
= &prRxCtrl
->rIndicatedRfbList
;
2671 DBGLOG(INIT
, WARN
, ("IndicatedRfbList num = %u\n", (unsigned int)prQueList
->u4NumElem
));
2673 while (QUEUE_IS_NOT_EMPTY(&prRxCtrl
->rIndicatedRfbList
)) {
2674 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_RX_QUE
);
2675 QUEUE_REMOVE_HEAD(&prRxCtrl
->rIndicatedRfbList
, prSwRfb
, P_SW_RFB_T
);
2676 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_RX_QUE
);
2678 if (nicRxSetupRFB(prAdapter
, prSwRfb
)){
2679 status
= WLAN_STATUS_RESOURCES
;
2682 nicRxReturnRFB(prAdapter
, prSwRfb
);
2683 if (status
== WLAN_STATUS_RESOURCES
)
2686 if (status
== WLAN_STATUS_RESOURCES
) {
2687 DBGLOG(INIT
, WARN
, ("Start ReturnIndicatedRfbList Timer (%ds)\n", RX_RETURN_INDICATED_RFB_TIMEOUT_SEC
));
2689 cnmTimerStartTimer(prAdapter
,
2690 &prAdapter
->rReturnIndicatedRfbListTimer
,
2691 SEC_TO_MSEC(RX_RETURN_INDICATED_RFB_TIMEOUT_SEC
));
2695 /*----------------------------------------------------------------------------*/
2697 * \brief This function is a required function that returns information about
2698 * the capabilities and status of the driver and/or its network adapter.
2700 * \param[IN] prAdapter Pointer to the Adapter structure.
2701 * \param[IN] pfnOidQryHandler Function pointer for the OID query handler.
2702 * \param[IN] pvInfoBuf Points to a buffer for return the query information.
2703 * \param[IN] u4QueryBufferLen Specifies the number of bytes at pvInfoBuf.
2704 * \param[OUT] pu4QueryInfoLen Points to the number of bytes it written or is needed.
2706 * \retval WLAN_STATUS_xxx Different WLAN_STATUS code returned by different handlers.
2709 /*----------------------------------------------------------------------------*/
2711 wlanQueryInformation (
2712 IN P_ADAPTER_T prAdapter
,
2713 IN PFN_OID_HANDLER_FUNC pfnOidQryHandler
,
2715 IN UINT_32 u4InfoBufLen
,
2716 OUT PUINT_32 pu4QryInfoLen
2719 WLAN_STATUS status
= WLAN_STATUS_FAILURE
;
2722 ASSERT(pu4QryInfoLen
);
2724 // ignore any OID request after connected, under PS current measurement mode
2725 if (prAdapter
->u4PsCurrentMeasureEn
&&
2726 (prAdapter
->prGlueInfo
->eParamMediaStateIndicated
== PARAM_MEDIA_STATE_CONNECTED
)) {
2727 return WLAN_STATUS_SUCCESS
; // note: return WLAN_STATUS_FAILURE or WLAN_STATUS_SUCCESS for blocking OIDs during current measurement ??
2731 /* most OID handler will just queue a command packet */
2732 status
= pfnOidQryHandler(prAdapter
,
2737 if (wlanIsHandlerNeedHwAccess(pfnOidQryHandler
, FALSE
)) {
2738 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
2740 /* Reset sleepy state */
2741 if(prAdapter
->fgWiFiInSleepyState
== TRUE
) {
2742 prAdapter
->fgWiFiInSleepyState
= FALSE
;
2745 status
= pfnOidQryHandler(prAdapter
,
2750 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
2753 status
= pfnOidQryHandler(prAdapter
,
2764 /*----------------------------------------------------------------------------*/
2766 * \brief This function is a required function that allows bound protocol drivers,
2767 * or NDIS, to request changes in the state information that the miniport
2768 * maintains for particular object identifiers, such as changes in multicast
2771 * \param[IN] prAdapter Pointer to the Glue info structure.
2772 * \param[IN] pfnOidSetHandler Points to the OID set handlers.
2773 * \param[IN] pvInfoBuf Points to a buffer containing the OID-specific data for the set.
2774 * \param[IN] u4InfoBufLen Specifies the number of bytes at prSetBuffer.
2775 * \param[OUT] pu4SetInfoLen Points to the number of bytes it read or is needed.
2777 * \retval WLAN_STATUS_xxx Different WLAN_STATUS code returned by different handlers.
2780 /*----------------------------------------------------------------------------*/
2782 wlanSetInformation (
2783 IN P_ADAPTER_T prAdapter
,
2784 IN PFN_OID_HANDLER_FUNC pfnOidSetHandler
,
2786 IN UINT_32 u4InfoBufLen
,
2787 OUT PUINT_32 pu4SetInfoLen
2790 WLAN_STATUS status
= WLAN_STATUS_FAILURE
;
2793 ASSERT(pu4SetInfoLen
);
2795 // ignore any OID request after connected, under PS current measurement mode
2796 if (prAdapter
->u4PsCurrentMeasureEn
&&
2797 (prAdapter
->prGlueInfo
->eParamMediaStateIndicated
== PARAM_MEDIA_STATE_CONNECTED
)) {
2798 return WLAN_STATUS_SUCCESS
; // note: return WLAN_STATUS_FAILURE or WLAN_STATUS_SUCCESS for blocking OIDs during current measurement ??
2802 /* most OID handler will just queue a command packet
2803 * for power state transition OIDs, handler will acquire power control by itself
2805 status
= pfnOidSetHandler(prAdapter
,
2810 if (wlanIsHandlerNeedHwAccess(pfnOidSetHandler
, TRUE
)) {
2811 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
2813 /* Reset sleepy state */
2814 if(prAdapter
->fgWiFiInSleepyState
== TRUE
) {
2815 prAdapter
->fgWiFiInSleepyState
= FALSE
;
2818 status
= pfnOidSetHandler(prAdapter
,
2823 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
2826 status
= pfnOidSetHandler(prAdapter
,
2837 #if CFG_SUPPORT_WAPI
2838 /*----------------------------------------------------------------------------*/
2840 * \brief This function is a used to query driver's config wapi mode or not
2842 * \param[IN] prAdapter Pointer to the Glue info structure.
2844 * \retval TRUE for use wapi mode
2847 /*----------------------------------------------------------------------------*/
2850 IN P_ADAPTER_T prAdapter
2855 return prAdapter
->rWifiVar
.rConnSettings
.fgWapiMode
;
2860 /*----------------------------------------------------------------------------*/
2862 * \brief This function is called to set RX filter to Promiscuous Mode.
2864 * \param[IN] prAdapter Pointer to the Adapter structure.
2865 * \param[IN] fgEnablePromiscuousMode Enable/ disable RX Promiscuous Mode.
2869 /*----------------------------------------------------------------------------*/
2871 wlanSetPromiscuousMode (
2872 IN P_ADAPTER_T prAdapter
,
2873 IN BOOLEAN fgEnablePromiscuousMode
2880 /*----------------------------------------------------------------------------*/
2882 * \brief This function is called to set RX filter to allow to receive
2883 * broadcast address packets.
2885 * \param[IN] prAdapter Pointer to the Adapter structure.
2886 * \param[IN] fgEnableBroadcast Enable/ disable broadcast packet to be received.
2890 /*----------------------------------------------------------------------------*/
2892 wlanRxSetBroadcast (
2893 IN P_ADAPTER_T prAdapter
,
2894 IN BOOLEAN fgEnableBroadcast
2900 /*----------------------------------------------------------------------------*/
2902 * \brief This function is called to send out CMD_NIC_POWER_CTRL command packet
2904 * \param[IN] prAdapter Pointer to the Adapter structure.
2905 * \param[IN] ucPowerMode refer to CMD/EVENT document
2907 * \return WLAN_STATUS_SUCCESS
2908 * \return WLAN_STATUS_FAILURE
2910 /*----------------------------------------------------------------------------*/
2912 wlanSendNicPowerCtrlCmd (
2913 IN P_ADAPTER_T prAdapter
,
2914 IN UINT_8 ucPowerMode
2917 WLAN_STATUS status
= WLAN_STATUS_SUCCESS
;
2918 P_GLUE_INFO_T prGlueInfo
;
2919 P_CMD_INFO_T prCmdInfo
;
2920 P_WIFI_CMD_T prWifiCmd
;
2921 UINT_8 ucTC
, ucCmdSeqNum
;
2925 prGlueInfo
= prAdapter
->prGlueInfo
;
2927 /* 1. Prepare CMD */
2928 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, (CMD_HDR_SIZE
+ sizeof(CMD_NIC_POWER_CTRL
)));
2930 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2931 return WLAN_STATUS_FAILURE
;
2934 /* 2.1 increase command sequence number */
2935 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
2936 DBGLOG(REQ
, TRACE
, ("ucCmdSeqNum =%d\n", ucCmdSeqNum
));
2938 /* 2.2 Setup common CMD Info Packet */
2939 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
2940 prCmdInfo
->u2InfoBufLen
= (UINT_16
)(CMD_HDR_SIZE
+ sizeof(CMD_NIC_POWER_CTRL
));
2941 prCmdInfo
->pfCmdDoneHandler
= NULL
;
2942 prCmdInfo
->pfCmdTimeoutHandler
= NULL
;
2943 prCmdInfo
->fgIsOid
= TRUE
;
2944 prCmdInfo
->ucCID
= CMD_ID_NIC_POWER_CTRL
;
2945 prCmdInfo
->fgSetQuery
= TRUE
;
2946 prCmdInfo
->fgNeedResp
= FALSE
;
2947 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
2948 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
2949 prCmdInfo
->u4SetInfoLen
= sizeof(CMD_NIC_POWER_CTRL
);
2951 /* 2.3 Setup WIFI_CMD_T */
2952 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
2953 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
2954 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
2955 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
2956 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
2958 kalMemZero(prWifiCmd
->aucBuffer
, sizeof(CMD_NIC_POWER_CTRL
));
2959 ((P_CMD_NIC_POWER_CTRL
)(prWifiCmd
->aucBuffer
))->ucPowerMode
= ucPowerMode
;
2961 /* 3. Issue CMD for entering specific power mode */
2965 // 3.0 Removal check
2966 if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2967 || fgIsBusAccessFailed
== TRUE
) {
2968 status
= WLAN_STATUS_FAILURE
;
2972 // 3.1 Acquire TX Resource
2973 if (nicTxAcquireResource(prAdapter
, ucTC
) == WLAN_STATUS_RESOURCES
) {
2975 /* wait and poll tx resource */
2976 if (nicTxPollingResource(prAdapter
, ucTC
) != WLAN_STATUS_SUCCESS
) {
2977 DBGLOG(INIT
, ERROR
,("Fail to get TX resource return within timeout\n"));
2978 status
= WLAN_STATUS_FAILURE
;
2986 // 3.2 Send CMD Info Packet
2987 if (nicTxCmd(prAdapter
, prCmdInfo
, ucTC
) != WLAN_STATUS_SUCCESS
) {
2988 DBGLOG(INIT
, ERROR
,("Fail to transmit CMD_NIC_POWER_CTRL command\n"));
2989 status
= WLAN_STATUS_FAILURE
;
2995 // 4. Free CMD Info Packet.
2996 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
2999 if(ucPowerMode
== 1) {
3000 prAdapter
->fgIsEnterD3ReqIssued
= TRUE
;
3007 /*----------------------------------------------------------------------------*/
3009 * \brief This function is called to check if it is RF test mode and
3010 * the OID is allowed to be called or not
3012 * \param[IN] prAdapter Pointer to the Adapter structure.
3013 * \param[IN] fgEnableBroadcast Enable/ disable broadcast packet to be received.
3017 /*----------------------------------------------------------------------------*/
3019 wlanIsHandlerAllowedInRFTest (
3020 IN PFN_OID_HANDLER_FUNC pfnOidHandler
,
3021 IN BOOLEAN fgSetInfo
3024 PFN_OID_HANDLER_FUNC
* apfnOidHandlerAllowedInRFTest
;
3026 UINT_32 u4NumOfElem
;
3029 apfnOidHandlerAllowedInRFTest
= apfnOidSetHandlerAllowedInRFTest
;
3030 u4NumOfElem
= sizeof(apfnOidSetHandlerAllowedInRFTest
) / sizeof(PFN_OID_HANDLER_FUNC
);
3033 apfnOidHandlerAllowedInRFTest
= apfnOidQueryHandlerAllowedInRFTest
;
3034 u4NumOfElem
= sizeof(apfnOidQueryHandlerAllowedInRFTest
) / sizeof(PFN_OID_HANDLER_FUNC
);
3037 for (i
= 0; i
< u4NumOfElem
; i
++) {
3038 if (apfnOidHandlerAllowedInRFTest
[i
] == pfnOidHandler
) {
3046 #if CFG_ENABLE_FW_DOWNLOAD
3047 #if CFG_ENABLE_FW_DOWNLOAD_AGGREGATION
3048 /*----------------------------------------------------------------------------*/
3050 * @brief This function is called to download FW image in an aggregated way
3052 * @param prAdapter Pointer to the Adapter structure.
3056 /*----------------------------------------------------------------------------*/
3058 wlanImageSectionDownloadAggregated (
3059 IN P_ADAPTER_T prAdapter
,
3060 IN UINT_32 u4DestAddr
,
3061 IN UINT_32 u4ImgSecSize
,
3062 IN PUINT_8 pucImgSecBuf
3065 #if defined(MT6620) || defined(MT6628)
3066 P_CMD_INFO_T prCmdInfo
;
3067 P_INIT_HIF_TX_HEADER_T prInitHifTxHeader
;
3068 P_INIT_CMD_DOWNLOAD_BUF prInitCmdDownloadBuf
;
3069 UINT_8 ucTC
, ucCmdSeqNum
;
3070 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
3071 PUINT_8 pucOutputBuf
= (PUINT_8
)NULL
; /* Pointer to Transmit Data Structure Frame */
3072 UINT_32 u4PktCnt
, u4Offset
, u4Length
;
3073 UINT_32 u4TotalLength
;
3076 ASSERT(pucImgSecBuf
);
3078 pucOutputBuf
= prAdapter
->rTxCtrl
.pucTxCoalescingBufPtr
;
3080 DEBUGFUNC("wlanImageSectionDownloadAggregated");
3082 if (u4ImgSecSize
== 0) {
3083 return WLAN_STATUS_SUCCESS
;
3086 // 1. Allocate CMD Info Packet and Pre-fill Headers
3087 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
,
3088 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + CMD_PKT_SIZE_FOR_IMAGE
);
3091 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
3092 return WLAN_STATUS_FAILURE
;
3095 prCmdInfo
->u2InfoBufLen
=
3096 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + CMD_PKT_SIZE_FOR_IMAGE
;
3098 // 2. Use TC0's resource to download image. (only TC0 is allowed)
3101 // 3. Setup common CMD Info Packet
3102 prInitHifTxHeader
= (P_INIT_HIF_TX_HEADER_T
)(prCmdInfo
->pucInfoBuffer
);
3103 prInitHifTxHeader
->ucEtherTypeOffset
= 0;
3104 prInitHifTxHeader
->ucCSflags
= 0;
3105 prInitHifTxHeader
->rInitWifiCmd
.ucCID
= INIT_CMD_ID_DOWNLOAD_BUF
;
3107 // 4. Setup CMD_DOWNLOAD_BUF
3108 prInitCmdDownloadBuf
= (P_INIT_CMD_DOWNLOAD_BUF
)(prInitHifTxHeader
->rInitWifiCmd
.aucBuffer
);
3109 prInitCmdDownloadBuf
->u4DataMode
= 0
3110 #if CFG_ENABLE_FW_ENCRYPTION
3111 | DOWNLOAD_BUF_ENCRYPTION_MODE
3115 // 5.0 reset loop control variable
3117 u4Offset
= u4PktCnt
= 0;
3119 // 5.1 main loop for maximize transmission count per access
3120 while(u4Offset
< u4ImgSecSize
) {
3121 if(nicTxAcquireResource(prAdapter
, ucTC
) == WLAN_STATUS_SUCCESS
) {
3122 // 5.1.1 calculate u4Length
3123 if(u4Offset
+ CMD_PKT_SIZE_FOR_IMAGE
< u4ImgSecSize
) {
3124 u4Length
= CMD_PKT_SIZE_FOR_IMAGE
;
3127 u4Length
= u4ImgSecSize
- u4Offset
;
3130 // 5.1.1 increase command sequence number
3131 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
3132 prInitHifTxHeader
->rInitWifiCmd
.ucSeqNum
= ucCmdSeqNum
;
3134 // 5.1.2 update HIF TX hardware header
3135 prInitHifTxHeader
->u2TxByteCount
= ALIGN_4(sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + (UINT_16
)u4Length
);
3137 // 5.1.3 fill command header
3138 prInitCmdDownloadBuf
->u4Address
= u4DestAddr
+ u4Offset
;
3139 prInitCmdDownloadBuf
->u4Length
= u4Length
;
3140 prInitCmdDownloadBuf
->u4CRC32
= wlanCRC32(pucImgSecBuf
+ u4Offset
, u4Length
);
3142 // 5.1.4.1 copy header to coalescing buffer
3143 kalMemCopy(pucOutputBuf
+ u4TotalLength
,
3144 (PVOID
)prCmdInfo
->pucInfoBuffer
,
3145 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
));
3147 // 5.1.4.2 copy payload to coalescing buffer
3148 kalMemCopy(pucOutputBuf
+ u4TotalLength
+ sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
),
3149 pucImgSecBuf
+ u4Offset
,
3152 // 5.1.4.3 update length and other variables
3153 u4TotalLength
+= ALIGN_4(sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + u4Length
);
3154 u4Offset
+= u4Length
;
3157 if(u4Offset
< u4ImgSecSize
) {
3161 else if(u4PktCnt
== 0) {
3162 /* no resource, so get some back */
3163 if (nicTxPollingResource(prAdapter
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3164 u4Status
= WLAN_STATUS_FAILURE
;
3165 DBGLOG(INIT
, ERROR
,("Fail to get TX resource return within timeout\n"));
3171 // start transmission
3172 HAL_WRITE_TX_PORT(prAdapter
,
3175 (PUINT_8
)pucOutputBuf
,
3176 prAdapter
->u4CoalescingBufCachedSize
);
3184 // 8. Free CMD Info Packet.
3185 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
3190 #error "Only MT6620/MT6628/MT6582 supports firmware download in an aggregated way"
3192 return WLAN_STATUS_FAILURE
;
3198 /*----------------------------------------------------------------------------*/
3200 * @brief This function is called to download FW image.
3202 * @param prAdapter Pointer to the Adapter structure.
3206 /*----------------------------------------------------------------------------*/
3208 wlanImageSectionDownload (
3209 IN P_ADAPTER_T prAdapter
,
3210 IN UINT_32 u4DestAddr
,
3211 IN UINT_32 u4ImgSecSize
,
3212 IN PUINT_8 pucImgSecBuf
3215 #if defined(MT6620) || defined(MT6628)
3217 P_CMD_INFO_T prCmdInfo
;
3218 P_INIT_HIF_TX_HEADER_T prInitHifTxHeader
;
3219 P_INIT_CMD_DOWNLOAD_BUF prInitCmdDownloadBuf
;
3220 UINT_8 ucTC
, ucCmdSeqNum
;
3221 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
3224 ASSERT(pucImgSecBuf
);
3225 ASSERT(u4ImgSecSize
<= CMD_PKT_SIZE_FOR_IMAGE
);
3227 DEBUGFUNC("wlanImageSectionDownload");
3229 if (u4ImgSecSize
== 0) {
3230 return WLAN_STATUS_SUCCESS
;
3233 // 1. Allocate CMD Info Packet and its Buffer.
3234 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
,
3235 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + u4ImgSecSize
);
3238 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
3239 return WLAN_STATUS_FAILURE
;
3242 prCmdInfo
->u2InfoBufLen
=
3243 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_DOWNLOAD_BUF
) + (UINT_16
)u4ImgSecSize
;
3245 // 2. Use TC0's resource to download image. (only TC0 is allowed)
3248 // 3. increase command sequence number
3249 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
3251 // 4. Setup common CMD Info Packet
3252 prInitHifTxHeader
= (P_INIT_HIF_TX_HEADER_T
)(prCmdInfo
->pucInfoBuffer
);
3253 prInitHifTxHeader
->rInitWifiCmd
.ucCID
= INIT_CMD_ID_DOWNLOAD_BUF
;
3254 prInitHifTxHeader
->rInitWifiCmd
.ucSeqNum
= ucCmdSeqNum
;
3256 // 5. Setup CMD_DOWNLOAD_BUF
3257 prInitCmdDownloadBuf
= (P_INIT_CMD_DOWNLOAD_BUF
)(prInitHifTxHeader
->rInitWifiCmd
.aucBuffer
);
3258 prInitCmdDownloadBuf
->u4Address
= u4DestAddr
;
3259 prInitCmdDownloadBuf
->u4Length
= u4ImgSecSize
;
3260 prInitCmdDownloadBuf
->u4CRC32
= wlanCRC32(pucImgSecBuf
, u4ImgSecSize
);
3262 prInitCmdDownloadBuf
->u4DataMode
= 0
3263 #if CFG_ENABLE_FW_DOWNLOAD_ACK
3264 | DOWNLOAD_BUF_ACK_OPTION
// ACK needed
3266 #if CFG_ENABLE_FW_ENCRYPTION
3267 | DOWNLOAD_BUF_ENCRYPTION_MODE
3271 kalMemCopy(prInitCmdDownloadBuf
->aucBuffer
, pucImgSecBuf
, u4ImgSecSize
);
3273 // 6. Send FW_Download command
3275 // 6.1 Acquire TX Resource
3276 if (nicTxAcquireResource(prAdapter
, ucTC
) == WLAN_STATUS_RESOURCES
) {
3277 if (nicTxPollingResource(prAdapter
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3278 u4Status
= WLAN_STATUS_FAILURE
;
3279 DBGLOG(INIT
, ERROR
,("Fail to get TX resource return within timeout\n"));
3287 // 6.2 Send CMD Info Packet
3288 if (nicTxInitCmd(prAdapter
, prCmdInfo
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3289 u4Status
= WLAN_STATUS_FAILURE
;
3290 DBGLOG(INIT
, ERROR
,("Fail to transmit image download command\n"));
3296 #if CFG_ENABLE_FW_DOWNLOAD_ACK
3297 // 7. Wait for INIT_EVENT_ID_CMD_RESULT
3298 u4Status
= wlanImageSectionDownloadStatus(prAdapter
, ucCmdSeqNum
);
3301 // 8. Free CMD Info Packet.
3302 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
3306 #elif defined(MT5931)
3309 P_HIF_HW_TX_HEADER_T prHifTxHeader
;
3311 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
3314 ASSERT(pucImgSecBuf
);
3315 ASSERT(u4ImgSecSize
<= CMD_PKT_SIZE_FOR_IMAGE
);
3317 DEBUGFUNC("wlanImageSectionDownload");
3318 DBGLOG(INIT
, TRACE
, ("Destination: 0x%08X / Length: 0x%08X\n", u4DestAddr
, u4ImgSecSize
));
3320 if (u4ImgSecSize
== 0) {
3321 return WLAN_STATUS_SUCCESS
;
3324 // 1. Use TX coalescing buffer
3325 prHifTxHeader
= (P_HIF_HW_TX_HEADER_T
) prAdapter
->pucCoalescingBufCached
;
3327 // 2. Setup HIF_TX_HEADER
3328 prHifTxHeader
->u2TxByteCount
= (UINT_16
)(ALIGN_4(sizeof(HIF_HW_TX_HEADER_T
) + u4ImgSecSize
));
3329 prHifTxHeader
->ucEtherTypeOffset
= 0;
3330 prHifTxHeader
->ucCSflags
= 0;
3333 kalMemCopy(prHifTxHeader
->aucBuffer
, pucImgSecBuf
, u4ImgSecSize
);
3335 // 3.1 add 4-bytes zero tail
3336 kalMemZero(&(prHifTxHeader
->aucBuffer
[ALIGN_4(u4ImgSecSize
)]), sizeof(HIF_HW_TX_HEADER_T
));
3338 // 4. Poll til FWDL_RDY = 1
3341 HAL_MCR_RD(prAdapter
, MCR_FWDLSR
, &u4Value
);
3343 if (u4Value
& FWDLSR_FWDL_RDY
) {
3344 DBGLOG(INIT
, TRACE
, ("FWDL_RDY detected\n"));
3347 else if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
3348 || fgIsBusAccessFailed
== TRUE
) {
3349 u4Status
= WLAN_STATUS_FAILURE
;
3352 else if(i
>= CFG_RESPONSE_POLLING_TIMEOUT
) {
3353 DBGLOG(INIT
, ERROR
, ("Waiting for FWDL_RDY: Timeout (0x%08X)\n", u4Value
));
3354 u4Status
= WLAN_STATUS_FAILURE
;
3364 HAL_PORT_WR(prAdapter
,
3366 prHifTxHeader
->u2TxByteCount
,
3367 (PUINT_8
)prHifTxHeader
,
3368 prAdapter
->u4CoalescingBufCachedSize
);
3375 #if !CFG_ENABLE_FW_DOWNLOAD_ACK
3376 /*----------------------------------------------------------------------------*/
3378 * @brief This function is called to confirm previously firmware download is done without error
3380 * @param prAdapter Pointer to the Adapter structure.
3384 /*----------------------------------------------------------------------------*/
3386 wlanImageQueryStatus(
3387 IN P_ADAPTER_T prAdapter
3390 P_CMD_INFO_T prCmdInfo
;
3391 P_INIT_HIF_TX_HEADER_T prInitHifTxHeader
;
3392 UINT_8 aucBuffer
[sizeof(INIT_HIF_RX_HEADER_T
) + sizeof(INIT_EVENT_PENDING_ERROR
)];
3393 UINT_32 u4RxPktLength
;
3394 P_INIT_HIF_RX_HEADER_T prInitHifRxHeader
;
3395 P_INIT_EVENT_PENDING_ERROR prEventPendingError
;
3396 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
3397 UINT_8 ucTC
, ucCmdSeqNum
;
3401 DEBUGFUNC("wlanImageQueryStatus");
3403 // 1. Allocate CMD Info Packet and it Buffer.
3404 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, sizeof(INIT_HIF_TX_HEADER_T
));
3407 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
3408 return WLAN_STATUS_FAILURE
;
3411 kalMemZero(prCmdInfo
, sizeof(INIT_HIF_TX_HEADER_T
));
3412 prCmdInfo
->u2InfoBufLen
= sizeof(INIT_HIF_TX_HEADER_T
);
3414 // 2. Use TC0's resource to download image. (only TC0 is allowed)
3417 // 3. increase command sequence number
3418 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
3420 // 4. Setup common CMD Info Packet
3421 prInitHifTxHeader
= (P_INIT_HIF_TX_HEADER_T
)(prCmdInfo
->pucInfoBuffer
);
3422 prInitHifTxHeader
->rInitWifiCmd
.ucCID
= INIT_CMD_ID_QUERY_PENDING_ERROR
;
3423 prInitHifTxHeader
->rInitWifiCmd
.ucSeqNum
= ucCmdSeqNum
;
3427 // 5.1 Acquire TX Resource
3428 if (nicTxAcquireResource(prAdapter
, ucTC
) == WLAN_STATUS_RESOURCES
) {
3429 if (nicTxPollingResource(prAdapter
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3430 u4Status
= WLAN_STATUS_FAILURE
;
3431 DBGLOG(INIT
, ERROR
,("Fail to get TX resource return within timeout\n"));
3439 // 5.2 Send CMD Info Packet
3440 if (nicTxInitCmd(prAdapter
, prCmdInfo
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3441 u4Status
= WLAN_STATUS_FAILURE
;
3442 DBGLOG(INIT
, ERROR
,("Fail to transmit image download command\n"));
3448 // 6. Wait for INIT_EVENT_ID_PENDING_ERROR
3450 if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
3451 || fgIsBusAccessFailed
== TRUE
) {
3452 u4Status
= WLAN_STATUS_FAILURE
;
3454 else if(nicRxWaitResponse(prAdapter
,
3457 sizeof(INIT_HIF_RX_HEADER_T
) + sizeof(INIT_EVENT_PENDING_ERROR
),
3458 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
3459 u4Status
= WLAN_STATUS_FAILURE
;
3462 prInitHifRxHeader
= (P_INIT_HIF_RX_HEADER_T
) aucBuffer
;
3464 // EID / SeqNum check
3465 if(prInitHifRxHeader
->rInitWifiEvent
.ucEID
!= INIT_EVENT_ID_PENDING_ERROR
) {
3466 u4Status
= WLAN_STATUS_FAILURE
;
3468 else if(prInitHifRxHeader
->rInitWifiEvent
.ucSeqNum
!= ucCmdSeqNum
) {
3469 u4Status
= WLAN_STATUS_FAILURE
;
3472 prEventPendingError
= (P_INIT_EVENT_PENDING_ERROR
) (prInitHifRxHeader
->rInitWifiEvent
.aucBuffer
);
3473 if(prEventPendingError
->ucStatus
!= 0) { // 0 for download success
3474 u4Status
= WLAN_STATUS_FAILURE
;
3477 u4Status
= WLAN_STATUS_SUCCESS
;
3483 // 7. Free CMD Info Packet.
3484 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
3491 /*----------------------------------------------------------------------------*/
3493 * @brief This function is called to confirm the status of
3494 * previously downloaded firmware scatter
3496 * @param prAdapter Pointer to the Adapter structure.
3497 * ucCmdSeqNum Sequence number of previous firmware scatter
3499 * @return WLAN_STATUS_SUCCESS
3500 * WLAN_STATUS_FAILURE
3502 /*----------------------------------------------------------------------------*/
3504 wlanImageSectionDownloadStatus (
3505 IN P_ADAPTER_T prAdapter
,
3506 IN UINT_8 ucCmdSeqNum
3509 UINT_8 aucBuffer
[sizeof(INIT_HIF_RX_HEADER_T
) + sizeof(INIT_EVENT_CMD_RESULT
)];
3510 P_INIT_HIF_RX_HEADER_T prInitHifRxHeader
;
3511 P_INIT_EVENT_CMD_RESULT prEventCmdResult
;
3512 UINT_32 u4RxPktLength
;
3513 WLAN_STATUS u4Status
;
3518 if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
3519 || fgIsBusAccessFailed
== TRUE
) {
3520 DBGLOG(INIT
, ERROR
,("kalIsCardRemoved or fgIsBusAccessFailed\n"));
3521 u4Status
= WLAN_STATUS_FAILURE
;
3523 else if(nicRxWaitResponse(prAdapter
,
3526 sizeof(INIT_HIF_RX_HEADER_T
) + sizeof(INIT_EVENT_CMD_RESULT
), /* 4B + 4B */
3527 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
3529 DBGLOG(INIT
, ERROR
,("nicRxWaitResponse fail\n"));
3530 u4Status
= WLAN_STATUS_FAILURE
;
3533 prInitHifRxHeader
= (P_INIT_HIF_RX_HEADER_T
) aucBuffer
;
3535 // EID / SeqNum check
3536 if(prInitHifRxHeader
->rInitWifiEvent
.ucEID
!= INIT_EVENT_ID_CMD_RESULT
) {
3537 DBGLOG(INIT
, ERROR
,("rInitWifiEvent.ucEID != INIT_EVENT_ID_CMD_RESULT\n"));
3538 u4Status
= WLAN_STATUS_FAILURE
;
3540 else if(prInitHifRxHeader
->rInitWifiEvent
.ucSeqNum
!= ucCmdSeqNum
) {
3541 DBGLOG(INIT
, ERROR
,("rInitWifiEvent.ucSeqNum != ucCmdSeqNum\n"));
3542 u4Status
= WLAN_STATUS_FAILURE
;
3545 prEventCmdResult
= (P_INIT_EVENT_CMD_RESULT
) (prInitHifRxHeader
->rInitWifiEvent
.aucBuffer
);
3546 if(prEventCmdResult
->ucStatus
!= 0) { // 0 for download success
3549 1: rejected by invalid param
3550 2: rejected by incorrect CRC
3551 3: rejected by decryption failure
3554 DBGLOG(INIT
, ERROR
, ("Read Response status error = %d\n",
3555 prEventCmdResult
->ucStatus
));
3556 u4Status
= WLAN_STATUS_FAILURE
;
3559 u4Status
= WLAN_STATUS_SUCCESS
;
3570 /*----------------------------------------------------------------------------*/
3572 * @brief This function is called to start FW normal operation.
3574 * @param prAdapter Pointer to the Adapter structure.
3578 /*----------------------------------------------------------------------------*/
3580 wlanConfigWifiFunc (
3581 IN P_ADAPTER_T prAdapter
,
3582 IN BOOLEAN fgEnable
,
3583 IN UINT_32 u4StartAddress
3586 P_CMD_INFO_T prCmdInfo
;
3587 P_INIT_HIF_TX_HEADER_T prInitHifTxHeader
;
3588 P_INIT_CMD_WIFI_START prInitCmdWifiStart
;
3589 UINT_8 ucTC
, ucCmdSeqNum
;
3590 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
3594 DEBUGFUNC("wlanConfigWifiFunc");
3596 // 1. Allocate CMD Info Packet and its Buffer.
3597 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
,
3598 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_WIFI_START
));
3601 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
3602 return WLAN_STATUS_FAILURE
;
3605 kalMemZero(prCmdInfo
, sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_WIFI_START
));
3606 prCmdInfo
->u2InfoBufLen
=
3607 sizeof(INIT_HIF_TX_HEADER_T
) + sizeof(INIT_CMD_WIFI_START
);
3609 // 2. Always use TC0
3612 // 3. increase command sequence number
3613 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
3615 // 4. Setup common CMD Info Packet
3616 prInitHifTxHeader
= (P_INIT_HIF_TX_HEADER_T
)(prCmdInfo
->pucInfoBuffer
);
3617 prInitHifTxHeader
->rInitWifiCmd
.ucCID
= INIT_CMD_ID_WIFI_START
;
3618 prInitHifTxHeader
->rInitWifiCmd
.ucSeqNum
= ucCmdSeqNum
;
3620 prInitCmdWifiStart
= (P_INIT_CMD_WIFI_START
)(prInitHifTxHeader
->rInitWifiCmd
.aucBuffer
);
3621 prInitCmdWifiStart
->u4Override
= (fgEnable
== TRUE
? 1 : 0);
3622 prInitCmdWifiStart
->u4Address
= u4StartAddress
;
3624 // 5. Seend WIFI start command
3626 // 5.1 Acquire TX Resource
3627 if (nicTxAcquireResource(prAdapter
, ucTC
) == WLAN_STATUS_RESOURCES
) {
3629 /* wait and poll tx resource */
3630 if (nicTxPollingResource(prAdapter
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3631 u4Status
= WLAN_STATUS_FAILURE
;
3632 DBGLOG(INIT
, ERROR
,("Fail to get TX resource return within timeout\n"));
3640 // 5.2 Send CMD Info Packet
3641 if (nicTxInitCmd(prAdapter
, prCmdInfo
, ucTC
) != WLAN_STATUS_SUCCESS
) {
3642 u4Status
= WLAN_STATUS_FAILURE
;
3643 DBGLOG(INIT
, ERROR
,("Fail to transmit WIFI start command\n"));
3649 // 6. Free CMD Info Packet.
3650 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
3656 /*----------------------------------------------------------------------------*/
3658 * @brief This function is used to generate CRC32 checksum
3660 * @param buf Pointer to the data.
3661 * @param len data length
3663 * @return crc32 value
3665 /*----------------------------------------------------------------------------*/
3670 UINT_32 i
, crc32
= 0xFFFFFFFF;
3671 const UINT_32 crc32_ccitt_table
[256] = {
3672 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
3673 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
3674 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
3675 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
3676 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
3677 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
3678 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
3679 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
3680 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
3681 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
3682 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
3683 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
3684 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
3685 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
3686 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
3687 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
3688 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
3689 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
3690 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
3691 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
3692 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
3693 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
3694 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
3695 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
3696 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
3697 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
3698 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
3699 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
3700 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
3701 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
3702 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
3703 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
3704 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
3705 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
3706 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
3707 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
3708 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
3709 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
3710 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
3711 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
3712 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
3713 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
3714 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
3715 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
3716 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
3717 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
3718 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
3719 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
3720 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
3721 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
3722 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
3725 for (i
= 0; i
< len
; i
++)
3726 crc32
= crc32_ccitt_table
[(crc32
^ buf
[i
]) & 0xff] ^ (crc32
>> 8);
3733 /*----------------------------------------------------------------------------*/
3735 * @brief This function is called to process queued RX packets
3737 * @param prAdapter Pointer to the Adapter structure.
3738 * prSwRfbListHead Pointer to head of RX packets link list
3742 /*----------------------------------------------------------------------------*/
3744 wlanProcessQueuedSwRfb (
3745 IN P_ADAPTER_T prAdapter
,
3746 IN P_SW_RFB_T prSwRfbListHead
3749 P_SW_RFB_T prSwRfb
, prNextSwRfb
;
3750 P_TX_CTRL_T prTxCtrl
;
3751 P_RX_CTRL_T prRxCtrl
;
3754 ASSERT(prSwRfbListHead
);
3756 prTxCtrl
= &prAdapter
->rTxCtrl
;
3757 prRxCtrl
= &prAdapter
->rRxCtrl
;
3759 prSwRfb
= prSwRfbListHead
;
3763 prNextSwRfb
= (P_SW_RFB_T
)QUEUE_GET_NEXT_ENTRY((P_QUE_ENTRY_T
)prSwRfb
);
3765 switch(prSwRfb
->eDst
) {
3766 case RX_PKT_DESTINATION_HOST
:
3768 nicRxProcessPktWithoutReorder(prAdapter
, prSwRfb
);
3771 case RX_PKT_DESTINATION_FORWARD
:
3772 /* need ot forward */
3773 nicRxProcessForwardPkt(prAdapter
, prSwRfb
);
3776 case RX_PKT_DESTINATION_HOST_WITH_FORWARD
:
3777 /* to host and forward */
3778 nicRxProcessGOBroadcastPkt(prAdapter
, prSwRfb
);
3781 case RX_PKT_DESTINATION_NULL
:
3783 nicRxReturnRFB(prAdapter
, prSwRfb
);
3790 #if CFG_HIF_RX_STARVATION_WARNING
3791 prRxCtrl
->u4DequeuedCnt
++;
3794 /* check next queued packet */
3795 prSwRfb
= prNextSwRfb
;
3798 return WLAN_STATUS_SUCCESS
;
3802 /*----------------------------------------------------------------------------*/
3804 * @brief This function is called to purge queued TX packets
3805 * by indicating failure to OS and returned to free list
3807 * @param prAdapter Pointer to the Adapter structure.
3808 * prMsduInfoListHead Pointer to head of TX packets link list
3812 /*----------------------------------------------------------------------------*/
3814 wlanProcessQueuedMsduInfo (
3815 IN P_ADAPTER_T prAdapter
,
3816 IN P_MSDU_INFO_T prMsduInfoListHead
3820 ASSERT(prMsduInfoListHead
);
3822 nicTxFreeMsduInfoPacket(prAdapter
, prMsduInfoListHead
);
3823 nicTxReturnMsduInfo(prAdapter
, prMsduInfoListHead
);
3825 return WLAN_STATUS_SUCCESS
;
3829 /*----------------------------------------------------------------------------*/
3831 * @brief This function is called to check if the OID handler needs timeout
3833 * @param prAdapter Pointer to the Adapter structure.
3834 * pfnOidHandler Pointer to the OID handler
3839 /*----------------------------------------------------------------------------*/
3841 wlanoidTimeoutCheck (
3842 IN P_ADAPTER_T prAdapter
,
3843 IN PFN_OID_HANDLER_FUNC pfnOidHandler
3846 PFN_OID_HANDLER_FUNC
* apfnOidHandlerWOTimeoutCheck
;
3848 UINT_32 u4NumOfElem
;
3850 apfnOidHandlerWOTimeoutCheck
= apfnOidWOTimeoutCheck
;
3851 u4NumOfElem
= sizeof(apfnOidWOTimeoutCheck
) / sizeof(PFN_OID_HANDLER_FUNC
);
3853 /* skip some OID timeout checks ? */
3854 for (i
= 0; i
< u4NumOfElem
; i
++) {
3855 if (apfnOidHandlerWOTimeoutCheck
[i
] == pfnOidHandler
) {
3860 // set timer if need timeout check
3861 //cnmTimerStartTimer(prAdapter,
3862 // &(prAdapter->rOidTimeoutTimer),
3864 cnmTimerStartTimer(prAdapter
,
3865 &(prAdapter
->rOidTimeoutTimer
),
3872 /*----------------------------------------------------------------------------*/
3874 * @brief This function is called to clear any pending OID timeout check
3876 * @param prAdapter Pointer to the Adapter structure.
3880 /*----------------------------------------------------------------------------*/
3882 wlanoidClearTimeoutCheck (
3883 IN P_ADAPTER_T prAdapter
3888 cnmTimerStopTimer(prAdapter
, &(prAdapter
->rOidTimeoutTimer
));
3892 /*----------------------------------------------------------------------------*/
3894 * @brief This function is called to set up the MCUSYS's OSC stable time
3896 * @param prAdapter Pointer to the Adapter structure.
3900 /*----------------------------------------------------------------------------*/
3902 #if CFG_SUPPORT_OSC_SETTING && defined(MT5931)
3904 wlanSetMcuOscStableTime (
3905 IN P_ADAPTER_T prAdapter
,
3906 IN UINT_16 u2OscStableTime
3909 UINT_8 ucCmdSeqNum
= 0;
3910 P_CMD_INFO_T prCmdInfo
= NULL
;
3911 P_WIFI_CMD_T prWifiCmd
= NULL
;
3912 P_CMD_MCU_LP_PARAM_T prMcuSetOscCmd
= NULL
;
3913 WLAN_STATUS status
= WLAN_STATUS_SUCCESS
;
3917 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
,
3918 CMD_HDR_SIZE
+ sizeof(CMD_MCU_LP_PARAM_T
));
3921 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
3922 return WLAN_STATUS_FAILURE
;
3925 // increase command sequence number
3926 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
3928 // compose CMD_MCU_LP_PARAM_T cmd pkt
3929 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
3930 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
+ sizeof(CMD_MCU_LP_PARAM_T
);
3931 prCmdInfo
->pfCmdDoneHandler
= NULL
;
3932 prCmdInfo
->pfCmdTimeoutHandler
= NULL
;
3933 prCmdInfo
->fgIsOid
= FALSE
;
3934 prCmdInfo
->ucCID
= CMD_ID_SET_OSC
;
3935 prCmdInfo
->fgSetQuery
= TRUE
;
3936 prCmdInfo
->fgNeedResp
= FALSE
;
3937 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
3938 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
3939 prCmdInfo
->u4SetInfoLen
= sizeof(CMD_MCU_LP_PARAM_T
);
3942 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
3943 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
3944 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
3945 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
3946 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
3948 // configure CMD_MCU_LP_PARAM_T
3949 prMcuSetOscCmd
= (P_CMD_MCU_LP_PARAM_T
)(prWifiCmd
->aucBuffer
);
3950 prMcuSetOscCmd
->u2OscStableTime
= u2OscStableTime
;
3952 status
= wlanSendCommand(prAdapter
, prCmdInfo
);
3953 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
3959 /*----------------------------------------------------------------------------*/
3961 * @brief This function is called to update network address in firmware domain
3963 * @param prAdapter Pointer to the Adapter structure.
3965 * @return WLAN_STATUS_FAILURE The request could not be processed
3966 * WLAN_STATUS_PENDING The request has been queued for later processing
3967 * WLAN_STATUS_SUCCESS The request has been processed
3969 /*----------------------------------------------------------------------------*/
3971 wlanUpdateNetworkAddress (
3972 IN P_ADAPTER_T prAdapter
3975 const UINT_8 aucZeroMacAddr
[] = NULL_MAC_ADDR
;
3976 PARAM_MAC_ADDRESS rMacAddr
;
3978 P_CMD_INFO_T prCmdInfo
;
3979 P_WIFI_CMD_T prWifiCmd
;
3980 P_CMD_BASIC_CONFIG prCmdBasicConfig
;
3983 DEBUGFUNC("wlanUpdateNetworkAddress");
3987 if(kalRetrieveNetworkAddress(prAdapter
->prGlueInfo
, &rMacAddr
) == FALSE
3988 || IS_BMCAST_MAC_ADDR(rMacAddr
)
3989 || EQUAL_MAC_ADDR(aucZeroMacAddr
, rMacAddr
)) {
3990 // eFUSE has a valid address, don't do anything
3991 if(prAdapter
->fgIsEmbbededMacAddrValid
== TRUE
) {
3992 #if CFG_SHOW_MACADDR_SOURCE
3993 DBGLOG(INIT
, INFO
, ("Using embedded MAC address"));
3995 return WLAN_STATUS_SUCCESS
;
3998 #if CFG_SHOW_MACADDR_SOURCE
3999 DBGLOG(INIT
, INFO
, ("Using dynamically generated MAC address"));
4002 u4SysTime
= kalGetTimeTick();
4008 kalMemCopy(&rMacAddr
[3], &u4SysTime
, 3);
4012 #if CFG_SHOW_MACADDR_SOURCE
4013 DBGLOG(INIT
, INFO
, ("Using host-supplied MAC address"));
4017 /* allocate command memory */
4018 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
,
4019 CMD_HDR_SIZE
+ sizeof(CMD_BASIC_CONFIG
));
4022 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4023 return WLAN_STATUS_FAILURE
;
4026 // increase command sequence number
4027 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4029 // compose CMD_BUILD_CONNECTION cmd pkt
4030 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4031 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
+ sizeof(CMD_BASIC_CONFIG
);
4032 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4033 prCmdInfo
->pfCmdTimeoutHandler
= NULL
;
4034 prCmdInfo
->fgIsOid
= FALSE
;
4035 prCmdInfo
->ucCID
= CMD_ID_BASIC_CONFIG
;
4036 prCmdInfo
->fgSetQuery
= TRUE
;
4037 prCmdInfo
->fgNeedResp
= FALSE
;
4038 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4039 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4040 prCmdInfo
->u4SetInfoLen
= sizeof(CMD_BASIC_CONFIG
);
4043 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4044 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4045 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4046 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4047 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4049 // configure CMD_BASIC_CONFIG
4050 prCmdBasicConfig
= (P_CMD_BASIC_CONFIG
)(prWifiCmd
->aucBuffer
);
4051 kalMemCopy(&(prCmdBasicConfig
->rMyMacAddr
), &rMacAddr
, PARAM_MAC_ADDR_LEN
);
4052 prCmdBasicConfig
->ucNative80211
= 0;
4053 prCmdBasicConfig
->rCsumOffload
.u2RxChecksum
= 0;
4054 prCmdBasicConfig
->rCsumOffload
.u2TxChecksum
= 0;
4056 #if CFG_TCP_IP_CHKSUM_OFFLOAD
4057 if(prAdapter
->u4CSUMFlags
& CSUM_OFFLOAD_EN_TX_TCP
)
4058 prCmdBasicConfig
->rCsumOffload
.u2TxChecksum
|= BIT(2);
4060 if(prAdapter
->u4CSUMFlags
& CSUM_OFFLOAD_EN_TX_UDP
)
4061 prCmdBasicConfig
->rCsumOffload
.u2TxChecksum
|= BIT(1);
4063 if(prAdapter
->u4CSUMFlags
& CSUM_OFFLOAD_EN_TX_IP
)
4064 prCmdBasicConfig
->rCsumOffload
.u2TxChecksum
|= BIT(0);
4066 if(prAdapter
->u4CSUMFlags
& CSUM_OFFLOAD_EN_RX_TCP
)
4067 prCmdBasicConfig
->rCsumOffload
.u2RxChecksum
|= BIT(2);
4069 if(prAdapter
->u4CSUMFlags
& CSUM_OFFLOAD_EN_RX_UDP
)
4070 prCmdBasicConfig
->rCsumOffload
.u2RxChecksum
|= BIT(1);
4072 if(prAdapter
->u4CSUMFlags
& (CSUM_OFFLOAD_EN_RX_IPv4
| CSUM_OFFLOAD_EN_RX_IPv6
))
4073 prCmdBasicConfig
->rCsumOffload
.u2RxChecksum
|= BIT(0);
4076 /* send the command to FW */
4077 if(wlanSendCommand(prAdapter
, prCmdInfo
) == WLAN_STATUS_RESOURCES
) {
4079 /* backup the command to wait response */
4080 prCmdInfo
->pfCmdDoneHandler
= nicCmdEventQueryAddress
;
4081 kalEnqueueCommand(prAdapter
->prGlueInfo
, (P_QUE_ENTRY_T
)prCmdInfo
);
4083 return WLAN_STATUS_PENDING
;
4086 /* send ok without response */
4087 nicCmdEventQueryAddress(prAdapter
, prCmdInfo
, (PUINT_8
)prCmdBasicConfig
);
4088 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4090 return WLAN_STATUS_SUCCESS
;
4094 /*----------------------------------------------------------------------------*/
4096 * @brief This function is called to check if the device is in RF test mode
4098 * @param pfnOidHandler Pointer to the OID handler
4103 /*----------------------------------------------------------------------------*/
4106 IN P_ADAPTER_T prAdapter
4111 return prAdapter
->fgTestMode
;
4115 /*----------------------------------------------------------------------------*/
4117 * @brief This function is called to identify 802.1x and Bluetooth-over-Wi-Fi
4118 * security frames, and queued into command queue for strict ordering
4119 * due to 802.1x frames before add-key OIDs are not to be encrypted
4121 * @param prAdapter Pointer of Adapter Data Structure
4122 * @param prPacket Pointer of native packet
4127 /*----------------------------------------------------------------------------*/
4129 wlanProcessSecurityFrame(
4130 IN P_ADAPTER_T prAdapter
,
4131 IN P_NATIVE_PACKET prPacket
4134 UINT_8 ucPriorityParam
;
4135 UINT_8 aucEthDestAddr
[PARAM_MAC_ADDR_LEN
];
4136 BOOLEAN fgIs1x
= FALSE
;
4137 BOOLEAN fgIsPAL
= FALSE
;
4138 UINT_32 u4PacketLen
;
4140 UINT_8 ucNetworkType
;
4141 P_CMD_INFO_T prCmdInfo
;
4146 /* retrieve some informations for packet classification */
4147 if (kalQoSFrameClassifierAndPacketInfo(prAdapter
->prGlueInfo
,
4154 &ucNetworkType
) == TRUE
) { /* almost TRUE except frame length < 14B */
4156 if(fgIs1x
== FALSE
) {
4160 /* 1x data packets */
4161 KAL_SPIN_LOCK_DECLARATION();
4163 /* get a free command entry */
4164 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_RESOURCE
);
4165 QUEUE_REMOVE_HEAD(&prAdapter
->rFreeCmdList
, prCmdInfo
, P_CMD_INFO_T
);
4166 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_RESOURCE
);
4168 DBGLOG(RSN
, INFO
, ("T1X len=%u\n", u4PacketLen
));
4171 P_STA_RECORD_T prStaRec
;
4173 // fill arrival time
4174 u4SysTime
= (OS_SYSTIME
)kalGetTimeTick();
4175 GLUE_SET_PKT_ARRIVAL_TIME(prPacket
, u4SysTime
);
4177 kalMemZero(prCmdInfo
, sizeof(CMD_INFO_T
));
4179 prCmdInfo
->eCmdType
= COMMAND_TYPE_SECURITY_FRAME
;
4180 prCmdInfo
->u2InfoBufLen
= (UINT_16
)u4PacketLen
;
4181 prCmdInfo
->pucInfoBuffer
= NULL
;
4182 prCmdInfo
->prPacket
= prPacket
;
4184 prCmdInfo
->ucStaRecIndex
= qmGetStaRecIdx(prAdapter
,
4186 (ENUM_NETWORK_TYPE_INDEX_T
)ucNetworkType
);
4188 prStaRec
= cnmGetStaRecByAddress(prAdapter
,
4189 (ENUM_NETWORK_TYPE_INDEX_T
)ucNetworkType
,
4192 prCmdInfo
->ucStaRecIndex
= prStaRec
->ucIndex
;
4195 prCmdInfo
->ucStaRecIndex
= STA_REC_INDEX_NOT_FOUND
;
4198 prCmdInfo
->eNetworkType
= (ENUM_NETWORK_TYPE_INDEX_T
)ucNetworkType
;
4199 prCmdInfo
->pfCmdDoneHandler
= wlanSecurityFrameTxDone
;
4200 prCmdInfo
->pfCmdTimeoutHandler
= wlanSecurityFrameTxTimeout
;
4201 prCmdInfo
->fgIsOid
= FALSE
;
4202 prCmdInfo
->fgSetQuery
= TRUE
;
4203 prCmdInfo
->fgNeedResp
= FALSE
;
4206 queue the 1x packet and we will send the packet to CONNSYS by
4209 kalEnqueueCommand(prAdapter
->prGlueInfo
, (P_QUE_ENTRY_T
)prCmdInfo
);
4211 /* TRUE: means we have already handled it in the function */
4216 /* no memory, why assert ? can skip the packet ? */
4228 /*----------------------------------------------------------------------------*/
4230 * @brief This function is called when 802.1x or Bluetooth-over-Wi-Fi
4231 * security frames has been sent to firmware
4233 * @param prAdapter Pointer of Adapter Data Structure
4234 * @param prCmdInfo Pointer of CMD_INFO_T
4235 * @param pucEventBuf meaningless, only for API compatibility
4239 /*----------------------------------------------------------------------------*/
4241 wlanSecurityFrameTxDone(
4242 IN P_ADAPTER_T prAdapter
,
4243 IN P_CMD_INFO_T prCmdInfo
,
4244 IN PUINT_8 pucEventBuf
4250 if (prCmdInfo
->eNetworkType
== NETWORK_TYPE_AIS_INDEX
&&
4251 prAdapter
->rWifiVar
.rAisSpecificBssInfo
.fgCounterMeasure
) {
4253 /* AIS counter measure so change RSN FSM to SEND_DEAUTH state */
4254 P_STA_RECORD_T prSta
= cnmGetStaRecByIndex(prAdapter
, prCmdInfo
->ucStaRecIndex
);
4257 secFsmEventEapolTxDone(prAdapter
, prSta
, TX_RESULT_SUCCESS
);
4261 /* free the packet */
4262 kalSecurityFrameSendComplete(prAdapter
->prGlueInfo
,
4263 prCmdInfo
->prPacket
,
4264 WLAN_STATUS_SUCCESS
);
4268 /*----------------------------------------------------------------------------*/
4270 * @brief This function is called when 802.1x or Bluetooth-over-Wi-Fi
4271 * security frames has failed sending to firmware
4273 * @param prAdapter Pointer of Adapter Data Structure
4274 * @param prCmdInfo Pointer of CMD_INFO_T
4278 /*----------------------------------------------------------------------------*/
4280 wlanSecurityFrameTxTimeout(
4281 IN P_ADAPTER_T prAdapter
,
4282 IN P_CMD_INFO_T prCmdInfo
4288 /* free the packet */
4289 kalSecurityFrameSendComplete(prAdapter
->prGlueInfo
,
4290 prCmdInfo
->prPacket
,
4291 WLAN_STATUS_FAILURE
);
4295 /*----------------------------------------------------------------------------*/
4297 * @brief This function is called before AIS is starting a new scan
4299 * @param prAdapter Pointer of Adapter Data Structure
4303 /*----------------------------------------------------------------------------*/
4305 wlanClearScanningResult(
4306 IN P_ADAPTER_T prAdapter
4309 BOOLEAN fgKeepCurrOne
= FALSE
;
4314 // clear scanning result except current one
4315 /* copy current one to prAdapter->rWlanInfo.arScanResult[0] */
4316 if(kalGetMediaStateIndicated(prAdapter
->prGlueInfo
) == PARAM_MEDIA_STATE_CONNECTED
) {
4317 for(i
= 0 ; i
< prAdapter
->rWlanInfo
.u4ScanResultNum
; i
++) {
4319 if(EQUAL_MAC_ADDR(prAdapter
->rWlanInfo
.rCurrBssId
.arMacAddress
,
4320 prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
)) {
4321 fgKeepCurrOne
= TRUE
;
4325 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[0]),
4326 &(prAdapter
->rWlanInfo
.arScanResult
[i
]),
4327 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
4330 if(prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
> 0) {
4331 if(prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] != &(prAdapter
->rWlanInfo
.aucScanIEBuf
[0])) {
4333 kalMemCopy(prAdapter
->rWlanInfo
.aucScanIEBuf
,
4334 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
],
4335 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
);
4338 // modify IE pointer
4339 prAdapter
->rWlanInfo
.apucScanResultIEs
[0] = &(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]);
4342 prAdapter
->rWlanInfo
.apucScanResultIEs
[0] = NULL
;
4350 if(fgKeepCurrOne
== TRUE
) {
4351 prAdapter
->rWlanInfo
.u4ScanResultNum
= 1;
4352 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
=
4353 ALIGN_4(prAdapter
->rWlanInfo
.arScanResult
[0].u4IELength
);
4356 prAdapter
->rWlanInfo
.u4ScanResultNum
= 0;
4357 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
= 0;
4364 /*----------------------------------------------------------------------------*/
4366 * @brief This function is called when AIS received a beacon timeout event
4368 * @param prAdapter Pointer of Adapter Data Structure
4369 * @param arBSSID MAC address of the specified BSS
4373 /*----------------------------------------------------------------------------*/
4375 wlanClearBssInScanningResult(
4376 IN P_ADAPTER_T prAdapter
,
4380 UINT_32 i
, j
, u4IELength
= 0, u4IEMoveLength
;
4385 // clear the scanning result for arBSSID
4388 if(i
>= prAdapter
->rWlanInfo
.u4ScanResultNum
) {
4392 if(EQUAL_MAC_ADDR(arBSSID
, prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
)) {
4394 // backup current IE length
4395 u4IELength
= ALIGN_4(prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
);
4396 pucIEPtr
= prAdapter
->rWlanInfo
.apucScanResultIEs
[i
];
4398 // removed from middle
4399 for(j
= i
+ 1 ; j
< prAdapter
->rWlanInfo
.u4ScanResultNum
; j
++) {
4400 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[j
-1]),
4401 &(prAdapter
->rWlanInfo
.arScanResult
[j
]),
4402 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
4404 prAdapter
->rWlanInfo
.apucScanResultIEs
[j
-1] =
4405 prAdapter
->rWlanInfo
.apucScanResultIEs
[j
];
4408 prAdapter
->rWlanInfo
.u4ScanResultNum
--;
4410 // remove IE buffer if needed := move rest of IE buffer
4411 if(u4IELength
> 0) {
4412 u4IEMoveLength
= prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
-
4413 (((ULONG
)pucIEPtr
) + (ULONG
)u4IELength
- ((ULONG
)(&(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]))));
4415 kalMemCopy(pucIEPtr
,
4416 pucIEPtr
+ u4IELength
,
4419 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
-= u4IELength
;
4421 // correction of pointers to IE buffer
4422 for(j
= 0 ; j
< prAdapter
->rWlanInfo
.u4ScanResultNum
; j
++) {
4423 if(prAdapter
->rWlanInfo
.apucScanResultIEs
[j
] > pucIEPtr
) {
4424 prAdapter
->rWlanInfo
.apucScanResultIEs
[j
] =
4425 (PUINT_8
)((ULONG
)(prAdapter
->rWlanInfo
.apucScanResultIEs
[j
]) - u4IELength
);
4438 #if CFG_TEST_WIFI_DIRECT_GO
4440 wlanEnableP2pFunction (
4441 IN P_ADAPTER_T prAdapter
4445 P_MSG_P2P_FUNCTION_SWITCH_T prMsgFuncSwitch
= (P_MSG_P2P_FUNCTION_SWITCH_T
)NULL
;
4447 prMsgFuncSwitch
= (P_MSG_P2P_FUNCTION_SWITCH_T
)cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_P2P_FUNCTION_SWITCH_T
));
4448 if (!prMsgFuncSwitch
) {
4454 prMsgFuncSwitch
->rMsgHdr
.eMsgId
= MID_MNY_P2P_FUN_SWITCH
;
4455 prMsgFuncSwitch
->fgIsFuncOn
= TRUE
;
4458 mboxSendMsg(prAdapter
,
4460 (P_MSG_HDR_T
)prMsgFuncSwitch
,
4461 MSG_SEND_METHOD_BUF
);
4468 IN P_ADAPTER_T prAdapter
4472 P_MSG_P2P_CONNECTION_REQUEST_T prMsgConnReq
= (P_MSG_P2P_CONNECTION_REQUEST_T
)NULL
;
4473 UINT_8 aucTargetDeviceID
[MAC_ADDR_LEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
4475 prMsgConnReq
= (P_MSG_P2P_CONNECTION_REQUEST_T
)cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_P2P_CONNECTION_REQUEST_T
));
4476 if (!prMsgConnReq
) {
4481 prMsgConnReq
->rMsgHdr
.eMsgId
= MID_MNY_P2P_CONNECTION_REQ
;
4483 /*=====Param Modified for test=====*/
4484 COPY_MAC_ADDR(prMsgConnReq
->aucDeviceID
, aucTargetDeviceID
);
4485 prMsgConnReq
->fgIsTobeGO
= TRUE
;
4486 prMsgConnReq
->fgIsPersistentGroup
= FALSE
;
4488 /*=====Param Modified for test=====*/
4490 mboxSendMsg(prAdapter
,
4492 (P_MSG_HDR_T
)prMsgConnReq
,
4493 MSG_SEND_METHOD_BUF
);
4500 /*----------------------------------------------------------------------------*/
4502 * @brief This function is called to retrieve permanent address from firmware
4504 * @param prAdapter Pointer of Adapter Data Structure
4506 * @return WLAN_STATUS_SUCCESS
4507 * WLAN_STATUS_FAILURE
4509 /*----------------------------------------------------------------------------*/
4511 wlanQueryPermanentAddress(
4512 IN P_ADAPTER_T prAdapter
4516 P_CMD_INFO_T prCmdInfo
;
4517 P_WIFI_CMD_T prWifiCmd
;
4518 UINT_32 u4RxPktLength
;
4519 UINT_8 aucBuffer
[sizeof(WIFI_EVENT_T
) + sizeof(EVENT_BASIC_CONFIG
)];
4520 P_HIF_RX_HEADER_T prHifRxHdr
;
4521 P_WIFI_EVENT_T prEvent
;
4522 P_EVENT_BASIC_CONFIG prEventBasicConfig
;
4526 DEBUGFUNC("wlanQueryPermanentAddress");
4528 // 1. Allocate CMD Info Packet and its Buffer
4529 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, CMD_HDR_SIZE
+ sizeof(CMD_BASIC_CONFIG
));
4531 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4532 return WLAN_STATUS_FAILURE
;
4535 // increase command sequence number
4536 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4538 // compose CMD_BUILD_CONNECTION cmd pkt
4539 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4540 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
+ sizeof(CMD_BASIC_CONFIG
);
4541 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4542 prCmdInfo
->fgIsOid
= FALSE
;
4543 prCmdInfo
->ucCID
= CMD_ID_BASIC_CONFIG
;
4544 prCmdInfo
->fgSetQuery
= FALSE
;
4545 prCmdInfo
->fgNeedResp
= TRUE
;
4546 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4547 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4548 prCmdInfo
->u4SetInfoLen
= sizeof(CMD_BASIC_CONFIG
);
4551 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4552 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4553 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4554 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4555 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4557 /* send the command */
4558 wlanSendCommand(prAdapter
, prCmdInfo
);
4559 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4561 /* wait for response */
4562 if(nicRxWaitResponse(prAdapter
,
4565 sizeof(WIFI_EVENT_T
) + sizeof(EVENT_BASIC_CONFIG
), /* 8B + 12B */
4566 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
4567 return WLAN_STATUS_FAILURE
;
4570 // header checking ..
4571 prHifRxHdr
= (P_HIF_RX_HEADER_T
)aucBuffer
;
4572 if ((prHifRxHdr
->u2PacketType
& HIF_RX_HDR_PACKET_TYPE_MASK
) != HIF_RX_PKT_TYPE_EVENT
) {
4573 return WLAN_STATUS_FAILURE
;
4576 prEvent
= (P_WIFI_EVENT_T
)aucBuffer
;
4577 if(prEvent
->ucEID
!= EVENT_ID_BASIC_CONFIG
) {
4578 return WLAN_STATUS_FAILURE
;
4581 prEventBasicConfig
= (P_EVENT_BASIC_CONFIG
)(prEvent
->aucBuffer
);
4583 COPY_MAC_ADDR(prAdapter
->rWifiVar
.aucPermanentAddress
, &(prEventBasicConfig
->rMyMacAddr
));
4584 COPY_MAC_ADDR(prAdapter
->rWifiVar
.aucMacAddress
, &(prEventBasicConfig
->rMyMacAddr
));
4586 return WLAN_STATUS_SUCCESS
;
4590 /*----------------------------------------------------------------------------*/
4592 * @brief This function is called to retrieve NIC capability from firmware
4594 * @param prAdapter Pointer of Adapter Data Structure
4596 * @return WLAN_STATUS_SUCCESS
4597 * WLAN_STATUS_FAILURE
4599 /*----------------------------------------------------------------------------*/
4601 wlanQueryNicCapability(
4602 IN P_ADAPTER_T prAdapter
4606 P_CMD_INFO_T prCmdInfo
;
4607 P_WIFI_CMD_T prWifiCmd
;
4608 UINT_32 u4RxPktLength
;
4609 UINT_8 aucBuffer
[sizeof(WIFI_EVENT_T
) + sizeof(EVENT_NIC_CAPABILITY
)];
4610 P_HIF_RX_HEADER_T prHifRxHdr
;
4611 P_WIFI_EVENT_T prEvent
;
4612 P_EVENT_NIC_CAPABILITY prEventNicCapability
;
4616 DEBUGFUNC("wlanQueryNicCapability");
4618 // 1. Allocate CMD Info Packet and its Buffer
4619 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, CMD_HDR_SIZE
+ sizeof(EVENT_NIC_CAPABILITY
));
4621 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4622 return WLAN_STATUS_FAILURE
;
4625 // increase command sequence number
4626 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4628 // compose CMD_BUILD_CONNECTION cmd pkt
4629 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4630 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
+ sizeof(EVENT_NIC_CAPABILITY
);
4631 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4632 prCmdInfo
->fgIsOid
= FALSE
;
4633 prCmdInfo
->ucCID
= CMD_ID_GET_NIC_CAPABILITY
;
4634 prCmdInfo
->fgSetQuery
= FALSE
;
4635 prCmdInfo
->fgNeedResp
= TRUE
;
4636 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4637 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4638 prCmdInfo
->u4SetInfoLen
= 0;
4641 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4642 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4643 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4644 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4645 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4647 /* send the command */
4648 wlanSendCommand(prAdapter
, prCmdInfo
);
4649 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4651 /* wait for FW response */
4652 if(nicRxWaitResponse(prAdapter
,
4655 sizeof(WIFI_EVENT_T
) + sizeof(EVENT_NIC_CAPABILITY
),
4656 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
4657 return WLAN_STATUS_FAILURE
;
4660 // header checking ..
4661 prHifRxHdr
= (P_HIF_RX_HEADER_T
)aucBuffer
;
4662 if ((prHifRxHdr
->u2PacketType
& HIF_RX_HDR_PACKET_TYPE_MASK
) != HIF_RX_PKT_TYPE_EVENT
) {
4663 return WLAN_STATUS_FAILURE
;
4666 prEvent
= (P_WIFI_EVENT_T
)aucBuffer
;
4667 if(prEvent
->ucEID
!= EVENT_ID_NIC_CAPABILITY
) {
4668 return WLAN_STATUS_FAILURE
;
4671 prEventNicCapability
= (P_EVENT_NIC_CAPABILITY
)(prEvent
->aucBuffer
);
4673 prAdapter
->rVerInfo
.u2FwProductID
= prEventNicCapability
->u2ProductID
;
4674 prAdapter
->rVerInfo
.u2FwOwnVersion
= prEventNicCapability
->u2FwVersion
;
4675 prAdapter
->rVerInfo
.u2FwPeerVersion
= prEventNicCapability
->u2DriverVersion
;
4676 prAdapter
->fgIsHw5GBandDisabled
= (BOOLEAN
)prEventNicCapability
->ucHw5GBandDisabled
;
4677 prAdapter
->fgIsEepromUsed
= (BOOLEAN
)prEventNicCapability
->ucEepromUsed
;
4678 prAdapter
->fgIsEfuseValid
= (BOOLEAN
)prEventNicCapability
->ucEfuseValid
;
4679 prAdapter
->fgIsEmbbededMacAddrValid
= (BOOLEAN
)prEventNicCapability
->ucMacAddrValid
;
4681 #if (CFG_SUPPORT_TDLS == 1)
4682 if (prEventNicCapability
->ucFeatureSet
& (1 << FEATURE_SET_OFFSET_TDLS
))
4683 prAdapter
->fgTdlsIsSup
= TRUE
;
4684 DBGLOG(TDLS
, TRACE
, ("<wifi> support flag: 0x%x\n",
4685 prEventNicCapability
->ucFeatureSet
));
4687 prAdapter
->fgTdlsIsSup
= 0;
4688 #endif /* CFG_SUPPORT_TDLS */
4690 if (!(prEventNicCapability
->ucFeatureSet
& (1 << FEATURE_SET_OFFSET_5G_SUPPORT
)))
4691 prAdapter
->fgEnable5GBand
= FALSE
; /* firmware does not support */
4693 #if CFG_ENABLE_CAL_LOG
4694 DBGLOG(INIT
, INFO
, (" RF CAL FAIL = (%d),BB CAL FAIL = (%d)\n",
4695 prEventNicCapability
->ucRfCalFail
,prEventNicCapability
->ucBbCalFail
));
4697 return WLAN_STATUS_SUCCESS
;
4701 /*----------------------------------------------------------------------------*/
4703 * @brief This function is called to retrieve NIC capability from firmware
4705 * @param prAdapter Pointer of Adapter Data Structure
4707 * @return WLAN_STATUS_SUCCESS
4708 * WLAN_STATUS_FAILURE
4710 /*----------------------------------------------------------------------------*/
4713 IN P_ADAPTER_T prAdapter
4717 P_CMD_INFO_T prCmdInfo
;
4718 P_WIFI_CMD_T prWifiCmd
;
4722 DEBUGFUNC("wlanQueryDebugCode");
4724 // 1. Allocate CMD Info Packet and its Buffer
4725 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, CMD_HDR_SIZE
);
4727 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4728 return WLAN_STATUS_FAILURE
;
4731 // increase command sequence number
4732 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4734 // compose CMD_BUILD_CONNECTION cmd pkt
4735 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4736 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
;
4737 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4738 prCmdInfo
->fgIsOid
= FALSE
;
4739 prCmdInfo
->ucCID
= CMD_ID_GET_DEBUG_CODE
;
4740 prCmdInfo
->fgSetQuery
= FALSE
;
4741 prCmdInfo
->fgNeedResp
= FALSE
;
4742 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4743 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4744 prCmdInfo
->u4SetInfoLen
= 0;
4747 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4748 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4749 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4750 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4751 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4753 /* send the command */
4754 wlanSendCommand(prAdapter
, prCmdInfo
);
4755 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4757 return WLAN_STATUS_SUCCESS
;
4761 /*----------------------------------------------------------------------------*/
4763 * @brief This function is called to retrieve compiler flag from firmware
4765 * @param prAdapter Pointer of Adapter Data Structure
4767 * @return WLAN_STATUS_SUCCESS
4768 * WLAN_STATUS_FAILURE
4770 /*----------------------------------------------------------------------------*/
4772 wlanQueryCompileFlag(
4773 IN P_ADAPTER_T prAdapter
,
4774 IN UINT_32 u4QueryID
,
4775 OUT PUINT_32 pu4CompilerFlag
4779 P_CMD_INFO_T prCmdInfo
;
4780 P_WIFI_CMD_T prWifiCmd
;
4781 UINT_32 u4RxPktLength
;
4782 UINT_8 aucBuffer
[sizeof(WIFI_EVENT_T
) + sizeof(CMD_SW_DBG_CTRL_T
)];
4783 P_HIF_RX_HEADER_T prHifRxHdr
;
4784 P_WIFI_EVENT_T prEvent
;
4785 P_CMD_SW_DBG_CTRL_T prCmdNicCompileFlag
, prEventNicCompileFlag
;
4789 DEBUGFUNC(__FUNCTION__
);
4791 // 1. Allocate CMD Info Packet and its Buffer
4792 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, CMD_HDR_SIZE
+ sizeof(CMD_SW_DBG_CTRL_T
));
4794 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4795 return WLAN_STATUS_FAILURE
;
4798 // increase command sequence number
4799 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4801 // compose CMD_BUILD_CONNECTION cmd pkt
4802 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4803 prCmdInfo
->u2InfoBufLen
= CMD_HDR_SIZE
+ sizeof(CMD_SW_DBG_CTRL_T
);
4804 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4805 prCmdInfo
->fgIsOid
= FALSE
;
4806 prCmdInfo
->ucCID
= CMD_ID_SW_DBG_CTRL
;
4807 prCmdInfo
->fgSetQuery
= FALSE
;
4808 prCmdInfo
->fgNeedResp
= TRUE
;
4809 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4810 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4811 prCmdInfo
->u4SetInfoLen
= 0;
4814 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4815 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4816 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4817 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4818 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4821 prCmdNicCompileFlag
= (P_CMD_SW_DBG_CTRL_T
)(prWifiCmd
->aucBuffer
);
4823 prCmdNicCompileFlag
->u4Id
= u4QueryID
;
4825 wlanSendCommand(prAdapter
, prCmdInfo
);
4826 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4828 if(nicRxWaitResponse(prAdapter
,
4831 sizeof(WIFI_EVENT_T
) + sizeof(CMD_SW_DBG_CTRL_T
),
4832 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
4833 return WLAN_STATUS_FAILURE
;
4836 // header checking ..
4837 prHifRxHdr
= (P_HIF_RX_HEADER_T
)aucBuffer
;
4838 if(prHifRxHdr
->u2PacketType
!= HIF_RX_PKT_TYPE_EVENT
) {
4839 return WLAN_STATUS_FAILURE
;
4842 prEvent
= (P_WIFI_EVENT_T
)aucBuffer
;
4843 if(prEvent
->ucEID
!= EVENT_ID_SW_DBG_CTRL
) {
4844 return WLAN_STATUS_FAILURE
;
4847 prEventNicCompileFlag
= (P_CMD_SW_DBG_CTRL_T
)(prEvent
->aucBuffer
);
4849 *pu4CompilerFlag
= prEventNicCompileFlag
->u4Data
;
4851 return WLAN_STATUS_SUCCESS
;
4855 wlanQueryCompileFlags(
4856 IN P_ADAPTER_T prAdapter
4859 wlanQueryCompileFlag(prAdapter
, 0xA0240000, &prAdapter
->u4FwCompileFlag0
);
4860 wlanQueryCompileFlag(prAdapter
, 0xA0240001, &prAdapter
->u4FwCompileFlag1
);
4862 DBGLOG(INIT
, TRACE
, ("Compile Flags: 0x%08x 0x%08x\n", prAdapter
->u4FwCompileFlag0
, prAdapter
->u4FwCompileFlag1
));
4864 return WLAN_STATUS_SUCCESS
;
4868 static INT_32
wlanChangeCodeWord(INT_32 au4Input
){
4871 #if TXPWR_USE_PDSLOPE
4872 CODE_MAPPING_T arCodeTable
[] = {
4893 CODE_MAPPING_T arCodeTable
[] = {
4915 for (i
= 0; i
< sizeof(arCodeTable
) / sizeof(CODE_MAPPING_T
); i
++) {
4917 if (arCodeTable
[i
].u4RegisterValue
== au4Input
){
4918 return arCodeTable
[i
].i4TxpowerOffset
;
4928 #if TXPWR_USE_PDSLOPE
4930 /*----------------------------------------------------------------------------*/
4934 * @param prAdapter Pointer of Adapter Data Structure
4936 * @return WLAN_STATUS_SUCCESS
4937 * WLAN_STATUS_FAILURE
4939 /*----------------------------------------------------------------------------*/
4942 IN P_ADAPTER_T prAdapter
,
4943 P_PARAM_MCR_RW_STRUC_T prMcrRdInfo
4947 P_CMD_INFO_T prCmdInfo
;
4948 P_WIFI_CMD_T prWifiCmd
;
4949 UINT_32 u4RxPktLength
;
4950 UINT_8 aucBuffer
[sizeof(WIFI_EVENT_T
) + sizeof(CMD_ACCESS_REG
)];
4951 P_HIF_RX_HEADER_T prHifRxHdr
;
4952 P_WIFI_EVENT_T prEvent
;
4953 P_CMD_ACCESS_REG prCmdMcrQuery
;
4957 // 1. Allocate CMD Info Packet and its Buffer
4958 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, CMD_HDR_SIZE
+ sizeof(CMD_ACCESS_REG
));
4961 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
4962 return WLAN_STATUS_FAILURE
;
4964 // increase command sequence number
4965 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
4967 // compose CMD_BUILD_CONNECTION cmd pkt
4968 prCmdInfo
->eCmdType
= COMMAND_TYPE_GENERAL_IOCTL
;
4969 prCmdInfo
->u2InfoBufLen
= (UINT_16
)(CMD_HDR_SIZE
+ sizeof(CMD_ACCESS_REG
));
4970 prCmdInfo
->pfCmdDoneHandler
= NULL
;
4971 prCmdInfo
->pfCmdTimeoutHandler
= nicOidCmdTimeoutCommon
;
4972 prCmdInfo
->fgIsOid
= FALSE
;
4973 prCmdInfo
->ucCID
= CMD_ID_ACCESS_REG
;
4974 prCmdInfo
->fgSetQuery
= FALSE
;
4975 prCmdInfo
->fgNeedResp
= TRUE
;
4976 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
4977 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
4978 prCmdInfo
->u4SetInfoLen
= sizeof(CMD_ACCESS_REG
);
4981 prWifiCmd
= (P_WIFI_CMD_T
)(prCmdInfo
->pucInfoBuffer
);
4982 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
4983 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
4984 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
4985 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
4986 kalMemCopy(prWifiCmd
->aucBuffer
, prMcrRdInfo
, sizeof(CMD_ACCESS_REG
));
4988 wlanSendCommand(prAdapter
, prCmdInfo
);
4989 cmdBufFreeCmdInfo(prAdapter
, prCmdInfo
);
4991 if(nicRxWaitResponse(prAdapter
,
4994 sizeof(WIFI_EVENT_T
) + sizeof(CMD_ACCESS_REG
),
4995 &u4RxPktLength
) != WLAN_STATUS_SUCCESS
) {
4996 return WLAN_STATUS_FAILURE
;
4999 // header checking ..
5000 prHifRxHdr
= (P_HIF_RX_HEADER_T
)aucBuffer
;
5001 if ((prHifRxHdr
->u2PacketType
& HIF_RX_HDR_PACKET_TYPE_MASK
) != HIF_RX_PKT_TYPE_EVENT
) {
5002 return WLAN_STATUS_FAILURE
;
5006 prEvent
= (P_WIFI_EVENT_T
)aucBuffer
;
5008 if(prEvent
->ucEID
!= EVENT_ID_ACCESS_REG
) {
5009 return WLAN_STATUS_FAILURE
;
5012 prCmdMcrQuery
= (P_CMD_ACCESS_REG
)(prEvent
->aucBuffer
);
5013 prMcrRdInfo
->u4McrOffset
= prCmdMcrQuery
->u4Address
;
5014 prMcrRdInfo
->u4McrData
= prCmdMcrQuery
->u4Data
;
5016 return WLAN_STATUS_SUCCESS
;
5019 static INT_32
wlanIntRound(INT_32 au4Input
)
5024 if((au4Input
%10) == 5){
5025 au4Input
= au4Input
+ 5;
5031 if((au4Input
%10) == -5){
5032 au4Input
= au4Input
- 5;
5040 static INT_32
wlanCal6628EfuseForm(IN P_ADAPTER_T prAdapter
,INT_32 au4Input
){
5042 PARAM_MCR_RW_STRUC_T rMcrRdInfo
;
5043 INT_32 au4PdSlope
,au4TxPwrOffset
,au4TxPwrOffset_Round
;
5044 INT_8 auTxPwrOffset_Round
;
5046 rMcrRdInfo
.u4McrOffset
= 0x60205c68;
5047 rMcrRdInfo
.u4McrData
= 0;
5048 au4TxPwrOffset
= au4Input
;
5049 wlanQueryPdMcr(prAdapter
,&rMcrRdInfo
);
5051 au4PdSlope
= (rMcrRdInfo
.u4McrData
) & BITS(0,6);
5052 au4TxPwrOffset_Round
= wlanIntRound((au4TxPwrOffset
*au4PdSlope
))/10;
5054 au4TxPwrOffset_Round
= -au4TxPwrOffset_Round
;
5056 if(au4TxPwrOffset_Round
< -128) {
5057 au4TxPwrOffset_Round
= 128;
5059 else if (au4TxPwrOffset_Round
< 0){
5060 au4TxPwrOffset_Round
+= 256;
5062 else if (au4TxPwrOffset_Round
> 127){
5063 au4TxPwrOffset_Round
= 127;
5066 auTxPwrOffset_Round
= (UINT8
) au4TxPwrOffset_Round
;
5068 return au4TxPwrOffset_Round
;
5075 static VOID
wlanChangeNvram6620to6628(PUINT_8 pucEFUSE
){
5078 #define EFUSE_CH_OFFSET1_L_MASK_6620 BITS(0,8)
5079 #define EFUSE_CH_OFFSET1_L_SHIFT_6620 0
5080 #define EFUSE_CH_OFFSET1_M_MASK_6620 BITS(9,17)
5081 #define EFUSE_CH_OFFSET1_M_SHIFT_6620 9
5082 #define EFUSE_CH_OFFSET1_H_MASK_6620 BITS(18,26)
5083 #define EFUSE_CH_OFFSET1_H_SHIFT_6620 18
5084 #define EFUSE_CH_OFFSET1_VLD_MASK_6620 BIT(27)
5085 #define EFUSE_CH_OFFSET1_VLD_SHIFT_6620 27
5087 #define EFUSE_CH_OFFSET1_L_MASK_5931 BITS(0,7)
5088 #define EFUSE_CH_OFFSET1_L_SHIFT_5931 0
5089 #define EFUSE_CH_OFFSET1_M_MASK_5931 BITS(8,15)
5090 #define EFUSE_CH_OFFSET1_M_SHIFT_5931 8
5091 #define EFUSE_CH_OFFSET1_H_MASK_5931 BITS(16,23)
5092 #define EFUSE_CH_OFFSET1_H_SHIFT_5931 16
5093 #define EFUSE_CH_OFFSET1_VLD_MASK_5931 BIT(24)
5094 #define EFUSE_CH_OFFSET1_VLD_SHIFT_5931 24
5095 #define EFUSE_ALL_CH_OFFSET1_MASK_5931 BITS(25,27)
5096 #define EFUSE_ALL_CH_OFFSET1_SHIFT_5931 25
5102 INT_16 au2ChOffsetL
,au2ChOffsetM
,au2ChOffsetH
;
5105 au4ChOffset
= *(UINT_32
*)(pucEFUSE
+ 72);
5107 if((au4ChOffset
& EFUSE_CH_OFFSET1_VLD_MASK_6620
) && ((*(UINT_32
*)(pucEFUSE
+ 28)) == 0)) {
5110 au2ChOffsetL
= ((au4ChOffset
& EFUSE_CH_OFFSET1_L_MASK_6620
) >>
5111 EFUSE_CH_OFFSET1_L_SHIFT_6620
);
5113 au2ChOffsetM
= ((au4ChOffset
& EFUSE_CH_OFFSET1_M_MASK_6620
) >>
5114 EFUSE_CH_OFFSET1_M_SHIFT_6620
);
5116 au2ChOffsetH
= ((au4ChOffset
& EFUSE_CH_OFFSET1_H_MASK_6620
) >>
5117 EFUSE_CH_OFFSET1_H_SHIFT_6620
);
5119 au2ChOffsetL
= wlanChangeCodeWord(au2ChOffsetL
);
5120 au2ChOffsetM
= wlanChangeCodeWord(au2ChOffsetM
);
5121 au2ChOffsetH
= wlanChangeCodeWord(au2ChOffsetH
);
5124 au4ChOffset
|= *(UINT_32
*)(pucEFUSE
+ 72)
5125 >> (EFUSE_CH_OFFSET1_VLD_SHIFT_6620
- EFUSE_CH_OFFSET1_VLD_SHIFT_5931
)& EFUSE_CH_OFFSET1_VLD_MASK_5931
;
5129 au4ChOffset
|= ((((UINT_32
)au2ChOffsetL
) << EFUSE_CH_OFFSET1_L_SHIFT_5931
) & EFUSE_CH_OFFSET1_L_MASK_5931
);
5130 au4ChOffset
|= ((((UINT_32
)au2ChOffsetM
) << EFUSE_CH_OFFSET1_M_SHIFT_5931
) & EFUSE_CH_OFFSET1_M_MASK_5931
);
5131 au4ChOffset
|= ((((UINT_32
)au2ChOffsetH
) << EFUSE_CH_OFFSET1_H_SHIFT_5931
) & EFUSE_CH_OFFSET1_H_MASK_5931
);
5133 *((INT_32
*)((pucEFUSE
+ 28))) = au4ChOffset
;
5142 /*----------------------------------------------------------------------------*/
5144 * @brief This function is called to load manufacture data from NVRAM
5145 * if available and valid
5147 * @param prAdapter Pointer of Adapter Data Structure
5148 * @param prRegInfo Pointer of REG_INFO_T
5150 * @return WLAN_STATUS_SUCCESS
5151 * WLAN_STATUS_FAILURE
5153 /*----------------------------------------------------------------------------*/
5155 wlanLoadManufactureData (
5156 IN P_ADAPTER_T prAdapter
,
5157 IN P_REG_INFO_T prRegInfo
5160 #if CFG_SUPPORT_RDD_TEST_MODE
5161 CMD_RDD_CH_T rRddParam
;
5166 /* 1. Version Check */
5167 kalGetConfigurationVersion(prAdapter
->prGlueInfo
,
5168 &(prAdapter
->rVerInfo
.u2Part1CfgOwnVersion
),
5169 &(prAdapter
->rVerInfo
.u2Part1CfgPeerVersion
),
5170 &(prAdapter
->rVerInfo
.u2Part2CfgOwnVersion
),
5171 &(prAdapter
->rVerInfo
.u2Part2CfgPeerVersion
));
5173 #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
5174 if(CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part1CfgPeerVersion
5175 || CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part2CfgPeerVersion
5176 || prAdapter
->rVerInfo
.u2Part1CfgOwnVersion
< CFG_DRV_PEER_VERSION
5177 || prAdapter
->rVerInfo
.u2Part2CfgOwnVersion
< CFG_DRV_PEER_VERSION
) {
5178 return WLAN_STATUS_FAILURE
;
5182 // MT6620 E1/E2 would be ignored directly
5183 if(prAdapter
->rVerInfo
.u2Part1CfgOwnVersion
== 0x0001) {
5184 prRegInfo
->ucTxPwrValid
= 1;
5187 /* 2. Load TX power gain parameters if valid */
5188 if(prRegInfo
->ucTxPwrValid
!= 0) {
5190 nicUpdateTxPower(prAdapter
, (P_CMD_TX_PWR_T
)(&(prRegInfo
->rTxPwr
)));
5194 /* 3. Check if needs to support 5GHz */
5195 //if(prRegInfo->ucEnable5GBand) { // Frank workaround
5197 // check if it is disabled by hardware
5198 if(prAdapter
->fgIsHw5GBandDisabled
5199 || prRegInfo
->ucSupport5GBand
== 0) {
5200 prAdapter
->fgEnable5GBand
= FALSE
;
5203 prAdapter
->fgEnable5GBand
= TRUE
;
5207 prAdapter
->fgEnable5GBand
= FALSE
;
5210 printk("NVRAM 5G Enable(%d) SW_En(%d) HW_Dis(%d)\n",
5211 prRegInfo
->ucEnable5GBand
,
5212 prRegInfo
->ucSupport5GBand
,
5213 prAdapter
->fgIsHw5GBandDisabled
5217 /* 4. Send EFUSE data */
5219 wlanChangeNvram6620to6628(prRegInfo
->aucEFUSE
);
5222 wlanSendSetQueryCmd(prAdapter
,
5223 CMD_ID_SET_PHY_PARAM
,
5229 sizeof(CMD_PHY_PARAM_T
),
5230 (PUINT_8
)(prRegInfo
->aucEFUSE
),
5234 #if CFG_SUPPORT_RDD_TEST_MODE
5235 rRddParam
.ucRddTestMode
= (UINT_8
) prRegInfo
->u4RddTestMode
;
5236 rRddParam
.ucRddShutCh
= (UINT_8
) prRegInfo
->u4RddShutFreq
;
5237 rRddParam
.ucRddStartCh
= (UINT_8
) nicFreq2ChannelNum(prRegInfo
->u4RddStartFreq
);
5238 rRddParam
.ucRddStopCh
= (UINT_8
) nicFreq2ChannelNum(prRegInfo
->u4RddStopFreq
);
5239 rRddParam
.ucRddDfs
= (UINT_8
) prRegInfo
->u4RddDfs
;
5240 prAdapter
->ucRddStatus
= 0;
5241 nicUpdateRddTestMode(prAdapter
, (P_CMD_RDD_CH_T
)(&rRddParam
));
5244 /* 5. Get 16-bits Country Code and Bandwidth */
5245 prAdapter
->rWifiVar
.rConnSettings
.u2CountryCode
=
5246 (((UINT_16
) prRegInfo
->au2CountryCode
[0]) << 8) |
5247 (((UINT_16
) prRegInfo
->au2CountryCode
[1]) & BITS(0,7));
5249 printk("NVRAM CountryCode(0x%x 0x%x)\n",
5250 prRegInfo
->au2CountryCode
[0],
5251 prRegInfo
->au2CountryCode
[1]
5254 #if 0 /* Bandwidth control will be controlled by GUI. 20110930
5255 * So ignore the setting from registry/NVRAM
5257 prAdapter
->rWifiVar
.rConnSettings
.uc2G4BandwidthMode
=
5258 prRegInfo
->uc2G4BwFixed20M
? CONFIG_BW_20M
: CONFIG_BW_20_40M
;
5259 prAdapter
->rWifiVar
.rConnSettings
.uc5GBandwidthMode
=
5260 prRegInfo
->uc5GBwFixed20M
? CONFIG_BW_20M
: CONFIG_BW_20_40M
;
5263 /* 6. Set domain and channel information to chip */
5264 rlmDomainSendCmd(prAdapter
, FALSE
);
5266 /* 7. set band edge tx power if available */
5267 if(prRegInfo
->fg2G4BandEdgePwrUsed
) {
5268 CMD_EDGE_TXPWR_LIMIT_T rCmdEdgeTxPwrLimit
;
5270 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrCCK
5271 = prRegInfo
->cBandEdgeMaxPwrCCK
;
5272 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM20
5273 = prRegInfo
->cBandEdgeMaxPwrOFDM20
;
5274 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM40
5275 = prRegInfo
->cBandEdgeMaxPwrOFDM40
;
5277 printk("NVRAM 2G Bandedge CCK(%d) HT20(%d)HT40(%d)\n",
5278 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrCCK
,
5279 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM20
,
5280 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM40
5283 wlanSendSetQueryCmd(prAdapter
,
5284 CMD_ID_SET_EDGE_TXPWR_LIMIT
,
5290 sizeof(CMD_EDGE_TXPWR_LIMIT_T
),
5291 (PUINT_8
)&rCmdEdgeTxPwrLimit
,
5295 /* 8. set 5G band edge tx power if available (add for 6625) */
5296 if (prAdapter
->fgEnable5GBand
){
5297 #define NVRAM_5G_TX_BANDEDGE_VALID_OFFSET 10
5298 #define NVRAM_5G_TX_BANDEDGE_OFDM20_OFFSET 11
5299 #define NVRAM_5G_TX_BANDEDGE_OFDM40_OFFSET 12
5301 if(prRegInfo
->aucEFUSE
[NVRAM_5G_TX_BANDEDGE_VALID_OFFSET
]) {
5302 CMD_EDGE_TXPWR_LIMIT_T rCmdEdgeTxPwrLimit
;
5304 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM20
5305 = prRegInfo
->aucEFUSE
[NVRAM_5G_TX_BANDEDGE_OFDM20_OFFSET
];
5306 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM40
5307 = prRegInfo
->aucEFUSE
[NVRAM_5G_TX_BANDEDGE_OFDM40_OFFSET
];
5309 printk("NVRAM 5G Bandedge HT20(%d)HT40(%d)\n",
5310 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM20
,
5311 rCmdEdgeTxPwrLimit
.cBandEdgeMaxPwrOFDM40
5314 wlanSendSetQueryCmd(prAdapter
,
5315 CMD_ID_SET_5G_EDGE_TXPWR_LIMIT
,
5321 sizeof(CMD_EDGE_TXPWR_LIMIT_T
),
5322 (PUINT_8
)&rCmdEdgeTxPwrLimit
,
5327 /* 9. set RSSI compensation */
5328 //printk("[frank] RSSI valid(%d) 2G(%d) 5G(%d)",prRegInfo->fgRssiCompensationValidbit,prRegInfo->uc2GRssiCompensation,prRegInfo->uc5GRssiCompensation);
5329 if (prRegInfo
->fgRssiCompensationValidbit
){
5330 CMD_RSSI_COMPENSATE_T rCmdRssiCompensate
;
5331 rCmdRssiCompensate
.uc2GRssiCompensation
= prRegInfo
->uc2GRssiCompensation
;
5332 rCmdRssiCompensate
.uc5GRssiCompensation
= prRegInfo
->uc5GRssiCompensation
;
5334 printk("NVRAM RSSI Comp. 2G(%d)5G(%d)\n",
5335 rCmdRssiCompensate
.uc2GRssiCompensation
,
5336 rCmdRssiCompensate
.uc5GRssiCompensation
5338 wlanSendSetQueryCmd(prAdapter
,
5339 CMD_ID_SET_RSSI_COMPENSATE
,
5345 sizeof(CMD_RSSI_COMPENSATE_T
),
5346 (PUINT_8
)&rCmdRssiCompensate
,
5350 /* 10. notify FW Band Support 5G */
5351 if (prAdapter
->fgEnable5GBand
){
5352 CMD_BAND_SUPPORT_T rCmdBandSupport
;
5353 rCmdBandSupport
.uc5GBandSupport
= TRUE
;
5354 printk("NVRAM 5G BandSupport\n");
5355 wlanSendSetQueryCmd(prAdapter
,
5356 CMD_ID_SET_BAND_SUPPORT
,
5362 sizeof(CMD_BAND_SUPPORT_T
),
5363 (PUINT_8
)&rCmdBandSupport
,
5369 return WLAN_STATUS_SUCCESS
;
5373 /*----------------------------------------------------------------------------*/
5375 * @brief This function is called to check
5376 * Media Stream Mode is set to non-default value or not,
5377 * and clear to default value if above criteria is met
5379 * @param prAdapter Pointer of Adapter Data Structure
5382 * The media stream mode was non-default value and has been reset
5384 * The media stream mode is default value
5386 /*----------------------------------------------------------------------------*/
5388 wlanResetMediaStreamMode(
5389 IN P_ADAPTER_T prAdapter
5394 if(prAdapter
->rWlanInfo
.eLinkAttr
.ucMediaStreamMode
!= 0) {
5395 prAdapter
->rWlanInfo
.eLinkAttr
.ucMediaStreamMode
= 0;
5405 /*----------------------------------------------------------------------------*/
5407 * @brief This function is called to check if any pending timer has expired
5409 * @param prAdapter Pointer of Adapter Data Structure
5411 * @return WLAN_STATUS_SUCCESS
5413 /*----------------------------------------------------------------------------*/
5415 wlanTimerTimeoutCheck(
5416 IN P_ADAPTER_T prAdapter
5421 /* check timer status */
5422 cnmTimerDoTimeOutCheck(prAdapter
);
5424 return WLAN_STATUS_SUCCESS
;
5428 /*----------------------------------------------------------------------------*/
5430 * @brief This function is called to check if any pending mailbox message
5433 * @param prAdapter Pointer of Adapter Data Structure
5435 * @return WLAN_STATUS_SUCCESS
5437 /*----------------------------------------------------------------------------*/
5439 wlanProcessMboxMessage(
5440 IN P_ADAPTER_T prAdapter
5447 for(i
= 0 ; i
< MBOX_ID_TOTAL_NUM
; i
++) { /* MBOX_ID_TOTAL_NUM = 1 */
5448 mboxRcvAllMsg(prAdapter
, (ENUM_MBOX_ID_T
)i
);
5451 return WLAN_STATUS_SUCCESS
;
5455 /*----------------------------------------------------------------------------*/
5457 * @brief This function is called to enqueue a single TX packet into CORE
5459 * @param prAdapter Pointer of Adapter Data Structure
5460 * prNativePacket Pointer of Native Packet
5462 * @return WLAN_STATUS_SUCCESS
5463 * WLAN_STATUS_RESOURCES
5464 * WLAN_STATUS_INVALID_PACKET
5466 /*----------------------------------------------------------------------------*/
5468 wlanEnqueueTxPacket (
5469 IN P_ADAPTER_T prAdapter
,
5470 IN P_NATIVE_PACKET prNativePacket
5473 P_TX_CTRL_T prTxCtrl
;
5474 P_MSDU_INFO_T prMsduInfo
;
5476 KAL_SPIN_LOCK_DECLARATION();
5480 prTxCtrl
= &prAdapter
->rTxCtrl
;
5482 /* get a free packet header */
5483 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_MSDU_INFO_LIST
);
5484 QUEUE_REMOVE_HEAD(&prTxCtrl
->rFreeMsduInfoList
, prMsduInfo
, P_MSDU_INFO_T
);
5485 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_MSDU_INFO_LIST
);
5487 if(prMsduInfo
== NULL
) {
5488 return WLAN_STATUS_RESOURCES
;
5491 prMsduInfo
->eSrc
= TX_PACKET_OS
;
5493 if(nicTxFillMsduInfo(prAdapter
,
5495 prNativePacket
) == FALSE
) { // packet is not extractable
5498 kalSendComplete(prAdapter
->prGlueInfo
,
5500 WLAN_STATUS_INVALID_PACKET
);
5502 nicTxReturnMsduInfo(prAdapter
, prMsduInfo
);
5504 return WLAN_STATUS_INVALID_PACKET
;
5508 nicTxEnqueueMsdu(prAdapter
, prMsduInfo
);
5510 return WLAN_STATUS_SUCCESS
;
5516 /*----------------------------------------------------------------------------*/
5518 * @brief This function is called to flush pending TX packets in CORE
5520 * @param prAdapter Pointer of Adapter Data Structure
5522 * @return WLAN_STATUS_SUCCESS
5524 /*----------------------------------------------------------------------------*/
5526 wlanFlushTxPendingPackets(
5527 IN P_ADAPTER_T prAdapter
5532 return nicTxFlush(prAdapter
);
5536 /*----------------------------------------------------------------------------*/
5538 * \brief this function sends pending MSDU_INFO_T to MT6620
5540 * @param prAdapter Pointer to the Adapter structure.
5541 * @param pfgHwAccess Pointer for tracking LP-OWN status
5543 * @retval WLAN_STATUS_SUCCESS Reset is done successfully.
5545 /*----------------------------------------------------------------------------*/
5547 wlanTxPendingPackets (
5548 IN P_ADAPTER_T prAdapter
,
5549 IN OUT PBOOLEAN pfgHwAccess
5552 P_TX_CTRL_T prTxCtrl
;
5553 P_MSDU_INFO_T prMsduInfo
;
5555 KAL_SPIN_LOCK_DECLARATION();
5558 prTxCtrl
= &prAdapter
->rTxCtrl
;
5560 ASSERT(pfgHwAccess
);
5562 // <1> dequeue packets by txDequeuTxPackets()
5563 /* Note: prMsduInfo is a packet list queue */
5564 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_QM_TX_QUEUE
);
5565 prMsduInfo
= qmDequeueTxPackets(prAdapter
, &prTxCtrl
->rTc
);
5566 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_QM_TX_QUEUE
);
5568 if(prMsduInfo
!= NULL
) {
5569 if(kalIsCardRemoved(prAdapter
->prGlueInfo
) == FALSE
) {
5570 /* <2> Acquire LP-OWN if necessary */
5571 if(*pfgHwAccess
== FALSE
) {
5572 *pfgHwAccess
= TRUE
;
5574 wlanAcquirePowerControl(prAdapter
);
5577 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
5578 if(prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
5579 nicDisableClockGating(prAdapter
);
5582 // <3> send packet"s" to HIF
5583 nicTxMsduInfoList(prAdapter
, prMsduInfo
);
5585 // <4> update TC by txAdjustTcQuotas()
5586 nicTxAdjustTcq(prAdapter
);
5590 /* free the packet */
5591 wlanProcessQueuedMsduInfo(prAdapter
, prMsduInfo
);
5595 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
5596 if(prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
5597 nicEnableClockGating(prAdapter
);
5601 return WLAN_STATUS_SUCCESS
;
5605 /*----------------------------------------------------------------------------*/
5607 * @brief This function is called to acquire power control from firmware
5609 * @param prAdapter Pointer of Adapter Data Structure
5611 * @return WLAN_STATUS_SUCCESS
5613 /*----------------------------------------------------------------------------*/
5615 wlanAcquirePowerControl(
5616 IN P_ADAPTER_T prAdapter
5622 ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter
);
5624 /* Reset sleepy state */ /* no use */
5625 if(prAdapter
->fgWiFiInSleepyState
== TRUE
) {
5626 prAdapter
->fgWiFiInSleepyState
= FALSE
;
5629 return WLAN_STATUS_SUCCESS
;
5633 /*----------------------------------------------------------------------------*/
5635 * @brief This function is called to release power control to firmware
5637 * @param prAdapter Pointer of Adapter Data Structure
5639 * @return WLAN_STATUS_SUCCESS
5641 /*----------------------------------------------------------------------------*/
5643 wlanReleasePowerControl(
5644 IN P_ADAPTER_T prAdapter
5650 RECLAIM_POWER_CONTROL_TO_PM(prAdapter
, FALSE
);
5652 return WLAN_STATUS_SUCCESS
;
5656 /*----------------------------------------------------------------------------*/
5658 * @brief This function is called to report currently pending TX frames count
5659 * (command packets are not included)
5661 * @param prAdapter Pointer of Adapter Data Structure
5663 * @return number of pending TX frames
5665 /*----------------------------------------------------------------------------*/
5667 wlanGetTxPendingFrameCount (
5668 IN P_ADAPTER_T prAdapter
5671 P_TX_CTRL_T prTxCtrl
;
5675 prTxCtrl
= &prAdapter
->rTxCtrl
;
5677 /* number in prTxQueue + number in RX forward */
5678 u4Num
= kalGetTxPendingFrameCount(prAdapter
->prGlueInfo
) + (UINT_32
)(prTxCtrl
->i4PendingFwdFrameCount
);
5684 /*----------------------------------------------------------------------------*/
5686 * @brief This function is to report current ACPI state
5688 * @param prAdapter Pointer of Adapter Data Structure
5690 * @return ACPI_STATE_D0 Normal Operation Mode
5691 * ACPI_STATE_D3 Suspend Mode
5693 /*----------------------------------------------------------------------------*/
5696 IN P_ADAPTER_T prAdapter
5701 return prAdapter
->rAcpiState
;
5705 /*----------------------------------------------------------------------------*/
5707 * @brief This function is to update current ACPI state only
5709 * @param prAdapter Pointer of Adapter Data Structure
5710 * @param ePowerState ACPI_STATE_D0 Normal Operation Mode
5711 * ACPI_STATE_D3 Suspend Mode
5715 /*----------------------------------------------------------------------------*/
5718 IN P_ADAPTER_T prAdapter
,
5719 IN ENUM_ACPI_STATE_T ePowerState
5723 ASSERT(ePowerState
<= ACPI_STATE_D3
);
5725 prAdapter
->rAcpiState
= ePowerState
;
5731 /*----------------------------------------------------------------------------*/
5733 * @brief This function is to query ECO version from HIFSYS CR
5735 * @param prAdapter Pointer of Adapter Data Structure
5737 * @return zero Unable to retrieve ECO version information
5738 * non-zero ECO version (1-based)
5740 /*----------------------------------------------------------------------------*/
5743 IN P_ADAPTER_T prAdapter
5748 if(nicVerifyChipID(prAdapter
) == TRUE
) {
5749 return (prAdapter
->ucRevID
+ 1);
5757 /*----------------------------------------------------------------------------*/
5759 * @brief This function is to setting the default Tx Power configuration
5761 * @param prAdapter Pointer of Adapter Data Structure
5763 * @return zero Unable to retrieve ECO version information
5764 * non-zero ECO version (1-based)
5766 /*----------------------------------------------------------------------------*/
5769 IN P_ADAPTER_T prAdapter
5773 P_GLUE_INFO_T prGlueInfo
= prAdapter
->prGlueInfo
;
5774 P_SET_TXPWR_CTRL_T prTxpwr
;
5778 prTxpwr
= &prGlueInfo
->rTxPwr
;
5780 prTxpwr
->c2GLegacyStaPwrOffset
= 0;
5781 prTxpwr
->c2GHotspotPwrOffset
= 0;
5782 prTxpwr
->c2GP2pPwrOffset
= 0;
5783 prTxpwr
->c2GBowPwrOffset
= 0;
5784 prTxpwr
->c5GLegacyStaPwrOffset
= 0;
5785 prTxpwr
->c5GHotspotPwrOffset
= 0;
5786 prTxpwr
->c5GP2pPwrOffset
= 0;
5787 prTxpwr
->c5GBowPwrOffset
= 0;
5788 prTxpwr
->ucConcurrencePolicy
= 0;
5790 prTxpwr
->acReserved1
[i
] = 0;
5793 prTxpwr
->acTxPwrLimit2G
[i
] = 63;
5796 prTxpwr
->acTxPwrLimit5G
[i
] = 63;
5799 prTxpwr
->acReserved2
[i
] = 0;
5804 /*----------------------------------------------------------------------------*/
5806 * @brief This function is to
5807 * set preferred band configuration corresponding to network type
5809 * @param prAdapter Pointer of Adapter Data Structure
5810 * @param eBand Given band
5811 * @param eNetTypeIndex Given Network Type
5815 /*----------------------------------------------------------------------------*/
5817 wlanSetPreferBandByNetwork (
5818 IN P_ADAPTER_T prAdapter
,
5819 IN ENUM_BAND_T eBand
,
5820 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
5824 ASSERT(eBand
<= BAND_NUM
);
5825 ASSERT(eNetTypeIndex
<= NETWORK_TYPE_INDEX_NUM
);
5827 /* 1. set prefer band according to network type */
5828 prAdapter
->aePreferBand
[eNetTypeIndex
] = eBand
;
5830 /* 2. remove buffered BSS descriptors correspondingly */
5831 if(eBand
== BAND_2G4
) {
5832 scanRemoveBssDescByBandAndNetwork(prAdapter
, BAND_5G
, eNetTypeIndex
);
5834 else if(eBand
== BAND_5G
) {
5835 scanRemoveBssDescByBandAndNetwork(prAdapter
, BAND_2G4
, eNetTypeIndex
);
5842 /*----------------------------------------------------------------------------*/
5844 * @brief This function is to
5845 * get channel information corresponding to specified network type
5847 * @param prAdapter Pointer of Adapter Data Structure
5848 * @param eNetTypeIndex Given Network Type
5850 * @return channel number
5852 /*----------------------------------------------------------------------------*/
5854 wlanGetChannelNumberByNetwork (
5855 IN P_ADAPTER_T prAdapter
,
5856 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
5859 P_BSS_INFO_T prBssInfo
;
5862 ASSERT(eNetTypeIndex
<= NETWORK_TYPE_INDEX_NUM
);
5864 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
5866 return prBssInfo
->ucPrimaryChannel
;
5870 /*----------------------------------------------------------------------------*/
5872 * @brief This function is to
5873 * get BSS descriptor information corresponding to specified network type
5875 * @param prAdapter Pointer of Adapter Data Structure
5876 * @param eNetTypeIndex Given Network Type
5878 * @return pointer to BSS_DESC_T
5880 /*----------------------------------------------------------------------------*/
5882 wlanGetTargetBssDescByNetwork (
5883 IN P_ADAPTER_T prAdapter
,
5884 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
5888 ASSERT(eNetTypeIndex
<= NETWORK_TYPE_INDEX_NUM
);
5890 switch(eNetTypeIndex
) {
5891 case NETWORK_TYPE_AIS_INDEX
:
5892 return prAdapter
->rWifiVar
.rAisFsmInfo
.prTargetBssDesc
;
5894 case NETWORK_TYPE_P2P_INDEX
:
5897 case NETWORK_TYPE_BOW_INDEX
:
5898 return prAdapter
->rWifiVar
.rBowFsmInfo
.prTargetBssDesc
;
5906 /*----------------------------------------------------------------------------*/
5908 * @brief This function is to
5909 * check unconfigured system properties and generate related message on
5910 * scan list to notify users
5912 * @param prAdapter Pointer of Adapter Data Structure
5914 * @return WLAN_STATUS_SUCCESS
5916 /*----------------------------------------------------------------------------*/
5918 wlanCheckSystemConfiguration (
5919 IN P_ADAPTER_T prAdapter
5922 #if (CFG_NVRAM_EXISTENCE_CHECK == 1) || (CFG_SW_NVRAM_VERSION_CHECK == 1)
5923 const UINT_8 aucZeroMacAddr
[] = NULL_MAC_ADDR
;
5924 const UINT_8 aucBCAddr
[] = BC_MAC_ADDR
;
5925 BOOLEAN fgIsConfExist
= TRUE
;
5926 BOOLEAN fgGenErrMsg
= FALSE
;
5927 P_REG_INFO_T prRegInfo
= NULL
;
5928 P_WLAN_BEACON_FRAME_T prBeacon
= NULL
;
5929 P_IE_SSID_T prSsid
= NULL
;
5930 UINT_32 u4ErrCode
= 0;
5931 UINT_8 aucErrMsg
[32];
5933 PARAM_802_11_CONFIG_T rConfiguration
;
5934 PARAM_RATES_EX rSupportedRates
;
5937 DEBUGFUNC("wlanCheckSystemConfiguration");
5941 #if (CFG_NVRAM_EXISTENCE_CHECK == 1)
5942 if(kalIsConfigurationExist(prAdapter
->prGlueInfo
) == FALSE
) {
5943 fgIsConfExist
= FALSE
;
5948 #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
5949 prRegInfo
= kalGetConfiguration(prAdapter
->prGlueInfo
);
5951 if(fgIsConfExist
== TRUE
&&
5952 (CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part1CfgPeerVersion
5953 || CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part2CfgPeerVersion
5954 || prAdapter
->rVerInfo
.u2Part1CfgOwnVersion
< CFG_DRV_PEER_VERSION
5955 || prAdapter
->rVerInfo
.u2Part2CfgOwnVersion
< CFG_DRV_PEER_VERSION
/* NVRAM */
5956 || CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2FwPeerVersion
5957 || prAdapter
->rVerInfo
.u2FwOwnVersion
< CFG_DRV_PEER_VERSION
5958 || (prAdapter
->fgIsEmbbededMacAddrValid
== FALSE
&&
5959 (IS_BMCAST_MAC_ADDR(prRegInfo
->aucMacAddr
)
5960 || EQUAL_MAC_ADDR(aucZeroMacAddr
, prRegInfo
->aucMacAddr
)))
5961 || prRegInfo
->ucTxPwrValid
== 0)) {
5966 if(fgGenErrMsg
== TRUE
) {
5967 prBeacon
= cnmMemAlloc(prAdapter
, RAM_TYPE_BUF
, sizeof(WLAN_BEACON_FRAME_T
) + sizeof(IE_SSID_T
));
5970 kalMemZero(prBeacon
, sizeof(WLAN_BEACON_FRAME_T
) + sizeof(IE_SSID_T
));
5972 // prBeacon initialization
5973 prBeacon
->u2FrameCtrl
= MAC_FRAME_BEACON
;
5974 COPY_MAC_ADDR(prBeacon
->aucDestAddr
, aucBCAddr
);
5975 COPY_MAC_ADDR(prBeacon
->aucSrcAddr
, aucZeroMacAddr
);
5976 COPY_MAC_ADDR(prBeacon
->aucBSSID
, aucZeroMacAddr
);
5977 prBeacon
->u2BeaconInterval
= 100;
5978 prBeacon
->u2CapInfo
= CAP_INFO_ESS
;
5980 // prSSID initialization
5981 prSsid
= (P_IE_SSID_T
)(&prBeacon
->aucInfoElem
[0]);
5982 prSsid
->ucId
= ELEM_ID_SSID
;
5984 // rConfiguration initialization
5985 rConfiguration
.u4Length
= sizeof(PARAM_802_11_CONFIG_T
);
5986 rConfiguration
.u4BeaconPeriod
= 100;
5987 rConfiguration
.u4ATIMWindow
= 1;
5988 rConfiguration
.u4DSConfig
= 2412;
5989 rConfiguration
.rFHConfig
.u4Length
= sizeof(PARAM_802_11_CONFIG_FH_T
);
5991 // rSupportedRates initialization
5992 kalMemZero(rSupportedRates
, sizeof(PARAM_RATES_EX
));
5995 #if (CFG_NVRAM_EXISTENCE_CHECK == 1)
5996 #define NVRAM_ERR_MSG "NVRAM WARNING: Err = 0x01"
5997 if(kalIsConfigurationExist(prAdapter
->prGlueInfo
) == FALSE
) {
5998 COPY_SSID(prSsid
->aucSSID
,
6001 strlen(NVRAM_ERR_MSG
));
6003 kalIndicateBssInfo(prAdapter
->prGlueInfo
,
6005 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
) + OFFSET_OF(IE_SSID_T
, aucSSID
) + prSsid
->ucLength
,
6008 COPY_SSID(rSsid
.aucSsid
, rSsid
.u4SsidLen
, NVRAM_ERR_MSG
, strlen(NVRAM_ERR_MSG
));
6009 nicAddScanResult(prAdapter
,
6014 PARAM_NETWORK_TYPE_FH
,
6018 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
) + OFFSET_OF(IE_SSID_T
, aucSSID
) + prSsid
->ucLength
- WLAN_MAC_MGMT_HEADER_LEN
,
6019 (PUINT_8
)((ULONG
)(prBeacon
) + WLAN_MAC_MGMT_HEADER_LEN
));
6023 #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
6024 #define VER_ERR_MSG "NVRAM WARNING: Err = 0x%02X"
6025 if(fgIsConfExist
== TRUE
) {
6026 if((CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part1CfgPeerVersion
6027 || CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2Part2CfgPeerVersion
6028 || prAdapter
->rVerInfo
.u2Part1CfgOwnVersion
< CFG_DRV_PEER_VERSION
6029 || prAdapter
->rVerInfo
.u2Part2CfgOwnVersion
< CFG_DRV_PEER_VERSION
/* NVRAM */
6030 || CFG_DRV_OWN_VERSION
< prAdapter
->rVerInfo
.u2FwPeerVersion
6031 || prAdapter
->rVerInfo
.u2FwOwnVersion
< CFG_DRV_PEER_VERSION
)) {
6032 u4ErrCode
|= NVRAM_ERROR_VERSION_MISMATCH
;
6036 if(prRegInfo
->ucTxPwrValid
== 0) {
6037 u4ErrCode
|= NVRAM_ERROR_INVALID_TXPWR
;
6040 if(prAdapter
->fgIsEmbbededMacAddrValid
== FALSE
&&
6041 (IS_BMCAST_MAC_ADDR(prRegInfo
->aucMacAddr
) || EQUAL_MAC_ADDR(aucZeroMacAddr
, prRegInfo
->aucMacAddr
))) {
6042 u4ErrCode
|= NVRAM_ERROR_INVALID_MAC_ADDR
;
6045 if(u4ErrCode
!= 0) {
6046 sprintf(aucErrMsg
, VER_ERR_MSG
, (unsigned int)u4ErrCode
);
6047 COPY_SSID(prSsid
->aucSSID
,
6052 kalIndicateBssInfo(prAdapter
->prGlueInfo
,
6054 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
) + OFFSET_OF(IE_SSID_T
, aucSSID
) + prSsid
->ucLength
,
6058 COPY_SSID(rSsid
.aucSsid
, rSsid
.u4SsidLen
, NVRAM_ERR_MSG
, strlen(NVRAM_ERR_MSG
));
6059 nicAddScanResult(prAdapter
,
6064 PARAM_NETWORK_TYPE_FH
,
6068 OFFSET_OF(WLAN_BEACON_FRAME_T
, aucInfoElem
) + OFFSET_OF(IE_SSID_T
, aucSSID
) + prSsid
->ucLength
- WLAN_MAC_MGMT_HEADER_LEN
,
6069 (PUINT_8
)((ULONG
)(prBeacon
) + WLAN_MAC_MGMT_HEADER_LEN
));
6074 if(fgGenErrMsg
== TRUE
) {
6075 cnmMemFree(prAdapter
, prBeacon
);
6078 return WLAN_STATUS_SUCCESS
;
6083 wlanoidQueryStaStatistics (
6084 IN P_ADAPTER_T prAdapter
,
6085 IN PVOID pvQueryBuffer
,
6086 IN UINT_32 u4QueryBufferLen
,
6087 OUT PUINT_32 pu4QueryInfoLen
6090 WLAN_STATUS rResult
= WLAN_STATUS_FAILURE
;
6091 P_STA_RECORD_T prStaRec
, prTempStaRec
;
6092 P_PARAM_GET_STA_STATISTICS prQueryStaStatistics
;
6094 P_QUE_MGT_T prQM
= &prAdapter
->rQM
;
6095 CMD_GET_STA_STATISTICS_T rQueryCmdStaStatistics
;
6099 ASSERT(pvQueryBuffer
);
6102 if ((prAdapter
== NULL
) || (pu4QueryInfoLen
== NULL
)) {
6106 if ((u4QueryBufferLen
) && (pvQueryBuffer
== NULL
)) {
6110 if (u4QueryBufferLen
< sizeof(PARAM_GET_STA_STA_STATISTICS
)) {
6111 *pu4QueryInfoLen
= sizeof(PARAM_GET_STA_STA_STATISTICS
);
6112 rResult
= WLAN_STATUS_BUFFER_TOO_SHORT
;
6116 prQueryStaStatistics
= (P_PARAM_GET_STA_STATISTICS
)pvQueryBuffer
;
6117 *pu4QueryInfoLen
= sizeof(PARAM_GET_STA_STA_STATISTICS
);
6119 //4 5. Get driver global QM counter
6120 for(ucIdx
= TC0_INDEX
; ucIdx
<= TC3_INDEX
; ucIdx
++) {
6121 prQueryStaStatistics
->au4TcAverageQueLen
[ucIdx
] = prQM
->au4AverageQueLen
[ucIdx
];
6122 prQueryStaStatistics
->au4TcCurrentQueLen
[ucIdx
] = prQM
->au4CurrentTcResource
[ucIdx
];
6125 //4 2. Get StaRec by MAC address
6128 for(ucStaRecIdx
= 0; ucStaRecIdx
< CFG_NUM_OF_STA_RECORD
; ucStaRecIdx
++){
6129 prTempStaRec
= &(prAdapter
->arStaRec
[ucStaRecIdx
]);
6130 if(prTempStaRec
->fgIsValid
&& prTempStaRec
->fgIsInUse
){
6131 if(EQUAL_MAC_ADDR(prTempStaRec
->aucMacAddr
, prQueryStaStatistics
->aucMacAddr
)){
6132 prStaRec
= prTempStaRec
;
6139 rResult
= WLAN_STATUS_INVALID_DATA
;
6143 prQueryStaStatistics
->u4Flag
|= BIT(0);
6145 #if CFG_ENABLE_PER_STA_STATISTICS
6146 //4 3. Get driver statistics
6147 prQueryStaStatistics
->u4TxTotalCount
= prStaRec
->u4TotalTxPktsNumber
;
6148 prQueryStaStatistics
->u4TxExceedThresholdCount
= prStaRec
->u4ThresholdCounter
;
6149 prQueryStaStatistics
->u4TxMaxTime
= prStaRec
->u4MaxTxPktsTime
;
6150 if(prStaRec
->u4TotalTxPktsNumber
) {
6151 prQueryStaStatistics
->u4TxAverageProcessTime
= (prStaRec
->u4TotalTxPktsTime
/ prStaRec
->u4TotalTxPktsNumber
);
6154 prQueryStaStatistics
->u4TxAverageProcessTime
= 0;
6157 for(ucIdx
= TC0_INDEX
; ucIdx
<= TC3_INDEX
; ucIdx
++) {
6158 prQueryStaStatistics
->au4TcResourceEmptyCount
[ucIdx
] = prQM
->au4QmTcResourceEmptyCounter
[prStaRec
->ucNetTypeIndex
][ucIdx
];
6160 prQM
->au4QmTcResourceEmptyCounter
[prStaRec
->ucNetTypeIndex
][ucIdx
] = 0;
6163 //4 4.1 Reset statistics
6164 prStaRec
->u4ThresholdCounter
= 0;
6165 prStaRec
->u4TotalTxPktsNumber
= 0;
6166 prStaRec
->u4TotalTxPktsTime
= 0;
6167 prStaRec
->u4MaxTxPktsTime
= 0;
6170 for(ucIdx
= TC0_INDEX
; ucIdx
<= TC3_INDEX
; ucIdx
++) {
6171 prQueryStaStatistics
->au4TcQueLen
[ucIdx
] = prStaRec
->arTxQueue
[ucIdx
].u4NumElem
;
6174 rResult
= WLAN_STATUS_SUCCESS
;
6176 //4 6. Ensure FW supports get station link status
6177 if(prAdapter
->u4FwCompileFlag0
& COMPILE_FLAG0_GET_STA_LINK_STATUS
) {
6179 rQueryCmdStaStatistics
.ucIndex
= prStaRec
->ucIndex
;
6180 COPY_MAC_ADDR(rQueryCmdStaStatistics
.aucMacAddr
, prQueryStaStatistics
->aucMacAddr
);
6181 rQueryCmdStaStatistics
.ucReadClear
= TRUE
;
6183 rResult
= wlanSendSetQueryCmd(prAdapter
,
6184 CMD_ID_GET_STA_STATISTICS
,
6188 nicCmdEventQueryStaStatistics
,
6189 nicOidCmdTimeoutCommon
,
6190 sizeof(CMD_GET_STA_STATISTICS_T
),
6191 (PUINT_8
)&rQueryCmdStaStatistics
,
6196 prQueryStaStatistics
->u4Flag
|= BIT(1);
6199 rResult
= WLAN_STATUS_NOT_SUPPORTED
;
6205 } /* wlanoidQueryP2pVersion */
6206 #if CFG_AUTO_CHANNEL_SEL_SUPPORT
6208 //4 Auto Channel Selection
6210 wlanoidQueryACSChannelList (
6211 IN P_ADAPTER_T prAdapter
,
6212 IN PVOID pvQueryBuffer
,
6213 IN UINT_32 u4QueryBufferLen
,
6214 OUT PUINT_32 pu4QueryInfoLen
6217 WLAN_STATUS rResult
= WLAN_STATUS_FAILURE
;
6218 P_STA_RECORD_T prStaRec
, prTempStaRec
;
6219 P_PARAM_GET_CHN_LOAD prQueryChnLoad
;
6220 P_PARAM_GET_LTE_MODE prLteMode
;
6222 P_QUE_MGT_T prQM
= &prAdapter
->rQM
;
6223 CMD_GET_CHN_LOAD_T rQueryCmdStaStatistics
;
6226 P_PARAM_CHN_LOAD_INFO prChnLoad
;
6228 DBGLOG(P2P
, INFO
,("[Auto Channel]wlanoidQueryACSChannelList\n"));
6230 ASSERT(pvQueryBuffer
);
6233 if ((prAdapter
== NULL
) || (pu4QueryInfoLen
== NULL
)) {
6237 if ((u4QueryBufferLen
) && (pvQueryBuffer
== NULL
)) {
6241 prLteMode
= (P_PARAM_GET_LTE_MODE
)pvQueryBuffer
;
6242 //4 2.Check AP Numbers
6243 for(ucIdx
=0;ucIdx
<MAX_AUTO_CHAL_NUM
;ucIdx
++)
6245 prChnLoad
= (P_PARAM_CHN_LOAD_INFO
)&(prAdapter
->rWifiVar
.rChnLoadInfo
.rEachChnLoad
[ucIdx
]);
6247 DBGLOG(P2P
, INFO
,("[Auto Channel] AP Num: Chn[%d]=%d\n",ucIdx
+1,prChnLoad
->u2APNum
));
6249 //4 3. Ensure FW supports get station link status
6251 if(prAdapter
->u4FwCompileFlag0
& COMPILE_FLAG0_GET_STA_LINK_STATUS
) {
6252 printk("wlanoidQueryACSChannelList\n");
6253 CMD_ACCESS_REG rCmdAccessReg
;
6254 rCmdAccessReg
.u4Address
= 0xFFFFFFFF;
6255 rCmdAccessReg
.u4Data
= ELEM_RM_TYPE_ACS_CHN
;
6257 rResult
=wlanSendSetQueryCmd(prAdapter
,
6262 nicCmdEventQueryChannelLoad
,//The handler to receive firmware notification
6263 nicOidCmdTimeoutCommon
,
6264 sizeof(CMD_ACCESS_REG
),
6265 (PUINT_8
)&rCmdAccessReg
,
6270 prQueryChnLoad
->u4Flag
|= BIT(1);
6273 rResult
= WLAN_STATUS_NOT_SUPPORTED
;
6276 //4 4.Avoid LTE Channels
6277 prLteMode
->u4Flags
&= BIT(0);
6278 /*if(prAdapter->u4FwCompileFlag0 & COMPILE_FLAG0_GET_STA_LINK_STATUS)*/ {
6281 CMD_GET_LTE_SAFE_CHN_T rQuery_LTE_SAFE_CHN
;
6282 rResult
=wlanSendSetQueryCmd(prAdapter
,
6287 nicCmdEventQueryLTESafeChn
,//The handler to receive firmware notification
6288 nicOidCmdTimeoutCommon
,
6289 sizeof(CMD_GET_LTE_SAFE_CHN_T
),
6290 (PUINT_8
)&rQuery_LTE_SAFE_CHN
,
6295 DBGLOG(P2P
, INFO
,("[Auto Channel] Get LTE Channels\n"));
6296 prLteMode
->u4Flags
|= BIT(1);
6301 rResult = WLAN_STATUS_NOT_SUPPORTED;
6305 //4 5. Calc the value
6307 DBGLOG(P2P
, INFO
,("[Auto Channel] Candidated Channels\n"));
6311 } /* wlanoidQueryP2pVersion */
6314 P_WLAN_CFG_ENTRY_T
wlanCfgGetEntry(IN P_ADAPTER_T prAdapter
, const PCHAR pucKey
)
6317 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6318 P_WLAN_CFG_T prWlanCfg
;
6320 prWlanCfg
= prAdapter
->prWlanCfg
;
6325 prWlanCfgEntry
= NULL
;
6327 for (i
= 0; i
< WLAN_CFG_ENTRY_NUM_MAX
; i
++) {
6328 prWlanCfgEntry
= &prWlanCfg
->arWlanCfgBuf
[i
];
6329 if (prWlanCfgEntry
->aucKey
[0] != '\0') {
6331 ("compare key %s saved key %s\n", pucKey
, prWlanCfgEntry
->aucKey
));
6332 if (kalStrniCmp(pucKey
, prWlanCfgEntry
->aucKey
, WLAN_CFG_KEY_LEN_MAX
- 1) ==
6334 return prWlanCfgEntry
;
6339 DBGLOG(INIT
, TRACE
, ("wifi config there is no entry \'%s\'\n", pucKey
));
6345 wlanCfgGet(IN P_ADAPTER_T prAdapter
,
6346 const PCHAR pucKey
, PCHAR pucValue
, PCHAR pucValueDef
, UINT_32 u4Flags
)
6349 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6350 P_WLAN_CFG_T prWlanCfg
;
6351 prWlanCfg
= prAdapter
->prWlanCfg
;
6356 /* Find the exist */
6357 prWlanCfgEntry
= wlanCfgGetEntry(prAdapter
, pucKey
);
6359 if (prWlanCfgEntry
) {
6360 kalStrnCpy(pucValue
, prWlanCfgEntry
->aucValue
, WLAN_CFG_VALUE_LEN_MAX
- 1);
6361 return WLAN_STATUS_SUCCESS
;
6364 kalStrnCpy(pucValue
, pucValueDef
, WLAN_CFG_VALUE_LEN_MAX
- 1);
6365 return WLAN_STATUS_FAILURE
;
6370 UINT_32
wlanCfgGetUint32(IN P_ADAPTER_T prAdapter
, const PCHAR pucKey
, UINT_32 u4ValueDef
)
6372 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6373 P_WLAN_CFG_T prWlanCfg
;
6375 prWlanCfg
= prAdapter
->prWlanCfg
;
6380 /* Find the exist */
6381 prWlanCfgEntry
= wlanCfgGetEntry(prAdapter
, pucKey
);
6383 if (prWlanCfgEntry
) {
6384 u4Ret
= kalStrtoul(prWlanCfgEntry
->aucValue
, NULL
, 0);
6389 INT_32
wlanCfgGetInt32(IN P_ADAPTER_T prAdapter
, const PCHAR pucKey
, INT_32 i4ValueDef
)
6391 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6392 P_WLAN_CFG_T prWlanCfg
;
6394 prWlanCfg
= prAdapter
->prWlanCfg
;
6399 /* Find the exist */
6400 prWlanCfgEntry
= wlanCfgGetEntry(prAdapter
, pucKey
);
6402 if (prWlanCfgEntry
) {
6403 i4Ret
= kalStrtol(prWlanCfgEntry
->aucValue
, NULL
, 0);
6411 wlanCfgSet(IN P_ADAPTER_T prAdapter
, const PCHAR pucKey
, PCHAR pucValue
, UINT_32 u4Flags
)
6414 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6415 P_WLAN_CFG_T prWlanCfg
;
6416 UINT_32 u4EntryIndex
;
6420 prWlanCfg
= prAdapter
->prWlanCfg
;
6424 /* Find the exist */
6426 prWlanCfgEntry
= wlanCfgGetEntry(prAdapter
, pucKey
);
6428 if (!prWlanCfgEntry
) {
6429 /* Find the empty */
6430 for (i
= 0; i
< WLAN_CFG_ENTRY_NUM_MAX
; i
++) {
6431 prWlanCfgEntry
= &prWlanCfg
->arWlanCfgBuf
[i
];
6432 if (prWlanCfgEntry
->aucKey
[0] == '\0') {
6438 if (u4EntryIndex
< WLAN_CFG_ENTRY_NUM_MAX
) {
6439 prWlanCfgEntry
= &prWlanCfg
->arWlanCfgBuf
[u4EntryIndex
];
6440 kalMemZero(prWlanCfgEntry
, sizeof(WLAN_CFG_ENTRY_T
));
6442 prWlanCfgEntry
= NULL
;
6443 DBGLOG(INIT
, ERROR
, ("wifi config there is no empty entry\n"));
6445 } /* !prWlanCfgEntry */
6450 if (prWlanCfgEntry
) {
6452 kalStrnCpy(prWlanCfgEntry
->aucKey
, pucKey
, WLAN_CFG_KEY_LEN_MAX
- 1);
6453 prWlanCfgEntry
->aucKey
[WLAN_CFG_KEY_LEN_MAX
- 1] = '\0';
6456 if (pucValue
&& pucValue
[0] != '\0') {
6457 kalStrnCpy(prWlanCfgEntry
->aucValue
, pucValue
, WLAN_CFG_VALUE_LEN_MAX
- 1);
6458 prWlanCfgEntry
->aucValue
[WLAN_CFG_VALUE_LEN_MAX
- 1] = '\0';
6461 if (prWlanCfgEntry
->pfSetCb
)
6462 prWlanCfgEntry
->pfSetCb(prAdapter
,
6463 prWlanCfgEntry
->aucKey
,
6464 prWlanCfgEntry
->aucValue
,
6465 prWlanCfgEntry
->pPrivate
, 0);
6468 /* Call the pfSetCb if value is empty ? */
6469 /* remove the entry if value is empty */
6470 kalMemZero(prWlanCfgEntry
, sizeof(WLAN_CFG_ENTRY_T
));
6474 /* prWlanCfgEntry */
6475 if (prWlanCfgEntry
) {
6476 DBGLOG(INIT
, INFO
, ("Set wifi config exist %u \'%s\' \'%s\'\n",
6477 ucExist
, prWlanCfgEntry
->aucKey
, prWlanCfgEntry
->aucValue
));
6478 return WLAN_STATUS_SUCCESS
;
6481 DBGLOG(INIT
, ERROR
, ("Set wifi config error key \'%s\'\n", pucKey
));
6484 DBGLOG(INIT
, ERROR
, ("Set wifi config error value \'%s\'\n", pucValue
));
6486 return WLAN_STATUS_FAILURE
;
6492 wlanCfgSetCb(IN P_ADAPTER_T prAdapter
,
6493 const PCHAR pucKey
, WLAN_CFG_SET_CB pfSetCb
, void *pPrivate
, UINT_32 u4Flags
)
6496 P_WLAN_CFG_ENTRY_T prWlanCfgEntry
;
6497 P_WLAN_CFG_T prWlanCfg
;
6499 prWlanCfg
= prAdapter
->prWlanCfg
;
6502 /* Find the exist */
6503 prWlanCfgEntry
= wlanCfgGetEntry(prAdapter
, pucKey
);
6505 if (prWlanCfgEntry
) {
6506 prWlanCfgEntry
->pfSetCb
= pfSetCb
;
6507 prWlanCfgEntry
->pPrivate
= pPrivate
;
6510 if (prWlanCfgEntry
) {
6511 return WLAN_STATUS_SUCCESS
;
6513 return WLAN_STATUS_FAILURE
;
6518 WLAN_STATUS
wlanCfgSetUint32(IN P_ADAPTER_T prAdapter
, const PCHAR pucKey
, UINT_32 u4Value
)
6521 P_WLAN_CFG_T prWlanCfg
;
6522 UINT_8 aucBuf
[WLAN_CFG_VALUE_LEN_MAX
];
6524 prWlanCfg
= prAdapter
->prWlanCfg
;
6528 kalMemZero(aucBuf
, sizeof(aucBuf
));
6530 kalSnprintf(aucBuf
, WLAN_CFG_VALUE_LEN_MAX
, "0x%x", (unsigned int)u4Value
);
6532 return wlanCfgSet(prAdapter
, pucKey
, aucBuf
, 0);
6542 struct WLAN_CFG_PARSE_STATE_S
{
6549 INT_32
wlanCfgFindNextToken(struct WLAN_CFG_PARSE_STATE_S
*state
)
6551 CHAR
*x
= state
->ptr
;
6554 if (state
->nexttoken
) {
6555 INT_32 t
= state
->nexttoken
;
6556 state
->nexttoken
= 0;
6568 return STATE_NEWLINE
;
6575 while (*x
&& (*x
!= '\n'))
6579 return STATE_NEWLINE
;
6594 state
->text
= s
= x
;
6606 state
->nexttoken
= STATE_NEWLINE
;
6614 /* unterminated quoted thing */
6643 /* \ <cr> <lf> -> line continuation */
6649 /* \ <lf> -> line continuation */
6651 /* eat any extra whitespace */
6652 while ((*x
== ' ') || (*x
== '\t'))
6656 /* unknown escape -- just copy */
6667 WLAN_STATUS
wlanCfgParseArgument(CHAR
*cmdLine
, INT_32
*argc
, CHAR
*argv
[]
6670 struct WLAN_CFG_PARSE_STATE_S state
;
6674 if (cmdLine
== NULL
|| argc
== NULL
|| argv
== NULL
) {
6676 return WLAN_STATUS_FAILURE
;
6680 state
.ptr
= cmdLine
;
6681 state
.nexttoken
= 0;
6684 if (kalStrnLen(cmdLine
, 512) >= 512) {
6686 return WLAN_STATUS_FAILURE
;
6690 switch (wlanCfgFindNextToken(&state
)) {
6696 if (nargs
< WLAN_CFG_ARGV_MAX
) {
6697 args
[nargs
++] = state
.text
;
6705 return WLAN_STATUS_SUCCESS
;
6711 wlanCfgParseAddEntry(IN P_ADAPTER_T prAdapter
,
6713 PUINT_8 pucKeyTail
, PUINT_8 pucValueHead
, PUINT_8 pucValueTail
)
6716 UINT_8 aucKey
[WLAN_CFG_KEY_LEN_MAX
];
6717 UINT_8 aucValue
[WLAN_CFG_VALUE_LEN_MAX
];
6720 kalMemZero(aucKey
, sizeof(aucKey
));
6721 kalMemZero(aucValue
, sizeof(aucValue
));
6723 if ((pucKeyHead
== NULL
)
6724 || (pucValueHead
== NULL
)
6726 return WLAN_STATUS_FAILURE
;
6730 if (pucKeyHead
> pucKeyTail
)
6731 return WLAN_STATUS_FAILURE
;
6732 u4Len
= pucKeyTail
- pucKeyHead
+ 1;
6734 u4Len
= kalStrnLen(pucKeyHead
, WLAN_CFG_KEY_LEN_MAX
- 1);
6737 if (u4Len
>= WLAN_CFG_KEY_LEN_MAX
) {
6738 u4Len
= WLAN_CFG_KEY_LEN_MAX
- 1;
6740 kalStrnCpy(aucKey
, pucKeyHead
, u4Len
);
6743 if (pucValueHead
> pucValueTail
)
6744 return WLAN_STATUS_FAILURE
;
6745 u4Len
= pucValueTail
- pucValueHead
+ 1;
6747 u4Len
= kalStrnLen(pucValueHead
, WLAN_CFG_VALUE_LEN_MAX
- 1);
6750 if (u4Len
>= WLAN_CFG_VALUE_LEN_MAX
) {
6751 u4Len
= WLAN_CFG_VALUE_LEN_MAX
- 1;
6753 kalStrnCpy(aucValue
, pucValueHead
, u4Len
);
6755 return wlanCfgSet(prAdapter
, aucKey
, aucValue
, 0);
6767 WLAN_STATUS
wlanCfgParse(IN P_ADAPTER_T prAdapter
, PUINT_8 pucConfigBuf
, UINT_32 u4ConfigBufLen
)
6770 struct WLAN_CFG_PARSE_STATE_S state
;
6771 PCHAR apcArgv
[WLAN_CFG_ARGV_MAX
];
6776 if (pucConfigBuf
== NULL
) {
6778 return WLAN_STATUS_FAILURE
;
6780 if (kalStrnLen(pucConfigBuf
, 4000) >= 4000) {
6782 return WLAN_STATUS_FAILURE
;
6784 if (u4ConfigBufLen
== 0) {
6785 return WLAN_STATUS_FAILURE
;
6789 state
.ptr
= pucConfigBuf
;
6790 state
.nexttoken
= 0;
6791 state
.maxSize
= u4ConfigBufLen
;
6794 switch (wlanCfgFindNextToken(&state
)) {
6797 wlanCfgParseAddEntry(prAdapter
, args
[0], NULL
, args
[1], NULL
);
6802 wlanCfgParseAddEntry(prAdapter
, args
[0], NULL
, args
[1], NULL
);
6807 if (nargs
< WLAN_CFG_ARGV_MAX
) {
6808 args
[nargs
++] = state
.text
;
6815 return WLAN_STATUS_SUCCESS
;
6823 PUINT_8 pucKeyTail
= NULL
;
6824 PUINT_8 pucKeyHead
= NULL
;
6825 PUINT_8 pucValueHead
= NULL
;
6826 PUINT_8 pucValueTail
= NULL
;
6828 ucState
= WAIT_KEY_HEAD
;
6829 pbuf
= pucConfigBuf
;
6831 for (i
= 0; i
< u4ConfigBufLen
; i
++) {
6833 if (c
== '\r' || c
== '\n') {
6835 if (ucState
== WAIT_VALUE_TAIL
) {
6838 wlanCfgParseAddEntry(prAdapter
, pucKeyHead
, pucKeyTail
,
6839 pucValueHead
, pucValueTail
);
6842 ucState
= WAIT_KEY_HEAD
;
6845 pucValueHead
= NULL
;
6846 pucValueTail
= NULL
;
6848 } else if (c
== '=') {
6849 if (ucState
== WAIT_KEY_TAIL
) {
6850 pucKeyTail
= &pbuf
[i
- 1];
6851 ucState
= WAIT_VALUE_HEAD
;
6853 } else if (c
== ' ' || c
== '\t') {
6854 if (ucState
== WAIT_KEY_HEAD
) {
6857 } else if (ucState
== WAIT_KEY_TAIL
) {
6858 pucKeyTail
= &pbuf
[i
- 1];
6859 ucState
= WAIT_VALUE_HEAD
;
6865 if (ucState
== WAIT_KEY_HEAD
) {
6866 ucState
= WAIT_COMMENT_TAIL
;
6867 } else if (ucState
== WAIT_VALUE_TAIL
) {
6868 pucValueTail
= &pbuf
[i
];
6872 if (ucState
== WAIT_KEY_HEAD
) {
6873 pucKeyHead
= &pbuf
[i
];
6874 pucKeyTail
= &pbuf
[i
];
6875 ucState
= WAIT_KEY_TAIL
;
6876 } else if (ucState
== WAIT_VALUE_HEAD
) {
6877 pucValueHead
= &pbuf
[i
];
6878 pucValueTail
= &pbuf
[i
];
6879 ucState
= WAIT_VALUE_TAIL
;
6880 } else if (ucState
== WAIT_VALUE_TAIL
) {
6881 pucValueTail
= &pbuf
[i
];
6888 if (ucState
== WAIT_VALUE_TAIL
) {
6891 wlanCfgParseAddEntry(prAdapter
, pucKeyHead
, pucKeyTail
, pucValueHead
,
6897 return WLAN_STATUS_SUCCESS
;
6899 #if CFG_SUPPORT_CFG_FILE
6902 IN P_ADAPTER_T prAdapter
,
6903 PUINT_8 pucConfigBuf
,
6904 UINT_32 u4ConfigBufLen
,
6908 P_WLAN_CFG_T prWlanCfg
;
6909 //P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
6910 prAdapter
->prWlanCfg
= &prAdapter
->rWlanCfg
;
6911 prWlanCfg
= prAdapter
->prWlanCfg
;
6913 kalMemZero(prWlanCfg
, sizeof(WLAN_CFG_T
));
6915 prWlanCfg
->u4WlanCfgEntryNumMax
= WLAN_CFG_ENTRY_NUM_MAX
;
6916 prWlanCfg
->u4WlanCfgKeyLenMax
= WLAN_CFG_KEY_LEN_MAX
;
6917 prWlanCfg
->u4WlanCfgValueLenMax
= WLAN_CFG_VALUE_LEN_MAX
;
6919 DBGLOG(INIT
, INFO
, ("Init wifi config len %u max entry %u\n",
6920 u4ConfigBufLen
, prWlanCfg
->u4WlanCfgEntryNumMax
));
6923 wlanCfgSet(prAdapter
, "ConfigValid","0x123", 0);
6924 if(wlanCfgGetUint32(prAdapter
,"ConfigValid",0) != 0x123) {
6925 DBGLOG(INIT
, INFO
, ("wifi config error %u\n",__LINE__
));
6927 wlanCfgSet(prAdapter
, "ConfigValid","1", 0);
6928 if(wlanCfgGetUint32(prAdapter
,"ConfigValid",0) != 1) {
6929 DBGLOG(INIT
, INFO
, ("wifi config error %u\n",__LINE__
));
6931 #if 0 /* soc chip didn't support these parameters now */
6932 /* Add initil config */
6933 /* use g,wlan,p2p,ap as prefix */
6934 /* Don't set cb here , overwrite by another api */
6935 wlanCfgSet(prAdapter
, "TxLdpc","1", 0);
6936 wlanCfgSet(prAdapter
, "RxLdpc","1", 0);
6937 wlanCfgSet(prAdapter
, "RxBeamformee","1",0);
6938 wlanCfgSet(prAdapter
, "RoamTh1","100",0);
6939 wlanCfgSet(prAdapter
, "RoamTh2","150",0);
6940 wlanCfgSet(prAdapter
, "wlanRxLdpc","1", 0);
6941 wlanCfgSet(prAdapter
, "apRxLdpc","1", 0);
6942 wlanCfgSet(prAdapter
, "p2pRxLdpc","1", 0);
6944 /* Parse the pucConfigBuff */
6946 if(pucConfigBuf
&& (u4ConfigBufLen
>0)) {
6947 wlanCfgParse(prAdapter
, pucConfigBuf
,u4ConfigBufLen
);
6951 return WLAN_STATUS_SUCCESS
;
6953 /*----------------------------------------------------------------------------*/
6955 * @brief This function is to initialize WLAN feature options
6957 * @param prAdapter Pointer of ADAPTER_T
6961 /*----------------------------------------------------------------------------*/
6964 IN P_ADAPTER_T prAdapter
6967 #define STR2BYTE(s) (((((PUINT_8)s)[0]-'0')*10)+(((PUINT_8)s)[1]-'0'))
6968 CHAR aucValue
[WLAN_CFG_VALUE_LEN_MAX
];
6971 P_WIFI_VAR_T prWifiVar
= &prAdapter
->rWifiVar
;
6972 P_REG_INFO_T prRegInfo
= &prAdapter
->prGlueInfo
->rRegInfo
;
6973 P_TX_PWR_PARAM_T prTxPwr
= &prRegInfo
->rTxPwr
;
6974 printk(KERN_ERR
"CFG_FILE: Apply Config File\n");
6975 /* Apply COUNTRY Config */
6976 if(wlanCfgGet(prAdapter
, "country", aucValue
, "",0) == WLAN_STATUS_SUCCESS
) {
6977 printk(KERN_ERR
"CFG_FILE: Found Country Key, Vaule=%s\n", aucValue
);
6978 prAdapter
->rWifiVar
.rConnSettings
.u2CountryCode
=
6979 (((UINT_16
) aucValue
[0]) << 8) | ((UINT_16
) aucValue
[1]) ;
6981 prWifiVar
->ucApWpsMode
= (UINT_8
)wlanCfgGetUint32(prAdapter
,"ApWpsMode", 0);
6982 printk(KERN_ERR
"CFG_FILE: ucApWpsMode = %u\n", prWifiVar
->ucApWpsMode
);
6984 if (wlanCfgGet(prAdapter
, "5G_support", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
) {
6985 prRegInfo
->ucSupport5GBand
= (*aucValue
== 'y') ? 1:0;
6987 if (wlanCfgGet(prAdapter
, "TxPower2G4CCK", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
6988 kalStrLen(aucValue
) == 2) {
6989 prTxPwr
->cTxPwr2G4Cck
= STR2BYTE(aucValue
);
6990 printk("2.4G cck=%d\n", prTxPwr
->cTxPwr2G4Cck
);
6992 if (wlanCfgGet(prAdapter
, "TxPower2G4OFDM", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
6993 kalStrLen(aucValue
) == 10) {
6994 prTxPwr
->cTxPwr2G4OFDM_BPSK
= STR2BYTE(aucValue
);
6995 prTxPwr
->cTxPwr2G4OFDM_QPSK
= STR2BYTE(aucValue
+2);
6996 prTxPwr
->cTxPwr2G4OFDM_16QAM
= STR2BYTE(aucValue
+4);
6997 prTxPwr
->cTxPwr2G4OFDM_48Mbps
= STR2BYTE(aucValue
+6);
6998 prTxPwr
->cTxPwr2G4OFDM_54Mbps
= STR2BYTE(aucValue
+8);
6999 printk("2.4G OFDM=%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr2G4OFDM_BPSK
, prTxPwr
->cTxPwr2G4OFDM_QPSK
,
7000 prTxPwr
->cTxPwr2G4OFDM_16QAM
,prTxPwr
->cTxPwr2G4OFDM_48Mbps
,prTxPwr
->cTxPwr2G4OFDM_54Mbps
);
7002 if (wlanCfgGet(prAdapter
, "TxPower2G4HT20", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
7003 kalStrLen(aucValue
) == 12) {
7004 prTxPwr
->cTxPwr2G4HT20_BPSK
= STR2BYTE(aucValue
);
7005 prTxPwr
->cTxPwr2G4HT20_QPSK
= STR2BYTE(aucValue
+2);
7006 prTxPwr
->cTxPwr2G4HT20_16QAM
= STR2BYTE(aucValue
+4);
7007 prTxPwr
->cTxPwr2G4HT20_MCS5
= STR2BYTE(aucValue
+6);
7008 prTxPwr
->cTxPwr2G4HT20_MCS6
= STR2BYTE(aucValue
+8);
7009 prTxPwr
->cTxPwr2G4HT20_MCS7
= STR2BYTE(aucValue
+10);
7010 printk("2.4G HT20=%d,%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr2G4HT20_BPSK
, prTxPwr
->cTxPwr2G4HT20_QPSK
,
7011 prTxPwr
->cTxPwr2G4HT20_16QAM
, prTxPwr
->cTxPwr2G4HT20_MCS5
, prTxPwr
->cTxPwr2G4HT20_MCS6
,
7012 prTxPwr
->cTxPwr2G4HT20_MCS7
);
7014 if (wlanCfgGet(prAdapter
, "TxPower2G4HT40", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
7015 kalStrLen(aucValue
) == 12) {
7016 prTxPwr
->cTxPwr2G4HT40_BPSK
= STR2BYTE(aucValue
);
7017 prTxPwr
->cTxPwr2G4HT40_QPSK
= STR2BYTE(aucValue
+2);
7018 prTxPwr
->cTxPwr2G4HT40_16QAM
= STR2BYTE(aucValue
+4);
7019 prTxPwr
->cTxPwr2G4HT40_MCS5
= STR2BYTE(aucValue
+6);
7020 prTxPwr
->cTxPwr2G4HT40_MCS6
= STR2BYTE(aucValue
+8);
7021 prTxPwr
->cTxPwr2G4HT40_MCS7
= STR2BYTE(aucValue
+10);
7022 printk("2.4G HT40=%d,%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr2G4HT40_BPSK
, prTxPwr
->cTxPwr2G4HT40_QPSK
,
7023 prTxPwr
->cTxPwr2G4HT40_16QAM
, prTxPwr
->cTxPwr2G4HT40_MCS5
, prTxPwr
->cTxPwr2G4HT40_MCS6
,
7024 prTxPwr
->cTxPwr2G4HT40_MCS7
);
7026 if (wlanCfgGet(prAdapter
, "TxPower5GOFDM", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
7027 kalStrLen(aucValue
) == 10) {
7028 prTxPwr
->cTxPwr5GOFDM_BPSK
= STR2BYTE(aucValue
);
7029 prTxPwr
->cTxPwr5GOFDM_QPSK
= STR2BYTE(aucValue
+2);
7030 prTxPwr
->cTxPwr5GOFDM_16QAM
= STR2BYTE(aucValue
+4);
7031 prTxPwr
->cTxPwr5GOFDM_48Mbps
= STR2BYTE(aucValue
+6);
7032 prTxPwr
->cTxPwr5GOFDM_54Mbps
= STR2BYTE(aucValue
+8);
7033 printk("5G OFDM=%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr5GOFDM_BPSK
, prTxPwr
->cTxPwr5GOFDM_QPSK
,
7034 prTxPwr
->cTxPwr5GOFDM_16QAM
,prTxPwr
->cTxPwr5GOFDM_48Mbps
,prTxPwr
->cTxPwr5GOFDM_54Mbps
);
7036 if (wlanCfgGet(prAdapter
, "TxPower5GHT20", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
7037 kalStrLen(aucValue
) == 12) {
7038 prTxPwr
->cTxPwr5GHT20_BPSK
= STR2BYTE(aucValue
);
7039 prTxPwr
->cTxPwr5GHT20_QPSK
= STR2BYTE(aucValue
+2);
7040 prTxPwr
->cTxPwr5GHT20_16QAM
= STR2BYTE(aucValue
+4);
7041 prTxPwr
->cTxPwr5GHT20_MCS5
= STR2BYTE(aucValue
+6);
7042 prTxPwr
->cTxPwr5GHT20_MCS6
= STR2BYTE(aucValue
+8);
7043 prTxPwr
->cTxPwr5GHT20_MCS7
= STR2BYTE(aucValue
+10);
7044 printk("5G HT20=%d,%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr5GHT20_BPSK
, prTxPwr
->cTxPwr5GHT20_QPSK
,
7045 prTxPwr
->cTxPwr5GHT20_16QAM
, prTxPwr
->cTxPwr5GHT20_MCS5
, prTxPwr
->cTxPwr5GHT20_MCS6
,
7046 prTxPwr
->cTxPwr5GHT20_MCS7
);
7048 if (wlanCfgGet(prAdapter
, "TxPower5GHT40", aucValue
, "", 0) == WLAN_STATUS_SUCCESS
&&
7049 kalStrLen(aucValue
) == 12) {
7050 prTxPwr
->cTxPwr5GHT40_BPSK
= STR2BYTE(aucValue
);
7051 prTxPwr
->cTxPwr5GHT40_QPSK
= STR2BYTE(aucValue
+2);
7052 prTxPwr
->cTxPwr5GHT40_16QAM
= STR2BYTE(aucValue
+4);
7053 prTxPwr
->cTxPwr5GHT40_MCS5
= STR2BYTE(aucValue
+6);
7054 prTxPwr
->cTxPwr5GHT40_MCS6
= STR2BYTE(aucValue
+8);
7055 prTxPwr
->cTxPwr5GHT40_MCS7
= STR2BYTE(aucValue
+10);
7056 printk("5G HT40=%d,%d,%d,%d,%d,%d\n", prTxPwr
->cTxPwr5GHT40_BPSK
, prTxPwr
->cTxPwr5GHT40_QPSK
,
7057 prTxPwr
->cTxPwr5GHT40_16QAM
, prTxPwr
->cTxPwr5GHT40_MCS5
, prTxPwr
->cTxPwr5GHT40_MCS6
,
7058 prTxPwr
->cTxPwr5GHT40_MCS7
);
7060 /* TODO: Apply other Config */
7062 #endif /* CFG_SUPPORT_CFG_FILE */