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 30 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(IN P_ADAPTER_T prAdapter
,
569 IN ENUM_STA_TYPE_T eStaType
,
570 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
, IN P_BSS_DESC_T prBssDesc
)
572 P_STA_RECORD_T prStaRec
;
573 UINT_8 ucNonHTPhyTypeSet
;
578 /* 4 <1> Get a valid STA_RECORD_T */
579 prStaRec
= cnmGetStaRecByAddress(prAdapter
, (UINT_8
) eNetTypeIndex
, prBssDesc
->aucSrcAddr
);
582 prStaRec
= cnmStaRecAlloc(prAdapter
, (UINT_8
) eNetTypeIndex
);
584 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
585 * exhausted case and do removal of unused STA_RECORD_T.
595 prStaRec
->ucJoinFailureCount
= 0;
596 /* TODO(Kevin): If this is an old entry, we may also reset the ucJoinFailureCount to 0.
599 COPY_MAC_ADDR(prStaRec
->aucMacAddr
, prBssDesc
->aucSrcAddr
);
602 /* 4 <2> Setup STA TYPE and NETWORK */
603 prStaRec
->eStaType
= eStaType
;
605 prStaRec
->ucNetTypeIndex
= eNetTypeIndex
;
608 /* 4 <3> Update information from BSS_DESC_T to current P_STA_RECORD_T */
609 prStaRec
->u2CapInfo
= prBssDesc
->u2CapInfo
;
611 prStaRec
->u2OperationalRateSet
= prBssDesc
->u2OperationalRateSet
;
612 prStaRec
->u2BSSBasicRateSet
= prBssDesc
->u2BSSBasicRateSet
;
614 prStaRec
->ucPhyTypeSet
= prBssDesc
->ucPhyTypeSet
;
616 if (!((prAdapter
->rWifiVar
.rConnSettings
.eEncStatus
== ENUM_ENCRYPTION3_ENABLED
) ||
617 (prAdapter
->rWifiVar
.rConnSettings
.eEncStatus
== ENUM_ENCRYPTION3_KEY_ABSENT
) ||
618 (prAdapter
->rWifiVar
.rConnSettings
.eEncStatus
== ENUM_ENCRYPTION_DISABLED
) ||
619 (prAdapter
->prGlueInfo
->u2WSCAssocInfoIELen
) ||
620 (prAdapter
->prGlueInfo
->u2WapiAssocInfoIESz
))) {
621 DBGLOG(BSS
, INFO
, ("Ignore the HT Bit for TKIP as pairwise cipher configed!\n"));
622 prStaRec
->ucPhyTypeSet
&= ~PHY_TYPE_BIT_HT
;
625 prStaRec
->ucDesiredPhyTypeSet
=
626 prStaRec
->ucPhyTypeSet
& prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
;
628 ucNonHTPhyTypeSet
= prStaRec
->ucDesiredPhyTypeSet
& PHY_TYPE_SET_802_11ABG
;
630 /* Check for Target BSS's non HT Phy Types */
631 if (ucNonHTPhyTypeSet
) {
633 if (ucNonHTPhyTypeSet
& PHY_TYPE_BIT_ERP
) {
634 prStaRec
->ucNonHTBasicPhyType
= PHY_TYPE_ERP_INDEX
;
635 } else if (ucNonHTPhyTypeSet
& PHY_TYPE_BIT_OFDM
) {
636 prStaRec
->ucNonHTBasicPhyType
= PHY_TYPE_OFDM_INDEX
;
637 } else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
639 prStaRec
->ucNonHTBasicPhyType
= PHY_TYPE_HR_DSSS_INDEX
;
642 prStaRec
->fgHasBasicPhyType
= TRUE
;
644 /* Use mandatory for 11N only BSS */
645 ASSERT(prStaRec
->ucPhyTypeSet
& PHY_TYPE_SET_802_11N
);
648 /* TODO(Kevin): which value should we set for 11n ? ERP ? */
649 prStaRec
->ucNonHTBasicPhyType
= PHY_TYPE_HR_DSSS_INDEX
;
652 prStaRec
->fgHasBasicPhyType
= FALSE
;
655 /* Update non HT Desired Rate Set */
657 P_CONNECTION_SETTINGS_T prConnSettings
;
660 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
662 prStaRec
->u2DesiredNonHTRateSet
=
663 (prStaRec
->u2OperationalRateSet
& prConnSettings
->u2DesiredNonHTRateSet
);
666 /* 4 <4> Update information from BSS_DESC_T to current P_STA_RECORD_T */
667 if (IS_AP_STA(prStaRec
)) {
668 /* do not need to parse IE for DTIM,
669 * which have been parsed before inserting into BSS_DESC_T
671 if (prBssDesc
->ucDTIMPeriod
) {
672 prStaRec
->ucDTIMPeriod
= prBssDesc
->ucDTIMPeriod
;
674 prStaRec
->ucDTIMPeriod
= 0; /* Means that TIM was not parsed. */
678 /* 4 <5> Update default value */
679 prStaRec
->fgDiagnoseConnection
= FALSE
;
682 /* 4 <6> Update default value for other Modules */
683 /* Determine fgIsWmmSupported and fgIsUapsdSupported in STA_REC */
684 mqmProcessScanResult(prAdapter
, prBssDesc
, prStaRec
);
688 } /* end of bssCreateStaRecFromBssDesc() */
691 /*----------------------------------------------------------------------------*/
693 * @brief This function will compose the Null Data frame.
695 * @param[in] prAdapter Pointer to the Adapter structure.
696 * @param[in] pucBuffer Pointer to the frame buffer.
697 * @param[in] prStaRec Pointer to the STA_RECORD_T.
701 /*----------------------------------------------------------------------------*/
702 VOID
bssComposeNullFrame(IN P_ADAPTER_T prAdapter
, IN PUINT_8 pucBuffer
, IN P_STA_RECORD_T prStaRec
)
704 P_WLAN_MAC_HEADER_T prNullFrame
;
705 P_BSS_INFO_T prBssInfo
;
711 ASSERT(prStaRec
->ucNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
713 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[prStaRec
->ucNetTypeIndex
]);
717 prNullFrame
= (P_WLAN_MAC_HEADER_T
) pucBuffer
;
719 /* 4 <1> Decide the Frame Control Field */
720 u2FrameCtrl
= MAC_FRAME_NULL
;
722 if (IS_AP_STA(prStaRec
)) {
723 u2FrameCtrl
|= MASK_FC_TO_DS
;
725 if (prStaRec
->fgSetPwrMgtBit
) {
726 u2FrameCtrl
|= MASK_FC_PWR_MGT
;
728 } else if (IS_CLIENT_STA(prStaRec
)) {
729 u2FrameCtrl
|= MASK_FC_FROM_DS
;
730 } else if (IS_DLS_STA(prStaRec
)) {
733 /* NOTE(Kevin): We won't send Null frame for IBSS */
738 /* 4 <2> Compose the Null frame */
739 /* Fill the Frame Control field. */
740 /* WLAN_SET_FIELD_16(&prNullFrame->u2FrameCtrl, u2FrameCtrl); */
741 prNullFrame
->u2FrameCtrl
= u2FrameCtrl
; /* NOTE(Kevin): Optimized for ARM */
743 /* Fill the Address 1 field with Target Peer Address. */
744 COPY_MAC_ADDR(prNullFrame
->aucAddr1
, prStaRec
->aucMacAddr
);
746 /* Fill the Address 2 field with our MAC Address. */
747 COPY_MAC_ADDR(prNullFrame
->aucAddr2
, prBssInfo
->aucOwnMacAddr
);
749 /* Fill the Address 3 field with Target BSSID. */
750 COPY_MAC_ADDR(prNullFrame
->aucAddr3
, prBssInfo
->aucBSSID
);
752 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
753 prNullFrame
->u2SeqCtrl
= 0;
757 } /* end of bssComposeNullFrameHeader() */
760 /*----------------------------------------------------------------------------*/
762 * @brief This function will compose the QoS Null Data frame.
764 * @param[in] prAdapter Pointer to the Adapter structure.
765 * @param[in] pucBuffer Pointer to the frame buffer.
766 * @param[in] prStaRec Pointer to the STA_RECORD_T.
767 * @param[in] ucUP User Priority.
768 * @param[in] fgSetEOSP Set the EOSP bit.
772 /*----------------------------------------------------------------------------*/
774 bssComposeQoSNullFrame(IN P_ADAPTER_T prAdapter
,
775 IN PUINT_8 pucBuffer
,
776 IN P_STA_RECORD_T prStaRec
, IN UINT_8 ucUP
, IN BOOLEAN fgSetEOSP
)
778 P_WLAN_MAC_HEADER_QOS_T prQoSNullFrame
;
779 P_BSS_INFO_T prBssInfo
;
781 UINT_16 u2QosControl
;
786 ASSERT(prStaRec
->ucNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
788 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[prStaRec
->ucNetTypeIndex
]);
792 prQoSNullFrame
= (P_WLAN_MAC_HEADER_QOS_T
) pucBuffer
;
794 /* 4 <1> Decide the Frame Control Field */
795 u2FrameCtrl
= MAC_FRAME_QOS_NULL
;
797 if (IS_AP_STA(prStaRec
)) {
798 u2FrameCtrl
|= MASK_FC_TO_DS
;
800 if (prStaRec
->fgSetPwrMgtBit
) {
801 u2FrameCtrl
|= MASK_FC_PWR_MGT
;
803 } else if (IS_CLIENT_STA(prStaRec
)) {
804 u2FrameCtrl
|= MASK_FC_FROM_DS
;
805 } else if (IS_DLS_STA(prStaRec
)) {
808 /* NOTE(Kevin): We won't send QoS Null frame for IBSS */
813 /* 4 <2> Compose the QoS Null frame */
814 /* Fill the Frame Control field. */
815 /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2FrameCtrl, u2FrameCtrl); */
816 prQoSNullFrame
->u2FrameCtrl
= u2FrameCtrl
; /* NOTE(Kevin): Optimized for ARM */
818 /* Fill the Address 1 field with Target Peer Address. */
819 COPY_MAC_ADDR(prQoSNullFrame
->aucAddr1
, prStaRec
->aucMacAddr
);
821 /* Fill the Address 2 field with our MAC Address. */
822 COPY_MAC_ADDR(prQoSNullFrame
->aucAddr2
, prBssInfo
->aucOwnMacAddr
);
824 /* Fill the Address 3 field with Target BSSID. */
825 COPY_MAC_ADDR(prQoSNullFrame
->aucAddr3
, prBssInfo
->aucBSSID
);
827 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
828 prQoSNullFrame
->u2SeqCtrl
= 0;
830 u2QosControl
= (UINT_16
) (ucUP
& WMM_QC_UP_MASK
);
833 u2QosControl
|= WMM_QC_EOSP
;
835 /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2QosCtrl, u2QosControl); */
836 prQoSNullFrame
->u2QosCtrl
= u2QosControl
; /* NOTE(Kevin): Optimized for ARM */
840 } /* end of bssComposeQoSNullFrameHeader() */
843 /*----------------------------------------------------------------------------*/
845 * @brief Send the Null Frame
847 * @param[in] prAdapter Pointer to the Adapter structure.
848 * @param[in] prStaRec Pointer to the STA_RECORD_T
849 * @param[in] pfTxDoneHandler TX Done call back function
851 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
852 * @retval WLAN_STATUS_SUCCESS Succe]ss.
854 /*----------------------------------------------------------------------------*/
856 bssSendNullFrame(IN P_ADAPTER_T prAdapter
,
857 IN P_STA_RECORD_T prStaRec
, IN PFN_TX_DONE_HANDLER pfTxDoneHandler
)
859 P_MSDU_INFO_T prMsduInfo
;
860 UINT_16 u2EstimatedFrameLen
;
863 /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
864 /* Init with MGMT Header Length */
865 u2EstimatedFrameLen
= MAC_TX_RESERVED_FIELD
+ WLAN_MAC_HEADER_LEN
;
867 /* Allocate a MSDU_INFO_T */
868 if ((prMsduInfo
= cnmMgtPktAlloc(prAdapter
, u2EstimatedFrameLen
)) == NULL
) {
869 DBGLOG(BSS
, WARN
, ("No PKT_INFO_T for sending Null Frame.\n"));
870 return WLAN_STATUS_RESOURCES
;
872 /* 4 <2> Compose Null frame in MSDU_INfO_T. */
873 bssComposeNullFrame(prAdapter
,
874 (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+ MAC_TX_RESERVED_FIELD
),
877 /* 4 <3> Update information of MSDU_INFO_T */
879 /* STA_REC ptr */ prStaRec
,
880 /* MSDU_INFO ptr */ prMsduInfo
,
882 (prMsduInfo
->pucBuffer
+ MAC_TX_RESERVED_FIELD
),
883 /* MAC HDR length */ WLAN_MAC_HEADER_LEN
,
885 (prMsduInfo
->pucBuffer
+ MAC_TX_RESERVED_FIELD
+
886 WLAN_MAC_HEADER_LEN
),
887 /* PAYLOAD length */ 0,
888 /* Network Type Index */ (UINT_8
) prStaRec
->ucNetTypeIndex
,
889 /* TID */ 0 /* BE: AC1 */ ,
890 /* Flag 802.11 */ TRUE
,
891 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
892 /* Resource TC */ 0 /* Irrelevant */ ,
893 /* Flag 802.1x */ FALSE
,
894 /* TX-done callback */ pfTxDoneHandler
,
895 /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS
,
896 /* PS Session ID */ 0 /* Irrelevant */ ,
897 /* Flag fixed rate */ TRUE
,
899 g_aprBssInfo
[prStaRec
->ucNetTypeIndex
]->ucHwDefaultFixedRateCode
,
900 /* Fixed-rate retry */
901 BSS_DEFAULT_CONN_TEST_NULL_FRAME_RETRY_LIMIT
,
902 /* PAL LLH */ 0 /* Irrelevant */ ,
903 /* ACL SN */ 0 /* Irrelevant */ ,
904 /* Flag No Ack */ FALSE
907 /* Terminate with a NULL pointer */
908 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo
, NULL
);
910 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
912 /* Indicate the packet to TXM */
913 /* 4 <4> Inform TXM to send this Null frame. */
914 txmSendFwDataPackets(prMsduInfo
);
917 prMsduInfo
->eSrc
= TX_PACKET_MGMT
;
918 prMsduInfo
->ucPacketType
= HIF_TX_PACKET_TYPE_DATA
;
919 prMsduInfo
->ucStaRecIndex
= prStaRec
->ucIndex
;
920 prMsduInfo
->ucNetworkType
= prStaRec
->ucNetTypeIndex
;
921 prMsduInfo
->ucMacHeaderLength
= WLAN_MAC_HEADER_LEN
;
922 prMsduInfo
->fgIs802_1x
= FALSE
;
923 prMsduInfo
->fgIs802_11
= TRUE
;
924 prMsduInfo
->u2FrameLength
= WLAN_MAC_HEADER_LEN
;
925 prMsduInfo
->ucTxSeqNum
= nicIncreaseTxSeqNum(prAdapter
);
926 prMsduInfo
->pfTxDoneHandler
= pfTxDoneHandler
;
927 prMsduInfo
->fgIsBasicRate
= FALSE
;
929 /* 4 <4> Inform TXM to send this Null frame. */
930 nicTxEnqueueMsdu(prAdapter
, prMsduInfo
);
932 return WLAN_STATUS_SUCCESS
;
934 } /* end of bssSendNullFrame() */
937 /*----------------------------------------------------------------------------*/
939 * @brief Send the QoS Null Frame
941 * @param[in] prAdapter Pointer to the Adapter structure.
942 * @param[in] prStaRec Pointer to the STA_RECORD_T
943 * @param[in] pfTxDoneHandler TX Done call back function
945 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
946 * @retval WLAN_STATUS_SUCCESS Success.
948 /*----------------------------------------------------------------------------*/
950 bssSendQoSNullFrame(IN P_ADAPTER_T prAdapter
,
951 IN P_STA_RECORD_T prStaRec
,
952 IN UINT_8 ucUP
, IN PFN_TX_DONE_HANDLER pfTxDoneHandler
)
954 P_MSDU_INFO_T prMsduInfo
;
955 UINT_16 u2EstimatedFrameLen
;
958 /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
959 /* Init with MGMT Header Length */
960 u2EstimatedFrameLen
= MAC_TX_RESERVED_FIELD
+ WLAN_MAC_HEADER_QOS_LEN
;
962 /* Allocate a MSDU_INFO_T */
963 if ((prMsduInfo
= cnmMgtPktAlloc(prAdapter
, u2EstimatedFrameLen
)) == NULL
) {
964 DBGLOG(BSS
, WARN
, ("No PKT_INFO_T for sending Null Frame.\n"));
965 return WLAN_STATUS_RESOURCES
;
967 /* 4 <2> Compose Null frame in MSDU_INfO_T. */
968 bssComposeQoSNullFrame(prAdapter
,
969 (PUINT_8
) ((UINT_32
) (prMsduInfo
->prPacket
) + MAC_TX_RESERVED_FIELD
),
970 prStaRec
, ucUP
, FALSE
);
972 /* 4 <3> Update information of MSDU_INFO_T */
974 /* STA_REC ptr */ prStaRec
,
975 /* MSDU_INFO ptr */ prMsduInfo
,
977 (prMsduInfo
->pucBuffer
+ MAC_TX_RESERVED_FIELD
),
978 /* MAC HDR length */ WLAN_MAC_HEADER_QOS_LEN
,
980 (prMsduInfo
->pucBuffer
+ MAC_TX_RESERVED_FIELD
+
981 WLAN_MAC_HEADER_QOS_LEN
),
982 /* PAYLOAD length */ 0,
983 /* Network Type Index */ (UINT_8
) prStaRec
->ucNetTypeIndex
,
984 /* TID */ 0 /* BE: AC1 */ ,
985 /* Flag 802.11 */ TRUE
,
986 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
987 /* Resource TC */ 0 /* Irrelevant */ ,
988 /* Flag 802.1x */ FALSE
,
989 /* TX-done callback */ pfTxDoneHandler
,
990 /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS
,
991 /* PS Session ID */ 0 /* Irrelevant */ ,
992 /* Flag fixed rate */ TRUE
,
994 g_aprBssInfo
[prStaRec
->ucNetTypeIndex
]->ucHwDefaultFixedRateCode
,
995 /* Fixed-rate retry */ TXM_DEFAULT_DATA_FRAME_RETRY_LIMIT
,
996 /* PAL LLH */ 0 /* Irrelevant */ ,
997 /* ACL SN */ 0 /* Irrelevant */ ,
998 /* Flag No Ack */ FALSE
1001 /* Terminate with a NULL pointer */
1002 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo
, NULL
);
1004 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1006 /* Indicate the packet to TXM */
1007 /* 4 <4> Inform TXM to send this Null frame. */
1008 txmSendFwDataPackets(prMsduInfo
);
1011 prMsduInfo
->eSrc
= TX_PACKET_MGMT
;
1012 prMsduInfo
->ucPacketType
= HIF_TX_PACKET_TYPE_MGMT
;
1013 prMsduInfo
->ucStaRecIndex
= prStaRec
->ucIndex
;
1014 prMsduInfo
->ucNetworkType
= prStaRec
->ucNetTypeIndex
;
1015 prMsduInfo
->ucMacHeaderLength
= WLAN_MAC_HEADER_QOS_LEN
;
1016 prMsduInfo
->fgIs802_1x
= FALSE
;
1017 prMsduInfo
->fgIs802_11
= TRUE
;
1018 prMsduInfo
->u2FrameLength
= WLAN_MAC_HEADER_QOS_LEN
;
1019 prMsduInfo
->ucTxSeqNum
= nicIncreaseTxSeqNum(prAdapter
);
1020 prMsduInfo
->pfTxDoneHandler
= pfTxDoneHandler
;
1021 prMsduInfo
->fgIsBasicRate
= TRUE
;
1023 /* 4 <4> Inform TXM to send this Null frame. */
1024 nicTxEnqueueMsdu(prAdapter
, prMsduInfo
);
1026 return WLAN_STATUS_SUCCESS
;
1028 } /* end of bssSendQoSNullFrame() */
1031 #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
1032 /*----------------------------------------------------------------------------*/
1033 /* Routines for both IBSS(AdHoc) and BSS(AP) */
1034 /*----------------------------------------------------------------------------*/
1035 /*----------------------------------------------------------------------------*/
1037 * @brief This function is used to generate Information Elements of Extended
1040 * @param[in] prAdapter Pointer to the Adapter structure.
1041 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1045 /*----------------------------------------------------------------------------*/
1046 VOID
bssGenerateExtSuppRate_IE(IN P_ADAPTER_T prAdapter
, IN P_MSDU_INFO_T prMsduInfo
)
1048 P_BSS_INFO_T prBssInfo
;
1050 UINT_8 ucExtSupRatesLen
;
1055 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[prMsduInfo
->ucNetworkType
]);
1058 pucBuffer
= (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
1059 (UINT_32
) prMsduInfo
->u2FrameLength
);
1062 if (prBssInfo
->ucAllSupportedRatesLen
> ELEM_MAX_LEN_SUP_RATES
) {
1064 ucExtSupRatesLen
= prBssInfo
->ucAllSupportedRatesLen
- ELEM_MAX_LEN_SUP_RATES
;
1066 ucExtSupRatesLen
= 0;
1069 /* Fill the Extended Supported Rates element. */
1070 if (ucExtSupRatesLen
) {
1072 EXT_SUP_RATES_IE(pucBuffer
)->ucId
= ELEM_ID_EXTENDED_SUP_RATES
;
1073 EXT_SUP_RATES_IE(pucBuffer
)->ucLength
= ucExtSupRatesLen
;
1075 kalMemCopy(EXT_SUP_RATES_IE(pucBuffer
)->aucExtSupportedRates
,
1076 &prBssInfo
->aucAllSupportedRates
[ELEM_MAX_LEN_SUP_RATES
],
1079 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1083 } /* end of bssGenerateExtSuppRate_IE() */
1086 /*----------------------------------------------------------------------------*/
1088 * @brief This function is used to compose Common Information Elements for Beacon
1089 * or Probe Response Frame.
1091 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1092 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
1093 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1097 /*----------------------------------------------------------------------------*/
1099 bssBuildBeaconProbeRespFrameCommonIEs(IN P_MSDU_INFO_T prMsduInfo
,
1100 IN P_BSS_INFO_T prBssInfo
, IN PUINT_8 pucDestAddr
)
1103 UINT_8 ucSupRatesLen
;
1109 pucBuffer
= (PUINT_8
) ((UINT_32
) prMsduInfo
->prPacket
+
1110 (UINT_32
) prMsduInfo
->u2FrameLength
);
1113 /* Compose the frame body of the Probe Response frame. */
1114 /* 4 <1> Fill the SSID element. */
1115 SSID_IE(pucBuffer
)->ucId
= ELEM_ID_SSID
;
1116 if (prBssInfo
->eHiddenSsidType
== ENUM_HIDDEN_SSID_LEN
) {
1117 if ((!pucDestAddr
) && /* For Beacon only */
1118 (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
)) {
1119 SSID_IE(pucBuffer
)->ucLength
= 0;
1120 } else { /* Probe response */
1121 SSID_IE(pucBuffer
)->ucLength
= prBssInfo
->ucSSIDLen
;
1122 if (prBssInfo
->ucSSIDLen
) {
1123 kalMemCopy(SSID_IE(pucBuffer
)->aucSSID
, prBssInfo
->aucSSID
,
1124 prBssInfo
->ucSSIDLen
);
1129 SSID_IE(pucBuffer
)->ucLength
= prBssInfo
->ucSSIDLen
;
1130 if (prBssInfo
->ucSSIDLen
) {
1131 kalMemCopy(SSID_IE(pucBuffer
)->aucSSID
, prBssInfo
->aucSSID
,
1132 prBssInfo
->ucSSIDLen
);
1136 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1137 pucBuffer
+= IE_SIZE(pucBuffer
);
1140 /* 4 <2> Fill the Supported Rates element. */
1141 if (prBssInfo
->ucAllSupportedRatesLen
> ELEM_MAX_LEN_SUP_RATES
) {
1143 ucSupRatesLen
= ELEM_MAX_LEN_SUP_RATES
;
1145 ucSupRatesLen
= prBssInfo
->ucAllSupportedRatesLen
;
1148 if (ucSupRatesLen
) {
1149 SUP_RATES_IE(pucBuffer
)->ucId
= ELEM_ID_SUP_RATES
;
1150 SUP_RATES_IE(pucBuffer
)->ucLength
= ucSupRatesLen
;
1151 kalMemCopy(SUP_RATES_IE(pucBuffer
)->aucSupportedRates
,
1152 prBssInfo
->aucAllSupportedRates
, ucSupRatesLen
);
1154 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1155 pucBuffer
+= IE_SIZE(pucBuffer
);
1158 /* 4 <3> Fill the DS Parameter Set element. */
1159 if (prBssInfo
->eBand
== BAND_2G4
) {
1160 DS_PARAM_IE(pucBuffer
)->ucId
= ELEM_ID_DS_PARAM_SET
;
1161 DS_PARAM_IE(pucBuffer
)->ucLength
= ELEM_MAX_LEN_DS_PARAMETER_SET
;
1162 DS_PARAM_IE(pucBuffer
)->ucCurrChnl
= prBssInfo
->ucPrimaryChannel
;
1164 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1165 pucBuffer
+= IE_SIZE(pucBuffer
);
1168 /* 4 <4> IBSS Parameter Set element, ID: 6 */
1169 if (prBssInfo
->eCurrentOPMode
== OP_MODE_IBSS
) {
1170 IBSS_PARAM_IE(pucBuffer
)->ucId
= ELEM_ID_IBSS_PARAM_SET
;
1171 IBSS_PARAM_IE(pucBuffer
)->ucLength
= ELEM_MAX_LEN_IBSS_PARAMETER_SET
;
1172 WLAN_SET_FIELD_16(&(IBSS_PARAM_IE(pucBuffer
)->u2ATIMWindow
),
1173 prBssInfo
->u2ATIMWindow
);
1175 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1176 pucBuffer
+= IE_SIZE(pucBuffer
);
1179 /* 4 <5> TIM element, ID: 5 */
1180 if ((!pucDestAddr
) && /* For Beacon only. */
1181 (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
)) {
1183 #if CFG_ENABLE_WIFI_DIRECT
1184 /*no fgIsP2PRegistered protect */
1185 if (prBssInfo
->ucNetTypeIndex
== NETWORK_TYPE_P2P_INDEX
) {
1187 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo
;
1188 UINT_8 ucBitmapControl
= 0;
1192 prP2pSpecificBssInfo
= &(prAdapter
->rWifiVar
.rP2pSpecificBssInfo
);
1194 /* Clear existing value. */
1195 prP2pSpecificBssInfo
->ucBitmapCtrl
= 0;
1196 kalMemZero(prP2pSpecificBssInfo
->aucPartialVirtualBitmap
,
1197 sizeof(prP2pSpecificBssInfo
->aucPartialVirtualBitmap
));
1200 /* IEEE 802.11 2007 - 7.3.2.6 */
1201 TIM_IE(pucBuffer
)->ucId
= ELEM_ID_TIM
;
1202 TIM_IE(pucBuffer
)->ucDTIMCount
= prBssInfo
->ucDTIMCount
;
1203 TIM_IE(pucBuffer
)->ucDTIMPeriod
= prBssInfo
->ucDTIMPeriod
;
1205 /* Setup DTIM Count for next TBTT. */
1206 if (prBssInfo
->ucDTIMCount
== 0) {
1207 /* 3 *** pmQueryBufferedBCAST(); */
1209 /* 3 *** pmQueryBufferedPSNode(); */
1210 /* TODO(Kevin): Call PM Module here to loop all STA_RECORD_Ts and it
1211 * will call bssSetTIMBitmap to toggle the Bitmap.
1214 /* Set Virtual Bitmap for UCAST */
1215 u4N1
= (prP2pSpecificBssInfo
->u2SmallestAID
>> 4) << 1; /* Find the largest even number. */
1216 u4N2
= prP2pSpecificBssInfo
->u2LargestAID
>> 3; /* Find the smallest number. */
1218 ASSERT(u4N2
>= u4N1
);
1220 kalMemCopy(TIM_IE(pucBuffer
)->aucPartialVirtualMap
,
1221 &prP2pSpecificBssInfo
->aucPartialVirtualBitmap
[u4N1
],
1222 ((u4N2
- u4N1
) + 1));
1224 /* Set Virtual Bitmap for BMCAST */
1225 /* BMC bit only indicated when DTIM count == 0. */
1226 if (prBssInfo
->ucDTIMCount
== 0) {
1227 ucBitmapControl
= prP2pSpecificBssInfo
->ucBitmapCtrl
;
1229 TIM_IE(pucBuffer
)->ucBitmapControl
= ucBitmapControl
| (UINT_8
) u4N1
;
1231 TIM_IE(pucBuffer
)->ucLength
= ((u4N2
- u4N1
) + 4);
1233 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1236 /* IEEE 802.11 2007 - 7.3.2.6 */
1237 TIM_IE(pucBuffer
)->ucId
= ELEM_ID_TIM
;
1238 TIM_IE(pucBuffer
)->ucLength
= (3 + MAX_LEN_TIM_PARTIAL_BMP
) /*((u4N2 - u4N1) + 4) */; /* NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only) */
1239 TIM_IE(pucBuffer
)->ucDTIMCount
= 0 /*prBssInfo->ucDTIMCount */; /* will be overwrite by FW */
1240 TIM_IE(pucBuffer
)->ucDTIMPeriod
= prBssInfo
->ucDTIMPeriod
;
1241 TIM_IE(pucBuffer
)->ucBitmapControl
= 0 /*ucBitmapControl | (UINT_8)u4N1 */; /* will be overwrite by FW */
1243 prMsduInfo
->u2FrameLength
+= IE_SIZE(pucBuffer
);
1248 #endif /* CFG_ENABLE_WIFI_DIRECT */
1250 /* NOTE(Kevin): 1. AIS - Didn't Support AP Mode.
1251 * 2. BOW - Didn't Support BCAST and PS.
1260 } /* end of bssBuildBeaconProbeRespFrameCommonIEs() */
1263 /*----------------------------------------------------------------------------*/
1265 * @brief This function will compose the Beacon/Probe Response frame header and
1268 * @param[in] pucBuffer Pointer to the frame buffer.
1269 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1270 * @param[in] pucOwnMACAddress Given Our MAC Address.
1271 * @param[in] pucBSSID Given BSSID of the BSS.
1272 * @param[in] u2BeaconInterval Given Beacon Interval.
1273 * @param[in] u2CapInfo Given Capability Info.
1277 /*----------------------------------------------------------------------------*/
1279 bssComposeBeaconProbeRespFrameHeaderAndFF(IN PUINT_8 pucBuffer
,
1280 IN PUINT_8 pucDestAddr
,
1281 IN PUINT_8 pucOwnMACAddress
,
1282 IN PUINT_8 pucBSSID
,
1283 IN UINT_16 u2BeaconInterval
, IN UINT_16 u2CapInfo
)
1285 P_WLAN_BEACON_FRAME_T prBcnProbRspFrame
;
1286 UINT_8 aucBCAddr
[] = BC_MAC_ADDR
;
1287 UINT_16 u2FrameCtrl
;
1289 DEBUGFUNC("bssComposeBeaconProbeRespFrameHeaderAndFF");
1290 /* DBGLOG(INIT, LOUD, ("\n")); */
1294 ASSERT(pucOwnMACAddress
);
1297 prBcnProbRspFrame
= (P_WLAN_BEACON_FRAME_T
) pucBuffer
;
1299 /* 4 <1> Compose the frame header of the Beacon /ProbeResp frame. */
1300 /* Fill the Frame Control field. */
1302 u2FrameCtrl
= MAC_FRAME_PROBE_RSP
;
1304 u2FrameCtrl
= MAC_FRAME_BEACON
;
1305 pucDestAddr
= aucBCAddr
;
1307 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2FrameCtrl, u2FrameCtrl); */
1308 prBcnProbRspFrame
->u2FrameCtrl
= u2FrameCtrl
; /* NOTE(Kevin): Optimized for ARM */
1310 /* Fill the DA field with BCAST MAC ADDR or TA of ProbeReq. */
1311 COPY_MAC_ADDR(prBcnProbRspFrame
->aucDestAddr
, pucDestAddr
);
1313 /* Fill the SA field with our MAC Address. */
1314 COPY_MAC_ADDR(prBcnProbRspFrame
->aucSrcAddr
, pucOwnMACAddress
);
1316 /* Fill the BSSID field with current BSSID. */
1317 COPY_MAC_ADDR(prBcnProbRspFrame
->aucBSSID
, pucBSSID
);
1319 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
1320 prBcnProbRspFrame
->u2SeqCtrl
= 0;
1323 /* 4 <2> Compose the frame body's common fixed field part of the Beacon /ProbeResp frame. */
1324 /* MAC will update TimeStamp field */
1326 /* Fill the Beacon Interval field. */
1327 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2BeaconInterval, u2BeaconInterval); */
1328 prBcnProbRspFrame
->u2BeaconInterval
= u2BeaconInterval
; /* NOTE(Kevin): Optimized for ARM */
1330 /* Fill the Capability Information field. */
1331 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2CapInfo, u2CapInfo); */
1332 prBcnProbRspFrame
->u2CapInfo
= u2CapInfo
; /* NOTE(Kevin): Optimized for ARM */
1335 } /* end of bssComposeBeaconProbeRespFrameHeaderAndFF() */
1338 /*----------------------------------------------------------------------------*/
1340 * @brief Update the Beacon Frame Template to FW for AIS AdHoc and P2P GO.
1342 * @param[in] prAdapter Pointer to the Adapter structure.
1343 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1345 * @retval WLAN_STATUS_SUCCESS Success.
1347 /*----------------------------------------------------------------------------*/
1349 bssUpdateBeaconContent(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
)
1351 P_BSS_INFO_T prBssInfo
;
1352 P_MSDU_INFO_T prMsduInfo
;
1353 P_WLAN_BEACON_FRAME_T prBcnFrame
;
1356 DEBUGFUNC("bssUpdateBeaconContent");
1357 DBGLOG(INIT
, LOUD
, ("\n"));
1359 ASSERT(eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
1361 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
1363 /* 4 <1> Allocate a PKT_INFO_T for Beacon Frame */
1364 /* Allocate a MSDU_INFO_T */
1366 prMsduInfo
= prBssInfo
->prBeacon
;
1368 /* beacon prMsduInfo will be NULLify once BSS deactivated, so skip if it is */
1369 if (prMsduInfo
== NULL
) {
1370 return WLAN_STATUS_SUCCESS
;
1372 /* 4 <2> Compose header */
1373 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8
)
1374 ((UINT_32
) (prMsduInfo
->prPacket
) +
1375 MAC_TX_RESERVED_FIELD
), NULL
,
1376 prBssInfo
->aucOwnMacAddr
, prBssInfo
->aucBSSID
,
1377 prBssInfo
->u2BeaconInterval
,
1378 prBssInfo
->u2CapInfo
);
1381 prMsduInfo
->u2FrameLength
= (WLAN_MAC_MGMT_HEADER_LEN
+
1382 (TIMESTAMP_FIELD_LEN
+ BEACON_INTERVAL_FIELD_LEN
+
1383 CAP_INFO_FIELD_LEN
));
1385 prMsduInfo
->ucNetworkType
= eNetTypeIndex
;
1387 /* 4 <3> Compose the frame body's Common IEs of the Beacon frame. */
1388 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo
, prBssInfo
, NULL
);
1391 /* 4 <4> Compose IEs in MSDU_INFO_T */
1393 /* Append IE for Beacon */
1394 for (i
= 0; i
< sizeof(txBcnIETable
) / sizeof(APPEND_VAR_IE_ENTRY_T
); i
++) {
1395 if (txBcnIETable
[i
].pfnAppendIE
) {
1396 txBcnIETable
[i
].pfnAppendIE(prAdapter
, prMsduInfo
);
1400 prBcnFrame
= (P_WLAN_BEACON_FRAME_T
) prMsduInfo
->prPacket
;
1402 return nicUpdateBeaconIETemplate(prAdapter
,
1403 IE_UPD_METHOD_UPDATE_ALL
,
1405 prBssInfo
->u2CapInfo
,
1406 (PUINT_8
) prBcnFrame
->aucInfoElem
,
1407 prMsduInfo
->u2FrameLength
- OFFSET_OF(WLAN_BEACON_FRAME_T
,
1411 } /* end of bssUpdateBeaconContent() */
1414 /*----------------------------------------------------------------------------*/
1416 * @brief Send the Beacon Frame(for BOW) or Probe Response Frame according to the given
1417 * Destination Address.
1419 * @param[in] prAdapter Pointer to the Adapter structure.
1420 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1421 * @param[in] pucDestAddr Pointer to the Destination Address to reply
1422 * @param[in] u4ControlFlags Control flags for information on Probe Response.
1424 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
1425 * @retval WLAN_STATUS_SUCCESS Success.
1427 /*----------------------------------------------------------------------------*/
1429 bssSendBeaconProbeResponse(IN P_ADAPTER_T prAdapter
,
1430 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
1431 IN PUINT_8 pucDestAddr
, IN UINT_32 u4ControlFlags
)
1433 P_BSS_INFO_T prBssInfo
;
1434 P_MSDU_INFO_T prMsduInfo
;
1435 UINT_16 u2EstimatedFrameLen
;
1436 UINT_16 u2EstimatedFixedIELen
;
1437 UINT_16 u2EstimatedExtraIELen
;
1438 P_APPEND_VAR_IE_ENTRY_T prIeArray
= NULL
;
1439 UINT_32 u4IeArraySize
= 0;
1443 ASSERT(eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
1445 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
1448 if (!pucDestAddr
) { /* For Beacon */
1449 prIeArray
= &txBcnIETable
[0];
1450 u4IeArraySize
= sizeof(txBcnIETable
) / sizeof(APPEND_VAR_IE_ENTRY_T
);
1452 prIeArray
= &txProbRspIETable
[0];
1453 u4IeArraySize
= sizeof(txProbRspIETable
) / sizeof(APPEND_VAR_IE_ENTRY_T
);
1457 /* 4 <1> Allocate a PKT_INFO_T for Beacon /Probe Response Frame */
1458 /* Allocate a MSDU_INFO_T */
1460 /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Fields */
1461 u2EstimatedFrameLen
= MAC_TX_RESERVED_FIELD
+
1462 WLAN_MAC_MGMT_HEADER_LEN
+
1463 TIMESTAMP_FIELD_LEN
+
1464 BEACON_INTERVAL_FIELD_LEN
+
1465 CAP_INFO_FIELD_LEN
+
1466 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_SSID
) +
1467 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_SUP_RATES
) +
1468 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_DS_PARAMETER_SET
) +
1469 (ELEM_HDR_LEN
+ ELEM_MAX_LEN_IBSS_PARAMETER_SET
) +
1470 (ELEM_HDR_LEN
+ (3 + MAX_LEN_TIM_PARTIAL_BMP
));
1472 /* + Extra IE Length */
1473 u2EstimatedExtraIELen
= 0;
1475 for (i
= 0; i
< u4IeArraySize
; i
++) {
1476 u2EstimatedFixedIELen
= prIeArray
[i
].u2EstimatedFixedIELen
;
1478 if (u2EstimatedFixedIELen
) {
1479 u2EstimatedExtraIELen
+= u2EstimatedFixedIELen
;
1481 ASSERT(prIeArray
[i
].pfnCalculateVariableIELen
);
1483 u2EstimatedExtraIELen
+= (UINT_16
)
1484 prIeArray
[i
].pfnCalculateVariableIELen(prAdapter
, eNetTypeIndex
, NULL
);
1488 u2EstimatedFrameLen
+= u2EstimatedExtraIELen
;
1490 if ((prMsduInfo
= cnmMgtPktAlloc(prAdapter
, u2EstimatedFrameLen
)) == NULL
) {
1491 DBGLOG(BSS
, WARN
, ("No PKT_INFO_T for sending %s.\n",
1492 ((!pucDestAddr
) ? "Beacon" : "Probe Response")));
1493 return WLAN_STATUS_RESOURCES
;
1496 /* 4 <2> Compose Beacon/Probe Response frame header and fixed fields in MSDU_INfO_T. */
1497 /* Compose Header and Fixed Field */
1498 #if CFG_ENABLE_WIFI_DIRECT
1499 if (u4ControlFlags
& BSS_PROBE_RESP_USE_P2P_DEV_ADDR
) {
1500 if (prAdapter
->fgIsP2PRegistered
) {
1501 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8
)
1502 ((UINT_32
) (prMsduInfo
->prPacket
)
1503 + MAC_TX_RESERVED_FIELD
),
1505 prAdapter
->rWifiVar
.
1507 prAdapter
->rWifiVar
.
1509 DOT11_BEACON_PERIOD_DEFAULT
,
1511 u2CapInfo
& ~(CAP_INFO_ESS
|
1515 #endif /* CFG_ENABLE_WIFI_DIRECT */
1517 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8
)
1518 ((UINT_32
) (prMsduInfo
->prPacket
) +
1519 MAC_TX_RESERVED_FIELD
), pucDestAddr
,
1520 prBssInfo
->aucOwnMacAddr
,
1521 prBssInfo
->aucBSSID
,
1522 prBssInfo
->u2BeaconInterval
,
1523 prBssInfo
->u2CapInfo
);
1527 /* 4 <3> Update information of MSDU_INFO_T */
1528 prMsduInfo
->eSrc
= TX_PACKET_MGMT
;
1529 prMsduInfo
->ucPacketType
= HIF_TX_PACKET_TYPE_MGMT
;
1530 prMsduInfo
->ucStaRecIndex
= 0xFF;
1531 prMsduInfo
->ucNetworkType
= (UINT_8
) eNetTypeIndex
;
1532 prMsduInfo
->ucMacHeaderLength
= WLAN_MAC_MGMT_HEADER_LEN
;
1533 prMsduInfo
->fgIs802_1x
= FALSE
;
1534 prMsduInfo
->fgIs802_11
= TRUE
;
1535 prMsduInfo
->u2FrameLength
= (WLAN_MAC_MGMT_HEADER_LEN
+
1536 TIMESTAMP_FIELD_LEN
+ BEACON_INTERVAL_FIELD_LEN
+
1537 CAP_INFO_FIELD_LEN
);
1538 prMsduInfo
->ucTxSeqNum
= nicIncreaseTxSeqNum(prAdapter
);
1539 prMsduInfo
->pfTxDoneHandler
= NULL
;
1540 prMsduInfo
->fgIsBasicRate
= TRUE
;
1543 /* 4 <4> Compose the frame body's Common IEs of the Beacon/ProbeResp frame. */
1544 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo
, prBssInfo
, pucDestAddr
);
1547 /* 4 <5> Compose IEs in MSDU_INFO_T */
1550 for (i
= 0; i
< u4IeArraySize
; i
++) {
1551 if (prIeArray
[i
].pfnAppendIE
) {
1552 prIeArray
[i
].pfnAppendIE(prAdapter
, prMsduInfo
);
1556 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1558 /* 4 <6> Inform TXM to send this Beacon /Probe Response frame. */
1559 nicTxEnqueueMsdu(prAdapter
, prMsduInfo
);
1561 return WLAN_STATUS_SUCCESS
;
1563 } /* end of bssSendBeaconProbeResponse() */
1566 /*----------------------------------------------------------------------------*/
1568 * @brief This function will process the Rx Probe Request Frame and then send
1569 * back the corresponding Probe Response Frame if the specified conditions
1572 * @param[in] prAdapter Pointer to the Adapter structure.
1573 * @param[in] prSwRfb Pointer to SW RFB data structure.
1575 * @retval WLAN_STATUS_SUCCESS Always return success
1577 /*----------------------------------------------------------------------------*/
1578 WLAN_STATUS
bssProcessProbeRequest(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
)
1580 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr
;
1581 P_BSS_INFO_T prBssInfo
;
1582 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
;
1583 UINT_8 aucBCBSSID
[] = BC_BSSID
;
1584 BOOLEAN fgIsBcBssid
;
1585 BOOLEAN fgReplyProbeResp
;
1586 UINT_32 u4CtrlFlagsForProbeResp
= 0;
1588 UINT_8 ucHwChannelNum
;
1593 /* 4 <1> Parse Probe Req and Get BSSID */
1594 prMgtHdr
= (P_WLAN_MAC_MGMT_HEADER_T
) prSwRfb
->pvHeader
;
1596 if (EQUAL_MAC_ADDR(aucBCBSSID
, prMgtHdr
->aucBSSID
)) {
1599 fgIsBcBssid
= FALSE
;
1603 /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
1604 for (eNetTypeIndex
= NETWORK_TYPE_AIS_INDEX
; eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
;
1607 if (!IS_NET_ACTIVE(prAdapter
, eNetTypeIndex
)) {
1611 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
1613 if ((!fgIsBcBssid
) && UNEQUAL_MAC_ADDR(prBssInfo
->aucBSSID
, prMgtHdr
->aucBSSID
)) {
1617 eBand
= HIF_RX_HDR_GET_RF_BAND(prSwRfb
->prHifRxHdr
);
1618 ucHwChannelNum
= HIF_RX_HDR_GET_CHNL_NUM(prSwRfb
->prHifRxHdr
);
1620 if (prBssInfo
->eBand
!= eBand
) {
1624 if (prBssInfo
->ucPrimaryChannel
!= ucHwChannelNum
) {
1628 fgReplyProbeResp
= FALSE
;
1630 if (NETWORK_TYPE_AIS_INDEX
== eNetTypeIndex
) {
1632 #if CFG_SUPPORT_ADHOC
1634 aisValidateProbeReq(prAdapter
, prSwRfb
, &u4CtrlFlagsForProbeResp
);
1637 #if CFG_ENABLE_WIFI_DIRECT
1638 else if ((prAdapter
->fgIsP2PRegistered
) &&
1639 (NETWORK_TYPE_P2P_INDEX
== eNetTypeIndex
)) {
1642 p2pFuncValidateProbeReq(prAdapter
, prSwRfb
, &u4CtrlFlagsForProbeResp
);
1645 #if CFG_ENABLE_BT_OVER_WIFI
1646 else if (NETWORK_TYPE_BOW_INDEX
== eNetTypeIndex
) {
1649 bowValidateProbeReq(prAdapter
, prSwRfb
, &u4CtrlFlagsForProbeResp
);
1653 if (fgReplyProbeResp
) {
1654 if (nicTxGetFreeCmdCount(prAdapter
) > (CFG_TX_MAX_CMD_PKT_NUM
/ 2)) {
1655 /* Resource margin is enough */
1656 bssSendBeaconProbeResponse(prAdapter
, eNetTypeIndex
,
1657 prMgtHdr
->aucSrcAddr
,
1658 u4CtrlFlagsForProbeResp
);
1663 return WLAN_STATUS_SUCCESS
;
1665 } /* end of bssProcessProbeRequest() */
1668 #if 0 /* NOTE(Kevin): condition check should move to P2P_FSM.c */
1669 /*----------------------------------------------------------------------------*/
1671 * @brief This function will process the Rx Probe Request Frame and then send
1672 * back the corresponding Probe Response Frame if the specified conditions
1675 * @param[in] prSwRfb Pointer to SW RFB data structure.
1677 * @retval WLAN_STATUS_SUCCESS Always return success
1679 /*----------------------------------------------------------------------------*/
1680 WLAN_STATUS
bssProcessProbeRequest(IN P_ADAPTER_T prAdapter
, IN P_SW_RFB_T prSwRfb
)
1682 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr
;
1683 P_BSS_INFO_T prBssInfo
;
1684 P_IE_SSID_T prIeSsid
= (P_IE_SSID_T
) NULL
;
1685 P_IE_SUPPORTED_RATE_T prIeSupportedRate
= (P_IE_SUPPORTED_RATE_T
) NULL
;
1686 P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate
= (P_IE_EXT_SUPPORTED_RATE_T
) NULL
;
1689 UINT_16 u2Offset
= 0;
1690 UINT_8 aucBCBSSID
[] = BC_BSSID
;
1691 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
;
1692 BOOLEAN fgReplyProbeResp
;
1693 #if CFG_ENABLE_WIFI_DIRECT
1694 BOOLEAN fgP2PTargetDeviceFound
;
1695 UINT_8 aucP2PWildcardSSID
[] = P2P_WILDCARD_SSID
;
1700 /* 4 <1> Parse Probe Req and Get SSID IE ptr */
1701 prMgtHdr
= (P_WLAN_MAC_MGMT_HEADER_T
) prSwRfb
->pvHeader
;
1703 u2IELength
= prSwRfb
->u2PacketLen
- prSwRfb
->u2HeaderLen
;
1704 pucIE
= (PUINT_8
) ((UINT_32
) prSwRfb
->pvHeader
+ prSwRfb
->u2HeaderLen
);
1706 prIeSsid
= (P_IE_SSID_T
) NULL
;
1708 IE_FOR_EACH(pucIE
, u2IELength
, u2Offset
) {
1709 switch (IE_ID(pucIE
)) {
1711 if ((!prIeSsid
) && (IE_LEN(pucIE
) <= ELEM_MAX_LEN_SSID
)) {
1712 prIeSsid
= (P_IE_SSID_T
) pucIE
;
1716 case ELEM_ID_SUP_RATES
:
1717 /* NOTE(Kevin): Buffalo WHR-G54S's supported rate set IE exceed 8.
1718 * IE_LEN(pucIE) == 12, "1(B), 2(B), 5.5(B), 6(B), 9(B), 11(B),
1719 * 12(B), 18(B), 24(B), 36(B), 48(B), 54(B)"
1721 /* if (IE_LEN(pucIE) <= ELEM_MAX_LEN_SUP_RATES) { */
1722 if (IE_LEN(pucIE
) <= RATE_NUM
) {
1723 prIeSupportedRate
= SUP_RATES_IE(pucIE
);
1727 case ELEM_ID_EXTENDED_SUP_RATES
:
1728 prIeExtSupportedRate
= EXT_SUP_RATES_IE(pucIE
);
1731 #if CFG_ENABLE_WIFI_DIRECT
1732 /* TODO: P2P IE & WCS IE parsing for P2P. */
1740 } /* end of IE_FOR_EACH */
1742 /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
1743 for (eNetTypeIndex
= NETWORK_TYPE_AIS_INDEX
; eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
;
1746 if (!IS_NET_ACTIVE(prAdapter
, eNetTypeIndex
)) {
1750 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
1752 if (UNEQUAL_MAC_ADDR(aucBCBSSID
, prMgtHdr
->aucBSSID
) &&
1753 UNEQUAL_MAC_ADDR(prBssInfo
->aucBSSID
, prMgtHdr
->aucBSSID
)) {
1754 /* BSSID not Wildcard BSSID. */
1758 fgReplyProbeResp
= FALSE
;
1760 if (NETWORK_TYPE_AIS_INDEX
== eNetTypeIndex
) {
1762 if (prBssInfo
->eCurrentOPMode
== OP_MODE_IBSS
) {
1764 /* TODO(Kevin): Check if we are IBSS Master. */
1768 if ((prIeSsid
->ucLength
== BC_SSID_LEN
) || /* WILDCARD SSID */
1769 EQUAL_SSID(prBssInfo
->aucSSID
,
1770 prBssInfo
->ucSSIDLen
,
1772 prIeSsid
->ucLength
)) {
1773 fgReplyProbeResp
= TRUE
;
1779 #if CFG_ENABLE_WIFI_DIRECT
1780 else if (NETWORK_TYPE_P2P_INDEX
== eNetTypeIndex
) {
1782 /* TODO(Kevin): Move following lines to p2p_fsm.c */
1785 ((prIeSsid
->ucLength
== BC_SSID_LEN
) ||
1786 (EQUAL_SSID(aucP2PWildcardSSID
,
1787 P2P_WILDCARD_SSID_LEN
,
1788 prIeSsid
->aucSSID
, prIeSsid
->ucLength
)))) {
1789 /* if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prMgtHdr->aucSrcAddr, pucIE, u2IELength)) { */
1790 if (p2pFsmRunEventRxProbeRequestFrame(prAdapter
, prSwRfb
)) {
1791 /* Extand channel request time & cancel scan request. */
1792 P_P2P_FSM_INFO_T prP2pFsmInfo
= (P_P2P_FSM_INFO_T
) NULL
;
1794 /* TODO: RX probe request may not caused by LISTEN state. */
1795 /* TODO: It can be GO. */
1796 /* Generally speaking, cancel a non-exist scan request is fine.
1797 * We can check P2P FSM here for only LISTEN state.
1800 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg
;
1802 prP2pFsmInfo
= prAdapter
->rWifiVar
.prP2pFsmInfo
;
1804 /* Abort JOIN process. */
1806 (P_MSG_SCN_SCAN_CANCEL
) cnmMemAlloc(prAdapter
,
1809 (MSG_SCN_SCAN_CANCEL
));
1810 if (!prScanCancelMsg
) {
1811 ASSERT(0); /* Can't abort SCN FSM */
1815 prScanCancelMsg
->rMsgHdr
.eMsgId
= MID_P2P_SCN_SCAN_CANCEL
;
1816 prScanCancelMsg
->ucSeqNum
= prP2pFsmInfo
->ucSeqNumOfScnMsg
;
1817 prScanCancelMsg
->ucNetTypeIndex
=
1818 (UINT_8
) NETWORK_TYPE_P2P_INDEX
;
1819 prScanCancelMsg
->fgIsChannelExt
= TRUE
;
1821 mboxSendMsg(prAdapter
,
1823 (P_MSG_HDR_T
) prScanCancelMsg
,
1824 MSG_SEND_METHOD_BUF
);
1827 /* 1. Probe Request without SSID.
1828 * 2. Probe Request with SSID not Wildcard SSID & not P2P Wildcard SSID.
1834 if (prAdapter
->rWifiVar
.prP2pFsmInfo
->eCurrentState
== P2P_STATE_LISTEN
) {
1835 /* P2P 2.4.1 - P2P Devices shall not respond to Probe Request frames which only contain 11b rates only. */
1836 if (prIeSupportedRate
|| prIeExtSupportedRate
) {
1837 UINT_16 u2OperationalRateSet
, u2BSSBasicRateSet
;
1838 BOOLEAN fgIsUnknownBssBasicRate
;
1840 rateGetRateSetFromIEs(prIeSupportedRate
, prIeExtSupportedRate
, &u2OperationalRateSet
, &u2BSSBasicRateSet
, /* Ignore any Basic Bit */
1841 &fgIsUnknownBssBasicRate
);
1843 if (u2OperationalRateSet
& ~RATE_SET_HR_DSSS
) {
1848 /* TODO: Check channel time before first check point to: */
1849 /* If Target device is selected:
1850 * 1. Send XXXX request frame.
1852 * 1. Send Probe Response frame.
1855 if (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
1856 /* TODO(Kevin): During PROVISION state, can we reply Probe Response ? */
1859 * If we are GO, accept legacy client --> accept Wildcard SSID
1860 * If we are in Listen State, accept only P2P Device --> check P2P IE and WPS IE
1862 if (TRUE
/* We are GO */) {
1864 UINT_8 aucSSID
[] = P2P_WILDCARD_SSID
;
1866 if ((prIeSsid
->ucLength
== BC_SSID_LEN
) || /* WILDCARD SSID */
1867 EQUAL_SSID(prBssInfo
->aucSSID
,
1868 prBssInfo
->ucSSIDLen
,
1871 || EQUAL_SSID(aucSSID
, P2P_WILDCARD_SSID_LEN
,
1873 prIeSsid
->ucLength
)) {
1874 fgReplyProbeResp
= TRUE
;
1878 /* else if (FALSE /* We are in Listen State */) { */
1881 /* TODO(Kevin): Check P2P IE and WPS IE */
1886 #if CFG_ENABLE_BT_OVER_WIFI
1887 else if (NETWORK_TYPE_BOW_INDEX
== eNetTypeIndex
) {
1889 if (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
1890 /* TODO(Kevin): TBD */
1895 ASSERT(eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
1898 if (fgReplyProbeResp
) {
1899 bssSendBeaconProbeResponse(prAdapter
, eNetTypeIndex
, prMgtHdr
->aucSrcAddr
);
1904 return WLAN_STATUS_SUCCESS
;
1906 } /* end of bssProcessProbeRequest() */
1910 /*----------------------------------------------------------------------------*/
1912 * @brief This function is used to clear the client list for AdHoc or AP Mode
1914 * @param[in] prAdapter Pointer to the Adapter structure.
1915 * @param[in] prBssInfo Given related BSS_INFO_T.
1919 /*----------------------------------------------------------------------------*/
1920 VOID
bssClearClientList(IN P_ADAPTER_T prAdapter
, IN P_BSS_INFO_T prBssInfo
)
1922 P_LINK_T prStaRecOfClientList
;
1927 prStaRecOfClientList
= &prBssInfo
->rStaRecOfClientList
;
1929 if (!LINK_IS_EMPTY(prStaRecOfClientList
)) {
1930 P_STA_RECORD_T prPeerStaRec
;
1932 LINK_FOR_EACH_ENTRY(prPeerStaRec
, prStaRecOfClientList
, rLinkEntry
, STA_RECORD_T
) {
1933 cnmStaRecChangeState(prAdapter
, prPeerStaRec
, STA_STATE_1
);
1936 LINK_INITIALIZE(prStaRecOfClientList
);
1940 } /* end of bssClearClientList() */
1944 /*----------------------------------------------------------------------------*/
1946 * @brief This function is used to Add a STA_RECORD_T to 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.
1950 * @param[in] prStaRec Pointer to the STA_RECORD_T
1954 /*----------------------------------------------------------------------------*/
1956 bssAddStaRecToClientList(IN P_ADAPTER_T prAdapter
,
1957 IN P_BSS_INFO_T prBssInfo
, IN P_STA_RECORD_T prStaRec
)
1959 P_LINK_T prStaRecOfClientList
;
1964 prStaRecOfClientList
= &prBssInfo
->rStaRecOfClientList
;
1966 if (!LINK_IS_EMPTY(prStaRecOfClientList
)) {
1967 P_STA_RECORD_T prCurrStaRec
;
1969 LINK_FOR_EACH_ENTRY(prCurrStaRec
, prStaRecOfClientList
, rLinkEntry
, STA_RECORD_T
) {
1971 if (prCurrStaRec
== prStaRec
) {
1973 ("Current Client List already contains that STA_RECORD_T["
1974 MACSTR
"]\n", MAC2STR(prStaRec
->aucMacAddr
)));
1980 LINK_INSERT_TAIL(prStaRecOfClientList
, &prStaRec
->rLinkEntry
);
1983 } /* end of bssAddStaRecToClientList() */
1986 /*----------------------------------------------------------------------------*/
1988 * @brief This function is used to Remove a STA_RECORD_T from the client list for AdHoc or AP Mode
1990 * @param[in] prAdapter Pointer to the Adapter structure.
1991 * @param[in] prStaRec Pointer to the STA_RECORD_T
1995 /*----------------------------------------------------------------------------*/
1997 bssRemoveStaRecFromClientList(IN P_ADAPTER_T prAdapter
,
1998 IN P_BSS_INFO_T prBssInfo
, 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
) {
2014 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList
,
2015 &prStaRec
->rLinkEntry
);
2023 ("Current Client List didn't contain that STA_RECORD_T[" MACSTR
2024 "] before removing.\n", MAC2STR(prStaRec
->aucMacAddr
)));
2027 } /* end of bssRemoveStaRecFromClientList() */
2028 #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
2031 #if CFG_SUPPORT_ADHOC
2032 /*----------------------------------------------------------------------------*/
2033 /* Routines for IBSS(AdHoc) only */
2034 /*----------------------------------------------------------------------------*/
2035 /*----------------------------------------------------------------------------*/
2037 * @brief This function is used to process Beacons from current Ad-Hoc network peers.
2038 * We also process Beacons from other Ad-Hoc network during SCAN. If it has
2039 * the same SSID and we'll decide to merge into it if it has a larger TSF.
2041 * @param[in] prAdapter Pointer to the Adapter structure.
2042 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2043 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2047 /*----------------------------------------------------------------------------*/
2049 ibssProcessMatchedBeacon(IN P_ADAPTER_T prAdapter
,
2050 IN P_BSS_INFO_T prBssInfo
, IN P_BSS_DESC_T prBssDesc
, IN UINT_8 ucRCPI
)
2052 P_STA_RECORD_T prStaRec
= NULL
;
2054 BOOLEAN fgIsCheckCapability
= FALSE
;
2055 BOOLEAN fgIsCheckTSF
= FALSE
;
2056 BOOLEAN fgIsGoingMerging
= FALSE
;
2057 BOOLEAN fgIsSameBSSID
;
2063 /* 4 <1> Process IBSS Beacon only after we create or merge with other IBSS. */
2064 if (!prBssInfo
->fgIsBeaconActivated
) {
2067 /* 4 <2> Get the STA_RECORD_T of TA. */
2068 prStaRec
= cnmGetStaRecByAddress(prAdapter
,
2069 (UINT_8
) NETWORK_TYPE_AIS_INDEX
, prBssDesc
->aucSrcAddr
);
2071 fgIsSameBSSID
= UNEQUAL_MAC_ADDR(prBssInfo
->aucBSSID
, prBssDesc
->aucBSSID
) ? FALSE
: TRUE
;
2074 /* 4 <3> IBSS Merge Decision Flow for Processing Beacon. */
2075 if (fgIsSameBSSID
) {
2078 * Case I. This is a new TA and it has decide to merged with us.
2079 * a) If fgIsMerging == FALSE - we will send msg to notify AIS.
2080 * b) If fgIsMerging == TRUE - already notify AIS.
2081 * Case II. This is an old TA and we've already merged together.
2085 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2086 fgIsCheckCapability
= TRUE
;
2088 /* If check is passed, then we perform merging with this new IBSS */
2089 fgIsGoingMerging
= TRUE
;
2093 ASSERT((prStaRec
->ucNetTypeIndex
== NETWORK_TYPE_AIS_INDEX
) &&
2094 IS_ADHOC_STA(prStaRec
));
2096 if (prStaRec
->ucStaState
!= STA_STATE_3
) {
2098 if (!prStaRec
->fgIsMerging
) {
2100 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2101 fgIsCheckCapability
= TRUE
;
2103 /* If check is passed, then we perform merging with this new IBSS */
2104 fgIsGoingMerging
= TRUE
;
2106 /* For Case II - Update rExpirationTime of Sta Record */
2107 GET_CURRENT_SYSTIME(&prStaRec
->rUpdateTime
);
2110 /* For Case II - Update rExpirationTime of Sta Record */
2111 GET_CURRENT_SYSTIME(&prStaRec
->rUpdateTime
);
2118 * Case III. This is a new TA and we need to compare the TSF and get the winner.
2119 * Case IV. This is an old TA and it merge into a new IBSS before we do the same thing.
2120 * We need to compare the TSF to get the winner.
2121 * Case V. This is an old TA and it restart a new IBSS. We also need to
2122 * compare the TSF to get the winner.
2125 /* For Case III, IV & V - We'll always check this new IBSS's capability first
2126 * before merging into new IBSS.
2128 fgIsCheckCapability
= TRUE
;
2130 /* If check is passed, we need to perform TSF check to decide the major BSSID */
2131 fgIsCheckTSF
= TRUE
;
2133 /* For Case IV & V - We won't update rExpirationTime of Sta Record */
2137 /* 4 <7> Check this BSS_DESC_T's capability. */
2138 if (fgIsCheckCapability
) {
2139 BOOLEAN fgIsCapabilityMatched
= FALSE
;
2144 ucPhyTypeSet
& (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
))) {
2146 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2147 " - Unsupported Phy.\n", MAC2STR(prBssDesc
->aucSrcAddr
)));
2152 if (prBssDesc
->fgIsUnknownBssBasicRate
) {
2154 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2155 " - Unknown Basic Rate.\n",
2156 MAC2STR(prBssDesc
->aucSrcAddr
)));
2161 if (ibssCheckCapabilityForAdHocMode(prAdapter
, prBssDesc
) ==
2162 WLAN_STATUS_FAILURE
) {
2164 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2165 " - Capability is not matched.\n",
2166 MAC2STR(prBssDesc
->aucSrcAddr
)));
2171 fgIsCapabilityMatched
= TRUE
;
2175 if (!fgIsCapabilityMatched
) {
2178 /* For Case II - We merge this STA_RECORD in RX Path.
2179 * Case IV & V - They change their BSSID after we merge with them.
2183 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2184 " - Capability is not matched.\n",
2185 MAC2STR(prBssDesc
->aucSrcAddr
)));
2192 ("IBSS MERGE: Peer MAC: " MACSTR
" - Check capability was passed.\n",
2193 MAC2STR(prBssDesc
->aucSrcAddr
)));
2199 fgIsGoingMerging
= TRUE
;
2201 if (prBssDesc
->fgIsLargerTSF
) {
2202 fgIsGoingMerging
= TRUE
;
2210 if (fgIsGoingMerging
) {
2211 P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg
;
2214 /* 4 <1> We will merge with to this BSS immediately. */
2215 prBssDesc
->fgIsConnecting
= TRUE
;
2216 prBssDesc
->fgIsConnected
= FALSE
;
2218 /* 4 <2> Setup corresponding STA_RECORD_T */
2219 prStaRec
= bssCreateStaRecFromBssDesc(prAdapter
,
2220 STA_TYPE_ADHOC_PEER
,
2221 NETWORK_TYPE_AIS_INDEX
, prBssDesc
);
2228 prStaRec
->fgIsMerging
= TRUE
;
2231 prStaRec
->ucRCPI
= ucRCPI
;
2233 /* 4 <3> Send Merge Msg to CNM to obtain the channel privilege. */
2234 prAisIbssPeerFoundMsg
= (P_MSG_AIS_IBSS_PEER_FOUND_T
)
2235 cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_AIS_IBSS_PEER_FOUND_T
));
2237 if (!prAisIbssPeerFoundMsg
) {
2239 ASSERT(0); /* Can't send Merge Msg */
2243 prAisIbssPeerFoundMsg
->rMsgHdr
.eMsgId
= MID_SCN_AIS_FOUND_IBSS
;
2244 prAisIbssPeerFoundMsg
->ucNetTypeIndex
= (UINT_8
) NETWORK_TYPE_AIS_INDEX
;
2245 prAisIbssPeerFoundMsg
->prStaRec
= prStaRec
;
2247 /* Inform AIS to do STATE TRANSITION
2248 * For Case I - If AIS in IBSS_ALONE, let it jump to NORMAL_TR after we know the new member.
2249 * For Case III, IV - Now this new BSSID wins the TSF, follow it.
2251 if (fgIsSameBSSID
) {
2252 prAisIbssPeerFoundMsg
->fgIsMergeIn
= TRUE
;
2255 prAisIbssPeerFoundMsg
->fgIsMergeIn
= TRUE
;
2257 prAisIbssPeerFoundMsg
->fgIsMergeIn
=
2258 (prBssDesc
->fgIsLargerTSF
) ? FALSE
: TRUE
;
2262 mboxSendMsg(prAdapter
,
2263 MBOX_ID_0
, (P_MSG_HDR_T
) prAisIbssPeerFoundMsg
, MSG_SEND_METHOD_BUF
);
2268 } /* end of ibssProcessMatchedBeacon() */
2271 /*----------------------------------------------------------------------------*/
2273 * @brief This function will check the Capability for Ad-Hoc to decide if we are
2274 * able to merge with(same capability).
2276 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2278 * @retval WLAN_STATUS_FAILURE Can't pass the check of Capability.
2279 * @retval WLAN_STATUS_SUCCESS Pass the check of Capability.
2281 /*----------------------------------------------------------------------------*/
2282 WLAN_STATUS
ibssCheckCapabilityForAdHocMode(IN P_ADAPTER_T prAdapter
, IN P_BSS_DESC_T prBssDesc
)
2284 P_CONNECTION_SETTINGS_T prConnSettings
;
2285 WLAN_STATUS rStatus
= WLAN_STATUS_FAILURE
;
2289 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2292 /* 4 <1> Check the BSS Basic Rate Set for current AdHoc Mode */
2293 if ((prConnSettings
->eAdHocMode
== AD_HOC_MODE_11B
) &&
2294 (prBssDesc
->u2BSSBasicRateSet
& ~RATE_SET_HR_DSSS
)) {
2296 } else if ((prConnSettings
->eAdHocMode
== AD_HOC_MODE_11A
) &&
2297 (prBssDesc
->u2BSSBasicRateSet
& ~RATE_SET_OFDM
)) {
2300 /* 4 <2> Check the Short Slot Time. */
2301 #if 0 /* Do not check ShortSlotTime until Wi-Fi define such policy */
2302 if (prConnSettings
->eAdHocMode
== AD_HOC_MODE_11G
) {
2303 if (((prConnSettings
->fgIsShortSlotTimeOptionEnable
) &&
2304 !(prBssDesc
->u2CapInfo
& CAP_INFO_SHORT_SLOT_TIME
)) ||
2305 (!(prConnSettings
->fgIsShortSlotTimeOptionEnable
) &&
2306 (prBssDesc
->u2CapInfo
& CAP_INFO_SHORT_SLOT_TIME
))) {
2312 /* 4 <3> Check the ATIM window setting. */
2313 if (prBssDesc
->u2ATIMWindow
) {
2314 DBGLOG(BSS
, INFO
, ("AdHoc PS was not supported(ATIM Window: %d)\n",
2315 prBssDesc
->u2ATIMWindow
));
2318 #if CFG_RSN_MIGRATION
2319 /* 4 <4> Check the Security setting. */
2320 if (!rsnPerformPolicySelection(prAdapter
, prBssDesc
)) {
2325 rStatus
= WLAN_STATUS_SUCCESS
;
2331 } /* end of ibssCheckCapabilityForAdHocMode() */
2334 /*----------------------------------------------------------------------------*/
2336 * @brief This function will initial the BSS_INFO_T for IBSS Mode.
2338 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2342 /*----------------------------------------------------------------------------*/
2343 VOID
ibssInitForAdHoc(IN P_ADAPTER_T prAdapter
, IN P_BSS_INFO_T prBssInfo
)
2345 UINT_8 ucLowestBasicRateIndex
;
2346 UINT_8 aucBSSID
[MAC_ADDR_LEN
];
2347 PUINT_16 pu2BSSID
= (PUINT_16
) &aucBSSID
[0];
2352 ASSERT(prBssInfo
->eCurrentOPMode
== OP_MODE_IBSS
);
2355 /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
2356 prBssInfo
->ucNonHTBasicPhyType
= (UINT_8
)
2357 rNonHTAdHocModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].ePhyTypeIndex
;
2358 prBssInfo
->u2BSSBasicRateSet
=
2359 rNonHTAdHocModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].u2BSSBasicRateSet
;
2362 prBssInfo
->u2OperationalRateSet
=
2363 rNonHTPhyAttributes
[prBssInfo
->ucNonHTBasicPhyType
].u2SupportedRateSet
;
2365 rateGetDataRatesFromRateSet(prBssInfo
->u2OperationalRateSet
,
2366 prBssInfo
->u2BSSBasicRateSet
,
2367 prBssInfo
->aucAllSupportedRates
,
2368 &prBssInfo
->ucAllSupportedRatesLen
);
2370 /* 4 <2> Setup BSSID */
2371 if (!prBssInfo
->fgHoldSameBssidForIBSS
) {
2373 for (i
= 0; i
< sizeof(aucBSSID
) / sizeof(UINT_16
); i
++) {
2374 pu2BSSID
[i
] = (UINT_16
) (kalRandomNumber() & 0xFFFF);
2377 aucBSSID
[0] &= ~0x01; /* 7.1.3.3.3 - The individual/group bit of the address is set to 0. */
2378 aucBSSID
[0] |= 0x02; /* 7.1.3.3.3 - The universal/local bit of the address is set to 1. */
2380 COPY_MAC_ADDR(prBssInfo
->aucBSSID
, aucBSSID
);
2383 /* 4 <3> Setup Capability - Short Preamble */
2384 if (rNonHTPhyAttributes
[prBssInfo
->ucNonHTBasicPhyType
].fgIsShortPreambleOptionImplemented
&& ((prAdapter
->rWifiVar
.ePreambleType
== PREAMBLE_TYPE_SHORT
) || /* Short Preamble Option Enable is TRUE */
2385 (prAdapter
->rWifiVar
.ePreambleType
== PREAMBLE_TYPE_AUTO
))) {
2387 prBssInfo
->fgIsShortPreambleAllowed
= TRUE
;
2388 prBssInfo
->fgUseShortPreamble
= TRUE
;
2390 prBssInfo
->fgIsShortPreambleAllowed
= FALSE
;
2391 prBssInfo
->fgUseShortPreamble
= FALSE
;
2395 /* 4 <4> Setup Capability - Short Slot Time */
2396 /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
2397 prBssInfo
->fgUseShortSlotTime
= FALSE
; /* Set to FALSE for AdHoc */
2400 /* 4 <5> Compoase Capability */
2401 prBssInfo
->u2CapInfo
= CAP_INFO_IBSS
;
2403 if (prBssInfo
->fgIsProtection
) {
2404 prBssInfo
->u2CapInfo
|= CAP_INFO_PRIVACY
;
2407 if (prBssInfo
->fgIsShortPreambleAllowed
) {
2408 prBssInfo
->u2CapInfo
|= CAP_INFO_SHORT_PREAMBLE
;
2411 if (prBssInfo
->fgUseShortSlotTime
) {
2412 prBssInfo
->u2CapInfo
|= CAP_INFO_SHORT_SLOT_TIME
;
2415 /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
2416 rateGetLowestRateIndexFromRateSet(prBssInfo
->u2BSSBasicRateSet
, &ucLowestBasicRateIndex
);
2418 prBssInfo
->ucHwDefaultFixedRateCode
=
2419 aucRateIndex2RateCode
[PREAMBLE_DEFAULT_LONG_NONE
][ucLowestBasicRateIndex
];
2422 } /* end of ibssInitForAdHoc() */
2424 #endif /* CFG_SUPPORT_ADHOC */
2429 /*----------------------------------------------------------------------------*/
2430 /* Routines for BSS(AP) only */
2431 /*----------------------------------------------------------------------------*/
2432 /*----------------------------------------------------------------------------*/
2434 * @brief This function will initial the BSS_INFO_T for AP Mode.
2436 * @param[in] prBssInfo Given related BSS_INFO_T.
2440 /*----------------------------------------------------------------------------*/
2441 VOID
bssInitForAP(IN P_ADAPTER_T prAdapter
, IN P_BSS_INFO_T prBssInfo
, IN BOOLEAN fgIsRateUpdate
)
2443 UINT_8 ucLowestBasicRateIndex
;
2445 P_AC_QUE_PARMS_T prACQueParms
;
2447 ENUM_WMM_ACI_T eAci
;
2449 UINT_8 auCWminLog2ForBcast
[WMM_AC_INDEX_NUM
] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
2450 UINT_8 auCWmaxLog2ForBcast
[WMM_AC_INDEX_NUM
] = { 10, 10, 4, 3 };
2451 UINT_8 auAifsForBcast
[WMM_AC_INDEX_NUM
] = { 3, 7, 2, 2 };
2452 UINT_8 auTxopForBcast
[WMM_AC_INDEX_NUM
] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2454 UINT_8 auCWminLog2
[WMM_AC_INDEX_NUM
] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
2455 UINT_8 auCWmaxLog2
[WMM_AC_INDEX_NUM
] = { 7, 10, 4, 3 };
2456 UINT_8 auAifs
[WMM_AC_INDEX_NUM
] = { 3, 7, 1, 1 };
2457 UINT_8 auTxop
[WMM_AC_INDEX_NUM
] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2459 DEBUGFUNC("bssInitForAP");
2460 DBGLOG(BSS
, LOUD
, ("\n"));
2463 ASSERT((prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
)
2464 || (prBssInfo
->eCurrentOPMode
== OP_MODE_BOW
));
2467 prAdapter
->rWifiVar
.rConnSettings
.fgRxShortGIDisabled
= TRUE
;
2468 prAdapter
->rWifiVar
.rConnSettings
.uc2G4BandwidthMode
= CONFIG_BW_20M
;
2469 prAdapter
->rWifiVar
.rConnSettings
.uc5GBandwidthMode
= CONFIG_BW_20M
;
2473 /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
2474 prBssInfo
->ucNonHTBasicPhyType
= (UINT_8
)
2475 rNonHTApModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].ePhyTypeIndex
;
2476 prBssInfo
->u2BSSBasicRateSet
=
2477 rNonHTApModeAttributes
[prBssInfo
->ucConfigAdHocAPMode
].u2BSSBasicRateSet
;
2480 prBssInfo
->u2OperationalRateSet
=
2481 rNonHTPhyAttributes
[prBssInfo
->ucNonHTBasicPhyType
].u2SupportedRateSet
;
2483 if (fgIsRateUpdate
) {
2484 rateGetDataRatesFromRateSet(prBssInfo
->u2OperationalRateSet
,
2485 prBssInfo
->u2BSSBasicRateSet
,
2486 prBssInfo
->aucAllSupportedRates
,
2487 &prBssInfo
->ucAllSupportedRatesLen
);
2489 /* 4 <2> Setup BSSID */
2490 COPY_MAC_ADDR(prBssInfo
->aucBSSID
, prBssInfo
->aucOwnMacAddr
);
2493 /* 4 <3> Setup Capability - Short Preamble */
2494 if (rNonHTPhyAttributes
[prBssInfo
->ucNonHTBasicPhyType
].fgIsShortPreambleOptionImplemented
&& ((prAdapter
->rWifiVar
.ePreambleType
== PREAMBLE_TYPE_SHORT
) || /* Short Preamble Option Enable is TRUE */
2495 (prAdapter
->rWifiVar
.ePreambleType
== PREAMBLE_TYPE_AUTO
))) {
2497 prBssInfo
->fgIsShortPreambleAllowed
= TRUE
;
2498 prBssInfo
->fgUseShortPreamble
= TRUE
;
2500 prBssInfo
->fgIsShortPreambleAllowed
= FALSE
;
2501 prBssInfo
->fgUseShortPreamble
= FALSE
;
2505 /* 4 <4> Setup Capability - Short Slot Time */
2506 prBssInfo
->fgUseShortSlotTime
= TRUE
;
2508 /* 4 <5> Compoase Capability */
2509 prBssInfo
->u2CapInfo
= CAP_INFO_ESS
;
2511 if (prBssInfo
->fgIsProtection
) {
2512 prBssInfo
->u2CapInfo
|= CAP_INFO_PRIVACY
;
2515 if (prBssInfo
->fgIsShortPreambleAllowed
) {
2516 prBssInfo
->u2CapInfo
|= CAP_INFO_SHORT_PREAMBLE
;
2519 if (prBssInfo
->fgUseShortSlotTime
) {
2520 prBssInfo
->u2CapInfo
|= CAP_INFO_SHORT_SLOT_TIME
;
2523 /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
2524 rateGetLowestRateIndexFromRateSet(prBssInfo
->u2BSSBasicRateSet
, &ucLowestBasicRateIndex
);
2526 prBssInfo
->ucHwDefaultFixedRateCode
=
2527 aucRateIndex2RateCode
[PREAMBLE_DEFAULT_LONG_NONE
][ucLowestBasicRateIndex
];
2530 /* 4 <7> Fill the EDCA */
2532 prACQueParms
= prBssInfo
->arACQueParmsForBcast
;
2534 for (eAci
= 0; eAci
< WMM_AC_INDEX_NUM
; eAci
++) {
2536 prACQueParms
[eAci
].fgIsACMSet
= FALSE
;
2537 prACQueParms
[eAci
].u2Aifsn
= auAifsForBcast
[eAci
];
2538 prACQueParms
[eAci
].u2CWmin
= BIT(auCWminLog2ForBcast
[eAci
]) - 1;
2539 prACQueParms
[eAci
].u2CWmax
= BIT(auCWmaxLog2ForBcast
[eAci
]) - 1;
2540 prACQueParms
[eAci
].u2TxopLimit
= auTxopForBcast
[eAci
];
2542 prBssInfo
->aucCWminLog2ForBcast
[eAci
] = auCWminLog2ForBcast
[eAci
]; /* used to send WMM IE */
2543 prBssInfo
->aucCWmaxLog2ForBcast
[eAci
] = auCWmaxLog2ForBcast
[eAci
];
2546 ("Bcast: eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2547 eAci
, prACQueParms
[eAci
].fgIsACMSet
, prACQueParms
[eAci
].u2Aifsn
,
2548 prACQueParms
[eAci
].u2CWmin
, prACQueParms
[eAci
].u2CWmax
,
2549 prACQueParms
[eAci
].u2TxopLimit
));
2553 prACQueParms
= prBssInfo
->arACQueParms
;
2555 for (eAci
= 0; eAci
< WMM_AC_INDEX_NUM
; eAci
++) {
2557 prACQueParms
[eAci
].fgIsACMSet
= FALSE
;
2558 prACQueParms
[eAci
].u2Aifsn
= auAifs
[eAci
];
2559 prACQueParms
[eAci
].u2CWmin
= BIT(auCWminLog2
[eAci
]) - 1;
2560 prACQueParms
[eAci
].u2CWmax
= BIT(auCWmaxLog2
[eAci
]) - 1;
2561 prACQueParms
[eAci
].u2TxopLimit
= auTxop
[eAci
];
2564 ("eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2565 eAci
, prACQueParms
[eAci
].fgIsACMSet
, prACQueParms
[eAci
].u2Aifsn
,
2566 prACQueParms
[eAci
].u2CWmin
, prACQueParms
[eAci
].u2CWmax
,
2567 prACQueParms
[eAci
].u2TxopLimit
));
2570 /* Note: Caller should update the EDCA setting to HW by nicQmUpdateWmmParms() it there is no AIS network */
2571 /* Note: In E2, only 4 HW queues. The the Edca parameters should be folow by AIS network */
2572 /* Note: In E3, 8 HW queues. the Wmm parameters should be updated to right queues according to BSS */
2576 } /* end of bssInitForAP() */
2579 /*----------------------------------------------------------------------------*/
2581 * @brief Update DTIM Count
2583 * @param[in] eNetTypeIndex Specify which network to update
2587 /*----------------------------------------------------------------------------*/
2588 VOID
bssUpdateDTIMCount(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
)
2590 P_BSS_INFO_T prBssInfo
;
2593 ASSERT(eNetTypeIndex
< NETWORK_TYPE_INDEX_NUM
);
2595 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIndex
]);
2597 if (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
2599 /* Setup DTIM Count for next TBTT. */
2600 if (prBssInfo
->ucDTIMCount
> 0) {
2601 prBssInfo
->ucDTIMCount
--;
2604 ASSERT(prBssInfo
->ucDTIMPeriod
> 0);
2606 prBssInfo
->ucDTIMCount
= prBssInfo
->ucDTIMPeriod
- 1;
2611 } /* end of bssUpdateDTIMIE() */
2614 /*----------------------------------------------------------------------------*/
2616 * @brief This function is used to set the Virtual Bitmap in TIM Information Elements
2618 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2619 * @param[in] u2AssocId The association id to set in Virtual Bitmap.
2623 /*----------------------------------------------------------------------------*/
2624 VOID
bssSetTIMBitmap(IN P_ADAPTER_T prAdapter
, IN P_BSS_INFO_T prBssInfo
, IN UINT_16 u2AssocId
)
2629 if (prBssInfo
->ucNetTypeIndex
== NETWORK_TYPE_P2P_INDEX
) {
2630 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo
;
2633 prP2pSpecificBssInfo
= &(prAdapter
->rWifiVar
.rP2pSpecificBssInfo
);
2635 /* Use Association ID == 0 for BMCAST indication */
2636 if (u2AssocId
== 0) {
2638 prP2pSpecificBssInfo
->ucBitmapCtrl
|= (UINT_8
) BIT(0);
2640 PUINT_8 pucPartialVirtualBitmap
;
2641 UINT_8 ucBitmapToSet
;
2644 pucPartialVirtualBitmap
= &prP2pSpecificBssInfo
->aucPartialVirtualBitmap
[(u2AssocId
>> 3)]; /* (u2AssocId / 8) */
2645 ucBitmapToSet
= (UINT_8
) BIT((u2AssocId
% 8));
2647 if (*pucPartialVirtualBitmap
& ucBitmapToSet
) {
2648 /* The virtual bitmap has been set */
2652 *pucPartialVirtualBitmap
|= ucBitmapToSet
;
2654 /* Update u2SmallestAID and u2LargestAID */
2655 if ((u2AssocId
< prP2pSpecificBssInfo
->u2SmallestAID
) ||
2656 (prP2pSpecificBssInfo
->u2SmallestAID
== 0)) {
2657 prP2pSpecificBssInfo
->u2SmallestAID
= u2AssocId
;
2660 if ((u2AssocId
> prP2pSpecificBssInfo
->u2LargestAID
) ||
2661 (prP2pSpecificBssInfo
->u2LargestAID
== 0)) {
2662 prP2pSpecificBssInfo
->u2LargestAID
= u2AssocId
;
2668 } /* end of bssSetTIMBitmap() */
2671 #endif /* CFG_SUPPORT_AAA */
2674 VOID
bssCreateStaRecFromAuth(IN P_ADAPTER_T prAdapter
)
2680 VOID
bssUpdateStaRecFromAssocReq(IN P_ADAPTER_T prAdapter
)