forked from morrownr/88x2bu-20210702
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtw_mi.c
1546 lines (1335 loc) · 40.7 KB
/
rtw_mi.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
/******************************************************************************
*
* Copyright(c) 2007 - 2019 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*****************************************************************************/
#define _RTW_MI_C_
#include <drv_types.h>
#include <hal_data.h>
void rtw_mi_update_union_chan_inf(_adapter *adapter, u8 ch, u8 offset , u8 bw)
{
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
if (!ch) {
dvobj->union_ch_bak = dvobj->union_ch;
dvobj->union_bw_bak = dvobj->union_bw;
dvobj->union_offset_bak = dvobj->union_offset;
}
dvobj->union_ch = ch;
dvobj->union_bw = bw;
dvobj->union_offset = offset;
}
#ifdef DBG_IFACE_STATUS
#ifdef CONFIG_P2P
static u8 _rtw_mi_p2p_listen_scan_chk(_adapter *adapter)
{
int i;
_adapter *iface;
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
u8 p2p_listen_scan_state = _FALSE;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (rtw_p2p_chk_state(&iface->wdinfo, P2P_STATE_LISTEN) ||
rtw_p2p_chk_state(&iface->wdinfo, P2P_STATE_SCAN)) {
p2p_listen_scan_state = _TRUE;
break;
}
}
return p2p_listen_scan_state;
}
#endif
#endif
u8 rtw_mi_stayin_union_ch_chk(_adapter *adapter)
{
u8 rst = _TRUE;
u8 u_ch, u_bw, u_offset;
u8 o_ch, o_bw, o_offset;
u_ch = rtw_mi_get_union_chan(adapter);
u_bw = rtw_mi_get_union_bw(adapter);
u_offset = rtw_mi_get_union_offset(adapter);
o_ch = rtw_get_oper_ch(adapter);
o_bw = rtw_get_oper_bw(adapter);
o_offset = rtw_get_oper_choffset(adapter);
if ((u_ch != o_ch) || (u_bw != o_bw) || (u_offset != o_offset))
rst = _FALSE;
#ifdef DBG_IFACE_STATUS
if (rst == _FALSE) {
RTW_ERR("%s Not stay in union channel\n", __func__);
if (GET_HAL_DATA(adapter)->bScanInProcess == _TRUE)
RTW_ERR("ScanInProcess\n");
#ifdef CONFIG_P2P
if (_rtw_mi_p2p_listen_scan_chk(adapter))
RTW_ERR("P2P in listen or scan state\n");
#endif
RTW_ERR("union ch, bw, offset: %u,%u,%u\n", u_ch, u_bw, u_offset);
RTW_ERR("oper ch, bw, offset: %u,%u,%u\n", o_ch, o_bw, o_offset);
RTW_ERR("=========================\n");
}
#endif
return rst;
}
u8 rtw_mi_stayin_union_band_chk(_adapter *adapter)
{
u8 rst = _TRUE;
u8 u_ch, o_ch;
u8 u_band, o_band;
u_ch = rtw_mi_get_union_chan(adapter);
o_ch = rtw_get_oper_ch(adapter);
u_band = (u_ch > 14) ? BAND_ON_5G : BAND_ON_2_4G;
o_band = (o_ch > 14) ? BAND_ON_5G : BAND_ON_2_4G;
if (u_ch != o_ch)
if(u_band != o_band)
rst = _FALSE;
#ifdef DBG_IFACE_STATUS
if (rst == _FALSE)
RTW_ERR("%s Not stay in union band\n", __func__);
#endif
return rst;
}
/* Find union about ch, bw, ch_offset of all linked/linking interfaces */
int rtw_mi_get_ch_setting_union_by_ifbmp(struct dvobj_priv *dvobj, u8 ifbmp, u8 *ch, u8 *bw, u8 *offset)
{
_adapter *iface;
struct mlme_ext_priv *mlmeext;
int i;
u8 ch_ret = 0;
u8 bw_ret = CHANNEL_WIDTH_20;
u8 offset_ret = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
int num = 0;
if (ch)
*ch = 0;
if (bw)
*bw = CHANNEL_WIDTH_20;
if (offset)
*offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (!iface || !(ifbmp & BIT(iface->iface_id)))
continue;
mlmeext = &iface->mlmeextpriv;
if (!check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE | WIFI_UNDER_LINKING))
continue;
if (check_fwstate(&iface->mlmepriv, WIFI_OP_CH_SWITCHING))
continue;
if (num == 0) {
ch_ret = mlmeext->cur_channel;
bw_ret = mlmeext->cur_bwmode;
offset_ret = mlmeext->cur_ch_offset;
num++;
continue;
}
if (ch_ret != mlmeext->cur_channel) {
num = 0;
break;
}
if (bw_ret < mlmeext->cur_bwmode) {
bw_ret = mlmeext->cur_bwmode;
offset_ret = mlmeext->cur_ch_offset;
} else if (bw_ret == mlmeext->cur_bwmode && offset_ret != mlmeext->cur_ch_offset) {
num = 0;
break;
}
num++;
}
if (num) {
if (ch)
*ch = ch_ret;
if (bw)
*bw = bw_ret;
if (offset)
*offset = offset_ret;
}
return num;
}
inline int rtw_mi_get_ch_setting_union(_adapter *adapter, u8 *ch, u8 *bw, u8 *offset)
{
return rtw_mi_get_ch_setting_union_by_ifbmp(adapter_to_dvobj(adapter), 0xFF, ch, bw, offset);
}
inline int rtw_mi_get_ch_setting_union_no_self(_adapter *adapter, u8 *ch, u8 *bw, u8 *offset)
{
return rtw_mi_get_ch_setting_union_by_ifbmp(adapter_to_dvobj(adapter), 0xFF & ~BIT(adapter->iface_id), ch, bw, offset);
}
void rtw_mi_status_by_ifbmp(struct dvobj_priv *dvobj, u8 ifbmp, struct mi_state *mstate)
{
_adapter *iface;
int i;
_rtw_memset(mstate, 0, sizeof(struct mi_state));
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (!iface || !(ifbmp & BIT(iface->iface_id)))
continue;
if (check_fwstate(&iface->mlmepriv, WIFI_STATION_STATE) == _TRUE) {
MSTATE_STA_NUM(mstate)++;
if (check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE) == _TRUE) {
MSTATE_STA_LD_NUM(mstate)++;
#ifdef CONFIG_TDLS
if (iface->tdlsinfo.link_established == _TRUE)
MSTATE_TDLS_LD_NUM(mstate)++;
#endif
#ifdef CONFIG_P2P
if (MLME_IS_GC(iface))
MSTATE_P2P_GC_NUM(mstate)++;
#endif
}
if (check_fwstate(&iface->mlmepriv, WIFI_UNDER_LINKING) == _TRUE)
MSTATE_STA_LG_NUM(mstate)++;
#ifdef CONFIG_AP_MODE
} else if (check_fwstate(&iface->mlmepriv, WIFI_AP_STATE) == _TRUE ) {
if (check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE) == _TRUE) {
MSTATE_AP_NUM(mstate)++;
if (iface->stapriv.asoc_sta_count > 2)
MSTATE_AP_LD_NUM(mstate)++;
#ifdef CONFIG_P2P
if (MLME_IS_GO(iface))
MSTATE_P2P_GO_NUM(mstate)++;
#endif
} else
MSTATE_AP_STARTING_NUM(mstate)++;
#endif
} else if (check_fwstate(&iface->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE) == _TRUE
&& check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE) == _TRUE
) {
MSTATE_ADHOC_NUM(mstate)++;
if (iface->stapriv.asoc_sta_count > 2)
MSTATE_ADHOC_LD_NUM(mstate)++;
#ifdef CONFIG_RTW_MESH
} else if (check_fwstate(&iface->mlmepriv, WIFI_MESH_STATE) == _TRUE
&& check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE) == _TRUE
) {
MSTATE_MESH_NUM(mstate)++;
if (iface->stapriv.asoc_sta_count > 2)
MSTATE_MESH_LD_NUM(mstate)++;
#endif
}
if (check_fwstate(&iface->mlmepriv, WIFI_UNDER_WPS) == _TRUE)
MSTATE_WPS_NUM(mstate)++;
if (check_fwstate(&iface->mlmepriv, WIFI_UNDER_SURVEY) == _TRUE) {
MSTATE_SCAN_NUM(mstate)++;
if (mlmeext_scan_state(&iface->mlmeextpriv) != SCAN_DISABLE
&& mlmeext_scan_state(&iface->mlmeextpriv) != SCAN_BACK_OP)
MSTATE_SCAN_ENTER_NUM(mstate)++;
}
#ifdef CONFIG_IOCTL_CFG80211
if (rtw_cfg80211_get_is_mgmt_tx(iface))
MSTATE_MGMT_TX_NUM(mstate)++;
if (rtw_cfg80211_get_is_roch(iface) == _TRUE)
MSTATE_ROCH_NUM(mstate)++;
#endif /* CONFIG_IOCTL_CFG80211 */
#ifdef CONFIG_P2P
if (MLME_IS_PD(iface))
MSTATE_P2P_DV_NUM(mstate)++;
#endif
}
}
inline void rtw_mi_status(_adapter *adapter, struct mi_state *mstate)
{
return rtw_mi_status_by_ifbmp(adapter_to_dvobj(adapter), 0xFF, mstate);
}
inline void rtw_mi_status_no_self(_adapter *adapter, struct mi_state *mstate)
{
return rtw_mi_status_by_ifbmp(adapter_to_dvobj(adapter), 0xFF & ~BIT(adapter->iface_id), mstate);
}
inline void rtw_mi_status_no_others(_adapter *adapter, struct mi_state *mstate)
{
return rtw_mi_status_by_ifbmp(adapter_to_dvobj(adapter), BIT(adapter->iface_id), mstate);
}
inline void rtw_mi_status_merge(struct mi_state *d, struct mi_state *a)
{
d->sta_num += a->sta_num;
d->ld_sta_num += a->ld_sta_num;
d->lg_sta_num += a->lg_sta_num;
#ifdef CONFIG_TDLS
d->ld_tdls_num += a->ld_tdls_num;
#endif
#ifdef CONFIG_AP_MODE
d->ap_num += a->ap_num;
d->ld_ap_num += a->ld_ap_num;
#endif
d->adhoc_num += a->adhoc_num;
d->ld_adhoc_num += a->ld_adhoc_num;
#ifdef CONFIG_RTW_MESH
d->mesh_num += a->mesh_num;
d->ld_mesh_num += a->ld_mesh_num;
#endif
d->scan_num += a->scan_num;
d->scan_enter_num += a->scan_enter_num;
d->uwps_num += a->uwps_num;
#ifdef CONFIG_IOCTL_CFG80211
#ifdef CONFIG_P2P
d->roch_num += a->roch_num;
#endif
d->mgmt_tx_num += a->mgmt_tx_num;
#endif
}
void dump_mi_status(void *sel, struct dvobj_priv *dvobj)
{
RTW_PRINT_SEL(sel, "== dvobj-iface_state ==\n");
RTW_PRINT_SEL(sel, "sta_num:%d\n", DEV_STA_NUM(dvobj));
RTW_PRINT_SEL(sel, "linking_sta_num:%d\n", DEV_STA_LG_NUM(dvobj));
RTW_PRINT_SEL(sel, "linked_sta_num:%d\n", DEV_STA_LD_NUM(dvobj));
#ifdef CONFIG_TDLS
RTW_PRINT_SEL(sel, "linked_tdls_num:%d\n", DEV_TDLS_LD_NUM(dvobj));
#endif
#ifdef CONFIG_AP_MODE
RTW_PRINT_SEL(sel, "ap_num:%d\n", DEV_AP_NUM(dvobj));
RTW_PRINT_SEL(sel, "starting_ap_num:%d\n", DEV_AP_STARTING_NUM(dvobj));
RTW_PRINT_SEL(sel, "linked_ap_num:%d\n", DEV_AP_LD_NUM(dvobj));
#endif
RTW_PRINT_SEL(sel, "adhoc_num:%d\n", DEV_ADHOC_NUM(dvobj));
RTW_PRINT_SEL(sel, "linked_adhoc_num:%d\n", DEV_ADHOC_LD_NUM(dvobj));
#ifdef CONFIG_RTW_MESH
RTW_PRINT_SEL(sel, "mesh_num:%d\n", DEV_MESH_NUM(dvobj));
RTW_PRINT_SEL(sel, "linked_mesh_num:%d\n", DEV_MESH_LD_NUM(dvobj));
#endif
#ifdef CONFIG_P2P
RTW_PRINT_SEL(sel, "p2p_device_num:%d\n", DEV_P2P_DV_NUM(dvobj));
RTW_PRINT_SEL(sel, "p2p_gc_num:%d\n", DEV_P2P_GC_NUM(dvobj));
RTW_PRINT_SEL(sel, "p2p_go_num:%d\n", DEV_P2P_GO_NUM(dvobj));
#endif
RTW_PRINT_SEL(sel, "scan_num:%d\n", DEV_SCAN_NUM(dvobj));
RTW_PRINT_SEL(sel, "under_wps_num:%d\n", DEV_WPS_NUM(dvobj));
#if defined(CONFIG_IOCTL_CFG80211)
#if defined(CONFIG_P2P)
RTW_PRINT_SEL(sel, "roch_num:%d\n", DEV_ROCH_NUM(dvobj));
#endif
RTW_PRINT_SEL(sel, "mgmt_tx_num:%d\n", DEV_MGMT_TX_NUM(dvobj));
#endif
RTW_PRINT_SEL(sel, "union_ch:%d\n", DEV_U_CH(dvobj));
RTW_PRINT_SEL(sel, "union_bw:%d\n", DEV_U_BW(dvobj));
RTW_PRINT_SEL(sel, "union_offset:%d\n", DEV_U_OFFSET(dvobj));
RTW_PRINT_SEL(sel, "================\n\n");
}
void dump_dvobj_mi_status(void *sel, const char *fun_name, _adapter *adapter)
{
RTW_INFO("\n[ %s ] call %s\n", fun_name, __func__);
dump_mi_status(sel, adapter_to_dvobj(adapter));
}
inline void rtw_mi_update_iface_status(struct mlme_priv *pmlmepriv, sint state)
{
_adapter *adapter = container_of(pmlmepriv, _adapter, mlmepriv);
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
struct mi_state *iface_state = &dvobj->iface_state;
struct mi_state tmp_mstate;
if (state == WIFI_MONITOR_STATE
|| state == 0xFFFFFFFF
)
return;
if (0)
RTW_INFO("%s => will change or clean state to 0x%08x\n", __func__, state);
rtw_mi_status(adapter, &tmp_mstate);
_rtw_memcpy(iface_state, &tmp_mstate, sizeof(struct mi_state));
#ifdef DBG_IFACE_STATUS
DBG_IFACE_STATUS_DUMP(adapter);
#endif
}
u8 rtw_mi_check_status(_adapter *adapter, u8 type)
{
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
struct mi_state *iface_state = &dvobj->iface_state;
u8 ret = _FALSE;
#ifdef DBG_IFACE_STATUS
DBG_IFACE_STATUS_DUMP(adapter);
RTW_INFO("%s-"ADPT_FMT" check type:%d\n", __func__, ADPT_ARG(adapter), type);
#endif
switch (type) {
case MI_LINKED:
if (MSTATE_STA_LD_NUM(iface_state) || MSTATE_AP_NUM(iface_state) || MSTATE_ADHOC_NUM(iface_state) || MSTATE_MESH_NUM(iface_state)) /*check_fwstate(&iface->mlmepriv, WIFI_ASOC_STATE)*/
ret = _TRUE;
break;
case MI_ASSOC:
if (MSTATE_STA_LD_NUM(iface_state) || MSTATE_AP_LD_NUM(iface_state) || MSTATE_ADHOC_LD_NUM(iface_state) || MSTATE_MESH_LD_NUM(iface_state))
ret = _TRUE;
break;
case MI_UNDER_WPS:
if (MSTATE_WPS_NUM(iface_state))
ret = _TRUE;
break;
case MI_AP_MODE:
if (MSTATE_AP_NUM(iface_state))
ret = _TRUE;
break;
case MI_AP_ASSOC:
if (MSTATE_AP_LD_NUM(iface_state))
ret = _TRUE;
break;
case MI_ADHOC:
if (MSTATE_ADHOC_NUM(iface_state))
ret = _TRUE;
break;
case MI_ADHOC_ASSOC:
if (MSTATE_ADHOC_LD_NUM(iface_state))
ret = _TRUE;
break;
#ifdef CONFIG_RTW_MESH
case MI_MESH:
if (MSTATE_MESH_NUM(iface_state))
ret = _TRUE;
break;
case MI_MESH_ASSOC:
if (MSTATE_MESH_LD_NUM(iface_state))
ret = _TRUE;
break;
#endif
case MI_STA_NOLINK: /* this is misleading, but not used now */
if (MSTATE_STA_NUM(iface_state) && (!(MSTATE_STA_LD_NUM(iface_state) || MSTATE_STA_LG_NUM(iface_state))))
ret = _TRUE;
break;
case MI_STA_LINKED:
if (MSTATE_STA_LD_NUM(iface_state))
ret = _TRUE;
break;
case MI_STA_LINKING:
if (MSTATE_STA_LG_NUM(iface_state))
ret = _TRUE;
break;
default:
break;
}
return ret;
}
/*
* return value : 0 is failed or have not interface meet condition
* return value : !0 is success or interface numbers which meet condition
* return value of ops_func must be _TRUE or _FALSE
*/
static u8 _rtw_mi_process(_adapter *padapter, bool exclude_self,
void *data, u8(*ops_func)(_adapter *padapter, void *data))
{
int i;
_adapter *iface;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
u8 ret = 0;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if ((iface) && rtw_is_adapter_up(iface)) {
if ((exclude_self) && (iface == padapter))
continue;
if (ops_func)
if (_TRUE == ops_func(iface, data))
ret++;
}
}
return ret;
}
static u8 _rtw_mi_process_without_schk(_adapter *padapter, bool exclude_self,
void *data, u8(*ops_func)(_adapter *padapter, void *data))
{
int i;
_adapter *iface;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
u8 ret = 0;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (iface) {
if ((exclude_self) && (iface == padapter))
continue;
if (ops_func)
if (ops_func(iface, data) == _TRUE)
ret++;
}
}
return ret;
}
static u8 _rtw_mi_netif_caroff_qstop(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
rtw_netif_carrier_off(pnetdev);
rtw_netif_stop_queue(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_caroff_qstop(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_caroff_qstop);
}
u8 rtw_mi_buddy_netif_caroff_qstop(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_caroff_qstop);
}
static u8 _rtw_mi_netif_caron_qstart(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
rtw_netif_carrier_on(pnetdev);
rtw_netif_start_queue(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_caron_qstart(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_caron_qstart);
}
u8 rtw_mi_buddy_netif_caron_qstart(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_caron_qstart);
}
static u8 _rtw_mi_netif_stop_queue(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
rtw_netif_stop_queue(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_stop_queue(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_stop_queue);
}
u8 rtw_mi_buddy_netif_stop_queue(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_stop_queue);
}
static u8 _rtw_mi_netif_wake_queue(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
if (pnetdev)
rtw_netif_wake_queue(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_wake_queue(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_wake_queue);
}
u8 rtw_mi_buddy_netif_wake_queue(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_wake_queue);
}
static u8 _rtw_mi_netif_carrier_on(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
if (pnetdev)
rtw_netif_carrier_on(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_carrier_on(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_carrier_on);
}
u8 rtw_mi_buddy_netif_carrier_on(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_carrier_on);
}
static u8 _rtw_mi_netif_carrier_off(_adapter *padapter, void *data)
{
struct net_device *pnetdev = padapter->pnetdev;
if (pnetdev)
rtw_netif_carrier_off(pnetdev);
return _TRUE;
}
u8 rtw_mi_netif_carrier_off(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_netif_carrier_off);
}
u8 rtw_mi_buddy_netif_carrier_off(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_netif_carrier_off);
}
static u8 _rtw_mi_scan_abort(_adapter *adapter, void *data)
{
bool bwait = *(bool *)data;
if (bwait)
rtw_scan_abort(adapter);
else
rtw_scan_abort_no_wait(adapter);
return _TRUE;
}
void rtw_mi_scan_abort(_adapter *adapter, bool bwait)
{
bool in_data = bwait;
_rtw_mi_process(adapter, _FALSE, &in_data, _rtw_mi_scan_abort);
}
void rtw_mi_buddy_scan_abort(_adapter *adapter, bool bwait)
{
bool in_data = bwait;
_rtw_mi_process(adapter, _TRUE, &in_data, _rtw_mi_scan_abort);
}
static u32 _rtw_mi_start_drv_threads(_adapter *adapter, bool exclude_self)
{
int i;
_adapter *iface = NULL;
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
u32 _status = _SUCCESS;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (iface) {
if ((exclude_self) && (iface == adapter))
continue;
if (rtw_start_drv_threads(iface) == _FAIL) {
_status = _FAIL;
break;
}
}
}
return _status;
}
u32 rtw_mi_start_drv_threads(_adapter *adapter)
{
return _rtw_mi_start_drv_threads(adapter, _FALSE);
}
u32 rtw_mi_buddy_start_drv_threads(_adapter *adapter)
{
return _rtw_mi_start_drv_threads(adapter, _TRUE);
}
static void _rtw_mi_stop_drv_threads(_adapter *adapter, bool exclude_self)
{
int i;
_adapter *iface = NULL;
struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (iface) {
if ((exclude_self) && (iface == adapter))
continue;
rtw_stop_drv_threads(iface);
}
}
}
void rtw_mi_stop_drv_threads(_adapter *adapter)
{
_rtw_mi_stop_drv_threads(adapter, _FALSE);
}
void rtw_mi_buddy_stop_drv_threads(_adapter *adapter)
{
_rtw_mi_stop_drv_threads(adapter, _TRUE);
}
static u8 _rtw_mi_cancel_all_timer(_adapter *adapter, void *data)
{
rtw_cancel_all_timer(adapter);
return _TRUE;
}
void rtw_mi_cancel_all_timer(_adapter *adapter)
{
_rtw_mi_process(adapter, _FALSE, NULL, _rtw_mi_cancel_all_timer);
}
void rtw_mi_buddy_cancel_all_timer(_adapter *adapter)
{
_rtw_mi_process(adapter, _TRUE, NULL, _rtw_mi_cancel_all_timer);
}
static u8 _rtw_mi_reset_drv_sw(_adapter *adapter, void *data)
{
rtw_reset_drv_sw(adapter);
return _TRUE;
}
void rtw_mi_reset_drv_sw(_adapter *adapter)
{
_rtw_mi_process_without_schk(adapter, _FALSE, NULL, _rtw_mi_reset_drv_sw);
}
void rtw_mi_buddy_reset_drv_sw(_adapter *adapter)
{
_rtw_mi_process_without_schk(adapter, _TRUE, NULL, _rtw_mi_reset_drv_sw);
}
static u8 _rtw_mi_intf_start(_adapter *adapter, void *data)
{
rtw_intf_start(adapter);
return _TRUE;
}
void rtw_mi_intf_start(_adapter *adapter)
{
_rtw_mi_process(adapter, _FALSE, NULL, _rtw_mi_intf_start);
}
void rtw_mi_buddy_intf_start(_adapter *adapter)
{
_rtw_mi_process(adapter, _TRUE, NULL, _rtw_mi_intf_start);
}
static u8 _rtw_mi_intf_stop(_adapter *adapter, void *data)
{
rtw_intf_stop(adapter);
return _TRUE;
}
void rtw_mi_intf_stop(_adapter *adapter)
{
_rtw_mi_process(adapter, _FALSE, NULL, _rtw_mi_intf_stop);
}
void rtw_mi_buddy_intf_stop(_adapter *adapter)
{
_rtw_mi_process(adapter, _TRUE, NULL, _rtw_mi_intf_stop);
}
#ifdef CONFIG_NEW_NETDEV_HDL
u8 rtw_mi_hal_iface_init(_adapter *padapter)
{
int i;
_adapter *iface;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
u8 ret = _TRUE;
for (i = 0; i < dvobj->iface_nums; i++) {
iface = dvobj->padapters[i];
if (iface && iface->netif_up)
rtw_hal_iface_init(padapter);
}
return ret;
}
#endif
static u8 _rtw_mi_suspend_free_assoc_resource(_adapter *padapter, void *data)
{
return rtw_suspend_free_assoc_resource(padapter);
}
void rtw_mi_suspend_free_assoc_resource(_adapter *adapter)
{
_rtw_mi_process(adapter, _FALSE, NULL, _rtw_mi_suspend_free_assoc_resource);
}
void rtw_mi_buddy_suspend_free_assoc_resource(_adapter *adapter)
{
_rtw_mi_process(adapter, _TRUE, NULL, _rtw_mi_suspend_free_assoc_resource);
}
static u8 _rtw_mi_is_scan_deny(_adapter *adapter, void *data)
{
return rtw_is_scan_deny(adapter);
}
u8 rtw_mi_is_scan_deny(_adapter *adapter)
{
return _rtw_mi_process(adapter, _FALSE, NULL, _rtw_mi_is_scan_deny);
}
u8 rtw_mi_buddy_is_scan_deny(_adapter *adapter)
{
return _rtw_mi_process(adapter, _TRUE, NULL, _rtw_mi_is_scan_deny);
}
#ifdef CONFIG_SET_SCAN_DENY_TIMER
static u8 _rtw_mi_set_scan_deny(_adapter *adapter, void *data)
{
u32 ms = *(u32 *)data;
rtw_set_scan_deny(adapter, ms);
return _TRUE;
}
void rtw_mi_set_scan_deny(_adapter *adapter, u32 ms)
{
u32 in_data = ms;
_rtw_mi_process(adapter, _FALSE, &in_data, _rtw_mi_set_scan_deny);
}
void rtw_mi_buddy_set_scan_deny(_adapter *adapter, u32 ms)
{
u32 in_data = ms;
_rtw_mi_process(adapter, _TRUE, &in_data, _rtw_mi_set_scan_deny);
}
#endif /*CONFIG_SET_SCAN_DENY_TIMER*/
#ifdef CONFIG_AP_MODE
static u8 _rtw_mi_beacon_update(_adapter *padapter, void *data)
{
if (!MLME_IS_STA(padapter)
&& check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == _TRUE) {
RTW_INFO(ADPT_FMT" - update_beacon\n", ADPT_ARG(padapter));
update_beacon(padapter, 0xFF, NULL, _TRUE, 0);
}
return _TRUE;
}
void rtw_mi_beacon_update(_adapter *padapter)
{
_rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_beacon_update);
}
void rtw_mi_buddy_beacon_update(_adapter *padapter)
{
_rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_beacon_update);
}
#endif /* CONFIG_AP_MODE */
#ifndef CONFIG_MI_WITH_MBSSID_CAM
static u8 _rtw_mi_hal_dump_macaddr(_adapter *padapter, void *sel)
{
u8 mac_addr[ETH_ALEN] = {0};
rtw_hal_get_hwreg(padapter, HW_VAR_MAC_ADDR, mac_addr);
RTW_PRINT_SEL(sel, ADPT_FMT"- hw port(%d) mac_addr ="MAC_FMT"\n",
ADPT_ARG(padapter), padapter->hw_port, MAC_ARG(mac_addr));
return _TRUE;
}
void rtw_mi_hal_dump_macaddr(void *sel, _adapter *padapter)
{
_rtw_mi_process(padapter, _FALSE, sel, _rtw_mi_hal_dump_macaddr);
}
void rtw_mi_buddy_hal_dump_macaddr(void *sel, _adapter *padapter)
{
_rtw_mi_process(padapter, _TRUE, sel, _rtw_mi_hal_dump_macaddr);
}
#endif
#ifdef CONFIG_PCI_HCI
static u8 _rtw_mi_xmit_tasklet_schedule(_adapter *padapter, void *data)
{
if (rtw_txframes_pending(padapter)) {
/* try to deal with the pending packets */
tasklet_hi_schedule(&(padapter->xmitpriv.xmit_tasklet));
}
return _TRUE;
}
void rtw_mi_xmit_tasklet_schedule(_adapter *padapter)
{
_rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_xmit_tasklet_schedule);
}
void rtw_mi_buddy_xmit_tasklet_schedule(_adapter *padapter)
{
_rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_xmit_tasklet_schedule);
}
#endif
u8 _rtw_mi_busy_traffic_check(_adapter *padapter, void *data)
{
return padapter->mlmepriv.LinkDetectInfo.bBusyTraffic;
}
u8 rtw_mi_busy_traffic_check(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_busy_traffic_check);
}
u8 rtw_mi_buddy_busy_traffic_check(_adapter *padapter)
{
return _rtw_mi_process(padapter, _TRUE, NULL, _rtw_mi_busy_traffic_check);
}
static u8 _rtw_mi_check_mlmeinfo_state(_adapter *padapter, void *data)
{
u32 state = *(u32 *)data;
struct mlme_ext_priv *mlmeext = &padapter->mlmeextpriv;
/*if (mlmeext_msr(mlmeext) == state)*/
if (check_mlmeinfo_state(mlmeext, state))
return _TRUE;
else
return _FALSE;
}
u8 rtw_mi_check_mlmeinfo_state(_adapter *padapter, u32 state)
{
u32 in_data = state;
return _rtw_mi_process(padapter, _FALSE, &in_data, _rtw_mi_check_mlmeinfo_state);
}
u8 rtw_mi_buddy_check_mlmeinfo_state(_adapter *padapter, u32 state)
{
u32 in_data = state;
return _rtw_mi_process(padapter, _TRUE, &in_data, _rtw_mi_check_mlmeinfo_state);
}
/*#define DBG_DUMP_FW_STATE*/
#ifdef DBG_DUMP_FW_STATE
static void rtw_dbg_dump_fwstate(_adapter *padapter, sint state)
{
u8 buf[32] = {0};
if (state & WIFI_FW_NULL_STATE) {
_rtw_memset(buf, 0, 32);
sprintf(buf, "WIFI_FW_NULL_STATE");
RTW_INFO(FUNC_ADPT_FMT"fwstate-%s\n", FUNC_ADPT_ARG(padapter), buf);
}
if (state & WIFI_ASOC_STATE) {
_rtw_memset(buf, 0, 32);
sprintf(buf, "WIFI_ASOC_STATE");
RTW_INFO(FUNC_ADPT_FMT"fwstate-%s\n", FUNC_ADPT_ARG(padapter), buf);
}
if (state & WIFI_UNDER_LINKING) {
_rtw_memset(buf, 0, 32);
sprintf(buf, "WIFI_UNDER_LINKING");
RTW_INFO(FUNC_ADPT_FMT"fwstate-%s\n", FUNC_ADPT_ARG(padapter), buf);
}
if (state & WIFI_UNDER_SURVEY) {
_rtw_memset(buf, 0, 32);
sprintf(buf, "WIFI_UNDER_SURVEY");
RTW_INFO(FUNC_ADPT_FMT"fwstate-%s\n", FUNC_ADPT_ARG(padapter), buf);
}
}
#endif
static u8 _rtw_mi_check_fwstate(_adapter *padapter, void *data)
{
u8 ret = _FALSE;
sint state = *(sint *)data;
if ((state == WIFI_FW_NULL_STATE) &&
(padapter->mlmepriv.fw_state == WIFI_FW_NULL_STATE))
ret = _TRUE;
else if (_TRUE == check_fwstate(&padapter->mlmepriv, state))
ret = _TRUE;
#ifdef DBG_DUMP_FW_STATE
if (ret)
rtw_dbg_dump_fwstate(padapter, state);
#endif
return ret;
}
u8 rtw_mi_check_fwstate(_adapter *padapter, sint state)
{
sint in_data = state;
return _rtw_mi_process(padapter, _FALSE, &in_data, _rtw_mi_check_fwstate);
}
u8 rtw_mi_buddy_check_fwstate(_adapter *padapter, sint state)
{
sint in_data = state;
return _rtw_mi_process(padapter, _TRUE, &in_data, _rtw_mi_check_fwstate);
}
static u8 _rtw_mi_traffic_statistics(_adapter *padapter , void *data)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
/* Tx */
pdvobjpriv->traffic_stat.tx_bytes += padapter->xmitpriv.tx_bytes;
pdvobjpriv->traffic_stat.tx_pkts += padapter->xmitpriv.tx_pkts;
pdvobjpriv->traffic_stat.tx_drop += padapter->xmitpriv.tx_drop;
/* Rx */
pdvobjpriv->traffic_stat.rx_bytes += padapter->recvpriv.rx_bytes;
pdvobjpriv->traffic_stat.rx_pkts += padapter->recvpriv.rx_pkts;
pdvobjpriv->traffic_stat.rx_drop += padapter->recvpriv.rx_drop;
return _TRUE;
}
u8 rtw_mi_traffic_statistics(_adapter *padapter)
{
return _rtw_mi_process(padapter, _FALSE, NULL, _rtw_mi_traffic_statistics);
}
static u8 _rtw_mi_check_miracast_enabled(_adapter *padapter , void *data)
{
return is_miracast_enabled(padapter);