summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76/usb.c
AgeCommit message (Collapse)Author
2021-10-20mt76: remove mt76_wcid pointer from mt76_tx_status_check signatureLorenzo Bianconi
Remove mt76_wcid pointer from mt76_tx_status_check signature since it is always set to NULL Tested-by: mrkiko.rs@gmail.com Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-17mt76: intialize tx queue entry wcid to 0xffff by defaultFelix Fietkau
Avoid accidentally mapping them to WCID 0 on completion Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-01-27mt76: usb: process URBs with status EPROTO properlyLorenzo Bianconi
Similar to commit '0e40dbd56d67 ("mt7601u: process URBs in status EPROTO properly")', do no schedule rx_worker for urb marked with status set -EPROTO Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-20mt76: usb: remove wake logic in mt76u_status_workerLorenzo Bianconi
Similar to mmio code path, remove wake logic in mt76u_status_worker handler. Starting from commit 90d494c99a99 ("mt76: improve tx queue stop/wake")', the wake queue logic on the usb status path is no longer necessary since the hw queues are no longer stopped on the mt76 tx path. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/00009bf0cfdc9565e4432cad3ed51888c667c25d.1607164041.git.lorenzo@kernel.org
2020-12-17mt76: mt76u: fix NULL pointer dereference in mt76u_status_workerLorenzo Bianconi
Fix the following NULL pointer dereference in mt76u_status_worker that can occur if status thread runs before allocating tx queues [ 31.395373] BUG: kernel NULL pointer dereference, address: 000000000000002c [ 31.395769] #PF: supervisor read access in kernel mode [ 31.395985] #PF: error_code(0x0000) - not-present page [ 31.396178] PGD 0 P4D 0 [ 31.396277] Oops: 0000 [#1] SMP [ 31.396430] CPU: 3 PID: 337 Comm: mt76-usb-status Not tainted 5.10.0-rc1-kvm+ #49 [ 31.396703] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-3.fc33 04/01/2014 [ 31.397048] RIP: 0010:mt76u_status_worker+0x2b/0x190 [ 31.397931] RSP: 0018:ffffc9000076fe98 EFLAGS: 00010282 [ 31.398118] RAX: 0000000000000001 RBX: ffff888111203fe8 RCX: 0000000000000000 [ 31.398400] RDX: 0000000000000001 RSI: 0000000000000246 RDI: ffff888111203fe8 [ 31.398668] RBP: ffff888111201d00 R08: 000000000000038c R09: 000000000000009b [ 31.398952] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 [ 31.399235] R13: 0000000000000000 R14: 0000000000000000 R15: ffff88810c987300 [ 31.399494] FS: 0000000000000000(0000) GS:ffff88817bd80000(0000) knlGS:0000000000000000 [ 31.399767] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 31.399991] CR2: 000000000000002c CR3: 0000000103525000 CR4: 00000000000006a0 [ 31.400236] Call Trace: [ 31.400348] ? schedule+0x3e/0xa0 [ 31.400514] __mt76_worker_fn+0x71/0xa0 [ 31.400634] ? mt76_get_min_avg_rssi+0x110/0x110 [ 31.400827] kthread+0x118/0x130 [ 31.400984] ? __kthread_bind_mask+0x60/0x60 [ 31.401212] ret_from_fork+0x1f/0x30 [ 31.401353] Modules linked in: [ 31.401480] CR2: 000000000000002c [ 31.401627] ---[ end trace 8bf174505cc34851 ]--- [ 31.401798] RIP: 0010:mt76u_status_worker+0x2b/0x190 [ 31.402636] RSP: 0018:ffffc9000076fe98 EFLAGS: 00010282 [ 31.402829] RAX: 0000000000000001 RBX: ffff888111203fe8 RCX: 0000000000000000 [ 31.403118] RDX: 0000000000000001 RSI: 0000000000000246 RDI: ffff888111203fe8 [ 31.403424] RBP: ffff888111201d00 R08: 000000000000038c R09: 000000000000009b [ 31.403689] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 [ 31.403933] R13: 0000000000000000 R14: 0000000000000000 R15: ffff88810c987300 [ 31.404209] FS: 0000000000000000(0000) GS:ffff88817bd80000(0000) knlGS:0000000000000000 [ 31.404482] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 31.404726] CR2: 000000000000002c CR3: 0000000103525000 CR4: 00000000000006a0 [ 31.405294] mt76x0u: probe of 1-1:1.0 failed with error -110 [ 31.406007] usb 1-1: USB disconnect, device number 2 [ 31.840756] usb 1-1: new high-speed USB device number 3 using xhci_hcd [ 32.461295] usb 1-1: reset high-speed USB device number 3 using xhci_hcd [ 32.659932] mt76x0u 1-1:1.0: ASIC revision: 76100002 MAC revision: 76502000 [ 33.197032] mt76x0u 1-1:1.0: EEPROM ver:02 fae:01 Fixes: 9daf27e62852 ("mt76: mt76u: use dedicated thread for status work") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/cd44dc407cf3e5f27688105d4a75fb1c68e62b06.1607419147.git.lorenzo@kernel.org
2020-12-08Merge tag 'mt76-for-kvalo-2020-12-04' of https://github.com/nbd168/wirelessKalle Valo
mt76 patches for 5.11 * mt7915 fixes * mt7615 fixes * support for more sta interfaces on mt7615/mt7915 * mt7915 encap offload * performance improvements * channel noise report on mt7915 * usb/sdio support improvements * mt7915 testmode support * mt7915 DBDC support * warning fixes
2020-12-04mt76: move tx hw data queues in mt76_phyLorenzo Bianconi
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 <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04mt76: rely on mt76_queue in tx_queue_skb signatureLorenzo Bianconi
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 <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04mt76: mt76u: use dedicated thread for status workLorenzo Bianconi
Split tx and status path in mt76-usb module relying on mt76 workers APIs Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04mt76: mt76u: rely on woker APIs for rx workLorenzo Bianconi
In order to improve parallelism, convert rx path in mt76-usb module to mt76 workers APIs Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04wireless: mt76: convert tasklets to use new tasklet_setup() APIAllen Pais
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 <romain.perier@gmail.com> Signed-off-by: Allen Pais <apais@linux.microsoft.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-02mt76: usb: fix crash on device removalStanislaw Gruszka
Currently 'while (q->queued > 0)' loop was removed from mt76u_stop_tx() code. This causes crash on device removal as we try to cleanup empty queue: [ 96.495571] kernel BUG at include/linux/skbuff.h:2297! [ 96.498983] invalid opcode: 0000 [#1] SMP PTI [ 96.501162] CPU: 3 PID: 27 Comm: kworker/3:0 Not tainted 5.10.0-rc5+ #11 [ 96.502754] Hardware name: LENOVO 20DGS08H00/20DGS08H00, BIOS J5ET48WW (1.19 ) 08/27/2015 [ 96.504378] Workqueue: usb_hub_wq hub_event [ 96.505983] RIP: 0010:skb_pull+0x2d/0x30 [ 96.507576] Code: 00 00 8b 47 70 39 c6 77 1e 29 f0 89 47 70 3b 47 74 72 17 48 8b 87 c8 00 00 00 89 f6 48 01 f0 48 89 87 c8 00 00 00 c3 31 c0 c3 <0f> 0b 90 0f 1f 44 00 00 53 48 89 fb 48 8b bf c8 00 00 00 8b 43 70 [ 96.509296] RSP: 0018:ffffb11b801639b8 EFLAGS: 00010287 [ 96.511038] RAX: 000000001c6939ed RBX: ffffb11b801639f8 RCX: 0000000000000000 [ 96.512964] RDX: ffffb11b801639f8 RSI: 0000000000000018 RDI: ffff90c64e4fb800 [ 96.514710] RBP: ffff90c654551ee0 R08: ffff90c652bce7a8 R09: ffffb11b80163728 [ 96.516450] R10: 0000000000000001 R11: 0000000000000001 R12: ffff90c64e4fb800 [ 96.519749] R13: 0000000000000010 R14: 0000000000000020 R15: ffff90c64e352ce8 [ 96.523455] FS: 0000000000000000(0000) GS:ffff90c96eec0000(0000) knlGS:0000000000000000 [ 96.527171] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 96.530900] CR2: 0000242556f18288 CR3: 0000000146a10002 CR4: 00000000003706e0 [ 96.534678] Call Trace: [ 96.538418] mt76x02u_tx_complete_skb+0x1f/0x50 [mt76x02_usb] [ 96.542231] mt76_queue_tx_complete+0x23/0x50 [mt76] [ 96.546028] mt76u_stop_tx.cold+0x71/0xa2 [mt76_usb] [ 96.549797] mt76x0u_stop+0x2f/0x90 [mt76x0u] [ 96.553638] drv_stop+0x33/0xd0 [mac80211] [ 96.557449] ieee80211_do_stop+0x558/0x860 [mac80211] [ 96.561262] ? dev_deactivate_many+0x298/0x2d0 [ 96.565101] ieee80211_stop+0x16/0x20 [mac80211] Fix that by adding while loop again. We need loop, not just single check, to clean all pending entries. Additionally move mt76_worker_disable/enable after !mt76_has_tx_pending() as we want to tx_worker to run to process tx queues, while we wait for exactly that. I was a bit worried about accessing q->queued without lock, but mt76_worker_disable() -> kthread_park() should assure this value will be seen updated on other cpus. Fixes: fe5b5ab52e9d ("mt76: unify queue tx cleanup code") Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Acked-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20201126125520.72912-1-stf_xl@wp.pl
2020-09-24mt76: Use fallthrough pseudo-keywordGustavo A. R. Silva
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 <gustavoars@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: convert from tx tasklet to tx worker threadFelix Fietkau
This improves performance by allowing the scheduler to move the tx scheduling work to idle CPUs. Since tx scheduling work is very latency sensitive and kept short via AQL, sched_set_fifo_low is used to keep worker priority above normal tasks Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: remove struct mt76_sw_queueFelix Fietkau
All members except for the struct mt76_queue pointer have been removed Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: rely on AQL for burst size limits on tx queueingFelix Fietkau
Now that AQL works well on all mt76 drivers, completely replace the arbitrary burst sizing and number of bursts logic for tx scheduling. For the short period of time in which AQL does not work well yet, limit each stations to 16 in-flight packets that have no estimated tx time. This should avoid filling the queue if a station connects and queues up a large number of packets before rate control information is available, especially with hardware rate control Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: remove swq from struct mt76_sw_queueFelix Fietkau
Since txq selection was moved to mac80211, it is no longer used Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: unify queue tx cleanup codeFelix Fietkau
Cleanup and preparation for changing tx scheduling behavior Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24mt76: usb: fix use of q->head and q->tailFelix Fietkau
Their use is reversed compared to DMA. The order for DMA makes more sense, so let's use that Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-08-04Merge git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.gitKalle Valo
mt76 driver had major conflicts within mt7615 directory. To make it easier for every merge wireless-drivers to wireless-drivers-next and solve those conflicts.
2020-07-21mt76: mt76u: add mt76_skb_adjust_pad utility routineLorenzo Bianconi
Introduce mt76_skb_adjust_pad to reuse the code adding sdio support to mt7615 driver and remove code duplication. Move 4B header configuration for usb devices out of mt76_skb_adjust_pad Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-07-21mt76: move mt76 workqueue in common codeLorenzo Bianconi
Move mt76 workqueue from usb to common code in order to be reused adding low-power support for mt7663 chipset Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-07-21mt76: usb: rely on mt76_for_each_q_rxLorenzo Bianconi
Rely on mt76_for_each_q_rx whenever possible in order to simply the code Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-07-21mt76: mt7615: fix hw queue mappingLorenzo Bianconi
mt7622/mt7663 chipsets rely on a fixed reverse queue map order respect to mac80211 one: - q(0): IEEE80211_AC_BK - q(1): IEEE80211_AC_BE - q(2): IEEE80211_AC_VI - q(3): IEEE80211_AC_VO Fixes: cdad4874057d ("mt76: mt7615: add dma and tx queue initialization for MT7622") Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Co-developed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-06-23mt76: mt7663u: fix memory leaks in mt7663u_probeLorenzo Bianconi
Fix the two following memory leaks in mt7663u_probe: 1- if device power-own times out, remove ieee80211 hw device. 2- if mt76u queues allocation fails, remove pending urbs. Fixes: eb99cc95c3b65 ("mt76: mt7615: introduce mt7663u support") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/e4098f0c8a9ac51997de07f38c2bcdf7042d6db1.1592755166.git.lorenzo@kernel.org
2020-06-07mt76: mt7615: fix hw queue mappingLorenzo Bianconi
mt7622/mt7663 chipsets rely on a fixed reverse queue map order respect to mac80211 one: - q(0): IEEE80211_AC_BK - q(1): IEEE80211_AC_BE - q(2): IEEE80211_AC_VI - q(3): IEEE80211_AC_VO Fixes: cdad4874057d ("mt76: mt7615: add dma and tx queue initialization for MT7622") Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support") Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Co-developed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-05-12mt76: mt76u: rely on mt7622 queue scheme for mt7663uLorenzo Bianconi
Rely on the mt7622 endpoint definitions for mt7663u Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-03-17mt76: mt76u: rely only on data buffer for usb control messaggesLorenzo Bianconi
Starting from commit 'a6bfb6d13f33 ("mt76: usb: use max packet length for m76u_copy")' reg_val does not share memory with usb data buffer. On non-coherent devices this approach can corrupt data pointer since data and reg_val share the same cache-line, resulting in the following crash: [ 371.544901] CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 8042fbb0 [ 371.558521] CPU: 0 PID: 11 Comm: kworker/u2:2 Not tainted 4.14.160 #0 [ 371.565204] Workqueue: mt76u mt76u_deinit [mt76_usb] [ 371.570331] task: 83823ac0 task.stack: 8386c000 [ 371.575004] $ 0 : 00000000 80590000 00000000 00000000 [ 371.580407] $ 4 : 82edaad0 00000002 83823ac0 fffffff8 [ 371.585810] $ 8 : fffffffd 0000fc00 8052da00 00000000 [ 371.591212] $12 : 000b2285 ae53a1a9 00108845 89da44c4 [ 371.596615] $16 : 82edaad0 82ed9d20 00001798 832edf00 [ 371.602019] $20 : 00000000 8386dda8 80530000 fffffffe [ 371.607421] $24 : 8051d040 76274d1b [ 371.612824] $28 : 8386c000 8386dd88 82edaad4 830d4d50 [ 371.618228] Hi : 000000f7 [ 371.621203] Lo : 33333371 [ 371.624196] epc : 8042fbb0 __mutex_lock.isra.2+0x134/0x378 [ 371.630043] ra : 830d4d50 mt76u_deinit+0x418/0xa6c [mt76_usb] [ 371.636237] Status: 1000fc03KERNEL EXL IE [ 371.640557] Cause : 0080000c (ExcCode 03) [ 371.644696] BadVA : 00000000 [ 371.647671] PrId : 00019374 (MIPS 24Kc) [ 371.726123] usbcore nls_base usb_common [ 371.730180] Process kworker/u2:2 (pid: 11, threadinfo=8386c000, task=83823ac0, tls=00000000) [ 371.738884] Stack : 833d009c 83210b4c 82ed8bc0 8386ddac 000001ff 8008ac50 8386ddac 83b74b00 [ 371.747519] 82edaad4 00000000 83b74b48 83210c38 82edaad0 82ed9d20 00001798 832edf00 [ 371.756157] 00000000 00000000 80530000 fffffffe 80530000 830d4d50 00000040 8389d850 [ 371.764794] 8052d9d8 8389d850 8386de30 82ed9d20 8386de5f 831c27bc 833d48ec 8052d9d8 [ 371.773431] 83823ac0 83823af0 82edab00 82ed9d20 8386de5f 831c5c30 00000000 8052d9a8 [ 371.782069] ... [ 371.784598] Call Trace: [ 371.787130] [<8042fbb0>] __mutex_lock.isra.2+0x134/0x378 [ 371.792622] [<830d4d50>] mt76u_deinit+0x418/0xa6c [mt76_usb] [ 371.808546] [ 371.810920] ---[ end trace c62f0601f6730eb0 ]--- [ 371.818101] Kernel panic - not syncing: Fatal exception [ 371.824420] Rebooting in 3 seconds.. Fix the issue relying only on data buffer to send/receive usb control messages Fixes: a6bfb6d13f33 ("mt76: usb: use max packet length for m76u_copy") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-03-17mt76: mt76u: fix a possible memory leak in mt76u_initLorenzo Bianconi
Remove usb workqueue if mt76u_set_endpoints fails. Fixes: 284efb473ef5 ("mt76: mt76u: rely on a dedicated stats workqueue") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-03-17mt76: mt76u: loop over all possible rx queues in mt76u_rx_taskletLorenzo Bianconi
Loop over all possible hw rx queues in mt76u_rx_tasklet since new devices will report mcu events through mcu hw queue Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: Introduce mt76_mcu data structureLorenzo Bianconi
Introduce mt76_mcu data structure to contain common fields between mt76u_mcu and mt76e_mcu. Initialize mcu common fields in mt76_alloc_device(). Rely on mt76_mcu in mt76_mcu_rx_event and in mt76_mcu_get_response in order to reuse them in usb code Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: rename stat_wq in wqLorenzo Bianconi
Rename usb stat_wq in wq in order to be reused not just for gathering hw tx statistics Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: introduce MT_DRV_RX_DMA_HDR flagLorenzo Bianconi
Define MT_DRV_RX_DMA_HDR flag in drv_flag in order to not skip rx frame dma header since new devices (e.g. mt7663u) reports rx frame info in the usb dma header Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: introduce mt76u_skb_dma_info routineLorenzo Bianconi
Introduce mt76u_skb_dma_info utility routine in mt76-usb module in order to be reused adding mt7663u support Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: take into account different queue mapping for 7663Lorenzo Bianconi
7663u devices rely on a different endpoint mapping. Take it into account in mt76u_alloc_tx routine Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add {read/write}_extended utility routinesLorenzo Bianconi
Introduce extended utility routines to read/write data o usb bus. New devices (e.g. mt7663u) will rely on both upper and lower part of the register address. Add ext parameter to mt76u_init signature in order to reuse the code adding mt7663u support. Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: introduce mt76u_alloc_mcu_queue utility routineLorenzo Bianconi
Add mt76u_alloc_mcu_queue utility routine to allocate mcu hw rx queue. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: resume all rx queue in mt76u_resume_rxLorenzo Bianconi
Resume all possible rx queues after suspend. This is a preliminary patch to support mt7663u devices Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add queue parameter to mt76u_rx_urb_allocLorenzo Bianconi
Add mt76_queue parameter to mt76u_rx_urb_alloc signature since this routine will be used to allocate urbs for mcu hw queue used by new chipset generation (e.g. mt7663u). Check sg_max_size in in mt76u_urb_alloc in order to use linear urb for mcu queue Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add mt76u_alloc_rx_queue utility routineLorenzo Bianconi
Introduce mt76u_alloc_rx_queue routine to allocate rx hw queue. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: stop/free all possible rx queuesLorenzo Bianconi
Stop/free all configured rx queues (data/mcu) in mt76u_stop_rx/mt76u_free_rx. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: introduce mt76u_free_rx_queue utility routineLorenzo Bianconi
Introduce mt76u_free_rx_queue utility routine to free rx hw queue. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: move mcu buffer allocation in mt76x02u driversLorenzo Bianconi
Move mcu buffer allocation in mt76x2u/mt76x0u drivers since newer chipsets (e.g. mt7663u) does not rely on synchronous mcu communication Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add queue id parameter to mt76u_submit_rx_buffersLorenzo Bianconi
Add queue_id parameter to mt76u_submit_rx_buffers in order to reuse it adding mt7663u support Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: use mt76_queue as mt76u_complete_rx contextLorenzo Bianconi
In order to reuse mt76u_complete_rx for both data and mcu rx queue, rely on mt76_queue as urb context in mt76u_complete_rx. Moreover set usb rx endoint according to rx queue in mt76u_submit_rx_buf. This is a preliminary patch to add mt7663u support Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add mt76_queue to mt76u_refill_rx signatureLorenzo Bianconi
Introduce mt76_queue parameter to mt76u_refill_rx signature in order to reuse it for mcu hw rx queue Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add mt76_queue to mt76u_get_next_rx_entry signatureLorenzo Bianconi
Rely on mt76_queue pointer in mt76u_get_next_rx_entry in order to add support for new devices (e.g 7663u) that reports fw events through hw rx mcu queue Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: add mt76u_process_rx_queue utility routineLorenzo Bianconi
Introduce mt76u_process_rx_queue routine to process rx hw queue. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: mt76u: check tx_status_data pointer in mt76u_tx_taskletLorenzo Bianconi
New devices (e.g. mt7663u) do not rely on stats workqueue to load tx statistics but will be reported by the firmware. Check tx_status_data pointer in mt76u_tx_tasklet in order to reuse tx tasklet for new devices Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-02-14mt76: usb: use max packet length for m76u_copyStanislaw Gruszka
For transferring data over USB the optimal size is endpoint maxpacket. For my hardware maxpaket for control endpoint is 64 bytes and changing to this value from 128 bytes further shorten TBTT work time from 3ms to 1ms. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>