2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/bss.c#3 $
6 \brief This file contains the functions for creating BSS(AP)/IBSS(AdHoc).
8 This file contains the functions for BSS(AP)/IBSS(AdHoc). We may create a BSS/IBSS
9 network, or merge with exist IBSS network and sending Beacon Frame or reply
10 the Probe Response Frame for received Probe Request Frame.
18 ** 08 29 2012 chinglan.wang
19 ** [ALPS00349664] [6577JB][WIFI] Phone can not connect to AP secured with AES via WPS in 802.11n Only
22 ** 07 26 2012 yuche.tsai
23 ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
24 ** Update driver code of ALPS.JB for hot-spot.
26 * 07 17 2012 yuche.tsai
28 * Let netdev bring up.
30 * 07 17 2012 yuche.tsai
32 * Compile no error before trial run.
34 * 06 14 2012 chinglan.wang
36 * Fix the losing of the HT IE in assoc request..
38 * 06 13 2012 yuche.tsai
40 * Update maintrunk driver.
41 * Add support for driver compose assoc request frame.
43 * 03 08 2012 yuche.tsai
45 * Fix FW assert when start Hot-Spot.
49 * Snc CFG80211 modification for ICS migration from branch 2.2.
51 * 01 20 2012 chinglan.wang
54 * Fix the WPA-PSK TKIP and WPA2-PSK AES security mode bug.
57 * Sync CFG80211 modification from branch 2,2.
59 * 01 15 2012 yuche.tsai
61 * Fix wrong basic rate issue.
63 * 01 13 2012 yuche.tsai
65 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
68 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
69 * Always set short slot time to TRUE initially in AP mode
72 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
73 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
75 * 09 14 2011 yuche.tsai
77 * Add P2P IE in assoc response.
80 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
81 * Remove flag CFG_WIFI_DIRECT_MOVED.
83 * 04 12 2011 eddie.chen
84 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
85 * Fix the sta index in processing security frame
86 * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
89 * 04 08 2011 eddie.chen
90 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
93 * 03 29 2011 eddie.chen
94 * [WCXRP00000608] [MT6620 Wi-Fi][DRV] Change wmm parameters in beacon
95 * Change wmm parameters in beacon.
97 * 03 29 2011 yuche.tsai
98 * [WCXRP00000607] [Volunteer Patch][MT6620][Driver] Coding Style Fix for klocwork scan.
101 * 03 19 2011 yuche.tsai
102 * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
103 * Make assoc req to append P2P IE if wifi direct is enabled.
105 * 03 11 2011 chinglan.wang
106 * [WCXRP00000537] [MT6620 Wi-Fi][Driver] Can not connect to 802.11b/g/n mixed AP with WEP security.
109 * 03 03 2011 george.huang
110 * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
113 * 03 03 2011 george.huang
114 * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
115 * modify to handle if beacon MSDU been released when BSS deactivated
118 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
119 * add code to let the beacon and probe response for Auto GO WSC .
122 * [WCXRP00000448] [MT6620 Wi-Fi][Driver] Fixed WSC IE not send out at probe request
123 * Add code to send beacon and probe response WSC IE at Auto GO.
125 * 02 17 2011 eddie.chen
126 * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
127 * 1) Chnage GetFrameAction decision when BSS is absent.
128 * 2) Check channel and resource in processing ProbeRequest
130 * 02 12 2011 yuche.tsai
131 * [WCXRP00000441] [Volunteer Patch][MT6620][Driver] BoW can not create desired station type when Hot Spot is enabled.
132 * bss should create station record type according to callers input.
134 * 02 11 2011 terry.wu
135 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
136 * In p2p link function, check networktype before calling p2p function.
138 * 02 11 2011 terry.wu
139 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
140 * Modify p2p link function to avoid assert.
142 * 01 26 2011 cm.chang
143 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
146 * 01 25 2011 yuche.tsai
147 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
148 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
150 * 01 25 2011 eddie.chen
151 * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
152 * Fix the compile error in windows.
154 * 01 24 2011 eddie.chen
155 * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
156 * Add destination decision in AP mode.
158 * 01 24 2011 terry.wu
159 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
160 * .Fix typo and missing entry
162 * 12 30 2010 eddie.chen
163 * [WCXRP00000322] Add WMM IE in beacon,
165 Add per station flow control when STA is in PS
168 * Fix prBssInfo->aucCWminLog to prBssInfo->aucCWminLogForBcast
170 * 12 29 2010 eddie.chen
171 * [WCXRP00000322] Add WMM IE in beacon,
173 Add per station flow control when STA is in PS
176 * Add WMM parameter for broadcast.
178 * 12 29 2010 eddie.chen
179 * [WCXRP00000322] Add WMM IE in beacon,
180 Add per station flow control when STA is in PS
182 * 1) PS flow control event
184 * 2) WMM IE in beacon, assoc resp, probe resp
187 * [WCXRP00000210] [MT6620 Wi-Fi][Driver][FW] Set RCPI value in STA_REC for initial TX rate selection of auto-rate algorithm
188 * update ucRcpi of STA_RECORD_T for AIS when
189 * 1) Beacons for IBSS merge is received
190 * 2) Associate Response for a connecting peer is received
193 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
194 * use definition macro to replace hard-coded constant
197 * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
198 * update the frog's new p2p state machine.
202 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
204 * 09 27 2010 chinghwa.yu
205 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
206 * Update BCM/BoW design and settings.
208 * 09 16 2010 cm.chang
210 * Change conditional compiling options for BOW
212 * 09 10 2010 cm.chang
214 * Always update Beacon content if FW sync OBSS info
218 * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
220 * 09 03 2010 kevin.huang
222 * Refine #include sequence and solve recursive/nested #include issue
224 * 08 31 2010 kevin.huang
226 * Use LINK LIST operation to process SCAN result
230 * eliminate klockwork errors
232 * 08 29 2010 yuche.tsai
234 * Finish SLT TX/RX & Rate Changing Support.
236 * 08 24 2010 cm.chang
238 * Support RLM initail channel of Ad-hoc, P2P and BOW
240 * 08 16 2010 yuche.tsai
242 * Before composing Beacon IE, assign network type index for msdu info,
243 * this information is needed by RLM module while composing some RLM related IE field.
247 * Replace CFG_SUPPORT_BOW by CFG_ENABLE_BT_OVER_WIFI.
248 * There is no CFG_SUPPORT_BOW in driver domain source.
250 * 08 16 2010 kevin.huang
252 * Refine AAA functions
254 * 08 12 2010 kevin.huang
256 * Fix undefined pucDestAddr in bssUpdateBeaconContent()
258 * 08 12 2010 kevin.huang
260 * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
264 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
265 * 2) extending scanning result to 64 instead of 48
267 * 08 02 2010 yuche.tsai
269 * P2P Group Negotiation Code Check in.
271 * 08 02 2010 george.huang
273 * add WMM-PS test related OID/ CMD handlers
275 * 07 26 2010 yuche.tsai
277 * Add support to RX probe response for P2P.
281 * 1) bugfix: do not stop timer for join after switched into normal_tr state, for providing chance for DHCP handshasking
282 * 2) modify rsnPerformPolicySelection() invoking
286 * update for security supporting.
290 * [WPD00003833] [MT6620 and MT5931] Driver migration.
291 * when IBSS is being merged-in, send command packet to PM for connected indication
295 * [WPD00003833] [MT6620 and MT5931] Driver migration.
296 * Add Ad-Hoc support to AIS-FSM
298 * 07 14 2010 yarco.yang
300 * 1. Remove CFG_MQM_MIGRATION
301 * 2. Add CMD_UPDATE_WMM_PARMS command
305 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
307 * 07 06 2010 george.huang
308 * [WPD00001556]Basic power managemenet function
309 * Update arguments for nicUpdateBeaconIETemplate()
312 * [WPD00003833][MT6620 and MT5931] Driver migration
313 * 1) sync to. CMD/EVENT document v0.03
314 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
315 * 3) send command packet to indicate FW-PM after
316 * a) 1st beacon is received after AIS has connected to an AP
317 * b) IBSS-ALONE has been created
318 * c) IBSS-MERGE has occured
321 * [WPD00003833][MT6620 and MT5931] Driver migration
322 * send MMPDU in basic rate.
324 * 06 25 2010 george.huang
325 * [WPD00001556]Basic power managemenet function
326 * Create beacon update path, with expose bssUpdateBeaconContent()
328 * 06 21 2010 yuche.tsai
329 * [WPD00003839][MT6620 5931][P2P] Feature migration
330 * Fix compile error while enable WIFI_DIRECT support.
332 * 06 21 2010 yarco.yang
333 * [WPD00003837][MT6620]Data Path Refine
334 * Support CFG_MQM_MIGRATION flag
337 * [WPD00003833][MT6620 and MT5931] Driver migration
338 * enable RX management frame handling.
341 * [WPD00003833][MT6620 and MT5931] Driver migration
342 * specify correct value for management frames.
344 * 06 18 2010 cm.chang
345 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
346 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
349 * [WPD00003833][MT6620 and MT5931] Driver migration
350 * correct when ADHOC support is turned on.
353 * [WPD00003833][MT6620 and MT5931] Driver migration
357 * [WPD00003833][MT6620 and MT5931] Driver migration
358 * add management dispatching function table.
361 * [WPD00003833][MT6620 and MT5931] Driver migration
362 * auth.c is migrated.
365 * [WPD00003833][MT6620 and MT5931] Driver migration
366 * fix compilation error when WIFI_DIRECT is turned on
369 * [WPD00003833][MT6620 and MT5931] Driver migration
372 * 06 04 2010 george.huang
373 * [BORA00000678][MT6620]WiFi LP integration
374 * [PM] Support U-APSD for STA mode
376 * 05 28 2010 kevin.huang
377 * [BORA00000794][WIFISYS][New Feature]Power Management Support
378 * Add ClientList handling API - bssClearClientList, bssAddStaRecToClientList
380 * 05 24 2010 kevin.huang
381 * [BORA00000794][WIFISYS][New Feature]Power Management Support
382 * Update bssProcessProbeRequest() to avoid redundant SSID IE {0,0} for IOT.
384 * 05 21 2010 kevin.huang
385 * [BORA00000794][WIFISYS][New Feature]Power Management Support
386 * Refine txmInitWtblTxRateTable() - set TX initial rate according to AP's operation rate set
388 * 05 18 2010 cm.chang
389 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
390 * Ad-hoc Beacon should not carry HT OP and OBSS IEs
392 * 05 14 2010 kevin.huang
393 * [BORA00000794][WIFISYS][New Feature]Power Management Support
394 * Use TX MGMT Frame API for sending PS NULL frame to avoid the TX Burst Mechanism in TX FW Frame API
396 * 05 14 2010 kevin.huang
397 * [BORA00000794][WIFISYS][New Feature]Power Management Support
398 * Seperate Beacon and ProbeResp IE array
400 * 05 12 2010 kevin.huang
401 * [BORA00000794][WIFISYS][New Feature]Power Management Support
402 * Add Power Management - Legacy PS-POLL support.
404 * 04 28 2010 tehuang.liu
405 * [BORA00000605][WIFISYS] Phase3 Integration
406 * Removed the use of compiling flag MQM_WMM_PARSING
408 * 04 27 2010 kevin.huang
409 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
410 * Add Set Slot Time and Beacon Timeout Support for AdHoc Mode
412 * 04 24 2010 cm.chang
413 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
414 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
416 * 04 22 2010 cm.chang
417 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
418 * First draft code to support protection in AP mode
420 * 04 20 2010 kevin.huang
421 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
422 * Fix restart Beacon Timeout Func after connection diagnosis
424 * 04 19 2010 kevin.huang
425 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
426 * Add Beacon Timeout Support and will send Null frame to diagnose connection
429 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
430 * adding the wpa-none for ibss beacon.
433 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
434 * fixed the protected bit at cap info for ad-hoc.
436 * 03 18 2010 kevin.huang
437 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
438 * Rename the CFG flags
440 * 03 16 2010 kevin.huang
441 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
444 * 02 26 2010 kevin.huang
445 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
446 * Update outgoing beacon's TX data rate
448 * 02 23 2010 kevin.huang
449 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
450 * Add DTIM count update while TX Beacon
452 * 02 05 2010 kevin.huang
453 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
454 * Modify code due to define - BAND_24G and specific BSS_INFO_T was changed
456 * 02 05 2010 kevin.huang
457 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
458 * Revise data structure to share the same BSS_INFO_T for avoiding coding error
460 * 02 04 2010 kevin.huang
461 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
462 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
465 /*******************************************************************************
466 * C O M P I L E R F L A G S
467 ********************************************************************************
470 /*******************************************************************************
471 * E X T E R N A L R E F E R E N C E S
472 ********************************************************************************
476 /*******************************************************************************
478 ********************************************************************************
481 /*******************************************************************************
483 ********************************************************************************
485 /*******************************************************************************
486 * P U B L I C D A T A
487 ********************************************************************************
489 #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
490 APPEND_VAR_IE_ENTRY_T txBcnIETable[] = {
491 { (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE } /* 50 */
492 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE } /* 42 */
493 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE } /* 45 */
494 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE } /* 61 */
495 #if CFG_ENABLE_WIFI_DIRECT
496 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE } /* 74 */
498 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE } /* 127 */
499 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE } /* 221 */
500 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE } /* 221 */
501 #if CFG_ENABLE_WIFI_DIRECT
502 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWPAIE } /* 221 */
503 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE } /* 48 */
504 #if 0 //LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
505 ,{ 0, p2pFuncCalculateExtra_IELenForBeacon, p2pFuncGenerateExtra_IEForBeacon } /* 221 */
507 ,{ 0, p2pFuncCalculateP2p_IELenForBeacon, p2pFuncGenerateP2p_IEForBeacon } /* 221 */
508 ,{ 0, p2pFuncCalculateWSC_IELenForBeacon, p2pFuncGenerateWSC_IEForBeacon } /* 221 */
510 #endif /* CFG_ENABLE_WIFI_DIRECT */
514 APPEND_VAR_IE_ENTRY_T txProbRspIETable[] = {
515 { (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE } /* 50 */
516 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE } /* 42 */
517 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE } /* 45 */
518 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE } /* 61 */
519 #if CFG_ENABLE_WIFI_DIRECT
520 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE } /* 48 */
521 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE } /* 74 */
523 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE } /* 127 */
524 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE } /* 221 */
525 ,{ (ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE } /* 221 */
528 #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
531 /*******************************************************************************
532 * P R I V A T E D A T A
533 ********************************************************************************
536 /*******************************************************************************
538 ********************************************************************************
542 /*******************************************************************************
543 * F U N C T I O N D E C L A R A T I O N S
544 ********************************************************************************
547 /*******************************************************************************
549 ********************************************************************************
551 /*----------------------------------------------------------------------------*/
552 /* Routines for all Operation Modes */
553 /*----------------------------------------------------------------------------*/
554 /*----------------------------------------------------------------------------*/
556 * @brief This function will create or reset a STA_RECORD_T by given BSS_DESC_T for
557 * Infrastructure or AdHoc Mode.
559 * @param[in] prAdapter Pointer to the Adapter structure.
560 * @param[in] eStaType Assign STA Type for this STA_RECORD_T
561 * @param[in] eNetTypeIndex Assign Net Type Index for this STA_RECORD_T
562 * @param[in] prBssDesc Received Beacon/ProbeResp from this STA
564 * @retval Pointer to STA_RECORD_T
566 /*----------------------------------------------------------------------------*/
568 bssCreateStaRecFromBssDesc (
569 IN P_ADAPTER_T prAdapter,
570 IN ENUM_STA_TYPE_T eStaType,
571 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
572 IN P_BSS_DESC_T prBssDesc
575 P_STA_RECORD_T prStaRec;
576 UINT_8 ucNonHTPhyTypeSet;
581 //4 <1> Get a valid STA_RECORD_T
582 prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) eNetTypeIndex,
583 prBssDesc->aucSrcAddr);
586 prStaRec = cnmStaRecAlloc(prAdapter, (UINT_8) eNetTypeIndex);
588 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
589 * exhausted case and do removal of unused STA_RECORD_T.
599 prStaRec->ucJoinFailureCount = 0;
600 /* TODO(Kevin): If this is an old entry, we may also reset the ucJoinFailureCount to 0.
603 COPY_MAC_ADDR(prStaRec->aucMacAddr, prBssDesc->aucSrcAddr);
607 //4 <2> Setup STA TYPE and NETWORK
608 prStaRec->eStaType = eStaType;
610 prStaRec->ucNetTypeIndex = eNetTypeIndex;
613 //4 <3> Update information from BSS_DESC_T to current P_STA_RECORD_T
614 prStaRec->u2CapInfo = prBssDesc->u2CapInfo;
616 prStaRec->u2OperationalRateSet = prBssDesc->u2OperationalRateSet;
617 prStaRec->u2BSSBasicRateSet = prBssDesc->u2BSSBasicRateSet;
619 prStaRec->ucPhyTypeSet = prBssDesc->ucPhyTypeSet;
621 if (!((prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_ENABLED) ||
622 (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_KEY_ABSENT) ||
623 (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION_DISABLED) ||
624 (prAdapter->prGlueInfo->u2WSCAssocInfoIELen) ||
625 (prAdapter->prGlueInfo->u2WapiAssocInfoIESz))) {
626 DBGLOG(BSS, INFO, ("Ignore the HT Bit for TKIP as pairwise cipher configed!\n"));
627 prStaRec->ucPhyTypeSet &= ~PHY_TYPE_BIT_HT;
630 prStaRec->ucDesiredPhyTypeSet = prStaRec->ucPhyTypeSet & prAdapter->rWifiVar.ucAvailablePhyTypeSet;
632 ucNonHTPhyTypeSet = prStaRec->ucDesiredPhyTypeSet & PHY_TYPE_SET_802_11ABG;
634 /* Check for Target BSS's non HT Phy Types */
635 if (ucNonHTPhyTypeSet) {
637 if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_ERP) {
638 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_ERP_INDEX;
640 else if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_OFDM) {
641 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_OFDM_INDEX;
643 else /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */ {
644 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
647 prStaRec->fgHasBasicPhyType = TRUE;
650 /* Use mandatory for 11N only BSS */
651 ASSERT(prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N);
654 /* TODO(Kevin): which value should we set for 11n ? ERP ? */
655 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
658 prStaRec->fgHasBasicPhyType = FALSE;
661 /* Update non HT Desired Rate Set */
663 P_CONNECTION_SETTINGS_T prConnSettings;
666 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
668 prStaRec->u2DesiredNonHTRateSet =
669 (prStaRec->u2OperationalRateSet & prConnSettings->u2DesiredNonHTRateSet);
672 //4 <4> Update information from BSS_DESC_T to current P_STA_RECORD_T
673 if (IS_AP_STA(prStaRec)) {
674 /* do not need to parse IE for DTIM,
675 * which have been parsed before inserting into BSS_DESC_T
677 if (prBssDesc->ucDTIMPeriod) {
678 prStaRec->ucDTIMPeriod = prBssDesc->ucDTIMPeriod;
681 prStaRec->ucDTIMPeriod = 0; // Means that TIM was not parsed.
686 //4 <5> Update default value
687 prStaRec->fgDiagnoseConnection = FALSE;
690 //4 <6> Update default value for other Modules
691 /* Determine fgIsWmmSupported and fgIsUapsdSupported in STA_REC */
692 mqmProcessScanResult(prAdapter, prBssDesc, prStaRec);
696 } /* end of bssCreateStaRecFromBssDesc() */
699 /*----------------------------------------------------------------------------*/
701 * @brief This function will compose the Null Data frame.
703 * @param[in] prAdapter Pointer to the Adapter structure.
704 * @param[in] pucBuffer Pointer to the frame buffer.
705 * @param[in] prStaRec Pointer to the STA_RECORD_T.
709 /*----------------------------------------------------------------------------*/
711 bssComposeNullFrame (
712 IN P_ADAPTER_T prAdapter,
713 IN PUINT_8 pucBuffer,
714 IN P_STA_RECORD_T prStaRec
717 P_WLAN_MAC_HEADER_T prNullFrame;
718 P_BSS_INFO_T prBssInfo;
724 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
726 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
730 prNullFrame = (P_WLAN_MAC_HEADER_T)pucBuffer;
732 //4 <1> Decide the Frame Control Field
733 u2FrameCtrl = MAC_FRAME_NULL;
735 if (IS_AP_STA(prStaRec)) {
736 u2FrameCtrl |= MASK_FC_TO_DS;
738 if (prStaRec->fgSetPwrMgtBit) {
739 u2FrameCtrl |= MASK_FC_PWR_MGT;
742 else if (IS_CLIENT_STA(prStaRec)) {
743 u2FrameCtrl |= MASK_FC_FROM_DS;
745 else if (IS_DLS_STA(prStaRec)) {
749 /* NOTE(Kevin): We won't send Null frame for IBSS */
754 //4 <2> Compose the Null frame
755 /* Fill the Frame Control field. */
756 //WLAN_SET_FIELD_16(&prNullFrame->u2FrameCtrl, u2FrameCtrl);
757 prNullFrame->u2FrameCtrl = u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
759 /* Fill the Address 1 field with Target Peer Address. */
760 COPY_MAC_ADDR(prNullFrame->aucAddr1, prStaRec->aucMacAddr);
762 /* Fill the Address 2 field with our MAC Address. */
763 COPY_MAC_ADDR(prNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
765 /* Fill the Address 3 field with Target BSSID. */
766 COPY_MAC_ADDR(prNullFrame->aucAddr3, prBssInfo->aucBSSID);
768 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
769 prNullFrame->u2SeqCtrl = 0;
773 } /* end of bssComposeNullFrameHeader() */
776 /*----------------------------------------------------------------------------*/
778 * @brief This function will compose the QoS Null Data frame.
780 * @param[in] prAdapter Pointer to the Adapter structure.
781 * @param[in] pucBuffer Pointer to the frame buffer.
782 * @param[in] prStaRec Pointer to the STA_RECORD_T.
783 * @param[in] ucUP User Priority.
784 * @param[in] fgSetEOSP Set the EOSP bit.
788 /*----------------------------------------------------------------------------*/
790 bssComposeQoSNullFrame (
791 IN P_ADAPTER_T prAdapter,
792 IN PUINT_8 pucBuffer,
793 IN P_STA_RECORD_T prStaRec,
798 P_WLAN_MAC_HEADER_QOS_T prQoSNullFrame;
799 P_BSS_INFO_T prBssInfo;
801 UINT_16 u2QosControl;
806 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
808 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
812 prQoSNullFrame = (P_WLAN_MAC_HEADER_QOS_T)pucBuffer;
814 //4 <1> Decide the Frame Control Field
815 u2FrameCtrl = MAC_FRAME_QOS_NULL;
817 if (IS_AP_STA(prStaRec)) {
818 u2FrameCtrl |= MASK_FC_TO_DS;
820 if (prStaRec->fgSetPwrMgtBit) {
821 u2FrameCtrl |= MASK_FC_PWR_MGT;
824 else if (IS_CLIENT_STA(prStaRec)) {
825 u2FrameCtrl |= MASK_FC_FROM_DS;
827 else if (IS_DLS_STA(prStaRec)) {
831 /* NOTE(Kevin): We won't send QoS Null frame for IBSS */
836 //4 <2> Compose the QoS Null frame
837 /* Fill the Frame Control field. */
838 //WLAN_SET_FIELD_16(&prQoSNullFrame->u2FrameCtrl, u2FrameCtrl);
839 prQoSNullFrame->u2FrameCtrl = u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
841 /* Fill the Address 1 field with Target Peer Address. */
842 COPY_MAC_ADDR(prQoSNullFrame->aucAddr1, prStaRec->aucMacAddr);
844 /* Fill the Address 2 field with our MAC Address. */
845 COPY_MAC_ADDR(prQoSNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
847 /* Fill the Address 3 field with Target BSSID. */
848 COPY_MAC_ADDR(prQoSNullFrame->aucAddr3, prBssInfo->aucBSSID);
850 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
851 prQoSNullFrame->u2SeqCtrl = 0;
853 u2QosControl = (UINT_16)(ucUP & WMM_QC_UP_MASK);
856 u2QosControl |= WMM_QC_EOSP;
859 //WLAN_SET_FIELD_16(&prQoSNullFrame->u2QosCtrl, u2QosControl);
860 prQoSNullFrame->u2QosCtrl = u2QosControl; // NOTE(Kevin): Optimized for ARM
864 } /* end of bssComposeQoSNullFrameHeader() */
867 /*----------------------------------------------------------------------------*/
869 * @brief Send the Null Frame
871 * @param[in] prAdapter Pointer to the Adapter structure.
872 * @param[in] prStaRec Pointer to the STA_RECORD_T
873 * @param[in] pfTxDoneHandler TX Done call back function
875 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
876 * @retval WLAN_STATUS_SUCCESS Succe]ss.
878 /*----------------------------------------------------------------------------*/
881 IN P_ADAPTER_T prAdapter,
882 IN P_STA_RECORD_T prStaRec,
883 IN PFN_TX_DONE_HANDLER pfTxDoneHandler
886 P_MSDU_INFO_T prMsduInfo;
887 UINT_16 u2EstimatedFrameLen;
890 //4 <1> Allocate a PKT_INFO_T for Null Frame
891 /* Init with MGMT Header Length */
892 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
895 /* Allocate a MSDU_INFO_T */
896 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
897 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending Null Frame.\n"));
898 return WLAN_STATUS_RESOURCES;
901 //4 <2> Compose Null frame in MSDU_INfO_T.
902 bssComposeNullFrame(prAdapter,
903 (PUINT_8)((UINT_32)prMsduInfo->prPacket + MAC_TX_RESERVED_FIELD),
906 //4 <3> Update information of MSDU_INFO_T
907 TXM_SET_DATA_PACKET( \
908 /* STA_REC ptr */ prStaRec, \
909 /* MSDU_INFO ptr */ prMsduInfo, \
910 /* MAC HDR ptr */ (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD), \
911 /* MAC HDR length */ WLAN_MAC_HEADER_LEN, \
912 /* PAYLOAD ptr */ (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_LEN), \
913 /* PAYLOAD length */ 0, \
914 /* Network Type Index */(UINT_8)prStaRec->ucNetTypeIndex, \
915 /* TID */ 0 /* BE: AC1 */, \
916 /* Flag 802.11 */ TRUE,\
917 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */, \
918 /* Resource TC */ 0 /* Irrelevant */, \
919 /* Flag 802.1x */ FALSE,\
920 /* TX-done callback */ pfTxDoneHandler, \
921 /* PS forwarding type*/ PS_FORWARDING_TYPE_NON_PS, \
922 /* PS Session ID */ 0 /* Irrelevant */, \
923 /* Flag fixed rate */ TRUE, \
924 /* Fixed tx rate */ g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode, \
925 /* Fixed-rate retry */ BSS_DEFAULT_CONN_TEST_NULL_FRAME_RETRY_LIMIT, \
926 /* PAL LLH */ 0 /* Irrelevant */,\
927 /* ACL SN */ 0 /* Irrelevant */,\
928 /* Flag No Ack */ FALSE \
931 /* Terminate with a NULL pointer */
932 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo,NULL);
934 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
936 /* Indicate the packet to TXM */
937 //4 <4> Inform TXM to send this Null frame.
938 txmSendFwDataPackets(prMsduInfo);
941 prMsduInfo->eSrc = TX_PACKET_MGMT;
942 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_DATA;
943 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
944 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
945 prMsduInfo->ucMacHeaderLength = WLAN_MAC_HEADER_LEN;
946 prMsduInfo->fgIs802_1x = FALSE;
947 prMsduInfo->fgIs802_11 = TRUE;
948 prMsduInfo->u2FrameLength = WLAN_MAC_HEADER_LEN;
949 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
950 prMsduInfo->pfTxDoneHandler = pfTxDoneHandler;
951 prMsduInfo->fgIsBasicRate = FALSE;
953 //4 <4> Inform TXM to send this Null frame.
954 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
956 return WLAN_STATUS_SUCCESS;
958 } /* end of bssSendNullFrame() */
961 /*----------------------------------------------------------------------------*/
963 * @brief Send the QoS Null Frame
965 * @param[in] prAdapter Pointer to the Adapter structure.
966 * @param[in] prStaRec Pointer to the STA_RECORD_T
967 * @param[in] pfTxDoneHandler TX Done call back function
969 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
970 * @retval WLAN_STATUS_SUCCESS Success.
972 /*----------------------------------------------------------------------------*/
974 bssSendQoSNullFrame (
975 IN P_ADAPTER_T prAdapter,
976 IN P_STA_RECORD_T prStaRec,
978 IN PFN_TX_DONE_HANDLER pfTxDoneHandler
981 P_MSDU_INFO_T prMsduInfo;
982 UINT_16 u2EstimatedFrameLen;
985 //4 <1> Allocate a PKT_INFO_T for Null Frame
986 /* Init with MGMT Header Length */
987 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
988 WLAN_MAC_HEADER_QOS_LEN;
990 /* Allocate a MSDU_INFO_T */
991 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
992 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending Null Frame.\n"));
993 return WLAN_STATUS_RESOURCES;
996 //4 <2> Compose Null frame in MSDU_INfO_T.
997 bssComposeQoSNullFrame(prAdapter,
998 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
1003 //4 <3> Update information of MSDU_INFO_T
1004 TXM_SET_DATA_PACKET( \
1005 /* STA_REC ptr */ prStaRec, \
1006 /* MSDU_INFO ptr */ prMsduInfo, \
1007 /* MAC HDR ptr */ (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD), \
1008 /* MAC HDR length */ WLAN_MAC_HEADER_QOS_LEN, \
1009 /* PAYLOAD ptr */ (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_QOS_LEN), \
1010 /* PAYLOAD length */ 0, \
1011 /* Network Type Index */(UINT_8)prStaRec->ucNetTypeIndex, \
1012 /* TID */ 0 /* BE: AC1 */, \
1013 /* Flag 802.11 */ TRUE,\
1014 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */, \
1015 /* Resource TC */ 0 /* Irrelevant */, \
1016 /* Flag 802.1x */ FALSE,\
1017 /* TX-done callback */ pfTxDoneHandler, \
1018 /* PS forwarding type*/ PS_FORWARDING_TYPE_NON_PS, \
1019 /* PS Session ID */ 0 /* Irrelevant */, \
1020 /* Flag fixed rate */ TRUE, \
1021 /* Fixed tx rate */ g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode, \
1022 /* Fixed-rate retry */ TXM_DEFAULT_DATA_FRAME_RETRY_LIMIT, \
1023 /* PAL LLH */ 0 /* Irrelevant */,\
1024 /* ACL SN */ 0 /* Irrelevant */,\
1025 /* Flag No Ack */ FALSE \
1028 /* Terminate with a NULL pointer */
1029 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo,NULL);
1031 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1033 /* Indicate the packet to TXM */
1034 //4 <4> Inform TXM to send this Null frame.
1035 txmSendFwDataPackets(prMsduInfo);
1038 prMsduInfo->eSrc = TX_PACKET_MGMT;
1039 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1040 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
1041 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
1042 prMsduInfo->ucMacHeaderLength = WLAN_MAC_HEADER_QOS_LEN;
1043 prMsduInfo->fgIs802_1x = FALSE;
1044 prMsduInfo->fgIs802_11 = TRUE;
1045 prMsduInfo->u2FrameLength = WLAN_MAC_HEADER_QOS_LEN;
1046 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1047 prMsduInfo->pfTxDoneHandler = pfTxDoneHandler;
1048 prMsduInfo->fgIsBasicRate = TRUE;
1050 //4 <4> Inform TXM to send this Null frame.
1051 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1053 return WLAN_STATUS_SUCCESS;
1055 } /* end of bssSendQoSNullFrame() */
1058 #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
1059 /*----------------------------------------------------------------------------*/
1060 /* Routines for both IBSS(AdHoc) and BSS(AP) */
1061 /*----------------------------------------------------------------------------*/
1062 /*----------------------------------------------------------------------------*/
1064 * @brief This function is used to generate Information Elements of Extended
1067 * @param[in] prAdapter Pointer to the Adapter structure.
1068 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1072 /*----------------------------------------------------------------------------*/
1074 bssGenerateExtSuppRate_IE (
1075 IN P_ADAPTER_T prAdapter,
1076 IN P_MSDU_INFO_T prMsduInfo
1079 P_BSS_INFO_T prBssInfo;
1081 UINT_8 ucExtSupRatesLen;
1086 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType]);
1089 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1090 (UINT_32)prMsduInfo->u2FrameLength);
1093 if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
1095 ucExtSupRatesLen = prBssInfo->ucAllSupportedRatesLen - ELEM_MAX_LEN_SUP_RATES;
1098 ucExtSupRatesLen = 0;
1101 /* Fill the Extended Supported Rates element. */
1102 if (ucExtSupRatesLen) {
1104 EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
1105 EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
1107 kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
1108 &prBssInfo->aucAllSupportedRates[ELEM_MAX_LEN_SUP_RATES],
1111 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1115 } /* end of bssGenerateExtSuppRate_IE() */
1118 /*----------------------------------------------------------------------------*/
1120 * @brief This function is used to compose Common Information Elements for Beacon
1121 * or Probe Response Frame.
1123 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1124 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
1125 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1129 /*----------------------------------------------------------------------------*/
1131 bssBuildBeaconProbeRespFrameCommonIEs (
1132 IN P_MSDU_INFO_T prMsduInfo,
1133 IN P_BSS_INFO_T prBssInfo,
1134 IN PUINT_8 pucDestAddr
1138 UINT_8 ucSupRatesLen;
1144 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1145 (UINT_32)prMsduInfo->u2FrameLength);
1148 /* Compose the frame body of the Probe Response frame. */
1149 //4 <1> Fill the SSID element.
1150 SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
1151 SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
1152 if (prBssInfo->ucSSIDLen) {
1153 kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
1156 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1157 pucBuffer += IE_SIZE(pucBuffer);
1160 //4 <2> Fill the Supported Rates element.
1161 if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
1163 ucSupRatesLen = ELEM_MAX_LEN_SUP_RATES;
1166 ucSupRatesLen = prBssInfo->ucAllSupportedRatesLen;
1169 if (ucSupRatesLen) {
1170 SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
1171 SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
1172 kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates,
1173 prBssInfo->aucAllSupportedRates,
1176 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1177 pucBuffer += IE_SIZE(pucBuffer);
1181 //4 <3> Fill the DS Parameter Set element.
1182 if (prBssInfo->eBand == BAND_2G4) {
1183 DS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_DS_PARAM_SET;
1184 DS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_DS_PARAMETER_SET;
1185 DS_PARAM_IE(pucBuffer)->ucCurrChnl = prBssInfo->ucPrimaryChannel;
1187 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1188 pucBuffer += IE_SIZE(pucBuffer);
1192 //4 <4> IBSS Parameter Set element, ID: 6
1193 if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
1194 IBSS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_IBSS_PARAM_SET;
1195 IBSS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_IBSS_PARAMETER_SET;
1196 WLAN_SET_FIELD_16(&(IBSS_PARAM_IE(pucBuffer)->u2ATIMWindow), prBssInfo->u2ATIMWindow);
1198 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1199 pucBuffer += IE_SIZE(pucBuffer);
1203 //4 <5> TIM element, ID: 5
1204 if ((!pucDestAddr) && // For Beacon only.
1205 (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)) {
1207 #if CFG_ENABLE_WIFI_DIRECT
1208 /*no fgIsP2PRegistered protect*/
1209 if (prBssInfo->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
1211 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
1212 UINT_8 ucBitmapControl = 0;
1216 prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
1218 // Clear existing value.
1219 prP2pSpecificBssInfo->ucBitmapCtrl = 0;
1220 kalMemZero(prP2pSpecificBssInfo->aucPartialVirtualBitmap,
1221 sizeof(prP2pSpecificBssInfo->aucPartialVirtualBitmap));
1224 // IEEE 802.11 2007 - 7.3.2.6
1225 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1226 TIM_IE(pucBuffer)->ucDTIMCount = prBssInfo->ucDTIMCount;
1227 TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
1229 // Setup DTIM Count for next TBTT.
1230 if (prBssInfo->ucDTIMCount == 0) {
1231 //3 *** pmQueryBufferedBCAST();
1234 //3 *** pmQueryBufferedPSNode();
1235 /* TODO(Kevin): Call PM Module here to loop all STA_RECORD_Ts and it
1236 * will call bssSetTIMBitmap to toggle the Bitmap.
1239 // Set Virtual Bitmap for UCAST
1240 u4N1 = (prP2pSpecificBssInfo->u2SmallestAID >> 4) << 1; // Find the largest even number.
1241 u4N2 = prP2pSpecificBssInfo->u2LargestAID >> 3; // Find the smallest number.
1243 ASSERT(u4N2 >= u4N1);
1245 kalMemCopy(TIM_IE(pucBuffer)->aucPartialVirtualMap,
1246 &prP2pSpecificBssInfo->aucPartialVirtualBitmap[u4N1],
1247 ((u4N2 - u4N1) + 1));
1249 // Set Virtual Bitmap for BMCAST
1250 // BMC bit only indicated when DTIM count == 0.
1251 if (prBssInfo->ucDTIMCount == 0) {
1252 ucBitmapControl = prP2pSpecificBssInfo->ucBitmapCtrl;
1254 TIM_IE(pucBuffer)->ucBitmapControl = ucBitmapControl | (UINT_8)u4N1;
1256 TIM_IE(pucBuffer)->ucLength = ((u4N2 - u4N1) + 4);
1258 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1261 // IEEE 802.11 2007 - 7.3.2.6
1262 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1263 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP)/*((u4N2 - u4N1) + 4)*/; // NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only)
1264 TIM_IE(pucBuffer)->ucDTIMCount = 0/*prBssInfo->ucDTIMCount*/; // will be overwrite by FW
1265 TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
1266 TIM_IE(pucBuffer)->ucBitmapControl = 0/*ucBitmapControl | (UINT_8)u4N1*/; // will be overwrite by FW
1268 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1274 #endif /* CFG_ENABLE_WIFI_DIRECT */
1276 /* NOTE(Kevin): 1. AIS - Didn't Support AP Mode.
1277 * 2. BOW - Didn't Support BCAST and PS.
1286 } /* end of bssBuildBeaconProbeRespFrameCommonIEs() */
1289 /*----------------------------------------------------------------------------*/
1291 * @brief This function will compose the Beacon/Probe Response frame header and
1294 * @param[in] pucBuffer Pointer to the frame buffer.
1295 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1296 * @param[in] pucOwnMACAddress Given Our MAC Address.
1297 * @param[in] pucBSSID Given BSSID of the BSS.
1298 * @param[in] u2BeaconInterval Given Beacon Interval.
1299 * @param[in] u2CapInfo Given Capability Info.
1303 /*----------------------------------------------------------------------------*/
1305 bssComposeBeaconProbeRespFrameHeaderAndFF (
1306 IN PUINT_8 pucBuffer,
1307 IN PUINT_8 pucDestAddr,
1308 IN PUINT_8 pucOwnMACAddress,
1309 IN PUINT_8 pucBSSID,
1310 IN UINT_16 u2BeaconInterval,
1311 IN UINT_16 u2CapInfo
1314 P_WLAN_BEACON_FRAME_T prBcnProbRspFrame;
1315 UINT_8 aucBCAddr[] = BC_MAC_ADDR;
1316 UINT_16 u2FrameCtrl;
1318 DEBUGFUNC("bssComposeBeaconProbeRespFrameHeaderAndFF");
1319 //DBGLOG(INIT, LOUD, ("\n"));
1323 ASSERT(pucOwnMACAddress);
1326 prBcnProbRspFrame = (P_WLAN_BEACON_FRAME_T)pucBuffer;
1328 //4 <1> Compose the frame header of the Beacon /ProbeResp frame.
1329 /* Fill the Frame Control field. */
1331 u2FrameCtrl = MAC_FRAME_PROBE_RSP;
1334 u2FrameCtrl = MAC_FRAME_BEACON;
1335 pucDestAddr = aucBCAddr;
1337 //WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2FrameCtrl, u2FrameCtrl);
1338 prBcnProbRspFrame->u2FrameCtrl = u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1340 /* Fill the DA field with BCAST MAC ADDR or TA of ProbeReq. */
1341 COPY_MAC_ADDR(prBcnProbRspFrame->aucDestAddr, pucDestAddr);
1343 /* Fill the SA field with our MAC Address. */
1344 COPY_MAC_ADDR(prBcnProbRspFrame->aucSrcAddr, pucOwnMACAddress);
1346 /* Fill the BSSID field with current BSSID. */
1347 COPY_MAC_ADDR(prBcnProbRspFrame->aucBSSID, pucBSSID);
1349 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
1350 prBcnProbRspFrame->u2SeqCtrl = 0;
1353 //4 <2> Compose the frame body's common fixed field part of the Beacon /ProbeResp frame.
1354 /* MAC will update TimeStamp field */
1356 /* Fill the Beacon Interval field. */
1357 //WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2BeaconInterval, u2BeaconInterval);
1358 prBcnProbRspFrame->u2BeaconInterval = u2BeaconInterval; // NOTE(Kevin): Optimized for ARM
1360 /* Fill the Capability Information field. */
1361 //WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2CapInfo, u2CapInfo);
1362 prBcnProbRspFrame->u2CapInfo = u2CapInfo; // NOTE(Kevin): Optimized for ARM
1365 } /* end of bssComposeBeaconProbeRespFrameHeaderAndFF() */
1368 /*----------------------------------------------------------------------------*/
1370 * @brief Update the Beacon Frame Template to FW for AIS AdHoc and P2P GO.
1372 * @param[in] prAdapter Pointer to the Adapter structure.
1373 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1375 * @retval WLAN_STATUS_SUCCESS Success.
1377 /*----------------------------------------------------------------------------*/
1379 bssUpdateBeaconContent (
1380 IN P_ADAPTER_T prAdapter,
1381 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
1384 P_BSS_INFO_T prBssInfo;
1385 P_MSDU_INFO_T prMsduInfo;
1386 P_WLAN_BEACON_FRAME_T prBcnFrame;
1389 DEBUGFUNC("bssUpdateBeaconContent");
1390 DBGLOG(INIT, LOUD, ("\n"));
1392 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1394 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1396 //4 <1> Allocate a PKT_INFO_T for Beacon Frame
1397 /* Allocate a MSDU_INFO_T */
1399 prMsduInfo = prBssInfo->prBeacon;
1401 // beacon prMsduInfo will be NULLify once BSS deactivated, so skip if it is
1402 if (prMsduInfo == NULL) {
1403 return WLAN_STATUS_SUCCESS;
1406 //4 <2> Compose header
1407 bssComposeBeaconProbeRespFrameHeaderAndFF(
1408 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
1410 prBssInfo->aucOwnMacAddr,
1411 prBssInfo->aucBSSID,
1412 prBssInfo->u2BeaconInterval,
1413 prBssInfo->u2CapInfo);
1416 prMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN +
1417 (TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN));
1419 prMsduInfo->ucNetworkType = eNetTypeIndex;
1421 //4 <3> Compose the frame body's Common IEs of the Beacon frame.
1422 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, NULL);
1425 //4 <4> Compose IEs in MSDU_INFO_T
1427 /* Append IE for Beacon */
1428 for (i = 0; i < sizeof(txBcnIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
1429 if (txBcnIETable[i].pfnAppendIE) {
1430 txBcnIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
1434 prBcnFrame = (P_WLAN_BEACON_FRAME_T)prMsduInfo->prPacket;
1436 return nicUpdateBeaconIETemplate(prAdapter,
1437 IE_UPD_METHOD_UPDATE_ALL,
1439 prBssInfo->u2CapInfo,
1440 (PUINT_8)prBcnFrame->aucInfoElem,
1441 prMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem));
1444 } /* end of bssUpdateBeaconContent() */
1447 /*----------------------------------------------------------------------------*/
1449 * @brief Send the Beacon Frame(for BOW) or Probe Response Frame according to the given
1450 * Destination Address.
1452 * @param[in] prAdapter Pointer to the Adapter structure.
1453 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1454 * @param[in] pucDestAddr Pointer to the Destination Address to reply
1455 * @param[in] u4ControlFlags Control flags for information on Probe Response.
1457 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
1458 * @retval WLAN_STATUS_SUCCESS Success.
1460 /*----------------------------------------------------------------------------*/
1462 bssSendBeaconProbeResponse (
1463 IN P_ADAPTER_T prAdapter,
1464 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
1465 IN PUINT_8 pucDestAddr,
1466 IN UINT_32 u4ControlFlags
1469 P_BSS_INFO_T prBssInfo;
1470 P_MSDU_INFO_T prMsduInfo;
1471 UINT_16 u2EstimatedFrameLen;
1472 UINT_16 u2EstimatedFixedIELen;
1473 UINT_16 u2EstimatedExtraIELen;
1474 P_APPEND_VAR_IE_ENTRY_T prIeArray = NULL;
1475 UINT_32 u4IeArraySize = 0;
1479 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1481 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1484 if (!pucDestAddr) { // For Beacon
1485 prIeArray = &txBcnIETable[0];
1486 u4IeArraySize = sizeof(txBcnIETable)/sizeof(APPEND_VAR_IE_ENTRY_T);
1489 prIeArray = &txProbRspIETable[0];
1490 u4IeArraySize = sizeof(txProbRspIETable)/sizeof(APPEND_VAR_IE_ENTRY_T);
1494 //4 <1> Allocate a PKT_INFO_T for Beacon /Probe Response Frame
1495 /* Allocate a MSDU_INFO_T */
1497 /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Fields */
1498 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
1499 WLAN_MAC_MGMT_HEADER_LEN + \
1500 TIMESTAMP_FIELD_LEN + \
1501 BEACON_INTERVAL_FIELD_LEN + \
1502 CAP_INFO_FIELD_LEN + \
1503 (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) + \
1504 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + \
1505 (ELEM_HDR_LEN + ELEM_MAX_LEN_DS_PARAMETER_SET) + \
1506 (ELEM_HDR_LEN + ELEM_MAX_LEN_IBSS_PARAMETER_SET) + \
1507 (ELEM_HDR_LEN + (3 + MAX_LEN_TIM_PARTIAL_BMP));
1509 /* + Extra IE Length */
1510 u2EstimatedExtraIELen = 0;
1512 for (i = 0; i < u4IeArraySize; i++) {
1513 u2EstimatedFixedIELen = prIeArray[i].u2EstimatedFixedIELen;
1515 if (u2EstimatedFixedIELen) {
1516 u2EstimatedExtraIELen += u2EstimatedFixedIELen;
1519 ASSERT(prIeArray[i].pfnCalculateVariableIELen);
1521 u2EstimatedExtraIELen += (UINT_16)
1522 prIeArray[i].pfnCalculateVariableIELen(prAdapter, eNetTypeIndex, NULL);
1526 u2EstimatedFrameLen += u2EstimatedExtraIELen;
1528 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
1529 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending %s.\n",
1530 ((!pucDestAddr)?"Beacon":"Probe Response")));
1531 return WLAN_STATUS_RESOURCES;
1535 //4 <2> Compose Beacon/Probe Response frame header and fixed fields in MSDU_INfO_T.
1536 /* Compose Header and Fixed Field */
1537 #if CFG_ENABLE_WIFI_DIRECT
1538 if (u4ControlFlags & BSS_PROBE_RESP_USE_P2P_DEV_ADDR) {
1539 if(prAdapter->fgIsP2PRegistered) {
1540 bssComposeBeaconProbeRespFrameHeaderAndFF(
1541 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
1543 prAdapter->rWifiVar.aucDeviceAddress,
1544 prAdapter->rWifiVar.aucDeviceAddress,
1545 DOT11_BEACON_PERIOD_DEFAULT,
1546 (prBssInfo->u2CapInfo & ~(CAP_INFO_ESS | CAP_INFO_IBSS)));
1550 #endif /* CFG_ENABLE_WIFI_DIRECT */
1552 bssComposeBeaconProbeRespFrameHeaderAndFF(
1553 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
1555 prBssInfo->aucOwnMacAddr,
1556 prBssInfo->aucBSSID,
1557 prBssInfo->u2BeaconInterval,
1558 prBssInfo->u2CapInfo);
1562 //4 <3> Update information of MSDU_INFO_T
1563 prMsduInfo->eSrc = TX_PACKET_MGMT;
1564 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1565 prMsduInfo->ucStaRecIndex = 0xFF;
1566 prMsduInfo->ucNetworkType = (UINT_8)eNetTypeIndex;
1567 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
1568 prMsduInfo->fgIs802_1x = FALSE;
1569 prMsduInfo->fgIs802_11 = TRUE;
1570 prMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN +
1571 TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN);
1572 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1573 prMsduInfo->pfTxDoneHandler = NULL;
1574 prMsduInfo->fgIsBasicRate = TRUE;
1577 //4 <4> Compose the frame body's Common IEs of the Beacon/ProbeResp frame.
1578 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, pucDestAddr);
1581 //4 <5> Compose IEs in MSDU_INFO_T
1584 for (i = 0; i < u4IeArraySize; i++) {
1585 if (prIeArray[i].pfnAppendIE) {
1586 prIeArray[i].pfnAppendIE(prAdapter, prMsduInfo);
1590 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1592 //4 <6> Inform TXM to send this Beacon /Probe Response frame.
1593 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1595 return WLAN_STATUS_SUCCESS;
1597 } /* end of bssSendBeaconProbeResponse() */
1600 /*----------------------------------------------------------------------------*/
1602 * @brief This function will process the Rx Probe Request Frame and then send
1603 * back the corresponding Probe Response Frame if the specified conditions
1606 * @param[in] prAdapter Pointer to the Adapter structure.
1607 * @param[in] prSwRfb Pointer to SW RFB data structure.
1609 * @retval WLAN_STATUS_SUCCESS Always return success
1611 /*----------------------------------------------------------------------------*/
1613 bssProcessProbeRequest (
1614 IN P_ADAPTER_T prAdapter,
1615 IN P_SW_RFB_T prSwRfb
1618 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
1619 P_BSS_INFO_T prBssInfo;
1620 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
1621 UINT_8 aucBCBSSID[] = BC_BSSID;
1622 BOOLEAN fgIsBcBssid;
1623 BOOLEAN fgReplyProbeResp;
1624 UINT_32 u4CtrlFlagsForProbeResp = 0;
1626 UINT_8 ucHwChannelNum;
1631 //4 <1> Parse Probe Req and Get BSSID
1632 prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T)prSwRfb->pvHeader;
1634 if (EQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID)) {
1638 fgIsBcBssid = FALSE;
1642 //4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent)
1643 for (eNetTypeIndex = NETWORK_TYPE_AIS_INDEX; eNetTypeIndex < NETWORK_TYPE_INDEX_NUM; eNetTypeIndex++) {
1645 if (!IS_NET_ACTIVE(prAdapter, eNetTypeIndex)) {
1649 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1651 if ((!fgIsBcBssid) &&
1652 UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID)) {
1656 eBand = HIF_RX_HDR_GET_RF_BAND(prSwRfb->prHifRxHdr);
1657 ucHwChannelNum = HIF_RX_HDR_GET_CHNL_NUM(prSwRfb->prHifRxHdr);
1659 if(prBssInfo->eBand != eBand) {
1663 if(prBssInfo->ucPrimaryChannel != ucHwChannelNum) {
1667 fgReplyProbeResp = FALSE;
1669 if (NETWORK_TYPE_AIS_INDEX == eNetTypeIndex) {
1671 #if CFG_SUPPORT_ADHOC
1672 fgReplyProbeResp = aisValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1675 #if CFG_ENABLE_WIFI_DIRECT
1676 else if ((prAdapter->fgIsP2PRegistered) &&
1677 (NETWORK_TYPE_P2P_INDEX == eNetTypeIndex)) {
1679 fgReplyProbeResp = p2pFuncValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1682 #if CFG_ENABLE_BT_OVER_WIFI
1683 else if (NETWORK_TYPE_BOW_INDEX == eNetTypeIndex) {
1685 fgReplyProbeResp = bowValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1689 if (fgReplyProbeResp) {
1690 if(nicTxGetFreeCmdCount(prAdapter) > (CFG_TX_MAX_CMD_PKT_NUM/2) ){
1691 /* Resource margin is enough */
1692 bssSendBeaconProbeResponse(prAdapter, eNetTypeIndex, prMgtHdr->aucSrcAddr, u4CtrlFlagsForProbeResp);
1697 return WLAN_STATUS_SUCCESS;
1699 } /* end of bssProcessProbeRequest() */
1702 #if 0 // NOTE(Kevin): condition check should move to P2P_FSM.c
1703 /*----------------------------------------------------------------------------*/
1705 * @brief This function will process the Rx Probe Request Frame and then send
1706 * back the corresponding Probe Response Frame if the specified conditions
1709 * @param[in] prSwRfb Pointer to SW RFB data structure.
1711 * @retval WLAN_STATUS_SUCCESS Always return success
1713 /*----------------------------------------------------------------------------*/
1715 bssProcessProbeRequest (
1716 IN P_ADAPTER_T prAdapter,
1717 IN P_SW_RFB_T prSwRfb
1720 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
1721 P_BSS_INFO_T prBssInfo;
1722 P_IE_SSID_T prIeSsid = (P_IE_SSID_T)NULL;
1723 P_IE_SUPPORTED_RATE_T prIeSupportedRate = (P_IE_SUPPORTED_RATE_T)NULL;
1724 P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate = (P_IE_EXT_SUPPORTED_RATE_T)NULL;
1727 UINT_16 u2Offset = 0;
1728 UINT_8 aucBCBSSID[] = BC_BSSID;
1729 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
1730 BOOLEAN fgReplyProbeResp;
1731 #if CFG_ENABLE_WIFI_DIRECT
1732 BOOLEAN fgP2PTargetDeviceFound;
1733 UINT_8 aucP2PWildcardSSID[] = P2P_WILDCARD_SSID;
1738 //4 <1> Parse Probe Req and Get SSID IE ptr
1739 prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T)prSwRfb->pvHeader;
1741 u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
1742 pucIE = (PUINT_8)((UINT_32)prSwRfb->pvHeader + prSwRfb->u2HeaderLen);
1744 prIeSsid = (P_IE_SSID_T)NULL;
1746 IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
1747 switch (IE_ID(pucIE)) {
1750 (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID)) {
1751 prIeSsid = (P_IE_SSID_T)pucIE;
1755 case ELEM_ID_SUP_RATES:
1756 /* NOTE(Kevin): Buffalo WHR-G54S's supported rate set IE exceed 8.
1757 * IE_LEN(pucIE) == 12, "1(B), 2(B), 5.5(B), 6(B), 9(B), 11(B),
1758 * 12(B), 18(B), 24(B), 36(B), 48(B), 54(B)"
1760 // if (IE_LEN(pucIE) <= ELEM_MAX_LEN_SUP_RATES) {
1761 if (IE_LEN(pucIE) <= RATE_NUM) {
1762 prIeSupportedRate = SUP_RATES_IE(pucIE);
1766 case ELEM_ID_EXTENDED_SUP_RATES:
1767 prIeExtSupportedRate = EXT_SUP_RATES_IE(pucIE);
1770 #if CFG_ENABLE_WIFI_DIRECT
1771 // TODO: P2P IE & WCS IE parsing for P2P.
1779 } /* end of IE_FOR_EACH */
1781 //4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent)
1782 for (eNetTypeIndex = NETWORK_TYPE_AIS_INDEX; eNetTypeIndex < NETWORK_TYPE_INDEX_NUM; eNetTypeIndex++) {
1784 if (!IS_NET_ACTIVE(prAdapter, eNetTypeIndex)) {
1788 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1790 if (UNEQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID) &&
1791 UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID)) {
1792 /* BSSID not Wildcard BSSID. */
1796 fgReplyProbeResp = FALSE;
1798 if (NETWORK_TYPE_AIS_INDEX == eNetTypeIndex) {
1800 if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
1802 /* TODO(Kevin): Check if we are IBSS Master. */
1806 if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
1807 EQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen,
1808 prIeSsid->aucSSID, prIeSsid->ucLength)) {
1809 fgReplyProbeResp = TRUE;
1815 #if CFG_ENABLE_WIFI_DIRECT
1816 else if (NETWORK_TYPE_P2P_INDEX == eNetTypeIndex) {
1818 // TODO(Kevin): Move following lines to p2p_fsm.c
1821 ((prIeSsid->ucLength == BC_SSID_LEN) ||
1822 (EQUAL_SSID(aucP2PWildcardSSID,
1823 P2P_WILDCARD_SSID_LEN,
1825 prIeSsid->ucLength)))) {
1826 // if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prMgtHdr->aucSrcAddr, pucIE, u2IELength)) {
1827 if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prSwRfb)) {
1828 /* Extand channel request time & cancel scan request. */
1829 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
1831 // TODO: RX probe request may not caused by LISTEN state.
1832 // TODO: It can be GO.
1833 /* Generally speaking, cancel a non-exist scan request is fine.
1834 * We can check P2P FSM here for only LISTEN state.
1837 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg;
1839 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1841 /* Abort JOIN process. */
1842 prScanCancelMsg = (P_MSG_SCN_SCAN_CANCEL)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_CANCEL));
1843 if (!prScanCancelMsg) {
1844 ASSERT(0); // Can't abort SCN FSM
1848 prScanCancelMsg->rMsgHdr.eMsgId = MID_P2P_SCN_SCAN_CANCEL;
1849 prScanCancelMsg->ucSeqNum = prP2pFsmInfo->ucSeqNumOfScnMsg;
1850 prScanCancelMsg->ucNetTypeIndex = (UINT_8)NETWORK_TYPE_P2P_INDEX;
1851 prScanCancelMsg->fgIsChannelExt = TRUE;
1853 mboxSendMsg(prAdapter,
1855 (P_MSG_HDR_T) prScanCancelMsg,
1856 MSG_SEND_METHOD_BUF);
1860 /* 1. Probe Request without SSID.
1861 * 2. Probe Request with SSID not Wildcard SSID & not P2P Wildcard SSID.
1867 if (prAdapter->rWifiVar.prP2pFsmInfo->eCurrentState == P2P_STATE_LISTEN) {
1868 // P2P 2.4.1 - P2P Devices shall not respond to Probe Request frames which only contain 11b rates only.
1869 if (prIeSupportedRate || prIeExtSupportedRate) {
1870 UINT_16 u2OperationalRateSet, u2BSSBasicRateSet;
1871 BOOLEAN fgIsUnknownBssBasicRate;
1873 rateGetRateSetFromIEs(prIeSupportedRate,
1874 prIeExtSupportedRate,
1875 &u2OperationalRateSet,
1876 &u2BSSBasicRateSet, /* Ignore any Basic Bit */
1877 &fgIsUnknownBssBasicRate);
1879 if (u2OperationalRateSet & ~RATE_SET_HR_DSSS) {
1885 // TODO: Check channel time before first check point to:
1886 /* If Target device is selected:
1887 * 1. Send XXXX request frame.
1889 * 1. Send Probe Response frame.
1892 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
1893 /* TODO(Kevin): During PROVISION state, can we reply Probe Response ? */
1896 * If we are GO, accept legacy client --> accept Wildcard SSID
1897 * If we are in Listen State, accept only P2P Device --> check P2P IE and WPS IE
1899 if (TRUE /* We are GO */) {
1901 UINT_8 aucSSID[]=P2P_WILDCARD_SSID;
1903 if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
1904 EQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen,
1905 prIeSsid->aucSSID, prIeSsid->ucLength) ||
1906 EQUAL_SSID(aucSSID, P2P_WILDCARD_SSID_LEN,
1907 prIeSsid->aucSSID, prIeSsid->ucLength)) {
1908 fgReplyProbeResp = TRUE;
1912 // else if (FALSE /* We are in Listen State */) {
1915 /* TODO(Kevin): Check P2P IE and WPS IE */
1920 #if CFG_ENABLE_BT_OVER_WIFI
1921 else if (NETWORK_TYPE_BOW_INDEX == eNetTypeIndex) {
1923 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
1924 /* TODO(Kevin): TBD */
1929 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1932 if (fgReplyProbeResp) {
1933 bssSendBeaconProbeResponse(prAdapter, eNetTypeIndex, prMgtHdr->aucSrcAddr);
1938 return WLAN_STATUS_SUCCESS;
1940 } /* end of bssProcessProbeRequest() */
1944 /*----------------------------------------------------------------------------*/
1946 * @brief This function is used to clear the client list for AdHoc or AP Mode
1948 * @param[in] prAdapter Pointer to the Adapter structure.
1949 * @param[in] prBssInfo Given related BSS_INFO_T.
1953 /*----------------------------------------------------------------------------*/
1955 bssClearClientList (
1956 IN P_ADAPTER_T prAdapter,
1957 IN P_BSS_INFO_T prBssInfo
1960 P_LINK_T prStaRecOfClientList;
1965 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
1967 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
1968 P_STA_RECORD_T prPeerStaRec;
1970 LINK_FOR_EACH_ENTRY(prPeerStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
1971 cnmStaRecChangeState(prAdapter, prPeerStaRec, STA_STATE_1);
1974 LINK_INITIALIZE(prStaRecOfClientList);
1978 } /* end of bssClearClientList() */
1982 /*----------------------------------------------------------------------------*/
1984 * @brief This function is used to Add a STA_RECORD_T to the client list for AdHoc or AP Mode
1986 * @param[in] prAdapter Pointer to the Adapter structure.
1987 * @param[in] prBssInfo Given related BSS_INFO_T.
1988 * @param[in] prStaRec Pointer to the STA_RECORD_T
1992 /*----------------------------------------------------------------------------*/
1994 bssAddStaRecToClientList (
1995 IN P_ADAPTER_T prAdapter,
1996 IN P_BSS_INFO_T prBssInfo,
1997 IN P_STA_RECORD_T prStaRec
2000 P_LINK_T prStaRecOfClientList;
2005 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
2007 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
2008 P_STA_RECORD_T prCurrStaRec;
2010 LINK_FOR_EACH_ENTRY(prCurrStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
2012 if (prCurrStaRec == prStaRec) {
2013 DBGLOG(BSS, WARN, ("Current Client List already contains that STA_RECORD_T["MACSTR"]\n",
2014 MAC2STR(prStaRec->aucMacAddr)));
2020 LINK_INSERT_TAIL(prStaRecOfClientList, &prStaRec->rLinkEntry);
2023 } /* end of bssAddStaRecToClientList() */
2026 /*----------------------------------------------------------------------------*/
2028 * @brief This function is used to Remove a STA_RECORD_T from the client list for AdHoc or AP Mode
2030 * @param[in] prAdapter Pointer to the Adapter structure.
2031 * @param[in] prStaRec Pointer to the STA_RECORD_T
2035 /*----------------------------------------------------------------------------*/
2037 bssRemoveStaRecFromClientList (
2038 IN P_ADAPTER_T prAdapter,
2039 IN P_BSS_INFO_T prBssInfo,
2040 IN P_STA_RECORD_T prStaRec
2043 P_LINK_T prStaRecOfClientList;
2048 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
2050 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
2051 P_STA_RECORD_T prCurrStaRec;
2053 LINK_FOR_EACH_ENTRY(prCurrStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
2055 if (prCurrStaRec == prStaRec) {
2057 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList, &prStaRec->rLinkEntry);
2064 DBGLOG(BSS, INFO, ("Current Client List didn't contain that STA_RECORD_T["MACSTR"] before removing.\n",
2065 MAC2STR(prStaRec->aucMacAddr)));
2068 } /* end of bssRemoveStaRecFromClientList() */
2069 #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
2072 #if CFG_SUPPORT_ADHOC
2073 /*----------------------------------------------------------------------------*/
2074 /* Routines for IBSS(AdHoc) only */
2075 /*----------------------------------------------------------------------------*/
2076 /*----------------------------------------------------------------------------*/
2078 * @brief This function is used to process Beacons from current Ad-Hoc network peers.
2079 * We also process Beacons from other Ad-Hoc network during SCAN. If it has
2080 * the same SSID and we'll decide to merge into it if it has a larger TSF.
2082 * @param[in] prAdapter Pointer to the Adapter structure.
2083 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2084 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2088 /*----------------------------------------------------------------------------*/
2090 ibssProcessMatchedBeacon (
2091 IN P_ADAPTER_T prAdapter,
2092 IN P_BSS_INFO_T prBssInfo,
2093 IN P_BSS_DESC_T prBssDesc,
2097 P_STA_RECORD_T prStaRec = NULL;
2099 BOOLEAN fgIsCheckCapability = FALSE;
2100 BOOLEAN fgIsCheckTSF = FALSE;
2101 BOOLEAN fgIsGoingMerging = FALSE;
2102 BOOLEAN fgIsSameBSSID;
2108 //4 <1> Process IBSS Beacon only after we create or merge with other IBSS.
2109 if (!prBssInfo->fgIsBeaconActivated) {
2113 //4 <2> Get the STA_RECORD_T of TA.
2114 prStaRec = cnmGetStaRecByAddress(prAdapter,
2115 (UINT_8) NETWORK_TYPE_AIS_INDEX,
2116 prBssDesc->aucSrcAddr);
2118 fgIsSameBSSID = UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID) ? FALSE : TRUE;
2121 //4 <3> IBSS Merge Decision Flow for Processing Beacon.
2122 if (fgIsSameBSSID) {
2125 * Case I. This is a new TA and it has decide to merged with us.
2126 * a) If fgIsMerging == FALSE - we will send msg to notify AIS.
2127 * b) If fgIsMerging == TRUE - already notify AIS.
2128 * Case II. This is an old TA and we've already merged together.
2132 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2133 fgIsCheckCapability = TRUE;
2135 /* If check is passed, then we perform merging with this new IBSS */
2136 fgIsGoingMerging = TRUE;
2141 ASSERT((prStaRec->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) &&
2142 IS_ADHOC_STA(prStaRec));
2144 if (prStaRec->ucStaState != STA_STATE_3) {
2146 if (!prStaRec->fgIsMerging) {
2148 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2149 fgIsCheckCapability = TRUE;
2151 /* If check is passed, then we perform merging with this new IBSS */
2152 fgIsGoingMerging = TRUE;
2155 /* For Case II - Update rExpirationTime of Sta Record */
2156 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
2160 /* For Case II - Update rExpirationTime of Sta Record */
2161 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
2169 * Case III. This is a new TA and we need to compare the TSF and get the winner.
2170 * Case IV. This is an old TA and it merge into a new IBSS before we do the same thing.
2171 * We need to compare the TSF to get the winner.
2172 * Case V. This is an old TA and it restart a new IBSS. We also need to
2173 * compare the TSF to get the winner.
2176 /* For Case III, IV & V - We'll always check this new IBSS's capability first
2177 * before merging into new IBSS.
2179 fgIsCheckCapability = TRUE;
2181 /* If check is passed, we need to perform TSF check to decide the major BSSID */
2182 fgIsCheckTSF = TRUE;
2184 /* For Case IV & V - We won't update rExpirationTime of Sta Record */
2188 //4 <7> Check this BSS_DESC_T's capability.
2189 if (fgIsCheckCapability) {
2190 BOOLEAN fgIsCapabilityMatched = FALSE;
2193 if (!(prBssDesc->ucPhyTypeSet & (prAdapter->rWifiVar.ucAvailablePhyTypeSet))) {
2195 ("IBSS MERGE: Ignore Peer MAC: "MACSTR" - Unsupported Phy.\n",
2196 MAC2STR(prBssDesc->aucSrcAddr)));
2201 if (prBssDesc->fgIsUnknownBssBasicRate) {
2203 ("IBSS MERGE: Ignore Peer MAC: "MACSTR" - Unknown Basic Rate.\n",
2204 MAC2STR(prBssDesc->aucSrcAddr)));
2209 if (ibssCheckCapabilityForAdHocMode(prAdapter, prBssDesc) == WLAN_STATUS_FAILURE) {
2211 ("IBSS MERGE: Ignore Peer MAC: "MACSTR" - Capability is not matched.\n",
2212 MAC2STR(prBssDesc->aucSrcAddr)));
2217 fgIsCapabilityMatched = TRUE;
2221 if (!fgIsCapabilityMatched) {
2224 /* For Case II - We merge this STA_RECORD in RX Path.
2225 * Case IV & V - They change their BSSID after we merge with them.
2229 ("IBSS MERGE: Ignore Peer MAC: "MACSTR" - Capability is not matched.\n",
2230 MAC2STR(prBssDesc->aucSrcAddr)));
2237 ("IBSS MERGE: Peer MAC: "MACSTR" - Check capability was passed.\n",
2238 MAC2STR(prBssDesc->aucSrcAddr)));
2244 fgIsGoingMerging = TRUE;
2246 if (prBssDesc->fgIsLargerTSF) {
2247 fgIsGoingMerging = TRUE;
2256 if (fgIsGoingMerging) {
2257 P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg;
2260 //4 <1> We will merge with to this BSS immediately.
2261 prBssDesc->fgIsConnecting = TRUE;
2262 prBssDesc->fgIsConnected = FALSE;
2264 //4 <2> Setup corresponding STA_RECORD_T
2265 prStaRec = bssCreateStaRecFromBssDesc(prAdapter,
2266 STA_TYPE_ADHOC_PEER,
2267 NETWORK_TYPE_AIS_INDEX,
2275 prStaRec->fgIsMerging = TRUE;
2278 prStaRec->ucRCPI = ucRCPI;
2280 //4 <3> Send Merge Msg to CNM to obtain the channel privilege.
2281 prAisIbssPeerFoundMsg = (P_MSG_AIS_IBSS_PEER_FOUND_T)
2282 cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_AIS_IBSS_PEER_FOUND_T));
2284 if (!prAisIbssPeerFoundMsg) {
2286 ASSERT(0); // Can't send Merge Msg
2290 prAisIbssPeerFoundMsg->rMsgHdr.eMsgId = MID_SCN_AIS_FOUND_IBSS;
2291 prAisIbssPeerFoundMsg->ucNetTypeIndex = (UINT_8)NETWORK_TYPE_AIS_INDEX;
2292 prAisIbssPeerFoundMsg->prStaRec = prStaRec;
2294 /* Inform AIS to do STATE TRANSITION
2295 * For Case I - If AIS in IBSS_ALONE, let it jump to NORMAL_TR after we know the new member.
2296 * For Case III, IV - Now this new BSSID wins the TSF, follow it.
2298 if (fgIsSameBSSID) {
2299 prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
2303 prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
2305 prAisIbssPeerFoundMsg->fgIsMergeIn = (prBssDesc->fgIsLargerTSF) ? FALSE: TRUE;
2309 mboxSendMsg(prAdapter,
2311 (P_MSG_HDR_T) prAisIbssPeerFoundMsg,
2312 MSG_SEND_METHOD_BUF);
2317 } /* end of ibssProcessMatchedBeacon() */
2320 /*----------------------------------------------------------------------------*/
2322 * @brief This function will check the Capability for Ad-Hoc to decide if we are
2323 * able to merge with(same capability).
2325 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2327 * @retval WLAN_STATUS_FAILURE Can't pass the check of Capability.
2328 * @retval WLAN_STATUS_SUCCESS Pass the check of Capability.
2330 /*----------------------------------------------------------------------------*/
2332 ibssCheckCapabilityForAdHocMode (
2333 IN P_ADAPTER_T prAdapter,
2334 IN P_BSS_DESC_T prBssDesc
2337 P_CONNECTION_SETTINGS_T prConnSettings;
2338 WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
2342 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2345 //4 <1> Check the BSS Basic Rate Set for current AdHoc Mode
2346 if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11B) &&
2347 (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_HR_DSSS)) {
2350 else if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11A) &&
2351 (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_OFDM)) {
2355 //4 <2> Check the Short Slot Time.
2356 #if 0 // Do not check ShortSlotTime until Wi-Fi define such policy
2357 if (prConnSettings->eAdHocMode == AD_HOC_MODE_11G) {
2358 if (((prConnSettings->fgIsShortSlotTimeOptionEnable) &&
2359 !(prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME)) ||
2360 (!(prConnSettings->fgIsShortSlotTimeOptionEnable) &&
2361 (prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME))) {
2367 //4 <3> Check the ATIM window setting.
2368 if (prBssDesc->u2ATIMWindow) {
2369 DBGLOG(BSS, INFO, ("AdHoc PS was not supported(ATIM Window: %d)\n",
2370 prBssDesc->u2ATIMWindow));
2374 #if CFG_RSN_MIGRATION
2375 //4 <4> Check the Security setting.
2376 if (!rsnPerformPolicySelection(prAdapter, prBssDesc)) {
2381 rStatus = WLAN_STATUS_SUCCESS;
2387 } /* end of ibssCheckCapabilityForAdHocMode() */
2390 /*----------------------------------------------------------------------------*/
2392 * @brief This function will initial the BSS_INFO_T for IBSS Mode.
2394 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2398 /*----------------------------------------------------------------------------*/
2401 IN P_ADAPTER_T prAdapter,
2402 IN P_BSS_INFO_T prBssInfo
2405 UINT_8 ucLowestBasicRateIndex;
2406 UINT_8 aucBSSID[MAC_ADDR_LEN];
2407 PUINT_16 pu2BSSID = (PUINT_16)&aucBSSID[0];
2412 ASSERT(prBssInfo->eCurrentOPMode == OP_MODE_IBSS);
2415 //4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set
2416 prBssInfo->ucNonHTBasicPhyType = (UINT_8)
2417 rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
2418 prBssInfo->u2BSSBasicRateSet =
2419 rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
2422 prBssInfo->u2OperationalRateSet =
2423 rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
2425 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
2426 prBssInfo->u2BSSBasicRateSet,
2427 prBssInfo->aucAllSupportedRates,
2428 &prBssInfo->ucAllSupportedRatesLen);
2431 if (!prBssInfo->fgHoldSameBssidForIBSS) {
2433 for (i = 0; i < sizeof(aucBSSID)/sizeof(UINT_16); i++) {
2434 pu2BSSID[i] = (UINT_16)(kalRandomNumber() & 0xFFFF);
2437 aucBSSID[0] &= ~0x01; // 7.1.3.3.3 - The individual/group bit of the address is set to 0.
2438 aucBSSID[0] |= 0x02; // 7.1.3.3.3 - The universal/local bit of the address is set to 1.
2440 COPY_MAC_ADDR(prBssInfo->aucBSSID, aucBSSID);
2444 //4 <3> Setup Capability - Short Preamble
2445 if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented &&
2446 ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
2447 (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO)) ) {
2449 prBssInfo->fgIsShortPreambleAllowed = TRUE;
2450 prBssInfo->fgUseShortPreamble = TRUE;
2453 prBssInfo->fgIsShortPreambleAllowed = FALSE;
2454 prBssInfo->fgUseShortPreamble = FALSE;
2458 //4 <4> Setup Capability - Short Slot Time
2459 // 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0.
2460 prBssInfo->fgUseShortSlotTime = FALSE; /* Set to FALSE for AdHoc */
2463 //4 <5> Compoase Capability
2464 prBssInfo->u2CapInfo = CAP_INFO_IBSS;
2466 if (prBssInfo->fgIsProtection) {
2467 prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
2470 if (prBssInfo->fgIsShortPreambleAllowed) {
2471 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
2474 if (prBssInfo->fgUseShortSlotTime) {
2475 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
2479 //4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU
2480 rateGetLowestRateIndexFromRateSet(prBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex);
2482 prBssInfo->ucHwDefaultFixedRateCode =
2483 aucRateIndex2RateCode[PREAMBLE_DEFAULT_LONG_NONE][ucLowestBasicRateIndex];
2486 } /* end of ibssInitForAdHoc() */
2488 #endif /* CFG_SUPPORT_ADHOC */
2493 /*----------------------------------------------------------------------------*/
2494 /* Routines for BSS(AP) only */
2495 /*----------------------------------------------------------------------------*/
2496 /*----------------------------------------------------------------------------*/
2498 * @brief This function will initial the BSS_INFO_T for AP Mode.
2500 * @param[in] prBssInfo Given related BSS_INFO_T.
2504 /*----------------------------------------------------------------------------*/
2507 IN P_ADAPTER_T prAdapter,
2508 IN P_BSS_INFO_T prBssInfo,
2509 IN BOOLEAN fgIsRateUpdate
2512 UINT_8 ucLowestBasicRateIndex;
2514 P_AC_QUE_PARMS_T prACQueParms;
2516 ENUM_WMM_ACI_T eAci;
2518 UINT_8 auCWminLog2ForBcast[WMM_AC_INDEX_NUM] = { 4/*BE*/, 4 /*BK*/, 3/*VO*/, 2/*VI*/};
2519 UINT_8 auCWmaxLog2ForBcast[WMM_AC_INDEX_NUM] = { 10, 10, 4, 3};
2520 UINT_8 auAifsForBcast[WMM_AC_INDEX_NUM] = { 3, 7, 2, 2 };
2521 UINT_8 auTxopForBcast[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2523 UINT_8 auCWminLog2[WMM_AC_INDEX_NUM] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/};
2524 UINT_8 auCWmaxLog2[WMM_AC_INDEX_NUM] = { 7, 10, 4, 3};
2525 UINT_8 auAifs[WMM_AC_INDEX_NUM] = { 3, 7, 1, 1 };
2526 UINT_8 auTxop[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2528 DEBUGFUNC("bssInitForAP");
2529 DBGLOG(BSS, LOUD,("\n"));
2532 ASSERT((prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) || (prBssInfo->eCurrentOPMode == OP_MODE_BOW));
2535 prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled = TRUE;
2536 prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode = CONFIG_BW_20M;
2537 prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode = CONFIG_BW_20M;
2541 //4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set
2542 prBssInfo->ucNonHTBasicPhyType = (UINT_8)
2543 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
2544 prBssInfo->u2BSSBasicRateSet =
2545 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
2548 prBssInfo->u2OperationalRateSet =
2549 rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
2551 if (fgIsRateUpdate) {
2552 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
2553 prBssInfo->u2BSSBasicRateSet,
2554 prBssInfo->aucAllSupportedRates,
2555 &prBssInfo->ucAllSupportedRatesLen);
2559 COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssInfo->aucOwnMacAddr);
2562 //4 <3> Setup Capability - Short Preamble
2563 if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented &&
2564 ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
2565 (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO)) ) {
2567 prBssInfo->fgIsShortPreambleAllowed = TRUE;
2568 prBssInfo->fgUseShortPreamble = TRUE;
2571 prBssInfo->fgIsShortPreambleAllowed = FALSE;
2572 prBssInfo->fgUseShortPreamble = FALSE;
2576 //4 <4> Setup Capability - Short Slot Time
2577 prBssInfo->fgUseShortSlotTime = TRUE;
2579 //4 <5> Compoase Capability
2580 prBssInfo->u2CapInfo = CAP_INFO_ESS;
2582 if (prBssInfo->fgIsProtection) {
2583 prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
2586 if (prBssInfo->fgIsShortPreambleAllowed) {
2587 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
2590 if (prBssInfo->fgUseShortSlotTime) {
2591 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
2595 //4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU
2596 rateGetLowestRateIndexFromRateSet(prBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex);
2598 prBssInfo->ucHwDefaultFixedRateCode =
2599 aucRateIndex2RateCode[PREAMBLE_DEFAULT_LONG_NONE][ucLowestBasicRateIndex];
2602 //4 <7> Fill the EDCA
2604 prACQueParms = prBssInfo->arACQueParmsForBcast;
2606 for(eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++){
2608 prACQueParms[eAci].fgIsACMSet = FALSE;
2609 prACQueParms[eAci].u2Aifsn = auAifsForBcast[eAci];
2610 prACQueParms[eAci].u2CWmin = BIT(auCWminLog2ForBcast[eAci])-1;
2611 prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2ForBcast[eAci])-1;
2612 prACQueParms[eAci].u2TxopLimit = auTxopForBcast[eAci];
2614 prBssInfo->aucCWminLog2ForBcast[eAci] = auCWminLog2ForBcast[eAci] ; /* used to send WMM IE */
2615 prBssInfo->aucCWmaxLog2ForBcast[eAci] = auCWmaxLog2ForBcast[eAci] ;
2617 DBGLOG(BSS, INFO, ("Bcast: eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2618 eAci,prACQueParms[eAci].fgIsACMSet ,
2619 prACQueParms[eAci].u2Aifsn,
2620 prACQueParms[eAci].u2CWmin,
2621 prACQueParms[eAci].u2CWmax,
2622 prACQueParms[eAci].u2TxopLimit));
2626 prACQueParms = prBssInfo->arACQueParms;
2628 for(eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++){
2630 prACQueParms[eAci].fgIsACMSet = FALSE;
2631 prACQueParms[eAci].u2Aifsn = auAifs[eAci];
2632 prACQueParms[eAci].u2CWmin = BIT(auCWminLog2[eAci])-1;
2633 prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2[eAci])-1;
2634 prACQueParms[eAci].u2TxopLimit = auTxop[eAci];
2636 DBGLOG(BSS, INFO, ("eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2637 eAci,prACQueParms[eAci].fgIsACMSet ,
2638 prACQueParms[eAci].u2Aifsn,
2639 prACQueParms[eAci].u2CWmin,
2640 prACQueParms[eAci].u2CWmax,
2641 prACQueParms[eAci].u2TxopLimit));
2644 /* Note: Caller should update the EDCA setting to HW by nicQmUpdateWmmParms() it there is no AIS network */
2645 /* Note: In E2, only 4 HW queues. The the Edca parameters should be folow by AIS network */
2646 /* Note: In E3, 8 HW queues. the Wmm parameters should be updated to right queues according to BSS */
2650 } /* end of bssInitForAP() */
2653 /*----------------------------------------------------------------------------*/
2655 * @brief Update DTIM Count
2657 * @param[in] eNetTypeIndex Specify which network to update
2661 /*----------------------------------------------------------------------------*/
2663 bssUpdateDTIMCount (
2664 IN P_ADAPTER_T prAdapter,
2665 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
2668 P_BSS_INFO_T prBssInfo;
2671 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
2673 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
2675 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
2677 // Setup DTIM Count for next TBTT.
2678 if (prBssInfo->ucDTIMCount > 0) {
2679 prBssInfo->ucDTIMCount--;
2683 ASSERT(prBssInfo->ucDTIMPeriod > 0);
2685 prBssInfo->ucDTIMCount = prBssInfo->ucDTIMPeriod - 1;
2690 } /* end of bssUpdateDTIMIE() */
2693 /*----------------------------------------------------------------------------*/
2695 * @brief This function is used to set the Virtual Bitmap in TIM Information Elements
2697 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2698 * @param[in] u2AssocId The association id to set in Virtual Bitmap.
2702 /*----------------------------------------------------------------------------*/
2705 IN P_ADAPTER_T prAdapter,
2706 IN P_BSS_INFO_T prBssInfo,
2707 IN UINT_16 u2AssocId
2713 if (prBssInfo->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
2714 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
2717 prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
2719 /* Use Association ID == 0 for BMCAST indication */
2720 if (u2AssocId == 0) {
2722 prP2pSpecificBssInfo->ucBitmapCtrl |= (UINT_8)BIT(0);
2725 PUINT_8 pucPartialVirtualBitmap;
2726 UINT_8 ucBitmapToSet;
2729 pucPartialVirtualBitmap = &prP2pSpecificBssInfo->aucPartialVirtualBitmap[(u2AssocId >> 3)]; // (u2AssocId / 8)
2730 ucBitmapToSet = (UINT_8) BIT((u2AssocId % 8));
2732 if (*pucPartialVirtualBitmap & ucBitmapToSet) {
2733 /* The virtual bitmap has been set */
2737 *pucPartialVirtualBitmap |= ucBitmapToSet;
2739 // Update u2SmallestAID and u2LargestAID
2740 if ((u2AssocId < prP2pSpecificBssInfo->u2SmallestAID) ||
2741 (prP2pSpecificBssInfo->u2SmallestAID == 0)) {
2742 prP2pSpecificBssInfo->u2SmallestAID = u2AssocId;
2745 if ((u2AssocId > prP2pSpecificBssInfo->u2LargestAID) ||
2746 (prP2pSpecificBssInfo->u2LargestAID == 0)) {
2747 prP2pSpecificBssInfo->u2LargestAID = u2AssocId;
2753 } /* end of bssSetTIMBitmap() */
2756 #endif /* CFG_SUPPORT_AAA */
2760 bssCreateStaRecFromAuth (
2761 IN P_ADAPTER_T prAdapter
2769 bssUpdateStaRecFromAssocReq (
2770 IN P_ADAPTER_T prAdapter