blob: 7b8d044a620cf10c1f70a5fc37079c29d0edf8a1 [file] [log] [blame]
Yue Ma0d4891e2013-08-06 17:01:45 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -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.
Yue Ma0d4891e2013-08-06 17:01:45 -070020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Yue Ma0d4891e2013-08-06 17:01:45 -070028#ifdef WLAN_OPEN_SOURCE
29#include <wlan_hdd_includes.h>
30#include <wlan_hdd_wowl.h>
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053031#include <vos_sched.h>
Yue Ma0d4891e2013-08-06 17:01:45 -070032
Yue Maddad6a72013-11-19 12:40:59 -080033#define MAX_USER_COMMAND_SIZE_WOWL_ENABLE 8
Yue Ma0d4891e2013-08-06 17:01:45 -070034#define MAX_USER_COMMAND_SIZE_WOWL_PATTERN 512
Yue Mab9c86f42013-08-14 15:59:08 -070035#define MAX_USER_COMMAND_SIZE_FRAME 4096
Yue Ma0d4891e2013-08-06 17:01:45 -070036
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053037static ssize_t __wcnss_wowenable_write(struct file *file,
Yue Maddad6a72013-11-19 12:40:59 -080038 const char __user *buf, size_t count, loff_t *ppos)
39{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053040 hdd_adapter_t *pAdapter;
41 hdd_context_t *pHddCtx;
Yue Maddad6a72013-11-19 12:40:59 -080042 char cmd[MAX_USER_COMMAND_SIZE_WOWL_ENABLE + 1];
43 char *sptr, *token;
44 v_U8_t wow_enable = 0;
45 v_U8_t wow_mp = 0;
46 v_U8_t wow_pbm = 0;
47
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053048 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Maddad6a72013-11-19 12:40:59 -080049 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
50 {
51 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
52 "%s: Invalid adapter or adapter has invalid magic.",
53 __func__);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053054 return -EINVAL;
55 }
56 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
57 if (0 != wlan_hdd_validate_context(pHddCtx))
58 {
59 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
60 "%s: HDD context is not valid",__func__);
Yue Maddad6a72013-11-19 12:40:59 -080061 return -EINVAL;
62 }
63
64 if (!sme_IsFeatureSupportedByFW(WOW))
65 {
66 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
67 "%s: Wake-on-Wireless feature is not supported "
68 "in firmware!", __func__);
69
70 return -EINVAL;
71 }
72
73 if (count > MAX_USER_COMMAND_SIZE_WOWL_ENABLE)
74 {
75 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
76 "%s: Command length is larger than %d bytes.",
77 __func__, MAX_USER_COMMAND_SIZE_WOWL_ENABLE);
78
79 return -EINVAL;
80 }
81
82 /* Get command from user */
83 if (copy_from_user(cmd, buf, count))
84 return -EFAULT;
85 cmd[count] = '\0';
86 sptr = cmd;
87
88 /* Get enable or disable wow */
89 token = strsep(&sptr, " ");
90 if (!token)
91 return -EINVAL;
92 if (kstrtou8(token, 0, &wow_enable))
93 return -EINVAL;
94
95 /* Disable wow */
96 if (!wow_enable) {
c_hpothu01484c02014-05-16 14:05:15 +053097 if (!hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER))
Yue Maddad6a72013-11-19 12:40:59 -080098 {
99 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
100 "%s: hdd_exit_wowl failed!", __func__);
101
102 return -EFAULT;
103 }
104
105 return count;
106 }
107
108 /* Get enable or disable magic packet mode */
109 token = strsep(&sptr, " ");
110 if (!token)
111 return -EINVAL;
112 if (kstrtou8(token, 0, &wow_mp))
113 return -EINVAL;
114 if (wow_mp > 1)
115 wow_mp = 1;
116
117 /* Get enable or disable pattern byte matching mode */
118 token = strsep(&sptr, " ");
119 if (!token)
120 return -EINVAL;
121 if (kstrtou8(token, 0, &wow_pbm))
122 return -EINVAL;
123 if (wow_pbm > 1)
124 wow_pbm = 1;
125
126 if (!hdd_enter_wowl(pAdapter, wow_mp, wow_pbm))
127 {
128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
129 "%s: hdd_enter_wowl failed!", __func__);
130
131 return -EFAULT;
132 }
133
134 return count;
135}
136
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530137static ssize_t wcnss_wowenable_write(struct file *file,
138 const char __user *buf, size_t count, loff_t *ppos)
139{
140 ssize_t ret;
141
142 vos_ssr_protect(__func__);
143 ret = __wcnss_wowenable_write(file, buf, count, ppos);
144 vos_ssr_unprotect(__func__);
145
146 return ret;
147}
148
149static ssize_t __wcnss_wowpattern_write(struct file *file,
Yue Ma0d4891e2013-08-06 17:01:45 -0700150 const char __user *buf, size_t count, loff_t *ppos)
151{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530152 hdd_adapter_t *pAdapter;
153 hdd_context_t *pHddCtx;
Yue Ma63993e32013-10-21 23:10:53 -0700154 char cmd[MAX_USER_COMMAND_SIZE_WOWL_PATTERN + 1];
Yue Ma0d4891e2013-08-06 17:01:45 -0700155 char *sptr, *token;
156 v_U8_t pattern_idx = 0;
157 v_U8_t pattern_offset = 0;
158 char *pattern_buf;
Yue Maddad6a72013-11-19 12:40:59 -0800159 char *pattern_mask;
Yue Ma0d4891e2013-08-06 17:01:45 -0700160
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530161 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Ma0d4891e2013-08-06 17:01:45 -0700162 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
163 {
164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
165 "%s: Invalid adapter or adapter has invalid magic.",
166 __func__);
167
168 return -EINVAL;
169 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530170 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
171 if (0 != wlan_hdd_validate_context(pHddCtx))
172 {
173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
174 "%s: HDD context is not valid",__func__);
175 return -EINVAL;
176 }
Yue Ma55855df2013-08-26 10:59:03 -0700177 if (!sme_IsFeatureSupportedByFW(WOW))
178 {
179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
180 "%s: Wake-on-Wireless feature is not supported "
181 "in firmware!", __func__);
182
183 return -EINVAL;
184 }
Yue Ma63993e32013-10-21 23:10:53 -0700185
186 if (count > MAX_USER_COMMAND_SIZE_WOWL_PATTERN)
Yue Ma0d4891e2013-08-06 17:01:45 -0700187 {
188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
189 "%s: Command length is larger than %d bytes.",
190 __func__, MAX_USER_COMMAND_SIZE_WOWL_PATTERN);
191
192 return -EINVAL;
193 }
194
195 /* Get command from user */
196 if (copy_from_user(cmd, buf, count))
197 return -EFAULT;
198 cmd[count] = '\0';
199 sptr = cmd;
200
201 /* Get pattern idx */
202 token = strsep(&sptr, " ");
203 if (!token)
204 return -EINVAL;
205
206 if (kstrtou8(token, 0, &pattern_idx))
207 return -EINVAL;
208
209 /* Get pattern offset */
210 token = strsep(&sptr, " ");
211
212 /* Delete pattern if no further argument */
213 if (!token) {
214 hdd_del_wowl_ptrn_debugfs(pAdapter, pattern_idx);
215
216 return count;
217 }
218
219 if (kstrtou8(token, 0, &pattern_offset))
220 return -EINVAL;
221
222 /* Get pattern */
223 token = strsep(&sptr, " ");
224 if (!token)
225 return -EINVAL;
226
227 pattern_buf = token;
Yue Maddad6a72013-11-19 12:40:59 -0800228
229 /* Get pattern mask */
230 token = strsep(&sptr, " ");
231 if (!token)
232 return -EINVAL;
233
234 pattern_mask = token;
235 pattern_mask[strlen(pattern_mask) - 1] = '\0';
Yue Ma0d4891e2013-08-06 17:01:45 -0700236
237 hdd_add_wowl_ptrn_debugfs(pAdapter, pattern_idx, pattern_offset,
Yue Maddad6a72013-11-19 12:40:59 -0800238 pattern_buf, pattern_mask);
Yue Ma0d4891e2013-08-06 17:01:45 -0700239
240 return count;
241}
242
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530243static ssize_t wcnss_wowpattern_write(struct file *file,
244 const char __user *buf, size_t count, loff_t *ppos)
245{
246 ssize_t ret;
247
248 vos_ssr_protect(__func__);
249 ret = __wcnss_wowpattern_write(file, buf, count, ppos);
250 vos_ssr_unprotect(__func__);
251
252 return ret;
253}
254
255static ssize_t __wcnss_patterngen_write(struct file *file,
Yue Mab9c86f42013-08-14 15:59:08 -0700256 const char __user *buf, size_t count, loff_t *ppos)
257{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530258 hdd_adapter_t *pAdapter;
Wilson Yang00256342013-10-10 23:13:38 -0700259 hdd_context_t *pHddCtx;
Yue Mab9c86f42013-08-14 15:59:08 -0700260 tSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams;
261 tSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams;
Yue Mab9c86f42013-08-14 15:59:08 -0700262 char *cmd, *sptr, *token;
263 v_U8_t pattern_idx = 0;
264 v_U8_t pattern_duration = 0;
265 char *pattern_buf;
266 v_U16_t pattern_len = 0;
267 v_U16_t i = 0;
268
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530269 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Mab9c86f42013-08-14 15:59:08 -0700270 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
271 {
272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
273 "%s: Invalid adapter or adapter has invalid magic.",
274 __func__);
275
276 return -EINVAL;
277 }
Wilson Yang00256342013-10-10 23:13:38 -0700278 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530279 if (0 != wlan_hdd_validate_context(pHddCtx))
280 {
281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
282 "%s: HDD context is not valid",__func__);
283 return -EINVAL;
284 }
Wilson Yang00256342013-10-10 23:13:38 -0700285
Yue Ma55855df2013-08-26 10:59:03 -0700286 if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN))
Yue Mab9c86f42013-08-14 15:59:08 -0700287 {
288 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Yue Ma55855df2013-08-26 10:59:03 -0700289 "%s: Periodic Tx Pattern Offload feature is not supported "
290 "in firmware!", __func__);
Yue Mab9c86f42013-08-14 15:59:08 -0700291
292 return -EINVAL;
293 }
294
295 /* Get command from user */
Yue Maddad6a72013-11-19 12:40:59 -0800296 if (count <= MAX_USER_COMMAND_SIZE_FRAME)
Yue Ma63993e32013-10-21 23:10:53 -0700297 cmd = vos_mem_malloc(count + 1);
Yue Mab9c86f42013-08-14 15:59:08 -0700298 else
299 {
300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson401c9ae2013-11-13 17:40:46 -0800301 "%s: Command length is larger than %d bytes.",
Yue Mab9c86f42013-08-14 15:59:08 -0700302 __func__, MAX_USER_COMMAND_SIZE_FRAME);
303
304 return -EINVAL;
305 }
306
Yue Ma5ac60e72013-11-16 01:03:02 -0800307 if (!cmd)
308 {
309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
310 "%s: Memory allocation for cmd failed!", __func__);
311
312 return -EFAULT;
313 }
314
Yue Mab9c86f42013-08-14 15:59:08 -0700315 if (copy_from_user(cmd, buf, count))
316 {
317 vos_mem_free(cmd);
318 return -EFAULT;
319 }
320 cmd[count] = '\0';
321 sptr = cmd;
322
323 /* Get pattern idx */
324 token = strsep(&sptr, " ");
325 if (!token)
326 goto failure;
327 if (kstrtou8(token, 0, &pattern_idx))
328 goto failure;
329
330 if (pattern_idx > (MAXNUM_PERIODIC_TX_PTRNS - 1))
331 {
332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
333 "%s: Pattern index %d is not in the range (0 ~ %d).",
334 __func__, pattern_idx, MAXNUM_PERIODIC_TX_PTRNS - 1);
335
336 goto failure;
337 }
338
339 /* Get pattern duration */
340 token = strsep(&sptr, " ");
341 if (!token)
342 goto failure;
343 if (kstrtou8(token, 0, &pattern_duration))
344 goto failure;
345
Yue Ma5ac60e72013-11-16 01:03:02 -0800346 /* Delete pattern using index if duration is 0 */
Yue Mab9c86f42013-08-14 15:59:08 -0700347 if (!pattern_duration)
348 {
349 delPeriodicTxPtrnParams =
350 vos_mem_malloc(sizeof(tSirDelPeriodicTxPtrn));
Yue Ma5ac60e72013-11-16 01:03:02 -0800351 if (!delPeriodicTxPtrnParams)
352 {
353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
354 "%s: Memory allocation for delPeriodicTxPtrnParams "
355 "failed!", __func__);
356
357 vos_mem_free(cmd);
358 return -EFAULT;
359 }
Yue Mab9c86f42013-08-14 15:59:08 -0700360
361 delPeriodicTxPtrnParams->ucPatternIdBitmap = 1 << pattern_idx;
362 vos_mem_copy(delPeriodicTxPtrnParams->macAddress,
363 pAdapter->macAddressCurrent.bytes, 6);
364
365 /* Delete pattern */
366 if (eHAL_STATUS_SUCCESS != sme_DelPeriodicTxPtrn(pHddCtx->hHal,
367 delPeriodicTxPtrnParams))
368 {
369 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
370 "%s: sme_DelPeriodicTxPtrn() failed!", __func__);
371
372 vos_mem_free(delPeriodicTxPtrnParams);
373 goto failure;
374 }
375
376 vos_mem_free(delPeriodicTxPtrnParams);
377 vos_mem_free(cmd);
378 return count;
379 }
380
Yue Ma55855df2013-08-26 10:59:03 -0700381 /* Check if it's in connected state only when adding patterns */
382 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
383 {
384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
385 "%s: Not in Connected state!", __func__);
Yue Ma5ac60e72013-11-16 01:03:02 -0800386
387 goto failure;
Yue Ma55855df2013-08-26 10:59:03 -0700388 }
389
Yue Mab9c86f42013-08-14 15:59:08 -0700390 /* Get pattern */
391 token = strsep(&sptr, " ");
392 if (!token)
393 goto failure;
394
395 pattern_buf = token;
396 pattern_buf[strlen(pattern_buf) - 1] = '\0';
397 pattern_len = strlen(pattern_buf);
398
399 /* Since the pattern is a hex string, 2 characters represent 1 byte. */
400 if (pattern_len % 2)
401 {
402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
403 "%s: Malformed pattern!", __func__);
404
405 goto failure;
406 }
407 else
408 pattern_len >>= 1;
409
410 if (pattern_len < 14 || pattern_len > PERIODIC_TX_PTRN_MAX_SIZE)
411 {
412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
413 "%s: Not an 802.3 frame!", __func__);
414
415 goto failure;
416 }
417
418 addPeriodicTxPtrnParams = vos_mem_malloc(sizeof(tSirAddPeriodicTxPtrn));
Yue Ma5ac60e72013-11-16 01:03:02 -0800419 if (!addPeriodicTxPtrnParams)
420 {
421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
422 "%s: Memory allocation for addPeriodicTxPtrnParams "
423 "failed!", __func__);
424
425 vos_mem_free(cmd);
426 return -EFAULT;
427 }
Yue Mab9c86f42013-08-14 15:59:08 -0700428
429 addPeriodicTxPtrnParams->ucPtrnId = pattern_idx;
430 addPeriodicTxPtrnParams->usPtrnIntervalMs = pattern_duration * 500;
431 addPeriodicTxPtrnParams->ucPtrnSize = pattern_len;
432 vos_mem_copy(addPeriodicTxPtrnParams->macAddress,
433 pAdapter->macAddressCurrent.bytes, 6);
434
435 /* Extract the pattern */
436 for(i = 0; i < addPeriodicTxPtrnParams->ucPtrnSize; i++)
437 {
438 addPeriodicTxPtrnParams->ucPattern[i] =
439 (hdd_parse_hex(pattern_buf[0]) << 4) + hdd_parse_hex(pattern_buf[1]);
440
441 /* Skip to next byte */
442 pattern_buf += 2;
443 }
444
445 /* Add pattern */
446 if (eHAL_STATUS_SUCCESS != sme_AddPeriodicTxPtrn(pHddCtx->hHal,
447 addPeriodicTxPtrnParams))
448 {
449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
450 "%s: sme_AddPeriodicTxPtrn() failed!", __func__);
451
452 vos_mem_free(addPeriodicTxPtrnParams);
453 goto failure;
454 }
455
456 vos_mem_free(addPeriodicTxPtrnParams);
457 vos_mem_free(cmd);
458 return count;
459
460failure:
461 vos_mem_free(cmd);
Sameer Thalappilb492efd2013-10-23 14:21:51 -0700462 return -EINVAL;
Yue Mab9c86f42013-08-14 15:59:08 -0700463}
464
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530465static ssize_t wcnss_patterngen_write(struct file *file,
466 const char __user *buf, size_t count, loff_t *ppos)
467{
468 ssize_t ret;
469
470 vos_ssr_protect(__func__);
471 ret = __wcnss_patterngen_write(file, buf, count, ppos);
472 vos_ssr_unprotect(__func__);
473
474 return ret;
475
476}
477
478static int __wcnss_debugfs_open(struct inode *inode, struct file *file)
Yue Ma0d4891e2013-08-06 17:01:45 -0700479{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530480 hdd_adapter_t *pAdapter;
481 hdd_context_t *pHddCtx;
482
483 pAdapter = (hdd_adapter_t *)file->private_data;
484 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
485 {
486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
487 "%s: Invalid adapter or adapter has invalid magic.",
488 __func__);
489 return -EINVAL;
490 }
491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
492 if (0 != wlan_hdd_validate_context(pHddCtx))
493 {
494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
495 "%s: HDD context is not valid",__func__);
496 return -EINVAL;
497 }
498
Yue Ma0d4891e2013-08-06 17:01:45 -0700499 if (inode->i_private)
500 {
501 file->private_data = inode->i_private;
502 }
503
504 return 0;
505}
506
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530507static int wcnss_debugfs_open(struct inode *inode, struct file *file)
508{
509 int ret;
510
511 vos_ssr_protect(__func__);
512 ret = __wcnss_debugfs_open(inode, file);
513 vos_ssr_unprotect(__func__);
514
515 return ret;
516}
517
Yue Maddad6a72013-11-19 12:40:59 -0800518static const struct file_operations fops_wowenable = {
519 .write = wcnss_wowenable_write,
520 .open = wcnss_debugfs_open,
521 .owner = THIS_MODULE,
522 .llseek = default_llseek,
523};
524
Yue Ma0d4891e2013-08-06 17:01:45 -0700525static const struct file_operations fops_wowpattern = {
526 .write = wcnss_wowpattern_write,
527 .open = wcnss_debugfs_open,
528 .owner = THIS_MODULE,
529 .llseek = default_llseek,
530};
531
Yue Mab9c86f42013-08-14 15:59:08 -0700532static const struct file_operations fops_patterngen = {
533 .write = wcnss_patterngen_write,
534 .open = wcnss_debugfs_open,
535 .owner = THIS_MODULE,
536 .llseek = default_llseek,
537};
538
Yue Ma0d4891e2013-08-06 17:01:45 -0700539VOS_STATUS hdd_debugfs_init(hdd_adapter_t *pAdapter)
540{
541 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
542 pHddCtx->debugfs_phy = debugfs_create_dir("wlan_wcnss", 0);
543
544 if (NULL == pHddCtx->debugfs_phy)
545 return VOS_STATUS_E_FAILURE;
546
Yue Maddad6a72013-11-19 12:40:59 -0800547 if (NULL == debugfs_create_file("wow_enable", S_IRUSR | S_IWUSR,
548 pHddCtx->debugfs_phy, pAdapter, &fops_wowenable))
549 return VOS_STATUS_E_FAILURE;
550
Yue Ma0d4891e2013-08-06 17:01:45 -0700551 if (NULL == debugfs_create_file("wow_pattern", S_IRUSR | S_IWUSR,
552 pHddCtx->debugfs_phy, pAdapter, &fops_wowpattern))
553 return VOS_STATUS_E_FAILURE;
554
Yue Mab9c86f42013-08-14 15:59:08 -0700555 if (NULL == debugfs_create_file("pattern_gen", S_IRUSR | S_IWUSR,
556 pHddCtx->debugfs_phy, pAdapter, &fops_patterngen))
557 return VOS_STATUS_E_FAILURE;
558
Yue Ma0d4891e2013-08-06 17:01:45 -0700559 return VOS_STATUS_SUCCESS;
560}
561
562void hdd_debugfs_exit(hdd_context_t *pHddCtx)
563{
564 debugfs_remove_recursive(pHddCtx->debugfs_phy);
565}
Yue Mab9c86f42013-08-14 15:59:08 -0700566#endif /* #ifdef WLAN_OPEN_SOURCE */
Yue Ma0d4891e2013-08-06 17:01:45 -0700567