Commit Graph
677 Commits
Author SHA1 Message Date
Felix Fietkau a39ab7043a mt76x2: adjust AGC control register 26 based on gain for VHT80
Signed-off-by: Felix Fietkau <[email protected]>
2018-06-15 18:41:20 +02:00
Felix Fietkau 2cbaa57a77 mt76x2: fix swapped values for RXO-18 in gain control
The lowest bit should be set to 0 only for strong links, not for weak
ones.

Signed-off-by: Felix Fietkau <[email protected]>
2018-06-15 18:28:53 +02:00
Felix Fietkau 9090f9c705 mt76x2: fix threshold for gain adjustment
The gain should be reduced only for very strong connections, not for mid
range.

Signed-off-by: Felix Fietkau <[email protected]>
2018-06-15 18:27:54 +02:00
Felix Fietkau 792dbe0261 mt7603: do not hold dev->mutex while flushing dev->mac_work
Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau fcbb49e863 mt76x2: use udelay instead of usleep_range in mt76x2_mac_stop
usleep_range can cause excessive latency on channel change if waiting
for the MAC to stop fails. It will be forced to stop by the code
following that loop anyway.

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau 730c292a2c mt76: wait for pending tx to complete before switching channel
Reduces interruption caused by scanning

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau 21c1e1eae5 mt76: move ieee80211_hw allocation to common core
Allows it to be shared between different drivers and locks to be
initialized earlier

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau f399da3b2e mt76: prevent tx scheduling during channel change
Re-schedule tx afterwards

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau 0ef26ef052 mt76: only stop tx queues on offchannel, not during the entire scan
During scans, mac80211 frequently switches back to the home channel to
minimize interruption of ongoing traffic. Keep regular tx queues active
during that time.

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau d87e4b0252 mt7603: clear PSE reset bit if PSE reset fails
If the firmware is blocked, it should not continue to attempt a reset
until it is safe to do so

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-20 07:57:25 +02:00
Felix Fietkau f24b56f935 update MT7628 firmware to the latest version
Signed-off-by: Felix Fietkau <[email protected]>
2018-05-19 10:52:29 +02:00
Felix Fietkau 664e32171c mt7603: add extra PSE hang check signature for MT7628
Signed-off-by: Felix Fietkau <[email protected]>
2018-05-19 10:48:48 +02:00
Felix Fietkau 20c0766c8f mt7603: adjust rx hang watchdog for MT7628
The MT7628 vendor driver checks a different DMA debug register compared to
MT7603.

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-19 10:48:33 +02:00
Felix Fietkau 0b8d1ddec9 mt76: fix beacon timer drift
The beacon timer drifts by 1 microsecond every TBTT. After 20 minutes
with a beacon interval of 100, the drift will be almost 12 ms, enough to
cause weird issues for devices in powersave mode.

Since the beacon timer is configured in units of 1/16 TU (64 us), we
need to adjust it once every 64 beacons and only for one beacon.

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-18 17:46:01 +02:00
Felix Fietkau 73edb22822 mt76: discard early received packets if not running yet
If the radio was previously in running state, it can receive some
packets before it is able to process them.
This can lead to a crash if the channel is not initialized yet.
Discard all rx packets until start() is called

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-15 14:28:28 +02:00
Lorenzo BianconiandFelix Fietkau e87f925667 mt76x2: apply coverage class on slot time too
According to 802.11-2007 17.3.8.6 (slot time), the slot time should
be increased by 3 us * coverage class. Taking into account coverage
class in slot time configuration allows to increase by an order of
magnitude the throughput on a 4Km link in a noisy environment

Tested-by: Luca Bisti <[email protected]>
Tested-by: Gaetano Catalli <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-05-15 13:16:16 +02:00
Felix Fietkau a78673d523 mt76: fix sending encrypted broadcast packets for secondary interfaces
For encryption to work properly, the BSS index needs to be initialized
for the WCID entry used for the interface.

Signed-off-by: Felix Fietkau <[email protected]>
2018-05-15 13:03:31 +02:00
Lorenzo BianconiandFelix Fietkau fd58b28292 mt76x2: add a polling delay in mt76x2_mac_stop routine
Add a usleep_range in mt76x2_mac_stop routine in order to add
a polling delay checking values of MT_MAC_STATUS and IBI_R12 registers

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-05-10 18:28:18 +02:00
Lorenzo BianconiandFelix Fietkau b2ecc529b4 mt76x2: fix avg_rssi estimation
Add leftover filter coefficients in IIR rssi estimation

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-05-03 13:38:49 +02:00
Felix Fietkau e2eedc9229 mt7603: retry PSE reset calls
PSE reset can fail and a subsequent reset could recover it again

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-18 11:53:24 +02:00
Lorenzo BianconiandFelix Fietkau e08d5dab5d mt76x2: fix is_mt7612 routine
Fix is_mt7612 routine since asic version is set in mt76_dev revision
field and not in mt76x2_dev one.
Moreover remove mt76x2_dev rev field since it is never used in the
driver

Fixes: 7bc04215a66b ('mt76: add driver code for MT76x2e')
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-18 09:39:48 +02:00
Felix Fietkau ec8435e711 mt76: initialize rx lock earlier
Fixes lockdep warning on mt7603

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-18 09:38:07 +02:00
Felix Fietkau ca5cc9a478 mt76: fix concurrent rx calls on A-MPDU release
Add a spinlock in mt76_rx_complete. Without this, multiple stats updates
could happen in parallel, which can lead to deadlocks. There are
probably more corner cases fixed by this change.

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-17 14:49:29 +02:00
Felix Fietkau 8c92c91abe mt7603: turn vif wcid entry back into a full mt7603_sta
The tx status reporting code needs access to mt7603_sta members for rate
status processing.

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-16 12:07:53 +02:00
Felix Fietkau 2d08440e90 mt76: add rcu locking around tx scheduling
Fixes a reported lockdep error in mac80211:

[  179.867321] =============================
[  179.871510] WARNING: suspicious RCU usage
[  179.875528] 4.14.32 #0 Not tainted
[  179.878924] -----------------------------
[  179.882981] backports-2017-11-01/net/mac80211/tx.c:594 suspicious rcu_dereference_check() usage!
[  179.891785]
[  179.891785] other info that might help us debug this:
[  179.891785]
[  179.899824]
[  179.899824] rcu_scheduler_active = 2, debug_locks = 1
[  179.906343] 2 locks held by ksoftirqd/0/7:
[  179.910479]  #0:  (&(&q->lock)->rlock){+.-.}, at: [<86b207a4>] mt76_dma_tx_cleanup+0x64/0x354 [mt76]
[  179.919734]  #1:  (&(&fq->lock)->rlock){+.-.}, at: [<87238410>] ieee80211_tx_dequeue+0x54/0xc3c [mac80211]
[  179.929890]
[  179.929890] stack backtrace:
[  179.934257] CPU: 0 PID: 7 Comm: ksoftirqd/0 Not tainted 4.14.32 #0
[  179.940421] Stack : 00000000 00000000 00000000 00000000 80e0fce2 00000036 00000000 00000000
[  179.948864]         87c3d24c 80696377 8061039c 00000000 00000007 00000001 87c5db78 6534689d
[  179.957306]         00000000 00000000 80e10000 87c5da74 00000001 0000015a 00000007 00000000
[  179.965748]         00000000 806a0000 000e4171 00000000 00000000 00000000 ffffffff 00000001
[  179.974189]         806c0000 8692b240 86b000d0 87316fe4 00000001 802c9a68 00000000 80700000
[  179.982632]         ...
[  179.985104] Call Trace:
[  179.987582] [<80010a48>] show_stack+0x58/0x100
[  179.992040] [<804c2c58>] dump_stack+0xe8/0x170
[  179.996868] [<87234a04>] ieee80211_tx_h_select_key+0xa8/0x5b8 [mac80211]
[  180.004299] [<87238d44>] ieee80211_tx_dequeue+0x988/0xc3c [mac80211]
[  180.011048] [<86b230dc>] mt76_txq_schedule+0x110/0x3a4 [mt76]
[  180.016821] [<86b209d0>] mt76_dma_tx_cleanup+0x290/0x354 [mt76]
[  180.022777] [<86be2e60>] mt7603_tx_tasklet+0x40/0x6c [mt7603e]
[  180.028637] [<80037058>] tasklet_action+0x110/0x1ec
[  180.033532] [<804e1dac>] __do_softirq+0x164/0x35c
[  180.038235] [<80037174>] run_ksoftirqd+0x40/0x84
[  180.042870] [<800580c8>] smpboot_thread_fn+0x1a8/0x1d8
[  180.048023] [<800542e8>] kthread+0x130/0x144
[  180.052297] [<8000b1f8>] ret_from_kernel_thread+0x14/0x1c

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-15 19:36:13 +02:00
Felix Fietkau ea6dd6f668 mt7603: add missing spin lock init
Signed-off-by: Felix Fietkau <[email protected]>
2018-04-15 19:26:25 +02:00
Felix Fietkau a8e8921559 mt7603: add more checks to avoid dereferencing invalid pointers in wcid lookup
Signed-off-by: Felix Fietkau <[email protected]>
2018-04-15 10:14:46 +02:00
Felix Fietkau d9e5da36e2 mt76: add rcu locking in tid reorder function
Avoids having the tid or station entry disappear prematurely.
Also cancel the reorder work earlier

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-14 21:48:35 +02:00
Felix Fietkau 873a7c990c mt7603: call mt76_txq_schedule_all as a barrier to prevent tx during reset
Signed-off-by: Felix Fietkau <[email protected]>
2018-04-13 11:50:19 +02:00
Felix Fietkau 7a31731af2 mt76: check for pending reset before attempting to schedule tx
The check within mt76_txq_send_burst is not enough, as it happens after
a first frame has already been queued up

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-13 11:47:45 +02:00
Felix Fietkau 9a23989932 mt7603: remove warning on rx with invalid channel info
This can happen during a watchdog reset and is harmless

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-13 10:42:01 +02:00
Felix Fietkau f36f3083ec mt7603: improve validation of rx frames
- discard packets that have no rx group 3 (signal/rate info missing)
- discard packets marked as VHT (no hardware support)
- discard packets with invalid HT rate values

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-13 10:38:35 +02:00
Felix Fietkau 9c52f36091 mt7603: pull the final rate index from the status descriptor
When doing rate probing, multiple frames might end up getting sent with
the probe rate, because of the way that rate probing is set up.
This race window is most visible with MCS rates and aggregation.

To improve rate control stats accuracy, pull the final tx rate from the
descriptor

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-12 18:17:10 +02:00
Felix Fietkau df9f9f6740 mt7603: always try tx rate1 first
Tx status reporting cannot account for the tx attempt starting at a rate
further down the chain, so without this flag it leads to inaccurate
results.

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-12 17:40:48 +02:00
Felix Fietkau 549f43b23e mt7603: ensure that the ACK flag is set for A-MPDUs with any acked subframe
Signed-off-by: Felix Fietkau <[email protected]>
2018-04-12 12:14:23 +02:00
Pawel DembickiandFelix Fietkau 1d23142954 mt76: add led active low to debugfs
In some boards mpcie leds have reversed polarity.
This patch allow change led polarity from userspace.

Signed-off-by: Pawel Dembicki <[email protected]>
2018-04-09 11:34:04 +02:00
Lorenzo BianconiandFelix Fietkau a3e7740ab8 mt76x2: fix tx_alc_enabled check
Fix mt76x2_temp_tx_alc_enabled routine since in order to enable tx_alc
temperature compensation it necessary to take into account BIT(15) of
MT_EE_TX_POWER_EXT_PA_5G eeprom info

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-09 10:15:14 +02:00
Lorenzo BianconiandFelix Fietkau 5153ece6b9 mt76x2: set default values in TX_ALC_CFG_{1,2} for tempetaure compensation
Initialize default values for temperature compensation in TX_ALC_CFG_{1,2}
if tssi has been enabled

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-09 10:14:39 +02:00
Lorenzo BianconiandFelix Fietkau 6e7d5ceb4f mt76x2: remove unnecessary MT_TX_ALC_CFG_4 configuration
Remove unnecessary MT_TX_ALC_CFG_4 configuration since the register value
will be properly set according to the usage of an external power amplifier

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-09 10:14:23 +02:00
Lorenzo BianconiandFelix Fietkau 700ed20476 mt76x2: make mt76x2_mac_reset routine static
Add static qualifier to mt76x2_mac_reset routine and remove the
prototype from mt76x2_mac.h since it is used just in mt76x2_init.c

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-03 21:36:32 +02:00
Lorenzo BianconiandFelix Fietkau bc35af8213 mt76x2: fix tssi initialization for 5GHz band
Fix mcu initial configuration for tssi calibration on 5GHz band

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-04-03 21:36:16 +02:00
Lorenzo BianconiandFelix Fietkau 880611b041 mt7603: main: fix warning in ieee80211_get_key_rx_seq()
Fall back to software encryption for hw unsupported ciphers in order
to fix the following warning in ieee80211_get_key_rx_seq routine:

WARNING: CPU: 0 PID: 1546 at backports-2017-11-01/net/mac80211/key.c:1010
mt76_wcid_key_setup+0x6c/0x210 [mt76]
CPU: 0 PID: 1546 Comm: hostapd Not tainted 4.9.87 #0
        ...
Call Trace:
[<8000e220>] show_stack+0x70/0x8c
[<80023a34>] __warn+0x110/0x118
[<80023ad0>] warn_slowpath_null+0x1c/0x2c
[<871515c0>] mt76_wcid_key_setup+0x6c/0x210 [mt76]
[<870a0c94>] 0x870a0c94
---[ end trace 1a391bb242f6a068 ]---

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-28 16:34:21 +02:00
Lorenzo BianconiandFelix Fietkau 238f3f1c2d mt76x2: remove warnings in mt76x2_mac_write_txwi()
Fix following sparse warnings in mt76x2_mac_write_txwi:
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:201:26: warning:
  incorrect type in assignment (different base types)
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:201:26: expected
  restricted __le32 [usertype] iv
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:201:26: got unsigned
  int [unsigned] [usertype] <noident>
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:202:27: warning:
  incorrect type in assignment (different base types)
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:202:27: expected
  restricted __le32 [usertype] eiv
- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c:202:27: got unsigned
  int [unsigned] [usertype] <noident>

Fixes: 23405236460b ("mt76: fix transmission of encrypted management
frames")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-21 11:23:10 +01:00
Lorenzo BianconiandFelix Fietkau ced433d006 mt76x2: add mac80211 {set,get}_antenna callbacks
Add capability to select tx/rx antennas. Possible values are:
 - 1: to use only the first antenna
 - 2: to use only the second antenna
 - 3: to use both of them

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-21 11:23:10 +01:00
Lorenzo BianconiandFelix Fietkau 6469dcafb5 mt76: add mt76_init_stream_cap routine
Add mt76_init_stream_cap utility routine to set ht/vht sta capabilities
related to number of streams currently used by the device
(it will be used by mac80211 set_antenna callback)

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-21 11:23:10 +01:00
Lorenzo BianconiandFelix Fietkau 7e6e00bf0a mt76: initialize available_antennas_{tx,rx} info
Initialize available_antennas related info in wiphy data structure
according to antenna_mask field; antenna_mask info is initialized
in device specific code and will be used in mac80211 {set,get}_antenna
callbacks

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-21 11:23:10 +01:00
Lorenzo BianconiandFelix Fietkau eb359f19b4 mt76x2: remove unnecessary len variable in mt76x2_eeprom_load()
Substitute unnecessary len variable in mt76x2_eeprom_load() with
MT7662_EEPROM_SIZE macro since len is used just to store eeprom
default size.

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-19 21:39:09 +01:00
Lorenzo BianconiandFelix Fietkau 54d6710c93 mt76: use mt76_poll_msec routine in mt76pci_load_firmware()
Use mt76_poll_msec() in mt76pci_load_firmware to check if the firmware
has been started instead of explicitly poll MCU running register

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-19 21:38:48 +01:00
Lorenzo BianconiandFelix Fietkau 249fa2deda mt76x2: fix warning in ieee80211_get_key_rx_seq()
Fall back to software encryption for hw unsupported ciphers in order
to fix the following warning in ieee80211_get_key_rx_seq routine:

WARNING: CPU: 1 PID: 1277 at backports-2017-11-01/net/mac80211/key.c:
1010 mt76_wcid_key_setup+0x6c/0x138 [mt76]
CPU: 1 PID: 1277 Comm: hostapd Tainted: G        W       4.9.86 #0
Stack : 00000000 00000000 80527b4a 00000042 80523824 00000000 00000000 80520000
        8fd79a9c 804bbda7 80454c84 00000001 000004fd 80523824 8f7e4ba0 8eceda12
        00000010 8006af94 00000001 80520000 804c1f04 804c1f08 80459890 8ec999b4
        00000003 800a7840 8f7e4ba0 8eceda12 8121de20 00000000 00000001 00c999b4
        00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
        ...
Call Trace:
[<8000f52c>] show_stack+0x70/0x8c
[<801d8d04>] dump_stack+0x94/0xd0
[<8002bcd4>] __warn+0x110/0x118
[<8002bd70>] warn_slowpath_null+0x1c/0x2c
[<8f0415cc>] mt76_wcid_key_setup+0x6c/0x138 [mt76]
[<8f1311b4>] mt76x2_dma_cleanup+0xa38/0x1048 [mt76x2e]

Fixes: 30ce7f4456ae ("mt76: validate rx CCMP PN")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-19 21:38:34 +01:00
Lorenzo BianconiandFelix Fietkau c66094e92d mt76x2: fix possible NULL pointer dereferencing in mt76x2_tx()
Fix a theoretical NULL pointer dereferencing in mt76x2_tx routine that
can occurs for injected frames in a monitor vif since vif pointer could
be NULL for that interfaces

Fixes: 23405236460b ("mt76: fix transmission of encrypted mgmt frames")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-03-19 21:38:25 +01:00