platform/kernel/linux-starfive.git
23 months agowifi: wcn36xx: Move capability bitmap to string translation function to firmware.c
Bryan O'Donoghue [Wed, 27 Jul 2022 16:16:54 +0000 (17:16 +0100)]
wifi: wcn36xx: Move capability bitmap to string translation function to firmware.c

Move wcn36xx_get_cap_name() function in main.c into firmware.c as
wcn36xx_firmware_get_cap_name().

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220727161655.2286867-4-bryan.odonoghue@linaro.org
23 months agowifi: wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
Bryan O'Donoghue [Wed, 27 Jul 2022 16:16:53 +0000 (17:16 +0100)]
wifi: wcn36xx: Move firmware feature bit storage to dedicated firmware.c file

The naming of the get/set/clear firmware feature capability bits doesn't
really follow the established namespace pattern of
wcn36xx_logicalblock_do_something();

The feature bits are accessed by smd.c and main.c. It would be nice to
display the found feature bits in debugfs. To do so though we should tidy
up the namespace a bit.

Move the firmware feature exchange API to its own file - firmware.c giving
us the opportunity to functionally decompose other firmware related
accessors as appropriate in future.

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220727161655.2286867-3-bryan.odonoghue@linaro.org
23 months agowifi: wcn36xx: Rename clunky firmware feature bit enum
Bryan O'Donoghue [Wed, 27 Jul 2022 16:16:52 +0000 (17:16 +0100)]
wifi: wcn36xx: Rename clunky firmware feature bit enum

The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
be changed to something else.

Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
contents and intent of the enum is obvious.

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220727161655.2286867-2-bryan.odonoghue@linaro.org
23 months agowifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`
Ammar Faizi [Mon, 25 Jul 2022 17:49:11 +0000 (20:49 +0300)]
wifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`

Commit 7a4836560a61 changes simple_write_to_buffer() with memdup_user()
but it forgets to change the value to be returned that came from
simple_write_to_buffer() call. It results in the following warning:

  warning: variable 'rc' is uninitialized when used here [-Wuninitialized]
           return rc;
                  ^~

Remove rc variable and just return the passed in length if the
memdup_user() succeeds.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 7a4836560a6198d245d5732e26f94898b12eb760 ("wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()")
Fixes: ff974e4083341383d3dd4079e52ed30f57f376f0 ("wil6210: debugfs interface to send raw WMI command")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220724202452.61846-1-ammar.faizi@intel.com
23 months agoRevert "ath11k: add support for hardware rfkill for QCA6390"
Kalle Valo [Mon, 25 Jul 2022 17:49:10 +0000 (20:49 +0300)]
Revert "ath11k: add support for hardware rfkill for QCA6390"

This reverts commit ec038c6127fa772d2c5604e329f22371830d5fa6. Tyler reported
that on L390 Yoga Thinkpad with QCA6390 the suspend was failing because of this commit.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9

Link: https://bugzilla.kernel.org/show_bug.cgi?id=215881
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220708164656.29549-1-kvalo@kernel.org
23 months agowifi: ath11k: Fix register write failure on QCN9074
Manikanta Pubbisetty [Mon, 25 Jul 2022 17:49:10 +0000 (20:49 +0300)]
wifi: ath11k: Fix register write failure on QCN9074

Commit 56c8ccf331bd ("ath11k: Add register access logic for WCN6750")
regressed QCN9074. With the above mentioned commit, writes are failing
for some registers on QCN9074 although the device seems to work
normally.

ath11k_pci 0000:03:00.0: failed to set pcie link register0x01e0e0a8: 0xffffffff != 0x00000010
ath11k_pci 0000:03:00.0: failed to set sysclk: -110

PCIe devices in ath11k (QCA6390, WCN6855, QCN9074, WCN6750) use window
concept for register accesses. There are two schemes, dynamic & static
window.

In dynamic window scheme, a single window(region in the BAR) is mapped
either to CE or DP register windows at any give time. QCA6390 & WCN6855
follow this scheme for register accesses.

In static window scheme, CE & DP register windows are statically mapped
to separate regions with in the BAR so that there is no switching of
register windows between CE & DP register accesses. QCN9074 & WCN6750
follow this scheme although the window start offsets are different for
QCN9074 & WCN6750.

QCN9074 uses 3rd & 2nd window for DP & CE register accesses respectively
whereas WCN6750 uses 1st & 2nd window for DP & CE. In QCN9074, along with
2nd & 3rd windows, 1st window is also used for certain configurations
which commit 56c8ccf331bd ("ath11k: Add register access logic for WCN6750")
did not account for and hence the regression.

Fix this by going back to the original way of accessing the registers on
QCN9074. Since this diverges from WCN6750 way of accessing registers, it
is required to register window_read32/window_write32() pci_ops for WCN6750.
We can also get rid of dp_window_idx & ce_window_idx members in hw_params,
so remove them.

Also add a new API ath11k_pcic_register_pci_ops() for registering pci_ops
to the ath11k core. This API checks for mandatory pci_ops() and reports
error if those are missing. Also initialize unused pci_ops to NULL.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.6.0.1-00861-QCAHKSWPL_SILICONZ-1

Fixes: 56c8ccf331bd ("ath11k: Add register access logic for WCN6750")
Reported-by: Maxime Bizon <mbizon@freebox.fr>
Tested-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Manikanta Pubbisetty <quic_mpubbise@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220608062954.27792-1-quic_mpubbise@quicinc.com
23 months agoMerge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Kalle Valo [Mon, 25 Jul 2022 16:50:38 +0000 (19:50 +0300)]
Merge ath-next from git://git./linux/kernel/git/kvalo/ath.git

ath.git patches for v5.20. One fix and rest minor cleanup.

23 months agowifi: mac80211: fix link data leak
Johannes Berg [Fri, 22 Jul 2022 09:15:20 +0000 (11:15 +0200)]
wifi: mac80211: fix link data leak

During the code reshuffling, I accidentally set this to
NULL before using it, fix that to fix the link data leak.

Fixes: d3e2439b0f33 ("wifi: mac80211: fix link manipulation")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: mlme: fix disassoc with MLO
Johannes Berg [Fri, 22 Jul 2022 09:01:18 +0000 (11:01 +0200)]
wifi: mac80211: mlme: fix disassoc with MLO

In MLO we shouldn't call ieee80211_bss_info_change_notify(),
call that only (for backward compatibility) without MLO, and
otherwise ieee80211_vif_cfg_change_notify().

Similarly, ieee80211_reset_erp_info() only applies to the
current link, and in MLO we assume the driver doesn't really
need that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: add macros to loop over active links
Gregory Greenman [Tue, 12 Jul 2022 09:22:50 +0000 (12:22 +0300)]
wifi: mac80211: add macros to loop over active links

Add a preliminary version which will be updated later
to loop over vif's and sta's active links.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: remove erroneous sband/link validation
Johannes Berg [Thu, 21 Jul 2022 22:07:29 +0000 (00:07 +0200)]
wifi: mac80211: remove erroneous sband/link validation

In sta_apply_parameters(), we really no longer need to
check that the link or sband exists, in fact, that's
harmful if link 0 doesn't exist, since then this will
fail.

Just remove this check, it was added for validation of
the sband where used, but it's not used here, it's now
only used in sta_link_apply_parameters() which has an
own lookup and check.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: mlme: transmit assoc frame with address translation
Johannes Berg [Thu, 21 Jul 2022 21:35:21 +0000 (23:35 +0200)]
wifi: mac80211: mlme: transmit assoc frame with address translation

To transmit the association frame to the right station and
with address translation, use the correct addresses there
and set up the AP address in the configuration earlier so
it's applied during the transmit of auth/assoc frames.

Fixes: 81151ce462e5 ("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: verify link addresses are different
Johannes Berg [Thu, 21 Jul 2022 17:54:20 +0000 (19:54 +0200)]
wifi: mac80211: verify link addresses are different

When adding multiple links, verify that they all have
different addresses.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: rx: track link in RX data
Johannes Berg [Thu, 21 Jul 2022 11:08:13 +0000 (13:08 +0200)]
wifi: mac80211: rx: track link in RX data

We'll need the link e.g. for decrypt, and shouldn't be
looking it up all the time later, so track it in the RX
data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: optionally implement MLO multicast TX
Johannes Berg [Thu, 21 Jul 2022 08:56:48 +0000 (10:56 +0200)]
wifi: mac80211: optionally implement MLO multicast TX

For drivers using software encryption for multicast TX, such
as mac80211_hwsim, mac80211 needs to duplicate the multicast
frames on each link, if MLO is enabled. Do this, but don't
just make it dependent on the key but provide a separate flag
for drivers to opt out of this.

This is not very efficient, I expect that drivers will do it
in firmware/hardware or at least with DMA engine assistence,
so this is mostly for hwsim.

To make this work, also implement the SNS11 sequence number
space that an AP MLD shall have, and modify the API to the
__ieee80211_subif_start_xmit() function to always require the
link ID bits to be set.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: expand ieee80211_mgmt_tx() for MLO
Johannes Berg [Mon, 18 Jul 2022 19:36:08 +0000 (21:36 +0200)]
wifi: mac80211: expand ieee80211_mgmt_tx() for MLO

There are a couple of new things that should be possible
with MLO:
 * selecting the link to transmit to a station by link ID,
   which a previous patch added to the nl80211 API
 * selecting the link by frequency, similarly
 * allowing transmittion to an MLD without specifying any
   channel or link ID, with MLD addresses

Enable these use cases. Also fix the address comparison
in client mode to use the AP (MLD) address.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: nl80211: add MLO link ID to the NL80211_CMD_FRAME TX API
Johannes Berg [Mon, 18 Jul 2022 10:13:46 +0000 (12:13 +0200)]
wifi: nl80211: add MLO link ID to the NL80211_CMD_FRAME TX API

Allow optionally specifying the link ID to transmit on,
which can be done instead of the link frequency, on an
MLD addressed frame. Both can also be omitted in which
case the frame must be MLD addressed and link selection
(and address translation) will be done on lower layers.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: report link ID to cfg80211 on mgmt RX
Johannes Berg [Mon, 18 Jul 2022 08:42:19 +0000 (10:42 +0200)]
wifi: mac80211: report link ID to cfg80211 on mgmt RX

For frames received on an MLD, report the link ID to
userspace.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: cfg80211: report link ID in NL80211_CMD_FRAME
Johannes Berg [Mon, 18 Jul 2022 08:40:44 +0000 (10:40 +0200)]
wifi: cfg80211: report link ID in NL80211_CMD_FRAME

If given by the underlying driver, report the link ID for
MLO in NL80211_CMD_FRAME.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: add hardware timestamps for RX and TX
Avraham Stern [Wed, 26 Jan 2022 09:15:31 +0000 (11:15 +0200)]
wifi: mac80211: add hardware timestamps for RX and TX

When the low level driver reports hardware timestamps for frame
TX status or frame RX, pass the timestamps to cfg80211.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: cfg80211: add hardware timestamps to frame RX info
Avraham Stern [Thu, 27 Jan 2022 11:56:29 +0000 (13:56 +0200)]
wifi: cfg80211: add hardware timestamps to frame RX info

Add hardware timestamps to management frame RX info.
This shall be used by drivers that support hardware timestamping for
Timing measurement and Fine timing measurement action frames RX.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: cfg80211/nl80211: move rx management data into a struct
Avraham Stern [Sun, 30 Jan 2022 16:17:51 +0000 (18:17 +0200)]
wifi: cfg80211/nl80211: move rx management data into a struct

The functions for reporting rx management take many arguments.
Collect all the arguments into a struct, which also make it easier
to add more arguments if needed.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: cfg80211: add a function for reporting TX status with hardware timestamps
Avraham Stern [Wed, 26 Jan 2022 17:13:47 +0000 (19:13 +0200)]
wifi: cfg80211: add a function for reporting TX status with hardware timestamps

Add a function for reporting TX status with hardware timestamps. This
function shall be used for reporting the TX status of Timing
measurement and Fine timing measurement action frames by devices that
support reporting hardware timestamps.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: nl80211: add RX and TX timestamp attributes
Avraham Stern [Wed, 26 Jan 2022 14:06:35 +0000 (16:06 +0200)]
wifi: nl80211: add RX and TX timestamp attributes

Add attributes for reporting hardware timestamps for management frames
RX and TX. These attributes will be used for reporting hardware
timestamps for Timing measurement and Fine Timing Measurement action
frames, which will allow userspace applications to measure the path
delay between devices and sync clocks.

For TX, these attributes are used for reporting the frame RX time and
the ack TX time. For TX, they are used for reporting the frame TX time
and the ack RX time.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: ieee80211: add helper functions for detecting TM/FTM frames
Avraham Stern [Thu, 27 Jan 2022 12:39:46 +0000 (14:39 +0200)]
wifi: ieee80211: add helper functions for detecting TM/FTM frames

Add helper functions for detection timing measurement
and fine timing measurement frames.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211_hwsim: handle links for wmediumd/virtio
Johannes Berg [Wed, 20 Jul 2022 20:35:44 +0000 (22:35 +0200)]
wifi: mac80211_hwsim: handle links for wmediumd/virtio

For wmediumd/virtio, handle both the RX channel for links,
as well as the link addresses when links are added/removed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: sta_info: fix link_sta insertion
Johannes Berg [Tue, 19 Jul 2022 10:08:29 +0000 (12:08 +0200)]
wifi: mac80211: sta_info: fix link_sta insertion

When inserting a link STA, make sure it doesn't exist first
and add lockdep assertions that we cannot modify the hash
table without holding the sta_mtx, so this check is really
correct.

Also return without hashing if the driver failed, and warn
if the hashing fails, which shouldn't happen due to the
check described above.

Fixes: cb71f1d136a6 ("wifi: mac80211: add sta link addition/removal")
Fixes: ba6ddab94fc6 ("wifi: mac80211: maintain link-sta hash table")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: mlme: fix link_sta setup
Johannes Berg [Tue, 19 Jul 2022 10:06:17 +0000 (12:06 +0200)]
wifi: mac80211: mlme: fix link_sta setup

We need to copy the address to both the private and public
portion of the link_sta (the private one is needed for the
hash table). Fix this.

Fixes: bbe90107e1d9 ("wifi: mac80211: mlme: refactor link station setup")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: nl80211/mac80211: clarify link ID in control port TX
Johannes Berg [Tue, 19 Jul 2022 08:26:50 +0000 (10:26 +0200)]
wifi: nl80211/mac80211: clarify link ID in control port TX

Clarify the link ID behaviour in control port TX, we need it
to select the link to transmit on for both MLD and non-MLD
receivers, but select the link address as the SA only if the
receiver is not an MLD.

Fixes: 67207bab9341 ("wifi: cfg80211/mac80211: Support control port TX from specific link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: return error from control port TX for drops
Johannes Berg [Tue, 19 Jul 2022 07:37:59 +0000 (09:37 +0200)]
wifi: mac80211: return error from control port TX for drops

If the frame is going to be dropped anyway because
ieee80211_lookup_ra_sta() returned an error (and
even though it's a bit racy, it will likely continue
to do so), return the error out instead of just
silently dropping the frame.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: nl80211: require MLD address on link STA add/modify
Johannes Berg [Tue, 19 Jul 2022 06:44:25 +0000 (08:44 +0200)]
wifi: nl80211: require MLD address on link STA add/modify

We always need the MLD address and link ID to add or
modify the link STA, so require it in the API.

Fixes: 577e5b8c3924 ("wifi: cfg80211: add API to add/modify/remove a link station")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: more station handling sanity checks
Johannes Berg [Mon, 18 Jul 2022 21:01:19 +0000 (23:01 +0200)]
wifi: mac80211: more station handling sanity checks

Add more sanity checks to the API handling, we shouldn't
be able to create a station without links, nor should we
be able to add a link to a station that wasn't created as
an MLD with links in the first place.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: fix link sta hash table handling
Johannes Berg [Mon, 18 Jul 2022 20:54:27 +0000 (22:54 +0200)]
wifi: mac80211: fix link sta hash table handling

There are two issues here: we unhash the link stations only
directly before freeing the station they belong to, and we
also don't unhash all the links correctly in all cases. Fix
these issues.

Fixes: ba6ddab94fc6 ("wifi: mac80211: maintain link-sta hash table")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: validate link address doesn't change
Johannes Berg [Mon, 18 Jul 2022 20:23:53 +0000 (22:23 +0200)]
wifi: mac80211: validate link address doesn't change

When modifying a link station, validate that the link address
doesn't change, except the first time the link is created.

Fixes: b95eb7f0eee4 ("wifi: cfg80211/mac80211: separate link params from station params")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: mlme: set sta.mlo to mlo state
Johannes Berg [Mon, 18 Jul 2022 14:04:05 +0000 (16:04 +0200)]
wifi: mac80211: mlme: set sta.mlo to mlo state

At this point, we've already changed link_id to be zero for
a non-MLO connection, so use the 'mlo' variable rather than
link ID to determine the MLO status of the station.

Fixes: bd363ee53302 ("wifi: mac80211: mlme: set sta.mlo correctly")
Fixes: 81151ce462e5 ("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: fast-xmit: handle non-MLO clients
Johannes Berg [Mon, 18 Jul 2022 14:58:18 +0000 (16:58 +0200)]
wifi: mac80211: fast-xmit: handle non-MLO clients

If there's a non-MLO client, the A2 must be set to the BSSID
of the link since no translation will happen in lower layers
and it's needed that way for encryption.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211_hwsim: fix address translation for MLO
Johannes Berg [Mon, 18 Jul 2022 14:45:50 +0000 (16:45 +0200)]
wifi: mac80211_hwsim: fix address translation for MLO

There are two issues here: we need to do the translation
even in case mac80211 selected a link, and we should only
translate the A3 if it's the BSSID. Fix both.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: fix RX MLD address translation
Johannes Berg [Mon, 18 Jul 2022 14:40:36 +0000 (16:40 +0200)]
wifi: mac80211: fix RX MLD address translation

We should only translate addr3 here if it's the BSSID.

Fixes: 42fb9148c078 ("wifi: mac80211: do link->MLD address translation on RX")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: fix NULL pointer deref with non-MLD STA
Johannes Berg [Mon, 18 Jul 2022 07:14:30 +0000 (09:14 +0200)]
wifi: mac80211: fix NULL pointer deref with non-MLD STA

If we have a non-MLD STA on an AP MLD, we crash while
adding the station. Fix that, in this case we need to
use the STA's address also on the link data structure.

Fixes: f36fe0a2df03 ("wifi: mac80211: fix up link station creation/insertion")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: mlme: fix override calculation
Johannes Berg [Sun, 17 Jul 2022 16:16:51 +0000 (18:16 +0200)]
wifi: mac80211: mlme: fix override calculation

In my previous changes here, I neglected to take the old
conn_flags into account that might still be present from
the authentication, and thus ieee80211_setup_assoc_link()
can misbehave, as well as the override calculation being
wrong. Fix that by ORing in the old flags.

Fixes: 1845c1d4a455 ("wifi: mac80211: mlme: refactor assoc link setup")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: mac80211: tx: use AP address in some places for MLO
Johannes Berg [Fri, 15 Jul 2022 13:37:23 +0000 (15:37 +0200)]
wifi: mac80211: tx: use AP address in some places for MLO

In a few places we need to use the AP (MLD) address, not the
deflink BSSID, the link address translation will happen later.

To make that work properly for fast-xmit, set up the ap_addr
in the vif.cfg earlier.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 months agowifi: wl1251: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:34:05 +0000 (12:34 +0800)]
wifi: wl1251: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710043405.38304-1-yuanjilin@cdjrlc.com
23 months agowifi: rsi: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:30:07 +0000 (12:30 +0800)]
wifi: rsi: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710043007.33288-1-yuanjilin@cdjrlc.com
23 months agowifi: rtl8192se: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:25:46 +0000 (12:25 +0800)]
wifi: rtl8192se: fix repeated words in comments

Delete the redundant word 'not'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710042546.28504-1-yuanjilin@cdjrlc.com
23 months agowifi: rtlwifi: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:20:40 +0000 (12:20 +0800)]
wifi: rtlwifi: fix repeated words in comments

Delete the redundant words 'in' and 'scan'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710042040.22456-1-yuanjilin@cdjrlc.com
23 months agowifi: rt2x00: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:14:42 +0000 (12:14 +0800)]
wifi: rt2x00: fix repeated words in comments

Delete the redundant words 'is' and 'with'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710041442.16177-1-yuanjilin@cdjrlc.com
23 months agowifi: qtnfmac: fix repeated words in comments
Jilin Yuan [Sun, 10 Jul 2022 04:10:05 +0000 (12:10 +0800)]
wifi: qtnfmac: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220710041005.10950-1-yuanjilin@cdjrlc.com
23 months agowifi: iwlegacy: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:53:16 +0000 (21:53 +0800)]
wifi: iwlegacy: fix repeated words in comments

Delete the redundant words 'to' and 'if'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709135316.41425-1-yuanjilin@cdjrlc.com
23 months agowifi: ipw2x00: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:47:01 +0000 (21:47 +0800)]
wifi: ipw2x00: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709134701.36081-1-yuanjilin@cdjrlc.com
23 months agowifi: brcmsmac: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:42:07 +0000 (21:42 +0800)]
wifi: brcmsmac: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709134207.30856-1-yuanjilin@cdjrlc.com
23 months agowifi: brcmfmac: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:36:18 +0000 (21:36 +0800)]
wifi: brcmfmac: fix repeated words in comments

Delete the redundant words 'this' and 'and'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709133618.25958-1-yuanjilin@cdjrlc.com
23 months agowifi: b43: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:31:19 +0000 (21:31 +0800)]
wifi: b43: fix repeated words in comments

Delete the redundant word 'early'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709133119.21076-1-yuanjilin@cdjrlc.com
23 months agowifi: atmel: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:26:37 +0000 (21:26 +0800)]
wifi: atmel: fix repeated words in comments

Delete the redundant word 'long'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709132637.16717-1-yuanjilin@cdjrlc.com
23 months agowifi: mac80211: do not abuse fq.lock in ieee80211_do_stop()
Tetsuo Handa [Sun, 17 Jul 2022 12:21:52 +0000 (21:21 +0900)]
wifi: mac80211: do not abuse fq.lock in ieee80211_do_stop()

lockdep complains use of uninitialized spinlock at ieee80211_do_stop() [1],
for commit f856373e2f31ffd3 ("wifi: mac80211: do not wake queues on a vif
that is being stopped") guards clear_bit() using fq.lock even before
fq_init() from ieee80211_txq_setup_flows() initializes this spinlock.

According to discussion [2], Toke was not happy with expanding usage of
fq.lock. Since __ieee80211_wake_txqs() is called under RCU read lock, we
can instead use synchronize_rcu() for flushing ieee80211_wake_txqs().

Link: https://syzkaller.appspot.com/bug?extid=eceab52db7c4b961e9d6
Link: https://lkml.kernel.org/r/874k0zowh2.fsf@toke.dk
Reported-by: syzbot <syzbot+eceab52db7c4b961e9d6@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: f856373e2f31ffd3 ("wifi: mac80211: do not wake queues on a vif that is being stopped")
Tested-by: syzbot <syzbot+eceab52db7c4b961e9d6@syzkaller.appspotmail.com>
Acked-by: Toke Høiland-Jørgensen <toke@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/9cc9b81d-75a3-3925-b612-9d0ad3cab82b@I-love.SAKURA.ne.jp
23 months agowifi: p54: add missing parentheses in p54_flush()
Rustam Subkhankulov [Thu, 14 Jul 2022 13:48:31 +0000 (16:48 +0300)]
wifi: p54: add missing parentheses in p54_flush()

The assignment of the value to the variable total in the loop
condition must be enclosed in additional parentheses, since otherwise,
in accordance with the precedence of the operators, the conjunction
will be performed first, and only then the assignment.

Due to this error, a warning later in the function after the loop may
not occur in the situation when it should.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
Fixes: 0d4171e2153b ("p54: implement flush callback")
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220714134831.106004-1-subkhankulov@ispras.ru
23 months agowifi: mt7601u: fix clang -Wformat warning
Justin Stitt [Mon, 11 Jul 2022 21:29:32 +0000 (14:29 -0700)]
wifi: mt7601u: fix clang -Wformat warning

When building with Clang we encounter this warning:
| drivers/net/wireless/mediatek/mt7601u/debugfs.c:92:6: error: format
| specifies type 'unsigned char' but the argument has type 'int'
| [-Werror,-Wformat] dev->ee->reg.start + dev->ee->reg.num - 1);

The format specifier used is `%hhu` which describes a u8. Both
`dev->ee->reg.start` and `.num` are u8 as well. However, the expression
as a whole is promoted to an int as you cannot get smaller-than-int from
addition. Therefore, to fix the warning, use the promoted-to-type's
format specifier -- in this case `%d`.

example:
```
uint8_t a = 4, b = 7;
int size = sizeof(a + b - 1);
printf("%d\n", size);
// output: 4
```

See more:
(https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules)
"Integer types smaller than int are promoted when an operation is
performed on them. If all values of the original type can be represented
as an int, the value of the smaller type is converted to an int;
otherwise, it is converted to an unsigned int."

Signed-off-by: Justin Stitt <justinstitt@google.com>
Acked-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220711212932.1501592-1-justinstitt@google.com
23 months agowifi: mt7601u: eeprom: fix clang -Wformat warning
Justin Stitt [Sat, 9 Jul 2022 00:15:27 +0000 (17:15 -0700)]
wifi: mt7601u: eeprom: fix clang -Wformat warning

When building with Clang we encounter the following warning:
| drivers/net/wireless/mediatek/mt7601u/eeprom.c:193:5: error: format
| specifies type 'char' but the argument has type 'int' [-Werror,-Wformat]
| chan_bounds[idx].start + chan_bounds[idx].num - 1);

Variadic functions (printf-like) undergo default argument promotion.
Documentation/core-api/printk-formats.rst specifically recommends using
the promoted-to-type's format flag.

Moreover, C11 6.3.1.1 states:
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf) `If an int
can represent all values of the original type ..., the value is
converted to an int; otherwise, it is converted to an unsigned int.
These are called the integer promotions.`

With this information in hand, we really should stop using `%hh[dxu]` or
`%h[dxu]` as they usually prompt Clang -Wformat warnings as well as go
against documented standard recommendations.

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220709001527.618593-1-justinstitt@google.com
23 months agowifi: p54: Use the bitmap API to allocate bitmaps
Christophe JAILLET [Mon, 4 Jul 2022 13:02:55 +0000 (15:02 +0200)]
wifi: p54: 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>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/2755b8b7d85a2db0663d39ea6df823f94f3401b3.1656939750.git.christophe.jaillet@wanadoo.fr
23 months agowifi: p54: Fix an error handling path in p54spi_probe()
Christophe JAILLET [Sun, 12 Jun 2022 21:12:20 +0000 (23:12 +0200)]
wifi: p54: Fix an error handling path in p54spi_probe()

If an error occurs after a successful call to p54spi_request_firmware(), it
must be undone by a corresponding release_firmware() as already done in
the error handling path of p54spi_request_firmware() and in the .remove()
function.

Add the missing call in the error handling path and remove it from
p54spi_request_firmware() now that it is the responsibility of the caller
to release the firmware

Fixes: cd8d3d321285 ("p54spi: p54spi driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/297d2547ff2ee627731662abceeab9dbdaf23231.1655068321.git.christophe.jaillet@wanadoo.fr
23 months agoMerge tag 'mt76-for-kvalo-2022-07-11' of https://github.com/nbd168/wireless
Kalle Valo [Mon, 18 Jul 2022 11:31:59 +0000 (14:31 +0300)]
Merge tag 'mt76-for-kvalo-2022-07-11' of https://github.com/nbd168/wireless

mt76 patches for 5.20

- preparation for new chipset support
- fixes
- VHT/HE related improvements
- ACPI SAR support

[kvalo@kernel.org: fix mac80211 API changes in start_ap() and stop_ap()]

23 months agowifi: wcn36xx: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 12:43:56 +0000 (20:43 +0800)]
wifi: wcn36xx: fix repeated words in comments

Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220709124356.52543-1-yuanjilin@cdjrlc.com
23 months agowifi: wil6210: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 13:21:37 +0000 (21:21 +0800)]
wifi: wil6210: fix repeated words in comments

Delete the redundant word 'for'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220709132137.12442-1-yuanjilin@cdjrlc.com
23 months agowifi: ath: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 12:40:36 +0000 (20:40 +0800)]
wifi: ath: fix repeated words in comments

Delete the redundant word 'have'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220709124036.49674-1-yuanjilin@cdjrlc.com
23 months agowifi: ath6kl: fix repeated words in comments
Jilin Yuan [Sat, 9 Jul 2022 12:32:08 +0000 (20:32 +0800)]
wifi: ath6kl: fix repeated words in comments

Delete the redundant words 'the' and 'of'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220709123208.41736-1-yuanjilin@cdjrlc.com
23 months agowifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()
Dan Carpenter [Fri, 15 Jul 2022 10:35:18 +0000 (13:35 +0300)]
wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()

The simple_write_to_buffer() function will succeed if even a single
byte is initialized.  However, we need to initialize the whole buffer
to prevent information leaks.  Just use memdup_user().

Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/Ysg14NdKAZF/hcNG@kili
23 months agowifi: ath5k: fix repeated words in comments
Jilin Yuan [Fri, 15 Jul 2022 10:35:18 +0000 (13:35 +0300)]
wifi: ath5k: fix repeated words in comments

Delete the redundant word 'don't' and 'but'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220708154929.19199-1-yuanjilin@cdjrlc.com
23 months agowifi: ath11k: mac: fix long line
Kalle Valo [Fri, 15 Jul 2022 10:35:16 +0000 (13:35 +0300)]
wifi: ath11k: mac: fix long line

Recent mac80211 API changes introduced a long line warning in ath11k:

drivers/net/wireless/ath/ath11k/mac.c:1404: line length of 92 exceeds 90 columns

Compile tested only.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220708170052.28615-1-kvalo@kernel.org
2 years agowifi: mac80211: mlme: set sta.mlo correctly
Johannes Berg [Fri, 15 Jul 2022 13:11:50 +0000 (15:11 +0200)]
wifi: mac80211: mlme: set sta.mlo correctly

Due to some changes and rebasing between different patches
this fell through the cracks; we need to set sta.mlo if the
connection is using MLO.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: remove stray printk
Johannes Berg [Fri, 15 Jul 2022 13:04:41 +0000 (15:04 +0200)]
wifi: mac80211: remove stray printk

Unfortunately, a printk snuck into a previous patch,
remove it.

Fixes: 81151ce462e5 ("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: support MLO authentication/association with one link
Johannes Berg [Wed, 1 Jun 2022 19:17:34 +0000 (21:17 +0200)]
wifi: mac80211: support MLO authentication/association with one link

It might seem a bit pointless to do a multi-link operation
connection with just a single link, but this is already a
big change, so for now, limit MLO connections to a single
link.

Extending that to multiple links will require
 * work on parsing the multi-link element with STA profile
   properly, including element fragmentation;
 * checking the per-link status in the multi-link element
 * implementing logic to have active/inactive links to let
   drivers decide which links should be active;
 * implementing multicast RX deduplication;
 * and likely more.

For now this is still useful since it lets us do multi-link
connections for the purposes of testing APIs and the higher
layers such as wpa_supplicant.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add API to parse multi-link element
Johannes Berg [Thu, 30 Jun 2022 11:48:22 +0000 (13:48 +0200)]
wifi: mac80211: add API to parse multi-link element

Add the necessary API to parse the multi-link element in
the future. For now, link only to the element when found
so we can use it in the client-side code later.

Later, we'll need to fill this in to deal with element
fragmentation, parse the STA profile, etc.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: fix TX link selection
Johannes Berg [Thu, 14 Jul 2022 19:58:00 +0000 (21:58 +0200)]
wifi: mac80211_hwsim: fix TX link selection

Now that we have a pointer to the TX STA even when it's
not authenticated/... yet, fix the TX link selection in
hwsim to select only among the valid links for the STA,
requiring a STA pointer here. Also implement a simple
round-robin between links to make life more interesting.

While at it, also consider A3 when translating to link
addresses.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: use MLO link ID for TX
Andrei Otcheretianski [Tue, 14 Jun 2022 14:17:20 +0000 (17:17 +0300)]
wifi: mac80211_hwsim: use MLO link ID for TX

Use the link ID provided in TX frame metadata to select the correct
channel. For now, always select the link with the lowest link ID and
do some address translation.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: do rc update per link
Andrei Otcheretianski [Wed, 22 Jun 2022 13:11:43 +0000 (16:11 +0300)]
wifi: mac80211_hwsim: do rc update per link

Make mac80211_hwsim_sta_rc_update() iterate over all the STA links.

This is somewhat temporary, we really should add the link to the
API, but then hwsim still calls it internally and would need this.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: do link->MLD address translation on RX
Johannes Berg [Thu, 14 Jul 2022 21:47:32 +0000 (23:47 +0200)]
wifi: mac80211: do link->MLD address translation on RX

In some cases, e.g. with Qualcomm devices and management
frames, or in hwsim, frames may be reported from the driver
with link addresses, but for decryption and matching needs
we really want to have them with MLD addresses. Support the
translation on RX.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: select link when transmitting to non-MLO stations
Andrei Otcheretianski [Wed, 13 Jul 2022 09:05:27 +0000 (12:05 +0300)]
wifi: mac80211: select link when transmitting to non-MLO stations

When an MLO AP is transmitting to a non-MLO station, addr2 should be set
to a link address. This should be done before the frame is encrypted as
otherwise aad verification would fail. In case of software encryption
this can't be left for the device to handle, and should be done by
mac80211 when building the frame hdr.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: fix up link station creation/insertion
Johannes Berg [Thu, 14 Jul 2022 21:40:47 +0000 (23:40 +0200)]
wifi: mac80211: fix up link station creation/insertion

When we create a station with a non-default link, then
we should have a link address, and we definitely need
to insert it into the link hash table on insertion.

Split the API into with and without link creation and
if it has a link, insert the link into the link hash
table on sta_info_insert().

Fixes: ba6ddab94fc6 ("wifi: mac80211: maintain link-sta hash table")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211_hwsim: implement sta_state for MLO
Johannes Berg [Thu, 14 Jul 2022 20:23:02 +0000 (22:23 +0200)]
wifi: mac80211_hwsim: implement sta_state for MLO

In MLO, we need to transmit to another MLD and select
the link to it, which requires knowing the station.
But in TX, mac80211 will not give us a station that's
not added to the driver, which in the older add/remove
API is only done later.

Implement the new API in MLO so we know about the STA
at all times and get a pointer during TX as well.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: limit A-MSDU subframes for client too
Johannes Berg [Wed, 13 Jul 2022 16:08:03 +0000 (18:08 +0200)]
wifi: mac80211: limit A-MSDU subframes for client too

In AP/mesh where the stations are added by userspace, we
limit the number of A-MSDU subframes according to the
extended capabilities.

Refactor the code and extend that also to client-side.

Fixes: 506bcfa8abeb ("mac80211: limit the A-MSDU Tx based on peer's capabilities")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor ieee80211_set_associated()
Johannes Berg [Tue, 12 Jul 2022 20:18:24 +0000 (22:18 +0200)]
wifi: mac80211: mlme: refactor ieee80211_set_associated()

Split out much of the code in ieee80211_set_associated()
into a new ieee80211_link_set_associated() which can be
called per link later for MLO.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: cfg80211: add cfg80211_get_iftype_ext_capa()
Johannes Berg [Tue, 12 Jul 2022 16:32:49 +0000 (18:32 +0200)]
wifi: cfg80211: add cfg80211_get_iftype_ext_capa()

Add a helper function cfg80211_get_iftype_ext_capa() to
look up interface type-specific (extended) capabilities.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: look up beacon elems only if needed
Johannes Berg [Tue, 12 Jul 2022 15:21:22 +0000 (17:21 +0200)]
wifi: mac80211: mlme: look up beacon elems only if needed

If NEED_DTIM_BEFORE_ASSOC isn't set, then we don't need
to enter an RCU critical section and look up the beacon
elements.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor assoc link setup
Johannes Berg [Tue, 12 Jul 2022 13:21:23 +0000 (15:21 +0200)]
wifi: mac80211: mlme: refactor assoc link setup

Factor out the code to set up the assoc link into a
new function ieee80211_setup_assoc_link().

While at it, also modify the 'override' handling to
just take into account whether or not the conn_flags
were changed, which is what we need to setup again
the channel later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: remove address arg to ieee80211_mark_sta_auth()
Johannes Berg [Tue, 12 Jul 2022 13:13:23 +0000 (15:13 +0200)]
wifi: mac80211: mlme: remove address arg to ieee80211_mark_sta_auth()

There's no need to pass the address, we can look at the auth_data
inside the function rather than outside.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor assoc success handling
Johannes Berg [Tue, 12 Jul 2022 12:59:22 +0000 (14:59 +0200)]
wifi: mac80211: mlme: refactor assoc success handling

Refactor the per-link setup out of ieee80211_assoc_success()
into a new function ieee80211_assoc_config_link().

It looks useless for now to parse the elements again inside
ieee80211_assoc_config_link(), but that will be done with
the link ID in the future.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor ieee80211_prep_channel() a bit
Johannes Berg [Tue, 12 Jul 2022 12:48:55 +0000 (14:48 +0200)]
wifi: mac80211: mlme: refactor ieee80211_prep_channel() a bit

Refactor ieee80211_prep_channel() to make the link argument
optional and add a conn_flags pointer argument instead, so
that we can later use this for links that don't exist yet
to build the right information for MLO.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor assoc req element building
Johannes Berg [Tue, 12 Jul 2022 12:38:02 +0000 (14:38 +0200)]
wifi: mac80211: mlme: refactor assoc req element building

For MLO, we will need to build these elements per link, so
factor out the code that does this, returning the capability,
to simplify building the multi-link element in the future.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: switch some things back to deflink
Johannes Berg [Tue, 12 Jul 2022 11:46:19 +0000 (13:46 +0200)]
wifi: mac80211: mlme: switch some things back to deflink

With MLO, when we'll disconnect from an AP MLD, we'll just
destroy all the links. Therefore, the only thing we (may)
need to reset is the deflink data, so switch back to that
and adjust the comments accordingly.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: change flags in ieee80211_determine_chantype()
Johannes Berg [Tue, 12 Jul 2022 09:33:57 +0000 (11:33 +0200)]
wifi: mac80211: mlme: change flags in ieee80211_determine_chantype()

For MLO we'll need to read flags not directly from the link as
it may not even exist yet if we're just setting up flags for
a secondary link before sending the association request, so
pass the incoming conn_flags separately. Also, while at it,
pass the sdata/link separately as for non-tracking now the
link may be NULL.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: shift some code around
Johannes Berg [Tue, 12 Jul 2022 09:13:56 +0000 (11:13 +0200)]
wifi: mac80211: mlme: shift some code around

We'll need ieee80211_prep_channel() in other code for MLO
later, so move the code up - unchanged for now - to avoid
forward declarations in the future.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: refactor link station setup
Johannes Berg [Tue, 12 Jul 2022 09:06:33 +0000 (11:06 +0200)]
wifi: mac80211: mlme: refactor link station setup

Refactor the code here since we need to have it also for each
link station after association in MLO later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: move IEEE80211_SDATA_OPERATING_GMODE to link
Johannes Berg [Tue, 12 Jul 2022 08:49:23 +0000 (10:49 +0200)]
wifi: mac80211: move IEEE80211_SDATA_OPERATING_GMODE to link

The flag here is currently per interface, but the way we
set and clear it means it should be per link, so change
it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: make ieee80211_check_rate_mask() link-aware
Johannes Berg [Mon, 11 Jul 2022 13:13:20 +0000 (15:13 +0200)]
wifi: mac80211: make ieee80211_check_rate_mask() link-aware

Change ieee80211_check_rate_mask() to use a link rather than
the sdata and deflink/bss_conf.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: add multi-link element to AUTH frames
Johannes Berg [Tue, 12 Jul 2022 11:38:07 +0000 (13:38 +0200)]
wifi: mac80211: add multi-link element to AUTH frames

When sending an authentication frame from an MLD, include
the multi-link element with the MLD address and use the
link address for transmission.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: mlme: clean up supported channels element code
Johannes Berg [Tue, 12 Jul 2022 11:40:02 +0000 (13:40 +0200)]
wifi: mac80211: mlme: clean up supported channels element code

Clean up the code building the supported channels element
a little bit by using a local variable instead of the long
line.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: release channel context on link stop
Johannes Berg [Tue, 12 Jul 2022 11:36:37 +0000 (13:36 +0200)]
wifi: mac80211: release channel context on link stop

When a link is stopped for removal, release the channel
context it may have.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: mac80211: prohibit DEAUTH_NEED_MGD_TX_PREP in MLO
Johannes Berg [Tue, 12 Jul 2022 11:35:54 +0000 (13:35 +0200)]
wifi: mac80211: prohibit DEAUTH_NEED_MGD_TX_PREP in MLO

For now, prohibit DEAUTH_NEED_MGD_TX_PREP since we can't
really transmit this on a specific link yet as we don't
know which links are active.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: fix some attribute policy entries
Johannes Berg [Tue, 12 Jul 2022 15:33:13 +0000 (17:33 +0200)]
wifi: nl80211: fix some attribute policy entries

The new NL80211_CMD_ADD_LINK_STA and NL80211_CMD_MODIFY_LINK_STA
commands have strict policy validation, so fix the policy so it
can be validated correctly.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: reject fragmented and non-inheritance elements
Johannes Berg [Mon, 11 Jul 2022 12:18:18 +0000 (14:18 +0200)]
wifi: nl80211: reject fragmented and non-inheritance elements

The underlying mac80211 code cannot deal with fragmented
elements for purposes of sorting the elements into the
association frame, so reject those inside the link. We
might want to reject them inside the assoc frame, but
they're used today for FILS, so cannot do that.

The non-inheritance element inside the links similarly
cannot be handled by mac80211, and outside the links it
makes no sense.

Reject both since using them could lead to an incorrect
implementation.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agowifi: nl80211: reject link specific elements on assoc link
Johannes Berg [Mon, 11 Jul 2022 09:53:20 +0000 (11:53 +0200)]
wifi: nl80211: reject link specific elements on assoc link

When we associate, we'll include all the elements for the
link we're sending the association request on in the frame
and the specific ones for other links in the multi-link
element container. Prohibit adding link-specific elements
for the association link.

Fixes: d648c23024bd ("wifi: nl80211: support MLO in auth/assoc")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>