blob: 13ea1271cf6a6f01b6d34858454f3c38c9ba7152 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*============================================================================
7 * @file wlan_hdd_wowl.c
8 *
9 * Copyright (c) 2009 QUALCOMM Incorporated.
10 * All Rights Reserved.
11 * Qualcomm Confidential and Proprietary
12 *
13 * ==========================================================================*/
14
15/*----------------------------------------------------------------------------
16 * Include Files
17 * -------------------------------------------------------------------------*/
18
19#include <wlan_hdd_includes.h>
20#include <wlan_hdd_wowl.h>
21
22/*----------------------------------------------------------------------------
23 * Preprocessor Definitions and Constants
24 * -------------------------------------------------------------------------*/
25
26#define WOWL_PTRN_MAX_SIZE 128
27#define WOWL_PTRN_MASK_MAX_SIZE 16
Yue Ma0d4891e2013-08-06 17:01:45 -070028#define WOWL_MAX_PTRNS_ALLOWED 16
Jeff Johnson295189b2012-06-20 16:38:30 -070029#define WOWL_INTER_PTRN_TOKENIZER ';'
30#define WOWL_INTRA_PTRN_TOKENIZER ':'
31
32/*----------------------------------------------------------------------------
33 * Type Declarations
34 * -------------------------------------------------------------------------*/
35
Yue Ma0d4891e2013-08-06 17:01:45 -070036static char *g_hdd_wowl_ptrns[WOWL_MAX_PTRNS_ALLOWED]; //Patterns 0-15
37static v_BOOL_t g_hdd_wowl_ptrns_debugfs[WOWL_MAX_PTRNS_ALLOWED] = {0};
38static v_U8_t g_hdd_wowl_ptrns_count = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070039
Srinivas Girigowda100eb322013-03-15 16:48:20 -070040int hdd_parse_hex(unsigned char c)
Jeff Johnson295189b2012-06-20 16:38:30 -070041{
42 if (c >= '0' && c <= '9')
43 return c-'0';
44 if (c >= 'a' && c <= 'f')
45 return c-'a'+10;
46 if (c >= 'A' && c <= 'F')
47 return c-'A'+10;
48
49 return 0;
50}
51
52static inline int find_ptrn_len(const char* ptrn)
53{
54 int len = 0;
55 while (*ptrn != '\0' && *ptrn != WOWL_INTER_PTRN_TOKENIZER)
56 {
57 len++; ptrn++;
58 }
59 return len;
60}
61
62static void hdd_wowl_callback( void *pContext, eHalStatus halStatus )
63{
Kumar Anandaca924e2013-07-22 14:35:34 -070064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080065 "%s: Return code = (%d)", __func__, halStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -070066}
67
Kumar Anandaca924e2013-07-22 14:35:34 -070068#ifdef WLAN_WAKEUP_EVENTS
69static void hdd_wowl_wakeIndication_callback( void *pContext,
70 tpSirWakeReasonInd pWakeReasonInd )
71{
72 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Wake Reason %d",
73 __func__, pWakeReasonInd->ulReason );
74 hdd_exit_wowl((hdd_adapter_t *)pContext);
75}
76#endif
77
Jeff Johnson295189b2012-06-20 16:38:30 -070078static void dump_hdd_wowl_ptrn(tSirWowlAddBcastPtrn *ptrn)
79{
80 int i;
81
82 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ucPatetrnId = 0x%x", __func__,
83 ptrn->ucPatternId);
84 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ucPatternByteOffset = 0x%x", __func__,
85 ptrn->ucPatternByteOffset);
86 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ucPatternSize = 0x%x", __func__,
87 ptrn->ucPatternSize);
88 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ucPatternMaskSize = 0x%x", __func__,
89 ptrn->ucPatternMaskSize);
90 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Pattern: ", __func__);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080091 for(i = 0; i < ptrn->ucPatternSize; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO," %02X", ptrn->ucPattern[i]);
93 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: PatternMask: ", __func__);
94 for(i = 0; i<ptrn->ucPatternMaskSize; i++)
95 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%02X", ptrn->ucPatternMask[i]);
96}
97
98
99/**============================================================================
100 @brief hdd_add_wowl_ptrn() - Function which will add the WoWL pattern to be
101 used when PBM filtering is enabled
102
103 @param ptrn : [in] pointer to the pattern string to be added
104
105 @return : FALSE if any errors encountered
106 : TRUE otherwise
107 ===========================================================================*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700108v_BOOL_t hdd_add_wowl_ptrn (hdd_adapter_t *pAdapter, const char * ptrn)
Jeff Johnson295189b2012-06-20 16:38:30 -0700109{
110 tSirWowlAddBcastPtrn localPattern;
111 int i, first_empty_slot, len, offset;
112 eHalStatus halStatus;
113 const char *temp;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
115 v_U8_t sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117 len = find_ptrn_len(ptrn);
118
119 /* There has to have atleast 1 byte for each field (pattern size, mask size,
120 * pattern, mask) e.g. PP:QQ:RR:SS ==> 11 chars */
121 while ( len >= 11 )
122 {
123 first_empty_slot = -1;
124
125 // Find an empty slot to store the pattern
126 for (i=0; i<WOWL_MAX_PTRNS_ALLOWED; i++)
127 {
128 if(g_hdd_wowl_ptrns[i] == NULL) {
129 first_empty_slot = i;
130 break;
131 }
132 }
133
134 // Maximum number of patterns have been configured already
135 if(first_empty_slot == -1)
136 {
137 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700138 "%s: Cannot add anymore patterns. No free slot!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 return VOS_FALSE;
140 }
141
142 // Detect duplicate pattern
143 for (i=0; i<WOWL_MAX_PTRNS_ALLOWED; i++)
144 {
145 if(g_hdd_wowl_ptrns[i] == NULL) continue;
146
147 if(!memcmp(ptrn, g_hdd_wowl_ptrns[i], len))
148 {
149 // Pattern Already configured, skip to next pattern
150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
151 "Trying to add duplicate WoWL pattern. Skip it!");
152 ptrn += len;
153 goto next_ptrn;
154 }
155 }
156
157 //Validate the pattern
158 if(ptrn[2] != WOWL_INTRA_PTRN_TOKENIZER ||
159 ptrn[5] != WOWL_INTRA_PTRN_TOKENIZER)
160 {
161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800162 "%s: Malformed pattern string. Skip!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 ptrn += len;
164 goto next_ptrn;
165 }
166
167 // Extract the pattern size
168 localPattern.ucPatternSize =
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700169 ( hdd_parse_hex( ptrn[0] ) * 0x10 ) + hdd_parse_hex( ptrn[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -0700170
171 // Extract the pattern mask size
172 localPattern.ucPatternMaskSize =
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700173 ( hdd_parse_hex( ptrn[3] ) * 0x10 ) + hdd_parse_hex( ptrn[4] );
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800175 if(localPattern.ucPatternSize > SIR_WOWL_BCAST_PATTERN_MAX_SIZE ||
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 localPattern.ucPatternMaskSize > WOWL_PTRN_MASK_MAX_SIZE)
177 {
178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800179 "%s: Invalid length specified. Skip!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 ptrn += len;
181 goto next_ptrn;
182 }
183
184 //compute the offset of tokenizer after the pattern
185 offset = 5 + 2*localPattern.ucPatternSize + 1;
186 if(offset >= len || ptrn[offset] != WOWL_INTRA_PTRN_TOKENIZER)
187 {
188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800189 "%s: Malformed pattern string..skip!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 ptrn += len;
191 goto next_ptrn;
192 }
193
194 //compute the end of pattern sring
195 offset = offset + 2*localPattern.ucPatternMaskSize;
196 if(offset+1 != len) //offset begins with 0
197 {
198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800199 "%s: Malformed pattern string...skip!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 ptrn += len;
201 goto next_ptrn;
202 }
203
204 temp = ptrn;
205
206 // Now advance to where pattern begins
207 ptrn += 6;
208
209 // Extract the pattern
210 for(i=0; i < localPattern.ucPatternSize; i++)
211 {
212 localPattern.ucPattern[i] =
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700213 (hdd_parse_hex( ptrn[0] ) * 0x10 ) + hdd_parse_hex( ptrn[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 ptrn += 2; //skip to next byte
215 }
216
217 ptrn++; // Skip over the ':' seperator after the pattern
218
219 // Extract the pattern Mask
220 for(i=0; i < localPattern.ucPatternMaskSize; i++)
221 {
222 localPattern.ucPatternMask[i] =
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700223 (hdd_parse_hex( ptrn[0] ) * 0x10 ) + hdd_parse_hex( ptrn[1] );
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 ptrn += 2; //skip to next byte
225 }
226
227 //All is good. Store the pattern locally
228 g_hdd_wowl_ptrns[first_empty_slot] = (char*) kmalloc(len+1, GFP_KERNEL);
229 if(g_hdd_wowl_ptrns[first_empty_slot] == NULL)
230 {
231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700232 "%s: kmalloc failure", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 return VOS_FALSE;
234 }
235
236 memcpy(g_hdd_wowl_ptrns[first_empty_slot], temp, len);
237 g_hdd_wowl_ptrns[first_empty_slot][len] = '\0';
238 localPattern.ucPatternId = first_empty_slot;
239 localPattern.ucPatternByteOffset = 0;
240
241 // Register the pattern downstream
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700242 halStatus = sme_WowlAddBcastPattern( hHal, &localPattern, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 if ( !HAL_STATUS_SUCCESS( halStatus ) )
244 {
245 // Add failed, so invalidate the local storage
246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700247 "sme_WowlAddBcastPattern failed with error code (%d)", halStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 kfree(g_hdd_wowl_ptrns[first_empty_slot]);
249 g_hdd_wowl_ptrns[first_empty_slot] = NULL;
250 }
251
252 dump_hdd_wowl_ptrn(&localPattern);
253
254 next_ptrn:
255 if (*ptrn == WOWL_INTER_PTRN_TOKENIZER)
256 {
257 ptrn += 1; // move past the tokenizer
258 len = find_ptrn_len(ptrn);
259 continue;
260 }
261 else
262 break;
263 }
264
265 return VOS_TRUE;
266}
267
268/**============================================================================
269 @brief hdd_del_wowl_ptrn() - Function which will remove a WoWL pattern
270
271 @param ptrn : [in] pointer to the pattern string to be removed
272
273 @return : FALSE if any errors encountered
274 : TRUE otherwise
275 ===========================================================================*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700276v_BOOL_t hdd_del_wowl_ptrn (hdd_adapter_t *pAdapter, const char * ptrn)
Jeff Johnson295189b2012-06-20 16:38:30 -0700277{
278 tSirWowlDelBcastPtrn delPattern;
279 unsigned char id;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700280 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 v_BOOL_t patternFound = VOS_FALSE;
282 eHalStatus halStatus;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700283 v_U8_t sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285 // Detect pattern
286 for (id=0; id<WOWL_MAX_PTRNS_ALLOWED && g_hdd_wowl_ptrns[id] != NULL; id++)
287 {
288 if(!strcmp(ptrn, g_hdd_wowl_ptrns[id]))
289 {
290 patternFound = VOS_TRUE;
291 break;
292 }
293 }
294
295 // If pattern present, remove it from downstream
296 if(patternFound)
297 {
298 delPattern.ucPatternId = id;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700299 halStatus = sme_WowlDelBcastPattern( hHal, &delPattern, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 if ( HAL_STATUS_SUCCESS( halStatus ) )
301 {
302 // Remove from local storage as well
303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
304 "Deleted pattern with id %d [%s]", id, g_hdd_wowl_ptrns[id]);
305
306 kfree(g_hdd_wowl_ptrns[id]);
307 g_hdd_wowl_ptrns[id] = NULL;
308 return VOS_TRUE;
309 }
310 }
311 return VOS_FALSE;
312}
313
314/**============================================================================
Yue Ma0d4891e2013-08-06 17:01:45 -0700315 @brief hdd_add_wowl_ptrn_debugfs() - Function which will add a WoW pattern
Yue Maddad6a72013-11-19 12:40:59 -0800316 sent from debugfs interface
Yue Ma0d4891e2013-08-06 17:01:45 -0700317
318 @param pAdapter : [in] pointer to the adapter
319 pattern_idx : [in] index of the pattern to be added
320 pattern_offset : [in] offset of the pattern in the frame payload
321 pattern_buf : [in] pointer to the pattern hex string to be added
Yue Maddad6a72013-11-19 12:40:59 -0800322 pattern_mask : [in] pointer to the pattern mask hex string
Yue Ma0d4891e2013-08-06 17:01:45 -0700323
324 @return : FALSE if any errors encountered
325 : TRUE otherwise
326 ===========================================================================*/
327v_BOOL_t hdd_add_wowl_ptrn_debugfs(hdd_adapter_t *pAdapter, v_U8_t pattern_idx,
Yue Maddad6a72013-11-19 12:40:59 -0800328 v_U8_t pattern_offset, char *pattern_buf,
329 char *pattern_mask)
Yue Ma0d4891e2013-08-06 17:01:45 -0700330{
331 tSirWowlAddBcastPtrn localPattern;
332 eHalStatus halStatus;
333 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
334 v_U8_t sessionId = pAdapter->sessionId;
Yue Maddad6a72013-11-19 12:40:59 -0800335 v_U16_t pattern_len, mask_len, i;
Yue Ma0d4891e2013-08-06 17:01:45 -0700336
337 if (pattern_idx > (WOWL_MAX_PTRNS_ALLOWED - 1))
338 {
339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
340 "%s: WoW pattern index %d is out of range (0 ~ %d).",
341 __func__, pattern_idx, WOWL_MAX_PTRNS_ALLOWED - 1);
342
343 return VOS_FALSE;
344 }
345
346 pattern_len = strlen(pattern_buf);
347
348 /* Since the pattern is a hex string, 2 characters represent 1 byte. */
349 if (pattern_len % 2)
350 {
351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
352 "%s: Malformed WoW pattern!", __func__);
353
354 return VOS_FALSE;
355 }
356 else
357 pattern_len >>= 1;
358
359 if (!pattern_len || pattern_len > WOWL_PTRN_MAX_SIZE)
360 {
361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
362 "%s: WoW pattern length %d is out of range (1 ~ %d).",
363 __func__, pattern_len, WOWL_PTRN_MAX_SIZE);
364
365 return VOS_FALSE;
366 }
367
368 localPattern.ucPatternId = pattern_idx;
369 localPattern.ucPatternByteOffset = pattern_offset;
370 localPattern.ucPatternSize = pattern_len;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800371 if (localPattern.ucPatternSize > SIR_WOWL_BCAST_PATTERN_MAX_SIZE) {
372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
373 "%s: WoW pattern size (%d) greater than max (%d)",
374 __func__, localPattern.ucPatternSize,
375 SIR_WOWL_BCAST_PATTERN_MAX_SIZE);
376 return VOS_FALSE;
377 }
Yue Ma0d4891e2013-08-06 17:01:45 -0700378 /* Extract the pattern */
379 for (i = 0; i < localPattern.ucPatternSize; i++)
380 {
381 localPattern.ucPattern[i] =
382 (hdd_parse_hex(pattern_buf[0]) << 4) + hdd_parse_hex(pattern_buf[1]);
383
384 /* Skip to next byte */
385 pattern_buf += 2;
386 }
387
Yue Maddad6a72013-11-19 12:40:59 -0800388 /* Get pattern mask size by pattern length */
389 localPattern.ucPatternMaskSize = pattern_len >> 3;
Yue Ma0d4891e2013-08-06 17:01:45 -0700390 if (pattern_len % 8)
Yue Ma0d4891e2013-08-06 17:01:45 -0700391 localPattern.ucPatternMaskSize += 1;
Yue Maddad6a72013-11-19 12:40:59 -0800392
393 mask_len = strlen(pattern_mask);
394 if ((mask_len % 2) || (localPattern.ucPatternMaskSize != (mask_len >> 1)))
395 {
396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
397 "%s: Malformed WoW pattern mask!", __func__);
398
399 return VOS_FALSE;
400 }
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800401 if (localPattern.ucPatternMaskSize > WOWL_PTRN_MASK_MAX_SIZE) {
402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
403 "%s: WoW pattern mask size (%d) greater than max (%d)",
404 __func__, localPattern.ucPatternMaskSize, WOWL_PTRN_MASK_MAX_SIZE);
405 return VOS_FALSE;
406 }
Yue Maddad6a72013-11-19 12:40:59 -0800407 /* Extract the pattern mask */
408 for (i = 0; i < localPattern.ucPatternMaskSize; i++)
409 {
410 localPattern.ucPatternMask[i] =
411 (hdd_parse_hex(pattern_mask[0]) << 4) + hdd_parse_hex(pattern_mask[1]);
412
413 /* Skip to next byte */
414 pattern_mask += 2;
Yue Ma0d4891e2013-08-06 17:01:45 -0700415 }
416
417 /* Register the pattern downstream */
418 halStatus = sme_WowlAddBcastPattern(hHal, &localPattern, sessionId);
419
420 if (!HAL_STATUS_SUCCESS(halStatus))
421 {
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700423 "%s: sme_WowlAddBcastPattern failed with error code (%d).",
Yue Ma0d4891e2013-08-06 17:01:45 -0700424 __func__, halStatus);
425
426 return VOS_FALSE;
427 }
428
Yue Ma0d4891e2013-08-06 17:01:45 -0700429 /* All is good. */
430 if (!g_hdd_wowl_ptrns_debugfs[pattern_idx])
431 {
432 g_hdd_wowl_ptrns_debugfs[pattern_idx] = 1;
433 g_hdd_wowl_ptrns_count++;
434 }
435
436 dump_hdd_wowl_ptrn(&localPattern);
437
438 return VOS_TRUE;
439}
440
441/**============================================================================
442 @brief hdd_del_wowl_ptrn_debugfs() - Function which will remove a WoW pattern
Yue Maddad6a72013-11-19 12:40:59 -0800443 sent from debugfs interface
Yue Ma0d4891e2013-08-06 17:01:45 -0700444
445 @param pAdapter : [in] pointer to the adapter
446 pattern_idx : [in] index of the pattern to be removed
447
448 @return : FALSE if any errors encountered
449 : TRUE otherwise
450 ===========================================================================*/
451v_BOOL_t hdd_del_wowl_ptrn_debugfs(hdd_adapter_t *pAdapter, v_U8_t pattern_idx)
452{
453 tSirWowlDelBcastPtrn delPattern;
454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
455 eHalStatus halStatus;
456 v_U8_t sessionId = pAdapter->sessionId;
457
458 if (pattern_idx > (WOWL_MAX_PTRNS_ALLOWED - 1))
459 {
460 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
461 "%s: WoW pattern index %d is not in the range (0 ~ %d).",
462 __func__, pattern_idx, WOWL_MAX_PTRNS_ALLOWED - 1);
463
464 return VOS_FALSE;
465 }
466
467 if (!g_hdd_wowl_ptrns_debugfs[pattern_idx])
468 {
469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
470 "%s: WoW pattern %d is not in the table.",
471 __func__, pattern_idx);
472
473 return VOS_FALSE;
474 }
475
476 delPattern.ucPatternId = pattern_idx;
477 halStatus = sme_WowlDelBcastPattern(hHal, &delPattern, sessionId);
478
479 if (!HAL_STATUS_SUCCESS(halStatus))
480 {
481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700482 "%s: sme_WowlDelBcastPattern failed with error code (%d).",
Yue Ma0d4891e2013-08-06 17:01:45 -0700483 __func__, halStatus);
484
485 return VOS_FALSE;
486 }
487
488 g_hdd_wowl_ptrns_debugfs[pattern_idx] = 0;
489 g_hdd_wowl_ptrns_count--;
490
Yue Ma0d4891e2013-08-06 17:01:45 -0700491 return VOS_TRUE;
492}
493
494/**============================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 @brief hdd_enter_wowl() - Function which will enable WoWL. Atleast one
496 of MP and PBM must be enabled
497
498 @param enable_mp : [in] Whether to enable magic packet WoWL mode
499 @param enable_pbm : [in] Whether to enable pattern byte matching WoWL mode
500
501 @return : FALSE if any errors encountered
502 : TRUE otherwise
503 ===========================================================================*/
504v_BOOL_t hdd_enter_wowl (hdd_adapter_t *pAdapter, v_BOOL_t enable_mp, v_BOOL_t enable_pbm)
505{
506 tSirSmeWowlEnterParams wowParams;
507 eHalStatus halStatus;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700508 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700509
510 wowParams.ucPatternFilteringEnable = enable_pbm;
511 wowParams.ucMagicPktEnable = enable_mp;
512 if(enable_mp)
513 {
514 vos_copy_macaddr( (v_MACADDR_t *)&(wowParams.magicPtrn),
515 &(pAdapter->macAddressCurrent) );
516 }
517
518 // Request to put Libra into WoWL
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700519 halStatus = sme_EnterWowl( hHal, hdd_wowl_callback,
Kumar Anandaca924e2013-07-22 14:35:34 -0700520 pAdapter,
521#ifdef WLAN_WAKEUP_EVENTS
522 hdd_wowl_wakeIndication_callback,
523 pAdapter,
524#endif // WLAN_WAKEUP_EVENTS
525 &wowParams, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700526
527 if ( !HAL_STATUS_SUCCESS( halStatus ) )
528 {
529 if ( eHAL_STATUS_PMC_PENDING != halStatus )
530 {
531 // We failed to enter WoWL
532 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700533 "sme_EnterWowl failed with error code (%d)", halStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 return VOS_FALSE;
535 }
536 }
537 return VOS_TRUE;
538}
539
540/**============================================================================
541 @brief hdd_exit_wowl() - Function which will disable WoWL
542
543 @return : FALSE if any errors encountered
544 : TRUE otherwise
545 ===========================================================================*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700546v_BOOL_t hdd_exit_wowl (hdd_adapter_t*pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700547{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700548 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 eHalStatus halStatus;
550
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700551 halStatus = sme_ExitWowl( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 if ( !HAL_STATUS_SUCCESS( halStatus ) )
553 {
554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700555 "sme_ExitWowl failed with error code (%d)", halStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 return VOS_FALSE;
557 }
558
559 return VOS_TRUE;
560}
561
562/**============================================================================
563 @brief hdd_init_wowl() - Init function which will initialize the WoWL module
564 and perform any required intial configuration
565
566 @return : FALSE if any errors encountered
567 : TRUE otherwise
568 ===========================================================================*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700569v_BOOL_t hdd_init_wowl (hdd_adapter_t*pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700570{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700571 hdd_context_t *pHddCtx = NULL;
572 pHddCtx = pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700573
574 memset(g_hdd_wowl_ptrns, 0, sizeof(g_hdd_wowl_ptrns));
575
576 //Add any statically configured patterns
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700577 hdd_add_wowl_ptrn(pAdapter, pHddCtx->cfg_ini->wowlPattern);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
579 return VOS_TRUE;
580}