338 Commits
Author SHA1 Message Date
Ryder LeeandFelix Fietkau e49af7036b mt76: use le32/16_get_bits() whenever possible
Switch to use le32/16_get_bits() to simplfy codes and specify
the size explicitly to avoid potential issues.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Felix Fietkau 7fa5229a42 mt76: improve signal strength reporting
Instead of just taking the maximum per-chain signal strength values,
add an approximation for the sum of the combined signal.
This should more accurately reflect the real signal strength, especially
if the per-chain signal strength values are close to each other

Signed-off-by: Felix Fietkau <[email protected]>
2022-02-04 20:13:03 +01:00
Lorenzo BianconiandFelix Fietkau 37c3bf2256 mt76: mt7603: check sta_rates pointer in mt7603_sta_rate_tbl_update
Check sta_rates pointer value in mt7603_sta_rate_tbl_update routine
since minstrel_ht_update_rates can fail allocating rates array.

Fixes: c8846e1015022 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-01-28 14:50:18 +01:00
Felix Fietkau 77fc6c439a mt76: mt7603: improve reliability of tx powersave filtering
Leave more time to abort transmissions (which could happen at low CCK rates)
Only warn if the last filter command is stuck

Signed-off-by: Felix Fietkau <[email protected]>
2021-11-25 20:13:29 +01:00
Lorenzo BianconiandFelix Fietkau 6644755744 mt76: mt7603: introduce SAR support
Add SAR spec support to mt7603 driver to allow configuring SAR power
limitations on the frequency ranges from the userland.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-25 20:04:00 +01:00
Xing SongandFelix Fietkau 526591b203 mt76: do not pass the received frame with decryption error
MAC80211 doesn't care any decryption error in 802.3 path, so received
frame will be dropped if HW tell us that the cipher configuration is not
matched as well as the header has been translated to 802.3. This case only
appears when IEEE80211_FCTL_PROTECTED is 0 and cipher suit is not none in
the corresponding HW entry.

The received frame is only reported to monitor interface if HW decryption
block tell us there is ICV error or CCMP/BIP/WPI MIC error. Note in this
case the reported frame is decrypted 802.11 frame and the payload may be
malformed due to mismatched key.

Signed-off-by: Xing Song <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-21 20:26:13 +01:00
Lorenzo BianconiandFelix Fietkau bcc8d9e03a mt76: remove mt76_wcid pointer from mt76_tx_status_check signature
Remove mt76_wcid pointer from mt76_tx_status_check signature since it is
always set to NULL

Tested-by: [email protected]
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-11 09:19:04 +02:00
Lorenzo BianconiandFelix Fietkau f143aedc1d mt76: introduce packet_id idr
Introduce per-wcid idr to manage packet id for txs. This allow fast idr
lookup and skb queueing at the same time.

Tested-by: [email protected]
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-11 09:19:04 +02:00
Felix Fietkau 8ee6446075 mt76: disable BH around napi_schedule() calls
napi_schedule() can call __raise_softirq_irqoff(), which can perform softirq
handling, so it must not be called in a pure process context with BH enabled.

Signed-off-by: Felix Fietkau <[email protected]>
2021-09-24 17:54:42 +02:00
Christophe JAILLETandFelix Fietkau 9dcfba3169 mt76: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.

It has been compile tested.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-09-24 17:42:12 +02:00
Felix Fietkau bbebea7d6d Revert "mt76: fix mt76_rates for the multiple devices"
Fix rate values for MT7915 and MT7921

This reverts commit ca64a36908.

Signed-off-by: Felix Fietkau <[email protected]>
2021-07-15 20:09:39 +02:00
Sean WangandFelix Fietkau ca64a36908 mt76: fix mt76_rates for the multiple devices
PHY offset in either .hw_value or .hw_value_short for mt7615, mt7663,
mt7915 and mt7921 device all start at bit 6, not 8.

Suggested-by: Ryder Lee <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-07-14 12:18:38 +02:00
Ryder LeeandFelix Fietkau 12bf28feba mt76: fix iv and CCMP header insertion
The iv from RXD is only for TKIP_RSC/CCMP_PN/GCMP_PN, and it needs a
check for CCMP header insertion. Move mt76_cipher_type to mt76.h to
reduce duplicated code.

Signed-off-by: Xing Song <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-06-18 17:19:44 +02:00
Ryder LeeandFelix Fietkau 23c6ec49c0 mt76: make mt76_update_survey() per phy
Reduce duplicated survey for DBDC.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-06-18 16:38:20 +02:00
Lorenzo BianconiandFelix Fietkau 321443258b mt76: move mt76_rates in mt76 module
Move mt76_rates array in mt76 module and remove duplicated code since it
is shared by all drivers

Signed-off-by: Lorenzo Bianconi <[email protected]>
2021-06-02 08:25:00 +02:00
Felix Fietkau e1f07d7f1c mt76: mt7603: avoid use of ieee80211_tx_info_clear_status
It overwrites mt76_tx_cb data in the skb

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 19:50:30 +02:00
Lorenzo BianconiandFelix Fietkau 51b3d1a9a2 mt76: dma: add the capability to define a custom rx napi poll routine
Add the capability to define a custom rx napi callback for each driver.
This is a preliminary patch to properly support runtime-pm on rx side

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-21 13:49:02 +02:00
Lorenzo BianconiandFelix Fietkau 0a094b11f3 mt76: improve mcu error logging
Dump mcu command code in hex and related prefix to help debugging

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-17 11:19:58 +02:00
Felix Fietkau c71f609b39 mt76: sync with upstream changes
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-14 09:12:11 +02:00
Felix Fietkau 5ac02e22fb mt76: flush tx status queue on DMA reset
After DMA reset, tx status information for queued frames will never arrive.
Flush the queue to free skbs immediately instead of waiting for a timeout

Signed-off-by: Felix Fietkau <[email protected]>
2021-04-13 20:10:31 +02:00
Ryder LeeandFelix Fietkau 7714dc914d mt76: report Rx timestamp
Frame reception timestamp (low 32-bits) that indicates the value of the
local TSF timer value at the time the first bit of the MAC header in the
received frame (PPDU unit) arriving at the MAC.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-11 12:49:17 +02:00
Felix Fietkau bfa8d5a6a9 mt76: adjust to upstream API for enabling threaded NAPI
Create a second dummy device for tx napi to avoid making it threaded

Signed-off-by: Felix Fietkau <[email protected]>
2021-03-14 17:36:54 +01:00
Felix Fietkau 0d7564d0d8 mt76: add support for 802.3 rx frames
Do not try to access the header when receiving them

Signed-off-by: Felix Fietkau <[email protected]>
2021-02-14 12:26:01 +01:00
Ryder LeeandFelix Fietkau c7d98fc358 mt76: use PCI_VENDOR_ID_MEDIATEK to avoid open coded
Use PCI standard defines.

Signed-off-by: Ryder Lee <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-02-14 11:34:10 +01:00
Felix Fietkau fb3e5ce1eb mt76: move vif_mask back from mt76_phy to mt76_dev
Since it is global for all drivers, it belongs to the main device

Signed-off-by: Felix Fietkau <[email protected]>
2021-01-20 13:11:46 +01:00
Lorenzo BianconiandFelix Fietkau d679b56b95 mt76: move mac_work in mt76_core module
Move mac_work delayed_work and mac_work_count in mt76_phy since it is
used by all drivers. This is a preliminary patch to create a common mcu
library used by mt7615 and mt7921 drivers

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-01-14 11:14:59 +01:00
Lorenzo BianconiandFelix Fietkau 8aa24c91b1 mt76: move hw mac_addr in mt76_phy
This is a preliminary patch to properly support mt7915 dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-13 11:19:13 +01:00
Lorenzo BianconiandFelix Fietkau e881fd67c7 mt76: move band capabilities in mt76_phy
This is a preliminary patch to move properly support mt7915 dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-13 11:19:13 +01:00
Lorenzo BianconiandFelix Fietkau 2e217fb9e9 mt76: move tx hw data queues in mt76_phy
Move hw data queues in mt76_phy from mt76_dev since mt7915 supports per
phy hw queues in dbdc mode

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau ccd62467d0 mt76: move mcu queues to mt76_dev q_mcu array
Move mcu queue to a dedicated array q_mcu in mt76_dev structure.
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau b0eb7edcc6 mt76: rely on mt76_queue in tx_queue_skb_raw signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau 8932975be0 mt76: introduce mt76_init_mcu_queue utility routine
Introduce mt76_init_mcu_queue utility routine in order to allocate
dedicate q_mcu pointers for mcu hw queues. This is a preliminary patch
to move data queues in mt76_phy and add dbdc support to mt7915 driver

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau 0f9350bef1 mt76: rely on mt76_queue in tx_queue_skb signature
Rely on mt76_queue instead of qid in tx_queue_skb signature.
This is a preliminary patch to move data queues in mt76_phy and add
dbdc support to mt7915 driver

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau 216cf8b285 mt76: dma: rely on mt76_queue in mt76_dma_tx_cleanup signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau c79d18723d mt76: move mt76_init_tx_queue in common code
Move mt76_init_tx_queue in mac80211.c since it is shared by all
drivers.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau 01b9432957 mt76: move mt76_mcu_send_firmware in common module
Move mt76_mcu_send_firmware routine in common code since it is actually
shared between mt7615, mt7663, mt7603 and mt7915 devices

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-11-10 13:19:53 +01:00
David BauerandFelix Fietkau 9a1a0a4dec mt76: mt7603: add additional EEPROM chip ID
Some newer MT7628 based routers (notably the TP-Link Archer C50 v4) are
shipped with a chip-id of 0x7600 in the on-flash EEPROM. Add this as a
possible valid ID.

Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2781

Suggested-by: Ron Asimi <[email protected]>
Signed-off-by: David Bauer <[email protected]>
2020-11-10 13:19:53 +01:00
Lorenzo BianconiandFelix Fietkau 68c4eedafd mt76: fix memory leak if device probing fails
Run mt76_free_device instead of ieee80211_free_hw if device probing
fails in order to remove the already allocated mt76 workqueue

Fixes: a86f1d01f5ce5 ("mt76: move mt76 workqueue in common code")
Fixes: f1d962369d568 ("mt76: mt7915: implement HE per-rate tx power support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-11-10 13:19:53 +01:00
Allen PaisandFelix Fietkau 4f9f79b085 wireless: mt76: convert tasklets to use new tasklet_setup() API
In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <[email protected]>
Signed-off-by: Allen Pais <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-10 13:15:51 +01:00
Felix Fietkau 35e3cd1db4 mt76: mt7603: fix ED/CCA monitoring with single-stream devices
Do not use the RSSI values of the unavailable chain

Signed-off-by: Felix Fietkau <[email protected]>
2020-10-27 07:14:14 +01:00
Felix Fietkau 4d019c9672 sync with upstream changes
Signed-off-by: Felix Fietkau <[email protected]>
2020-10-23 11:38:05 +02:00
Felix Fietkau 80c310c59a mt76: mt7603: switch to .mcu_skb_send_msg
Reduces code duplication

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 05:35:49 +02:00
Felix Fietkau fcfbb046c2 mt76: move mcu timeout handling to .mcu_parse_response
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 04:01:03 +02:00
Felix Fietkau 8c73f3b15a mt76: implement .mcu_parse_response in struct mt76_mcu_ops
Do not free skb inside that function
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 03:54:03 +02:00
Felix Fietkau 6cdebe8058 mt76: rename __mt76_mcu_send_msg to mt76_mcu_send_msg
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 03:09:22 +02:00
Felix Fietkau 1a2547b27d mt76: do not set NEEDS_UNIQUE_STA_ADDR for 7615 and 7915
The newer chipsets can deal with the same STA on multiple interfaces
Preparation for supporting more station interfaces

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-26 22:40:13 +02:00
Qinglang MiaoandFelix Fietkau 1449e602fa mt76: Convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-23 08:16:55 +02:00
Gustavo A. R. SilvaandFelix Fietkau 1ccd31bbe1 mt76: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-08 23:44:29 +02:00
Felix Fietkau 115b62efac mt76: remove retry_q from struct mt76_txq and related code
Since the switch to using AQL by default, mtxq->retry_q is never filled anymore
Remove it to get rid of a few more unnecessary cycles in the tx path

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-04 19:31:36 +02:00
Felix Fietkau b36d7ae096 mt76: mt7603: move number of streams detection to eeprom init
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-25 12:35:34 +02:00