blob: 463ea211f8bf2b37f4846d3d55f9e6c990c26b80 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. 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
22/******************************************************************************
23*
24* Name: pmcLogDump.c
25*
26* Description: Implements the dump commands specific to PMC module
27*
28* Copyright 2008 (c) Qualcomm, Incorporated.
29* All Rights Reserved.
30* Qualcomm Confidential and Proprietary.
31*
32******************************************************************************/
33
34#include "palTypes.h"
35#include "aniGlobal.h"
36#include "pmcApi.h"
37#include "pmc.h"
38#include "logDump.h"
39#include "smsDebug.h"
40#include "sme_Api.h"
41#include "cfgApi.h"
42
43#if defined(ANI_LOGDUMP)
44
45void dump_pmc_callbackRoutine (void *callbackContext, eHalStatus status)
46{
47 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
48 smsLog(pMac, LOGW, "*********Received callback from PMC with status = %d\n*********",status);
49}
50
51#ifdef WLAN_WAKEUP_EVENTS
52void dump_pmc_callbackRoutine2 (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd)
53{
54 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
55 smsLog(pMac, LOGW, "*********Received callback from PMC with reason = %d\n*********",pWakeReasonInd->ulReason);
56}
57#endif // WLAN_WAKEUP_EVENTS
58
59void dump_pmc_deviceUpdateRoutine (void *callbackContext, tPmcState pmcState)
60{
61 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
62 smsLog(pMac, LOGW, "*********Received msg from PMC: Device is in %s state\n*********", pmcGetPmcStateStr(pmcState));
63}
64
65static char *
66dump_pmc_state( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
67{
68 char *ptr = p;
69
70 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
71
72 p += log_sprintf( pMac,p, "******** PMC State & Configuration ******** \n");
73 p += log_sprintf( pMac,p, " PMC: IMPS Enabled? %d\n", pMac->pmc.impsEnabled);
74 p += log_sprintf( pMac,p, " PMC: Auto BMPS Timer Enabled? %d\n", pMac->pmc.autoBmpsEntryEnabled);
75 p += log_sprintf( pMac,p, " PMC: BMPS Enabled? %d\n", pMac->pmc.bmpsEnabled);
76 p += log_sprintf( pMac,p, " PMC: UAPSD Enabled? %d\n", pMac->pmc.uapsdEnabled);
77 p += log_sprintf( pMac,p, " PMC: WoWL Enabled? %d\n", pMac->pmc.wowlEnabled);
78 p += log_sprintf( pMac,p, " PMC: Standby Enabled? %d\n", pMac->pmc.standbyEnabled);
79 p += log_sprintf( pMac,p, " PMC: Auto BMPS timer period (ms): %d\n", pMac->pmc.bmpsConfig.trafficMeasurePeriod);
80 p += log_sprintf( pMac,p, " PMC: BMPS Listen Interval (Beacon intervals): %d\n", pMac->pmc.bmpsConfig.bmpsPeriod);
81 p += log_sprintf( pMac,p, " PMC: Device State = %s\n", pmcGetPmcStateStr(pMac->pmc.pmcState));
82 p += log_sprintf( pMac,p, " PMC: RequestFullPowerPending = %d\n", pMac->pmc.requestFullPowerPending);
83 p += log_sprintf( pMac,p, " PMC: UapsdSessionRequired = %d\n", pMac->pmc.uapsdSessionRequired);
84 p += log_sprintf( pMac,p, " PMC: wowlModeRequired = %d\n\n", pMac->pmc.wowlModeRequired);
85
86 smsLog(pMac, LOGW, "\n%s", ptr);
87
88 return p;
89}
90
91static char *
92dump_pmc_enable_imps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
93{
94 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
95 (void)pmcEnablePowerSave(pMac, ePMC_IDLE_MODE_POWER_SAVE);
96 return p;
97}
98
99static char *
100dump_pmc_disable_imps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
101{
102 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
103 (void)pmcDisablePowerSave(pMac, ePMC_IDLE_MODE_POWER_SAVE);
104 return p;
105}
106
107static char *
108dump_pmc_request_imps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
109{
110 (void) arg2; (void) arg3; (void) arg4;
111 pMac->pmc.impsEnabled = TRUE;
112 (void)pmcRequestImps(pMac, arg1, dump_pmc_callbackRoutine, pMac);
113 return p;
114}
115
116static char *
117dump_pmc_start_auto_bmps_timer( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
118{
119 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
120 pMac->pmc.bmpsEnabled = TRUE;
121 (void)pmcStartAutoBmpsTimer(pMac);
122 return p;
123}
124
125static char *
126dump_pmc_stop_auto_bmps_timer( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
127{
128 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
129 (void)pmcStopAutoBmpsTimer(pMac);
130 return p;
131}
132
133static char *
134dump_pmc_enable_bmps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
135{
136 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
137 (void)pmcEnablePowerSave(pMac, ePMC_BEACON_MODE_POWER_SAVE);
138 return p;
139}
140
141static char *
142dump_pmc_disable_bmps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
143{
144 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
145 (void)pmcDisablePowerSave(pMac, ePMC_BEACON_MODE_POWER_SAVE);
146 return p;
147}
148
149static char *
150dump_pmc_request_bmps( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
151{
152 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
153 pMac->pmc.bmpsEnabled = TRUE;
154 (void)sme_RequestBmps(pMac, dump_pmc_callbackRoutine, pMac);
155 return p;
156}
157
158static char *
159dump_pmc_enable_uapsd( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
160{
161 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
162 (void)pmcEnablePowerSave(pMac, ePMC_UAPSD_MODE_POWER_SAVE);
163 return p;
164}
165
166static char *
167dump_pmc_disable_uapsd( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
168{
169 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
170 (void)pmcDisablePowerSave(pMac, ePMC_UAPSD_MODE_POWER_SAVE);
171 return p;
172}
173
174static char *
175dump_pmc_start_uapsd( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
176{
177 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
178 pMac->pmc.bmpsEnabled = TRUE;
179 pMac->pmc.uapsdEnabled = TRUE;
180 (void)pmcStartUapsd(pMac, dump_pmc_callbackRoutine, pMac);
181 return p;
182}
183
184static char *
185dump_pmc_stop_uapsd( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
186{
187 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
188 (void)pmcStopUapsd(pMac);
189 return p;
190}
191
192static char *
193dump_pmc_request_standby( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
194{
195 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
196 pMac->pmc.standbyEnabled = TRUE;
197 (void)pmcRequestStandby(pMac, dump_pmc_callbackRoutine, pMac);
198 return p;
199}
200
201static char *
202dump_pmc_request_full_power( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
203{
204 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
205 (void)sme_RequestFullPower(pMac, dump_pmc_callbackRoutine, pMac, eSME_FULL_PWR_NEEDED_BY_HDD);
206 return p;
207}
208
209static char *
210dump_pmc_enter_wowl( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
211{
212 tSirSmeWowlEnterParams wowlEnterParams;
213 tSirRetStatus status;
214 tANI_U32 length;
215 (void) arg3; (void) arg4;
216
217 palZeroMemory(pMac->hHdd, &wowlEnterParams, sizeof(tSirSmeWowlEnterParams));
218
219 if (arg1 == 0 && arg2 == 0)
220 {
221 smsLog(pMac, LOGE, "Requesting WoWL but neither magic pkt and ptrn byte matching is being enabled\n");
222 return p;
223 }
224 if(arg1 == 1)
225 {
226 wowlEnterParams.ucMagicPktEnable = 1;
227 /* magic packet */
228 length = SIR_MAC_ADDR_LENGTH;
229 status = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *)wowlEnterParams.magicPtrn, &length);
230 if (eSIR_SUCCESS != status)
231 {
232 smsLog(pMac, LOGE, "Reading of WNI_CFG_STA_ID from CFG failed. Using hardcoded STA MAC Addr\n");
233 wowlEnterParams.magicPtrn[0] = 0x00;
234 wowlEnterParams.magicPtrn[1] = 0x0a;
235 wowlEnterParams.magicPtrn[2] = 0xf5;
236 wowlEnterParams.magicPtrn[3] = 0x04;
237 wowlEnterParams.magicPtrn[4] = 0x05;
238 wowlEnterParams.magicPtrn[5] = 0x06;
239 }
240 }
241 if(arg2 == 1)
242 {
243 wowlEnterParams.ucPatternFilteringEnable = 1;
244 }
245
246 pMac->pmc.bmpsEnabled = TRUE;
247 pMac->pmc.wowlEnabled = TRUE;
248#ifdef WLAN_WAKEUP_EVENTS
249 (void)sme_EnterWowl(pMac, dump_pmc_callbackRoutine, pMac, dump_pmc_callbackRoutine2, pMac, &wowlEnterParams);
250#else // WLAN_WAKEUP_EVENTS
251 (void)sme_EnterWowl(pMac, dump_pmc_callbackRoutine, pMac, &wowlEnterParams);
252#endif // WLAN_WAKEUP_EVENTS
253 return p;
254}
255
256static char *
257dump_pmc_exit_wowl( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
258{
259 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
260 (void)sme_ExitWowl(pMac);
261 return p;
262}
263
264static char *
265dump_pmc_remove_ptrn( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
266{
267 tSirWowlDelBcastPtrn delPattern;
268 (void) arg2; (void) arg3; (void) arg4;
269
270 palZeroMemory(pMac->hHdd, &delPattern, sizeof(tSirWowlDelBcastPtrn));
271
272 if(arg1 <= 7)
273 {
274 delPattern.ucPatternId = (tANI_U8)arg1;
275 }
276 else
277 {
278 smsLog(pMac, LOGE, "dump_pmc_remove_ptrn: Invalid pattern Id %d\n",arg1);
279 return p;
280 }
281
282 (void)pmcWowlDelBcastPattern(pMac, &delPattern);
283 return p;
284}
285
286static char *
287dump_pmc_test_uapsd( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
288{
289 tSirSmeRsp smeRsp;
290 smeRsp.statusCode = eSIR_SME_SUCCESS;
291
292 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
293
294 pMac->pmc.uapsdEnabled = TRUE;
295 pMac->pmc.pmcState = BMPS;
296
297 pmcRegisterDeviceStateUpdateInd(pMac, dump_pmc_deviceUpdateRoutine, pMac);
298
299 pmcStartUapsd(pMac, dump_pmc_callbackRoutine, pMac);
300 smeRsp.messageType = eWNI_PMC_ENTER_UAPSD_RSP;
301 pmcMessageProcessor(pMac, &smeRsp);
302 pmcStopUapsd(pMac);
303 smeRsp.messageType = eWNI_PMC_EXIT_UAPSD_RSP;
304 pmcMessageProcessor(pMac, &smeRsp);
305 pmcDeregisterDeviceStateUpdateInd(pMac, dump_pmc_deviceUpdateRoutine);
306 return p;
307}
308
309static char *
310dump_pmc_test_Wowl( tpAniSirGlobal pMac, tANI_U32 arg1, tANI_U32 arg2, tANI_U32 arg3, tANI_U32 arg4, char *p)
311{
312 tSirSmeRsp smeRsp;
313 tSirWowlAddBcastPtrn addPattern;
314 tSirWowlDelBcastPtrn delPattern;
315 tSirSmeWowlEnterParams wowlEnterParams;
316
317 smeRsp.statusCode = eSIR_SME_SUCCESS;
318 palZeroMemory(pMac->hHdd, &addPattern, sizeof(tSirWowlAddBcastPtrn));
319 palZeroMemory(pMac->hHdd, &delPattern, sizeof(tSirWowlDelBcastPtrn));
320 palZeroMemory(pMac->hHdd, &wowlEnterParams, sizeof(tSirSmeWowlEnterParams));
321
322 (void) arg1; (void) arg2; (void) arg3; (void) arg4;
323
324 //Add pattern
325 sme_WowlAddBcastPattern(pMac, &addPattern);
326
327 //Delete pattern
328 sme_WowlDelBcastPattern(pMac, &delPattern);
329
330 //Force the device into BMPS
331 pMac->pmc.pmcState = BMPS;
332
333 //Enter Wowl
334#ifdef WLAN_WAKEUP_EVENTS
335 sme_EnterWowl(pMac, dump_pmc_callbackRoutine, pMac, dump_pmc_callbackRoutine2, pMac, &wowlEnterParams);
336#else // WLAN_WAKEUP_EVENTS
337 sme_EnterWowl(pMac, dump_pmc_callbackRoutine, pMac, &wowlEnterParams);
338#endif // WLAN_WAKEUP_EVENTS
339 smeRsp.messageType = eWNI_PMC_ENTER_WOWL_RSP;
340 pmcMessageProcessor(pMac, &smeRsp);
341
342 //Exit Wowl
343 sme_ExitWowl(pMac);
344 smeRsp.messageType = eWNI_PMC_EXIT_WOWL_RSP;
345 pmcMessageProcessor(pMac, &smeRsp);
346 return p;
347}
348
349static tDumpFuncEntry pmcMenuDumpTable[] = {
350 {0, "PMC (900-925)", NULL},
351 // General
352 {900, "PMC: Dump State + config", dump_pmc_state},
353 // IMPS Related
354 {901, "PMC: Enable IMPS", dump_pmc_enable_imps},
355 {902, "PMC: Disable IMPS", dump_pmc_disable_imps},
356 {903, "PMC: Request IMPS: Syntax: dump 903 <imps_period_ms>", dump_pmc_request_imps},
357 // BMPS Related
358 {904, "PMC: Start Auto BMPS Timer", dump_pmc_start_auto_bmps_timer},
359 {905, "PMC: Stop Auto BMPS Timer", dump_pmc_stop_auto_bmps_timer},
360 {906, "PMC: Request BMPS", dump_pmc_request_bmps},
361 // UAPSD Related
362 {907, "PMC: Enable UAPSD", dump_pmc_enable_uapsd},
363 {908, "PMC: Disable UAPSD", dump_pmc_disable_uapsd},
364 {909, "PMC: Start UAPSD", dump_pmc_start_uapsd},
365 {910, "PMC: Stop UAPSD", dump_pmc_stop_uapsd},
366 // Standby Related
367 {911, "PMC: Request Standby", dump_pmc_request_standby},
368 // Full Power Related
369 {912, "PMC: Request Full Power", dump_pmc_request_full_power},
370 //Unit Test Related
371 {913, "PMC: Test UAPSD", dump_pmc_test_uapsd},
372 {914, "PMC: Test WOWL", dump_pmc_test_Wowl},
373 // WoWL Related
374 {915, "PMC: Enter WoWL: Syntax: dump 915 <enable_magic_pkt> <enable_ptrn_match>", dump_pmc_enter_wowl},
375 {916, "PMC: Exit WoWL", dump_pmc_exit_wowl},
376 {917, "PMC: Remove a pattern: Syntax: dump 917 <pattern_id(0-7)>", dump_pmc_remove_ptrn},
377 {918, "PMC: Enable BMPS", dump_pmc_enable_bmps},
378 {919, "PMC: Disable BMPS", dump_pmc_disable_bmps}
379};
380
381void pmcDumpInit(tHalHandle hHal)
382{
383 logDumpRegisterTable( (tpAniSirGlobal)hHal, &pmcMenuDumpTable[0],
384 sizeof(pmcMenuDumpTable)/sizeof(pmcMenuDumpTable[0]) );
385}
386
387#endif //#if defined(ANI_LOGDUMP)