Commit Graph

1489 Commits

Author SHA1 Message Date
Zong-Zhe Yang
b8a2f9e0fa wifi: rtw89: mcc: handle the case where NoA start time has passed
MCC will limit the time a role can use in a schedule according to the
periodic NoA. Original logic didn't consider the case where NoA start
time has passed. It might lead to inaccurate result. So, tweak it.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-9-pkshih@realtek.com
2025-04-28 14:38:39 +08:00
Zong-Zhe Yang
50f9dc17a1 wifi: rtw89: mcc: make GO+STA mode calculate dynamic beacon offset
There are two roles during MCC and the offset between their TBTT is called
beacon offset. Originally, when MCC runs GO+STA mode, it used fixed beacon
offset to simplify some logic because GO role can master its TSF. However,
if MCC is stopped and restarted before a same GO is down, its TSF might be
discontinuous. Then, there might be undefined behavior happens in GC sides.
So, to let a same GO have a continuous TSF, MCC no longer changes its TSF
to meet a fixed beacon offset. Instead, GO+STA mode also calculates beacon
offset dynamically as what GC+STA mode did.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-8-pkshih@realtek.com
2025-04-28 14:37:14 +08:00
Zong-Zhe Yang
13bd2b36f2 wifi: rtw89: don't re-randomize TSF of AP/GO
When APs or GOs are up, their TSF start point are randomized to avoid
collisions. However, the TSF of an existing AP/GO would be randomized
multiple times. It caused the TSF is discontinuous to the corresponding
STA/GC sides. So, once TSF has been randomized, don't re-randomize it
unless SER (system error recovery) happens unfortunately.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-7-pkshih@realtek.com
2025-04-28 14:35:49 +08:00
Zong-Zhe Yang
98019abbf9 wifi: rtw89: mcc: make GO announce one-time NoA for HW scan process
Since FW cannot handle HW scan process and MCC (multi-channel concurrency)
mode simultaneously, if a HW scan is requested during MCC, MCC mode will be
paused temporarily. Then, the GO role if any might be absent. So, calculate
an estimated time for the requested HW scan process and search for existing
GO roles to fill one-time NoA.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-6-pkshih@realtek.com
2025-04-28 14:35:36 +08:00
Zong-Zhe Yang
57a5fbe39a wifi: rtw89: refactor flow that hw scan handles channel list
FW has a limited amount of channels that can be dealt with by one HW scan
H2C command. Based on the limit, channels in scan request might be parsed
into SW structure piece by piece along with multiple HW scan H2C commands.
But, in order to estimate things of entire HW scan process, it's required
to have the whole parsed channel list when HW scan is going to start. So,
tweak HW scan flow to prepare the whole channel list ahead. Still, each HW
scan H2C command takes allowed amount of channels from the list according
to the limit.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-5-pkshih@realtek.com
2025-04-28 14:34:12 +08:00
Zong-Zhe Yang
27982c9082 wifi: rtw89: add suffix "_ax" to Wi-Fi 6 HW scan struct and func
These stuffs have no suffix, but not universal, and only work for Wi-Fi 6.
Since the corresponding HW scan struct/func of Wi-Fi 7 have suffix "_be",
to avoid misunderstanding and improve readability, also add suffix "_ax"
to these Wi-Fi 6 stuffs.

(No logic is changed.)

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-4-pkshih@realtek.com
2025-04-28 14:33:24 +08:00
Kuan-Chung Chen
df6da0b81e wifi: rtw89: acpi: introduce country specific TAS enabling
A new ACPI table entry format for TAS is defined, which includes
a "specific country" field. In this field, determine which
country can enable TAS.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-3-pkshih@realtek.com
2025-04-28 14:32:02 +08:00
Kuan-Chung Chen
74f754da76 wifi: rtw89: 8922a: increase beacon loss to 6 seconds
Intermittent beacon loss from specific AP triggers disconnection
and reconnection. Increasing the beacon loss count will make the
connection more stable.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250422014620.18421-2-pkshih@realtek.com
2025-04-28 14:30:42 +08:00
Kuan-Chung Chen
3e03579821 wifi: rtw89: set pre-calculated antenna matrices for HE trigger frame
Pre-calculated antenna matrices can improve 160MHz uplink OFDMA
performance, but they are only needed for the HE trigger frame.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250416081241.36138-5-pkshih@realtek.com
2025-04-26 15:27:32 +08:00
Zong-Zhe Yang
f64801d6f1 wifi: rtw89: regd: indicate if regd_UK TX power settings follow regd_ETSI
Before adopting regd_UK TX power settings, some certifications are needed
and might be platform-level. Without that, should adopt regd_ETSI TX power
settings. But for now, there is no way to inform driver of it yet. So, add
a flag first. But for now, comprehensively use regd_ETSI TX power settings
to restrict regd_UK.

Plan to define an ACPI DSM function to inform driver whether to use regd_UK
own TX power settings or not afterwards.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250416081241.36138-4-pkshih@realtek.com
2025-04-26 15:25:53 +08:00
Kuan-Chung Chen
20aac091a1 wifi: rtw89: 8922a: fix TX fail with wrong VCO setting
An incorrect Voltage Controlled Oscillator (VCO) setting
may cause Synthesizer (SYN) unlock, which may lead to a
failure in the TX authentication request.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250416081241.36138-3-pkshih@realtek.com
2025-04-26 15:25:42 +08:00
Ping-Ke Shih
603f4c71cc wifi: rtw89: 8852c: update supported firmware format to 2
After firmware 0.27.125.0, it adds more fields to support firmware secure
boot. Though current driver has supported the format, old driver can't
recognize the new format, increase firmware format to 2 to avoid failed
to load the firmware by old driver.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250416081241.36138-2-pkshih@realtek.com
2025-04-26 15:20:40 +08:00
Zong-Zhe Yang
28b921020b wifi: rtw89: 8852bx: support different SAR configs by antenna
Calculate difference of SAR configs between RF path A and RF path B.
And then, based on the calculated result, set the TX power reference
CR (control register). Finally, declare to support SAR by antenna in
8852b/8852bt chip info.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-13-pkshih@realtek.com
2025-03-31 14:29:52 +08:00
Zong-Zhe Yang
7b51b39368 wifi: rtw89: 8852c: support different SAR configs by antenna
Set SAR configs to the corresponding CRs (control registers) according to
RF path. Then, declare to support SAR by antenna in chip info.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-12-pkshih@realtek.com
2025-03-31 14:28:41 +08:00
Zong-Zhe Yang
711b6ce3e8 wifi: rtw89: 8922a: support different SAR configs by antenna
Set SAR configs to the corresponding CRs (control registers) according to
RF path. Then, declare to support SAR by antenna in chip info.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-11-pkshih@realtek.com
2025-03-31 14:27:28 +08:00
Zong-Zhe Yang
c6c830b265 wifi: rtw89: sar: add skeleton for different configs by antenna
Some SAR sources, e.g. ACPI, may allow different SAR configs by antenna.
Previously, the minimum config between antennas was taken. Because there
are differences between HW design, different chips might have different
solutions to achieve this. So, it cannot be done through a single common
handling. Now, add the relevant skeleton for this purpose ahead.

First, add a flag into chip info to describe whether it has implemented
this function or not. Second, support to query SAR config for a given RF
path. With it, each chip can implement its own handling. Then, if a chip
declares to support this function, when it queries SAR config without a
given RF path, it gets a maximum config between antennas.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-10-pkshih@realtek.com
2025-03-31 14:26:09 +08:00
Zong-Zhe Yang
5bafc85d71 wifi: rtw89: acpi: support loading GEO SAR tables
Support to load GEO (geography) SAR tables with ACPI RWGS method. When
SAR values could be different by regulatory, GEO SAR can be used. The
format of GEO SAR is like the following, where regulatory number, band
number, and delta number are determined by header of either static SAR
or dynamic SAR. (It also means that no GEO SAR will be considered when
neither static SAR nor dynamic SAR is configured.)

                               delta number
                             /               \
                    + +-----+-----------------+
                  / | | max | delta...        | \
                 /  | +-----+-----------------+  band
                /   | | max | delta...        |  number
               /    | +-----+-----------------+
              /     | |...                    | /
                    + +-----+-----------------+
                    | | max | delta...        | \
       regulatory   | +-----+-----------------+  band
       number       | | max | delta...        |  number
                    | +-----+-----------------+
                    | |...                    | /
                    + +-----+-----------------+
              \     | |...                    |
               \    | |...                    |
                \   | |...                    |
                 \  | |                       |
                  \ | |                       |
                    + +-----+-----------------+

Each entry of GEO SAR contains delta field(s), which are offset(s) used
to tweak the loaded static/dynamic SAR table(s) by antenna, and one max
field, which describes the maximum of the final SAR values after tweaked.
Different entries should be configured based on both regulatory and band.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-9-pkshih@realtek.com
2025-03-31 14:25:55 +08:00
Zong-Zhe Yang
2eba885ab8 wifi: rtw89: acpi: support loading dynamic SAR tables and indicator
Support to load dynamic SAR tables with ACPI RWRD method. The content
format of a single dynamic SAR table is basically the same as static
SAR table. However, it's able to carry multiple dynamic SAR tables at
one time. And, its header contains one more field to describe how many
dynamic SAR tables are filled in the content. Either static SAR table
or dynamic SAR tables can be supported, but not both simultaneously.

Besides, also support to load indicator of dynamic SAR with ACPI RWSI
method. The indicator will describe a target dynamic SAR table, which
should be followed currently, by antenna. It can be changed at runtime
according to platform mode. For example, tablet mode can use different
SAR from normal mode. So, track indicator configuration if dynamic SAR
is configured.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-8-pkshih@realtek.com
2025-03-31 14:24:35 +08:00
Zong-Zhe Yang
91f4ea1174 wifi: rtw89: acpi: support loading static SAR table
Support to load static SAR table with ACPI WRDS method. The format of
a static SAR table is like the following, where according to header,
antenna number could be either 2 or 4 and subband number could either
contain 6 GHz or not. And then, an entry of it describes a TX power
limitation with a given unit, which is also based on header, for the
antenna under the subband. Though things can be determined by header,
still not all combinations are allowed in content. For the recognizing
flow, there is a list of allowed combinations.

               +--------------------------------+
               |             header             |
               +--------------------------------+
               +---+---+---+---+---+------------+ +
             / |   |   |   |   |   | ...        | | \
               +---+---+---+---+---+------------+ |
      antenna  |   |   |   |   |   | ...        | |
      number   +---+---+---+---+---+------------+ |   content
               |...|   |   |   |   | ...        | |
               +---+---+---+---+---+------------+ |
             \ |...|   |   |   |   | ...        | | /
               +---+---+---+---+---+------------+ +
                \                              /
                          subband number

Following the format above, try to load a static SAR table and normalize
its content into SW structure. If any recognized is loaded, SW SAR flow
is then set up with source from ACPI.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-7-pkshih@realtek.com
2025-03-31 14:23:16 +08:00
Zong-Zhe Yang
5ee5f84846 wifi: rtw89: acpi: introduce method evaluation function for reuse
The following implementations will evaluate different ACPI methods, but
the pre-process flow of them are the same. So, introduce a function for
these pre-process things. Besides, also change ACPI RTAG method to call
this function.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-6-pkshih@realtek.com
2025-03-31 14:23:03 +08:00
Zong-Zhe Yang
88ca3107d2 wifi: rtw89: sar: add skeleton for SAR configuration via ACPI
To support SAR configuration in BIOS via ACPI, add related subbnad/band
converting/handling function and define SW format to store result after
parsing. Then, register a new SAR source, i.e. ACPI, into SAR flow and
implement its query function.

Besides, tweak priority of common SAR to be the highest. And, ACPI SAR
can just be configured once when no other sources is already working.
For now, evaluating SAR via ACPI returns -ENOENT, i.e. ACPI SAR doesn't
really work yet. The evaluating flow will be implemented in the following.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-5-pkshih@realtek.com
2025-03-31 14:21:46 +08:00
Zong-Zhe Yang
1e262fc8df wifi: rtw89: sar: introduce structure to wrap query parameters
The following implementations will support SAR source from ACPI/BIOS.
And when querying, it needs to take more parameters into account. To
avoid changing function prototype of querying SAR everytime when new
SAR source is introduced, wrap query parameters into a structure first.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-4-pkshih@realtek.com
2025-03-31 14:21:27 +08:00
Zong-Zhe Yang
4cecf99124 wifi: rtw89: regd: introduce string getter for reuse
Introduce a function to get the string for a given regulatory. It will be
used in the following. Besides, drop similar things in debug code and use
this too.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-3-pkshih@realtek.com
2025-03-31 14:20:12 +08:00
Zong-Zhe Yang
8bde621f12 wifi: rtw89: fix typo of "access" in rtw89_sar_info description
The "acces" should be "access".
So, fix it.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250326020643.14487-2-pkshih@realtek.com
2025-03-31 14:19:03 +08:00
Ping-Ke Shih
e95129709a wifi: rtw89: phy: reset value of force TX power for MAC ID
The force TX power function is disabled, but the force TX power value is
preserved, causing misunderstand the behavior in debug. Clear all values.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250325031021.15619-1-pkshih@realtek.com
2025-03-31 14:08:46 +08:00
Ping-Ke Shih
bc1265b5c9 wifi: rtw89: fw: cast mfw_hdr pointer from address of zeroth byte of firmware->data
The firmware->size is validated before using firmware->data, but Coverity
still reports:
  Downcasting "firmware->data" from "u8 const *" to "struct rtw89_mfw_hdr"
  implies that the data that this pointer points to is tainted."

Using &firmware->data[0] to avoid the warning. No change logic at all.

Addresses-Coverity-ID: 1494046 ("Untrusted loop bound")
Addresses-Coverity-ID: 1544385 ("Untrusted array index read")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250325025424.14079-1-pkshih@realtek.com
2025-03-31 14:07:03 +08:00
Ping-Ke Shih
81433a8a4f wifi: rtw89: set 2TX for 1SS rate by default
To improve performance in range, for 1SS rate, transmit the same signal
on 2 antenna, which is called 2TX.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250321034736.6269-1-pkshih@realtek.com
2025-03-31 14:00:27 +08:00
Ching-Te Ku
e5c45671d9 wifi: rtw89: coex: Update Wi-Fi/Bluetooth coexistence version to 7.0.4
RTL8852BE-VT support for firmware 29.122. Add parser for Bluetooth channel
map report version 7.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250308025832.10400-5-pkshih@realtek.com
2025-03-13 09:03:45 +08:00
Ching-Te Ku
6db476db57 wifi: rtw89: coex: Add parser for Bluetooth channel map report version 7
In order to rearrange the structure member, the format update to version 7.
And to parse the report correctly, add the related logic.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250308025832.10400-4-pkshih@realtek.com
2025-03-13 09:02:27 +08:00
Ching-Te Ku
a36230aa5f wifi: rtw89: coex: Fix coexistence report not show as expected
This report will feedback some basic information from firmware(PTA counter,
report counter, mailbox counter etc). And the report version need to match
driver & firmware both side. The original logic break the switch case logic
before driver update the report version. It made the report can not be
parsed correctly. Delete the break at the version 7 and 8.
Add logic to count C2H event report.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250308025832.10400-3-pkshih@realtek.com
2025-03-13 09:02:14 +08:00
Ching-Te Ku
bb76dd94b7 wifi: rtw89: coex: RTL8852BT coexistence Wi-Fi firmware support for 0.29.122.0
Add format version of Wi-Fi firmware commands/events for firmware
version 0.29.122.0.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250308025832.10400-2-pkshih@realtek.com
2025-03-13 09:02:01 +08:00
Dian-Syuan Yang
a9b56f219a wifi: rtw89: set force HE TB mode when connecting to 11ax AP
Some of 11ax AP set the UL HE-SIG-A2 reserved subfield to all 0s, which
will cause the 11be chip to recognize trigger frame as EHT. We propose
a method to bypass the "UL HE-SIG-A2 reserved subfield" and always uses
HE TB in response to the AP's trigger frame.

Signed-off-by: Dian-Syuan Yang <dian_syuan0116@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250306021144.12854-6-pkshih@realtek.com
2025-03-13 08:47:04 +08:00
Kuan-Chung Chen
6f039d9ba9 wifi: rtw89: 8922a: enable dynamic antenna gain
The 8922A now supports dynamic antenna gain. However, in firmware
before v0.35.64.0, different transmit powers cannot be applied to
each RF path. To comply with regulatory limits in these older
firmware, the lower of the two requested transmit powers will
be used for both paths when they differ.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250306021144.12854-5-pkshih@realtek.com
2025-03-13 08:45:43 +08:00
Kuan-Chung Chen
9c225e1198 wifi: rtw89: enable dynamic antenna gain based on country
The dynamic antenna gain (DAG) considers the country, meaning DAG can
be activated only when countries and regulatory domains allow it.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250306021144.12854-4-pkshih@realtek.com
2025-03-13 08:44:25 +08:00
Kuan-Chung Chen
8ef675fc79 wifi: rtw89: refine mechanism of TAS
TAS state switching mechanism now incorporates the TX ratio as a
decision parameter. The average power calculation has been improved
by using a higher resolution conversion from dBm to linear. During
scan or MCC operations, TAS state is forced to static SAR and
suspend the average power calculation. Additionally, TAS window
size depends on the regulatory domain and band to ensure compliance.

TAS is enabled when permitted by the regulatory domain and is
currently supported on the 8852CE.

For debugging, add a flag to disable_dm that can stop TAS mechanism.

Co-developed-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250306021144.12854-3-pkshih@realtek.com
2025-03-13 08:42:10 +08:00
Kuan-Chung Chen
3df4583ae0 wifi: rtw89: add support for negative values of dBm to linear conversion
Enhanced the dBm to linear conversion function to accommodate negative
dBm values and improved the precision from 1 dBm to 0.25 dBm.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250306021144.12854-2-pkshih@realtek.com
2025-03-13 08:40:00 +08:00
Ping-Ke Shih
3218f5bd8e wifi: rtw89: pci: correct ISR RDU bit for 8922AE
The interrupt status (ISR) bits of RX desc unavailable (RDU) for 8922AE
are B_BE_RDU_CH1_INT_V1 and B_BE_RDU_CH0_INT_V1. With wrong bits, if it
happens, driver can't recognize the situation and prompt a message.
Fix the definition accordingly.

Fixes: aa70f76120 ("wifi: rtw89: pci: generalize interrupt status bits of interrupt handlers")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250227131907.9864-1-pkshih@realtek.com
2025-03-05 19:52:05 +08:00
Ping-Ke Shih
ad26d0dcb3 wifi: rtw89: fw: don't reject firmware in blacklist to prevent breaking users
Once update driver blacklist of firmware, users' firmware might be in
the list, and then driver stops working. Since breaking users is not
expected, report a significant message instead of stopping.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250227131228.8457-5-pkshih@realtek.com
2025-03-05 19:46:52 +08:00
Ping-Ke Shih
88b46320fc wifi: rtw89: fw: correct debug message format in rtw89_build_txpwr_trk_tbl_from_elm()
The format should be "%08x". Fix the mistakes.

Fixes: d60e73e5dd ("wifi: rtw89: fw: load TX power track tables from fw_element")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250227131228.8457-4-pkshih@realtek.com
2025-03-05 19:46:40 +08:00
Po-Hao Huang
b521af1dcd wifi: rtw89: fw: update role_maintain H2C command for roles operating on band 1
Add new fields band and port ID to make chips operating on the band and
port ID other than 0, so that multiple vif(s) can be working at the
same time.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250227131228.8457-3-pkshih@realtek.com
2025-03-05 19:46:28 +08:00
Po-Hao Huang
385eff211e wifi: rtw89: fw: use struct to fill role_maintain H2C command
The role_maintain H2C command is to align operating mode of WiFi role,
such as STA or AP modes, between driver and firmware.

Use a struct to fill fields of this H2C command.

Don't change logic at all.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250227131228.8457-2-pkshih@realtek.com
2025-03-05 19:42:03 +08:00
Chih-Kang Chang
e16acf907a wifi: rtw89: Parse channel from IE to correct invalid hardware reports during scanning
For some packets, we could not get channel information from PPDU status.
And this causes wrong frequencies being reported. Parse the channel
information from IE if provided by AP to fix this.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250220064357.17962-1-pkshih@realtek.com
2025-02-27 13:53:35 +08:00
Kuan-Chung Chen
9e9877bd82 wifi: rtw89: add support for HW TKIP crypto
For 8852BTE, 8852CE, and 8922AE, TKIP encryption and decryption
will be handled by hardware. All other chips will retain their
existing software-based encryption and decryption.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250220062344.15836-1-pkshih@realtek.com
2025-02-27 13:45:43 +08:00
Ping-Ke Shih
e072210330 wifi: rtw89: fw: safely cast mfw_hdr pointer from firmware->data
Check size of struct mfw_hdr within firmware->size before type casting
to ensure to validly dereference fields from mfm_hdr pointer. Then,
check if signature field is equal to RTW89_MFW_SIG to assert current
is multi-firmware.

Addresses-Coverity-ID: 1494046 ("Untrusted loop bound")
Addresses-Coverity-ID: 1544385 ("Untrusted array index read")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217064308.43559-6-pkshih@realtek.com
2025-02-21 09:51:43 +08:00
Ping-Ke Shih
dc2fc1a341 wifi: rtw89: fw: add debug message for unexpected secure firmware
If failed to load a non-secure firmware with a secure chip, it only throws
a unclear message:

   rtw89_8922ae 0000:03:00.0: parse fw header fail

To address this case simpler, add a message to point out this.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217064308.43559-5-pkshih@realtek.com
2025-02-21 09:51:26 +08:00
Ping-Ke Shih
56e1acaa0f wifi: rtw89: fw: propagate error code from rtw89_h2c_tx()
The error code should be propagated to callers during downloading firmware
header and body. Remove unnecessary assignment of -1.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217064308.43559-4-pkshih@realtek.com
2025-02-21 09:50:56 +08:00
Ping-Ke Shih
2f9da853f4 wifi: rtw89: fw: get sb_sel_ver via get_unaligned_le32()
The sb_sel_ver is selection version for secure boot recorded in firmware
binary data, and its size is 4 and offset is 58 (not natural alignment).
Use get_unaligned_le32() to get this value safely. Find this by reviewing.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217064308.43559-3-pkshih@realtek.com
2025-02-21 09:50:44 +08:00
Ping-Ke Shih
f11d042b3a wifi: rtw89: fw: add blacklist to avoid obsolete secure firmware
To ensure secure chip only runs expected secure firmware, stop using
obsolete firmware in blacklist which weakness or flaw was found.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217064308.43559-2-pkshih@realtek.com
2025-02-21 09:49:17 +08:00
Ping-Ke Shih
c852d2abee wifi: rtw89: add H2C command of TX time for WiFi 7 chips
BT-coexistence configure WiFi TX time to share time slots with Bluetooth
devices. Since the format is different from WiFi 6 chips, add the new
format accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217063053.38936-3-pkshih@realtek.com
2025-02-21 09:41:31 +08:00
Ping-Ke Shih
a5b8fd3f07 wifi: rtw89: mac: define registers of agg_limit and txcnt_limit to share common flow
The agg_limit and txcnt_limit are used by BT-coexistence to reduce
WiFi TX time at once to share time with Bluetooth devices. Since
these registers address are different from WiFi 6 and 7 chips, define
them accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217063053.38936-2-pkshih@realtek.com
2025-02-21 09:40:13 +08:00
Kuan-Chung Chen
bdce057424 wifi: rtw89: 8922a: fix incorrect STA-ID in EHT MU PPDU
EHT MU PPDU contains user field of EHT-SIG field with STA-ID that
must match AID subfield in the Associate Response. Add a necessary
setting to prevent these from being inconsistent.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250217061235.32031-1-pkshih@realtek.com
2025-02-21 09:37:31 +08:00
Dmitry Antipov
bfc8e71ef6 wifi: rtw89: rtw8852b{t}: fix TSSI debug timestamps
Since the vendor driver is claimed to measure 'tssi_alimk_time' of
'struct rtw89_tssi_info' in microseconds, adjust rtw8852b{t}-specific
'_tssi_alimentk()' to not mess the former with nanoseconds and print
both per-call and accumulated times. Compile tested only.

Fixes: 7f18a70d7b ("wifi: rtw89: 8852b: rfk: add TSSI")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250213095006.1308810-1-dmantipov@yandex.ru
2025-02-21 09:29:31 +08:00
Ping-Ke Shih
a0519433ad wifi: rtw89: debugfs depends on CFG80211's one
The wiphy_locked_debugfs_read() and wiphy_locked_debugfs_write() used
by rtw89 are defined if CFG80211_DEBUGFS enabled. Add the dependency
accordingly.

Fixes: 8fdf78f3cd ("wifi: rtw89: debugfs: use wiphy_locked_debugfs_{read,write}() if needed")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502101810.3CUpUL7p-lkp@intel.com/
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250210123105.10466-1-pkshih@realtek.com
2025-02-10 20:56:47 +08:00
Ping-Ke Shih
85c726b20f wifi: rtw89: regd: avoid using BITMAP_FROM_U64() to assign function bitmap
Since there are two function features for now, func_bitmap[] has single
one element, which BITMAP_FROM_U64() generating two elements is exceeded.
Change to assign function bitmap barely.

With i386-allmodconfig (a 32 bit system), it throws

 >> include/linux/bitmap.h:736:33: warning: excess elements in array initializer
      736 |                                 ((unsigned long) ((u64)(n) >> 32))
          |                                 ^
    drivers/net/wireless/realtek/rtw89/regd.c:16:34: note: in expansion of macro 'BITMAP_FROM_U64'
       16 |                 .func_bitmap = { BITMAP_FROM_U64(_fmap), },     \
          |                                  ^~~~~~~~~~~~~~~
    drivers/net/wireless/realtek/rtw89/regd.c:20:9: note: in expansion of macro 'COUNTRY_REGD'
       20 |         COUNTRY_REGD("00", RTW89_WW, RTW89_WW, RTW89_WW, 0x0);
          |         ^~~~~~~~~~~~

Fixes: 79a36fc56b ("wifi: rtw89: regd: handle supported regulatory functions by country")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502031932.BMQ4lhJT-lkp@intel.com/
Cc: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250205014051.13765-1-pkshih@realtek.com
2025-02-10 11:26:49 +08:00
Ching-Te Ku
f94ba3c640 wifi: rtw89: coex: Update Wi-Fi/Bluetooth coexistence version to 7.0.3
Refine the TWS Bluetooth related coexistence mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250205013233.10945-4-pkshih@realtek.com
2025-02-10 11:19:44 +08:00
Ching-Te Ku
e53aa85e4b wifi: rtw89: coex: To avoid TWS serials A2DP lag, adjust slot arrangement
The TWS(True wireless stereo) serials Bluetooth audio device need to keep
packet traffic not only with DUT, it also need to synchronize packet with
its assistant earbud. And all the BR/EDR Bluetooth device need to do page
scan to keep re-connect event sensitively between different DUT.
These behavior will make TWS Bluetooth device cost more time slot to keep
the good audio performance. This patch decrease half of Wi-Fi slot(from
40ms to 20ms) in a single cycle. Make the slot more flexible to prevent
audio lag. The single cycle will be shorter, then it will bring some slot
protection cost make Wi-Fi throughput decrease about 5%.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250205013233.10945-3-pkshih@realtek.com
2025-02-10 11:19:32 +08:00
Ching-Te Ku
2e4c4717b3 wifi: rtw89: coex: Assign value over than 0 to avoid firmware timer hang
If the slot duration is 0, the firmware timer will trigger timer hang at
the timer initializing state in a low rate due to hardware algorithm.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250205013233.10945-2-pkshih@realtek.com
2025-02-10 11:19:18 +08:00
Ping-Ke Shih
2b8bdc5237 wifi: rtw89: fw: validate multi-firmware header before getting its size
To access firmware elements appended after multi-firmware, add its size
as offset to get start address of firmware elements.

         +-----+-------+------+---------+--------------+ --
         | sig | fw_nr | rsvd | version | reserved     |   \
         +---------------------------------------------+   |
 fw 0    | cv | type | mp | rsvd | shift | size | rsvd |   |
         +---------------------------------------------+   |
 fw 1    | cv | type | mp | rsvd | shift | size | rsvd |   |
         +---------------------------------------------+   |
 fw N-1  |                  ...                        |   |
         +=============================================+   | mfw size
         |               fw 0 content                  |   |
         +=============================================+   |
         |               fw 1 content                  |   |
         +=============================================+   |
         |                  ...                        |   |
         +=============================================+   |
         |               fw N -1 content               |   |
         +=============================================+ --/
         |             fw element TLV X                |
         +=============================================+
         |             fw element TLV Y                |
         +=============================================+
         |             fw element TLV Z                |
         +=============================================+

To avoid Coverity warning when getting mfw size, validate it header ahead.

Addresses-Coverity-ID: 1544385 ("Untrusted array index read")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250203072911.47313-5-pkshih@realtek.com
2025-02-10 11:02:03 +08:00
Ping-Ke Shih
1f0efffd59 wifi: rtw89: fw: validate multi-firmware header before accessing
A firmeware file contains multi-firmware with a header to represent
contents. The mfw_hdr->fw_nr is to define number of firmware in file.

         +-----+-------+------+---------+--------------+
         | sig | fw_nr | rsvd | version | reserved     |
         +---------------------------------------------+ --
 fw 0    | cv | type | mp | rsvd | shift | size | rsvd |   \
         +---------------------------------------------+   |
 fw 1    | cv | type | mp | rsvd | shift | size | rsvd |   | mfw_hdr->fw_nr
         +---------------------------------------------+   |
 fw N-1  |                  ...                        |   /
         +=============================================+ --
         |               fw 0 content                  |
         |       (pointed by fw0 shift/size)           |
         +=============================================+

To avoid Coverity warning, validate header is in range of firmware size,
and also validate the range of actual firmware content is in range.

Addresses-Coverity-ID: 1494046 ("Untrusted loop bound")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250203072911.47313-4-pkshih@realtek.com
2025-02-10 11:01:51 +08:00
Eric Huang
5dde1a569c wifi: rtw89: ps: update H2C command with more info for PS
Adding beacon BW offset, OP1dB table and rfe_type to lps_ml_cmn_info.
These information will help FW to configure RX more accurately.

Signed-off-by: Eric Huang <echuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250203072911.47313-3-pkshih@realtek.com
2025-02-10 11:00:31 +08:00
Ping-Ke Shih
d078f5857a wifi: rtw89: call power_on ahead before selecting firmware
Driver selects firmware by hardware version, which normally can be read
from registers before selecting firmware. However, certain chips such as
RTL8851B, it needs to read hardware version from efuse while doing
power_on, but do power_on after selecting firmware in current flow.

To resolve this flow problem, move power_on out from
rtw89_mac_partial_init(), and call rtw89_mac_pwr_on() separately at
proper places to have expected flow.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250203072911.47313-2-pkshih@realtek.com
2025-02-10 10:56:11 +08:00
Ping-Ke Shih
8afa4ff99a wifi: rtw89: pci: not assert wiphy_lock to free early_h2c for PCI probe/remove
Except probe/remove flow, the consumers of early_h2c list are interface
start and debugfs. There must be no race between probe/remove flow and
interface start. The failed probe flow is to free early_h2c list as well
as remove flow, at these two moments debugfs doesn't present. Thus, it is
safe to free early_h2c list without held wiphy_lock in these situations.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-11-pkshih@realtek.com
2025-02-03 10:30:16 +08:00
Ping-Ke Shih
2345f351c7 wifi: rtw89: remove definition of driver mutex
No consumers of driver mutex now, so remove definition eventually.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-10-pkshih@realtek.com
2025-02-03 10:28:57 +08:00
Ping-Ke Shih
ed114a7ac6 wifi: rtw89: manual cosmetic along lockdep_assert_wiphy()
With spatch script, already remove most driver mutex and generate
lockdep_assert_wiphy(), and some are needed to refine manually further to
be expected:

- lockdep_assert_wiphy() always be the first statement in function
- return directly rather than unnecessary goto
- change assert from mutex to wiphy lock, which script can't convert
  automatically.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-9-pkshih@realtek.com
2025-02-03 10:28:16 +08:00
Ping-Ke Shih
6ee1937d8b wifi: rtw89: remove consumers of driver mutex
All need lock have taken both driver mutex and wiphy lock, so we can remove
driver mutex safely by below spatch script. Also, check every
lockdep_assert_wiphy() is executed without locks warning at runtime.

@ rule1_1 @
@@

- lockdep_assert_held(&rtwdev->mutex);
+ lockdep_assert_wiphy(rtwdev->hw->wiphy);

@ rule1_2 @
@@

- guard(mutex)(&rtwdev->mutex);
+ lockdep_assert_wiphy(rtwdev->hw->wiphy);

@ rule2_1 @
@@

- mutex_lock(&rtwdev->mutex);
+ lockdep_assert_wiphy(rtwdev->hw->wiphy);
  ...
- mutex_unlock(&rtwdev->mutex);

@ rule2_2 @
@@

- mutex_unlock(&rtwdev->mutex);
+ lockdep_assert_wiphy(rtwdev->hw->wiphy);
  ...
- mutex_lock(&rtwdev->mutex);

@ rule3_1 @
type t;
identifier fn;
@@
  t fn(struct wiphy *wiphy, ...)
  {
  ...
- lockdep_assert_wiphy(rtwdev->hw->wiphy);
+ lockdep_assert_wiphy(wiphy);
  ...
  }

@ rule3_1_1 @
type t;
identifier fn;
@@
  t fn(...)
  {
  ...
  struct wiphy *wiphy = ...;
  ...
- lockdep_assert_wiphy(rtwdev->hw->wiphy);
+ lockdep_assert_wiphy(wiphy);
  ...
  }

@ rule3_2 @
type t;
identifier fn;
@@
  t fn(struct ieee80211_hw *hw, ...)
  {
  ...
- lockdep_assert_wiphy(rtwdev->hw->wiphy);
+ lockdep_assert_wiphy(hw->wiphy);
  ...
  }

@ rule3_2_1 @
type t;
identifier fn;
@@
  t fn(...)
  {
  ...
  struct ieee80211_hw *hw = ...;
  ...
- lockdep_assert_wiphy(rtwdev->hw->wiphy);
+ lockdep_assert_wiphy(hw->wiphy);
  ...
  }

The compiler warnings will be fixed manually by latter patch:

  rtw89/mac80211.c:371:1: warning: statement expected after label

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-8-pkshih@realtek.com
2025-02-03 10:27:36 +08:00
Ping-Ke Shih
bdf874dc3c wifi: rtw89: debugfs: use debugfs_short_fops
With this change, the object code size can reduce 768 bytes.

   text    data     bss     dec     hex filename
  77257    4262       4   81523   13e73 debug.o   (before)
  76489    4262       4   80755   13b73 debug.o   (after)

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-7-pkshih@realtek.com
2025-02-03 10:27:26 +08:00
Ping-Ke Shih
8fdf78f3cd wifi: rtw89: debugfs: use wiphy_locked_debugfs_{read,write}() if needed
If a debugfs entry takes driver mutex now, let it uses
wiphy_locked_debugfs_{read,write}() to take both driver mutex and
wiphy lock. Add rwlock option to support this.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-6-pkshih@realtek.com
2025-02-03 10:26:11 +08:00
Ping-Ke Shih
01fd45d9e1 wifi: rtw89: debugfs: specify buffer size allocated by devm_kazlloc() for reading
Some debufs entries need output buffer over default size 4K. Since reading
of many debugfs entries is to access IO, it costs time to dynamically
re-allocate larger buffer and access IO again and again. Add an option to
specify the size it needs.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-5-pkshih@realtek.com
2025-02-03 10:26:02 +08:00
Ping-Ke Shih
831cceed3b wifi: rtw89: debugfs: implement file_ops::read/write to replace seq_file
Since debugfs needs wiphy lock held, wiphy_locked_debugfs_{read,write}()
will be adopted, so implmenet file_ops::read/write along with their
arguments.

For reading part, it needs lots of changes because seq_file is not
suitable for wiphy_locked_debugfs_{read,write}(), so use spatch script
below to convert basically, and manually implement the functions.

  @ rule1 @
  identifier m;
  @@

  - seq_printf(m,
  + p += scnprintf(p, end - p,
    ...)

  @ rule2 @
  identifier m;
  @@

  - seq_puts(m,
  + p += scnprintf(p, end - p,
    ...)

For current version, only 4K buffer to output. To note ourselves, add
ellipsis symbol "..." to trailing if buffer is full. Later, add an option
to specify buffer size needed by a debugfs entry.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-4-pkshih@realtek.com
2025-02-03 10:24:26 +08:00
Ping-Ke Shih
4afde17d26 wifi: rtw89: use wiphy_work() to replace ieee802111_work()
For certain works protected by driver mutex, use wiphy_work() directly
to have wiphy lock held naturally. Then every this kind of works is
protected by both wiphy lock and driver mutex.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-3-pkshih@realtek.com
2025-02-03 10:23:05 +08:00
Ping-Ke Shih
ebfc9199df wifi: rtw89: add wiphy_lock() to work that isn't held wiphy_lock() yet
To ensure where are protected by driver mutex can also be protected by
wiphy_lock(), so afterward we can remove driver mutex safely.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-2-pkshih@realtek.com
2025-02-03 10:22:55 +08:00
Zong-Zhe Yang
c281bdb882 wifi: rtw89: cleanup unused rtwdev::roc_work
The needed one was moved to rtwvif::roc_work. And, rtwdev::roc_work is
unused. So, remove it.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250120034004.21135-1-pkshih@realtek.com
2025-02-03 10:15:35 +08:00
Zong-Zhe Yang
b45acf2455 wifi: rtw89: regd: refactor init/setup flow and prototype
The regulatory and wiphy setup should be done in rtw89_regd_setup(). And,
what rtw89_regd_init() should do is to initialize target regulatory domain
(regd), if and only if one is programmed in efuse. Since HW is registered
after rtw89_regd_setup() and before rtw89_regd_init(), do not fill fields
of regulatory in rtw89_regd_init(). So, move the regulatory->reg_6ghz_power
assignment into rtw89_regd_setup().

Besides, rtw89_regd_notifier is assigned in rtw89_regd_setup() instead of
rtw89_regd_init(). To reduce confusion, stop passing rtw89_regd_notifier to
rtw89_regd_init(). And, rename rtw89_regd_init() to rtw89_regd_init_hint().

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250120032723.19042-4-pkshih@realtek.com
2025-02-03 10:07:59 +08:00
Zong-Zhe Yang
79a36fc56b wifi: rtw89: regd: handle supported regulatory functions by country
There are two regulatory functions including TAS (Time Average SAR) and
DAG (Dynamic Antenna Gain) for now. They are used to improve RF behavior.
But, availability depends on country. Extend regd map to record the status
of whether a country allows to enable certain regulatory functions.

Also, extend the handling of loading regd map via FW element for this.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250120032723.19042-3-pkshih@realtek.com
2025-02-03 10:06:39 +08:00
Zong-Zhe Yang
e7196b32a4 wifi: rtw89: regd: support loading regd table from fw element
Regd table is a table that we use to describe how to map Realtek RF TX
power settings on different countries. Originally, a common regd table
for all chips is implemented in driver. However, in order to work on all
chips, the common regd table might have some trade-off. So now, there are
also an individual regd table for some chips. And, we support loading it
from FW element.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250120032723.19042-2-pkshih@realtek.com
2025-02-03 10:04:46 +08:00
Ping-Ke Shih
076652f56e wifi: rtw89: phy: disable CFO track when two PHY are working simultaneously
To have good performance, adjust hardware XTAL to track CFO (carrier
frequency offset). However, there is only one hardware XTAL, so it is not
possible to track on two PHY simultaneously. It also can't track on single
one PHY when two PHY are working, because the adjustment of XTAL will
affect all PHY. Thus, disable CFO track for this case.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-9-pkshih@realtek.com
2025-02-03 09:57:06 +08:00
Ping-Ke Shih
0a51f04a9a wifi: rtw89: phy: support EDCCA log per PHY
The registers of EDCCA log for PHY 1 isn't a simple offset, so define
them accordingly. Then the function use register set to access reports
according to phy_idx.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-8-pkshih@realtek.com
2025-02-03 09:55:20 +08:00
Ping-Ke Shih
af5fa884e2 wifi: rtw89: phy: support EDCCA per PHY
Dynamic mechanism EDCCA (Energy Detection Clear Channel Assessment) is to
dynamically adjusted to make EDCCA suitable for situations.

Use PHY context to support two PHY.

For the EDCCA log part, registers to report EDCCA for PHY 1 is not a
simple offset from PHY 0, so add them by separate patch.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-7-pkshih@realtek.com
2025-02-03 09:53:42 +08:00
Ping-Ke Shih
786e485c61 wifi: rtw89: phy: support ch_info per PHY
The ch_info is to record current channel info such as minimum RSSI of
connected stations, and to assist in dynamic mechanisms of DIG and EDCCA.

Move the struct to PHY context, so the dynamic mechanisms can use the info
of the same PHY.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-6-pkshih@realtek.com
2025-02-03 09:52:08 +08:00
Ping-Ke Shih
dc0ac60f2a wifi: rtw89: phy: support DIG per PHY
DIG standing for dynamic initial gain is to define RX coverage. Adjust this
value dynamically to gain good RX performance.

Use PHY context to extend DIG algorithm to support two PHY.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-5-pkshih@realtek.com
2025-02-03 09:50:48 +08:00
Ping-Ke Shih
11a625160a wifi: rtw89: phy: support env_monitor per PHY
The env_monitor is to collect information of current operating channel as
helper to make decision with better hardware parameters to adopt current
environment.

Use PHY context as argument to control PHY accordingly, and use
rtw89_phy_{write32,read32}_idx with phy_idx to access registers.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-4-pkshih@realtek.com
2025-02-03 09:49:24 +08:00
Ping-Ke Shih
57a6cdf2fe wifi: rtw89: phy: add PHY context array to support functions per PHY
To support MLO working on PHY 0 and PHY 1, extend existing PHY dynamic
mechanism from PHY 0 to PHY 0/1.

Implement a 2 elements array for two PHY instances, and pass pointer
of each element as argument to existing functions. Then existing algorithm
is kept, unchanged.

Also provide iterate and get function to access PHY context.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-3-pkshih@realtek.com
2025-02-03 09:45:59 +08:00
Ping-Ke Shih
f0dc53a7b7 wifi: rtw89: phy: rename to RTW89_PHY_NUM as proper naming
The meaning is number of PHY, not maximum ID of PHY. Change to proper
naming.

No change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250117072828.16728-2-pkshih@realtek.com
2025-02-03 09:41:19 +08:00
Liang Jie
361cb056e2 wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
Ensures the correct calculation of `cfg_len` prior to the allocation of
the skb in the `rtw89_fw_h2c_scan_offload_be` function, particularly when
the `SCAN_OFFLOAD_BE_V0` firmware feature is enabled. It addresses an
issue where an incorrect skb size might be allocated due to a delayed
setting of `cfg_len`, potentially leading to memory inefficiencies.

By moving the conditional check and assignment of `cfg_len` before skb
allocation, the patch guarantees that `len`, which depends on `cfg_len`,
is accurately computed, ensuring proper skb size and preventing any
unnecessary memory reservation for firmware operations not supporting
beyond the `w8` member of the command data structure.

This correction helps to optimize memory usage and maintain consistent
behavior across different firmware versions.

Fixes: 6ca6b918f2 ("wifi: rtw89: 8922a: Add new fields for scan offload H2C command")
Signed-off-by: Liang Jie <liangjie@lixiang.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250112105144.615474-1-buaajxlj@163.com
2025-01-20 09:27:25 +08:00
Ching-Te Ku
dbb6a738f6 wifi: rtw89: coex: Update Wi-Fi/Bluetooth coexistence version to 7.0.2
With this version, fix Wi-Fi scan/connecting/RF calibration triggered A2DP
sound lag related issues.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250110015416.10704-4-pkshih@realtek.com
2025-01-20 09:19:26 +08:00
Ching-Te Ku
4a57346652 wifi: rtw89: coex: Separated Wi-Fi connecting event from Wi-Fi scan event
Wi-Fi connecting process don't need to assign to firmware slot control,
if assign firmware slot control for Wi-Fi connecting event, firmware will
not toggle slots because driver don't tell the slot schedule to firmware.
Wi-Fi connecting event end should also cancel the 4way handshake status.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250110015416.10704-3-pkshih@realtek.com
2025-01-20 09:19:13 +08:00
Ching-Te Ku
5251fd3216 wifi: rtw89: coex: Add protect to avoid A2DP lag while Wi-Fi connecting
To get a well Wi-Fi RF quality, Wi-Fi need to do RF calibrations. While
Wi-Fi is doing RF calibrations, driver will pause the Bluetooth traffic
to make sure the RF calibration will not be interfered by Bluetooth.
However, if the RF calibrations take too much time, Bluetooth audio
will perform a lag sound. Add a function to make Bluetooth can do
traffic between the individual calibrations to avoid Bluetooth sound
lag. And patch related A2DP coexistence mechanism actions.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250110015416.10704-2-pkshih@realtek.com
2025-01-20 09:14:44 +08:00
Ping-Ke Shih
456ad3210a wifi: rtw89: 8922ae: add variant info to support RTL8922AE-VS
RTL8922AE-VS is a variant of RTL8922AE, which is supported by firmware
version after 0.35.54.0 and only can support up to MCS11. Add a variant
struct to describe these requirements accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250108020955.14668-3-pkshih@realtek.com
2025-01-12 09:36:49 +08:00
Ping-Ke Shih
3f0e689089 wifi: rtw89: read hardware capabilities part 1 via firmware command
Firmware after version 0.35.51.0 defines and exports more hardware
capabilities, which driver will consider reported QAM field as
EHT MCS capability to register hardware.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250108020955.14668-2-pkshih@realtek.com
2025-01-12 09:35:22 +08:00
Ping-Ke Shih
ba4bb0402c wifi: rtw89: fix race between cancel_hw_scan and hw_scan completion
The rtwdev->scanning flag isn't protected by mutex originally, so
cancel_hw_scan can pass the condition, but suddenly hw_scan completion
unset the flag and calls ieee80211_scan_completed() that will free
local->hw_scan_req. Then, cancel_hw_scan raises null-ptr-deref and
use-after-free. Fix it by moving the check condition to where
protected by mutex.

 KASAN: null-ptr-deref in range [0x0000000000000088-0x000000000000008f]
 CPU: 2 PID: 6922 Comm: kworker/2:2 Tainted: G           OE
 Hardware name: LENOVO 2356AD1/2356AD1, BIOS G7ETB6WW (2.76 ) 09/10/2019
 Workqueue: events cfg80211_conn_work [cfg80211]
 RIP: 0010:rtw89_fw_h2c_scan_offload_be+0xc33/0x13c3 [rtw89_core]
 Code: 00 45 89 6c 24 1c 0f 85 23 01 00 00 48 8b 85 20 ff ff ff 48 8d
 RSP: 0018:ffff88811fd9f068 EFLAGS: 00010206
 RAX: dffffc0000000000 RBX: ffff88811fd9f258 RCX: 0000000000000001
 RDX: 0000000000000011 RSI: 0000000000000001 RDI: 0000000000000089
 RBP: ffff88811fd9f170 R08: 0000000000000000 R09: 0000000000000000
 R10: ffff88811fd9f108 R11: 0000000000000000 R12: ffff88810e47f960
 R13: 0000000000000000 R14: 000000000000ffff R15: 0000000000000000
 FS:  0000000000000000(0000) GS:ffff8881d6f00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 00007531dfca55b0 CR3: 00000001be296004 CR4: 00000000001706e0
 Call Trace:
  <TASK>
  ? show_regs+0x61/0x73
  ? __die_body+0x20/0x73
  ? die_addr+0x4f/0x7b
  ? exc_general_protection+0x191/0x1db
  ? asm_exc_general_protection+0x27/0x30
  ? rtw89_fw_h2c_scan_offload_be+0xc33/0x13c3 [rtw89_core]
  ? rtw89_fw_h2c_scan_offload_be+0x458/0x13c3 [rtw89_core]
  ? __pfx_rtw89_fw_h2c_scan_offload_be+0x10/0x10 [rtw89_core]
  ? do_raw_spin_lock+0x75/0xdb
  ? __pfx_do_raw_spin_lock+0x10/0x10
  rtw89_hw_scan_offload+0xb5e/0xbf7 [rtw89_core]
  ? _raw_spin_unlock+0xe/0x24
  ? __mutex_lock.constprop.0+0x40c/0x471
  ? __pfx_rtw89_hw_scan_offload+0x10/0x10 [rtw89_core]
  ? __mutex_lock_slowpath+0x13/0x1f
  ? mutex_lock+0xa2/0xdc
  ? __pfx_mutex_lock+0x10/0x10
  rtw89_hw_scan_abort+0x58/0xb7 [rtw89_core]
  rtw89_ops_cancel_hw_scan+0x120/0x13b [rtw89_core]
  ieee80211_scan_cancel+0x468/0x4d0 [mac80211]
  ieee80211_prep_connection+0x858/0x899 [mac80211]
  ieee80211_mgd_auth+0xbea/0xdde [mac80211]
  ? __pfx_ieee80211_mgd_auth+0x10/0x10 [mac80211]
  ? cfg80211_find_elem+0x15/0x29 [cfg80211]
  ? is_bss+0x1b7/0x1d7 [cfg80211]
  ieee80211_auth+0x18/0x27 [mac80211]
  cfg80211_mlme_auth+0x3bb/0x3e7 [cfg80211]
  cfg80211_conn_do_work+0x410/0xb81 [cfg80211]
  ? __pfx_cfg80211_conn_do_work+0x10/0x10 [cfg80211]
  ? __kasan_check_read+0x11/0x1f
  ? psi_group_change+0x8bc/0x944
  ? __kasan_check_write+0x14/0x22
  ? mutex_lock+0x8e/0xdc
  ? __pfx_mutex_lock+0x10/0x10
  ? __pfx___radix_tree_lookup+0x10/0x10
  cfg80211_conn_work+0x245/0x34d [cfg80211]
  ? __pfx_cfg80211_conn_work+0x10/0x10 [cfg80211]
  ? update_cfs_rq_load_avg+0x3bc/0x3d7
  ? sched_clock_noinstr+0x9/0x1a
  ? sched_clock+0x10/0x24
  ? sched_clock_cpu+0x7e/0x42e
  ? newidle_balance+0x796/0x937
  ? __pfx_sched_clock_cpu+0x10/0x10
  ? __pfx_newidle_balance+0x10/0x10
  ? __kasan_check_read+0x11/0x1f
  ? psi_group_change+0x8bc/0x944
  ? _raw_spin_unlock+0xe/0x24
  ? raw_spin_rq_unlock+0x47/0x54
  ? raw_spin_rq_unlock_irq+0x9/0x1f
  ? finish_task_switch.isra.0+0x347/0x586
  ? __schedule+0x27bf/0x2892
  ? mutex_unlock+0x80/0xd0
  ? do_raw_spin_lock+0x75/0xdb
  ? __pfx___schedule+0x10/0x10
  process_scheduled_works+0x58c/0x821
  worker_thread+0x4c7/0x586
  ? __kasan_check_read+0x11/0x1f
  kthread+0x285/0x294
  ? __pfx_worker_thread+0x10/0x10
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x29/0x6f
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1b/0x30
  </TASK>

Fixes: 8959077797 ("rtw89: 8852a: add ieee80211_ops::hw_scan")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250107114254.6769-1-pkshih@realtek.com
2025-01-12 09:31:11 +08:00
Zong-Zhe Yang
35642ba31d wifi: rtw89: mcc: consider time limits not divisible by 1024
For each MCC role, time limits, including max_tob_us, max_toa_us, and
mac_dur_us, are calculated if there are NoA attributes. The relation
between these time limits is "max_dur_us = max_tob_us + max_toa_us".
Then, the unit is converted from us to TU. However, originally, each
time limit was divided by 1024 independently. It missed to consider
the cases that max_tob_us or max_toa_us is not divisible by 1024. It
causes the result breaks "max_dur (TU) = max_tob (TU) + max_toa (TU)".
Finally, when MCC calculates pattern parameters based on these kinds
of time limits, it might not perform well.

Fixes: b09df09b55 ("wifi: rtw89: mcc: initialize start flow")
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250103074412.124066-1-pkshih@realtek.com
2025-01-12 09:28:33 +08:00
Ping-Ke Shih
6ab452d458 wifi: rtw89: pci: treat first receiving part as first segment for 8922AE
For early chips, the RX BD info contains FS/LS bits for first/last segments
of a receiving packet. For 8922AE, the FS bit should be ignored, or it
may throw warning:

  rtw89_8922ae 0000:1a:00.0: skb should not be ready before first segment start

To have compatible logic, FS determined by what pending skb is existing
(!new) or not.

Since we expect every single receiving packet in single one segment,
enlarge 4 bytes for RX BD info, and add a debug message to note if
RX buffer is possibly smaller than expected size.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250103025126.15378-1-pkshih@realtek.com
2025-01-12 09:24:21 +08:00
Chih-Kang Chang
2f7667675d wifi: rtw89: avoid to init mgnt_entry list twice when WoWLAN failed
If WoWLAN failed in resume flow, the rtw89_ops_add_interface() triggered
without removing the interface first. Then the mgnt_entry list init again,
causing the list_empty() check in rtw89_chanctx_ops_assign_vif()
useless, and list_add_tail() again. Therefore, we have added a check to
prevent double adding of the list.

rtw89_8852ce 0000:01:00.0: failed to check wow status disabled
rtw89_8852ce 0000:01:00.0: wow: failed to check disable fw ready
rtw89_8852ce 0000:01:00.0: wow: failed to swap to normal fw
rtw89_8852ce 0000:01:00.0: failed to disable wow
rtw89_8852ce 0000:01:00.0: failed to resume for wow -110
rtw89_8852ce 0000:01:00.0: MAC has already powered on
i2c_hid_acpi i2c-ILTK0001:00: PM: acpi_subsys_resume+0x0/0x60 returned 0 after 284705 usecs
list_add corruption. prev->next should be next (ffff9d9719d82228), but was ffff9d9719f96030. (prev=ffff9d9719f96030).
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:34!
invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
CPU: 2 PID: 6918 Comm: kworker/u8:19 Tainted: G     U     O
Hardware name: Google Anraggar/Anraggar, BIOS Google_Anraggar.15217.514.0 03/25/2024
Workqueue: events_unbound async_run_entry_fn
RIP: 0010:__list_add_valid_or_report+0x9f/0xb0
Code: e8 56 89 ff ff 0f 0b 48 c7 c7 3e fc e0 96 48 89 c6 e8 45 89 ff ...
RSP: 0018:ffffa51b42bbbaf0 EFLAGS: 00010246
RAX: 0000000000000075 RBX: ffff9d9719d82ab0 RCX: 13acb86e047a4400
RDX: 3fffffffffffffff RSI: 0000000000000000 RDI: 00000000ffffdfff
RBP: ffffa51b42bbbb28 R08: ffffffff9768e250 R09: 0000000000001fff
R10: ffffffff9765e250 R11: 0000000000005ffd R12: ffff9d9719f95c40
R13: ffff9d9719f95be8 R14: ffff9d97081bfd78 R15: ffff9d9719d82060
FS:  0000000000000000(0000) GS:ffff9d9a6fb00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007e7d029a4060 CR3: 0000000345e38000 CR4: 0000000000750ee0
PKRU: 55555554
Call Trace:
 <TASK>
 ? __die_body+0x68/0xb0
 ? die+0xaa/0xd0
 ? do_trap+0x9f/0x170
 ? __list_add_valid_or_report+0x9f/0xb0
 ? __list_add_valid_or_report+0x9f/0xb0
 ? handle_invalid_op+0x69/0x90
 ? __list_add_valid_or_report+0x9f/0xb0
 ? exc_invalid_op+0x3c/0x50
 ? asm_exc_invalid_op+0x16/0x20
 ? __list_add_valid_or_report+0x9f/0xb0
 rtw89_chanctx_ops_assign_vif+0x1f9/0x210 [rtw89_core cbb375c44bf28564ce479002bff66617a25d9ac1]
 ? __mutex_unlock_slowpath+0xa0/0xf0
 rtw89_ops_assign_vif_chanctx+0x4b/0x90 [rtw89_core cbb375c44bf28564ce479002bff66617a25d9ac1]
 drv_assign_vif_chanctx+0xa7/0x1f0 [mac80211 6efaad16237edaaea0868b132d4f93ecf918a8b6]
 ieee80211_reconfig+0x9cb/0x17b0 [mac80211 6efaad16237edaaea0868b132d4f93ecf918a8b6]
 ? __pfx_wiphy_resume+0x10/0x10 [cfg80211 572d03acaaa933fe38251be7fce3b3675284b8ed]
 ? dev_printk_emit+0x51/0x70
 ? _dev_info+0x6e/0x90
 wiphy_resume+0x89/0x180 [cfg80211 572d03acaaa933fe38251be7fce3b3675284b8ed]
 ? __pfx_wiphy_resume+0x10/0x10 [cfg80211 572d03acaaa933fe38251be7fce3b3675284b8ed]
 dpm_run_callback+0x37/0x1e0
 device_resume+0x26d/0x4b0
 ? __pfx_dpm_watchdog_handler+0x10/0x10
 async_resume+0x1d/0x30
 async_run_entry_fn+0x29/0xd0
 worker_thread+0x397/0x970
 kthread+0xed/0x110
 ? __pfx_worker_thread+0x10/0x10
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x38/0x50
 ? __pfx_kthread+0x10/0x10
 ret_from_fork_asm+0x1b/0x30
 </TASK>

Fixes: 68ec751b28 ("wifi: rtw89: chan: manage active interfaces")
Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250103024500.14990-1-pkshih@realtek.com
2025-01-12 09:21:19 +08:00
Po-Hao Huang
b2658bf4d7 wifi: rtw89: correct header conversion rule for MLO only
Header conversion should only be used with MLO connections. Otherwise
P2P connection fails due to wrong probe responses sent. Fix it
accordingly.

Fixes: b8499664fc ("wifi: rtw89: Add header conversion for MLO connections")
Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241231004811.8646-4-pkshih@realtek.com
2025-01-12 09:12:30 +08:00
Zong-Zhe Yang
e4790b3e31 wifi: rtw89: chan: fix soft lockup in rtw89_entity_recalc_mgnt_roles()
During rtw89_entity_recalc_mgnt_roles(), there is a normalizing process
which will re-order the list if an entry with target pattern is found.
And once one is found, should have aborted the list_for_each_entry. But,
`break` just aborted the inner for-loop. The outer list_for_each_entry
still continues. Normally, only the first entry will match the target
pattern, and the re-ordering will change nothing, so there won't be
soft lockup. However, in some special cases, soft lockup would happen.

Fix it by `goto fill` to break from the list_for_each_entry.

The following is a sample of kernel log for this problem.

watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [wpa_supplicant:2055]
[...]
RIP: 0010:rtw89_entity_recalc ([...] chan.c:392 chan.c:479) rtw89_core
[...]

Fixes: 68ec751b28 ("wifi: rtw89: chan: manage active interfaces")
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241231004811.8646-3-pkshih@realtek.com
2025-01-12 09:12:20 +08:00
Zong-Zhe Yang
e47f0a5898 wifi: rtw89: fix proceeding MCC with wrong scanning state after sequence changes
When starting/proceeding MCC, it will abort an ongoing hw scan process.
In the proceeding cases, it unexpectedly tries to abort a non-exist hw
scan process. Then, a trace shown at the bottom will happen. This problem
is caused by a previous commit which changed some call sequence inside
rtw89_hw_scan_complete() to fix some coex problems. These changes lead
to our scanning flag was not cleared when proceeding MCC. To keep the
fixes on coex, and resolve the problem here, re-consider the related
call sequence.

The known sequence requirements are listed below.

* the old sequence:
	A. notify coex
	B. clear scanning flag
	C. proceed chanctx
		C-1. set channel
		C-2. proceed MCC
(the problem: A needs to be after C-1)

* the current sequence:
	C. proceed chanctx
		C-1. set channel
		C-2. proceed MCC
	A. notify coex
	B. clear scanning flag
(the problem: C-2 needs to be after B)

So, now let hw scan caller pass a callback to proceed chanctx if needed.
Then, the new sequence will be like the below.
	C-1. set channel
	A. notify coex
	B. clear scanning flag
	C-2. proceed MCC

The following is the kernel log for the problem in current sequence.

rtw89_8852be 0000:04:00.0: rtw89_hw_scan_offload failed ret -110
------------[ cut here ]------------
[...]
CPU: 2 PID: 3991 Comm: kworker/u16:0 Tainted: G           OE      6.6.17 #3
Hardware name: LENOVO 2356AD1/2356AD1, BIOS G7ETB3WW (2.73 ) 11/28/2018
Workqueue: events_unbound wiphy_work_cancel [cfg80211]
RIP: 0010:ieee80211_sched_scan_stopped+0xaea/0xd80 [mac80211]
Code: 9c 24 d0 11 00 00 49 39 dd 0f 85 46 ff ff ff 4c 89 e7 e8 09 2d
RSP: 0018:ffffb27783643d48 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff8a2280964bc0 RSI: 0000000000000000 RDI: ffff8a23df580900
RBP: ffffb27783643d88 R08: 0000000000000001 R09: 0000000000000400
R10: 0000000000000000 R11: 0000000000008268 R12: ffff8a23df580900
R13: ffff8a23df581b00 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff8a258e680000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f26a0654000 CR3: 000000002ea2e002 CR4: 00000000001706e0
Call Trace:
 <TASK>
 ? show_regs+0x68/0x70
 ? ieee80211_sched_scan_stopped+0xaea/0xd80 [mac80211]
 ? __warn+0x8f/0x150
 ? ieee80211_sched_scan_stopped+0xaea/0xd80 [mac80211]
 ? report_bug+0x1f5/0x200
 ? handle_bug+0x46/0x80
 ? exc_invalid_op+0x19/0x70
 ? asm_exc_invalid_op+0x1b/0x20
 ? ieee80211_sched_scan_stopped+0xaea/0xd80 [mac80211]
 ieee80211_scan_work+0x14a/0x650 [mac80211]
 ? __queue_work+0x10f/0x410
 wiphy_work_cancel+0x2fb/0x310 [cfg80211]
 process_scheduled_works+0x9d/0x390
 ? __pfx_worker_thread+0x10/0x10
 worker_thread+0x15b/0x2d0
 ? __pfx_worker_thread+0x10/0x10
 kthread+0x108/0x140
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x3c/0x60
 ? __pfx_kthread+0x10/0x10
 ret_from_fork_asm+0x1b/0x30
 </TASK>
---[ end trace 0000000000000000 ]---

Fixes: f16c40acd3 ("wifi: rtw89: Fix TX fail with A2DP after scanning")
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241231004811.8646-2-pkshih@realtek.com
2025-01-12 09:09:11 +08:00
Chin-Yen Lee
f69ccbc50a wifi: rtw89: pci: disable PCI completion timeout control
Realtek's chips follow suggestion of PCIe spec to design the max timeout of
PCI completion, but some PCIe host reply too slow to meet it and lead PCI
AER. Disable PCI completion timeout function via PCI configuration to
avoid the AER.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241225122804.10214-1-pkshih@realtek.com
2025-01-07 15:40:58 +08:00
Zong-Zhe Yang
2927cb7b3b wifi: rtw89: debug: print regd for QATAR/UK/THAILAND
The regd enum was extended for these countries. But, the dbgfs doesn't
recognize them yet. So, add them.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241219014545.9157-1-pkshih@realtek.com
2024-12-30 09:25:29 +08:00
Chih-Kang Chang
f8bcfb2076 wifi: rtw89: adjust thermal protection step and more RTL8852BE-VT ID
To have better tuning of TX duty for fields usage, adjust thermal
protection step to 5, then TX duty reduce to 75% at most. Add RTL8852BE-VT
ID to enable this function by the way.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241219014511.9056-1-pkshih@realtek.com
2024-12-30 09:14:15 +08:00
Ping-Ke Shih
0948981201 wifi: rtw89: phy: add dummy C2H event handler for report of TAS power
The newer firmware, lik RTL8852C version 0.27.111.0, will notify driver
report of TAS (Time Averaged SAR) power by new C2H events. This is to
assist in higher accurate calculation of TAS.

For now, driver doesn't use the report yet, so add a dummy handler to
avoid it throws info like:
   rtw89_8852ce 0000:03:00.0: c2h class 9 func 6 not support

Also add "MAC" and "PHY" to the message to disambiguate the source of
C2H event.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241209042127.21424-1-pkshih@realtek.com
2024-12-12 11:09:12 +08:00
Ping-Ke Shih
5fdf5e557f wifi: rtw89: 8851b: rfk: remove unnecessary assignment of return value of _dpk_dgain_read()
The return value of _dpk_dgain_read() is not used afterward, so remove
it safely.

Addresses-Coverity-ID: 1504753 ("Unused value")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241209042020.21290-2-pkshih@realtek.com
2024-12-12 11:06:29 +08:00
Ping-Ke Shih
b6c10a1936 wifi: rtw89: 8852c: rfk: refine target channel calculation in _rx_dck_channel_calc()
The channel is not possibly 0, so original code is fine. Still want to
avoid Coverity warning, so ensure -32 offset for the channel number which
is larger than 125 only. Actually, don't change logic at all.

Addresses-Coverity-ID: 1628150 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241209042020.21290-1-pkshih@realtek.com
2024-12-12 11:06:19 +08:00
Chih-Kang Chang
9ae817c779 wifi: rtw89: 8922a: update format of RFK pre-notify H2C command v2
The RFK pre-notify H2C command is to tell firmware the channels driver is
using. Since the format is changed after 0.35.49.0, update it accordingly.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-8-pkshih@realtek.com
2024-12-12 10:21:52 +08:00
Zong-Zhe Yang
a2854ac338 wifi: rtw89: regd: update regulatory map to R68-R51
Sync Realtek Channel Plan R68 and Realtek Regulatory R51.
Configure 6 GHz field of Realtek regd for the following countries.
	BO, DO, EG, LS, MZ, NG, OM, ZW, PK, PH, TH, KM, CG, CD,
	GE, GI, GU, LR, MH, FM, MP, PW, MF, SX, SZ, TZ, VI
Besides, add entries for the following countries.
	CU, SY, SD

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-7-pkshih@realtek.com
2024-12-12 10:21:43 +08:00
Kuan-Chung Chen
9ddc6ee0b2 wifi: rtw89: 8852c: disable ER SU when 4x HE-LTF and 0.8 GI capability differ
Since hardware only has single one register for HE-LTF setting,
to prevent interoperability issues, 8852CE disables ER SU when
the AP can handle SU/MU with 4x HE-LTF and 0.8 GI, but does
not support ER SU with the same settings.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-6-pkshih@realtek.com
2024-12-12 10:20:27 +08:00
Kuan-Chung Chen
f0441c540f wifi: rtw89: disable firmware training HE GI and LTF
Given the performance trade-off associated with firmware training
HE GI/LTF, especially in high attenuation environments, we have
decided to utilize a constant value instead.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-5-pkshih@realtek.com
2024-12-12 10:19:10 +08:00
Eric Huang
5b4ca80479 wifi: rtw89: ps: update data for firmware and settings for hardware before/after PS
For MLO supported IC, send H2C command to firmware before PS with link
information for each PHY for MLO to work properly. And re-init hardware
settings regarding to RX descriptor information after PS.

Signed-off-by: Eric Huang <echuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-4-pkshih@realtek.com
2024-12-12 10:17:46 +08:00
Ping-Ke Shih
8c86036693 wifi: rtw89: ps: refactor channel info to firmware before entering PS
In PS mode, firmware needs hardware parameters related to channel info
to configure hardware itself. Before entering PS, driver prepares these
info to firmware via firmware H2C command.

Since firmware only consider PS for single one vif, change the argument
of entry function to rtwvif, and only consider first link for this old
H2C command that only support legacy.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-3-pkshih@realtek.com
2024-12-12 10:17:02 +08:00
Ping-Ke Shih
1015d61570 wifi: rtw89: ps: refactor PS flow to support MLO
Firmware can only support PS on single one VIF operating in station mode,
so argument of PS entry rtw89_enter_lps() should be rtwvif insetad of
rtwvif_link.

To enter PS under MLO, for each rtwvif, driver sends H2C command to tell
firmware which mac_id will enter PS one by one, and afterward asks
firmware to enter deep PS.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241206055716.18598-2-pkshih@realtek.com
2024-12-12 10:12:44 +08:00
Chih-Kang Chang
7b98caea39 wifi: rtw89: add crystal_cap check to avoid setting as overflow value
In the original flow, the crystal_cap might be calculated as a negative
value and set as an overflow value. Therefore, we added a check to limit
the calculated crystal_cap value. Additionally, we shrank the crystal_cap
adjustment according to specific CFO.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-7-pkshih@realtek.com
2024-12-05 14:28:30 +08:00
Zong-Zhe Yang
148cd1e184 wifi: rtw89: refine link handling for link_sta_rc_update
The original handling will iterate all active links under the given sta
and apply the changes to each. Now, stack tweaks ops from sta_rc_update
to link_sta_rc_update, which means targeting a given link. Then, our link
iteration looks redundant. So, refine it to apply the changes to the link
directly.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-6-pkshih@realtek.com
2024-12-05 14:27:30 +08:00
Chih-Kang Chang
b6853ed2be wifi: rtw89: 8922a: use RSSI from PHY report in RX descriptor
The PPDU status of probe response will fail to parse the IE due to being
filtered by the to_self check. Therefore, we parse RSSI from PHY report in
RX descriptor.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-5-pkshih@realtek.com
2024-12-05 14:26:05 +08:00
Po-Hao Huang
3374c63111 wifi: rtw89: 8852bt: add beacon filter and CQM support
Declare beacon filter and connection monitor for 8852BT.
This offloads connection monitor mechanism to firmware, and this
is required for the MCC feature.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-4-pkshih@realtek.com
2024-12-05 14:25:52 +08:00
Po-Hao Huang
d56c261e52 wifi: rtw89: 8852b: add beacon filter and CQM support
Declare beacon filter and connection monitor for 8852B.
This offloads connection monitor mechanism to firmware, and this
is required for the MCC feature.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-3-pkshih@realtek.com
2024-12-05 14:25:39 +08:00
Po-Hao Huang
05b6555fee wifi: rtw89: 8922a: Extend channel info field length for scan
Extend the bitfield for duration in channel info to 16 bits.
Update the related format in H2C and C2H, then increase firmware
format sequence to 3.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241128055433.11851-2-pkshih@realtek.com
2024-12-05 14:22:07 +08:00
Zong-Zhe Yang
f79257f5b9 wifi: rtw89: pass target link_id to ieee80211_nullfunc_get()
When calling ieee80211_nullfunc_get(), pass the target link_id
instead of always -1.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-7-pkshih@realtek.com
2024-11-27 11:13:02 +08:00
Zong-Zhe Yang
55709b1954 wifi: rtw89: pass target link_id to ieee80211_gtk_rekey_add()
When calling ieee80211_gtk_rekey_add(), pass the target link_id
instead of always -1.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-6-pkshih@realtek.com
2024-11-27 11:12:53 +08:00
Zong-Zhe Yang
a6db83bef0 wifi: rtw89: apply MLD pairwise key to dynamically active links
In MLD connection, a pairwise key should work on all active links. And, we
take just one entry in security CAM for one pairwise key. (It means we will
reuse one single entry for all links.) Originally, we already applied the
security CAM entry of pairwise key to deflink's address CAM.

However, links can be activated dynamically. So now for pairwise keys, each
rtw89_sta records the IDs of the security CAM entries. Then, when driver is
notified that some links are active via change_sta_links(), we apply target
pairwise keys to them according to the record.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-5-pkshih@realtek.com
2024-11-27 11:11:36 +08:00
Zong-Zhe Yang
d2b387bdca wifi: rtw89: implement ops of change vif/sta links
To support MLO, implement change_vif_links() and change_sta_links() ops.
Basically, we follow arguments to set/clear links. One special thing is
that when vif is idle, i.e. no connection, link id 0 is set up by us for
default uses. So, when bitmap of vif links change from 0x0 to non-zero,
we clear the default one first. And when bitmap of vif links change from
non-zero to 0x0, we set up a default one at the end.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-4-pkshih@realtek.com
2024-11-27 11:10:16 +08:00
Zong-Zhe Yang
c821a8af43 wifi: rtw89: register ops of can_activate_links
Register mac80211 ops of can_activate_links which is required when
we are ready to enable multiple active links.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-3-pkshih@realtek.com
2024-11-27 11:09:00 +08:00
Zong-Zhe Yang
144c6cd24b wifi: rtw89: 8922a: configure AP_LINK_PS if FW supports
After FW v0.35.46.0, for AP mode, RTL8922A FW supports a new FW feature,
called NOTIFY_AP_INFO, to notify driver information related to AP mode.
And, one function of it is to monitor PS states of remote stations. Once
one of them changes, FW will send a C2H event to tell driver. With this
FW feature, we can declare AP_LINK_PS.

For now, driver still needs to determine if a frame is ps-poll or U-APSD
trigger. So, add the corresponding RX handling in driver, which activates
only when at least one AP is running.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241120034054.13575-2-pkshih@realtek.com
2024-11-27 11:07:36 +08:00
Kuan-Chung Chen
50191eace8 wifi: rtw89: handle different TX power between RF path
The dynamic antenna gain (DAG) may independently apply different TX
powers for each RF path. This can be accomplished by using the larger
TX power as the reference path and adjusting the TX power of the
other path based on the difference. Currently only 8852BE/8852BTE/
8852CE are supported.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241111065132.19587-4-pkshih@realtek.com
2024-11-18 10:12:45 +08:00
Kuan-Chung Chen
f0f08a4456 wifi: rtw89: introduce dynamic antenna gain feature
Dynamic Antenna Gain (DAG) adjusts the transmit power based on the
platform's antenna gain. This allows for higher transmit power when
the antenna gain is lower, while still complying with regulatory
limits. The driver reads the Realtek Antenna Gain (RTAG) data from
BIOS, and DAG is only enabled when the regulatory domain allows it.
Currently, it only supports 8852BE/8852BTE/8852CE.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241111065132.19587-3-pkshih@realtek.com
2024-11-18 10:11:25 +08:00
Kuan-Chung Chen
abb541d1e5 wifi: rtw89: sar: tweak 6GHz SAR subbands span
Given that the 6GHz subband edges are not aligned, specific frequencies
can span two adjacent subbands. We considered the need for this
functionality outside of SAR and moved it to a common function.

No logic change for existing chips.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241111065132.19587-2-pkshih@realtek.com
2024-11-18 10:10:08 +08:00
Ping-Ke Shih
9c1df813e0 wifi: rtw89: pci: disable PCIE wake bit when PCIE deinit
The PCIE wake bit is to control PCIE wake signal to host. When PCIE is
going down, clear this bit to prevent waking up host unexpectedly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241111063835.15454-1-pkshih@realtek.com
2024-11-18 10:05:59 +08:00
Jakub Kicinski
5c46638540 wireless-next patches for v6.13
Most likely the last -next pull request for v6.13. Most changes are in
 Realtek and Qualcomm drivers, otherwise not really anything
 noteworthy.
 
 Major changes:
 
 mac80211
 
 * EHT 1024 aggregation size for transmissions
 
 ath12k
 
 * switch to using wiphy_lock() and remove ar->conf_mutex
 
 * firmware coredump collection support
 
 * add debugfs support for a multitude of statistics
 
 ath11k
 
 * dt: document WCN6855 hardware inputs
 
 ath9k
 
 * remove include/linux/ath9k_platform.h
 
 ath5k
 
 * Arcadyan ARV45XX AR2417 & Gigaset SX76[23] AR241[34]A support
 
 rtw88:
 
 * 8821au and 8812au USB adapters support
 
 rtw89
 
 * thermal protection
 
 * firmware secure boot for WiFi 6 chip
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEiBjanGPFTz4PRfLobhckVSbrbZsFAmc04UYRHGt2YWxvQGtl
 cm5lbC5vcmcACgkQbhckVSbrbZuckgf/RV0zy8gMuzJ/cSk1GDKoOYmEwAZ4JvtW
 teAKghsODDW/bng2iKnXphJyx3spZRCNuvOmfPcHsWoResX+vqrKJOaER/3159OF
 68xAPZNXPRF4M693IpIUB/P3uTw/jieXPI7ftSPuUOhStca/ALwQd5Lp3kNKkVtq
 HipXJwCenVS7Hd8DdHbpvYFUckRWr3tHPFlOgG3qOQOVvfRen2z9rhM14oK9rn+h
 f309ATHKTbpTKNagOPYAYcyHs3zE59hlVRgRqHL7Ew0a0HI8uPJ4KK2n5W6tZJFN
 swhoQolc1uXrRYlZ3Bdr7mKSIqt557kRz7NJ9ITe7KKCU0CxM/7nhQ==
 =v8bS
 -----END PGP SIGNATURE-----

Merge tag 'wireless-next-2024-11-13' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next

Kalle Valo says:

====================
wireless-next patches for v6.13

Most likely the last -next pull request for v6.13. Most changes are in
Realtek and Qualcomm drivers, otherwise not really anything
noteworthy.

Major changes:

mac80211
 * EHT 1024 aggregation size for transmissions

ath12k
 * switch to using wiphy_lock() and remove ar->conf_mutex
 * firmware coredump collection support
 * add debugfs support for a multitude of statistics

ath11k
 * dt: document WCN6855 hardware inputs

ath9k
 * remove include/linux/ath9k_platform.h

ath5k
 * Arcadyan ARV45XX AR2417 & Gigaset SX76[23] AR241[34]A support

rtw88:
 * 8821au and 8812au USB adapters support

rtw89
 * thermal protection
 * firmware secure boot for WiFi 6 chip

* tag 'wireless-next-2024-11-13' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next: (154 commits)
  Revert "wifi: iwlegacy: do not skip frames with bad FCS"
  wifi: mac80211: pass MBSSID config by reference
  wifi: mac80211: Support EHT 1024 aggregation size in TX
  net: rfkill: gpio: Add check for clk_enable()
  wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw()
  wifi: Switch back to struct platform_driver::remove()
  wifi: ipw2x00: libipw_rx_any(): fix bad alignment
  wifi: brcmfmac: release 'root' node in all execution paths
  wifi: iwlwifi: mvm: don't call power_update_mac in fast suspend
  wifi: iwlwifi: s/IWL_MVM_INVALID_STA/IWL_INVALID_STA
  wifi: iwlwifi: bump minimum API version in BZ/SC to 92
  wifi: iwlwifi: move IWL_LMAC_*_INDEX to fw/api/context.h
  wifi: iwlwifi: be less noisy if the NIC is dead in S3
  wifi: iwlwifi: mvm: tell iwlmei when we finished suspending
  wifi: iwlwifi: allow fast resume on ax200
  wifi: iwlwifi: mvm: support new initiator and responder command version
  wifi: iwlwifi: mvm: use wiphy locked debugfs for low-latency
  wifi: iwlwifi: mvm: MLO scan upon channel condition degradation
  wifi: iwlwifi: mvm: support new versions of the wowlan APIs
  wifi: iwlwifi: mvm: allow always calling iwl_mvm_get_bss_vif()
  ...
====================

Link: https://patch.msgid.link/20241113172918.A8A11C4CEC3@smtp.kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-11-13 18:35:19 -08:00
Kalle Valo
5255ee958f rtw-next patches for v6.13
Major changes are listed:
 
 rtw88:
  - support two USB adapters 8821au and 8812au
 
 rtw89:
  - add thermal protection
  - fine tune BT-coexsitence to improve user experience
  - firmware secure boot for WiFi 6 chip
  - more materials for MLO
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEuyEnvMdOsBl1WjpdjlvZYmhshd8FAmcrHQ8ACgkQjlvZYmhs
 hd8Gvg/8C847J/bMveQNlqNw16WboNdIkvDd0hfELyicwekz1vumODW/JSeeJ8Ap
 F4i88UL4yTp6QYjDtI6R3Ox5i2FBmQ5lGPNMbyjYGfaKG2YXhR4U29Ge0Awcq2vP
 AmbXfcWuOTVrW3gQQFvzLpV9dWoy/NyTXAQsGwbEF0RzJ7ILzyacoYYTkr6+quxt
 AH+TC7dJCfHYGceZNL2llOorRWAgrV66jb2v527f2RIaaq90a8MFcpCnfpNQGmPP
 nbBvOzSERDfZEeBzOkwwolXbPyCvUuQs4WNgqDf/jUD1k5cs/qqyBDeHfsV6CK2q
 4FV1vHgE00c8Gaz7NXhnlKx3ixPDM4cQzUM/PKtrZ9ag8AZTXja7i176v4nIs/JI
 Cj77kBm9CPHVbJCk434RvezdVDtTJhEdG7v7FkqPu/kW5KaMus8moGGdKcCTHNUs
 UqjlM8PG7n/SPPGfutSdz5tTLbgkGkWczIe22L5OTGDDiv/+9hWnHdHiW8RROJJ8
 9eZKJyle4Susa8eOLk6888wMTAKo+4ZO6ijyST83ZIo72WLJmfjNrc0+NnxMrWZR
 1YOB6SUdnFJL6qHTvK1cQPrrmpAlz/MLCFS/vfSa78p8yy56OtRUTf/S0qv77H1a
 LlKouLy+L2LAq+Z7cL7tvV5mLTjTZsy+zyhEvDpQgAAR4TEJjYg=
 =7ogU
 -----END PGP SIGNATURE-----

Merge tag 'rtw-next-2024-11-06' of https://github.com/pkshih/rtw

rtw-next patches for v6.13

Major changes are listed:

rtw88:
 - support two USB adapters 8821au and 8812au

rtw89:
 - add thermal protection
 - fine tune BT-coexsitence to improve user experience
 - firmware secure boot for WiFi 6 chip
 - more materials for MLO
2024-11-11 13:07:21 +02:00
Ching-Te Ku
1b1350e200 wifi: rtw89: coex: set higher priority to BT when WL scan and BT A2DP exist
If WiFi operation channel & scan channel both at 2.4GHz, original will keep
going at WL > BT priority table for a long time. It makes A2DP can not sent
audio data to SUT device in time then performed a lag audio. Assign
a BT > WL priority table when A2DP exist, to avoid the issue.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241031023032.7102-1-pkshih@realtek.com
2024-11-06 14:26:27 +08:00
Chih-Kang Chang
927f19c8ef wifi: rtw89: 8852b: change RF mode to normal mode when set channel
Set the RF mode from 0xA(low power mode) to 0x3(Normal mode) to avoid
abnormal TX waveform in OFDM rate. Originally the RF mode will be changed
to normal mode by the firmware after entering LPS once. Therefore, this
change does not affect power saving.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030091603.6073-1-pkshih@realtek.com
2024-11-06 14:22:26 +08:00
Pei Xiao
81df5ed446 wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()
kmalloc may fail, return value might be NULL and will cause
NULL pointer dereference. Add check NULL return of kmalloc in
btc_fw_set_monreg().

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Fixes: b952cb0a6e ("wifi: rtw89: coex: Add register monitor report v7 format")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/516a91f3997534f708af43c7592cbafdd53dd599.1730253508.git.xiaopei01@kylinos.cn
2024-11-06 14:18:27 +08:00
Kuan-Chung Chen
95fa945622 wifi: rtw89: 8922a: fill the missing OP1dB configuration
OP1dB stands for Output 1dB Compression Point. At this point, the power
amplifier starts to enter the saturation region, resulting in distortion.
The configuration of OP1dB can optimize the RX gain saturation region,
improving RX throughput from 573 to 675 Mbps.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022903.13243-1-pkshih@realtek.com
2024-11-06 14:09:24 +08:00
Ping-Ke Shih
da824a86b0 wifi: rtw89: mac: no configure CMAC/DMAC tables for firmware secure boot
The initial CMAC/DMAC tables used by WiFi 6 chips are not needed to be
called for firmware secure boot. Otherwise, it causes firmware abnormal
and throw warnings.

  rtw89_8852be 0000:03:00.0: FW status = 0x1400
  rtw89_8852be 0000:03:00.0: FW BADADDR = 0xb872f800
  rtw89_8852be 0000:03:00.0: FW EPC/RA = 0xb89333b7
  rtw89_8852be 0000:03:00.0: FW MISC = 0x0
  rtw89_8852be 0000:03:00.0: R_AX_HALT_C2H = 0x10002010
  rtw89_8852be 0000:03:00.0: R_AX_SER_DBG_INFO = 0x0
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c97
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c95
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c99
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c9b
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c9f
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c9b
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c99
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c9d
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c97
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c97
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c97
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c99
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c97
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c9f
  rtw89_8852be 0000:03:00.0: [ERR]fw PC = 0xb89a2c99

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-9-pkshih@realtek.com
2024-11-06 14:01:26 +08:00
Ping-Ke Shih
6d995ef770 wifi: rtw89: fw: use common function to parse security section for WiFi 6 chips
The MSSC (multiple security section count) can be regular number (shown in
below figure) or 0xFF (supported already). For WiFi 7 or newer WiFi 6
chips, the MSSC will be 0xFF. But early WiFi 6 chip such as RTL8852B
could be either one of the cases.

Extend __parse_security_section() to support both with/without secure
boot mode accordingly.

           +---------------------------+ -\
           |      firmware header      |  |
           |                           |  |
           | +-----------------------+ |  |
           | | section type/size * N | |  |
           | +-----------------------+ |  |
           +---------------------------+ -/
           :                           :
           +---------------------------+ -\
           | secure section type (ID:9)|  |
           |                           |  |
      +----|-> [ security key data ]   |  |
      |    +---------------------------+ -/
      |    |MSS Pool for above section |
      |    |  [ security key data 1 ]  |
      +----|- [ security key data 2 ]  |
by mss_idx |  [ security key data 3 ]  |
           |  ...                 M    | * M = MSSC (MSSC != 0xFF)
           +---------------------------+

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-8-pkshih@realtek.com
2024-11-06 14:00:44 +08:00
Ping-Ke Shih
f9fe3baeb2 wifi: rtw89: fw: move v1 MSSC out of __parse_security_section() to share with v0
The security section can be a common parser for v0 and v1 format of
firmware header, so move retrieval code of v1 MSSC from the function, and
then sharing becomes possible.

Not logic change at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-7-pkshih@realtek.com
2024-11-06 14:00:32 +08:00
Ping-Ke Shih
86ee0024e5 wifi: rtw89: fw: set recorded IDMEM share mode in firmware header to register
For WiFi 6 chips, firmware secure boot will run on a IDMEM mode specified
in firmware header. Retrieve the mode from firmware, and set to registers
accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-6-pkshih@realtek.com
2024-11-06 13:59:18 +08:00
Ping-Ke Shih
40c06adf63 wifi: rtw89: fw: shrink download size of security section for RTL8852B
For RTL8852B, when current firmware is secure boot, the security section
needs a special treatment that shrink its size to 960.

As figure below, not only shrink the amount of download size of security
section (2), but also need to modify the section size in firmware header
(1) that is also downloaded to chip.

   +---------------------------+
   |      firmware header      |
   |                           |
   | +-----------------------+ |
   | | section type, size N -|-|-------+
   | | ...               (1) | |       |
   | +-----------------------+ |       |
   +---------------------------+       | 2048 shrink to 960
   :                           :       |
   +---------------------------+ -\    |
   |  security section type 9  |  |    |
   |           (2)             |  | <--+
   |                           |  |
   +---------------------------+ -/

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-5-pkshih@realtek.com
2024-11-06 13:58:35 +08:00
Ping-Ke Shih
e1551a79c4 wifi: rtw89: efuse: read firmware secure info v0 from efuse for WiFi 6 chips
WiFi 6 chips could program secure information in v0 or v1 format. Use
existing v1 parser or newly added v0 parser to recognize firmware key
that is going to be used.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-4-pkshih@realtek.com
2024-11-06 13:57:17 +08:00
Ping-Ke Shih
0ce1df1cc3 wifi: rtw89: efuse: move recognize firmware MSS info v1 to common
The WiFi 6 chip use the same firmware MSS information v1 read from efuse,
so move this logic to common.

No change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-3-pkshih@realtek.com
2024-11-06 13:56:57 +08:00
Ping-Ke Shih
d230e215e3 wifi: rtw89: efuse: move reading efuse of fw secure info to common
The secure key used by certain hardware module is programmed in efuse, so
driver should read the information from efuse before downloading firmware.

Originally only RTL8922AE can support firmware secure boot, and read efuse
during chip power on. To extend to support all chips, move the caller to
common power on flow and add separate functions to read efuse for
WiFi 6 chips.

No logic change at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241030022135.11688-2-pkshih@realtek.com
2024-11-06 13:55:55 +08:00
Chih-Kang Chang
3e407dae71 wifi: rtw89: set pause_data field to avoid transmitting data in scan channels
Set pause_data to all of the scan channels, excluding the OP channel,
to prevent data frame transmission to the scan channels, which causes
retransmission. Additionally, this flag won't affect the transmission
of probe requests from the scan channels.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241026022143.7304-1-pkshih@realtek.com
2024-11-01 10:17:10 +08:00
Chin-Yen Lee
345c894ee7 wifi: rtw89: don't check done-ack for entering PS
In WoWLAN mode, driver will disable interrupt after calling H2C command
for entering PS mode, but it may lead to failing to enter deep PS mode by
firmware because the done-ack of the H2C from firmware is not handled by
driver. In fact, the done-ack for entering PS is not necessary for driver
to check, so remove it.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241024055509.8000-1-pkshih@realtek.com
2024-11-01 10:08:25 +08:00
Jakub Kicinski
5b1c965956 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR (net-6.12-rc6).

Conflicts:

drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
  cbe84e9ad5 ("wifi: iwlwifi: mvm: really send iwl_txpower_constraints_cmd")
  188a1bf894 ("wifi: mac80211: re-order assigning channel in activate links")
https://lore.kernel.org/all/20241028123621.7bbb131b@canb.auug.org.au/

net/mac80211/cfg.c
  c4382d5ca1 ("wifi: mac80211: update the right link for tx power")
  8dd0498983 ("wifi: mac80211: Fix setting txpower with emulate_chanctx")

drivers/net/ethernet/intel/ice/ice_ptp_hw.h
  6e58c33106 ("ice: fix crash on probe for DPLL enabled E810 LOM")
  e4291b64e1 ("ice: Align E810T GPIO to other products")
  ebb2693f8f ("ice: Read SDP section from NVM for pin definitions")
  ac532f4f42 ("ice: Cleanup unused declarations")
https://lore.kernel.org/all/20241030120524.1ee1af18@canb.auug.org.au/

No adjacent changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-10-31 18:10:07 -07:00
Zong-Zhe Yang
94318a4003 wifi: rtw89: 8922a: extend RFK handling and consider MLO
Extend FW and driver handling on RFK to support it on both HW bands.
Then, according to MLO cases, do the corresponding RF settings.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241022083106.149252-6-pkshih@realtek.com
2024-10-29 11:28:30 +08:00
Zong-Zhe Yang
2305ebc183 wifi: rtw89: tweak setting of channel and TX power for MLO
Setting of channel and TX power depend on channel contexts, but original
code cannot handle combination of MCC (multi-channel concurrency) and MLO
well. So according to active interfaces, we generate a table for current
channel contexts. And then based on entity mode, we get the corresponding
channel context to apply during channel or TX power setting. When MLO is
supported, there will be dual-PHY and we will apply the channel context of
the 2nd link to the 2nd PHY.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241022083106.149252-5-pkshih@realtek.com
2024-10-29 11:27:12 +08:00
Zong-Zhe Yang
68ec751b28 wifi: rtw89: chan: manage active interfaces
To set channel well for combination of MCC (multi-channel concurrency) and
impending MLO support, we need a method to manage relation between active
interfaces and channel contexts. If an interface owns at least one active
link, we call it an active interface. We add a list to manage active ones.

Basically, the list follows the active order except for the below case. To
be compatible with legacy behavior, the first interface that owns the first
channel context will put at the first entry in the list when recalculating.

Besides, MCC can also select and fill roles based on the above active list.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241022083106.149252-4-pkshih@realtek.com
2024-10-29 11:25:54 +08:00
Po-Hao Huang
c39eed4bd7 wifi: rtw89: Add encryption support for MLO connections
In order to make encryption/decryption work properly with MLO
connections, MLD address needs to be filled in so circuits can
operate with the correct information.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241022083106.149252-3-pkshih@realtek.com
2024-10-29 11:25:36 +08:00
Po-Hao Huang
b8499664fc wifi: rtw89: Add header conversion for MLO connections
For MLO connections, this setting replaces 802.11 header addresses
to according link addresses based on each packet's destination.
The fields most likely to be replaced would be both A1 and A2.
For legacy connections, it's the same with or without the conversion.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241022083106.149252-2-pkshih@realtek.com
2024-10-29 11:23:35 +08:00
Dan Carpenter
ac4f4e5a20 wifi: rtw89: unlock on error path in rtw89_ops_unassign_vif_chanctx()
We need to call mutex_unlock() on this error path.

Fixes: aad0394e7a ("wifi: rtw89: tweak driver architecture for impending MLO support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/8683a712-ffc2-466b-8382-0b264719f8ef@stanley.mountain
2024-10-25 10:26:46 +08:00
Po-Hao Huang
f16c40acd3 wifi: rtw89: Fix TX fail with A2DP after scanning
There might be some racing between BT and WiFi after scan. Since
one of the TX related register will be modified by both FW and
rtw89_set_channel() in driver, which could cause Tx fail. Reorder
the calling sequence to only notify coexistence mechanism after
rtw89_set_channel() is called, so that there are no concurrent
operations.

Fixes: 5f499ce69b ("wifi: rtw89: pause/proceed MCC for ROC and HW scan")
Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241021063219.22613-1-pkshih@realtek.com
2024-10-25 10:24:38 +08:00
Ching-Te Ku
9dffa44171 wifi: rtw89: coex: Set Wi-Fi/Bluetooth priority for Wi-Fi scan case
The priority table should be changed according to what the in using
Bluetooth application is. To avoid Bluetooth audio + HID (mouse) will
trigger the lag experience, update the priority table.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241019063131.9462-1-pkshih@realtek.com
2024-10-25 10:22:13 +08:00
Arnd Bergmann
c67d7c7f41 wifi: rtw89: fix -Wenum-compare-conditional warnings
This is one of three drivers that trigger -Wenum-compare-conditional warnings
with clang:

drivers/net/wireless/realtek/rtw89/core.c:1806:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1806 |                 return eht ? NL80211_RATE_INFO_EHT_GI_0_8 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1807 |                              NL80211_RATE_INFO_HE_GI_0_8;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1810:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1810 |                 return eht ? NL80211_RATE_INFO_EHT_GI_1_6 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1811 |                              NL80211_RATE_INFO_HE_GI_1_6;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1813:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1813 |                 return eht ? NL80211_RATE_INFO_EHT_GI_3_2 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1814 |                              NL80211_RATE_INFO_HE_GI_3_2;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1818:15: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1818 |                         return eht ? NL80211_RATE_INFO_EHT_GI_3_2 :
      |                                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1819 |                                      NL80211_RATE_INFO_HE_GI_3_2;
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this case, all four warnings can be easily avoided by splitting the
function into two separate ones, in a way that helps readability as well,
at the expense of a few extra source lines.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241018152311.4023979-1-arnd@kernel.org
2024-10-25 10:19:16 +08:00
Zong-Zhe Yang
39fc7d3865 wifi: rtw89: regd: block 6 GHz if marked as N/A in regd map
If 6 GHz of a country is marked as N/A in our regd map,
we block 6 GHz channels now.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241016134457.9375-1-pkshih@realtek.com
2024-10-25 10:10:26 +08:00
Ping-Ke Shih
9ef90a49b0 wifi: rtw89: pci: add quirks by PCI subsystem ID for thermal protection
Specific PCI subsystem ID (SSID) of WiFi cards is used by specific
customer who want to enable various features with different arguments.

Define PCI SSID quirks tables to enable thermal protection with two kinds
of thermal values for 110 and 120 degree Celsius.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241016133735.7571-3-pkshih@realtek.com
2024-10-25 09:31:13 +08:00
Ping-Ke Shih
63aca17262 wifi: rtw89: add thermal protection
To prevent chip overheating, reduce TX duty as the mechanism of thermal
protection. When temperature is raising over a threshold, send a firmware
command to reduce TX duty. If temperature is still raising, higher level
is adopted to have lower active duration.

The equation and unit of thermal values are different from chip to chip,
so define constant thresholds of thermal value to corresponding absolute
temperature of 110 and 120 degree Celsius.

Latter patch will decide which thermal threshold is adopted, and current
is still not enable thermal protection.

For debugging, add a flag to disable_dm that thermal protection can be
disabled to clarify low throughput in field.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241016133735.7571-2-pkshih@realtek.com
2024-10-25 09:29:54 +08:00
Johannes Berg
88b67e91e2 wifi: mac80211: call rate_control_rate_update() for link STA
In order to update the right link information, call the update
rate_control_rate_update() with the right link_sta, and then
pass that through to the driver's sta_rc_update() method. The
software rate control still doesn't support it, but that'll be
skipped by not having a rate control ref.

Since it now operates on a link sta, rename the driver method.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241007144851.5851b6b5fd41.Ibdf50d96afa4b761dd9b9dfd54a1147e77a75329@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2024-10-23 16:43:27 +02:00
Ping-Ke Shih
062689f2cb wifi: rtw89: sar: add supported UNII-4 frequency range along with UNII-3 of SAR subband
The UNII-4 uses the same SAR value of UNII-3, so add UNII-4 frequency
range and change the enum name to represent UNII-3 and UNII-4.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009071619.16841-1-pkshih@realtek.com
2024-10-20 10:35:06 +08:00
Ping-Ke Shih
74432751ff wifi: rtw89: 8852c: use 'int' as return type of error code pwr_{on,off}_func()
The return type of error code of rtw8852c_pwr_{on,off}_func() and its
callee is 'int'. Correct it.

Addresses-Coverity-ID: 1626056 ("Overflowed constant")
Addresses-Coverity-ID: 1627945 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-7-pkshih@realtek.com
2024-10-20 10:32:02 +08:00
Ping-Ke Shih
c72c54fd96 wifi: rtw89: 8852bt: use 'int' as return type of error code pwr_{on,off}_func()
The return type of error code of rtw8852bt_pwr_{on,off}_func() and its
callee is 'int'. Correct it.

Addresses-Coverity-ID: 1630962 ("Overflowed constant")
Addresses-Coverity-ID: 1632126 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-6-pkshih@realtek.com
2024-10-20 10:31:54 +08:00
Ping-Ke Shih
50e9febff3 wifi: rtw89: 8852b: use 'int' as return type of error code pwr_{on,off}_func()
The return type of error code of rtw8852b_pwr_{on,off}_func() and its
callee is 'int'. Correct it.

Addresses-Coverity-ID: 1622433 ("Overflowed constant")
Addresses-Coverity-ID: 1630710 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-5-pkshih@realtek.com
2024-10-20 10:31:46 +08:00
Ping-Ke Shih
66595e3198 wifi: rtw89: 8851b: use 'int' as return type of error code pwr_{on,off}_func()
The return type of error code of rtw8851b_pwr_{on,off}_func() and its
callee is 'int'. Correct it.

Addresses-Coverity-ID: 1624679 ("Overflowed constant")
Addresses-Coverity-ID: 1630970 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-4-pkshih@realtek.com
2024-10-20 10:31:37 +08:00
Ping-Ke Shih
778e2478d1 wifi: rtw89: pci: use 'int' as return type of error code in poll_{tx,rx}dma_ch_idle()
The return type of error code of read_poll_timeout() and
rtw89_pci_poll_{tx,rx}dma_ch_idle_ax() and must be 'int'.
Correct them accordingly.

Addresses-Coverity-ID: 1622341 ("Overflowed constant")
Addresses-Coverity-ID: 1627296 ("Overflowed constant")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-3-pkshih@realtek.com
2024-10-20 10:31:24 +08:00
Ping-Ke Shih
5af57c4f99 wifi: rtw89: wow: cast nd_config->delay to u64 in tsf arithmetic
The type of tsf arithmetic is
   u64 += u16 * int;

When (u16 * int) is larger than 0x7FFFFFFF, the value casting to u64 with
sign-extension will become all 1 in upper 32 bits part.

To meet the case, u16 value should be larger than 20491
(0x7FFFFFFF / 104800). Fortunately the meaning of 20491 is delay time of
WoWLAN net detection in unit of second, so 20491 seconds (5.7 hours)
might not a real case we can meet.

Addresses-Coverity-ID: 1620910 ("Unintended sign extension")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241009004300.8144-2-pkshih@realtek.com
2024-10-20 10:29:55 +08:00
Ping-Ke Shih
aa70ff0945 wifi: rtw89: pci: early chips only enable 36-bit DMA on specific PCI hosts
The early chips including RTL8852A, RTL8851B, RTL8852B and RTL8852BT have
interoperability problems of 36-bit DMA with some PCI hosts. Rollback
to 32-bit DMA by default, and only enable 36-bit DMA for tested platforms.

Since all Intel platforms we have can work correctly, add the vendor ID to
white list. Otherwise, list vendor/device ID of bridge we have tested.

Fixes: 1fd4b3fe52 ("wifi: rtw89: pci: support 36-bit PCI DMA address")
Reported-by: Marcel Weißenbach <mweissenbach@ignaz.org>
Closes: https://lore.kernel.org/linux-wireless/20240918073237.Horde.VLueh0_KaiDw-9asEEcdM84@ignaz.org/T/#m07c5694df1acb173a42e1a0bab7ac22bd231a2b8
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Tested-by: Marcel Weißenbach <mweissenbach@ignaz.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20240924021633.19861-1-pkshih@realtek.com
2024-10-17 17:23:15 +03:00
Chin-Yen Lee
fc44256001 wifi: rtw89: wow: do not configure CPU IO to receive packets for old firmware
The older firmware of 8852A and 8852B can't receive packets via
CPU IO function and will lead to WoWLAN fail if calling it.
So use firmware feature to distinguish.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241004065408.10261-1-pkshih@realtek.com
2024-10-10 08:45:37 +08:00
Ching-Te Ku
5ab2f78302 wifi: rtw89: coex: Add function to reorder Wi-Fi firmware report index
To parsing firmware report correctly, driver need to re-order the report
index to match with different chips and different Wi-Fi firmware version.
Use wrong index to parse the report will lead the coexistence run into
wrong mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241003105140.10867-5-pkshih@realtek.com
2024-10-10 08:37:33 +08:00
Ching-Te Ku
e7a7f705a8 wifi: rtw89: coex: Solved BT PAN profile idle decrease Wi-Fi throughput
Some Bluetooth device will make up connection as PAN link, though the
connection is idle, it will still report the PAN link is active. The
coexistence mechanism will enable TDMA to protect the PAN, it makes
Wi-Fi throughput degrade at least 50%. But the link is idle, don't
need so much bandwidth. Add TDMA case to let Wi-Fi can do traffic 80%
bandwidth.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241003105140.10867-4-pkshih@realtek.com
2024-10-10 08:37:21 +08:00
Ching-Te Ku
afa753d823 wifi: rtw89: coex: Reorder Bluetooth info related logic
Reorder Bluetooth firmware related event index, it should be the same
with Wi-Fi firmware definition. To fix coexistence can not recognize
Bluetooth PAN(Personal area network) profile correctly, modified the
related logic.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241003105140.10867-3-pkshih@realtek.com
2024-10-10 08:35:54 +08:00
Ching-Te Ku
e6802d1e69 wifi: rtw89: coex: Update priority setting for Wi-Fi is scanning
Update coexistence priority setting for Wi-Fi scanning channel, the new
setting will allow Wi-Fi do RX while Bluetooth audio is not busy. Forced
to set new TDMA policy while RF calibration request come, to make sure
the calibration can do well, and switch to normal setting while the
calibration is done. Remove the code that no longer use.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241003105140.10867-2-pkshih@realtek.com
2024-10-10 08:34:31 +08:00
Ping-Ke Shih
284939d7e8 wifi: rtw89: debug: add beacon RSSI for debugging
In range test, the RSSI is helpful to check attenuation of cable and align
difference between environments. Since data packets can be transmitted with
different rate and power, the RSSI of all packets can be variant.
Oppositely beacon is transmitted with the same rate and power, so beacon
RSSI will be relatively invariant, and more helpful to diagnose problems.

The output of beacon RSSI in unit of dBm looks like:

  Beacon: 19 (-33 dBm), TF: 0

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240927013512.7106-1-pkshih@realtek.com
2024-10-05 10:49:16 +08:00
Zong-Zhe Yang
ad95bb3b92 wifi: rtw89: handle entity active flag per PHY
Originally, we have an active flag to record whether we have set PHY once.
After impending MLO support, there will be dual-PHY and they can be set
individually on Wi-Fi 7 chips. So, we now have active flag per PHY and
handle them individually.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925020119.13170-3-pkshih@realtek.com
2024-10-01 21:03:05 +08:00
Zong-Zhe Yang
f82a4471fc wifi: rtw89: initialize dual HW bands for MLO and control them by link
To support MLO, we initialize things on dual HW bands of Wi-Fi 7 chip.
And, each link will indicate which HW band it's bound to. So, in link
control flow, we control major things based on target link's HW band
instead of hardcode like RTW89_PHY_X or RTW89_MAC_X.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925020119.13170-2-pkshih@realtek.com
2024-10-01 21:01:39 +08:00
Ping-Ke Shih
6f46547d3d wifi: rtw89: 8852ce: set offset K of PCI PHY EQ to manual mode to improve compatibility
Read calibration value of PCI RX offset, and set to manual mode as the
value at PCI probe to prevent abnormal calibration results at runtime.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925013901.9835-5-pkshih@realtek.com
2024-10-01 20:57:59 +08:00
Ping-Ke Shih
c76afc421c wifi: rtw89: 8852ce: fix gray code conversion for filter out EQ
To use manual mode to set value of filter out EQ, read the source value of
filter out EQ coded in gray code, and write to the target register in
binary number. The function to convert from gray code to binary number is
wrong originally, causing unexpected EQ, so fix it.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925013901.9835-4-pkshih@realtek.com
2024-10-01 20:57:50 +08:00
Ping-Ke Shih
bbc0be2ee2 wifi: rtw89: 8922ae: disable PCI PHY EQ to improve compatibility
For adaption EQ circuit, this HW design and affected by EIEOS (Electrical
Idle Exit Order Set) amplitude from platform and process from IC, so
disable EQ to improve that.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925013901.9835-3-pkshih@realtek.com
2024-10-01 20:57:29 +08:00
Ping-Ke Shih
1a82680839 wifi: rtw89: pci: consolidate PCI basic configurations for probe and resume
The PCI settings aren't always persistent after chip suspends, so
reconfigure the settings after chip resumes. Since most of these settings
are the same, consolidate them into a function to avoid missing somewhere.

Fix the missing case of 8922AE resume flow.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240925013901.9835-2-pkshih@realtek.com
2024-10-01 20:56:12 +08:00
Ping-Ke Shih
7bf2f8fe42 wifi: rtw89: 8852c: rfk: remove unnecessary assignment of return value of _dpk_dgain_read()
The return value of _dpk_dgain_read() is not used afterward, so remove
it safely.

Addresses-Coverity-ID: 1504753 ("Unused value")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240919081216.28505-4-pkshih@realtek.com
2024-09-26 09:22:14 +08:00
Ping-Ke Shih
6cdfb56596 wifi: rtw89: coex: initialize local .dbcc_2g_phy in _set_btg_ctrl()
For the case of DBCC enabled and fwrole version 0, the local variable
wl_rinfo.dbcc_2g_phy might not be set by following for-loop, leading
uninitialized variable before using.

Addresses-Coverity-ID: 1586724 ("Uninitialized scalar variable")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240919081216.28505-3-pkshih@realtek.com
2024-09-26 09:22:02 +08:00
Ping-Ke Shih
630d5d8f2b wifi: rtw89: check return value of ieee80211_probereq_get() for RNR
The return value of ieee80211_probereq_get() might be NULL, so check it
before using to avoid NULL pointer access.

Addresses-Coverity-ID: 1529805 ("Dereference null return value")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240919081216.28505-2-pkshih@realtek.com
2024-09-26 09:17:59 +08:00
Zong-Zhe Yang
aad0394e7a wifi: rtw89: tweak driver architecture for impending MLO support
The drv_priv hooked to mac80211 become as below.

                           (drv_priv)             (instance-0)
 +---------------+       +-----------+          +----------------+
 | ieee80211_vif | <---> | rtw89_vif | -------> | rtw89_vif_link |
 +---------------+       +-----------+    |     +----------------+
                                          |
                                          |       (instance-1)
                                          |     +----------------+
                                          +---> | rtw89_vif_link |
                                                +----------------+

                           (drv_priv)             (instance-0)
 +---------------+       +-----------+          +----------------+
 | ieee80211_sta | <---> | rtw89_sta | -------> | rtw89_sta_link |
 +---------------+       +-----------+    |     +----------------+
                                          |
                                          |       (instance-1)
                                          |     +----------------+
                                          +---> | rtw89_sta_link |
                                                +----------------+

The relation bewteen mac80211 link_id and our link instance is like below.

                 |\
 (link_id)       | \
     0  -------- |  |
     1  -------- |  | ------ instance-0 (link_id: X) -> work on HW band 0
     2  -------- |  |
     ...         |  | ------ instance-1 (link_id: Y) -> work on HW band 1
     14 -------- |  |
                 | /
                 |/

	N.B. For cases of non-MLD connection, we set our link instance-0
	active with link_id 0. So, our code flow can be compatible between
	non-MLD connection and MLD connection.

Based on above, we tweak entire driver architecture first. But, we don't
dynamically enable multiple links here. That will be handled separately.
Most of the things changed here are changing flows to iterate all active
links and read bss_conf/link_sta data according to target link. And, for
cases of scan, ROC, WOW, we use instance-0 to deal with the request.

There are some things listed below, which work for now but need to extend
before multiple active links.
	1. tx path
		select suitable link instance among multiple active links
	2. rx path
		determine rx link by PPDU instead of always link instance-0
	3. CAM
		apply MLD pairwise key to any active links dynamically

Besides, PS code cannot easily work along with tweaking architecture. With
supporting MLO flag (currently false), we disable PS first and will fix it
by another commit in the following.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-8-pkshih@realtek.com
2024-09-24 09:20:20 +08:00
Zong-Zhe Yang
72e9457c19 wifi: rtw89: refactor STA related func ahead for MLO
Refactor STA related functions, e.g. add/assoc/disassoc/disconnect/remove
to separate most link stuffs into sub-functions for MLO reuse.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-7-pkshih@realtek.com
2024-09-24 09:18:59 +08:00
Zong-Zhe Yang
26d460e13f wifi: rtw89: refactor VIF related func ahead for MLO
Refactor VIF related functions, e.g. add/remove/assoc/mapping
to separate most link stuffs into sub-functions for MLO reuse.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-6-pkshih@realtek.com
2024-09-24 09:17:40 +08:00
Zong-Zhe Yang
04911c0fe8 wifi: rtw89: read link_sta corresponding to the link
Tweak code to not always access sta->deflink directly. Instead,
according to link_id, read target link_sta from sta->link[].

For now, rtwsta_link->link_id keeps 0. When driver starts to
support MLO, the link_id will be assigned.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-5-pkshih@realtek.com
2024-09-24 09:16:17 +08:00
Zong-Zhe Yang
89bac818bb wifi: rtw89: read bss_conf corresponding to the link
Tweak code to not always access vif->bss_conf directly. Instead,
according to link_id, read target bss_conf from vif->link_conf[].

For now, rtwvif_link->link_id keeps 0. When driver starts to
support MLO, the link_id will be assigned.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-4-pkshih@realtek.com
2024-09-24 09:14:55 +08:00
Zong-Zhe Yang
9ee2821934 wifi: rtw89: rename rtw89_sta to rtw89_sta_link ahead for MLO
This is an intermediate version that is separated from subsequent major
MLO changes, so some functions' namings are not really determined here.
e.g. struct rtw89_sta_link *sta_to_rtwsta_safe(struct ieee80211_sta *sta)

No logic is changed.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-3-pkshih@realtek.com
2024-09-24 09:13:32 +08:00
Zong-Zhe Yang
2f7dae17c4 wifi: rtw89: rename rtw89_vif to rtw89_vif_link ahead for MLO
This is an intermediate version that is separated from subsequent major
MLO changes, so some functions' namings are not really determined here.
e.g. struct rtw89_vif_link *vif_to_rtwvif_safe(struct ieee80211_vif *vif)

No logic is changed.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240916053158.47350-2-pkshih@realtek.com
2024-09-24 09:09:05 +08:00
Ping-Ke Shih
bd25f45f08 wifi: rtw89: rfk: update firmware debug log of DACK to v2
Update DACK (digital-to-analog converters calibration) log to v2 by
firmware C2H events.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-6-pkshih@realtek.com
2024-09-20 10:48:46 +08:00
Ping-Ke Shih
6f54067045 wifi: rtw89: rfk: add firmware debug log of IQK
Print out IQ signal calibration log from firmware C2H events.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-5-pkshih@realtek.com
2024-09-20 10:48:04 +08:00
Ping-Ke Shih
8d445310ba wifi: rtw89: rfk: add firmware debug log of TSSI
TSSI is short for transmitter signal strength indication. Print out the
TSSI log from firmware C2H events.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-4-pkshih@realtek.com
2024-09-20 10:47:20 +08:00
Ping-Ke Shih
cd0d81d101 wifi: rtw89: 8922a: rfk: support firmware command RX DCK v1 format
RX DCK stands for receiver DC calibration. The v1 format adds a field to
indicate the calibration is for operation channel or an average value for
all scanning channels. Update the format accordingly, and increase
firmware format sequence to 2.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-3-pkshih@realtek.com
2024-09-20 10:46:05 +08:00
Ping-Ke Shih
2e8fd540c0 wifi: rtw89: 8922a: rfk: enlarge TSSI timeout time to 20ms
Firmware needs more time to execute TSSI calibration command. Enlarge
timeout time accordingly, otherwise driver throws messages:

   rtw89_8922ae 0000:03:00.0: failed to wait RF TSSI

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240913071340.41822-2-pkshih@realtek.com
2024-09-20 10:45:56 +08:00
Ping-Ke Shih
5575058ba9 wifi: rtw89: coex: add debug message of link counts on 2/5GHz bands for wl_info v7
The counts will be used by MLO, and it is ongoing to add the code, so add
debug message in todo part to avoid warnings reported by clang:

coex.c:6323:23: warning:
	 variable 'cnt_2g' set but not used [-Wunused-but-set-variable]
 6323 |         u8 i, mode, cnt = 0, cnt_2g = 0, cnt_5g = 0, ...
      |                              ^
coex.c:6323:35: warning:
	 variable 'cnt_5g' set but not used [-Wunused-but-set-variable]
 6323 |         u8 i, mode, cnt = 0, cnt_2g = 0, cnt_5g = 0, ...
      |                                          ^

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20240912021626.10494-1-pkshih@realtek.com
2024-09-18 16:33:17 +03:00
Zong-Zhe Yang
ed2e4bb17a wifi: rtw89: avoid reading out of bounds when loading TX power FW elements
Because the loop-expression will do one more time before getting false from
cond-expression, the original code copied one more entry size beyond valid
region.

Fix it by moving the entry copy to loop-body.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240902015803.20420-1-pkshih@realtek.com
2024-09-05 09:13:44 +08:00
Eric Huang
c9ac071e30 wifi: rtw89: use frequency domain RSSI
To get more accurate RSSI, this commit includes frequency domain RSSI
info in RSSI calculation. Add correspond physts parsing and macro to
get frequency domain RSSI information for supported IC.

Signed-off-by: Eric Huang <echuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240828055217.10263-3-pkshih@realtek.com
2024-09-05 08:55:02 +08:00
Eric Huang
9ecb64ed07 wifi: rtw89: adjust DIG threshold to reduce false alarm
Use RSSI without subtracting offset as packet detection lower bound and
set an absolute minimal threshold. It's equivalent to setting a higher
noise floor, thereby reducing false alarm and improving interference
endurance.

Signed-off-by: Eric Huang <echuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240828055217.10263-2-pkshih@realtek.com
2024-09-05 08:50:47 +08:00
Chin-Yen Lee
30ce797d46 wifi: rtw89: wow: add scan interval option for net-detect
The scan interval option is the period in unit of second for WoWLAN
firmware to do each scan. We get the option from cfg80211 and practice it.
If the interval is too short for firmware to finish one scan, the firmware
will start next scan immediately after finishing one and the WiFi chip
could never enter idle mode to reduce power consumption.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240826090439.17242-5-pkshih@realtek.com
2024-09-02 09:15:02 +08:00
Chin-Yen Lee
1de4006941 wifi: rtw89: wow: add net-detect support for 8922ae
Enable net-detect in WoWLAN stub of 8922a, and declare net-detect
support up to 8 SSIDs.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240826090439.17242-4-pkshih@realtek.com
2024-09-02 09:14:53 +08:00
Chin-Yen Lee
f6409a8a0a wifi: rtw89: wow: add wait for H2C of FW-IPS mode
The C2H packet of FW-IPS mode is not handled by driver in the suspend
flow, and lead to WoWLAN firmware fail to enter PS mode and even some
SER happen. So add wait function for H2C of FW-IPS mode to check driver
handle the C2H packet before disabling interrupt and make the net-detect
function work fine.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240826090439.17242-3-pkshih@realtek.com
2024-09-02 09:13:33 +08:00
Zong-Zhe Yang
d9dd3ac77c wifi: rtw89: wow: fix wait condition for AOAC report request
Each condition binding to the same wait should be unique. AOAC code misused
the wait of FW offload series and broke the above rule. It added another
macro to generate wait condition of WoWLAN/AOAC, but the results conflict
to the ones of FW offload series. It means that we might be completed
wrongly in logic. We don't want things work/read like this and should
have avoided this.

Fix this by adding another wait which aims for WoWLAN functions.

Fixes: ff53fce5c7 ("wifi: rtw89: wow: update latest PTK GTK info to mac80211 after resume")
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240826090439.17242-2-pkshih@realtek.com
2024-09-02 09:12:16 +08:00
Zong-Zhe Yang
fef6315094 wifi: rtw89: introduce chip support link number and driver MLO capability
Configure supported link number by chip. And, introduce driver capability
flag for MLO. Driver should depend on runtime FW features and chip info to
determine whether to set the MLO capability flag or not. Once the MLO flag
is set, driver will consider/register/initialize things for MLO usages.

However, we just add the driver MLO capability flag ahead and don't really
set it. Then, we can start to tweak driver architecture for MLO. Some code
should depend on this flag. And after tweaking driver architecture is done,
we will set it based on runtime conditions as mentioned above.

Besides, MLD number supported by HW should be
	chip supported mac_id number / chip supported link number
Without driver MLO capability flag, we allocate stations based on supported
mac_id number. With driver MLO capability flag, we allocate stations based
on supported MLD number.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240819091724.33730-9-pkshih@realtek.com
2024-08-27 10:58:01 +08:00
Zong-Zhe Yang
d03b3d7493 wifi: rtw89: rename roc_entity_idx to roc_chanctx_idx
The target enum has been renamed to rtw89_"chanctx"_idx. So for
readability, rename roc_entity_idx to roc_"chanctx"_idx to align.

No logic is changed.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240819091724.33730-8-pkshih@realtek.com
2024-08-27 10:56:42 +08:00