blob: 9af633692f82f96cb7904700987e879054ab22bf [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302 * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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 * 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
28/**
29 * DOC: wlan_hdd_debugfs.c
30 *
31 * This driver currently supports the following debugfs files:
32 * wlan_wcnss/wow_enable to enable/disable WoWL.
33 * wlan_wcnss/wow_pattern to configure WoWL patterns.
34 * wlan_wcnss/pattern_gen to configure periodic TX patterns.
35 */
36
37#ifdef WLAN_OPEN_SOURCE
38#include <wlan_hdd_includes.h>
39#include <wlan_hdd_wowl.h>
40#include <cds_sched.h>
41
42#define MAX_USER_COMMAND_SIZE_WOWL_ENABLE 8
43#define MAX_USER_COMMAND_SIZE_WOWL_PATTERN 512
44#define MAX_USER_COMMAND_SIZE_FRAME 4096
45
46/**
47 * __wcnss_wowenable_write() - wow_enable debugfs handler
48 * @file: debugfs file handle
49 * @buf: text being written to the debugfs
50 * @count: size of @buf
51 * @ppos: (unused) offset into the virtual file system
52 *
53 * Return: number of bytes processed
54 */
55static ssize_t __wcnss_wowenable_write(struct file *file,
56 const char __user *buf, size_t count,
57 loff_t *ppos)
58{
59 hdd_adapter_t *pAdapter;
60 hdd_context_t *hdd_ctx;
61 char cmd[MAX_USER_COMMAND_SIZE_WOWL_ENABLE + 1];
62 char *sptr, *token;
63 uint8_t wow_enable = 0;
64 uint8_t wow_mp = 0;
65 uint8_t wow_pbm = 0;
66 int ret;
67
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053068 ENTER();
69
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 pAdapter = (hdd_adapter_t *)file->private_data;
71 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
72 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_FATAL,
73 "%s: Invalid adapter or adapter has invalid magic.",
74 __func__);
75
76 return -EINVAL;
77 }
78
79 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
80 ret = wlan_hdd_validate_context(hdd_ctx);
81 if (0 != ret)
82 return ret;
83
84
85 if (!sme_is_feature_supported_by_fw(WOW)) {
86 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
87 "%s: Wake-on-Wireless feature is not supported in firmware!",
88 __func__);
89
90 return -EINVAL;
91 }
92
93 if (count > MAX_USER_COMMAND_SIZE_WOWL_ENABLE) {
94 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
95 "%s: Command length is larger than %d bytes.",
96 __func__, MAX_USER_COMMAND_SIZE_WOWL_ENABLE);
97
98 return -EINVAL;
99 }
100
101 /* Get command from user */
102 if (copy_from_user(cmd, buf, count))
103 return -EFAULT;
104 cmd[count] = '\0';
105 sptr = cmd;
106
107 /* Get enable or disable wow */
108 token = strsep(&sptr, " ");
109 if (!token)
110 return -EINVAL;
111 if (kstrtou8(token, 0, &wow_enable))
112 return -EINVAL;
113
114 /* Disable wow */
115 if (!wow_enable) {
116 if (!hdd_exit_wowl(pAdapter)) {
117 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
118 "%s: hdd_exit_wowl failed!", __func__);
119
120 return -EFAULT;
121 }
122
123 return count;
124 }
125
126 /* Get enable or disable magic packet mode */
127 token = strsep(&sptr, " ");
128 if (!token)
129 return -EINVAL;
130 if (kstrtou8(token, 0, &wow_mp))
131 return -EINVAL;
132 if (wow_mp > 1)
133 wow_mp = 1;
134
135 /* Get enable or disable pattern byte matching mode */
136 token = strsep(&sptr, " ");
137 if (!token)
138 return -EINVAL;
139 if (kstrtou8(token, 0, &wow_pbm))
140 return -EINVAL;
141 if (wow_pbm > 1)
142 wow_pbm = 1;
143
144 if (!hdd_enter_wowl(pAdapter, wow_mp, wow_pbm)) {
145 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
146 "%s: hdd_enter_wowl failed!", __func__);
147
148 return -EFAULT;
149 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530150 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 return count;
152}
153
154/**
155 * wcnss_wowenable_write() - SSR wrapper for wcnss_wowenable_write
156 * @file: file pointer
157 * @buf: buffer
158 * @count: count
159 * @ppos: position pointer
160 *
161 * Return: 0 on success, error number otherwise
162 */
163static ssize_t wcnss_wowenable_write(struct file *file,
164 const char __user *buf,
165 size_t count, loff_t *ppos)
166{
167 ssize_t ret;
168
169 cds_ssr_protect(__func__);
170 ret = __wcnss_wowenable_write(file, buf, count, ppos);
171 cds_ssr_unprotect(__func__);
172
173 return ret;
174}
175
176/**
177 * __wcnss_wowpattern_write() - wow_pattern debugfs handler
178 * @file: debugfs file handle
179 * @buf: text being written to the debugfs
180 * @count: size of @buf
181 * @ppos: (unused) offset into the virtual file system
182 *
183 * Return: number of bytes processed
184 */
185static ssize_t __wcnss_wowpattern_write(struct file *file,
186 const char __user *buf, size_t count,
187 loff_t *ppos)
188{
189 hdd_adapter_t *pAdapter = (hdd_adapter_t *) file->private_data;
190 hdd_context_t *hdd_ctx;
191 char cmd[MAX_USER_COMMAND_SIZE_WOWL_PATTERN + 1];
192 char *sptr, *token;
193 uint8_t pattern_idx = 0;
194 uint8_t pattern_offset = 0;
195 char *pattern_buf;
196 char *pattern_mask;
197 int ret;
198
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530199 ENTER();
200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
202 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_FATAL,
203 "%s: Invalid adapter or adapter has invalid magic.",
204 __func__);
205
206 return -EINVAL;
207 }
208
209 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
210 ret = wlan_hdd_validate_context(hdd_ctx);
211 if (0 != ret)
212 return ret;
213
214 if (!sme_is_feature_supported_by_fw(WOW)) {
215 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
216 "%s: Wake-on-Wireless feature is not supported in firmware!",
217 __func__);
218
219 return -EINVAL;
220 }
221
222 if (count > MAX_USER_COMMAND_SIZE_WOWL_PATTERN) {
223 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
224 "%s: Command length is larger than %d bytes.",
225 __func__, MAX_USER_COMMAND_SIZE_WOWL_PATTERN);
226
227 return -EINVAL;
228 }
229
230 /* Get command from user */
231 if (copy_from_user(cmd, buf, count))
232 return -EFAULT;
233 cmd[count] = '\0';
234 sptr = cmd;
235
236 /* Get pattern idx */
237 token = strsep(&sptr, " ");
238 if (!token)
239 return -EINVAL;
240
241 if (kstrtou8(token, 0, &pattern_idx))
242 return -EINVAL;
243
244 /* Get pattern offset */
245 token = strsep(&sptr, " ");
246
247 /* Delete pattern if no further argument */
248 if (!token) {
249 hdd_del_wowl_ptrn_debugfs(pAdapter, pattern_idx);
250
251 return count;
252 }
253
254 if (kstrtou8(token, 0, &pattern_offset))
255 return -EINVAL;
256
257 /* Get pattern */
258 token = strsep(&sptr, " ");
259 if (!token)
260 return -EINVAL;
261
262 pattern_buf = token;
263
264 /* Get pattern mask */
265 token = strsep(&sptr, " ");
266 if (!token)
267 return -EINVAL;
268
269 pattern_mask = token;
270 pattern_mask[strlen(pattern_mask) - 1] = '\0';
271
272 hdd_add_wowl_ptrn_debugfs(pAdapter, pattern_idx, pattern_offset,
273 pattern_buf, pattern_mask);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530274 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 return count;
276}
277
278/**
279 * wcnss_wowpattern_write() - SSR wrapper for __wcnss_wowpattern_write
280 * @file: file pointer
281 * @buf: buffer
282 * @count: count
283 * @ppos: position pointer
284 *
285 * Return: 0 on success, error number otherwise
286 */
287static ssize_t wcnss_wowpattern_write(struct file *file,
288 const char __user *buf,
289 size_t count, loff_t *ppos)
290{
291 ssize_t ret;
292
293 cds_ssr_protect(__func__);
294 ret = __wcnss_wowpattern_write(file, buf, count, ppos);
295 cds_ssr_unprotect(__func__);
296
297 return ret;
298}
299
300/**
301 * wcnss_patterngen_write() - pattern_gen debugfs handler
302 * @file: debugfs file handle
303 * @buf: text being written to the debugfs
304 * @count: size of @buf
305 * @ppos: (unused) offset into the virtual file system
306 *
307 * Return: number of bytes processed
308 */
309static ssize_t __wcnss_patterngen_write(struct file *file,
310 const char __user *buf, size_t count,
311 loff_t *ppos)
312{
313 hdd_adapter_t *pAdapter;
314 hdd_context_t *pHddCtx;
315 tSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams;
316 tSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams;
317
318 char *cmd, *sptr, *token;
319 uint8_t pattern_idx = 0;
320 uint8_t pattern_duration = 0;
321 char *pattern_buf;
322 uint16_t pattern_len = 0;
323 uint16_t i = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530324 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 int ret;
326
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530327 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328
329 pAdapter = (hdd_adapter_t *)file->private_data;
330 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
331 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_FATAL,
332 "%s: Invalid adapter or adapter has invalid magic.",
333 __func__);
334
335 return -EINVAL;
336 }
337
338 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
339 ret = wlan_hdd_validate_context(pHddCtx);
340 if (0 != ret)
341 return ret;
342
343 if (!sme_is_feature_supported_by_fw(WLAN_PERIODIC_TX_PTRN)) {
344 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
345 "%s: Periodic Tx Pattern Offload feature is not supported in firmware!",
346 __func__);
347 return -EINVAL;
348 }
349
350 /* Get command from user */
351 if (count <= MAX_USER_COMMAND_SIZE_FRAME)
352 cmd = cdf_mem_malloc(count + 1);
353 else {
354 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
355 "%s: Command length is larger than %d bytes.",
356 __func__, MAX_USER_COMMAND_SIZE_FRAME);
357
358 return -EINVAL;
359 }
360
361 if (!cmd) {
362 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
363 FL("Memory allocation for cmd failed!"));
364 return -ENOMEM;
365 }
366
367 if (copy_from_user(cmd, buf, count)) {
368 cdf_mem_free(cmd);
369 return -EFAULT;
370 }
371 cmd[count] = '\0';
372 sptr = cmd;
373
374 /* Get pattern idx */
375 token = strsep(&sptr, " ");
376 if (!token)
377 goto failure;
378 if (kstrtou8(token, 0, &pattern_idx))
379 goto failure;
380
381 if (pattern_idx > (MAXNUM_PERIODIC_TX_PTRNS - 1)) {
382 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
383 "%s: Pattern index %d is not in the range (0 ~ %d).",
384 __func__, pattern_idx, MAXNUM_PERIODIC_TX_PTRNS - 1);
385
386 goto failure;
387 }
388
389 /* Get pattern duration */
390 token = strsep(&sptr, " ");
391 if (!token)
392 goto failure;
393 if (kstrtou8(token, 0, &pattern_duration))
394 goto failure;
395
396 /* Delete pattern using index if duration is 0 */
397 if (!pattern_duration) {
398 delPeriodicTxPtrnParams =
399 cdf_mem_malloc(sizeof(tSirDelPeriodicTxPtrn));
400 if (!delPeriodicTxPtrnParams) {
401 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
402 FL("Memory allocation failed!"));
403 cdf_mem_free(cmd);
404 return -ENOMEM;
405 }
406 delPeriodicTxPtrnParams->ucPtrnId = pattern_idx;
407 delPeriodicTxPtrnParams->ucPatternIdBitmap = 1 << pattern_idx;
Srinivas Girigowdaa5bba7a2015-11-18 22:44:36 -0800408 cdf_copy_macaddr(&delPeriodicTxPtrnParams->mac_address,
409 &pAdapter->macAddressCurrent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410
411 /* Delete pattern */
412 status = sme_del_periodic_tx_ptrn(pHddCtx->hHal,
413 delPeriodicTxPtrnParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530414 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
416 "%s: sme_del_periodic_tx_ptrn() failed!",
417 __func__);
418
419 cdf_mem_free(delPeriodicTxPtrnParams);
420 goto failure;
421 }
422 cdf_mem_free(cmd);
423 cdf_mem_free(delPeriodicTxPtrnParams);
424 return count;
425 }
426
427 /*
428 * In SAP mode allow configuration without any connection check
429 * In STA mode check if it's in connected state before adding
430 * patterns
431 */
432 hdd_info("device mode %d", pAdapter->device_mode);
433 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
434 (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))) {
435 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
436 "%s: Not in Connected state!", __func__);
437 goto failure;
438 }
439
440 /* Get pattern */
441 token = strsep(&sptr, " ");
442 if (!token)
443 goto failure;
444
445 pattern_buf = token;
446 pattern_buf[strlen(pattern_buf) - 1] = '\0';
447 pattern_len = strlen(pattern_buf);
448
449 /* Since the pattern is a hex string, 2 characters represent 1 byte. */
450 if (pattern_len % 2) {
451 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
452 "%s: Malformed pattern!", __func__);
453
454 goto failure;
455 } else
456 pattern_len >>= 1;
457
458 if (pattern_len < 14 || pattern_len > PERIODIC_TX_PTRN_MAX_SIZE) {
459 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
460 "%s: Not an 802.3 frame!", __func__);
461
462 goto failure;
463 }
464
465 addPeriodicTxPtrnParams = cdf_mem_malloc(sizeof(tSirAddPeriodicTxPtrn));
466 if (!addPeriodicTxPtrnParams) {
467 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
468 FL("Memory allocation failed!"));
469 cdf_mem_free(cmd);
470 return -ENOMEM;
471 }
472
473 addPeriodicTxPtrnParams->ucPtrnId = pattern_idx;
474 addPeriodicTxPtrnParams->usPtrnIntervalMs = pattern_duration * 500;
475 addPeriodicTxPtrnParams->ucPtrnSize = pattern_len;
Srinivas Girigowda31896552015-11-18 22:59:52 -0800476 cdf_copy_macaddr(&addPeriodicTxPtrnParams->mac_address,
477 &pAdapter->macAddressCurrent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478
479 /* Extract the pattern */
480 for (i = 0; i < addPeriodicTxPtrnParams->ucPtrnSize; i++) {
481 addPeriodicTxPtrnParams->ucPattern[i] =
482 (hex_to_bin(pattern_buf[0]) << 4) +
483 hex_to_bin(pattern_buf[1]);
484
485 /* Skip to next byte */
486 pattern_buf += 2;
487 }
488
489 /* Add pattern */
490 status = sme_add_periodic_tx_ptrn(pHddCtx->hHal,
491 addPeriodicTxPtrnParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530492 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_ERROR,
494 "%s: sme_add_periodic_tx_ptrn() failed!", __func__);
495
496 cdf_mem_free(addPeriodicTxPtrnParams);
497 goto failure;
498 }
499 cdf_mem_free(cmd);
500 cdf_mem_free(addPeriodicTxPtrnParams);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530501 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 return count;
503
504failure:
505 cdf_mem_free(cmd);
506 return -EINVAL;
507}
508
509/**
510 * wcnss_patterngen_write() - SSR wrapper for __wcnss_patterngen_write
511 * @file: file pointer
512 * @buf: buffer
513 * @count: count
514 * @ppos: position pointer
515 *
516 * Return: 0 on success, error number otherwise
517 */
518static ssize_t wcnss_patterngen_write(struct file *file,
519 const char __user *buf,
520 size_t count, loff_t *ppos)
521{
522 ssize_t ret;
523
524 cds_ssr_protect(__func__);
525 ret = __wcnss_patterngen_write(file, buf, count, ppos);
526 cds_ssr_unprotect(__func__);
527
528 return ret;
529}
530
531/**
532 * __wcnss_debugfs_open() - Generic debugfs open() handler
533 * @inode: inode of the debugfs file
534 * @file: file handle of the debugfs file
535 *
536 * Return: 0
537 */
538static int __wcnss_debugfs_open(struct inode *inode, struct file *file)
539{
540 hdd_adapter_t *adapter;
541 hdd_context_t *hdd_ctx;
542 int ret;
543
544 ENTER();
545
546 if (inode->i_private)
547 file->private_data = inode->i_private;
548
549 adapter = (hdd_adapter_t *)file->private_data;
550 if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
551 CDF_TRACE(CDF_MODULE_ID_HDD, CDF_TRACE_LEVEL_FATAL,
552 "%s: Invalid adapter or adapter has invalid magic.",
553 __func__);
554 return -EINVAL;
555 }
556
557 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
558 ret = wlan_hdd_validate_context(hdd_ctx);
559 if (0 != ret)
560 return ret;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +0530561 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 return 0;
563}
564
565/**
566 * wcnss_debugfs_open() - SSR wrapper for __wcnss_debugfs_open
567 * @inode: inode pointer
568 * @file: file pointer
569 *
570 * Return: 0 on success, error number otherwise
571 */
572static int wcnss_debugfs_open(struct inode *inode, struct file *file)
573{
574 int ret;
575
576 cds_ssr_protect(__func__);
577 ret = __wcnss_debugfs_open(inode, file);
578 cds_ssr_unprotect(__func__);
579
580 return ret;
581}
582
583static const struct file_operations fops_wowenable = {
584 .write = wcnss_wowenable_write,
585 .open = wcnss_debugfs_open,
586 .owner = THIS_MODULE,
587 .llseek = default_llseek,
588};
589
590static const struct file_operations fops_wowpattern = {
591 .write = wcnss_wowpattern_write,
592 .open = wcnss_debugfs_open,
593 .owner = THIS_MODULE,
594 .llseek = default_llseek,
595};
596
597static const struct file_operations fops_patterngen = {
598 .write = wcnss_patterngen_write,
599 .open = wcnss_debugfs_open,
600 .owner = THIS_MODULE,
601 .llseek = default_llseek,
602};
603
604/**
605 * hdd_debugfs_init() - Initialize debugfs interface
606 * @pAdapter: primary wlan adapter
607 *
608 * Register support for the debugfs files supported by the driver.
609 *
610 * NB: The current implementation only supports debugfs operations
611 * on the primary interface, i.e. wlan0
612 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530613 * Return: QDF_STATUS_SUCCESS if all files registered,
614 * QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530616QDF_STATUS hdd_debugfs_init(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617{
618 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
619 pHddCtx->debugfs_phy = debugfs_create_dir("wlan_wcnss", 0);
620
621 if (NULL == pHddCtx->debugfs_phy)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530622 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
624 if (NULL == debugfs_create_file("wow_enable", S_IRUSR | S_IWUSR,
625 pHddCtx->debugfs_phy, pAdapter,
626 &fops_wowenable))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530627 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628
629 if (NULL == debugfs_create_file("wow_pattern", S_IRUSR | S_IWUSR,
630 pHddCtx->debugfs_phy, pAdapter,
631 &fops_wowpattern))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530632 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633
634 if (NULL == debugfs_create_file("pattern_gen", S_IRUSR | S_IWUSR,
635 pHddCtx->debugfs_phy, pAdapter,
636 &fops_patterngen))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530637 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530639 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640}
641
642/**
643 * hdd_debugfs_exit() - Shutdown debugfs interface
644 * @pHddCtx: the global HDD context
645 *
646 * Unregister support for the debugfs files supported by the driver.
647 *
648 * Return: None
649 */
650void hdd_debugfs_exit(hdd_context_t *pHddCtx)
651{
652 debugfs_remove_recursive(pHddCtx->debugfs_phy);
653}
654#endif /* #ifdef WLAN_OPEN_SOURCE */