summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/realtek/rtw88/main.h
AgeCommit message (Collapse)AuthorFilesLines
2020-08-02rtw88: update tx descriptor of mgmt and reserved page packetsTzu-En Huang1-0/+2
Previous settings for TX descriptors of and reserved page packets are insufficient. For the sequence number of packets downloaded to reserved page, it should be filled by hardware. And for ps-poll packets in reserved page, to prevent AID being changed by hardware, NAVUSEHDR should be set. Additionally, the rate should be adjusted based on the current band for mgmt and reserved page packets. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200717064937.27966-4-yhchuang@realtek.com
2020-07-15rtw88: coex: Fix ACL Tx pause during BT inquiry/page.Zong-Zhe Yang1-0/+3
Add a set of logic with corresponding coexistence parameters to handle the situation under BT inquiry/page. We will set PSTDMA while WL-Busy + BT inquiry/page to separate WL/BT slots. PSTDMA can protect WL data rate and BT performance. If WL-Busy + BT inquiry/page and there was BT device paired, We will set the mechanism to 4Slot PSTDMA. In 4Slot PSTDMA, the paired devices can perform more smoothly and prevent some issues trigger from insufficient data. And to avoid A2DP glitch or disconnection, we will adjust ACL data priority higher than inquiry/page. In addition, we found sometimes BT inquiry/page still working last for seconds after BT had notified inquiry/page finished. It will lead to A2DP glitch cause of ACL data, inquiry/page priority toggled. To fix the corner, we add a timer to remain the inquiry/page status. And we found WL busy/idle threshold is too sensitive, it will keep switching in some weak network environment and coexistence mechanism will switch between TDMA and PSTDMA. The very frequently switching may destroyed not only the handshake with AP, but BT performance. And it will trigger some unexpected error. To prevent the frequently switching, we add a timer to delay the status change while WL busy switch to idle. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200715023324.8600-1-yhchuang@realtek.com
2020-07-15rtw88: 8821c: add power trackingTzu-En Huang1-0/+1
The TX power requires to be adjusted based on the thermal value. The actual power will decrease if the thermal value raised, and will increase if the thermal value lowered. Driver comapres the thermal value, as moving averages. If it changes over a limit, driver will modify the TX power index to compensate. Implement rtw_chip_ops::pwr_track() for 8821c. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200603094218.19942-3-yhchuang@realtek.com
2020-07-15rtw88: 8821c: add cck pd settingsTzu-En Huang1-0/+1
CCK PD can reduce the number of false alarm of the CCK rates. It dynamically adjusts the power threshold and CS ratio. The values are compared to the values of the previous level, if the level is changed, set new values of power threshold and CS ratio. Implement rtw_chip_ops::cck_pd_set() for 8821c. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200603094218.19942-2-yhchuang@realtek.com
2020-07-15rtw88: 8821c: add set channel supportTzu-En Huang1-0/+5
8821c is capable of 2.4G and 5G. Implement rtw_chip_ops::set_channel() to set 2G and 5G channels. This includes MAC, BB and RF related settings. Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200616091625.26489-5-yhchuang@realtek.com
2020-07-15rtw88: 8821c: add basic functionsTzu-En Huang1-0/+1
RTL8821CE chipsets are 802.11ac dual-band WiFi + BT combo chips. This patch adds the basic functions such as parameter tables, chip information, power on flow. Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200616091625.26489-2-yhchuang@realtek.com
2020-05-29rtw88: fix EAPOL 4-way failure by finish IQK earlierPing-Ke Shih1-0/+3
Connecting to an AP with WPA2 security may fail. The IQK and the EAPOL 4-way handshake may overlap because the driver does IQK right after assoc success. For 802.11n devices, the IQK is done in the driver and it could require more than 100ms to complete. During IQK, any TX/RX events are paused. So if the EAPOL 4-way handshake started before IQK finished, then the 1/4 and 2/4 part of the handshake could be dropped. The AP will then issue deauth with reason IEEE8021X_FAILED (23). To resolve this, move IQK routine into managed TX prepare (ieee80211_ops::mgd_prepare_tx()). The callback is called before the managed frames (auth/assoc) are sent. This will make sure that the IQK is completed before the handshake starts. But don't do IQK during scanning because doing it on each channel will take too long. For 802.11ac devices, the IQK is done in firmware and it takes less time to complete. Therefore we don't see a failure during the EAPOL 4-way handshake. But it is still worth moving the IQK into ieee80211_ops::mgd_prepare_tx(). Fixes: f5df1a8b4376 ("rtw88: 8723d: Add 8723DE to Kconfig and Makefile") Tested-by: You-Sheng Yang <vicamo.yang@canonical.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200529025009.2468-4-yhchuang@realtek.com
2020-05-29rtw88: coex: 8723d: set antanna control ownerPing-Ke Shih1-0/+1
Without setting antenna control owner, the WiFi could be disconnected if the BT has traffic. Because the antenna is switched to BT side for its traffic, and the WiFi will have no chance to transfer data. Set control owner to prevent WiFi disconnect issue. Fixes: f5df1a8b4376 ("rtw88: 8723d: Add 8723DE to Kconfig and Makefile") Tested-by: You-Sheng Yang <vicamo.yang@canonical.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200529025009.2468-2-yhchuang@realtek.com
2020-05-18rtw88: extract: make 8723d an individual kernel moduleZong-Zhe Yang1-1/+0
Make objects about 8723d functions and 8723d tables, i.e. rtw8723d.o and rtw8723d_table.o, an individual kernel module called rtw88_8723d.ko. For 8723d pcie chip, i.e. 8723DE chip, add a chip entry point module called rtw88_8723de.ko which will depend on rtw88_8723d.ko and rtwpci.ko. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200515052327.31874-6-yhchuang@realtek.com
2020-05-18rtw88: extract: make 8822b an individual kernel moduleZong-Zhe Yang1-1/+0
Make objects about 8822b functions and 8822b tables, i.e. rtw8822b.o and rtw8822b_table.o, an individual kernel module called rtw88_8822b.ko. For 8822b pcie chip, i.e. 8822BE chip, add a chip entry point module called rtw88_8822be.ko which will depend on rtw88_8822b.ko and rtwpci.ko. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200515052327.31874-5-yhchuang@realtek.com
2020-05-18rtw88: extract: make 8822c an individual kernel moduleZong-Zhe Yang1-1/+0
Make objects about 8822c functions and 8822c tables, i.e. rtw8822c.o and rtw8822c_table.o, an individual kernel module called rtw88_8822c.ko. For 8822c pcie chip, i.e. 8822CE chip, add a chip entry point module called rtw88_8822ce.ko which will depend on rtw88_8822c.ko and rtwpci.ko. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200515052327.31874-4-yhchuang@realtek.com
2020-05-13rtw88: 8723d: set ltecoex register address in chip_infoPing-Ke Shih1-0/+7
Since 8723D use different address of ltecoex register, this commit add a new field in chip_info and fill proper address. Then, ltecoex_read_reg() and ltecoex_reg_write() can use them to access ltecoex according to chip. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-7-yhchuang@realtek.com
2020-05-13rtw88: 8723d: implement flush queuePing-Ke Shih1-0/+11
Flush queue is used to check if queue is empty, before doing something else. Since 8723D uses different registers and page number of availabl/reserved occupy 8 bits instead of 16 bits, so use a 'wsize' field to discriminate which rtw_read{8,16} is adopted. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-6-yhchuang@realtek.com
2020-05-13rtw88: 8723d: Add shutdown callback to disable BT USB suspendPing-Ke Shih1-0/+1
Without this patch, wifi card can't initialize properly due to BT in USB suspend state. So, we disable BT USB suspend (wakeup) in shutdown callback that is the moment before rebooting. To save BT USB power, we can't do this in 'remove' callback. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-5-yhchuang@realtek.com
2020-05-13rtw88: 8723d: Add power trackingPing-Ke Shih1-0/+4
When chip's temperature is changed, RF characters are changed. To keep the characters to be consistent, 8723d uses thermal meter to assist in calibrating LCK, IQK, crystal and TX power. A base thermal value is programmed in efuse, all calibration data in MP process is based on this thermal value. So we calucate the delta of thermal value between the base value, and use this delta to reference XTAL and TX power offset tables to know how much we need to adjust. For IQK and LCK, driver checks if delta of thermal value is over 8, then they are triggered. For crystal adjustment, when delta of thermal value is changed, we check XTAL tables to get offset of XTAL value. If thermal value is larger than base value, positive table (_p as suffix) is used. Otherwise, we use negative table (_n as suffix). Then, we add offset to XTAL default value programmed in efuse, and write sum value to register. To compensate TX power, there are two hierarchical tables. First level use delta of thermal value to access eight tables to yield delta of TX power index. Then, plus base TX power index to get index of BB swing table (second level tables) where register value is induced. BB swing table can't deal with all cases, if index of BB swing table is over the size of the table. In this case, TX AGC is used to compensate the remnant part. Assume 'upper' is the upper bound of BB swing table, and 'target' is the desired index. Then, we can illustrate them as compensation method BB swing TX AGC ------------------- -------- -------------- target > upper upper target - upper target < 0 0 target otherwise target 0 For debug purpose, add a column 'rem' to tx_pwr_tbl entry, and it looks like path rate pwr base (byr lmt ) rem A CCK_1M 32(0x20) 34 -2 ( 0 -2) 0 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-4-yhchuang@realtek.com
2020-05-13rtw88: 8723d: add IQ calibrationPing-Ke Shih1-0/+12
IQ calibration is used to calibrate RF characteristic to yield expected performance. Basically, we do calibration twice and compare the similarity to determine calibration is good or not, if not we do the third calibration, and then compare with the results of first and second calibration. If it still not similar, IQK is failed. Before doing calibration, we need to backup registers that will be modified in calibration procedure, and restore these registers after calibration is done. A calibration procedure can divided into four sub-procedures that are S1-TX, S1-RX, S0-TX and S0-RX. Where, S1 and S0 represent to path A and B respectively. Each sub-procedure configure proper registers, and then rigger one-shot calibration and poll until completion. For RX calibration, it needs to do twice one-shot calibration, first one is to yield parameter used by second one. The result of TX part is stored for TX power tracking that adjusts TX AGC to output expected power. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-3-yhchuang@realtek.com
2020-05-13rtw88: 8723d: Add LC calibrationPing-Ke Shih1-0/+1
LC calibration is done by hardware circuit. Driver sets the LCK bit to kick start, and then poll the bit to check if it's done. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200512102621.5148-2-yhchuang@realtek.com
2020-05-06rtw88: 8723d: Set IG register for CCK ratePing-Ke Shih1-0/+1
DIG sets only one IG register for most chips, but 8723D need to set additional register for CCK rate. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200504105010.10780-8-yhchuang@realtek.com
2020-05-06rtw88: 8723d: some chips don't support LDPCPing-Ke Shih1-0/+6
Some chips are not able to receive LDPC packets. Add an attribute to rtw_chip_info to determine if the LDPC capability in [ht/vht]_cap should be advertised or not. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200504105010.10780-6-yhchuang@realtek.com
2020-05-04rtw88: 8822c: update phy parameter tables to v50Yan-Hsuan Chuang1-0/+1
Update RTL8822C devices' phy tables to v50. The new parameters introduces new RFE type 5 for some new modules. Also added a new regulatory CN for power limit. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200424073812.26896-1-yhchuang@realtek.com
2020-04-23rtw88: 8723d: initialize mac/bb/rf basic functionsPing-Ke Shih1-0/+1
Implement rtw_chip_ops::phy_set_param and ::mac_init to initialize mac/bb/rf, and they are used during interface up. The procedure contains power on sequence registers, download firmware, load predefined parameters, mac/bb/rf specific register and etc. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200422034607.28747-9-yhchuang@realtek.com
2020-04-23rtw88: add legacy firmware download for 8723D devicesPing-Ke Shih1-0/+16
The WLAN CPU of 8723D device is different from others, add legacy firmware download function for it. A new variable wlan_cpu is used to decide which firmware download function we should use. Legacy firmware file contains 32 bytes header including version and subversion. When downloading to wlan cpu, header is excluded. Firmware is downloaded via beacon queue to reserved page that is a part of TX buffer. Since 11N WLAN CPU uses different control registers, this patch introduces related control registers. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200422034607.28747-2-yhchuang@realtek.com
2020-04-21rtw88: 8723d: Add new chip op efuse_grant() to control efuse accessPing-Ke Shih1-0/+13
8723D devices need to grant efuse access before dumping physical efuse map, other chips don't need it, so keep this ops as blank. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200420055054.14592-8-yhchuang@realtek.com
2020-04-21rtw88: 8723d: Add RF read/write opsPing-Ke Shih1-0/+10
8723D use SIPI to indirectly read RF register instead of directly read, so introduce a new struct rtw_rf_sipi_addr and new function rtw_phy_read_rf_sipi(). Since other chips don't use the new function, only 8723D needs to fill struct rtw_rf_sipi_addr in rtw_chip_info. Because there are two kinds of functions for reading RF registers now, change rtw_phy_read_rf() to chip->ops->read_rf() in rtw_phy_write_rf_reg_sipi() so that we can switch tp proper RF read functions depends on the type of the chip. Though 8723D is an 1x1 chip, it has two RF PHY and we can switch to one of them, and that should be configured properly. Hence, add a fix_rf_phy_num to struct rtw_chip_info to allow driver to set one of the PHY's registers for 8723D, even it is only 1x1. Another variable rf_phy_num is introduced to keep the constraint number of RF path we can access, and its value is: rf_phy_num = (fix_rf_phy_num ? fix_rf_phy_num : rf_path_num) Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200420055054.14592-5-yhchuang@realtek.com
2020-04-21rtw88: 8723d: Add power sequencePing-Ke Shih1-0/+1
Add corresponding power sequence for 8723D devices Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200420055054.14592-4-yhchuang@realtek.com
2020-04-21rtw88: 8723d: Add basic chip capabilitiesPing-Ke Shih1-0/+2
RTL8723DE is an 11n 1x1 2.4G single band chip with the following capabilities: - TX/RX BD size: 16/8 - TX/RX desc size: 40/24 - physical/logical/protected efuse size: 512/512/96 - TX gain index factor: 1 - max TX power index: 0x3F - band: 2G - HT: support - VHT: Not support Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200420055054.14592-2-yhchuang@realtek.com
2020-04-15rtw88: make rtw_chip_ops::set_antenna return intYan-Hsuan Chuang1-4/+5
To support ieee80211_ops::set_antenna, the driver can decide if the antenna mask is accepted, otherwise it can return an error code. Because each chip could have different limitations, let the chip check the mask and return. Also the antenna mask for TRX from upper space is 32-bit long. Change the antenna mask for rtw_chip_ops::set_antenna from u8 to u32. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200410100950.3199-2-yhchuang@realtek.com
2020-03-26rtw88: fix non-increase management packet sequence numberTzu-En Huang1-0/+3
In previous setting, management packets' sequence numbers will not increase and always stay at 0. Add hw sequence number support for mgmt packets. The table below shows different sequence number setting in the tx descriptor. seq num ctrl | EN_HWSEQ | DISQSELSEL | HW_SSN_SEL ------------------------------------------------------ sw ctrl | 0 | N/A | N/A hw ctrl per MACID | 1 | 0 | N/A hw ctrl per HWREG | 1 | 1 |HWREG(0/1/2/3) Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Brian Norris <briannorris@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200326020408.25218-1-yhchuang@realtek.com
2020-03-26rtw88: add a debugfs entry to dump coex's infoYan-Hsuan Chuang1-0/+18
Add a new entry "coex_info" in debugfs to dump coex's states for us to debug on coex's issues. The basic concept for co-existence (coex, usually for WiFi + BT) is to decide a strategy based on the current status of WiFi and BT. So, it means the WiFi driver requires to gather information from BT side and choose a strategy (TDMA/table/HW settings). Althrough we can easily check the current status of WiFi, e.g., from kernel log or just dump the hardware registers, it is still very difficult for us to gather so many different types of WiFi states (such as RFE config, antenna, channel/band, TRX, Power save). Also we will need BT's information that is stored in "struct rtw_coex". So it is necessary for us to have a debugfs that can dump all of the WiFi/BT information required. Note that to debug on coex related issues, we usually need a longer period of time of coex_info dump every 2 seconds (for example, 30 secs, so we should have 15 times of coex_info's dump). Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Chris Chiu <chiu@endlessm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200313033008.20070-2-yhchuang@realtek.com
2020-03-23rtw88: associate reserved pages with each vifYan-Hsuan Chuang1-0/+1
Each device has only one reserved page shared with all of the vifs, so it seems not reasonable to pass vif as one of the arguments to rtw_fw_download_rsvd_page(). If driver is going to run more than one vif, the content of reserved page could not be built for all of the vifs. To fix it, let each vif maintain its own reserved page list, and build the final reserved page to download to the firmware from all of the vifs. Hence driver should add reserved pages to each vif according to the vif->type when adding the vif. For station mode, add reserved page with rtw_add_rsvd_page_sta(). If the station mode is going to suspend in PNO (net-detect) mode, remove the reserved pages used for normal mode, and add new one for wowlan mode with rtw_add_rsvd_page_pno(). For beacon mode, only beacon is required to be added using rtw_add_rsvd_page_bcn(). This would make the code flow simpler as we don't need to add reserved pages when vif is running, just add/remove them when ieee80211_ops::[add|remove]_interface. When driver is going to download the reserved page, it will collect pages from all of the vifs, this list is maintained by rtwdev, with build_list as the pages' member. That way, we can still build a list of reserved pages to be downloaded. Also we can get the location of the pages from the list that is maintained by rtwdev. The biggest problem is that the first page should always be beacon, if other type of reserved page is put in the first page, the tx descriptor and offset could be wrong. But station mode vif does not add beacon into its list, so we need to add a dummy page in front of the list, to make sure other pages will not be put in the first page. As the dummy page is allocated when building the list, we must free it before building a new list of reserved pages to firmware. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200312080852.16684-4-yhchuang@realtek.com
2020-03-23wireless: realtek: Replace zero-length array with flexible-array memberGustavo A. R. Silva1-1/+1
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200225002746.GA26789@embeddedor
2020-03-12rtw88: remove unused member of struct rtw_halKevin Lo1-1/+0
Remove unused fab_version member from struct rtw_hal. Some of the checks being made were nonsense. Signed-off-by: Kevin Lo <kevlo@kevlo.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-02-12rtw88: 8822[bc]: Make tables const, reduce data object sizeJoe Perches1-11/+11
Reduce the data size 2kb or 3kb by making tables const. Add const to pointer declarations to make compilation work too. (x86-64 defconfig) $ size drivers/net/wireless/realtek/rtw88/rtw8822?.o* text data bss dec hex filename 25054 672 8 25734 6486 drivers/net/wireless/realtek/rtw88/rtw8822b.o.new 23870 1872 8 25750 6496 drivers/net/wireless/realtek/rtw88/rtw8822b.o.old 53646 828 0 54474 d4ca drivers/net/wireless/realtek/rtw88/rtw8822c.o.new 52846 1652 0 54498 d4e2 drivers/net/wireless/realtek/rtw88/rtw8822c.o.old (x86-64 allyesconfig) $ size drivers/net/wireless/realtek/rtw88/rtw8822?.o* text data bss dec hex filename 45811 6280 128 52219 cbfb drivers/net/wireless/realtek/rtw88/rtw8822b.o.new 44211 7880 128 52219 cbfb drivers/net/wireless/realtek/rtw88/rtw8822b.o.old 100195 8128 0 108323 1a723 drivers/net/wireless/realtek/rtw88/rtw8822c.o.new 98947 9376 0 108323 1a723 drivers/net/wireless/realtek/rtw88/rtw8822c.o.old Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-02-12rtw88: Use secondary channel offset enumerationPing-Ke Shih1-0/+10
The hardware value of secondary channel offset isn't very intuitive. This commit adds enumeration, so we can easier to check the logic with the suffix of enumeration name, likes _UPPER or _LOWER. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Chris Chiu <chiu@endlessm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: remove unused vif pointer in struct rtw_vifYan-Hsuan Chuang1-1/+0
As driver can easily get vif with container_of(), we can just remove it. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: remove unused variable 'in_lps'Yan-Hsuan Chuang1-1/+0
Unused, will not be used neither, because the hardware/firmware can only support one vif for LPS currnetly. If there's more than one vif, than driver will never enter LPS. So remove it. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: remove unused spinlockTzu-En Huang1-3/+0
dm_lock is never used. Thus, remove this redundant spinlock. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: Add wowlan net-detect supportChin-Yen Lee1-0/+25
Net-detect is an option of wowlan to allow the device to be woken up from suspend mode when configured network is detected. When user enables net-detect and lets the device enter suspend state, wowlan firmware will periodically scan until beacon or probe response of configured networks are received. Between two scans, wowlan firmware keeps wifi chip in idle mode to reduce power consumption. If configured networks are detected, wowlan firmware will trigger resume process. Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: Add wowlan pattern match supportChin-Yen Lee1-0/+14
Pattern match is an option of wowlan to allow the device to be woken up from suspend mode when receiving packets matched user-designed patterns. The patterns are written into hardware cam in suspend flow if users have set up them. If packets matched designed pattern are received, wowlan firmware will get an interrupt and then wake up the device. Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: support wowlan feature for 8822cChin-Yen Lee1-0/+18
Wake on WLAN(wowlan) is a feature which allows devices to be woken up from suspend state through wlan events. When user enables wowlan feature and then let the device enter suspend state, wowlan firmware will be loaded by the driver and periodically monitors wifi packets. Power consumption of wifi chip will be reduced in this state. If wowlan firmware detects that specific wlan event happens, it will issue wakeup signal to trigger resume process. Driver will load normal firmware and let wifi chip return to the original state. Currently supported wlan events include receiving magic packet, rekey packet and deauth packet, and disconnecting from AP. Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-01-26rtw88: load wowlan firmware if wowlan is supportedChin-Yen Lee1-0/+10
Driver used to download normal firmware only, but some devices support wowlan and require to download wowlan firmware when system suspends. So modify rtw_load_firmware() and its callback to allow driver to download both normal and wowlan firmware. Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-24rtw88: add phy_info debugfs to show Tx/Rx physical statusTsang-Shian Lin1-0/+58
This commit adds several Tx/Rx physical information to phy_info debugfs for 8822B/8822C. By this debugfs, we can know physical information, such as Tx/Rx rate, RSSI, EVM,SNR, etc. The information is gotten from the packets of Tx/Rx path. It has no impact for the performance of 8822B/8822C. In the fields, we may meet different kinds of problems, but we may have no professional instrument to check them. At this moment, this debugfs is a good tool, and it may provide useful information for debug. Signed-off-by: Tsang-Shian Lin <thlin@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Chris Chiu <chiu@endlessm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-24rtw88: add set_bitrate_mask supportTzu-En Huang1-0/+3
Support setting bit rate from upper layer. After configuring the original rate control result in the driver, the result is then masked by the bit rate mask received from the ops set_bitrate_mask. Lastly, the masked result will be sent to firmware. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Chris Chiu <chiu@endlessm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-24rtw88: Enable 802.11ac beamformee supportTzu-En Huang1-0/+43
Enable MU-MIMO transmit beamformee support for chipset 8822b and 8822c. If the driver is in station mode and associated with an AP, and the capabilities of both meet the requirement of beamforming, driver will run as a beamformee and the corresponding chip settings will be set. In addition, module parameter support_bf is added to enable or disable beamforming. Sometimes driver will need to disable for inter-operate issues, and it would be easier for driver to debug. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-24rtw88: add power tracking supportTzu-En Huang1-1/+48
The temperature of the chip can affect the output power of the RF components. Hence driver requires to compensate the power by adjusting the power index recorded in the power swing table. And if the difference of current thermal value to the default thermal value exceeds a threshold, the RF IQK should be triggered to re-calibrate the characteristics of the RF components, to keep the output IQ vectors of the RF components orthogonal enough. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Chris Chiu <chiu@endlessm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-24rtw88: use macro to check the current bandYan-Hsuan Chuang1-0/+13
Add macros to see which band we are, based on the current channel. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-14rtw88: include interrupt.h for tasklet_structBrian Norris1-0/+1
Depending on implicit header includes, we might see this compilation error: .../main.h:1391:24: error: field has incomplete type 'struct tasklet_struct' struct tasklet_struct tx_tasklet; ^ Fixes: 3745d3e550d1 ("rtw88: add driver TX queue support") Signed-off-by: Brian Norris <briannorris@chromium.org> Acked-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-04rtw88: configure TX queue EDCA parametersYan-Hsuan Chuang1-0/+8
Set CWmax/CWmin, TXOP and AIFS according to ieee80211_tx_queue_params. Do note that hardware has only one group of EDCA[ac] registers, if more than one vif are added, the EDCA[ac] registers will contain value of params of the most recent set by ieee80211_ops::conf_tx(). And AIFS = AIFSN[ac] * slot_time + SIFS, so if use_short_slot is changed, need to also change AIFS. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-04rtw88: flush hardware tx queuesYan-Hsuan Chuang1-1/+2
Sometimes mac80211 will ask us to flush the hardware queues. To flush them, first we need to get the corresponding priority queues from the RQPN mapping table. Then we can check the available pages are equal to the originally reserved pages, which means the hardware has returned all of the pages it used to transmit. Note that now we only check for 100 ms for the priority queue, but sometimes if we have a lot of traffic (ex. 100Mbps up), some of the packets could be dropped. Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-10-04rtw88: report tx rate to mac80211 stackTzu-En Huang1-0/+10
Whenever the firmware increases/decreases the bit rate used to transmit to a peer, it sends an RA report through C2H to driver. Driver can then record the bit rate in the peer's struct rtw_sta_info, and report to mac80211 when it asks us for the statistics of the sta by ieee80211_ops::sta_statistics Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>