platform/kernel/linux-starfive.git
4 years agoMerge tag 'mt76-for-kvalo-2019-11-20' of https://github.com/nbd168/wireless
Kalle Valo [Wed, 20 Nov 2019 18:11:58 +0000 (20:11 +0200)]
Merge tag 'mt76-for-kvalo-2019-11-20' of https://github.com/nbd168/wireless

mt76 patches for 5.5

* monitor mode fix for mt7615
* fixes for rx aggregation race conditions
* cleanups
* mt7615 smart carrier sense support
* code unification / deduplication
* mt7615 debugfs improvements
* debugfs aggregation statistics
* airtime fairness support
* mt76x0 OF mac address support
* locking fixes
* usb support improvements
* rate control fixes

4 years agoMerge tag 'iwlwifi-next-for-kalle-2019-11-20' of git://git.kernel.org/pub/scm/linux...
Kalle Valo [Wed, 20 Nov 2019 18:09:50 +0000 (20:09 +0200)]
Merge tag 'iwlwifi-next-for-kalle-2019-11-20' of git://git./linux/kernel/git/iwlwifi/iwlwifi-next

Patches intended for v5.5

* Fix a merge damage that causes issues with high-throuput on AX200+;
* Support TX/RX antennas reporting;
* Small fix in DVM's BT link-quality code;
* Bump supported FW API version to 52;
* Yet another scan FW API update;
* Some clean-ups;

4 years agomt76: mt76u: fix endpoint definition order
Lorenzo Bianconi [Sun, 17 Nov 2019 12:26:14 +0000 (14:26 +0200)]
mt76: mt76u: fix endpoint definition order

Even if they are not currently used fix BK/BE endpoint definition order.

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: read {tx,rx} mask from eeprom
Lorenzo Bianconi [Thu, 14 Nov 2019 20:21:11 +0000 (22:21 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: move mt76_get_antenna in mt76_core module
Lorenzo Bianconi [Thu, 14 Nov 2019 15:12:07 +0000 (17:12 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs
Lorenzo Bianconi [Wed, 6 Nov 2019 23:01:58 +0000 (01:01 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agoRevert "mt76: mt76x0e: don't use hw encryption for MT7630E"
Stanislaw Gruszka [Tue, 5 Nov 2019 10:00:32 +0000 (11:00 +0100)]
Revert "mt76: mt76x0e: don't use hw encryption for MT7630E"

This reverts commit 34b0e9b767bfa09ae233ca0d6ceb299bf2e24600.

Since commit 7bd0650be63c ("mt76: dma: fix buffer unmap with non-linear skbs")
is no longer necessary to disable HW encryption for MT7630E.

Disabling HW encryption helped previously because somehow fragmented
skb's are not created if mac80211 encrypt frames, so buffer unmap bug
of non-linear skbs was not triggered. Now since this bug is properly
fixed by commit 7bd0650be63c ("mt76: dma: fix buffer unmap with
non-linear skbs") , we can enable HW encryption back.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: disable radar pattern detector during scanning
Lorenzo Bianconi [Fri, 1 Nov 2019 22:21:07 +0000 (23:21 +0100)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: move interface_modes definition in mt76_core module
Lorenzo Bianconi [Thu, 31 Oct 2019 10:03:12 +0000 (11:03 +0100)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add ibss support
Lorenzo Bianconi [Mon, 7 Oct 2019 22:49:00 +0000 (00:49 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: move SUPPORTS_REORDERING_BUFFER hw property in mt76_register_device
Lorenzo Bianconi [Thu, 31 Oct 2019 08:15:09 +0000 (09:15 +0100)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: use mt76_dev in mt76_is_{mmio,usb}
Lorenzo Bianconi [Tue, 29 Oct 2019 13:34:44 +0000 (14:34 +0100)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: Remove set but not used variable 'idx'
zhengbin [Tue, 29 Oct 2019 04:48:39 +0000 (12:48 +0800)]
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 <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76u: rely on a dedicated stats workqueue
Lorenzo Bianconi [Mon, 28 Oct 2019 16:38:05 +0000 (17:38 +0100)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76u: rely on usb_interface instead of usb_dev
Lorenzo Bianconi [Mon, 28 Oct 2019 15:21:41 +0000 (16:21 +0100)]
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 <lorenzo@kernel.org>
Tested-By: Zero_Chaos <sidhayn@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: remove unneeded semicolon
YueHaibing [Fri, 25 Oct 2019 09:16:16 +0000 (17:16 +0800)]
mt76: mt7615: remove unneeded semicolon

remove unneeded semicolon.
This is detected by coccinelle.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x0: remove 350ms delay in mt76x0_phy_calibrate
Lorenzo Bianconi [Fri, 18 Oct 2019 21:31:23 +0000 (23:31 +0200)]
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 <sidhayn@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02u: update ewma pkt len in mt76x02u_tx_prepare_skb
Lorenzo Bianconi [Thu, 17 Oct 2019 22:50:04 +0000 (00:50 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: remove obsolete .add_buf() from struct mt76_queue_ops
Felix Fietkau [Mon, 14 Oct 2019 10:01:09 +0000 (12:01 +0200)]
mt76: remove obsolete .add_buf() from struct mt76_queue_ops

It hasn't been used in a while

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: add sanity check for a-mpdu rx wcid index
Felix Fietkau [Thu, 10 Oct 2019 19:59:46 +0000 (21:59 +0200)]
mt76: add sanity check for a-mpdu rx wcid index

Avoid dereferencing invalid ids

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: refactor cc_lock locking scheme
Lorenzo Bianconi [Tue, 15 Oct 2019 15:16:43 +0000 (17:16 +0200)]
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 <markus.theil@tu-ilmenau.de>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x0: eeprom: add support for MAC address from OF
Pawel Dembicki [Fri, 4 Oct 2019 13:23:49 +0000 (15:23 +0200)]
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 <paweldembicki@gmail.com>
[adjusted for kernel submission]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: avoid enabling interrupt if NAPI poll is still pending
Felix Fietkau [Mon, 7 Oct 2019 10:33:39 +0000 (12:33 +0200)]
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 <nbd@nbd.name>
4 years agomt76: fix aggregation stop issue
Felix Fietkau [Mon, 7 Oct 2019 10:30:46 +0000 (12:30 +0200)]
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 <nbd@nbd.name>
4 years agomt76: drop rcu read lock in mt76_rx_aggr_stop
Felix Fietkau [Mon, 7 Oct 2019 13:30:18 +0000 (15:30 +0200)]
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 <nbd@nbd.name>
4 years agomt76: add missing locking around ampdu action
Felix Fietkau [Mon, 7 Oct 2019 10:32:14 +0000 (12:32 +0200)]
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 <nbd@nbd.name>
4 years agomt76: do not use devm API for led classdev
Felix Fietkau [Sun, 29 Sep 2019 20:04:37 +0000 (22:04 +0200)]
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 <nbd@nbd.name>
4 years agomt76: enable airtime fairness
Felix Fietkau [Fri, 6 Sep 2019 09:29:09 +0000 (11:29 +0200)]
mt76: enable airtime fairness

It is supported by all hardware drivers now

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 years agomt76: mt7615: track tx/rx airtime for airtime fairness
Lorenzo Bianconi [Wed, 18 Sep 2019 10:58:05 +0000 (12:58 +0200)]
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 <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce mt7615_mac_wtbl_update routine
Lorenzo Bianconi [Wed, 18 Sep 2019 10:58:03 +0000 (12:58 +0200)]
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix survey channel busy time
Felix Fietkau [Thu, 26 Sep 2019 16:23:56 +0000 (18:23 +0200)]
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 <nbd@nbd.name>
4 years agomt76: mt7615: report tx_time, bss_rx and busy time to mac80211
Lorenzo Bianconi [Wed, 18 Sep 2019 10:58:02 +0000 (12:58 +0200)]
mt76: mt7615: report tx_time, bss_rx and busy time to mac80211

Report tx time/rx time and obss time from hw mib counters to fill survey
info requested by mac80211

Co-developed-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02: track approximate tx airtime for airtime fairness and survey
Felix Fietkau [Fri, 6 Sep 2019 08:19:19 +0000 (10:19 +0200)]
mt76: mt76x02: track approximate tx airtime for airtime fairness and survey

Estimate by calculating duration for EWMA packet size + estimated A-MPDU
length on tx status events

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02: move MT_CH_TIME_CFG init to mt76x02_mac_cc_reset
Felix Fietkau [Thu, 5 Sep 2019 17:30:21 +0000 (19:30 +0200)]
mt76: mt76x02: move MT_CH_TIME_CFG init to mt76x02_mac_cc_reset

Reduces code duplication and adds missing bits for USB variants

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: unify channel survey update code
Felix Fietkau [Thu, 5 Sep 2019 16:29:13 +0000 (18:29 +0200)]
mt76: unify channel survey update code

Host time is used to calculate the channel active time on mt7603 and mt7615.
Use the same on mt76x02 and move the lock to core code to get rid of some
duplicated code.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: switch to a different counter for survey busy time
Felix Fietkau [Wed, 4 Sep 2019 19:12:10 +0000 (21:12 +0200)]
mt76: mt7603: switch to a different counter for survey busy time

MT_MIB_STAT_PSCCA only counts rx CCA busy time, which does not include
tx time. MT_MIB_STAT_CCA counts full busy time, including Rx, Tx and NAV

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: track tx airtime for airtime fairness and survey
Felix Fietkau [Wed, 4 Sep 2019 18:50:14 +0000 (20:50 +0200)]
mt76: mt7603: track tx airtime for airtime fairness and survey

Poll per-station hardware counters after tx status events

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: track rx airtime for airtime fairness and survey
Felix Fietkau [Wed, 4 Sep 2019 15:45:02 +0000 (17:45 +0200)]
mt76: track rx airtime for airtime fairness and survey

Report total rx airtime for valid stations as BSS rx time in survey

mt7615 is left out for now, it will be supported later by reading
hardware counters instead of calculating airtime in software

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: store current channel survey_state in struct mt76_dev
Felix Fietkau [Thu, 5 Sep 2019 14:58:08 +0000 (16:58 +0200)]
mt76: store current channel survey_state in struct mt76_dev

Move mt76_channel_state() from mt76.h to mac80211.c
Preparation for updating channel state from more places in the drivers/core

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: rename mt76_driver_ops txwi_flags to drv_flags and include tx aligned4
Felix Fietkau [Sat, 31 Aug 2019 10:41:59 +0000 (12:41 +0200)]
mt76: rename mt76_driver_ops txwi_flags to drv_flags and include tx aligned4

This reduces the struct size and is useful for adding more flags later

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: report rx a-mpdu subframe status
Felix Fietkau [Wed, 28 Aug 2019 09:28:36 +0000 (11:28 +0200)]
mt76: report rx a-mpdu subframe status

This can be used in monitor mode to figure out which subframes were sent as
part of which A-MPDU

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: remove q_rx field from struct mt7603_dev
Felix Fietkau [Wed, 28 Aug 2019 09:07:39 +0000 (11:07 +0200)]
mt76: mt7603: remove q_rx field from struct mt7603_dev

It is no longer used

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: collect aggregation stats
Lorenzo Bianconi [Fri, 13 Sep 2019 07:05:54 +0000 (09:05 +0200)]
mt76: mt7603: collect aggregation stats

Introduce ampdu_stat entry in mt7603 debugfs in order to dump 802.11
aggr cumulative statistics

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: collect aggregation stats
Lorenzo Bianconi [Fri, 13 Sep 2019 07:05:53 +0000 (09:05 +0200)]
mt76: mt7615: collect aggregation stats

Introduce ampdu_stat entry in mt7615 debugfs in order to dump 802.11
aggr cumulative statistics

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: move aggr_stats array in mt76_dev
Lorenzo Bianconi [Fri, 13 Sep 2019 07:05:52 +0000 (09:05 +0200)]
mt76: move aggr_stats array in mt76_dev

Move aggr_stats array from mt76x02_dev to mt76_dev in order to be reused
adding aggregation stats for mt7603/mt7615 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add queue entry in debugfs
Lorenzo Bianconi [Fri, 13 Sep 2019 07:05:51 +0000 (09:05 +0200)]
mt76: mt7615: add queue entry in debugfs

Introduce mt7615_queues_read routine to dump hw queue related info.
Add hw ac queues statistics in mt7615 debugfs

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: move queue debugfs entry to driver specific code
Lorenzo Bianconi [Fri, 13 Sep 2019 07:05:50 +0000 (09:05 +0200)]
mt76: move queue debugfs entry to driver specific code

Move queue debugfs entry to driver specific code since mt7615 devices
rely on a different queue layout

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02u: move mt76x02u_mac_start in mt76x02-usb module
Lorenzo Bianconi [Thu, 12 Sep 2019 09:06:38 +0000 (11:06 +0200)]
mt76: mt76x02u: move mt76x02u_mac_start in mt76x02-usb module

Unify mt76x02u_mac_start between mt76x2u and mt76x0u since the
code is shared between both drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x0u: reset counter starting the device
Lorenzo Bianconi [Thu, 12 Sep 2019 09:06:37 +0000 (11:06 +0200)]
mt76: mt76x0u: reset counter starting the device

Remove mt76x02_mac_reset_counters from mt76x0_init_hardware since
it will be run starting the device

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x2: move mt76x02_mac_reset_counters in mt76x02_mac_start
Lorenzo Bianconi [Thu, 12 Sep 2019 09:06:36 +0000 (11:06 +0200)]
mt76: mt76x2: move mt76x02_mac_reset_counters in mt76x02_mac_start

Move mt76x02_mac_reset_counters in mt76x02_mac_start and get rid of
mt76x2_mac_start since it is just a wrapper for mt76x02_mac_start

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02: move mac_reset_counter in mt76x02_lib module
Lorenzo Bianconi [Thu, 12 Sep 2019 09:06:35 +0000 (11:06 +0200)]
mt76: mt76x02: move mac_reset_counter in mt76x02_lib module

Unify mac_reset_counter routine and move it in mt76x02_lib module
since it is shared by all mt76x02 drivers (pci/usb)

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: enable SCS by default
Lorenzo Bianconi [Fri, 6 Sep 2019 15:29:04 +0000 (17:29 +0200)]
mt76: mt7615: enable SCS by default

Enable Smart Carrier Sense algorithm by default in order to improve
performances in a noisy environment

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x0e: make array mt76x0_chan_map static const, makes object smaller
Colin Ian King [Fri, 6 Sep 2019 12:19:26 +0000 (13:19 +0100)]
mt76: mt76x0e: make array mt76x0_chan_map static const, makes object smaller

Don't populate the array mt76x0_chan_map on the stack but instead make it
static const. Makes the object code smaller by 80 bytes.

Before:
   text    data     bss     dec     hex filename
   7685    1192       0    8877    22ad mediatek/mt76/mt76x0/eeprom.o

After:
   text    data     bss     dec     hex filename
   7541    1256       0    8797    225d mediatek/mt76/mt76x0/eeprom.o

(gcc version 9.2.1, amd64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: usb: add lockdep_assert_held in __mt76u_vendor_request
Lorenzo Bianconi [Thu, 5 Sep 2019 16:32:58 +0000 (18:32 +0200)]
mt76: usb: add lockdep_assert_held in __mt76u_vendor_request

Introduce lockdep_assert_held macro in __mt76u_vendor_request routine
and remove comments regarding usb_ctrl_mtx lock

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: remove empty flag in mt76_txq_schedule_list
Lorenzo Bianconi [Thu, 22 Aug 2019 09:49:10 +0000 (11:49 +0200)]
mt76: remove empty flag in mt76_txq_schedule_list

Remove empty flag in mt76_txq_schedule_list and mt76_txq_send_burst
since we just need retry_q length to notify mac80211 to reschedule the
current tx queue

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: use cancel_delayed_work_sync in mt76_rx_aggr_shutdown
Felix Fietkau [Sun, 15 Sep 2019 16:43:59 +0000 (18:43 +0200)]
mt76: use cancel_delayed_work_sync in mt76_rx_aggr_shutdown

The workqueue item needs to be fully shut down before the struct can be
freed.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: remove aggr_work field from struct mt76_wcid
Felix Fietkau [Sun, 15 Sep 2019 16:43:14 +0000 (18:43 +0200)]
mt76: remove aggr_work field from struct mt76_wcid

It is unused

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix control frame rx in monitor mode
Felix Fietkau [Thu, 12 Sep 2019 14:42:53 +0000 (16:42 +0200)]
mt76: mt7615: fix control frame rx in monitor mode

Adjust filters and ensure frames don't get sent to MCU instead of host

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agoiwlwifi: bump FW API to 52 for 22000 series
Luca Coelho [Wed, 10 Apr 2019 06:23:39 +0000 (09:23 +0300)]
iwlwifi: bump FW API to 52 for 22000 series

Start supporting API version 52 for 22000 series.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: check kasprintf() return value
Johannes Berg [Tue, 5 Nov 2019 13:50:32 +0000 (14:50 +0100)]
iwlwifi: check kasprintf() return value

kasprintf() can fail, we should check the return value.

Fixes: 5ed540aecc2a ("iwlwifi: use mac80211 throughput trigger")
Fixes: 8ca151b568b6 ("iwlwifi: add the MVM driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: mvm: remove outdated comment referring to wake lock
Johannes Berg [Mon, 30 Sep 2019 12:16:18 +0000 (14:16 +0200)]
iwlwifi: mvm: remove outdated comment referring to wake lock

There's no multicast wake lock in the driver, remove the comment
that refers to it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: pcie: trace IOVA for iwlwifi_dev_tx_tb
Johannes Berg [Mon, 30 Sep 2019 09:49:49 +0000 (11:49 +0200)]
iwlwifi: pcie: trace IOVA for iwlwifi_dev_tx_tb

We trace the whole TFD with all TBs when in iwlwifi_dev_tx,
but sometimes we add TBs to it later and then we don't have
any of this data. Trace the I/O virtual address (IOVA) (it
can be the physical address, or as returned by the IOMMU)
here to aid debugging the DMA flows.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: dvm: excessive if in rs_bt_update_lq()
Denis Efremov [Wed, 25 Sep 2019 20:49:35 +0000 (23:49 +0300)]
iwlwifi: dvm: excessive if in rs_bt_update_lq()

There is no need to check 'priv->bt_ant_couple_ok' twice in
rs_bt_update_lq(). The second check is always true. Thus, the
expression can be simplified.

Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: mvm: Report tx/rx antennas
Ben Greear [Thu, 5 Sep 2019 21:28:01 +0000 (14:28 -0700)]
iwlwifi: mvm: Report tx/rx antennas

This makes it easier for user-space to know how many antennas the
radio has.  Seems to work with the AX200 radio, at least.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: pcie: rx: use rxq queue_size instead of constant
Johannes Berg [Fri, 27 Sep 2019 09:11:20 +0000 (11:11 +0200)]
iwlwifi: pcie: rx: use rxq queue_size instead of constant

This is a little less efficient now as it's known to be a
multiqueue device in this function, but a future patch will
have to use a variable here anyway, so use rxq->queue_size
now instead to make it clearer.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: mvm: remove left-over non-functional email alias
Johannes Berg [Fri, 27 Sep 2019 16:36:10 +0000 (18:36 +0200)]
iwlwifi: mvm: remove left-over non-functional email alias

This email alias (ilw@linux.intel.com) hasn't been functional
for probably closer to a decade than not, remove it. It's not
really clear to me how this ended up in new code though.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: config: remove max_rx_agg_size
Johannes Berg [Fri, 27 Sep 2019 08:42:38 +0000 (10:42 +0200)]
iwlwifi: config: remove max_rx_agg_size

This field isn't set by any configuration, remove it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: pcie: make some RX functions static
Johannes Berg [Fri, 27 Sep 2019 10:54:14 +0000 (12:54 +0200)]
iwlwifi: pcie: make some RX functions static

These aren't used outside the rx.c file, so make them static.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: scan: support scan req FW API ver 13
Tova Mussai [Sun, 15 Sep 2019 07:22:58 +0000 (10:22 +0300)]
iwlwifi: scan: support scan req FW API ver 13

1. Modify channel config flags to be used for legacy bands channels
   as well, to indicate SSIDs elements from ssidIEsArray.
2. Add new general flag.
3. Remove ssidNum from probe params.

Signed-off-by: Tova Mussai <tova.mussai@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agoiwlwifi: pcie: fix support for transmitting SKBs with fraglist
Johannes Berg [Fri, 1 Jun 2018 08:32:55 +0000 (10:32 +0200)]
iwlwifi: pcie: fix support for transmitting SKBs with fraglist

When the implementation of SKBs with fraglist was sent upstream, a
merge-damage occurred and half the patch was not applied.

This causes problems in high-throughput situations with AX200 devices,
including low throughput and FW crashes.

Introduce the part that was missing from the original patch.

Fixes: 0044f1716c4d ("iwlwifi: pcie: support transmitting SKBs with fraglist")
Cc: stable@vger.kernel.org # 4.20+
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
[ This patch was created by me, but the original author of this code
  is Johannes, so his s-o-b is here and he's marked as the author of
  the patch. ]
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
4 years agortl8xxxu: Remove set but not used variable 'vif','dev','len'
zhengbin [Tue, 19 Nov 2019 02:25:14 +0000 (10:25 +0800)]
rtl8xxxu: Remove set but not used variable 'vif','dev','len'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c: In function rtl8xxxu_c2hcmd_callback:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5396:24: warning: variable vif set but not used [-Wunused-but-set-variable]
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c: In function rtl8xxxu_c2hcmd_callback:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5397:17: warning: variable dev set but not used [-Wunused-but-set-variable]
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c: In function rtl8xxxu_c2hcmd_callback:
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5400:6: warning: variable len set but not used [-Wunused-but-set-variable]

They are introduced by commit e542e66b7c2e ("rtl8xxxu:
add bluetooth co-existence support for single antenna"), but never used,
so remove them.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Reviewed-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agobrcmfmac: remove monitor interface when detaching
Rafał Miłecki [Mon, 18 Nov 2019 12:38:55 +0000 (13:38 +0100)]
brcmfmac: remove monitor interface when detaching

This fixes a minor WARNING in the cfg80211:
[  130.658034] ------------[ cut here ]------------
[  130.662805] WARNING: CPU: 1 PID: 610 at net/wireless/core.c:954 wiphy_unregister+0xb4/0x198 [cfg80211]

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agobrcmfmac: disable PCIe interrupts before bus reset
Rafał Miłecki [Mon, 18 Nov 2019 11:53:08 +0000 (12:53 +0100)]
brcmfmac: disable PCIe interrupts before bus reset

Keeping interrupts on could result in brcmfmac freeing some resources
and then IRQ handlers trying to use them. That was obviously a straight
path for crashing a kernel.

Example:
CPU0                           CPU1
----                           ----
brcmf_pcie_reset
  brcmf_pcie_bus_console_read
  brcmf_detach
    ...
    brcmf_fweh_detach
    brcmf_proto_detach
                               brcmf_pcie_isr_thread
                                 ...
                                 brcmf_proto_msgbuf_rx_trigger
                                   ...
                                   drvr->proto->pd
    brcmf_pcie_release_irq

[  363.789218] Unable to handle kernel NULL pointer dereference at virtual address 00000038
[  363.797339] pgd = c0004000
[  363.800050] [00000038] *pgd=00000000
[  363.803635] Internal error: Oops: 17 [#1] SMP ARM
(...)
[  364.029209] Backtrace:
[  364.031725] [<bf243838>] (brcmf_proto_msgbuf_rx_trigger [brcmfmac]) from [<bf2471dc>] (brcmf_pcie_isr_thread+0x228/0x274 [brcmfmac])
[  364.043662]  r7:00000001 r6:c8ca0000 r5:00010000 r4:c7b4f800

Fixes: 4684997d9eea ("brcmfmac: reset PCIe bus on a firmware crash")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortw88: allows to enable/disable HCI link PS mechanism
Yan-Hsuan Chuang [Mon, 18 Nov 2019 09:54:32 +0000 (17:54 +0800)]
rtw88: allows to enable/disable HCI link PS mechanism

Different interfaces have its own link-related power save mechanism.
Such as PCI can enter L1 state based on the traffic on the link, and
sometimes driver needs to enable/disable it to avoid some issues, like
throughput degrade when PCI trying to enter L1 state even if driver is
having heavy traffic.

For now, rtw88 only supports PCIE chips, and they just need to disable
ASPM L1 when driver is not in power save mode, such as IPS and LPS.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortw88: pci: enable CLKREQ function if host supports it
Yan-Hsuan Chuang [Mon, 18 Nov 2019 09:54:31 +0000 (17:54 +0800)]
rtw88: pci: enable CLKREQ function if host supports it

By Realtek's design, there are two HW modules associated for CLKREQ,
one is responsible to follow the PCIE host settings, and another
is to actually working on it. But the module that is actually working
on it is default disabled, and driver should enable that module if
host and device have successfully sync'ed with each other.

The module is default disabled because sometimes the host does not
support it, and if there is any incorrect settings (ex. CLKREQ# is
not Bi-Direction), device can be lost and disconnected to the host.

So driver should first check after host and device are sync'ed, and
the host does support the function and set it in configuration
space, then driver can turn on the HW module to working on it.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Reviewed-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortw88: pci: use for loop instead of while loop for DBI/MDIO
Yan-Hsuan Chuang [Mon, 18 Nov 2019 09:54:30 +0000 (17:54 +0800)]
rtw88: pci: use for loop instead of while loop for DBI/MDIO

Use a for loop to polling DBI/MDIO read/write flags to avoid
infinite loop happens

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Reviewed-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortw88: pci: use macros to access PCI DBI/MDIO registers
Yan-Hsuan Chuang [Mon, 18 Nov 2019 09:54:29 +0000 (17:54 +0800)]
rtw88: pci: use macros to access PCI DBI/MDIO registers

Add some register and bit macros to access DBI/MDIO register. This
should not change the logic.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: process HE capabilities requests
Mikhail Karpenko [Mon, 18 Nov 2019 08:23:16 +0000 (08:23 +0000)]
qtnfmac: process HE capabilities requests

Pass HE interface type data requests between firmware and driver.

Signed-off-by: Mikhail Karpenko <mkarpenko@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: add TLV for extension IEs
Mikhail Karpenko [Mon, 18 Nov 2019 08:23:14 +0000 (08:23 +0000)]
qtnfmac: add TLV for extension IEs

Extension information elements have additional field for ID. This
commit adds TLV for such elements and a structure for interface HE
capabilities communication with firmware.

Signed-off-by: Mikhail Karpenko <mkarpenko@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: signal that all packets coming from device are already flooded
Igor Mitsyanko [Mon, 18 Nov 2019 08:23:12 +0000 (08:23 +0000)]
qtnfmac: signal that all packets coming from device are already flooded

Firmware floods all packets that need to be flooded (multicast, broadcast,
unknown unicast) as required. Tell kernel bridge subsystem it does not
need to flood packet itself by marking each incoming frame
with skb->offload_fwd_mark flag.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: advertise netdev port parent ID
Igor Mitsyanko [Mon, 18 Nov 2019 08:23:10 +0000 (08:23 +0000)]
qtnfmac: advertise netdev port parent ID

Use MAC address of the first active radio as a unique device ID.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: add interface ID to each packet
Igor Mitsyanko [Mon, 18 Nov 2019 08:23:08 +0000 (08:23 +0000)]
qtnfmac: add interface ID to each packet

Add interface ID information to the tail of each transmitted packet
so that firmware can know to which interface the packet belongs to.
This is only needed if device supports HW switch capability.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: track broadcast domain of each interface
Igor Mitsyanko [Mon, 18 Nov 2019 08:23:06 +0000 (08:23 +0000)]
qtnfmac: track broadcast domain of each interface

If firmware reports that it supports hardware switch capabilities,
driver needs to track and notify device whenever broadcast domain
of a particular network device changes (ie. whenever it's upper
master device changes).

Firmware needs a unique ID to tell broadcast domains from each other
which is an opaque number otherwise. For that purpose we can use
netspace:ifidx pair to uniquely identify each broadcast domain:
 - if netdev is not part of a bridge, then use it's own ifidx
   as a broadcast domain ID
 - if netdev is part of a bridge, then use bridge netdev ifidx
   as broadcast domain ID

Firmware makes sure that packets are only forwarded between
interfaces marked with the same broadcast domain ID.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoqtnfmac: remove VIF in firmware in case of error
Igor Mitsyanko [Mon, 18 Nov 2019 08:23:04 +0000 (08:23 +0000)]
qtnfmac: remove VIF in firmware in case of error

Currently in case of error when registering network device with the
kernel, we won't properly cleanup VIF state in firmware due to DEL_VIF
command will not be send to wifi card. Make sure it does.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortlwifi: set proper udelay within rf_serial_read
Ping-Ke Shih [Mon, 18 Nov 2019 03:14:55 +0000 (11:14 +0800)]
rtlwifi: set proper udelay within rf_serial_read

Since read RF register is an indirect access that hardware needs time to
accomplish read action, but there's no ready bit, so delay is required to
guarantee the read value is correct. After investigating internal documents,
these delays are reduced as proper values.

Reported-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agortlwifi: rf_lock use non-irqsave spin_lock
Ping-Ke Shih [Mon, 18 Nov 2019 03:14:54 +0000 (11:14 +0800)]
rtlwifi: rf_lock use non-irqsave spin_lock

rf_lock is used to protect RF register access, but they will not called
from interrupt context, so *_irqsave version isn't necessary. Then, these
delays don't affect IRQ services.

The old code holds spin_lock_irqsave() that will be detected a long delay
as below:

  kworker/-276     4d...    0us : _raw_spin_lock_irqsave
  kworker/-276     4d...    0us : rtl8723_phy_rf_serial_read <-rtl8723de_phy_set_rf_reg
  kworker/-276     4d...    1us : rtl8723_phy_query_bb_reg <-rtl8723_phy_rf_serial_read
  kworker/-276     4d...    3us : rtl8723_phy_set_bb_reg <-rtl8723_phy_rf_serial_read
  kworker/-276     4d...    4us : __const_udelay <-rtl8723_phy_rf_serial_read
  kworker/-276     4d...    4us!: delay_mwaitx <-rtl8723_phy_rf_serial_read
  kworker/-276     4d... 1004us : rtl8723_phy_set_bb_reg <-rtl8723_phy_rf_serial_read
  [...]

Reported-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoipw2x00: remove set but not used variable 'force_update'
zhengbin [Sat, 16 Nov 2019 07:41:23 +0000 (15:41 +0800)]
ipw2x00: remove set but not used variable 'force_update'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/intel/ipw2x00/ipw2100.c: In function shim__set_security:
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5582:9: warning: variable force_update set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoipw2x00: remove set but not used variable 'reason'
zhengbin [Sat, 16 Nov 2019 07:41:22 +0000 (15:41 +0800)]
ipw2x00: remove set but not used variable 'reason'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function ipw_wx_set_mlme:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:6805:9: warning: variable reason set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agobrcmfmac: remove set but not used variable 'mpnum','nsp','nmp'
zhengbin [Sat, 16 Nov 2019 07:22:47 +0000 (15:22 +0800)]
brcmfmac: remove set but not used variable 'mpnum','nsp','nmp'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c: In function brcmf_chip_dmp_get_regaddr:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c:790:5: warning: variable mpnum set but not used [-Wunused-but-set-variable]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c: In function brcmf_chip_dmp_erom_scan:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c:866:10: warning: variable nsp set but not used [-Wunused-but-set-variable]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c: In function brcmf_chip_dmp_erom_scan:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c:866:5: warning: variable nmp set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
4 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
David S. Miller [Sun, 17 Nov 2019 02:47:31 +0000 (18:47 -0800)]
Merge git://git./linux/kernel/git/netdev/net

Lots of overlapping changes and parallel additions, stuff
like that.

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Linus Torvalds [Sun, 17 Nov 2019 02:14:32 +0000 (18:14 -0800)]
Merge branch 'linus' of git://git./linux/kernel/git/herbert/crypto-2.6

Pull crypto fix from Herbert Xu:
 "This reverts a number of changes to the khwrng thread which feeds the
  kernel random number pool from hwrng drivers. They were trying to fix
  issues with suspend-and-resume but ended up causing regressions"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  Revert "hwrng: core - Freeze khwrng thread during suspend"

4 years agoRevert "hwrng: core - Freeze khwrng thread during suspend"
Herbert Xu [Sun, 17 Nov 2019 00:48:17 +0000 (08:48 +0800)]
Revert "hwrng: core - Freeze khwrng thread during suspend"

This reverts commit 03a3bb7ae631 ("hwrng: core - Freeze khwrng
thread during suspend"), ff296293b353 ("random: Support freezable
kthreads in add_hwgenerator_randomness()") and 59b569480dc8 ("random:
Use wait_event_freezable() in add_hwgenerator_randomness()").

These patches introduced regressions and we need more time to
get them ready for mainline.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
4 years agoMerge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 17 Nov 2019 00:10:59 +0000 (16:10 -0800)]
Merge branch 'x86-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:
 "Two fixes: disable unreliable HPET on Intel Coffe Lake platforms, and
  fix a lockdep splat in the resctrl code"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/resctrl: Fix potential lockdep warning
  x86/quirks: Disable HPET on Intel Coffe Lake platforms

4 years agoMerge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 17 Nov 2019 00:08:46 +0000 (16:08 -0800)]
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull timer fix from Ingo Molnar:
 "Fix integer truncation bug in __do_adjtimex()"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  ntp/y2038: Remove incorrect time_t truncation

4 years agoMerge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 16 Nov 2019 23:56:01 +0000 (15:56 -0800)]
Merge branch 'perf-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "Misc fixes: a handful of AUX event handling related fixes, a Sparse
  fix and two ABI fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix missing static inline on perf_cgroup_switch()
  perf/core: Consistently fail fork on allocation failures
  perf/aux: Disallow aux_output for kernel events
  perf/core: Reattach a misplaced comment
  perf/aux: Fix the aux_output group inheritance fix
  perf/core: Disallow uncore-cgroup events

4 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Linus Torvalds [Sat, 16 Nov 2019 23:52:00 +0000 (15:52 -0800)]
Merge git://git./linux/kernel/git/netdev/net

Pull networking fixes from David Miller:

 1) Fix memory leak in xfrm_state code, from Steffen Klassert.

 2) Fix races between devlink reload operations and device
    setup/cleanup, from Jiri Pirko.

 3) Null deref in NFC code, from Stephan Gerhold.

 4) Refcount fixes in SMC, from Ursula Braun.

 5) Memory leak in slcan open error paths, from Jouni Hogander.

 6) Fix ETS bandwidth validation in hns3, from Yonglong Liu.

 7) Info leak on short USB request answers in ax88172a driver, from
    Oliver Neukum.

 8) Release mem region properly in ep93xx_eth, from Chuhong Yuan.

 9) PTP config timestamp flags validation, from Richard Cochran.

10) Dangling pointers after SKB data realloc in seg6, from Andrea Mayer.

11) Missing free_netdev() in gemini driver, from Chuhong Yuan.

* git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (56 commits)
  ipmr: Fix skb headroom in ipmr_get_route().
  net: hns3: cleanup of stray struct hns3_link_mode_mapping
  net/smc: fix fastopen for non-blocking connect()
  rds: ib: update WR sizes when bringing up connection
  net: gemini: add missed free_netdev
  net: dsa: tag_8021q: Fix dsa_8021q_restore_pvid for an absent pvid
  seg6: fix skb transport_header after decap_and_validate()
  seg6: fix srh pointer in get_srh()
  net: stmmac: Use the correct style for SPDX License Identifier
  octeontx2-af: Use the correct style for SPDX License Identifier
  ptp: Extend the test program to check the external time stamp flags.
  mlx5: Reject requests to enable time stamping on both edges.
  igb: Reject requests that fail to enable time stamping on both edges.
  dp83640: Reject requests to enable time stamping on both edges.
  mv88e6xxx: Reject requests to enable time stamping on both edges.
  ptp: Introduce strict checking of external time stamp options.
  renesas: reject unsupported external timestamp flags
  mlx5: reject unsupported external timestamp flags
  igb: reject unsupported external timestamp flags
  dp83640: reject unsupported external timestamp flags
  ...

4 years agomscc.c: fix semicolon.cocci warnings
kbuild test robot [Fri, 15 Nov 2019 22:38:34 +0000 (06:38 +0800)]
mscc.c: fix semicolon.cocci warnings

drivers/net/phy/mscc.c:1683:3-4: Unneeded semicolon

 Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Fixes: 75a1ccfe6c72 ("mscc.c: Add support for additional VSC PHYs")
CC: Bryan Whitehead <Bryan.Whitehead@microchip.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: net: avoid ptl lock contention in tcp_mmap
Eric Dumazet [Sat, 16 Nov 2019 01:55:54 +0000 (17:55 -0800)]
selftests: net: avoid ptl lock contention in tcp_mmap

tcp_mmap is used as a reference program for TCP rx zerocopy,
so it is important to point out some potential issues.

If multiple threads are concurrently using getsockopt(...
TCP_ZEROCOPY_RECEIVE), there is a chance the low-level mm
functions compete on shared ptl lock, if vma are arbitrary placed.

Instead of letting the mm layer place the chunks back to back,
this patch enforces an alignment so that each thread uses
a different ptl lock.

Performance measured on a 100 Gbit NIC, with 8 tcp_mmap clients
launched at the same time :

$ for f in {1..8}; do ./tcp_mmap -H 2002:a05:6608:290:: & done

In the following run, we reproduce the old behavior by requesting no alignment :

$ tcp_mmap -sz -C $((128*1024)) -a 4096
received 32768 MB (100 % mmap'ed) in 9.69532 s, 28.3516 Gbit
  cpu usage user:0.08634 sys:3.86258, 120.511 usec per MB, 171839 c-switches
received 32768 MB (100 % mmap'ed) in 25.4719 s, 10.7914 Gbit
  cpu usage user:0.055268 sys:21.5633, 659.745 usec per MB, 9065 c-switches
received 32768 MB (100 % mmap'ed) in 28.5419 s, 9.63069 Gbit
  cpu usage user:0.057401 sys:23.8761, 730.392 usec per MB, 14987 c-switches
received 32768 MB (100 % mmap'ed) in 28.655 s, 9.59268 Gbit
  cpu usage user:0.059689 sys:23.8087, 728.406 usec per MB, 18509 c-switches
received 32768 MB (100 % mmap'ed) in 28.7808 s, 9.55074 Gbit
  cpu usage user:0.066042 sys:23.4632, 718.056 usec per MB, 24702 c-switches
received 32768 MB (100 % mmap'ed) in 28.8259 s, 9.5358 Gbit
  cpu usage user:0.056547 sys:23.6628, 723.858 usec per MB, 23518 c-switches
received 32768 MB (100 % mmap'ed) in 28.8808 s, 9.51767 Gbit
  cpu usage user:0.059357 sys:23.8515, 729.703 usec per MB, 14691 c-switches
received 32768 MB (100 % mmap'ed) in 28.8879 s, 9.51534 Gbit
  cpu usage user:0.047115 sys:23.7349, 725.769 usec per MB, 21773 c-switches

New behavior (automatic alignment based on Hugepagesize),
we can see the system overhead being dramatically reduced.

$ tcp_mmap -sz -C $((128*1024))
received 32768 MB (100 % mmap'ed) in 13.5339 s, 20.3103 Gbit
  cpu usage user:0.122644 sys:3.4125, 107.884 usec per MB, 168567 c-switches
received 32768 MB (100 % mmap'ed) in 16.0335 s, 17.1439 Gbit
  cpu usage user:0.132428 sys:3.55752, 112.608 usec per MB, 188557 c-switches
received 32768 MB (100 % mmap'ed) in 17.5506 s, 15.6621 Gbit
  cpu usage user:0.155405 sys:3.24889, 103.891 usec per MB, 226652 c-switches
received 32768 MB (100 % mmap'ed) in 19.1924 s, 14.3222 Gbit
  cpu usage user:0.135352 sys:3.35583, 106.542 usec per MB, 207404 c-switches
received 32768 MB (100 % mmap'ed) in 22.3649 s, 12.2906 Gbit
  cpu usage user:0.142429 sys:3.53187, 112.131 usec per MB, 250225 c-switches
received 32768 MB (100 % mmap'ed) in 22.5336 s, 12.1986 Gbit
  cpu usage user:0.140654 sys:3.61971, 114.757 usec per MB, 253754 c-switches
received 32768 MB (100 % mmap'ed) in 22.5483 s, 12.1906 Gbit
  cpu usage user:0.134035 sys:3.55952, 112.718 usec per MB, 252997 c-switches
received 32768 MB (100 % mmap'ed) in 22.6442 s, 12.139 Gbit
  cpu usage user:0.126173 sys:3.71251, 117.147 usec per MB, 253728 c-switches

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Arjun Roy <arjunroy@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: load firmware for RTL8168fp/RTL8117
Heiner Kallweit [Fri, 15 Nov 2019 21:38:25 +0000 (22:38 +0100)]
r8169: load firmware for RTL8168fp/RTL8117

Load Realtek-provided firmware for RTL8168fp/RTL8117. Unlike the
firmware for other chip versions which is for the PHY, firmware for
RTL8168fp/RTL8117 is for the MAC.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: improve conditional firmware loading for RTL8168d
Heiner Kallweit [Fri, 15 Nov 2019 20:35:22 +0000 (21:35 +0100)]
r8169: improve conditional firmware loading for RTL8168d

Using constant MII_EXPANSION is misleading here because register 0x06
has a different meaning on page 0x0005. Here a proprietary PHY
parameter is read by writing the parameter id to register 0x05 on page
0x0005, followed by reading the parameter value from register 0x06.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>