blob: fb3e74bb4fcded0cfd470c719709f0b823905f26 [file] [log] [blame]
developer849549c2023-08-02 17:26:48 +08001From e3eb835c5f9c1f40a1aaf4fae2a2de83f2cd1a9c Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Thu, 3 Aug 2023 14:49:59 +0800
4Subject: [PATCH] sync to master codebase
5
6---
7 Makefile | 8 +
8 mt76_connac3_mac.h | 14 +
9 mt76x02_mac.c | 3 +-
10 mt7915/main.c | 3 +-
11 mt7915/mcu.c | 2 +-
12 mt7921/Kconfig | 4 +-
13 mt7921/Makefile | 9 +-
14 mt7921/acpi_sar.h | 105 ---
15 mt7921/debugfs.c | 228 +------
16 mt7921/init.c | 304 +--------
17 mt7921/mac.c | 442 ++-----------
18 mt7921/main.c | 796 +++++-----------------
19 mt7921/mcu.c | 217 ++----
20 mt7921/mt7921.h | 320 ++-------
21 mt7921/pci.c | 223 ++++---
22 mt7921/pci_mac.c | 18 +-
23 mt7921/pci_mcu.c | 71 +-
24 mt7921/regs.h | 464 +------------
25 mt7921/sdio.c | 32 +-
26 mt7921/sdio_mac.c | 6 +-
27 mt7921/sdio_mcu.c | 14 +-
28 mt7921/testmode.c | 10 +-
29 mt7921/trace.c | 12 -
30 mt7921/usb.c | 205 +++---
31 mt7921/usb_mac.c | 255 -------
32 mt792x.h | 367 +++++++++++
33 mt7921/acpi_sar.c => mt792x_acpi_sar.c | 128 ++--
34 mt792x_acpi_sar.h | 105 +++
35 mt792x_core.c | 844 ++++++++++++++++++++++++
36 mt792x_debugfs.c | 168 +++++
37 mt7921/dma.c => mt792x_dma.c | 336 +++++-----
38 mt792x_mac.c | 385 +++++++++++
39 mt792x_regs.h | 479 ++++++++++++++
40 mt792x_trace.c | 14 +
41 mt7921/mt7921_trace.h => mt792x_trace.h | 16 +-
42 mt792x_usb.c | 309 +++++++++
43 mt7996/mt7996.h | 14 -
44 testmode.c | 1 +
45 38 files changed, 3586 insertions(+), 3345 deletions(-)
46 delete mode 100644 mt7921/acpi_sar.h
47 delete mode 100644 mt7921/trace.c
48 delete mode 100644 mt7921/usb_mac.c
49 create mode 100644 mt792x.h
50 rename mt7921/acpi_sar.c => mt792x_acpi_sar.c (64%)
51 create mode 100644 mt792x_acpi_sar.h
52 create mode 100644 mt792x_core.c
53 create mode 100644 mt792x_debugfs.c
54 rename mt7921/dma.c => mt792x_dma.c (55%)
55 create mode 100644 mt792x_mac.c
56 create mode 100644 mt792x_regs.h
57 create mode 100644 mt792x_trace.c
58 rename mt7921/mt7921_trace.h => mt792x_trace.h (68%)
59 create mode 100644 mt792x_usb.c
60
61diff --git a/Makefile b/Makefile
62index f9b94280..c8aedf6d 100644
63--- a/Makefile
64+++ b/Makefile
65@@ -6,6 +6,8 @@ obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
66 obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
67 obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
68 obj-$(CONFIG_MT76_CONNAC_LIB) += mt76-connac-lib.o
69+obj-$(CONFIG_MT792x_LIB) += mt792x-lib.o
70+obj-$(CONFIG_MT792x_USB) += mt792x-usb.o
71
72 mt76-y := \
73 mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
74@@ -20,6 +22,7 @@ mt76-sdio-y := sdio.o sdio_txrx.o
75 CFLAGS_trace.o := -I$(src)
76 CFLAGS_usb_trace.o := -I$(src)
77 CFLAGS_mt76x02_trace.o := -I$(src)
78+CFLAGS_mt792x_trace.o := -I$(src)
79
80 mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \
81 mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o \
82@@ -30,6 +33,11 @@ mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
83
84 mt76-connac-lib-y := mt76_connac_mcu.o mt76_connac_mac.o mt76_connac3_mac.o
85
86+mt792x-lib-y := mt792x_core.o mt792x_mac.o mt792x_trace.o \
87+ mt792x_debugfs.o mt792x_dma.o
88+mt792x-lib-$(CONFIG_ACPI) += mt792x_acpi_sar.o
89+mt792x-usb-y := mt792x_usb.o
90+
91 obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
92 obj-$(CONFIG_MT76x2_COMMON) += mt76x2/
93 obj-$(CONFIG_MT7603E) += mt7603/
94diff --git a/mt76_connac3_mac.h b/mt76_connac3_mac.h
95index 6663a0b4..68ca0844 100644
96--- a/mt76_connac3_mac.h
97+++ b/mt76_connac3_mac.h
98@@ -4,6 +4,20 @@
99 #ifndef __MT76_CONNAC3_MAC_H
100 #define __MT76_CONNAC3_MAC_H
101
102+enum {
103+ MT_CTX0,
104+ MT_HIF0 = 0x0,
105+
106+ MT_LMAC_AC00 = 0x0,
107+ MT_LMAC_AC01,
108+ MT_LMAC_AC02,
109+ MT_LMAC_AC03,
110+ MT_LMAC_ALTX0 = 0x10,
111+ MT_LMAC_BMC0,
112+ MT_LMAC_BCN0,
113+ MT_LMAC_PSMP0,
114+};
115+
116 #define MT_CT_PARSE_LEN 72
117 #define MT_CT_DMA_BUF_NUM 2
118
119diff --git a/mt76x02_mac.c b/mt76x02_mac.c
120index 3e41d809..d5db6ffd 100644
121--- a/mt76x02_mac.c
122+++ b/mt76x02_mac.c
123@@ -853,7 +853,8 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
124 if (WARN_ON_ONCE(len > skb->len))
125 return -EINVAL;
126
127- pskb_trim(skb, len);
128+ if (pskb_trim(skb, len))
129+ return -EINVAL;
130
131 status->chains = BIT(0);
132 signal = mt76x02_mac_get_rssi(dev, rxwi->rssi[0], 0);
133diff --git a/mt7915/main.c b/mt7915/main.c
134index 33bfa4a6..9b79e915 100644
135--- a/mt7915/main.c
136+++ b/mt7915/main.c
137@@ -471,7 +471,8 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
138 ieee80211_wake_queues(hw);
139 }
140
141- if (changed & IEEE80211_CONF_CHANGE_POWER) {
142+ if (changed & (IEEE80211_CONF_CHANGE_POWER |
143+ IEEE80211_CONF_CHANGE_CHANNEL)) {
144 ret = mt7915_mcu_set_txpower_sku(phy);
145 if (ret)
146 return ret;
147diff --git a/mt7915/mcu.c b/mt7915/mcu.c
148index b0328d4f..8224f8be 100644
149--- a/mt7915/mcu.c
150+++ b/mt7915/mcu.c
151@@ -3038,7 +3038,7 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
152 }
153
154 ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO),
155- req, sizeof(req), true, &skb);
156+ req, len * sizeof(req[0]), true, &skb);
157 if (ret)
158 return ret;
159
160diff --git a/mt7921/Kconfig b/mt7921/Kconfig
161index adff2d73..7ed51e05 100644
162--- a/mt7921/Kconfig
163+++ b/mt7921/Kconfig
164@@ -1,7 +1,7 @@
165 # SPDX-License-Identifier: ISC
166 config MT7921_COMMON
167 tristate
168- select MT76_CONNAC_LIB
169+ select MT792x_LIB
170 select WANT_DEV_COREDUMP
171
172 config MT7921E
173@@ -27,7 +27,7 @@ config MT7921S
174
175 config MT7921U
176 tristate "MediaTek MT7921U (USB) support"
177- select MT76_USB
178+ select MT792x_USB
179 select MT7921_COMMON
180 depends on MAC80211
181 depends on USB
182diff --git a/mt7921/Makefile b/mt7921/Makefile
183index e5d2d2e1..849be9e8 100644
184--- a/mt7921/Makefile
185+++ b/mt7921/Makefile
186@@ -5,11 +5,8 @@ obj-$(CONFIG_MT7921E) += mt7921e.o
187 obj-$(CONFIG_MT7921S) += mt7921s.o
188 obj-$(CONFIG_MT7921U) += mt7921u.o
189
190-CFLAGS_trace.o := -I$(src)
191-
192-mt7921-common-y := mac.o mcu.o main.o init.o debugfs.o trace.o
193+mt7921-common-y := mac.o mcu.o main.o init.o debugfs.o
194 mt7921-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
195-mt7921-common-$(CONFIG_ACPI) += acpi_sar.o
196-mt7921e-y := pci.o pci_mac.o pci_mcu.o dma.o
197+mt7921e-y := pci.o pci_mac.o pci_mcu.o
198 mt7921s-y := sdio.o sdio_mac.o sdio_mcu.o
199-mt7921u-y := usb.o usb_mac.o
200+mt7921u-y := usb.o
201diff --git a/mt7921/acpi_sar.h b/mt7921/acpi_sar.h
202deleted file mode 100644
203index 35268b08..00000000
204--- a/mt7921/acpi_sar.h
205+++ /dev/null
206@@ -1,105 +0,0 @@
207-/* SPDX-License-Identifier: ISC */
208-/* Copyright (C) 2022 MediaTek Inc. */
209-
210-#ifndef __MT7921_ACPI_SAR_H
211-#define __MT7921_ACPI_SAR_H
212-
213-#define MT7921_ASAR_MIN_DYN 1
214-#define MT7921_ASAR_MAX_DYN 8
215-#define MT7921_ASAR_MIN_GEO 3
216-#define MT7921_ASAR_MAX_GEO 8
217-#define MT7921_ASAR_MIN_FG 8
218-
219-#define MT7921_ACPI_MTCL "MTCL"
220-#define MT7921_ACPI_MTDS "MTDS"
221-#define MT7921_ACPI_MTGS "MTGS"
222-#define MT7921_ACPI_MTFG "MTFG"
223-
224-struct mt7921_asar_dyn_limit {
225- u8 idx;
226- u8 frp[5];
227-} __packed;
228-
229-struct mt7921_asar_dyn {
230- u8 names[4];
231- u8 enable;
232- u8 nr_tbl;
233- struct mt7921_asar_dyn_limit tbl[0];
234-} __packed;
235-
236-struct mt7921_asar_dyn_limit_v2 {
237- u8 idx;
238- u8 frp[11];
239-} __packed;
240-
241-struct mt7921_asar_dyn_v2 {
242- u8 names[4];
243- u8 enable;
244- u8 rsvd;
245- u8 nr_tbl;
246- struct mt7921_asar_dyn_limit_v2 tbl[0];
247-} __packed;
248-
249-struct mt7921_asar_geo_band {
250- u8 pwr;
251- u8 offset;
252-} __packed;
253-
254-struct mt7921_asar_geo_limit {
255- u8 idx;
256- /* 0:2G, 1:5G */
257- struct mt7921_asar_geo_band band[2];
258-} __packed;
259-
260-struct mt7921_asar_geo {
261- u8 names[4];
262- u8 version;
263- u8 nr_tbl;
264- struct mt7921_asar_geo_limit tbl[0];
265-} __packed;
266-
267-struct mt7921_asar_geo_limit_v2 {
268- u8 idx;
269- /* 0:2G, 1:5G, 2:6G */
270- struct mt7921_asar_geo_band band[3];
271-} __packed;
272-
273-struct mt7921_asar_geo_v2 {
274- u8 names[4];
275- u8 version;
276- u8 rsvd;
277- u8 nr_tbl;
278- struct mt7921_asar_geo_limit_v2 tbl[0];
279-} __packed;
280-
281-struct mt7921_asar_cl {
282- u8 names[4];
283- u8 version;
284- u8 mode_6g;
285- u8 cl6g[6];
286-} __packed;
287-
288-struct mt7921_asar_fg {
289- u8 names[4];
290- u8 version;
291- u8 rsvd;
292- u8 nr_flag;
293- u8 rsvd1;
294- u8 flag[0];
295-} __packed;
296-
297-struct mt7921_acpi_sar {
298- u8 ver;
299- union {
300- struct mt7921_asar_dyn *dyn;
301- struct mt7921_asar_dyn_v2 *dyn_v2;
302- };
303- union {
304- struct mt7921_asar_geo *geo;
305- struct mt7921_asar_geo_v2 *geo_v2;
306- };
307- struct mt7921_asar_cl *countrylist;
308- struct mt7921_asar_fg *fg;
309-};
310-
311-#endif
312diff --git a/mt7921/debugfs.c b/mt7921/debugfs.c
313index d6c66e77..616b66a3 100644
314--- a/mt7921/debugfs.c
315+++ b/mt7921/debugfs.c
316@@ -6,11 +6,11 @@
317 static int
318 mt7921_reg_set(void *data, u64 val)
319 {
320- struct mt7921_dev *dev = data;
321+ struct mt792x_dev *dev = data;
322
323- mt7921_mutex_acquire(dev);
324+ mt792x_mutex_acquire(dev);
325 mt76_wr(dev, dev->mt76.debugfs_reg, val);
326- mt7921_mutex_release(dev);
327+ mt792x_mutex_release(dev);
328
329 return 0;
330 }
331@@ -18,11 +18,11 @@ mt7921_reg_set(void *data, u64 val)
332 static int
333 mt7921_reg_get(void *data, u64 *val)
334 {
335- struct mt7921_dev *dev = data;
336+ struct mt792x_dev *dev = data;
337
338- mt7921_mutex_acquire(dev);
339+ mt792x_mutex_acquire(dev);
340 *val = mt76_rr(dev, dev->mt76.debugfs_reg);
341- mt7921_mutex_release(dev);
342+ mt792x_mutex_release(dev);
343
344 return 0;
345 }
346@@ -32,14 +32,14 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt7921_reg_get, mt7921_reg_set,
347 static int
348 mt7921_fw_debug_set(void *data, u64 val)
349 {
350- struct mt7921_dev *dev = data;
351+ struct mt792x_dev *dev = data;
352
353- mt7921_mutex_acquire(dev);
354+ mt792x_mutex_acquire(dev);
355
356 dev->fw_debug = (u8)val;
357 mt7921_mcu_fw_log_2_host(dev, dev->fw_debug);
358
359- mt7921_mutex_release(dev);
360+ mt792x_mutex_release(dev);
361
362 return 0;
363 }
364@@ -47,7 +47,7 @@ mt7921_fw_debug_set(void *data, u64 val)
365 static int
366 mt7921_fw_debug_get(void *data, u64 *val)
367 {
368- struct mt7921_dev *dev = data;
369+ struct mt792x_dev *dev = data;
370
371 *val = dev->fw_debug;
372
373@@ -57,128 +57,7 @@ mt7921_fw_debug_get(void *data, u64 *val)
374 DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7921_fw_debug_get,
375 mt7921_fw_debug_set, "%lld\n");
376
377-static void
378-mt7921_ampdu_stat_read_phy(struct mt7921_phy *phy,
379- struct seq_file *file)
380-{
381- struct mt7921_dev *dev = file->private;
382- int bound[15], range[4], i;
383-
384- if (!phy)
385- return;
386-
387- mt7921_mac_update_mib_stats(phy);
388-
389- /* Tx ampdu stat */
390- for (i = 0; i < ARRAY_SIZE(range); i++)
391- range[i] = mt76_rr(dev, MT_MIB_ARNG(0, i));
392-
393- for (i = 0; i < ARRAY_SIZE(bound); i++)
394- bound[i] = MT_MIB_ARNCR_RANGE(range[i / 4], i % 4) + 1;
395-
396- seq_printf(file, "\nPhy0\n");
397-
398- seq_printf(file, "Length: %8d | ", bound[0]);
399- for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
400- seq_printf(file, "%3d %3d | ", bound[i] + 1, bound[i + 1]);
401-
402- seq_puts(file, "\nCount: ");
403- for (i = 0; i < ARRAY_SIZE(bound); i++)
404- seq_printf(file, "%8d | ", phy->mt76->aggr_stats[i]);
405- seq_puts(file, "\n");
406-
407- seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt);
408-}
409-
410-static int
411-mt7921_tx_stats_show(struct seq_file *file, void *data)
412-{
413- struct mt7921_dev *dev = file->private;
414- struct mt7921_phy *phy = &dev->phy;
415- struct mt76_mib_stats *mib = &phy->mib;
416- int i;
417-
418- mt7921_mutex_acquire(dev);
419-
420- mt7921_ampdu_stat_read_phy(phy, file);
421-
422- seq_puts(file, "Tx MSDU stat:\n");
423- for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
424- seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ",
425- i + 1, mib->tx_amsdu[i]);
426- if (mib->tx_amsdu_cnt)
427- seq_printf(file, "(%3d%%)\n",
428- mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt);
429- else
430- seq_puts(file, "\n");
431- }
432-
433- mt7921_mutex_release(dev);
434-
435- return 0;
436-}
437-
438-DEFINE_SHOW_ATTRIBUTE(mt7921_tx_stats);
439-
440-static int
441-mt7921_queues_acq(struct seq_file *s, void *data)
442-{
443- struct mt7921_dev *dev = dev_get_drvdata(s->private);
444- int i;
445-
446- mt7921_mutex_acquire(dev);
447-
448- for (i = 0; i < 4; i++) {
449- u32 ctrl, val, qlen = 0;
450- int j;
451-
452- val = mt76_rr(dev, MT_PLE_AC_QEMPTY(i));
453- ctrl = BIT(31) | BIT(11) | (i << 24);
454-
455- for (j = 0; j < 32; j++) {
456- if (val & BIT(j))
457- continue;
458-
459- mt76_wr(dev, MT_PLE_FL_Q0_CTRL, ctrl | j);
460- qlen += mt76_get_field(dev, MT_PLE_FL_Q3_CTRL,
461- GENMASK(11, 0));
462- }
463- seq_printf(s, "AC%d: queued=%d\n", i, qlen);
464- }
465-
466- mt7921_mutex_release(dev);
467-
468- return 0;
469-}
470-
471-static int
472-mt7921_queues_read(struct seq_file *s, void *data)
473-{
474- struct mt7921_dev *dev = dev_get_drvdata(s->private);
475- struct {
476- struct mt76_queue *q;
477- char *queue;
478- } queue_map[] = {
479- { dev->mphy.q_tx[MT_TXQ_BE], "WFDMA0" },
480- { dev->mt76.q_mcu[MT_MCUQ_WM], "MCUWM" },
481- { dev->mt76.q_mcu[MT_MCUQ_FWDL], "MCUFWQ" },
482- };
483- int i;
484-
485- for (i = 0; i < ARRAY_SIZE(queue_map); i++) {
486- struct mt76_queue *q = queue_map[i].q;
487-
488- if (!q)
489- continue;
490-
491- seq_printf(s,
492- "%s: queued=%d head=%d tail=%d\n",
493- queue_map[i].queue, q->queued, q->head,
494- q->tail);
495- }
496-
497- return 0;
498-}
499+DEFINE_SHOW_ATTRIBUTE(mt792x_tx_stats);
500
501 static void
502 mt7921_seq_puts_array(struct seq_file *file, const char *str,
503@@ -211,13 +90,13 @@ mt7921_seq_puts_array(struct seq_file *file, const char *str,
504 static int
505 mt7921_txpwr(struct seq_file *s, void *data)
506 {
507- struct mt7921_dev *dev = dev_get_drvdata(s->private);
508+ struct mt792x_dev *dev = dev_get_drvdata(s->private);
509 struct mt7921_txpwr txpwr;
510 int ret;
511
512- mt7921_mutex_acquire(dev);
513+ mt792x_mutex_acquire(dev);
514 ret = mt7921_get_txpwr_info(dev, &txpwr);
515- mt7921_mutex_release(dev);
516+ mt792x_mutex_release(dev);
517
518 if (ret)
519 return ret;
520@@ -263,7 +142,7 @@ mt7921_txpwr(struct seq_file *s, void *data)
521 static int
522 mt7921_pm_set(void *data, u64 val)
523 {
524- struct mt7921_dev *dev = data;
525+ struct mt792x_dev *dev = data;
526 struct mt76_connac_pm *pm = &dev->pm;
527
528 if (mt76_is_usb(&dev->mt76))
529@@ -296,7 +175,7 @@ out:
530 static int
531 mt7921_pm_get(void *data, u64 *val)
532 {
533- struct mt7921_dev *dev = data;
534+ struct mt792x_dev *dev = data;
535
536 *val = dev->pm.enable_user;
537
538@@ -308,7 +187,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7921_pm_get, mt7921_pm_set, "%lld\n");
539 static int
540 mt7921_deep_sleep_set(void *data, u64 val)
541 {
542- struct mt7921_dev *dev = data;
543+ struct mt792x_dev *dev = data;
544 struct mt76_connac_pm *pm = &dev->pm;
545 bool monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR);
546 bool enable = !!val;
547@@ -316,7 +195,7 @@ mt7921_deep_sleep_set(void *data, u64 val)
548 if (mt76_is_usb(&dev->mt76))
549 return -EOPNOTSUPP;
550
551- mt7921_mutex_acquire(dev);
552+ mt792x_mutex_acquire(dev);
553 if (pm->ds_enable_user == enable)
554 goto out;
555
556@@ -324,7 +203,7 @@ mt7921_deep_sleep_set(void *data, u64 val)
557 pm->ds_enable = enable && !monitor;
558 mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
559 out:
560- mt7921_mutex_release(dev);
561+ mt792x_mutex_release(dev);
562
563 return 0;
564 }
565@@ -332,7 +211,7 @@ out:
566 static int
567 mt7921_deep_sleep_get(void *data, u64 *val)
568 {
569- struct mt7921_dev *dev = data;
570+ struct mt792x_dev *dev = data;
571
572 *val = dev->pm.ds_enable_user;
573
574@@ -342,67 +221,24 @@ mt7921_deep_sleep_get(void *data, u64 *val)
575 DEFINE_DEBUGFS_ATTRIBUTE(fops_ds, mt7921_deep_sleep_get,
576 mt7921_deep_sleep_set, "%lld\n");
577
578-static int
579-mt7921_pm_stats(struct seq_file *s, void *data)
580-{
581- struct mt7921_dev *dev = dev_get_drvdata(s->private);
582- struct mt76_connac_pm *pm = &dev->pm;
583-
584- unsigned long awake_time = pm->stats.awake_time;
585- unsigned long doze_time = pm->stats.doze_time;
586-
587- if (!test_bit(MT76_STATE_PM, &dev->mphy.state))
588- awake_time += jiffies - pm->stats.last_wake_event;
589- else
590- doze_time += jiffies - pm->stats.last_doze_event;
591-
592- seq_printf(s, "awake time: %14u\ndoze time: %15u\n",
593- jiffies_to_msecs(awake_time),
594- jiffies_to_msecs(doze_time));
595-
596- seq_printf(s, "low power wakes: %9d\n", pm->stats.lp_wake);
597-
598- return 0;
599-}
600-
601-static int
602-mt7921_pm_idle_timeout_set(void *data, u64 val)
603-{
604- struct mt7921_dev *dev = data;
605-
606- dev->pm.idle_timeout = msecs_to_jiffies(val);
607-
608- return 0;
609-}
610-
611-static int
612-mt7921_pm_idle_timeout_get(void *data, u64 *val)
613-{
614- struct mt7921_dev *dev = data;
615-
616- *val = jiffies_to_msecs(dev->pm.idle_timeout);
617-
618- return 0;
619-}
620-
621-DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt7921_pm_idle_timeout_get,
622- mt7921_pm_idle_timeout_set, "%lld\n");
623+DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt792x_pm_idle_timeout_get,
624+ mt792x_pm_idle_timeout_set, "%lld\n");
625
626 static int mt7921_chip_reset(void *data, u64 val)
627 {
628- struct mt7921_dev *dev = data;
629+ struct mt792x_dev *dev = data;
630 int ret = 0;
631
632 switch (val) {
633 case 1:
634 /* Reset wifisys directly. */
635- mt7921_reset(&dev->mt76);
636+ mt792x_reset(&dev->mt76);
637 break;
638 default:
639 /* Collect the core dump before reset wifisys. */
640- mt7921_mutex_acquire(dev);
641+ mt792x_mutex_acquire(dev);
642 ret = mt76_connac_mcu_chip_config(&dev->mt76);
643- mt7921_mutex_release(dev);
644+ mt792x_mutex_release(dev);
645 break;
646 }
647
648@@ -414,7 +250,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_reset, NULL, mt7921_chip_reset, "%lld\n");
649 static int
650 mt7921s_sched_quota_read(struct seq_file *s, void *data)
651 {
652- struct mt7921_dev *dev = dev_get_drvdata(s->private);
653+ struct mt792x_dev *dev = dev_get_drvdata(s->private);
654 struct mt76_sdio *sdio = &dev->mt76.sdio;
655
656 seq_printf(s, "pse_data_quota\t%d\n", sdio->sched.pse_data_quota);
657@@ -425,7 +261,7 @@ mt7921s_sched_quota_read(struct seq_file *s, void *data)
658 return 0;
659 }
660
661-int mt7921_init_debugfs(struct mt7921_dev *dev)
662+int mt7921_init_debugfs(struct mt792x_dev *dev)
663 {
664 struct dentry *dir;
665
666@@ -435,23 +271,23 @@ int mt7921_init_debugfs(struct mt7921_dev *dev)
667
668 if (mt76_is_mmio(&dev->mt76))
669 debugfs_create_devm_seqfile(dev->mt76.dev, "xmit-queues",
670- dir, mt7921_queues_read);
671+ dir, mt792x_queues_read);
672 else
673 debugfs_create_devm_seqfile(dev->mt76.dev, "xmit-queues",
674 dir, mt76_queues_read);
675
676 debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir,
677- mt7921_queues_acq);
678+ mt792x_queues_acq);
679 debugfs_create_devm_seqfile(dev->mt76.dev, "txpower_sku", dir,
680 mt7921_txpwr);
681- debugfs_create_file("tx_stats", 0400, dir, dev, &mt7921_tx_stats_fops);
682+ debugfs_create_file("tx_stats", 0400, dir, dev, &mt792x_tx_stats_fops);
683 debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug);
684 debugfs_create_file("runtime-pm", 0600, dir, dev, &fops_pm);
685 debugfs_create_file("idle-timeout", 0600, dir, dev,
686 &fops_pm_idle_timeout);
687 debugfs_create_file("chip_reset", 0600, dir, dev, &fops_reset);
688 debugfs_create_devm_seqfile(dev->mt76.dev, "runtime_pm_stats", dir,
689- mt7921_pm_stats);
690+ mt792x_pm_stats);
691 debugfs_create_file("deep-sleep", 0600, dir, dev, &fops_ds);
692 if (mt76_is_sdio(&dev->mt76))
693 debugfs_create_devm_seqfile(dev->mt76.dev, "sched-quota", dir,
694diff --git a/mt7921/init.c b/mt7921/init.c
695index 94b7cdfd..ff63f37f 100644
696--- a/mt7921/init.c
697+++ b/mt7921/init.c
698@@ -10,63 +10,19 @@
699 #include "../mt76_connac2_mac.h"
700 #include "mcu.h"
701
702-static const struct ieee80211_iface_limit if_limits[] = {
703- {
704- .max = MT7921_MAX_INTERFACES,
705- .types = BIT(NL80211_IFTYPE_STATION)
706- },
707- {
708- .max = 1,
709- .types = BIT(NL80211_IFTYPE_AP)
710- }
711-};
712-
713-static const struct ieee80211_iface_combination if_comb[] = {
714- {
715- .limits = if_limits,
716- .n_limits = ARRAY_SIZE(if_limits),
717- .max_interfaces = MT7921_MAX_INTERFACES,
718- .num_different_channels = 1,
719- .beacon_int_infra_match = true,
720- },
721-};
722-
723-static const struct ieee80211_iface_limit if_limits_chanctx[] = {
724- {
725- .max = 2,
726- .types = BIT(NL80211_IFTYPE_STATION) |
727- BIT(NL80211_IFTYPE_P2P_CLIENT)
728- },
729- {
730- .max = 1,
731- .types = BIT(NL80211_IFTYPE_AP) |
732- BIT(NL80211_IFTYPE_P2P_GO)
733- }
734-};
735-
736-static const struct ieee80211_iface_combination if_comb_chanctx[] = {
737- {
738- .limits = if_limits_chanctx,
739- .n_limits = ARRAY_SIZE(if_limits_chanctx),
740- .max_interfaces = 2,
741- .num_different_channels = 2,
742- .beacon_int_infra_match = false,
743- }
744-};
745-
746 static ssize_t mt7921_thermal_temp_show(struct device *dev,
747 struct device_attribute *attr,
748 char *buf)
749 {
750 switch (to_sensor_dev_attr(attr)->index) {
751 case 0: {
752- struct mt7921_phy *phy = dev_get_drvdata(dev);
753- struct mt7921_dev *mdev = phy->dev;
754+ struct mt792x_phy *phy = dev_get_drvdata(dev);
755+ struct mt792x_dev *mdev = phy->dev;
756 int temperature;
757
758- mt7921_mutex_acquire(mdev);
759+ mt792x_mutex_acquire(mdev);
760 temperature = mt7921_mcu_get_temperature(phy);
761- mt7921_mutex_release(mdev);
762+ mt792x_mutex_release(mdev);
763
764 if (temperature < 0)
765 return temperature;
766@@ -85,7 +41,7 @@ static struct attribute *mt7921_hwmon_attrs[] = {
767 };
768 ATTRIBUTE_GROUPS(mt7921_hwmon);
769
770-static int mt7921_thermal_init(struct mt7921_phy *phy)
771+static int mt7921_thermal_init(struct mt792x_phy *phy)
772 {
773 struct wiphy *wiphy = phy->mt76->hw->wiphy;
774 struct device *hwmon;
775@@ -110,206 +66,20 @@ mt7921_regd_notifier(struct wiphy *wiphy,
776 struct regulatory_request *request)
777 {
778 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
779- struct mt7921_dev *dev = mt7921_hw_dev(hw);
780+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
781
782 memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
783 dev->mt76.region = request->dfs_region;
784 dev->country_ie_env = request->country_ie_env;
785
786- mt7921_mutex_acquire(dev);
787+ mt792x_mutex_acquire(dev);
788 mt7921_mcu_set_clc(dev, request->alpha2, request->country_ie_env);
789 mt76_connac_mcu_set_channel_domain(hw->priv);
790 mt7921_set_tx_sar_pwr(hw, NULL);
791- mt7921_mutex_release(dev);
792-}
793-
794-static int
795-mt7921_init_wiphy(struct ieee80211_hw *hw)
796-{
797- struct mt7921_phy *phy = mt7921_hw_phy(hw);
798- struct mt7921_dev *dev = phy->dev;
799- struct wiphy *wiphy = hw->wiphy;
800-
801- hw->queues = 4;
802- hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
803- hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
804- hw->netdev_features = NETIF_F_RXCSUM;
805-
806- hw->radiotap_timestamp.units_pos =
807- IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
808-
809- phy->slottime = 9;
810-
811- hw->sta_data_size = sizeof(struct mt7921_sta);
812- hw->vif_data_size = sizeof(struct mt7921_vif);
813-
814- if (dev->fw_features & MT7921_FW_CAP_CNM) {
815- wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
816- wiphy->iface_combinations = if_comb_chanctx;
817- wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_chanctx);
818- } else {
819- wiphy->flags &= ~WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
820- wiphy->iface_combinations = if_comb;
821- wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
822- }
823- wiphy->flags &= ~(WIPHY_FLAG_IBSS_RSN | WIPHY_FLAG_4ADDR_AP |
824- WIPHY_FLAG_4ADDR_STATION);
825- wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
826- BIT(NL80211_IFTYPE_AP) |
827- BIT(NL80211_IFTYPE_P2P_CLIENT) |
828- BIT(NL80211_IFTYPE_P2P_GO);
829- wiphy->max_remain_on_channel_duration = 5000;
830- wiphy->max_scan_ie_len = MT76_CONNAC_SCAN_IE_LEN;
831- wiphy->max_scan_ssids = 4;
832- wiphy->max_sched_scan_plan_interval =
833- MT76_CONNAC_MAX_TIME_SCHED_SCAN_INTERVAL;
834- wiphy->max_sched_scan_ie_len = IEEE80211_MAX_DATA_LEN;
835- wiphy->max_sched_scan_ssids = MT76_CONNAC_MAX_SCHED_SCAN_SSID;
836- wiphy->max_match_sets = MT76_CONNAC_MAX_SCAN_MATCH;
837- wiphy->max_sched_scan_reqs = 1;
838- wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |
839- WIPHY_FLAG_SPLIT_SCAN_6GHZ;
840- wiphy->reg_notifier = mt7921_regd_notifier;
841-
842- wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |
843- NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
844- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL);
845- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_LEGACY);
846- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HT);
847- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT);
848- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HE);
849- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT);
850- wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
851-
852- ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
853- ieee80211_hw_set(hw, HAS_RATE_CONTROL);
854- ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
855- ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
856- ieee80211_hw_set(hw, WANT_MONITOR_VIF);
857- ieee80211_hw_set(hw, SUPPORTS_PS);
858- ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
859- ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
860- ieee80211_hw_set(hw, CONNECTION_MONITOR);
861-
862- if (dev->pm.enable)
863- ieee80211_hw_set(hw, CONNECTION_MONITOR);
864-
865- hw->max_tx_fragments = 4;
866-
867- return 0;
868-}
869-
870-static void
871-mt7921_mac_init_band(struct mt7921_dev *dev, u8 band)
872-{
873- u32 mask, set;
874-
875- mt76_rmw_field(dev, MT_TMAC_CTCR0(band),
876- MT_TMAC_CTCR0_INS_DDLMT_REFTIME, 0x3f);
877- mt76_set(dev, MT_TMAC_CTCR0(band),
878- MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN |
879- MT_TMAC_CTCR0_INS_DDLMT_EN);
880-
881- mt76_set(dev, MT_WF_RMAC_MIB_TIME0(band), MT_WF_RMAC_MIB_RXTIME_EN);
882- mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(band), MT_WF_RMAC_MIB_RXTIME_EN);
883-
884- /* enable MIB tx-rx time reporting */
885- mt76_set(dev, MT_MIB_SCR1(band), MT_MIB_TXDUR_EN);
886- mt76_set(dev, MT_MIB_SCR1(band), MT_MIB_RXDUR_EN);
887-
888- mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_MAX_RX_LEN, 1536);
889- /* disable rx rate report by default due to hw issues */
890- mt76_clear(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN);
891-
892- /* filter out non-resp frames and get instantaneous signal reporting */
893- mask = MT_WTBLOFF_TOP_RSCR_RCPI_MODE | MT_WTBLOFF_TOP_RSCR_RCPI_PARAM;
894- set = FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_MODE, 0) |
895- FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_PARAM, 0x3);
896- mt76_rmw(dev, MT_WTBLOFF_TOP_RSCR(band), mask, set);
897-}
898-
899-static u8
900-mt7921_get_offload_capability(struct device *dev, const char *fw_wm)
901-{
902- const struct mt76_connac2_fw_trailer *hdr;
903- struct mt7921_realease_info *rel_info;
904- const struct firmware *fw;
905- int ret, i, offset = 0;
906- const u8 *data, *end;
907- u8 offload_caps = 0;
908-
909- ret = request_firmware(&fw, fw_wm, dev);
910- if (ret)
911- return ret;
912-
913- if (!fw || !fw->data || fw->size < sizeof(*hdr)) {
914- dev_err(dev, "Invalid firmware\n");
915- goto out;
916- }
917-
918- data = fw->data;
919- hdr = (const void *)(fw->data + fw->size - sizeof(*hdr));
920-
921- for (i = 0; i < hdr->n_region; i++) {
922- const struct mt76_connac2_fw_region *region;
923-
924- region = (const void *)((const u8 *)hdr -
925- (hdr->n_region - i) * sizeof(*region));
926- offset += le32_to_cpu(region->len);
927- }
928-
929- data += offset + 16;
930- rel_info = (struct mt7921_realease_info *)data;
931- data += sizeof(*rel_info);
932- end = data + le16_to_cpu(rel_info->len);
933-
934- while (data < end) {
935- rel_info = (struct mt7921_realease_info *)data;
936- data += sizeof(*rel_info);
937-
938- if (rel_info->tag == MT7921_FW_TAG_FEATURE) {
939- struct mt7921_fw_features *features;
940-
941- features = (struct mt7921_fw_features *)data;
942- offload_caps = features->data;
943- break;
944- }
945-
946- data += le16_to_cpu(rel_info->len) + rel_info->pad_len;
947- }
948-
949-out:
950- release_firmware(fw);
951-
952- return offload_caps;
953+ mt792x_mutex_release(dev);
954 }
955
956-struct ieee80211_ops *
957-mt7921_get_mac80211_ops(struct device *dev, void *drv_data, u8 *fw_features)
958-{
959- struct ieee80211_ops *ops;
960-
961- ops = devm_kmemdup(dev, &mt7921_ops, sizeof(mt7921_ops), GFP_KERNEL);
962- if (!ops)
963- return NULL;
964-
965- *fw_features = mt7921_get_offload_capability(dev, drv_data);
966- if (!(*fw_features & MT7921_FW_CAP_CNM)) {
967- ops->remain_on_channel = NULL;
968- ops->cancel_remain_on_channel = NULL;
969- ops->add_chanctx = NULL;
970- ops->remove_chanctx = NULL;
971- ops->change_chanctx = NULL;
972- ops->assign_vif_chanctx = NULL;
973- ops->unassign_vif_chanctx = NULL;
974- ops->mgd_prepare_tx = NULL;
975- ops->mgd_complete_tx = NULL;
976- }
977- return ops;
978-}
979-EXPORT_SYMBOL_GPL(mt7921_get_mac80211_ops);
980-
981-int mt7921_mac_init(struct mt7921_dev *dev)
982+int mt7921_mac_init(struct mt792x_dev *dev)
983 {
984 int i;
985
986@@ -319,17 +89,17 @@ int mt7921_mac_init(struct mt7921_dev *dev)
987 /* enable hardware rx header translation */
988 mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_RX_HDR_TRANS_EN);
989
990- for (i = 0; i < MT7921_WTBL_SIZE; i++)
991+ for (i = 0; i < MT792x_WTBL_SIZE; i++)
992 mt7921_mac_wtbl_update(dev, i,
993 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
994 for (i = 0; i < 2; i++)
995- mt7921_mac_init_band(dev, i);
996+ mt792x_mac_init_band(dev, i);
997
998 return mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 0);
999 }
1000 EXPORT_SYMBOL_GPL(mt7921_mac_init);
1001
1002-static int __mt7921_init_hardware(struct mt7921_dev *dev)
1003+static int __mt7921_init_hardware(struct mt792x_dev *dev)
1004 {
1005 int ret;
1006
1007@@ -337,7 +107,7 @@ static int __mt7921_init_hardware(struct mt7921_dev *dev)
1008 * which should be set before firmware download stage.
1009 */
1010 mt76_wr(dev, MT_SWDEF_MODE, MT_SWDEF_NORMAL_MODE);
1011- ret = mt7921_mcu_init(dev);
1012+ ret = mt792x_mcu_init(dev);
1013 if (ret)
1014 goto out;
1015
1016@@ -352,21 +122,21 @@ out:
1017 return ret;
1018 }
1019
1020-static int mt7921_init_hardware(struct mt7921_dev *dev)
1021+static int mt7921_init_hardware(struct mt792x_dev *dev)
1022 {
1023 int ret, i;
1024
1025 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
1026
1027- for (i = 0; i < MT7921_MCU_INIT_RETRY_COUNT; i++) {
1028+ for (i = 0; i < MT792x_MCU_INIT_RETRY_COUNT; i++) {
1029 ret = __mt7921_init_hardware(dev);
1030 if (!ret)
1031 break;
1032
1033- mt7921_init_reset(dev);
1034+ mt792x_init_reset(dev);
1035 }
1036
1037- if (i == MT7921_MCU_INIT_RETRY_COUNT) {
1038+ if (i == MT792x_MCU_INIT_RETRY_COUNT) {
1039 dev_err(dev->mt76.dev, "hardware init failed\n");
1040 return ret;
1041 }
1042@@ -374,26 +144,9 @@ static int mt7921_init_hardware(struct mt7921_dev *dev)
1043 return 0;
1044 }
1045
1046-static int mt7921_init_wcid(struct mt7921_dev *dev)
1047-{
1048- int idx;
1049-
1050- /* Beacon and mgmt frames should occupy wcid 0 */
1051- idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
1052- if (idx)
1053- return -ENOSPC;
1054-
1055- dev->mt76.global_wcid.idx = idx;
1056- dev->mt76.global_wcid.hw_key_idx = -1;
1057- dev->mt76.global_wcid.tx_info |= MT_WCID_TX_INFO_SET;
1058- rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid);
1059-
1060- return 0;
1061-}
1062-
1063 static void mt7921_init_work(struct work_struct *work)
1064 {
1065- struct mt7921_dev *dev = container_of(work, struct mt7921_dev,
1066+ struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
1067 init_work);
1068 int ret;
1069
1070@@ -429,7 +182,7 @@ static void mt7921_init_work(struct work_struct *work)
1071 mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable);
1072 }
1073
1074-int mt7921_register_device(struct mt7921_dev *dev)
1075+int mt7921_register_device(struct mt792x_dev *dev)
1076 {
1077 struct ieee80211_hw *hw = mt76_hw(dev);
1078 int ret;
1079@@ -437,17 +190,17 @@ int mt7921_register_device(struct mt7921_dev *dev)
1080 dev->phy.dev = dev;
1081 dev->phy.mt76 = &dev->mt76.phy;
1082 dev->mt76.phy.priv = &dev->phy;
1083- dev->mt76.tx_worker.fn = mt7921_tx_worker;
1084+ dev->mt76.tx_worker.fn = mt792x_tx_worker;
1085
1086- INIT_DELAYED_WORK(&dev->pm.ps_work, mt7921_pm_power_save_work);
1087- INIT_WORK(&dev->pm.wake_work, mt7921_pm_wake_work);
1088+ INIT_DELAYED_WORK(&dev->pm.ps_work, mt792x_pm_power_save_work);
1089+ INIT_WORK(&dev->pm.wake_work, mt792x_pm_wake_work);
1090 spin_lock_init(&dev->pm.wake.lock);
1091 mutex_init(&dev->pm.mutex);
1092 init_waitqueue_head(&dev->pm.wait);
1093 if (mt76_is_sdio(&dev->mt76))
1094 init_waitqueue_head(&dev->mt76.sdio.wait);
1095 spin_lock_init(&dev->pm.txq_lock);
1096- INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7921_mac_work);
1097+ INIT_DELAYED_WORK(&dev->mphy.mac_work, mt792x_mac_work);
1098 INIT_DELAYED_WORK(&dev->phy.scan_work, mt7921_scan_work);
1099 INIT_DELAYED_WORK(&dev->coredump.work, mt7921_coredump_work);
1100 #if IS_ENABLED(CONFIG_IPV6)
1101@@ -461,10 +214,10 @@ int mt7921_register_device(struct mt7921_dev *dev)
1102 INIT_WORK(&dev->init_work, mt7921_init_work);
1103
1104 INIT_WORK(&dev->phy.roc_work, mt7921_roc_work);
1105- timer_setup(&dev->phy.roc_timer, mt7921_roc_timer, 0);
1106+ timer_setup(&dev->phy.roc_timer, mt792x_roc_timer, 0);
1107 init_waitqueue_head(&dev->phy.roc_wait);
1108
1109- dev->pm.idle_timeout = MT7921_PM_TIMEOUT;
1110+ dev->pm.idle_timeout = MT792x_PM_TIMEOUT;
1111 dev->pm.stats.last_wake_event = jiffies;
1112 dev->pm.stats.last_doze_event = jiffies;
1113 if (!mt76_is_usb(&dev->mt76)) {
1114@@ -477,16 +230,17 @@ int mt7921_register_device(struct mt7921_dev *dev)
1115 if (!mt76_is_mmio(&dev->mt76))
1116 hw->extra_tx_headroom += MT_SDIO_TXD_SIZE + MT_SDIO_HDR_SIZE;
1117
1118- mt7921_init_acpi_sar(dev);
1119+ mt792x_init_acpi_sar(dev);
1120
1121- ret = mt7921_init_wcid(dev);
1122+ ret = mt792x_init_wcid(dev);
1123 if (ret)
1124 return ret;
1125
1126- ret = mt7921_init_wiphy(hw);
1127+ ret = mt792x_init_wiphy(hw);
1128 if (ret)
1129 return ret;
1130
1131+ hw->wiphy->reg_notifier = mt7921_regd_notifier;
1132 dev->mphy.sband_2g.sband.ht_cap.cap |=
1133 IEEE80211_HT_CAP_LDPC_CODING |
1134 IEEE80211_HT_CAP_MAX_AMSDU;
1135diff --git a/mt7921/mac.c b/mt7921/mac.c
1136index 368f9271..21f93745 100644
1137--- a/mt7921/mac.c
1138+++ b/mt7921/mac.c
1139@@ -15,35 +15,7 @@
1140
1141 #define MT_WTBL_AC0_CTT_OFFSET 20
1142
1143-static u32 mt7921_mac_wtbl_lmac_addr(int idx, u8 offset)
1144-{
1145- return MT_WTBL_LMAC_OFFS(idx, 0) + offset * 4;
1146-}
1147-
1148-static struct mt76_wcid *mt7921_rx_get_wcid(struct mt7921_dev *dev,
1149- u16 idx, bool unicast)
1150-{
1151- struct mt7921_sta *sta;
1152- struct mt76_wcid *wcid;
1153-
1154- if (idx >= ARRAY_SIZE(dev->mt76.wcid))
1155- return NULL;
1156-
1157- wcid = rcu_dereference(dev->mt76.wcid[idx]);
1158- if (unicast || !wcid)
1159- return wcid;
1160-
1161- if (!wcid->sta)
1162- return NULL;
1163-
1164- sta = container_of(wcid, struct mt7921_sta, wcid);
1165- if (!sta->vif)
1166- return NULL;
1167-
1168- return &sta->vif->sta.wcid;
1169-}
1170-
1171-bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask)
1172+bool mt7921_mac_wtbl_update(struct mt792x_dev *dev, int idx, u32 mask)
1173 {
1174 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX,
1175 FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, idx) | mask);
1176@@ -52,7 +24,12 @@ bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask)
1177 0, 5000);
1178 }
1179
1180-static void mt7921_mac_sta_poll(struct mt7921_dev *dev)
1181+static u32 mt7921_mac_wtbl_lmac_addr(int idx, u8 offset)
1182+{
1183+ return MT_WTBL_LMAC_OFFS(idx, 0) + offset * 4;
1184+}
1185+
1186+static void mt7921_mac_sta_poll(struct mt792x_dev *dev)
1187 {
1188 static const u8 ac_to_tid[] = {
1189 [IEEE80211_AC_BE] = 0,
1190@@ -61,7 +38,7 @@ static void mt7921_mac_sta_poll(struct mt7921_dev *dev)
1191 [IEEE80211_AC_VO] = 6
1192 };
1193 struct ieee80211_sta *sta;
1194- struct mt7921_sta *msta;
1195+ struct mt792x_sta *msta;
1196 u32 tx_time[IEEE80211_NUM_ACS], rx_time[IEEE80211_NUM_ACS];
1197 LIST_HEAD(sta_poll_list);
1198 struct rate_info *rate;
1199@@ -84,7 +61,7 @@ static void mt7921_mac_sta_poll(struct mt7921_dev *dev)
1200 break;
1201 }
1202 msta = list_first_entry(&sta_poll_list,
1203- struct mt7921_sta, wcid.poll_list);
1204+ struct mt792x_sta, wcid.poll_list);
1205 list_del_init(&msta->wcid.poll_list);
1206 spin_unlock_bh(&dev->mt76.sta_poll_lock);
1207
1208@@ -184,54 +161,8 @@ static void mt7921_mac_sta_poll(struct mt7921_dev *dev)
1209 }
1210 }
1211
1212-static void
1213-mt7921_get_status_freq_info(struct mt7921_dev *dev, struct mt76_phy *mphy,
1214- struct mt76_rx_status *status, u8 chfreq)
1215-{
1216- if (chfreq > 180) {
1217- status->band = NL80211_BAND_6GHZ;
1218- chfreq = (chfreq - 181) * 4 + 1;
1219- } else if (chfreq > 14) {
1220- status->band = NL80211_BAND_5GHZ;
1221- } else {
1222- status->band = NL80211_BAND_2GHZ;
1223- }
1224- status->freq = ieee80211_channel_to_frequency(chfreq, status->band);
1225-}
1226-
1227-static void
1228-mt7921_mac_rssi_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
1229-{
1230- struct sk_buff *skb = priv;
1231- struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
1232- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1233- struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
1234-
1235- if (status->signal > 0)
1236- return;
1237-
1238- if (!ether_addr_equal(vif->addr, hdr->addr1))
1239- return;
1240-
1241- ewma_rssi_add(&mvif->rssi, -status->signal);
1242-}
1243-
1244-static void
1245-mt7921_mac_assoc_rssi(struct mt7921_dev *dev, struct sk_buff *skb)
1246-{
1247- struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
1248-
1249- if (!ieee80211_is_assoc_resp(hdr->frame_control) &&
1250- !ieee80211_is_auth(hdr->frame_control))
1251- return;
1252-
1253- ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev),
1254- IEEE80211_IFACE_ITER_RESUME_ALL,
1255- mt7921_mac_rssi_iter, skb);
1256-}
1257-
1258 static int
1259-mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1260+mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
1261 {
1262 u32 csum_mask = MT_RXD0_NORMAL_IP_SUM | MT_RXD0_NORMAL_UDP_TCP_SUM;
1263 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
1264@@ -240,7 +171,7 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1265 u16 hdr_gap;
1266 __le32 *rxv = NULL, *rxd = (__le32 *)skb->data;
1267 struct mt76_phy *mphy = &dev->mt76.phy;
1268- struct mt7921_phy *phy = &dev->phy;
1269+ struct mt792x_phy *phy = &dev->phy;
1270 struct ieee80211_supported_band *sband;
1271 u32 csum_status = *(u32 *)skb->cb;
1272 u32 rxd0 = le32_to_cpu(rxd[0]);
1273@@ -248,7 +179,7 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1274 u32 rxd2 = le32_to_cpu(rxd[2]);
1275 u32 rxd3 = le32_to_cpu(rxd[3]);
1276 u32 rxd4 = le32_to_cpu(rxd[4]);
1277- struct mt7921_sta *msta = NULL;
1278+ struct mt792x_sta *msta = NULL;
1279 u16 seq_ctrl = 0;
1280 __le16 fc = 0;
1281 u8 mode = 0;
1282@@ -276,10 +207,10 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1283 chfreq = FIELD_GET(MT_RXD3_NORMAL_CH_FREQ, rxd3);
1284 unicast = FIELD_GET(MT_RXD3_NORMAL_ADDR_TYPE, rxd3) == MT_RXD3_NORMAL_U2M;
1285 idx = FIELD_GET(MT_RXD1_NORMAL_WLAN_IDX, rxd1);
1286- status->wcid = mt7921_rx_get_wcid(dev, idx, unicast);
1287+ status->wcid = mt792x_rx_get_wcid(dev, idx, unicast);
1288
1289 if (status->wcid) {
1290- msta = container_of(status->wcid, struct mt7921_sta, wcid);
1291+ msta = container_of(status->wcid, struct mt792x_sta, wcid);
1292 spin_lock_bh(&dev->mt76.sta_poll_lock);
1293 if (list_empty(&msta->wcid.poll_list))
1294 list_add_tail(&msta->wcid.poll_list,
1295@@ -287,7 +218,7 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1296 spin_unlock_bh(&dev->mt76.sta_poll_lock);
1297 }
1298
1299- mt7921_get_status_freq_info(dev, mphy, status, chfreq);
1300+ mt792x_get_status_freq_info(status, chfreq);
1301
1302 switch (status->band) {
1303 case NL80211_BAND_5GHZ:
1304@@ -496,7 +427,7 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1305 status->flag |= RX_FLAG_8023;
1306 }
1307
1308- mt7921_mac_assoc_rssi(dev, skb);
1309+ mt792x_mac_assoc_rssi(dev, skb);
1310
1311 if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023))
1312 mt76_connac2_mac_decode_he_radiotap(&dev->mt76, skb, rxv, mode);
1313@@ -511,9 +442,9 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
1314 return 0;
1315 }
1316
1317-void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data)
1318+void mt7921_mac_add_txs(struct mt792x_dev *dev, void *data)
1319 {
1320- struct mt7921_sta *msta = NULL;
1321+ struct mt792x_sta *msta = NULL;
1322 struct mt76_wcid *wcid;
1323 __le32 *txs_data = data;
1324 u16 wcidx;
1325@@ -528,7 +459,7 @@ void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data)
1326 if (pid < MT_PACKET_ID_FIRST)
1327 return;
1328
1329- if (wcidx >= MT7921_WTBL_SIZE)
1330+ if (wcidx >= MT792x_WTBL_SIZE)
1331 return;
1332
1333 rcu_read_lock();
1334@@ -537,7 +468,7 @@ void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data)
1335 if (!wcid)
1336 goto out;
1337
1338- msta = container_of(wcid, struct mt7921_sta, wcid);
1339+ msta = container_of(wcid, struct mt792x_sta, wcid);
1340
1341 mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data);
1342 if (!wcid->sta)
1343@@ -552,7 +483,7 @@ out:
1344 rcu_read_unlock();
1345 }
1346
1347-static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
1348+static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
1349 {
1350 struct mt76_connac_tx_free *free = data;
1351 __le32 *tx_info = (__le32 *)(data + sizeof(*free));
1352@@ -582,7 +513,7 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
1353 * 1'b0: msdu_id with the same 'wcid pair' as above.
1354 */
1355 if (info & MT_TX_FREE_PAIR) {
1356- struct mt7921_sta *msta;
1357+ struct mt792x_sta *msta;
1358 u16 idx;
1359
1360 count++;
1361@@ -592,7 +523,7 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
1362 if (!sta)
1363 continue;
1364
1365- msta = container_of(wcid, struct mt7921_sta, wcid);
1366+ msta = container_of(wcid, struct mt792x_sta, wcid);
1367 spin_lock_bh(&mdev->sta_poll_lock);
1368 if (list_empty(&msta->wcid.poll_list))
1369 list_add_tail(&msta->wcid.poll_list,
1370@@ -634,7 +565,7 @@ static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len)
1371
1372 bool mt7921_rx_check(struct mt76_dev *mdev, void *data, int len)
1373 {
1374- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
1375+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
1376 __le32 *rxd = (__le32 *)data;
1377 __le32 *end = (__le32 *)&rxd[len / 4];
1378 enum rx_pkt_type type;
1379@@ -659,7 +590,7 @@ EXPORT_SYMBOL_GPL(mt7921_rx_check);
1380 void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
1381 struct sk_buff *skb, u32 *info)
1382 {
1383- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
1384+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
1385 __le32 *rxd = (__le32 *)skb->data;
1386 __le32 *end = (__le32 *)&skb->data[skb->len];
1387 enum rx_pkt_type type;
1388@@ -699,128 +630,12 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
1389 }
1390 EXPORT_SYMBOL_GPL(mt7921_queue_rx_skb);
1391
1392-void mt7921_mac_reset_counters(struct mt7921_phy *phy)
1393-{
1394- struct mt7921_dev *dev = phy->dev;
1395- int i;
1396-
1397- for (i = 0; i < 4; i++) {
1398- mt76_rr(dev, MT_TX_AGG_CNT(0, i));
1399- mt76_rr(dev, MT_TX_AGG_CNT2(0, i));
1400- }
1401-
1402- dev->mt76.phy.survey_time = ktime_get_boottime();
1403- memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats));
1404-
1405- /* reset airtime counters */
1406- mt76_rr(dev, MT_MIB_SDR9(0));
1407- mt76_rr(dev, MT_MIB_SDR36(0));
1408- mt76_rr(dev, MT_MIB_SDR37(0));
1409-
1410- mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
1411- mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
1412-}
1413-
1414-void mt7921_mac_set_timing(struct mt7921_phy *phy)
1415-{
1416- s16 coverage_class = phy->coverage_class;
1417- struct mt7921_dev *dev = phy->dev;
1418- u32 val, reg_offset;
1419- u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) |
1420- FIELD_PREP(MT_TIMEOUT_VAL_CCA, 48);
1421- u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) |
1422- FIELD_PREP(MT_TIMEOUT_VAL_CCA, 28);
1423- bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ;
1424- int sifs = is_2ghz ? 10 : 16, offset;
1425-
1426- if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
1427- return;
1428-
1429- mt76_set(dev, MT_ARB_SCR(0),
1430- MT_ARB_SCR_TX_DISABLE | MT_ARB_SCR_RX_DISABLE);
1431- udelay(1);
1432-
1433- offset = 3 * coverage_class;
1434- reg_offset = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, offset) |
1435- FIELD_PREP(MT_TIMEOUT_VAL_CCA, offset);
1436-
1437- mt76_wr(dev, MT_TMAC_CDTR(0), cck + reg_offset);
1438- mt76_wr(dev, MT_TMAC_ODTR(0), ofdm + reg_offset);
1439- mt76_wr(dev, MT_TMAC_ICR0(0),
1440- FIELD_PREP(MT_IFS_EIFS, 360) |
1441- FIELD_PREP(MT_IFS_RIFS, 2) |
1442- FIELD_PREP(MT_IFS_SIFS, sifs) |
1443- FIELD_PREP(MT_IFS_SLOT, phy->slottime));
1444-
1445- if (phy->slottime < 20 || !is_2ghz)
1446- val = MT7921_CFEND_RATE_DEFAULT;
1447- else
1448- val = MT7921_CFEND_RATE_11B;
1449-
1450- mt76_rmw_field(dev, MT_AGG_ACR0(0), MT_AGG_ACR_CFEND_RATE, val);
1451- mt76_clear(dev, MT_ARB_SCR(0),
1452- MT_ARB_SCR_TX_DISABLE | MT_ARB_SCR_RX_DISABLE);
1453-}
1454-
1455-static u8
1456-mt7921_phy_get_nf(struct mt7921_phy *phy, int idx)
1457-{
1458- return 0;
1459-}
1460-
1461-static void
1462-mt7921_phy_update_channel(struct mt76_phy *mphy, int idx)
1463-{
1464- struct mt7921_dev *dev = container_of(mphy->dev, struct mt7921_dev, mt76);
1465- struct mt7921_phy *phy = (struct mt7921_phy *)mphy->priv;
1466- struct mt76_channel_state *state;
1467- u64 busy_time, tx_time, rx_time, obss_time;
1468- int nf;
1469-
1470- busy_time = mt76_get_field(dev, MT_MIB_SDR9(idx),
1471- MT_MIB_SDR9_BUSY_MASK);
1472- tx_time = mt76_get_field(dev, MT_MIB_SDR36(idx),
1473- MT_MIB_SDR36_TXTIME_MASK);
1474- rx_time = mt76_get_field(dev, MT_MIB_SDR37(idx),
1475- MT_MIB_SDR37_RXTIME_MASK);
1476- obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_AIRTIME14(idx),
1477- MT_MIB_OBSSTIME_MASK);
1478-
1479- nf = mt7921_phy_get_nf(phy, idx);
1480- if (!phy->noise)
1481- phy->noise = nf << 4;
1482- else if (nf)
1483- phy->noise += nf - (phy->noise >> 4);
1484-
1485- state = mphy->chan_state;
1486- state->cc_busy += busy_time;
1487- state->cc_tx += tx_time;
1488- state->cc_rx += rx_time + obss_time;
1489- state->cc_bss_rx += rx_time;
1490- state->noise = -(phy->noise >> 4);
1491-}
1492-
1493-void mt7921_update_channel(struct mt76_phy *mphy)
1494-{
1495- struct mt7921_dev *dev = container_of(mphy->dev, struct mt7921_dev, mt76);
1496-
1497- if (mt76_connac_pm_wake(mphy, &dev->pm))
1498- return;
1499-
1500- mt7921_phy_update_channel(mphy, 0);
1501- /* reset obss airtime */
1502- mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
1503-
1504- mt76_connac_power_save_sched(mphy, &dev->pm);
1505-}
1506-EXPORT_SYMBOL_GPL(mt7921_update_channel);
1507-
1508 static void
1509 mt7921_vif_connect_iter(void *priv, u8 *mac,
1510 struct ieee80211_vif *vif)
1511 {
1512- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1513- struct mt7921_dev *dev = mvif->phy->dev;
1514+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1515+ struct mt792x_dev *dev = mvif->phy->dev;
1516 struct ieee80211_hw *hw = mt76_hw(dev);
1517
1518 if (vif->type == NL80211_IFTYPE_STATION)
1519@@ -841,7 +656,7 @@ mt7921_vif_connect_iter(void *priv, u8 *mac,
1520 /* system error recovery */
1521 void mt7921_mac_reset_work(struct work_struct *work)
1522 {
1523- struct mt7921_dev *dev = container_of(work, struct mt7921_dev,
1524+ struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
1525 reset_work);
1526 struct ieee80211_hw *hw = mt76_hw(dev);
1527 struct mt76_connac_pm *pm = &dev->pm;
1528@@ -857,7 +672,7 @@ void mt7921_mac_reset_work(struct work_struct *work)
1529
1530 for (i = 0; i < 10; i++) {
1531 mutex_lock(&dev->mt76.mutex);
1532- ret = mt7921_dev_reset(dev);
1533+ ret = mt792x_dev_reset(dev);
1534 mutex_unlock(&dev->mt76.mutex);
1535
1536 if (!ret)
1537@@ -884,185 +699,12 @@ void mt7921_mac_reset_work(struct work_struct *work)
1538 mt76_connac_power_save_sched(&dev->mt76.phy, pm);
1539 }
1540
1541-void mt7921_reset(struct mt76_dev *mdev)
1542-{
1543- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
1544- struct mt76_connac_pm *pm = &dev->pm;
1545-
1546- if (!dev->hw_init_done)
1547- return;
1548-
1549- if (dev->hw_full_reset)
1550- return;
1551-
1552- if (pm->suspended)
1553- return;
1554-
1555- queue_work(dev->mt76.wq, &dev->reset_work);
1556-}
1557-EXPORT_SYMBOL_GPL(mt7921_reset);
1558-
1559-void mt7921_mac_update_mib_stats(struct mt7921_phy *phy)
1560-{
1561- struct mt76_mib_stats *mib = &phy->mib;
1562- struct mt7921_dev *dev = phy->dev;
1563- int i, aggr0 = 0, aggr1;
1564- u32 val;
1565-
1566- mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(0),
1567- MT_MIB_SDR3_FCS_ERR_MASK);
1568- mib->ack_fail_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR3(0),
1569- MT_MIB_ACK_FAIL_COUNT_MASK);
1570- mib->ba_miss_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR2(0),
1571- MT_MIB_BA_FAIL_COUNT_MASK);
1572- mib->rts_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR0(0),
1573- MT_MIB_RTS_COUNT_MASK);
1574- mib->rts_retries_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR1(0),
1575- MT_MIB_RTS_FAIL_COUNT_MASK);
1576-
1577- mib->tx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR12(0));
1578- mib->tx_mpdu_attempts_cnt += mt76_rr(dev, MT_MIB_SDR14(0));
1579- mib->tx_mpdu_success_cnt += mt76_rr(dev, MT_MIB_SDR15(0));
1580-
1581- val = mt76_rr(dev, MT_MIB_SDR32(0));
1582- mib->tx_pkt_ebf_cnt += FIELD_GET(MT_MIB_SDR9_EBF_CNT_MASK, val);
1583- mib->tx_pkt_ibf_cnt += FIELD_GET(MT_MIB_SDR9_IBF_CNT_MASK, val);
1584-
1585- val = mt76_rr(dev, MT_ETBF_TX_APP_CNT(0));
1586- mib->tx_bf_ibf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_IBF_CNT, val);
1587- mib->tx_bf_ebf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_EBF_CNT, val);
1588-
1589- val = mt76_rr(dev, MT_ETBF_RX_FB_CNT(0));
1590- mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_ETBF_RX_FB_ALL, val);
1591- mib->tx_bf_rx_fb_he_cnt += FIELD_GET(MT_ETBF_RX_FB_HE, val);
1592- mib->tx_bf_rx_fb_vht_cnt += FIELD_GET(MT_ETBF_RX_FB_VHT, val);
1593- mib->tx_bf_rx_fb_ht_cnt += FIELD_GET(MT_ETBF_RX_FB_HT, val);
1594-
1595- mib->rx_mpdu_cnt += mt76_rr(dev, MT_MIB_SDR5(0));
1596- mib->rx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR22(0));
1597- mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0));
1598- mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0));
1599-
1600- for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
1601- val = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i));
1602- mib->tx_amsdu[i] += val;
1603- mib->tx_amsdu_cnt += val;
1604- }
1605-
1606- for (i = 0, aggr1 = aggr0 + 8; i < 4; i++) {
1607- u32 val2;
1608-
1609- val = mt76_rr(dev, MT_TX_AGG_CNT(0, i));
1610- val2 = mt76_rr(dev, MT_TX_AGG_CNT2(0, i));
1611-
1612- phy->mt76->aggr_stats[aggr0++] += val & 0xffff;
1613- phy->mt76->aggr_stats[aggr0++] += val >> 16;
1614- phy->mt76->aggr_stats[aggr1++] += val2 & 0xffff;
1615- phy->mt76->aggr_stats[aggr1++] += val2 >> 16;
1616- }
1617-}
1618-
1619-void mt7921_mac_work(struct work_struct *work)
1620-{
1621- struct mt7921_phy *phy;
1622- struct mt76_phy *mphy;
1623-
1624- mphy = (struct mt76_phy *)container_of(work, struct mt76_phy,
1625- mac_work.work);
1626- phy = mphy->priv;
1627-
1628- mt7921_mutex_acquire(phy->dev);
1629-
1630- mt76_update_survey(mphy);
1631- if (++mphy->mac_work_count == 2) {
1632- mphy->mac_work_count = 0;
1633-
1634- mt7921_mac_update_mib_stats(phy);
1635- }
1636-
1637- mt7921_mutex_release(phy->dev);
1638-
1639- mt76_tx_status_check(mphy->dev, false);
1640- ieee80211_queue_delayed_work(phy->mt76->hw, &mphy->mac_work,
1641- MT7921_WATCHDOG_TIME);
1642-}
1643-
1644-void mt7921_pm_wake_work(struct work_struct *work)
1645-{
1646- struct mt7921_dev *dev;
1647- struct mt76_phy *mphy;
1648-
1649- dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
1650- pm.wake_work);
1651- mphy = dev->phy.mt76;
1652-
1653- if (!mt7921_mcu_drv_pmctrl(dev)) {
1654- struct mt76_dev *mdev = &dev->mt76;
1655- int i;
1656-
1657- if (mt76_is_sdio(mdev)) {
1658- mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
1659- mt76_worker_schedule(&mdev->sdio.txrx_worker);
1660- } else {
1661- local_bh_disable();
1662- mt76_for_each_q_rx(mdev, i)
1663- napi_schedule(&mdev->napi[i]);
1664- local_bh_enable();
1665- mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
1666- mt76_connac_tx_cleanup(mdev);
1667- }
1668- if (test_bit(MT76_STATE_RUNNING, &mphy->state))
1669- ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1670- MT7921_WATCHDOG_TIME);
1671- }
1672-
1673- ieee80211_wake_queues(mphy->hw);
1674- wake_up(&dev->pm.wait);
1675-}
1676-
1677-void mt7921_pm_power_save_work(struct work_struct *work)
1678-{
1679- struct mt7921_dev *dev;
1680- unsigned long delta;
1681- struct mt76_phy *mphy;
1682-
1683- dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
1684- pm.ps_work.work);
1685- mphy = dev->phy.mt76;
1686-
1687- delta = dev->pm.idle_timeout;
1688- if (test_bit(MT76_HW_SCANNING, &mphy->state) ||
1689- test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) ||
1690- dev->fw_assert)
1691- goto out;
1692-
1693- if (mutex_is_locked(&dev->mt76.mutex))
1694- /* if mt76 mutex is held we should not put the device
1695- * to sleep since we are currently accessing device
1696- * register map. We need to wait for the next power_save
1697- * trigger.
1698- */
1699- goto out;
1700-
1701- if (time_is_after_jiffies(dev->pm.last_activity + delta)) {
1702- delta = dev->pm.last_activity + delta - jiffies;
1703- goto out;
1704- }
1705-
1706- if (!mt7921_mcu_fw_pmctrl(dev)) {
1707- cancel_delayed_work_sync(&mphy->mac_work);
1708- return;
1709- }
1710-out:
1711- queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta);
1712-}
1713-
1714 void mt7921_coredump_work(struct work_struct *work)
1715 {
1716- struct mt7921_dev *dev;
1717+ struct mt792x_dev *dev;
1718 char *dump, *data;
1719
1720- dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
1721+ dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev,
1722 coredump.work.work);
1723
1724 if (time_is_after_jiffies(dev->coredump.last_activity +
1725@@ -1101,12 +743,12 @@ void mt7921_coredump_work(struct work_struct *work)
1726 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ,
1727 GFP_KERNEL);
1728
1729- mt7921_reset(&dev->mt76);
1730+ mt792x_reset(&dev->mt76);
1731 }
1732
1733 /* usb_sdio */
1734 static void
1735-mt7921_usb_sdio_write_txwi(struct mt7921_dev *dev, struct mt76_wcid *wcid,
1736+mt7921_usb_sdio_write_txwi(struct mt792x_dev *dev, struct mt76_wcid *wcid,
1737 enum mt76_txq_id qid, struct ieee80211_sta *sta,
1738 struct ieee80211_key_conf *key, int pid,
1739 struct sk_buff *skb)
1740@@ -1123,7 +765,7 @@ int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
1741 struct ieee80211_sta *sta,
1742 struct mt76_tx_info *tx_info)
1743 {
1744- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
1745+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
1746 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
1747 struct ieee80211_key_conf *key = info->control.hw_key;
1748 struct sk_buff *skb = tx_info->skb;
1749@@ -1140,7 +782,7 @@ int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
1750 wcid = &dev->mt76.global_wcid;
1751
1752 if (sta) {
1753- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
1754+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1755
1756 if (time_after(jiffies, msta->last_txs + HZ / 4)) {
1757 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
1758@@ -1189,11 +831,11 @@ EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_complete_skb);
1759
1760 bool mt7921_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update)
1761 {
1762- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
1763+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
1764
1765- mt7921_mutex_acquire(dev);
1766+ mt792x_mutex_acquire(dev);
1767 mt7921_mac_sta_poll(dev);
1768- mt7921_mutex_release(dev);
1769+ mt792x_mutex_release(dev);
1770
1771 return false;
1772 }
1773@@ -1202,8 +844,8 @@ EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_status_data);
1774 #if IS_ENABLED(CONFIG_IPV6)
1775 void mt7921_set_ipv6_ns_work(struct work_struct *work)
1776 {
1777- struct mt7921_dev *dev = container_of(work, struct mt7921_dev,
1778- ipv6_ns_work);
1779+ struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
1780+ ipv6_ns_work);
1781 struct sk_buff *skb;
1782 int ret = 0;
1783
1784@@ -1213,10 +855,10 @@ void mt7921_set_ipv6_ns_work(struct work_struct *work)
1785 if (!skb)
1786 break;
1787
1788- mt7921_mutex_acquire(dev);
1789+ mt792x_mutex_acquire(dev);
1790 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
1791 MCU_UNI_CMD(OFFLOAD), true);
1792- mt7921_mutex_release(dev);
1793+ mt792x_mutex_release(dev);
1794
1795 } while (!ret);
1796
1797diff --git a/mt7921/main.c b/mt7921/main.c
1798index 87067ac3..0844d28b 100644
1799--- a/mt7921/main.c
1800+++ b/mt7921/main.c
1801@@ -10,7 +10,7 @@
1802 #include "mcu.h"
1803
1804 static int
1805-mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
1806+mt7921_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
1807 struct ieee80211_sband_iftype_data *data)
1808 {
1809 int i, idx = 0;
1810@@ -185,7 +185,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
1811 return idx;
1812 }
1813
1814-void mt7921_set_stream_he_caps(struct mt7921_phy *phy)
1815+void mt7921_set_stream_he_caps(struct mt792x_phy *phy)
1816 {
1817 struct ieee80211_sband_iftype_data *data;
1818 struct ieee80211_supported_band *band;
1819@@ -219,7 +219,7 @@ void mt7921_set_stream_he_caps(struct mt7921_phy *phy)
1820 }
1821 }
1822
1823-int __mt7921_start(struct mt7921_phy *phy)
1824+int __mt7921_start(struct mt792x_phy *phy)
1825 {
1826 struct mt76_phy *mphy = phy->mt76;
1827 int err;
1828@@ -240,11 +240,11 @@ int __mt7921_start(struct mt7921_phy *phy)
1829 if (err)
1830 return err;
1831
1832- mt7921_mac_reset_counters(phy);
1833+ mt792x_mac_reset_counters(phy);
1834 set_bit(MT76_STATE_RUNNING, &mphy->state);
1835
1836 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1837- MT7921_WATCHDOG_TIME);
1838+ MT792x_WATCHDOG_TIME);
1839
1840 return 0;
1841 }
1842@@ -252,20 +252,20 @@ EXPORT_SYMBOL_GPL(__mt7921_start);
1843
1844 static int mt7921_start(struct ieee80211_hw *hw)
1845 {
1846- struct mt7921_phy *phy = mt7921_hw_phy(hw);
1847+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
1848 int err;
1849
1850- mt7921_mutex_acquire(phy->dev);
1851+ mt792x_mutex_acquire(phy->dev);
1852 err = __mt7921_start(phy);
1853- mt7921_mutex_release(phy->dev);
1854+ mt792x_mutex_release(phy->dev);
1855
1856 return err;
1857 }
1858
1859 void mt7921_stop(struct ieee80211_hw *hw)
1860 {
1861- struct mt7921_dev *dev = mt7921_hw_dev(hw);
1862- struct mt7921_phy *phy = mt7921_hw_phy(hw);
1863+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
1864+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
1865
1866 cancel_delayed_work_sync(&phy->mt76->mac_work);
1867
1868@@ -274,26 +274,26 @@ void mt7921_stop(struct ieee80211_hw *hw)
1869 cancel_work_sync(&dev->reset_work);
1870 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
1871
1872- mt7921_mutex_acquire(dev);
1873+ mt792x_mutex_acquire(dev);
1874 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
1875 mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
1876- mt7921_mutex_release(dev);
1877+ mt792x_mutex_release(dev);
1878 }
1879 EXPORT_SYMBOL_GPL(mt7921_stop);
1880
1881-static int mt7921_add_interface(struct ieee80211_hw *hw,
1882- struct ieee80211_vif *vif)
1883+static int
1884+mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1885 {
1886- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1887- struct mt7921_dev *dev = mt7921_hw_dev(hw);
1888- struct mt7921_phy *phy = mt7921_hw_phy(hw);
1889+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1890+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
1891+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
1892 struct mt76_txq *mtxq;
1893 int idx, ret = 0;
1894
1895- mt7921_mutex_acquire(dev);
1896+ mt792x_mutex_acquire(dev);
1897
1898 mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
1899- if (mvif->mt76.idx >= MT7921_MAX_INTERFACES) {
1900+ if (mvif->mt76.idx >= MT792x_MAX_INTERFACES) {
1901 ret = -ENOSPC;
1902 goto out;
1903 }
1904@@ -311,7 +311,7 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
1905 dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
1906 phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
1907
1908- idx = MT7921_WTBL_RESERVED - mvif->mt76.idx;
1909+ idx = MT792x_WTBL_RESERVED - mvif->mt76.idx;
1910
1911 INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
1912 mvif->sta.wcid.idx = idx;
1913@@ -333,89 +333,55 @@ static int mt7921_add_interface(struct ieee80211_hw *hw,
1914
1915 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
1916 out:
1917- mt7921_mutex_release(dev);
1918+ mt792x_mutex_release(dev);
1919
1920 return ret;
1921 }
1922
1923-static void mt7921_remove_interface(struct ieee80211_hw *hw,
1924- struct ieee80211_vif *vif)
1925-{
1926- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1927- struct mt7921_sta *msta = &mvif->sta;
1928- struct mt7921_dev *dev = mt7921_hw_dev(hw);
1929- struct mt7921_phy *phy = mt7921_hw_phy(hw);
1930- int idx = msta->wcid.idx;
1931-
1932- mt7921_mutex_acquire(dev);
1933- mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
1934- mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, false);
1935-
1936- rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
1937-
1938- dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
1939- phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
1940- mt7921_mutex_release(dev);
1941-
1942- spin_lock_bh(&dev->mt76.sta_poll_lock);
1943- if (!list_empty(&msta->wcid.poll_list))
1944- list_del_init(&msta->wcid.poll_list);
1945- spin_unlock_bh(&dev->mt76.sta_poll_lock);
1946-
1947- mt76_packet_id_flush(&dev->mt76, &msta->wcid);
1948-}
1949-
1950 static void mt7921_roc_iter(void *priv, u8 *mac,
1951 struct ieee80211_vif *vif)
1952 {
1953- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1954- struct mt7921_phy *phy = priv;
1955+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
1956+ struct mt792x_phy *phy = priv;
1957
1958 mt7921_mcu_abort_roc(phy, mvif, phy->roc_token_id);
1959 }
1960
1961 void mt7921_roc_work(struct work_struct *work)
1962 {
1963- struct mt7921_phy *phy;
1964+ struct mt792x_phy *phy;
1965
1966- phy = (struct mt7921_phy *)container_of(work, struct mt7921_phy,
1967+ phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy,
1968 roc_work);
1969
1970 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
1971 return;
1972
1973- mt7921_mutex_acquire(phy->dev);
1974+ mt792x_mutex_acquire(phy->dev);
1975 ieee80211_iterate_active_interfaces(phy->mt76->hw,
1976 IEEE80211_IFACE_ITER_RESUME_ALL,
1977 mt7921_roc_iter, phy);
1978- mt7921_mutex_release(phy->dev);
1979+ mt792x_mutex_release(phy->dev);
1980 ieee80211_remain_on_channel_expired(phy->mt76->hw);
1981 }
1982
1983-void mt7921_roc_timer(struct timer_list *timer)
1984-{
1985- struct mt7921_phy *phy = from_timer(phy, timer, roc_timer);
1986-
1987- ieee80211_queue_work(phy->mt76->hw, &phy->roc_work);
1988-}
1989-
1990-static int mt7921_abort_roc(struct mt7921_phy *phy, struct mt7921_vif *vif)
1991+static int mt7921_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)
1992 {
1993 int err = 0;
1994
1995 del_timer_sync(&phy->roc_timer);
1996 cancel_work_sync(&phy->roc_work);
1997
1998- mt7921_mutex_acquire(phy->dev);
1999+ mt792x_mutex_acquire(phy->dev);
2000 if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
2001 err = mt7921_mcu_abort_roc(phy, vif, phy->roc_token_id);
2002- mt7921_mutex_release(phy->dev);
2003+ mt792x_mutex_release(phy->dev);
2004
2005 return err;
2006 }
2007
2008-static int mt7921_set_roc(struct mt7921_phy *phy,
2009- struct mt7921_vif *vif,
2010+static int mt7921_set_roc(struct mt792x_phy *phy,
2011+ struct mt792x_vif *vif,
2012 struct ieee80211_channel *chan,
2013 int duration,
2014 enum mt7921_roc_req type)
2015@@ -450,13 +416,13 @@ static int mt7921_remain_on_channel(struct ieee80211_hw *hw,
2016 int duration,
2017 enum ieee80211_roc_type type)
2018 {
2019- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2020- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2021+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2022+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2023 int err;
2024
2025- mt7921_mutex_acquire(phy->dev);
2026+ mt792x_mutex_acquire(phy->dev);
2027 err = mt7921_set_roc(phy, mvif, chan, duration, MT7921_ROC_REQ_ROC);
2028- mt7921_mutex_release(phy->dev);
2029+ mt792x_mutex_release(phy->dev);
2030
2031 return err;
2032 }
2033@@ -464,20 +430,20 @@ static int mt7921_remain_on_channel(struct ieee80211_hw *hw,
2034 static int mt7921_cancel_remain_on_channel(struct ieee80211_hw *hw,
2035 struct ieee80211_vif *vif)
2036 {
2037- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2038- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2039+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2040+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2041
2042 return mt7921_abort_roc(phy, mvif);
2043 }
2044
2045-static int mt7921_set_channel(struct mt7921_phy *phy)
2046+static int mt7921_set_channel(struct mt792x_phy *phy)
2047 {
2048- struct mt7921_dev *dev = phy->dev;
2049+ struct mt792x_dev *dev = phy->dev;
2050 int ret;
2051
2052 cancel_delayed_work_sync(&phy->mt76->mac_work);
2053
2054- mt7921_mutex_acquire(dev);
2055+ mt792x_mutex_acquire(dev);
2056 set_bit(MT76_RESET, &phy->mt76->state);
2057
2058 mt76_set_channel(phy->mt76);
2059@@ -486,18 +452,18 @@ static int mt7921_set_channel(struct mt7921_phy *phy)
2060 if (ret)
2061 goto out;
2062
2063- mt7921_mac_set_timing(phy);
2064+ mt792x_mac_set_timeing(phy);
2065
2066- mt7921_mac_reset_counters(phy);
2067+ mt792x_mac_reset_counters(phy);
2068 phy->noise = 0;
2069
2070 out:
2071 clear_bit(MT76_RESET, &phy->mt76->state);
2072- mt7921_mutex_release(dev);
2073+ mt792x_mutex_release(dev);
2074
2075 mt76_worker_schedule(&dev->mt76.tx_worker);
2076 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mt76->mac_work,
2077- MT7921_WATCHDOG_TIME);
2078+ MT792x_WATCHDOG_TIME);
2079
2080 return ret;
2081 }
2082@@ -506,9 +472,9 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2083 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
2084 struct ieee80211_key_conf *key)
2085 {
2086- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2087- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2088- struct mt7921_sta *msta = sta ? (struct mt7921_sta *)sta->drv_priv :
2089+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2090+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2091+ struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv :
2092 &mvif->sta;
2093 struct mt76_wcid *wcid = &msta->wcid;
2094 u8 *wcid_keyidx = &wcid->hw_key_idx;
2095@@ -546,7 +512,7 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2096 return -EOPNOTSUPP;
2097 }
2098
2099- mt7921_mutex_acquire(dev);
2100+ mt792x_mutex_acquire(dev);
2101
2102 if (cmd == SET_KEY) {
2103 *wcid_keyidx = idx;
2104@@ -570,7 +536,7 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2105 key, MCU_UNI_CMD(STA_REC_UPDATE),
2106 &mvif->wep_sta->wcid, cmd);
2107 out:
2108- mt7921_mutex_release(dev);
2109+ mt792x_mutex_release(dev);
2110
2111 return err;
2112 }
2113@@ -578,7 +544,7 @@ out:
2114 static void
2115 mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
2116 {
2117- struct mt7921_dev *dev = priv;
2118+ struct mt792x_dev *dev = priv;
2119 struct ieee80211_hw *hw = mt76_hw(dev);
2120 bool pm_enable = dev->pm.enable;
2121 int err;
2122@@ -599,7 +565,7 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
2123 static void
2124 mt7921_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
2125 {
2126- struct mt7921_dev *dev = priv;
2127+ struct mt792x_dev *dev = priv;
2128 struct ieee80211_hw *hw = mt76_hw(dev);
2129 struct mt76_connac_pm *pm = &dev->pm;
2130 bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
2131@@ -614,7 +580,7 @@ mt7921_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
2132 mt7921_mcu_set_beacon_filter(dev, vif, false);
2133 }
2134
2135-void mt7921_set_runtime_pm(struct mt7921_dev *dev)
2136+void mt7921_set_runtime_pm(struct mt792x_dev *dev)
2137 {
2138 struct ieee80211_hw *hw = mt76_hw(dev);
2139 struct mt76_connac_pm *pm = &dev->pm;
2140@@ -630,8 +596,8 @@ void mt7921_set_runtime_pm(struct mt7921_dev *dev)
2141
2142 static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
2143 {
2144- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2145- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2146+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2147+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2148 int ret = 0;
2149
2150 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
2151@@ -642,7 +608,7 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
2152 ieee80211_wake_queues(hw);
2153 }
2154
2155- mt7921_mutex_acquire(dev);
2156+ mt792x_mutex_acquire(dev);
2157
2158 if (changed & IEEE80211_CONF_CHANGE_POWER) {
2159 ret = mt7921_set_tx_sar_pwr(hw, NULL);
2160@@ -657,25 +623,11 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
2161 }
2162
2163 out:
2164- mt7921_mutex_release(dev);
2165+ mt792x_mutex_release(dev);
2166
2167 return ret;
2168 }
2169
2170-static int
2171-mt7921_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2172- unsigned int link_id, u16 queue,
2173- const struct ieee80211_tx_queue_params *params)
2174-{
2175- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2176-
2177- /* no need to update right away, we'll get BSS_CHANGED_QOS */
2178- queue = mt76_connac_lmac_mapping(queue);
2179- mvif->queue_params[queue] = *params;
2180-
2181- return 0;
2182-}
2183-
2184 static void mt7921_configure_filter(struct ieee80211_hw *hw,
2185 unsigned int changed_flags,
2186 unsigned int *total_flags,
2187@@ -686,7 +638,7 @@ static void mt7921_configure_filter(struct ieee80211_hw *hw,
2188 #define MT7921_FILTER_OTHER_BSS BIT(6)
2189 #define MT7921_FILTER_ENABLE BIT(31)
2190
2191- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2192+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2193 u32 flags = MT7921_FILTER_ENABLE;
2194
2195 #define MT7921_FILTER(_fif, _type) do { \
2196@@ -698,9 +650,9 @@ static void mt7921_configure_filter(struct ieee80211_hw *hw,
2197 MT7921_FILTER(FIF_CONTROL, CONTROL);
2198 MT7921_FILTER(FIF_OTHER_BSS, OTHER_BSS);
2199
2200- mt7921_mutex_acquire(dev);
2201+ mt792x_mutex_acquire(dev);
2202 mt7921_mcu_set_rxfilter(dev, flags, 0, 0);
2203- mt7921_mutex_release(dev);
2204+ mt792x_mutex_release(dev);
2205
2206 *total_flags &= (FIF_OTHER_BSS | FIF_FCSFAIL | FIF_CONTROL);
2207 }
2208@@ -710,17 +662,17 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
2209 struct ieee80211_bss_conf *info,
2210 u64 changed)
2211 {
2212- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2213- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2214+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2215+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2216
2217- mt7921_mutex_acquire(dev);
2218+ mt792x_mutex_acquire(dev);
2219
2220 if (changed & BSS_CHANGED_ERP_SLOT) {
2221 int slottime = info->use_short_slot ? 9 : 20;
2222
2223 if (slottime != phy->slottime) {
2224 phy->slottime = slottime;
2225- mt7921_mac_set_timing(phy);
2226+ mt792x_mac_set_timeing(phy);
2227 }
2228 }
2229
2230@@ -743,24 +695,24 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
2231 }
2232
2233 if (changed & BSS_CHANGED_ARP_FILTER) {
2234- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2235+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2236
2237 mt76_connac_mcu_update_arp_filter(&dev->mt76, &mvif->mt76,
2238 info);
2239 }
2240
2241- mt7921_mutex_release(dev);
2242+ mt792x_mutex_release(dev);
2243 }
2244
2245 int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2246 struct ieee80211_sta *sta)
2247 {
2248- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
2249- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2250- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2251+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
2252+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
2253+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2254 int ret, idx;
2255
2256- idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
2257+ idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT792x_WTBL_STA - 1);
2258 if (idx < 0)
2259 return -ENOSPC;
2260
2261@@ -796,11 +748,11 @@ EXPORT_SYMBOL_GPL(mt7921_mac_sta_add);
2262 void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2263 struct ieee80211_sta *sta)
2264 {
2265- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
2266- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2267- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2268+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
2269+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
2270+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2271
2272- mt7921_mutex_acquire(dev);
2273+ mt792x_mutex_acquire(dev);
2274
2275 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
2276 mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
2277@@ -814,15 +766,15 @@ void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2278
2279 mt7921_mcu_sta_update(dev, sta, vif, true, MT76_STA_INFO_STATE_ASSOC);
2280
2281- mt7921_mutex_release(dev);
2282+ mt792x_mutex_release(dev);
2283 }
2284 EXPORT_SYMBOL_GPL(mt7921_mac_sta_assoc);
2285
2286 void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2287 struct ieee80211_sta *sta)
2288 {
2289- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
2290- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2291+ struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
2292+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
2293
2294 mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
2295 mt76_connac_pm_wake(&dev->mphy, &dev->pm);
2296@@ -832,7 +784,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2297 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
2298
2299 if (vif->type == NL80211_IFTYPE_STATION) {
2300- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2301+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2302
2303 mvif->wep_sta = NULL;
2304 ewma_rssi_init(&mvif->rssi);
2305@@ -851,67 +803,13 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
2306 }
2307 EXPORT_SYMBOL_GPL(mt7921_mac_sta_remove);
2308
2309-void mt7921_tx_worker(struct mt76_worker *w)
2310-{
2311- struct mt7921_dev *dev = container_of(w, struct mt7921_dev,
2312- mt76.tx_worker);
2313-
2314- if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
2315- queue_work(dev->mt76.wq, &dev->pm.wake_work);
2316- return;
2317- }
2318-
2319- mt76_txq_schedule_all(&dev->mphy);
2320- mt76_connac_pm_unref(&dev->mphy, &dev->pm);
2321-}
2322-
2323-static void mt7921_tx(struct ieee80211_hw *hw,
2324- struct ieee80211_tx_control *control,
2325- struct sk_buff *skb)
2326-{
2327- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2328- struct mt76_phy *mphy = hw->priv;
2329- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2330- struct ieee80211_vif *vif = info->control.vif;
2331- struct mt76_wcid *wcid = &dev->mt76.global_wcid;
2332- int qid;
2333-
2334- if (control->sta) {
2335- struct mt7921_sta *sta;
2336-
2337- sta = (struct mt7921_sta *)control->sta->drv_priv;
2338- wcid = &sta->wcid;
2339- }
2340-
2341- if (vif && !control->sta) {
2342- struct mt7921_vif *mvif;
2343-
2344- mvif = (struct mt7921_vif *)vif->drv_priv;
2345- wcid = &mvif->sta.wcid;
2346- }
2347-
2348- if (mt76_connac_pm_ref(mphy, &dev->pm)) {
2349- mt76_tx(mphy, control->sta, wcid, skb);
2350- mt76_connac_pm_unref(mphy, &dev->pm);
2351- return;
2352- }
2353-
2354- qid = skb_get_queue_mapping(skb);
2355- if (qid >= MT_TXQ_PSD) {
2356- qid = IEEE80211_AC_BE;
2357- skb_set_queue_mapping(skb, qid);
2358- }
2359-
2360- mt76_connac_pm_queue_skb(hw, &dev->pm, wcid, skb);
2361-}
2362-
2363 static int mt7921_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
2364 {
2365- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2366+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2367
2368- mt7921_mutex_acquire(dev);
2369+ mt792x_mutex_acquire(dev);
2370 mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 0);
2371- mt7921_mutex_release(dev);
2372+ mt792x_mutex_release(dev);
2373
2374 return 0;
2375 }
2376@@ -921,10 +819,10 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2377 struct ieee80211_ampdu_params *params)
2378 {
2379 enum ieee80211_ampdu_mlme_action action = params->action;
2380- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2381+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2382 struct ieee80211_sta *sta = params->sta;
2383 struct ieee80211_txq *txq = sta->txq[params->tid];
2384- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2385+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
2386 u16 tid = params->tid;
2387 u16 ssn = params->ssn;
2388 struct mt76_txq *mtxq;
2389@@ -935,7 +833,7 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2390
2391 mtxq = (struct mt76_txq *)txq->drv_priv;
2392
2393- mt7921_mutex_acquire(dev);
2394+ mt792x_mutex_acquire(dev);
2395 switch (action) {
2396 case IEEE80211_AMPDU_RX_START:
2397 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
2398@@ -968,7 +866,7 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2399 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
2400 break;
2401 }
2402- mt7921_mutex_release(dev);
2403+ mt792x_mutex_release(dev);
2404
2405 return ret;
2406 }
2407@@ -979,293 +877,22 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
2408 enum ieee80211_sta_state old_state,
2409 enum ieee80211_sta_state new_state)
2410 {
2411- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2412+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2413
2414 if (dev->pm.ds_enable) {
2415- mt7921_mutex_acquire(dev);
2416+ mt792x_mutex_acquire(dev);
2417 mt76_connac_sta_state_dp(&dev->mt76, old_state, new_state);
2418- mt7921_mutex_release(dev);
2419+ mt792x_mutex_release(dev);
2420 }
2421
2422 return mt76_sta_state(hw, vif, sta, old_state, new_state);
2423 }
2424
2425-static int
2426-mt7921_get_stats(struct ieee80211_hw *hw,
2427- struct ieee80211_low_level_stats *stats)
2428-{
2429- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2430- struct mt76_mib_stats *mib = &phy->mib;
2431-
2432- mt7921_mutex_acquire(phy->dev);
2433-
2434- stats->dot11RTSSuccessCount = mib->rts_cnt;
2435- stats->dot11RTSFailureCount = mib->rts_retries_cnt;
2436- stats->dot11FCSErrorCount = mib->fcs_err_cnt;
2437- stats->dot11ACKFailureCount = mib->ack_fail_cnt;
2438-
2439- mt7921_mutex_release(phy->dev);
2440-
2441- return 0;
2442-}
2443-
2444-static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = {
2445- /* tx counters */
2446- "tx_ampdu_cnt",
2447- "tx_mpdu_attempts",
2448- "tx_mpdu_success",
2449- "tx_pkt_ebf_cnt",
2450- "tx_pkt_ibf_cnt",
2451- "tx_ampdu_len:0-1",
2452- "tx_ampdu_len:2-10",
2453- "tx_ampdu_len:11-19",
2454- "tx_ampdu_len:20-28",
2455- "tx_ampdu_len:29-37",
2456- "tx_ampdu_len:38-46",
2457- "tx_ampdu_len:47-55",
2458- "tx_ampdu_len:56-79",
2459- "tx_ampdu_len:80-103",
2460- "tx_ampdu_len:104-127",
2461- "tx_ampdu_len:128-151",
2462- "tx_ampdu_len:152-175",
2463- "tx_ampdu_len:176-199",
2464- "tx_ampdu_len:200-223",
2465- "tx_ampdu_len:224-247",
2466- "ba_miss_count",
2467- "tx_beamformer_ppdu_iBF",
2468- "tx_beamformer_ppdu_eBF",
2469- "tx_beamformer_rx_feedback_all",
2470- "tx_beamformer_rx_feedback_he",
2471- "tx_beamformer_rx_feedback_vht",
2472- "tx_beamformer_rx_feedback_ht",
2473- "tx_msdu_pack_1",
2474- "tx_msdu_pack_2",
2475- "tx_msdu_pack_3",
2476- "tx_msdu_pack_4",
2477- "tx_msdu_pack_5",
2478- "tx_msdu_pack_6",
2479- "tx_msdu_pack_7",
2480- "tx_msdu_pack_8",
2481- /* rx counters */
2482- "rx_mpdu_cnt",
2483- "rx_ampdu_cnt",
2484- "rx_ampdu_bytes_cnt",
2485- "rx_ba_cnt",
2486- /* per vif counters */
2487- "v_tx_mode_cck",
2488- "v_tx_mode_ofdm",
2489- "v_tx_mode_ht",
2490- "v_tx_mode_ht_gf",
2491- "v_tx_mode_vht",
2492- "v_tx_mode_he_su",
2493- "v_tx_mode_he_ext_su",
2494- "v_tx_mode_he_tb",
2495- "v_tx_mode_he_mu",
2496- "v_tx_bw_20",
2497- "v_tx_bw_40",
2498- "v_tx_bw_80",
2499- "v_tx_bw_160",
2500- "v_tx_mcs_0",
2501- "v_tx_mcs_1",
2502- "v_tx_mcs_2",
2503- "v_tx_mcs_3",
2504- "v_tx_mcs_4",
2505- "v_tx_mcs_5",
2506- "v_tx_mcs_6",
2507- "v_tx_mcs_7",
2508- "v_tx_mcs_8",
2509- "v_tx_mcs_9",
2510- "v_tx_mcs_10",
2511- "v_tx_mcs_11",
2512- "v_tx_nss_1",
2513- "v_tx_nss_2",
2514- "v_tx_nss_3",
2515- "v_tx_nss_4",
2516-};
2517-
2518-static void
2519-mt7921_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2520- u32 sset, u8 *data)
2521-{
2522- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2523-
2524- if (sset != ETH_SS_STATS)
2525- return;
2526-
2527- memcpy(data, *mt7921_gstrings_stats, sizeof(mt7921_gstrings_stats));
2528-
2529- if (mt76_is_sdio(&dev->mt76))
2530- return;
2531-
2532- data += sizeof(mt7921_gstrings_stats);
2533- page_pool_ethtool_stats_get_strings(data);
2534-}
2535-
2536-static int
2537-mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2538- int sset)
2539-{
2540- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2541-
2542- if (sset != ETH_SS_STATS)
2543- return 0;
2544-
2545- if (mt76_is_sdio(&dev->mt76))
2546- return ARRAY_SIZE(mt7921_gstrings_stats);
2547-
2548- return ARRAY_SIZE(mt7921_gstrings_stats) +
2549- page_pool_ethtool_stats_get_count();
2550-}
2551-
2552-static void
2553-mt7921_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
2554-{
2555- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2556- struct mt76_ethtool_worker_info *wi = wi_data;
2557-
2558- if (msta->vif->mt76.idx != wi->idx)
2559- return;
2560-
2561- mt76_ethtool_worker(wi, &msta->wcid.stats, false);
2562-}
2563-
2564-static
2565-void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2566- struct ethtool_stats *stats, u64 *data)
2567-{
2568- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2569- int stats_size = ARRAY_SIZE(mt7921_gstrings_stats);
2570- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2571- struct mt7921_dev *dev = phy->dev;
2572- struct mt76_mib_stats *mib = &phy->mib;
2573- struct mt76_ethtool_worker_info wi = {
2574- .data = data,
2575- .idx = mvif->mt76.idx,
2576- };
2577- int i, ei = 0;
2578-
2579- mt7921_mutex_acquire(dev);
2580-
2581- mt7921_mac_update_mib_stats(phy);
2582-
2583- data[ei++] = mib->tx_ampdu_cnt;
2584- data[ei++] = mib->tx_mpdu_attempts_cnt;
2585- data[ei++] = mib->tx_mpdu_success_cnt;
2586- data[ei++] = mib->tx_pkt_ebf_cnt;
2587- data[ei++] = mib->tx_pkt_ibf_cnt;
2588-
2589- /* Tx ampdu stat */
2590- for (i = 0; i < 15; i++)
2591- data[ei++] = phy->mt76->aggr_stats[i];
2592-
2593- data[ei++] = phy->mib.ba_miss_cnt;
2594-
2595- /* Tx Beamformer monitor */
2596- data[ei++] = mib->tx_bf_ibf_ppdu_cnt;
2597- data[ei++] = mib->tx_bf_ebf_ppdu_cnt;
2598-
2599- /* Tx Beamformer Rx feedback monitor */
2600- data[ei++] = mib->tx_bf_rx_fb_all_cnt;
2601- data[ei++] = mib->tx_bf_rx_fb_he_cnt;
2602- data[ei++] = mib->tx_bf_rx_fb_vht_cnt;
2603- data[ei++] = mib->tx_bf_rx_fb_ht_cnt;
2604-
2605- /* Tx amsdu info (pack-count histogram) */
2606- for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++)
2607- data[ei++] = mib->tx_amsdu[i];
2608-
2609- /* rx counters */
2610- data[ei++] = mib->rx_mpdu_cnt;
2611- data[ei++] = mib->rx_ampdu_cnt;
2612- data[ei++] = mib->rx_ampdu_bytes_cnt;
2613- data[ei++] = mib->rx_ba_cnt;
2614-
2615- /* Add values for all stations owned by this vif */
2616- wi.initial_stat_idx = ei;
2617- ieee80211_iterate_stations_atomic(hw, mt7921_ethtool_worker, &wi);
2618-
2619- mt7921_mutex_release(dev);
2620-
2621- if (!wi.sta_count)
2622- return;
2623-
2624- ei += wi.worker_stat_count;
2625-
2626- if (!mt76_is_sdio(&dev->mt76)) {
2627- mt76_ethtool_page_pool_stats(&dev->mt76, &data[ei], &ei);
2628- stats_size += page_pool_ethtool_stats_get_count();
2629- }
2630-
2631- if (ei != stats_size)
2632- dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %d", ei, stats_size);
2633-}
2634-
2635-static u64
2636-mt7921_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2637-{
2638- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2639- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2640- u8 omac_idx = mvif->mt76.omac_idx;
2641- union {
2642- u64 t64;
2643- u32 t32[2];
2644- } tsf;
2645- u16 n;
2646-
2647- mt7921_mutex_acquire(dev);
2648-
2649- n = omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : omac_idx;
2650- /* TSF software read */
2651- mt76_set(dev, MT_LPON_TCR(0, n), MT_LPON_TCR_SW_MODE);
2652- tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(0));
2653- tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(0));
2654-
2655- mt7921_mutex_release(dev);
2656-
2657- return tsf.t64;
2658-}
2659-
2660-static void
2661-mt7921_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2662- u64 timestamp)
2663-{
2664- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2665- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2666- u8 omac_idx = mvif->mt76.omac_idx;
2667- union {
2668- u64 t64;
2669- u32 t32[2];
2670- } tsf = { .t64 = timestamp, };
2671- u16 n;
2672-
2673- mt7921_mutex_acquire(dev);
2674-
2675- n = omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : omac_idx;
2676- mt76_wr(dev, MT_LPON_UTTR0(0), tsf.t32[0]);
2677- mt76_wr(dev, MT_LPON_UTTR1(0), tsf.t32[1]);
2678- /* TSF software overwrite */
2679- mt76_set(dev, MT_LPON_TCR(0, n), MT_LPON_TCR_SW_WRITE);
2680-
2681- mt7921_mutex_release(dev);
2682-}
2683-
2684-static void
2685-mt7921_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
2686-{
2687- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2688- struct mt7921_dev *dev = phy->dev;
2689-
2690- mt7921_mutex_acquire(dev);
2691- phy->coverage_class = max_t(s16, coverage_class, 0);
2692- mt7921_mac_set_timing(phy);
2693- mt7921_mutex_release(dev);
2694-}
2695-
2696 void mt7921_scan_work(struct work_struct *work)
2697 {
2698- struct mt7921_phy *phy;
2699+ struct mt792x_phy *phy;
2700
2701- phy = (struct mt7921_phy *)container_of(work, struct mt7921_phy,
2702+ phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy,
2703 scan_work.work);
2704
2705 while (true) {
2706@@ -1298,13 +925,13 @@ static int
2707 mt7921_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2708 struct ieee80211_scan_request *req)
2709 {
2710- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2711+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2712 struct mt76_phy *mphy = hw->priv;
2713 int err;
2714
2715- mt7921_mutex_acquire(dev);
2716+ mt792x_mutex_acquire(dev);
2717 err = mt76_connac_mcu_hw_scan(mphy, vif, req);
2718- mt7921_mutex_release(dev);
2719+ mt792x_mutex_release(dev);
2720
2721 return err;
2722 }
2723@@ -1312,12 +939,12 @@ mt7921_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2724 static void
2725 mt7921_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2726 {
2727- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2728+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2729 struct mt76_phy *mphy = hw->priv;
2730
2731- mt7921_mutex_acquire(dev);
2732+ mt792x_mutex_acquire(dev);
2733 mt76_connac_mcu_cancel_hw_scan(mphy, vif);
2734- mt7921_mutex_release(dev);
2735+ mt792x_mutex_release(dev);
2736 }
2737
2738 static int
2739@@ -1325,11 +952,11 @@ mt7921_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2740 struct cfg80211_sched_scan_request *req,
2741 struct ieee80211_scan_ies *ies)
2742 {
2743- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2744+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2745 struct mt76_phy *mphy = hw->priv;
2746 int err;
2747
2748- mt7921_mutex_acquire(dev);
2749+ mt792x_mutex_acquire(dev);
2750
2751 err = mt76_connac_mcu_sched_scan_req(mphy, vif, req);
2752 if (err < 0)
2753@@ -1337,7 +964,7 @@ mt7921_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2754
2755 err = mt76_connac_mcu_sched_scan_enable(mphy, vif, true);
2756 out:
2757- mt7921_mutex_release(dev);
2758+ mt792x_mutex_release(dev);
2759
2760 return err;
2761 }
2762@@ -1345,13 +972,13 @@ out:
2763 static int
2764 mt7921_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2765 {
2766- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2767+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2768 struct mt76_phy *mphy = hw->priv;
2769 int err;
2770
2771- mt7921_mutex_acquire(dev);
2772+ mt792x_mutex_acquire(dev);
2773 err = mt76_connac_mcu_sched_scan_enable(mphy, vif, false);
2774- mt7921_mutex_release(dev);
2775+ mt792x_mutex_release(dev);
2776
2777 return err;
2778 }
2779@@ -1359,8 +986,8 @@ mt7921_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2780 static int
2781 mt7921_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
2782 {
2783- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2784- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2785+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2786+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2787 int max_nss = hweight8(hw->wiphy->available_antennas_tx);
2788
2789 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
2790@@ -1369,7 +996,7 @@ mt7921_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
2791 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
2792 return -EINVAL;
2793
2794- mt7921_mutex_acquire(dev);
2795+ mt792x_mutex_acquire(dev);
2796
2797 phy->mt76->antenna_mask = tx_ant;
2798 phy->mt76->chainmask = tx_ant;
2799@@ -1377,54 +1004,17 @@ mt7921_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
2800 mt76_set_stream_caps(phy->mt76, true);
2801 mt7921_set_stream_he_caps(phy);
2802
2803- mt7921_mutex_release(dev);
2804+ mt792x_mutex_release(dev);
2805
2806 return 0;
2807 }
2808
2809-static void mt7921_sta_statistics(struct ieee80211_hw *hw,
2810- struct ieee80211_vif *vif,
2811- struct ieee80211_sta *sta,
2812- struct station_info *sinfo)
2813-{
2814- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2815- struct rate_info *txrate = &msta->wcid.rate;
2816-
2817- if (!txrate->legacy && !txrate->flags)
2818- return;
2819-
2820- if (txrate->legacy) {
2821- sinfo->txrate.legacy = txrate->legacy;
2822- } else {
2823- sinfo->txrate.mcs = txrate->mcs;
2824- sinfo->txrate.nss = txrate->nss;
2825- sinfo->txrate.bw = txrate->bw;
2826- sinfo->txrate.he_gi = txrate->he_gi;
2827- sinfo->txrate.he_dcm = txrate->he_dcm;
2828- sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
2829- }
2830- sinfo->tx_failed = msta->wcid.stats.tx_failed;
2831- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
2832-
2833- sinfo->tx_retries = msta->wcid.stats.tx_retries;
2834- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
2835-
2836- sinfo->txrate.flags = txrate->flags;
2837- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
2838-
2839- sinfo->ack_signal = (s8)msta->ack_signal;
2840- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);
2841-
2842- sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal);
2843- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
2844-}
2845-
2846 #ifdef CONFIG_PM
2847 static int mt7921_suspend(struct ieee80211_hw *hw,
2848 struct cfg80211_wowlan *wowlan)
2849 {
2850- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2851- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2852+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2853+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2854
2855 cancel_delayed_work_sync(&phy->scan_work);
2856 cancel_delayed_work_sync(&phy->mt76->mac_work);
2857@@ -1432,7 +1022,7 @@ static int mt7921_suspend(struct ieee80211_hw *hw,
2858 cancel_delayed_work_sync(&dev->pm.ps_work);
2859 mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
2860
2861- mt7921_mutex_acquire(dev);
2862+ mt792x_mutex_acquire(dev);
2863
2864 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
2865 ieee80211_iterate_active_interfaces(hw,
2866@@ -1440,17 +1030,17 @@ static int mt7921_suspend(struct ieee80211_hw *hw,
2867 mt7921_mcu_set_suspend_iter,
2868 &dev->mphy);
2869
2870- mt7921_mutex_release(dev);
2871+ mt792x_mutex_release(dev);
2872
2873 return 0;
2874 }
2875
2876 static int mt7921_resume(struct ieee80211_hw *hw)
2877 {
2878- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2879- struct mt7921_phy *phy = mt7921_hw_phy(hw);
2880+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2881+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
2882
2883- mt7921_mutex_acquire(dev);
2884+ mt792x_mutex_acquire(dev);
2885
2886 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
2887 ieee80211_iterate_active_interfaces(hw,
2888@@ -1459,51 +1049,34 @@ static int mt7921_resume(struct ieee80211_hw *hw)
2889 &dev->mphy);
2890
2891 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
2892- MT7921_WATCHDOG_TIME);
2893+ MT792x_WATCHDOG_TIME);
2894
2895- mt7921_mutex_release(dev);
2896+ mt792x_mutex_release(dev);
2897
2898 return 0;
2899 }
2900
2901-static void mt7921_set_wakeup(struct ieee80211_hw *hw, bool enabled)
2902-{
2903- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2904- struct mt76_dev *mdev = &dev->mt76;
2905-
2906- device_set_wakeup_enable(mdev->dev, enabled);
2907-}
2908-
2909 static void mt7921_set_rekey_data(struct ieee80211_hw *hw,
2910 struct ieee80211_vif *vif,
2911 struct cfg80211_gtk_rekey_data *data)
2912 {
2913- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2914+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2915
2916- mt7921_mutex_acquire(dev);
2917+ mt792x_mutex_acquire(dev);
2918 mt76_connac_mcu_update_gtk_rekey(hw, vif, data);
2919- mt7921_mutex_release(dev);
2920+ mt792x_mutex_release(dev);
2921 }
2922 #endif /* CONFIG_PM */
2923
2924-static void mt7921_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2925- u32 queues, bool drop)
2926-{
2927- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2928-
2929- wait_event_timeout(dev->mt76.tx_wait, !mt76_has_tx_pending(&dev->mphy),
2930- HZ / 2);
2931-}
2932-
2933 static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
2934 struct ieee80211_vif *vif,
2935 struct ieee80211_sta *sta,
2936 bool enabled)
2937 {
2938- struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
2939- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2940+ struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
2941+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2942
2943- mt7921_mutex_acquire(dev);
2944+ mt792x_mutex_acquire(dev);
2945
2946 if (enabled)
2947 set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
2948@@ -1513,7 +1086,7 @@ static void mt7921_sta_set_decap_offload(struct ieee80211_hw *hw,
2949 mt76_connac_mcu_sta_update_hdr_trans(&dev->mt76, vif, &msta->wcid,
2950 MCU_UNI_CMD(STA_REC_UPDATE));
2951
2952- mt7921_mutex_release(dev);
2953+ mt792x_mutex_release(dev);
2954 }
2955
2956 #if IS_ENABLED(CONFIG_IPV6)
2957@@ -1521,8 +1094,8 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
2958 struct ieee80211_vif *vif,
2959 struct inet6_dev *idev)
2960 {
2961- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
2962- struct mt7921_dev *dev = mvif->phy->dev;
2963+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
2964+ struct mt792x_dev *dev = mvif->phy->dev;
2965 struct inet6_ifaddr *ifa;
2966 struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
2967 struct sk_buff *skb;
2968@@ -1580,28 +1153,25 @@ int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
2969 const struct cfg80211_sar_specs *sar)
2970 {
2971 struct mt76_phy *mphy = hw->priv;
2972- int err;
2973
2974 if (sar) {
2975- err = mt76_init_sar_power(hw, sar);
2976+ int err = mt76_init_sar_power(hw, sar);
2977+
2978 if (err)
2979 return err;
2980 }
2981+ mt792x_init_acpi_sar_power(mt792x_hw_phy(hw), !sar);
2982
2983- mt7921_init_acpi_sar_power(mt7921_hw_phy(hw), !sar);
2984-
2985- err = mt76_connac_mcu_set_rate_txpower(mphy);
2986-
2987- return err;
2988+ return mt76_connac_mcu_set_rate_txpower(mphy);
2989 }
2990
2991 static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
2992 const struct cfg80211_sar_specs *sar)
2993 {
2994- struct mt7921_dev *dev = mt7921_hw_dev(hw);
2995+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
2996 int err;
2997
2998- mt7921_mutex_acquire(dev);
2999+ mt792x_mutex_acquire(dev);
3000 err = mt7921_mcu_set_clc(dev, dev->mt76.alpha2,
3001 dev->country_ie_env);
3002 if (err < 0)
3003@@ -1609,7 +1179,7 @@ static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
3004
3005 err = mt7921_set_tx_sar_pwr(hw, sar);
3006 out:
3007- mt7921_mutex_release(dev);
3008+ mt792x_mutex_release(dev);
3009
3010 return err;
3011 }
3012@@ -1619,23 +1189,23 @@ mt7921_channel_switch_beacon(struct ieee80211_hw *hw,
3013 struct ieee80211_vif *vif,
3014 struct cfg80211_chan_def *chandef)
3015 {
3016- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3017+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
3018
3019- mt7921_mutex_acquire(dev);
3020+ mt792x_mutex_acquire(dev);
3021 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, true);
3022- mt7921_mutex_release(dev);
3023+ mt792x_mutex_release(dev);
3024 }
3025
3026 static int
3027 mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3028 struct ieee80211_bss_conf *link_conf)
3029 {
3030- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3031- struct mt7921_phy *phy = mt7921_hw_phy(hw);
3032- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3033+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3034+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
3035+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
3036 int err;
3037
3038- mt7921_mutex_acquire(dev);
3039+ mt792x_mutex_acquire(dev);
3040
3041 err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
3042 true, mvif->ctx);
3043@@ -1649,7 +1219,7 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3044 err = mt7921_mcu_sta_update(dev, NULL, vif, true,
3045 MT76_STA_INFO_STATE_NONE);
3046 out:
3047- mt7921_mutex_release(dev);
3048+ mt792x_mutex_release(dev);
3049
3050 return err;
3051 }
3052@@ -1658,12 +1228,12 @@ static void
3053 mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3054 struct ieee80211_bss_conf *link_conf)
3055 {
3056- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3057- struct mt7921_phy *phy = mt7921_hw_phy(hw);
3058- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3059+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3060+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
3061+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
3062 int err;
3063
3064- mt7921_mutex_acquire(dev);
3065+ mt792x_mutex_acquire(dev);
3066
3067 err = mt7921_mcu_set_bss_pm(dev, vif, false);
3068 if (err)
3069@@ -1673,7 +1243,7 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3070 mvif->ctx);
3071
3072 out:
3073- mt7921_mutex_release(dev);
3074+ mt792x_mutex_release(dev);
3075 }
3076
3077 static int
3078@@ -1692,7 +1262,7 @@ mt7921_remove_chanctx(struct ieee80211_hw *hw,
3079 static void mt7921_ctx_iter(void *priv, u8 *mac,
3080 struct ieee80211_vif *vif)
3081 {
3082- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3083+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3084 struct ieee80211_chanctx_conf *ctx = priv;
3085
3086 if (ctx != mvif->ctx)
3087@@ -1709,77 +1279,47 @@ mt7921_change_chanctx(struct ieee80211_hw *hw,
3088 struct ieee80211_chanctx_conf *ctx,
3089 u32 changed)
3090 {
3091- struct mt7921_phy *phy = mt7921_hw_phy(hw);
3092+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
3093
3094- mt7921_mutex_acquire(phy->dev);
3095+ mt792x_mutex_acquire(phy->dev);
3096 ieee80211_iterate_active_interfaces(phy->mt76->hw,
3097 IEEE80211_IFACE_ITER_ACTIVE,
3098 mt7921_ctx_iter, ctx);
3099- mt7921_mutex_release(phy->dev);
3100-}
3101-
3102-static int
3103-mt7921_assign_vif_chanctx(struct ieee80211_hw *hw,
3104- struct ieee80211_vif *vif,
3105- struct ieee80211_bss_conf *link_conf,
3106- struct ieee80211_chanctx_conf *ctx)
3107-{
3108- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3109- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3110-
3111- mutex_lock(&dev->mt76.mutex);
3112- mvif->ctx = ctx;
3113- mutex_unlock(&dev->mt76.mutex);
3114-
3115- return 0;
3116-}
3117-
3118-static void
3119-mt7921_unassign_vif_chanctx(struct ieee80211_hw *hw,
3120- struct ieee80211_vif *vif,
3121- struct ieee80211_bss_conf *link_conf,
3122- struct ieee80211_chanctx_conf *ctx)
3123-{
3124- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3125- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3126-
3127- mutex_lock(&dev->mt76.mutex);
3128- mvif->ctx = NULL;
3129- mutex_unlock(&dev->mt76.mutex);
3130+ mt792x_mutex_release(phy->dev);
3131 }
3132
3133 static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw,
3134 struct ieee80211_vif *vif,
3135 struct ieee80211_prep_tx_info *info)
3136 {
3137- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3138- struct mt7921_dev *dev = mt7921_hw_dev(hw);
3139+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3140+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
3141 u16 duration = info->duration ? info->duration :
3142 jiffies_to_msecs(HZ);
3143
3144- mt7921_mutex_acquire(dev);
3145+ mt792x_mutex_acquire(dev);
3146 mt7921_set_roc(mvif->phy, mvif, mvif->ctx->def.chan, duration,
3147 MT7921_ROC_REQ_JOIN);
3148- mt7921_mutex_release(dev);
3149+ mt792x_mutex_release(dev);
3150 }
3151
3152 static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw,
3153 struct ieee80211_vif *vif,
3154 struct ieee80211_prep_tx_info *info)
3155 {
3156- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3157+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3158
3159 mt7921_abort_roc(mvif->phy, mvif);
3160 }
3161
3162 const struct ieee80211_ops mt7921_ops = {
3163- .tx = mt7921_tx,
3164+ .tx = mt792x_tx,
3165 .start = mt7921_start,
3166 .stop = mt7921_stop,
3167 .add_interface = mt7921_add_interface,
3168- .remove_interface = mt7921_remove_interface,
3169+ .remove_interface = mt792x_remove_interface,
3170 .config = mt7921_config,
3171- .conf_tx = mt7921_conf_tx,
3172+ .conf_tx = mt792x_conf_tx,
3173 .configure_filter = mt7921_configure_filter,
3174 .bss_info_changed = mt7921_bss_info_changed,
3175 .start_ap = mt7921_start_ap,
3176@@ -1797,19 +1337,19 @@ const struct ieee80211_ops mt7921_ops = {
3177 .release_buffered_frames = mt76_release_buffered_frames,
3178 .channel_switch_beacon = mt7921_channel_switch_beacon,
3179 .get_txpower = mt76_get_txpower,
3180- .get_stats = mt7921_get_stats,
3181- .get_et_sset_count = mt7921_get_et_sset_count,
3182- .get_et_strings = mt7921_get_et_strings,
3183- .get_et_stats = mt7921_get_et_stats,
3184- .get_tsf = mt7921_get_tsf,
3185- .set_tsf = mt7921_set_tsf,
3186+ .get_stats = mt792x_get_stats,
3187+ .get_et_sset_count = mt792x_get_et_sset_count,
3188+ .get_et_strings = mt792x_get_et_strings,
3189+ .get_et_stats = mt792x_get_et_stats,
3190+ .get_tsf = mt792x_get_tsf,
3191+ .set_tsf = mt792x_set_tsf,
3192 .get_survey = mt76_get_survey,
3193 .get_antenna = mt76_get_antenna,
3194 .set_antenna = mt7921_set_antenna,
3195- .set_coverage_class = mt7921_set_coverage_class,
3196+ .set_coverage_class = mt792x_set_coverage_class,
3197 .hw_scan = mt7921_hw_scan,
3198 .cancel_hw_scan = mt7921_cancel_hw_scan,
3199- .sta_statistics = mt7921_sta_statistics,
3200+ .sta_statistics = mt792x_sta_statistics,
3201 .sched_scan_start = mt7921_start_sched_scan,
3202 .sched_scan_stop = mt7921_stop_sched_scan,
3203 CFG80211_TESTMODE_CMD(mt7921_testmode_cmd)
3204@@ -1817,18 +1357,18 @@ const struct ieee80211_ops mt7921_ops = {
3205 #ifdef CONFIG_PM
3206 .suspend = mt7921_suspend,
3207 .resume = mt7921_resume,
3208- .set_wakeup = mt7921_set_wakeup,
3209+ .set_wakeup = mt792x_set_wakeup,
3210 .set_rekey_data = mt7921_set_rekey_data,
3211 #endif /* CONFIG_PM */
3212- .flush = mt7921_flush,
3213+ .flush = mt792x_flush,
3214 .set_sar_specs = mt7921_set_sar_specs,
3215 .remain_on_channel = mt7921_remain_on_channel,
3216 .cancel_remain_on_channel = mt7921_cancel_remain_on_channel,
3217 .add_chanctx = mt7921_add_chanctx,
3218 .remove_chanctx = mt7921_remove_chanctx,
3219 .change_chanctx = mt7921_change_chanctx,
3220- .assign_vif_chanctx = mt7921_assign_vif_chanctx,
3221- .unassign_vif_chanctx = mt7921_unassign_vif_chanctx,
3222+ .assign_vif_chanctx = mt792x_assign_vif_chanctx,
3223+ .unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
3224 .mgd_prepare_tx = mt7921_mgd_prepare_tx,
3225 .mgd_complete_tx = mt7921_mgd_complete_tx,
3226 };
3227diff --git a/mt7921/mcu.c b/mt7921/mcu.c
3228index a0ad18c7..90c93970 100644
3229--- a/mt7921/mcu.c
3230+++ b/mt7921/mcu.c
3231@@ -4,9 +4,9 @@
3232 #include <linux/fs.h>
3233 #include <linux/firmware.h>
3234 #include "mt7921.h"
3235-#include "mt7921_trace.h"
3236 #include "mcu.h"
3237 #include "../mt76_connac2_mac.h"
3238+#include "../mt792x_trace.h"
3239
3240 #define MT_STA_BFER BIT(0)
3241 #define MT_STA_BFEE BIT(1)
3242@@ -25,7 +25,7 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
3243 if (!skb) {
3244 dev_err(mdev->dev, "Message %08x (seq %d) timeout\n",
3245 cmd, seq);
3246- mt7921_reset(mdev);
3247+ mt792x_reset(mdev);
3248
3249 return -ETIMEDOUT;
3250 }
3251@@ -69,7 +69,7 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
3252 }
3253 EXPORT_SYMBOL_GPL(mt7921_mcu_parse_response);
3254
3255-static int mt7921_mcu_read_eeprom(struct mt7921_dev *dev, u32 offset, u8 *val)
3256+static int mt7921_mcu_read_eeprom(struct mt792x_dev *dev, u32 offset, u8 *val)
3257 {
3258 struct mt7921_mcu_eeprom_info *res, req = {
3259 .addr = cpu_to_le32(round_down(offset,
3260@@ -96,7 +96,7 @@ static int
3261 mt7921_mcu_set_ipv6_ns_filter(struct mt76_dev *dev,
3262 struct ieee80211_vif *vif, bool suspend)
3263 {
3264- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3265+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3266 struct {
3267 struct {
3268 u8 bss_idx;
3269@@ -134,7 +134,7 @@ void mt7921_mcu_set_suspend_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
3270 #endif /* CONFIG_PM */
3271
3272 static void
3273-mt7921_mcu_uni_roc_event(struct mt7921_dev *dev, struct sk_buff *skb)
3274+mt7921_mcu_uni_roc_event(struct mt792x_dev *dev, struct sk_buff *skb)
3275 {
3276 struct mt7921_roc_grant_tlv *grant;
3277 struct mt76_connac2_mcu_rxd *rxd;
3278@@ -157,17 +157,17 @@ mt7921_mcu_uni_roc_event(struct mt7921_dev *dev, struct sk_buff *skb)
3279 }
3280
3281 static void
3282-mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb)
3283+mt7921_mcu_scan_event(struct mt792x_dev *dev, struct sk_buff *skb)
3284 {
3285 struct mt76_phy *mphy = &dev->mt76.phy;
3286- struct mt7921_phy *phy = (struct mt7921_phy *)mphy->priv;
3287+ struct mt792x_phy *phy = (struct mt792x_phy *)mphy->priv;
3288
3289 spin_lock_bh(&dev->mt76.lock);
3290 __skb_queue_tail(&phy->scan_event_list, skb);
3291 spin_unlock_bh(&dev->mt76.lock);
3292
3293 ieee80211_queue_delayed_work(mphy->hw, &phy->scan_work,
3294- MT7921_HW_SCAN_TIMEOUT);
3295+ MT792x_HW_SCAN_TIMEOUT);
3296 }
3297
3298 static void
3299@@ -188,7 +188,7 @@ mt7921_mcu_connection_loss_iter(void *priv, u8 *mac,
3300 }
3301
3302 static void
3303-mt7921_mcu_connection_loss_event(struct mt7921_dev *dev, struct sk_buff *skb)
3304+mt7921_mcu_connection_loss_event(struct mt792x_dev *dev, struct sk_buff *skb)
3305 {
3306 struct mt76_connac_beacon_loss_event *event;
3307 struct mt76_phy *mphy = &dev->mt76.phy;
3308@@ -202,7 +202,7 @@ mt7921_mcu_connection_loss_event(struct mt7921_dev *dev, struct sk_buff *skb)
3309 }
3310
3311 static void
3312-mt7921_mcu_debug_msg_event(struct mt7921_dev *dev, struct sk_buff *skb)
3313+mt7921_mcu_debug_msg_event(struct mt792x_dev *dev, struct sk_buff *skb)
3314 {
3315 struct mt7921_debug_msg {
3316 __le16 id;
3317@@ -229,7 +229,7 @@ mt7921_mcu_debug_msg_event(struct mt7921_dev *dev, struct sk_buff *skb)
3318 }
3319
3320 static void
3321-mt7921_mcu_low_power_event(struct mt7921_dev *dev, struct sk_buff *skb)
3322+mt7921_mcu_low_power_event(struct mt792x_dev *dev, struct sk_buff *skb)
3323 {
3324 struct mt7921_mcu_lp_event {
3325 u8 state;
3326@@ -243,7 +243,7 @@ mt7921_mcu_low_power_event(struct mt7921_dev *dev, struct sk_buff *skb)
3327 }
3328
3329 static void
3330-mt7921_mcu_tx_done_event(struct mt7921_dev *dev, struct sk_buff *skb)
3331+mt7921_mcu_tx_done_event(struct mt792x_dev *dev, struct sk_buff *skb)
3332 {
3333 struct mt7921_mcu_tx_done_event *event;
3334
3335@@ -254,7 +254,7 @@ mt7921_mcu_tx_done_event(struct mt7921_dev *dev, struct sk_buff *skb)
3336 }
3337
3338 static void
3339-mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
3340+mt7921_mcu_rx_unsolicited_event(struct mt792x_dev *dev, struct sk_buff *skb)
3341 {
3342 struct mt76_connac2_mcu_rxd *rxd;
3343
3344@@ -288,7 +288,7 @@ mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
3345 }
3346
3347 static void
3348-mt7921_mcu_uni_rx_unsolicited_event(struct mt7921_dev *dev,
3349+mt7921_mcu_uni_rx_unsolicited_event(struct mt792x_dev *dev,
3350 struct sk_buff *skb)
3351 {
3352 struct mt76_connac2_mcu_rxd *rxd;
3353@@ -305,7 +305,7 @@ mt7921_mcu_uni_rx_unsolicited_event(struct mt7921_dev *dev,
3354 dev_kfree_skb(skb);
3355 }
3356
3357-void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
3358+void mt7921_mcu_rx_event(struct mt792x_dev *dev, struct sk_buff *skb)
3359 {
3360 struct mt76_connac2_mcu_rxd *rxd;
3361
3362@@ -339,11 +339,11 @@ void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
3363 }
3364
3365 /** starec & wtbl **/
3366-int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
3367+int mt7921_mcu_uni_tx_ba(struct mt792x_dev *dev,
3368 struct ieee80211_ampdu_params *params,
3369 bool enable)
3370 {
3371- struct mt7921_sta *msta = (struct mt7921_sta *)params->sta->drv_priv;
3372+ struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;
3373
3374 if (enable && !params->amsdu)
3375 msta->wcid.amsdu = false;
3376@@ -353,48 +353,24 @@ int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
3377 enable, true);
3378 }
3379
3380-int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev,
3381+int mt7921_mcu_uni_rx_ba(struct mt792x_dev *dev,
3382 struct ieee80211_ampdu_params *params,
3383 bool enable)
3384 {
3385- struct mt7921_sta *msta = (struct mt7921_sta *)params->sta->drv_priv;
3386+ struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;
3387
3388 return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->mt76, params,
3389 MCU_UNI_CMD(STA_REC_UPDATE),
3390 enable, false);
3391 }
3392
3393-static char *mt7921_patch_name(struct mt7921_dev *dev)
3394-{
3395- char *ret;
3396-
3397- if (is_mt7922(&dev->mt76))
3398- ret = MT7922_ROM_PATCH;
3399- else
3400- ret = MT7921_ROM_PATCH;
3401-
3402- return ret;
3403-}
3404-
3405-static char *mt7921_ram_name(struct mt7921_dev *dev)
3406-{
3407- char *ret;
3408-
3409- if (is_mt7922(&dev->mt76))
3410- ret = MT7922_FIRMWARE_WM;
3411- else
3412- ret = MT7921_FIRMWARE_WM;
3413-
3414- return ret;
3415-}
3416-
3417-static int mt7921_load_clc(struct mt7921_dev *dev, const char *fw_name)
3418+static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
3419 {
3420 const struct mt76_connac2_fw_trailer *hdr;
3421 const struct mt76_connac2_fw_region *region;
3422 const struct mt7921_clc *clc;
3423 struct mt76_dev *mdev = &dev->mt76;
3424- struct mt7921_phy *phy = &dev->phy;
3425+ struct mt792x_phy *phy = &dev->phy;
3426 const struct firmware *fw;
3427 int ret, i, len, offset = 0;
3428 u8 *clc_base = NULL, hw_encap = 0;
3429@@ -472,42 +448,7 @@ out:
3430 return ret;
3431 }
3432
3433-static int mt7921_load_firmware(struct mt7921_dev *dev)
3434-{
3435- int ret;
3436-
3437- ret = mt76_connac2_load_patch(&dev->mt76, mt7921_patch_name(dev));
3438- if (ret)
3439- return ret;
3440-
3441- if (mt76_is_sdio(&dev->mt76)) {
3442- /* activate again */
3443- ret = __mt7921_mcu_fw_pmctrl(dev);
3444- if (!ret)
3445- ret = __mt7921_mcu_drv_pmctrl(dev);
3446- }
3447-
3448- ret = mt76_connac2_load_ram(&dev->mt76, mt7921_ram_name(dev), NULL);
3449- if (ret)
3450- return ret;
3451-
3452- if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY,
3453- MT_TOP_MISC2_FW_N9_RDY, 1500)) {
3454- dev_err(dev->mt76.dev, "Timeout for initializing firmware\n");
3455-
3456- return -EIO;
3457- }
3458-
3459-#ifdef CONFIG_PM
3460- dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;
3461-#endif /* CONFIG_PM */
3462-
3463- dev_dbg(dev->mt76.dev, "Firmware init done\n");
3464-
3465- return 0;
3466-}
3467-
3468-int mt7921_mcu_fw_log_2_host(struct mt7921_dev *dev, u8 ctrl)
3469+int mt7921_mcu_fw_log_2_host(struct mt792x_dev *dev, u8 ctrl)
3470 {
3471 struct {
3472 u8 ctrl_val;
3473@@ -520,11 +461,11 @@ int mt7921_mcu_fw_log_2_host(struct mt7921_dev *dev, u8 ctrl)
3474 &data, sizeof(data), false);
3475 }
3476
3477-int mt7921_run_firmware(struct mt7921_dev *dev)
3478+int mt7921_run_firmware(struct mt792x_dev *dev)
3479 {
3480 int err;
3481
3482- err = mt7921_load_firmware(dev);
3483+ err = mt792x_load_firmware(dev);
3484 if (err)
3485 return err;
3486
3487@@ -533,7 +474,7 @@ int mt7921_run_firmware(struct mt7921_dev *dev)
3488 return err;
3489
3490 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
3491- err = mt7921_load_clc(dev, mt7921_ram_name(dev));
3492+ err = mt7921_load_clc(dev, mt792x_ram_name(dev));
3493 if (err)
3494 return err;
3495
3496@@ -541,9 +482,9 @@ int mt7921_run_firmware(struct mt7921_dev *dev)
3497 }
3498 EXPORT_SYMBOL_GPL(mt7921_run_firmware);
3499
3500-int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif)
3501+int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
3502 {
3503- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3504+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3505 struct edca {
3506 __le16 cw_min;
3507 __le16 cw_max;
3508@@ -635,12 +576,12 @@ int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif)
3509 &req_mu, sizeof(req_mu), false);
3510 }
3511
3512-int mt7921_mcu_set_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
3513+int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
3514 struct ieee80211_channel *chan, int duration,
3515 enum mt7921_roc_req type, u8 token_id)
3516 {
3517 int center_ch = ieee80211_frequency_to_channel(chan->center_freq);
3518- struct mt7921_dev *dev = phy->dev;
3519+ struct mt792x_dev *dev = phy->dev;
3520 struct {
3521 struct {
3522 u8 rsv[4];
3523@@ -702,10 +643,10 @@ int mt7921_mcu_set_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
3524 &req, sizeof(req), false);
3525 }
3526
3527-int mt7921_mcu_abort_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
3528+int mt7921_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
3529 u8 token_id)
3530 {
3531- struct mt7921_dev *dev = phy->dev;
3532+ struct mt792x_dev *dev = phy->dev;
3533 struct {
3534 struct {
3535 u8 rsv[4];
3536@@ -732,9 +673,9 @@ int mt7921_mcu_abort_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
3537 &req, sizeof(req), false);
3538 }
3539
3540-int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd)
3541+int mt7921_mcu_set_chan_info(struct mt792x_phy *phy, int cmd)
3542 {
3543- struct mt7921_dev *dev = phy->dev;
3544+ struct mt792x_dev *dev = phy->dev;
3545 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
3546 int freq1 = chandef->center_freq1;
3547 struct {
3548@@ -791,7 +732,7 @@ int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd)
3549 return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true);
3550 }
3551
3552-int mt7921_mcu_set_eeprom(struct mt7921_dev *dev)
3553+int mt7921_mcu_set_eeprom(struct mt792x_dev *dev)
3554 {
3555 struct req_hdr {
3556 u8 buffer_mode;
3557@@ -807,9 +748,9 @@ int mt7921_mcu_set_eeprom(struct mt7921_dev *dev)
3558 }
3559 EXPORT_SYMBOL_GPL(mt7921_mcu_set_eeprom);
3560
3561-int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif)
3562+int mt7921_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif)
3563 {
3564- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3565+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3566 struct {
3567 struct {
3568 u8 bss_idx;
3569@@ -845,10 +786,10 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif)
3570 }
3571
3572 static int
3573-mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3574+mt7921_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif,
3575 bool enable)
3576 {
3577- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3578+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3579 struct {
3580 struct {
3581 u8 bss_idx;
3582@@ -881,10 +822,10 @@ mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3583 }
3584
3585 int
3586-mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3587+mt7921_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif,
3588 bool enable)
3589 {
3590- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3591+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3592 struct {
3593 u8 bss_idx;
3594 u8 dtim_period;
3595@@ -918,11 +859,11 @@ mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3596 &req, sizeof(req), false);
3597 }
3598
3599-int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
3600+int mt7921_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,
3601 struct ieee80211_vif *vif, bool enable,
3602 enum mt76_sta_info_state state)
3603 {
3604- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3605+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3606 int rssi = -ewma_rssi_read(&mvif->rssi);
3607 struct mt76_sta_cmd_info info = {
3608 .sta = sta,
3609@@ -933,60 +874,16 @@ int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
3610 .offload_fw = true,
3611 .rcpi = to_rcpi(rssi),
3612 };
3613- struct mt7921_sta *msta;
3614+ struct mt792x_sta *msta;
3615
3616- msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
3617+ msta = sta ? (struct mt792x_sta *)sta->drv_priv : NULL;
3618 info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
3619 info.newly = msta ? state != MT76_STA_INFO_STATE_ASSOC : true;
3620
3621 return mt76_connac_mcu_sta_cmd(&dev->mphy, &info);
3622 }
3623
3624-int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
3625-{
3626- struct mt76_phy *mphy = &dev->mt76.phy;
3627- struct mt76_connac_pm *pm = &dev->pm;
3628- int err = 0;
3629-
3630- mutex_lock(&pm->mutex);
3631-
3632- if (!test_bit(MT76_STATE_PM, &mphy->state))
3633- goto out;
3634-
3635- err = __mt7921_mcu_drv_pmctrl(dev);
3636-out:
3637- mutex_unlock(&pm->mutex);
3638-
3639- if (err)
3640- mt7921_reset(&dev->mt76);
3641-
3642- return err;
3643-}
3644-EXPORT_SYMBOL_GPL(mt7921_mcu_drv_pmctrl);
3645-
3646-int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
3647-{
3648- struct mt76_phy *mphy = &dev->mt76.phy;
3649- struct mt76_connac_pm *pm = &dev->pm;
3650- int err = 0;
3651-
3652- mutex_lock(&pm->mutex);
3653-
3654- if (mt76_connac_skip_fw_pmctrl(mphy, pm))
3655- goto out;
3656-
3657- err = __mt7921_mcu_fw_pmctrl(dev);
3658-out:
3659- mutex_unlock(&pm->mutex);
3660-
3661- if (err)
3662- mt7921_reset(&dev->mt76);
3663-
3664- return err;
3665-}
3666-EXPORT_SYMBOL_GPL(mt7921_mcu_fw_pmctrl);
3667-
3668-int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
3669+int mt7921_mcu_set_beacon_filter(struct mt792x_dev *dev,
3670 struct ieee80211_vif *vif,
3671 bool enable)
3672 {
3673@@ -1021,7 +918,7 @@ int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
3674 return 0;
3675 }
3676
3677-int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr)
3678+int mt7921_get_txpwr_info(struct mt792x_dev *dev, struct mt7921_txpwr *txpwr)
3679 {
3680 struct mt7921_txpwr_event *event;
3681 struct mt7921_txpwr_req req = {
3682@@ -1044,7 +941,7 @@ int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr)
3683 return 0;
3684 }
3685
3686-int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3687+int mt7921_mcu_set_sniffer(struct mt792x_dev *dev, struct ieee80211_vif *vif,
3688 bool enable)
3689 {
3690 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
3691@@ -1074,7 +971,7 @@ int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif,
3692 true);
3693 }
3694
3695-int mt7921_mcu_config_sniffer(struct mt7921_vif *vif,
3696+int mt7921_mcu_config_sniffer(struct mt792x_vif *vif,
3697 struct ieee80211_chanctx_conf *ctx)
3698 {
3699 struct cfg80211_chan_def *chandef = &ctx->def;
3700@@ -1143,12 +1040,12 @@ int mt7921_mcu_config_sniffer(struct mt7921_vif *vif,
3701 }
3702
3703 int
3704-mt7921_mcu_uni_add_beacon_offload(struct mt7921_dev *dev,
3705+mt7921_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
3706 struct ieee80211_hw *hw,
3707 struct ieee80211_vif *vif,
3708 bool enable)
3709 {
3710- struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
3711+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
3712 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
3713 struct ieee80211_mutable_offsets offs;
3714 struct {
3715@@ -1221,7 +1118,7 @@ mt7921_mcu_uni_add_beacon_offload(struct mt7921_dev *dev,
3716 }
3717
3718 static
3719-int __mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
3720+int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
3721 enum environment_cap env_cap,
3722 struct mt7921_clc *clc,
3723 u8 idx)
3724@@ -1241,7 +1138,7 @@ int __mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
3725 } __packed req = {
3726 .idx = idx,
3727 .env = env_cap,
3728- .acpi_conf = mt7921_acpi_get_flags(&dev->phy),
3729+ .acpi_conf = mt792x_acpi_get_flags(&dev->phy),
3730 };
3731 int ret, valid_cnt = 0;
3732 u8 i, *pos;
3733@@ -1283,10 +1180,10 @@ int __mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
3734 return 0;
3735 }
3736
3737-int mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
3738+int mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
3739 enum environment_cap env_cap)
3740 {
3741- struct mt7921_phy *phy = (struct mt7921_phy *)&dev->phy;
3742+ struct mt792x_phy *phy = (struct mt792x_phy *)&dev->phy;
3743 int i, ret;
3744
3745 /* submit all clc config */
3746@@ -1305,9 +1202,9 @@ int mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
3747 return 0;
3748 }
3749
3750-int mt7921_mcu_get_temperature(struct mt7921_phy *phy)
3751+int mt7921_mcu_get_temperature(struct mt792x_phy *phy)
3752 {
3753- struct mt7921_dev *dev = phy->dev;
3754+ struct mt792x_dev *dev = phy->dev;
3755 struct {
3756 u8 ctrl_id;
3757 u8 action;
3758@@ -1322,7 +1219,7 @@ int mt7921_mcu_get_temperature(struct mt7921_phy *phy)
3759 sizeof(req), true);
3760 }
3761
3762-int mt7921_mcu_set_rxfilter(struct mt7921_dev *dev, u32 fif,
3763+int mt7921_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
3764 u8 bit_op, u32 bit_map)
3765 {
3766 struct {
3767diff --git a/mt7921/mt7921.h b/mt7921/mt7921.h
3768index ec987965..87dd0685 100644
3769--- a/mt7921/mt7921.h
3770+++ b/mt7921/mt7921.h
3771@@ -4,21 +4,8 @@
3772 #ifndef __MT7921_H
3773 #define __MT7921_H
3774
3775-#include <linux/interrupt.h>
3776-#include <linux/ktime.h>
3777-#include "../mt76_connac_mcu.h"
3778+#include "../mt792x.h"
3779 #include "regs.h"
3780-#include "acpi_sar.h"
3781-
3782-#define MT7921_MAX_INTERFACES 4
3783-#define MT7921_WTBL_SIZE 20
3784-#define MT7921_WTBL_RESERVED (MT7921_WTBL_SIZE - 1)
3785-#define MT7921_WTBL_STA (MT7921_WTBL_RESERVED - \
3786- MT7921_MAX_INTERFACES)
3787-
3788-#define MT7921_PM_TIMEOUT (HZ / 12)
3789-#define MT7921_HW_SCAN_TIMEOUT (HZ / 10)
3790-#define MT7921_WATCHDOG_TIME (HZ / 4)
3791
3792 #define MT7921_TX_RING_SIZE 2048
3793 #define MT7921_TX_MCU_RING_SIZE 256
3794@@ -27,27 +14,11 @@
3795 #define MT7921_RX_RING_SIZE 1536
3796 #define MT7921_RX_MCU_RING_SIZE 512
3797
3798-#define MT7921_DRV_OWN_RETRY_COUNT 10
3799-#define MT7921_MCU_INIT_RETRY_COUNT 10
3800-#define MT7921_WFSYS_INIT_RETRY_COUNT 2
3801-
3802-#define MT7921_FW_TAG_FEATURE 4
3803-#define MT7921_FW_CAP_CNM BIT(7)
3804-
3805-#define MT7921_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7961_1.bin"
3806-#define MT7921_ROM_PATCH "mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
3807-
3808-#define MT7922_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7922_1.bin"
3809-#define MT7922_ROM_PATCH "mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
3810-
3811 #define MT7921_EEPROM_SIZE 3584
3812 #define MT7921_TOKEN_SIZE 8192
3813
3814 #define MT7921_EEPROM_BLOCK_SIZE 16
3815