wifi: rtw88: Prepare to support RTL8814AU (part 1/2)
v2 cover wifi: rtw88: Prepare to support RTL8814AU (part 1/2)
A few small changes for RTL8814AU. Mostly it's about supporting more than 2 RF paths and spatial streams.
Part 2 will have 8 more patches to prepare things.
Part 3 will be mostly the new files for RTL8814AU.
Part 4 will improve performance.
Bitterblue Smith (9):
wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
wifi: rtw88: Constify some more structs and arrays
wifi: rtw88: Rename RTW_RATE_SECTION_MAX to RTW_RATE_SECTION_NUM
wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
drivers/net/wireless/realtek/rtw88/fw.c | 15 ++ drivers/net/wireless/realtek/rtw88/fw.h | 1 + drivers/net/wireless/realtek/rtw88/mac.c | 6 +- drivers/net/wireless/realtek/rtw88/main.c | 18 +- drivers/net/wireless/realtek/rtw88/main.h | 36 +++- drivers/net/wireless/realtek/rtw88/pci.c | 4 +- drivers/net/wireless/realtek/rtw88/phy.c | 191 ++++++++++++------ drivers/net/wireless/realtek/rtw88/phy.h | 20 +- drivers/net/wireless/realtek/rtw88/reg.h | 3 +- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 2 +- drivers/net/wireless/realtek/rtw88/sar.c | 2 +- drivers/net/wireless/realtek/rtw88/sdio.c | 2 +- drivers/net/wireless/realtek/rtw88/usb.c | 2 +- 16 files changed, 205 insertions(+), 103 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/9 wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
Don't call ltecoex_read_reg() and ltecoex_reg_write() when the ltecoex_addr member of struct rtw_chip_info is NULL. The RTL8814AU doesn't have this feature.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/mac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/mac.c +4 -2
@@ -784,7 +784,8 @@ static int __rtw_download_firmware(struct rtw_dev *rtwdev,if (!check_firmware_size (data, size))return -EINVAL ; -if (!ltecoex_read_reg (rtwdev,0x38 , <ecoex_bckp)) +if (rtwdev->chip->ltecoex_addr && + !ltecoex_read_reg (rtwdev,0x38 , <ecoex_bckp))return -EBUSY ;wlan_cpu_enable (rtwdev, false);
@@ -802,7 +803,8 @@ static int __rtw_download_firmware(struct rtw_dev *rtwdev,wlan_cpu_enable (rtwdev, true); -if (!ltecoex_reg_write (rtwdev,0x38 , ltecoex_bckp)) { +if (rtwdev->chip->ltecoex_addr && + !ltecoex_reg_write (rtwdev,0x38 , ltecoex_bckp)) { ret = -EBUSY ; goto dlfw_fail; }
Signature · 1 line
2.48.1
RE: [PATCH v2 1/9] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
Quoted 5 lines · Bitterblue Smith
Don't call
ltecoex_read_reg()andltecoex_reg_write()when theltecoex_addrmember of structrtw_chip_infois NULL. The RTL8814AU doesn't have this feature.Signed-off-by Bitterblue Smith <[email protected]>
Quoted 3 lines
---
v2:
- No change.
Next time please take my Acked-by in v1. That will help me to save time in v2.
Re: [PATCH v2 1/9] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
Quoted 7 lines · Ping-Ke Shih
Quoted 5 lines · Bitterblue Smith
Don't call
ltecoex_read_reg()andltecoex_reg_write()when theltecoex_addrmember of structrtw_chip_infois NULL. The RTL8814AU doesn't have this feature.Signed-off-by Bitterblue Smith <[email protected]>
Quoted 8 lines
Acked-by Ping-Ke Shih <[email protected]>Quoted 3 lines
---
v2:
- No change.Next time please take my Acked-by in v1. That will help me to save time in v2.
Okay, I will do that.
Ping-Ke Shih
maintainerRe: [PATCH v2 1/9] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
In reply to Bitterblue SmithQuoted 6 lines · Bitterblue Smith
Don't call
ltecoex_read_reg()andltecoex_reg_write()when theltecoex_addrmember of structrtw_chip_infois NULL. The RTL8814AU doesn't have this feature.Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
9 patch(es) applied to rtw-next branch of rtw.git, thanks.
8425f5c8f04d wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU 9e8243025cc0 wifi: rtw88: Fix download_firmware_validate() for RTL8814AU 62f726848da4 wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU d80e7d9b6ba3 wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU 8f0076726b66 wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU e66f3b5c7535 wifi: rtw88: Constify some more structs and arrays ad815f392003 wifi: rtw88: Rename RTW_RATE_SECTION_MAX to RTW_RATE_SECTION_NUM 0f98a5959657 wifi: rtw88: Extend TX power stuff for 3-4 spatial streams 9f00e2218e15 wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
PATCH v2 2/9 wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
In reply to Bitterblue SmithAfter the firmware is uploaded, download_firmware_validate() checks some bits in REG_MCUFW_CTRL to see if everything went okay. The RTL8814AU power on sequence sets bits 13 and 12 to 2, which this function does not expect, so it thinks the firmware upload failed.
Make download_firmware_validate() ignore bits 13 and 12.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/reg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/reg.h +2 -1
@@ -130,6 +130,7 @@#define BIT_SHIFT_ROM_PGE 16#define BIT_FW_INIT_RDY BIT(15)#define BIT_FW_DW_RDY BIT(14) +#define BIT_CPU_CLK_SEL (BIT(12) | BIT(13))#define BIT_RPWM_TOGGLE BIT(7)#define BIT_RAM_DL_SEL BIT(7)/* legacy only */ #define BIT_DMEM_CHKSUM_OK BIT(6)
@@ -147,7 +148,7 @@ BIT_CHECK_SUM_OK)#define FW_READY_LEGACY (BIT_MCUFWDL_RDY | BIT_FWDL_CHK_RPT | \ BIT_WINTINI_RDY | BIT_RAM_DL_SEL) -#define FW_READY_MASK 0xffff +#define FW_READY_MASK (0xffff & ~BIT_CPU_CLK_SEL)#define REG_MCU_TST_CFG 0x84#define VAL_FW_TRIGGER 0x1
Signature · 1 line
2.48.1
RE: [PATCH v2 2/9] wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
Quoted 8 lines · Bitterblue Smith
After the firmware is uploaded,
download_firmware_validate()checks some bits inREG_MCUFW_CTRLto see if everything went okay. The RTL8814AU power on sequence sets bits 13 and 12 to 2, which this function does not expect, so it thinks the firmware upload failed.Make
download_firmware_validate()ignore bits 13 and 12.Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 3/9 wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
In reply to Bitterblue SmithCurrently this struct has the members required for chips with 2 RF paths. Add more members to support chips with 4 RF paths, like the RTL8814AU.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/main.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/realtek/rtw88/main.h +12 -0
@@ -1130,14 +1130,26 @@ struct rtw_rfe_def {* For 2G there are cck rate and ofdm rate with different settings. */ struct rtw_pwr_track_tbl { +const u8 *pwrtrk_5gd_n[RTW_PWR_TRK_5G_NUM ]; +const u8 *pwrtrk_5gd_p[RTW_PWR_TRK_5G_NUM ]; +const u8 *pwrtrk_5gc_n[RTW_PWR_TRK_5G_NUM ]; +const u8 *pwrtrk_5gc_p[RTW_PWR_TRK_5G_NUM ];const u8 *pwrtrk_5gb_n[RTW_PWR_TRK_5G_NUM ];const u8 *pwrtrk_5gb_p[RTW_PWR_TRK_5G_NUM ];const u8 *pwrtrk_5ga_n[RTW_PWR_TRK_5G_NUM ];const u8 *pwrtrk_5ga_p[RTW_PWR_TRK_5G_NUM ]; +const u8 *pwrtrk_2gd_n; +const u8 *pwrtrk_2gd_p; +const u8 *pwrtrk_2gc_n; +const u8 *pwrtrk_2gc_p;const u8 *pwrtrk_2gb_n;const u8 *pwrtrk_2gb_p;const u8 *pwrtrk_2ga_n;const u8 *pwrtrk_2ga_p; +const u8 *pwrtrk_2g_cckd_n; +const u8 *pwrtrk_2g_cckd_p; +const u8 *pwrtrk_2g_cckc_n; +const u8 *pwrtrk_2g_cckc_p;const u8 *pwrtrk_2g_cckb_n;const u8 *pwrtrk_2g_cckb_p;const u8 *pwrtrk_2g_ccka_n;
Signature · 1 line
2.48.1
RE: [PATCH v2 3/9] wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
Quoted 5 lines · Bitterblue Smith
Currently this struct has the members required for chips with 2 RF paths. Add more members to support chips with 4 RF paths, like the RTL8814AU.
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 4/9 wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
In reply to Bitterblue SmithThese members of struct rtw_chip_info each have a size of 2. Increase their size to 4, which is the number of RF paths the RTL8814AU has.
This is required to read and write the RF registers of the RTL8814AU.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +2 -2
@@ -1239,8 +1239,8 @@ struct rtw_chip_info {const struct rtw_hw_reg *dig;const struct rtw_hw_reg *dig_cck; -u32 rf_base_addr[2 ]; -u32 rf_sipi_addr[2 ]; +u32 rf_base_addr[RTW_RF_PATH_MAX ]; +u32 rf_sipi_addr[RTW_RF_PATH_MAX ];const struct rtw_rf_sipi_addr *rf_sipi_read_addr;u8 fix_rf_phy_num;const struct rtw_ltecoex_addr *ltecoex_addr;
Signature · 1 line
2.48.1
RE: [PATCH v2 4/9] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
Quoted 6 lines · Bitterblue Smith
These members of struct
rtw_chip_infoeach have a size of 2. Increase their size to 4, which is the number of RF paths the RTL8814AU has.This is required to read and write the RF registers of the RTL8814AU.
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 5/9 wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
In reply to Bitterblue SmithThe existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.
---
v2:
- Add RTW_CHIP_TYPE_8814A enum.
- Check the chip type instead of the presence of RF path C.
- Reduce indentation.
--- drivers/net/wireless/realtek/rtw88/fw.c | 15 +++++++++++++++ drivers/net/wireless/realtek/rtw88/fw.h | 1 + drivers/net/wireless/realtek/rtw88/main.h | 1 + 3 files changed, 17 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +15 -0
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, {u8 h2c_pkt[H2C_PKT_SIZE ] = {0 };bool disable_pt = true; +u32 mask_hi;SET_H2C_CMD_ID_CLASS (h2c_pkt,H2C_CMD_RA_INFO );
@@ -755,6 +756,20 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, si->init_ra_lv =0 ;rtw_fw_send_h2c_command (rtwdev, h2c_pkt); + +if (rtwdev->chip->id !=RTW_CHIP_TYPE_8814A ) +return ; + +SET_H2C_CMD_ID_CLASS (h2c_pkt,H2C_CMD_RA_INFO_HI ); + + mask_hi = si->ra_mask >>32 ; + +SET_RA_INFO_RA_MASK0 (h2c_pkt, (mask_hi &0xff )); +SET_RA_INFO_RA_MASK1 (h2c_pkt, (mask_hi &0xff00 ) >>8 ); +SET_RA_INFO_RA_MASK2 (h2c_pkt, (mask_hi &0xff0000 ) >>16 ); +SET_RA_INFO_RA_MASK3 (h2c_pkt, (mask_hi &0xff000000 ) >>24 ); + +rtw_fw_send_h2c_command (rtwdev, h2c_pkt); }void rtw_fw_media_status_report (struct rtw_dev *rtwdev,u8 mac_id,bool connect)
drivers/net/wireless/realtek/rtw88/fw.h +1 -0
@@ -557,6 +557,7 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)#define H2C_CMD_DEFAULT_PORT 0x2c#define H2C_CMD_RA_INFO 0x40#define H2C_CMD_RSSI_MONITOR 0x42 +#define H2C_CMD_RA_INFO_HI 0x46#define H2C_CMD_BCN_FILTER_OFFLOAD_P0 0x56#define H2C_CMD_BCN_FILTER_OFFLOAD_P1 0x57#define H2C_CMD_WL_PHY_INFO 0x58
drivers/net/wireless/realtek/rtw88/main.h +1 -0
@@ -191,6 +191,7 @@ enum rtw_chip_type {RTW_CHIP_TYPE_8703B ,RTW_CHIP_TYPE_8821A ,RTW_CHIP_TYPE_8812A , + RTW_CHIP_TYPE_8814A, }; enum rtw_tx_queue_type {
Signature · 1 line
2.48.1
RE: [PATCH v2 5/9] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
Quoted 5 lines · Bitterblue Smith
The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 6/9 wifi: rtw88: Constify some more structs and arrays
In reply to Bitterblue SmithThese structs and arrays are never modified, so make them const:
rtw_band_2ghzrtw_band_5ghzrtw_pci_tx_queue_idx_addrrtw_pci_opsrtw_cck_ratesrtw_ofdm_ratesrtw_ht_1s_ratesrtw_ht_2s_ratesrtw_vht_1s_ratesrtw_vht_2s_ratesrtw_rate_sectionrtw_rate_sizertw_sdio_opsrtw_usb_ops
---
v2:
- Patch is new in v2.
--- drivers/net/wireless/realtek/rtw88/main.c | 4 ++-- drivers/net/wireless/realtek/rtw88/main.h | 2 +- drivers/net/wireless/realtek/rtw88/pci.c | 4 ++-- drivers/net/wireless/realtek/rtw88/phy.c | 26 ++++++++++++++--------- drivers/net/wireless/realtek/rtw88/phy.h | 16 +++++++------- drivers/net/wireless/realtek/rtw88/sdio.c | 2 +- drivers/net/wireless/realtek/rtw88/usb.c | 2 +- 7 files changed, 31 insertions(+), 25 deletions(-)
drivers/net/wireless/realtek/rtw88/main.c +2 -2
@@ -136,7 +136,7 @@ u16 rtw_desc_to_bitrate(u8 desc_rate)return rate.bitrate; } -static struct ieee80211_supported_band rtw_band_2ghz = { +static const struct ieee80211_supported_band rtw_band_2ghz = { .band =NL80211_BAND_2GHZ , .channels = rtw_channeltable_2g,
@@ -149,7 +149,7 @@ static struct ieee80211_supported_band rtw_band_2ghz = { .vht_cap = {0}, }; -static struct ieee80211_supported_band rtw_band_5ghz = { +static const struct ieee80211_supported_band rtw_band_5ghz = { .band =NL80211_BAND_5GHZ , .channels = rtw_channeltable_5g,
drivers/net/wireless/realtek/rtw88/main.h +1 -1
@@ -61,7 +61,7 @@ enum rtw_hci_type { };struct rtw_hci { -struct rtw_hci_ops *ops; +const struct rtw_hci_ops *ops;enum rtw_hci_type type;u32 rpwm_addr;
drivers/net/wireless/realtek/rtw88/pci.c +2 -2
@@ -20,7 +20,7 @@ module_param_named(disable_aspm, rtw_pci_disable_aspm, bool, 0644);MODULE_PARM_DESC (disable_msi,"Set Y to disable MSI interrupt support" );MODULE_PARM_DESC (disable_aspm,"Set Y to disable PCI ASPM support" ); -static u32 rtw_pci_tx_queue_idx_addr[] = { +static const u32 rtw_pci_tx_queue_idx_addr[] = { [RTW_TX_QUEUE_BK ] =RTK_PCI_TXBD_IDX_BKQ , [RTW_TX_QUEUE_BE ] =RTK_PCI_TXBD_IDX_BEQ , [RTW_TX_QUEUE_VI ] =RTK_PCI_TXBD_IDX_VIQ ,
@@ -1591,7 +1591,7 @@ static void rtw_pci_destroy(struct rtw_dev *rtwdev, struct pci_dev *pdev)rtw_pci_io_unmapping (rtwdev, pdev); } -static struct rtw_hci_ops rtw_pci_ops = { +static const struct rtw_hci_ops rtw_pci_ops = { .tx_write = rtw_pci_tx_write, .tx_kick_off = rtw_pci_tx_kick_off, .flush_queues = rtw_pci_flush_queues,
drivers/net/wireless/realtek/rtw88/phy.c +16 -10
@@ -52,44 +52,50 @@ static const u32 db_invert_table[12][8] = { 1995262315, 2511886432U, 3162277660U, 3981071706U} }; -u8 rtw_cck_rates[] = {DESC_RATE1M ,DESC_RATE2M ,DESC_RATE5_5M ,DESC_RATE11M }; -u8 rtw_ofdm_rates[] = { +const u8 rtw_cck_rates[] = {DESC_RATE1M ,DESC_RATE2M ,DESC_RATE5_5M ,DESC_RATE11M }; + +const u8 rtw_ofdm_rates[] = {DESC_RATE6M ,DESC_RATE9M ,DESC_RATE12M ,DESC_RATE18M ,DESC_RATE24M ,DESC_RATE36M ,DESC_RATE48M ,DESC_RATE54M }; -u8 rtw_ht_1s_rates[] = { + +const u8 rtw_ht_1s_rates[] = {DESC_RATEMCS0 ,DESC_RATEMCS1 ,DESC_RATEMCS2 ,DESC_RATEMCS3 ,DESC_RATEMCS4 ,DESC_RATEMCS5 ,DESC_RATEMCS6 ,DESC_RATEMCS7 }; -u8 rtw_ht_2s_rates[] = { + +const u8 rtw_ht_2s_rates[] = {DESC_RATEMCS8 ,DESC_RATEMCS9 ,DESC_RATEMCS10 ,DESC_RATEMCS11 ,DESC_RATEMCS12 ,DESC_RATEMCS13 ,DESC_RATEMCS14 ,DESC_RATEMCS15 }; -u8 rtw_vht_1s_rates[] = { + +const u8 rtw_vht_1s_rates[] = {DESC_RATEVHT1SS_MCS0 ,DESC_RATEVHT1SS_MCS1 ,DESC_RATEVHT1SS_MCS2 ,DESC_RATEVHT1SS_MCS3 ,DESC_RATEVHT1SS_MCS4 ,DESC_RATEVHT1SS_MCS5 ,DESC_RATEVHT1SS_MCS6 ,DESC_RATEVHT1SS_MCS7 ,DESC_RATEVHT1SS_MCS8 ,DESC_RATEVHT1SS_MCS9 }; -u8 rtw_vht_2s_rates[] = { + +const u8 rtw_vht_2s_rates[] = {DESC_RATEVHT2SS_MCS0 ,DESC_RATEVHT2SS_MCS1 ,DESC_RATEVHT2SS_MCS2 ,DESC_RATEVHT2SS_MCS3 ,DESC_RATEVHT2SS_MCS4 ,DESC_RATEVHT2SS_MCS5 ,DESC_RATEVHT2SS_MCS6 ,DESC_RATEVHT2SS_MCS7 ,DESC_RATEVHT2SS_MCS8 ,DESC_RATEVHT2SS_MCS9 }; -u8 *rtw_rate_section[RTW_RATE_SECTION_MAX ] = { + +const u8 *const rtw_rate_section[RTW_RATE_SECTION_MAX ] = { rtw_cck_rates, rtw_ofdm_rates, rtw_ht_1s_rates, rtw_ht_2s_rates, rtw_vht_1s_rates, rtw_vht_2s_rates };EXPORT_SYMBOL (rtw_rate_section); -u8 rtw_rate_size[RTW_RATE_SECTION_MAX ] = { +const u8 rtw_rate_size[RTW_RATE_SECTION_MAX ] = {ARRAY_SIZE (rtw_cck_rates),ARRAY_SIZE (rtw_ofdm_rates),ARRAY_SIZE (rtw_ht_1s_rates),
@@ -2214,7 +2220,7 @@ static void rtw_phy_set_tx_power_index_by_rs(struct rtw_dev *rtwdev, {struct rtw_hal *hal = &rtwdev->hal;u8 regd =rtw_regd_get (rtwdev); -u8 *rates; +const u8 *rates;u8 size;u8 rate;u8 pwr_idx;
@@ -2274,7 +2280,7 @@ EXPORT_SYMBOL(rtw_phy_set_tx_power_level);static void rtw_phy_tx_power_by_rate_config_by_path (struct rtw_hal *hal,u8 path, -u8 rs,u8 size,u8 *rates) +u8 rs,u8 size,const u8 *rates) {u8 rate;u8 base_idx, rate_idx;
drivers/net/wireless/realtek/rtw88/phy.h +8 -8
@@ -7,14 +7,14 @@#include "debug.h" -extern u8 rtw_cck_rates[]; -extern u8 rtw_ofdm_rates[]; -extern u8 rtw_ht_1s_rates[]; -extern u8 rtw_ht_2s_rates[]; -extern u8 rtw_vht_1s_rates[]; -extern u8 rtw_vht_2s_rates[]; -extern u8 *rtw_rate_section[]; -extern u8 rtw_rate_size[]; +extern const u8 rtw_cck_rates[]; +extern const u8 rtw_ofdm_rates[]; +extern const u8 rtw_ht_1s_rates[]; +extern const u8 rtw_ht_2s_rates[]; +extern const u8 rtw_vht_1s_rates[]; +extern const u8 rtw_vht_2s_rates[]; +extern const u8 *const rtw_rate_section[]; +extern const u8 rtw_rate_size[];void rtw_phy_init (struct rtw_dev *rtwdev);void rtw_phy_dynamic_mechanism (struct rtw_dev *rtwdev);
drivers/net/wireless/realtek/rtw88/sdio.c +1 -1
@@ -1147,7 +1147,7 @@ static void rtw_sdio_declaim(struct rtw_dev *rtwdev,sdio_release_host (sdio_func); } -static struct rtw_hci_ops rtw_sdio_ops = { +static const struct rtw_hci_ops rtw_sdio_ops = { .tx_write = rtw_sdio_tx_write, .tx_kick_off = rtw_sdio_tx_kick_off, .setup = rtw_sdio_setup,
drivers/net/wireless/realtek/rtw88/usb.c +1 -1
@@ -881,7 +881,7 @@ static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) } } -static struct rtw_hci_ops rtw_usb_ops = { +static const struct rtw_hci_ops rtw_usb_ops = { .tx_write = rtw_usb_tx_write, .tx_kick_off = rtw_usb_tx_kick_off, .setup = rtw_usb_setup,
Signature · 1 line
2.48.1
RE: [PATCH v2 6/9] wifi: rtw88: Constify some more structs and arrays
Quoted 17 lines · Bitterblue Smith
These structs and arrays are never modified, so make them const:
rtw_band_2ghzrtw_band_5ghzrtw_pci_tx_queue_idx_addrrtw_pci_opsrtw_cck_ratesrtw_ofdm_ratesrtw_ht_1s_ratesrtw_ht_2s_ratesrtw_vht_1s_ratesrtw_vht_2s_ratesrtw_rate_sectionrtw_rate_sizertw_sdio_opsrtw_usb_ops
Quoted 1 line
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 7/9 wifi: rtw88: Rename RTW_RATE_SECTION_MAX to RTW_RATE_SECTION_NUM
In reply to Bitterblue SmithIt fits the meaning of the enum better.
---
v2:
- Patch is new in v2.
--- drivers/net/wireless/realtek/rtw88/main.h | 12 +++++----- drivers/net/wireless/realtek/rtw88/phy.c | 24 +++++++++---------- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 2 +- drivers/net/wireless/realtek/rtw88/sar.c | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +6 -6
@@ -168,7 +168,7 @@ enum rtw_rate_section {RTW_RATE_SECTION_VHT_2S ,/* keep last */ - RTW_RATE_SECTION_MAX, + RTW_RATE_SECTION_NUM, }; enum rtw_wireless_set {
@@ -1937,7 +1937,7 @@ union rtw_sar_cfg {struct rtw_sar {enum rtw_sar_sources src; -union rtw_sar_cfg cfg[RTW_RF_PATH_MAX ][RTW_RATE_SECTION_MAX ]; +union rtw_sar_cfg cfg[RTW_RF_PATH_MAX ][RTW_RATE_SECTION_NUM ]; };struct rtw_hal {
@@ -1981,16 +1981,16 @@ struct rtw_hal {s8 tx_pwr_by_rate_offset_5g[RTW_RF_PATH_MAX ] [DESC_RATE_MAX ];s8 tx_pwr_by_rate_base_2g[RTW_RF_PATH_MAX ] - [RTW_RATE_SECTION_MAX ]; + [RTW_RATE_SECTION_NUM ];s8 tx_pwr_by_rate_base_5g[RTW_RF_PATH_MAX ] - [RTW_RATE_SECTION_MAX ]; + [RTW_RATE_SECTION_NUM ];s8 tx_pwr_limit_2g[RTW_REGD_MAX ] [RTW_CHANNEL_WIDTH_MAX ] - [RTW_RATE_SECTION_MAX ] + [RTW_RATE_SECTION_NUM ] [RTW_MAX_CHANNEL_NUM_2G ];s8 tx_pwr_limit_5g[RTW_REGD_MAX ] [RTW_CHANNEL_WIDTH_MAX ] - [RTW_RATE_SECTION_MAX ] + [RTW_RATE_SECTION_NUM ] [RTW_MAX_CHANNEL_NUM_5G ];s8 tx_pwr_tbl[RTW_RF_PATH_MAX ] [DESC_RATE_MAX ];
drivers/net/wireless/realtek/rtw88/phy.c +12 -12
@@ -88,14 +88,14 @@ const u8 rtw_vht_2s_rates[] = {DESC_RATEVHT2SS_MCS8 ,DESC_RATEVHT2SS_MCS9 }; -const u8 *const rtw_rate_section[RTW_RATE_SECTION_MAX ] = { +const u8 *const rtw_rate_section[RTW_RATE_SECTION_NUM ] = { rtw_cck_rates, rtw_ofdm_rates, rtw_ht_1s_rates, rtw_ht_2s_rates, rtw_vht_1s_rates, rtw_vht_2s_rates };EXPORT_SYMBOL (rtw_rate_section); -const u8 rtw_rate_size[RTW_RATE_SECTION_MAX ] = { +const u8 rtw_rate_size[RTW_RATE_SECTION_NUM ] = {ARRAY_SIZE (rtw_cck_rates),ARRAY_SIZE (rtw_ofdm_rates), ARRAY_SIZE(rtw_ht_1s_rates),
@@ -1596,7 +1596,7 @@ static void rtw_phy_set_tx_power_limit(struct rtw_dev *rtwdev, u8 regd, u8 band, ch_idx =rtw_channel_to_idx (band, ch);if (regd >=RTW_REGD_MAX || bw >=RTW_CHANNEL_WIDTH_MAX || - rs >=RTW_RATE_SECTION_MAX || ch_idx <0 ) { + rs >=RTW_RATE_SECTION_NUM || ch_idx <0 ) {WARN (1 ,"wrong txpwr_lmt regd=%u, band=%u bw=%u, rs=%u, ch_idx=%u, pwr_limit=%d\n" , regd, band, bw, rs, ch_idx, pwr_limit);
@@ -1701,7 +1701,7 @@ rtw_cfg_txpwr_lmt_by_alt(struct rtw_dev *rtwdev, u8 regd, u8 regd_alt)u8 bw, rs;for (bw =0 ; bw <RTW_CHANNEL_WIDTH_MAX ; bw++) -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++)__cfg_txpwr_lmt_by_alt (&rtwdev->hal, regd, regd_alt, bw, rs); }
@@ -2060,7 +2060,7 @@ static u8 rtw_phy_get_5g_tx_power_index(struct rtw_dev *rtwdev,return tx_power; } -/* return RTW_RATE_SECTION_MAX to indicate rate is invalid */ +/* return RTW_RATE_SECTION_NUM to indicate rate is invalid */ static u8 rtw_phy_rate_to_rate_section (u8 rate) {if (rate >=DESC_RATE1M && rate <=DESC_RATE11M )
@@ -2076,7 +2076,7 @@ static u8 rtw_phy_rate_to_rate_section(u8 rate)else if (rate >=DESC_RATEVHT2SS_MCS0 && rate <=DESC_RATEVHT2SS_MCS9 )return RTW_RATE_SECTION_VHT_2S ;else -return RTW_RATE_SECTION_MAX ; +return RTW_RATE_SECTION_NUM ; } static s8 rtw_phy_get_tx_power_limit(struct rtw_dev *rtwdev, u8 band,
@@ -2094,7 +2094,7 @@ static s8 rtw_phy_get_tx_power_limit(struct rtw_dev *rtwdev, u8 band,if (regd >RTW_REGD_WW )return power_limit; -if (rs ==RTW_RATE_SECTION_MAX ) +if (rs ==RTW_RATE_SECTION_NUM ) goto err;/* only 20M BW with cck and ofdm */
@@ -2138,7 +2138,7 @@ static s8 rtw_phy_get_tx_power_sar(struct rtw_dev *rtwdev, u8 sar_band, .rs = rs, }; -if (rs ==RTW_RATE_SECTION_MAX ) +if (rs ==RTW_RATE_SECTION_NUM ) goto err;return rtw_query_sar (rtwdev, &arg);
@@ -2227,7 +2227,7 @@ static void rtw_phy_set_tx_power_index_by_rs(struct rtw_dev *rtwdev,u8 bw;int i; -if (rs >=RTW_RATE_SECTION_MAX ) +if (rs >=RTW_RATE_SECTION_NUM )return ; rates = rtw_rate_section[rs];
@@ -2258,7 +2258,7 @@ static void rtw_phy_set_tx_power_level_by_path(struct rtw_dev *rtwdev,else rs =RTW_RATE_SECTION_OFDM ; -for (; rs <RTW_RATE_SECTION_MAX ; rs++) +for (; rs <RTW_RATE_SECTION_NUM ; rs++)rtw_phy_set_tx_power_index_by_rs (rtwdev, ch, path, rs); }
@@ -2353,7 +2353,7 @@ void rtw_phy_tx_power_limit_config(struct rtw_hal *hal)for (regd =0 ; regd <RTW_REGD_MAX ; regd++)for (bw =0 ; bw <RTW_CHANNEL_WIDTH_MAX ; bw++) -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++)__rtw_phy_tx_power_limit_config (hal, regd, bw, rs); }
@@ -2389,7 +2389,7 @@ void rtw_phy_init_tx_power(struct rtw_dev *rtwdev)/* init tx power limit */ for (regd =0 ; regd <RTW_REGD_MAX ; regd++)for (bw =0 ; bw <RTW_CHANNEL_WIDTH_MAX ; bw++) -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++)rtw_phy_init_tx_power_limit (rtwdev, regd, bw, rs); }
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -1
@@ -709,7 +709,7 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) { +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) {if (rs ==RTW_RATE_SECTION_HT_2S || rs ==RTW_RATE_SECTION_VHT_2S )continue ;
drivers/net/wireless/realtek/rtw88/rtw8822b.c +1 -1
@@ -964,7 +964,7 @@ static void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++)rtw8822b_set_tx_power_index_by_rate (rtwdev, path, rs, &phy_pwr_idx); }
drivers/net/wireless/realtek/rtw88/rtw8822c.c +1 -1
@@ -2746,7 +2746,7 @@ static void rtw8822c_set_tx_power_index(struct rtw_dev *rtwdev)s8 diff_idx[4 ];rtw8822c_set_write_tx_power_ref (rtwdev, pwr_ref_cck, pwr_ref_ofdm); -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) { +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) {for (j =0 ; j < rtw_rate_size[rs]; j++) { rate = rtw_rate_section[rs][j]; pwr_a = hal->tx_pwr_tbl[RF_PATH_A ][rate];
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +1 -1
@@ -1637,7 +1637,7 @@ void rtw88xxa_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_MAX ; rs++) { +for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) {if (hal->rf_path_num ==1 && (rs ==RTW_RATE_SECTION_HT_2S || rs ==RTW_RATE_SECTION_VHT_2S ))
drivers/net/wireless/realtek/rtw88/sar.c +1 -1
@@ -97,7 +97,7 @@ int rtw_set_sar_specs(struct rtw_dev *rtwdev, power, BIT(RTW_COMMON_SAR_FCT));for (j =0 ; j <RTW_RF_PATH_MAX ; j++) { -for (k =0 ; k <RTW_RATE_SECTION_MAX ; k++) { +for (k =0 ; k <RTW_RATE_SECTION_NUM ; k++) { arg = (struct rtw_sar_arg ){ .sar_band = idx, .path = j,
Signature · 1 line
2.48.1
RE: [PATCH v2 7/9] wifi: rtw88: Rename RTW_RATE_SECTION_MAX to RTW_RATE_SECTION_NUM
Quoted 3 lines · Bitterblue Smith
It fits the meaning of the enum better.
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 8/9 wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
In reply to Bitterblue SmithAlthough the RTL8814AU only has 3 spatial streams, maybe some other chip has 4.
Correct the TX power index and TX power limit calculations for 3SS and 4SS HT/VHT rates.
With this the RTL8814AU can set the TX power correctly.
---
v2:
- Constify the new arrays rtw_ht_3s_rates, rtw_ht_4s_rates, rtw_vht_3s_rates, rtw_vht_4s_rates.
- Make rs_cmp static const.
- Introduce __RTW_RATE_SECTION_2SS_MAX instead of using RTW_RATE_SECTION_HT_3S in for loops.
--- drivers/net/wireless/realtek/rtw88/main.h | 5 + drivers/net/wireless/realtek/rtw88/phy.c | 145 ++++++++++++------ drivers/net/wireless/realtek/rtw88/phy.h | 4 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 2 +- 7 files changed, 111 insertions(+), 51 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +5 -0
@@ -166,6 +166,11 @@ enum rtw_rate_section {RTW_RATE_SECTION_HT_2S ,RTW_RATE_SECTION_VHT_1S ,RTW_RATE_SECTION_VHT_2S , + __RTW_RATE_SECTION_2SS_MAX =RTW_RATE_SECTION_VHT_2S , +RTW_RATE_SECTION_HT_3S , +RTW_RATE_SECTION_HT_4S , +RTW_RATE_SECTION_VHT_3S , +RTW_RATE_SECTION_VHT_4S ,/* keep last */ RTW_RATE_SECTION_NUM,
drivers/net/wireless/realtek/rtw88/phy.c +98 -47
256 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/phy.h +4 -0
@@ -13,6 +13,10 @@ extern const u8 rtw_ht_1s_rates[];extern const u8 rtw_ht_2s_rates[];extern const u8 rtw_vht_1s_rates[];extern const u8 rtw_vht_2s_rates[]; +extern const u8 rtw_ht_3s_rates[]; +extern const u8 rtw_ht_4s_rates[]; +extern const u8 rtw_vht_3s_rates[]; +extern const u8 rtw_vht_4s_rates[];extern const u8 *const rtw_rate_section[];extern const u8 rtw_rate_size[];
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -1
@@ -709,7 +709,7 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) { +for (rs =0 ; rs <= __RTW_RATE_SECTION_2SS_MAX; rs++) {if (rs ==RTW_RATE_SECTION_HT_2S || rs ==RTW_RATE_SECTION_VHT_2S )continue ;
drivers/net/wireless/realtek/rtw88/rtw8822b.c +1 -1
@@ -964,7 +964,7 @@ static void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) +for (rs =0 ; rs <= __RTW_RATE_SECTION_2SS_MAX; rs++)rtw8822b_set_tx_power_index_by_rate (rtwdev, path, rs, &phy_pwr_idx); }
drivers/net/wireless/realtek/rtw88/rtw8822c.c +1 -1
@@ -2746,7 +2746,7 @@ static void rtw8822c_set_tx_power_index(struct rtw_dev *rtwdev)s8 diff_idx[4 ];rtw8822c_set_write_tx_power_ref (rtwdev, pwr_ref_cck, pwr_ref_ofdm); -for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) { +for (rs =0 ; rs <= __RTW_RATE_SECTION_2SS_MAX; rs++) {for (j =0 ; j < rtw_rate_size[rs]; j++) { rate = rtw_rate_section[rs][j]; pwr_a = hal->tx_pwr_tbl[RF_PATH_A ][rate];
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +1 -1
@@ -1637,7 +1637,7 @@ void rtw88xxa_set_tx_power_index(struct rtw_dev *rtwdev)int rs, path;for (path =0 ; path < hal->rf_path_num; path++) { -for (rs =0 ; rs <RTW_RATE_SECTION_NUM ; rs++) { +for (rs =0 ; rs <= __RTW_RATE_SECTION_2SS_MAX; rs++) {if (hal->rf_path_num ==1 && (rs ==RTW_RATE_SECTION_HT_2S || rs ==RTW_RATE_SECTION_VHT_2S ))
Signature · 1 line
2.48.1
RE: [PATCH v2 8/9] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
Quoted 9 lines · Bitterblue Smith
Although the RTL8814AU only has 3 spatial streams, maybe some other chip has 4.
Correct the TX power index and TX power limit calculations for 3SS and 4SS HT/VHT rates.
With this the RTL8814AU can set the TX power correctly.
Signed-off-by Bitterblue Smith <[email protected]>
PATCH v2 9/9 wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
In reply to Bitterblue SmithThis function tells the firmware what rates it can use.
Put the 3SS and 4SS HT rates supported by the other station into the rate mask.
Remove the 3SS and 4SS rates from the rate mask if the hardware only has 2 spatial streams.
And finally, select the right rate ID (a parameter for the firmware) when the hardware has 3 spatial streams.
---
v2:
- No change.
--- drivers/net/wireless/realtek/rtw88/main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/main.c +9 -5
@@ -1234,7 +1234,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,if (sta->deflink.vht_cap.cap &IEEE80211_VHT_CAP_RXLDPC ) ldpc_en =VHT_LDPC_EN ; }else if (sta->deflink.ht_cap.ht_supported) { - ra_mask |= (sta->deflink.ht_cap.mcs.rx_mask[1 ] <<20 ) | + ra_mask |= ((u64 )sta->deflink.ht_cap.mcs.rx_mask[3 ] <<36 ) | + ((u64 )sta->deflink.ht_cap.mcs.rx_mask[2 ] <<28 ) | + (sta->deflink.ht_cap.mcs.rx_mask[1 ] <<20 ) | (sta->deflink.ht_cap.mcs.rx_mask[0 ] <<12 );if (sta->deflink.ht_cap.cap &IEEE80211_HT_CAP_RX_STBC ) stbc_en =HT_STBC_EN ;
@@ -1244,6 +1246,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,if (efuse->hw_cap.nss ==1 || rtwdev->hal.txrx_1ss) ra_mask &=RA_MASK_VHT_RATES_1SS |RA_MASK_HT_RATES_1SS ; +else if (efuse->hw_cap.nss ==2 ) + ra_mask &=RA_MASK_VHT_RATES_2SS |RA_MASK_HT_RATES_2SS | +RA_MASK_VHT_RATES_1SS |RA_MASK_HT_RATES_1SS ;if (hal->current_band_type ==RTW_BAND_5G ) { ra_mask |= (u64 )sta->deflink.supp_rates[NL80211_BAND_5GHZ ] <<4 ;
@@ -1302,10 +1307,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,break ; } -if (sta->deflink.vht_cap.vht_supported && ra_mask &0xffc00000 ) - tx_num =2 ; -else if (sta->deflink.ht_cap.ht_supported && ra_mask &0xfff00000 ) - tx_num =2 ; +if (sta->deflink.vht_cap.vht_supported || + sta->deflink.ht_cap.ht_supported) + tx_num = efuse->hw_cap.nss; rate_id =get_rate_id (wireless_set, bw_mode, tx_num);
Signature · 1 line
2.48.1
RE: [PATCH v2 9/9] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
Quoted 5 lines · Bitterblue Smith
This function tells the firmware what rates it can use.
Put the 3SS and 4SS HT rates supported by the other station into the rate mask.
Quoted 7 lines
Remove the 3SS and 4SS rates from the rate mask if the hardware only has 2 spatial streams.
And finally, select the right rate ID (a parameter for the firmware) when the hardware has 3 spatial streams.
Signed-off-by Bitterblue Smith <[email protected]>