blob: b53edcc3be5827b1a364acb387c3a6123296559c [file] [log] [blame]
Yue Ma0d4891e2013-08-06 17:01:45 -07001/*
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -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.
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
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053048 ENTER();
49
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053050 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Maddad6a72013-11-19 12:40:59 -080051 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
52 {
53 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
54 "%s: Invalid adapter or adapter has invalid magic.",
55 __func__);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053056 return -EINVAL;
57 }
58 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
59 if (0 != wlan_hdd_validate_context(pHddCtx))
60 {
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 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530133 EXIT();
Yue Maddad6a72013-11-19 12:40:59 -0800134 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
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530161 ENTER();
162
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530163 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Ma0d4891e2013-08-06 17:01:45 -0700164 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
165 {
166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
167 "%s: Invalid adapter or adapter has invalid magic.",
168 __func__);
169
170 return -EINVAL;
171 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530172 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
173 if (0 != wlan_hdd_validate_context(pHddCtx))
174 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530175 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);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530239 EXIT();
Yue Ma0d4891e2013-08-06 17:01:45 -0700240 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
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530269 ENTER();
270
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530271 pAdapter = (hdd_adapter_t *)file->private_data;
Yue Mab9c86f42013-08-14 15:59:08 -0700272 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
273 {
274 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
275 "%s: Invalid adapter or adapter has invalid magic.",
276 __func__);
277
278 return -EINVAL;
279 }
Wilson Yang00256342013-10-10 23:13:38 -0700280 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530281 if (0 != wlan_hdd_validate_context(pHddCtx))
282 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530283 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);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530458 EXIT();
Yue Mab9c86f42013-08-14 15:59:08 -0700459 return count;
460
461failure:
462 vos_mem_free(cmd);
Sameer Thalappilb492efd2013-10-23 14:21:51 -0700463 return -EINVAL;
Yue Mab9c86f42013-08-14 15:59:08 -0700464}
465
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530466static ssize_t wcnss_patterngen_write(struct file *file,
467 const char __user *buf, size_t count, loff_t *ppos)
468{
469 ssize_t ret;
470
471 vos_ssr_protect(__func__);
472 ret = __wcnss_patterngen_write(file, buf, count, ppos);
473 vos_ssr_unprotect(__func__);
474
475 return ret;
476
477}
478
479static int __wcnss_debugfs_open(struct inode *inode, struct file *file)
Yue Ma0d4891e2013-08-06 17:01:45 -0700480{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530481 hdd_adapter_t *pAdapter;
482 hdd_context_t *pHddCtx;
483
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530484 ENTER();
485
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530486 pAdapter = (hdd_adapter_t *)file->private_data;
487 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
488 {
489 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
490 "%s: Invalid adapter or adapter has invalid magic.",
491 __func__);
492 return -EINVAL;
493 }
494 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
495 if (0 != wlan_hdd_validate_context(pHddCtx))
496 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530497 return -EINVAL;
498 }
499
Yue Ma0d4891e2013-08-06 17:01:45 -0700500 if (inode->i_private)
501 {
502 file->private_data = inode->i_private;
503 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530504 EXIT();
Yue Ma0d4891e2013-08-06 17:01:45 -0700505 return 0;
506}
507
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530508static int wcnss_debugfs_open(struct inode *inode, struct file *file)
509{
510 int ret;
511
512 vos_ssr_protect(__func__);
513 ret = __wcnss_debugfs_open(inode, file);
514 vos_ssr_unprotect(__func__);
515
516 return ret;
517}
518
Yue Maddad6a72013-11-19 12:40:59 -0800519static const struct file_operations fops_wowenable = {
520 .write = wcnss_wowenable_write,
521 .open = wcnss_debugfs_open,
522 .owner = THIS_MODULE,
523 .llseek = default_llseek,
524};
525
Yue Ma0d4891e2013-08-06 17:01:45 -0700526static const struct file_operations fops_wowpattern = {
527 .write = wcnss_wowpattern_write,
528 .open = wcnss_debugfs_open,
529 .owner = THIS_MODULE,
530 .llseek = default_llseek,
531};
532
Yue Mab9c86f42013-08-14 15:59:08 -0700533static const struct file_operations fops_patterngen = {
534 .write = wcnss_patterngen_write,
535 .open = wcnss_debugfs_open,
536 .owner = THIS_MODULE,
537 .llseek = default_llseek,
538};
539
Yue Ma0d4891e2013-08-06 17:01:45 -0700540VOS_STATUS hdd_debugfs_init(hdd_adapter_t *pAdapter)
541{
542 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
543 pHddCtx->debugfs_phy = debugfs_create_dir("wlan_wcnss", 0);
544
545 if (NULL == pHddCtx->debugfs_phy)
546 return VOS_STATUS_E_FAILURE;
547
Yue Maddad6a72013-11-19 12:40:59 -0800548 if (NULL == debugfs_create_file("wow_enable", S_IRUSR | S_IWUSR,
549 pHddCtx->debugfs_phy, pAdapter, &fops_wowenable))
550 return VOS_STATUS_E_FAILURE;
551
Yue Ma0d4891e2013-08-06 17:01:45 -0700552 if (NULL == debugfs_create_file("wow_pattern", S_IRUSR | S_IWUSR,
553 pHddCtx->debugfs_phy, pAdapter, &fops_wowpattern))
554 return VOS_STATUS_E_FAILURE;
555
Yue Mab9c86f42013-08-14 15:59:08 -0700556 if (NULL == debugfs_create_file("pattern_gen", S_IRUSR | S_IWUSR,
557 pHddCtx->debugfs_phy, pAdapter, &fops_patterngen))
558 return VOS_STATUS_E_FAILURE;
559
Yue Ma0d4891e2013-08-06 17:01:45 -0700560 return VOS_STATUS_SUCCESS;
561}
562
563void hdd_debugfs_exit(hdd_context_t *pHddCtx)
564{
565 debugfs_remove_recursive(pHddCtx->debugfs_phy);
566}
Yue Mab9c86f42013-08-14 15:59:08 -0700567#endif /* #ifdef WLAN_OPEN_SOURCE */
Yue Ma0d4891e2013-08-06 17:01:45 -0700568