Commit Graph
1646 Commits
Author SHA1 Message Date
Felix Fietkau 8ca0484685 mt76: add function for allocating an external wiphy
Unlike the core phy, this will have extra allocated memory for a driver
private struct.

Signed-off-by: Felix Fietkau <[email protected]>
2019-12-03 20:04:12 +01:00
Felix Fietkau 842cae558b mt76: add priv pointer to struct mt76_phy
Will be used for per-phy driver private data

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:58:37 +01:00
Felix Fietkau 502d09a6e8 mt76: add multiple wiphy support to mt76_get_min_avg_rssi
Allow tracking clients of both wiphys separately

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:58:37 +01:00
Felix Fietkau 9e95fa6208 mt76: move txpower and antenna mask to struct mt76_phy
Adds multiple wiphy support to mt76_get_txpower

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:58:37 +01:00
Felix Fietkau df74d69933 mt76: move txpower_conf back to driver specific structs
Nothing in the core uses it

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:55:24 +01:00
Felix Fietkau 9cda51d195 mt76: move chainmask back to driver specific structs
Nothing in the core uses it

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:55:24 +01:00
Felix Fietkau a3e88bcf17 mt76: move state from struct mt76_dev to mt76_phy
Allows keeping per-wiphy state separate

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:55 +01:00
Felix Fietkau d246beb233 mt76: keep a set of software tx queues per phy
Allows tracking tx scheduling separately per phy

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau ee36c8e217 mt76: move channel state to struct mt76_phy
Add support for an extra wiphy in mt76_set_channel and mt76_get_survey
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau e5e755a7a6 mt76: add support for an extra wiphy in mt76_sta_state()
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau 1d80118714 mt76: add support for an extra wiphy in the tx status path
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau c5f1e83e30 mt76: add support for an extra wiphy in the main tx path
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau ea46624355 mt76: add support for an extra wiphy in the rx path
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau 6493e234b4 mt76: introduce struct mt76_phy
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

On the first wiphy, hw->priv will point to struct mt76_dev, which contains a
struct mt76_phy at the start. For the secondary wiphy, hw->priv will point
to a mt76_phy encapsulated in a driver specific struct

To simplify access to struct mt76_phy members from drivers, the driver specific
device struct is changed to add a union of struct mt76_dev and struct mt76_phy
as the first element

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau af83ee8de9 mt76: move initialization of some struct members to mt76_alloc_device
Reduces duplication and prepares for further rework

Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:54:17 +01:00
Felix Fietkau 44825e88a4 mt76: use rcu_read_lock_bh in mt76_dma_rx_poll
Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq
enabled.

Reported-by: Markus Theil <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:37:28 +01:00
Lorenzo BianconiandFelix Fietkau faf5e6fedd mt76: mt7615: read {tx,rx} mask from eeprom
Parse configured {tx,rx} mask from eeprom data instead of just setting it
to four tx-rx streams

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:27:21 +01:00
Lorenzo BianconiandFelix Fietkau db78ee08d9 mt76: move mt76_get_antenna in mt76_core module
Move mt76_get_antenna in mac80211.c in order to be reused by all
drivers. Initialize .get_antenna function pointer for mt76x0, mt7603,
mt7615 and mt76x2u drivers

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:27:21 +01:00
Lorenzo BianconiandFelix Fietkau 7121e163c0 mt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs
Fix possible out-of-bound access of status rates array in
mt7615_fill_txs/mt7603_fill_txs routines

Fixes: c5211e997eca ("mt76: mt7603: rework and fix tx status reporting")
Fixes: 4af81f02b49c ("mt76: mt7615: sync with mt7603 rate control changes")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:53 +01:00
Lorenzo BianconiandFelix Fietkau 5dfb0ec9c6 mt76: mt7615: disable radar pattern detector during scanning
Set switch_reason to CH_SWITCH_SCAN_BYPASS_DPD during frequency scanning
in order to disable radar pattern detector

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau e2f90adcc3 mt76: move interface_modes definition in mt76_core module
Move interface modes declaration in common code since now mt76
chipsets support all modes (NL80211_IFTYPE_STATION, NL80211_IFTYPE_AP,
NL80211_IFTYPE_MESH_POINT and NL80211_IFTYPE_ADHOC)

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau cfdb75124e mt76: mt7615: add ibss support
Enable IFTYPE_ADHOC support on 7615 devices. The feature has been tested
using a mt76x2 device as wireless peer.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau e0731a82a1 mt76: move SUPPORTS_REORDERING_BUFFER hw property in mt76_register_device
Move SUPPORTS_REORDERING_BUFFER hw property configuration from chip
specific code to mt76_register_device since it is supported by all mt76
drivers

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau a85c06cec8 mt76: use mt76_dev in mt76_is_{mmio,usb}
Convert mt76_is_mmio and mt76_is_usb to rely on mt76_dev instead of
mt76x02_dev since this is a property not strictly related to hw chipset
and it will be more reusable

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
zhengbinandFelix Fietkau ea19cd7ac6 mt76: Remove set but not used variable 'idx'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/mediatek/mt76/dma.c: In function mt76_dma_rx_fill:
drivers/net/wireless/mediatek/mt76/dma.c:377:6: warning: variable idx set but not used [-Wunused-but-set-variable]

It is not used since commit 17f1de56df05 ("mt76:
add common code shared between multiple chipsets")

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: zhengbin <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau 3cbaf81a18 mt76: mt76u: rely on a dedicated stats workqueue
rate controller and throughput are very sensitive to tx status timing.
In order to improve performances when the system is heavily loaded,
substitute stat_work delayed_work with a regular work_struct and create
a mt76u dedicated workqueue for tx status reporting

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau 20f0589787 mt76: mt76u: rely on usb_interface instead of usb_dev
usb drivers are supposed to communicate using usb_interface instead
mt76x{0,2}u is now registering through usb_device. Fix it by passing
usb_intf device to mt76_alloc_device routine.

Fixes: 112f980ac8926 ("mt76usb: use usb_dev private data")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Tested-By: Zero_Chaos <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-11-20 12:26:32 +01:00
Lorenzo BianconiandFelix Fietkau f2be00b101 mt76: dma: fix buffer unmap with non-linear skbs
mt76 dma layer is supposed to unmap skb data buffers while keep txwi
mapped on hw dma ring. At the moment mt76 wrongly unmap txwi or does
not unmap data fragments in even positions for non-linear skbs. This
issue may result in hw hangs with A-MSDU if the system relies on IOMMU
or SWIOTLB. Fix this behaviour properly unmapping data fragments on
non-linear skbs.

Fixes: 17f1de56df05 ("mt76: add common code shared between multiple chipsets")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-10-28 08:42:32 +01:00
Lorenzo BianconiandFelix Fietkau c14d6563c4 mt76: mt76x2e: disable pcie_aspm by default
On same device (e.g. U7612E-H1) PCIE_ASPM causes continuous mcu hangs and
instability. Since mt76x2 series does not manage PCIE PS states, first we
try to disable ASPM using pci_disable_link_state. If it fails, we will
disable PCIE PS configuring PCI registers.
This patch has been successfully tested on U7612E-H1 mini-pice card

Tested-by: Oleksandr Natalenko <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-10-28 08:42:23 +01:00
YueHaibingandFelix Fietkau 58e1e969f0 mt76: mt7615: remove unneeded semicolon
remove unneeded semicolon.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
2019-10-28 08:41:44 +01:00
Lorenzo BianconiandFelix Fietkau c93a2d1c13 mt76: mt76x02u: update ewma pkt len in mt76x02u_tx_prepare_skb
Update ewma packet length in mt76x02u_tx_prepare_skb as it is
done for pci counterpart in order to properly estimate tx time on
current channel

Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-10-28 08:41:31 +01:00
Lorenzo BianconiandFelix Fietkau 1987b741da mt76: mt76x0: remove 350ms delay in mt76x0_phy_calibrate
Since mt76x0 does not save the phy calibration data it is not necessary
to wait 350ms in mt76x0_phy_calibrate

Tested-by: Sid Hayn <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-10-28 08:41:13 +01:00
Lorenzo BianconiandFelix Fietkau 50b1e9bd25 mt76: refactor cc_lock locking scheme
Read busy counters not holding cc_lock spinlock since usb read can't be
performed in interrupt context. Move cc_active and cc_rx counters out of
cc_lock since they are not modified in interrupt context.
Grab cc_lock updating cur_cc_bss_rx in mt76_airtime_report and do not
hold rx_lock in mt76_update_survey.
Moreover grab mt76 mutex in mt76_get_survey before running
mt76_update_survey. This patch fixes the following 'schedule while
atomic'

[  291.790866] BUG: scheduling while atomic: iw/2161/0x00000202
[  291.791002] Preemption disabled at:
[  291.791007] [<0000000000000000>] 0x0
[  291.791015] CPU: 0 PID: 2161 Comm: iw Tainted: G W 5.4.= 0-rc2-3-ARCH-00104-g9e208aa06c21 #1
[  291.791017] Hardware name: LENOVO 2349QM6/2349QM6, BIOS G1ETC2WW (2.82=) 08/07/2019
[  291.791019] Call Trace:
[  291.791042]  dump_stack+0x5c/0x80
[  291.791049]  __schedule_bug.cold+0x8e/0x9b
[  291.791055]  __schedule+0x5f8/0x770
[  291.791062]  schedule+0x43/0xd0
[  291.791068]  schedule_preempt_disabled+0x14/0x20
[  291.791074]  __mutex_lock.isra.0+0x18a/0x530
[  291.791099]  mt76u_rr+0x1f/0x40 [mt76_usb]
[  291.791113]  mt76x02_update_channel+0x22/0x40 [mt76x02_lib]
[  291.791122]  mt76_update_survey+0x42/0xe0 [mt76]
[  291.791129]  mt76_get_survey+0x2f/0x1b0 [mt76]
[  291.791170]  ieee80211_dump_survey+0x5e/0x140 [mac80211]
[  291.791217]  nl80211_dump_survey+0x13c/0x2f0 [cfg80211]
[  291.791222]  ? __kmalloc_reserve.isra.0+0x2d/0x70
[  291.791225]  ? __alloc_skb+0x96/0x1d0
[  291.791229]  netlink_dump+0x17b/0x370
[  291.791247]  __netlink_dump_start+0x16f/0x1e0
[  291.791253]  genl_family_rcv_msg+0x396/0x410
[  291.791290]  ? nl80211_prepare_wdev_dump+0x1b0/0x1b0 [cfg80211]
[  291.791297]  ? _raw_spin_unlock_irqrestore+0x20/0x40
[  291.791312]  ? __wake_up_common_lock+0x8a/0xc0
[  291.791316]  genl_rcv_msg+0x47/0x90
[  291.791320]  ? genl_family_rcv_msg+0x410/0x410
[  291.791323]  netlink_rcv_skb+0x49/0x110
[  291.791329]  genl_rcv+0x24/0x40
[  291.791333]  netlink_unicast+0x171/0x200
[  291.791340]  netlink_sendmsg+0x208/0x3d0
[  291.791358]  sock_sendmsg+0x5e/0x60
[  291.791361]  ___sys_sendmsg+0x2ae/0x330
[  291.791368]  ? filemap_map_pages+0x272/0x390
[  291.791374]  ? _raw_spin_unlock+0x16/0x30
[  291.791379]  ? __handle_mm_fault+0x112f/0x1390
[  291.791388]  __sys_sendmsg+0x59/0xa0
[  291.791396]  do_syscall_64+0x5b/0x1a0
[  291.791400]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  291.791404] RIP: 0033:0x7f5d0c7f37b7
[  291.791418] Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 0=
0 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05=
 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
[  291.791421] RSP: 002b:00007ffe8b5d0538 EFLAGS: 00000246 ORIG_RAX: 0000= 00000000002e
[  291.791426] RAX: ffffffffffffffda RBX: 000055a038e6c390 RCX: 00007f5d0= c7f37b7
[  291.791430] RDX: 0000000000000000 RSI: 00007ffe8b5d0570 RDI: 000000000= 0000003
[  291.791434] RBP: 000055a038e718c0 R08: 000055a038e6c02a R09: 000000000= 0000002
[  291.791438] R10: 000055a03808cb00 R11: 0000000000000246 R12: 000055a03= 8e71780
[  291.791440] R13: 00007ffe8b5d0570 R14: 000055a038e717d0 R15: 000055a03= 8e718c0
[  291.791480] NOHZ: local_softirq_pending 202

Fixes: 168aea24f4bb ("mt76: mt76x02u: enable survey support")
Tested-by: Markus Theil <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2019-10-15 19:11:00 +02:00
Felix Fietkau d868638fdd mt76: remove obsolete .add_buf() from struct mt76_queue_ops
It hasn't been used in a while

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-14 12:01:24 +02:00
Felix Fietkau dc14ac64e7 mt7615: remove vif sta from poll list on interface remove
Signed-off-by: Felix Fietkau <[email protected]>
2019-10-11 16:03:55 +02:00
Felix Fietkau 2a0a19168d mt7603: remove vif sta from poll list on interface remove
Signed-off-by: Felix Fietkau <[email protected]>
2019-10-11 16:03:39 +02:00
Felix Fietkau d3a589586d mt76: fix a-mpdu boundary detection issue for airtime reporting
status->ampdu_ref can be 0 if the first frame is an A-MPDU. Avoid calling
mt76_airtime_flush_ampdu again without reinitializing the status wcid by
checking dev->rx_ampdu_len first.

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-10 22:28:53 +02:00
Felix Fietkau 391e1488f8 mt76: add sanity check for a-mpdu rx wcid index
Avoid dereferencing invalid ids

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-10 21:59:49 +02:00
Felix Fietkau 01642d8bed mt76: mt76x02: fix use-after-free in tx status code handling airtime
Signed-off-by: Felix Fietkau <[email protected]>
2019-10-10 21:39:15 +02:00
Pawel DembickiandFelix Fietkau c11a4ad06d mt76: mt76x0: eeprom: add support for MAC address from OF
mt76x0e driver only supports MAC addresses from
calibration data eeprom. Many routers however do not
have a valid stock address set in this field.

This patch makes it possible to take a MAC address
from OF (e.g. from mtd).

Signed-off-by: Pawel Dembicki <[email protected]>
[adjusted for kernel submission]
Signed-off-by: Adrian Schmutzler <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 16:11:03 +02:00
Felix Fietkau d94cc81d39 mt76: drop rcu read lock in mt76_rx_aggr_stop
A rcu read locked section is not allowed to sleep, and the rcu lock here
isn't actually necessary, because we're holding dev->mutex.
Fixes an issue when the tid work item is still running while freeing
a station or stopping the aggregation session

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 15:31:26 +02:00
Felix Fietkau 7d8764d320 mt76: avoid enabling interrupt if NAPI poll is still pending
if napi_complete() returns false, it means that polling is still pending.
Interrupts should not fire until the polling is no longer scheduled

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 12:33:40 +02:00
Felix Fietkau 5b02a078d4 mt76: add missing locking around ampdu action
This is needed primarily to avoid races in dealing with rx aggregation
related data structures

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 12:32:21 +02:00
Felix Fietkau 71c2ef0420 mt76: fix aggregation stop issue
Cancel the workqueue after the tid has been cleaned up, in order to
avoid a possible rescheduling from within the work function.

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 12:31:48 +02:00
Felix Fietkau 6f7d0f503d mt76: fix use-after-free bug in airtime fairness code
status.info could point to skb->cb, leading to a use-after-free after the tx
status has been reported to mac80211

Signed-off-by: Felix Fietkau <[email protected]>
2019-09-29 22:07:16 +02:00
Felix Fietkau 8f22de0611 mt76: do not use devm API for led classdev
With the devm API, the unregister happens after the device cleanup is done,
after which the struct mt76_dev which contains the led_cdev has already been
freed. This leads to a use-after-free bug that can crash the system.

Signed-off-by: Felix Fietkau <[email protected]>
2019-09-29 22:04:38 +02:00
Felix Fietkau e7199f9447 mt76: enable airtime fairness
It is supported by all hardware drivers now

Signed-off-by: Felix Fietkau <[email protected]>
2019-09-26 18:35:01 +02:00
Lorenzo BianconiandFelix Fietkau 81f2be0c45 mt76: mt7615: track tx/rx airtime for airtime fairness
Poll per-station hardware counters available in WTBL after tx/rx
status events in order to report tx/rx airtime to mac80211 layer

Co-developed-by: Felix Fietkau <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-09-26 18:34:32 +02:00
Lorenzo BianconiandFelix Fietkau 2579122ba2 mt76: mt7615: introduce mt7615_mac_wtbl_update routine
Introduce mt7615_mac_wtbl_update utility routine in order to update
WTBL update register

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-09-26 18:34:32 +02:00
Felix Fietkau d91f7c1bcd mt76: mt7615: fix survey channel busy time
Like on mt7603, MIB status register 16 tracks CCA time, but does not
include tx time. Switch to status register 9 to includ NAV and tx
time as well.

Signed-off-by: Felix Fietkau <[email protected]>
2019-09-26 18:34:32 +02:00