Commit Graph
119 Commits
Author SHA1 Message Date
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 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
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 2c62d03d69 mt76x02: clear running flag when resetting state on restart
Use it to avoid unsafe calls to mt76_wake_tx_queue

Signed-off-by: Felix Fietkau <[email protected]>
2019-03-01 14:51:48 +01:00
Lorenzo BianconiandFelix Fietkau b216d3ca4e mt76: introduce q->stopped parameter
Introduce mt76_queue stopped parameter in order to run
ieee80211_wake_queue only when mac80211 queues have been
previously stopped and avoid to disable interrupts when
it is not necessary

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-01 13:00:31 +01:00
Felix Fietkau b4ee01f95c mt76: fix tx status timeout processing
Remove bogus check for MT_PACKET_ID_NO_ACK in mt76_tx_status_skb_get, which
is already handled in callers and turns timeout calls into no-ops
Do not clean up pending status items on reordering of tx status information
if the timeout is not reached yet

Signed-off-by: Felix Fietkau <[email protected]>
2019-01-25 15:22:41 +01:00
Felix Fietkau 1c751f391f mt76: avoid scheduling tx queues for powersave stations
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-21 17:33:38 +01:00
Felix Fietkau f84b008222 mt76: fix tx status reporting for non-probing frames
On MT76x2, the hardware does not report tx status in the FIFO register,
if the packet id is 0.
Change the allocation of packet IDs to use 0 for no-ack packets, 1 for
non-probing packets and 2-255 for packets with tx status requested.
Fixes rate control issues

Signed-off-by: Felix Fietkau <[email protected]>
2019-01-11 15:24:32 +01:00
Lorenzo BianconiandFelix Fietkau fa7335bbe3 mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues
Starting from mac80211 commit adf8ed01e4fd ("mac80211: add an optional
TXQ for other PS-buffered frames") and commit 0eeb2b674f05 ("mac80211:
add an option for station management TXQ") a new per-sta queue has been
introduced for bufferable management frames.
sta->txq[IEEE80211_NUM_TIDS] is initialized just if the driver reports
the following hw flags:
- IEEE80211_HW_STA_MMPDU_TXQ
- IEEE80211_HW_BUFF_MMPDU_TXQ
This can produce a NULL pointer dereference in mt76_stop_tx_queues
since mt76 iterates on all available sta tx queues assuming they are
initialized by mac80211. This issue has been spotted analyzing the code
(it has not triggered any crash yet)

Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-11-17 18:15:00 +01:00
Felix Fietkau 83a80cabbd mt76: request tx status for powersave released EOSP packet
Allows mac80211 to keep track of the service period

Signed-off-by: Felix Fietkau <[email protected]>
2018-11-13 20:54:19 +01:00
Felix Fietkau 67458301fd mt76: fix race condition in station removal
If there are still pending packets in the tx queue when removing a station,
it could possibly lead to a call to further attempts to pull packets from
the mac80211 tx queue after it has already been removed from the scheduling
list.
Prevent this from happening by calling synchronize_rcu after deleting the
wcid pointer before further cleaning up the tx queues.
To be extra careful, ensure that mtxq->list is always initialized properly.

Also drop the useless call to mt76x02_mac_wcid_setup, which only re-assigns
the bss index of the wcid entry, but does not help with the cleanup in any
way.

Signed-off-by: Felix Fietkau <[email protected]>
2018-11-13 11:30:00 +01:00
Felix Fietkau ef06c3074f mt76: avoid queue/status spinlocks while passing tx status to mac80211
There is some code in the mac80211 tx status processing code that could
potentially call back into the tx codepath.
To avoid deadlocks, make sure that no tx related spinlocks are taken
during the ieee80211_tx_status call.

Signed-off-by: Felix Fietkau <[email protected]>
2018-11-05 21:11:42 +01:00
Felix Fietkau fdc63f168e mt76: fix regression in tx status handling
Tx status reporting needs to work on non-STA WCID entries as well

Signed-off-by: Felix Fietkau <[email protected]>
2018-10-27 17:36:53 +02:00
Felix Fietkau 9d59d2a53f mt76: add support for reporting tx status with skb
MT76x2/MT76x0 has somewhat unreliable tx status reporting, and for that
reason the driver currently does not report per-skb tx ack status at all.
This breaks things like client idle polling, which relies on the tx ack
status of a transmitted nullfunc frame.

This patch adds code to report skb-attached tx status if requested by
mac80211 or the rate control module. Since tx status is polled from a
simple FIFO register, the code needs to account for the possibility of
tx status events getting lost.

The code keeps a list of skbs for which tx status is required and passes
them to mac80211 once tx status has been filled in and the DMA queue is
done with it.
If a tx status event is not received after one second, the status rates
are cleared, and a succesful ACK is indicated to avoid spurious disassoc
during assoc or client polling.

Signed-off-by: Felix Fietkau <[email protected]>
2018-10-25 18:27:55 +02:00
Felix Fietkau 96fa353e79 mt76: do not store aggregation sequence number for null-data frames
Fixes a rare corner case where a BlockAckReq might get the wrong
sequence number.

Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:46:42 +02:00
Felix Fietkau 7464cc9710 mt76: check aggregation sequence number for frames sent via drv_tx
ps-poll response frames can be sent via drv_tx. Store the frame sequence number
for such frames, in case a BlockAckReq needs to be sent

Signed-off-by: Felix Fietkau <[email protected]>
2018-09-29 13:15:33 +02:00
Stanislaw GruszkaandFelix Fietkau a69033307e mt76: unify AC to hw queue mapping
Use the same AC to hardware queue mappings for all subdrivers.
Note: this change BK and BE mappings for USB drivers.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 66f394984d mt76: introduce tx_queue_skb function pointer in mt76_bus_ops
Add tx_queue_skb function pointer in mt76_bus_ops since mt76x2u based
devices do not map mt76x2_txwi on dma buffers and it is not possible
to reuse mt76_dma_tx_queue_skb() routine to enqueue tx frames to
hw buffers

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 7ac6dac9a3 mt76: rename mt76_tx_queue_skb in mt76_dma_tx_queue_skb
Move mt76_dma_tx_queue_skb routine in dma.c.
Remove static qualifier from mt76_get_txwi definition

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +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 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 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
Rosen PenevandFelix Fietkau e7647871da Fix errors found by cppcheck
Mismatching declarations as well as unused results.

Signed-off-by: Rosen Penev <[email protected]>
2017-10-27 12:15:53 +02:00
Lorenzo BianconiandFelix Fietkau 3c4c9a647e tx: move state check in mt76_txq_send_burst()
Move device state check in mt76_txq_send_burst() in order to be more
reactive in stopping tx process during hw reset

Signed-off-by: Lorenzo Bianconi <[email protected]>
2017-07-17 10:22:05 +02:00
Lorenzo BianconiandFelix Fietkau 70d225123f tx: fix AGGR burst length estimation
Use tx_info reference of last dequeued frame instead of the previous one
to compute 802.11 aggregate burst length

Signed-off-by: Lorenzo Bianconi <[email protected]>
2017-06-16 15:27:34 +02:00
Felix Fietkau b18d66f749 core: fix checkpatch errors
Signed-off-by: Felix Fietkau <[email protected]>
2016-09-05 11:12:19 +02:00
Felix Fietkau 53c1b7f6ac update my email address
Signed-off-by: Felix Fietkau <[email protected]>
2016-09-04 17:33:28 +02:00
Felix Fietkau ced81a3458 relicense to ISC (except for util.h which is based on GPL'd kernel code
Signed-off-by: Felix Fietkau <[email protected]>
2016-07-12 08:38:46 +02:00
Daniel GolleandFelix Fietkau 9226e96c40 tx: remove spurious semicolon
Remove spurious semicolon resulting in ieee80211_sta_set_buffered()
being always called independent from the result of the expression
evaluated by the preceding if-clause.

Spotted by gcc-6 while attempting to build the driver outside of the
buildroot.

Signed-off-by: Daniel Golle <[email protected]>
2016-07-08 10:20:53 +02:00
Felix Fietkau 9ecf04c4d7 tx: fix locking error pointed out by dnnn88
Signed-off-by: Felix Fietkau <[email protected]>
2016-04-12 11:52:43 +02:00
Felix Fietkau 101dacba43 tx: always leave one descriptor free in the dma ring to avoid getting the queue stuck
Signed-off-by: Felix Fietkau <[email protected]>
2016-03-04 12:40:20 +01:00
Felix Fietkau 4554e8a23d tx: add missing locking in mt76_txq_schedule_all
Signed-off-by: Felix Fietkau <[email protected]>
2016-03-04 12:40:20 +01:00
Felix Fietkau 7e9d52f998 tx: add missing locking in mt76_release_buffered_frames
Signed-off-by: Felix Fietkau <[email protected]>
2016-03-04 12:40:20 +01:00
Felix Fietkau 675868d4e8 mt7603: opt out of the tx BAR refresh at wakeup time
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-28 22:02:21 +01:00
Felix Fietkau 06619cd877 fix freeing frames on tx
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-28 10:47:27 +01:00
Felix Fietkau d1610c641c mt7603: add code to recover from MAC/DMA hangs
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-27 19:47:00 +01:00
Felix Fietkau 2cfb50f84d mt7603: pass the correct hardware queue index to the tx header
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-25 21:29:15 +01:00
Felix Fietkau 079ad90fe2 update copyright lines
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-25 18:09:13 +01:00
Felix Fietkau d7f5fea7e6 tx: fix frame queueing in mt76_release_buffered_frames
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-18 20:35:03 +01:00
Felix Fietkau 2dfb9faa78 add support for queueing frames spanning multiple descriptors
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-05 01:15:35 +01:00
Felix Fietkau b08f5433d1 tx: move dma mapping code to core, unify tx callbacks into one that prepares tx_info, skb and txwi
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-03 20:14:53 +01:00
Felix Fietkau 2c2fa07e98 suspend txq scheduling during scanning
Signed-off-by: Felix Fietkau <[email protected]>
2016-02-03 16:10:54 +01:00
Felix Fietkau 1389db799a move txwi cache to core
Signed-off-by: Felix Fietkau <[email protected]>
2015-12-17 15:50:01 +01:00
Felix Fietkau 5a2e904bbd move more tx code to common
Signed-off-by: Felix Fietkau <[email protected]>
2015-12-16 19:11:16 +01:00
Felix Fietkau 43d5b84989 move tx scheduling code to common
Signed-off-by: Felix Fietkau <[email protected]>
2015-12-16 19:04:06 +01:00
Felix Fietkau a0ee20716f add a mt76x2_ prefix to all files
Signed-off-by: Felix Fietkau <[email protected]>
2015-12-06 16:54:53 +01:00
Felix Fietkau 31c11fdb05 replace mt76 prefix with mt76x2 in preparation for splitting the driver for more chipset support
Signed-off-by: Felix Fietkau <[email protected]>
2015-12-06 16:54:53 +01:00
Felix Fietkau 2f31d1e329 tx: check for an empty txq list in mt76_txq_schedule_list
Signed-off-by: Felix Fietkau <[email protected]>
2015-10-12 14:33:57 +02:00
Felix Fietkau 4e356ab590 tx: get txq fields inside the locked section before calling ieee80211_send_bar
Signed-off-by: Felix Fietkau <[email protected]>
2015-10-12 14:31:50 +02:00