Colin Ian King [Wed, 20 Sep 2023 12:12:40 +0000 (13:12 +0100)]
wifi: rt2x00: remove redundant check if u8 array element is less than zero
The check on vga_gain[ch_idx] being less than zero is always false since
vga_gain is a u8 array. Clean up the code by removing the check and the
following assignment. Cleans up clang scan build warning:
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:9704:26: warning:
result of comparison of unsigned expression < 0 is always
false [-Wtautological-unsigned-zero-compare]
Johannes Berg [Mon, 25 Sep 2023 15:25:10 +0000 (17:25 +0200)]
wifi: mac80211: split ieee80211_drop_unencrypted_mgmt() return value
This has many different reasons, split the return value into
the individual reasons for better traceability. Also, since
symbolic tracing doesn't work for these, add a few comments
for the numbering.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Mon, 25 Sep 2023 15:24:39 +0000 (17:24 +0200)]
wifi: mac80211: fix check for unusable RX result
If we just check "result & RX_DROP_UNUSABLE", this really only works
by accident, because SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE got to
have the value 1, and SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR is 2.
Fix this to really check the entire subsys mask for the value, so it
doesn't matter what the subsystem value is.
Fixes: 7f4e09700bdc ("wifi: mac80211: report all unusable beacon frames") Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Introduce new feature flags for OWE offload that driver can
advertise to indicate kernel/application space to avoid DH IE
handling. When this flag is advertised, the driver/device will
take care of DH IE inclusion and processing of peer DH IE to
generate PMK.
Johannes Berg [Thu, 21 Sep 2023 08:58:08 +0000 (11:58 +0300)]
wifi: iwlwifi: mvm: support injection antenna control
Pull up the injection rate control one layer, and let it
control the antenna settings as well. Since mac80211 has
already checked that enough antennas are configured, and
we only have two bits, it's enough to just copy the data
over.
Johannes Berg [Thu, 21 Sep 2023 08:58:07 +0000 (11:58 +0300)]
wifi: iwlwifi: mvm: refactor TX rate handling
Refactor the injection and other frame TX rate handling
to always return the injection rate directly, by factoring
the legay rate portion out into a new function called in
the two relevant places (injection and non-injection).
Johannes Berg [Thu, 21 Sep 2023 08:58:05 +0000 (11:58 +0300)]
wifi: iwlwifi: fail NIC access fast on dead NIC
If the NIC is already dead, as detected by the transport then
there's no point to try to grab the NIC access and time out,
we can just fail fast. This may speed up recovery.
wifi: iwlwifi: mvm: add support for new wowlan_info_notif
This new version of wolan_info_notif supports the handling
of bigtk during d3, this patch holds parsing of the new
notif version, adding new keys and updating ipn of
existing keys during the resume flow.
Johannes Berg [Thu, 21 Sep 2023 08:58:03 +0000 (11:58 +0300)]
wifi: iwlwifi: pcie: (re-)assign BAR0 on driver bind
There's a race with runtime PM getting enabled by userspace:
- we rescan the PCI bus
- this creates the new PCI device including its sysfs
representation
- udev sees the new device, and the (OS-specific?) scripting
enables runtime PM by writing to power/control; this can
happen _before_ the next step - this will runtime-suspend
the device which saves the config space, including the BAR0
that wasn't assigned yet
- the bus rescan assigns resources to the devices and writes
them to the config space of the device
(but not the runtime-pm saved copy)
- the driver binds and this disallows runtime PM, so the device
is resumed, restoring the (incomplete!) config space
- the driver cannot work due to BAR0 not being configured
Fixing the actual race is hard and deep in the PCI layer,
though probably should be done for upstream as well; perhaps
runtime PM should only be allowed after resource assignment,
or some other TBD way.
Work around this in the driver for now by simply (re-)assigning
BAR0 when the driver initializes, if it's unset.
wifi: iwlwifi: implement enable/disable for China 2022 regulatory
China 2022 regulations are enabled by default. Disable only when
disabled in BIOS or the firmware don't support this capability. If the
firmware has this capability, read BIOS configuration data in
function 4 using ACPI API and send GRP_REGULATORY_LARI_CONFIG_CHANGE_CMD
to the firmware. Any error while reading BIOS data results in enablement
of china 2022 regulations.
Johannes Berg [Thu, 21 Sep 2023 08:58:01 +0000 (11:58 +0300)]
wifi: iwlwifi: mvm: handle link-STA allocation in restart
During HW restart, STA link changes happen while the link-sta is
already allocated (had been prior to the restart). Adjust the
allocation and checks to handle that.
set_antenna() is supported only when the device is not started in
mac80211 which translates to the firmware not being loaded in iwlwifi.
The tricky part is that iwlwifi populates the sband data during its boot
and doesn't touch this data afterwards, but if the antenna settings
forbid MIMO, we need to update the sband data.
Rework the nvm parsing code to allow to get an existing nvm_data and
modify the sband with additional constraints (tx / rx chains masks).
Benjamin Berg [Wed, 20 Sep 2023 18:25:29 +0000 (21:25 +0300)]
wifi: mac80211: reject MLO channel configuration if not supported
Reject configuring a channel for MLO if either EHT is not supported or
the BSS does not have the correct ML element. This avoids trying to do
a multi-link association with a misconfigured AP.
Benjamin Berg [Wed, 20 Sep 2023 18:25:28 +0000 (21:25 +0300)]
wifi: mac80211: report per-link error during association
With this cfg80211 can report the link that caused the error to
userspace which is then able to react to it by e.g. removing the link
from the association and retrying.
Benjamin Berg [Wed, 20 Sep 2023 18:25:27 +0000 (21:25 +0300)]
wifi: cfg80211: report per-link errors during association
When one of the links (other than the assoc_link) is misconfigured
and cannot work the association will fail. However, userspace was not
able to tell that the operation only failed because of a problem with
one of the links. Fix this, by allowing the driver to set a per-link
error code and reporting the (first) offending link by setting the
bad_attr accordingly.
This only allows us to report the first error, but that is sufficient
for userspace to e.g. remove the offending link and retry.
Johannes Berg [Wed, 20 Sep 2023 18:25:26 +0000 (21:25 +0300)]
wifi: mac80211: support antenna control in injection
Support antenna control for injection by parsing the antenna
radiotap field (which may be presented multiple times) and
telling the driver about the resulting antenna bitmap. Of
course there's no guarantee the driver will actually honour
this, just like any other injection control.
If misconfigured, i.e. the injected HT/VHT MCS needs more
chains than antennas are configured, the bitmap is reset to
zero, indicating no selection.
For now this is only set up for two anntenas so we keep more
free bits, but that can be trivially extended if any driver
implements support for it that can deal with hardware with
more antennas.
wifi: mac80211: support handling of advertised TID-to-link mapping
Support handling of advertised TID-to-link mapping elements received
in a beacon.
These elements are used by AP MLD to disable specific links and force
all clients to stop using these links.
By default if no TID-to-link mapping is advertised, all TIDs shall be
mapped to all links.
Johannes Berg [Wed, 20 Sep 2023 18:25:15 +0000 (21:25 +0300)]
wifi: mac80211: relax RCU check in for_each_vif_active_link()
To iterate the vif links we don't necessarily need to be in an
RCU critical section, it's also possible to hold the sdata/wdev
mutex. Annotate for_each_vif_active_link() accordingly.
wifi: mac80211: don't connect to an AP while it's in a CSA process
Connection to an AP that is running a CSA flow may end up with a
failure as the AP might change its channel during the connection
flow while we do not track the channel change yet.
Avoid that by rejecting a connection to such an AP.
Johannes Berg [Mon, 25 Sep 2023 06:56:38 +0000 (08:56 +0200)]
wifi: cfg80211: split struct cfg80211_ap_settings
Using the full struct cfg80211_ap_settings for an update is
misleading, since most settings cannot be updated. Split the
update case off into a new struct cfg80211_ap_update.
Change-Id: I3ba4dd9280938ab41252f145227a7005edf327e4 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Tue, 19 Sep 2023 06:40:52 +0000 (08:40 +0200)]
wifi: mac80211: ethtool: always hold wiphy mutex
Drivers should really be able to rely on the wiphy mutex
being held all the time, unless otherwise documented. For
ethtool, that wasn't quite right. Fix and clarify this in
both code and documentation.
Reported-by: syzbot+c12a771b218dcbba32e1@syzkaller.appspotmail.com Fixes: 0e8185ce1dde ("wifi: mac80211: check wiphy mutex in ops") Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Zong-Zhe Yang [Wed, 20 Sep 2023 07:43:22 +0000 (15:43 +0800)]
wifi: rtw89: load TX power related tables from FW elements
The following FW elements are recognized, and then the valid entries
in them are loaded into SW struct case by case.
* TX power by rate
* TX power limit 2 GHz
* TX power limit 5 GHz
* TX power limit 6 GHz
* TX power limit RU 2 GHz
* TX power limit RU 5 GHz
* TX power limit RU 6 GHz
* TX shape limit
* TX shape limit RU
One single firmware file can contain multiples of each of the above FW
elements. Each of them is configured with a target RFE (RF front end)
type. We choose one of the multiples to load based on RFE type. If there
are multiples of the same FW elements with the same target RFE type. The
last one will be applied.
We don't want to have many loading variants for above FW elements. Even if
between different chips or between different generations, we would like to
maintain only one single set of loadings. So, the loadings are designed to
consider compatibility. The main concepts are listed below.
* The driver structures, which are used to cast binary entry from FW,
cannot insert new members in the middle. If there are something new,
they should always be appended at the tail.
* Each binary entry from FW uses a dictionary way containing a key set
and a data. The keys in the key set indicate where to put the data.
* If size of driver struct and size of binary entry do not match when
loading, it means the number of keys in the key set are different.
Then, we deal with compatibility. No matter which one has more keys,
we take/use zero on those mismatched keys.
If driver struct is bigger (backward compatibility):
e.g. SW uses two keys, but FW is built with one key.
Then, put the data of FW(keyX) into SW[keyX][0].
If binary entry is bigger (forward compatibility):
e.g. FW is built with two keys, but SW uses one key.
Then, only take the data of FW(keyX, keyY = 0) into SW[keyX]
Besides, chip info setup flow is tweaked a bit for the following.
* Before loading FW elements, we need to determine chip RFE via efuse.
* Setting up RFE parameters depends on loading FW elements ahead.
Zong-Zhe Yang [Wed, 20 Sep 2023 07:43:21 +0000 (15:43 +0800)]
wifi: rtw89: phy: extend TX power common stuffs for Wi-Fi 7 chips
The following are introduced for Wi-Fi 7 chips.
1. take BW/OFDMA into account on TX power by rate
2. increase TX power offset types up to EHT
3. split TX shape into tx_shape_lmt and tx_shape_lmt_ru
If functions which are only for AX, they always access TX power by rate
with BW/OFDMA = 0/0, and they don't access tx_shape's lmt_ru section.
Zong-Zhe Yang [Wed, 20 Sep 2023 07:43:20 +0000 (15:43 +0800)]
wifi: rtw89: load TX power by rate when RFE parms setup
Table of TX power by rate only needs to be loaded once. But, we originally
loaded it every time we start core. Now, we load it one time along as RFE
(RF Front End) parameters are determined.
Zong-Zhe Yang [Wed, 20 Sep 2023 07:43:19 +0000 (15:43 +0800)]
wifi: rtw89: phy: refine helpers used for raw TX power
Originally, these helpers were implemented by macros. We rewrite them
by normal functions. In the new function to seek raw TX power by rate,
we access the array according to rate section and discard the original
pointer arithmetic.
Zong-Zhe Yang [Wed, 20 Sep 2023 07:43:18 +0000 (15:43 +0800)]
wifi: rtw89: indicate TX power by rate table inside RFE parameter
For next-generation chips, TX power by rate table comes from RFE (RF
front end) parameter. It can be different according to RFE type. So,
we indicate TX power by rate table inside RFE parameter ahead. For
current chips, even with different RFE types, a chip is configured
with a single TX power by rate table. So, this commit doesn't really
affect these currently supported chips.
For next-generation chips, TX shape table comes from RFE (RF front end)
parameter. It can be different according to RFE type. So, we indicate
TX shape table inside RFE parameter ahead. For current chips, even with
different RFE types, a chip is configured with a single TX shape table.
So, this commit doesn't really affect these currently supported chips.
wifi: rtw89: add subband index of primary channel to struct rtw89_chan
The subband index is a hardware value of relationship between primary
channel and bandwidth, and it is used by setting channel/bandwidth to
specify the primary channel.
Because this index is only needed when bandwidth >= 20 MHz, adjust
order of enumerator bandwidth to access offsets array easier. To prevent
misuse RTW89_CHANNEL_WIDTH_NUM as size, change it to
RTW89_CHANNEL_WIDTH_ORDINARY_NUM that will be the size of array. The
enumerator values of bandwidth (before ordinary number) will be also
used by upcoming TX power table built in firmware file, so add a comment
to remind keeping the order.
Since 'mwifiex_write_reg()' just issues void 'iowrite32()',
convert the former to 'void' and simplify all related users
(with the only exception of 'read_poll_timeout()' which
explicitly requires a non-void function argument).
Found by Linux Verification Center (linuxtesting.org) with SVACE.
wifi: ipw2x00: Annotate struct libipw_txb with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct libipw_txb.
Cc: Stanislav Yakovlev <stas.yakovlev@gmail.com> Cc: Kalle Valo <kvalo@kernel.org> Cc: linux-wireless@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230915200602.never.582-kees@kernel.org
wifi: wilc1000: add back-off algorithm to balance tx queue packets
Add an algorithm to backoff the Tx Task when low memory scenario is
triggered at firmware. During high data transfer from host, the firmware
runs out of VMM memory, which is used to hold the frames from the host.
So, adding the flow control delays the transmit from host side when
there is not enough space to accommodate frames in firmware side.
wifi: brcmfmac: firmware: Annotate struct brcmf_fw_request with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct brcmf_fw_request.
wifi: brcmfmac: Annotate struct brcmf_gscan_config with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct brcmf_gscan_config.
Cc: Arend van Spriel <aspriel@gmail.com> Cc: Franky Lin <franky.lin@broadcom.com> Cc: Hante Meuleman <hante.meuleman@broadcom.com> Cc: Kalle Valo <kvalo@kernel.org> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: Hector Martin <marcan@marcan.st> Cc: Ryohei Kondo <ryohei.kondo@cypress.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: SHA-cyfmac-dev-list@infineon.com Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230915200542.never.417-kees@kernel.org
wifi: wlcore: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.
wlcore_remove() returned zero unconditionally. With that converted to
return void instead, the wl12xx and wl18xx driver can be converted to
.remove_new trivially.
wifi: rtw89: consolidate registers of mac port to struct
MAC port is a design to support virtual interface on single MAC hardware.
For next generation chips, register addresses are changed but definitions
are the same, so move registers together to be easier to reuse codes.
wifi: rtw89: add to fill TX descriptor for firmware command v2
This kind of TX descriptor is used to download firmware or send firmware
command. Because we want to reduce descriptor overhead and this only needs
two fields 'size' and 'type', hardware designers choose short form of
RX descriptor for it.
RX descriptor is used to provide meta data of received data. The WiFi 7
chips use different RX descriptor format, so add this parser along with
hardware design.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:45 +0000 (11:11 +0800)]
wifi: rtw89: mcc: deal with beacon NoA if GO exists
In MCC STA+GO mode, we calculate NoA information and fill it into the
beacon of P2P GO. Since NoA uses only 32 bits to describe time things,
we need to deal with renewal when TSF[63:32] is carried. We trigger FW
to notify that. Then, we can update NoA information for new time period
once we get notification from FW.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:44 +0000 (11:11 +0800)]
wifi: rtw89: mcc: deal with BT slot change
When receiving request of adjusting BT slot from coex. mechanism,
we need to fetch the new BT slot and use the new one to calculate
MCC (multi-channel concurrency) pattern. Then, we update the new
MCC pattern to FW.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:43 +0000 (11:11 +0800)]
wifi: rtw89: mcc: deal with P2P PS change
MCC fills duration limit of a role according to NoA description.
If P2P PS changes during MCC, we don't process P2P PS via normal
flow. Instead, we re-fill duration limit of the role for new NoA
description, and then we do MCC update.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:42 +0000 (11:11 +0800)]
wifi: rtw89: mcc: track beacon offset and update when needed
In MCC STA+GC mode, the offset between TBTTs of remote AP and remote GO
might change. If the change is larger than tolerance, we should update
MCC after re-calculating parameters for new things. So, we track that in
rtw89_track_work() now. And, we add MCC update flow to tell FW either to
change durations of roles or to replace entire pattern according to how
MCC plans BT slot.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:41 +0000 (11:11 +0800)]
wifi: rtw89: mcc: update role bitmap when changed
Each MCC (multi-channel concurrency) role maintains a bitmap of mac IDs.
The bitmap is supposed to contain the two points below.
* mac ID of itself
* mac ID(s) of STA(s) connecting to it
Under STA+GC mode, the bitmaps of both roles should not change. However,
under STA+GO mode, the bitmap of GO may change due to P2P clients which
connect/disconnect to/from it.
FW controls (TDMA-based) MCC things via mac IDs in bitmap of each role.
For example, mac IDs are required by FW when it wants to pause role1's
TX in role0 slot.
So, to sync between driver and FW, we update the new mac ID bitmap of GO
to FW once it's changed.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:40 +0000 (11:11 +0800)]
wifi: rtw89: 52c: rfk: disable DPK during MCC
DPK is one kind of RF calibration. When MCC (multi-channel concurrency)
start/stop, DPK needs to do extra things to be off/on. We add a chanctx
callback type, RTW89_CHANCTX_CALLBACK_RFK, and register it for RTL8852C
to deal with DPK according to MCC states.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:39 +0000 (11:11 +0800)]
wifi: rtw89: rfk: disable driver tracking during MCC
After MCC (multi-channel concurrency) is started, FW will control channel
changes and use the corresponding backup of RF calibration result. And,
driver RF calibration (RF-K) won't be able to keep up with the speed at
which the channels are changing. So, even if we keep tracking it in driver,
the RF-K result might not be good either. To save these unnecessary things,
we disable driver RF-K tracking during MCC.
Zong-Zhe Yang [Fri, 8 Sep 2023 03:11:38 +0000 (11:11 +0800)]
wifi: rtw89: 52c: rfk: refine MCC channel info notification
RF calibration will notify FW to backup the calibration result after it
is done on a channel. For MCC (multi-channel concurrency) flow, when we
at RTW89_ENTITY_MODE_MCC_PREPARE mode, RF calibration should execute on
second channel of MCC, i.e. RTW89_SUB_ENTITY_1, and then, notify FW to
backup the result for the second one.
Originally, the RF calibration flow only fit single channel case. We are
planning to support MCC on RTL8852C, so we refine its RF calibration flow
to fit MCC case.
Jeff Johnson [Thu, 31 Aug 2023 18:22:57 +0000 (11:22 -0700)]
wifi: cw1200: Avoid processing an invalid TIM IE
While converting struct ieee80211_tim_ie::virtual_map to be a flexible
array it was observed that the TIM IE processing in cw1200_rx_cb()
could potentially process a malformed IE in a manner that could result
in a buffer over-read. Add logic to verify that the TIM IE length is
large enough to hold a valid TIM payload before processing it.
Wen Gong [Thu, 14 Sep 2023 08:20:26 +0000 (04:20 -0400)]
wifi: cfg80211: save power spectral density(psd) of regulatory rule
6 GHz regulatory domains introduces Power Spectral Density (PSD).
The PSD value of the regulatory rule should be taken into effect
for the ieee80211_channels falling into that particular regulatory
rule. Save the values in the channel which has PSD value and add
nl80211 attributes accordingly to handle it.
Co-developed-by: Aditya Kumar Singh <quic_adisi@quicinc.com> Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> Signed-off-by: Wen Gong <quic_wgong@quicinc.com> Link: https://lore.kernel.org/r/20230914082026.3709-1-quic_wgong@quicinc.com
[use hole in chan flags, reword docs] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Thu, 14 Sep 2023 07:13:10 +0000 (09:13 +0200)]
wifi: cfg80211: fix kernel-doc for wiphy_delayed_work_flush()
Now that I fixed the function name, we see the parameters
are wrong as well. Fix that too.
Change-Id: I1a4cfea446875998a5a242ca36acc8244991a199 Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Stephen Douthit [Mon, 13 Feb 2023 20:40:24 +0000 (15:40 -0500)]
wifi: mac80211: Sanity check tx bitrate if not provided by driver
If the driver doesn't fill NL80211_STA_INFO_TX_BITRATE in sta_set_sinfo()
then as a fallback sta->deflink.tx_stats.last_rate is used. Unfortunately
there's no guarantee that this has actually been set before it's used.
Originally found when 'iw <dev> link' would always return a tx rate of
6Mbps regardless of actual link speed for the QCA9337 running firmware
WLAN.TF.2.1-00021-QCARMSWP-1 in my netbook.
Use the sanity check logic from ieee80211_fill_rx_status() and refactor
that to use the new inline function.
wifi: iwlwifi: no power save during transition to D3
Transition to d3 is much faster if there is no power save during the
transition. Therefore a new flag was added to the device power cmd to
indicate the power save isn't allowed until the transition is completed.
Set this flag in _iwl_mvm_suspend, when the transition begins.
If the firmware crashes in the de-activation / re-activation
of the link during CSA, we will not have a valid phy_ctxt
pointer in mvmvif. This is a legit case, but when mac80211
removes the station to cleanup our state during the
re-configuration, we need to make sure we clear ap_sta
otherwise we won't re-add the station after the firmware has
been restarted. Later on, we'd activate the link, try to send
a TLC command crash again on ASSERT 3508.
Currently we are setting the rate in the tx cmd for
mgmt frames (e.g. during connection establishment).
This was problematic when sending mgmt frames in eSR mode,
as we don't know what link this frame will be sent on
(This is decided by the FW), so we don't know what is the
lowest rate.
Fix this by not setting the rate in tx cmd and rely
on FW to choose the right one.
Set rate only for injected frames with fixed rate,
or when no sta is given.
Also set for important frames (EAPOL etc.) the High Priority flag.
wifi: iwlwifi: mvm: enable FILS DF Tx on non-PSC channel
If the channel bandwidth is greater or equal than 80MHz,
enable FILS DF transmittion, even if the control channel is non-PSC.
That's because that in 80MHz there must be a sub 20MHz PSC
channel, and since the FILS DF is duplicated on all sub 20MHz
channels, within the 80MHz (hence it will be sent on a PSC channel).
Also, if FILS DF Tx is enabled, always configure the firmware
with the actual channel bandwidth, even before there is a connected
client (rather than the minimum bandwidth e.g. 20MHz), since FILS
DF transmission on a PSC channel take presedent over power
consumption.
Johannes Berg [Wed, 13 Sep 2023 11:56:43 +0000 (14:56 +0300)]
wifi: iwlwifi: mvm: make "pldr_sync" mode effective
If the device initialized with ME active, this would indeed
work, since the NVM information would be obtained from ME.
However, in the much more likely case that ME isn't active
and the firmware takes actions requiring the sync, this was
not working correctly when the firmware is only run at init
to obtain NVM data, since mac80211 isn't even initialized.
Fix this by moving the 'pldr_sync' handling to a different
place.
Johannes Berg [Wed, 13 Sep 2023 11:56:39 +0000 (14:56 +0300)]
wifi: iwlwifi: pcie: enable TOP fatal error interrupt
Enable the TOP (HW part) fatal error interrupt and add a
print when it happens. Currently FW always adds also the
SW error interrupt, but for >= Bz we'll need to do PLDR
in case this is asserted, so leave a TODO item already.
Johannes Berg [Wed, 13 Sep 2023 11:56:38 +0000 (14:56 +0300)]
wifi: iwlwifi: pcie: give up mem read if HW is dead
If the hardware is not responding, as indicated by (currently)
five consecutive HW errors during reading, then just give up
and fail, rather than attempting forever and forever for this
to not return any useful data anyway.
Even though we no longer completely deadlock the machine if it
takes a long time, we still make it pretty much unusable since
we'll eventually hold the RTNL while waiting for this process
to finish.
Johannes Berg [Wed, 13 Sep 2023 11:56:37 +0000 (14:56 +0300)]
wifi: iwlwifi: pcie: rescan bus if no parent
If the bus has no parent due to the topology, the device rescan
(after some kind of reset was detected) wouldn't work. On the
other hand, some platforms appear to require scanning the parent,
though it's not clear why.
However if there's no parent, then we skip the rescan, which isn't a
good idea. Change the code to go to the parent only if that exists,
and rescan the bus itself where it doesn't.
wifi: cfg80211: export DFS CAC time and usable state helper functions
cfg80211 has cfg80211_chandef_dfs_usable() function to know whether
at least one channel in the chandef is in usable state or not. Also,
cfg80211_chandef_dfs_cac_time() function is there which tells the CAC
time required for the given chandef.
Make these two functions visible to drivers by exporting their symbol
to global list of kernel symbols.
Lower level drivers can make use of these two functions to be aware
if CAC is required on the given chandef and for how long. For example
drivers which maintains the CAC state internally can make use of these.
Abhishek Kumar [Thu, 29 Jun 2023 03:52:54 +0000 (03:52 +0000)]
wifi: cfg80211: call reg_call_notifier on beacon hints
Currently the channel property updates are not propagated to
driver. This causes issues in the discovery of hidden SSIDs and
fails to connect to them.
This change defines a new wiphy flag which when enabled by vendor
driver, the reg_call_notifier callback will be trigger on beacon
hints. This ensures that the channel property changes are visible
to the vendor driver. The vendor changes the channels for active
scans. This fixes the discovery issue of hidden SSID.
wifi: cfg80211: allow reg update by driver even if wiphy->regd is set
Currently regulatory update by driver is not allowed when the
wiphy->regd is already set and drivers_request->intersect is false.
During wiphy registration, some drivers (ath10k does this currently)
first register the world regulatory to cfg80211 using
wiphy_apply_custom_regulatory(). The driver then obtain the current
operating country and tries to update the correct regulatory to
cfg80211 using regulatory_hint().
But at this point, wiphy->regd is already set to world regulatory.
Also, since this is the first request from driver after the world
regulatory is set this will result in drivers_request->intersect
set to false. In this condition the driver request regulatory is not
allowed to update to cfg80211 in reg_set_rd_driver(). This restricts
the device operation to the world regulatory.
This driver request to update the regulatory with current operating
country is valid and should be updated to cfg80211. Hence allow
regulatory update by driver even if the wiphy->regd is already set
and driver_request->intersect is false.
Aloka Dixit [Thu, 27 Jul 2023 17:40:59 +0000 (10:40 -0700)]
wifi: nl80211: additions to NL80211_CMD_SET_BEACON
FILS discovery and unsolicited broadcast probe response templates
need to be updated along with beacon templates in some cases such as
the channel switch operation. Add the missing implementation.
Aloka Dixit [Thu, 27 Jul 2023 17:40:58 +0000 (10:40 -0700)]
wifi: cfg80211: modify prototype for change_beacon
Modify the prototype for change_beacon() in struct cfg80211_op to
accept cfg80211_ap_settings instead of cfg80211_beacon_data so that
it can process data in addition to beacons.
Modify the prototypes of ieee80211_change_beacon() and driver specific
functions accordingly.
Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com> Link: https://lore.kernel.org/r/20230727174100.11721-4-quic_alokad@quicinc.com
[while at it, remove pointless "if (info)" check in tracing that just
makes all the lines longer than they need be - it's never NULL] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Aloka Dixit [Thu, 27 Jul 2023 17:40:57 +0000 (10:40 -0700)]
wifi: mac80211: fixes in FILS discovery updates
FILS discovery configuration gets updated only if the maximum interval
is set to a non-zero value, hence there is no way to reset this value
to 0 once set. Replace the check for interval with a new flag which is
set only if the configuration should be updated.
Add similar changes for the unsolicited broadcast probe response handling.
Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com> Link: https://lore.kernel.org/r/20230727174100.11721-3-quic_alokad@quicinc.com
[move NULL'ing to else branch to not have intermediate NULL visible] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Aloka Dixit [Thu, 27 Jul 2023 17:40:56 +0000 (10:40 -0700)]
wifi: nl80211: fixes to FILS discovery updates
Add a new flag 'update' which is set to true during start_ap()
if (and only if) one of the following two conditions are met:
- Userspace passed an empty nested attribute which indicates that
the feature should be disabled and templates deleted.
- Userspace passed all the parameters for the nested attribute.
Existing configuration will not be changed while the flag
remains false.
Add similar changes for unsolicited broadcast probe response
transmission.
Tom Rix [Wed, 17 May 2023 12:33:10 +0000 (08:33 -0400)]
wifi: lib80211: remove unused variables iv32 and iv16
clang with W=1 reports
net/wireless/lib80211_crypt_tkip.c:667:7: error: variable 'iv32'
set but not used [-Werror,-Wunused-but-set-variable]
u32 iv32 = tkey->tx_iv32;
^
This variable not used so remove it.
Then remove a similar iv16 variable.
Change the comment because the unmodified value is returned.
Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/r/20230517123310.873023-1-trix@redhat.com
[change commit log wrt. 'length', add comment in the code] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg [Tue, 29 Aug 2023 10:17:44 +0000 (12:17 +0200)]
wifi: mac80211: remove shifted rate support
We really cannot even get into this as we can't have
a BSS with a 5/10 MHz (scan) width, and therefore all
the code handling shifted rates cannot happen. Remove
it all, since it's broken anyway, at least with MLO.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>