summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/realtek/rtw89
AgeCommit message (Collapse)Author
2025-05-16wifi: rtw89: fix firmware scan delay unit for WiFi 6 chipsChin-Yen Lee
The scan delay unit of firmware command for WiFi 6 chips is microsecond, but is wrong set now and lead to abnormal work for net-detect. Correct the unit to avoid the error. Fixes: e99dd80c8a18 ("wifi: rtw89: wow: add delay option for net-detect") Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250513125203.6858-1-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: avoid redundant recalculations if no chance to improveZong-Zhe Yang
MCC will track the changes of beacon offset, and trigger a recalculation when the difference is larger than the tolerance. It means that a better pattern is expected after recalculating. However, in the cases which get a worse beacon offset, there is no chance to improve the pattern even if recalculating. So, bypass 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/20250511035217.10410-7-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: deal with non-periodic NoAZong-Zhe Yang
Originally, MCC just took periodic NoA into account. When the connected GO announces non-periodic NoA and GC side is during MCC, sometimes GC cannot receive beacons well if the MCC scheduling conflicts with the non-periodic NoA planning. After the loss exceeds the tolerable amount, beacon filter will report connection loss. However, in this case, the loss is acceptable. So now, MCC will calculate the range of non-periodic NoA. And then, don't care beacon loss during the range. Besides, rtw89_mcc_fill_role_limit() only makes sense for GC. Remove the redundant check of GO. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250511035217.10410-6-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: introduce calculation of anchor patternZong-Zhe Yang
In the cases that two MCC roles' TBTTs are too close or too far, original MCC pattern calculation logic will lead to a result that both roles might not cover its TBTT with sufficient time. Introduce a new calculation logic called anchor pattern for these corner cases. It allows to choose one role as anchor to put its TBTT in the middle of its duration directly. For now, a P2P role has a higher priority to be chosen as an anchor. Then, if able, another role might need to depend on courtesy mechanism to take time from anchor. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250511035217.10410-5-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: add courtesy mechanism conditions to P2P rolesZong-Zhe Yang
In one enablement of courtesy mechanism, there is one provider and one receiver. And, receiver can use the provider's time in a given period. But, to make P2P NoA protocol work as expected as possible, GO should be present at the time it doesn't announce absent, and GC should not use the time when GO announces absent. So, don't enable courtesy mechanism if provider is GO or receiver is GC. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250511035217.10410-4-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: drop queued chanctx changes when stoppingZong-Zhe Yang
When MCC is about to stop, there may be some chanctx changes which are queued for work but have not yet been run. To avoid these changes from being processed in a wrong state (e.g. next new MCC instance), cancel the queued work and drop queued changes. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250511035217.10410-3-pkshih@realtek.com
2025-05-16wifi: rtw89: mcc: pass whom to stop at when pausing chanctxZong-Zhe Yang
When stopping MCC, FW can stop at a given MCC role following H2C command. When pausing chanctx during MCC, in general, the caller expects to process things with its chanctx. So, pass the caller as target and let FW stop MCC at 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/20250511035217.10410-2-pkshih@realtek.com
2025-05-16wifi: rtw89: pci: enlarge retry times of RX tag to 1000Ping-Ke Shih
RX tag is sequence number to ensure RX DMA is complete. On platform Gigabyte X870 AORUS ELITE WIFI7, sometimes it needs longer retry times to complete RX DMA, or driver throws warnings and connection drops: rtw89_8922ae 0000:07:00.0: failed to update 162 RXBD info: -11 rtw89_8922ae 0000:07:00.0: failed to update 163 RXBD info: -11 rtw89_8922ae 0000:07:00.0: failed to update 32 RXBD info: -11 rtw89_8922ae 0000:07:00.0: failed to release TX skbs Fixes: 0bc7d1d4e63c ("wifi: rtw89: pci: validate RX tag for RXQ and RPQ") Reported-by: Samuel Reyes <zohrlaffz@gmail.com> Closes: https://lore.kernel.org/linux-wireless/f4355539f3ac46bbaf9c586d059a8cbb@realtek.com/T/#t Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250509013433.7573-1-pkshih@realtek.com
2025-05-16wifi: rtw89: leave idle mode when setting WEP encryption for AP modeDian-Syuan Yang
Due to mac80211 triggering the hardware to enter idle mode, it fails to install WEP key causing connected station can't ping successfully. Currently, it forces the hardware to leave idle mode before driver adding WEP keys. Signed-off-by: Dian-Syuan Yang <dian_syuan0116@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250507031203.8256-1-pkshih@realtek.com
2025-05-16wifi: rtw89: pci: configure manual DAC mode via PCI config API onlyPing-Ke Shih
To support 36-bit DMA, configure chip proprietary bit via PCI config API or chip DBI interface. However, the PCI device mmap isn't set yet and the DBI is also inaccessible via mmap, so only if the bit can be accessible via PCI config API, chip can support 36-bit DMA. Otherwise, fallback to 32-bit DMA. With NULL mmap address, kernel throws trace: BUG: unable to handle page fault for address: 0000000000001090 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 0 P4D 0 Oops: Oops: 0002 [#1] PREEMPT SMP PTI CPU: 1 UID: 0 PID: 71 Comm: irq/26-pciehp Tainted: G OE 6.14.2-061402-generic #202504101348 Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE RIP: 0010:rtw89_pci_ops_write16+0x12/0x30 [rtw89_pci] RSP: 0018:ffffb0ffc0acf9d8 EFLAGS: 00010206 RAX: ffffffffc158f9c0 RBX: ffff94865e702020 RCX: 0000000000000000 RDX: 0000000000000718 RSI: 0000000000001090 RDI: ffff94865e702020 RBP: ffffb0ffc0acf9d8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000015 R13: 0000000000000719 R14: ffffb0ffc0acfa1f R15: ffffffffc1813060 FS: 0000000000000000(0000) GS:ffff9486f3480000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000001090 CR3: 0000000090440001 CR4: 00000000000626f0 Call Trace: <TASK> rtw89_pci_read_config_byte+0x6d/0x120 [rtw89_pci] rtw89_pci_cfg_dac+0x5b/0xb0 [rtw89_pci] rtw89_pci_probe+0xa96/0xbd0 [rtw89_pci] ? __pfx___device_attach_driver+0x10/0x10 ? __pfx___device_attach_driver+0x10/0x10 local_pci_probe+0x47/0xa0 pci_call_probe+0x5d/0x190 pci_device_probe+0xa7/0x160 really_probe+0xf9/0x370 ? pm_runtime_barrier+0x55/0xa0 __driver_probe_device+0x8c/0x140 driver_probe_device+0x24/0xd0 __device_attach_driver+0xcd/0x170 bus_for_each_drv+0x99/0x100 __device_attach+0xb4/0x1d0 device_attach+0x10/0x20 pci_bus_add_device+0x59/0x90 pci_bus_add_devices+0x31/0x80 pciehp_configure_device+0xaa/0x170 pciehp_enable_slot+0xd6/0x240 pciehp_handle_presence_or_link_change+0xf1/0x180 pciehp_ist+0x162/0x1c0 irq_thread_fn+0x24/0x70 irq_thread+0xef/0x1c0 ? __pfx_irq_thread_fn+0x10/0x10 ? __pfx_irq_thread_dtor+0x10/0x10 ? __pfx_irq_thread+0x10/0x10 kthread+0xfc/0x230 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x47/0x70 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Fixes: 1fd4b3fe52ef ("wifi: rtw89: pci: support 36-bit PCI DMA address") Reported-by: Bitterblue Smith <rtl8821cerfe2@gmail.com> Closes: https://lore.kernel.org/linux-wireless/ccaf49b6-ff41-4917-90f1-f53cadaaa0da@gmail.com/T/#u Closes: https://github.com/openwrt/openwrt/issues/17025 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250506015356.7995-1-pkshih@realtek.com
2025-05-10wifi: rtw89: declare MLO support if prerequisites are metZong-Zhe Yang
When the following prerequisites are met, driver will enable support_mlo. It means that driver will declare WIPHY_FLAG_SUPPORTS_MLO, and then deal with MLO related things. The main prerequisites are as below. 1. all prerequisites for running with chanctx 2. FW feature NOTIFY_AP_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/20250505072440.45113-12-pkshih@realtek.com
2025-05-10wifi: rtw89: debug: add mlo_mode dbgfsZong-Zhe Yang
Add an dbgfs mlo_mode to get/set MLO mode. And, support to trigger MLSR switching. Setting it will automatically disable MLO Dynamic Mechanism (DM). Then MLO things can follow commands via dbgfs mlo_mode instead of MLO DM. The disabled DM(s) can be checked/cleared via dbgfs disable_dm. The following is an use example. Read it to show current MLD status. $ cat mlo_mode MLD(s) status: (MLO DM: enable) #0: MLO mode 0, valid 0x6, active 0x2 Write it to switch to MLSR on link id 2. $ echo 0 2 > mlo_mode $ cat mlo_mode MLD(s) status: (MLO DM: disable) #0: MLO mode 0, valid 0x6, active 0x4 Besides, to be safer, add RWLOCK attribute to dbgfs disable_dm. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-11-pkshih@realtek.com
2025-05-10wifi: rtw89: debug: add FW log component for MLOPo-Hao Huang
This allows showing MLO related logs when FW debug mode is on. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-10-pkshih@realtek.com
2025-05-10wifi: rtw89: debug: add MLD table dumpPo-Hao Huang
Add definition for MLD table dump, this is for debug purpose only. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-9-pkshih@realtek.com
2025-05-10wifi: rtw89: debug: extend dbgfs for MLOPo-Hao Huang
Extend dbgfs vif/sta info to show current designated link. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-8-pkshih@realtek.com
2025-05-10wifi: rtw89: add MLO track for MLSR switch decisionPo-Hao Huang
Add MLSR switch mechanism based on tracking RSSI. Switch to a 2 GHz link (if any) when average RSSI is lower than threshold -53. And, switch out from a 2 GHz link when average RSSI is larger than threshold -38. The sequence of MLSR switch handling is like the following. 1. initialize target link and configure to PS mode 2. configure current designated link to PS mode 3. configure target link to non-PS mode 4. deinitialize currently active links except target link The above flow also implies that target link becomes new designated link. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-7-pkshih@realtek.com
2025-05-10wifi: rtw89: add handling of mlo_link_cfg H2C command and C2H eventZong-Zhe Yang
The mlo_link_cfg H2C command is used to tell FW to enter/leave PS mode on a given link. And, need to wait for status of C2H event to ensure if FW deals with it successfully. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-6-pkshih@realtek.com
2025-05-10wifi: rtw89: chan: re-calculate MLO DBCC mode during setting channelZong-Zhe Yang
Wi-Fi 7 chips have dual HW bands. After impending MLO support, they can work with HW-[0] / HW-[1] / HW-[0,1] according to active links. So, during setting channel, also re-calculate the MLO DBCC mode flag. Then, leaf chip functions of setting channel can configure with HWs based on current case. Besides, tweak the initial and idle MLO DBCC mode of Wi-Fi 7 chips to MLO_1_PLUS_1_1RF to work with dual HW bands. And, after disconnecting, due to no active links, MLO DBCC mode will re-calculate to idle case, i.e. MLO_1_PLUS_1_1RF. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-5-pkshih@realtek.com
2025-05-10wifi: rtw89: send nullfunc based on the given linkPo-Hao Huang
The nullfunc sender function is link specific. Use core_tx_write_link with sw_mld flag to TX the nullfunc via the given link. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-4-pkshih@realtek.com
2025-05-10wifi: rtw89: allow driver to do specific band TX for MLOPo-Hao Huang
For data packets that can be sent on any band, fill in main mac_id and let HW decide. For packets that we wish to transmit on specific band, fill in sw_mld field so HW would only send it on that band. Main mac_id is the corresponding mac_id on band 0. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-3-pkshih@realtek.com
2025-05-10wifi: rtw89: extract link part from core tx write functionZong-Zhe Yang
Extract core_tx_write_link from core_tx_write to accept given links as parameters. To make the follow-up changes of TX description more clear, tweak SW functions to split things ahead. (don't change logic at all) Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250505072440.45113-2-pkshih@realtek.com
2025-05-05wifi: rtw89: constrain TX power according to dynamic antenna power tableKuan-Chung Chen
Dynamic Antenna Gain (DAG) adjusts TX power based on antenna gain. To prevent signal distortion from excessive power increases, a dynamic antenna power table limits the maximum adjustable TX power. Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250430055157.13623-3-pkshih@realtek.com
2025-05-05wifi: rtw89: phy: add C2H event handler for report of FW scanKuan-Chung Chen
Newer firmware will notify driver of the Packet Detection (PD) value on the channel after switch channels during FW scan. Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250430055157.13623-2-pkshih@realtek.com
2025-05-05wifi: rtw89: Fix inadverent sharing of struct ieee80211_supported_band dataOndrej Jirman
Internally wiphy writes to individual channels in this structure, so we must not share one static definition of channel list between multiple device instances, because that causes hard to debug breakage. For example, with two rtw89 driven devices in the system, channel information may get incoherent, preventing channel use. Signed-off-by: Ondrej Jirman <megi@xff.cz> Acked-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250429122916.1734879-3-megi@xff.cz
2025-05-05wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*Ondrej Jirman
The code can be simplified by using device managed memory allocations. Simplify it. Signed-off-by: Ondrej Jirman <megi@xff.cz> Acked-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250429122916.1734879-2-megi@xff.cz
2025-05-05wifi: rtw89: introduce helper to get designated link for MLOZong-Zhe Yang
A link bound to HW band 0 was previously always assumed to exist, because it's true on non-MLD connection, and MLO connection is not supported yet. Now, start to consider MLO cases and prepare to enable MLO support in the following. Add skeleton of designated link. For single-link cases, helper returns the one. For multi-link cases, priorities can be scheduled. Then, drop assumption of link bound to HW band 0. One exception is that MCC doesn't work with MLD yet, so it still expects link on HW band 0 somewhere. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-11-pkshih@realtek.com
2025-05-05wifi: rtw89: roc: dynamically handle link id and link instance indexZong-Zhe Yang
Originally, a macro, RTW89_ROC_BY_LINK_INDEX, is used to decide the link which deals with the ROC process. Before enabling MLO support, it's fine to hard-code RTW89_ROC_BY_LINK_INDEX as 0 since the link instance-0 (on HW-0) is always active. But, for the impending enablement of MLO support, tweak the leaf functions to dynamically handle ROC link instance index. Besides, in the follow-up, ROC caller will get a designated link and will then drop RTW89_ROC_BY_LINK_INDEX. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-10-pkshih@realtek.com
2025-05-05wifi: rtw89: Fill in correct Rx link ID for MLOPo-Hao Huang
For MLO connections, RX link ID is required to do address conversion. Fill it in by the hardware info. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-9-pkshih@realtek.com
2025-05-05wifi: rtw89: add MLD capabilities declarationPo-Hao Huang
Add MLD capabilities so association requests can carry multi-link element with correct content. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-8-pkshih@realtek.com
2025-05-05wifi: rtw89: extend join_info H2C command for MLO fieldsPo-Hao Huang
The join_info H2C command is used to indicate a station is connected and tell FW to create/maintain an instance for it. Extend to fill MLO fields. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-7-pkshih@realtek.com
2025-05-05wifi: rtw89: Configure scan band when mlo_dbcc_mode changesPo-Hao Huang
Previously only the first band is used for scanning. With MLO, update scan parameters accordingly by so we can choose to scan from either band. C2H event return value reflects current scanning band, mask it out so we don't treat correct return value as fail. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-6-pkshih@realtek.com
2025-05-05wifi: rtw89: extend mapping from Qsel to DMA ch for MLOZong-Zhe Yang
After impending MLO support, TX Qsel would come from other HW band rather than HW-0. For example, when working on HW-1, TX release report may fill QSEL_XX_1 and cause warning "Cannot map qsel to dma: ...". So, extend the mapping to recognize multiple HW bands. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-5-pkshih@realtek.com
2025-05-05wifi: rtw89: Adjust management queue mapping for [MLO, HW-1]Po-Hao Huang
Adjust mapping of management packets accordingly to send it on the second hardware band. Previously only single band is used and we plan to enable MLO, so the second band will be needed. Data packets will be steered by hardware so no related changes are required. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-4-pkshih@realtek.com
2025-05-05wifi: rtw89: 8922a: use SW CRYPTO when broadcast in MLO modePo-Hao Huang
8922A doesn't support broadcast/multicast traffic under MLO mode. So let mac80211 do the encryption/decryption for us when the connection is in MLO mode. Future BE ICs fixes this issue. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-3-pkshih@realtek.com
2025-05-05wifi: rtw89: 8922a: rfk: adjust timeout time of RX DCKPing-Ke Shih
The RX DCK in firmware could retry 3 times if calibration value is not stable. Roughly each calibration can be done within 16 ms, so expect 16 * 4 (with additional 16 ms) will be enough. More, in coming MLO, it will do calibration on two path, so multiply 2. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250428112456.13165-2-pkshih@realtek.com
2025-05-05wifi: rtw89: fw: Remove "const" on allocation typeKees Cook
In preparation for making the kmalloc family of allocators type aware, we need to make sure that the returned type from the allocation matches the type of the variable being assigned. (Before, the allocator would always return "void *", which can be implicitly cast to any pointer type.) The assigned type is "struct rtw89_reg2_def *" but the returned type, while technically matching, will be const qualified. As there isn't a general way to discard "const" qualifiers, adjust the returned type to match the assigned type. No change in allocation size results. Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250426060935.work.049-kees@kernel.org
2025-04-28wifi: rtw89: mcc: avoid that loose pattern sets negative timing for auxiliary GOZong-Zhe Yang
A MCC (multi-channel concurrency) schedule is like the following. |< mcc interval >| |< duration ref >|< duration aux >| |< tob ref >|< toa ref >|< tob aux >|< toa aux >| V V tbtt ref tbtt aux |< beacon offset >| Original logic might unexpectedly calculate toa (time offset ahead) of auxiliary role to be negative even when there is no role timing limit. If toa-aux is negative, TBTT-aux would in logic fall into duration-ref. Then, if auxiliary role is GO unfortunately, it cannot guarantee that beacons will TX well. So now, when deciding the lower bound of toa-ref, take toa-aux into account. Make toa-aux at least be zero in normal cases. 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-13-pkshih@realtek.com
2025-04-28wifi: rtw89: mcc: refine filling function of start TSFZong-Zhe Yang
Since tob (time offset behind) could be negative, change the type of tob in microsecond to s32. And, refine accumulation with while-loop by calculation with roundup_u64(). Besides, as long as one of the MCC roles is GO, use the short MCC start time. 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-12-pkshih@realtek.com
2025-04-28wifi: rtw89: mcc: support courtesy mechanism on both roles at the same timeZong-Zhe Yang
MCC has a courtesy mechanism which allows one role to use another's duration in a given cycle. Originally, this courtesy mechanism only supports in one direction. However, in some field cases, both of MCC roles may simultaneously have timing configurations that are not good enough. So, support courtesy mechanism in both directions. 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-11-pkshih@realtek.com
2025-04-28wifi: rtw89: mcc: update entire plan when courtesy config changesZong-Zhe Yang
MCC has a courtesy mechanism which allows one role to use another's duration in a given cycle. Courtesy mechanism will be enabled when one role has a not perfect duration. Otherwise, not. When MCC updates, duration of each role will be re-calculated. And then, the new courtesy config might be different from the old one. However, to change courtesy config, the entire MCC plan requires to be renewed when MCC updates. 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-10-pkshih@realtek.com
2025-04-28wifi: rtw89: mcc: handle the case where NoA start time has passedZong-Zhe Yang
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-28wifi: rtw89: mcc: make GO+STA mode calculate dynamic beacon offsetZong-Zhe Yang
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-28wifi: rtw89: don't re-randomize TSF of AP/GOZong-Zhe Yang
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-28wifi: rtw89: mcc: make GO announce one-time NoA for HW scan processZong-Zhe Yang
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-28wifi: rtw89: refactor flow that hw scan handles channel listZong-Zhe Yang
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-28wifi: rtw89: add suffix "_ax" to Wi-Fi 6 HW scan struct and funcZong-Zhe Yang
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-28wifi: rtw89: acpi: introduce country specific TAS enablingKuan-Chung Chen
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-28wifi: rtw89: 8922a: increase beacon loss to 6 secondsKuan-Chung Chen
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-26wifi: rtw89: set pre-calculated antenna matrices for HE trigger frameKuan-Chung Chen
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-26wifi: rtw89: regd: indicate if regd_UK TX power settings follow regd_ETSIZong-Zhe Yang
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