Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/dev/mediatek/mt76/mt7925/mcu.h
107715 views
1
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
2
/* Copyright (C) 2023 MediaTek Inc. */
3
4
#ifndef __MT7925_MCU_H
5
#define __MT7925_MCU_H
6
7
#include "../mt76_connac_mcu.h"
8
9
/* ext event table */
10
enum {
11
MCU_EXT_EVENT_RATE_REPORT = 0x87,
12
};
13
14
struct mt7925_mcu_eeprom_info {
15
__le32 addr;
16
__le32 valid;
17
u8 data[MT7925_EEPROM_BLOCK_SIZE];
18
} __packed;
19
20
#define MT_RA_RATE_NSS GENMASK(8, 6)
21
#define MT_RA_RATE_MCS GENMASK(3, 0)
22
#define MT_RA_RATE_TX_MODE GENMASK(12, 9)
23
#define MT_RA_RATE_DCM_EN BIT(4)
24
#define MT_RA_RATE_BW GENMASK(14, 13)
25
26
struct mt7925_mcu_rxd {
27
__le32 rxd[8];
28
29
__le16 len;
30
__le16 pkt_type_id;
31
32
u8 eid;
33
u8 seq;
34
u8 option;
35
u8 __rsv;
36
37
u8 ext_eid;
38
u8 __rsv1[2];
39
u8 s2d_index;
40
41
u8 tlv[];
42
};
43
44
struct mt7925_mcu_uni_event {
45
u8 cid;
46
u8 pad[3];
47
__le32 status; /* 0: success, others: fail */
48
} __packed;
49
50
enum {
51
MT_EBF = BIT(0), /* explicit beamforming */
52
MT_IBF = BIT(1) /* implicit beamforming */
53
};
54
55
struct mt7925_mcu_reg_event {
56
__le32 reg;
57
__le32 val;
58
} __packed;
59
60
struct mt7925_mcu_ant_id_config {
61
u8 ant_id[4];
62
} __packed;
63
64
struct mt7925_txpwr_req {
65
u8 _rsv[4];
66
__le16 tag;
67
__le16 len;
68
69
u8 format_id;
70
u8 catg;
71
u8 band_idx;
72
u8 _rsv1;
73
} __packed;
74
75
struct mt7925_txpwr_event {
76
u8 rsv[4];
77
__le16 tag;
78
__le16 len;
79
80
u8 catg;
81
u8 band_idx;
82
u8 ch_band;
83
u8 format; /* 0:Legacy, 1:HE */
84
85
/* Rate power info */
86
struct mt7925_txpwr txpwr;
87
88
s8 pwr_max;
89
s8 pwr_min;
90
u8 rsv1;
91
} __packed;
92
93
enum {
94
TM_SWITCH_MODE,
95
TM_SET_AT_CMD,
96
TM_QUERY_AT_CMD,
97
};
98
99
enum {
100
MT7925_TM_NORMAL,
101
MT7925_TM_TESTMODE,
102
MT7925_TM_ICAP,
103
MT7925_TM_ICAP_OVERLAP,
104
MT7925_TM_WIFISPECTRUM,
105
};
106
107
struct mt7925_rftest_evt {
108
__le32 param0;
109
__le32 param1;
110
} __packed;
111
112
enum {
113
UNI_CHANNEL_SWITCH,
114
UNI_CHANNEL_RX_PATH,
115
};
116
117
enum {
118
UNI_CHIP_CONFIG_CHIP_CFG = 0x2,
119
UNI_CHIP_CONFIG_NIC_CAPA = 0x3,
120
};
121
122
enum {
123
UNI_BAND_CONFIG_RADIO_ENABLE,
124
UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
125
UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,
126
};
127
128
enum {
129
UNI_WSYS_CONFIG_FW_LOG_CTRL,
130
UNI_WSYS_CONFIG_FW_DBG_CTRL,
131
};
132
133
enum {
134
UNI_EFUSE_ACCESS = 1,
135
UNI_EFUSE_BUFFER_MODE,
136
UNI_EFUSE_FREE_BLOCK,
137
UNI_EFUSE_BUFFER_RD,
138
};
139
140
enum {
141
UNI_CMD_ACCESS_REG_BASIC = 0x0,
142
UNI_CMD_ACCESS_RF_REG_BASIC,
143
};
144
145
enum {
146
UNI_MBMC_SETTING,
147
};
148
149
enum {
150
UNI_EVENT_SCAN_DONE_BASIC = 0,
151
UNI_EVENT_SCAN_DONE_CHNLINFO = 2,
152
UNI_EVENT_SCAN_DONE_NLO = 3,
153
};
154
155
enum {
156
UNI_CMD_RSSI_MONITOR_SET = 0,
157
};
158
159
enum {
160
UNI_EVENT_RSSI_MONITOR_INFO = 0,
161
};
162
163
enum connac3_mcu_cipher_type {
164
CONNAC3_CIPHER_NONE = 0,
165
CONNAC3_CIPHER_WEP40 = 1,
166
CONNAC3_CIPHER_TKIP = 2,
167
CONNAC3_CIPHER_AES_CCMP = 4,
168
CONNAC3_CIPHER_WEP104 = 5,
169
CONNAC3_CIPHER_BIP_CMAC_128 = 6,
170
CONNAC3_CIPHER_WEP128 = 7,
171
CONNAC3_CIPHER_WAPI = 8,
172
CONNAC3_CIPHER_CCMP_256 = 10,
173
CONNAC3_CIPHER_GCMP = 11,
174
CONNAC3_CIPHER_GCMP_256 = 12,
175
};
176
177
struct mt7925_mcu_scan_chinfo_event {
178
u8 nr_chan;
179
u8 alpha2[3];
180
} __packed;
181
182
enum {
183
UNI_SCAN_REQ = 1,
184
UNI_SCAN_CANCEL = 2,
185
UNI_SCAN_SCHED_REQ = 3,
186
UNI_SCAN_SCHED_ENABLE = 4,
187
UNI_SCAN_SSID = 10,
188
UNI_SCAN_BSSID,
189
UNI_SCAN_CHANNEL,
190
UNI_SCAN_IE,
191
UNI_SCAN_MISC,
192
UNI_SCAN_SSID_MATCH_SETS,
193
};
194
195
enum {
196
UNI_SNIFFER_ENABLE,
197
UNI_SNIFFER_CONFIG,
198
};
199
200
#define MT7925_RNR_SCAN_MAX_BSSIDS 10
201
struct scan_hdr_tlv {
202
/* fixed field */
203
u8 seq_num;
204
u8 bss_idx;
205
u8 pad[2];
206
/* tlv */
207
u8 data[];
208
} __packed;
209
210
struct scan_req_tlv {
211
__le16 tag;
212
__le16 len;
213
214
u8 scan_type; /* 0: PASSIVE SCAN
215
* 1: ACTIVE SCAN
216
*/
217
u8 probe_req_num; /* Number of probe request for each SSID */
218
u8 scan_func; /* BIT(0) Enable random MAC scan
219
* BIT(1) Disable DBDC scan type 1~3.
220
* BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).
221
*/
222
u8 src_mask;
223
__le16 channel_min_dwell_time;
224
__le16 channel_dwell_time; /* channel Dwell interval */
225
__le16 timeout_value;
226
__le16 probe_delay_time;
227
__le32 func_mask_ext;
228
} __packed;
229
230
struct scan_ssid_tlv {
231
__le16 tag;
232
__le16 len;
233
234
u8 ssid_type; /* BIT(0) wildcard SSID
235
* BIT(1) P2P wildcard SSID
236
* BIT(2) specified SSID + wildcard SSID
237
* BIT(2) + ssid_type_ext BIT(0) specified SSID only
238
*/
239
u8 ssids_num;
240
u8 is_short_ssid;
241
u8 pad;
242
struct mt76_connac_mcu_scan_ssid ssids[MT7925_RNR_SCAN_MAX_BSSIDS];
243
} __packed;
244
245
struct scan_bssid_tlv {
246
__le16 tag;
247
__le16 len;
248
249
u8 bssid[ETH_ALEN];
250
u8 match_ch;
251
u8 match_ssid_ind;
252
u8 rcpi;
253
u8 match_short_ssid_ind;
254
u8 pad[2];
255
} __packed;
256
257
struct scan_chan_info_tlv {
258
__le16 tag;
259
__le16 len;
260
261
u8 channel_type; /* 0: Full channels
262
* 1: Only 2.4GHz channels
263
* 2: Only 5GHz channels
264
* 3: P2P social channel only (channel #1, #6 and #11)
265
* 4: Specified channels
266
* Others: Reserved
267
*/
268
u8 channels_num; /* valid when channel_type is 4 */
269
u8 pad[2];
270
struct mt76_connac_mcu_scan_channel channels[64];
271
} __packed;
272
273
struct scan_ie_tlv {
274
__le16 tag;
275
__le16 len;
276
277
__le16 ies_len;
278
u8 band;
279
u8 pad;
280
u8 ies[];
281
};
282
283
struct scan_misc_tlv {
284
__le16 tag;
285
__le16 len;
286
287
u8 random_mac[ETH_ALEN];
288
u8 rsv[2];
289
};
290
291
struct scan_sched_req {
292
__le16 tag;
293
__le16 len;
294
295
u8 version;
296
u8 stop_on_match;
297
u8 intervals_num;
298
u8 scan_func;
299
__le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];
300
};
301
302
struct scan_sched_ssid_match_sets {
303
__le16 tag;
304
__le16 len;
305
306
u8 match_num;
307
u8 rsv[3];
308
309
struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];
310
};
311
312
struct scan_sched_enable {
313
__le16 tag;
314
__le16 len;
315
316
u8 active;
317
u8 rsv[3];
318
};
319
320
struct mbmc_set_req {
321
u8 pad[4];
322
u8 data[];
323
} __packed;
324
325
struct mbmc_conf_tlv {
326
__le16 tag;
327
__le16 len;
328
329
u8 mbmc_en;
330
u8 band;
331
u8 pad[2];
332
} __packed;
333
334
struct edca {
335
__le16 tag;
336
__le16 len;
337
338
u8 queue;
339
u8 set;
340
u8 cw_min;
341
u8 cw_max;
342
__le16 txop;
343
u8 aifs;
344
u8 __rsv;
345
};
346
347
struct bss_req_hdr {
348
u8 bss_idx;
349
u8 __rsv[3];
350
} __packed;
351
352
struct bss_rate_tlv {
353
__le16 tag;
354
__le16 len;
355
u8 __rsv1[2];
356
__le16 basic_rate;
357
__le16 bc_trans;
358
__le16 mc_trans;
359
u8 short_preamble;
360
u8 bc_fixed_rate;
361
u8 mc_fixed_rate;
362
u8 __rsv2;
363
} __packed;
364
365
struct bss_mld_tlv {
366
__le16 tag;
367
__le16 len;
368
u8 group_mld_id;
369
u8 own_mld_id;
370
u8 mac_addr[ETH_ALEN];
371
u8 remap_idx;
372
u8 link_id;
373
u8 eml_enable;
374
u8 max_link_num;
375
u8 hybrid_mode;
376
u8 __rsv[3];
377
} __packed;
378
379
struct bss_eht_tlv {
380
__le16 tag;
381
__le16 len;
382
u8 is_eht_op_present;
383
u8 is_eth_dscb_present;
384
u8 eht_ctrl;
385
u8 eht_ccfs0;
386
u8 eht_ccfs1;
387
u8 pad1;
388
__le16 eht_dis_sub_chan_bitmap;
389
u8 pad2[4];
390
} __packed;
391
392
struct sta_rec_ba_uni {
393
__le16 tag;
394
__le16 len;
395
u8 tid;
396
u8 ba_type;
397
u8 amsdu;
398
u8 ba_en;
399
__le16 ssn;
400
__le16 winsize;
401
u8 ba_rdd_rro;
402
u8 __rsv[3];
403
} __packed;
404
405
struct sta_rec_eht {
406
__le16 tag;
407
__le16 len;
408
u8 tid_bitmap;
409
u8 _rsv;
410
__le16 mac_cap;
411
__le64 phy_cap;
412
__le64 phy_cap_ext;
413
u8 mcs_map_bw20[4];
414
u8 mcs_map_bw80[3];
415
u8 mcs_map_bw160[3];
416
u8 mcs_map_bw320[3];
417
u8 _rsv2[3];
418
} __packed;
419
420
struct sta_rec_sec_uni {
421
__le16 tag;
422
__le16 len;
423
u8 add;
424
u8 tx_key;
425
u8 key_type;
426
u8 is_authenticator;
427
u8 peer_addr[6];
428
u8 bss_idx;
429
u8 cipher_id;
430
u8 key_id;
431
u8 key_len;
432
u8 wlan_idx;
433
u8 mgmt_prot;
434
u8 key[32];
435
u8 key_rsc[16];
436
} __packed;
437
438
struct sta_rec_hdr_trans {
439
__le16 tag;
440
__le16 len;
441
u8 from_ds;
442
u8 to_ds;
443
u8 dis_rx_hdr_tran;
444
u8 rsv;
445
} __packed;
446
447
struct sta_rec_mld {
448
__le16 tag;
449
__le16 len;
450
u8 mac_addr[ETH_ALEN];
451
__le16 primary_id;
452
__le16 secondary_id;
453
__le16 wlan_id;
454
u8 link_num;
455
u8 rsv[3];
456
struct {
457
__le16 wlan_id;
458
u8 bss_idx;
459
u8 rsv;
460
} __packed link[2];
461
} __packed;
462
463
struct sta_rec_eht_mld {
464
__le16 tag;
465
__le16 len;
466
u8 nsep;
467
u8 mld_type;
468
u8 __rsv1[1];
469
u8 str_cap[3];
470
u8 eml_cap[3];
471
u8 __rsv2[3];
472
} __packed;
473
474
struct bss_ifs_time_tlv {
475
__le16 tag;
476
__le16 len;
477
u8 slot_valid;
478
u8 sifs_valid;
479
u8 rifs_valid;
480
u8 eifs_valid;
481
__le16 slot_time;
482
__le16 sifs_time;
483
__le16 rifs_time;
484
__le16 eifs_time;
485
u8 eifs_cck_valid;
486
u8 rsv;
487
__le16 eifs_cck_time;
488
} __packed;
489
490
struct bss_rlm_tlv {
491
__le16 tag;
492
__le16 len;
493
u8 control_channel;
494
u8 center_chan;
495
u8 center_chan2;
496
u8 bw;
497
u8 tx_streams;
498
u8 rx_streams;
499
u8 ht_op_info;
500
u8 sco;
501
u8 band;
502
u8 pad[3];
503
} __packed;
504
505
#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
506
sizeof(struct sta_rec_basic) + \
507
sizeof(struct sta_rec_bf) + \
508
sizeof(struct sta_rec_ht) + \
509
sizeof(struct sta_rec_he_v2) + \
510
sizeof(struct sta_rec_ba_uni) + \
511
sizeof(struct sta_rec_vht) + \
512
sizeof(struct sta_rec_uapsd) + \
513
sizeof(struct sta_rec_amsdu) + \
514
sizeof(struct sta_rec_bfee) + \
515
sizeof(struct sta_rec_phy) + \
516
sizeof(struct sta_rec_ra) + \
517
sizeof(struct sta_rec_sec_uni) + \
518
sizeof(struct sta_rec_ra_fixed) + \
519
sizeof(struct sta_rec_he_6g_capa) + \
520
sizeof(struct sta_rec_eht) + \
521
sizeof(struct sta_rec_hdr_trans) + \
522
sizeof(struct sta_rec_mld) + \
523
sizeof(struct tlv) * 2 + \
524
sizeof(struct sta_rec_remove))
525
526
#define MT7925_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \
527
sizeof(struct mt76_connac_bss_basic_tlv) + \
528
sizeof(struct mt76_connac_bss_qos_tlv) + \
529
sizeof(struct bss_rate_tlv) + \
530
sizeof(struct bss_mld_tlv) + \
531
sizeof(struct bss_info_uni_he) + \
532
sizeof(struct bss_info_uni_bss_color) + \
533
sizeof(struct bss_ifs_time_tlv) + \
534
sizeof(struct bss_rlm_tlv) + \
535
sizeof(struct tlv))
536
537
#define MT_CONNAC3_SKU_POWER_LIMIT 449
538
struct mt7925_sku_tlv {
539
u8 channel;
540
s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];
541
} __packed;
542
543
struct mt7925_tx_power_limit_tlv {
544
u8 rsv[4];
545
546
__le16 tag;
547
__le16 len;
548
549
/* DW0 - common info*/
550
u8 ver;
551
u8 pad0;
552
__le16 rsv1;
553
/* DW1 - cmd hint */
554
u8 n_chan; /* # channel */
555
u8 band; /* 2.4GHz - 5GHz - 6GHz */
556
u8 last_msg;
557
u8 limit_type;
558
/* DW3 */
559
u8 alpha2[4]; /* regulatory_request.alpha2 */
560
u8 pad2[32];
561
562
u8 data[];
563
} __packed;
564
565
struct mt7925_arpns_tlv {
566
__le16 tag;
567
__le16 len;
568
569
u8 enable;
570
u8 ips_num;
571
u8 rsv[2];
572
} __packed;
573
574
struct mt7925_wow_pattern_tlv {
575
__le16 tag;
576
__le16 len;
577
u8 bss_idx;
578
u8 index; /* pattern index */
579
u8 enable; /* 0: disable
580
* 1: enable
581
*/
582
u8 data_len; /* pattern length */
583
u8 offset;
584
u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];
585
u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];
586
u8 rsv[4];
587
};
588
589
struct roc_acquire_tlv {
590
__le16 tag;
591
__le16 len;
592
u8 bss_idx;
593
u8 tokenid;
594
u8 control_channel;
595
u8 sco;
596
u8 band;
597
u8 bw;
598
u8 center_chan;
599
u8 center_chan2;
600
u8 bw_from_ap;
601
u8 center_chan_from_ap;
602
u8 center_chan2_from_ap;
603
u8 reqtype;
604
__le32 maxinterval;
605
u8 dbdcband;
606
u8 rsv[3];
607
} __packed;
608
609
enum ENUM_CMD_TEST_CTRL_ACT {
610
CMD_TEST_CTRL_ACT_SWITCH_MODE = 0,
611
CMD_TEST_CTRL_ACT_SET_AT = 1,
612
CMD_TEST_CTRL_ACT_GET_AT = 2,
613
CMD_TEST_CTRL_ACT_SET_AT_ENG = 3,
614
CMD_TEST_CTRL_ACT_GET_AT_ENG = 4,
615
CMD_TEST_CTRL_ACT_NUM
616
};
617
618
enum ENUM_CMD_TEST_CTRL_ACT_SWITCH_MODE_OP {
619
CMD_TEST_CTRL_ACT_SWITCH_MODE_NORMAL = 0,
620
CMD_TEST_CTRL_ACT_SWITCH_MODE_RF_TEST = 1,
621
CMD_TEST_CTRL_ACT_SWITCH_MODE_ICAP = 2,
622
CMD_TEST_CTRL_ACT_SWITCH_MODE_NUM
623
};
624
625
union testmode_data {
626
__le32 op_mode;
627
__le32 channel_freq;
628
u8 rf_at_info[84];
629
};
630
631
union testmode_evt {
632
__le32 op_mode;
633
__le32 channel_freq;
634
u8 rf_at_info[1024];
635
};
636
637
struct uni_cmd_testmode_ctrl {
638
u16 tag;
639
u16 length;
640
u8 action;
641
u8 reserved[3];
642
union testmode_data data;
643
} __packed;
644
645
struct mt7925_rftest_cmd {
646
u8 padding[4];
647
struct uni_cmd_testmode_ctrl ctrl;
648
} __packed;
649
650
static inline enum connac3_mcu_cipher_type
651
mt7925_mcu_get_cipher(int cipher)
652
{
653
switch (cipher) {
654
case WLAN_CIPHER_SUITE_WEP40:
655
return CONNAC3_CIPHER_WEP40;
656
case WLAN_CIPHER_SUITE_WEP104:
657
return CONNAC3_CIPHER_WEP104;
658
case WLAN_CIPHER_SUITE_TKIP:
659
return CONNAC3_CIPHER_TKIP;
660
case WLAN_CIPHER_SUITE_AES_CMAC:
661
return CONNAC3_CIPHER_BIP_CMAC_128;
662
case WLAN_CIPHER_SUITE_CCMP:
663
return CONNAC3_CIPHER_AES_CCMP;
664
case WLAN_CIPHER_SUITE_CCMP_256:
665
return CONNAC3_CIPHER_CCMP_256;
666
case WLAN_CIPHER_SUITE_GCMP:
667
return CONNAC3_CIPHER_GCMP;
668
case WLAN_CIPHER_SUITE_GCMP_256:
669
return CONNAC3_CIPHER_GCMP_256;
670
case WLAN_CIPHER_SUITE_SMS4:
671
return CONNAC3_CIPHER_WAPI;
672
default:
673
return CONNAC3_CIPHER_NONE;
674
}
675
}
676
677
int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable);
678
int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
679
struct ieee80211_scan_request *scan_req);
680
int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,
681
struct ieee80211_vif *vif);
682
int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
683
struct ieee80211_vif *vif,
684
struct cfg80211_sched_scan_request *sreq,
685
struct ieee80211_scan_ies *ies);
686
int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
687
struct ieee80211_vif *vif,
688
bool enable);
689
void mt7925_mcu_del_dev(struct mt76_dev *mdev,
690
struct ieee80211_vif *vif);
691
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
692
struct ieee80211_chanctx_conf *ctx,
693
struct ieee80211_bss_conf *link_conf,
694
struct ieee80211_link_sta *link_sta,
695
int enable);
696
int mt7925_mcu_set_timing(struct mt792x_phy *phy,
697
struct ieee80211_bss_conf *link_conf);
698
int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
699
int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev);
700
int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
701
int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
702
int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif_link *mvif,
703
struct ieee80211_bss_conf *link_conf,
704
struct ieee80211_chanctx_conf *ctx);
705
int mt7925_mcu_set_eht_pp(struct mt76_phy *phy, struct mt76_vif_link *mvif,
706
struct ieee80211_bss_conf *link_conf,
707
struct ieee80211_chanctx_conf *ctx);
708
int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
709
int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
710
struct ieee80211_bss_conf *link_conf);
711
int
712
mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev,
713
struct ieee80211_bss_conf *link_conf, bool enable);
714
#endif
715
716