forked from lwfinger/rtw89
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.h
3485 lines (3052 loc) · 77.6 KB
/
core.h
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
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/* Copyright(c) 2019-2020 Realtek Corporation
*/
#ifndef __RTW89_CORE_H__
#define __RTW89_CORE_H__
#include <linux/average.h>
#include <linux/bitfield.h>
#include <linux/firmware.h>
#include <linux/iopoll.h>
#include <linux/workqueue.h>
#include <net/mac80211.h>
#include <linux/version.h>
struct rtw89_dev;
extern const struct ieee80211_ops rtw89_ops;
extern const struct rtw89_chip_info rtw8852a_chip_info;
#define MASKBYTE0 0xff
#define MASKBYTE1 0xff00
#define MASKBYTE2 0xff0000
#define MASKBYTE3 0xff000000
#define MASKBYTE4 0xff00000000ULL
#define MASKHWORD 0xffff0000
#define MASKLWORD 0x0000ffff
#define MASKDWORD 0xffffffff
#define RFREG_MASK 0xfffff
#define INV_RF_DATA 0xffffffff
#define RTW89_TRACK_WORK_PERIOD round_jiffies_relative(HZ * 2)
#define CFO_TRACK_MAX_USER 64
#define MAX_RSSI 110
#define RSSI_FACTOR 1
#define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI)
#define RTW89_MAX_HW_PORT_NUM 5
#define RTW89_HTC_MASK_VARIANT GENMASK(1, 0)
#define RTW89_HTC_VARIANT_HE 3
#define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2)
#define RTW89_HTC_VARIANT_HE_CID_CAS 6
#define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6)
enum rtw89_subband {
RTW89_CH_2G = 0,
RTW89_CH_5G_BAND_1 = 1,
/* RTW89_CH_5G_BAND_2 = 2, unused */
RTW89_CH_5G_BAND_3 = 3,
RTW89_CH_5G_BAND_4 = 4,
RTW89_SUBBAND_NR,
};
enum rtw89_hci_type {
RTW89_HCI_TYPE_PCIE,
RTW89_HCI_TYPE_USB,
RTW89_HCI_TYPE_SDIO,
};
enum rtw89_core_chip_id {
RTL8852A,
RTL8852B,
RTL8852C,
};
enum rtw89_cv {
CHIP_CAV,
CHIP_CBV,
CHIP_CCV,
CHIP_CDV,
CHIP_CEV,
CHIP_CFV,
CHIP_CV_MAX,
CHIP_CV_INVALID = CHIP_CV_MAX,
};
enum rtw89_core_tx_type {
RTW89_CORE_TX_TYPE_DATA,
RTW89_CORE_TX_TYPE_MGMT,
RTW89_CORE_TX_TYPE_FWCMD,
};
enum rtw89_core_rx_type {
RTW89_CORE_RX_TYPE_WIFI = 0,
RTW89_CORE_RX_TYPE_PPDU_STAT = 1,
RTW89_CORE_RX_TYPE_CHAN_INFO = 2,
RTW89_CORE_RX_TYPE_BB_SCOPE = 3,
RTW89_CORE_RX_TYPE_F2P_TXCMD = 4,
RTW89_CORE_RX_TYPE_SS2FW = 5,
RTW89_CORE_RX_TYPE_TX_REPORT = 6,
RTW89_CORE_RX_TYPE_TX_REL_HOST = 7,
RTW89_CORE_RX_TYPE_DFS_REPORT = 8,
RTW89_CORE_RX_TYPE_TX_REL_CPU = 9,
RTW89_CORE_RX_TYPE_C2H = 10,
RTW89_CORE_RX_TYPE_CSI = 11,
RTW89_CORE_RX_TYPE_CQI = 12,
};
enum rtw89_txq_flags {
RTW89_TXQ_F_AMPDU = 0,
RTW89_TXQ_F_BLOCK_BA = 1,
};
enum rtw89_net_type {
RTW89_NET_TYPE_NO_LINK = 0,
RTW89_NET_TYPE_AD_HOC = 1,
RTW89_NET_TYPE_INFRA = 2,
RTW89_NET_TYPE_AP_MODE = 3,
};
enum rtw89_wifi_role {
RTW89_WIFI_ROLE_NONE,
RTW89_WIFI_ROLE_STATION,
RTW89_WIFI_ROLE_AP,
RTW89_WIFI_ROLE_AP_VLAN,
RTW89_WIFI_ROLE_ADHOC,
RTW89_WIFI_ROLE_ADHOC_MASTER,
RTW89_WIFI_ROLE_MESH_POINT,
RTW89_WIFI_ROLE_MONITOR,
RTW89_WIFI_ROLE_P2P_DEVICE,
RTW89_WIFI_ROLE_P2P_CLIENT,
RTW89_WIFI_ROLE_P2P_GO,
RTW89_WIFI_ROLE_NAN,
RTW89_WIFI_ROLE_MLME_MAX
};
enum rtw89_upd_mode {
RTW89_VIF_CREATE,
RTW89_VIF_REMOVE,
RTW89_VIF_TYPE_CHANGE,
RTW89_VIF_INFO_CHANGE,
RTW89_VIF_CON_DISCONN
};
enum rtw89_self_role {
RTW89_SELF_ROLE_CLIENT,
RTW89_SELF_ROLE_AP,
RTW89_SELF_ROLE_AP_CLIENT
};
enum rtw89_msk_sO_el {
RTW89_NO_MSK,
RTW89_SMA,
RTW89_TMA,
RTW89_BSSID
};
enum rtw89_sch_tx_sel {
RTW89_SCH_TX_SEL_ALL,
RTW89_SCH_TX_SEL_HIQ,
RTW89_SCH_TX_SEL_MG0,
RTW89_SCH_TX_SEL_MACID,
};
/* RTW89_ADDR_CAM_SEC_NONE : not enabled
* RTW89_ADDR_CAM_SEC_ALL_UNI : 0 - 6 unicast
* RTW89_ADDR_CAM_SEC_NORMAL : 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP
* RTW89_ADDR_CAM_SEC_4GROUP : 0 - 1 unicast, 2 - 5 group, 6 BIP
*/
enum rtw89_add_cam_sec_mode {
RTW89_ADDR_CAM_SEC_NONE = 0,
RTW89_ADDR_CAM_SEC_ALL_UNI = 1,
RTW89_ADDR_CAM_SEC_NORMAL = 2,
RTW89_ADDR_CAM_SEC_4GROUP = 3,
};
enum rtw89_sec_key_type {
RTW89_SEC_KEY_TYPE_NONE = 0,
RTW89_SEC_KEY_TYPE_WEP40 = 1,
RTW89_SEC_KEY_TYPE_WEP104 = 2,
RTW89_SEC_KEY_TYPE_TKIP = 3,
RTW89_SEC_KEY_TYPE_WAPI = 4,
RTW89_SEC_KEY_TYPE_GCMSMS4 = 5,
RTW89_SEC_KEY_TYPE_CCMP128 = 6,
RTW89_SEC_KEY_TYPE_CCMP256 = 7,
RTW89_SEC_KEY_TYPE_GCMP128 = 8,
RTW89_SEC_KEY_TYPE_GCMP256 = 9,
RTW89_SEC_KEY_TYPE_BIP_CCMP128 = 10,
};
enum rtw89_port {
RTW89_PORT_0 = 0,
RTW89_PORT_1 = 1,
RTW89_PORT_2 = 2,
RTW89_PORT_3 = 3,
RTW89_PORT_4 = 4,
RTW89_PORT_NUM
};
enum rtw89_band {
RTW89_BAND_2G = 0,
RTW89_BAND_5G = 1,
RTW89_BAND_MAX,
};
enum rtw89_hw_rate {
RTW89_HW_RATE_CCK1 = 0x0,
RTW89_HW_RATE_CCK2 = 0x1,
RTW89_HW_RATE_CCK5_5 = 0x2,
RTW89_HW_RATE_CCK11 = 0x3,
RTW89_HW_RATE_OFDM6 = 0x4,
RTW89_HW_RATE_OFDM9 = 0x5,
RTW89_HW_RATE_OFDM12 = 0x6,
RTW89_HW_RATE_OFDM18 = 0x7,
RTW89_HW_RATE_OFDM24 = 0x8,
RTW89_HW_RATE_OFDM36 = 0x9,
RTW89_HW_RATE_OFDM48 = 0xA,
RTW89_HW_RATE_OFDM54 = 0xB,
RTW89_HW_RATE_MCS0 = 0x80,
RTW89_HW_RATE_MCS1 = 0x81,
RTW89_HW_RATE_MCS2 = 0x82,
RTW89_HW_RATE_MCS3 = 0x83,
RTW89_HW_RATE_MCS4 = 0x84,
RTW89_HW_RATE_MCS5 = 0x85,
RTW89_HW_RATE_MCS6 = 0x86,
RTW89_HW_RATE_MCS7 = 0x87,
RTW89_HW_RATE_MCS8 = 0x88,
RTW89_HW_RATE_MCS9 = 0x89,
RTW89_HW_RATE_MCS10 = 0x8A,
RTW89_HW_RATE_MCS11 = 0x8B,
RTW89_HW_RATE_MCS12 = 0x8C,
RTW89_HW_RATE_MCS13 = 0x8D,
RTW89_HW_RATE_MCS14 = 0x8E,
RTW89_HW_RATE_MCS15 = 0x8F,
RTW89_HW_RATE_MCS16 = 0x90,
RTW89_HW_RATE_MCS17 = 0x91,
RTW89_HW_RATE_MCS18 = 0x92,
RTW89_HW_RATE_MCS19 = 0x93,
RTW89_HW_RATE_MCS20 = 0x94,
RTW89_HW_RATE_MCS21 = 0x95,
RTW89_HW_RATE_MCS22 = 0x96,
RTW89_HW_RATE_MCS23 = 0x97,
RTW89_HW_RATE_MCS24 = 0x98,
RTW89_HW_RATE_MCS25 = 0x99,
RTW89_HW_RATE_MCS26 = 0x9A,
RTW89_HW_RATE_MCS27 = 0x9B,
RTW89_HW_RATE_MCS28 = 0x9C,
RTW89_HW_RATE_MCS29 = 0x9D,
RTW89_HW_RATE_MCS30 = 0x9E,
RTW89_HW_RATE_MCS31 = 0x9F,
RTW89_HW_RATE_VHT_NSS1_MCS0 = 0x100,
RTW89_HW_RATE_VHT_NSS1_MCS1 = 0x101,
RTW89_HW_RATE_VHT_NSS1_MCS2 = 0x102,
RTW89_HW_RATE_VHT_NSS1_MCS3 = 0x103,
RTW89_HW_RATE_VHT_NSS1_MCS4 = 0x104,
RTW89_HW_RATE_VHT_NSS1_MCS5 = 0x105,
RTW89_HW_RATE_VHT_NSS1_MCS6 = 0x106,
RTW89_HW_RATE_VHT_NSS1_MCS7 = 0x107,
RTW89_HW_RATE_VHT_NSS1_MCS8 = 0x108,
RTW89_HW_RATE_VHT_NSS1_MCS9 = 0x109,
RTW89_HW_RATE_VHT_NSS2_MCS0 = 0x110,
RTW89_HW_RATE_VHT_NSS2_MCS1 = 0x111,
RTW89_HW_RATE_VHT_NSS2_MCS2 = 0x112,
RTW89_HW_RATE_VHT_NSS2_MCS3 = 0x113,
RTW89_HW_RATE_VHT_NSS2_MCS4 = 0x114,
RTW89_HW_RATE_VHT_NSS2_MCS5 = 0x115,
RTW89_HW_RATE_VHT_NSS2_MCS6 = 0x116,
RTW89_HW_RATE_VHT_NSS2_MCS7 = 0x117,
RTW89_HW_RATE_VHT_NSS2_MCS8 = 0x118,
RTW89_HW_RATE_VHT_NSS2_MCS9 = 0x119,
RTW89_HW_RATE_VHT_NSS3_MCS0 = 0x120,
RTW89_HW_RATE_VHT_NSS3_MCS1 = 0x121,
RTW89_HW_RATE_VHT_NSS3_MCS2 = 0x122,
RTW89_HW_RATE_VHT_NSS3_MCS3 = 0x123,
RTW89_HW_RATE_VHT_NSS3_MCS4 = 0x124,
RTW89_HW_RATE_VHT_NSS3_MCS5 = 0x125,
RTW89_HW_RATE_VHT_NSS3_MCS6 = 0x126,
RTW89_HW_RATE_VHT_NSS3_MCS7 = 0x127,
RTW89_HW_RATE_VHT_NSS3_MCS8 = 0x128,
RTW89_HW_RATE_VHT_NSS3_MCS9 = 0x129,
RTW89_HW_RATE_VHT_NSS4_MCS0 = 0x130,
RTW89_HW_RATE_VHT_NSS4_MCS1 = 0x131,
RTW89_HW_RATE_VHT_NSS4_MCS2 = 0x132,
RTW89_HW_RATE_VHT_NSS4_MCS3 = 0x133,
RTW89_HW_RATE_VHT_NSS4_MCS4 = 0x134,
RTW89_HW_RATE_VHT_NSS4_MCS5 = 0x135,
RTW89_HW_RATE_VHT_NSS4_MCS6 = 0x136,
RTW89_HW_RATE_VHT_NSS4_MCS7 = 0x137,
RTW89_HW_RATE_VHT_NSS4_MCS8 = 0x138,
RTW89_HW_RATE_VHT_NSS4_MCS9 = 0x139,
RTW89_HW_RATE_HE_NSS1_MCS0 = 0x180,
RTW89_HW_RATE_HE_NSS1_MCS1 = 0x181,
RTW89_HW_RATE_HE_NSS1_MCS2 = 0x182,
RTW89_HW_RATE_HE_NSS1_MCS3 = 0x183,
RTW89_HW_RATE_HE_NSS1_MCS4 = 0x184,
RTW89_HW_RATE_HE_NSS1_MCS5 = 0x185,
RTW89_HW_RATE_HE_NSS1_MCS6 = 0x186,
RTW89_HW_RATE_HE_NSS1_MCS7 = 0x187,
RTW89_HW_RATE_HE_NSS1_MCS8 = 0x188,
RTW89_HW_RATE_HE_NSS1_MCS9 = 0x189,
RTW89_HW_RATE_HE_NSS1_MCS10 = 0x18A,
RTW89_HW_RATE_HE_NSS1_MCS11 = 0x18B,
RTW89_HW_RATE_HE_NSS2_MCS0 = 0x190,
RTW89_HW_RATE_HE_NSS2_MCS1 = 0x191,
RTW89_HW_RATE_HE_NSS2_MCS2 = 0x192,
RTW89_HW_R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1B9,
RTW89_HW_RATE_HE_NSS4_MCS10 = 0x1BA,
RTW89_HW_RATE_HE_NSS4_MCS11 = 0x1BB,
RTW89_HW_RATE_NR,
RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
};
/* 2G channels,
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
*/
#define RTW89_2G_CH_NUM 14
/* 5G channels,
* 36, 38, 40, 42, 44, 46, 48, 50,
* 52, 54, 56, 58, 60, 62, 64,
* 100, 102, 104, 106, 108, 110, 112, 114,
* 116, 118, 120, 122, 124, 126, 128, 130,
* 132, 134, 136, 138, 140, 142, 144,
* 149, 151, 153, 155, 157, 159, 161, 163,
* 165, 167, 169, 171, 173, 175, 177
*/
#define RTW89_5G_CH_NUM 53
enum rtw89_rate_section {
RTW89_RS_CCK,
RTW89_RS_OFDM,
RTW89_RS_MCS, /* for HT/VHT/HE */
RTW89_RS_HEDCM,
RTW89_RS_OFFSET,
RTW89_RS_MAX,
RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1,
};
enum rtw89_rate_max {
RTW89_RATE_CCK_MAX = 4,
RTW89_RATE_OFDM_MAX = 8,
RTW89_RATE_MCS_MAX = 12,
RTW89_RATE_HEDCM_MAX = 4, /* for HEDCM MCS0/1/3/4 */
RTW89_RATE_OFFSET_MAX = 5, /* for HE(HEDCM)/VHT/HT/OFDM/CCK offset */
};
enum rtw89_nss {
RTW89_NSS_1 = 0,
RTW89_NSS_2 = 1,
/* HE DCM only support 1ss and 2ss */
RTW89_NSS_HEDCM_MAX = RTW89_NSS_2 + 1,
RTW89_NSS_3 = 2,
RTW89_NSS_4 = 3,
RTW89_NSS_MAX,
};
enum rtw89_ntx {
RTW89_1TX = 0,
RTW89_2TX = 1,
RTW89_NTX_NUM,
};
enum rtw89_beamforming_type {
RTW89_NONBF = 0,
RTW89_BF = 1,
RTW89_BF_NUM,
};
enum rtw89_regulation_type {
RTW89_WW = 0,
RTW89_ETSI = 1,
RTW89_FCC = 2,
RTW89_MKK = 3,
RTW89_NA = 4,
RTW89_IC = 5,
RTW89_KCC = 6,
RTW89_NCC = 7,
RTW89_CHILE = 8,
RTW89_ACMA = 9,
RTW89_MEXICO = 10,
RTW89_UKRAINE = 11,
RTW89_CN = 12,
RTW89_REGD_NUM,
};
extern const u8 rtw89_rs_idx_max[RTW89_RS_MAX];
extern const u8 rtw89_rs_nss_max[RTW89_RS_MAX];
struct rtw89_txpwr_byrate {
s8 cck[RTW89_RATE_CCK_MAX];
s8 ofdm[RTW89_RATE_OFDM_MAX];
s8 mcs[RTW89_NSS_MAX][RTW89_RATE_MCS_MAX];
s8 hedcm[RTW89_NSS_HEDCM_MAX][RTW89_RATE_HEDCM_MAX];
s8 offset[RTW89_RATE_OFFSET_MAX];
};
enum rtw89_bandwidth_section_num {
RTW89_BW20_SEC_NUM = 8,
RTW89_BW40_SEC_NUM = 4,
RTW89_BW80_SEC_NUM = 2,
};
struct rtw89_txpwr_limit {
s8 cck_20m[RTW89_BF_NUM];
s8 cck_40m[RTW89_BF_NUM];
s8 ofdm[RTW89_BF_NUM];
s8 mcs_20m[RTW89_BW20_SEC_NUM][RTW89_BF_NUM];
s8 mcs_40m[RTW89_BW40_SEC_NUM][RTW89_BF_NUM];
s8 mcs_80m[RTW89_BW80_SEC_NUM][RTW89_BF_NUM];
s8 mcs_160m[RTW89_BF_NUM];
s8 mcs_40m_0p5[RTW89_BF_NUM];
s8 mcs_40m_2p5[RTW89_BF_NUM];
};
#define RTW89_RU_SEC_NUM 8
struct rtw89_txpwr_limit_ru {
s8 ru26[RTW89_RU_SEC_NUM];
s8 ru52[RTW89_RU_SEC_NUM];
s8 ru106[RTW89_RU_SEC_NUM];
};
struct rtw89_rate_desc {
enum rtw89_nss nss;
enum rtw89_rate_section rs;
u8 idx;
};
#define PHY_STS_HDR_LEN 8
#define RF_PATH_MAX 4
#define RTW89_MAX_PPDU_CNT 8
struct rtw89_rx_phy_ppdu {
u8 *buf;
u32 len;
u8 rssi_avg;
s8 rssi[RF_PATH_MAX];
u8 mac_id;
bool to_self;
bool valid;
};
enum rtw89_mac_idx {
RTW89_MAC_0 = 0,
RTW89_MAC_1 = 1,
};
enum rtw89_phy_idx {
RTW89_PHY_0 = 0,
RTW89_PHY_1 = 1,
RTW89_PHY_MAX
};
enum rtw89_rf_path {
RF_PATH_A = 0,
RF_PATH_B = 1,
RF_PATH_C = 2,
RF_PATH_D = 3,
RF_PATH_AB,
RF_PATH_AC,
RF_PATH_AD,
RF_PATH_BC,
RF_PATH_BD,
RF_PATH_CD,
RF_PATH_ABC,
RF_PATH_ABD,
RF_PATH_ACD,
RF_PATH_BCD,
RF_PATH_ABCD,
};
enum rtw89_rf_path_bit {
RF_A = BIT(0),
RF_B = BIT(1),
RF_C = BIT(2),
RF_D = BIT(3),
RF_AB = (RF_A | RF_B),
RF_AC = (RF_A | RF_C),
RF_AD = (RF_A | RF_D),
RF_BC = (RF_B | RF_C),
RF_BD = (RF_B | RF_D),
RF_CD = (RF_C | RF_D),
RF_ABC = (RF_A | RF_B | RF_C),
RF_ABD = (RF_A | RF_B | RF_D),
RF_ACD = (RF_A | RF_C | RF_D),
RF_BCD = (RF_B | RF_C | RF_D),
RF_ABCD = (RF_A | RF_B | RF_C | RF_D),
};
enum rtw89_bandwidth {
RTW89_CHANNEL_WIDTH_20 = 0,
RTW89_CHANNEL_WIDTH_40 = 1,
RTW89_CHANNEL_WIDTH_80 = 2,
RTW89_CHANNEL_WIDTH_160 = 3,
RTW89_CHANNEL_WIDTH_80_80 = 4,
RTW89_CHANNEL_WIDTH_5 = 5,
RTW89_CHANNEL_WIDTH_10 = 6,
};
enum rtw89_ps_mode {
RTW89_PS_MODE_NONE = 0,
RTW89_PS_MODE_RFOFF = 1,
RTW89_PS_MODE_CLK_GATED = 2,
RTW89_PS_MODE_PWR_GATED = 3,
};
#define RTW89_MAX_CHANNEL_WIDTH RTW89_CHANNEL_WIDTH_80
#define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
#define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_80 + 1)
#define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_80 + 1)
enum rtw89_ru_bandwidth {
RTW89_RU26 = 0,
RTW89_RU52 = 1,
RTW89_RU106 = 2,
RTW89_RU_NUM,
};
enum rtw89_sc_offset {
RTW89_SC_DONT_CARE = 0,
RTW89_SC_20_UPPER = 1,
RTW89_SC_20_LOWER = 2,
RTW89_SC_20_UPMOST = 3,
RTW89_SC_20_LOWEST = 4,
RTW89_SC_40_UPPER = 9,
RTW89_SC_40_LOWER = 10,
};
struct rtw89_channel_params {
u8 center_chan;
u8 primary_chan;
u8 bandwidth;
u8 pri_ch_idx;
u8 cch_by_bw[RTW89_MAX_CHANNEL_WIDTH + 1];
};
struct rtw89_channel_help_params {
u16 tx_en;
};
struct rtw89_port_reg {
u32 port_cfg;
u32 tbtt_prohib;
u32 bcn_area;
u32 bcn_early;
u32 tbtt_early;
u32 tbtt_agg;
u32 bcn_space;
u32 bcn_forcetx;
u32 bcn_err_cnt;
u32 bcn_err_flag;
u32 dtim_ctrl;
u32 tbtt_shift;
u32 bcn_cnt_tmr;
u32 tsftr_l;
u32 tsftr_h;
};
struct rtw89_txwd_body {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
} __packed;
struct rtw89_txwd_info {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
} __packed;
struct rtw89_rx_desc_info {
u16 pkt_size;
u8 pkt_type;
u8 drv_info_size;
u8 shift;
u8 wl_hd_iv_len;
bool long_rxdesc;
bool bb_sel;
bool mac_info_valid;
u16 data_rate;
u8 gi_ltf;
u8 bw;
u32 free_run_cnt;
u8 user_id;
bool sr_en;
u8 ppdu_cnt;
u8 ppdu_type;
bool icv_err;
bool crc32_err;
bool hw_dec;
bool sw_dec;
bool addr1_match;
u8 frag;
u16 seq;
u8 frame_type;
u8 rx_pl_id;
bool addr_cam_valid;
u8 addr_cam_id;
u8 sec_cam_id;
u8 mac_id;
u16 offset;
bool ready;
};
struct rtw89_rxdesc_short {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
} __packed;
struct rtw89_rxdesc_long {
__le32 dword0;
__le32 dword1;
__le32 dword2;
__le32 dword3;
__le32 dword4;
__le32 dword5;
__le32 dword6;
__le32 dword7;
} __packed;
struct rtw89_tx_desc_info {
u16 pkt_size;
u8 wp_offset;
u8 qsel;
u8 ch_dma;
u8 hdr_llc_len;
bool is_bmc;
bool en_wd_info;
bool wd_page;
bool use_rate;
bool dis_data_fb;
bool tid_indicate;
bool agg_en;
bool bk;
u8 ampdu_density;
u8 ampdu_num;
bool sec_en;
u8 sec_type;
u8 sec_cam_idx;
u16 data_rate;
bool fw_dl;
u16 seq;
bool a_ctrl_bsr;
};
struct rtw89_core_tx_request {
enum rtw89_core_tx_type tx_type;
struct sk_buff *skb;
struct ieee80211_vif *vif;
struct ieee80211_sta *sta;
struct rtw89_tx_desc_info desc_info;
};
struct rtw89_txq {
struct list_head list;
unsigned long flags;
int wait_cnt;
};
struct rtw89_mac_ax_gnt {
u8 gnt_bt_sw_en;
u8 gnt_bt;
u8 gnt_wl_sw_en;
u8 gnt_wl;
};
#define RTW89_MAC_AX_COEX_GNT_NR 2
struct rtw89_mac_ax_coex_gnt {
struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR];
};
enum rtw89_btc_ncnt {
BTC_NCNT_POWER_ON = 0x0,
BTC_NCNT_POWER_OFF,
BTC_NCNT_INIT_COEX,
BTC_NCNT_SCAN_START,
BTC_NCNT_SCAN_FINISH,
BTC_NCNT_SPECIAL_PACKET,
BTC_NCNT_SWITCH_BAND,
BTC_NCNT_RFK_TIMEOUT,
BTC_NCNT_SHOW_COEX_INFO,
BTC_NCNT_ROLE_INFO,
BTC_NCNT_CONTROL,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_INFOSAME,
BTC_BCNT_SCBDUPDATE,
BTC_BCNT_HIPRI_TX,
BTC_BCNT_HIPRI_RX,
BTC_BCNT_LOPRI_TX,
BTC_BCNT_LOPRI_RX,
BTC_BCNT_RATECHG,
BTC_BCNT_NUM
};
enum rtw89_btc_bt_profile {
BTC_BT_NOPROFILE = 0,
BTC_BT_HFP = BIT(0),
BTC_BT_HID = BIT(1),
BTC_BT_A2DP = BIT(2),
BTC_BT_PAN = BIT(3),
BTC_PROFILE_MAX = 4,
};
struct rtw89_btc_ant_info {
u8 type; /* shared, dedicated */
u8 num;
u8 isolation;
u8 single_pos: 1;/* Single antenna at S0 or S1 */
u8 diversity: 1;
};
enum rtw89_tfc_dir {
RTW89_TFC_UL,
RTW89_TFC_DL,
};
struct rtw89_btc_wl_smap {
u32 busy: 1;
u32 scan: 1;
u32 connecting: 1;
u32 roaming: 1;
u32 _4way: 1;
u32 rf_off: 1;
u32 lps: 1;
u32 ips: 1;
u32 init_ok: 1;
u32 traffic_dir : 2;
u32 rf_off_pre: 1;
u32 lps_pre: 1;
};
enum rtw89_tfc_lv {
RTW89_TFC_IDLE,
RTW89_TFC_ULTRA_LOW,
RTW89_TFC_LOW,
RTW89_TFC_MID,
RTW89_TFC_HIGH,
};
#define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */
DECLARE_EWMA(tp, 10, 2);
struct rtw89_traffic_stats {
/* units in bytes */
u64 tx_unicast;
u64 rx_unicast;
u32 tx_avg_len;
u32 rx_avg_len;
/* count for packets */
u64 tx_cnt;
u64 rx_cnt;
/* units in Mbps */
u32 tx_throughput;
u32 rx_throughput;
u32 tx_throughput_raw;
u32 rx_throughput_raw;
enum rtw89_tfc_lv tx_tfc_lv;
enum rtw89_tfc_lv rx_tfc_lv;
struct ewma_tp tx_ewma_tp;
struct ewma_tp rx_ewma_tp;
u16 tx_rate;
u16 rx_rate;
};
struct rtw89_btc_statistic {
u8 rssi; /* 0%~110% (dBm = rssi -110) */
struct rtw89_traffic_stats traffic;
};
#define BTC_WL_RSSI_THMAX 4
struct rtw89_btc_wl_link_info {
struct rtw89_btc_statistic stat;
enum rtw89_tfc_dir dir;
u8 rssi_state[BTC_WL_RSSI_THMAX];
u8 mac_addr[ETH_ALEN];
u8 busy;
u8 ch;
u8 bw;
u8 band;
u8 role;
u8 pid;
u8 phy;
u8 dtim_period;
u8 mode;
u8 mac_id;
u8 tx_retry;
u32 bcn_period;
u32 busy_t;
u32 tx_time;
u32 client_cnt;
u32 rx_rate_drop_cnt;
u32 active: 1;
u32 noa: 1;
u32 client_ps: 1;
u32 connected: 2;
};
union rtw89_btc_wl_state_map {
u32 val;
struct rtw89_btc_wl_smap map;
};
struct rtw89_btc_bt_hfp_desc {
u32 exist: 1;
u32 type: 2;
u32 rsvd: 29;
};
struct rtw89_btc_bt_hid_desc {
u32 exist: 1;
u32 slot_info: 2;
u32 pair_cnt: 2;
u32 type: 8;
u32 rsvd: 19;
};
struct rtw89_btc_bt_a2dp_desc {
u8 exist: 1;
u8 exist_last: 1;
u8 play_latency: 1;
u8 type: 3;
u8 active: 1;
u8 sink: 1;
u8 bitpool;
u16 vendor_id;
u32 device_name;
u32 flush_time;
};
struct rtw89_btc_bt_pan_desc {
u32 exist: 1;
u32 type: 1;
u32 active: 1;
u32 rsvd: 29;
};
struct rtw89_btc_bt_rfk_info {
u32 run: 1;
u32 req: 1;
u32 timeout: 1;
u32 rsvd: 29;
};
union rtw89_btc_bt_rfk_info_map {
u32 val;
struct rtw89_btc_bt_rfk_info map;
};
struct rtw89_btc_bt_ver_info {
u32 fw_coex; /* match with which coex_ver */
u32 fw;
};
struct rtw89_btc_bool_sta_chg {
u32 now: 1;
u32 last: 1;
u32 remain: 1;
u32 srvd: 29;
};
struct rtw89_btc_u8_sta_chg {
u8 now;
u8 last;
u8 remain;
u8 rsvd;
};
struct rtw89_btc_wl_scan_info {
u8 band[RTW89_PHY_MAX];
u8 phy_map;
u8 rsvd;
};
struct rtw89_btc_wl_dbcc_info {
u8 op_band[RTW89_PHY_MAX]; /* op band in each phy */
u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
u8 real_band[RTW89_PHY_MAX];
u8 role[RTW89_PHY_MAX]; /* role in each phy */
};
struct rtw89_btc_wl_active_role {
u8 connected: 1;
u8 pid: 3;
u8 phy: 1;
u8 noa: 1;
u8 band: 2;
u8 client_ps: 1;
u8 bw: 7;
u8 role;