blob: 2c587d9e7da4f1835a67108f2a00c2a1f3810872 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 *
44 * Airgo Networks, Inc proprietary. All rights reserved.
45 * macInitApi.c - This file has all the mac level init functions
46 * for all the defined threads at system level.
47 * Author: Dinesh Upadhyay
48 * Date: 04/23/2007
49 * History:-
50 * Date: 04/08/2008 Modified by: Santosh Mandiganal
51 * Modification Information: Code to allocate and free the memory for DumpTable entry.
52 * --------------------------------------------------------------------------
53 *
54 */
55/* Standard include files */
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "cfgApi.h" // cfgCleanup
57#include "limApi.h" // limCleanup
58#include "sirTypes.h"
59#include "sysDebug.h"
60#include "sysEntryFunc.h"
61#include "macInitApi.h"
62#if defined(ANI_LOGDUMP)
63#include "logDump.h"
64#endif //#if defined(ANI_LOGDUMP)
65
66#ifdef TRACE_RECORD
67#include "macTrace.h"
68#endif
69
70extern tSirRetStatus halDoCfgInit(tpAniSirGlobal pMac);
71extern tSirRetStatus halProcessStartEvent(tpAniSirGlobal pMac);
72
73
74
75
76tSirRetStatus macReset(tpAniSirGlobal pMac, tANI_U32 rc);
77
Jeff Johnson295189b2012-06-20 16:38:30 -070078tSirRetStatus macPreStart(tHalHandle hHal)
79{
80 tSirRetStatus status = eSIR_SUCCESS;
81 tANI_BOOLEAN memAllocFailed = eANI_BOOLEAN_FALSE;
82 tpAniSirGlobal pMac = (tpAniSirGlobal) hHal;
83 tANI_U8 i;
84
85 for(i=0; i<MAX_DUMP_TABLE_ENTRY; i++)
86 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +053087 pMac->dumpTableEntry[i] = vos_mem_malloc(sizeof(tDumpModuleEntry));
88 if ( NULL == pMac->dumpTableEntry[i] )
Jeff Johnson295189b2012-06-20 16:38:30 -070089 {
90 memAllocFailed = eANI_BOOLEAN_TRUE;
91 break;
92 }
93 else
94 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +053095 vos_mem_set(pMac->dumpTableEntry[i], sizeof(tSirMbMsg), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070096 }
97 }
98 if( memAllocFailed )
99 {
100 while(i>0)
101 {
102 i--;
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530103 vos_mem_free(pMac->dumpTableEntry[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700104 }
105 sysLog(pMac, LOGE, FL("pMac->dumpTableEntry is NULL\n"));
106 status = eSIR_FAILURE;
107 }
108
109#if defined(ANI_LOGDUMP)
110 //logDumpInit must be called before any module starts
111 logDumpInit(pMac);
112#endif //#if defined(ANI_LOGDUMP)
113
114 return status;
115}
116
117tSirRetStatus macStart(tHalHandle hHal, void* pHalMacStartParams)
118{
119 tSirRetStatus status = eSIR_SUCCESS;
120 tpAniSirGlobal pMac = (tpAniSirGlobal) hHal;
121
122 if (NULL == pMac)
123 {
124 VOS_ASSERT(0);
125 status = eSIR_FAILURE;
126 return status;
127 }
128
129 pMac->gDriverType = ((tHalMacStartParameters*)pHalMacStartParams)->driverType;
130
131 sysLog(pMac, LOG2, FL("called\n"));
132
133 do
134 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530135 pMac->pResetMsg = vos_mem_malloc(sizeof(tSirMbMsg));
136 if ( NULL == pMac->pResetMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 {
138 sysLog(pMac, LOGE, FL("pMac->pResetMsg is NULL\n"));
139 status = eSIR_FAILURE;
140 break;
141 }
142 else
143 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530144 vos_mem_set(pMac->pResetMsg, sizeof(tSirMbMsg), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 }
146
147 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
148 {
149 status = peStart(pMac);
150 }
151
152 } while(0);
153 pMac->sys.abort = false;
154
155 return status;
156}
157
Jeff Johnson295189b2012-06-20 16:38:30 -0700158
159/** -------------------------------------------------------------
160\fn macStop
161\brief this function will be called from HDD to stop MAC. This function will stop all the mac modules.
162\ memory with global context will only be initialized not freed here.
163\param tHalHandle hHal
164\param tHalStopType
165\return tSirRetStatus
166 -------------------------------------------------------------*/
167
168tSirRetStatus macStop(tHalHandle hHal, tHalStopType stopType)
169{
170 tANI_U8 i;
171 tpAniSirGlobal pMac = (tpAniSirGlobal) hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 peStop(pMac);
173 cfgCleanup( pMac );
174 // need to free memory if not called in reset context.
175 // in reset context this memory will be freed by HDD.
176 if(false == pMac->sys.abort)
177 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530178 vos_mem_free(pMac->pResetMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 pMac->pResetMsg = NULL;
180 }
181 /* Free the DumpTableEntry */
182 for(i=0; i<MAX_DUMP_TABLE_ENTRY; i++)
183 {
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530184 vos_mem_free(pMac->dumpTableEntry[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 }
186
187 return eSIR_SUCCESS;
188}
189
190/** -------------------------------------------------------------
191\fn macOpen
192\brief this function will be called during init. This function is suppose to allocate all the
193\ memory with the global context will be allocated here.
194\param tHalHandle pHalHandle
195\param tHddHandle hHdd
196\param tHalOpenParameters* pHalOpenParams
197\return tSirRetStatus
198 -------------------------------------------------------------*/
199
200tSirRetStatus macOpen(tHalHandle *pHalHandle, tHddHandle hHdd, tMacOpenParameters *pMacOpenParms)
201{
202 tpAniSirGlobal pMac = NULL;
203
204 if(pHalHandle == NULL)
205 return eSIR_FAILURE;
206
207 /*
Jeff Johnsona8a1a482012-12-12 16:49:33 -0800208 * Make sure this adapter is not already opened. (Compare pAdapter pointer in already
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 * allocated pMac structures.)
210 * If it is opened just return pointer to previously allocated pMac pointer.
211 * Or should this result in error?
212 */
213
214 /* Allocate pMac */
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530215 pMac = vos_mem_malloc(sizeof(tAniSirGlobal));
216 if ( NULL == pMac )
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 return eSIR_FAILURE;
218
219 /* Initialize the pMac structure */
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530220 vos_mem_set(pMac, sizeof(tAniSirGlobal), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700221
222 /** Store the Driver type in pMac Global.*/
223 //pMac->gDriverType = pMacOpenParms->driverType;
224
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 /*
226 * Set various global fields of pMac here
227 * (Could be platform dependant as some variables in pMac are platform
228 * dependant)
229 */
230 pMac->hHdd = hHdd;
231 pMac->pAdapter = hHdd; //This line wil be removed
232 *pHalHandle = (tHalHandle)pMac;
233
234 {
235 /* Call various PE (and other layer init here) */
Jeff Johnson43971f52012-07-17 12:26:56 -0700236 if( eSIR_SUCCESS != logInit(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 return eSIR_FAILURE;
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800238
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 /* Call routine to initialize CFG data structures */
240 if( eSIR_SUCCESS != cfgInit(pMac) )
241 return eSIR_FAILURE;
242
243 sysInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 }
245
Jeff Johnson295189b2012-06-20 16:38:30 -0700246
247 return peOpen(pMac, pMacOpenParms);
248}
249
250/** -------------------------------------------------------------
251\fn macClose
252\brief this function will be called in shutdown sequence from HDD. All the
253\ allocated memory with global context will be freed here.
254\param tpAniSirGlobal pMac
255\return none
256 -------------------------------------------------------------*/
257
258tSirRetStatus macClose(tHalHandle hHal)
259{
260
261 tpAniSirGlobal pMac = (tpAniSirGlobal) hHal;
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 peClose(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700264
265 /* Call routine to free-up all CFG data structures */
266 cfgDeInit(pMac);
267
268 logDeinit(pMac);
269
270 // Finally, de-allocate the global MAC datastructure:
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530271 vos_mem_free( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273 return eSIR_SUCCESS;
274}
275
276/** -------------------------------------------------------------
277\fn macReset
278\brief this function is called to send Reset message to HDD. Then HDD will start the reset process.
279\param tpAniSirGlobal pMac
280\param tANI_U32 rc
281\return tSirRetStatus.
282 -------------------------------------------------------------*/
283
284tSirRetStatus macReset(tpAniSirGlobal pMac, tANI_U32 rc)
285{
286 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 sysLog(pMac, LOGE, FL("*************No-op. Need to call WDA reset function \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 return status;
289}
290
291// ----------------------------------------------------------------------
292/**
293 * macSysResetReq
294 *
295 * FUNCTION:
296 * All MAC modules use this interface in case of an exception.
297 *
298 * LOGIC:
299 *
300 * ASSUMPTIONS:
301 *
302 *
303 * NOTE:
304 *
305 * @param tpAniSirGlobal MAC parameters structure
306 * @param tANI_U32 reset reason code
307 * @return tANI_U16 - returs the status.
308 */
309
310void
311macSysResetReq(tpAniSirGlobal pMac, tANI_U32 rc)
312{
313 sysLog(pMac, LOGE, FL("Reason Code = 0x%X\n"),rc);
314
315 switch (rc)
316 {
317 case eSIR_STOP_BSS:
318 case eSIR_SME_BSS_RESTART:
319 case eSIR_RADIO_HW_SWITCH_STATUS_IS_OFF:
320 case eSIR_CFB_FLAG_STUCK_EXCEPTION:
321 // FIXME
322 //macReset(pMac, rc);
323 break;
324
325 case eSIR_EOF_SOF_EXCEPTION:
326 case eSIR_BMU_EXCEPTION:
327 case eSIR_CP_EXCEPTION:
328 case eSIR_LOW_PDU_EXCEPTION:
329 case eSIR_USER_TRIG_RESET:
330 case eSIR_AHB_HANG_EXCEPTION:
331 default:
332 macReset(pMac, rc);
333 break;
334
335 }
336}
337
338// -------------------------------------------------------------
339/**
340 * macSysResetReqFromHDD
341 *
342 * FUNCTION:
343 * This reset function gets invoked from the HDD to request a reset.
344 *
345 * LOGIC:
346 *
347 * ASSUMPTIONS:
348 *
349 *
350 * NOTE:
351 *
352 * @param tpAniSirGlobal MAC parameters structure
353 * @return tANI_U16 - returs the status.
354 */
355
356void
357macSysResetReqFromHDD(void *pMac, tANI_U32 rc)
358{
359 macSysResetReq( (tpAniSirGlobal)pMac, rc );
360}
361