Loading...
1/* SPDX-License-Identifier: ISC */
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 */
10enum {
11 MCU_EXT_EVENT_RATE_REPORT = 0x87,
12};
13
14struct 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
26struct 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
44struct mt7925_mcu_uni_event {
45 u8 cid;
46 u8 pad[3];
47 __le32 status; /* 0: success, others: fail */
48} __packed;
49
50enum {
51 MT_EBF = BIT(0), /* explicit beamforming */
52 MT_IBF = BIT(1) /* implicit beamforming */
53};
54
55struct mt7925_mcu_reg_event {
56 __le32 reg;
57 __le32 val;
58} __packed;
59
60struct mt7925_mcu_ant_id_config {
61 u8 ant_id[4];
62} __packed;
63
64struct 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
75struct 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
93enum {
94 TM_SWITCH_MODE,
95 TM_SET_AT_CMD,
96 TM_QUERY_AT_CMD,
97};
98
99enum {
100 MT7925_TM_NORMAL,
101 MT7925_TM_TESTMODE,
102 MT7925_TM_ICAP,
103 MT7925_TM_ICAP_OVERLAP,
104 MT7925_TM_WIFISPECTRUM,
105};
106
107struct mt7925_rftest_cmd {
108 u8 action;
109 u8 rsv[3];
110 __le32 param0;
111 __le32 param1;
112} __packed;
113
114struct mt7925_rftest_evt {
115 __le32 param0;
116 __le32 param1;
117} __packed;
118
119enum {
120 UNI_CHANNEL_SWITCH,
121 UNI_CHANNEL_RX_PATH,
122};
123
124enum {
125 UNI_CHIP_CONFIG_CHIP_CFG = 0x2,
126 UNI_CHIP_CONFIG_NIC_CAPA = 0x3,
127};
128
129enum {
130 UNI_BAND_CONFIG_RADIO_ENABLE,
131 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
132 UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,
133};
134
135enum {
136 UNI_WSYS_CONFIG_FW_LOG_CTRL,
137 UNI_WSYS_CONFIG_FW_DBG_CTRL,
138};
139
140enum {
141 UNI_EFUSE_ACCESS = 1,
142 UNI_EFUSE_BUFFER_MODE,
143 UNI_EFUSE_FREE_BLOCK,
144 UNI_EFUSE_BUFFER_RD,
145};
146
147enum {
148 UNI_CMD_ACCESS_REG_BASIC = 0x0,
149 UNI_CMD_ACCESS_RF_REG_BASIC,
150};
151
152enum {
153 UNI_MBMC_SETTING,
154};
155
156enum {
157 UNI_EVENT_SCAN_DONE_BASIC = 0,
158 UNI_EVENT_SCAN_DONE_CHNLINFO = 2,
159 UNI_EVENT_SCAN_DONE_NLO = 3,
160};
161
162enum connac3_mcu_cipher_type {
163 CONNAC3_CIPHER_NONE = 0,
164 CONNAC3_CIPHER_WEP40 = 1,
165 CONNAC3_CIPHER_TKIP = 2,
166 CONNAC3_CIPHER_AES_CCMP = 4,
167 CONNAC3_CIPHER_WEP104 = 5,
168 CONNAC3_CIPHER_BIP_CMAC_128 = 6,
169 CONNAC3_CIPHER_WEP128 = 7,
170 CONNAC3_CIPHER_WAPI = 8,
171 CONNAC3_CIPHER_CCMP_256 = 10,
172 CONNAC3_CIPHER_GCMP = 11,
173 CONNAC3_CIPHER_GCMP_256 = 12,
174};
175
176struct mt7925_mcu_scan_chinfo_event {
177 u8 nr_chan;
178 u8 alpha2[3];
179} __packed;
180
181enum {
182 UNI_SCAN_REQ = 1,
183 UNI_SCAN_CANCEL = 2,
184 UNI_SCAN_SCHED_REQ = 3,
185 UNI_SCAN_SCHED_ENABLE = 4,
186 UNI_SCAN_SSID = 10,
187 UNI_SCAN_BSSID,
188 UNI_SCAN_CHANNEL,
189 UNI_SCAN_IE,
190 UNI_SCAN_MISC,
191 UNI_SCAN_SSID_MATCH_SETS,
192};
193
194enum {
195 UNI_SNIFFER_ENABLE,
196 UNI_SNIFFER_CONFIG,
197};
198
199struct scan_hdr_tlv {
200 /* fixed field */
201 u8 seq_num;
202 u8 bss_idx;
203 u8 pad[2];
204 /* tlv */
205 u8 data[];
206} __packed;
207
208struct scan_req_tlv {
209 __le16 tag;
210 __le16 len;
211
212 u8 scan_type; /* 0: PASSIVE SCAN
213 * 1: ACTIVE SCAN
214 */
215 u8 probe_req_num; /* Number of probe request for each SSID */
216 u8 scan_func; /* BIT(0) Enable random MAC scan
217 * BIT(1) Disable DBDC scan type 1~3.
218 * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).
219 */
220 u8 src_mask;
221 __le16 channel_min_dwell_time;
222 __le16 channel_dwell_time; /* channel Dwell interval */
223 __le16 timeout_value;
224 __le16 probe_delay_time;
225 __le32 func_mask_ext;
226};
227
228struct scan_ssid_tlv {
229 __le16 tag;
230 __le16 len;
231
232 u8 ssid_type; /* BIT(0) wildcard SSID
233 * BIT(1) P2P wildcard SSID
234 * BIT(2) specified SSID + wildcard SSID
235 * BIT(2) + ssid_type_ext BIT(0) specified SSID only
236 */
237 u8 ssids_num;
238 u8 pad[2];
239 struct mt76_connac_mcu_scan_ssid ssids[4];
240};
241
242struct scan_bssid_tlv {
243 __le16 tag;
244 __le16 len;
245
246 u8 bssid[ETH_ALEN];
247 u8 match_ch;
248 u8 match_ssid_ind;
249 u8 rcpi;
250 u8 pad[3];
251};
252
253struct scan_chan_info_tlv {
254 __le16 tag;
255 __le16 len;
256
257 u8 channel_type; /* 0: Full channels
258 * 1: Only 2.4GHz channels
259 * 2: Only 5GHz channels
260 * 3: P2P social channel only (channel #1, #6 and #11)
261 * 4: Specified channels
262 * Others: Reserved
263 */
264 u8 channels_num; /* valid when channel_type is 4 */
265 u8 pad[2];
266 struct mt76_connac_mcu_scan_channel channels[64];
267};
268
269struct scan_ie_tlv {
270 __le16 tag;
271 __le16 len;
272
273 __le16 ies_len;
274 u8 band;
275 u8 pad;
276 u8 ies[MT76_CONNAC_SCAN_IE_LEN];
277};
278
279struct scan_misc_tlv {
280 __le16 tag;
281 __le16 len;
282
283 u8 random_mac[ETH_ALEN];
284 u8 rsv[2];
285};
286
287struct scan_sched_req {
288 __le16 tag;
289 __le16 len;
290
291 u8 version;
292 u8 stop_on_match;
293 u8 intervals_num;
294 u8 scan_func;
295 __le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];
296};
297
298struct scan_sched_ssid_match_sets {
299 __le16 tag;
300 __le16 len;
301
302 u8 match_num;
303 u8 rsv[3];
304
305 struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];
306};
307
308struct scan_sched_enable {
309 __le16 tag;
310 __le16 len;
311
312 u8 active;
313 u8 rsv[3];
314};
315
316struct mbmc_set_req {
317 u8 pad[4];
318 u8 data[];
319} __packed;
320
321struct mbmc_conf_tlv {
322 __le16 tag;
323 __le16 len;
324
325 u8 mbmc_en;
326 u8 band;
327 u8 pad[2];
328} __packed;
329
330struct edca {
331 __le16 tag;
332 __le16 len;
333
334 u8 queue;
335 u8 set;
336 u8 cw_min;
337 u8 cw_max;
338 __le16 txop;
339 u8 aifs;
340 u8 __rsv;
341};
342
343struct bss_req_hdr {
344 u8 bss_idx;
345 u8 __rsv[3];
346} __packed;
347
348struct bss_rate_tlv {
349 __le16 tag;
350 __le16 len;
351 u8 __rsv1[2];
352 __le16 basic_rate;
353 __le16 bc_trans;
354 __le16 mc_trans;
355 u8 short_preamble;
356 u8 bc_fixed_rate;
357 u8 mc_fixed_rate;
358 u8 __rsv2;
359} __packed;
360
361struct bss_mld_tlv {
362 __le16 tag;
363 __le16 len;
364 u8 group_mld_id;
365 u8 own_mld_id;
366 u8 mac_addr[ETH_ALEN];
367 u8 remap_idx;
368 u8 link_id;
369 u8 __rsv[2];
370} __packed;
371
372struct sta_rec_ba_uni {
373 __le16 tag;
374 __le16 len;
375 u8 tid;
376 u8 ba_type;
377 u8 amsdu;
378 u8 ba_en;
379 __le16 ssn;
380 __le16 winsize;
381 u8 ba_rdd_rro;
382 u8 __rsv[3];
383} __packed;
384
385struct sta_rec_eht {
386 __le16 tag;
387 __le16 len;
388 u8 tid_bitmap;
389 u8 _rsv;
390 __le16 mac_cap;
391 __le64 phy_cap;
392 __le64 phy_cap_ext;
393 u8 mcs_map_bw20[4];
394 u8 mcs_map_bw80[3];
395 u8 mcs_map_bw160[3];
396 u8 mcs_map_bw320[3];
397 u8 _rsv2[3];
398} __packed;
399
400struct sta_rec_sec_uni {
401 __le16 tag;
402 __le16 len;
403 u8 add;
404 u8 tx_key;
405 u8 key_type;
406 u8 is_authenticator;
407 u8 peer_addr[6];
408 u8 bss_idx;
409 u8 cipher_id;
410 u8 key_id;
411 u8 key_len;
412 u8 wlan_idx;
413 u8 mgmt_prot;
414 u8 key[32];
415 u8 key_rsc[16];
416} __packed;
417
418struct sta_rec_hdr_trans {
419 __le16 tag;
420 __le16 len;
421 u8 from_ds;
422 u8 to_ds;
423 u8 dis_rx_hdr_tran;
424 u8 rsv;
425} __packed;
426
427struct sta_rec_mld {
428 __le16 tag;
429 __le16 len;
430 u8 mac_addr[ETH_ALEN];
431 __le16 primary_id;
432 __le16 secondary_id;
433 __le16 wlan_id;
434 u8 link_num;
435 u8 rsv[3];
436 struct {
437 __le16 wlan_id;
438 u8 bss_idx;
439 u8 rsv;
440 } __packed link[2];
441} __packed;
442
443struct bss_ifs_time_tlv {
444 __le16 tag;
445 __le16 len;
446 u8 slot_valid;
447 u8 sifs_valid;
448 u8 rifs_valid;
449 u8 eifs_valid;
450 __le16 slot_time;
451 __le16 sifs_time;
452 __le16 rifs_time;
453 __le16 eifs_time;
454 u8 eifs_cck_valid;
455 u8 rsv;
456 __le16 eifs_cck_time;
457} __packed;
458
459#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
460 sizeof(struct sta_rec_basic) + \
461 sizeof(struct sta_rec_bf) + \
462 sizeof(struct sta_rec_ht) + \
463 sizeof(struct sta_rec_he_v2) + \
464 sizeof(struct sta_rec_ba_uni) + \
465 sizeof(struct sta_rec_vht) + \
466 sizeof(struct sta_rec_uapsd) + \
467 sizeof(struct sta_rec_amsdu) + \
468 sizeof(struct sta_rec_bfee) + \
469 sizeof(struct sta_rec_phy) + \
470 sizeof(struct sta_rec_ra) + \
471 sizeof(struct sta_rec_sec_uni) + \
472 sizeof(struct sta_rec_ra_fixed) + \
473 sizeof(struct sta_rec_he_6g_capa) + \
474 sizeof(struct sta_rec_eht) + \
475 sizeof(struct sta_rec_hdr_trans) + \
476 sizeof(struct sta_rec_mld) + \
477 sizeof(struct tlv))
478
479#define MT7925_BSS_UPDATE_MAX_SIZE (sizeof(struct bss_req_hdr) + \
480 sizeof(struct mt76_connac_bss_basic_tlv) + \
481 sizeof(struct mt76_connac_bss_qos_tlv) + \
482 sizeof(struct bss_rate_tlv) + \
483 sizeof(struct bss_mld_tlv) + \
484 sizeof(struct bss_info_uni_he) + \
485 sizeof(struct bss_info_uni_bss_color) + \
486 sizeof(struct bss_ifs_time_tlv) + \
487 sizeof(struct tlv))
488
489#define MT_CONNAC3_SKU_POWER_LIMIT 449
490struct mt7925_sku_tlv {
491 u8 channel;
492 s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];
493} __packed;
494
495struct mt7925_tx_power_limit_tlv {
496 u8 rsv[4];
497
498 __le16 tag;
499 __le16 len;
500
501 /* DW0 - common info*/
502 u8 ver;
503 u8 pad0;
504 __le16 rsv1;
505 /* DW1 - cmd hint */
506 u8 n_chan; /* # channel */
507 u8 band; /* 2.4GHz - 5GHz - 6GHz */
508 u8 last_msg;
509 u8 limit_type;
510 /* DW3 */
511 u8 alpha2[4]; /* regulatory_request.alpha2 */
512 u8 pad2[32];
513
514 u8 data[];
515} __packed;
516
517struct mt7925_arpns_tlv {
518 __le16 tag;
519 __le16 len;
520
521 u8 enable;
522 u8 ips_num;
523 u8 rsv[2];
524} __packed;
525
526struct mt7925_wow_pattern_tlv {
527 __le16 tag;
528 __le16 len;
529 u8 bss_idx;
530 u8 index; /* pattern index */
531 u8 enable; /* 0: disable
532 * 1: enable
533 */
534 u8 data_len; /* pattern length */
535 u8 offset;
536 u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];
537 u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];
538 u8 rsv[7];
539} __packed;
540
541static inline enum connac3_mcu_cipher_type
542mt7925_mcu_get_cipher(int cipher)
543{
544 switch (cipher) {
545 case WLAN_CIPHER_SUITE_WEP40:
546 return CONNAC3_CIPHER_WEP40;
547 case WLAN_CIPHER_SUITE_WEP104:
548 return CONNAC3_CIPHER_WEP104;
549 case WLAN_CIPHER_SUITE_TKIP:
550 return CONNAC3_CIPHER_TKIP;
551 case WLAN_CIPHER_SUITE_AES_CMAC:
552 return CONNAC3_CIPHER_BIP_CMAC_128;
553 case WLAN_CIPHER_SUITE_CCMP:
554 return CONNAC3_CIPHER_AES_CCMP;
555 case WLAN_CIPHER_SUITE_CCMP_256:
556 return CONNAC3_CIPHER_CCMP_256;
557 case WLAN_CIPHER_SUITE_GCMP:
558 return CONNAC3_CIPHER_GCMP;
559 case WLAN_CIPHER_SUITE_GCMP_256:
560 return CONNAC3_CIPHER_GCMP_256;
561 case WLAN_CIPHER_SUITE_SMS4:
562 return CONNAC3_CIPHER_WAPI;
563 default:
564 return CONNAC3_CIPHER_NONE;
565 }
566}
567
568int mt7925_mcu_set_dbdc(struct mt76_phy *phy);
569int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
570 struct ieee80211_scan_request *scan_req);
571int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,
572 struct ieee80211_vif *vif);
573int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
574 struct ieee80211_vif *vif,
575 struct cfg80211_sched_scan_request *sreq);
576int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
577 struct ieee80211_vif *vif,
578 bool enable);
579int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
580 struct ieee80211_chanctx_conf *ctx,
581 struct ieee80211_vif *vif,
582 struct ieee80211_sta *sta,
583 int enable);
584int mt7925_mcu_set_timing(struct mt792x_phy *phy,
585 struct ieee80211_vif *vif);
586int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
587int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
588int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
589int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
590 struct ieee80211_chanctx_conf *ctx);
591int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
592int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
593 struct mt76_vif *vif,
594 struct ieee80211_bss_conf *info);
595#endif