]> Git Repo - linux.git/log
linux.git
2 years agowifi: mt76: mt7915: add basedband Txpower info into debugfs
Ryder Lee [Tue, 22 Nov 2022 07:53:10 +0000 (15:53 +0800)]
wifi: mt76: mt7915: add basedband Txpower info into debugfs

This helps user to debug Txpower propagation path easily.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: add support to configure spatial reuse parameter set
Ryder Lee [Thu, 17 Nov 2022 17:09:47 +0000 (01:09 +0800)]
wifi: mt76: mt7915: add support to configure spatial reuse parameter set

The SPR parameter set comprises OBSS PD threshold for SRG and
non SRG and Bitmap of BSS color and partial BSSID. This adds
support to configure fields of SPR element to firmware.

User can disable firmware SR algorithms by turning sr_scene_detect off.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: add missing MODULE_PARM_DESC
Ryder Lee [Thu, 17 Nov 2022 17:09:46 +0000 (01:09 +0800)]
wifi: mt76: mt7915: add missing MODULE_PARM_DESC

Add documentation for module_param so that they're visible with
modinfo command.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable WED RX stats
Sujuan Chen [Sat, 12 Nov 2022 15:40:41 +0000 (16:40 +0100)]
wifi: mt76: mt7915: enable WED RX stats

Introduce the capability to report WED RX stats to mac80211.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable WED RX support
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:40 +0000 (16:40 +0100)]
wifi: mt76: mt7915: enable WED RX support

Enable RX Wireless Ethernet Dispatch available on MT7986 Soc in oreder
to offlad traffic received by WLAN NIC and forwarded to LAN/WAN one.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: introduce mt76_connac_mcu_sta_wed_update utility routine
Sujuan Chen [Sat, 12 Nov 2022 15:40:39 +0000 (16:40 +0100)]
wifi: mt76: connac: introduce mt76_connac_mcu_sta_wed_update utility routine

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: add info parameter to rx_skb signature
Sujuan Chen [Sat, 12 Nov 2022 15:40:38 +0000 (16:40 +0100)]
wifi: mt76: add info parameter to rx_skb signature

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: add WED RX support to dma queue alloc
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:37 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to dma queue alloc

Introduce the capability to allocate WED RX buffers in
mt76_dma_wed_setup routine.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: add WED RX support to mt76_dma_rx_fill
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:36 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to mt76_dma_rx_fill

Introduce the capability to refill WED RX buffers in mt76_dma_rx_fill
utility routine.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: add WED RX support to mt76_dma_{add,get}_buf
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:35 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf

Introduce the capability to configure RX WED in mt76_dma_{add,get}_buf
utility routines.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: introduce rxwi and rx token utility routines
Sujuan Chen [Sat, 12 Nov 2022 15:40:34 +0000 (16:40 +0100)]
wifi: mt76: introduce rxwi and rx token utility routines

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: fix wrong power after multiple SAR set
YN Chen [Wed, 16 Nov 2022 14:43:02 +0000 (22:43 +0800)]
wifi: mt76: mt7921: fix wrong power after multiple SAR set

We should update CLC config before SAR set to synchronize all
related settings.

Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: YN Chen <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: introduce helper for mt7996 chipset
Shayne Chen [Thu, 10 Nov 2022 09:35:24 +0000 (17:35 +0800)]
wifi: mt76: connac: introduce helper for mt7996 chipset

Introduce is_mt7996() helper for new chipset.
This is a preliminary patch to support mt7996 driver.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: add more starec command tags
Shayne Chen [Thu, 10 Nov 2022 09:35:23 +0000 (17:35 +0800)]
wifi: mt76: connac: add more starec command tags

Add starec tags which will be used in new chipset.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: add more bss info command tags
Shayne Chen [Thu, 10 Nov 2022 09:35:22 +0000 (17:35 +0800)]
wifi: mt76: connac: add more bss info command tags

Add bss info tags which will be used in new chipset.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: introduce unified event table
Shayne Chen [Thu, 10 Nov 2022 09:35:21 +0000 (17:35 +0800)]
wifi: mt76: connac: introduce unified event table

Add event IDs and related bit fields for unified event support.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: add more unified command IDs
Shayne Chen [Thu, 10 Nov 2022 09:35:20 +0000 (17:35 +0800)]
wifi: mt76: connac: add more unified command IDs

Add more unified command IDs which will be used in new chipset.
This is the preliminary patch for mt7996 support.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: rework fields for larger bandwidth support in sta_rec_bf
Shayne Chen [Thu, 10 Nov 2022 09:35:19 +0000 (17:35 +0800)]
wifi: mt76: connac: rework fields for larger bandwidth support in sta_rec_bf

Rename nrow_bw160 and ncol_bw160 since channel width 320 MHz will share
the same field.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: update struct sta_rec_phy
Shayne Chen [Thu, 10 Nov 2022 09:35:18 +0000 (17:35 +0800)]
wifi: mt76: connac: update struct sta_rec_phy

For connac3 generation, max_ampdu_len should be filled in
struct sta_rec_phy.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: rework macros for unified command
Shayne Chen [Thu, 10 Nov 2022 09:35:17 +0000 (17:35 +0800)]
wifi: mt76: connac: rework macros for unified command

Rework some macros for connac3 unified command.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: introduce chanctx support
Sean Wang [Tue, 15 Nov 2022 00:11:24 +0000 (08:11 +0800)]
wifi: mt76: mt7921: introduce chanctx support

The firmware can have the capability to manage the channel context
scheduling on multiple roles running on the device including Station,
AP and P2P GC/GO mode (will be extended based on the future patchset)
to help users sharing the network with others on a single device.

The firmware is able to support the channel chanctx up to 2 interface
simultaneously running on the different channels.

Another thing to be noted is that before the driver is going sent out the
management frames, the driver has to get the privilege from the firmware
to occupy the current channel context until the frame handshake is
completed and then get the privilege back to the firmware.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: introduce remain_on_channel support
Sean Wang [Tue, 15 Nov 2022 00:11:23 +0000 (08:11 +0800)]
wifi: mt76: mt7921: introduce remain_on_channel support

Introduce remain_on_channel support. Additionally, we add
mt7921_check_offload_capability to disable .remain_on_channel and
.cancel_remain_on_channel and related configuration because those
operations would rely on the fundamental MCU commands that will be only
supported with newer firmware.

Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: accept hw scan request at a time
Sean Wang [Thu, 10 Nov 2022 21:23:47 +0000 (05:23 +0800)]
wifi: mt76: connac: accept hw scan request at a time

The current hw scan cannot accept multiple hw scan requests at a time, we
return the proper error code when the hw scan is still undergoing.

Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: drop ieee80211_[start, stop]_queues in driver
Sean Wang [Thu, 10 Nov 2022 21:23:46 +0000 (05:23 +0800)]
wifi: mt76: mt7921: drop ieee80211_[start, stop]_queues in driver

The firmware would be in charge of braking and continuing the traffic while
the channel contexts are switching between different BSS and HW SCAN in the
background.

Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: add unified ROC cmd/event support
Quan Zhou [Thu, 10 Nov 2022 21:23:45 +0000 (05:23 +0800)]
wifi: mt76: mt7921: add unified ROC cmd/event support

Add unified ROC cmd/event which is only supported by the newer fw.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Co-developed-by: Kaikai Hu <[email protected]>
Signed-off-by: Kaikai Hu <[email protected]>
Signed-off-by: Quan Zhou <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: add chanctx parameter to mt76_connac_mcu_uni_add_bss signature
Sean Wang [Thu, 10 Nov 2022 21:23:44 +0000 (05:23 +0800)]
wifi: mt76: mt7921: add chanctx parameter to mt76_connac_mcu_uni_add_bss signature

Add a chanctx parameter to mt76_connac_mcu_uni_add_bss signature to allow
the firmware binds the BSS into the specific channel context.

Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx
Sean Wang [Thu, 10 Nov 2022 21:23:43 +0000 (05:23 +0800)]
wifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx

add mt76_connac_mcu_uni_set_chctx to set up the channel context per BSS
in the firmware

Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: do not run mt76u_status_worker if the device is not running
Lorenzo Bianconi [Thu, 13 Oct 2022 19:07:37 +0000 (21:07 +0200)]
wifi: mt76: do not run mt76u_status_worker if the device is not running

Fix the following NULL pointer dereference avoiding to run
mt76u_status_worker thread if the device is not running yet.

KASAN: null-ptr-deref in range
[0x0000000000000000-0x0000000000000007]
CPU: 0 PID: 98 Comm: kworker/u2:2 Not tainted 5.14.0+ #78 Hardware
name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Workqueue: mt76 mt76u_tx_status_data
RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0
Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00
48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f>
b6
04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7
RSP: 0018:ffffc900005af988 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a
RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c
R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8
R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28
FS:  0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
 mt76x02_send_tx_status+0x1d2/0xeb0
 mt76x02_tx_status_data+0x8e/0xd0
 mt76u_tx_status_data+0xe1/0x240
 process_one_work+0x92b/0x1460
 worker_thread+0x95/0xe00
 kthread+0x3a1/0x480
 ret_from_fork+0x1f/0x30
Modules linked in:
--[ end trace 8df5d20fc5040f65 ]--
RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0
Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00
48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f>
b6
04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7
RSP: 0018:ffffc900005af988 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a
RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c
R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8
R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28
FS:  0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554

Moreover move stat_work schedule out of the for loop.

Reported-by: Dokyung Song <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: update nss calculation in txs
Evelyn Tsai [Fri, 11 Nov 2022 07:36:15 +0000 (15:36 +0800)]
wifi: mt76: connac: update nss calculation in txs

The hardware reports the number of transmitting antennas not the actual
number of spatial streams

Co-developed-by: Peter Chiu <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Evelyn Tsai <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: don't claim 160MHz support with mt7915 DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:53 +0000 (16:39 +0100)]
wifi: mt76: mt7915: don't claim 160MHz support with mt7915 DBDC

The hardware simply does not support this in DBDC mode.  Remove it from
the HE capabilities.

Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: Fix VHT beamforming capabilities with DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:52 +0000 (16:39 +0100)]
wifi: mt76: mt7915: Fix VHT beamforming capabilities with DBDC

Do not hardcode beamformee 4 space-time streams support, because
DBDC can only support up to 2.

Fixes: 00b2e16e0063 ("mt76: mt7915: add TxBF capabilities")
Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: Fix chainmask calculation on mt7915 DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:51 +0000 (16:39 +0100)]
wifi: mt76: mt7915: Fix chainmask calculation on mt7915 DBDC

mt7915 does not have a per-band number of chains unlike the other chips,
it only has a total number of chains.  Yet the current code would
consider the total number as a per-band number.

For example, it would report that a 2x2 + 2x2 DBDC card have 4 chains on
each band and set chainmask to 0b1111 for the first interface and
0b11110000 for the second.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Co-developed-by: Felix Fietkau <[email protected]>
Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable coredump support
Ryder Lee [Wed, 9 Nov 2022 20:36:34 +0000 (04:36 +0800)]
wifi: mt76: mt7915: enable coredump support

Host triggered and catastrophic event triggered firmware core dumping
for basic firmware issues triage, including state reporting, task/irq
info, function calltrace and MCU memory dump.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: add full system reset into debugfs
Ryder Lee [Wed, 9 Nov 2022 20:36:33 +0000 (04:36 +0800)]
wifi: mt76: mt7915: add full system reset into debugfs

Trigger firmware crash and enable full system recovery through debugfs.
This also renames knob "fw_ser" to a clear-cut name "sys_recovery".

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable full system reset support
Bo Jiao [Wed, 9 Nov 2022 20:36:32 +0000 (04:36 +0800)]
wifi: mt76: mt7915: enable full system reset support

Add mt7915_reset() and refactor mt7915_mac_reset_work() to support
full system recovery.

Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: rework mt7915_dma_reset()
Bo Jiao [Wed, 9 Nov 2022 20:36:31 +0000 (04:36 +0800)]
wifi: mt76: mt7915: rework mt7915_dma_reset()

Reuse mt7915_dma_disable() to reduce duplicated code.
This is a preliminary patch to enable full system reset.

Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: move aggr_stats array in mt76_phy
Lorenzo Bianconi [Wed, 2 Nov 2022 22:29:15 +0000 (23:29 +0100)]
wifi: mt76: move aggr_stats array in mt76_phy

Move aggregation stats array per-phy instead of share it between multiple
interfaces. This is a preliminary patch to add mt7996 driver support.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7615: rely on mt7615_phy in mt7615_mac_reset_counters
Lorenzo Bianconi [Wed, 2 Nov 2022 22:29:14 +0000 (23:29 +0100)]
wifi: mt76: mt7615: rely on mt7615_phy in mt7615_mac_reset_counters

This is a preliminary patch to move aggr_stats array in mt76_phy
structure.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: fix reporting of TX AGGR histogram
Lorenzo Bianconi [Wed, 2 Nov 2022 12:46:50 +0000 (13:46 +0100)]
wifi: mt76: mt7921: fix reporting of TX AGGR histogram

Similar to mt7915, fix stats clash between bins [4-7] in 802.11 tx
aggregation histogram.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: fix reporting of TX AGGR histogram
Lorenzo Bianconi [Wed, 2 Nov 2022 12:35:01 +0000 (13:35 +0100)]
wifi: mt76: mt7915: fix reporting of TX AGGR histogram

Fix stats clash between bins [4-7] in 802.11 tx aggregation histogram.

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7615: enable use_cts_prot support
Ryder Lee [Tue, 25 Oct 2022 00:31:01 +0000 (08:31 +0800)]
wifi: mt76: mt7615: enable use_cts_prot support

This adds selectable RTC/CTS enablement for each interface.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable use_cts_prot support
Ryder Lee [Tue, 25 Oct 2022 00:31:00 +0000 (08:31 +0800)]
wifi: mt76: mt7915: enable use_cts_prot support

This adds selectable RTC/CTS enablement for each interface.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: fix bandwidth 80MHz link fail in 6GHz band
Ming Yen Hsieh [Mon, 24 Oct 2022 12:45:08 +0000 (20:45 +0800)]
wifi: mt76: fix bandwidth 80MHz link fail in 6GHz band

Due to information missing, the firmware may be fail on bandwidth
related settings in mt7921/mt7922. Add new cmd STA_REC_HE_V2 to apply
additional capabilities in 6GHz band.

Tested-by: Ben Greear <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Ming Yen Hsieh <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: add ack signal support
Ryder Lee [Fri, 14 Oct 2022 02:57:48 +0000 (10:57 +0800)]
wifi: mt76: mt7915: add ack signal support

This reports signal strength of ACK packets from the peer as measured
at each interface.

Tested-by: Shurong Wen <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: improve accuracy of time_busy calculation
Ryder Lee [Fri, 14 Oct 2022 02:57:47 +0000 (10:57 +0800)]
wifi: mt76: mt7915: improve accuracy of time_busy calculation

The MIB INFO command is fetching MIB_BUSY_TIME, MIB_TX_TIME, MIB_RX_TIME and
MIB_OBSS_AIRTIME from the radio and filling out cc_busy, cc_tx, cc_bss_rx
and cc_rx respectively.

busy should be >= tx + rx >= tx + bss_rx but we don’t always quite see this.
Sometimes tx + rx is a bit higher than busy due to inaccurate accounting,
so this patch recalculates numbers to make them more reasonable.

Reported-By: Kevin Schneider <[email protected]>
Tested-by: Kevin Schneider <[email protected]>
Tested-by: Chad Monroe <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agoRevert "mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD"
Ben Greear [Sat, 1 Oct 2022 14:19:20 +0000 (07:19 -0700)]
Revert "mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD"

This reverts commit f17f4864504d754bcbf31e4c89412cdf9946c409 and adds the
MT_DRV_AMSDU_OFFLOAD flag for MT7921 USB/SDIO

The reverted commit significantly decreases performance when running
a test where two MT7915 radios have 16 station vdevs each, configured
for AC mode, and transmitting UDP traffic to AP.

Co-developed-by: Felix Fietkau <[email protected]>
Reported-by: Carson Vandegriffe <[email protected]>
Signed-off-by: Ben Greear <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable wed for mt7986-wmac chipset
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:43 +0000 (11:19 +0200)]
wifi: mt76: mt7915: enable wed for mt7986-wmac chipset

Enable WED tx support for mt7986-wmac chipset available on mt7986 board.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Bo Jiao <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: enable wed for mt7986 chipset
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:42 +0000 (11:19 +0200)]
wifi: mt76: mt7915: enable wed for mt7986 chipset

Introduce wed tx support for MT7986 chipset

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Bo Jiao <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: move wed init routines in mmio.c
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:41 +0000 (11:19 +0200)]
wifi: mt76: mt7915: move wed init routines in mmio.c

This is a preliminary patch to enable wed support for mt7986-wmac
chipset.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Bo Jiao <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: fix mt7915_mac_set_timing()
Ryder Lee [Sat, 1 Oct 2022 01:42:44 +0000 (09:42 +0800)]
wifi: mt76: mt7915: fix mt7915_mac_set_timing()

Correct mac timiing settings for different hardware generations.
This improves 40-60Mbps performance.

Fixes: 9aac2969fe5f ("mt76: mt7915: update mac timing settings")
Reported-By: Carson Vandegriffe <[email protected]>
Tested-by: Chad Monroe <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: set correct antenna for radar detection on MT7915D
Shayne Chen [Fri, 30 Sep 2022 15:13:15 +0000 (23:13 +0800)]
wifi: mt76: mt7915: set correct antenna for radar detection on MT7915D

For MT7915D, correct antenna index should be set to let DFS radar
detection work on the 5 GHz band.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: add spatial extension index support
Shayne Chen [Fri, 30 Sep 2022 15:13:14 +0000 (23:13 +0800)]
wifi: mt76: mt7915: add spatial extension index support

In previous, we only allow user to configure tx antenna mask
contiguously (e.g. 0x3, 0xf).
This patch allows user to configure tx antenna mask interleavingly
(e.g. 0x5, 0x8). By setting proper antenna mask and nss, user can
prioritized the signal of different antennas, which helps to test
their performance in normal mode.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: connac: introduce mt76_connac_spe_idx()
Shayne Chen [Fri, 30 Sep 2022 15:13:13 +0000 (23:13 +0800)]
wifi: mt76: connac: introduce mt76_connac_spe_idx()

Add mt76_connac_spe_idx() for antenna mask to spatial extension
index conversion. This is used to support flexible control of
tx antenna.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: rework testmode tx antenna setting
Shayne Chen [Fri, 30 Sep 2022 15:13:12 +0000 (23:13 +0800)]
wifi: mt76: mt7915: rework testmode tx antenna setting

Let the configuration of testmode antenna mask on both band0 and band1
become antenna_mask rather than chainmask. This could simplify the
settings for user and get rid of the conversion when sending fw command.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: deal with special variant of mt7916
Peter Chiu [Fri, 30 Sep 2022 15:13:11 +0000 (23:13 +0800)]
wifi: mt76: mt7915: deal with special variant of mt7916

A variant of mt7916 supports up to 3 tx/rx paths but with only
2 spatial streams. An example usage of the 3rd path is to server as
an auxiliary for beamforming.
In order to deal with this case, this patch reworks some parts to
correctly use paths or streams.

Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: rework eeprom tx paths and streams init
Shayne Chen [Fri, 30 Sep 2022 15:13:10 +0000 (23:13 +0800)]
wifi: mt76: mt7915: rework eeprom tx paths and streams init

Rework tx paths and streams init part to improve readability, and make
sure that the available tx streams should be smaller than or equal to
the available tx paths.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: reserve 8 bits for the index of rf registers
Evelyn Tsai [Fri, 30 Sep 2022 14:14:41 +0000 (22:14 +0800)]
wifi: mt76: mt7915: reserve 8 bits for the index of rf registers

The value of regidx of rf registers is combined with WF selection and
offset. Extend the WF selection field from 4 to 8 bits since the
adie index should also be specified.

Signed-off-by: Evelyn Tsai <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7915: fix bounds checking for tx-free-done command
Ben Greear [Thu, 29 Sep 2022 15:15:25 +0000 (08:15 -0700)]
wifi: mt76: mt7915: fix bounds checking for tx-free-done command

According to the tx-free-done documentation, the DW4 can be repeated,
so have to be more careful about how we test for walking off the
end of the array.

Signed-off-by: Ben Greear <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: Remove unused inline function mt76_wcid_mask_test()
Gaosheng Cui [Thu, 22 Sep 2022 07:47:11 +0000 (15:47 +0800)]
wifi: mt76: Remove unused inline function mt76_wcid_mask_test()

All uses of mt76_wcid_mask_test() have
been removed since commit 8950a62f19c9 ("mt76: get rid of
mt76_wcid_hw routine"), so remove it.

Signed-off-by: Gaosheng Cui <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt7921: fix antenna signal are way off in monitor mode
Sean Wang [Fri, 16 Sep 2022 22:46:45 +0000 (06:46 +0800)]
wifi: mt76: mt7921: fix antenna signal are way off in monitor mode

Group 3 in RxD is disabled in monitor mode. We should use the group 5 in
RxD instead to fix antenna signal way off issue, e.g we would see the
incorrect antenna signal value in wireshark. On the other hand, Group 5
wouldn't be used in STA or AP mode, so the patch shouldn't cause any
harm to those modes.

Fixes: cbaa0a404f8d ("mt76: mt7921: fix up the monitor mode")
Reported-by: Adrian Granados <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: mt76x02: simplify struct mt76x02_rate_power
Felix Fietkau [Wed, 28 Sep 2022 09:29:45 +0000 (11:29 +0200)]
wifi: mt76: mt76x02: simplify struct mt76x02_rate_power

- remove stbc, because mt76x0 doesn't support it and mt76x2 uses the same
  values as HT/VHT
- reduce vht array to 2 elements, because VHT MCS0-7 are the same as HT

Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mt76: move mt76_rate_power from core to mt76x02 driver code
Felix Fietkau [Wed, 28 Sep 2022 08:49:11 +0000 (10:49 +0200)]
wifi: mt76: move mt76_rate_power from core to mt76x02 driver code

Its layout and code is mt76x02 specific

Signed-off-by: Felix Fietkau <[email protected]>
2 years agowifi: mac80211: fix and simplify unencrypted drop check for mesh
Felix Fietkau [Thu, 1 Dec 2022 13:57:30 +0000 (14:57 +0100)]
wifi: mac80211: fix and simplify unencrypted drop check for mesh

ieee80211_drop_unencrypted is called from ieee80211_rx_h_mesh_fwding and
ieee80211_frame_allowed.

Since ieee80211_rx_h_mesh_fwding can forward packets for other mesh nodes
and is called earlier, it needs to check the decryptions status and if the
packet is using the control protocol on its own, instead of deferring to
the later call from ieee80211_frame_allowed.

Because of that, ieee80211_drop_unencrypted has a mesh specific check
that skips over the mesh header in order to check the payload protocol.
This code is invalid when called from ieee80211_frame_allowed, since that
happens after the 802.11->802.3 conversion.

Fix this by moving the mesh specific check directly into
ieee80211_rx_h_mesh_fwding.

Signed-off-by: Felix Fietkau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: add support for restricting netdev features per vif
Felix Fietkau [Mon, 10 Oct 2022 09:43:38 +0000 (11:43 +0200)]
wifi: mac80211: add support for restricting netdev features per vif

This can be used to selectively disable feature flags for checksum offload,
scatter/gather or GSO by changing vif->netdev_features.
Removing features from vif->netdev_features does not affect the netdev
features themselves, but instead fixes up skbs in the tx path so that the
offloads are not needed in the driver.

Aside from making it easier to deal with vif type based hardware limitations,
this also makes it possible to optimize performance on hardware without native
GSO support by declaring GSO support in hw->netdev_features and removing it
from vif->netdev_features. This allows mac80211 to handle GSO segmentation
after the sta lookup, but before itxq enqueue, thus reducing the number of
unnecessary sta lookups, as well as some other per-packet processing.

Signed-off-by: Felix Fietkau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: update TIM for S1G specification changes
Kieran Frewen [Sun, 6 Nov 2022 22:16:02 +0000 (11:16 +1300)]
wifi: mac80211: update TIM for S1G specification changes

Updates to the TIM information element to match changes made in the
IEEE Std 802.11ah-2020.

Signed-off-by: Kieran Frewen <[email protected]>
Co-developed-by: Gilad Itzkovitch <[email protected]>
Signed-off-by: Gilad Itzkovitch <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[use skb_put_data/skb_put_u8]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: don't parse multi-BSSID in assoc resp
Johannes Berg [Fri, 14 Oct 2022 16:56:11 +0000 (18:56 +0200)]
wifi: mac80211: don't parse multi-BSSID in assoc resp

It's not valid to have the multiple BSSID element in the
association response (per 802.11 REVme D1.0), so don't
try to parse it there, but only in the fallback beacon
elements if needed.

The other case that was parsing association requests was
already changed in a previous commit.

Change-Id: I659d2ef1253e079cc71c46a017044e116e31c024
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: cfg80211: use bss_from_pub() instead of container_of()
Johannes Berg [Mon, 17 Oct 2022 07:03:48 +0000 (09:03 +0200)]
wifi: cfg80211: use bss_from_pub() instead of container_of()

There's no need to open-code container_of() when we have
bss_from_pub(). Use it.

Change-Id: I074723717909ba211a40e6499f0c36df0e2ba4be
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: remove unnecessary synchronize_net()
Johannes Berg [Wed, 2 Nov 2022 08:47:47 +0000 (09:47 +0100)]
wifi: mac80211: remove unnecessary synchronize_net()

The call to ieee80211_do_stop() right after will also do
synchronize_rcu() to ensure the SDATA_STATE_RUNNING bit
is cleared, so we don't need to synchronize_net() here.

Change-Id: Id9f9ffcf195002013e5d9fde288877d219780864
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: Drop not needed check for NULL
Alexander Wetzel [Mon, 7 Nov 2022 16:13:28 +0000 (17:13 +0100)]
wifi: mac80211: Drop not needed check for NULL

ieee80211_get_txq() can only be called with vif != NULL.
Remove not needed NULL test in function.

Signed-off-by: Alexander Wetzel <[email protected]>
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails
Chen Zhongjin [Wed, 9 Nov 2022 09:02:37 +0000 (17:02 +0800)]
wifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails

In regulatory_init_db(), when it's going to return a error, reg_pdev
should be unregistered. When load_builtin_regdb_keys() fails it doesn't
do it and makes cfg80211 can't be reload with report:

sysfs: cannot create duplicate filename '/devices/platform/regulatory.0'
 ...
 <TASK>
 dump_stack_lvl+0x79/0x9b
 sysfs_warn_dup.cold+0x1c/0x29
 sysfs_create_dir_ns+0x22d/0x290
 kobject_add_internal+0x247/0x800
 kobject_add+0x135/0x1b0
 device_add+0x389/0x1be0
 platform_device_add+0x28f/0x790
 platform_device_register_full+0x376/0x4b0
 regulatory_init+0x9a/0x4b2 [cfg80211]
 cfg80211_init+0x84/0x113 [cfg80211]
 ...

Fixes: 90a53e4432b1 ("cfg80211: implement regdb signature checking")
Signed-off-by: Chen Zhongjin <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: cfg80211: fix comparison of BSS frequencies
JUN-KYU SHIN [Fri, 11 Nov 2022 02:33:04 +0000 (11:33 +0900)]
wifi: cfg80211: fix comparison of BSS frequencies

If the "channel->freq_offset" comparison is omitted in cmp_bss(),
BSS with different kHz units cannot be distinguished in the S1G Band.
So "freq_offset" should also be included in the comparison.

Signed-off-by: JUN-KYU SHIN <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: fix maybe-unused warning
Íñigo Huguet [Fri, 11 Nov 2022 15:36:22 +0000 (16:36 +0100)]
wifi: mac80211: fix maybe-unused warning

In ieee80211_lookup_key, the variable named `local` is unused if
compiled without lockdep, getting this warning:

net/mac80211/cfg.c: In function ‘ieee80211_lookup_key’:
net/mac80211/cfg.c:542:26: error: unused variable ‘local’ [-Werror=unused-variable]
  struct ieee80211_local *local = sdata->local;
                          ^~~~~

Fix it with __maybe_unused.

Fixes: 8cbf0c2ab6df ("wifi: mac80211: refactor some key code")
Signed-off-by: Íñigo Huguet <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agor8169: use tp_to_dev instead of open code
Juhee Kang [Tue, 29 Nov 2022 16:12:44 +0000 (01:12 +0900)]
r8169: use tp_to_dev instead of open code

The open code is defined as a helper function(tp_to_dev) on r8169_main.c,
which the open code is &tp->pci_dev->dev. The helper function was added
in commit 1e1205b7d3e9 ("r8169: add helper tp_to_dev"). And then later,
commit f1e911d5d0df ("r8169: add basic phylib support") added
r8169_phylink_handler function but it didn't use the helper function.
Thus, tp_to_dev() replaces the open code. This patch doesn't change logic.

Signed-off-by: Juhee Kang <[email protected]>
Reviewed-by: Heiner Kallweit <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
2 years agowifi: cfg80211: Correct example of ieee80211_iface_limit
Philipp Hortmann [Mon, 14 Nov 2022 20:01:35 +0000 (21:01 +0100)]
wifi: cfg80211: Correct example of ieee80211_iface_limit

Correct wrong closing bracket.

Signed-off-by: Philipp Hortmann <[email protected]>
Link: https://lore.kernel.org/r/20221114200135.GA100176@matrix-ESPRIMO-P710
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: mac80211: fix memory leak in ieee80211_if_add()
Zhengchao Shao [Thu, 17 Nov 2022 06:45:00 +0000 (14:45 +0800)]
wifi: mac80211: fix memory leak in ieee80211_if_add()

When register_netdevice() failed in ieee80211_if_add(), ndev->tstats
isn't released. Fix it.

Fixes: 5a490510ba5f ("mac80211: use per-CPU TX/RX statistics")
Signed-off-by: Zhengchao Shao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()
Yuan Can [Tue, 29 Nov 2022 01:42:11 +0000 (01:42 +0000)]
wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()

As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Fixes: ce08cd344a00 ("wifi: nl80211: expose link information for interfaces")
Signed-off-by: Yuan Can <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agowifi: ieee80211: Do not open-code qos address offsets
Kees Cook [Wed, 30 Nov 2022 21:26:45 +0000 (13:26 -0800)]
wifi: ieee80211: Do not open-code qos address offsets

When building with -Wstringop-overflow, GCC's KASAN implementation does
not correctly perform bounds checking within some complex structures
when faced with literal offsets, and can get very confused. For example,
this warning is seen due to literal offsets into sturct ieee80211_hdr
that may or may not be large enough:

drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c: In function 'iwl_mvm_rx_mpdu_mq':
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c:2022:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2022 |                         *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
In file included from drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h:32,
                 from drivers/net/wireless/intel/iwlwifi/mvm/sta.h:15,
                 from drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:27,
                 from drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c:10:
drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/rx.h:559:16: note: at offset [78, 166] into destination object 'mpdu_len' of size 2
  559 |         __le16 mpdu_len;
      |                ^~~~~~~~

Refactor ieee80211_get_qos_ctl() to avoid using literal offsets,
requiring the creation of the actual structure that is described in the
comments. Explicitly choose the desired offset, making the code more
human-readable too. This is one of the last remaining warning to fix
before enabling -Wstringop-overflow globally.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490
Link: https://github.com/KSPP/linux/issues/181
Cc: Johannes Berg <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: Gregory Greenman <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
2 years agoMerge branch 'fix-rtnl_mutex-deadlock-with-dpaa2-and-sfp-modules'
Paolo Abeni [Thu, 1 Dec 2022 12:40:25 +0000 (13:40 +0100)]
Merge branch 'fix-rtnl_mutex-deadlock-with-dpaa2-and-sfp-modules'

Vladimir Oltean says:

====================
Fix rtnl_mutex deadlock with DPAA2 and SFP modules

This patch set deliberately targets net-next and lacks Fixes: tags due
to caution on my part.

While testing some SFP modules on the Solidrun Honeycomb LX2K platform,
I noticed that rebooting causes a deadlock:

============================================
WARNING: possible recursive locking detected
6.1.0-rc5-07010-ga9b9500ffaac-dirty #656 Not tainted
--------------------------------------------
systemd-shutdow/1 is trying to acquire lock:
ffffa62db6cf42f0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x1c/0x30

but task is already holding lock:
ffffa62db6cf42f0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x1c/0x30

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(rtnl_mutex);
  lock(rtnl_mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

6 locks held by systemd-shutdow/1:
 #0: ffffa62db6863c70 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot+0xd4/0x260
 #1: ffff2f2b0176f100 (&dev->mutex){....}-{4:4}, at: device_shutdown+0xf4/0x260
 #2: ffff2f2b017be900 (&dev->mutex){....}-{4:4}, at: device_shutdown+0x104/0x260
 #3: ffff2f2b017680f0 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0x40/0x260
 #4: ffff2f2b0e1608f0 (&dev->mutex){....}-{4:4}, at: device_release_driver_internal+0x40/0x260
 #5: ffffa62db6cf42f0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x1c/0x30

stack backtrace:
CPU: 6 PID: 1 Comm: systemd-shutdow Not tainted 6.1.0-rc5-07010-ga9b9500ffaac-dirty #656
Hardware name: SolidRun LX2160A Honeycomb (DT)
Call trace:
 lock_acquire+0x68/0x84
 __mutex_lock+0x98/0x460
 mutex_lock_nested+0x2c/0x40
 rtnl_lock+0x1c/0x30
 sfp_bus_del_upstream+0x1c/0xac
 phylink_destroy+0x1c/0x50
 dpaa2_mac_disconnect+0x28/0x70
 dpaa2_eth_remove+0x1dc/0x1f0
 fsl_mc_driver_remove+0x24/0x60
 device_remove+0x70/0x80
 device_release_driver_internal+0x1f0/0x260
 device_links_unbind_consumers+0xe0/0x110
 device_release_driver_internal+0x138/0x260
 device_release_driver+0x18/0x24
 bus_remove_device+0x12c/0x13c
 device_del+0x16c/0x424
 fsl_mc_device_remove+0x28/0x40
 __fsl_mc_device_remove+0x10/0x20
 device_for_each_child+0x5c/0xac
 dprc_remove+0x94/0xb4
 fsl_mc_driver_remove+0x24/0x60
 device_remove+0x70/0x80
 device_release_driver_internal+0x1f0/0x260
 device_release_driver+0x18/0x24
 bus_remove_device+0x12c/0x13c
 device_del+0x16c/0x424
 fsl_mc_bus_remove+0x8c/0x10c
 fsl_mc_bus_shutdown+0x10/0x20
 platform_shutdown+0x24/0x3c
 device_shutdown+0x15c/0x260
 kernel_restart+0x40/0xa4
 __do_sys_reboot+0x1e4/0x260
 __arm64_sys_reboot+0x24/0x30

But fixing this appears to be not so simple. The patch set represents my
attempt to address it.

In short, the problem is that dpaa2_mac_connect() and dpaa2_mac_disconnect()
call 2 phylink functions in a row, one takes rtnl_lock() itself -
phylink_create(), and one which requires rtnl_lock() to be held by the
caller - phylink_fwnode_phy_connect(). The existing approach in the
drivers is too simple. We take rtnl_lock() when calling dpaa2_mac_connect(),
which is what results in the deadlock.

Fixing just that creates another problem. The drivers make use of
rtnl_lock() for serializing with other code paths too. I think I've
found all those code paths, and established other mechanisms for
serializing with them.
====================

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-mac: move rtnl_lock() only around phylink_{,dis}connect_phy()
Vladimir Oltean [Tue, 29 Nov 2022 14:12:21 +0000 (16:12 +0200)]
net: dpaa2-mac: move rtnl_lock() only around phylink_{,dis}connect_phy()

After the introduction of a private mac_lock that serializes access to
priv->mac (and port_priv->mac in the switch), the only remaining purpose
of rtnl_lock() is to satisfy the locking requirements of
phylink_fwnode_phy_connect() and phylink_disconnect_phy().

But the functions these live in, dpaa2_mac_connect() and
dpaa2_mac_disconnect(), have contradictory locking requirements.
While phylink_fwnode_phy_connect() wants rtnl_lock() to be held,
phylink_create() wants it to not be held.

Move the rtnl_lock() from top-level (in the dpaa2-eth and dpaa2-switch
drivers) to only surround the phylink calls that require it, in the
dpaa2-mac library code.

This is possible because dpaa2_mac_connect() and dpaa2_mac_disconnect()
run unlocked, and there isn't any danger of an AB/BA deadlock between
the rtnl_mutex and other private locks.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-switch: serialize changes to priv->mac with a mutex
Vladimir Oltean [Tue, 29 Nov 2022 14:12:20 +0000 (16:12 +0200)]
net: dpaa2-switch: serialize changes to priv->mac with a mutex

The dpaa2-switch driver uses a DPMAC in the same way as the dpaa2-eth
driver, so we need to duplicate the locking solution established by the
previous change to the switch driver as well.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-eth: serialize changes to priv->mac with a mutex
Vladimir Oltean [Tue, 29 Nov 2022 14:12:19 +0000 (16:12 +0200)]
net: dpaa2-eth: serialize changes to priv->mac with a mutex

The dpaa2 architecture permits dynamic connections between objects on
the fsl-mc bus, specifically between a DPNI object (represented by a
struct net_device) and a DPMAC object (represented by a struct phylink).

The DPNI driver is notified when those connections are created/broken
through the dpni_irq0_handler_thread() method. To ensure that ethtool
operations, as well as netdev up/down operations serialize with the
connection/disconnection of the DPNI with a DPMAC,
dpni_irq0_handler_thread() takes the rtnl_lock() to block those other
operations from taking place.

There is code called by dpaa2_mac_connect() which wants to acquire the
rtnl_mutex once again, see phylink_create() -> phylink_register_sfp() ->
sfp_bus_add_upstream() -> rtnl_lock(). So the strategy doesn't quite
work out, even though it's fairly simple.

Create a different strategy, where all code paths in the dpaa2-eth
driver access priv->mac only while they are holding priv->mac_lock.
The phylink instance is not created or connected to the PHY under the
priv->mac_lock, but only assigned to priv->mac then. This will eliminate
the reliance on the rtnl_mutex.

Add lockdep annotations and put comments where holding the lock is not
necessary, and priv->mac can be dereferenced freely.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-eth: connect to MAC before requesting the "endpoint changed" IRQ
Vladimir Oltean [Tue, 29 Nov 2022 14:12:18 +0000 (16:12 +0200)]
net: dpaa2-eth: connect to MAC before requesting the "endpoint changed" IRQ

dpaa2_eth_connect_mac() is called both from dpaa2_eth_probe() and from
dpni_irq0_handler_thread().

It could happen that the DPNI gets connected to a DPMAC on the fsl-mc
bus exactly during probe, as soon as the "endpoint change" interrupt is
requested in dpaa2_eth_setup_irqs(). This will cause the
dpni_irq0_handler_thread() to register a phylink instance for that DPMAC.

Then, the probing function will also try to register a phylink instance
for the same DPMAC, operation which should fail (and this will fail the
probing of the driver).

Reorder dpaa2_eth_setup_irqs() and dpaa2_eth_connect_mac(), such that
dpni_irq0_handler_thread() never races with the DPMAC-related portion of
the probing path.

Also reorder dpaa2_eth_disconnect_mac() to be in the mirror position of
dpaa2_eth_connect_mac() in the teardown path.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-switch replace direct MAC access with dpaa2_switch_port_has_mac()
Vladimir Oltean [Tue, 29 Nov 2022 14:12:17 +0000 (16:12 +0200)]
net: dpaa2-switch replace direct MAC access with dpaa2_switch_port_has_mac()

The helper function will gain a lockdep annotation in a future patch.
Make sure to benefit from it.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2: publish MAC stringset to ethtool -S even if MAC is missing
Vladimir Oltean [Tue, 29 Nov 2022 14:12:16 +0000 (16:12 +0200)]
net: dpaa2: publish MAC stringset to ethtool -S even if MAC is missing

DPNIs and DPSW objects can connect and disconnect at runtime from DPMAC
objects on the same fsl-mc bus. The DPMAC object also holds "ethtool -S"
unstructured counters. Those counters are only shown for the entity
owning the netdev (DPNI, DPSW) if it's connected to a DPMAC.

The ethtool stringset code path is split into multiple callbacks, but
currently, connecting and disconnecting the DPMAC takes the rtnl_lock().
This blocks the entire ethtool code path from running, see
ethnl_default_doit() -> rtnl_lock() -> ops->prepare_data() ->
strset_prepare_data().

This is going to be a problem if we are going to no longer require
rtnl_lock() when connecting/disconnecting the DPMAC, because the DPMAC
could appear between ops->get_sset_count() and ops->get_strings().
If it appears out of the blue, we will provide a stringset into an array
that was dimensioned thinking the DPMAC wouldn't be there => array
accessed out of bounds.

There isn't really a good way to work around that, and I don't want to
put too much pressure on the ethtool framework by playing locking games.
Just make the DPMAC counters be always available. They'll be zeroes if
the DPNI or DPSW isn't connected to a DPMAC.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-switch: assign port_priv->mac after dpaa2_mac_connect() call
Vladimir Oltean [Tue, 29 Nov 2022 14:12:15 +0000 (16:12 +0200)]
net: dpaa2-switch: assign port_priv->mac after dpaa2_mac_connect() call

The dpaa2-switch has the exact same locking requirements when connected
to a DPMAC, so it needs port_priv->mac to always point either to NULL,
or to a DPMAC with a fully initialized phylink instance.

Make the same preparatory change in the dpaa2-switch driver as in the
dpaa2-eth one.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-eth: assign priv->mac after dpaa2_mac_connect() call
Vladimir Oltean [Tue, 29 Nov 2022 14:12:14 +0000 (16:12 +0200)]
net: dpaa2-eth: assign priv->mac after dpaa2_mac_connect() call

There are 2 requirements for correct code:

- Any time the driver accesses the priv->mac pointer at runtime, it
  either holds NULL to indicate a DPNI-DPNI connection (or unconnected
  DPNI), or a struct dpaa2_mac whose phylink instance was fully
  initialized (created and connected to the PHY). No changes are made to
  priv->mac while it is being used. Currently, rtnl_lock() watches over
  the call to dpaa2_eth_connect_mac(), so it serves the purpose of
  serializing this with all readers of priv->mac.

- dpaa2_mac_connect() should run unlocked, because inside it are 2
  phylink calls with incompatible locking requirements: phylink_create()
  requires that the rtnl_mutex isn't held, and phylink_fwnode_phy_connect()
  requires that the rtnl_mutex is held. The only way to solve those
  contradictory requirements is to let dpaa2_mac_connect() take
  rtnl_lock() when it needs to.

To solve both requirements, we need to identify the writer side of the
priv->mac pointer, which can be wrapped in a mutex private to the driver
in a future patch. The dpaa2_mac_connect() cannot be part of the writer
side critical section, because of an AB/BA deadlock with rtnl_lock().

So the strategy needs to be that where we prepare the DPMAC by calling
dpaa2_mac_connect(), and only make priv->mac point to it once it's fully
prepared. This ensures that the writer side critical section has the
absolute minimum surface it can.

The reverse strategy is adopted in the dpaa2_eth_disconnect_mac() code
path. This makes sure that priv->mac is NULL when we start tearing down
the DPMAC that we disconnected from, and concurrent code will simply not
see it.

No locking changes in this patch (concurrent code is still blocked by
the rtnl_mutex).

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-mac: remove defensive check in dpaa2_mac_disconnect()
Vladimir Oltean [Tue, 29 Nov 2022 14:12:13 +0000 (16:12 +0200)]
net: dpaa2-mac: remove defensive check in dpaa2_mac_disconnect()

dpaa2_mac_disconnect() will only be called with a NULL mac->phylink if
dpaa2_mac_connect() failed, or was never called.

The callers are these:

dpaa2_eth_disconnect_mac():

if (dpaa2_eth_is_type_phy(priv))
dpaa2_mac_disconnect(priv->mac);

dpaa2_switch_port_disconnect_mac():

if (dpaa2_switch_port_is_type_phy(port_priv))
dpaa2_mac_disconnect(port_priv->mac);

priv->mac can be NULL, but in that case, dpaa2_eth_is_type_phy() returns
false, and dpaa2_mac_disconnect() is never called. Similar for
dpaa2-switch.

When priv->mac is non-NULL, it means that dpaa2_mac_connect() returned
zero (success), and therefore, priv->mac->phylink is also a valid
pointer.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-mac: absorb phylink_start() call into dpaa2_mac_start()
Vladimir Oltean [Tue, 29 Nov 2022 14:12:12 +0000 (16:12 +0200)]
net: dpaa2-mac: absorb phylink_start() call into dpaa2_mac_start()

The phylink handling is intended to be hidden inside the dpaa2_mac
object. Move the phylink_start() call into dpaa2_mac_start(), and
phylink_stop() into dpaa2_mac_stop().

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2: replace dpaa2_mac_is_type_fixed() with dpaa2_mac_is_type_phy()
Vladimir Oltean [Tue, 29 Nov 2022 14:12:11 +0000 (16:12 +0200)]
net: dpaa2: replace dpaa2_mac_is_type_fixed() with dpaa2_mac_is_type_phy()

dpaa2_mac_is_type_fixed() is a header with no implementation and no
callers, which is referenced from the documentation though. It can be
deleted.

On the other hand, it would be useful to reuse the code between
dpaa2_eth_is_type_phy() and dpaa2_switch_port_is_type_phy(). That common
code should be called dpaa2_mac_is_type_phy(), so let's create that.

The removal and the addition are merged into the same patch because,
in fact, is_type_phy() is the logical opposite of is_type_fixed().

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: dpaa2-eth: don't use -ENOTSUPP error code
Vladimir Oltean [Tue, 29 Nov 2022 14:12:10 +0000 (16:12 +0200)]
net: dpaa2-eth: don't use -ENOTSUPP error code

dpaa2_eth_setup_dpni() is called from the probe path and
dpaa2_eth_set_link_ksettings() is propagated to user space.

include/linux/errno.h says that ENOTSUPP is "Defined for the NFSv3
protocol". Conventional wisdom has it to not use it in networking
drivers. Replace it with -EOPNOTSUPP.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Ioana Ciornei <[email protected]>
Tested-by: Ioana Ciornei <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
2 years agonet: microchip: sparx5: Fix error handling in vcap_show_admin()
Dan Carpenter [Tue, 29 Nov 2022 09:43:47 +0000 (12:43 +0300)]
net: microchip: sparx5: Fix error handling in vcap_show_admin()

If vcap_dup_rule() fails that leads to an error pointer dereference
side the call to vcap_free_rule().  Also it only returns an error if the
very last call to vcap_read_rule() fails and it returns success for
other errors.

I've changed it to just stop printing after the first error and return
an error code.

Fixes: 3a7921560d2f ("net: microchip: sparx5: Add VCAP rule debugFS support for the VCAP API")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Steen Hegelund <[email protected]>
Link: https://lore.kernel.org/r/Y4XUUx9kzurBN+BV@kili
Signed-off-by: Paolo Abeni <[email protected]>
2 years agowifi: rtw89: link rtw89_vif and chanctx stuffs
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:30 +0000 (16:31 +0800)]
wifi: rtw89: link rtw89_vif and chanctx stuffs

First, introduce struct rtw89_sub_entity for chanctx related stuffs.
Second, add enum rtw89_sub_entity_idx to rtw89_vif for vif operation
to access its/right chanctx stuffs after future multi-channel support.

Besides, RTW89_SUB_ENTITY_0 is the default chanctx entry throughout
driver, i.e. it's used for things which may not have a target chanctx
yet. So, we need to ensure that RTW89_SUB_ENTITY_0 is always working.
If there is at least one alive chanctx, then one of them must take
RTW89_SUB_ENTITY_0. If no alive chanctx, RTW89_SUB_ENTITY_0 will be
filled by rtw89_config_default_chandef().

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: fw: implement MCC related H2C
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:29 +0000 (16:31 +0800)]
wifi: rtw89: fw: implement MCC related H2C

These MCC H2C(s) require to wait for MCC C2H to determine if the
execution is successful. Through rtw89_wait_for_cond(), we make
them wait for either a completion with data from MCC C2H handlers,
which calls rtw89_complete_cond(), or timeout.

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: mac: process MCC related C2H
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:28 +0000 (16:31 +0800)]
wifi: rtw89: mac: process MCC related C2H

Process C2H(s) related to MCC (multi-channel concurrency). These handling,
which either call rtw89_complete_cond() or show message in debug mode, can
be considered atomic/lock-free. So, they should be safe to be processed
directly after C2H pre-check in previous patch.

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: introduce helpers to wait/complete on condition
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:27 +0000 (16:31 +0800)]
wifi: rtw89: introduce helpers to wait/complete on condition

MCC (multi-channel concurrency) related H2Cs (host to chip commands)
require to wait for C2H (chip to host events) responses to judge the
execution result and data. We introduce helpers to assist this process.
Besides, we would like the helpers to be generic for use in driver even
outside of MCC H2C/C2H, so we make a independent patch for them.

In the following, I describe the things first.
```
(A) C2H is generated by FW, and then transferred upto driver. Hence,
driver cannot get it immediately without a bit waitting/blocking.
For this, we choose to use wait_for_completion_*() instead of
busy polling.
(B) From the driver management perspective, a scenario, e.g. MCC,
may have mulitple kind of H2C functions requiring this process
to wait for corresponding C2Hs. But, the driver management flow
uses mutex to protect each behavior. So, one scenario triggers
one H2C function at one time. To avoid rampant instances of
struct completion for each H2C function, we choose to use one
struct completion with one condition flag for one scenario.
(C) C2Hs, which H2Cs will be waitting for, cannot be ordered with
driver management flow, i.e. cannot enqueue work to the same
ordered workqueue and cannot lock by the same mutex, to prevent
H2C side from getting no C2H responses. So, those C2Hs are parsed
in interrupt context directly as done in previous commit.
(D) Following (C), the above underline H2Cs and C2Hs will be handled
in different contexts without sync. So, we use atomic_cmpxchg()
to compare and change the condition in atomic.
```

So, we introduce struct rtw89_wait_info which combines struct completion
and atomic_t. Then, the below are the descriptions for helper functions.
* rtw89_wait_for_cond() to wait for a completion based on a condition.
* rtw89_complete_cond() to complete a given condition and carry data.
Each rtw89_wait_info instance independently determines the meaning of
its waitting conditions. But, RTW89_WAIT_COND_IDLE (UINT_MAX) is reserved.

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: check if atomic before queuing c2h
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:26 +0000 (16:31 +0800)]
wifi: rtw89: check if atomic before queuing c2h

Before queuing C2H work, we check atomicity of the C2H's handler first now.
If atomic or lock-free, handle it directly; otherwise, handle it with mutex
in work as previous. This prepares for MAC MCC C2Hs which require to be
processed directly. And, their handlers will be functions which can be
considered atomic.

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: rfk: rename rtw89_mcc_info to rtw89_rfk_mcc_info
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:25 +0000 (16:31 +0800)]
wifi: rtw89: rfk: rename rtw89_mcc_info to rtw89_rfk_mcc_info

The `rtw89_mcc_info mcc` is only for RFK MCC stuffs instead of common
MCC management info. Replace it with `rtw89_rfk_mcc_info rfk_mcc` to
avoid confusion and reserve `struct rtw89_mcc_info mcc` for MCC management
code.

(No logic changes.)

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw88: 8821c: enable BT device recovery mechanism
Ping-Ke Shih [Mon, 28 Nov 2022 07:56:53 +0000 (15:56 +0800)]
wifi: rtw88: 8821c: enable BT device recovery mechanism

8821ce is a combo card, and BT is a USB device that could get card lost
during stress test, and need WiFi firmware to detect and recover it, so
driver sends a H2C to enable this mechanism.

Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: 8852b: turn off PoP function in monitor mode
Ping-Ke Shih [Fri, 25 Nov 2022 07:24:16 +0000 (15:24 +0800)]
wifi: rtw89: 8852b: turn off PoP function in monitor mode

PoP stands for Packet on Packet that can improve performance in noisy
environment, but it could get RX stuck suddenly. In normal mode, firmware
can help to resolve the stuck, but firmware doesn't work in monitor mode.
Therefore, turn off PoP to avoid RX stuck.

Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
2 years agowifi: rtw89: add HE radiotap for monitor mode
Ping-Ke Shih [Fri, 25 Nov 2022 07:24:15 +0000 (15:24 +0800)]
wifi: rtw89: add HE radiotap for monitor mode

With basic HE radiotap, we can check data rate in sniffer data. To store
the radiotap data, we reserve headroom of aligned 64 bytes, and then
update HE radiotap in monitor mode, so it doesn't affect performance in
normal mode.

Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
This page took 0.117911 seconds and 4 git commands to generate.