|
1 /* |
|
2 * MeasurementSrv.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 measurementSrv.c |
|
40 * \brief This file include the measurement SRV interface functions implementation. |
|
41 * \author Ronen Kalish |
|
42 * \date 09-November-2005 |
|
43 */ |
|
44 |
|
45 #define __FILE_ID__ FILE_ID_110 |
|
46 #include "tidef.h" |
|
47 #include "MeasurementSrv.h" |
|
48 #include "MeasurementSrvSM.h" |
|
49 #include "report.h" |
|
50 #include "timer.h" |
|
51 #include "osApi.h" |
|
52 #include "MacServices.h" |
|
53 #include "measurementSrvDbgPrint.h" |
|
54 #include "eventMbox_api.h" |
|
55 #include "CmdBld.h" |
|
56 |
|
57 /** |
|
58 * \author Ronen Kalish\n |
|
59 * \date 08-November-2005\n |
|
60 * \brief Creates the measurement SRV object |
|
61 * |
|
62 * Function Scope \e Public.\n |
|
63 * \param hOS - handle to the OS object.\n |
|
64 * \return a handle to the measurement SRV object, NULL if an error occurred.\n |
|
65 */ |
|
66 TI_HANDLE MacServices_measurementSRV_create( TI_HANDLE hOS ) |
|
67 { |
|
68 measurementSRV_t* pMeasurementSRV; |
|
69 |
|
70 /* allocate the measurement SRV object */ |
|
71 pMeasurementSRV = os_memoryAlloc( hOS, sizeof(measurementSRV_t),MemoryNormal); |
|
72 if ( NULL == pMeasurementSRV ) |
|
73 { |
|
74 WLAN_OS_REPORT( ("ERROR: Failed to create measurement SRV object.")); |
|
75 return NULL; |
|
76 } |
|
77 |
|
78 /* nullify the object */ |
|
79 os_memoryZero( hOS, pMeasurementSRV, sizeof(measurementSRV_t)); |
|
80 |
|
81 /* store OS handle */ |
|
82 pMeasurementSRV->hOS = hOS; |
|
83 |
|
84 /* allocate the SM */ |
|
85 if ( TI_OK != fsm_Create( hOS, &(pMeasurementSRV->SM), MSR_SRV_NUM_OF_STATES, MSR_SRV_NUM_OF_EVENTS )) |
|
86 { |
|
87 pMeasurementSRV->SM = NULL; |
|
88 WLAN_OS_REPORT(("Failed to create measurement SRV state machine.\n")); |
|
89 MacServices_measurementSRV_destroy( pMeasurementSRV ); |
|
90 return NULL; |
|
91 } |
|
92 |
|
93 return (TI_HANDLE)pMeasurementSRV; |
|
94 } |
|
95 |
|
96 /** |
|
97 * \author Ronen Kalish\n |
|
98 * \date 08-November-2005\n |
|
99 * \brief Initializes the measurement SRV object |
|
100 * |
|
101 * Function Scope \e Public.\n |
|
102 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
103 * \param hReport - handle to the report object.\n |
|
104 * \param hCmdBld - handle to the Command Builder object.\n |
|
105 * \param hPowerSaveSRV - handle to the power save SRV object.\n |
|
106 */ |
|
107 TI_STATUS MacServices_measurementSRV_init (TI_HANDLE hMeasurementSRV, |
|
108 TI_HANDLE hReport, |
|
109 TI_HANDLE hCmdBld, |
|
110 TI_HANDLE hEventMbox, |
|
111 TI_HANDLE hPowerSaveSRV, |
|
112 TI_HANDLE hTimer) |
|
113 { |
|
114 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
115 TI_INT32 i; |
|
116 |
|
117 /* store handles */ |
|
118 pMeasurementSRV->hReport = hReport; |
|
119 pMeasurementSRV->hCmdBld = hCmdBld; |
|
120 pMeasurementSRV->hEventMbox = hEventMbox; |
|
121 pMeasurementSRV->hPowerSaveSRV = hPowerSaveSRV; |
|
122 pMeasurementSRV->hTimer = hTimer; |
|
123 |
|
124 /* Initialize the state machine */ |
|
125 measurementSRVSM_init (hMeasurementSRV); |
|
126 |
|
127 /* allocate the module timers */ |
|
128 pMeasurementSRV->hStartStopTimer = tmr_CreateTimer (pMeasurementSRV->hTimer); |
|
129 if (pMeasurementSRV->hStartStopTimer == NULL) |
|
130 { |
|
131 TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_measurementSRV_init(): Failed to create hStartStopTimer!\n"); |
|
132 return TI_NOK; |
|
133 } |
|
134 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
135 |
|
136 for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) |
|
137 { |
|
138 pMeasurementSRV->hRequestTimer[i] = tmr_CreateTimer (pMeasurementSRV->hTimer); |
|
139 if (pMeasurementSRV->hRequestTimer[i] == NULL) |
|
140 { |
|
141 TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, "MacServices_measurementSRV_init(): Failed to create hRequestTimer!\n"); |
|
142 return TI_NOK; |
|
143 } |
|
144 pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; |
|
145 } |
|
146 |
|
147 /* register HAL callbacks */ |
|
148 /* Register and Enable the Measure Start event in HAL */ |
|
149 |
|
150 |
|
151 eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, |
|
152 TWD_OWN_EVENT_MEASUREMENT_START, |
|
153 (void *)MacServices_measurementSRV_measureStartCB, |
|
154 hMeasurementSRV); |
|
155 eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_MEASUREMENT_START, NULL, NULL); |
|
156 |
|
157 /* Register and Enable the Measurement Complete event in HAL. |
|
158 This event will be received when the Measurement duration expired, |
|
159 or after Stop Measure command. */ |
|
160 |
|
161 eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, |
|
162 TWD_OWN_EVENT_MEASUREMENT_COMPLETE, |
|
163 (void *)MacServices_measurementSRV_measureCompleteCB, |
|
164 hMeasurementSRV); |
|
165 eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_MEASUREMENT_COMPLETE, NULL, NULL); |
|
166 |
|
167 /* Register and Enable the AP Discovery Complete event in HAL */ |
|
168 eventMbox_RegisterEvent (pMeasurementSRV->hEventMbox, |
|
169 TWD_OWN_EVENT_AP_DISCOVERY_COMPLETE, |
|
170 (void *)MacServices_measurementSRV_apDiscoveryCompleteCB, |
|
171 hMeasurementSRV); |
|
172 eventMbox_UnMaskEvent (pMeasurementSRV->hEventMbox, TWD_OWN_EVENT_AP_DISCOVERY_COMPLETE, NULL, NULL); |
|
173 |
|
174 TRACE0(hReport, REPORT_SEVERITY_INIT , ".....Measurement SRV configured successfully.\n"); |
|
175 |
|
176 return TI_OK; |
|
177 } |
|
178 |
|
179 /** |
|
180 * \brief Restart the measurement SRV object upon recovery. |
|
181 * |
|
182 * Function Scope \e Public.\n |
|
183 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
184 */ |
|
185 void measurementSRV_restart( TI_HANDLE hMeasurementSRV) |
|
186 { |
|
187 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
188 TI_INT32 i; |
|
189 |
|
190 /* if a timer is running, stop it */ |
|
191 if (pMeasurementSRV->bStartStopTimerRunning) |
|
192 { |
|
193 tmr_StopTimer (pMeasurementSRV->hStartStopTimer); |
|
194 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
195 } |
|
196 for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) |
|
197 { |
|
198 if (pMeasurementSRV->bRequestTimerRunning[i]) |
|
199 { |
|
200 tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); |
|
201 pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; |
|
202 } |
|
203 } |
|
204 |
|
205 |
|
206 /* Initialize the state machine */ |
|
207 /* initialize current state */ |
|
208 pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; |
|
209 |
|
210 /* mark that all timers are not running */ |
|
211 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
212 for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) |
|
213 { |
|
214 pMeasurementSRV->bRequestTimerRunning[ i ] = TI_FALSE; |
|
215 } |
|
216 |
|
217 } |
|
218 |
|
219 /** |
|
220 * \author Ronen Kalish\n |
|
221 * \date 08-November-2005\n |
|
222 * \brief Destroys the measurement SRV object |
|
223 * |
|
224 * Function Scope \e Public.\n |
|
225 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
226 */ |
|
227 void MacServices_measurementSRV_destroy( TI_HANDLE hMeasurementSRV ) |
|
228 { |
|
229 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
230 TI_INT32 i; |
|
231 |
|
232 /* sanity cehcking */ |
|
233 if ( NULL == hMeasurementSRV ) |
|
234 { |
|
235 return; |
|
236 } |
|
237 |
|
238 /* release state machine */ |
|
239 if ( NULL != pMeasurementSRV->SM ) |
|
240 { |
|
241 fsm_Unload( pMeasurementSRV->hOS, pMeasurementSRV->SM ); |
|
242 } |
|
243 |
|
244 /* release timers */ |
|
245 for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) |
|
246 { |
|
247 if (pMeasurementSRV->hRequestTimer[i]) |
|
248 { |
|
249 tmr_DestroyTimer (pMeasurementSRV->hRequestTimer[i]); |
|
250 } |
|
251 } |
|
252 if (pMeasurementSRV->hStartStopTimer) |
|
253 { |
|
254 tmr_DestroyTimer (pMeasurementSRV->hStartStopTimer); |
|
255 } |
|
256 |
|
257 /* release object space */ |
|
258 os_memoryFree( pMeasurementSRV->hOS, (TI_HANDLE)pMeasurementSRV, sizeof(measurementSRV_t)); |
|
259 } |
|
260 |
|
261 /** |
|
262 * \author Ronen Kalish\n |
|
263 * \date 09-November-2005\n |
|
264 * \brief Starts a measurement operation.\n |
|
265 * |
|
266 * Function Scope \e Public.\n |
|
267 * \param hMacServices - handle to the MacServices object.\n |
|
268 * \param pMsrRequest - a structure containing measurement parameters.\n |
|
269 * \param timeToRequestexpiryMs - the time (in milliseconds) the measurement SRV has to start the request.\n |
|
270 * \param cmdResponseCBFunc - callback function to used for command response.\n |
|
271 * \param cmdResponseCBObj - handle to pass to command response CB.\n |
|
272 * \param cmdCompleteCBFunc - callback function to be used for command complete.\n |
|
273 * \param cmdCompleteCBObj - handle to pass to command complete CB.\n |
|
274 * \return TI_OK if successful (various, TBD codes if not).\n |
|
275 */ |
|
276 TI_STATUS MacServices_measurementSRV_startMeasurement( TI_HANDLE hMacServices, |
|
277 TMeasurementRequest* pMsrRequest, |
|
278 TI_UINT32 timeToRequestExpiryMs, |
|
279 TCmdResponseCb cmdResponseCBFunc, |
|
280 TI_HANDLE cmdResponseCBObj, |
|
281 TMeasurementSrvCompleteCb cmdCompleteCBFunc, |
|
282 TI_HANDLE cmdCompleteCBObj ) |
|
283 { |
|
284 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; |
|
285 TI_INT32 i; |
|
286 |
|
287 #ifdef TI_DBG |
|
288 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received measurement request.\n"); |
|
289 measurementSRVPrintRequest( (TI_HANDLE)pMeasurementSRV, pMsrRequest ); |
|
290 TRACE3( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "time to expiry: %d ms, cmd response CB: 0x%x, cmd response handle: 0x%x\n", timeToRequestExpiryMs, cmdResponseCBFunc, cmdResponseCBObj); |
|
291 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "cmd complete CB: 0x%x, cmd complete handle: 0x%x\n", cmdCompleteCBFunc, cmdCompleteCBObj); |
|
292 #endif |
|
293 |
|
294 /* mark that request is in progress */ |
|
295 pMeasurementSRV->bInRequest = TI_TRUE; |
|
296 |
|
297 /* mark to send NULL data when exiting driver mode (can be changed to TI_FALSE |
|
298 only when explictly stopping the measurement */ |
|
299 pMeasurementSRV->bSendNullDataWhenExitPs = TI_TRUE; |
|
300 |
|
301 /* Nullify return status */ |
|
302 pMeasurementSRV->returnStatus = TI_OK; |
|
303 |
|
304 /* copy request parameters */ |
|
305 os_memoryCopy (pMeasurementSRV->hOS, |
|
306 (void *)&pMeasurementSRV->msrRequest, |
|
307 (void *)pMsrRequest, |
|
308 sizeof(TMeasurementRequest)); |
|
309 |
|
310 /* Mark the current time stamp and the duration to start to cehck expiry later */ |
|
311 pMeasurementSRV->requestRecptionTimeStampMs = os_timeStampMs( pMeasurementSRV->hOS ); |
|
312 pMeasurementSRV->timeToRequestExpiryMs = timeToRequestExpiryMs; |
|
313 |
|
314 /* copy callbacks */ |
|
315 pMeasurementSRV->commandResponseCBFunc = cmdResponseCBFunc; |
|
316 pMeasurementSRV->commandResponseCBObj = cmdResponseCBObj; |
|
317 pMeasurementSRV->measurmentCompleteCBFunc = cmdCompleteCBFunc; |
|
318 pMeasurementSRV->measurementCompleteCBObj = cmdCompleteCBObj; |
|
319 |
|
320 /* initialize reply */ |
|
321 pMeasurementSRV->msrReply.numberOfTypes = pMsrRequest->numberOfTypes; |
|
322 for ( i = 0; i < pMsrRequest->numberOfTypes; i++ ) |
|
323 { |
|
324 pMeasurementSRV->msrReply.msrTypes[ i ].msrType = pMeasurementSRV->msrRequest.msrTypes[ i ].msrType; |
|
325 pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_OK; |
|
326 } |
|
327 |
|
328 /* nullify the pending CBs bitmap */ |
|
329 pMeasurementSRV->pendingParamCBs = 0; |
|
330 |
|
331 /* send a start measurement event to the SM */ |
|
332 measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), |
|
333 MSR_SRV_EVENT_MEASURE_START_REQUEST ); |
|
334 |
|
335 /* mark that request has been sent */ |
|
336 pMeasurementSRV->bInRequest = TI_FALSE; |
|
337 |
|
338 return pMeasurementSRV->returnStatus; |
|
339 } |
|
340 |
|
341 /** |
|
342 * \author Ronen Kalish\n |
|
343 * \date 09-November-2005\n |
|
344 * \brief Stops a measurement operation in progress.\n |
|
345 * |
|
346 * Function Scope \e Public.\n |
|
347 * \param hMacServices - handle to the MacServices object.\n |
|
348 * \param bSendNullData - whether to send NULL data when exiting driver mode.\n |
|
349 * \param cmdResponseCBFunc - callback function to used for command response.\n |
|
350 * \param cmdResponseCBObj - handle to pass to command response CB.\n |
|
351 * \return TI_OK if successful (various, TBD codes if not).\n |
|
352 */ |
|
353 TI_STATUS MacServices_measurementSRV_stopMeasurement( TI_HANDLE hMacServices, |
|
354 TI_BOOL bSendNullData, |
|
355 TCmdResponseCb cmdResponseCBFunc, |
|
356 TI_HANDLE cmdResponseCBObj ) |
|
357 { |
|
358 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; |
|
359 |
|
360 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received measurement stop request.\n"); |
|
361 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "Send null data:, cmd response CB: 0x%x, cmd response handle: 0x%x\n", cmdResponseCBFunc, cmdResponseCBObj); |
|
362 |
|
363 /* store callbacks */ |
|
364 pMeasurementSRV->commandResponseCBFunc = cmdResponseCBFunc; |
|
365 pMeasurementSRV->commandResponseCBObj = cmdResponseCBObj; |
|
366 |
|
367 /* store NULL data indication */ |
|
368 pMeasurementSRV->bSendNullDataWhenExitPs = bSendNullData; |
|
369 |
|
370 /* mark that current return status is TI_OK */ |
|
371 pMeasurementSRV->returnStatus = TI_OK; |
|
372 |
|
373 /* mark that a stop request is in progress */ |
|
374 pMeasurementSRV->bInRequest = TI_TRUE; |
|
375 |
|
376 /* send a stop event to the SM */ |
|
377 measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), |
|
378 MSR_SRV_EVENT_MEASURE_STOP_REQUEST ); |
|
379 |
|
380 /*mark that stop request has completed */ |
|
381 pMeasurementSRV->bInRequest = TI_FALSE; |
|
382 |
|
383 return pMeasurementSRV->returnStatus; |
|
384 } |
|
385 |
|
386 /** |
|
387 * \author Ronen Kalish\n |
|
388 * \date 09-November-2005\n |
|
389 * \brief Notifies the measurement SRV of a FW reset (recovery).\n |
|
390 * |
|
391 * Function Scope \e Public.\n |
|
392 * \param hMacServices - handle to the MacServices object.\n |
|
393 */ |
|
394 void MacServices_measurementSRV_FWReset( TI_HANDLE hMacServices ) |
|
395 { |
|
396 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV; |
|
397 TI_INT32 i; |
|
398 |
|
399 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Received FW reset indication.\n"); |
|
400 |
|
401 /* if a timer is running, stop it */ |
|
402 if (pMeasurementSRV->bStartStopTimerRunning) |
|
403 { |
|
404 tmr_StopTimer (pMeasurementSRV->hStartStopTimer); |
|
405 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
406 } |
|
407 for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) |
|
408 { |
|
409 if (pMeasurementSRV->bRequestTimerRunning[i]) |
|
410 { |
|
411 tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); |
|
412 pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; |
|
413 } |
|
414 } |
|
415 |
|
416 /* change SM state to idle */ |
|
417 pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; |
|
418 } |
|
419 |
|
420 /** |
|
421 * \author Ronen Kalish\n |
|
422 * \date 09-November-2005\n |
|
423 * \brief callback function used by the power manager to notify driver mode result |
|
424 * |
|
425 * Function Scope \e Public.\n |
|
426 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
427 * \param PSMode - the power save mode the STA is currently in.\n |
|
428 * \param psStatus - the power save request status.\n |
|
429 */ |
|
430 void MacServices_measurementSRV_powerSaveCB( TI_HANDLE hMeasurementSRV, TI_UINT8 PSMode, TI_UINT8 psStatus ) |
|
431 { |
|
432 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
433 |
|
434 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Power save SRV CB called. PS mode:%d status: %d\n", PSMode, psStatus); |
|
435 |
|
436 /* if driver mode entry succeedded */ |
|
437 if ( ENTER_POWER_SAVE_SUCCESS == psStatus ) |
|
438 { |
|
439 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": PS successful.\n"); |
|
440 |
|
441 /* send a RIVER_MODE_SUCCESS event */ |
|
442 measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), |
|
443 MSR_SRV_EVENT_DRIVER_MODE_SUCCESS ); |
|
444 } |
|
445 /* driver mode entry failed */ |
|
446 else |
|
447 { |
|
448 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": PS failed, status %d.\n", psStatus); |
|
449 |
|
450 /* Set the return status to TI_NOK */ |
|
451 pMeasurementSRV->returnStatus = (TI_STATUS)psStatus; |
|
452 |
|
453 /* send a DRIVER_MODE_FAILURE event */ |
|
454 measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), |
|
455 MSR_SRV_EVENT_DRIVER_MODE_FAILURE ); |
|
456 } |
|
457 } |
|
458 |
|
459 /** |
|
460 * \author Ronen Kalish\n |
|
461 * \date 14-November-2005\n |
|
462 * \brief callback function used by the HAL for measure start event (sent when the FW |
|
463 * has started measurement operation, i.e. switched channel and changed RX filters).\n |
|
464 * |
|
465 * Function Scope \e Public.\n |
|
466 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
467 */ |
|
468 void MacServices_measurementSRV_measureStartCB( TI_HANDLE hMeasurementSRV ) |
|
469 { |
|
470 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
471 |
|
472 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure start CB called.\n"); |
|
473 |
|
474 /* stop the FW guard timer */ |
|
475 tmr_StopTimer (pMeasurementSRV->hStartStopTimer); |
|
476 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
477 |
|
478 /* clear the CB function, so that it won't be called on stop as well! */ |
|
479 pMeasurementSRV->commandResponseCBFunc = NULL; |
|
480 pMeasurementSRV->commandResponseCBObj = NULL; |
|
481 |
|
482 measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), |
|
483 MSR_SRV_EVENT_START_SUCCESS ); |
|
484 } |
|
485 |
|
486 /** |
|
487 * \author Ronen Kalish\n |
|
488 * \date 14-November-2005\n |
|
489 * \brief callback function used by the HAL for measure stop event (sent when the FW |
|
490 * has finished measurement operation, i.e. switched channel to serving channel and changed back RX filters).\n |
|
491 * |
|
492 * Function Scope \e Public.\n |
|
493 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
494 */ |
|
495 void MacServices_measurementSRV_measureCompleteCB( TI_HANDLE hMeasurementSRV ) |
|
496 { |
|
497 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
498 |
|
499 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure complete CB called.\n"); |
|
500 |
|
501 /* stop the FW guard timer */ |
|
502 tmr_StopTimer (pMeasurementSRV->hStartStopTimer); |
|
503 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
504 |
|
505 measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), |
|
506 MSR_SRV_EVENT_STOP_COMPLETE ); |
|
507 } |
|
508 |
|
509 /** |
|
510 * \author Ronen Kalish\n |
|
511 * \date 14-November-2005\n |
|
512 * \brief callback function used by the HAL for AP discovery stop event (sent when the FW |
|
513 * has finished AP discovery operation).\n |
|
514 * |
|
515 * Function Scope \e Public.\n |
|
516 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
517 */ |
|
518 void MacServices_measurementSRV_apDiscoveryCompleteCB( TI_HANDLE hMeasurementSRV ) |
|
519 { |
|
520 #ifdef TI_DBG |
|
521 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
522 |
|
523 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": AP Discovery complete CB called.\n"); |
|
524 #endif /* TI_DBG */ |
|
525 } |
|
526 |
|
527 /** |
|
528 * \author Ronen Kalish\n |
|
529 * \date 14-November-2005\n |
|
530 * \brief called when a measurement FW guard timer expires. |
|
531 * |
|
532 * Function Scope \e Public.\n |
|
533 * \param hMeasuremntSRV - handle to the measurement SRV object.\n |
|
534 * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n |
|
535 */ |
|
536 void MacServices_measurementSRV_startStopTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured) |
|
537 { |
|
538 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
539 TI_INT32 i; |
|
540 |
|
541 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": FW guard timer expired.\n"); |
|
542 |
|
543 /* mark that the FW guard timer is not running */ |
|
544 pMeasurementSRV->bStartStopTimerRunning = TI_FALSE; |
|
545 |
|
546 /* if any other timer is running - stop it */ |
|
547 for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++) |
|
548 { |
|
549 if (pMeasurementSRV->bRequestTimerRunning[i]) |
|
550 { |
|
551 tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]); |
|
552 pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE; |
|
553 } |
|
554 } |
|
555 |
|
556 /* change SM state to idle */ |
|
557 pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE; |
|
558 |
|
559 /*Error Reporting - call the centeral error function in the health monitor if a request for measurement was faield*/ |
|
560 pMeasurementSRV->failureEventFunc(pMeasurementSRV->failureEventObj ,MEASUREMENT_FAILURE); |
|
561 } |
|
562 |
|
563 /** |
|
564 * \author Ronen Kalish\n |
|
565 * \date 15-November-2005\n |
|
566 * \brief called when a measurement type timer expires.\n |
|
567 * |
|
568 * Function Scope \e Public.\n |
|
569 * \param hMeasuremntSRV - handle to the measurement SRV object.\n |
|
570 * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n |
|
571 */ |
|
572 void MacServices_measurementSRV_requestTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured) |
|
573 { |
|
574 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
575 TI_INT32 requestIndex; |
|
576 |
|
577 /* find the expired measurement type */ |
|
578 requestIndex = measurementSRVFindMinDuration( hMeasurementSRV ); |
|
579 if ( -1 == requestIndex ) |
|
580 { |
|
581 /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ |
|
582 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Request timer expired and request index from findMinDuration is -1?!?"); |
|
583 return; |
|
584 } |
|
585 |
|
586 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": request timer expired, request index: %d.\n", requestIndex); |
|
587 |
|
588 /* mark that the timer is not running and that this request has completed */ |
|
589 pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_FALSE; |
|
590 |
|
591 /* collect results and send stop command if necessary */ |
|
592 switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) |
|
593 { |
|
594 case MSR_TYPE_BEACON_MEASUREMENT: |
|
595 measurementSRVHandleBeaconMsrComplete( hMeasurementSRV, requestIndex ); |
|
596 break; |
|
597 |
|
598 case MSR_TYPE_CCA_LOAD_MEASUREMENT: |
|
599 measurementSRVHandleChannelLoadComplete( hMeasurementSRV, requestIndex ); |
|
600 break; |
|
601 |
|
602 case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: |
|
603 measurementSRVHandleNoiseHistogramComplete( hMeasurementSRV, requestIndex ); |
|
604 break; |
|
605 |
|
606 /* used here to avoid compilation warning only, does nothing */ |
|
607 case MSR_TYPE_BASIC_MEASUREMENT: |
|
608 case MSR_TYPE_FRAME_MEASUREMENT: |
|
609 case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES: |
|
610 default: |
|
611 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": measure type %d not supported for request %d\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType, requestIndex); |
|
612 break; |
|
613 } |
|
614 |
|
615 /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ |
|
616 if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) |
|
617 { |
|
618 /* send the event */ |
|
619 measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), |
|
620 MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); |
|
621 } |
|
622 } |
|
623 |
|
624 /** |
|
625 * \author Ronen Kalish\n |
|
626 * \date 13-November-2005\n |
|
627 * \brief Checks whether a beacon measurement is part of current measurement request |
|
628 * |
|
629 * Function Scope \e Private.\n |
|
630 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
631 * \return TI_TRUE if a beacon measurement is part of current request, TI_FALSE otherwise.\n |
|
632 */ |
|
633 TI_BOOL measurementSRVIsBeaconMeasureIncluded( TI_HANDLE hMeasurementSRV ) |
|
634 { |
|
635 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
636 TI_INT32 i; |
|
637 |
|
638 for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ ) |
|
639 { |
|
640 if ( MSR_TYPE_BEACON_MEASUREMENT == pMeasurementSRV->msrRequest.msrTypes[ i ].msrType ) |
|
641 { |
|
642 return TI_TRUE; |
|
643 } |
|
644 } |
|
645 return TI_FALSE; |
|
646 } |
|
647 |
|
648 /** |
|
649 * \author Ronen Kalish\n |
|
650 * \date 15-November-2005\n |
|
651 * \brief Finds the index for the measurement request with the shortest period |
|
652 * (the one that has now completed).\n |
|
653 * |
|
654 * Function Scope \e Private.\n |
|
655 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
656 * \return index of the measurement request with the shortest duration.\n |
|
657 */ |
|
658 TI_INT32 measurementSRVFindMinDuration( TI_HANDLE hMeasurementSRV ) |
|
659 { |
|
660 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
661 TI_INT32 i, minIndex; |
|
662 TI_UINT32 minValue; |
|
663 |
|
664 |
|
665 minIndex = minValue = 0; /* minIndex is initialized only to avoid compilation warning! */ |
|
666 |
|
667 /* find the index with the minimum duration */ |
|
668 for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) |
|
669 { |
|
670 if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] ) |
|
671 { |
|
672 if ( (0 == minValue) || |
|
673 (pMeasurementSRV->msrRequest.msrTypes[ i ].duration < minValue)) |
|
674 { |
|
675 minValue = pMeasurementSRV->msrRequest.msrTypes[ i ].duration; |
|
676 minIndex = i; |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 /* if no entry with positive duration exists, return -1 */ |
|
682 if ( 0 == minValue ) |
|
683 { |
|
684 return -1; |
|
685 } |
|
686 else |
|
687 { /* otherwise, return the index of the type with the shortest duration */ |
|
688 return minIndex; |
|
689 } |
|
690 } |
|
691 |
|
692 /** |
|
693 * \author Ronen Kalish\n |
|
694 * \date 15-November-2005\n |
|
695 * \brief Handles an AP discovery timer expiry, by setting necessary values in the |
|
696 * reply struct.\n |
|
697 * |
|
698 * Function Scope \e Private.\n |
|
699 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
700 * \param requestIndex - index of the beacon request in the request structure.\n |
|
701 */ |
|
702 void measurementSRVHandleBeaconMsrComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) |
|
703 { |
|
704 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
705 TI_INT32 status; |
|
706 |
|
707 |
|
708 TRACE0(pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Sending AP Discovery Stop to the HAL..."); |
|
709 |
|
710 /* send stop AP discovery command */ |
|
711 status = cmdBld_CmdApDiscoveryStop (pMeasurementSRV->hCmdBld, NULL, NULL); |
|
712 if ( TI_OK != status ) |
|
713 { |
|
714 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": status %d received from cmdBld_CmdApDiscoveryStop\n", status); |
|
715 } |
|
716 } |
|
717 |
|
718 /** |
|
719 * \author Ronen Kalish\n |
|
720 * \date 15-November-2005\n |
|
721 * \brief Handles a channel load timer expiry, by requesting channel load |
|
722 * results from the FW.\n |
|
723 * |
|
724 * Function Scope \e Private.\n |
|
725 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
726 * \param requestIndex - index of the channel load request in the request structure.\n |
|
727 */ |
|
728 void measurementSRVHandleChannelLoadComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) |
|
729 { |
|
730 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
731 TTwdParamInfo tTwdParam; |
|
732 TI_STATUS status; |
|
733 |
|
734 /* Getting the Medium Occupancy Register */ |
|
735 tTwdParam.paramType = TWD_MEDIUM_OCCUPANCY_PARAM_ID; |
|
736 tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_channelLoadParamCB; |
|
737 tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; |
|
738 tTwdParam.content.interogateCmdCBParams.pCb = (TI_UINT8*)(&(pMeasurementSRV->mediumOccupancyResults)); |
|
739 status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); |
|
740 |
|
741 if ( status != TI_OK ) |
|
742 { |
|
743 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_GetParam returned status %d\n", status); |
|
744 |
|
745 /* mark that the specific measurment type has failed */ |
|
746 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
747 |
|
748 /* if all measurement types has finished, an event will be send by request timer expired */ |
|
749 } |
|
750 else |
|
751 { |
|
752 /* mark that channel load param CB is pending */ |
|
753 pMeasurementSRV->pendingParamCBs |= MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; |
|
754 } |
|
755 } |
|
756 |
|
757 /** |
|
758 * \author Ronen Kalish\n |
|
759 * \date 15-November-2005\n |
|
760 * \brief Handles a noise histogram timer expiry, by requesting noise histogram |
|
761 * reaults from the FW.\n |
|
762 * |
|
763 * Function Scope \e Private.\n |
|
764 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
765 * \param requestIndex - index of the beacon request in the request structure.\n |
|
766 */ |
|
767 void measurementSRVHandleNoiseHistogramComplete( TI_HANDLE hMeasurementSRV, TI_INT32 requestIndex ) |
|
768 { |
|
769 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
770 TTwdParamInfo tTwdParam; |
|
771 TNoiseHistogram pNoiseHistParams; |
|
772 TI_STATUS status; |
|
773 |
|
774 /* Set Noise Histogram Cmd Params */ |
|
775 pNoiseHistParams.cmd = STOP_NOISE_HIST; |
|
776 pNoiseHistParams.sampleInterval = 0; |
|
777 os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES ); |
|
778 |
|
779 /* Send a Stop command to the FW */ |
|
780 status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL); |
|
781 |
|
782 if ( TI_OK != status ) |
|
783 { |
|
784 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_NoiseHistogramCmd returned status %d\n", status); |
|
785 |
|
786 /* mark that the specific measurment type has failed */ |
|
787 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
788 |
|
789 /* if all measurement types has finished, an event will be send by request timer expired */ |
|
790 } |
|
791 |
|
792 /* Get measurement results */ |
|
793 tTwdParam.paramType = TWD_NOISE_HISTOGRAM_PARAM_ID; |
|
794 tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_noiseHistCallBack; |
|
795 tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; |
|
796 tTwdParam.content.interogateCmdCBParams.pCb = (TI_UINT8*)&pMeasurementSRV->noiseHistogramResults; |
|
797 status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); |
|
798 |
|
799 if ( TI_OK == status ) |
|
800 { |
|
801 /* setting On the Waitng for Noise Histogram Results Bit */ |
|
802 pMeasurementSRV->pendingParamCBs |= MSR_SRV_WAITING_NOISE_HIST_RESULTS; |
|
803 |
|
804 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": sent noise histogram stop command.\n"); |
|
805 } |
|
806 else |
|
807 { |
|
808 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": whalCtrl_GetParam returned status %d\n", status); |
|
809 |
|
810 /* mark that the specific measurment type has failed */ |
|
811 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
812 |
|
813 /* if all measurement types has finished, an event will be send by request timer expired */ |
|
814 } |
|
815 } |
|
816 |
|
817 /** |
|
818 * \author Ronen Kalish\n |
|
819 * \date 16-November-2005\n |
|
820 * \brief Callback for channel load get param call.\n |
|
821 * |
|
822 * Function Scope \e Public.\n |
|
823 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
824 * \param status - the get_param call status.\n |
|
825 * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) |
|
826 */ |
|
827 void MacServices_measurementSRV_channelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, |
|
828 TI_UINT8* CB_buf ) |
|
829 { |
|
830 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
831 TI_UINT32 mediumUsageInMs, periodInMs; |
|
832 TI_INT32 requestIndex; |
|
833 |
|
834 /* when this CB is called as a result of the nulify call at the measurement beginning, |
|
835 the handle will be NULL. In this case, nothing needs to be done. */ |
|
836 if ( NULL == hMeasurementSRV ) |
|
837 { |
|
838 return; |
|
839 } |
|
840 |
|
841 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Channel load CB called, status:%d\n", status); |
|
842 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n",CB_buf, &(pMeasurementSRV->mediumOccupancyResults)); |
|
843 TRACE_INFO_HEX(pMeasurementSRV->hReport, CB_buf, sizeof(TMediumOccupancy)); |
|
844 |
|
845 /* setting Off the Waitng for Channel Load Results Bit */ |
|
846 pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; |
|
847 |
|
848 /* find the request index */ |
|
849 requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_CCA_LOAD_MEASUREMENT ); |
|
850 if ( -1 == requestIndex ) |
|
851 { |
|
852 /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ |
|
853 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); |
|
854 return; |
|
855 } |
|
856 |
|
857 if ( (TI_OK == status) && (0 != pMeasurementSRV->mediumOccupancyResults.Period)) |
|
858 { |
|
859 /* calculate results */ |
|
860 mediumUsageInMs = pMeasurementSRV->mediumOccupancyResults.MediumUsage / 1000; |
|
861 periodInMs = pMeasurementSRV->mediumOccupancyResults.Period / 1000; |
|
862 |
|
863 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": MediumUsage = %d Period = %d\n",mediumUsageInMs, periodInMs); |
|
864 |
|
865 if ( periodInMs <= pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration ) |
|
866 { |
|
867 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = |
|
868 ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / |
|
869 pMeasurementSRV->mediumOccupancyResults.Period; |
|
870 } |
|
871 else |
|
872 { |
|
873 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = |
|
874 ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / |
|
875 (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000); |
|
876 } |
|
877 } |
|
878 else |
|
879 { |
|
880 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": channel load failed. Status=%d, period=%d\n", status, pMeasurementSRV->mediumOccupancyResults.Period); |
|
881 |
|
882 /* mark result status */ |
|
883 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
884 } |
|
885 |
|
886 /* if no measurement are running and no CBs are pending, |
|
887 send ALL TYPES COMPLETE event */ |
|
888 if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) |
|
889 { |
|
890 /* send the event */ |
|
891 measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), |
|
892 MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); |
|
893 } |
|
894 } |
|
895 |
|
896 /** |
|
897 * \date 03-January-2005\n |
|
898 * \brief Dummy callback for channel load get param call. Used to clear the channel load tracker.\n |
|
899 * |
|
900 * Function Scope \e Public.\n |
|
901 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
902 * \param status - the get_param call status.\n |
|
903 * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) |
|
904 */ |
|
905 void MacServices_measurementSRV_dummyChannelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, |
|
906 TI_UINT8* CB_buf ) |
|
907 { |
|
908 #ifdef TI_DBG |
|
909 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*) hMeasurementSRV; |
|
910 |
|
911 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Dummy Channel Load callback called (status = %d)\n", status); |
|
912 #endif /* TI_DBG */ |
|
913 } |
|
914 |
|
915 /** |
|
916 * \author Ronen Kalish\n |
|
917 * \date 16-November-2005\n |
|
918 * \brief Callback for noise histogram get param call.\n |
|
919 * |
|
920 * Function Scope \e Public.\n |
|
921 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
922 * \param status - the get_param call status.\n |
|
923 * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) |
|
924 */ |
|
925 void MacServices_measurementSRV_noiseHistCallBack( TI_HANDLE hMeasurementSRV, TI_STATUS status, |
|
926 TI_UINT8* CB_buf ) |
|
927 { |
|
928 measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
929 TI_UINT8 index; |
|
930 TI_UINT32 sumOfSamples; |
|
931 TI_INT32 requestIndex; |
|
932 |
|
933 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": noise histogram CB called, status: %d\n", status); |
|
934 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n", CB_buf, &(pMeasurementSRV->noiseHistogramResults)); |
|
935 TRACE_INFO_HEX( pMeasurementSRV->hReport, CB_buf, sizeof(TNoiseHistogramResults)); |
|
936 |
|
937 /* setting Off the Waitng for noise histogram Results Bit */ |
|
938 pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_NOISE_HIST_RESULTS; |
|
939 |
|
940 /* find the request index */ |
|
941 requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT ); |
|
942 if ( -1 == requestIndex ) |
|
943 { |
|
944 /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ |
|
945 TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); |
|
946 return; |
|
947 } |
|
948 |
|
949 if ( TI_OK == status ) |
|
950 { |
|
951 sumOfSamples = pMeasurementSRV->noiseHistogramResults.numOfLostCycles; |
|
952 |
|
953 /* Print For Debug */ |
|
954 TRACE4( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": numOfLostCycles = %d numOfTxHwGenLostCycles = %d numOfRxLostCycles = %d numOfExceedLastThresholdLostCycles = %d\n", pMeasurementSRV->noiseHistogramResults.numOfLostCycles, pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles, pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles, pMeasurementSRV->noiseHistogramResults.numOfLostCycles - (pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles + pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles)); |
|
955 |
|
956 for ( index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++ ) |
|
957 { |
|
958 sumOfSamples += pMeasurementSRV->noiseHistogramResults.counters[ index ]; |
|
959 |
|
960 /* Print For Debug */ |
|
961 TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Counter #%d = %x\n", index, pMeasurementSRV->noiseHistogramResults.counters[index]); |
|
962 } |
|
963 |
|
964 /* If there weren't enough samples --> Reject the Request */ |
|
965 if ( (sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) < |
|
966 NOISE_HISTOGRAM_THRESHOLD ) |
|
967 { |
|
968 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB, rejecting request because %d samples received.\n", sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles); |
|
969 |
|
970 /* set negative result status */ |
|
971 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
972 } |
|
973 else |
|
974 { |
|
975 for (index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++) |
|
976 { |
|
977 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ index ] = |
|
978 ( 255 * pMeasurementSRV->noiseHistogramResults.counters[ index ]) / sumOfSamples; |
|
979 } |
|
980 |
|
981 TRACE8( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Valid noise histogram reply. RPIDensity: %d %d %d %d %d %d %d %d\n", pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 0 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 1 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 2 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 3 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 4 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 5 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 6 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 7 ]); |
|
982 } |
|
983 } |
|
984 else |
|
985 { |
|
986 TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB with status: %d, rejecting request.\n", status); |
|
987 /* set negative result status */ |
|
988 pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; |
|
989 } |
|
990 |
|
991 /* if no measurement are running and no CBs are pending, |
|
992 send ALL TYPES COMPLETE event */ |
|
993 if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) |
|
994 { |
|
995 /* send the event */ |
|
996 measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), |
|
997 MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); |
|
998 } |
|
999 } |
|
1000 |
|
1001 /** |
|
1002 * \author Ronen Kalish\n |
|
1003 * \date 16-November-2005\n |
|
1004 * \brief Checks whether all measuremtn types had completed and all param CBs had been called.\n |
|
1005 * |
|
1006 * Function Scope \e Public.\n |
|
1007 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
1008 * \param status - the get_param call status.\n |
|
1009 * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) |
|
1010 */ |
|
1011 TI_BOOL measurementSRVIsMeasurementComplete( TI_HANDLE hMeasurementSRV ) |
|
1012 { |
|
1013 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
1014 TI_INT32 i; |
|
1015 |
|
1016 /* verify that no request is currently running */ |
|
1017 for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) |
|
1018 { |
|
1019 if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] ) |
|
1020 { |
|
1021 return TI_FALSE; |
|
1022 } |
|
1023 } |
|
1024 |
|
1025 /* verify that no CBs are pending */ |
|
1026 if ( 0 != (pMeasurementSRV->pendingParamCBs & |
|
1027 (MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS | MSR_SRV_WAITING_NOISE_HIST_RESULTS))) |
|
1028 { |
|
1029 return TI_FALSE; |
|
1030 } |
|
1031 |
|
1032 return TI_TRUE; |
|
1033 } |
|
1034 |
|
1035 /** |
|
1036 * \author Ronen Kalish\n |
|
1037 * \date 17-November-2005\n |
|
1038 * \brief Finds a measure type index in the measure request array.\n |
|
1039 * |
|
1040 * Function Scope \e Public.\n |
|
1041 * \param hMeasurementSRV - handle to the measurement SRV object.\n |
|
1042 * \param type - the measure type to look for.\n |
|
1043 * \return the type index, -1 if not found.\n |
|
1044 */ |
|
1045 TI_INT32 measurementSRVFindIndexByType( TI_HANDLE hMeasurementSRV, EMeasurementType type ) |
|
1046 { |
|
1047 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
1048 TI_INT32 i; |
|
1049 |
|
1050 for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) |
|
1051 { |
|
1052 if ( type == pMeasurementSRV->msrRequest.msrTypes[ i ].msrType ) |
|
1053 { |
|
1054 return i; |
|
1055 } |
|
1056 } |
|
1057 return -1; |
|
1058 } |
|
1059 |
|
1060 |
|
1061 |
|
1062 /**************************************************************************************** |
|
1063 * measurementSRVRegisterFailureEventCB * |
|
1064 **************************************************************************************** |
|
1065 DESCRIPTION: Registers a failure event callback for scan error notifications. |
|
1066 |
|
1067 |
|
1068 INPUT: - hMeasurementSRV - handle to the Measurement SRV object. |
|
1069 - failureEventCB - the failure event callback function.\n |
|
1070 - hFailureEventObj - handle to the object passed to the failure event callback function. |
|
1071 |
|
1072 OUTPUT: |
|
1073 RETURN: void. |
|
1074 ****************************************************************************************/ |
|
1075 |
|
1076 void measurementSRVRegisterFailureEventCB( TI_HANDLE hMeasurementSRV, |
|
1077 void * failureEventCB, TI_HANDLE hFailureEventObj ) |
|
1078 { |
|
1079 measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; |
|
1080 |
|
1081 pMeasurementSRV->failureEventFunc = (TFailureEventCb)failureEventCB; |
|
1082 pMeasurementSRV->failureEventObj = hFailureEventObj; |
|
1083 } |
|
1084 |
|
1085 |