2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/rlm_obss.c#2 $
15 * 07 17 2012 yuche.tsai
17 * Compile no error before trial run.
21 * Avoid possible OBSS scan when BSS is switched
25 * Add RLM and CNM debug message for XLOG
28 * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
29 * Regulation class is changed to 81 in 20_40_coexistence action frame
32 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
36 * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
40 * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode and stop ampdu timer when sta_rec is freed
41 * Process received 20/40 coexistence action frame for AP mode
44 * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
45 * Refine function when rcv a 20/40M public action frame
48 * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
49 * Use SCO of BSS_INFO to replace user-defined setting variables
52 * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
53 * User-defined bandwidth is for 2.4G and 5G individually
56 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
57 * use definition macro to replace hard-coded constant
61 * Change conditional compiling options for BOW
65 * Always update Beacon content if FW sync OBSS info
69 * Support RLM initail channel of Ad-hoc, P2P and BOW
73 * Migrate RLM code to host from FW
75 * 07 26 2010 yuche.tsai
77 * Fix compile error while enabling WiFi Direct function.
79 * 07 21 2010 yuche.tsai
81 * Add P2P Scan & Scan Result Parsing & Saving.
85 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
88 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
89 * Check draft RLM code for HT cap
92 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
93 * Process 20/40 coexistence public action frame in AP mode
96 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
97 * First draft support for 20/40M bandwidth for AP mode
100 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
101 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
103 * 04 13 2010 cm.chang
104 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
105 * Add more ASSERT to check exception
107 * 04 07 2010 cm.chang
108 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
109 * Add virtual test for OBSS scan
111 * 03 30 2010 cm.chang
112 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
113 * Support 2.4G OBSS scan
115 * 03 03 2010 cm.chang
116 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
117 * To support CFG_SUPPORT_BCM_STP
119 * 02 13 2010 cm.chang
120 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
121 * Support PCO in STA mode
123 * 02 12 2010 cm.chang
124 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
125 * Use bss info array for concurrent handle
127 * 02 05 2010 kevin.huang
128 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
129 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
131 * 01 25 2010 cm.chang
132 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
133 * Support protection and bandwidth switch
136 /*******************************************************************************
137 * C O M P I L E R F L A G S
138 ********************************************************************************
141 /*******************************************************************************
142 * E X T E R N A L R E F E R E N C E S
143 ********************************************************************************
147 /*******************************************************************************
149 ********************************************************************************
152 /*******************************************************************************
154 ********************************************************************************
157 /*******************************************************************************
158 * P U B L I C D A T A
159 ********************************************************************************
162 /*******************************************************************************
163 * P R I V A T E D A T A
164 ********************************************************************************
167 /*******************************************************************************
169 ********************************************************************************
172 /*******************************************************************************
173 * F U N C T I O N D E C L A R A T I O N S
174 ********************************************************************************
178 P_ADAPTER_T prAdapter
,
182 /*******************************************************************************
184 ********************************************************************************
187 /*----------------------------------------------------------------------------*/
195 /*----------------------------------------------------------------------------*/
198 P_ADAPTER_T prAdapter
201 P_BSS_INFO_T prBssInfo
;
204 RLM_NET_FOR_EACH(ucNetIdx
) {
205 prBssInfo
= &prAdapter
->rWifiVar
.arBssInfo
[ucNetIdx
];
208 cnmTimerInitTimer(prAdapter
, &prBssInfo
->rObssScanTimer
,
209 rlmObssScanTimeout
, (ULONG
) prBssInfo
);
210 } /* end of RLM_NET_FOR_EACH */
213 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
223 rlmObssUpdateChnlLists (
224 P_ADAPTER_T prAdapter
,
231 /*----------------------------------------------------------------------------*/
239 /*----------------------------------------------------------------------------*/
242 P_ADAPTER_T prAdapter
,
246 P_MSG_SCN_SCAN_DONE prScanDoneMsg
;
247 P_BSS_INFO_T prBssInfo
;
248 P_MSDU_INFO_T prMsduInfo
;
249 P_ACTION_20_40_COEXIST_FRAME prTxFrame
;
250 UINT_16 i
, u2PayloadLen
;
254 prScanDoneMsg
= (P_MSG_SCN_SCAN_DONE
) prMsgHdr
;
255 prBssInfo
= &prAdapter
->rWifiVar
.arBssInfo
[prScanDoneMsg
->ucNetTypeIndex
];
258 DBGLOG(RLM
, INFO
, ("OBSS Scan Done (NetIdx=%d, Mode=%d)\n",
259 prScanDoneMsg
->ucNetTypeIndex
, prBssInfo
->eCurrentOPMode
));
261 cnmMemFree(prAdapter
, prMsgHdr
);
263 #if CFG_ENABLE_WIFI_DIRECT
265 if ((prAdapter
->fgIsP2PRegistered
) &&
266 (IS_NET_ACTIVE(prAdapter
, prBssInfo
->ucNetTypeIndex
)) &&
267 (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
)) {
273 if (prBssInfo
->eCurrentOPMode
!= OP_MODE_INFRASTRUCTURE
||
274 !RLM_NET_PARAM_VALID(prBssInfo
) || prBssInfo
->u2ObssScanInterval
== 0) {
275 DBGLOG(RLM
, WARN
, ("OBSS Scan Done (NetIdx=%d) -- Aborted!!\n",
276 prBssInfo
->ucNetTypeIndex
));
280 /* To do: check 2.4G channel list to decide if obss mgmt should be
281 * sent to associated AP. Note: how to handle concurrent network?
282 * To do: invoke rlmObssChnlLevel() to decide if 20/40 BSS coexistence
283 * management frame is needed.
285 if ((prBssInfo
->auc2G_20mReqChnlList
[0] > 0 ||
286 prBssInfo
->auc2G_NonHtChnlList
[0] > 0) &&
287 (prMsduInfo
= (P_MSDU_INFO_T
) cnmMgtPktAlloc(prAdapter
,
288 MAC_TX_RESERVED_FIELD
+ PUBLIC_ACTION_MAX_LEN
)) != NULL
) {
290 DBGLOG(RLM
, INFO
, ("Send 20/40 coexistence mgmt(20mReq=%d, NonHt=%d)\n",
291 prBssInfo
->auc2G_20mReqChnlList
[0],
292 prBssInfo
->auc2G_NonHtChnlList
[0]));
294 prTxFrame
= (P_ACTION_20_40_COEXIST_FRAME
)
295 ((ULONG
)(prMsduInfo
->prPacket
) + MAC_TX_RESERVED_FIELD
);
297 prTxFrame
->u2FrameCtrl
= MAC_FRAME_ACTION
;
298 COPY_MAC_ADDR(prTxFrame
->aucDestAddr
, prBssInfo
->aucBSSID
);
299 COPY_MAC_ADDR(prTxFrame
->aucSrcAddr
, prBssInfo
->aucOwnMacAddr
);
300 COPY_MAC_ADDR(prTxFrame
->aucBSSID
, prBssInfo
->aucBSSID
);
302 prTxFrame
->ucCategory
= CATEGORY_PUBLIC_ACTION
;
303 prTxFrame
->ucAction
= ACTION_PUBLIC_20_40_COEXIST
;
305 /* To do: find correct algorithm */
306 prTxFrame
->rBssCoexist
.ucId
= ELEM_ID_20_40_BSS_COEXISTENCE
;
307 prTxFrame
->rBssCoexist
.ucLength
= 1;
308 prTxFrame
->rBssCoexist
.ucData
=
309 (prBssInfo
->auc2G_20mReqChnlList
[0] > 0) ? BSS_COEXIST_20M_REQ
: 0;
311 u2PayloadLen
= 2 + 3;
313 if (prBssInfo
->auc2G_NonHtChnlList
[0] > 0) {
314 ASSERT(prBssInfo
->auc2G_NonHtChnlList
[0] <= CHNL_LIST_SZ_2G
);
316 prTxFrame
->rChnlReport
.ucId
= ELEM_ID_20_40_INTOLERANT_CHNL_REPORT
;
317 prTxFrame
->rChnlReport
.ucLength
=
318 prBssInfo
->auc2G_NonHtChnlList
[0] + 1;
319 prTxFrame
->rChnlReport
.ucRegulatoryClass
= 81; /* 2.4GHz, ch1~13 */
320 for (i
= 0; i
< prBssInfo
->auc2G_NonHtChnlList
[0] &&
321 i
< CHNL_LIST_SZ_2G
; i
++) {
322 prTxFrame
->rChnlReport
.aucChannelList
[i
] =
323 prBssInfo
->auc2G_NonHtChnlList
[i
+1];
326 u2PayloadLen
+= IE_SIZE(&prTxFrame
->rChnlReport
);
328 ASSERT((WLAN_MAC_HEADER_LEN
+ u2PayloadLen
) <= PUBLIC_ACTION_MAX_LEN
);
330 /* Clear up channel lists in 2.4G band */
331 prBssInfo
->auc2G_20mReqChnlList
[0] = 0;
332 prBssInfo
->auc2G_NonHtChnlList
[0] = 0;
335 //4 Update information of MSDU_INFO_T
336 prMsduInfo
->ucPacketType
= HIF_TX_PACKET_TYPE_MGMT
; /* Management frame */
337 prMsduInfo
->ucStaRecIndex
= prBssInfo
->prStaRecOfAP
->ucIndex
;
338 prMsduInfo
->ucNetworkType
= prBssInfo
->ucNetTypeIndex
;
339 prMsduInfo
->ucMacHeaderLength
= WLAN_MAC_MGMT_HEADER_LEN
;
340 prMsduInfo
->fgIs802_1x
= FALSE
;
341 prMsduInfo
->fgIs802_11
= TRUE
;
342 prMsduInfo
->u2FrameLength
= WLAN_MAC_MGMT_HEADER_LEN
+ u2PayloadLen
;
343 prMsduInfo
->ucTxSeqNum
= nicIncreaseTxSeqNum(prAdapter
);
344 prMsduInfo
->pfTxDoneHandler
= NULL
;
345 prMsduInfo
->fgIsBasicRate
= FALSE
;
347 //4 Enqueue the frame to send this action frame.
348 nicTxEnqueueMsdu(prAdapter
, prMsduInfo
);
349 } /* end of prMsduInfo != NULL */
351 if (prBssInfo
->u2ObssScanInterval
> 0) {
352 DBGLOG(RLM
, INFO
, ("Set OBSS timer (NetIdx=%d, %d sec)\n",
353 prBssInfo
->ucNetTypeIndex
, prBssInfo
->u2ObssScanInterval
));
355 cnmTimerStartTimer(prAdapter
, &prBssInfo
->rObssScanTimer
,
356 prBssInfo
->u2ObssScanInterval
* MSEC_PER_SEC
);
360 /*----------------------------------------------------------------------------*/
368 /*----------------------------------------------------------------------------*/
371 P_ADAPTER_T prAdapter
,
375 P_BSS_INFO_T prBssInfo
;
377 prBssInfo
= (P_BSS_INFO_T
) ulData
;
380 #if CFG_ENABLE_WIFI_DIRECT
381 if (prAdapter
->fgIsP2PRegistered
&&
382 (IS_NET_ACTIVE(prAdapter
, prBssInfo
->ucNetTypeIndex
))) {
385 if (prBssInfo
->eCurrentOPMode
== OP_MODE_ACCESS_POINT
) {
387 prBssInfo
->fgObssActionForcedTo20M
= FALSE
;
389 /* Check if Beacon content need to be updated */
390 rlmUpdateParamsForAP(prAdapter
, prBssInfo
, FALSE
);
398 P_WFD_CFG_SETTINGS_T prWfdCfgSettings
= &prAdapter
->rWifiVar
.prP2pFsmInfo
->rWfdConfigureSettings
;
399 P_BSS_INFO_T prP2pBssInfo
= &prAdapter
->rWifiVar
.arBssInfo
[NETWORK_TYPE_P2P_INDEX
];
401 /* If WFD is enabled & connected */
402 if (prWfdCfgSettings
->ucWfdEnable
&&
403 (prWfdCfgSettings
->u4WfdFlag
& BIT(0)) &&
404 RLM_NET_PARAM_VALID(prP2pBssInfo
)) {
407 prBssInfo
->u2ObssScanInterval
= 0;
409 DBGLOG(RLM
, INFO
, ("WFD is running. Stop net[%u] OBSS scan.\n",
410 (UINT_32
)prBssInfo
->ucNetTypeIndex
));
417 #endif /* end of CFG_ENABLE_WIFI_DIRECT */
421 if (prBssInfo
->eCurrentOPMode
!= OP_MODE_INFRASTRUCTURE
||
422 !RLM_NET_PARAM_VALID(prBssInfo
) || prBssInfo
->u2ObssScanInterval
== 0) {
423 DBGLOG(RLM
, WARN
, ("OBSS Scan timeout (NetIdx=%d) -- Aborted!!\n",
424 prBssInfo
->ucNetTypeIndex
));
428 rlmObssTriggerScan(prAdapter
, prBssInfo
);
431 /*----------------------------------------------------------------------------*/
439 /*----------------------------------------------------------------------------*/
442 P_ADAPTER_T prAdapter
,
443 P_BSS_INFO_T prBssInfo
446 P_MSG_SCN_SCAN_REQ prScanReqMsg
;
450 prScanReqMsg
= (P_MSG_SCN_SCAN_REQ
)
451 cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_SCN_SCAN_REQ
));
452 ASSERT(prScanReqMsg
);
455 DBGLOG(RLM
, WARN
, ("No buf for OBSS scan (NetIdx=%d)!!\n",
456 prBssInfo
->ucNetTypeIndex
));
458 cnmTimerStartTimer(prAdapter
, &prBssInfo
->rObssScanTimer
,
459 prBssInfo
->u2ObssScanInterval
* MSEC_PER_SEC
);
463 /* It is ok that ucSeqNum is set to fixed value because the same network
464 * OBSS scan interval is limited to OBSS_SCAN_MIN_INTERVAL (min 10 sec)
465 * and scan module don't care seqNum of OBSS scanning
467 prScanReqMsg
->rMsgHdr
.eMsgId
= MID_RLM_SCN_SCAN_REQ
;
468 prScanReqMsg
->ucSeqNum
= 0x33;
469 prScanReqMsg
->ucNetTypeIndex
= prBssInfo
->ucNetTypeIndex
;
470 prScanReqMsg
->eScanType
= SCAN_TYPE_ACTIVE_SCAN
;
471 prScanReqMsg
->ucSSIDType
= SCAN_REQ_SSID_WILDCARD
;
472 prScanReqMsg
->ucSSIDLength
= 0;
473 prScanReqMsg
->eScanChannel
= SCAN_CHANNEL_2G4
;
474 prScanReqMsg
->u2IELen
= 0;
476 mboxSendMsg(prAdapter
,
478 (P_MSG_HDR_T
) prScanReqMsg
,
479 MSG_SEND_METHOD_BUF
);
481 DBGLOG(RLM
, INFO
, ("Timeout to trigger OBSS scan (NetIdx=%d)!!\n",
482 prBssInfo
->ucNetTypeIndex
));