platform/kernel/linux-rpi.git
2 years agomt76: mt7915: add missing bh-disable around tx napi enable/schedule
Felix Fietkau [Thu, 2 Jun 2022 19:43:04 +0000 (21:43 +0200)]
mt76: mt7915: add missing bh-disable around tx napi enable/schedule

napi_schedule() can call __raise_softirq_irqoff(), which can perform softirq
handling, so it must not be called in a pure process context with BH enabled.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agodt-bindings: net: wireless: mt76: add clock description for MT7986.
Peter Chiu [Thu, 12 May 2022 04:38:59 +0000 (12:38 +0800)]
dt-bindings: net: wireless: mt76: add clock description for MT7986.

Add clocks and clock-names for MT7986.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921s: fix firmware download random fail
YN Chen [Sat, 28 May 2022 01:28:54 +0000 (09:28 +0800)]
mt76: mt7921s: fix firmware download random fail

To avoid racing problems in chip, mt7921s should reacquire drv-own after
firmware semaphore is released.

Fixes: 78b217580c509 ("mt76: mt7921s: fix bus hang with wrong privilege")
Signed-off-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: add PATCH_FINISH_REQ cmd response handling
YN Chen [Sat, 28 May 2022 01:28:53 +0000 (09:28 +0800)]
mt76: mt7921: add PATCH_FINISH_REQ cmd response handling

add new case to fetch the return value of PATCH_FINISH_REQ

Signed-off-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: add DBDC rxq handlings into mac_reset_work
Ryder Lee [Thu, 26 May 2022 09:08:55 +0000 (17:08 +0800)]
mt76: add DBDC rxq handlings into mac_reset_work

Enable/disable rx napi for DBDC.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add more ethtool stats
Ryder Lee [Thu, 26 May 2022 09:08:54 +0000 (17:08 +0800)]
mt76: mt7915: add more ethtool stats

Add channel time and MAC ready stats.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: introduce ACPI SAR config in tx power
Deren Wu [Fri, 20 May 2022 09:03:39 +0000 (17:03 +0800)]
mt76: mt7921: introduce ACPI SAR config in tx power

Add new function mt7921_set_tx_sar_pwr() to update SAR power from
.set_sar_specs and ACPI setting. Both settings would be merged into
mt76_freq_range_power for final tx power value.

Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: introduce ACPI SAR support
Deren Wu [Fri, 20 May 2022 09:03:38 +0000 (17:03 +0800)]
mt76: mt7921: introduce ACPI SAR support

In ACPI SAR enabled device, mt7921 should read power limit in ACPI config.
The limit value would be applied to regular tx power settings in mt76.

Two major functionalities added:
1. Get SAR power table through ACPI.
2. Read power in Dynamic/Geo SAR table for tx power limit.

Table note
MTDS: Dynamic SAR table
MTGS: Geo SAR table
MTCL: Country List table (for 6GHz support)

Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Quan Zhou <quan.zhou@mediatek.com>
Signed-off-by: Quan Zhou <quan.zhou@mediatek.com>
Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: add 6 GHz band support in mt76_sar_freq_ranges
Deren Wu [Fri, 20 May 2022 09:03:37 +0000 (17:03 +0800)]
mt76: add 6 GHz band support in mt76_sar_freq_ranges

Add new frequencies support in mt76_sar_freq_ranges[]
* 5945 - 6165
* 6165 - 6405
* 6405 - 6525
* 6525 - 6705
* 6705 - 6865
* 6865 - 7125

Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix endian bug in mt7915_rf_regval_set()
Dan Carpenter [Thu, 19 May 2022 13:57:22 +0000 (16:57 +0300)]
mt76: mt7915: fix endian bug in mt7915_rf_regval_set()

This code is supposed to set a u32 value, but casting will not work on
big endian systems.

Fixes: 0a17329ae9c1 ("mt76: mt7915: add debugfs knob for RF registers read/write")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt76x02u: fix possible memory leak in __mt76x02u_mcu_send_msg
Lorenzo Bianconi [Tue, 17 May 2022 16:37:07 +0000 (18:37 +0200)]
mt76: mt76x02u: fix possible memory leak in __mt76x02u_mcu_send_msg

Free the skb if mt76u_bulk_msg fails in __mt76x02u_mcu_send_msg routine.

Fixes: 4c89ff2c74e39 ("mt76: split __mt76u_mcu_send_msg and mt76u_mcu_send_msg routines")
Co-developed-by: Gergo Koteles <soyer@irl.hu>
Signed-off-by: Gergo Koteles <soyer@irl.hu>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix endianness in mt7915_rf_regval_get
Lorenzo Bianconi [Tue, 17 May 2022 16:05:59 +0000 (18:05 +0200)]
mt76: mt7915: fix endianness in mt7915_rf_regval_get

Fix the following sparse warning in mt7915_rf_regval_get routine:
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c:979:16: warning: cast to restricted __le32

Fixes: 0a17329ae9c1f ("mt76: mt7915: add debugfs knob for RF registers read/write")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agowifi: mac80211_hwsim: add back erroneously removed cast
Johannes Berg [Mon, 11 Jul 2022 11:14:24 +0000 (13:14 +0200)]
wifi: mac80211_hwsim: add back erroneously removed cast

The robots report that we're now casting to a differently
sized integer, which is correct, and the previous patch
had erroneously removed it.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: fix race condition in pending packet
Jeongik Cha [Mon, 4 Jul 2022 08:43:54 +0000 (17:43 +0900)]
wifi: mac80211_hwsim: fix race condition in pending packet

A pending packet uses a cookie as an unique key, but it can be duplicated
because it didn't use atomic operators.

And also, a pending packet can be null in hwsim_tx_info_frame_received_nl
due to race condition with mac80211_hwsim_stop.

For this,
 * Use an atomic type and operator for a cookie
 * Add a lock around the loop for pending packets

Signed-off-by: Jeongik Cha <jeongik@google.com>
Link: https://lore.kernel.org/r/20220704084354.3556326-1-jeongik@google.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: Use the bitmap API to allocate bitmaps
Christophe JAILLET [Mon, 4 Jul 2022 19:16:09 +0000 (21:16 +0200)]
wifi: mac80211: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/dfb438a6a199ee4c95081fa01bd758fd30e50931.1656962156.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: fix center freq calculation in ieee80211_chandef_downgrade
MeiChia Chiu [Fri, 8 Jul 2022 09:58:23 +0000 (17:58 +0800)]
wifi: mac80211: fix center freq calculation in ieee80211_chandef_downgrade

When mac80211 downgrades working bandwidth, the
center_freq and center_freq1 need to be recalculated.
There is a typo in the case of downgrading bandwidth from
320MHz to 160MHz which would cause a wrong frequency value.

Reviewed-by: Money Wang <Money.Wang@mediatek.com>
Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
Link: https://lore.kernel.org/r/20220708095823.12959-1-MeiChia.Chiu@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: fix sending link ID info of associated BSS
Veerendranath Jakkam [Fri, 8 Jul 2022 12:26:07 +0000 (17:56 +0530)]
wifi: nl80211: fix sending link ID info of associated BSS

commit dd374f84baec ("wifi: nl80211: expose link ID for associated
BSSes") used a top-level attribute to send link ID of the associated
BSS in the nested attribute NL80211_ATTR_BSS. But since NL80211_ATTR_BSS
is a nested attribute of the attributes defined in enum nl80211_bss,
define a new attribute in enum nl80211_bss and use it for sending the
link ID of the BSS.

Fixes: dd374f84baec ("wifi: nl80211: expose link ID for associated BSSes")
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20220708122607.1836958-1-quic_vjakkam@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: fix a comment in cfg80211_mlme_mgmt_tx()
Veerendranath Jakkam [Fri, 8 Jul 2022 16:55:44 +0000 (22:25 +0530)]
wifi: cfg80211: fix a comment in cfg80211_mlme_mgmt_tx()

A comment in cfg80211_mlme_mgmt_tx() is describing this API used only
for transmitting action frames. Fix the comment since
cfg80211_mlme_mgmt_tx() can be used to transmit any management frame.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://lore.kernel.org/r/20220708165545.2072999-1-quic_vjakkam@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: Fix reading NL80211_ATTR_MLO_LINK_ID in nl80211_pre_doit
Veerendranath Jakkam [Mon, 11 Jul 2022 05:34:43 +0000 (11:04 +0530)]
wifi: nl80211: Fix reading NL80211_ATTR_MLO_LINK_ID in nl80211_pre_doit

nl80211_pre_doit() using nla_get_u16() to read u8 attribute
NL80211_ATTR_MLO_LINK_ID. Fix this by using nla_get_u8() to
read NL80211_ATTR_MLO_LINK_ID attribute.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://lore.kernel.org/r/1657517683-5724-1-git-send-email-quic_vjakkam@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agoMerge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Kalle Valo [Fri, 8 Jul 2022 14:03:42 +0000 (17:03 +0300)]
Merge ath-next from git://git./linux/kernel/git/kvalo/ath.git

ath.git patches for v5.20. Major changes:

ath9k

* fix use-after-free in ath9k_hif_usb_rx_cb()

2 years agoath9k: remove unexpected words "the" in comments
Jiang Jian [Tue, 21 Jun 2022 08:02:40 +0000 (16:02 +0800)]
ath9k: remove unexpected words "the" in comments

there is unexpected word "the" in comments need to remove

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220621080240.42198-1-jiangjian@cdjrlc.com
2 years agoath11k: Fix typo in comments
Zhang Jiaming [Mon, 4 Jul 2022 03:00:04 +0000 (11:00 +0800)]
ath11k: Fix typo in comments

There is a typo(isn't') in comments.
It maybe 'isn't' instead of 'isn't''.

Signed-off-by: Zhang Jiaming <jiaming@nfschina.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220704030004.16484-1-jiaming@nfschina.com
2 years agowifi: nl80211: retrieve EHT related elements in AP mode
Aloka Dixit [Mon, 23 May 2022 06:49:04 +0000 (23:49 -0700)]
wifi: nl80211: retrieve EHT related elements in AP mode

Add support to retrieve EHT capabilities and EHT operation elements
passed by the userspace in the beacon template and store the pointers
in struct cfg80211_ap_settings to be used by the drivers.

Co-developed-by: Vikram Kandukuri <quic_vikram@quicinc.com>
Signed-off-by: Vikram Kandukuri <quic_vikram@quicinc.com>
Co-developed-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
Link: https://lore.kernel.org/r/20220523064904.28523-1-quic_alokad@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: Increase akm_suites array size in cfg80211_crypto_settings
Veerendranath Jakkam [Mon, 23 May 2022 13:25:58 +0000 (18:55 +0530)]
wifi: cfg80211: Increase akm_suites array size in cfg80211_crypto_settings

Increase akm_suites array size in struct cfg80211_crypto_settings to 10
and advertise the capability to userspace. This allows userspace to send
more than two AKMs to driver in netlink commands such as
NL80211_CMD_CONNECT.

This capability is needed for implementing WPA3-Personal transition mode
correctly with any driver that handles roaming internally. Currently,
the possible AKMs for multi-AKM connect can include PSK, PSK-SHA-256,
SAE, FT-PSK and FT-SAE. Since the count is already 5, increasing
the akm_suites array size to 10 should be reasonable for future
usecases.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://lore.kernel.org/r/1653312358-12321-1-git-send-email-quic_vjakkam@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: remove chandef check in cfg80211_cac_event()
Johannes Berg [Mon, 27 Jun 2022 10:49:03 +0000 (12:49 +0200)]
wifi: cfg80211: remove chandef check in cfg80211_cac_event()

The current check only worked for AP mode, but we can do
radar detection in mesh as well (for example). We could
try to check this using wdev_chandef(), but we also don't
really care since the chandef is passed in and we have no
need to use it anymore (since we added the argument in
commit d2859df5e7f0 ("cfg80211/mac80211: DFS setup chandef
for cac event")).

Change-Id: I856e4344d5e64ff4d2eead0b4c53b11f264be9b8
Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: relax wdev mutex check in wdev_chandef()
Johannes Berg [Mon, 27 Jun 2022 10:49:03 +0000 (12:49 +0200)]
wifi: nl80211: relax wdev mutex check in wdev_chandef()

In many cases we might get here from driver code that's
not really set up to care about the locking, and for the
non-MLO cases we really don't care so much about it. So
relax the checking here for now, perhaps we should even
remove it completely since we might not really care if
we point to an invalid link's chandef and can require
the caller to check the link validity first.

Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: acquire wdev mutex earlier in start_ap
Johannes Berg [Mon, 27 Jun 2022 10:49:03 +0000 (12:49 +0200)]
wifi: nl80211: acquire wdev mutex earlier in start_ap

We need to hold the wdev mutex already in order to call
nl80211_parse_tx_bitrate_mask(), so acquire it earlier.

Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: hold wdev mutex for tid config
Johannes Berg [Mon, 27 Jun 2022 10:43:37 +0000 (12:43 +0200)]
wifi: nl80211: hold wdev mutex for tid config

We need wdev_chandef() in this code, which now requires
the wdev mutex due to the per-link nature. Hold it here
to make sure we can access the link.

Reported-by: syzbot+b4e9aa0f32ffd9902442@syzkaller.appspotmail.com
Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: handle IBSS in channel switch
Johannes Berg [Mon, 27 Jun 2022 10:36:03 +0000 (12:36 +0200)]
wifi: cfg80211: handle IBSS in channel switch

Prior to commit 7b0a0e3c3a88 ("wifi: cfg80211: do some
rework towards MLO link APIs") the interface type didn't
really matter here, but now we need to handle all of the
possible cases. Add IBSS ("ADHOC") and handle it.

Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
Reported-by: syzbot+90d912872157e63589e4@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: properly skip link info driver update
Johannes Berg [Mon, 27 Jun 2022 10:28:31 +0000 (12:28 +0200)]
wifi: mac80211: properly skip link info driver update

If the interface isn't (yet) added to the driver, skip the
link info update. This was previously done for the BSS info
changes, but I forgot to copy the same check here.

Fixes: 7b7090b4c6a9 ("wifi: mac80211: split bss_info_changed method")
Reported-by: syzbot+bce2ca140cc00578ed07@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: only accumulate airtime deficit for active clients
Felix Fietkau [Sat, 25 Jun 2022 21:24:11 +0000 (23:24 +0200)]
wifi: mac80211: only accumulate airtime deficit for active clients

When a client does not generate any local tx activity, accumulating airtime
deficit for the round-robin scheduler can be harmful. If this goes on for too
long, the deficit could grow quite large, which might cause unreasonable
initial latency once the client becomes active

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-7-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add debugfs file to display per-phy AQL pending airtime
Felix Fietkau [Sat, 25 Jun 2022 21:24:10 +0000 (23:24 +0200)]
wifi: mac80211: add debugfs file to display per-phy AQL pending airtime

Now that the global pending airtime is more relevant for airtime fairness,
it makes sense to make it accessible via debugfs for debugging

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-6-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add a per-PHY AQL limit to improve fairness
Felix Fietkau [Sat, 25 Jun 2022 21:24:09 +0000 (23:24 +0200)]
wifi: mac80211: add a per-PHY AQL limit to improve fairness

In order to maintain fairness, the amount of queueing needs to be limited
beyond the simple per-station AQL budget, otherwise the driver can simply
repeatedly do scheduling rounds until all queues that have not used their
AQL budget become eligble.

To be conservative, use the high AQL limit for the first txq and add half
of the low AQL for each subsequent queue.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-5-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: keep recently active tx queues in scheduling list
Felix Fietkau [Sat, 25 Jun 2022 21:24:08 +0000 (23:24 +0200)]
wifi: mac80211: keep recently active tx queues in scheduling list

This allows proper deficit accounting to ensure that they don't carry their
deficit until the next time they become active

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-4-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: consider aql_tx_pending when checking airtime deficit
Felix Fietkau [Sat, 25 Jun 2022 21:24:07 +0000 (23:24 +0200)]
wifi: mac80211: consider aql_tx_pending when checking airtime deficit

When queueing packets for a station, deficit only gets added once the packets
have been transmitted, which could be much later. During that time, a lot of
temporary unfairness could happen, which could lead to bursty behavior.
Fix this by subtracting the aql_tx_pending when checking the deficit in tx
scheduling.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-3-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: make sta airtime deficit field s32 instead of s64
Felix Fietkau [Sat, 25 Jun 2022 21:24:06 +0000 (23:24 +0200)]
wifi: mac80211: make sta airtime deficit field s32 instead of s64

32 bit is more than enough range for the airtime deficit

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-2-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: switch airtime fairness back to deficit round-robin scheduling
Felix Fietkau [Sat, 25 Jun 2022 21:24:05 +0000 (23:24 +0200)]
wifi: mac80211: switch airtime fairness back to deficit round-robin scheduling

This reverts commits 6a789ba679d652587532cec2a0e0274fda172f3b and
2433647bc8d983a543e7d31b41ca2de1c7e2c198.

The virtual time scheduler code has a number of issues:
- queues slowed down by hardware/firmware powersave handling were not properly
  handled.
- on ath10k in push-pull mode, tx queues that the driver tries to pull from
  were starved, causing excessive latency
- delay between tx enqueue and reported airtime use were causing excessively
  bursty tx behavior

The bursty behavior may also be present on the round-robin scheduler, but there
it is much easier to fix without introducing additional regressions

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220625212411.36675-1-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: fix a kernel-doc complaint
Johannes Berg [Fri, 1 Jul 2022 08:42:40 +0000 (10:42 +0200)]
wifi: mac80211: fix a kernel-doc complaint

Somehow kernel-doc complains here about strong markup, but
we really don't need the [] so just remove that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: remove redundant documentation
Johannes Berg [Fri, 1 Jul 2022 08:36:36 +0000 (10:36 +0200)]
wifi: cfg80211: remove redundant documentation

These struct members no longer exist, remove them
from documentation.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: sta_info: fix a missing kernel-doc struct element
Mauro Carvalho Chehab [Tue, 28 Jun 2022 09:46:07 +0000 (10:46 +0100)]
wifi: mac80211: sta_info: fix a missing kernel-doc struct element

struct link_sta_info has now a cur_max_bandwidth data:

net/mac80211/sta_info.h:569: warning: Function parameter or member 'cur_max_bandwidth' not described in 'link_sta_info'

Copy the meaning from struct sta_info, documenting it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/37d898634bb30776442a33833c48cbb21c90ecc6.1656409369.git.mchehab@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add a missing comma at kernel-doc markup
Mauro Carvalho Chehab [Tue, 28 Jun 2022 09:46:06 +0000 (10:46 +0100)]
wifi: mac80211: add a missing comma at kernel-doc markup

The lack of the colon makes it not parse the function parameter:
include/net/mac80211.h:6250: warning: Function parameter or member 'vif' not described in 'ieee80211_channel_switch_disconnect'

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/11c1bdb861d89c93058fcfe312749b482851cbdb.1656409369.git.mchehab@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: fix kernel-doc warnings all over the file
Mauro Carvalho Chehab [Tue, 28 Jun 2022 09:46:05 +0000 (10:46 +0100)]
wifi: cfg80211: fix kernel-doc warnings all over the file

There are currently 17 kernel-doc warnings on this file:
include/net/cfg80211.h:391: warning: Function parameter or member 'bw' not described in 'ieee80211_eht_mcs_nss_supp'
include/net/cfg80211.h:437: warning: Function parameter or member 'eht_cap' not described in 'ieee80211_sband_iftype_data'
include/net/cfg80211.h:507: warning: Function parameter or member 's1g' not described in 'ieee80211_sta_s1g_cap'
include/net/cfg80211.h:1390: warning: Function parameter or member 'counter_offset_beacon' not described in 'cfg80211_color_change_settings'
include/net/cfg80211.h:1390: warning: Function parameter or member 'counter_offset_presp' not described in 'cfg80211_color_change_settings'
include/net/cfg80211.h:1430: warning: Enum value 'STATION_PARAM_APPLY_STA_TXPOWER' not described in enum 'station_parameters_apply_mask'
include/net/cfg80211.h:2195: warning: Function parameter or member 'dot11MeshConnectedToAuthServer' not described in 'mesh_config'
include/net/cfg80211.h:2341: warning: Function parameter or member 'short_ssid' not described in 'cfg80211_scan_6ghz_params'
include/net/cfg80211.h:3328: warning: Function parameter or member 'kck_len' not described in 'cfg80211_gtk_rekey_data'
include/net/cfg80211.h:3698: warning: Function parameter or member 'ftm' not described in 'cfg80211_pmsr_result'
include/net/cfg80211.h:3828: warning: Function parameter or member 'global_mcast_stypes' not described in 'mgmt_frame_regs'
include/net/cfg80211.h:4977: warning: Function parameter or member 'ftm' not described in 'cfg80211_pmsr_capabilities'
include/net/cfg80211.h:5742: warning: Function parameter or member 'u' not described in 'wireless_dev'
include/net/cfg80211.h:5742: warning: Function parameter or member 'links' not described in 'wireless_dev'
include/net/cfg80211.h:5742: warning: Function parameter or member 'valid_links' not described in 'wireless_dev'
include/net/cfg80211.h:6076: warning: Function parameter or member 'is_amsdu' not described in 'ieee80211_data_to_8023_exthdr'
include/net/cfg80211.h:6949: warning: Function parameter or member 'sig_dbm' not described in 'cfg80211_notify_new_peer_candidate'

Address them, in order to build a better documentation from this
header.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/f6f522cdc716a01744bb0eae2186f4592976222b.1656409369.git.mchehab@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: ieee80211: s1g action frames are not robust
Peter Chiu [Wed, 22 Jun 2022 01:08:20 +0000 (09:08 +0800)]
wifi: ieee80211: s1g action frames are not robust

S1g action frame with code 22 is not protected so update the robust
action frame list.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Link: https://lore.kernel.org/r/20220622010820.17522-1-chui-hao.chiu@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: rtw89: 8852a: rfk: fix div 0 exception
Ping-Ke Shih [Mon, 13 Jun 2022 06:51:44 +0000 (14:51 +0800)]
wifi: rtw89: 8852a: rfk: fix div 0 exception

The DPK is a kind of RF calibration whose algorithm is to fine tune
parameters and calibrate, and check the result. If the result isn't good
enough, it could adjust parameters and try again.

This issue is to read and show the result, but it could be a negative
calibration result that causes divisor 0 and core dump. So, fix it by
phy_div() that does division only if divisor isn't zero; otherwise,
zero is adopted.

  divide error: 0000 [#1] PREEMPT SMP NOPTI
  CPU: 1 PID: 728 Comm: wpa_supplicant Not tainted 5.10.114-16019-g462a1661811a #1 <HASH:d024 28>
  RIP: 0010:rtw8852a_dpk+0x14ae/0x288f [rtw89_core]
  RSP: 0018:ffffa9bb412a7520 EFLAGS: 00010246
  RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
  RDX: 0000000000000000 RSI: 00000000000180fc RDI: ffffa141d01023c0
  RBP: ffffa9bb412a76a0 R08: 0000000000001319 R09: 00000000ffffff92
  R10: ffffffffc0292de3 R11: ffffffffc00d2f51 R12: 0000000000000000
  R13: ffffa141d01023c0 R14: ffffffffc0290250 R15: ffffa141d0102638
  FS:  00007fa99f5c2740(0000) GS:ffffa142e5e80000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000000013e8e010 CR3: 0000000110d2c000 CR4: 0000000000750ee0
  PKRU: 55555554
  Call Trace:
   rtw89_core_sta_add+0x95/0x9c [rtw89_core <HASH:d239 29>]
   rtw89_ops_sta_state+0x5d/0x108 [rtw89_core <HASH:d239 29>]
   drv_sta_state+0x115/0x66f [mac80211 <HASH:81fe 30>]
   sta_info_insert_rcu+0x45c/0x713 [mac80211 <HASH:81fe 30>]
   sta_info_insert+0xf/0x1b [mac80211 <HASH:81fe 30>]
   ieee80211_prep_connection+0x9d6/0xb0c [mac80211 <HASH:81fe 30>]
   ieee80211_mgd_auth+0x2aa/0x352 [mac80211 <HASH:81fe 30>]
   cfg80211_mlme_auth+0x160/0x1f6 [cfg80211 <HASH:00cd 31>]
   nl80211_authenticate+0x2e5/0x306 [cfg80211 <HASH:00cd 31>]
   genl_rcv_msg+0x371/0x3a1
   ? nl80211_stop_sched_scan+0xe5/0xe5 [cfg80211 <HASH:00cd 31>]
   ? genl_rcv+0x36/0x36
   netlink_rcv_skb+0x8a/0xf9
   genl_rcv+0x28/0x36
   netlink_unicast+0x27b/0x3a0
   netlink_sendmsg+0x2aa/0x469
   sock_sendmsg_nosec+0x49/0x4d
   ____sys_sendmsg+0xe5/0x213
   __sys_sendmsg+0xec/0x157
   ? syscall_enter_from_user_mode+0xd7/0x116
   do_syscall_64+0x43/0x55
   entry_SYSCALL_64_after_hwframe+0x44/0xa9
  RIP: 0033:0x7fa99f6e689b

Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220613065144.15647-1-pkshih@realtek.com
2 years agowifi: rtw89: disable invalid phy reports for all ICs
Po-Hao Huang [Fri, 10 Jun 2022 07:26:10 +0000 (15:26 +0800)]
wifi: rtw89: disable invalid phy reports for all ICs

Previously we only disable invalid reports for 52A, since we plan to
support more ICs in the future, enable settings for those as well.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-12-pkshih@realtek.com
2 years agowifi: rtw89: pci: fix PCI doesn't reclaim TX BD properly
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:09 +0000 (15:26 +0800)]
wifi: rtw89: pci: fix PCI doesn't reclaim TX BD properly

TX BD (TX ring index) and TX WD (WiFi descriptor buffer) are freed
asynchronously. With burst packets, we free TX WD, but the corresponding
TX BD couldn't be freed yet. Then, TX can possibly get stuck due to no
more TX BD.

To avoid this, ignore reclaiming TX BD only if TX WD is no free space,
because at this moment TX BD must have some spaces. Otherwise, we reclaim
TX BD to resolve TX stuck issue.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-11-pkshih@realtek.com
2 years agowifi: rtw89: fix long RX latency in low power mode
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:08 +0000 (15:26 +0800)]
wifi: rtw89: fix long RX latency in low power mode

In low power mode, regular IO is power off, so we don't schedule napi to
poll RX and TX completion. Therefore, calling ieee80211_rx_napi() with
napi instance causes long RX latency. To fix this, use NULL as argument,
and then it can use netif_receive_skb_list() to receive.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-10-pkshih@realtek.com
2 years agowifi: rtw89: drop invalid TX rate report of legacy rate
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:07 +0000 (15:26 +0800)]
wifi: rtw89: drop invalid TX rate report of legacy rate

Somehow, firmware could report invalid TX rate, and we consider the
invalid rate as 0 that will make a wrong decision. So, drop invalid
reports, and also suppress the warning message.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-9-pkshih@realtek.com
2 years agowifi: rtw89: add UNEXP debug mask to keep monitor messages unexpected to happen frequ...
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:06 +0000 (15:26 +0800)]
wifi: rtw89: add UNEXP debug mask to keep monitor messages unexpected to happen frequently

Some warning messages could bother users. With proper handling, these
situations don't really affect usage, but we still need to keep monitor
these messages. If they happen frequently, we must review driver or
hardware design to clarify.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-8-pkshih@realtek.com
2 years agowifi: rtw89: enable VO TX AMPDU
Kuan-Chung Chen [Fri, 10 Jun 2022 07:26:05 +0000 (15:26 +0800)]
wifi: rtw89: enable VO TX AMPDU

To improve VO throughput, we enable VO TX AMPDU.

We measure the latency of enable or disable VO TX AMPDU. The experimental
results show that the difference between the two is insignificant only
300µs, so the little impact can be ignored for user experience.

Moreover, we found some APs will have a group key handshake timeout issue
when the EAPOL's TID is already setup BA session. Therefore, when
transmitting EAPOL, if EAPOL's TID BA session is already setup, we need
to delete it.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-7-pkshih@realtek.com
2 years agowifi: rtw89: fix potential TX stuck
Kuan-Chung Chen [Fri, 10 Jun 2022 07:26:04 +0000 (15:26 +0800)]
wifi: rtw89: fix potential TX stuck

The potential TX stuck occurs when there are lots of packets to be
transmitted and the boundary of the tx_resource is hit. Add this
patch to avoid the TX stuck when burst traffic.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-6-pkshih@realtek.com
2 years agowifi: rtw89: support TDLS
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:03 +0000 (15:26 +0800)]
wifi: rtw89: support TDLS

Since we can allocate MAC ID, BSSID and address CAM to TDLS peer, declare
we can support TDLS now.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-5-pkshih@realtek.com
2 years agowifi: rtw89: allocate BSSID CAM per TDLS peer
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:02 +0000 (15:26 +0800)]
wifi: rtw89: allocate BSSID CAM per TDLS peer

In STA mode, if peer is TDLS. Allocate a BSSID CAM entry with peer's
address to match address properly, and then hardware can ACK peer's
packets and receive packets to driver.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-4-pkshih@realtek.com
2 years agowifi: rtw89: separate BSSID CAM operations
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:01 +0000 (15:26 +0800)]
wifi: rtw89: separate BSSID CAM operations

Normally, we allocate a BSSID CAM to a vif. By hardware design, we must
allocate a BSSID CAM to each TDLS peer, so separate BSSID CAM operations
that will be used by later patches.

This patch doesn't change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-3-pkshih@realtek.com
2 years agowifi: rtw89: allocate address CAM and MAC ID to TDLS peer
Ping-Ke Shih [Fri, 10 Jun 2022 07:26:00 +0000 (15:26 +0800)]
wifi: rtw89: allocate address CAM and MAC ID to TDLS peer

Normally, we only allocate an address CAM and single one MAC ID to AP in
STA mode. To support TDLS, we handle TDLS peers like AP handles stations.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220610072610.27095-2-pkshih@realtek.com
2 years agowifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()
Alexey Kodanev [Wed, 8 Jun 2022 17:16:14 +0000 (20:16 +0300)]
wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()

As a result of the execution of the inner while loop, the value
of 'idx' can be equal to LINK_QUAL_MAX_RETRY_NUM. However, this
is not checked after the loop and 'idx' is used to write the
LINK_QUAL_MAX_RETRY_NUM size array 'lq_cmd->rs_table[idx]' below
in the outer loop.

The fix is to check the new value of 'idx' inside the nested loop,
and break both loops if index equals the size. Checking it at the
start is now pointless, so let's remove it.

Detected using the static analysis tool - Svace.

Fixes: be663ab67077 ("iwlwifi: split the drivers for agn and legacy devices 3945/4965")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220608171614.28891-1-aleksei.kodanev@bell-sw.com
2 years agocfg80211: Indicate MLO connection info in connect and roam callbacks
Veerendranath Jakkam [Wed, 8 Jun 2022 09:16:37 +0000 (14:46 +0530)]
cfg80211: Indicate MLO connection info in connect and roam callbacks

The MLO links used for connection with an MLD AP are decided by the
driver in case of SME offloaded to driver.

Add support for the drivers to indicate the information of links used
for MLO connection in connect and roam callbacks, update the connected
links information in wdev from connect/roam result sent by driver.
Also, send the connected links information to userspace.

Add a netlink flag attribute to indicate that userspace supports
handling of MLO connection. Drivers must not do MLO connection when this
flag is not set. This is to maintain backwards compatibility with older
supplicant versions which doesn't have support for MLO connection.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: print the link id
Shaul Triebitz [Tue, 14 Jun 2022 09:26:39 +0000 (12:26 +0300)]
wifi: mac80211_hwsim: print the link id

Print the link ID in link_info_changed function.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: support creating MLO-capable radios
Johannes Berg [Wed, 8 Jun 2022 12:23:39 +0000 (14:23 +0200)]
wifi: mac80211_hwsim: support creating MLO-capable radios

Add initial support to hwsim for creating MLO-capable
radios dynamically (and statically via module parameter,
but that's not really recommended.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: expose link ID for associated BSSes
Johannes Berg [Mon, 13 Jun 2022 14:52:02 +0000 (16:52 +0200)]
wifi: nl80211: expose link ID for associated BSSes

When retrieving scan data, expose not just whether or not the
interface (possibly an MLD) is associated to the BSS or not,
but also on which link ID if it is an MLD.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: expose link information for interfaces
Johannes Berg [Mon, 13 Jun 2022 14:51:27 +0000 (16:51 +0200)]
wifi: nl80211: expose link information for interfaces

When getting/dumping an interface, expose information about
valid links.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: send a beacon per link
Shaul Triebitz [Mon, 6 Jun 2022 17:03:17 +0000 (20:03 +0300)]
wifi: mac80211_hwsim: send a beacon per link

Add to hwsim a link_data structure.
For now, move the beacon interval and beacon timer to
the link_data structure (making them per link).
Set a beacon timer for each link and transmit a per
link beacon (pass the link_id to ieee80211_beacon_get).

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: set STA deflink addresses
Johannes Berg [Wed, 15 Jun 2022 09:50:00 +0000 (11:50 +0200)]
wifi: mac80211: set STA deflink addresses

We should set the STA deflink addresses in case no
link is really added.

Fixes: 046d2e7c50e3 ("mac80211: prepare sta handling for MLO support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: maintain link-sta hash table
Johannes Berg [Tue, 14 Jun 2022 11:07:42 +0000 (13:07 +0200)]
wifi: mac80211: maintain link-sta hash table

Maintain a hash table of link-sta addresses so we can find
them for management frames etc. where addresses haven't
been replaced by the drivers to the MLD address yet.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: RCU-ify link STA pointers
Johannes Berg [Wed, 15 Jun 2022 07:20:45 +0000 (09:20 +0200)]
wifi: mac80211: RCU-ify link STA pointers

We need to be able to access these in a race-free way under
traffic while adding/removing them, so RCU-ify the pointers.
This requires passing a link_sta to a lot of functions so
we don't have to do the RCU handling everywhere.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: ethtool: use deflink for now
Johannes Berg [Tue, 14 Jun 2022 11:22:49 +0000 (13:22 +0200)]
wifi: mac80211: ethtool: use deflink for now

Hardcoding link[0] is more confusing than using deflink,
so use deflink for now, which requires making the macro
a bit safer.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: move ieee80211_bssid_match() function
Johannes Berg [Tue, 14 Jun 2022 10:07:11 +0000 (12:07 +0200)]
wifi: mac80211: move ieee80211_bssid_match() function

This is only used in rx.c, so move it into the file.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: return a beacon for a specific link
Shaul Triebitz [Mon, 6 Jun 2022 11:25:54 +0000 (14:25 +0300)]
wifi: mac80211: return a beacon for a specific link

Pass the link id through to the get_beacon and return
the beacon for a specific link id.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: pass the link id in start/stop ap
Shaul Triebitz [Thu, 2 Jun 2022 12:08:16 +0000 (15:08 +0300)]
wifi: mac80211: pass the link id in start/stop ap

In start_ap and stop_ap mac80211 callbacks pass the link_id
to the drivers.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: use link in start/stop ap
Shaul Triebitz [Wed, 1 Jun 2022 09:55:14 +0000 (12:55 +0300)]
wifi: mac80211: use link in start/stop ap

Use link and link_conf according to the link_id
provided by cfg in start_ap/stop_ap and change_beacon.
Also use them in the functions called by them.
Note that for a non MLD device, the link_id is 0,
and link[0] and link_conf[0] equal to deflink and
bss_conf respectively (what was there before).

Also, call vif_info_change for BSS related changes (SSID), and
link_info_change for LINK related changes (instead of the
legacy bss_info_change).

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: implement add/del interface link callbacks
Johannes Berg [Fri, 10 Jun 2022 09:21:21 +0000 (11:21 +0200)]
wifi: mac80211: implement add/del interface link callbacks

When a link is added or removed via nl80211, these are
called. Implement them so we don't have to check in all
the different per-link commands whether we've already
created the necessary datastructures.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: add optional link add/remove callbacks
Johannes Berg [Fri, 10 Jun 2022 09:07:55 +0000 (11:07 +0200)]
wifi: cfg80211: add optional link add/remove callbacks

Add some optional callbacks for link add/remove so that
drivers can react here. Initially, I thought it would be
sufficient to just create the link in start_ap etc., but
it turns out that's not so simple, since there are quite
a few callbacks that can be called: if they're erroneously
without start_ap, things might crash.

Thus it might be easier for drivers to allocate all the
necessary data structures immediately, to not have to
worry about it in each callback, since cfg80211 checks
that the link ID is valid (has been added.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: sort trace.h
Johannes Berg [Fri, 10 Jun 2022 08:50:18 +0000 (10:50 +0200)]
wifi: cfg80211: sort trace.h

We wanted to have this sorted by direction (to/from driver),
but didn't maintain that well. Sort the file now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add sta link addition/removal
Johannes Berg [Tue, 31 May 2022 21:20:08 +0000 (23:20 +0200)]
wifi: mac80211: add sta link addition/removal

Add the necessary infrastructure, including a new driver
method, to add/remove links to/from a station. To do this,
refactor the link alloc/free a bit, splitting that so we
can do it without linking them, to handle failures better.

Note that a station entry must be created representing an
MLD or a non-MLD STA, it cannot change between the two.
When representing an MLD, the 'deflink' is used for the
first link, which might be removed later, in which case
the memory isn't reused.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add MLO link ID to TX frame metadata
Johannes Berg [Thu, 9 Jun 2022 20:05:07 +0000 (22:05 +0200)]
wifi: mac80211: add MLO link ID to TX frame metadata

Take a few bits out of the control.flags to add the link ID
to TX frame metadata, so drivers don't need to look it up
by the address themselves. Implement that lookup where it's
needed, for internal frame TX, and set it to "unspecified"
for data transmissions.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: remove band from TX info in MLO
Johannes Berg [Wed, 1 Jun 2022 13:59:31 +0000 (15:59 +0200)]
wifi: mac80211: remove band from TX info in MLO

If the interface is an MLD, then we don't know which band
the frame will be transmitted on, and we don't know how to
look up the band. Set the band information to zero in that
case, the driver cannot rely on it anyway.

No longer inline ieee80211_tx_skb_tid() since it's even
bigger now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add vif link addition/removal
Johannes Berg [Tue, 31 May 2022 21:20:08 +0000 (23:20 +0200)]
wifi: mac80211: add vif link addition/removal

Add the necessary infrastructure, including a new driver
method, to add/remove links to/from an interface.

Also add the missing link address to bss_conf (which we
use as link_conf too), and fill it, in station mode for
now just randomly, in AP mode we get the address from
cfg80211 since the link must be created with an address
first.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: support MLO in auth/assoc
Johannes Berg [Tue, 31 May 2022 17:48:33 +0000 (19:48 +0200)]
wifi: nl80211: support MLO in auth/assoc

For authentication, we need the BSS, the link_id and the AP
MLD address to create the link and station, (for now) the
driver assigns a link address and sends the frame, the MLD
address needs to be the address of the interface.

For association, pass the list of BSSes that were selected
for the MLO connection, along with extra per-STA profile
elements, the AP MLD address and the link ID on which the
association request should be sent.

Note that for now we don't have a proper way to pass the link
address(es) and so the driver/mac80211 will select one, but
depending on how that selection works it means that assoc w/o
auth data still being around (mac80211 implementation detail)
the association won't necessarily work - so this will need to
be extended in the future to sort out the link addressing.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: ignore IEEE80211_CONF_CHANGE_SMPS in chanctx mode
Johannes Berg [Wed, 8 Jun 2022 12:18:17 +0000 (14:18 +0200)]
wifi: mac80211: ignore IEEE80211_CONF_CHANGE_SMPS in chanctx mode

When channel contexts are used, IEEE80211_CONF_CHANGE_SMPS
doesn't make sense and doesn't apply (which is documented).
Mask it in this case.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: split bss_info_changed to vif/link info_changed
Shaul Triebitz [Mon, 6 Jun 2022 12:51:45 +0000 (15:51 +0300)]
wifi: mac80211_hwsim: split bss_info_changed to vif/link info_changed

Replace the bss_info_changed callback with vif_cfg_changed
and link_info_changed callbacks (for vif changes and link
changes).

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: simplify cfg80211_mlme_auth() prototype
Johannes Berg [Wed, 1 Jun 2022 20:42:28 +0000 (22:42 +0200)]
wifi: cfg80211: simplify cfg80211_mlme_auth() prototype

This function has far too many parameters now, move out
the BSS lookup and pass the request struct instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: ieee80211: add definitions for multi-link element
Johannes Berg [Tue, 31 May 2022 12:03:38 +0000 (14:03 +0200)]
wifi: ieee80211: add definitions for multi-link element

Add the definitions necessary to build and parse some of the
multi-link element, the per-STA profile isn't fully included.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: refactor BSS lookup in nl80211_associate()
Johannes Berg [Tue, 31 May 2022 16:31:19 +0000 (18:31 +0200)]
wifi: nl80211: refactor BSS lookup in nl80211_associate()

For MLO we'll need to do this multiple times, so refactor
this. For now keep the disconnect_bssid, but we'll need to
figure out how to handle that with MLD.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: mlme: get BSS entry outside cfg80211_mlme_assoc()
Johannes Berg [Tue, 31 May 2022 16:00:00 +0000 (18:00 +0200)]
wifi: cfg80211: mlme: get BSS entry outside cfg80211_mlme_assoc()

Today it makes more sense to pass the necessary parameters to
look up the BSS entry to cfg80211_mlme_assoc(), but with MLO
we will need to look up multiple, and that gets awkward. Pull
the lookup code into the callers so we can change it better.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: tx: simplify chanctx_conf handling
Johannes Berg [Wed, 1 Jun 2022 12:25:44 +0000 (14:25 +0200)]
wifi: mac80211: tx: simplify chanctx_conf handling

In ieee80211_build_hdr() we do the same thing for all
interface types except for AP_VLAN, but we can simplify
the code by pulling the common thing in front of the
switch and overriding it for AP_VLAN. This will also
simplify the code for MLD here later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: status: look up band only where needed
Johannes Berg [Wed, 1 Jun 2022 12:16:00 +0000 (14:16 +0200)]
wifi: mac80211: status: look up band only where needed

For MLD, we might eventually not really know the band on status,
but some code assumes it's there. Move the sband lookup deep to
the code that actually needs it, to make it clear where exactly
it's needed and for what purposes.

For rate control, at least initially we won't support it in MLO,
so that won't be an issue.

For TX monitoring, we may have to elide the rate and/or rely on
ieee80211_tx_status_ext() for rate information.

This also simplifies the function prototypes.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: sort trace.h file
Johannes Berg [Tue, 31 May 2022 21:06:19 +0000 (23:06 +0200)]
wifi: mac80211: sort trace.h file

This used to be sorted by driver methods, APIs and internal
functions, but got added to in the wrong sections. Fix that
by ordering the file properly again.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: correct link config data in tracing
Johannes Berg [Mon, 30 May 2022 22:02:33 +0000 (00:02 +0200)]
wifi: mac80211: correct link config data in tracing

We need to no longer use bss_conf here, but the per-link data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: make ieee80211_he_cap_ie_to_sta_he_cap() MLO-aware
Johannes Berg [Mon, 30 May 2022 21:52:41 +0000 (23:52 +0200)]
wifi: mac80211: make ieee80211_he_cap_ie_to_sta_he_cap() MLO-aware

Add the link_id parameter and adjust the code accordingly.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: make some SMPS code MLD-aware
Johannes Berg [Mon, 30 May 2022 21:45:04 +0000 (23:45 +0200)]
wifi: mac80211: make some SMPS code MLD-aware

Start making some SMPS related code MLD-aware. This isn't
really done yet, but again cuts down our 'deflink' reliance.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: HT: make ieee80211_ht_cap_ie_to_sta_ht_cap() MLO-aware
Johannes Berg [Mon, 30 May 2022 21:34:04 +0000 (23:34 +0200)]
wifi: mac80211: HT: make ieee80211_ht_cap_ie_to_sta_ht_cap() MLO-aware

Update ieee80211_ht_cap_ie_to_sta_ht_cap() to handle per-link
data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add link_id to eht.c code for MLO
Johannes Berg [Mon, 30 May 2022 21:22:19 +0000 (23:22 +0200)]
wifi: mac80211: add link_id to eht.c code for MLO

Update the code in eht.c and add the link_id parameter where
necessary.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add link_id to vht.c code for MLO
Johannes Berg [Mon, 30 May 2022 21:22:19 +0000 (23:22 +0200)]
wifi: mac80211: add link_id to vht.c code for MLO

Update the code in vht.c and add the link_id parameter where
necessary.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: refactor some link setup code
Johannes Berg [Mon, 30 May 2022 21:01:50 +0000 (23:01 +0200)]
wifi: mac80211: refactor some link setup code

We don't need to setup lists and work structs every time
we switch the interface type, factor that out into a new
ieee80211_link_init() function and use it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: validate some driver features for MLO
Johannes Berg [Mon, 30 May 2022 20:52:14 +0000 (22:52 +0200)]
wifi: mac80211: validate some driver features for MLO

If MLO is enabled by the driver then validate a set of
capabilities that mac80211 will initially not support
in MLO. This might change if features are implemented.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: use IEEE80211_MLD_MAX_NUM_LINKS
Johannes Berg [Mon, 30 May 2022 20:36:30 +0000 (22:36 +0200)]
wifi: mac80211: use IEEE80211_MLD_MAX_NUM_LINKS

Remove MAX_STA_LINKS and use IEEE80211_MLD_MAX_NUM_LINKS
instead to unify between the station and other data structures.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: refactor some sta_info link handling
Johannes Berg [Mon, 30 May 2022 19:31:37 +0000 (21:31 +0200)]
wifi: mac80211: refactor some sta_info link handling

Refactor the code a bit to initialize a link belonging
to a station, and (later) free all allocated links.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: remove sta_info_tx_streams()
Johannes Berg [Mon, 30 May 2022 19:28:31 +0000 (21:28 +0200)]
wifi: mac80211: remove sta_info_tx_streams()

The function is unused since commit 52b4810bed83 ("mac80211: Remove
support for changing AP SMPS mode") so we can just remove it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: make channel context code MLO-aware
Johannes Berg [Mon, 30 May 2022 16:35:23 +0000 (18:35 +0200)]
wifi: mac80211: make channel context code MLO-aware

Make the channel context code MLO aware, along with some
functions that it uses, so that the chan.c file is now
MLD-clean and no longer uses deflink/bss_conf/etc.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: pass link ID where already present
Johannes Berg [Mon, 30 May 2022 12:18:09 +0000 (14:18 +0200)]
wifi: mac80211: pass link ID where already present

In a few cases we already have the link ID in the APIs,
pass it already even if it cannot be non-zero yet.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>