|
1 /* |
|
2 * MacServices.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 MacServices.c |
|
40 * \brief This file include public definitions for the scan SRV module, comprising its API. |
|
41 * \date 6-Oct-2005 |
|
42 */ |
|
43 |
|
44 #define __FILE_ID__ FILE_ID_109 |
|
45 #include "report.h" |
|
46 #include "ScanSrv.h" |
|
47 #include "MeasurementSrv.h" |
|
48 #include "MacServices.h" |
|
49 #include "PowerSrv_API.h" |
|
50 |
|
51 |
|
52 /**************************************************************************************** |
|
53 * MacServices_create * |
|
54 ***************************************************************************************** |
|
55 DESCRIPTION: Creates MacServices module |
|
56 |
|
57 INPUT: hOS - handle to the OS object. |
|
58 OUTPUT: |
|
59 RETURN: handle to MacServices Object, NULL on failure . |
|
60 ****************************************************************************************/ |
|
61 |
|
62 TI_HANDLE MacServices_create( TI_HANDLE hOS) |
|
63 { |
|
64 MacServices_t *pMacServices = (MacServices_t*)os_memoryAlloc( hOS, sizeof(MacServices_t),MemoryNormal ); |
|
65 if ( NULL == pMacServices ) |
|
66 { |
|
67 WLAN_OS_REPORT( ("ERROR: Failed to create Mac SRV module") ); |
|
68 return NULL; |
|
69 } |
|
70 |
|
71 /* nullify all handles, so that only handles in existence will be released */ |
|
72 pMacServices->hScanSRV = NULL; |
|
73 pMacServices->hPowerSrv = NULL; |
|
74 |
|
75 /* create the scanSRV handle */ |
|
76 pMacServices->hScanSRV = MacServices_scanSRV_create(hOS); |
|
77 if ( NULL == pMacServices->hScanSRV ) |
|
78 { |
|
79 MacServices_destroy( pMacServices ); |
|
80 return NULL; |
|
81 } |
|
82 |
|
83 /* create the measurment handle */ |
|
84 pMacServices->hMeasurementSRV = MacServices_measurementSRV_create( hOS ); |
|
85 if ( NULL == pMacServices->hMeasurementSRV ) |
|
86 { |
|
87 MacServices_destroy(pMacServices); |
|
88 return NULL; |
|
89 } |
|
90 |
|
91 pMacServices->hPowerSrv = powerSrv_create(hOS); |
|
92 if (NULL == pMacServices->hPowerSrv ) |
|
93 { |
|
94 MacServices_destroy(pMacServices); |
|
95 return NULL; |
|
96 } |
|
97 |
|
98 /* store OS handle */ |
|
99 pMacServices->hOS = hOS; |
|
100 |
|
101 return pMacServices; |
|
102 } |
|
103 |
|
104 |
|
105 |
|
106 /**************************************************************************************** |
|
107 * MacServices_destroy * |
|
108 ***************************************************************************************** |
|
109 DESCRIPTION: destroys MacServices module |
|
110 |
|
111 INPUT: hMacServices - handle to the Mac Services object. |
|
112 OUTPUT: |
|
113 RETURN: |
|
114 ****************************************************************************************/ |
|
115 void MacServices_destroy( TI_HANDLE hMacServices ) |
|
116 { |
|
117 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
118 |
|
119 /* destroy all SRV modules */ |
|
120 if ( NULL != pMacServices->hScanSRV ) |
|
121 { |
|
122 MacServices_scanSRV_destroy( pMacServices->hScanSRV ); |
|
123 } |
|
124 if ( NULL != pMacServices->hMeasurementSRV ) |
|
125 { |
|
126 MacServices_measurementSRV_destroy( pMacServices->hMeasurementSRV ); |
|
127 } |
|
128 |
|
129 if(pMacServices->hPowerSrv) |
|
130 powerSrv_destroy(pMacServices->hPowerSrv); |
|
131 |
|
132 /* free the Mac services allocated context */ |
|
133 os_memoryFree( pMacServices->hOS, (TI_HANDLE)pMacServices , sizeof(MacServices_t) ); |
|
134 } |
|
135 |
|
136 |
|
137 /**************************************************************************************** |
|
138 * MacServices_init * |
|
139 ***************************************************************************************** |
|
140 DESCRIPTION: Initializes the MacServices module |
|
141 |
|
142 INPUT: hMacServices - handle to the Mac Services object.\n |
|
143 hReport - handle to the report object.\n |
|
144 hHalCtrl - handle to the HAL ctrl object.\n |
|
145 OUTPUT: |
|
146 RETURN: |
|
147 ****************************************************************************************/ |
|
148 void MacServices_init (TI_HANDLE hMacServices, |
|
149 TI_HANDLE hReport, |
|
150 TI_HANDLE hTWD, |
|
151 TI_HANDLE hCmdBld, |
|
152 TI_HANDLE hEventMbox, |
|
153 TI_HANDLE hTimer) |
|
154 { |
|
155 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
156 |
|
157 MacServices_scanSRV_init (hMacServices, hReport, hTWD, hTimer, hEventMbox, hCmdBld); |
|
158 |
|
159 MacServices_measurementSRV_init (pMacServices->hMeasurementSRV, |
|
160 hReport, |
|
161 hCmdBld, |
|
162 hEventMbox, |
|
163 pMacServices->hPowerSrv, |
|
164 hTimer); |
|
165 |
|
166 if (powerSrv_init (pMacServices->hPowerSrv, |
|
167 hReport, |
|
168 hEventMbox, |
|
169 hCmdBld, |
|
170 hTimer) != TI_OK) |
|
171 { |
|
172 WLAN_OS_REPORT(("\n.....PowerSRV_init configuration failure \n")); |
|
173 /*return TI_NOK;*/ |
|
174 } |
|
175 } |
|
176 |
|
177 |
|
178 /**************************************************************************************** |
|
179 * MacServices_config * |
|
180 ***************************************************************************************** |
|
181 DESCRIPTION: config the MacServices moduleand sub modules |
|
182 |
|
183 INPUT: hMacServices - handle to the Mac Services object.\n |
|
184 pInitParams - pointer to the init params |
|
185 OUTPUT: |
|
186 RETURN: |
|
187 ****************************************************************************************/ |
|
188 void MacServices_config( TI_HANDLE hMacServices, TTwdInitParams *pInitParams) |
|
189 { |
|
190 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
191 |
|
192 if (powerSrv_config(pMacServices->hPowerSrv,&pInitParams->tPowerSrv) != TI_OK) |
|
193 { |
|
194 WLAN_OS_REPORT(("\n.....PowerSRV_config failure \n")); |
|
195 } |
|
196 |
|
197 MacServices_scanSrv_config (pMacServices, &pInitParams->tScanSrv); |
|
198 } |
|
199 |
|
200 /**************************************************************************************** |
|
201 * MacServices_restart * |
|
202 ***************************************************************************************** |
|
203 DESCRIPTION: restart the MacServices moduleand sub modules upon recovery |
|
204 |
|
205 INPUT: hMacServices - handle to the Mac Services object.\n |
|
206 OUTPUT: |
|
207 RETURN: |
|
208 ****************************************************************************************/ |
|
209 void MacServices_restart (TI_HANDLE hMacServices) |
|
210 { |
|
211 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
212 |
|
213 scanSRV_restart (pMacServices->hScanSRV); |
|
214 measurementSRV_restart (pMacServices->hMeasurementSRV); |
|
215 powerSrv_restart (pMacServices->hPowerSrv); |
|
216 } |
|
217 |
|
218 |
|
219 /**************************************************************************************** |
|
220 * MacServices_registerFailureEventCB * |
|
221 ***************************************************************************************** |
|
222 DESCRIPTION: register the centeral error function from the health monitor to the MacService's sub modules |
|
223 |
|
224 INPUT: hMacServices - handle to the Mac Services object. |
|
225 failureEventCB - pointer ro the call back |
|
226 hFailureEventObj -handle of the Callback Object |
|
227 OUTPUT: |
|
228 RETURN: |
|
229 ****************************************************************************************/ |
|
230 |
|
231 void MacServices_registerFailureEventCB (TI_HANDLE hMacServices, |
|
232 void * failureEventCB, |
|
233 TI_HANDLE hFailureEventObj) |
|
234 { |
|
235 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
236 |
|
237 powerSrvRegisterFailureEventCB (pMacServices->hPowerSrv, |
|
238 failureEventCB, |
|
239 hFailureEventObj); |
|
240 |
|
241 measurementSRVRegisterFailureEventCB (pMacServices->hMeasurementSRV, |
|
242 failureEventCB, |
|
243 hFailureEventObj); |
|
244 |
|
245 scanSRV_registerFailureEventCB (pMacServices->hScanSRV, |
|
246 failureEventCB, |
|
247 hFailureEventObj); |
|
248 |
|
249 } |
|
250 |
|
251 /**************************************************************************************** |
|
252 * MacServices_powerSrv_SetPsMode * |
|
253 **************************************************************************************** |
|
254 DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetPsMode function |
|
255 |
|
256 INPUT: - hMacServices - handle to the Mac services object. |
|
257 - psMode - Power save/Active request |
|
258 - sendNullDataOnExit - |
|
259 - powerSaveCBObject - handle to the Callback function module. |
|
260 - powerSaveCompleteCB - Callback function - for success/faild notification. |
|
261 OUTPUT: |
|
262 RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. |
|
263 ****************************************************************************************/ |
|
264 |
|
265 TI_STATUS MacServices_powerSrv_SetPsMode (TI_HANDLE hMacServices, |
|
266 E80211PsMode psMode, |
|
267 TI_BOOL sendNullDataOnExit, |
|
268 void * powerSaveCompleteCBObject, |
|
269 TPowerSaveCompleteCb powerSaveCompleteCB, |
|
270 TPowerSaveResponseCb powerSavecmdResponseCB) |
|
271 { |
|
272 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
273 |
|
274 return powerSrv_SetPsMode (pMacServices->hPowerSrv, |
|
275 psMode, |
|
276 sendNullDataOnExit, |
|
277 powerSaveCompleteCBObject, |
|
278 powerSaveCompleteCB, |
|
279 powerSavecmdResponseCB); |
|
280 } |
|
281 |
|
282 |
|
283 /**************************************************************************************** |
|
284 * MacServices_powerSrv_ReservePS * |
|
285 **************************************************************************************** |
|
286 DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReservePS function |
|
287 |
|
288 INPUT: - hMacServices - handle to the Mac services object. |
|
289 - psMode - Power save/Active request |
|
290 - sendNullDataOnExit - |
|
291 - powerSaveCBObject - handle to the Callback function module. |
|
292 - powerSaveCompleteCB - Callback function - for success/faild notification. |
|
293 OUTPUT: |
|
294 RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. |
|
295 ****************************************************************************************/ |
|
296 TI_STATUS MacServices_powerSrv_ReservePS( TI_HANDLE hMacServices, |
|
297 E80211PsMode psMode, |
|
298 TI_BOOL sendNullDataOnExit, |
|
299 void * powerSaveCBObject, |
|
300 TPowerSaveCompleteCb powerSaveCompleteCB) |
|
301 { |
|
302 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
303 |
|
304 return powerSrv_ReservePS(pMacServices->hPowerSrv,psMode,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB); |
|
305 } |
|
306 |
|
307 |
|
308 /**************************************************************************************** |
|
309 * MacServices_powerSrv_ReleasePS * |
|
310 **************************************************************************************** |
|
311 DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReleasePS function |
|
312 |
|
313 INPUT: - hPowerSrv - handle to the PowerSrv object. |
|
314 - sendNullDataOnExit - |
|
315 - powerSaveCBObject - handle to the Callback function module. |
|
316 - powerSaveCompleteCB - Callback function - for success/faild notification. |
|
317 OUTPUT: |
|
318 RETURN: TI_STATUS - TI_OK / PENDING / TI_NOK. |
|
319 ****************************************************************************************/ |
|
320 |
|
321 TI_STATUS MacServices_powerSrv_ReleasePS( TI_HANDLE hMacServices, |
|
322 TI_BOOL sendNullDataOnExit, |
|
323 void * powerSaveCBObject, |
|
324 TPowerSaveCompleteCb powerSaveCompleteCB) |
|
325 { |
|
326 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
327 |
|
328 return powerSrv_ReleasePS(pMacServices->hPowerSrv,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB); |
|
329 } |
|
330 |
|
331 |
|
332 /**************************************************************************************** |
|
333 * MacServices_powerSrv_getPsStatus * |
|
334 ***************************************************************************************** |
|
335 DESCRIPTION: This function is a wrapper for the power server's powerSrv_getPsStatus function |
|
336 |
|
337 INPUT: - hPowerSrv - handle to the PowerSrv object. |
|
338 |
|
339 OUTPUT: |
|
340 RETURN: TI_BOOL - true if the SM is in PS state - false otherwise |
|
341 ****************************************************************************************/ |
|
342 TI_BOOL MacServices_powerSrv_getPsStatus(TI_HANDLE hMacServices) |
|
343 { |
|
344 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
345 |
|
346 return powerSrv_getPsStatus( pMacServices->hPowerSrv); |
|
347 } |
|
348 |
|
349 |
|
350 /**************************************************************************************** |
|
351 * MacServices_powerSrv_SetRateModulation * |
|
352 ***************************************************************************************** |
|
353 DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetRateModulation function |
|
354 |
|
355 INPUT: - hPowerSrv - handle to the PowerSrv object. |
|
356 - dot11mode_e - The current radio mode (A or G) |
|
357 |
|
358 OUTPUT: |
|
359 RETURN: TI_BOOL - true if the SM is in PS state - false otherwise |
|
360 ****************************************************************************************/ |
|
361 void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, TI_UINT16 rate) |
|
362 { |
|
363 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
364 |
|
365 powerSrv_SetRateModulation( pMacServices->hPowerSrv, rate); |
|
366 } |
|
367 |
|
368 |
|
369 TI_UINT32 MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices) |
|
370 { |
|
371 MacServices_t *pMacServices = (MacServices_t*)hMacServices; |
|
372 |
|
373 return powerSrv_GetRateModulation( pMacServices->hPowerSrv); |
|
374 } |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |