Commit Graph
1347 Commits
Author SHA1 Message Date
Stanislaw GruszkaandFelix Fietkau 91ade88519 mt76x02: add hrtimer for pre TBTT for USB
Add timer and work for pre TBTT for USB devices. For now code
doesn't do anyting useful, just add hrtimer which synchronize
with hardware MT_TBTT_TIMER.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:20:43 +01:00
Stanislaw GruszkaandFelix Fietkau f2a18f5a7f mt76x02: introduce mt76x02_beacon.c
Move most of beaconing code into separate file and separate beacon
initialization for USB and MMIO as pre TBTT implementation for USB
will be different.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:20:43 +01:00
Felix Fietkau 6fc50ea917 mt7603: send BAR after powersave wakeup
Now that the sequence number allocation is fixed, we can finally send a BAR
at powersave wakeup time to refresh the receiver side reorder window

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-23 18:01:28 +01:00
Felix Fietkau 5912e8a1ff mt7603: fix sequence number assignment
If the MT_TXD3_SN_VALID flag is not set in the tx descriptor, the hardware
assigns the sequence number. However, the rest of the code assumes that the
sequence number specified in the 802.11 header gets transmitted.
This was causing issues with the aggregation setup, which worked for the
initial one (where the sequence numbers were still close), but not for
further teardown/re-establishing of sessions.

Additionally, the overwrite of the TID sequence number in WTBL2 was resetting
the hardware assigned sequence numbers, causing them to drift further apart.

Fix this by using the software assigned sequence numbers

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-23 17:58:06 +01:00
Felix Fietkau 60e508ed14 mt76: use readl/writel instead of ioread32/iowrite32
readl/writel is faster because it gets rid of unnecessary extra checks

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-23 15:24:58 +01:00
Felix Fietkau c9402eb0f0 mt76: use napi polling for tx cleanup
This allows tx scheduling and tx cleanup to run concurrently

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-22 14:05:08 +01:00
Felix Fietkau deacb8fa8a mt76: fix using mac80211 tx skb header padding
If the 802.11 frame has no payload, skip the padding.
Also add missing code to mt76x02u

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-22 14:02:57 +01:00
Felix Fietkau 3a7e6bbac3 mt76: fix potential deadlock on cancelling workqueues
mutex->lock must not be held while cancelling workqueues, because it is held
by the workqueue items themselves

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-22 13:29:47 +01:00
Felix Fietkau 7e9e9ad734 mt76: mt7603: add missing initialization for dev->ps_lock
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-22 13:29:47 +01:00
Felix Fietkau 4d8c7e8284 mt76: mt76x02: send no-skb tx status without holding the status lock
Simplifies locking and reduces lock contention

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-22 13:29:47 +01:00
Felix Fietkau e7bd802cf7 mt76: adjust for mac80211 txq scheduling API changes
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-19 10:09:15 +01:00
Lorenzo BianconiandFelix Fietkau 223649049a mt76: usb: reduce code indentation in mt76u_alloc_tx
Improve code readability reducing code indentation in
mt76u_alloc_tx

Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-03-16 20:31:01 +01:00
Lorenzo BianconiandFelix Fietkau 48dc7e9730 mt7603: core: do not use magic numbers in mt7603_reg_map
Use register definitions instead of magic numbers in mt7603_reg_map

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-16 20:28:17 +01:00
Lorenzo BianconiandFelix Fietkau 81a32aa61f mt7603: remove mt7603_mcu_init routine
Remove mt7603_mcu_init since mcu.mutex has been already initialized
in mt76_mmio_init. Run mt7603_load_firmware directly in
mt7603_init_hardware

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-16 20:28:17 +01:00
Lorenzo BianconiandFelix Fietkau 3ce8a93ae1 mt76: dma: add static qualifier to mt76_dma_tx_queue_skb
As already done for mt76_dma_tx_queue_skb_raw, add static qualifier to
mt76_dma_tx_queue_skb and introduce mt76_tx_queue_skb in order to run
mt76_dma_tx_queue_skb in driver code

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-16 20:28:17 +01:00
Felix Fietkau 2660aa98c4 mt76: mt7603: store software PN/IV in wcid
Avoids expensive 64-bit atomic access in the data path

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-16 20:11:42 +01:00
Felix Fietkau 42ce040662 mt76: use TX_NEEDS_ALIGNED4_SKBS
Remove custom header padding insert code

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-15 11:27:33 +01:00
Felix Fietkau 688d708a43 mt76: only schedule txqs from the tx tasklet
Reduces lock contention from the tx path and improves performance

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Felix Fietkau 5323005150 mt76: move tx tasklet to struct mt76_dev
Allows it to be scheduled from core code

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Felix Fietkau f37ad72f1a mt76: mt76x02: store software PN/IV in wcid
Avoids expensive 64-bit atomic access in the data path

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Felix Fietkau c0ab515474 mt76: store wcid tx rate info in one u32 reduce locking
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Felix Fietkau b77b9323c6 mt76: reduce locking in mt76_dma_tx_cleanup
q->tail can be safely updated without locking, because there is no
concurrent access. If called from outside of the tasklet (for flushing),
the tasklet is always disabled.
q->queued can be safely read without locking, as long as the decrement
happens within the locked section.
This patch allows cleaning up tx packets outside of the section that holds
the queue lock for improved performance

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Felix Fietkau 72fe286f2d mt76: use mac80211 txq scheduling
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:37:30 +01:00
Lorenzo BianconiandFelix Fietkau f977a924b8 mt76: introduce mt76_tx_info data structure
Add mt76_tx_info as auxiliary data structure to pass values
to tx_prepare_skb pointer. This is a preliminary patch to add
support for new chipsets (e.g. mt7615)

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:09:32 +01:00
Lorenzo BianconiandFelix Fietkau 0b03f87b22 mt76: move skb dma mapping before running tx_prepare_skb
Move skb dma mapping before configuring txwi since new chipsets (mt7615)
will need skb dma addresses in order to properly configure txwi

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:09:32 +01:00
Lorenzo BianconiandFelix Fietkau efe9a473af mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
Introduce tx_aligned4_skbs in mt76_driver_ops and move
mt76_insert_hdr_pad in mt76_dma_tx_queue_skb. This is a preliminary
patch in order to unify tx dma mapping for mt76x02 and new chipsets

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:09:32 +01:00
Lorenzo BianconiandFelix Fietkau 0fe6386820 mt76: move mt76x02_insert_hdr_pad in mt76-core module
Move mt76x02_insert_hdr_pad in m76-core and rename it in
mt76_insert_hdr_pad in order to be used in mt76_dma_tx_queue_skb.
This is a preliminary patch in order to properly support tx dma
mapping for new chipsets (e.g. mt7615)

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-14 22:09:32 +01:00
Felix Fietkau 312f6fc6f6 mt76: remove irqsave/restore in locking for tx status fifo
Use a separate lock and spin_trylock to avoid disabling interrupts.
Should improve performance and latency

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-13 12:53:23 +01:00
Lorenzo BianconiandFelix Fietkau 2dc63b0da0 mt76: introduce mt76_txq_id field in mt76_queue_entry
Add mt76_txq_id field to mt76_queue_entry in order to properly
track outstanding frames for mt7615 that relies on a single hw queue

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-13 12:53:23 +01:00
Lorenzo BianconiandFelix Fietkau 06c917faeb mt76: introduce mt76_sw_queue data structure
Introduce mt76_sw_queue data structure in order to support new
chipsets (e.g. mt7615) that have a shared hardware queue for all traffic
identifiers. mt76_sw_queue will be used to track outstanding packets

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-13 12:53:23 +01:00
Lorenzo BianconiandFelix Fietkau 9bc2d56c37 mt76: remove mt76_queue dependency from tx_complete_skb function pointer
Remove mt76_queue dependency from tx_complete_skb function pointer and
rely on mt76_tx_qid instead. Remove flush from tx_complete_skb
signature. This is a preliminary patch to introduce mt76_sw_queue
support

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-12 16:58:06 +01:00
Lorenzo BianconiandFelix Fietkau ddd98f8870 mt76: remove mt76_queue dependency from tx_prepare_skb function pointer
Remove mt76_queue dependency from tx_prepare_skb function pointer and
rely on mt76_tx_qid instead. This is a preliminary patch to introduce
mt76_sw_queue support

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-12 16:58:06 +01:00
Lorenzo BianconiandFelix Fietkau e97a209226 mt76: remove mt76_queue dependency from tx_queue_skb function pointer
Remove mt76_queue dependency from tx_queue_skb function pointer and
rely on mt76_tx_qid instead. This is a preliminary patch to introduce
mt76_sw_queue support

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-12 16:58:06 +01:00
Stanislaw GruszkaandFelix Fietkau abcb544579 mt76x02: do not enable RTS/CTS by default
My commit 26a7b5473191 ("mt76x02: set protection according to ht
operation element") enabled by default RTS/CTS protection for OFDM
and CCK traffic, because MT_TX_RTS_CFG_THRESH is configured to non
0xffff by initvals and .set_rts_threshold callback is not called by
mac80211 on initialization, only on user request or during
ieee80211_reconfig() (suspend/resuem or restart_hw).

Enabling RTS/CTS cause some problems when sending probe request
frames by hcxdumptool penetration tool, but I expect it can cause
other issues on different scenarios.

Restore previous setting of RTS/CTS being disabled by default for
OFDM/CCK by changing MT_TX_RTS_CFG_THRESH initvals to 0xffff.

Fixes: 26a7b5473191 ("mt76x02: set protection according to ht operation element")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-12 16:46:26 +01:00
Lorenzo BianconiandFelix Fietkau bdee9247f9 mt76: fix schedule while atomic in mt76x02_reset_state
Fix following schedule while atomic in mt76x02_reset_state
since synchronize_rcu is run inside a RCU section

[44036.944222] mt76x2e 0000:06:00.0: MCU message 31 (seq 3) timed out
[44036.944281] BUG: sleeping function called from invalid context at kernel/rcu/tree_exp.h:818
[44036.944284] in_atomic(): 1, irqs_disabled(): 0, pid: 28066, name: kworker/u4:1
[44036.944287] INFO: lockdep is turned off.
[44036.944292] CPU: 1 PID: 28066 Comm: kworker/u4:1 Tainted: G        W         5.0.0-rc7-wdn-t1+ #7
[44036.944294] Hardware name: Dell Inc. Studio XPS 1340/0K183D, BIOS A11 09/08/2009
[44036.944305] Workqueue: phy1 mt76x02_wdt_work [mt76x02_lib]
[44036.944308] Call Trace:
[44036.944317]  dump_stack+0x67/0x90
[44036.944322]  ___might_sleep.cold.88+0x9f/0xaf
[44036.944327]  rcu_blocking_is_gp+0x13/0x50
[44036.944330]  synchronize_rcu+0x17/0x80
[44036.944337]  mt76_sta_state+0x138/0x1d0 [mt76]
[44036.944349]  mt76x02_wdt_work+0x1c9/0x610 [mt76x02_lib]
[44036.944355]  process_one_work+0x2a5/0x620
[44036.944361]  worker_thread+0x35/0x3e0
[44036.944368]  kthread+0x11c/0x140
[44036.944376]  ret_from_fork+0x3a/0x50
[44036.944384] BUG: scheduling while atomic: kworker/u4:1/28066/0x00000002
[44036.944387] INFO: lockdep is turned off.
[44036.944389] Modules linked in: cmac ctr ccm af_packet snd_hda_codec_hdmi

Introduce __mt76_sta_remove in order to run sta_remove without holding dev->mutex.
Move __mt76_sta_remove outside of RCU section in mt76x02_reset_state

Fixes: e4ebb8b403d1 ("mt76: mt76x2: implement full device restart on watchdog reset")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-03-12 10:42:49 +01:00
Felix Fietkau 320af65ca1 mt76: mt7603: use the correct hweight8() function
__sw_hweight8() is only defined if CONFIG_GENERIC_HWEIGHT is enabled.
The function that works on all architectures is hweight8().

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-11 14:09:05 +01:00
Felix Fietkau 00ac79d1af mt7603: fix initialization of max rx length
The previous version only accidentally disabled A-MSDU deaggregation by
using the wrong mask for rx length configuration, which left previous
length value in place.
Fix the length and initialize the register completely to keep A-MSDU
de-aggregation remaining disabled

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-08 19:51:42 +01:00
Stanislaw GruszkaandFelix Fietkau e72376d2f0 mt76x02: fix hdr pointer in write txwi for USB
Since we add txwi at the begining of skb->data, it no longer point
to ieee80211_hdr. This breaks settings TS bit for probe response and
beacons.

Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-04 09:04:44 +01:00
Wei YongjunandFelix Fietkau 0b927b26d2 mt76: fix return value check in mt76_wmac_probe()
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Wei Yongjun <[email protected]>
2019-03-04 09:03:41 +01:00
Felix Fietkau 1d7760d904 mt76: mt7603: set moredata flag when queueing ps-filtered packets
Clients should poll for more packets afterwards

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-04 08:37:34 +01:00
Felix Fietkau 461f3b0930 mt76: mt76x02: disable ED/CCA by default
This feature has been reported to cause stability issues on several systems.
Disable it until it has been fixed and verified. It can still be enabled
through debugfs

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:40:38 +01:00
Felix Fietkau 42ab27e54a mt76: when releasing PS frames, end the service period if no frame was found
Fixes a rare corner case if the txq dequeue attempt fails, but mac80211
still has PS buffered packets

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:21:42 +01:00
Felix Fietkau 3687eec55f mt76: mt7603: clear the service period on releasing PS filtered packets
These packets have no txwi entry in the ring, so tracking via tx status does
not work. To prevent PS poll requests from being unanswered, end the service
period right away

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:21:42 +01:00
Felix Fietkau eb1ecc402f mt76: mt7603: notify mac80211 about buffered frames in ps queue
Also fix the size check for filtered powersave frames
Fixes a corner case with waking up clients

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:21:42 +01:00
Felix Fietkau d13b065957 mt76: mt7603: fix up hardware queue index for PS filtered packets
Make the queue index match the hardware queue on which they get sent out

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:21:42 +01:00
Felix Fietkau 8bfe6d44ae mt76: mt7603: clear ps filtering mode before releasing buffered frames
Fixes sending them, otherwise they loop back right into the buffer

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 19:21:42 +01:00
Felix Fietkau 8ee225996f mt76: mt76x2: fix 2.4 GHz channel gain settings
AGC register 35, 37 override for the low gain setting should only be done
on 5 GHz. Also, 2.4 GHz needs a different value for register 35

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 15:12:19 +01:00
Felix Fietkau d2c682325d mt76: mt76x2: fix external LNA gain settings
Devices with external LNA need different values for AGC registers 8 and 9

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 15:10:44 +01:00
Felix Fietkau 2ed938271c mt76: mt7603: fix tx status HT rate validation
Use the correct variable in the check. Fixes an uninitialized variable warning

Reported-by: Gustavo A. R. Silva <[email protected]>
Fixes: c8846e1015022 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-03 11:06:20 +01:00
Felix Fietkau 669bc492f2 mt76: mt76x02: reduce false positives in ED/CCA tx blocking
Full tx blocking (as opposed to CCA blocking) should only happen if there
is a continuous non-802.11 signal above the energy detect threshold.
Unfortunately the ED/CCA counter can't detect that, as it also counts 802.11
signals as busy.

Similar to the vendor code, implement a learning mode that waits until the AGC
gain has already been adjusted to the lowest value (due to false CCA events),
and the number of false CCA events still remains high, and the blocking
threshold is exceeded for more than 5 seconds.

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-02 18:23:23 +01:00