Skip to content

Commit cf1d7dc

Browse files
committed
Merge tag 'mt76-next-2025-11-24' of https://github.com/nbd168/wireless
Felix Fietkau says: =================== mt76 patches for 6.19 - relicense to BSD-3-Clause-Clear - fixes - support WED on devices which exceed 32-bit DMA - airoha NPU support - mt7925 regd improvements - more mt7996 MLO work =================== Link: https://patch.msgid.link/6b6d1033-dddf-4cc9-b240-93da7f8b8773@nbd.name Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 parents a8e5a11 + 53d1548 commit cf1d7dc

218 files changed

Lines changed: 2497 additions & 676 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ properties:
151151
- ETSI
152152
- JP
153153

154+
country:
155+
$ref: /schemas/types.yaml#/definitions/string
156+
pattern: '^[A-Z]{2}$'
157+
description:
158+
ISO 3166-1 alpha-2 country code for power limits
159+
154160
patternProperties:
155161
"^txpower-[256]g$":
156162
type: object
@@ -210,6 +216,66 @@ properties:
210216
minItems: 13
211217
maxItems: 13
212218

219+
paths-cck:
220+
$ref: /schemas/types.yaml#/definitions/uint8-array
221+
minItems: 4
222+
maxItems: 4
223+
description:
224+
4 half-dBm backoff values (1 - 4 antennas, single spacial
225+
stream)
226+
227+
paths-ofdm:
228+
$ref: /schemas/types.yaml#/definitions/uint8-array
229+
minItems: 4
230+
maxItems: 4
231+
description:
232+
4 half-dBm backoff values (1 - 4 antennas, single spacial
233+
stream)
234+
235+
paths-ofdm-bf:
236+
$ref: /schemas/types.yaml#/definitions/uint8-array
237+
minItems: 4
238+
maxItems: 4
239+
description:
240+
4 half-dBm backoff values for beamforming
241+
(1 - 4 antennas, single spacial stream)
242+
243+
paths-ru:
244+
$ref: /schemas/types.yaml#/definitions/uint8-matrix
245+
description:
246+
Sets of half-dBm backoff values for 802.11ax rates for
247+
1T1ss (aka 1 transmitting antenna with 1 spacial stream),
248+
2T1ss, 3T1ss, 4T1ss, 2T2ss, 3T2ss, 4T2ss, 3T3ss, 4T3ss
249+
and 4T4ss.
250+
Each set starts with the number of channel bandwidth or
251+
resource unit settings for which the rate set applies,
252+
followed by 10 power limit values. The order of the
253+
channel resource unit settings is RU26, RU52, RU106,
254+
RU242/SU20, RU484/SU40, RU996/SU80 and RU2x996/SU160.
255+
minItems: 1
256+
maxItems: 7
257+
items:
258+
minItems: 11
259+
maxItems: 11
260+
261+
paths-ru-bf:
262+
$ref: /schemas/types.yaml#/definitions/uint8-matrix
263+
description:
264+
Sets of half-dBm backoff (beamforming) values for 802.11ax
265+
rates for 1T1ss (aka 1 transmitting antenna with 1 spacial
266+
stream), 2T1ss, 3T1ss, 4T1ss, 2T2ss, 3T2ss, 4T2ss, 3T3ss,
267+
4T3ss and 4T4ss.
268+
Each set starts with the number of channel bandwidth or
269+
resource unit settings for which the rate set applies,
270+
followed by 10 power limit values. The order of the
271+
channel resource unit settings is RU26, RU52, RU106,
272+
RU242/SU20, RU484/SU40, RU996/SU80 and RU2x996/SU160.
273+
minItems: 1
274+
maxItems: 7
275+
items:
276+
minItems: 11
277+
maxItems: 11
278+
213279
txs-delta:
214280
$ref: /schemas/types.yaml#/definitions/uint32-array
215281
description:

drivers/net/wireless/mediatek/mt76/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-License-Identifier: GPL-2.0-only
1+
# SPDX-License-Identifier: BSD-3-Clause-Clear
22
config MT76_CORE
33
tristate
44
select PAGE_POOL
@@ -37,6 +37,10 @@ config MT792x_USB
3737
tristate
3838
select MT76_USB
3939

40+
config MT76_NPU
41+
bool
42+
depends on MT76_CORE
43+
4044
source "drivers/net/wireless/mediatek/mt76/mt76x0/Kconfig"
4145
source "drivers/net/wireless/mediatek/mt76/mt76x2/Kconfig"
4246
source "drivers/net/wireless/mediatek/mt76/mt7603/Kconfig"

drivers/net/wireless/mediatek/mt76/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-License-Identifier: GPL-2.0-only
1+
# SPDX-License-Identifier: BSD-3-Clause-Clear
22
obj-$(CONFIG_MT76_CORE) += mt76.o
33
obj-$(CONFIG_MT76_USB) += mt76-usb.o
44
obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
@@ -12,6 +12,7 @@ mt76-y := \
1212
mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
1313
tx.o agg-rx.o mcu.o wed.o scan.o channel.o
1414

15+
mt76-$(CONFIG_MT76_NPU) += npu.o
1516
mt76-$(CONFIG_PCI) += pci.o
1617
mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o
1718

drivers/net/wireless/mediatek/mt76/agg-rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: ISC
1+
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (C) 2018 Felix Fietkau <nbd@nbd.name>
44
*/

drivers/net/wireless/mediatek/mt76/channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: ISC
1+
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (C) 2024 Felix Fietkau <nbd@nbd.name>
44
*/

drivers/net/wireless/mediatek/mt76/debugfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: ISC
1+
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
44
*/
@@ -93,9 +93,9 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str,
9393
{
9494
int i;
9595

96-
seq_printf(file, "%10s:", str);
96+
seq_printf(file, "%16s:", str);
9797
for (i = 0; i < len; i++)
98-
seq_printf(file, " %2d", val[i]);
98+
seq_printf(file, " %4d", val[i]);
9999
seq_puts(file, "\n");
100100
}
101101
EXPORT_SYMBOL_GPL(mt76_seq_puts_array);

drivers/net/wireless/mediatek/mt76/dma.c

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: ISC
1+
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
44
*/
@@ -7,37 +7,6 @@
77
#include "mt76.h"
88
#include "dma.h"
99

10-
#if IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED)
11-
12-
#define Q_READ(_q, _field) ({ \
13-
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
14-
u32 _val; \
15-
if ((_q)->flags & MT_QFLAG_WED) \
16-
_val = mtk_wed_device_reg_read((_q)->wed, \
17-
((_q)->wed_regs + \
18-
_offset)); \
19-
else \
20-
_val = readl(&(_q)->regs->_field); \
21-
_val; \
22-
})
23-
24-
#define Q_WRITE(_q, _field, _val) do { \
25-
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
26-
if ((_q)->flags & MT_QFLAG_WED) \
27-
mtk_wed_device_reg_write((_q)->wed, \
28-
((_q)->wed_regs + _offset), \
29-
_val); \
30-
else \
31-
writel(_val, &(_q)->regs->_field); \
32-
} while (0)
33-
34-
#else
35-
36-
#define Q_READ(_q, _field) readl(&(_q)->regs->_field)
37-
#define Q_WRITE(_q, _field, _val) writel(_val, &(_q)->regs->_field)
38-
39-
#endif
40-
4110
static struct mt76_txwi_cache *
4211
mt76_alloc_txwi(struct mt76_dev *dev)
4312
{
@@ -220,10 +189,15 @@ static void
220189
mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q)
221190
{
222191
Q_WRITE(q, desc_base, q->desc_dma);
223-
if (q->flags & MT_QFLAG_WED_RRO_EN)
192+
if ((q->flags & MT_QFLAG_WED_RRO_EN) && !mt76_npu_device_active(dev))
224193
Q_WRITE(q, ring_size, MT_DMA_RRO_EN | q->ndesc);
225194
else
226195
Q_WRITE(q, ring_size, q->ndesc);
196+
197+
if (mt76_queue_is_npu_tx(q)) {
198+
writel(q->desc_dma, &q->regs->desc_base);
199+
writel(q->ndesc, &q->regs->ring_size);
200+
}
227201
q->head = Q_READ(q, dma_idx);
228202
q->tail = q->head;
229203
}
@@ -235,7 +209,7 @@ void mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q,
235209
return;
236210

237211
if (!mt76_queue_is_wed_rro_ind(q) &&
238-
!mt76_queue_is_wed_rro_rxdmad_c(q)) {
212+
!mt76_queue_is_wed_rro_rxdmad_c(q) && !mt76_queue_is_npu(q)) {
239213
int i;
240214

241215
/* clear descriptors */
@@ -446,6 +420,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
446420

447421
while (q->queued > 0 && q->tail != last) {
448422
mt76_dma_tx_cleanup_idx(dev, q, q->tail, &entry);
423+
mt76_npu_txdesc_cleanup(q, q->tail);
449424
mt76_queue_tx_complete(dev, q, &entry);
450425

451426
if (entry.txwi) {
@@ -680,6 +655,10 @@ mt76_dma_tx_queue_skb(struct mt76_phy *phy, struct mt76_queue *q,
680655
if (test_bit(MT76_RESET, &phy->state))
681656
goto free_skb;
682657

658+
/* TODO: Take into account unlinear skbs */
659+
if (mt76_npu_device_active(dev) && skb_linearize(skb))
660+
goto free_skb;
661+
683662
t = mt76_get_txwi(dev);
684663
if (!t)
685664
goto free_skb;
@@ -727,6 +706,9 @@ mt76_dma_tx_queue_skb(struct mt76_phy *phy, struct mt76_queue *q,
727706
if (ret < 0)
728707
goto unmap;
729708

709+
if (mt76_npu_device_active(dev))
710+
return mt76_npu_dma_add_buf(phy, q, skb, &tx_info.buf[1], txwi);
711+
730712
return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf,
731713
tx_info.info, tx_info.skb, t);
732714

@@ -825,9 +807,17 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
825807
q->ndesc = n_desc;
826808
q->buf_size = bufsize;
827809
q->hw_idx = idx;
810+
q->dev = dev;
811+
812+
if (mt76_queue_is_wed_rro_ind(q))
813+
size = sizeof(struct mt76_wed_rro_desc);
814+
else if (mt76_queue_is_npu_tx(q))
815+
size = sizeof(struct airoha_npu_tx_dma_desc);
816+
else if (mt76_queue_is_npu_rx(q))
817+
size = sizeof(struct airoha_npu_rx_dma_desc);
818+
else
819+
size = sizeof(struct mt76_desc);
828820

829-
size = mt76_queue_is_wed_rro_ind(q) ? sizeof(struct mt76_wed_rro_desc)
830-
: sizeof(struct mt76_desc);
831821
q->desc = dmam_alloc_coherent(dev->dma_dev, q->ndesc * size,
832822
&q->desc_dma, GFP_KERNEL);
833823
if (!q->desc)
@@ -843,6 +833,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
843833
if (ret)
844834
return ret;
845835

836+
mt76_npu_queue_setup(dev, q);
846837
ret = mt76_wed_dma_setup(dev, q, false);
847838
if (ret)
848839
return ret;
@@ -870,6 +861,11 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q)
870861
if (!q->ndesc)
871862
return;
872863

864+
if (mt76_queue_is_npu(q)) {
865+
mt76_npu_queue_cleanup(dev, q);
866+
return;
867+
}
868+
873869
do {
874870
spin_lock_bh(&q->lock);
875871
buf = mt76_dma_dequeue(dev, q, true, NULL, NULL, &more, NULL);
@@ -900,7 +896,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
900896
return;
901897

902898
if (!mt76_queue_is_wed_rro_ind(q) &&
903-
!mt76_queue_is_wed_rro_rxdmad_c(q)) {
899+
!mt76_queue_is_wed_rro_rxdmad_c(q) && !mt76_queue_is_npu(q)) {
904900
int i;
905901

906902
for (i = 0; i < q->ndesc; i++)
@@ -920,7 +916,10 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
920916
return;
921917

922918
mt76_dma_sync_idx(dev, q);
923-
mt76_dma_rx_fill_buf(dev, q, false);
919+
if (mt76_queue_is_npu(q))
920+
mt76_npu_fill_rx_queue(dev, q);
921+
else
922+
mt76_dma_rx_fill(dev, q, false);
924923
}
925924

926925
static void

drivers/net/wireless/mediatek/mt76/dma.h

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: ISC */
1+
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
22
/*
33
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
44
*/
@@ -46,6 +46,73 @@
4646
#define MT_FCE_INFO_LEN 4
4747
#define MT_RX_RXWI_LEN 32
4848

49+
#if IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED)
50+
51+
#define Q_READ(_q, _field) ({ \
52+
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
53+
u32 _val; \
54+
if ((_q)->flags & MT_QFLAG_WED) \
55+
_val = mtk_wed_device_reg_read((_q)->wed, \
56+
((_q)->wed_regs + \
57+
_offset)); \
58+
else \
59+
_val = readl(&(_q)->regs->_field); \
60+
_val; \
61+
})
62+
63+
#define Q_WRITE(_q, _field, _val) do { \
64+
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
65+
if ((_q)->flags & MT_QFLAG_WED) \
66+
mtk_wed_device_reg_write((_q)->wed, \
67+
((_q)->wed_regs + _offset), \
68+
_val); \
69+
else \
70+
writel(_val, &(_q)->regs->_field); \
71+
} while (0)
72+
73+
#elif IS_ENABLED(CONFIG_MT76_NPU)
74+
75+
#define Q_READ(_q, _field) ({ \
76+
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
77+
u32 _val = 0; \
78+
if ((_q)->flags & MT_QFLAG_NPU) { \
79+
struct airoha_npu *npu; \
80+
\
81+
rcu_read_lock(); \
82+
npu = rcu_dereference(q->dev->mmio.npu); \
83+
if (npu) \
84+
regmap_read(npu->regmap, \
85+
((_q)->wed_regs + _offset), &_val); \
86+
rcu_read_unlock(); \
87+
} else { \
88+
_val = readl(&(_q)->regs->_field); \
89+
} \
90+
_val; \
91+
})
92+
93+
#define Q_WRITE(_q, _field, _val) do { \
94+
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
95+
if ((_q)->flags & MT_QFLAG_NPU) { \
96+
struct airoha_npu *npu; \
97+
\
98+
rcu_read_lock(); \
99+
npu = rcu_dereference(q->dev->mmio.npu); \
100+
if (npu) \
101+
regmap_write(npu->regmap, \
102+
((_q)->wed_regs + _offset), _val); \
103+
rcu_read_unlock(); \
104+
} else { \
105+
writel(_val, &(_q)->regs->_field); \
106+
} \
107+
} while (0)
108+
109+
#else
110+
111+
#define Q_READ(_q, _field) readl(&(_q)->regs->_field)
112+
#define Q_WRITE(_q, _field, _val) writel(_val, &(_q)->regs->_field)
113+
114+
#endif
115+
49116
struct mt76_desc {
50117
__le32 buf0;
51118
__le32 ctrl;

0 commit comments

Comments
 (0)