linux-2.6-microblaze.git
6 months agowifi: rtlwifi: Remove unused structs and avoid multiple -Wfamnae warnings
Gustavo A. R. Silva [Wed, 1 May 2024 22:41:37 +0000 (16:41 -0600)]
wifi: rtlwifi: Remove unused structs and avoid multiple -Wfamnae warnings

Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, remove unused structs and fix the following
-Wflex-array-member-not-at-end warnings:

drivers/net/wireless/realtek/rtlwifi/btcoexist/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8188ee/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192c/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192ce/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192de/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8192se/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8723be/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8723com/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/../wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/realtek/rtlwifi/wifi.h:1063:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/ZjLFIa31BGPVCGh1@neat
6 months agowifi: rtw89: correct aSIFSTime for 6GHz band
Ping-Ke Shih [Tue, 30 Apr 2024 02:05:15 +0000 (10:05 +0800)]
wifi: rtw89: correct aSIFSTime for 6GHz band

aSIFSTime is 10us for 2GHz band and 16us for 5GHz and 6GHz bands.
Originally, it doesn't consider 6GHz band and use wrong value, so correct
it accordingly.

Cc: stable@vger.kernel.org
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240430020515.8399-1-pkshih@realtek.com
6 months agowifi: rtw89: wow: add ARP offload feature
Chin-Yen Lee [Thu, 2 May 2024 02:25:05 +0000 (10:25 +0800)]
wifi: rtw89: wow: add ARP offload feature

Add H2C command and offload template packet to allow firmware send ARP
response in WoWLAN mode. Then, firmware in WoWLAN mode can interactive
with peer that issue ARP request to query MAC address.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-13-pkshih@realtek.com
6 months agowifi: rtw89: wow: support WEP cipher on WoWLAN
Chih-Kang Chang [Thu, 2 May 2024 02:25:04 +0000 (10:25 +0800)]
wifi: rtw89: wow: support WEP cipher on WoWLAN

When using the WEP cipher, we need to add the address cam type as all
unicast mode to let firmware to work. Although WEP only set GTK in
mac80211, but we need to set both PTK and GTK information to firmware.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-12-pkshih@realtek.com
6 months agowifi: rtw89: wow: support 802.11w PMF IGTK rekey
Chih-Kang Chang [Thu, 2 May 2024 02:25:03 +0000 (10:25 +0800)]
wifi: rtw89: wow: support 802.11w PMF IGTK rekey

Once we connect to AP with 802.11w enabled, IGTK rekey happen during GTK
happen. We get IGTK IPN from mac80211 and set to firmware, and get latest
IGTK IPN from AOAC report then update to mac80211 after resume. When rekey
happen, also update new IGTK key info to mac80211. Furthermore, We
construct SA query reply packet to firmware. If firmware received SA query
request from AP can transmit reply back when suspend.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-11-pkshih@realtek.com
6 months agowifi: rtw89: wow: update latest PTK GTK info to mac80211 after resume
Chih-Kang Chang [Thu, 2 May 2024 02:25:02 +0000 (10:25 +0800)]
wifi: rtw89: wow: update latest PTK GTK info to mac80211 after resume

When resume we parse AOAC report from firmware using H2C and C2H
registers before enable interrupt, then update PTK RX PN and GTK RX PN.
After enable interrupt, we parse AOAC report using H2C and C2H commands,
then update PTK TX PN and update new GTK key info if GTK rekey during
suspend. Furthermore, We update pattern match index if wakeup by pattern.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-10-pkshih@realtek.com
6 months agowifi: rtw89: wow: add GTK rekey feature related H2C commands
Chih-Kang Chang [Thu, 2 May 2024 02:25:01 +0000 (10:25 +0800)]
wifi: rtw89: wow: add GTK rekey feature related H2C commands

Add PTK TRX IV, GTK RX IV, key encryption algorithm to H2C command to
enable GTK rekey feature.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-9-pkshih@realtek.com
6 months agowifi: rtw89: wow: construct EAPoL packet for GTK rekey offload
Chih-Kang Chang [Thu, 2 May 2024 02:25:00 +0000 (10:25 +0800)]
wifi: rtw89: wow: construct EAPoL packet for GTK rekey offload

We construct EAPoL packet with various encryption method, and download
to firmware. Also we add Key Encryption Key (KEK) and Key Confirmation Key
(KCK) to H2C command. Once firmware received EAPoL group rekey packet(1/2)
can TX EAPoL group rekey packet(2/2) when suspend.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-8-pkshih@realtek.com
6 months agowifi: rtw89: use struct to fill H2C of WoWLAN global configuration
Chih-Kang Chang [Thu, 2 May 2024 02:24:59 +0000 (10:24 +0800)]
wifi: rtw89: use struct to fill H2C of WoWLAN global configuration

This H2C command is used to set WoWLAN global config, and we correct
the H2C format by enlarging the H2C size to fill GTK and PTK info.
This fix is compatible with old firmware.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-7-pkshih@realtek.com
6 months agowifi: rtw89: use struct to access firmware command h2c_dctl_sec_cam_v1
Chih-Kang Chang [Thu, 2 May 2024 02:24:58 +0000 (10:24 +0800)]
wifi: rtw89: use struct to access firmware command h2c_dctl_sec_cam_v1

This H2C command set key information into security CAM including key
index, entry index and valid map. No logic is changed.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-6-pkshih@realtek.com
6 months agowifi: rtw89: wow: prepare PTK GTK info from mac80211
Chih-Kang Chang [Thu, 2 May 2024 02:24:57 +0000 (10:24 +0800)]
wifi: rtw89: wow: prepare PTK GTK info from mac80211

Get the PTK and PTK TRX PN value and transfer to IV value, these
values will used by firmware to generate packets with correct IV value.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-5-pkshih@realtek.com
6 months agowifi: rtw89: wow: parsing Auth Key Management from associate request
Chih-Kang Chang [Thu, 2 May 2024 02:24:56 +0000 (10:24 +0800)]
wifi: rtw89: wow: parsing Auth Key Management from associate request

Need Auth Key Management(AKM) to let firmware to generate appropriate
EAPoL packet for GTK rekey. The AKM is present in the association request
RSN IE to indicate which cipher that station selected.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-4-pkshih@realtek.com
6 months agowifi: rtw89: wow: refine WoWLAN flows of HCI interrupts and low power mode
Chih-Kang Chang [Thu, 2 May 2024 02:24:55 +0000 (10:24 +0800)]
wifi: rtw89: wow: refine WoWLAN flows of HCI interrupts and low power mode

After enabling packet offload, the TX will be stuck after resume from
WoWLAN mode. And the 8852c gets error messages like

rtw89_8852ce 0000:04:00.0: No busy txwd pages available
rtw89_8852ce 0000:04:00.0: queue 0 txwd 100 is not idle
rtw89_8852ce 0000:04:00.0: queue 0 txwd 101 is not idle
rtw89_8852ce 0000:04:00.0: queue 0 txwd 102 is not idle
rtw89_8852ce 0000:04:00.0: queue 0 txwd 103 is not idle

If suspend/resume many times that firmware will download failed and
disconnection.

To fix these issues, We removed the rtw89_hci_disable_intr() and
rtw89_hci_enable_intr() during rtw89_wow_swap_fw() to prevent add packet
offload can't receive c2h back due to interrupt disable. Only 8852C and
8922A needs to disable interrupt before downloading fw.

Furthermore, we avoid using low power HCI mode on WoWLAN mode, to prevent
interrupt enabled, then get interrupt and calculate RXBD mismatched due to
software RXBD index already reset but hardware RXBD index not yet.

Fixes: 5c12bb66b79d ("wifi: rtw89: refine packet offload flow")
Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-3-pkshih@realtek.com
6 months agowifi: rtw89: wow: send RFK pre-nofity H2C command in WoWLAN mode
Chin-Yen Lee [Thu, 2 May 2024 02:24:54 +0000 (10:24 +0800)]
wifi: rtw89: wow: send RFK pre-nofity H2C command in WoWLAN mode

802.11be WiFi chips need a RFK (RF calibration) notify H2C command after
downloading WoWLAN firmware to make sure RF TX/RX work fine when leaving
power save mode, so add it to correct RF TX/RX in WoWLAN mode.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240502022505.28966-2-pkshih@realtek.com
6 months agowifi: rtl8xxxu: cleanup includes
Ping-Ke Shih [Mon, 29 Apr 2024 02:47:11 +0000 (10:47 +0800)]
wifi: rtl8xxxu: cleanup includes

Remove unnecessary includes from driver. The first step is to add
necessary includes to driver's header files to make them can be included
individually. Then, driver's C files include driver's header files first,
and check if still missed header files of kernel.

The results show that most C files only include driver's header files.
Only core.c needs to include additional linux/firmware.h.

Also sort includes in alphabetic order.

Compile tested only.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240429024711.30992-1-pkshih@realtek.com
6 months agowifi: rtl8xxxu: remove rtl8xxxu_ prefix from filenames
Kalle Valo [Fri, 26 Apr 2024 14:19:39 +0000 (17:19 +0300)]
wifi: rtl8xxxu: remove rtl8xxxu_ prefix from filenames

The driver is already in a directory named rtl8xxxu, there's no need to
duplicate that in the filename as well. Now file listing looks a lot more
reasonable:

8188e.c  8192c.c  8192f.c  8723a.c  core.c   Makefile  rtl8xxxu.h
8188f.c  8192e.c  8710b.c  8723b.c  Kconfig  regs.h

No functional changes, compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240426141939.3881678-2-kvalo@kernel.org
6 months agowifi: rtl8xxxu: remove some unused includes
Kalle Valo [Fri, 26 Apr 2024 14:19:38 +0000 (17:19 +0300)]
wifi: rtl8xxxu: remove some unused includes

I noticed by random that rtl8xxxu includes linux/wireless.h even though it
doesn't need it. While investigating a bit more I found even more unused
include files:

#include <linux/init.h>
#include <linux/sched.h>
#include <linux/ethtool.h>

It looks like that the includes are just copied to every file without checking
if the file really needs the include. So more includes could be removed but
that would need more careful analysis per each file.

No functional changes, compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240426141939.3881678-1-kvalo@kernel.org
6 months agowifi: rtw89: 8852c: refine power sequence to imporve power consumption
Chia-Yuan Li [Fri, 26 Apr 2024 06:12:00 +0000 (14:12 +0800)]
wifi: rtw89: 8852c: refine power sequence to imporve power consumption

Power sequence is a flow to enable/disable WiFi card with hardware
parameters. Adjust power and clock parameters according to results
of internal simulation and verification, so apply them to have better
power consumption.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240426061200.44262-2-pkshih@realtek.com
6 months agowifi: rtw89: reset AFEDIG register in power off sequence
Chin-Yen Lee [Fri, 26 Apr 2024 06:11:59 +0000 (14:11 +0800)]
wifi: rtw89: reset AFEDIG register in power off sequence

Some Wi-Fi chips meet card lost issue due to unstable hardware signal of
GPIO pins during power off. Reset AFEDIG register before BB reset in
power off sequence could avoid unstable signal and fix the issue.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240426061200.44262-1-pkshih@realtek.com
6 months agowifi: rtlwifi: Adjust rtl8192d-common for USB
Bitterblue Smith [Thu, 25 Apr 2024 18:15:20 +0000 (21:15 +0300)]
wifi: rtlwifi: Adjust rtl8192d-common for USB

A few of the shared functions need small changes for the USB driver:
 - firmware loading
 - efuse reading
 - rate mask updating
 - rf register reading
 - initial gain for scanning

Also, add a few macros to wifi.h and initialise rtlhal.interfaceindex
for USB devices.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/28100330-f421-4b85-b41b-f1045380cef2@gmail.com
6 months agowifi: rtlwifi: Clean up rtl8192d-common a bit
Bitterblue Smith [Thu, 25 Apr 2024 18:14:35 +0000 (21:14 +0300)]
wifi: rtlwifi: Clean up rtl8192d-common a bit

Improve readability:
 * add empty lines
 * use abs_diff in rtl92d_dm_txpower_tracking_callback_thermalmeter
 * roll up repeated statements into a for loop in
   rtl92d_dm_txpower_tracking_callback_thermalmeter
 * shorten lines by replacing many instances of "rtlpriv->dm" with "dm"
   pointer in rtl92d_dm_txpower_tracking_callback_thermalmeter
 * sort some declarations by length
 * refactor _rtl92d_get_txpower_writeval_by_regulatory a little
 * refactor _rtl92de_readpowervalue_fromprom a little

Delete unused structs tag_dynamic_init_gain_operation_type_definition
and swat.

Simplify rtl92d_fill_h2c_cmd a little and delete a pointless wrapper
function.

Tested with a single MAC single PHY USB dongle from Aliexpress labelled
"CC&C WL-6210-V3".

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/f6acfa78-2f4e-47f1-95d4-65aa77510113@gmail.com
6 months agowifi: rtlwifi: Move code from rtl8192de to rtl8192d-common
Bitterblue Smith [Thu, 25 Apr 2024 18:14:04 +0000 (21:14 +0300)]
wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common

Create the new module rtl8192d-common and move some code into it from
rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver
(USB) can share some of the code.

This is mostly the code that required little effort to make it
shareable. There are a few more functions which they could share, with
more changes.

Add phy_iq_calibrate member to struct rtl_hal_ops to allow moving the
TX power tracking code from dm.c.

The other changes in this patch are adjusting whitespace, renaming some
functions, making some arrays const, and making checkpatch.pl less
unhappy.

rtl8192de is compile-tested only. rtl8192d-common is tested with the
new rtl8192du driver.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/69c4358a-6fbf-4433-92a6-341c83e9dd48@gmail.com
6 months agowifi: rtlwifi: rtl8192de: Fix endianness issue in RX path
Bitterblue Smith [Thu, 25 Apr 2024 18:13:12 +0000 (21:13 +0300)]
wifi: rtlwifi: rtl8192de: Fix endianness issue in RX path

Structs rx_desc_92d and rx_fwinfo_92d will not work for big endian
systems.

Delete rx_desc_92d because it's big and barely used, and instead use
the get_rx_desc_rxmcs and get_rx_desc_rxht functions, which work on big
endian systems too.

Fix rx_fwinfo_92d by duplicating four of its members in the correct
order.

Tested only with RTL8192DU, which will use the same code.
Tested only on a little endian system.

Cc: stable@vger.kernel.org
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/698463da-5ef1-40c7-b744-fa51ad847caf@gmail.com
6 months agowifi: rtlwifi: rtl8192de: Fix low speed with WPA3-SAE
Bitterblue Smith [Thu, 25 Apr 2024 18:12:38 +0000 (21:12 +0300)]
wifi: rtlwifi: rtl8192de: Fix low speed with WPA3-SAE

Some (all?) management frames are incorrectly reported to mac80211 as
decrypted when actually the hardware did not decrypt them. This results
in speeds 3-5 times lower than expected, 20-30 Mbps instead of 100
Mbps.

Fix this by checking the encryption type field of the RX descriptor.
rtw88 does the same thing.

This fix was tested only with rtl8192du, which will use the same code.

Cc: stable@vger.kernel.org
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/4d600435-f0ea-46b0-bdb4-e60f173da8dd@gmail.com
6 months agowifi: rtlwifi: rtl8192de: Fix 5 GHz TX power
Bitterblue Smith [Thu, 25 Apr 2024 18:09:21 +0000 (21:09 +0300)]
wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power

Different channels have different TX power settings. rtl8192de is using
the TX power setting from the wrong channel in the 5 GHz band because
_rtl92c_phy_get_rightchnlplace expects an array which includes all the
channel numbers, but it's using an array which includes only the 5 GHz
channel numbers.

Use the array channel_all (defined in rtl8192de/phy.c) instead of
the incorrect channel5g (defined in core.c).

Tested only with rtl8192du, which will use the same TX power code.

Cc: stable@vger.kernel.org
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/c7653517-cf88-4f57-b79a-8edb0a8b32f0@gmail.com
6 months agowifi: rtlwifi: rtl8723be: Make read-only arrays static const
Colin Ian King [Thu, 25 Apr 2024 15:57:33 +0000 (16:57 +0100)]
wifi: rtlwifi: rtl8723be: Make read-only arrays static const

Don't populate the read-only arrays cck_rates, ofdm_rates, ht_rates_1t and
channel_all on the stack at run time, instead make them static const and
clean up the formatting.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240425155733.114423-1-colin.i.king@gmail.com
6 months agowifi: rtw89: Remove the redundant else branch in the function rtw89_phy_get_kpath
Jiapeng Chong [Mon, 22 Apr 2024 07:29:22 +0000 (15:29 +0800)]
wifi: rtw89: Remove the redundant else branch in the function rtw89_phy_get_kpath

The assignment of the else and if branches is the same in the "case:
MLO_2_PLUS_0_1RF" branch of the function rtw89_phy_get_kpath, so we
remove it and add comments here to make the code easier to understand.

./drivers/net/wireless/realtek/rtw89/phy.c:6406:2-4: WARNING: possible condition with no effect (if == else).

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=8812
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240422072922.50940-1-jiapeng.chong@linux.alibaba.com
6 months agowifi: rtw89: coex: Check and enable reports after run coex
Ching-Te Ku [Tue, 23 Apr 2024 13:05:02 +0000 (21:05 +0800)]
wifi: rtw89: coex: Check and enable reports after run coex

If there is any changes with Wi-Fi/Bluetooth, the mechanism will
trigger run_coex to update information and coexistence mechanism.
Enable/Disable reports here can make sure the action take effect
in time.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-9-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Wi-Fi role v8 condition when set BTG control
Ching-Te Ku [Tue, 23 Apr 2024 13:05:01 +0000 (21:05 +0800)]
wifi: rtw89: coex: Add Wi-Fi role v8 condition when set BTG control

BTG(A hardware block, which Wi-Fi 2.4Ghz & Bluetooth shared a part
of hardware). Because some information are saved in role info. So the
logic also need to get value from the version 8 role info.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-8-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Wi-Fi role v8 condition when set Bluetooth channel
Ching-Te Ku [Tue, 23 Apr 2024 13:05:00 +0000 (21:05 +0800)]
wifi: rtw89: coex: Add Wi-Fi role v8 condition when set Bluetooth channel

This function is to let Bluetooth know Wi-Fi is using which channel,
and ask Bluetooth do not hop into the nearby channel. Wi-Fi channel
is saved at role info, this patch make the logic also get the channel
value from version 8 role info.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-7-pkshih@realtek.com
6 months agowifi: rtw89: coex: Fix unexpected value in version 7 slot parameter
Ching-Te Ku [Tue, 23 Apr 2024 13:04:59 +0000 (21:04 +0800)]
wifi: rtw89: coex: Fix unexpected value in version 7 slot parameter

It will assign wrong value to version 7 slot parameter setting, because
the structure member order has changed. Add a for-loop to assign variables
manually.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-6-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Bluetooth version report version 7
Ching-Te Ku [Tue, 23 Apr 2024 13:04:58 +0000 (21:04 +0800)]
wifi: rtw89: coex: Add Bluetooth version report version 7

The report is reported from Bluetooth, it shows the current Bluetooth
driver & firmware version code. Wi-Fi & Bluetooth need to use compatible
version. The version 7 report adjust the structure variables order.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-5-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Bluetooth frequency hopping map version 7
Ching-Te Ku [Tue, 23 Apr 2024 13:04:57 +0000 (21:04 +0800)]
wifi: rtw89: coex: Add Bluetooth frequency hopping map version 7

The report is reported from Bluetooth, it described the usable
Bluetooth channel map. Bluetooth should not hopped into Wi-Fi
using channel. Version 8 report adjust the structure variables
order.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-4-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Bluetooth scan parameter report version 7
Ching-Te Ku [Tue, 23 Apr 2024 13:04:56 +0000 (21:04 +0800)]
wifi: rtw89: coex: Add Bluetooth scan parameter report version 7

This report is reported from Bluetooth, it described Bluetooth scan
parameters. Version 7 adjust the structure variables order.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-3-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add Wi-Fi null data status version 7
Ching-Te Ku [Tue, 23 Apr 2024 13:04:55 +0000 (21:04 +0800)]
wifi: rtw89: coex: Add Wi-Fi null data status version 7

The mechanism will use Wi-Fi null packet to stop the packets from
access point to avoid the interference to Bluetooth when switch
to Bluetooth slot. The report can check whether the null packet is
working as expected or not.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423130502.32682-2-pkshih@realtek.com
6 months agowifi: rtw89: 8852b: update hardware parameters for RFE type 5
Ping-Ke Shih [Tue, 23 Apr 2024 12:12:47 +0000 (20:12 +0800)]
wifi: rtw89: 8852b: update hardware parameters for RFE type 5

RFE type 5 of 8852B is a type of hardware module, which can use different
external components, so update register settings accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423121247.24714-2-pkshih@realtek.com
6 months agowifi: rtw89: fix CTS transmission issue with center frequency deviation
Kuan-Chung Chen [Tue, 23 Apr 2024 12:12:46 +0000 (20:12 +0800)]
wifi: rtw89: fix CTS transmission issue with center frequency deviation

The CTS cannot be received by the peer due to center frequency
deviation. This issue can be solved by correct settings to
transmit proper CTS.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240423121247.24714-1-pkshih@realtek.com
6 months agowifi: rtw89: coex: Re-order the index for the report from firmware
Ching-Te Ku [Thu, 18 Apr 2024 02:12:07 +0000 (10:12 +0800)]
wifi: rtw89: coex: Re-order the index for the report from firmware

The report index has changed, correct the index for the corresponding
firmware version.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-10-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add coexistence firmware control report version 8
Ching-Te Ku [Thu, 18 Apr 2024 02:12:06 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add coexistence firmware control report version 8

This report summary monitor the firmware related counters, firmware
version. It will help to analysis the communication between driver and
firmware.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-9-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add GPIO signal control version 7
Ching-Te Ku [Thu, 18 Apr 2024 02:12:05 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add GPIO signal control version 7

The feature can help to know how the firmware mechanism working.
There are several trigger point set in firmware. If driver send
the H2C command to firmware to enable the trigger, firmware will
toggle GPIO to perform the firmware mechanism.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-8-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add register monitor report v7 format
Ching-Te Ku [Thu, 18 Apr 2024 02:12:04 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add register monitor report v7 format

To avoid driver I/O, firmware will periodic monitor the register
settings and update to driver. The v7 report adjust the structure
variables order, so driver does changes accordingly.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-7-pkshih@realtek.com
6 months agowifi: rtw89: coex: Update Bluetooth polluted Wi-Fi TX logic
Ching-Te Ku [Thu, 18 Apr 2024 02:12:03 +0000 (10:12 +0800)]
wifi: rtw89: coex: Update Bluetooth polluted Wi-Fi TX logic

When the PTA breaks Wi-Fi traffic request caused Bluetooth traffic,
it means Bluetooth polluted the Wi-Fi traffic. When Wi-Fi is TX, the
mechanism can ignore the polluted Wi-Fi packet retry counter, it is
help to the stability of Wi-Fi TX rate. The chip RTL8922A has not only
one MAC, so need to include the all MAC as reference.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-6-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add PTA path control condition for chip RTL8922A
Ching-Te Ku [Thu, 18 Apr 2024 02:12:02 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add PTA path control condition for chip RTL8922A

PTA(packet traffic arbitration) is a coexistence hardware feature.
Wi-Fi & Bluetooth owns their PTA, the function is to show whose PTA
control the traffic now. RTL8922A PTA control is controlled by hardware
logic, there is no register to monitor the setting.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-5-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add version 3 report map of H2C command
Ching-Te Ku [Thu, 18 Apr 2024 02:12:01 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add version 3 report map of H2C command

The map is the H2C index for driver forward the driver status to firmware.
The status is for firmware to make mechanism decision, if driver provided
the wrong index to firmware, it will make parse the status incorrectly.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-4-pkshih@realtek.com
6 months agowifi: rtw89: coex: Add v7 firmware cycle status report
Ching-Te Ku [Thu, 18 Apr 2024 02:12:00 +0000 (10:12 +0800)]
wifi: rtw89: coex: Add v7 firmware cycle status report

To support v7 version firmware cycle report, which adjusts the structure
variables order, apply the related structure and functions. The cycle
report can show how the firmware mechanism runs.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-3-pkshih@realtek.com
6 months agowifi: rtw89: coex: Allow Bluetooth doing traffic during Wi-Fi scan
Ching-Te Ku [Thu, 18 Apr 2024 02:11:59 +0000 (10:11 +0800)]
wifi: rtw89: coex: Allow Bluetooth doing traffic during Wi-Fi scan

The Wi-Fi/Bluetooth slot are toggled by firmware timer when Wi-Fi doing
firmware scan, and Wi-Fi slot don't allow Bluetooth do traffic when
Wi-Fi slot. It will trigger Bluetooth audio lag in a random rate, because
Bluetooth can not have enough time slot to keep enough data to play audio.
This patch make Bluetooth can do traffic during Wi-Fi slot, this can help
Bluetooth to collect audio data in time.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418021207.32173-2-pkshih@realtek.com
6 months agowifi: rtl8xxxu: Add LED control code for RTL8723BU
Bitterblue Smith [Mon, 22 Apr 2024 21:38:35 +0000 (00:38 +0300)]
wifi: rtl8xxxu: Add LED control code for RTL8723BU

Software control (on/off) and hardware control (automatic blinking)
tested with EDUP EP-N8568.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/7df66d1f-87a1-4f44-9aac-ce75438abde3@gmail.com
6 months agowifi: rtl8xxxu: Add LED control code for RTL8192CU family
Bitterblue Smith [Thu, 18 Apr 2024 22:03:35 +0000 (01:03 +0300)]
wifi: rtl8xxxu: Add LED control code for RTL8192CU family

Also, don't set bit 7 of LEDCFG2 for RTL8192CU. If bit 7 is set the LED
never turns on. In this family only RTL8188CUS needs bit 7 of LEDCFG2
set.

Software control (on/off) and hardware control (automatic blinking)
tested with Netcore NW362 (RTL8192CU).

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/4b5970cf-d28b-415a-b911-82cdb5e9ce99@gmail.com
6 months agowifi: rtl8xxxu: Add separate MAC init table for RTL8192CU
Bitterblue Smith [Thu, 18 Apr 2024 22:02:37 +0000 (01:02 +0300)]
wifi: rtl8xxxu: Add separate MAC init table for RTL8192CU

Until now RTL8192CU family was using the MAC init table from RTL8723AU,
but these tables are not identical in the two vendor drivers. Import
the correct table for RTL8192CU.

Also move the existing MAC init table to rtl8xxxu_8723a.c, which is
the only remaining user.

Tested with the Netcore NW362 (RTL8192CU).

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/a53ed8b9-27fc-4871-a20a-ad42c6d210d3@gmail.com
6 months agowifi: rtl8xxxu: enable MFP support with security flag of RX descriptor
Martin Kaistra [Thu, 18 Apr 2024 07:18:13 +0000 (09:18 +0200)]
wifi: rtl8xxxu: enable MFP support with security flag of RX descriptor

In order to connect to networks which require 802.11w, add the
MFP_CAPABLE flag and let mac80211 do the actual crypto in software.

When a robust management frame is received, rx_dec->swdec is not set,
even though the HW did not decrypt it. Extend the check and don't set
RX_FLAG_DECRYPTED for these frames in order to use SW decryption.

Use the security flag in the RX descriptor for this purpose, like it is
done in the rtw88 driver.

Cc: stable@vger.kernel.org
Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418071813.1883174-3-martin.kaistra@linutronix.de
6 months agoRevert "wifi: rtl8xxxu: enable MFP support"
Martin Kaistra [Thu, 18 Apr 2024 07:18:12 +0000 (09:18 +0200)]
Revert "wifi: rtl8xxxu: enable MFP support"

This reverts commit 77f5924fc41c243e907c80ce2576902d3a9cb336.

There is a more elegant solution to check for not decrypted frames,
which is to check the security flag in the RX descriptor.

Revert commit 77f5924fc41c ("wifi: rtl8xxxu: enable MFP support") in
favor of this to be able to send it to stable.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418071813.1883174-2-martin.kaistra@linutronix.de
6 months agowifi: rtw88: suppress messages of failed to flush queue
Ping-Ke Shih [Thu, 18 Apr 2024 00:29:16 +0000 (08:29 +0800)]
wifi: rtw88: suppress messages of failed to flush queue

Driver throws messages when scanning with a lot of traffic, because packets
in TX buffer can not be transmitted in time. Since this is a common
occurrence, change them to debug message with special debug mask that
developers can turn on this mask by default for further analysis.

Cc: Lewis Robbins <lewis.robbins2@gmail.com>
Tested-by: Lewis Robbins <lewis.robbins2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240418002916.5965-1-pkshih@realtek.com
6 months agowifi: rtw89: 8922a: fix argument to hal_reset in bb_cfg_txrx_path
Zong-Zhe Yang [Wed, 17 Apr 2024 09:00:58 +0000 (17:00 +0800)]
wifi: rtw89: 8922a: fix argument to hal_reset in bb_cfg_txrx_path

When hal_reset on MAC_1/PHY_1, we should pass tx_en1 instead of tx_en0.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240417090058.42663-1-pkshih@realtek.com
6 months agowifi: rtw89: set WIPHY_FLAG_DISABLE_WEXT before MLO
Zong-Zhe Yang [Wed, 17 Apr 2024 09:00:50 +0000 (17:00 +0800)]
wifi: rtw89: set WIPHY_FLAG_DISABLE_WEXT before MLO

We will support MLO on 802.11be chip, e.g. RTL8922A, in the future. At that
time being, we will set WIPHY_FLAG_SUPPORTS_MLO according to chip info and
FW features at runtime. But, with WIPHY_FLAG_SUPPORTS_MLO flag, cfg80211
will disable WEXT. In case inconsistent user experience, if 802.11be chip,
we disable WEXT uniformly from now on.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240417090050.42607-1-pkshih@realtek.com
7 months agowifi: rtl8xxxu: Fix the TX power of RTL8192CU, RTL8723AU
Bitterblue Smith [Mon, 15 Apr 2024 20:59:05 +0000 (23:59 +0300)]
wifi: rtl8xxxu: Fix the TX power of RTL8192CU, RTL8723AU

Don't subtract 1 from the power index. This was added in commit
2fc0b8e5a17d ("rtl8xxxu: Add TX power base values for gen1 parts")
for unknown reasons. The vendor drivers don't do this.

Also correct the calculations of values written to
REG_OFDM0_X{C,D}_TX_IQ_IMBALANCE. According to the vendor driver,
these are used for TX power training.

With these changes rtl8xxxu sets the TX power of RTL8192CU the same
as the vendor driver.

None of this appears to have any effect on my RTL8192CU device.

Cc: stable@vger.kernel.org
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/6ae5945b-644e-45e4-a78f-4c7d9c987910@gmail.com
7 months agowifi: rtw89: regd: handle policy of 6 GHz SP according to BIOS
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:29 +0000 (19:57 +0800)]
wifi: rtw89: regd: handle policy of 6 GHz SP according to BIOS

According to BIOS configuration of Realtek ACPI DSM function 7,
RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, we handle the regd policy of 6 GHz SP.

If BIOS indicates to override driver settings, we only allow the countries,
which are enabled by BIOS, to use 6 GHz SP power. Other countries will be
applied to select default power when recalculating 6 GHz regulatory power
selection.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-9-pkshih@realtek.com
7 months agowifi: rtw89: acpi: process 6 GHz SP policy from ACPI DSM
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:28 +0000 (19:57 +0800)]
wifi: rtw89: acpi: process 6 GHz SP policy from ACPI DSM

Realtek ACPI DSM func 7, RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, accepts a format
via ACPI buffer as below.

| index | description                      |
--------------------------------------------
| [0-3] | signature                        |
| [4]   | revision                         |
| [5]   | override driver settings, or not |
| [6]   | configuration if override        |
| [7]   | reserved                         |

where field of [6] is a bitmap by country,
and for now, only define BIT(0) is for US.

Through this function with overriding, BIOS can indicate to allow/block
6 GHz SP power by country.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-8-pkshih@realtek.com
7 months agowifi: rtw89: regd: extend policy of UNII-4 for IC regulatory
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:27 +0000 (19:57 +0800)]
wifi: rtw89: regd: extend policy of UNII-4 for IC regulatory

Originally, we have an ACPI function to determine whether to enable UNII-4.
Since IC (Industry Canada) has allowed UNII-4, the ACPI result is extended
to be two bits as below.
  * BIT(0): determine if rtw89_regd::FCC enable UNII-4
  * BIT(1): determine if rtw89_regd::IC enable UNII-4

Besides, to take old platforms into account, we enable UNII-4 on IC if and
only if BIOS configuration enable it.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-7-pkshih@realtek.com
7 months agowifi: rtw89: regd: block 6 GHz by policy if not specific country
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:26 +0000 (19:57 +0800)]
wifi: rtw89: regd: block 6 GHz by policy if not specific country

We allow 6 GHz on target regd if and only if
  1. it is a specific country, i.e. not any world-wide cases
  2. its 6 GHz is not blocked

So, for world-wide cases, their 6 GHz will be blocked now.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-6-pkshih@realtek.com
7 months agowifi: rtw89: 8852c: update TX power tables to R69.1 (2 of 2)
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:25 +0000 (19:57 +0800)]
wifi: rtw89: 8852c: update TX power tables to R69.1 (2 of 2)

Deconfigure fields for 6GHz SP. Don't use these set of values until
getting certification of 6GHz SP regulation. Without configuring
these fields, driver takes world-wide values when 6GHz SP cases.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-5-pkshih@realtek.com
7 months agowifi: rtw89: 8852c: update TX power tables to R69.1 (1 of 2)
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:24 +0000 (19:57 +0800)]
wifi: rtw89: 8852c: update TX power tables to R69.1 (1 of 2)

Deconfigure fields for 6GHz SP. Don't use these set of values until
getting certification of 6GHz SP regulation. Without configuring
these fields, driver takes world-wide values when 6GHz SP cases.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-4-pkshih@realtek.com
7 months agowifi: rtw89: fw: scan offload prohibit all 6 GHz channel if no 6 GHz sband
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:23 +0000 (19:57 +0800)]
wifi: rtw89: fw: scan offload prohibit all 6 GHz channel if no 6 GHz sband

We have some policy via BIOS to block uses of 6 GHz. In this case, 6 GHz
sband will be NULL even if it is WiFi 7 chip. So, add NULL handling here
to avoid crash.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-3-pkshih@realtek.com
7 months agowifi: rtw89: sar: correct TX power boundary for MAC domain
Zong-Zhe Yang [Fri, 12 Apr 2024 11:57:22 +0000 (19:57 +0800)]
wifi: rtw89: sar: correct TX power boundary for MAC domain

TX power in MAC domain is signed 7 bits. (unit: based on txpwr_factor_mac)
The valid range should be [-64, 63].

While the original wrong bounds might not really be encountered, still make
them correct.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240412115729.8316-2-pkshih@realtek.com
7 months agowifi: rtw89: pci: correct TX resource checking for PCI DMA channel of firmware command
Ping-Ke Shih [Wed, 10 Apr 2024 01:13:16 +0000 (09:13 +0800)]
wifi: rtw89: pci: correct TX resource checking for PCI DMA channel of firmware command

The DMA channel of firmware command doesn't use TX WD (WiFi descriptor), so
don't need to consider number of TX WD as factor of TX resource. Otherwise,
during pause state (a transient state to switch to/from low power mode)
firmware commands could be dropped and driver throws warnings suddenly:

   rtw89_8852ce 0000:04:00.0: no tx fwcmd resource
   rtw89_8852ce 0000:04:00.0: failed to send h2c

The case we met is that driver sends RSSI strength of firmware command at
RX path that could be running concurrently with switching low power mode.
The missing of this firmware command doesn't affect user experiences,
because the RSSI strength will be updated again after a while.

The DMA descriptors of normal packets has three layers like:

  +-------+
  | TX BD | (*n elements)
  +-------+
      |
      |   +-------+
      +-> | TX WD | (*m elements)
          +-------+
              |
              |   +--------+
              +-> |   SKB  |
                  +--------+

And, firmware command queue (TXCH 12) is a special queue that has only
two layers:

  +-------+
  | TX BD | (*n elements)
  +-------+
      |
      |   +------------------+
      +-> | firmware command |
          +------------------+

Fixes: 4a29213cd775 ("wifi: rtw89: pci: correct TX resource checking in low power mode")
Cc: stable@vger.kernel.org
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240410011316.9906-1-pkshih@realtek.com
7 months agowifi: mac80211: extend IEEE80211_KEY_FLAG_GENERATE_MMIE to other ciphers
Michael-CY Lee [Tue, 26 Mar 2024 00:30:36 +0000 (08:30 +0800)]
wifi: mac80211: extend IEEE80211_KEY_FLAG_GENERATE_MMIE to other ciphers

Extend the flag IEEE80211_KEY_FLAG_GENERATE_MMIE to BIP-CMAC-256,
BIP-GMAC-128 and BIP-GMAC-256 for the same reason and in the same
way that the flag was added originally in commit a0b4496a4368
("mac80211: add IEEE80211_KEY_FLAG_GENERATE_MMIE to ieee80211_key_flags").

Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
Link: https://msgid.link/20240326003036.15215-1-michael-cy.lee@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 months agowifi: mac80211: Add missing return value documentation
Jeff Johnson [Fri, 29 Mar 2024 20:27:18 +0000 (13:27 -0700)]
wifi: mac80211: Add missing return value documentation

kernel-doc is reporting some warnings, so fix them:

% scripts/kernel-doc -Wall -Werror -none include/net/mac80211.h
include/net/mac80211.h:2056: warning: No description found for return value of 'wdev_to_ieee80211_vif'
include/net/mac80211.h:2066: warning: No description found for return value of 'ieee80211_vif_to_wdev'
include/net/mac80211.h:5603: warning: No description found for return value of 'ieee80211_beacon_cntdwn_is_complete'
include/net/mac80211.h:5968: warning: No description found for return value of 'ieee80211_gtk_rekey_add'
include/net/mac80211.h:6350: warning: No description found for return value of 'ieee80211_find_sta_by_link_addrs'
include/net/mac80211.h:6478: warning: No description found for return value of 'ieee80211_txq_airtime_check'
include/net/mac80211.h:6981: warning: No description found for return value of 'rate_control_set_rates'
include/net/mac80211.h:7142: warning: No description found for return value of 'ieee80211_tx_prepare_skb'
include/net/mac80211.h:7156: warning: No description found for return value of 'ieee80211_parse_tx_radiotap'
include/net/mac80211.h:7277: warning: No description found for return value of 'ieee80211_tx_dequeue'
include/net/mac80211.h:7292: warning: No description found for return value of 'ieee80211_tx_dequeue_ni'
include/net/mac80211.h:7324: warning: No description found for return value of 'ieee80211_next_txq'
include/net/mac80211.h:7405: warning: No description found for return value of 'ieee80211_txq_may_transmit'
include/net/mac80211.h:7466: warning: No description found for return value of 'ieee80211_calc_rx_airtime'
include/net/mac80211.h:7480: warning: No description found for return value of 'ieee80211_calc_tx_airtime'
include/net/mac80211.h:7528: warning: No description found for return value of 'ieee80211_is_tx_data'
include/net/mac80211.h:7562: warning: No description found for return value of 'ieee80211_set_active_links'
17 warnings as Errors

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://msgid.link/20240329-mac80211-kdoc-retval-v1-2-5e4d1ad6c250@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 months agowifi: mac80211: remove ieee80211_set_hw_80211_encap()
Jeff Johnson [Fri, 29 Mar 2024 20:27:17 +0000 (13:27 -0700)]
wifi: mac80211: remove ieee80211_set_hw_80211_encap()

While fixing kernel-doc issues it was discovered that the
ieee80211_set_hw_80211_encap() prototype doesn't actually have an
implementation, so remove it.

Note the implementation was removed in commit 6aea26ce5a4c ("mac80211:
rework tx encapsulation offload API").

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://msgid.link/20240329-mac80211-kdoc-retval-v1-1-5e4d1ad6c250@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 months agowifi: mac80211: correctly document struct mesh_table
Jeff Johnson [Fri, 29 Mar 2024 05:44:13 +0000 (22:44 -0700)]
wifi: mac80211: correctly document struct mesh_table

Currently kernel-doc -Wall reports:

net/mac80211/ieee80211_i.h:687: warning: missing initial short description on line:
 * struct mesh_table

So add a short description.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/linux-wireless/a009a21a-56d7-4a1a-aaf9-feefa5acc561@infradead.org/
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://msgid.link/20240328-mesh_table-kerneldoc-v1-1-174c4df341b1@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 months agoMerge tag 'rtw-next-2024-04-04' of https://github.com/pkshih/rtw
Kalle Valo [Fri, 5 Apr 2024 09:00:33 +0000 (12:00 +0300)]
Merge tag 'rtw-next-2024-04-04' of https://github.com/pkshih/rtw

rtw-next patches for v6.10

Some fixes and changes of capabilities detailed in following:

rtl8xxxu:

 * enable MFP support

rtlwifi:

 * some cleanups

rtw88:

 * disable unsupported interface type of mesh point for all chips, and only
   support station mode for SDIO chips.

rtw89:

 * fixes of 8852b, 8852c and 8922a

7 months agowifi: mwifiex: replace open-coded module_sdio_driver()
Krzysztof Kozlowski [Fri, 29 Mar 2024 17:10:19 +0000 (18:10 +0100)]
wifi: mwifiex: replace open-coded module_sdio_driver()

Use module_sdio_driver() instead of open-coding it.  No functional
difference.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240329171019.63836-6-krzysztof.kozlowski@linaro.org
7 months agowifi: wilc1000: replace open-coded module_sdio_driver()
Krzysztof Kozlowski [Fri, 29 Mar 2024 17:10:18 +0000 (18:10 +0100)]
wifi: wilc1000: replace open-coded module_sdio_driver()

Use module_sdio_driver() instead of open-coding it.  No functional
difference.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240329171019.63836-5-krzysztof.kozlowski@linaro.org
7 months agowifi: wl1251: simplify module initialization
Krzysztof Kozlowski [Fri, 29 Mar 2024 17:10:17 +0000 (18:10 +0100)]
wifi: wl1251: simplify module initialization

This driver's initialization functions do not perform any custom code,
except printing messages.  Printing messages on modules
loading/unloading is discouraged because it pollutes the dmesg
regardless whether user actually has this device.  Core kernel code
already gives tools to investigate whether module was loaded or not.

Drop the printing messages which allows to replace open-coded
module_sdio_driver().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240329171019.63836-4-krzysztof.kozlowski@linaro.org
7 months agowifi: rsi: sdio: simplify module initialization
Krzysztof Kozlowski [Fri, 29 Mar 2024 17:10:16 +0000 (18:10 +0100)]
wifi: rsi: sdio: simplify module initialization

This driver's initialization functions do not perform any custom code,
except printing messages.  Printing messages on modules
loading/unloading is discouraged because it pollutes the dmesg
regardless whether user actually has this device.  Core kernel code
already gives tools to investigate whether module was loaded or not.

Drop the printing messages which allows to replace open-coded
module_sdio_driver().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240329171019.63836-3-krzysztof.kozlowski@linaro.org
7 months agowifi: rtw89: 8922a: configure UL MU/OFDMA power setting
Kuan-Chung Chen [Mon, 1 Apr 2024 06:38:18 +0000 (14:38 +0800)]
wifi: rtw89: 8922a: configure UL MU/OFDMA power setting

8922A needs to set UL MU/OFDMA power and fine tune power
error tolerance for proper response to AP's trigger frame.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240401063818.12880-1-pkshih@realtek.com
7 months agowifi: rtw88: Set default CQM config if not present
Po-Hao Huang [Mon, 1 Apr 2024 03:30:19 +0000 (11:30 +0800)]
wifi: rtw88: Set default CQM config if not present

When wpa_supplicant is initiated by users and not by NetworkManager,
the CQM configuration might not be set. Without this setting, ICs
with connection quality monitor handled by firmware won't detect
connection loss. To fix this we prepare a default setting upon
associated at first, then update again if any is given later.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240401033019.9664-1-pkshih@realtek.com
7 months agoMerge branch 'mlxsw-preparations-for-improving-performance'
Jakub Kicinski [Thu, 4 Apr 2024 02:50:43 +0000 (19:50 -0700)]
Merge branch 'mlxsw-preparations-for-improving-performance'

Petr Machata says:

====================
mlxsw: Preparations for improving performance

Amit Cohen writes:

mlxsw driver will use NAPI for event processing in a next patch set.
Some additional improvements will be added later. This patch set
prepares the code for NAPI usage and refactor some relevant areas. See
more details in commit messages.

Patch Set overview:
Patches #1-#2 are preparations for patch #3
Patch #3 setups tasklets as part of queue initializtion
Patch #4 removes handling of unlikely scenario
Patch #5 removes unused counters
Patch #6 makes style change in mlxsw_pci_eq_tasklet()
Patch #7-#10 poll command interface instead of EQ0 usage
Patches #11-#12 make style change and break the function
mlxsw_pci_cq_tasklet()
Patches #13-#14 remove functions which can be replaced by a stored value
Patch #15 improves accessing to descriptor queue instance
====================

Link: https://lore.kernel.org/r/cover.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Store DQ pointer as part of CQ structure
Amit Cohen [Tue, 2 Apr 2024 13:54:28 +0000 (15:54 +0200)]
mlxsw: pci: Store DQ pointer as part of CQ structure

Currently, for each completion, we check the number of descriptor queue
and take it via mlxsw_pci_{sdq,rdq}_get(). This is inefficient, the
DQ should be the same for all the completions in CQ, as each CQ handles
only one DQ - SDQ or RDQ. This mapping is handled as part of DQ
initialization via mlxsw_cmd_mbox_sw2hw_dq_cq_set().

Instead, as part of DQ initialization, set DQ pointer in the appropriate
CQ structure. When we handle completions, warn in case that the DQ number
that we expect is different from the number we get in the CQE. Call
WARN_ON_ONCE() only after checking the value, to avoid calling this method
for each completion.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/a5b2559cd6d532c120f3194f89a1e257110318f1.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Remove mlxsw_pci_cq_count()
Amit Cohen [Tue, 2 Apr 2024 13:54:27 +0000 (15:54 +0200)]
mlxsw: pci: Remove mlxsw_pci_cq_count()

Currently, for each interrupt we call mlxsw_pci_cq_count() to determine the
number of CQs. This call makes additional two function's calls. This can
be removed by storing this value as part of structure 'mlxsw_pci', as we
already do for number of SDQs. Remove the function and
__mlxsw_pci_queue_count() which is now not used and store the value
instead.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/f08ad113e8160678f3c8d401382a696c6c7f44c7.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Remove mlxsw_pci_sdq_count()
Amit Cohen [Tue, 2 Apr 2024 13:54:26 +0000 (15:54 +0200)]
mlxsw: pci: Remove mlxsw_pci_sdq_count()

The number of SDQs is stored as part of 'mlxsw_pci' structure. In some
cases, the driver uses this value and in some cases it calls
mlxsw_pci_sdq_count() to get the value. Align the code to use the
stored value. This simplifies the code and makes it clearer that the
value is always the same. Rename 'mlxsw_pci->num_sdq_cqs' to
'mlxsw_pci->num_sdqs' as now it is used not only in CQ context.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/0c8788506d9af35d589dbf64be35a508fd63d681.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Break mlxsw_pci_cq_tasklet() into tasklets per queue type
Amit Cohen [Tue, 2 Apr 2024 13:54:25 +0000 (15:54 +0200)]
mlxsw: pci: Break mlxsw_pci_cq_tasklet() into tasklets per queue type

Completion queues are used for completions of RDQ or SDQ. Each
completion queue is used for one DQ. The first CQs are used for SDQs and
the rest are used for RDQs.

Currently, for each CQE (completion queue element), we check 'sr' value
(send/receive) to know if it is completion of RDQ or SDQ. Actually, we
do not really have to check it, as according to the queue number we know
if it handles completions of Rx or Tx.

Break the tasklet into two - one for Rx (RDQ) and one for Tx (SDQ). Then,
setup the appropriate tasklet for each queue as part of queue
initialization. Use 'sr' value for unlikely case that we get completion
with type that we do not expect. Call WARN_ON_ONCE() only after checking
the value, to avoid calling this method for each completion.

A next patch set will use NAPI to handle events, then we will have a
separate poll method for Rx and Tx. This change is a preparation for
NAPI usage.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/50fbc366f8de54cb5dc72a7c4f394333ef71f1d0.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Make style change in mlxsw_pci_cq_tasklet()
Amit Cohen [Tue, 2 Apr 2024 13:54:24 +0000 (15:54 +0200)]
mlxsw: pci: Make style change in mlxsw_pci_cq_tasklet()

This function will be broken into several functions later. As preparation,
reorder variables to reverse xmas tree.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/7170a8f4429ecb5a539b0374c621697778ff8363.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Remove unused wait queue
Amit Cohen [Tue, 2 Apr 2024 13:54:23 +0000 (15:54 +0200)]
mlxsw: pci: Remove unused wait queue

The previous patch changed the code to do not handle command interface
from event queue. With this change the wait queue is not used anymore.
Remove it and 'wait_done' variable.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/f3af6a5a9dabd97d2920cefe475c6aa57767f504.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Use only one event queue
Amit Cohen [Tue, 2 Apr 2024 13:54:22 +0000 (15:54 +0200)]
mlxsw: pci: Use only one event queue

The device supports two event queues. EQ0 is used for command interface
completion events. EQ1 is used for completion events of RDQ or SDQ.

Currently, for each EQE (event queue element), we check the queue number
and handle accordingly. More than that, for each interrupt we schedule
tasklets for both EQs. This is really ineffective, especially because of
the fact that EQ0 is used only as part of driver init/fini, when EMADs are
not available. There is no point to schedule the tasklet for it and check
each EQE.

A previous patch changed the code to poll command interface for each use of
it. It means that now there is no real reason to use EQ0, as we poll the
command interface.

Initialize only one event queue and use it as EQ1 (this is determined by
queue number). Then, for each interrupt we can schedule the tasklet only
for one queue and we do not have to check the queue number. This
simplifies the code and should improve performance. Note that polling
command interface is ok as we use it only as part of driver init/fini.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/23d764f5c032e4c363b98590b746a4b32d2bf900.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Rename MLXSW_PCI_EQS_COUNT
Amit Cohen [Tue, 2 Apr 2024 13:54:21 +0000 (15:54 +0200)]
mlxsw: pci: Rename MLXSW_PCI_EQS_COUNT

Currently we use MLXSW_PCI_EQS_COUNT event queues. A next patch will
change the driver to initialize only EQ1, as EQ0 is not required anymore
when we poll command interface.

Rename the macro to MLXSW_PCI_EQS_MAX as later we will not initialize
the maximum supported EQs, this value represents the maximum and a new
macro will be added to represent the actual used queues.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/b08df430b62f23ca1aa3aaa257896d2d95aa7691.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Poll command interface for each cmd_exec()
Amit Cohen [Tue, 2 Apr 2024 13:54:20 +0000 (15:54 +0200)]
mlxsw: pci: Poll command interface for each cmd_exec()

Command interface is used for configuring and querying FW when EMADs are
not available. During the time that the driver sets up the asynchronous
queues, it polls the command interface for getting completions. Then,
there is a short period when asynchronous queues work, but EMADs are not
available (marked in the code as nopoll = true). During this time, we
send commands via command interface, but we do not poll it, as we can get
an interrupt for the completion. Completions of command interface are
received from HW in EQ0 (event queue 0).

The usage of EQ0 instead of polling is done only 4 times during
initialization and one time during tear down, but it makes an overhead
during lifetime of the driver. For each interrupt, we have to check if
we get events in EQ0 or EQ1 and handle them. This is really ineffective,
especially because of the fact that EQ0 is used only as part of driver
init/fini.

Instead, we can poll command interface for each call of cmd_exec(). It
means that when we send a command via command interface (as EMADs are
not available), we will poll it, regardless of availability of the
asynchronous queues. This will allow us to configure later only EQ1 and
simplify the flow.

Remove 'nopoll' indication and change mlxsw_pci_cmd_exec() to poll till
answer/timeout regardless of queues' state. For now, completions are
handled also by EQ0, but it will be removed in next patch. Additional
cleanups will be added in next patches.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/e674c70380ceda953e0e45a77334c5d22e69938f.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Make style changes in mlxsw_pci_eq_tasklet()
Amit Cohen [Tue, 2 Apr 2024 13:54:19 +0000 (15:54 +0200)]
mlxsw: pci: Make style changes in mlxsw_pci_eq_tasklet()

This function will be used later only for EQ1. As preparation, reorder
variables to reverse xmas tree and return earlier when it is possible, to
simplify the code.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/2412d6c135b2a6aedb4484f5d8baab3aecd7b9ae.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Remove unused counters
Amit Cohen [Tue, 2 Apr 2024 13:54:18 +0000 (15:54 +0200)]
mlxsw: pci: Remove unused counters

The structure 'mlxsw_pci_queue' stores several counters which were consumed
via debugfs. Since commit 9a32562becd9 ("mlxsw: Remove debugfs interface"),
these counters are not used. Remove them. This makes the 'union u' and
'struct eq' redundant. Maintain 'struct cq' as it will be extended later.

Replace increasing 'q->u.eq.ev_other_count' with WARN_ON_ONCE(), as it is
used in an unreasonable case of receiving event in EQ which is not EQ0 or
EQ1. When the queues are initialized, we check number of event queues and
fail with the print "Unsupported number of queues" in case that the driver
tries to initialize more than two queues.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/ee9e658800aa0390e08342100bc27daff4c176c0.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Arm CQ doorbell regardless of number of completions
Amit Cohen [Tue, 2 Apr 2024 13:54:17 +0000 (15:54 +0200)]
mlxsw: pci: Arm CQ doorbell regardless of number of completions

Currently, as part of mlxsw_pci_cq_tasklet(), we check if any item
was handled, and only in such case we arm doorbell. This is unlikely case,
as we schedule tasklet only for CQs that we get an event for them, which
means that they contain completions to handle. Remove this check, which
is supposed to be true always, and even if it is false, it is not a mistake
to ring the doorbell. We can warn on such case, but it is not really worth
to add a check which will be run for each CQ handling when we do not expect
to reach it and it does not point to logic error that should be handled.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/f8efa481bfe7bebb9f93bb803f44ab7da77f53e6.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Do not setup tasklet from operation
Amit Cohen [Tue, 2 Apr 2024 13:54:16 +0000 (15:54 +0200)]
mlxsw: pci: Do not setup tasklet from operation

Currently, the structure 'mlxsw_pci_queue_ops' holds a pointer to the
callback function of tasklet. This is used only for EQ and CQ. mlxsw
driver will use NAPI in a following patch set, so CQ will not use tasklet
anymore. As preparation, remove this pointer from the shared operation
structure and setup the tasklet as part of queue initialization.
For now, setup tasklet for EQ and CQ. Later, CQ code will be changed.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/a326cae5fc1ad085a1a063c004983de6fe389414.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Move mlxsw_pci_cq_{init, fini}()
Amit Cohen [Tue, 2 Apr 2024 13:54:15 +0000 (15:54 +0200)]
mlxsw: pci: Move mlxsw_pci_cq_{init, fini}()

Move mlxsw_pci_cq_{init, fini}() after mlxsw_pci_cq_tasklet() as a next
patch will setup the tasklet as part of initialization.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/25196cb5baf5acf6ec1e956203790e018ba8e306.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agomlxsw: pci: Move mlxsw_pci_eq_{init, fini}()
Amit Cohen [Tue, 2 Apr 2024 13:54:14 +0000 (15:54 +0200)]
mlxsw: pci: Move mlxsw_pci_eq_{init, fini}()

Move mlxsw_pci_eq_{init, fini}() after mlxsw_pci_eq_tasklet() as a next
patch will setup the tasklet as part of initialization.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/7ae120a02e1c490084daae7e684a0d40b7cce4e7.1712062203.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agoMerge branch 'mlx5-misc-patches'
Jakub Kicinski [Thu, 4 Apr 2024 02:48:01 +0000 (19:48 -0700)]
Merge branch 'mlx5-misc-patches'

Tariq Toukan says:

====================
mlx5 misc patches

This patchset includes small features and misc code enhancements for the
mlx5 core and EN drivers.

Patches 1-4 by Gal improves the mlx5e ethtool stats implementation, for
example by using standard helpers ethtool_sprintf/puts.

Patch 5 by me adds a reset option for the FW command interface debugfs
stats entries. This allows explicit FW command interface stats reset
between different runs of a test case.

Patches 6 and 7 are simple cleanups.

Patch 8 by Gal adds driver support for 800Gbps link modes.

Patch 9 by Jianbo enhances the L4 steering abilities.

Patches 10-11 by Jianbo save redundant operations.
====================

Link: https://lore.kernel.org/r/20240402133043.56322-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5: Don't call give_pages() if request 0 page
Jianbo Liu [Tue, 2 Apr 2024 13:30:43 +0000 (16:30 +0300)]
net/mlx5: Don't call give_pages() if request 0 page

Firmware will return 0 on query BOOT/INIT PAGES for non-page supplier
functions (external host PF/VF/SF), so no page is needed to be
allocated for them.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20240402133043.56322-12-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5: Skip pages EQ creation for non-page supplier function
Jianbo Liu [Tue, 2 Apr 2024 13:30:42 +0000 (16:30 +0300)]
net/mlx5: Skip pages EQ creation for non-page supplier function

Page events are not issued by device on the function if
page_request_disable is set, so no need to create pages EQ.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20240402133043.56322-11-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5: Support matching on l4_type for ttc_table
Jianbo Liu [Tue, 2 Apr 2024 13:30:41 +0000 (16:30 +0300)]
net/mlx5: Support matching on l4_type for ttc_table

Replace matching on TCP and UDP protocols with new l4_type field which
is parsed by steering for ttc_table. It is enabled by the
outer_l4_type or inner_l4_type bits in nic_rx or port_sel flow table
capabilities and used only if pcc_ifa2 bit in HCA capabilities is set.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20240402133043.56322-10-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5e: Add support for 800Gbps link modes
Gal Pressman [Tue, 2 Apr 2024 13:30:40 +0000 (16:30 +0300)]
net/mlx5e: Add support for 800Gbps link modes

Add support for 800Gbps speed, link modes of 100Gbps per lane.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20240402133043.56322-9-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5: Convert uintX_t to uX
Gal Pressman [Tue, 2 Apr 2024 13:30:39 +0000 (16:30 +0300)]
net/mlx5: Convert uintX_t to uX

In the kernel, the preferred types are uX.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240402133043.56322-8-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5e: XDP, Fix an inconsistent comment
Carolina Jubran [Tue, 2 Apr 2024 13:30:38 +0000 (16:30 +0300)]
net/mlx5e: XDP, Fix an inconsistent comment

Starting from commit
eb9b9fdcafe2 ("net/mlx5e: Introduce extended version for mlx5e_xmit_data")
sinfo is no longer passed as an argument to
mlx5e_xmit_xdp_frame(), the comment is inconsistent.

check_result must be zero when the packet is fragmented.

Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240402133043.56322-7-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5e: debugfs, Add reset option for command interface stats
Tariq Toukan [Tue, 2 Apr 2024 13:30:37 +0000 (16:30 +0300)]
net/mlx5e: debugfs, Add reset option for command interface stats

Resetting stats just before some test/debug case allows us to eliminate
out the impact of previous commands. Useful in particular for the
average latency calculation.

The average_write() callback was unreachable, as "average" is a
read-only file. Extend, rename,  and use it for a newly exposed
write-only "reset" file.

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240402133043.56322-6-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
7 months agonet/mlx5e: Make stats group fill_stats callbacks consistent with the API
Gal Pressman [Tue, 2 Apr 2024 13:30:36 +0000 (16:30 +0300)]
net/mlx5e: Make stats group fill_stats callbacks consistent with the API

The fill_strings() callbacks were changed to accept a **data pointer,
and not rely on propagating the index value.
Make a similar change to fill_stats() callbacks to keep the API
consistent.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240402133043.56322-5-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>