• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * MacServices.c
3  *
4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  *  * Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *  * Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *  * Neither the name Texas Instruments nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /** \file MacServices.c
35  *  \brief This file include public definitions for the scan SRV module, comprising its API.
36  *  \author Yuval Adler
37  *  \date 6-Oct-2005
38  */
39 
40 #define __FILE_ID__  FILE_ID_109
41 #include "report.h"
42 #include "ScanSrv.h"
43 #include "MeasurementSrv.h"
44 #include "MacServices.h"
45 #include "PowerSrv_API.h"
46 
47 
48 /****************************************************************************************
49  *                        MacServices_create                                                     *
50  *****************************************************************************************
51 DESCRIPTION: Creates MacServices module
52 
53 INPUT:          hOS - handle to the OS object.
54 OUTPUT:
55 RETURN:     handle to MacServices Object, NULL on failure .
56 ****************************************************************************************/
57 
MacServices_create(TI_HANDLE hOS)58 TI_HANDLE MacServices_create( TI_HANDLE hOS)
59 {
60     MacServices_t *pMacServices = (MacServices_t*)os_memoryAlloc( hOS, sizeof(MacServices_t) );
61     if ( NULL == pMacServices )
62     {
63         WLAN_OS_REPORT( ("ERROR: Failed to create Mac SRV module") );
64         return NULL;
65     }
66 
67     /* nullify all handles, so that only handles in existence will be released */
68     pMacServices->hScanSRV = NULL;
69     pMacServices->hPowerSrv = NULL;
70 
71     /* create the scanSRV handle */
72     pMacServices->hScanSRV = MacServices_scanSRV_create(hOS);
73     if ( NULL == pMacServices->hScanSRV )
74     {
75         MacServices_destroy( pMacServices );
76         return NULL;
77     }
78 
79 /* create the measurment handle */
80     pMacServices->hMeasurementSRV = MacServices_measurementSRV_create( hOS );
81     if ( NULL == pMacServices->hMeasurementSRV )
82     {
83             MacServices_destroy(pMacServices);
84         return NULL;
85     }
86 
87     pMacServices->hPowerSrv = powerSrv_create(hOS);
88     if (NULL == pMacServices->hPowerSrv  )
89     {
90         MacServices_destroy(pMacServices);
91         return NULL;
92      }
93 
94     /* store OS handle */
95     pMacServices->hOS      = hOS;
96 
97     return pMacServices;
98 }
99 
100 
101 
102 /****************************************************************************************
103  *                        MacServices_destroy                                                    *
104  *****************************************************************************************
105 DESCRIPTION: destroys MacServices module
106 
107 INPUT:          hMacServices - handle to the Mac Services object.
108 OUTPUT:
109 RETURN:
110 ****************************************************************************************/
MacServices_destroy(TI_HANDLE hMacServices)111 void MacServices_destroy( TI_HANDLE hMacServices )
112 {
113     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
114 
115     /* destroy all SRV modules */
116     if ( NULL != pMacServices->hScanSRV )
117     {
118         MacServices_scanSRV_destroy( pMacServices->hScanSRV );
119     }
120     if ( NULL != pMacServices->hMeasurementSRV )
121     {
122         MacServices_measurementSRV_destroy( pMacServices->hMeasurementSRV );
123     }
124 
125     if(pMacServices->hPowerSrv)
126     powerSrv_destroy(pMacServices->hPowerSrv);
127 
128     /* free the Mac services allocated context */
129     os_memoryFree( pMacServices->hOS, (TI_HANDLE)pMacServices , sizeof(MacServices_t) );
130 }
131 
132 
133  /****************************************************************************************
134  *                        MacServices_init                                                   *
135  *****************************************************************************************
136 DESCRIPTION: Initializes the MacServices module
137 
138 INPUT:    hMacServices - handle to the Mac Services object.\n
139         hReport - handle to the report object.\n
140         hHalCtrl - handle to the HAL ctrl object.\n
141 OUTPUT:
142 RETURN:
143 ****************************************************************************************/
MacServices_init(TI_HANDLE hMacServices,TI_HANDLE hReport,TI_HANDLE hTWD,TI_HANDLE hCmdBld,TI_HANDLE hEventMbox,TI_HANDLE hTimer)144 void MacServices_init (TI_HANDLE hMacServices,
145                        TI_HANDLE hReport,
146                        TI_HANDLE hTWD,
147                        TI_HANDLE hCmdBld,
148                        TI_HANDLE hEventMbox,
149                        TI_HANDLE hTimer)
150 {
151     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
152 
153     MacServices_scanSRV_init (hMacServices, hReport, hTWD, hTimer, hEventMbox, hCmdBld);
154 
155     MacServices_measurementSRV_init (pMacServices->hMeasurementSRV,
156                                      hReport,
157                                      hCmdBld,
158                                      hEventMbox,
159                                      pMacServices->hPowerSrv,
160                                      hTimer);
161 
162     if (powerSrv_init (pMacServices->hPowerSrv,
163                        hReport,
164                        hEventMbox,
165                        hCmdBld,
166                        hTimer) != TI_OK)
167     {
168         WLAN_OS_REPORT(("\n.....PowerSRV_init configuration failure \n"));
169         /*return TI_NOK;*/
170     }
171 }
172 
173 
174  /****************************************************************************************
175  *                        MacServices_config                                                     *
176  *****************************************************************************************
177 DESCRIPTION: config the MacServices moduleand sub modules
178 
179 INPUT:    hMacServices - handle to the Mac Services object.\n
180         pInitParams  - pointer to the init params
181 OUTPUT:
182 RETURN:
183 ****************************************************************************************/
MacServices_config(TI_HANDLE hMacServices,TTwdInitParams * pInitParams)184 void MacServices_config( TI_HANDLE hMacServices, TTwdInitParams *pInitParams)
185 {
186     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
187 
188     if (powerSrv_config(pMacServices->hPowerSrv,&pInitParams->tPowerSrv) != TI_OK)
189     {
190         WLAN_OS_REPORT(("\n.....PowerSRV_config failure \n"));
191     }
192 
193     MacServices_scanSrv_config (pMacServices, &pInitParams->tScanSrv);
194 }
195 
196  /****************************************************************************************
197  *                        MacServices_restart                                                     *
198  *****************************************************************************************
199 DESCRIPTION: restart the MacServices moduleand sub modules upon recovery
200 
201 INPUT:    hMacServices - handle to the Mac Services object.\n
202 OUTPUT:
203 RETURN:
204 ****************************************************************************************/
MacServices_restart(TI_HANDLE hMacServices)205 void MacServices_restart (TI_HANDLE hMacServices)
206 {
207     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
208 
209     scanSRV_restart (pMacServices->hScanSRV);
210     measurementSRV_restart (pMacServices->hMeasurementSRV);
211     powerSrv_restart (pMacServices->hPowerSrv);
212 }
213 
214 
215 /****************************************************************************************
216  *                        MacServices_registerFailureEventCB                                                     *
217  *****************************************************************************************
218 DESCRIPTION: register the centeral error function from the health monitor to the MacService's sub modules
219 
220 INPUT:    hMacServices      - handle to the Mac Services object.
221         failureEventCB  - pointer ro the call back
222         hFailureEventObj    -handle of the Callback Object
223 OUTPUT:
224 RETURN:
225 ****************************************************************************************/
226 
MacServices_registerFailureEventCB(TI_HANDLE hMacServices,void * failureEventCB,TI_HANDLE hFailureEventObj)227 void MacServices_registerFailureEventCB (TI_HANDLE hMacServices,
228                                          void * failureEventCB,
229                                          TI_HANDLE hFailureEventObj)
230 {
231     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
232 
233     powerSrvRegisterFailureEventCB (pMacServices->hPowerSrv,
234                                     failureEventCB,
235                                     hFailureEventObj);
236 
237     measurementSRVRegisterFailureEventCB (pMacServices->hMeasurementSRV,
238                                           failureEventCB,
239                                           hFailureEventObj);
240 
241     scanSRV_registerFailureEventCB (pMacServices->hScanSRV,
242                                     failureEventCB,
243                                     hFailureEventObj);
244 
245 }
246 
247 /****************************************************************************************
248  *                        MacServices_powerSrv_SetPsMode                                                            *
249  ****************************************************************************************
250 DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetPsMode function
251 
252 INPUT:      - hMacServices          - handle to the Mac services object.
253             - psMode                    - Power save/Active request
254             - sendNullDataOnExit        -
255             - powerSaveCBObject     - handle to the Callback function module.
256             - powerSaveCompleteCB   - Callback function - for success/faild notification.
257 OUTPUT:
258 RETURN:    TI_STATUS - TI_OK / PENDING / TI_NOK.
259 ****************************************************************************************/
260 
MacServices_powerSrv_SetPsMode(TI_HANDLE hMacServices,E80211PsMode psMode,TI_BOOL sendNullDataOnExit,void * powerSaveCompleteCBObject,TPowerSaveCompleteCb powerSaveCompleteCB,TPowerSaveResponseCb powerSavecmdResponseCB)261 TI_STATUS MacServices_powerSrv_SetPsMode (TI_HANDLE                   hMacServices,
262                                           E80211PsMode                psMode,
263                                           TI_BOOL                        sendNullDataOnExit,
264                                           void *                      powerSaveCompleteCBObject,
265                                           TPowerSaveCompleteCb        powerSaveCompleteCB,
266                                           TPowerSaveResponseCb        powerSavecmdResponseCB)
267 {
268     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
269 
270     return powerSrv_SetPsMode (pMacServices->hPowerSrv,
271                                psMode,
272                                sendNullDataOnExit,
273                                powerSaveCompleteCBObject,
274                                powerSaveCompleteCB,
275                                powerSavecmdResponseCB);
276 }
277 
278 
279 /****************************************************************************************
280  *                        MacServices_powerSrv_ReservePS                                                        *
281  ****************************************************************************************
282 DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReservePS function
283 
284 INPUT:      - hMacServices                  - handle to the Mac services object.
285             - psMode                            - Power save/Active request
286             - sendNullDataOnExit                -
287             - powerSaveCBObject             - handle to the Callback function module.
288             - powerSaveCompleteCB           - Callback function - for success/faild notification.
289 OUTPUT:
290 RETURN:    TI_STATUS - TI_OK / PENDING / TI_NOK.
291 ****************************************************************************************/
MacServices_powerSrv_ReservePS(TI_HANDLE hMacServices,E80211PsMode psMode,TI_BOOL sendNullDataOnExit,void * powerSaveCBObject,TPowerSaveCompleteCb powerSaveCompleteCB)292 TI_STATUS MacServices_powerSrv_ReservePS(   TI_HANDLE               hMacServices,
293                                             E80211PsMode psMode,
294                                             TI_BOOL                    sendNullDataOnExit,
295                                             void *                  powerSaveCBObject,
296                                             TPowerSaveCompleteCb    powerSaveCompleteCB)
297 {
298     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
299 
300     return powerSrv_ReservePS(pMacServices->hPowerSrv,psMode,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB);
301 }
302 
303 
304 /****************************************************************************************
305  *                        MacServices_powerSrv_ReleasePS                                                        *
306  ****************************************************************************************
307 DESCRIPTION: This function is a wrapper for the power server's powerSrv_ReleasePS function
308 
309 INPUT:      - hPowerSrv                         - handle to the PowerSrv object.
310             - sendNullDataOnExit                -
311             - powerSaveCBObject     - handle to the Callback function module.
312             - powerSaveCompleteCB           - Callback function - for success/faild notification.
313 OUTPUT:
314 RETURN:    TI_STATUS - TI_OK / PENDING / TI_NOK.
315 ****************************************************************************************/
316 
MacServices_powerSrv_ReleasePS(TI_HANDLE hMacServices,TI_BOOL sendNullDataOnExit,void * powerSaveCBObject,TPowerSaveCompleteCb powerSaveCompleteCB)317 TI_STATUS MacServices_powerSrv_ReleasePS(   TI_HANDLE                   hMacServices,
318                                     TI_BOOL                        sendNullDataOnExit,
319                                     void *                          powerSaveCBObject,
320                                     TPowerSaveCompleteCb              powerSaveCompleteCB)
321 {
322     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
323 
324     return powerSrv_ReleasePS(pMacServices->hPowerSrv,sendNullDataOnExit,powerSaveCBObject,powerSaveCompleteCB);
325 }
326 
327 
328 /****************************************************************************************
329  *                        MacServices_powerSrv_getPsStatus                                                       *
330  *****************************************************************************************
331 DESCRIPTION: This function is a wrapper for the power server's powerSrv_getPsStatus function
332 
333 INPUT:      - hPowerSrv                         - handle to the PowerSrv object.
334 
335 OUTPUT:
336 RETURN:    TI_BOOL - true if the SM is in PS state -  false otherwise
337 ****************************************************************************************/
MacServices_powerSrv_getPsStatus(TI_HANDLE hMacServices)338 TI_BOOL MacServices_powerSrv_getPsStatus(TI_HANDLE hMacServices)
339 {
340     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
341 
342     return powerSrv_getPsStatus( pMacServices->hPowerSrv);
343 }
344 
345 
346  /****************************************************************************************
347  *                        MacServices_powerSrv_SetRateModulation                                                         *
348  *****************************************************************************************
349 DESCRIPTION: This function is a wrapper for the power server's powerSrv_SetRateModulation function
350 
351 INPUT:      - hPowerSrv                         - handle to the PowerSrv object.
352             - dot11mode_e - The current radio mode (A or G)
353 
354 OUTPUT:
355 RETURN:    TI_BOOL - true if the SM is in PS state -  false otherwise
356 ****************************************************************************************/
MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices,TI_UINT16 rate)357 void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, TI_UINT16  rate)
358 {
359     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
360 
361     powerSrv_SetRateModulation( pMacServices->hPowerSrv,   rate);
362 }
363 
364 
MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices)365 TI_UINT32 MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices)
366 {
367     MacServices_t *pMacServices = (MacServices_t*)hMacServices;
368 
369     return powerSrv_GetRateModulation( pMacServices->hPowerSrv);
370 }
371 
372 
373 
374 
375 
376 
377