Wen Gong [Thu, 11 Jan 2024 13:56:58 +0000 (15:56 +0200)]
wifi: ath11k: save max transmit power in vdev start response event from firmware
Save the max transmit power received in the vdev start response event from
firmware. A subsequent patch will use this to calculate the final power
value for WMI_VDEV_SET_TPC_POWER_CMDID.
Wen Gong [Thu, 11 Jan 2024 13:56:58 +0000 (15:56 +0200)]
wifi: ath11k: update regulatory rules when connect to AP on 6 GHz band for station
When station connect to AP on 6 GHz band, it needs switch the regulatory
rules according to the regulatory info sub field in HE operation element.
Switch to the power type which AP used for station interface.
Wen Gong [Thu, 11 Jan 2024 13:56:57 +0000 (15:56 +0200)]
wifi: ath11k: update regulatory rules when interface added
There are two power types for 6 GHz regulatory, one is AP, another
is client.
When firmware boots up, WMI_REG_CHAN_LIST_CC_EXT_EVENTID is sent from
firmware at an early stage, the interface mode is not decided at
this point, then ath11k select reg rules of AP type as default.
After interface is created, it is exactly decided the interface
type such as AP/mesh point/station. Then ath11k need to update
reg rules to the exact power type matched to the interface type.
The client power type is used for station interface, and AP power
type is used for AP/mesh point interface.
Baochen Qiang [Thu, 11 Jan 2024 13:56:57 +0000 (15:56 +0200)]
wifi: ath11k: fix a possible dead lock caused by ab->base_lock
spin_lock()/spin_unlock() are used in ath11k_reg_chan_list_event() to
acquire/release ab->base_lock. For now this is safe because that
function is only called in soft IRQ context.
But ath11k_reg_chan_list_event() will be called from process
context in an upcoming patch, and this can result in a deadlock if
ab->base_lock is acquired in process context and then soft IRQ occurs
on the same CPU and tries to acquire that lock.
Fix it by using spin_lock_bh() and spin_unlock_bh() instead.
Wen Gong [Thu, 11 Jan 2024 13:56:57 +0000 (15:56 +0200)]
wifi: ath11k: store cur_regulatory_info for each radio
The regulatory info of WMI_REG_CHAN_LIST_CC_EXT_EVENTID is not saved
in ath11k now, the info should be saved in ath11k. Save the info for
each radio and support switch regulatory rules dynamically.
As mac.c will also call ath11k_reg_handle_chan_list() in next patches move the
function to reg.c.
Wen Gong [Thu, 11 Jan 2024 13:56:57 +0000 (15:56 +0200)]
wifi: ath11k: add support to select 6 GHz regulatory type
There are 3 types of regulatory rules for AP mode and 6 type for
station mode. Add wmi_vdev_type and ieee80211_ap_reg_power to
select the exact reg rules.
Since 'ath12k_wmi_tlv_parse_alloc()' always operates on 'skb->data,
skb->len' tuple, it may be simplified to pass the only 'skb' argument
instead (which implies refactoring of 'ath12k_pull_bcn_tx_status_ev()',
'ath12k_pull_chan_info_ev()' and 'ath12k_pull_pdev_temp_ev()' in the
same way). This is an ath12k counterpart of the recently submitted
ath11k patch and compile tested only as well.
Jeff Johnson [Sun, 17 Dec 2023 17:26:46 +0000 (09:26 -0800)]
wifi: ath12k: Make QMI message rules const
Commit ff6d365898d4 ("soc: qcom: qmi: use const for struct
qmi_elem_info") allows QMI message encoding/decoding rules
to be const, so do that for ath12k.
Baochen Qiang [Sun, 17 Dec 2023 11:29:04 +0000 (13:29 +0200)]
wifi: ath12k: support default regdb while searching board-2.bin for WCN7850
Sometimes board-2.bin does not have the regdb data which matches the
parameters such as vendor, device, subsystem-vendor, subsystem-device
etc. Add default regdb data with only 'bus=%s' into board-2.bin for
WCN7850, then ath12k uses 'bus=pci' to search regdb data in board-2.bin
for WCN7850.
[ 46.114895] ath12k_pci 0000:03:00.0: boot using board name 'bus=pci,vendor=17cb,device=1107,subsystem-vendor=17cb,subsystem-device=3378,qmi-chip-id=2,qmi-board-id=260'
[ 46.118167] ath12k_pci 0000:03:00.0: boot firmware request ath12k/WCN7850/hw2.0/board-2.bin size 380280
[ 46.118173] ath12k_pci 0000:03:00.0: board name
[ 46.118176] ath12k_pci 0000:03:00.0: 00000000: 62 75 73 3d 70 63 69 bus=pci
[ 46.118179] ath12k_pci 0000:03:00.0: failed to fetch regdb data for bus=pci,vendor=17cb,device=1107,subsystem-vendor=17cb,subsystem-device=3378,qmi-chip-id=2,qmi-board-id=260 from ath12k/WCN7850/hw2.0/board-2.bin
[ 46.118239] ath12k_pci 0000:03:00.0: boot using board name 'bus=pci'
[ 46.119842] ath12k_pci 0000:03:00.0: boot firmware request ath12k/WCN7850/hw2.0/board-2.bin size 380280
[ 46.119847] ath12k_pci 0000:03:00.0: board name
[ 46.119849] ath12k_pci 0000:03:00.0: 00000000: 62 75 73 3d 70 63 69 bus=pci
[ 46.119852] ath12k_pci 0000:03:00.0: boot found match regdb data for name 'bus=pci'
[ 46.119855] ath12k_pci 0000:03:00.0: boot found regdb data for 'bus=pci'
[ 46.119857] ath12k_pci 0000:03:00.0: fetched regdb
Wen Gong [Sun, 17 Dec 2023 11:29:04 +0000 (13:29 +0200)]
wifi: ath12k: add support to search regdb data in board-2.bin for WCN7850
Currently ath12k only downloads the same regdb.bin file for all WCN7850
chips, actually ath12k needs to distinguish all different WCN7850 chips.
This is to re-use the string type which includes bus, chip id, board id,
vendor, device, subsystem-vendor, subsystem-device and variant for
WCN7850 to distinguish different regdb in board-2.bin.
ath12k will first load board-2.bin and search in it for the regdb data
with the above parameters. If matched with one regdb data, download it
to firmware. And if not, download regdb.bin instead.
Add enum value ATH12K_BD_IE_REGDB and enum type ath12k_bd_ie_regdb_type
to distinguish regdb data and board data since they are in the same file
board-2.bin.
Wen Gong [Sun, 17 Dec 2023 11:29:04 +0000 (13:29 +0200)]
wifi: ath12k: add fallback board name without variant while searching board-2.bin
Currently a variant value read from DT or SMBIOS is considered while
searching board-2.bin, this may fail because not all board-2.bin files
contains that symbol.
Add fallback board name which removes variant value and searches again
in board-2.bin when fails to increase boot up success rate.
Wen Gong [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath12k: add string type to search board data in board-2.bin for WCN7850
Currently ath12k only supports string type with bus, chip id and board id
such as "bus=ahb,qmi-chip-id=1,qmi-board-id=4" for AHB bus chip and
"bus=pci,qmi-chip-id=0,qmi-board-id=255" for PCI bus chip in board-2.bin.
For WCN7850, it is not enough to distinguish all different chips.
Add a new string type which includes bus, chip id, board id, vendor,
device, subsystem-vendor and subsystem-device for WCN7850.
ath12k will first load board-2.bin and searches in it for the board data
with the above parameters. If matched with one board data, ath12k downloads
it to firmware. And if not, downloads board.bin instead.
Jeff Johnson [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath10k: remove duplicate memset() in 10.4 TDLS peer update
In [1] it was identified that in ath10k_wmi_10_4_gen_tdls_peer_update()
the memset(skb->data, 0, sizeof(*cmd)) is unnecessary since function
ath10k_wmi_alloc_skb() already zeroes skb->data, so remove it.
Jeff Johnson [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath10k: use flexible array in struct wmi_tdls_peer_capabilities
Currently struct wmi_tdls_peer_capabilities defines:
struct wmi_channel peer_chan_list[1];
Per the guidance in [1] this should be a flexible array, and at one
point Gustavo was trying to fix this [2], but had questions about the
correct behavior when the associated peer_chan_len is 0.
I have been unable to determine if firmware requires that at least one
record be present even if peer_chan_len is 0. But since that is the
current behavior, follow the example from [3] and replace the
one-element array with a union that contains both a flexible array and
a single instance of the array element. This results in a struct that
has the same footprint as the original, so no other driver changes are
required.
Jeff Johnson [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath10k: remove unused template structs
Currently both the wmi_bcn_tmpl_cmd and wmi_prb_tmpl_cmd structs
define:
u8 data[1];
Per the guidance in [1] both instances of this should be flexible
arrays. However during conversion it was discovered that neither of
these structs are actually used, so just remove them.
Currently struct wmi_pdev_chanlist_update_event defines:
struct wmi_channel channel_list[1];
Per the guidance in [1] this should be a flexible array. However
during conversion it was discovered that this struct is not used, so
just remove the entire struct.
Jeff Johnson [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath10k: use flexible arrays for WMI start scan TLVs
Currently ath10k defines the following struct:
struct wmi_start_scan_tlvs {
u8 tlvs[0];
} __packed;
Per the guidance in [1] this should be a flexible array. However, a
direct replace to u8 tlvs[] results in the compilation error:
flexible array member in a struct with no named members
This is because C99 6.7.2.1 (16) requires that a structure containing
a flexible array member must have more than one named member.
So rather than defining a separate struct wmi_start_scan_tlvs which
contains the flexible tlvs[] array, just define the tlvs[] array where
struct wmi_start_scan_tlvs is being used.
Jeff Johnson [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath10k: use flexible array in struct wmi_host_mem_chunks
Currently struct wmi_host_mem_chunks defines:
struct host_memory_chunk items[1];
Per the guidance in [1] this should be a flexible array. However there
is a documented requirement:
some fw revisions require at least 1 chunk regardless of count
To satisfy this requirement, follow the guidance from [2] and wrap the
array in a union which contains both the flexible array and a single
instance of the underlying struct. Since the footprint of the struct
is unchanged, no additional driver changes are required.
Dmitry Antipov [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath9k: fix LNA selection in ath_ant_try_scan()
In 'ath_ant_try_scan()', (most likely) the 2nd LNA's signal
strength should be used in comparison against RSSI when
selecting first LNA as the main one. Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Uwe Kleine-König [Sun, 17 Dec 2023 11:29:03 +0000 (13:29 +0200)]
wifi: ath9k: 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Since 'ath11k_wmi_tlv_parse_alloc()' always operates on
'skb->data, skb->len' tuple, it may be simplified to pass
the only 'skb' argument instead (which also implies
refactoring of 'ath11k_pull_bcn_tx_status_ev()' and
'ath11k_pull_chan_info_ev()' in the same way). Compile
tested only.
Xingyuan Mo [Sun, 17 Dec 2023 11:29:01 +0000 (13:29 +0200)]
wifi: ath10k: fix NULL pointer dereference in ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev()
We should check whether the WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_EVENT tlv is
present before accessing it, otherwise a null pointer deference error will
occur.
wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings
Transform zero-length arrays `rate`, `adm_stat` and `msdu_cnt` into
proper flexible-array members in anonymous union in `struct
mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY()
helper; and fix multiple -Warray-bounds warnings:
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:544:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:551:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:553:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:530:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:538:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:540:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:520:57: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=]
This results in no differences in binary output, helps with the ongoing
efforts to globally enable -Warray-bounds.
Kalle Valo [Thu, 14 Dec 2023 16:17:40 +0000 (18:17 +0200)]
wifi: ath11k: workaround too long expansion sparse warnings
In v6.7-rc1 sparse warns:
drivers/net/wireless/ath/ath11k/mac.c:4702:15: error: too long token expansion
drivers/net/wireless/ath/ath11k/mac.c:4702:15: error: too long token expansion
drivers/net/wireless/ath/ath11k/mac.c:8393:23: error: too long token expansion
drivers/net/wireless/ath/ath11k/mac.c:8393:23: error: too long token expansion
Workaround the warnings by refactoring the code to a new function, which also
reduces code duplication. And in the new function use max3() to make the code
more readable.
Revert "wifi: ath12k: use ATH12K_PCI_IRQ_DP_OFFSET for DP IRQ"
This reverts commit 1f1f7d548a00ebe50808cb1f580df9693e194a7c. The commit
caused bootup failure on QCN9274 hw2.0 platform. Incorrect hardcode DP
irq offset overwrite the CE irq, which caused the driver to miss the
mandatory bootup message from the firmware through the CE interrupt. This
occurs because the CE count differs between platforms. The revert has no
impact since the original change was based on an incorrect assumption.
Log:
ath12k_pci 0000:06:00.0: fw_version 0x1011001d fw_build_timestamp 2022-12-02 01:16 fw_build_id QC_IMAGE_VERSION_STRING=WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
ath12k_pci 0000:06:00.0: failed to receive control response completion, polling..
ath12k_pci 0000:06:00.0: Service connect timeout
ath12k_pci 0000:06:00.0: failed to connect to HTT: -110
ath12k_pci 0000:06:00.0: failed to start core: -110
Dmitry Antipov [Wed, 13 Dec 2023 05:14:43 +0000 (08:14 +0300)]
wifi: rt2x00: remove useless code in rt2x00queue_create_tx_descriptor()
In 'rt2x00queue_create_tx_descriptor()', there is no need to call
'ieee80211_get_rts_cts_rate()' while checking for RTS/CTS frame
since this function returns NULL or pointer to internal bitrate
table entry, and the return value is not actually used. Compile
tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Ping-Ke Shih [Mon, 11 Dec 2023 08:33:39 +0000 (16:33 +0800)]
wifi: rtw89: mac: add suffix _ax to MAC functions
Many existing MAC access functions are used by WiFi 6 chips only, so add
suffix _ax to be clearer. Some are common and can be used by WiFi 7, so
export this kind of functions. This patch doesn't change logic at all.
Ping-Ke Shih [Mon, 11 Dec 2023 08:33:38 +0000 (16:33 +0800)]
wifi: rtw89: mac: add flags to check if CMAC and DMAC are enabled
Before accessing CMAC and DMAC registers, we should ensure they have been
powered on, so add flag to determine the state. For old chips, we read
registers and check corresponding bit, but it takes extra cost to read.
Ping-Ke Shih [Mon, 11 Dec 2023 08:33:36 +0000 (16:33 +0800)]
wifi: rtw89: add XTAL SI for WiFi 7 chips
The XTAL SI is a serial interface to indirectly access registers of
analog hardware circuit. Since WiFi 7 chips use different registers, add
a ops to access them via common functions. This patch doesn't change logic
for existing chips.
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:54 +0000 (08:50 +0800)]
wifi: rtw89: phy: print out RFK log with formatted string
With formatted string loaded from firmware file, we can use the formatted
string ID and get corresponding string, and then use regular rtw89_debug()
to show the message if debug mask of RFK is enabled.
If the string ID doesn't present, fallback to print plain hexadecimal.
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:53 +0000 (08:50 +0800)]
wifi: rtw89: parse and print out RFK log from C2H events
RFK log events contains two types. One called RUN log is to reflect state
during RFK is running, and it replies on formatted string loaded from
firmware file, but print this type as plain hexadecimal only in this patch.
The other is REPORT log that reflects the final result of a RFK, and
each calibration has its own struct to carry many specific information.
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:52 +0000 (08:50 +0800)]
wifi: rtw89: add C2H event handlers of RFK log and report
Trigger a RFK (RF calibration) in firmware by a H2C command, and in
progress it reports log and a result finally by C2H events. Firstly, add
prototype of the C2H event handlers to have a simple picture of framework.
The callers who trigger H2C will wait until a C2H event is received,
so we must process these C2H events in receiving process. Thus, mark this
kind of C2H events as atomic. Also, timestamp is also useful for
debugging, mark C2H events carrying RFK log as atomic as well.
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:51 +0000 (08:50 +0800)]
wifi: rtw89: load RFK log format string from firmware file
To debug RFK (RF calibration) in firmware, it sends log via firmware C2H
events to driver with string format ID and four arguments. Load formatted
string from firmware file, and the string ID can get back its string. Then,
use regular print format to show the message.
This firmware element layout looks like
+============================================+
| elm ID | elm size | version | |
+----------+----------+----------+-----------+
| | nr |rsvd |rfk_id|rsvd|
+--------------------------------------------+
| offset[] (__le16 * nr) |
| ... |
+--------------------------------------------+
| formatted string with null termintor (*nr) |
| ... |
+============================================+
* a firmware file can contains more than one elements with this element ID
named RTW89_FW_ELEMENT_ID_RFKLOG_FMT (19), because many RFK needs its
own formatted strings, so add 'rfk_id' to know it belongs to which RFK.
* the 'formatted string' just follow 'offset[]' without padding to align
32bits.
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:50 +0000 (08:50 +0800)]
wifi: rtw89: fw: add version field to BB MCU firmware element
8922AE has more than one hardware version, and they use different BB MCU
firmware, so occupy a byte from element priv[] to annotate version. Since
there are more than one firmware and only matched version is adopted,
return 1 to ignore not matched firmware.
+===========================================+
| elm ID | elm size | version | |
+----------+----------+----------+----------+
| | element_priv[] |
+-------------------------------------------+
change to |
v
+===========================================+
| elm ID | elm size | version | |
+----------+----------+----------+----------+
| | cv | element_rsvd[] |
+-------------------------------------------+
Ping-Ke Shih [Wed, 13 Dec 2023 00:50:49 +0000 (08:50 +0800)]
wifi: rtw89: fw: load TX power track tables from fw_element
The TX power track tables are used to define compensation power reflected
to thermal value. Currently, we have 16 (2 * 4 * 2) tables made by
combinations of
{negative/positive thermal value, 2GHz/2GHz-CCK/5GHz/6GHz, path A/B}
David Lin [Fri, 15 Dec 2023 00:51:18 +0000 (08:51 +0800)]
wifi: mwifiex: configure BSSID consistently when starting AP
AP BSSID configuration is missing at AP start. Without this fix, FW returns
STA interface MAC address after first init. When hostapd restarts, it gets MAC
address from netdev before driver sets STA MAC to netdev again. Now MAC address
between hostapd and net interface are different causes STA cannot connect to
AP. After that MAC address of uap0 mlan0 become the same. And issue disappears
after following hostapd restart (another issue is AP/STA MAC address become the
same).
David Lin [Fri, 8 Dec 2023 23:40:29 +0000 (07:40 +0800)]
wifi: mwifiex: add extra delay for firmware ready
For SDIO IW416, due to a bug, FW may return ready before complete full
initialization. Command timeout may occur at driver load after reboot.
Workaround by adding 100ms delay at checking FW status.
Hancheng Yang [Tue, 5 Dec 2023 17:06:23 +0000 (18:06 +0100)]
wifi: ath9k: reset survey of current channel after a scan started
In the `ath_set_channel()` function, we only reset surveys that are not
from the current channel. This leads to the accumulation of survey data for
the current channel indefinitely. This may not be the most optimal
approach, as we want the ACS to rely on the most recent survey.
So reset the survey data for the current channel at the start of each scan.
Lingbo Kong [Wed, 6 Dec 2023 14:17:59 +0000 (22:17 +0800)]
wifi: ath12k: fix the issue that the multicast/broadcast indicator is not read correctly for WCN7850
We observe some packets are discarded in ieee80211_rx_handlers_result
function for WCN7850. This is because the way to get multicast/broadcast
indicator with RX_MSDU_END_INFO5_DA_IS_MCBC & info5 is incorrect. It should
use RX_MSDU_END_INFO13_MCAST_BCAST & info13 to get multicast/broadcast
indicator.
Jeff Johnson [Tue, 5 Dec 2023 21:00:17 +0000 (13:00 -0800)]
wifi: ath11k: Fix ath11k_htc_record flexible record
Transform the zero-length ath11k_htc_record::credit_report array into
a proper flexible array. Since this is the only array in
ath11k_htc_record, remove the unnecessary union.
Chris Morgan [Fri, 8 Dec 2023 15:07:39 +0000 (09:07 -0600)]
wifi: rtw88: Use random MAC when efuse MAC invalid
When the MAC address read from the efuse data is invalid, warn the
user and use a random MAC address instead.
On a device I am currently using (Anbernic RG-ARC) with a rtw8821cs
the efuse appears to be incompletely/improperly programmed. The MAC
address reads as ff:ff:ff:ff:ff:ff. When networkmanager attempts to
initiate a connection (and I haven't hard-coded a MAC address or
set it to random) it fails to establish a connection.
Dmitry Antipov [Mon, 4 Dec 2023 17:11:28 +0000 (20:11 +0300)]
wifi: wfx: fix possible NULL pointer dereference in wfx_set_mfp_ap()
Since 'ieee80211_beacon_get()' can return NULL, 'wfx_set_mfp_ap()'
should check the return value before examining skb data. So convert
the latter to return an appropriate error code and propagate it to
return from 'wfx_start_ap()' as well. Compile tested only.
Arnd Bergmann [Mon, 4 Dec 2023 07:30:13 +0000 (08:30 +0100)]
wifi: rtw89: avoid stringop-overflow warning
After -Wstringop-overflow got enabled, the rtw89 driver produced
two odd warnings with gcc-13:
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start':
drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
5362 | wl->dbcc_info.scan_band[phy_idx] = band;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from drivers/net/wireless/realtek/rtw89/coex.h:8,
from drivers/net/wireless/realtek/rtw89/coex.c:5:
drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
| ^~~~~~~~~
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band':
drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
5406 | wl->dbcc_info.scan_band[phy_idx] = band;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
| ^~~~~~~~~
I don't know what happened here, but adding an explicit range check
shuts up the output.
Dmitry Antipov [Fri, 8 Dec 2023 15:31:25 +0000 (18:31 +0300)]
wifi: mac80211: drop spurious WARN_ON() in ieee80211_ibss_csa_beacon()
The WARN_ON() in subject was actually seen only once, with 5.10.200
under syzkaller. It looks like a weird artifact of (ab?)using the
syzkaller itself [1], and hopefully may be safely removed.
Johannes Berg [Mon, 11 Dec 2023 07:05:29 +0000 (09:05 +0200)]
wifi: mac80211: don't set ESS capab bit in assoc request
The ESS capability bit is reserved in frames transmitted by
the client, so we shouldn't set it. Since we've set it for
decades, keep that old behaviour unless we're connection to
a new EHT AP.
Benjamin Berg [Mon, 11 Dec 2023 07:05:28 +0000 (09:05 +0200)]
wifi: cfg80211: consume both probe response and beacon IEs
When doing a channel switch, cfg80211_update_known_bss may be called
with a BSS where both proberesp_ies and beacon_ies is set. If that
happens, both need to be consumed.
Benjamin Berg [Mon, 11 Dec 2023 07:05:27 +0000 (09:05 +0200)]
wifi: cfg80211: generate an ML element for per-STA profiles
The specification says that this information should not be explicitly
included in the per-STA profile. However, we need this information
readily available in the BSS for userspace and also internally when
associating. As such, append the appropriate element before
adding/updating the BSS.
Ilan Peer [Mon, 11 Dec 2023 07:05:22 +0000 (09:05 +0200)]
wifi: cfg80211: Add support for setting TID to link mapping
Add support for setting the TID to link mapping for a non-AP MLD
station.
This is useful in cases user space needs to restrict the possible
set of active links, e.g., since it got a BSS Transition Management
request forcing to use only a subset of the valid links etc.
Johannes Berg [Mon, 11 Dec 2023 07:05:21 +0000 (09:05 +0200)]
wifi: mac80211: update some locking documentation
With the locking rework, more functions need to be called
with the wiphy mutex held. Document that, and for that use
the "Context" description that shows up more nicely in the
generated documentation.
Johannes Berg [Mon, 11 Dec 2023 07:05:20 +0000 (09:05 +0200)]
wifi: cfg80211: add BSS usage reporting
Sometimes there may be reasons for which a BSS that's
actually found in scan cannot be used to connect to,
for example a nonprimary link of an NSTR mobile AP MLD
cannot be used for normal direct connections to it.
Not indicating these to userspace as we do now of course
avoids being able to connect to them, but it's better if
they're shown to userspace and it can make an appropriate
decision, without e.g. doing an additional ML probe.
Thus add an indication of what a BSS can be used for,
currently "normal" and "MLD link", including a reason
bitmap for it being not usable.
The latter can be extended later for certain BSSes if there
are other reasons they cannot be used.
wifi: iwlwifi: mvm: do not send STA_DISABLE_TX_CMD for newer firmware
Newest firmware has completely offloaded this logic and this command
will be deprecated soon. Based on a capability bit advertised by the
firmware, skip this command.
Johannes Berg [Thu, 7 Dec 2023 02:50:15 +0000 (04:50 +0200)]
wifi: iwlwifi: remove async command callback
There's only one user of this code, which is STA unblock
during sleep for uAPSD on really old devices. Instead of
having this all through the API with calls up and down,
just implemented a special-case CMD_BLOCK_TXQS flag for
this, it's only needed in the old gen1 transport.
While at it, fix a complain that lockdep would have, as
we lock the cmd queue and then the TXQs in the reclaim
by using spin_lock_nested(). We no longer need to disable
BHs in iwl_trans_pcie_block_txq_ptrs() since it's called
with them disabled already.
Johannes Berg [Thu, 7 Dec 2023 02:50:11 +0000 (04:50 +0200)]
wifi: iwlwifi: pcie: clean up device removal work
We shouldn't access the device if we don't hold a reference,
and if - after locking - we see that it has no bus, we also
can't do anything, in fact, pci_stop_and_remove_bus_device()
will be a no-op.
Johannes Berg [Thu, 7 Dec 2023 02:50:09 +0000 (04:50 +0200)]
wifi: iwlwifi: refactor RX tracing
When there's not going to be any data in the data event, we
don't need to add it at all (unlike the TX version, it has
no data at all.)
Also combine the tracing into a separate inline so we only
call iwl_rx_trace_len() once, which also simplifies things,
and lets us have a single place to later add other checks.
Miri Korenblit [Thu, 7 Dec 2023 02:50:08 +0000 (04:50 +0200)]
wifi: iwlwifi: don't support triggered EHT CQI feedback
EHT CQI is one of the EHT PHY capabilities. We don't support EHT CQI.
The non-triggered CQI feedback bit was unset in a previous patch,
but the triggered CQI feedback bit wasn't. Unset it.
Vinayak Yadawad [Wed, 29 Nov 2023 12:50:43 +0000 (18:20 +0530)]
wifi: nl80211: Extend del pmksa support for SAE and OWE security
Current handling of del pmksa with SSID is limited to FILS
security. In the current change the del pmksa support is extended
to SAE/OWE security offloads as well. For OWE/SAE offloads, the
PMK is generated and cached at driver/FW, so user app needs the
capability to request cache deletion based on SSID for drivers
supporting SAE/OWE offload.
Dmitry Antipov [Wed, 6 Dec 2023 06:09:27 +0000 (09:09 +0300)]
wifi: mac80211: cleanup airtime arithmetic with ieee80211_sta_keep_active()
Prefer native jiffies-wide 'unsigned long' for the 'last_active' field of
'struct airtime_info' and introduce 'ieee80211_sta_keep_active()' for airtime
check in 'ieee80211_txq_keep_active()' and 'ieee80211_sta_register_airtime()'.
Evan Quan [Mon, 11 Dec 2023 10:06:25 +0000 (18:06 +0800)]
wifi: mac80211: Add support for WBRF features
To support the WBRF mechanism, Wifi adapters utilized in the system must
register the frequencies in use (or unregister those frequencies no longer
used) via the dedicated calls. So that, other drivers responding to the
frequencies can take proper actions to mitigate possible interference.
Ming Yen Hsieh [Wed, 22 Nov 2023 03:06:46 +0000 (11:06 +0800)]
wifi: mt76: mt7921: fix wrong 6Ghz power type
To avoid using incorrect 6g power settings after disconnection,
it should to update back to the default state when disconnected.
Fixes: 51ba0e3a15eb ("wifi: mt76: mt7921: add 6GHz power type support for clc") Signed-off-by: Ming Yen Hsieh <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
Ming Yen Hsieh [Wed, 22 Nov 2023 03:06:45 +0000 (11:06 +0800)]
wifi: mt76: mt7921: fix CLC command timeout when suspend/resume
When enter suspend/resume while in a connected state, the upper layer
will trigger disconnection before entering suspend, and at the same time,
it will trigger regd_notifier() and update CLC, causing the CLC event to
not be received due to suspend, resulting in a command timeout.
Therefore, the update of CLC is postponed until resume, to ensure data
consistency and avoid the occurrence of command timeout.
Fixes: 4fc8df50fd41 ("wifi: mt76: mt7921: get regulatory information from the clc event") Signed-off-by: Ming Yen Hsieh <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
Ming Yen Hsieh [Wed, 22 Nov 2023 03:06:44 +0000 (11:06 +0800)]
wifi: mt76: mt7921: fix country count limitation for CLC
Due to the increase in the number of power tables for 6Ghz on CLC,
the variable nr_country is no longer sufficient to represent the
total quantity. Therefore, we have switched to calculating the
length of clc buf to obtain the correct power table. Additionally,
the version number has been incremented to 1.
Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support") Signed-off-by: Ming Yen Hsieh <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
Sean Wang [Tue, 21 Nov 2023 22:27:22 +0000 (06:27 +0800)]
wifi: mt76: mt7921: reduce the size of MCU firmware download Rx queue
We actually don't need the reserve the 512 entries for the MCU firmware
download Rx queue because the queue was only used in the firmware download
phase to save the most of space and the reduction can significantly help
with reducing latency we spent by ~20% further in resetting the Rx queue
as the device was waking up from deep sleep mode.
Ma Jun [Mon, 11 Dec 2023 10:06:23 +0000 (18:06 +0800)]
platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature
Due to electrical and mechanical constraints in certain platform designs
there may be likely interference of relatively high-powered harmonics of
the (G-)DDR memory clocks with local radio module frequency bands used
by Wifi 6/6e/7.
To mitigate this, AMD has introduced a mechanism that devices can use to
notify active use of particular frequencies so that other devices can make
relative internal adjustments as necessary to avoid this resonance.
Wang Zhao [Fri, 17 Nov 2023 12:54:49 +0000 (20:54 +0800)]
wifi: mt76: mt7921s: fix workqueue problem causes STA association fail
The ieee80211_queue_work function queues work into the mac80211
local->workqueue, which is widely used for mac80211 internal
work processes. In the mt76 driver, both the mt76-sido-status and
mt76-sdio-net threads enqueue workers to the workqueue with this
function. However, in some cases, when two workers are enqueued
to the workqueue almost simultaneously, the second worker may not
be scheduled immediately and may get stuck for a while.
This can cause timing issues. To avoid these timing
conflicts caused by worker scheduling, replace the worker
with an independent thread.
Uwe Kleine-König [Fri, 17 Nov 2023 09:31:03 +0000 (10:31 +0100)]
wifi: mt76: 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().
Trivially convert the three mt76 drivers from always returning zero in
the remove callback to the void returning variant.
StanleyYP Wang [Mon, 13 Nov 2023 07:06:17 +0000 (15:06 +0800)]
wifi: mt76: mt7996: adjust interface num and wtbl size for mt7992
MT7992 chipsets support up to 32 interfaces (with maximum 19 per-band)
and 512 station entries.
This is a preliminary patch for mt7992 chipsets support.