-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdhd_linux_exportfs.c
4043 lines (3348 loc) · 98.5 KB
/
dhd_linux_exportfs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Broadcom Dongle Host Driver (DHD), Linux-specific network interface
* Basically selected code segments from usb-cdc.c and usb-rndis.c
*
* Copyright (C) 2023, Broadcom.
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2 (the "GPL"),
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
* following added to such license:
*
* As a special exception, the copyright holders of this software give you
* permission to link this software with independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that
* you also meet, for each linked independent module, the terms and conditions of
* the license of that module. An independent module is a module which is not
* derived from this software. The special exception does not apply to any
* modifications of the software.
*
*
* <<Broadcom-WL-IPTag/Dual:>>
*/
#include <linux/kobject.h>
#include <linux/proc_fs.h>
#include <linux/sysfs.h>
#include <osl.h>
#include <dhd.h>
#include <dhd_dbg.h>
#include <dhd_linux_priv.h>
#include <dhd_proto.h>
#if defined(WL_BAM)
#include <wl_bam.h>
#endif /* WL_BAM */
#ifdef PWRSTATS_SYSFS
#include <wldev_common.h>
#endif /* PWRSTATS_SYSFS */
#ifdef WL_CFG80211
#include <wl_cfg80211.h>
#endif /* WL_CFG80211 */
#ifdef SHOW_LOGTRACE
extern dhd_pub_t* g_dhd_pub;
static int dhd_proc_open(struct inode *inode, struct file *file);
ssize_t dhd_ring_proc_read(struct file *file, char *buffer, size_t tt, loff_t *loff);
#ifdef EWP_EVENTTS_LOG
ssize_t dhd_ring_eventts_proc_read(struct file *file, char *buffer, size_t tt, loff_t *loff);
#endif
ssize_t dhd_buffer_proc_read(struct file *file, char __user *usrbuf, size_t usrsz, loff_t *loff);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
static const struct file_operations dhd_ring_proc_ops = {
.open = dhd_proc_open,
.read = dhd_ring_proc_read,
.release = single_release,
};
#else
static const struct proc_ops dhd_ring_proc_ops = {
.proc_open = dhd_proc_open,
.proc_read = dhd_ring_proc_read,
.proc_release = single_release,
};
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) */
#ifdef EWP_EVENTTS_LOG
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
static const struct file_operations dhd_ring_eventts_proc_ops = {
.open = dhd_proc_open,
.read = dhd_ring_eventts_proc_read,
.release = single_release,
};
#else
static const struct proc_ops dhd_ring_eventts_proc_ops = {
.proc_open = dhd_proc_open,
.proc_read = dhd_ring_eventts_proc_read,
.proc_release = single_release,
};
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) */
#endif /* EWP_EVENTTS_LOG */
#ifdef DHD_PCIE_WRAPPER_DUMP
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
static const struct file_operations dhd_buffer_proc_ops = {
.open = dhd_proc_open,
.read = dhd_buffer_proc_read,
.release = single_release,
};
#else
static const struct proc_ops dhd_buffer_proc_ops = {
.proc_open = dhd_proc_open,
.proc_read = dhd_buffer_proc_read,
.proc_release = single_release,
};
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) */
#endif /* DHD_PCIE_WRAPPER_DUMP */
static int
dhd_proc_open(struct inode *inode, struct file *file)
{
int ret = BCME_ERROR;
if (inode) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0))
ret = single_open(file, 0, PDE_DATA(inode));
#else
/* This feature is not supported for lower kernel versions */
ret = single_open(file, 0, NULL);
#endif
} else {
DHD_ERROR(("%s: inode is NULL\n", __FUNCTION__));
}
return ret;
}
ssize_t
dhd_ring_proc_read(struct file *file, char __user *buffer, size_t tt, loff_t *loff)
{
trace_buf_info_t *trace_buf_info;
int ret = BCME_ERROR;
dhd_dbg_ring_t *ring = (dhd_dbg_ring_t *)((struct seq_file *)(file->private_data))->private;
if (ring == NULL) {
DHD_ERROR(("%s: ring is NULL\n", __FUNCTION__));
return ret;
}
ASSERT(g_dhd_pub);
trace_buf_info = (trace_buf_info_t *)MALLOCZ(g_dhd_pub->osh, sizeof(trace_buf_info_t));
if (trace_buf_info) {
dhd_dbg_read_ring_into_trace_buf(ring, trace_buf_info);
if (!buffer || (MIN(trace_buf_info->size, tt) > TRACE_LOG_BUF_MAX_SIZE)) {
DHD_ERROR(("%s: size %lu tt %lu trace_buf_sz %d\n", __FUNCTION__,
MIN(trace_buf_info->size, tt), tt, trace_buf_info->size));
ret = -ENOMEM;
goto exit;
}
if (copy_to_user(buffer, (void*)trace_buf_info->buf,
MIN(trace_buf_info->size, tt))) {
ret = -EFAULT;
goto exit;
}
if (trace_buf_info->availability == BUF_NOT_AVAILABLE)
ret = BUF_NOT_AVAILABLE;
else
ret = trace_buf_info->size;
} else
DHD_ERROR(("%s: Memory allocation Failed\n", __FUNCTION__));
exit:
if (trace_buf_info) {
MFREE(g_dhd_pub->osh, trace_buf_info, sizeof(trace_buf_info_t));
}
return ret;
}
#ifdef EWP_EVENTTS_LOG
ssize_t
dhd_ring_eventts_proc_read(struct file *file, char __user *usrbuf, size_t usrsz, loff_t *loff)
{
char *tmpbuf = NULL;
int ret = 0;
int rlen = 0;
dhd_dbg_ring_t *ring = NULL;
int buflen = TRACE_LOG_BUF_MAX_SIZE;
ring = (dhd_dbg_ring_t *)((struct seq_file *)(file->private_data))->private;
if (ring == NULL) {
DHD_ERROR(("%s: ring is NULL!\n", __FUNCTION__));
return -EFAULT;
}
tmpbuf = MALLOCZ(g_dhd_pub->osh, buflen);
if (!tmpbuf) {
DHD_ERROR(("Failed to alloc tmpbuf\n"));
return -ENOMEM;
}
rlen = dhd_dbg_ring_pull_single(ring, tmpbuf, buflen, TRUE);
if (!rlen) {
/* rlen can also be zero when there is no data in the ring */
DHD_INFO(("%s: dhd_dbg_ring_pull_single, rlen=%d, tmpbuf size=%lu\n",
__FUNCTION__, rlen, sizeof(tmpbuf)));
ret = -EAGAIN;
goto fail;
}
DHD_INFO(("%s: dhd_dbg_ring_pull_single rlen=%d , usrsz=%lu\n", __FUNCTION__, rlen, usrsz));
if (rlen > usrsz) {
DHD_ERROR(("%s: usr buf insufficient! rlen=%d, usrsz=%ld \n",
__FUNCTION__, rlen, usrsz));
ret = -EFAULT;
goto fail;
}
ret = copy_to_user(usrbuf, (void*)tmpbuf, rlen);
if (ret) {
DHD_ERROR(("%s: copy_to_usr fails! rlen=%d, usrsz=%ld \n",
__FUNCTION__, rlen, usrsz));
ret = -EFAULT;
goto fail;
}
*loff += rlen;
fail:
MFREE(g_dhd_pub->osh, tmpbuf, buflen);
if (ret) {
return ret;
} else {
return rlen;
}
}
#endif /* EWP_EVENTTS_LOG */
#ifdef DHD_PCIE_WRAPPER_DUMP
/* Generic buffer read from proc */
ssize_t
dhd_buffer_proc_read(struct file *file, char __user *usrbuf, size_t usrsz, loff_t *loff)
{
dhd_dbg_buf_t *dbg_buf;
dbg_buf = (dhd_dbg_buf_t *)((struct seq_file *)(file->private_data))->private;
if (dbg_buf->buf == NULL) {
DHD_ERROR(("%s: ring is NULL!\n", __FUNCTION__));
return -EFAULT;
}
if (*loff) {
return 0;
}
return simple_read_from_buffer(usrbuf, usrsz, loff, dbg_buf->buf, dbg_buf->len);
}
#endif /* DHD_PCIE_WRAPPER_DUMP */
void
dhd_dbg_ring_proc_create(dhd_pub_t *dhdp)
{
dhd_info_t *dhd = (dhd_info_t*)dhdp->info;
#ifdef DEBUGABILITY
dhd_dbg_ring_t *dbg_verbose_ring = NULL;
dbg_verbose_ring = dhd_dbg_get_ring_from_ring_id(dhdp, FW_VERBOSE_RING_ID);
if (dbg_verbose_ring) {
dhd->dhd_trace_proc = proc_create_data("dhd_trace", S_IRUSR, NULL,
&dhd_ring_proc_ops, dbg_verbose_ring);
if (!dhd->dhd_trace_proc) {
DHD_ERROR(("Failed to create /proc/dhd_trace procfs interface\n"));
} else {
DHD_INFO(("Created /proc/dhd_trace procfs interface\n"));
}
} else {
DHD_ERROR(("dbg_verbose_ring is NULL, /proc/dhd_trace not created\n"));
}
#endif /* DEBUGABILITY */
#ifdef EWP_ECNTRS_LOGGING
dhd->dhd_ecounters_proc = proc_create_data("dhd_ecounters", S_IRUSR, NULL,
&dhd_ring_proc_ops, dhdp->ecntr_dbg_ring);
if (!dhd->dhd_ecounters_proc) {
DHD_ERROR(("Failed to create /proc/dhd_ecounters procfs interface\n"));
} else {
DHD_INFO(("Created /proc/dhd_ecounters procfs interface\n"));
}
#endif /* EWP_ECNTRS_LOGGING */
#ifdef EWP_RTT_LOGGING
dhd->dhd_rtt_proc = proc_create_data("dhd_rtt", S_IRUSR, NULL, &dhd_ring_proc_ops,
dhdp->rtt_dbg_ring);
if (!dhd->dhd_rtt_proc) {
DHD_ERROR(("Failed to create /proc/dhd_rtt procfs interface\n"));
} else {
DHD_INFO(("Created /proc/dhd_rtt procfs interface\n"));
}
#endif /* EWP_RTT_LOGGING */
#ifdef EWP_EVENTTS_LOG
dhd->dhd_eventts_proc = proc_create_data("dhd_eventts", S_IRUSR, NULL,
&dhd_ring_eventts_proc_ops, dhdp->eventts_dbg_ring);
if (!dhd->dhd_eventts_proc) {
DHD_ERROR(("%s: Failed to create /proc/dhd_eventts interface\n", __FUNCTION__));
} else {
DHD_INFO(("%s: Created /proc/dhd_eventts interface\n", __FUNCTION__));
}
#endif /* EWP_EVENTTS_LOG */
#ifdef DHD_PCIE_WRAPPER_DUMP
dhd->dhd_wrapper_dump_proc = proc_create_data("dhd_wrapper_dump", S_IRUSR, NULL,
&dhd_buffer_proc_ops, (void *)(&dhdp->dbg->wrapper_buf));
if (!dhd->dhd_wrapper_dump_proc) {
DHD_ERROR(("%s: Failed to create /proc/dhd_wrapper_dump interface\n",
__FUNCTION__));
} else {
DHD_INFO(("%s: Created /proc/dhd_wrapper_dump interface\n", __FUNCTION__));
}
#endif /* DHD_PCIE_WRAPPER_DUMP */
BCM_REFERENCE(dhd);
}
void
dhd_dbg_ring_proc_destroy(dhd_pub_t *dhdp)
{
dhd_info_t *dhd = (dhd_info_t*)dhdp->info;
#ifdef DEBUGABILITY
if (dhd->dhd_trace_proc) {
remove_proc_entry("dhd_trace", NULL);
}
#endif /* DEBUGABILITY */
#ifdef EWP_ECNTRS_LOGGING
if (dhd->dhd_ecounters_proc) {
remove_proc_entry("dhd_ecounters", NULL);
}
#endif /* EWP_ECNTRS_LOGGING */
#ifdef EWP_RTT_LOGGING
if (dhd->dhd_rtt_proc) {
remove_proc_entry("dhd_rtt", NULL);
}
#endif /* EWP_RTT_LOGGING */
#ifdef EWP_EVENTTS_LOG
if (dhd->dhd_eventts_proc) {
remove_proc_entry("dhd_eventts", NULL);
}
#endif /* EWP_EVENTTS_LOG */
#ifdef DHD_PCIE_WRAPPER_DUMP
if (dhd->dhd_wrapper_dump_proc) {
remove_proc_entry("dhd_wrapper_dump", NULL);
}
#endif /* DHD_PCIE_WRAPPER_DUMP */
BCM_REFERENCE(dhd);
}
#endif /* SHOW_LOGTRACE */
/* ----------------------------------------------------------------------------
* Infrastructure code for sysfs interface support for DHD
*
* What is sysfs interface?
* https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt
*
* Why sysfs interface?
* This is the Linux standard way of changing/configuring Run Time parameters
* for a driver. We can use this interface to control "linux" specific driver
* parameters.
*
* -----------------------------------------------------------------------------
*/
#if defined(DHD_TRACE_WAKE_LOCK)
extern atomic_t trace_wklock_onoff;
/* Function to show the history buffer */
static ssize_t
show_wklock_trace(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
dhd_info_t *dhd = (dhd_info_t *)dev;
buf[ret] = '\n';
buf[ret+1] = 0;
dhd_wk_lock_stats_dump(&dhd->pub);
return ret+1;
}
/* Function to enable/disable wakelock trace */
static ssize_t
wklock_trace_onoff(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
BCM_REFERENCE(dhd);
onoff = bcm_strtoul(buf, NULL, 10);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
atomic_set(&trace_wklock_onoff, onoff);
if (atomic_read(&trace_wklock_onoff)) {
DHD_PRINT(("ENABLE WAKLOCK TRACE\n"));
} else {
DHD_PRINT(("DISABLE WAKELOCK TRACE\n"));
}
return (ssize_t)(onoff+1);
}
#endif /* DHD_TRACE_WAKE_LOCK */
#ifdef DHD_LOG_DUMP
extern int logdump_ecntr_enable;
static ssize_t
show_logdump_ecntr(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long val;
val = logdump_ecntr_enable;
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n", val);
return ret;
}
static ssize_t
logdump_ecntr_onoff(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long val;
val = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &val);
if (val != 0 && val != 1) {
return -EINVAL;
}
logdump_ecntr_enable = val;
return count;
}
#endif /* DHD_LOG_DUMP */
extern uint enable_ecounter;
static ssize_t
show_enable_ecounter(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long onoff;
onoff = enable_ecounter;
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n",
onoff);
return ret;
}
static ssize_t
ecounter_onoff(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
dhd_pub_t *dhdp;
if (!dhd) {
DHD_ERROR(("%s: dhd is NULL\n", __FUNCTION__));
return count;
}
dhdp = &dhd->pub;
if (!FW_SUPPORTED(dhdp, ecounters)) {
DHD_ERROR(("%s: ecounters not supported by FW\n", __FUNCTION__));
return count;
}
onoff = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &onoff);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
if (enable_ecounter == onoff) {
DHD_PRINT(("%s: ecounters already %d\n", __FUNCTION__, enable_ecounter));
return count;
}
enable_ecounter = onoff;
dhd_ecounter_configure(dhdp, enable_ecounter);
return count;
}
#if defined(DHD_QOS_ON_SOCK_FLOW)
#include <dhd_linux_sock_qos.h>
static ssize_t
show_sock_qos_onoff(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
onoff = dhd_sock_qos_get_status(dhd);
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n",
onoff);
return ret;
}
static ssize_t
update_sock_qos_onoff(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
onoff = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &onoff);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
dhd_sock_qos_set_status(dhd, onoff);
return count;
}
static ssize_t
show_sock_qos_upgrade(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
onoff = dhd_sock_qos_get_force_upgrade(dhd);
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n",
onoff);
return ret;
}
static ssize_t
update_sock_qos_upgrade(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
dhd_info_t *dhd = (dhd_info_t *)dev;
onoff = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &onoff);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
dhd_sock_qos_set_force_upgrade(dhd, onoff);
return count;
}
static ssize_t
show_sock_qos_numfl_upgrd_thresh(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
int upgrade_thresh;
dhd_info_t *dhd = (dhd_info_t *)dev;
upgrade_thresh = dhd_sock_qos_get_numfl_upgrd_thresh(dhd);
ret = scnprintf(buf, PAGE_SIZE - 1, "%d \n",
upgrade_thresh);
return ret;
}
static ssize_t
update_sock_qos_numfl_upgrd_thresh(struct dhd_info *dev, const char *buf, size_t count)
{
int upgrade_thresh;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%d", &upgrade_thresh);
if (upgrade_thresh < 0) {
return -EINVAL;
}
dhd_sock_qos_set_numfl_upgrd_thresh(dhd, upgrade_thresh);
return count;
}
static ssize_t
show_sock_qos_avgpktsize_thresh(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long avgpktsize_low, avgpktsize_high;
dhd_info_t *dhd = (dhd_info_t *)dev;
dhd_sock_qos_get_avgpktsize_thresh(dhd, &avgpktsize_low, &avgpktsize_high);
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu %lu\n",
avgpktsize_low, avgpktsize_high);
return ret;
}
static ssize_t
update_sock_qos_avgpktsize_thresh(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long avgpktsize_low, avgpktsize_high;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%lu %lu", &avgpktsize_low, &avgpktsize_high);
dhd_sock_qos_set_avgpktsize_thresh(dhd, avgpktsize_low, avgpktsize_high);
return count;
}
static ssize_t
show_sock_qos_numpkts_thresh(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long numpkts_low, numpkts_high;
dhd_info_t *dhd = (dhd_info_t *)dev;
dhd_sock_qos_get_numpkts_thresh(dhd, &numpkts_low, &numpkts_high);
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu %lu\n",
numpkts_low, numpkts_high);
return ret;
}
static ssize_t
update_sock_qos_numpkts_thresh(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long numpkts_low, numpkts_high;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%lu %lu", &numpkts_low, &numpkts_high);
dhd_sock_qos_set_numpkts_thresh(dhd, numpkts_low, numpkts_high);
return count;
}
static ssize_t
show_sock_qos_detectcnt_thresh(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned char detectcnt_inc, detectcnt_dec;
dhd_info_t *dhd = (dhd_info_t *)dev;
dhd_sock_qos_get_detectcnt_thresh(dhd, &detectcnt_inc, &detectcnt_dec);
ret = scnprintf(buf, PAGE_SIZE - 1, "%d %d\n",
detectcnt_inc, detectcnt_dec);
return ret;
}
static ssize_t
update_sock_qos_detectcnt_thresh(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned int detectcnt_inc, detectcnt_dec;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%u %u", &detectcnt_inc, &detectcnt_dec);
dhd_sock_qos_set_detectcnt_thresh(dhd, detectcnt_inc, detectcnt_dec);
return count;
}
static ssize_t
show_sock_qos_detectcnt_upgrd_thresh(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned int detectcnt_upgrd_thresh;
dhd_info_t *dhd = (dhd_info_t *)dev;
detectcnt_upgrd_thresh = dhd_sock_qos_get_detectcnt_upgrd_thresh(dhd);
ret = scnprintf(buf, PAGE_SIZE - 1, "%d \n", detectcnt_upgrd_thresh);
return ret;
}
static ssize_t
update_sock_qos_detectcnt_upgrd_thresh(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned int detectcnt_upgrd_thresh;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%u", &detectcnt_upgrd_thresh);
dhd_sock_qos_set_detectcnt_upgrd_thresh(dhd, detectcnt_upgrd_thresh);
return count;
}
static ssize_t
show_sock_qos_maxfl(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned int maxfl;
dhd_info_t *dhd = (dhd_info_t *)dev;
maxfl = dhd_sock_qos_get_maxfl(dhd);
ret = scnprintf(buf, PAGE_SIZE - 1, "%u \n", maxfl);
return ret;
}
static ssize_t
update_sock_qos_maxfl(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned int maxfl;
dhd_info_t *dhd = (dhd_info_t *)dev;
sscanf(buf, "%u", &maxfl);
dhd_sock_qos_set_maxfl(dhd, maxfl);
return count;
}
static ssize_t
show_sock_qos_stats(struct dhd_info *dev, char *buf)
{
dhd_info_t *dhd = (dhd_info_t *)dev;
dhd_sock_qos_show_stats(dhd, buf, PAGE_SIZE);
return PAGE_SIZE - 1;
}
static ssize_t
clear_sock_qos_stats(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long clear;
dhd_info_t *dhd = (dhd_info_t *)dev;
clear = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &clear);
if (clear != 0) {
return -EINVAL;
}
dhd_sock_qos_clear_stats(dhd);
return count;
}
#ifdef DHD_QOS_ON_SOCK_FLOW_UT
/*
* test_id sub_id Description
* ------ ------ -----------
* 1 0 psk_qos->sk_fl
* The number of free sk_fl entries in the Table is exhausted
* and more sockets are still getting created
*
* 1 1 psk_qos->sk_fl
* is Full for more than x seconds, there are lot of periodic
* flows, but none of them are detected for upgrade for more
* than 'x' seconds
*
* 2 Force upgrade the socket flows to reach skfl_upgrade_thresh
* check the behaviour
*
* Downgrade one of the sk_fls and check if the 'next' pending
* sk_fl is getting upgraded. The sk_fl getting upgraded
* should follow FIFO scheme.
*
* 3 Upgrade a socket flow ... after some time downgrade the
* same and check if the sk_fl is actually getting downgraded
* Keep switching the behavior every 'x' seconds and observe
* the switches
*/
static ssize_t
do_sock_qos_unit_test(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned int test_id = 0;
unsigned int sub_id = 0;
dhd_info_t *dhd = (dhd_info_t *)dev;
int ret;
BCM_REFERENCE(dhd);
ret = sscanf(buf, "%d %d", &test_id, &sub_id);
if (ret < 1) {
return -EINVAL;
}
return count;
}
#endif /* DHD_QOS_ON_SOCK_FLOW_UT */
#endif /* DHD_QOS_ON_SOCK_FLOW */
#ifdef DHD_SSSR_DUMP
static ssize_t
show_sssr_enab(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long onoff;
onoff = sssr_enab;
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n",
onoff);
return ret;
}
static ssize_t
set_sssr_enab(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
onoff = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &onoff);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
sssr_enab = (uint)onoff;
return count;
}
static ssize_t
show_fis_enab(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
unsigned long onoff;
onoff = fis_enab;
ret = scnprintf(buf, PAGE_SIZE - 1, "%lu \n",
onoff);
return ret;
}
static ssize_t
set_fis_enab(struct dhd_info *dev, const char *buf, size_t count)
{
unsigned long onoff;
onoff = bcm_strtoul(buf, NULL, 10);
sscanf(buf, "%lu", &onoff);
if (onoff != 0 && onoff != 1) {
return -EINVAL;
}
fis_enab = (uint)onoff;
return count;
}
#endif /* DHD_SSSR_DUMP */
#define FMT_BUFSZ 32
extern char firmware_path[];
static ssize_t
show_firmware_path(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
ret = scnprintf(buf, PAGE_SIZE - 1, "%s\n", firmware_path);
return ret;
}
static ssize_t
store_firmware_path(struct dhd_info *dev, const char *buf, size_t count)
{
char fmt_spec[FMT_BUFSZ] = "";
if ((int)strlen(buf) >= MOD_PARAM_PATHLEN) {
return -EINVAL;
}
snprintf(fmt_spec, FMT_BUFSZ, "%%%ds", MOD_PARAM_PATHLEN - 1);
sscanf(buf, fmt_spec, firmware_path);
return count;
}
extern char nvram_path[];
static ssize_t
show_nvram_path(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
ret = scnprintf(buf, PAGE_SIZE - 1, "%s\n", nvram_path);
return ret;
}
static ssize_t
store_nvram_path(struct dhd_info *dev, const char *buf, size_t count)
{
char fmt_spec[FMT_BUFSZ] = "";
if ((int)strlen(buf) >= MOD_PARAM_PATHLEN) {
return -EINVAL;
}
snprintf(fmt_spec, FMT_BUFSZ, "%%%ds", MOD_PARAM_PATHLEN - 1);
sscanf(buf, fmt_spec, nvram_path);
return count;
}
extern char signature_path[];
static ssize_t
show_signature_path(struct dhd_info *dev, char *buf)
{
ssize_t ret = 0;
ret = scnprintf(buf, PAGE_SIZE - 1, "%s\n", signature_path);
return ret;
}
static ssize_t
store_signature_path(struct dhd_info *dev, const char *buf, size_t count)
{
char fmt_spec[FMT_BUFSZ] = "";
if ((int)strlen(buf) >= MOD_PARAM_PATHLEN) {
return -EINVAL;
}
snprintf(fmt_spec, FMT_BUFSZ, "%%%ds", MOD_PARAM_PATHLEN - 1);
sscanf(buf, fmt_spec, signature_path);
return count;
}
#ifdef PWRSTATS_SYSFS
typedef struct wl_pwrstats_sysfs {
uint64 current_ts;
uint64 pm_cnt;
uint64 pm_dur;
uint64 pm_last_entry_us;
uint64 awake_cnt;
uint64 awake_dur;
uint64 awake_last_entry_us;
uint64 l0_cnt;
uint64 l0_dur_us;
uint64 l1_cnt;
uint64 l1_dur_us;
uint64 l1_1_cnt;
uint64 l1_1_dur_us;
uint64 l1_2_cnt;
uint64 l1_2_dur_us;
uint64 l2_cnt;
uint64 l2_dur_us;
} wl_pwrstats_sysfs_t;
uint64 last_delta = 0;
wl_pwrstats_sysfs_t accumstats = {0, };
wl_pwrstats_sysfs_t laststats = {0, };
static const char pwrstr_cnt[] = "count:";
static const char pwrstr_dur[] = "duration_usec:";
static const char pwrstr_ts[] = "last_entry_timestamp_usec:";
ssize_t print_pwrstats_cum(char *buf)
{
ssize_t ret = 0;
ret += scnprintf(buf, PAGE_SIZE, "WIFI\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "AWAKE:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.awake_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.awake_dur);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_ts,
laststats.awake_last_entry_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "ASLEEP:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.pm_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.pm_dur);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_ts,
laststats.pm_last_entry_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\nWIFI-PCIE\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "L0:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.l0_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.l0_dur_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "L1:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.l1_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.l1_dur_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "L1_1:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.l1_1_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.l1_1_dur_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "L1_2:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.l1_2_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.l1_2_dur_us);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "L2:\n");
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_cnt,
accumstats.l2_cnt);
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s 0x%0llx\n", pwrstr_dur,
accumstats.l2_dur_us);
return ret;
}
void update_pwrstats_cum(uint64 *accum, uint64 *last, uint64 *now, bool force)
{
if (accum) { /* accumulation case, ex; counts, duration */
if (*now < *last) {
if (force) {
/* force update for pm_cnt/awake_cnt and PCIE stats */
*accum += *now;
*last = *now;
}