import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6630 / wlan / mgmt / p2p_scan.c
CommitLineData
6fa3eb70
S
1/*
2** $Id: @(#) p2p_scan.c@@
3*/
4
5/*! \file "p2p_scan.c"
6 \brief This file defines the p2p scan profile and the processing function of
7 scan result for SCAN Module.
8
9 The SCAN Profile selection is part of SCAN MODULE and responsible for defining
10 SCAN Parameters - e.g. MIN_CHANNEL_TIME, number of scan channels.
11 In this file we also define the process of SCAN Result including adding, searching
12 and removing SCAN record from the list.
13*/
14
15
16
17
18
19/*******************************************************************************
20* C O M P I L E R F L A G S
21********************************************************************************
22*/
23
24/*******************************************************************************
25* E X T E R N A L R E F E R E N C E S
26********************************************************************************
27*/
28
29#include "precomp.h"
30
31/*******************************************************************************
32* C O N S T A N T S
33********************************************************************************
34*/
35
36/*******************************************************************************
37* D A T A T Y P E S
38********************************************************************************
39*/
40
41/*******************************************************************************
42* P U B L I C D A T A
43********************************************************************************
44*/
45
46/*******************************************************************************
47* P R I V A T E D A T A
48********************************************************************************
49*/
50
51/*******************************************************************************
52* M A C R O S
53********************************************************************************
54*/
55
56/*******************************************************************************
57* F U N C T I O N D E C L A R A T I O N S
58********************************************************************************
59*/
60
61/*******************************************************************************
62* F U N C T I O N S
63********************************************************************************
64*/
65
66
67VOID
68scanP2pProcessBeaconAndProbeResp(IN P_ADAPTER_T prAdapter,
69 IN P_SW_RFB_T prSwRfb,
70 IN P_WLAN_STATUS prStatus,
71 IN P_BSS_DESC_T prBssDesc,
72 IN P_WLAN_BEACON_FRAME_T prWlanBeaconFrame)
73{
74 if (prBssDesc->fgIsP2PPresent) {
75 if ((prBssDesc->fgIsConnected) && /* P2P GC connected. */
76 ((prWlanBeaconFrame->u2FrameCtrl & MASK_FRAME_TYPE) == MAC_FRAME_BEACON) /* TX Beacon */
77 ) {
78 UINT_32 u4Idx = 0;
79 P_BSS_INFO_T prP2pBssInfo = (P_BSS_INFO_T) NULL;
80
81 for (u4Idx = 0; u4Idx < BSS_INFO_NUM; u4Idx++) {
82 /* Check BSS for P2P. */
83 /* Check BSSID. */
84 prP2pBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, (UINT_8) u4Idx);
85
86 if (!IS_BSS_ACTIVE(prP2pBssInfo)) {
87 continue;
88 }
89
90 if ((prP2pBssInfo->eNetworkType != NETWORK_TYPE_P2P) ||
91 (UNEQUAL_MAC_ADDR(prP2pBssInfo->aucBSSID, prBssDesc->aucBSSID)
92 ||
93 (!EQUAL_SSID
94 (prP2pBssInfo->aucSSID, prP2pBssInfo->ucSSIDLen,
95 prBssDesc->aucSSID, prBssDesc->ucSSIDLen)))) {
96 continue;
97 }
98
99 if ((prP2pBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) && /* P2P GC */
100 (prP2pBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) && /* Connected */
101 (!prP2pBssInfo->ucDTIMPeriod)) { /* First Time. */
102 prP2pBssInfo->ucDTIMPeriod = prBssDesc->ucDTIMPeriod;
103 nicPmIndicateBssConnected(prAdapter,
104 prP2pBssInfo->ucBssIndex);
105 }
106
107 }
108
109 }
110
111 do {
112 RF_CHANNEL_INFO_T rChannelInfo;
113
114 ASSERT_BREAK((prSwRfb != NULL) && (prBssDesc != NULL));
115
116 if (((prWlanBeaconFrame->u2FrameCtrl & MASK_FRAME_TYPE) !=
117 MAC_FRAME_PROBE_RSP)) {
118 /* Only report Probe Response frame to supplicant. */
119 /* Probe response collect much more information. */
120 break;
121 }
122
123 rChannelInfo.ucChannelNum = prBssDesc->ucChannelNum;
124 rChannelInfo.eBand = prBssDesc->eBand;
125 prBssDesc->fgIsP2PReport = TRUE;
126
127 DBGLOG(P2P, INFO,
128 ("indicate %s [%d]\n", prBssDesc->aucSSID, prBssDesc->ucChannelNum));
129
130 kalP2PIndicateBssInfo(prAdapter->prGlueInfo,
131 (PUINT_8) prSwRfb->pvHeader,
132 (UINT_32) prSwRfb->u2PacketLen,
133 &rChannelInfo, RCPI_TO_dBm(prBssDesc->ucRCPI));
134
135
136 } while (FALSE);
137 }
138}
139
140VOID scnEventReturnChannel(IN P_ADAPTER_T prAdapter, IN UINT_8 ucScnSeqNum)
141{
142
143 CMD_SCAN_CANCEL rCmdScanCancel;
144
145 /* send cancel message to firmware domain */
146 rCmdScanCancel.ucSeqNum = ucScnSeqNum;
147 rCmdScanCancel.ucIsExtChannel = (UINT_8) FALSE;
148
149 wlanSendSetQueryCmd(prAdapter,
150 CMD_ID_SCAN_CANCEL,
151 TRUE,
152 FALSE,
153 FALSE,
154 NULL,
155 NULL, sizeof(CMD_SCAN_CANCEL), (PUINT_8) & rCmdScanCancel, NULL, 0);
156
157 return;
158} /* scnEventReturnChannel */
159
160VOID scanRemoveAllP2pBssDesc(IN P_ADAPTER_T prAdapter)
161{
162 P_LINK_T prBSSDescList;
163 P_BSS_DESC_T prBssDesc;
164 P_BSS_DESC_T prBSSDescNext;
165
166 ASSERT(prAdapter);
167
168 prBSSDescList = &(prAdapter->rWifiVar.rScanInfo.rBSSDescList);
169
170 /* Search BSS Desc from current SCAN result list. */
171 LINK_FOR_EACH_ENTRY_SAFE(prBssDesc, prBSSDescNext, prBSSDescList, rLinkEntry, BSS_DESC_T) {
172 scanRemoveP2pBssDesc(prAdapter, prBssDesc);
173 }
174} /* scanRemoveAllP2pBssDesc */
175
176VOID scanRemoveP2pBssDesc(IN P_ADAPTER_T prAdapter, IN P_BSS_DESC_T prBssDesc)
177{
178
179 return;
180} /* scanRemoveP2pBssDesc */
181
182
183P_BSS_DESC_T
184scanP2pSearchDesc(IN P_ADAPTER_T prAdapter, IN P_P2P_CONNECTION_REQ_INFO_T prConnReqInfo)
185{
186 P_BSS_DESC_T prCandidateBssDesc = (P_BSS_DESC_T) NULL, prBssDesc = (P_BSS_DESC_T) NULL;
187 P_LINK_T prBssDescList = (P_LINK_T) NULL;
188
189 do {
190 if ((prAdapter == NULL) || (prConnReqInfo == NULL)) {
191 break;
192 }
193
194
195 prBssDescList = &(prAdapter->rWifiVar.rScanInfo.rBSSDescList);
196
197 DBGLOG(P2P, LOUD,
198 ("Connecting to BSSID: " MACSTR "\n", MAC2STR(prConnReqInfo->aucBssid)));
199 DBGLOG(P2P, LOUD,
200 ("Connecting to SSID:%s, length:%d\n", prConnReqInfo->rSsidStruct.aucSsid,
201 prConnReqInfo->rSsidStruct.ucSsidLen));
202
203 LINK_FOR_EACH_ENTRY(prBssDesc, prBssDescList, rLinkEntry, BSS_DESC_T) {
204 DBGLOG(P2P, LOUD,
205 ("Checking BSS: " MACSTR "\n", MAC2STR(prBssDesc->aucBSSID)));
206
207 if (prBssDesc->eBSSType != BSS_TYPE_INFRASTRUCTURE) {
208 DBGLOG(P2P, LOUD, ("Ignore mismatch BSS type.\n"));
209 continue;
210 }
211
212
213 if (UNEQUAL_MAC_ADDR(prBssDesc->aucBSSID, prConnReqInfo->aucBssid)) {
214 DBGLOG(P2P, LOUD, ("Ignore mismatch BSSID.\n"));
215 continue;
216 }
217
218
219 /* SSID should be the same? SSID is vary for each connection. so... */
220 if (UNEQUAL_SSID(prConnReqInfo->rSsidStruct.aucSsid,
221 prConnReqInfo->rSsidStruct.ucSsidLen,
222 prBssDesc->aucSSID, prBssDesc->ucSSIDLen)) {
223
224 DBGLOG(P2P, TRACE,
225 ("Connecting to BSSID: " MACSTR "\n",
226 MAC2STR(prConnReqInfo->aucBssid)));
227 DBGLOG(P2P, TRACE,
228 ("Connecting to SSID:%s, length:%d\n",
229 prConnReqInfo->rSsidStruct.aucSsid,
230 prConnReqInfo->rSsidStruct.ucSsidLen));
231 DBGLOG(P2P, TRACE,
232 ("Checking SSID:%s, length:%d\n", prBssDesc->aucSSID,
233 prBssDesc->ucSSIDLen));
234 DBGLOG(P2P, TRACE, ("Ignore mismatch SSID, (But BSSID match).\n"));
235 //ASSERT(FALSE); /*let p2p re-scan again */
236 continue;
237 }
238
239 if (!prBssDesc->fgIsP2PPresent) {
240 DBGLOG(P2P, ERROR,
241 ("SSID, BSSID, BSSTYPE match, but no P2P IE present.\n"));
242 continue;
243 }
244
245 /* Final decision. */
246 prCandidateBssDesc = prBssDesc;
247 break;
248 }
249
250
251
252 } while (FALSE);
253
254 return prCandidateBssDesc;
255} /* scanP2pSearchDesc */