platform/kernel/linux-starfive.git
2 years agowireless: add plfxlc driver for pureLiFi X, XL, XC devices
Srinivasan Raju [Thu, 24 Feb 2022 18:20:07 +0000 (18:20 +0000)]
wireless: add plfxlc driver for pureLiFi X, XL, XC devices

This is a driver for pureLiFi X, XL, XC devices which use light to transmit
data, so they are not compatible with normal Wi-Fi devices. The driver uses
separate NL80211_BAND_LC band to distinguish from Wi-Fi.  The driver is based
on 802.11 softMAC Architecture and uses native 802.11 for configuration and
management. Station and Ad-Hoc modes are supported.

The driver is compiled and tested in ARM, x86 architectures and compiled in
powerpc architecture. This driver implementation has been based on the zd1211rw
driver.

Signed-off-by: Srinivasan Raju <srini.raju@purelifi.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220224182042.132466-3-srini.raju@purelifi.com
2 years agortw89: 8852c: add chip_ops related to BTC
Ping-Ke Shih [Thu, 21 Apr 2022 12:09:03 +0000 (20:09 +0800)]
rtw89: 8852c: add chip_ops related to BTC

Add some chip_ops to support BT coexistence to work properly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-15-pkshih@realtek.com
2 years agortw89: 8852c: fill freq and band of RX status by PPDU report
Ping-Ke Shih [Thu, 21 Apr 2022 12:09:02 +0000 (20:09 +0800)]
rtw89: 8852c: fill freq and band of RX status by PPDU report

Hardware reports PPDU status containing encoded channel index to driver,
so we decode it and then fill freq and band.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-14-pkshih@realtek.com
2 years agortw89: 8852c: implement chip_ops::get_thermal
Ping-Ke Shih [Thu, 21 Apr 2022 12:09:01 +0000 (20:09 +0800)]
rtw89: 8852c: implement chip_ops::get_thermal

Read thermal value, and then we can use EWMA thermal value to do RF
calibrations if the value is changed over a threshold.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-13-pkshih@realtek.com
2 years agortw89: 8852c: implement chip_ops related to TX power
Ping-Ke Shih [Thu, 21 Apr 2022 12:09:00 +0000 (20:09 +0800)]
rtw89: 8852c: implement chip_ops related to TX power

Three chip_ops are implemented in this patch. The ::set_txpwr_ctrl and
::init_txpwr_unit are called when we up interface and then configure TX
power registers to initial values. The ::set_txpwr_ctrl is to configure
'txpwr_ref' to make basic output TX power of OFDM and CCK rate to be the
same. The ::init_txpwr_unit is to initialize TSSI (a method to do TX power
compensation depends on thermal value) control and bandedge.

The ::set_txpwr is called once switching channel. First, it sets TX power
for each rate section (e.g. CCK, OFDM), and then sets TX power offset
between 1SS and 2SS rate. Finally, it sets TX power limit to prevent
power over regulation.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-12-pkshih@realtek.com
2 years agortw89: 8852c: configure default BB TX/RX path
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:59 +0000 (20:08 +0800)]
rtw89: 8852c: configure default BB TX/RX path

8852c propose new API to configure BB TX/RX path. Without fix patch, it
can't transmit any packet.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-11-pkshih@realtek.com
2 years agortw89: add RF H2C to notify firmware
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:58 +0000 (20:08 +0800)]
rtw89: add RF H2C to notify firmware

IQK results in hardware has two copies that are used by firmware to switch
these two to support MCC.

This H2C tell firmware the corresponding channel and band of each IQK
results, and currrent one.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-10-pkshih@realtek.com
2 years agortw89: don't flush hci queues and send h2c if power is off
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:57 +0000 (20:08 +0800)]
rtw89: don't flush hci queues and send h2c if power is off

When disconnecting, it warns somethings after power is off, and we can't
do HCI IO. So, add this patch to avoid below messages:

  rtw89_8852ce 0000:03:00.0: timed out to flush pci txch: 11
  rtw89_8852ce 0000:03:00.0: failed to pre-release fwcmd

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-9-pkshih@realtek.com
2 years agortw89: pci: allow to process RPP prior to TX BD
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:56 +0000 (20:08 +0800)]
rtw89: pci: allow to process RPP prior to TX BD

RPP is to report certain skb(s) can be freed, and TX BD indicates which
TX descriptors can be freed. Normally, TX BD is happened before RPP.
In low power mode, RPP can happen ahead, so change flow to handle this
case.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-8-pkshih@realtek.com
2 years agortw89: ps: access TX/RX rings via another registers in low power mode
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:55 +0000 (20:08 +0800)]
rtw89: ps: access TX/RX rings via another registers in low power mode

In low power mode, we need to pause PCI to configure IMR and PCI ring
index registers accordingly, because the regular registers are power-off
in this mode.

In the transition moment named paused in code, we can't touch ring index,
so don't kick off DMA immediately. Instead, queue them into pending queue,
and kick off after the moment.

There are three low power modes, which are RF off/clock gate/power gate,
but PCI enter low power mode in later two modes only. So, add a mask
to achieve this.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-7-pkshih@realtek.com
2 years agortw89: ser: re-enable interrupt in threadfn if under_recovery
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:54 +0000 (20:08 +0800)]
rtw89: ser: re-enable interrupt in threadfn if under_recovery

Normally, we re-enable interrupt by napi_poll, but for this special
situation, we must turn it on immediately because napi_poll isn't
scheduled.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-6-pkshih@realtek.com
2 years agortw89: pci: add a separate interrupt handler for low power mode
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:53 +0000 (20:08 +0800)]
rtw89: pci: add a separate interrupt handler for low power mode

In lower power mode, there are very low amount of RX, and it must process
in a separated function instead of schedule_napi(), because the existing
napi_poll does many things to optimize performance, but not all registers
can access in low power mode. The simple way is to use threadfn to process
the simple thing.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-5-pkshih@realtek.com
2 years agortw89: pci: reclaim TX BD only if it really need
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:52 +0000 (20:08 +0800)]
rtw89: pci: reclaim TX BD only if it really need

To reclaim TX BD, we need to read hardware reading index to determine if
any DMA is complete. Since this IO spends time, do this thing only if we
really need it when TX BD has no free buffer corresponding to target skb.

The experimental result shows that reading counter decreases from 26,000
to 130 per second.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-4-pkshih@realtek.com
2 years agortw89: pci: add variant RPWM/CPWM to enter low power mode
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:51 +0000 (20:08 +0800)]
rtw89: pci: add variant RPWM/CPWM to enter low power mode

RPWM/CPWM are registers that can set and check low power mode. Since chips
use different address, add a field to access them in common flow.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-3-pkshih@realtek.com
2 years agortw89: pci: add variant IMR/ISR and configure functions
Ping-Ke Shih [Thu, 21 Apr 2022 12:08:50 +0000 (20:08 +0800)]
rtw89: pci: add variant IMR/ISR and configure functions

8852CE uses different but similar IMR/ISR registers, and its masks are also
different in various states, so add config_intr_mask ops to configure masks
according to under_recovery or low_power states.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-2-pkshih@realtek.com
2 years agortw88: pci: 8821c: Disable 21ce completion timeout
Po-Hao Huang [Wed, 20 Apr 2022 09:30:58 +0000 (17:30 +0800)]
rtw88: pci: 8821c: Disable 21ce completion timeout

Disable this capability to avoid timeout errors on certain platforms.
Without it, pci bus might stuck and leads to disconnection.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Tested-by: Chris Chiu <chris.chiu@canonical.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220420093058.31646-2-pkshih@realtek.com
2 years agortw88: fix uninitialized 'tim_offset' warning
Po-Hao Huang [Wed, 20 Apr 2022 09:30:57 +0000 (17:30 +0800)]
rtw88: fix uninitialized 'tim_offset' warning

This avoids below warning and makes compiler happy.
error: uninitialized symbol 'tim_offset'

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220420093058.31646-1-pkshih@realtek.com
2 years agowl12xx: scan: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 20 Apr 2022 09:02:47 +0000 (09:02 +0000)]
wl12xx: scan: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. This change is just to simplify the code, no
actual functional changes.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220420090247.2588680-1-chi.minghao@zte.com.cn
2 years agowl12xx: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 20 Apr 2022 09:02:14 +0000 (09:02 +0000)]
wl12xx: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. This change is just to simplify the code, no
actual functional changes.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220420090214.2588618-1-chi.minghao@zte.com.cn
2 years agortw89: 8852c: add help function of set channel
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:26 +0000 (14:20 +0800)]
rtw89: 8852c: add help function of set channel

During setting channel, we need to backup/restore and disable/enable some
settings. The settings include SCH (scheduler channel), PPDU status report,
and RF components, DFS and ADC.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-13-pkshih@realtek.com
2 years agortw89: 8852c: add set channel of BB part
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:25 +0000 (14:20 +0800)]
rtw89: 8852c: add set channel of BB part

BB does many settings during setting channel. First is to configure CCK
for 2G channels, and then basic channel and bandwidth settings with a
encoded channel index that will report to driver when we receive packets.
Configure spur elimination to avoid spur of CSI and NBI tones in certain
frequencies. Also, it initializes BT grant to arrange path sharing with
BT according to band. Finally, reset TSSI and BB hardware to ensure it
stays in initial state.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-12-pkshih@realtek.com
2 years agortw89: 8852c: set channel of MAC part
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:24 +0000 (14:20 +0800)]
rtw89: 8852c: set channel of MAC part

Configure channel and bandwidth of MAC registers to work properly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-11-pkshih@realtek.com
2 years agortw89: 8852c: add set channel function of RF part
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:23 +0000 (14:20 +0800)]
rtw89: 8852c: add set channel function of RF part

Prepare functions to configure channel and bandwidth accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-10-pkshih@realtek.com
2 years agortw89: 8852c: add HFC parameters
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:22 +0000 (14:20 +0800)]
rtw89: 8852c: add HFC parameters

HFC is short for HCI flow control, and these parameters is used to
configure PCI quota for TX/RX.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-9-pkshih@realtek.com
2 years agortw89: 8852c: add efuse gain offset parser
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:21 +0000 (14:20 +0800)]
rtw89: 8852c: add efuse gain offset parser

Define efuse struct to access gain offset, and store them for further use
by setting channel.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-8-pkshih@realtek.com
2 years agortw89: 8852c: support bb gain info
Zong-Zhe Yang [Thu, 14 Apr 2022 06:20:20 +0000 (14:20 +0800)]
rtw89: 8852c: support bb gain info

Add parser for bb gain table and configure bb gain table for 8852c.
While ctrl_ch, obtain bb gain error settings and write them to phy.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-7-pkshih@realtek.com
2 years agortw89: 8852c: add BB initial and reset functions
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:19 +0000 (14:20 +0800)]
rtw89: 8852c: add BB initial and reset functions

chip_ops::bb_sethw is to initialize BB settings out of BB parameters
tables. Once switching channel or initialing, we do chip_ops::bb_reset to
reset hardware counters and states to make things in expectation.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-6-pkshih@realtek.com
2 years agortw89: 8852c: phy: configure TSSI bandedge
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:18 +0000 (14:20 +0800)]
rtw89: 8852c: phy: configure TSSI bandedge

TSSI is used to manage TX power with thermal value as a factor. This patch
is to configure bandedge to TX proper waveform.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-5-pkshih@realtek.com
2 years agortw89: 8852c: add TX power track tables
Zong-Zhe Yang [Thu, 14 Apr 2022 06:20:17 +0000 (14:20 +0800)]
rtw89: 8852c: add TX power track tables

TX power track tables are used to do TX power compensation according to
thermal value. In order to work in existing and new chip, add new 6G
entries, and change type from u8 to s8.

Internal version table is HALRF_027_00_031.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-4-pkshih@realtek.com
2 years agortw89: 8852c: add TX power by rate and limit tables
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:16 +0000 (14:20 +0800)]
rtw89: 8852c: add TX power by rate and limit tables

TX power depends on rate, but must follow regulation for specific country.
Once asked to set channel, we configure registers according to these TX
power tables.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-3-pkshih@realtek.com
2 years agortw89: 8852c: add BB and RF parameters tables
Ping-Ke Shih [Thu, 14 Apr 2022 06:20:15 +0000 (14:20 +0800)]
rtw89: 8852c: add BB and RF parameters tables

These parameters are used to initialize BB and RF hardware when we are
going to bring up interface and start to transmit and receive.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220414062027.62638-2-pkshih@realtek.com
2 years agowl18xx: debugfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 13 Apr 2022 09:33:56 +0000 (09:33 +0000)]
wl18xx: debugfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413093356.2538192-1-chi.minghao@zte.com.cn
2 years agowlcore: cmd: using pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 20 Apr 2022 09:01:41 +0000 (09:01 +0000)]
wlcore: cmd: using pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. This change is just to simplify the code, no
actual functional changes.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220420090141.2588553-1-chi.minghao@zte.com.cn
2 years agowlcore: sdio: using pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Tue, 19 Apr 2022 11:04:45 +0000 (11:04 +0000)]
wlcore: sdio: using pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. This change is just to simplify the code, no
actual functional changes.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220419110445.2574424-1-chi.minghao@zte.com.cn
2 years agowlcore: vendor_cmd: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 13 Apr 2022 09:39:39 +0000 (09:39 +0000)]
wlcore: vendor_cmd: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413093939.2538825-1-chi.minghao@zte.com.cn
2 years agowlcore: testmode: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 13 Apr 2022 09:35:02 +0000 (09:35 +0000)]
wlcore: testmode: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413093502.2538316-1-chi.minghao@zte.com.cn
2 years agowlcore: sysfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Wed, 13 Apr 2022 09:34:31 +0000 (09:34 +0000)]
wlcore: sysfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413093431.2538254-1-chi.minghao@zte.com.cn
2 years agowlcore: main: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Tue, 12 Apr 2022 09:17:42 +0000 (09:17 +0000)]
wlcore: main: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220412091742.2533527-1-chi.minghao@zte.com.cn
2 years agortw89: pci: correct return value handling of rtw89_write16_mdio_mask()
Ping-Ke Shih [Wed, 13 Apr 2022 01:08:04 +0000 (09:08 +0800)]
rtw89: pci: correct return value handling of rtw89_write16_mdio_mask()

Fix wrong checking statement. Fortunately, this wrong code doesn't affect
existing chip.

Fixes: 740c431c22fe ("rtw89: pci: add register definition to rtw89_pci_info to generalize pci code")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413010804.8941-5-pkshih@realtek.com
2 years agortw89: configure security CAM for V1 chip
Ping-Ke Shih [Wed, 13 Apr 2022 01:08:03 +0000 (09:08 +0800)]
rtw89: configure security CAM for V1 chip

Add to configure security CAM while mac80211 calls set_key and del_key.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413010804.8941-4-pkshih@realtek.com
2 years agortw89: add new H2C to configure security CAM via DCTL for V1 chip
Ping-Ke Shih [Wed, 13 Apr 2022 01:08:02 +0000 (09:08 +0800)]
rtw89: add new H2C to configure security CAM via DCTL for V1 chip

DCTL is short for D-MAC control that V1 chip uses this H2C to configure
security CAM. Implement the callers in next patch.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413010804.8941-3-pkshih@realtek.com
2 years agortw89: extend H2C of CMAC control info
Ping-Ke Shih [Wed, 13 Apr 2022 01:08:01 +0000 (09:08 +0800)]
rtw89: extend H2C of CMAC control info

In order to support new chip that has capability of 160M, we need new
format to fill new information, so add a new V1 ID for newer use. Since
most fields are the same, fill fields according to the function ID of chip.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220413010804.8941-2-pkshih@realtek.com
2 years agoMerge branch 'wfx-move-out-of-staging'
Kalle Valo [Tue, 12 Apr 2022 14:31:44 +0000 (17:31 +0300)]
Merge branch 'wfx-move-out-of-staging'

This is an immutable branch shared between wireless-next and
staging-next for moving wfx driver out of staging to
drivers/net/wireless directory.

2 years agortlwifi: rtl8192cu: Fix spelling mistake "writting" -> "writing"
Lv Ruyi [Mon, 11 Apr 2022 03:24:58 +0000 (03:24 +0000)]
rtlwifi: rtl8192cu: Fix spelling mistake "writting" -> "writing"

There are some spelling mistakes in the comments. Fix it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220411032458.2517551-1-lv.ruyi@zte.com.cn
2 years agortlwifi: Fix spelling mistake "cacluated" -> "calculated"
Lv Ruyi [Fri, 8 Apr 2022 09:58:03 +0000 (09:58 +0000)]
rtlwifi: Fix spelling mistake "cacluated" -> "calculated"

There are some spelling mistakes in the comments. Fix it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408095803.2495336-1-lv.ruyi@zte.com.cn
2 years agowlcore: debugfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
Minghao Chi [Fri, 8 Apr 2022 08:12:05 +0000 (08:12 +0000)]
wlcore: debugfs: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408081205.2494512-1-chi.minghao@zte.com.cn
2 years agortw88: 8821ce: Disable PCIe ASPM L1 for 8821CE using chip ID
Jimmy Hon [Thu, 7 Apr 2022 07:51:23 +0000 (02:51 -0500)]
rtw88: 8821ce: Disable PCIe ASPM L1 for 8821CE using chip ID

Make workaround work for other 8821CE devices with different PCI ID

Signed-off-by: Jimmy Hon <honyuenkwun@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407075123.420696-3-honyuenkwun@gmail.com
2 years agortw88: 8821ce: add support for device ID 0xb821
Jimmy Hon [Thu, 7 Apr 2022 07:51:22 +0000 (02:51 -0500)]
rtw88: 8821ce: add support for device ID 0xb821

New device ID 0xb821 found on TP-Link T2E
Tested it with c821 driver. 2.4GHz and 5GHz works.

PCI id:
05:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b821
        Subsystem: Realtek Semiconductor Co., Ltd. Device b821

Signed-off-by: Jimmy Hon <honyuenkwun@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407075123.420696-2-honyuenkwun@gmail.com
2 years agortw88: 8821c: fix debugfs rssi value
Po-Hao Huang [Thu, 7 Apr 2022 09:58:58 +0000 (17:58 +0800)]
rtw88: 8821c: fix debugfs rssi value

RSSI value per frame is reported to mac80211 but not maintained in
our own statistics, add it back to help us debug.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-7-pkshih@realtek.com
2 years agortw88: do PHY calibration while starting AP
Ping-Ke Shih [Thu, 7 Apr 2022 09:58:57 +0000 (17:58 +0800)]
rtw88: do PHY calibration while starting AP

Calling calibration to yield expected PHY performance. We do this in STA
mode, so do this in AP mode as well.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-6-pkshih@realtek.com
2 years agortw88: 8821c: Enable TX report for management frames
Po-Hao Huang [Thu, 7 Apr 2022 09:58:56 +0000 (17:58 +0800)]
rtw88: 8821c: Enable TX report for management frames

Without this setting, hardware would not report to driver even if
management frames are transmitted successfully. So we fix it.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-5-pkshih@realtek.com
2 years agortw88: Add update beacon flow for AP mode
Po-Hao Huang [Thu, 7 Apr 2022 09:58:55 +0000 (17:58 +0800)]
rtw88: Add update beacon flow for AP mode

To support stations in power saving mode, AP should notify stations
that there are frames buffered at the AP via TIM during beacons.
Driver used to transmit identical beacons that were downloaded to
hardware during the initiation phase. This beacon will become
obsolete over time.

If the beacon does not contain sufficient information, station would
not be able to percept that there is data to receive. Hence it won't
wake up and start the PS-poll procedure, this could lead to timeout
and/or lost data segments. In order to resolve this issue, driver will
now download beacon to hardware whenever the content is updated.

Enable hardware to update dtim_count for more efficiency, this reduces
the overhead of downloading beacon at every beacon interval since most
of the time only the dtim_count needs to be updated.

Change queue mapping for broadcast/multicast frames to high queue, so
these frames can be prioritized and sent when dtim_count is zero.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-4-pkshih@realtek.com
2 years agortw88: fix incorrect frequency reported
Po-Hao Huang [Thu, 7 Apr 2022 09:58:54 +0000 (17:58 +0800)]
rtw88: fix incorrect frequency reported

We should only fill in frequency reported by firmware during scan.
Add this so frames won't be dropped by mac80211 due to frequency
mismatch.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-3-pkshih@realtek.com
2 years agortw88: add ieee80211:sta_rc_update ops
Po-Hao Huang [Thu, 7 Apr 2022 09:58:53 +0000 (17:58 +0800)]
rtw88: add ieee80211:sta_rc_update ops

Adding this allows us to get notification when bitrate configuration
of the station changes. Update according parameters to firmware so
the rate control algorithm can work properly.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220407095858.46807-2-pkshih@realtek.com
2 years agortw89: rtw89_ser: add const to struct state_ent and event_ent
Joe Perches [Thu, 7 Apr 2022 20:14:44 +0000 (13:14 -0700)]
rtw89: rtw89_ser: add const to struct state_ent and event_ent

Change the struct and the uses to const to reduce data.

$ size drivers/net/wireless/realtek/rtw89/ser.o* (x86-64 defconfig w/ rtw89)
   text    data     bss     dec     hex filename
   3741       8       0    3749     ea5 drivers/net/wireless/realtek/rtw89/ser.o.new
   3437     312       0    3749     ea5 drivers/net/wireless/realtek/rtw89/ser.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/2fd88e6119f62b968477ef9781abb1832d399fd6.camel@perches.com
2 years agortw89: 8852c: add 8852c specific BT-coexistence initial function
Chia-Yuan Li [Fri, 8 Apr 2022 00:13:49 +0000 (08:13 +0800)]
rtw89: 8852c: add 8852c specific BT-coexistence initial function

Initialize registers to default values, such as PTA and GNT pin, and set
pin MUX according to number of antenna on hardware module.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-10-pkshih@realtek.com
2 years agortw89: Skip useless dig gain and igi related settings for 8852C
Johnson Lin [Fri, 8 Apr 2022 00:13:48 +0000 (08:13 +0800)]
rtw89: Skip useless dig gain and igi related settings for 8852C

Separated DIG RX gain, IGI configurations from not supportted HW using
"support_igi" capability flag.

Signed-off-by: Johnson Lin <johnson.lin@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-9-pkshih@realtek.com
2 years agortw89: 8852c: disable firmware watchdog if CPU disabled
Chia-Yuan Li [Fri, 8 Apr 2022 00:13:47 +0000 (08:13 +0800)]
rtw89: 8852c: disable firmware watchdog if CPU disabled

Disable watchdog timer to prevent it timeout suddenly.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-8-pkshih@realtek.com
2 years agortw89: reset BA CAM
Ping-Ke Shih [Fri, 8 Apr 2022 00:13:46 +0000 (08:13 +0800)]
rtw89: reset BA CAM

BA CAM is used to react receiving AMPDU packets, so reset them to be
expected initial state.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-7-pkshih@realtek.com
2 years agortw89: change station scheduler setting for hardware TX mode
Ping-Ke Shih [Fri, 8 Apr 2022 00:13:45 +0000 (08:13 +0800)]
rtw89: change station scheduler setting for hardware TX mode

The bit B_AX_SS_NONEMPTY_SS2FINFO_EN should be clear, because we configure
C-MAC as hardware TX/RX mode.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-6-pkshih@realtek.com
2 years agortw89: ser: configure top ERR IMR for firmware to recover
Ping-Ke Shih [Fri, 8 Apr 2022 00:13:44 +0000 (08:13 +0800)]
rtw89: ser: configure top ERR IMR for firmware to recover

Turn on ERR IMR, and then firmware can capture interrupts reflecting
errors to recover hardware states.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-5-pkshih@realtek.com
2 years agortw89: ser: configure C-MAC interrupt mask
Chia-Yuan Li [Fri, 8 Apr 2022 00:13:43 +0000 (08:13 +0800)]
rtw89: ser: configure C-MAC interrupt mask

Similarly, create functions to set specific C-MAC masks for firmware
recovery.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-4-pkshih@realtek.com
2 years agortw89: ser: configure D-MAC interrupt mask
Chia-Yuan Li [Fri, 8 Apr 2022 00:13:42 +0000 (08:13 +0800)]
rtw89: ser: configure D-MAC interrupt mask

These interrupts are used by firmware to recover hardware. Create
functions to set specific D-MAC masks to replace plain register settings.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-3-pkshih@realtek.com
2 years agortw89: ser: fix unannotated fall-through
Zong-Zhe Yang [Fri, 8 Apr 2022 00:13:41 +0000 (08:13 +0800)]
rtw89: ser: fix unannotated fall-through

add `break` to fix warning of unannotated fall-through between switch
labels.

Fixes: 14f9f4790048 ("rtw89: ser: control hci interrupts on/off by state")
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220408001353.17188-2-pkshih@realtek.com
2 years agomac80211: prepare sta handling for MLO support
Sriram R [Mon, 4 Apr 2022 15:41:23 +0000 (21:11 +0530)]
mac80211: prepare sta handling for MLO support

Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.

With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.

To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.

For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.

For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.

Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.

Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.

  @ieee80211_sta@
  struct ieee80211_sta *s;
  struct sta_info *si;
  identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
  @@

  (
    s->
  -    var
  +    deflink.var
  |
   si->sta.
  -    var
  +    deflink.var
  )

  @sta_info@
  struct sta_info *si;
  identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
  @@

  (
    si->
  -    var
  +    deflink.var
  )

Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agomac80211: minstrel_ht: fix where rate stats are stored (fixes debugfs output)
Peter Seiderer [Mon, 4 Apr 2022 16:54:14 +0000 (18:54 +0200)]
mac80211: minstrel_ht: fix where rate stats are stored (fixes debugfs output)

Using an ath9k card the debugfs output of minstrel_ht looks like the following
(note the zero values for the first four rates sum-of success/attempts):

             best    ____________rate__________    ____statistics___    _____last____    ______sum-of________
mode guard #  rate   [name   idx airtime  max_tp]  [avg(tp) avg(prob)]  [retry|suc|att]  [#success | #attempts]
OFDM       1    DP     6.0M  272    1640     5.2       3.1      53.8       3     0 0             0   0
OFDM       1   C       9.0M  273    1104     7.7       4.6      53.8       4     0 0             0   0
OFDM       1  B       12.0M  274     836    10.0       6.0      53.8       4     0 0             0   0
OFDM       1 A    S   18.0M  275     568    14.3       8.5      53.8       5     0 0             0   0
OFDM       1      S   24.0M  276     436    18.1       0.0       0.0       5     0 1            80   1778
OFDM       1          36.0M  277     300    24.9       0.0       0.0       0     0 1             0   107
OFDM       1      S   48.0M  278     236    30.4       0.0       0.0       0     0 0             0   75
OFDM       1          54.0M  279     212    33.0       0.0       0.0       0     0 0             0   72

Total packet count::    ideal 16582      lookaround 885
Average # of aggregated frames per A-MPDU: 1.0

Debugging showed that the rate statistics for the first four rates where
stored in the MINSTREL_CCK_GROUP instead of the MINSTREL_OFDM_GROUP because
in minstrel_ht_get_stats() the supported check was not honoured as done in
various other places, e.g net/mac80211/rc80211_minstrel_ht_debugfs.c:

 74                 if (!(mi->supported[i] & BIT(j)))
 75                         continue;

With the patch applied the output looks good:

              best    ____________rate__________    ____statistics___    _____last____    ______sum-of________
mode guard #  rate   [name   idx airtime  max_tp]  [avg(tp) avg(prob)]  [retry|suc|att]  [#success | #attempts]
OFDM       1    D      6.0M  272    1640     5.2       5.2     100.0       3     0 0             1   1
OFDM       1   C       9.0M  273    1104     7.7       7.7     100.0       4     0 0            38   38
OFDM       1  B       12.0M  274     836    10.0       9.9      89.5       4     2 2           372   395
OFDM       1 A   P    18.0M  275     568    14.3      14.3      97.2       5    52 53         6956   7181
OFDM       1      S   24.0M  276     436    18.1       0.0       0.0       0     0 1             6   163
OFDM       1          36.0M  277     300    24.9       0.0       0.0       0     0 1             0   35
OFDM       1      S   48.0M  278     236    30.4       0.0       0.0       0     0 0             0   38
OFDM       1      S   54.0M  279     212    33.0       0.0       0.0       0     0 0             0   38

Total packet count::    ideal 7097      lookaround 287
Average # of aggregated frames per A-MPDU: 1.0

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Link: https://lore.kernel.org/r/20220404165414.1036-1-ps.report@gmx.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agonl80211: show SSID for P2P_GO interfaces
Johannes Berg [Fri, 18 Mar 2022 12:46:57 +0000 (13:46 +0100)]
nl80211: show SSID for P2P_GO interfaces

There's no real reason not to send the SSID to userspace
when it requests information about P2P_GO, it is, in that
respect, exactly the same as AP interfaces. Fix that.

Fixes: 44905265bc15 ("nl80211: don't expose wdev->ssid for most interfaces")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20220318134656.14354ae223f0.Ia25e85a512281b92e1645d4160766a4b1a471597@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agomac80211: introduce BSS color collision detection
Lorenzo Bianconi [Fri, 25 Mar 2022 10:42:41 +0000 (11:42 +0100)]
mac80211: introduce BSS color collision detection

Add ieee80211_rx_check_bss_color_collision routine in order to introduce
BSS color collision detection in mac80211 if it is not supported in HW/FW
(e.g. for mt7915 chipset).
Add IEEE80211_HW_DETECTS_COLOR_COLLISION flag to let the driver notify
BSS color collision detection is supported in HW/FW. Set this for ath11k
which apparently didn't need this code.

Tested-by: Peter Chiu <Chui-Hao.Chiu@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/a05eeeb1841a84560dc5aaec77894fcb69a54f27.1648204871.git.lorenzo@kernel.org
[clarify commit message a bit, move flag to mac80211]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agomac80211: Improve confusing comment around tx_info clearing
Toke Høiland-Jørgensen [Mon, 4 Apr 2022 21:01:08 +0000 (23:01 +0200)]
mac80211: Improve confusing comment around tx_info clearing

The comment above the ieee80211_tx_info_clear_status() helper was somewhat
confusing as to which fields it was or wasn't clearing. So replace it by
something that is hopefully more, well, clear.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220404210108.2684907-1-toke@toke.dk
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agomac80211: protect ieee80211_assign_beacon with next_beacon check
Lorenzo Bianconi [Thu, 7 Apr 2022 10:36:58 +0000 (12:36 +0200)]
mac80211: protect ieee80211_assign_beacon with next_beacon check

Even if it is not a real issue since ieee80211_set_after_csa_beacon()
or ieee80211_set_after_color_change_beacon() are run only when csa or bcc
is active, move next_beacon check before running ieee80211_assign_beacon
routine.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/041764ed7e9781bcee66c33b41f1365aa4205932.1649327683.git.lorenzo@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2 years agoipw2x00: use DEVICE_ATTR_*() macro
Meng Tang [Wed, 6 Apr 2022 01:54:44 +0000 (09:54 +0800)]
ipw2x00: use DEVICE_ATTR_*() macro

Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.

Signed-off-by: Meng Tang <tangmeng@uniontech.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220406015444.14408-1-tangmeng@uniontech.com
2 years agoorinoco: Prepare cleanup of powerpc's asm/prom.h
Christophe Leroy [Sat, 2 Apr 2022 10:10:37 +0000 (12:10 +0200)]
orinoco: Prepare cleanup of powerpc's asm/prom.h

powerpc's asm/prom.h brings some headers that it doesn't
need itself.

In order to clean it up, first add missing headers in
users of asm/prom.h

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/4e3bfd4ffe2ed6b713ddd99b69dcc3d96adffe34.1648833427.git.christophe.leroy@csgroup.eu
2 years agoipw2x00: Fix potential NULL dereference in libipw_xmit()
Haowen Bai [Fri, 1 Apr 2022 07:10:54 +0000 (15:10 +0800)]
ipw2x00: Fix potential NULL dereference in libipw_xmit()

crypt and crypt->ops could be null, so we need to checking null
before dereference

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/1648797055-25730-1-git-send-email-baihaowen@meizu.com
2 years agob43: Fix assigning negative value to unsigned variable
Haowen Bai [Fri, 25 Mar 2022 10:15:15 +0000 (18:15 +0800)]
b43: Fix assigning negative value to unsigned variable

fix warning reported by smatch:
drivers/net/wireless/broadcom/b43/phy_n.c:585 b43_nphy_adjust_lna_gain_table()
warn: assigning (-2) to unsigned variable '*(lna_gain[0])'

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/1648203315-28093-1-git-send-email-baihaowen@meizu.com
2 years agob43legacy: Fix assigning negative value to unsigned variable
Haowen Bai [Fri, 25 Mar 2022 10:17:13 +0000 (18:17 +0800)]
b43legacy: Fix assigning negative value to unsigned variable

fix warning reported by smatch:
drivers/net/wireless/broadcom/b43legacy/phy.c:1181 b43legacy_phy_lo_b_measure()
warn: assigning (-772) to unsigned variable 'fval'

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/1648203433-8736-1-git-send-email-baihaowen@meizu.com
2 years agortl8xxxu: fill up txrate info for gen1 chips
Chris Chiu [Fri, 25 Mar 2022 03:57:35 +0000 (11:57 +0800)]
rtl8xxxu: fill up txrate info for gen1 chips

RTL8188CUS/RTL8192CU(gen1) don't support rate adaptive report hence
no real txrate info can be retrieved. The vendor driver reports the
highest rate in HT capabilities from the IEs to avoid empty txrate.
This commit initiates the txrate information with the highest supported
rate negotiated with AP. The gen2 chip keeps update the txrate from
the rate adaptive reports, and gen1 chips at least have non-NULL txrate
after associated.

Signed-off-by: Chris Chiu <chris.chiu@canonical.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325035735.4745-3-chris.chiu@canonical.com
2 years agortl8xxxu: feed antenna information for cfg80211
Chris Chiu [Fri, 25 Mar 2022 03:57:34 +0000 (11:57 +0800)]
rtl8xxxu: feed antenna information for cfg80211

Fill up the available TX/RX antenna so the iw commands can show
correct antenna information for different chips.

Signed-off-by: Chris Chiu <chris.chiu@canonical.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325035735.4745-2-chris.chiu@canonical.com
2 years agortlwifi: replace usage of found with dedicated list iterator variable
Jakob Koschel [Thu, 24 Mar 2022 07:21:24 +0000 (08:21 +0100)]
rtlwifi: replace usage of found with dedicated list iterator variable

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].

This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220324072124.62458-1-jakobkoschel@gmail.com
2 years agobrcmfmac: Avoid keeping power to SDIO card unless WOWL is used
Ulf Hansson [Wed, 23 Mar 2022 08:39:50 +0000 (09:39 +0100)]
brcmfmac: Avoid keeping power to SDIO card unless WOWL is used

Keeping the power to the SDIO card during system wide suspend, consumes
energy. Especially on battery driven embedded systems, this can be a
problem. Therefore, let's change the behaviour into allowing the SDIO card
to be powered off, unless WOWL is supported and enabled.

Note that, the downside from this change, is that during system resume the
SDIO card needs to be re-initialized and the FW must be re-programmed. Even
if this may take some time to complete, it should we worth it, rather than
draining the battery.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Christophe Roullier <christophe.roullier@foss.st.com>
Reviewed-by: Yann Gautier <yann.gautier@foss.st.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220323083950.414783-1-ulf.hansson@linaro.org
2 years agomwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue
Niels Dossche [Mon, 21 Mar 2022 22:55:16 +0000 (23:55 +0100)]
mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue

cfg80211_ch_switch_notify uses ASSERT_WDEV_LOCK to assert that
net_device->ieee80211_ptr->mtx (which is the same as priv->wdev.mtx)
is held during the function's execution.
mwifiex_dfs_chan_sw_work_queue is one of its callers, which does not
hold that lock, therefore violating the assertion.
Add a lock around the call.

Disclaimer:
I am currently working on a static analyser to detect missing locks.
This was a reported case. I manually verified the report by looking
at the code, so that I do not send wrong information or patches.
After concluding that this seems to be a true positive, I created
this patch.
However, as I do not in fact have this particular hardware,
I was unable to test it.

Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220321225515.32113-1-dossche.niels@gmail.com
2 years agortw89: fix misconfiguration on hw_scan channel time
Po Hao Huang [Fri, 1 Apr 2022 05:50:43 +0000 (13:50 +0800)]
rtw89: fix misconfiguration on hw_scan channel time

Without this patch, hw scan won't stay long enough on DFS/passive
channels. Found previous logic error and fix it.

Signed-off-by: Po Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220401055043.12512-5-pkshih@realtek.com
2 years agortw89: coex: Add case for scan offload
Ching-Te Ku [Fri, 1 Apr 2022 05:50:42 +0000 (13:50 +0800)]
rtw89: coex: Add case for scan offload

Turn off coexistence driver control, let firmware can control the
traffic during scan. This prevents potential unexpected behavior of
the BT driver.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220401055043.12512-4-pkshih@realtek.com
2 years agortw89: packet offload handler to avoid warning
Po Hao Huang [Fri, 1 Apr 2022 05:50:41 +0000 (13:50 +0800)]
rtw89: packet offload handler to avoid warning

Add a dummy function for packet offload to eliminate warning message
"c2h class 1 func 2 not support". This c2h is for debug purpose and
its presence itself can do the work, so further parsing won't be
required for now.

Signed-off-by: Po Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220401055043.12512-3-pkshih@realtek.com
2 years agortw89: change idle mode condition during hw_scan
Po Hao Huang [Fri, 1 Apr 2022 05:50:40 +0000 (13:50 +0800)]
rtw89: change idle mode condition during hw_scan

Previously we only consider single interface's status, idle mode
behavior could be unexpected when multiple interfaces is active.
Change to enter/leave idle mode by mac80211's configuration state.

Signed-off-by: Po Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220401055043.12512-2-pkshih@realtek.com
2 years agortw89: update ptcl_init
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:55 +0000 (14:00 +0800)]
rtw89: update ptcl_init

ptcl_init, standing for protocol initialization, is updated to the latest
version.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-17-pkshih@realtek.com
2 years agortw89: update TMAC parameters
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:54 +0000 (14:00 +0800)]
rtw89: update TMAC parameters

TMAC is short for TX MAC, and this patch is to configure FIFO thresholds.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-16-pkshih@realtek.com
2 years agortw89: initialize NAV control
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:53 +0000 (14:00 +0800)]
rtw89: initialize NAV control

Configure NAV function and its parameters.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-15-pkshih@realtek.com
2 years agortw89: update scheduler setting
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:52 +0000 (14:00 +0800)]
rtw89: update scheduler setting

Update IC specific settings accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-14-pkshih@realtek.com
2 years agortw89: 8852c: update security engine setting
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:51 +0000 (14:00 +0800)]
rtw89: 8852c: update security engine setting

The security setting of 8852A and 8852C are different, so change the
settings accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-13-pkshih@realtek.com
2 years agortw89: Turn on CR protection of CMAC
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:50 +0000 (14:00 +0800)]
rtw89: Turn on CR protection of CMAC

CMAC is Control MAC, and this patch is to turn on CR (control registers)
protection.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-12-pkshih@realtek.com
2 years agortw89: add chip_ops::{enable,disable}_bb_rf to support v1 chip
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:49 +0000 (14:00 +0800)]
rtw89: add chip_ops::{enable,disable}_bb_rf to support v1 chip

The v1 chip use specific functions to enable and disable BB/RF.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-11-pkshih@realtek.com
2 years agortw89: update STA scheduler parameters for v1 chip
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:48 +0000 (14:00 +0800)]
rtw89: update STA scheduler parameters for v1 chip

The v1 chip has additional setting of STA scheduler, so add it.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-10-pkshih@realtek.com
2 years agortw89: extend dmac_pre_init to support 8852C
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:47 +0000 (14:00 +0800)]
rtw89: extend dmac_pre_init to support 8852C

DMAC is short for data MAC. 8852C has more settings than 8852A, so add
them.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-9-pkshih@realtek.com
2 years agortw89: pci: add L1 settings
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:46 +0000 (14:00 +0800)]
rtw89: pci: add L1 settings

Configure L1 settings of enter and exit.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-8-pkshih@realtek.com
2 years agortw89: pci: add deglitch setting
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:45 +0000 (14:00 +0800)]
rtw89: pci: add deglitch setting

Add setting to support 8852ce.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-7-pkshih@realtek.com
2 years agortw89: pci: set address info registers depends on chips
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:44 +0000 (14:00 +0800)]
rtw89: pci: set address info registers depends on chips

Address info registers are used to configure size of DMA address info to
point skb->data. With different size, it can support different number of
scatters.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-6-pkshih@realtek.com
2 years agortw89: pci: add LTR setting for v1 chip
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:43 +0000 (14:00 +0800)]
rtw89: pci: add LTR setting for v1 chip

Add LTR handle to PCI deinit as well.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-5-pkshih@realtek.com
2 years agortw89: pci: refine pci pre_init function
Chia-Yuan Li [Fri, 25 Mar 2022 06:00:42 +0000 (14:00 +0800)]
rtw89: pci: refine pci pre_init function

The pre_init is used to initialize partial PCI function during PCI probe.
It doesn't need to initialize all functions, so probe can be faster.

Signed-off-by: Chia-Yuan Li <leo.li@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-4-pkshih@realtek.com
2 years agortw89: pci: add pci attributes to configure operating mode
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:41 +0000 (14:00 +0800)]
rtw89: pci: add pci attributes to configure operating mode

Refine operating mode function to support variant chips.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-3-pkshih@realtek.com
2 years agortw89: pci: add register definition to rtw89_pci_info to generalize pci code
Ping-Ke Shih [Fri, 25 Mar 2022 06:00:40 +0000 (14:00 +0800)]
rtw89: pci: add register definition to rtw89_pci_info to generalize pci code

The PCI code of 8852AE and 8852CE are different, but the flow and register
names are similar. To reuse the code, add a struct to define register or
value accordingly. We also use chip id to control the slightly different
flow.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-2-pkshih@realtek.com