summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h
blob: b8315a89f4a9ac00cb182f72b1d89315317c4365 (plain)
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
/* SPDX-License-Identifier: ISC */
/* Copyright (C) 2023 MediaTek Inc. */

#ifndef __MT7925_MCU_H
#define __MT7925_MCU_H

#include "../mt76_connac_mcu.h"

/* ext event table */
enum {
	MCU_EXT_EVENT_RATE_REPORT = 0x87,
};

struct mt7925_mcu_eeprom_info {
	__le32 addr;
	__le32 valid;
	u8 data[MT7925_EEPROM_BLOCK_SIZE];
} __packed;

#define MT_RA_RATE_NSS			GENMASK(8, 6)
#define MT_RA_RATE_MCS			GENMASK(3, 0)
#define MT_RA_RATE_TX_MODE		GENMASK(12, 9)
#define MT_RA_RATE_DCM_EN		BIT(4)
#define MT_RA_RATE_BW			GENMASK(14, 13)

struct mt7925_mcu_rxd {
	__le32 rxd[8];

	__le16 len;
	__le16 pkt_type_id;

	u8 eid;
	u8 seq;
	u8 option;
	u8 __rsv;

	u8 ext_eid;
	u8 __rsv1[2];
	u8 s2d_index;

	u8 tlv[];
};

struct mt7925_mcu_uni_event {
	u8 cid;
	u8 pad[3];
	__le32 status; /* 0: success, others: fail */
} __packed;

enum {
	MT_EBF = BIT(0),	/* explicit beamforming */
	MT_IBF = BIT(1)		/* implicit beamforming */
};

struct mt7925_mcu_reg_event {
	__le32 reg;
	__le32 val;
} __packed;

struct mt7925_mcu_ant_id_config {
	u8 ant_id[4];
} __packed;

struct mt7925_txpwr_req {
	u8 _rsv[4];
	__le16 tag;
	__le16 len;

	u8 format_id;
	u8 catg;
	u8 band_idx;
	u8 _rsv1;
} __packed;

struct mt7925_txpwr_event {
	u8 rsv[4];
	__le16 tag;
	__le16 len;

	u8 catg;
	u8 band_idx;
	u8 ch_band;
	u8 format; /* 0:Legacy, 1:HE */

	/* Rate power info */
	struct mt7925_txpwr txpwr;

	s8 pwr_max;
	s8 pwr_min;
	u8 rsv1;
} __packed;

enum {
	TM_SWITCH_MODE,
	TM_SET_AT_CMD,
	TM_QUERY_AT_CMD,
};

enum {
	MT7925_TM_NORMAL,
	MT7925_TM_TESTMODE,
	MT7925_TM_ICAP,
	MT7925_TM_ICAP_OVERLAP,
	MT7925_TM_WIFISPECTRUM,
};

struct mt7925_rftest_cmd {
	u8 action;
	u8 rsv[3];
	__le32 param0;
	__le32 param1;
} __packed;

struct mt7925_rftest_evt {
	__le32 param0;
	__le32 param1;
} __packed;

enum {
	UNI_CHANNEL_SWITCH,
	UNI_CHANNEL_RX_PATH,
};

enum {
	UNI_CHIP_CONFIG_CHIP_CFG = 0x2,
	UNI_CHIP_CONFIG_NIC_CAPA = 0x3,
};

enum {
	UNI_BAND_CONFIG_RADIO_ENABLE,
	UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
	UNI_BAND_CONFIG_SET_MAC80211_RX_FILTER = 0x0C,
};

enum {
	UNI_WSYS_CONFIG_FW_LOG_CTRL,
	UNI_WSYS_CONFIG_FW_DBG_CTRL,
};

enum {
	UNI_EFUSE_ACCESS = 1,
	UNI_EFUSE_BUFFER_MODE,
	UNI_EFUSE_FREE_BLOCK,
	UNI_EFUSE_BUFFER_RD,
};

enum {
	UNI_CMD_ACCESS_REG_BASIC = 0x0,
	UNI_CMD_ACCESS_RF_REG_BASIC,
};

enum {
	UNI_MBMC_SETTING,
};

enum {
	UNI_EVENT_SCAN_DONE_BASIC = 0,
	UNI_EVENT_SCAN_DONE_CHNLINFO = 2,
	UNI_EVENT_SCAN_DONE_NLO = 3,
};

enum connac3_mcu_cipher_type {
	CONNAC3_CIPHER_NONE = 0,
	CONNAC3_CIPHER_WEP40 = 1,
	CONNAC3_CIPHER_TKIP = 2,
	CONNAC3_CIPHER_AES_CCMP = 4,
	CONNAC3_CIPHER_WEP104 = 5,
	CONNAC3_CIPHER_BIP_CMAC_128 = 6,
	CONNAC3_CIPHER_WEP128 = 7,
	CONNAC3_CIPHER_WAPI = 8,
	CONNAC3_CIPHER_CCMP_256 = 10,
	CONNAC3_CIPHER_GCMP = 11,
	CONNAC3_CIPHER_GCMP_256 = 12,
};

struct mt7925_mcu_scan_chinfo_event {
	u8 nr_chan;
	u8 alpha2[3];
} __packed;

enum {
	UNI_SCAN_REQ = 1,
	UNI_SCAN_CANCEL = 2,
	UNI_SCAN_SCHED_REQ = 3,
	UNI_SCAN_SCHED_ENABLE = 4,
	UNI_SCAN_SSID = 10,
	UNI_SCAN_BSSID,
	UNI_SCAN_CHANNEL,
	UNI_SCAN_IE,
	UNI_SCAN_MISC,
	UNI_SCAN_SSID_MATCH_SETS,
};

enum {
	UNI_SNIFFER_ENABLE,
	UNI_SNIFFER_CONFIG,
};

struct scan_hdr_tlv {
	/* fixed field */
	u8 seq_num;
	u8 bss_idx;
	u8 pad[2];
	/* tlv */
	u8 data[];
} __packed;

struct scan_req_tlv {
	__le16 tag;
	__le16 len;

	u8 scan_type; /* 0: PASSIVE SCAN
		       * 1: ACTIVE SCAN
		       */
	u8 probe_req_num; /* Number of probe request for each SSID */
	u8 scan_func; /* BIT(0) Enable random MAC scan
		       * BIT(1) Disable DBDC scan type 1~3.
		       * BIT(2) Use DBDC scan type 3 (dedicated one RF to scan).
		       */
	u8 src_mask;
	__le16 channel_min_dwell_time;
	__le16 channel_dwell_time; /* channel Dwell interval */
	__le16 timeout_value;
	__le16 probe_delay_time;
	__le32 func_mask_ext;
};

struct scan_ssid_tlv {
	__le16 tag;
	__le16 len;

	u8 ssid_type; /* BIT(0) wildcard SSID
		       * BIT(1) P2P wildcard SSID
		       * BIT(2) specified SSID + wildcard SSID
		       * BIT(2) + ssid_type_ext BIT(0) specified SSID only
		       */
	u8 ssids_num;
	u8 pad[2];
	struct mt76_connac_mcu_scan_ssid ssids[4];
};

struct scan_bssid_tlv {
	__le16 tag;
	__le16 len;

	u8 bssid[ETH_ALEN];
	u8 match_ch;
	u8 match_ssid_ind;
	u8 rcpi;
	u8 pad[3];
};

struct scan_chan_info_tlv {
	__le16 tag;
	__le16 len;

	u8 channel_type; /* 0: Full channels
			  * 1: Only 2.4GHz channels
			  * 2: Only 5GHz channels
			  * 3: P2P social channel only (channel #1, #6 and #11)
			  * 4: Specified channels
			  * Others: Reserved
			  */
	u8 channels_num; /* valid when channel_type is 4 */
	u8 pad[2];
	struct mt76_connac_mcu_scan_channel channels[64];
};

struct scan_ie_tlv {
	__le16 tag;
	__le16 len;

	__le16 ies_len;
	u8 band;
	u8 pad;
	u8 ies[MT76_CONNAC_SCAN_IE_LEN];
};

struct scan_misc_tlv {
	__le16 tag;
	__le16 len;

	u8 random_mac[ETH_ALEN];
	u8 rsv[2];
};

struct scan_sched_req {
	__le16 tag;
	__le16 len;

	u8 version;
	u8 stop_on_match;
	u8 intervals_num;
	u8 scan_func;
	__le16 intervals[MT76_CONNAC_MAX_NUM_SCHED_SCAN_INTERVAL];
};

struct scan_sched_ssid_match_sets {
	__le16 tag;
	__le16 len;

	u8 match_num;
	u8 rsv[3];

	struct mt76_connac_mcu_scan_match match[MT76_CONNAC_MAX_SCAN_MATCH];
};

struct scan_sched_enable {
	__le16 tag;
	__le16 len;

	u8 active;
	u8 rsv[3];
};

struct mbmc_set_req {
	u8 pad[4];
	u8 data[];
} __packed;

struct mbmc_conf_tlv {
	__le16 tag;
	__le16 len;

	u8 mbmc_en;
	u8 band;
	u8 pad[2];
} __packed;

struct edca {
	__le16 tag;
	__le16 len;

	u8 queue;
	u8 set;
	u8 cw_min;
	u8 cw_max;
	__le16 txop;
	u8 aifs;
	u8 __rsv;
};

struct bss_req_hdr {
	u8 bss_idx;
	u8 __rsv[3];
} __packed;

struct bss_rate_tlv {
	__le16 tag;
	__le16 len;
	u8 __rsv1[2];
	__le16 basic_rate;
	__le16 bc_trans;
	__le16 mc_trans;
	u8 short_preamble;
	u8 bc_fixed_rate;
	u8 mc_fixed_rate;
	u8 __rsv2;
} __packed;

struct bss_mld_tlv {
	__le16 tag;
	__le16 len;
	u8 group_mld_id;
	u8 own_mld_id;
	u8 mac_addr[ETH_ALEN];
	u8 remap_idx;
	u8 link_id;
	u8 __rsv[2];
} __packed;

struct sta_rec_ba_uni {
	__le16 tag;
	__le16 len;
	u8 tid;
	u8 ba_type;
	u8 amsdu;
	u8 ba_en;
	__le16 ssn;
	__le16 winsize;
	u8 ba_rdd_rro;
	u8 __rsv[3];
} __packed;

struct sta_rec_eht {
	__le16 tag;
	__le16 len;
	u8 tid_bitmap;
	u8 _rsv;
	__le16 mac_cap;
	__le64 phy_cap;
	__le64 phy_cap_ext;
	u8 mcs_map_bw20[4];
	u8 mcs_map_bw80[3];
	u8 mcs_map_bw160[3];
	u8 mcs_map_bw320[3];
	u8 _rsv2[3];
} __packed;

struct sta_rec_sec_uni {
	__le16 tag;
	__le16 len;
	u8 add;
	u8 tx_key;
	u8 key_type;
	u8 is_authenticator;
	u8 peer_addr[6];
	u8 bss_idx;
	u8 cipher_id;
	u8 key_id;
	u8 key_len;
	u8 wlan_idx;
	u8 mgmt_prot;
	u8 key[32];
	u8 key_rsc[16];
} __packed;

struct sta_rec_hdr_trans {
	__le16 tag;
	__le16 len;
	u8 from_ds;
	u8 to_ds;
	u8 dis_rx_hdr_tran;
	u8 rsv;
} __packed;

struct sta_rec_mld {
	__le16 tag;
	__le16 len;
	u8 mac_addr[ETH_ALEN];
	__le16 primary_id;
	__le16 secondary_id;
	__le16 wlan_id;
	u8 link_num;
	u8 rsv[3];
	struct {
		__le16 wlan_id;
		u8 bss_idx;
		u8 rsv;
	} __packed link[2];
} __packed;

struct bss_ifs_time_tlv {
	__le16 tag;
	__le16 len;
	u8 slot_valid;
	u8 sifs_valid;
	u8 rifs_valid;
	u8 eifs_valid;
	__le16 slot_time;
	__le16 sifs_time;
	__le16 rifs_time;
	__le16 eifs_time;
	u8 eifs_cck_valid;
	u8 rsv;
	__le16 eifs_cck_time;
} __packed;

#define MT7925_STA_UPDATE_MAX_SIZE	(sizeof(struct sta_req_hdr) +		\
					 sizeof(struct sta_rec_basic) +		\
					 sizeof(struct sta_rec_bf) +		\
					 sizeof(struct sta_rec_ht) +		\
					 sizeof(struct sta_rec_he_v2) +		\
					 sizeof(struct sta_rec_ba_uni) +	\
					 sizeof(struct sta_rec_vht) +		\
					 sizeof(struct sta_rec_uapsd) +		\
					 sizeof(struct sta_rec_amsdu) +		\
					 sizeof(struct sta_rec_bfee) +		\
					 sizeof(struct sta_rec_phy) +		\
					 sizeof(struct sta_rec_ra) +		\
					 sizeof(struct sta_rec_sec_uni) +   \
					 sizeof(struct sta_rec_ra_fixed) +	\
					 sizeof(struct sta_rec_he_6g_capa) +	\
					 sizeof(struct sta_rec_eht) +		\
					 sizeof(struct sta_rec_hdr_trans) +	\
					 sizeof(struct sta_rec_mld) +		\
					 sizeof(struct tlv))

#define MT7925_BSS_UPDATE_MAX_SIZE	(sizeof(struct bss_req_hdr) +		\
					 sizeof(struct mt76_connac_bss_basic_tlv) +	\
					 sizeof(struct mt76_connac_bss_qos_tlv) +	\
					 sizeof(struct bss_rate_tlv) +			\
					 sizeof(struct bss_mld_tlv) +			\
					 sizeof(struct bss_info_uni_he) +		\
					 sizeof(struct bss_info_uni_bss_color) +	\
					 sizeof(struct bss_ifs_time_tlv) +		\
					 sizeof(struct tlv))

#define MT_CONNAC3_SKU_POWER_LIMIT      449
struct mt7925_sku_tlv {
	u8 channel;
	s8 pwr_limit[MT_CONNAC3_SKU_POWER_LIMIT];
} __packed;

struct mt7925_tx_power_limit_tlv {
	u8 rsv[4];

	__le16 tag;
	__le16 len;

	/* DW0 - common info*/
	u8 ver;
	u8 pad0;
	__le16 rsv1;
	/* DW1 - cmd hint */
	u8 n_chan; /* # channel */
	u8 band; /* 2.4GHz - 5GHz - 6GHz */
	u8 last_msg;
	u8 limit_type;
	/* DW3 */
	u8 alpha2[4]; /* regulatory_request.alpha2 */
	u8 pad2[32];

	u8 data[];
} __packed;

struct mt7925_arpns_tlv {
	__le16 tag;
	__le16 len;

	u8 enable;
	u8 ips_num;
	u8 rsv[2];
} __packed;

struct mt7925_wow_pattern_tlv {
	__le16 tag;
	__le16 len;
	u8 bss_idx;
	u8 index; /* pattern index */
	u8 enable; /* 0: disable
		    * 1: enable
		    */
	u8 data_len; /* pattern length */
	u8 offset;
	u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN];
	u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN];
	u8 rsv[7];
} __packed;

static inline enum connac3_mcu_cipher_type
mt7925_mcu_get_cipher(int cipher)
{
	switch (cipher) {
	case WLAN_CIPHER_SUITE_WEP40:
		return CONNAC3_CIPHER_WEP40;
	case WLAN_CIPHER_SUITE_WEP104:
		return CONNAC3_CIPHER_WEP104;
	case WLAN_CIPHER_SUITE_TKIP:
		return CONNAC3_CIPHER_TKIP;
	case WLAN_CIPHER_SUITE_AES_CMAC:
		return CONNAC3_CIPHER_BIP_CMAC_128;
	case WLAN_CIPHER_SUITE_CCMP:
		return CONNAC3_CIPHER_AES_CCMP;
	case WLAN_CIPHER_SUITE_CCMP_256:
		return CONNAC3_CIPHER_CCMP_256;
	case WLAN_CIPHER_SUITE_GCMP:
		return CONNAC3_CIPHER_GCMP;
	case WLAN_CIPHER_SUITE_GCMP_256:
		return CONNAC3_CIPHER_GCMP_256;
	case WLAN_CIPHER_SUITE_SMS4:
		return CONNAC3_CIPHER_WAPI;
	default:
		return CONNAC3_CIPHER_NONE;
	}
}

int mt7925_mcu_set_dbdc(struct mt76_phy *phy);
int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
		       struct ieee80211_scan_request *scan_req);
int mt7925_mcu_cancel_hw_scan(struct mt76_phy *phy,
			      struct ieee80211_vif *vif);
int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
			      struct ieee80211_vif *vif,
			      struct cfg80211_sched_scan_request *sreq);
int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
				 struct ieee80211_vif *vif,
				 bool enable);
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
			    struct ieee80211_chanctx_conf *ctx,
			    struct ieee80211_vif *vif,
			    struct ieee80211_sta *sta,
			    int enable);
int mt7925_mcu_set_timing(struct mt792x_phy *phy,
			  struct ieee80211_vif *vif);
int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
			 struct ieee80211_chanctx_conf *ctx);
int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,
				 struct mt76_vif *vif,
				 struct ieee80211_bss_conf *info);
#endif