0
|
1 |
/*
|
|
2 |
* ScanSrv.c
|
|
3 |
*
|
|
4 |
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* This program and the accompanying materials are made available under the
|
|
8 |
* terms of the Eclipse Public License v1.0 or BSD License which accompanies
|
|
9 |
* this distribution. The Eclipse Public License is available at
|
|
10 |
* http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.
|
|
11 |
*
|
|
12 |
* Redistribution and use in source and binary forms, with or without
|
|
13 |
* modification, are permitted provided that the following conditions
|
|
14 |
* are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in
|
|
20 |
* the documentation and/or other materials provided with the
|
|
21 |
* distribution.
|
|
22 |
* * Neither the name Texas Instruments nor the names of its
|
|
23 |
* contributors may be used to endorse or promote products derived
|
|
24 |
* from this software without specific prior written permission.
|
|
25 |
*
|
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37 |
*/
|
|
38 |
|
|
39 |
/** \file ScanSrv.c
|
|
40 |
* \brief This file include the scan SRV module implementation
|
|
41 |
*
|
|
42 |
* \see ScanSrv.h, ScanSrvSm.h, ScanSrvSm.c
|
|
43 |
*/
|
|
44 |
|
|
45 |
|
|
46 |
#define __FILE_ID__ FILE_ID_115
|
|
47 |
#include "report.h"
|
|
48 |
#include "timer.h"
|
|
49 |
#include "ScanSrv.h"
|
|
50 |
#include "ScanSrvSM.h"
|
|
51 |
#include "MacServices.h"
|
|
52 |
#include "MacServices_api.h"
|
|
53 |
#include "eventMbox_api.h"
|
|
54 |
#include "CmdBld.h"
|
|
55 |
|
|
56 |
/**
|
|
57 |
* \date 16-Oct-2004\n
|
|
58 |
* \brief Creates the scan SRV object
|
|
59 |
*
|
|
60 |
* Function Scope \e Public.\n
|
|
61 |
* \param hOS - handle to the OS object.\n
|
|
62 |
* \return a handle to the scan SRV object, NULL if an error occurred.\n
|
|
63 |
*/
|
|
64 |
TI_HANDLE MacServices_scanSRV_create( TI_HANDLE hOS )
|
|
65 |
{
|
|
66 |
/* allocate the scan SRV object */
|
|
67 |
scanSRV_t *pScanSRV = os_memoryAlloc( hOS, sizeof(scanSRV_t),MemoryNormal);
|
|
68 |
if ( NULL == pScanSRV )
|
|
69 |
{
|
|
70 |
WLAN_OS_REPORT( ("ERROR: Failed to create scan SRV module"));
|
|
71 |
return NULL;
|
|
72 |
}
|
|
73 |
|
|
74 |
/* allocate the state machine */
|
|
75 |
if ( TI_OK != fsm_Create( hOS, &(pScanSRV->SM), SCAN_SRV_NUM_OF_STATES, SCAN_SRV_NUM_OF_EVENTS ))
|
|
76 |
{
|
|
77 |
WLAN_OS_REPORT( ("ERROR: Failed to allocate scan SRV state machine"));
|
|
78 |
os_memoryFree( hOS, pScanSRV, sizeof(scanSRV_t));
|
|
79 |
return NULL;
|
|
80 |
}
|
|
81 |
|
|
82 |
/* store the OS handle */
|
|
83 |
pScanSRV->hOS = hOS;
|
|
84 |
|
|
85 |
return pScanSRV;
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
* \date 29-Dec-2004\n
|
|
90 |
* \brief Finalizes the scan SRV module (releasing memory and timer)
|
|
91 |
*
|
|
92 |
* Function Scope \e Public.\n
|
|
93 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
94 |
*/
|
|
95 |
void MacServices_scanSRV_destroy( TI_HANDLE hScanSRV )
|
|
96 |
{
|
|
97 |
scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
|
|
98 |
|
|
99 |
/* free timer */
|
|
100 |
tmr_DestroyTimer (pScanSRV->hScanSrvTimer);
|
|
101 |
|
|
102 |
/* free memory */
|
|
103 |
fsm_Unload( pScanSRV->hOS, pScanSRV->SM );
|
|
104 |
os_memoryFree( pScanSRV->hOS, (TI_HANDLE)pScanSRV , sizeof(scanSRV_t));
|
|
105 |
}
|
|
106 |
|
|
107 |
/**
|
|
108 |
* \date 29-Dec-2004\n
|
|
109 |
* \brief Initializes the scan SRV module, registers SCAN_COMPLETE to HAL.
|
|
110 |
*
|
|
111 |
* Function Scope \e Public.\n
|
|
112 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
113 |
* \param Handles of other modules.\n
|
|
114 |
*/
|
|
115 |
TI_STATUS MacServices_scanSRV_init (TI_HANDLE hMacServices,
|
|
116 |
TI_HANDLE hReport,
|
|
117 |
TI_HANDLE hTWD,
|
|
118 |
TI_HANDLE hTimer,
|
|
119 |
TI_HANDLE hEventMbox,
|
|
120 |
TI_HANDLE hCmdBld)
|
|
121 |
{
|
|
122 |
MacServices_t* pMacServices = (MacServices_t*)hMacServices;
|
|
123 |
scanSRV_t *pScanSRV = pMacServices->hScanSRV;
|
|
124 |
|
|
125 |
/* store handles */
|
|
126 |
pScanSRV->hTWD = hTWD;
|
|
127 |
pScanSRV->hTimer = hTimer;
|
|
128 |
pScanSRV->hReport = hReport;
|
|
129 |
pScanSRV->hEventMbox = hEventMbox;
|
|
130 |
pScanSRV->hPowerSrv = pMacServices->hPowerSrv;
|
|
131 |
pScanSRV->hCmdBld = hCmdBld;
|
|
132 |
pScanSRV->commandResponseFunc = NULL;
|
|
133 |
pScanSRV->commandResponseObj = NULL;
|
|
134 |
|
|
135 |
/* create the timer */
|
|
136 |
pScanSRV->hScanSrvTimer = tmr_CreateTimer (pScanSRV->hTimer);
|
|
137 |
if (pScanSRV->hScanSrvTimer == NULL)
|
|
138 |
{
|
|
139 |
TRACE0(pScanSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_scanSRV_init(): Failed to create hScanSrvTimer!\n");
|
|
140 |
return TI_NOK;
|
|
141 |
}
|
|
142 |
|
|
143 |
/* init state machine */
|
|
144 |
scanSRVSM_init ((TI_HANDLE)pScanSRV);
|
|
145 |
|
|
146 |
/* Register our scan complete handler to the HAL events mailbox */
|
|
147 |
eventMbox_RegisterEvent (pScanSRV->hEventMbox,
|
|
148 |
TWD_OWN_EVENT_SCAN_CMPLT,
|
|
149 |
(void *)MacServices_scanSRV_scanCompleteCB,
|
|
150 |
(TI_HANDLE)pScanSRV);
|
|
151 |
eventMbox_RegisterEvent (pScanSRV->hEventMbox,
|
|
152 |
TWD_OWN_EVENT_SPS_SCAN_CMPLT,
|
|
153 |
(void *)MacServices_scanSRV_scanCompleteCB,
|
|
154 |
(TI_HANDLE)pScanSRV);
|
|
155 |
|
|
156 |
/* init other stuff */
|
|
157 |
pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0;
|
|
158 |
|
|
159 |
TRACE0( hReport, REPORT_SEVERITY_INIT, ".....Scan SRV configured successfully.\n");
|
|
160 |
|
|
161 |
return TI_OK;
|
|
162 |
}
|
|
163 |
|
|
164 |
/**
|
|
165 |
* \brief Restart the scan SRV module upon recovery.
|
|
166 |
*
|
|
167 |
* Function Scope \e Public.\n
|
|
168 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
169 |
*/
|
|
170 |
void scanSRV_restart (TI_HANDLE hScanSRV)
|
|
171 |
{
|
|
172 |
scanSRV_t *pScanSRV = (scanSRV_t *)hScanSRV;
|
|
173 |
/* init state machine */
|
|
174 |
/* initialize current state */
|
|
175 |
pScanSRV->SMState = SCAN_SRV_STATE_IDLE;
|
|
176 |
|
|
177 |
if (pScanSRV->bTimerRunning)
|
|
178 |
{
|
|
179 |
tmr_StopTimer (pScanSRV->hScanSrvTimer);
|
|
180 |
pScanSRV->bTimerRunning = TI_FALSE;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
/**
|
|
185 |
* \author Ronen Kalish\n
|
|
186 |
* \date 26-July-2006\n
|
|
187 |
* \brief Configures the scan SRV module with initialization values
|
|
188 |
*
|
|
189 |
* Function Scope \e Public.\n
|
|
190 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
191 |
* \param hReport - handle to the report object.\n
|
|
192 |
* \param hTWD - handle to the HAL ctrl object.\n
|
|
193 |
*/
|
|
194 |
void MacServices_scanSrv_config( TI_HANDLE hMacServices, TScanSrvInitParams* pInitParams )
|
|
195 |
{
|
|
196 |
MacServices_t* pMacServices = (MacServices_t*)hMacServices;
|
|
197 |
scanSRV_t *pScanSRV = pMacServices->hScanSRV;
|
|
198 |
|
|
199 |
pScanSRV->numberOfNoScanCompleteToRecovery = pInitParams->numberOfNoScanCompleteToRecovery;
|
|
200 |
|
|
201 |
/* Set Triggered scan time out per channel */
|
|
202 |
pScanSRV->uTriggeredScanTimeOut = pInitParams->uTriggeredScanTimeOut;
|
|
203 |
TWD_CmdSetSplitScanTimeOut (pScanSRV->hTWD, pScanSRV->uTriggeredScanTimeOut);
|
|
204 |
}
|
|
205 |
|
|
206 |
/**
|
|
207 |
* \author Ronen Kalish\n
|
|
208 |
* \date 29-Dec-2004\n
|
|
209 |
* \brief Registers a complete callback for scan complete notifications.
|
|
210 |
*
|
|
211 |
* Function Scope \e Public.\n
|
|
212 |
* \param hMacServices - handle to the MacServices object.\n
|
|
213 |
* \param scanCompleteCB - the complete callback function.\n
|
|
214 |
* \param hScanCompleteObj - handle to the object passed to the scan complete callback function.\n
|
|
215 |
*/
|
|
216 |
void MacServices_scanSRV_registerScanCompleteCB( TI_HANDLE hMacServices,
|
|
217 |
TScanSrvCompleteCb scanCompleteCB, TI_HANDLE hScanCompleteObj )
|
|
218 |
{
|
|
219 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
220 |
|
|
221 |
pScanSRV->scanCompleteNotificationFunc = scanCompleteCB;
|
|
222 |
pScanSRV->scanCompleteNotificationObj = hScanCompleteObj;
|
|
223 |
}
|
|
224 |
|
|
225 |
/**
|
|
226 |
* \brief Registers a failure event callback for scan error notifications.
|
|
227 |
*
|
|
228 |
* Function Scope \e member.\n
|
|
229 |
* \param hScanSRV - handle to the Scan SRV object.\n
|
|
230 |
* \param failureEventCB - the failure event callback function.\n
|
|
231 |
* \param hFailureEventObj - handle to the object passed to the failure event callback function.\n
|
|
232 |
*/
|
|
233 |
void scanSRV_registerFailureEventCB( TI_HANDLE hScanSRV,
|
|
234 |
void * failureEventCB, TI_HANDLE hFailureEventObj )
|
|
235 |
{
|
|
236 |
scanSRV_t *pScanSRV = (scanSRV_t*)(hScanSRV);
|
|
237 |
|
|
238 |
pScanSRV->failureEventFunc = (TFailureEventCb)failureEventCB;
|
|
239 |
pScanSRV->failureEventObj = hFailureEventObj;
|
|
240 |
}
|
|
241 |
|
|
242 |
/**
|
|
243 |
* \date 27-Sep-2005\n
|
|
244 |
* \brief This function is the CB which is called as response to 'StartScan' or 'StopScan' \n.
|
|
245 |
* here we check if there is a GWSI command response , and call it if necessary .\n
|
|
246 |
* Function Scope \e Private.\n
|
|
247 |
* \param hScanSrv - handle to the scan SRV object.\n
|
|
248 |
* \param MboxStatus - mailbox status. \n
|
|
249 |
*/
|
|
250 |
void MacServices_scanSRVCommandMailBoxCB(TI_HANDLE hScanSrv,TI_UINT16 MboxStatus)
|
|
251 |
{
|
|
252 |
scanSRV_t* pScanSRV = (scanSRV_t*)hScanSrv;
|
|
253 |
TI_UINT16 responseStatus;
|
|
254 |
TCmdResponseCb CB_Func;
|
|
255 |
TI_HANDLE CB_Handle;
|
|
256 |
|
|
257 |
TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, " status %u\n",MboxStatus);
|
|
258 |
|
|
259 |
/* set response to TI_OK or TI_NOK */
|
|
260 |
responseStatus = ((MboxStatus > 0) ? TI_NOK : TI_OK);
|
|
261 |
|
|
262 |
/* if we have a Response Function (only in GWSI) we set it back to NULL and then
|
|
263 |
we call it */
|
|
264 |
if (pScanSRV->commandResponseFunc != NULL)
|
|
265 |
{
|
|
266 |
CB_Func = pScanSRV->commandResponseFunc;
|
|
267 |
CB_Handle = pScanSRV->commandResponseObj;
|
|
268 |
|
|
269 |
pScanSRV->commandResponseFunc = NULL;
|
|
270 |
pScanSRV->commandResponseObj = NULL;
|
|
271 |
|
|
272 |
CB_Func(CB_Handle, responseStatus);
|
|
273 |
}
|
|
274 |
/* if scan request failed */
|
|
275 |
if ( TI_OK != responseStatus )
|
|
276 |
{
|
|
277 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Mail box returned error , quitting scan.\n");
|
|
278 |
|
|
279 |
/* send a scan complete event. This will do all necessary clean-up (timer, power manager, notifying scan complete) */
|
|
280 |
scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE );
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
/**
|
|
285 |
* \author Ronen Kalish\n
|
|
286 |
* \date 29-Dec-2004\n
|
|
287 |
* \brief Performs a scan
|
|
288 |
*
|
|
289 |
* Function Scope \e Public.\n
|
|
290 |
* \param hMacServices - handle to the MacServices object.\n
|
|
291 |
* \param scanParams - the scan specific parameters.\n
|
|
292 |
* \param eScanresultTag - tag used for result and scan complete tracking
|
|
293 |
* \param bHighPriority - whether to perform a high priority (overlaps DTIM) scan.\n
|
|
294 |
* \param bDriverMode - whether to try to enter driver mode (with PS on) before issuing the scan command.\n
|
|
295 |
* \param bScanOnDriverModeError - whether to proceed with the scan if requested to enter driver mode and failed.\n
|
|
296 |
* \param psRequest - Parameter sent to PowerSaveServer on PS request to indicate PS on or "keep current"
|
|
297 |
* \param bSendNullData - whether to send Null data when exiting driver mode on scan complete.\n
|
|
298 |
* \param commandResponseFunc - CB function which called after downloading the command. \n
|
|
299 |
* \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n
|
|
300 |
* \param psRequest - Parameter sent to PowerSaveServer on PS request to indicate PS on or "keep current"
|
|
301 |
* \return TI_OK if successful (various, TBD codes if not).\n
|
|
302 |
*/
|
|
303 |
TI_STATUS MacServices_scanSRV_scan( TI_HANDLE hMacServices, TScanParams *scanParams, EScanResultTag eScanTag,
|
|
304 |
TI_BOOL bHighPriority, TI_BOOL bDriverMode, TI_BOOL bScanOnDriverModeError,
|
|
305 |
E80211PsMode psRequest, TI_BOOL bSendNullData,
|
|
306 |
TCmdResponseCb commandResponseFunc, TI_HANDLE commandResponseObj)
|
|
307 |
{
|
|
308 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
309 |
|
|
310 |
|
|
311 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Scan request received.\n");
|
|
312 |
|
|
313 |
/* sanity check - scan can only start if the scan SRV is idle */
|
|
314 |
if ( SCAN_SRV_STATE_IDLE != pScanSRV->SMState )
|
|
315 |
{
|
|
316 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_WARNING, "Scan request while scan is running!\n");
|
|
317 |
return TI_NOK;
|
|
318 |
}
|
|
319 |
|
|
320 |
/* Response function for GWSI only. In Legacy run we get NULL and never use it. */
|
|
321 |
pScanSRV->commandResponseFunc = commandResponseFunc;
|
|
322 |
pScanSRV->commandResponseObj = commandResponseObj;
|
|
323 |
|
|
324 |
pScanSRV->bInRequest = TI_TRUE;
|
|
325 |
pScanSRV->returnStatus = TI_OK;
|
|
326 |
|
|
327 |
/* copy scan paramaters */
|
|
328 |
pScanSRV->scanParams = scanParams;
|
|
329 |
pScanSRV->eScanTag = eScanTag;
|
|
330 |
pScanSRV->uResultCount = 0;
|
|
331 |
pScanSRV->bHighPriority = bHighPriority;
|
|
332 |
pScanSRV->bScanOnDriverModeFailure = bScanOnDriverModeError;
|
|
333 |
pScanSRV->bSendNullData = bSendNullData;
|
|
334 |
pScanSRV->psRequest = psRequest;
|
|
335 |
|
|
336 |
if ( SCAN_TYPE_SPS == scanParams->scanType )
|
|
337 |
{
|
|
338 |
pScanSRV->bSPSScan = TI_TRUE;
|
|
339 |
|
|
340 |
}
|
|
341 |
else
|
|
342 |
{
|
|
343 |
pScanSRV->bSPSScan = TI_FALSE;
|
|
344 |
}
|
|
345 |
|
|
346 |
|
|
347 |
/* check whether the scan will overlap DTIM frame */
|
|
348 |
if ( (TI_FALSE == bHighPriority) && (TI_TRUE == bDriverMode))
|
|
349 |
{
|
|
350 |
pScanSRV->bDtimOverlapping = TI_FALSE;
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
pScanSRV->bDtimOverlapping = TI_TRUE;
|
|
355 |
}
|
|
356 |
|
|
357 |
/* mark the no scan complete flag. The purpose of this flag is to be able to identify
|
|
358 |
whether the scan complete is a normal process, or was it generated because a no scan ocmplete
|
|
359 |
was identified, a stop scan command was snet to the FW, and thus a scan complete was received.
|
|
360 |
In the former case we nullify the consecutive no scan complete counter, whereas in the latter
|
|
361 |
we do not. */
|
|
362 |
pScanSRV->bNoScanCompleteFlag = TI_FALSE;
|
|
363 |
|
|
364 |
/* if required to enter driver mode */
|
|
365 |
if ( TI_TRUE == bDriverMode )
|
|
366 |
{
|
|
367 |
pScanSRV->bExitFromDriverMode = TI_TRUE;
|
|
368 |
/* send a PS_REQUEST event */
|
|
369 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&(pScanSRV->SMState), SCAN_SRV_EVENT_REQUEST_PS );
|
|
370 |
}
|
|
371 |
/* no driver mode required */
|
|
372 |
else
|
|
373 |
{
|
|
374 |
pScanSRV->bExitFromDriverMode = TI_FALSE;
|
|
375 |
/* send a PS_SUCCESS event - will start the scan */
|
|
376 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS );
|
|
377 |
}
|
|
378 |
|
|
379 |
pScanSRV->bInRequest = TI_FALSE;
|
|
380 |
|
|
381 |
return pScanSRV->returnStatus;
|
|
382 |
}
|
|
383 |
|
|
384 |
/**
|
|
385 |
* \author Ronen Kalish\n
|
|
386 |
* \date 29-Dec-2004\n
|
|
387 |
* \brief Sends a Stop Scan command to FW, no matter if we are in scan progress or not
|
|
388 |
*
|
|
389 |
* Function Scope \e Public.\n
|
|
390 |
* \param hMacServices - handle to the MacServices object.\n
|
|
391 |
* \param eScanTag - scan tag, used for scan complete and result tracking
|
|
392 |
* \param bSendNullData - indicates whether to send Null data when exiting driver mode.\n
|
|
393 |
* \param commandResponseFunc - CB function which called after downloading the command. \n
|
|
394 |
* \param commandResponseObj - The CB function Obj (Notice : last 2 params are NULL in Legacy run). \n
|
|
395 |
* \return TI_OK if successful (various, TBD codes if not).\n
|
|
396 |
*/
|
|
397 |
TI_STATUS MacServices_scanSRV_stopScan( TI_HANDLE hMacServices, EScanResultTag eScanTag, TI_BOOL bSendNullData,
|
|
398 |
TCmdResponseCb ScanCommandResponseCB, TI_HANDLE CB_handle )
|
|
399 |
{
|
|
400 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
401 |
TI_INT32 stopScanStatus;
|
|
402 |
|
|
403 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Stop scan request received.\n");
|
|
404 |
|
|
405 |
/* update the driver mode exit flag */
|
|
406 |
pScanSRV->bSendNullData = bSendNullData;
|
|
407 |
|
|
408 |
if ( TI_TRUE == pScanSRV->bSPSScan )
|
|
409 |
{
|
|
410 |
stopScanStatus = cmdBld_CmdStopSPSScan (pScanSRV->hCmdBld, eScanTag, (void *)ScanCommandResponseCB, CB_handle);
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
stopScanStatus = cmdBld_CmdStopScan (pScanSRV->hCmdBld, eScanTag, (void *)ScanCommandResponseCB, CB_handle);
|
|
415 |
}
|
|
416 |
|
|
417 |
if (TI_OK != stopScanStatus)
|
|
418 |
{
|
|
419 |
return TI_NOK;
|
|
420 |
}
|
|
421 |
|
|
422 |
/* send a stop scan event */
|
|
423 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_STOP_SCAN );
|
|
424 |
|
|
425 |
return pScanSRV->returnStatus;
|
|
426 |
}
|
|
427 |
|
|
428 |
/**
|
|
429 |
* \author Ronen Kalish\n
|
|
430 |
* \date 17-Jan-2005\n
|
|
431 |
* \brief Notifies the scan SRV of a FW reset (that had originally been reported by a different module).\n
|
|
432 |
*
|
|
433 |
* Function Scope \e Public.\n
|
|
434 |
* \param hMacServices - handle to the MacServices object.\n
|
|
435 |
* \return TI_OK if successful (various, TBD codes if not).\n
|
|
436 |
*/
|
|
437 |
TI_STATUS MacServices_scanSRV_stopOnFWReset( TI_HANDLE hMacServices )
|
|
438 |
{
|
|
439 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
440 |
|
|
441 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "FW reset notification received.\n");
|
|
442 |
|
|
443 |
/* mark the return status */
|
|
444 |
pScanSRV->returnStatus = TI_NOK;
|
|
445 |
|
|
446 |
/* send a FW reset event */
|
|
447 |
return scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_FW_RESET );
|
|
448 |
}
|
|
449 |
|
|
450 |
/**
|
|
451 |
* \author Ronen Kalish\n
|
|
452 |
* \date 29-Dec-2004\n
|
|
453 |
* \brief callback function used by the power server to notify driver mode result
|
|
454 |
* this CB is used in requesting PS and exiting PS.
|
|
455 |
* Function Scope \e Public.\n
|
|
456 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
457 |
* \param psStatus - the power save request status.\n
|
|
458 |
*/
|
|
459 |
void MacServices_scanSRV_powerSaveCB( TI_HANDLE hScanSRV, TI_UINT8 PSMode,TI_UINT8 psStatus )
|
|
460 |
{
|
|
461 |
scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
|
|
462 |
|
|
463 |
TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS Call Back status %d .\n",psStatus);
|
|
464 |
|
|
465 |
/* if driver mode enter/exit succeedded */
|
|
466 |
if ( (ENTER_POWER_SAVE_SUCCESS == psStatus) || (EXIT_POWER_SAVE_SUCCESS == psStatus))
|
|
467 |
{
|
|
468 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS successful.\n");
|
|
469 |
|
|
470 |
/* send a PS_SUCCESS event */
|
|
471 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS );
|
|
472 |
}
|
|
473 |
/* driver mode entry failed, and scan is requested even on PS failure but we are entering PS and not Exiting */
|
|
474 |
else if ( (TI_TRUE == pScanSRV->bScanOnDriverModeFailure) && ( ENTER_POWER_SAVE_FAIL == psStatus))
|
|
475 |
{
|
|
476 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "PS enter failed, continune scan .\n");
|
|
477 |
|
|
478 |
/* send a PS_SUCCESS event */
|
|
479 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS );
|
|
480 |
}
|
|
481 |
/* driver mode enter or exit failed */
|
|
482 |
else
|
|
483 |
{
|
|
484 |
/* if we are trying to enter PS and fail to do so - return error on scan complete */
|
|
485 |
if ( ENTER_POWER_SAVE_FAIL == psStatus)
|
|
486 |
{
|
|
487 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_WARNING, "PS enter failed . quiting scan .\n");
|
|
488 |
/* Set the return status */
|
|
489 |
pScanSRV->returnStatus = TI_NOK;
|
|
490 |
}
|
|
491 |
|
|
492 |
/* send a PS FAIL event */
|
|
493 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL );
|
|
494 |
}
|
|
495 |
}
|
|
496 |
|
|
497 |
|
|
498 |
/**
|
|
499 |
* \author Ronen Kalish\n
|
|
500 |
* \date 29-Dec-2004\n
|
|
501 |
* \brief Callback function used by the HAL ctrl to notify scan complete
|
|
502 |
*
|
|
503 |
* Function Scope \e Public.\n
|
|
504 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
505 |
* \param str - pointer to scan result buffer (holding SPS status for SPS scan only!).\n
|
|
506 |
* \param strLen - scan result buffer length (should ALWAYS be 2, even for non SPS scans).\n
|
|
507 |
*/
|
|
508 |
void MacServices_scanSRV_scanCompleteCB( TI_HANDLE hScanSRV, char* str, TI_UINT32 strLen )
|
|
509 |
{
|
|
510 |
scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
|
|
511 |
scanCompleteResults_t *pResult = (scanCompleteResults_t*)str;
|
|
512 |
|
|
513 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Scan complete notification from TNET.\n");
|
|
514 |
|
|
515 |
/* nullify the consecutive no scan complete events counter - only if this is a scan complete that
|
|
516 |
does not happen afetr a stop scan (due to a timer expiry) */
|
|
517 |
if ( TI_FALSE == pScanSRV->bNoScanCompleteFlag )
|
|
518 |
{
|
|
519 |
pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0;
|
|
520 |
}
|
|
521 |
|
|
522 |
/* copy result counter and scan tag */
|
|
523 |
pScanSRV->uResultCount = pResult->numberOfScanResults;
|
|
524 |
pScanSRV->eScanTag = (EScanResultTag)pResult->scanTag;
|
|
525 |
|
|
526 |
/* copy scan SPS addmitted channels and SPS result */
|
|
527 |
if (TI_FALSE == pScanSRV->bSPSScan)
|
|
528 |
{
|
|
529 |
/* normal scan - no result is available */
|
|
530 |
pScanSRV->bTSFError = TI_FALSE;
|
|
531 |
TRACE0( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "Normal scan completed.\n");
|
|
532 |
}
|
|
533 |
else
|
|
534 |
{
|
|
535 |
/* SPS scan - first byte indicates whether a TSF error (AP recovery) occured */
|
|
536 |
if ( 0 != (pResult->scheduledScanStatus >> 24))
|
|
537 |
{
|
|
538 |
pScanSRV->bTSFError = TI_TRUE;
|
|
539 |
}
|
|
540 |
else
|
|
541 |
{
|
|
542 |
pScanSRV->bTSFError = TI_FALSE;
|
|
543 |
}
|
|
544 |
|
|
545 |
/* next two bytes indicates on which channels scan was attempted */
|
|
546 |
pScanSRV->SPSScanResult = (TI_UINT16)(pResult->scheduledScanStatus >> 16) | 0xff;
|
|
547 |
pScanSRV->SPSScanResult = ENDIAN_HANDLE_WORD( pScanSRV->SPSScanResult );
|
|
548 |
TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "SPS scan completed. TSF error: , SPS result: %x\n", pScanSRV->SPSScanResult);
|
|
549 |
}
|
|
550 |
|
|
551 |
/* send a SCAN_COMPLETE event */
|
|
552 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE );
|
|
553 |
}
|
|
554 |
|
|
555 |
/**
|
|
556 |
* \author Ronen Kalish\n
|
|
557 |
* \date 29-Dec-2004\n
|
|
558 |
* \brief called when a scan timer expires. Completes the scan and starts a recovery process.
|
|
559 |
*
|
|
560 |
* Function Scope \e Public.\n
|
|
561 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
562 |
* \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n
|
|
563 |
*/
|
|
564 |
void MacServices_scanSRV_scanTimerExpired (TI_HANDLE hScanSRV, TI_BOOL bTwdInitOccured)
|
|
565 |
{
|
|
566 |
scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
|
|
567 |
|
|
568 |
/* mark that no scan complete occured (see sanSRV_scan for more detailed explanation) */
|
|
569 |
pScanSRV->bNoScanCompleteFlag = TI_TRUE;
|
|
570 |
|
|
571 |
/* send a TIMER_EXPIRED event */
|
|
572 |
scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_TIMER_EXPIRED );
|
|
573 |
}
|
|
574 |
|
|
575 |
/**
|
|
576 |
* \author Ronen Kalish\n
|
|
577 |
* \date 29-Dec-2004\n
|
|
578 |
* \brief Calculates the maximal time required for a scan operation
|
|
579 |
*
|
|
580 |
* Function Scope \e Public.\n
|
|
581 |
* \param hScanSRV - handle to the scan SRV object.\n
|
|
582 |
* \param scanParams - the scan parameters
|
|
583 |
* \param bConsiderDTIM - whether this scan overlaps DTIM
|
|
584 |
* \return the time (in milliseconds)
|
|
585 |
*/
|
|
586 |
TI_UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSRV, TScanParams* scanParams, TI_BOOL bConsiderDTIM )
|
|
587 |
{
|
|
588 |
TI_UINT32 i, uDtimPeriodMs, uBeaconIntervalMs, timeout = 0;
|
|
589 |
scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
|
|
590 |
|
|
591 |
/********************************************************************************
|
|
592 |
timeout calculation is performed according to scan type:
|
|
593 |
1. for normal scan, multiply the channel time by the number of channels.
|
|
594 |
if this scan is not overlapping DTIM, add the DTIM period (in case
|
|
595 |
starting the scan right now will cause the very last milliseconds of the
|
|
596 |
scan to overlap the next DTIM). Add the guard time.
|
|
597 |
2. for triggered scan, multiply the channel time plus the trigger time
|
|
598 |
constant (the maximum time between two frames from the Tid
|
|
599 |
according to which the scan is triggered) by the number of channels.
|
|
600 |
DTIM period is added only as precaution - since the scan is divided to
|
|
601 |
channels, only very few of them will be delayed due to DTIM (in the worst
|
|
602 |
case), and this delay would be only the length of one channel scan.
|
|
603 |
Eventually, Add the guard time.
|
|
604 |
3. for SPS scan: Measure the time from current TSF to the TSF at which the
|
|
605 |
scan is scheduled to finish (done by the scan manager, and passed as
|
|
606 |
a parameter in the scan structure). Add guard time. DTIM overlapping is not
|
|
607 |
considered because if the scan overlaps DTIM the channels which are
|
|
608 |
scheduled during the DTIM (if any) won't be scanned.
|
|
609 |
********************************************************************************/
|
|
610 |
|
|
611 |
/* get DTIM time, if scanning in connected mode and need to consider DTIM */
|
|
612 |
if ( bConsiderDTIM )
|
|
613 |
{
|
|
614 |
/* new dtimPeriod calculation */
|
|
615 |
uBeaconIntervalMs = MacServices_scanSRVConvertTUToMsec (pScanSRV->uBeaconInterval);
|
|
616 |
uDtimPeriodMs = uBeaconIntervalMs * pScanSRV->uDtimPeriod;
|
|
617 |
}
|
|
618 |
else
|
|
619 |
{
|
|
620 |
uDtimPeriodMs = 0;
|
|
621 |
}
|
|
622 |
|
|
623 |
switch (scanParams->scanType)
|
|
624 |
{
|
|
625 |
case SCAN_TYPE_NORMAL_ACTIVE:
|
|
626 |
case SCAN_TYPE_NORMAL_PASSIVE:
|
|
627 |
/* the timeout is the scan duration on all channels */
|
|
628 |
for ( i = 0; i < scanParams->numOfChannels; i++ )
|
|
629 |
{
|
|
630 |
timeout += scanParams->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime;
|
|
631 |
}
|
|
632 |
timeout = (timeout / 1000) + uDtimPeriodMs + SCAN_SRV_FW_GUARD_TIME_MS;
|
|
633 |
break;
|
|
634 |
|
|
635 |
case SCAN_TYPE_TRIGGERED_ACTIVE:
|
|
636 |
case SCAN_TYPE_TRIGGERED_PASSIVE:
|
|
637 |
/* the timeout is the scan duration on all channels, plus the maximum time that can pass
|
|
638 |
between two different frames from the same Tid */
|
|
639 |
for ( i = 0; i < scanParams->numOfChannels; i++ )
|
|
640 |
{
|
|
641 |
timeout += scanParams->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime;
|
|
642 |
}
|
|
643 |
timeout = (timeout / 1000) + uDtimPeriodMs +
|
|
644 |
((pScanSRV->uTriggeredScanTimeOut / 1000 + 1) * scanParams->numOfChannels) +
|
|
645 |
SCAN_SRV_FW_GUARD_TIME_MS;
|
|
646 |
break;
|
|
647 |
|
|
648 |
case SCAN_TYPE_SPS:
|
|
649 |
timeout = scanParams->SPSScanDuration + SCAN_SRV_FW_GUARD_TIME_MS;
|
|
650 |
break;
|
|
651 |
|
|
652 |
default:
|
|
653 |
TRACE1( pScanSRV->hReport, REPORT_SEVERITY_ERROR, "Trying to calculate timeout for undefined scan type %d\n", scanParams->scanType);
|
|
654 |
break;
|
|
655 |
}
|
|
656 |
TRACE1( pScanSRV->hReport, REPORT_SEVERITY_INFORMATION, "scanSRVcalculateScanTimeout, timeout = %d\n", timeout);
|
|
657 |
|
|
658 |
return timeout;
|
|
659 |
}
|
|
660 |
|
|
661 |
/**
|
|
662 |
* \author Ronen Kalish\n
|
|
663 |
* \date 16-Jan-2005\n
|
|
664 |
* \brief Convert time units (1024 usecs) to millisecs
|
|
665 |
*
|
|
666 |
* Function Scope \e Private.\n
|
|
667 |
* \param tu - the time in time units
|
|
668 |
* \return the time in milliseconds
|
|
669 |
*/
|
|
670 |
TI_UINT32 MacServices_scanSRVConvertTUToMsec( TI_UINT32 tu )
|
|
671 |
{
|
|
672 |
return (tu * 1024) / 1000;
|
|
673 |
}
|
|
674 |
|
|
675 |
|
|
676 |
/**
|
|
677 |
* \author Arik Klein\n
|
|
678 |
* \brief Save DTIM and Beacon periods for scan timeout calculations
|
|
679 |
*
|
|
680 |
* Function Scope \e Public.\n
|
|
681 |
* \param hMacServices - module object
|
|
682 |
* \param uDtimPeriod - DTIM period in number of beacons
|
|
683 |
* \param uBeaconInterval - Beacon perios in TUs (1024 msec)
|
|
684 |
* \return void
|
|
685 |
*/
|
|
686 |
void MacServices_scanSrv_UpdateDtimTbtt (TI_HANDLE hMacServices,
|
|
687 |
TI_UINT8 uDtimPeriod,
|
|
688 |
TI_UINT16 uBeaconInterval)
|
|
689 |
{
|
|
690 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
691 |
|
|
692 |
pScanSRV->uDtimPeriod = uDtimPeriod;
|
|
693 |
pScanSRV->uBeaconInterval = uBeaconInterval;
|
|
694 |
}
|
|
695 |
|
|
696 |
|
|
697 |
#ifdef TI_DBG
|
|
698 |
/**
|
|
699 |
* \author Shirit Brook\n
|
|
700 |
* \date God knows when...\n
|
|
701 |
* \brief Prints Scan Server SM status.\n
|
|
702 |
*
|
|
703 |
* Function Scope \e Public.\n
|
|
704 |
* \param hMacServices - handle to the Mac Services object.\n
|
|
705 |
* \return always TI_OK.\n
|
|
706 |
*/
|
|
707 |
void MacServices_scanSrv_printDebugStatus(TI_HANDLE hMacServices)
|
|
708 |
{
|
|
709 |
scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
|
|
710 |
|
|
711 |
WLAN_OS_REPORT(("scanSrv State="));
|
|
712 |
switch (pScanSRV->SMState)
|
|
713 |
{
|
|
714 |
case SCAN_SRV_STATE_IDLE:
|
|
715 |
WLAN_OS_REPORT((" IDLE\n"));
|
|
716 |
break;
|
|
717 |
case SCAN_SRV_STATE_PS_WAIT:
|
|
718 |
WLAN_OS_REPORT((" PS_WAIT\n"));
|
|
719 |
break;
|
|
720 |
case SCAN_SRV_STATE_PS_EXIT:
|
|
721 |
WLAN_OS_REPORT((" PS_EXIT\n"));
|
|
722 |
break;
|
|
723 |
case SCAN_SRV_STATE_SCANNING:
|
|
724 |
WLAN_OS_REPORT((" SCANNING\n"));
|
|
725 |
break;
|
|
726 |
case SCAN_SRV_STATE_STOPPING:
|
|
727 |
WLAN_OS_REPORT((" STOPPING\n"));
|
|
728 |
break;
|
|
729 |
default:
|
|
730 |
WLAN_OS_REPORT((" Invalid State=%d\n",pScanSRV->SMState));
|
|
731 |
break;
|
|
732 |
|
|
733 |
}
|
|
734 |
|
|
735 |
if (NULL != pScanSRV->scanParams)
|
|
736 |
{
|
|
737 |
WLAN_OS_REPORT(("scanSrv bExitFromDriverMode=%d, bHighPriority=%d, bInRequest=%d,\n \
|
|
738 |
bScanOnDriverModeFailure=%d, bSendNullData=%d, bSPSScan=%d, bTimerRunning=%d, \n \
|
|
739 |
psRequest=%d, scanType=%d\n",
|
|
740 |
pScanSRV->bExitFromDriverMode,
|
|
741 |
pScanSRV->bHighPriority,
|
|
742 |
pScanSRV->bInRequest,
|
|
743 |
pScanSRV->bScanOnDriverModeFailure,
|
|
744 |
pScanSRV->bSendNullData,
|
|
745 |
pScanSRV->bSPSScan,
|
|
746 |
pScanSRV->bTimerRunning,
|
|
747 |
pScanSRV->psRequest,
|
|
748 |
pScanSRV->scanParams->scanType));
|
|
749 |
}
|
|
750 |
}
|
|
751 |
#endif
|
|
752 |
|