1. 18 4月, 2021 3 次提交
    • P
      rtw88: 8822c: add CFO tracking · fb8517f4
      Po-Hao Huang 提交于
      Add CFO tracking, which stands for central frequency offset tracking, to
      adjust oscillator to align central frequency of connected AP. Then, it can
      yield better performance.
      Signed-off-by: NPo-Hao Huang <phhuang@realtek.com>
      Signed-off-by: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20210416030901.7099-1-pkshih@realtek.com
      fb8517f4
    • P
      rtw88: Fix array overrun in rtw_get_tx_power_params() · 2ff25985
      Ping-Ke Shih 提交于
      Using a kernel with the Undefined Behaviour Sanity Checker (UBSAN) enabled, the
      following array overrun is logged:
      
      ================================================================================
      UBSAN: array-index-out-of-bounds in /home/finger/wireless-drivers-next/drivers/net/wireless/realtek/rtw88/phy.c:1789:34
      index 5 is out of range for type 'u8 [5]'
      CPU: 2 PID: 84 Comm: kworker/u16:3 Tainted: G           O      5.12.0-rc5-00086-gd88bba47038e-dirty #651
      Hardware name: TOSHIBA TECRA A50-A/TECRA A50-A, BIOS Version 4.50   09/29/2014
      Workqueue: phy0 ieee80211_scan_work [mac80211]
      Call Trace:
       dump_stack+0x64/0x7c
       ubsan_epilogue+0x5/0x40
       __ubsan_handle_out_of_bounds.cold+0x43/0x48
       rtw_get_tx_power_params+0x83a/drivers/net/wireless/realtek/rtw88/0xad0 [rtw_core]
       ? rtw_pci_read16+0x20/0x20 [rtw_pci]
       ? check_hw_ready+0x50/0x90 [rtw_core]
       rtw_phy_get_tx_power_index+0x4d/0xd0 [rtw_core]
       rtw_phy_set_tx_power_level+0xee/0x1b0 [rtw_core]
       rtw_set_channel+0xab/0x110 [rtw_core]
       rtw_ops_config+0x87/0xc0 [rtw_core]
       ieee80211_hw_config+0x9d/0x130 [mac80211]
       ieee80211_scan_state_set_channel+0x81/0x170 [mac80211]
       ieee80211_scan_work+0x19f/0x2a0 [mac80211]
       process_one_work+0x1dd/0x3a0
       worker_thread+0x49/0x330
       ? rescuer_thread+0x3a0/0x3a0
       kthread+0x134/0x150
       ? kthread_create_worker_on_cpu+0x70/0x70
       ret_from_fork+0x22/0x30
      ================================================================================
      
      The statement where an array is being overrun is shown in the following snippet:
      
      	if (rate <= DESC_RATE11M)
      		tx_power = pwr_idx_2g->cck_base[group];
      	else
      ====>		tx_power = pwr_idx_2g->bw40_base[group];
      
      The associated arrays are defined in main.h as follows:
      
      struct rtw_2g_txpwr_idx {
      	u8 cck_base[6];
      	u8 bw40_base[5];
      	struct rtw_2g_1s_pwr_idx_diff ht_1s_diff;
      	struct rtw_2g_ns_pwr_idx_diff ht_2s_diff;
      	struct rtw_2g_ns_pwr_idx_diff ht_3s_diff;
      	struct rtw_2g_ns_pwr_idx_diff ht_4s_diff;
      };
      
      The problem arises because the value of group is 5 for channel 14. The trivial
      increase in the dimension of bw40_base fails as this struct must match the layout of
      efuse. The fix is to add the rate as an argument to rtw_get_channel_group() and set
      the group for channel 14 to 4 if rate <= DESC_RATE11M.
      
      This patch fixes commit fa6dfe6b ("rtw88: resolve order of tx power setting routines")
      
      Fixes: fa6dfe6b ("rtw88: resolve order of tx power setting routines")
      Reported-by: NБогдан Пилипенко <bogdan.pylypenko107@gmail.com>
      Signed-off-by: NLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: NPing-Ke Shih <pkshih@realtek.com>
      Cc: Stable <stable@vger.kernel.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20210401192717.28927-1-Larry.Finger@lwfinger.net
      2ff25985
    • P
      rtw88: update statistics to fw for fine-tuning performance · ec7480ed
      Po-Hao Huang 提交于
      Since firmware can't have proper statistics, driver update the statistics
      periodically to firmware to assist in tuning performance.
      Signed-off-by: NPo-Hao Huang <phhuang@realtek.com>
      Signed-off-by: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20210326092147.30252-1-pkshih@realtek.com
      ec7480ed
  2. 11 4月, 2021 2 次提交
  3. 12 2月, 2021 1 次提交
  4. 24 11月, 2020 1 次提交
  5. 27 8月, 2020 2 次提交
  6. 18 5月, 2020 1 次提交
  7. 13 5月, 2020 2 次提交
    • P
      rtw88: 8723d: Add power tracking · 608d2a08
      Ping-Ke Shih 提交于
      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: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200512102621.5148-4-yhchuang@realtek.com
      608d2a08
    • P
      rtw88: 8723d: add IQ calibration · 1d229e88
      Ping-Ke Shih 提交于
      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: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200512102621.5148-3-yhchuang@realtek.com
      1d229e88
  8. 06 5月, 2020 1 次提交
  9. 21 4月, 2020 1 次提交
    • P
      rtw88: 8723d: Add RF read/write ops · e0c27cdb
      Ping-Ke Shih 提交于
      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: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NZong-Zhe Yang <kevin_yang@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200420055054.14592-5-yhchuang@realtek.com
      e0c27cdb
  10. 13 2月, 2020 1 次提交
  11. 26 1月, 2020 1 次提交
  12. 31 10月, 2019 3 次提交
  13. 24 10月, 2019 3 次提交
  14. 02 10月, 2019 1 次提交
  15. 13 9月, 2019 2 次提交
    • T
      rtw88: add dynamic cck pd mechanism · 479c4ee9
      Tzu-En Huang 提交于
      This mechanism reduces the numbers of false alram in cck rate by
      dynamically adjusting the value of power threshold and cs_ratio.
      We determine the new value by three factors, which are rssi, false alarm
      count and igi. Based on these factors, we define the current condition
      into five levels. Compared to the previous level, if the level is changed,
      we set the new values for power threshold and cs_ratio.
      Signed-off-by: NTzu-En Huang <tehuang@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      479c4ee9
    • T
      rtw88: 8822c: add SW DPK support · 5227c2ee
      Tzu-En Huang 提交于
      Power amplifiers are not linear components, and require DPK to
      reduce its nonlinearity. DPK is called Digital Pre-distortion
      Calibration, can be used to compensate the output of power.
      
      DPK tracking is in charge of tracking the thermal changes. And
      it then shifts the power curve accordingly, which makes the
      power output remains linear even if the PA works in different
      temperature.
      
      To perform DPK, the parameter table should also be updated.
      And the table will be applied when device is powered on.
      Then DPK will reference the values to calibrate.
      Signed-off-by: NTzu-En Huang <tehuang@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      5227c2ee
  16. 06 8月, 2019 1 次提交
    • B
      rtw88: use txpwr_lmt_cfg_pair struct, not arrays · 3457f86d
      Brian Norris 提交于
      We're just trusting that these tables are of the right dimensions, when
      we could do better by just using the struct directly. Let's expose the
      struct txpwr_lmt_cfg_pair instead.
      
      The table changes were made by using some Vim macros, so that should
      help prevent any translation mistakes along the way.
      
      Remaining work: get the 'void *data' out of the generic struct
      rtw_table; all of these tables really deserve to be their own data
      structure, with proper type fields.
      Signed-off-by: NBrian Norris <briannorris@chromium.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      3457f86d
  17. 28 6月, 2019 9 次提交
  18. 25 6月, 2019 1 次提交
  19. 28 5月, 2019 3 次提交
    • Y
      rtw88: Make some symbols static · 6aca0977
      YueHaibing 提交于
      Fix sparse warnings:
      
      drivers/net/wireless/realtek/rtw88/phy.c:851:4: warning: symbol 'rtw_cck_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/phy.c:852:4: warning: symbol 'rtw_ofdm_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/phy.c:853:4: warning: symbol 'rtw_ht_1s_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/phy.c:854:4: warning: symbol 'rtw_ht_2s_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/phy.c:855:4: warning: symbol 'rtw_vht_1s_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/phy.c:856:4: warning: symbol 'rtw_vht_2s_size' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/fw.c:11:6: warning: symbol 'rtw_fw_c2h_cmd_handle_ext' was not declared. Should it be static?
      drivers/net/wireless/realtek/rtw88/fw.c:50:6: warning: symbol 'rtw_fw_send_h2c_command' was not declared. Should it be static?
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      6aca0977
    • Y
      rtw88: fix unassigned rssi_level in rtw_sta_info · a24bad74
      Yan-Hsuan Chuang 提交于
      The new rssi_level should be stored in si, otherwise the rssi_level will
      never be updated and get a wrong RA mask, which is calculated by the
      rssi level
      
      If a wrong RA mask is chosen, the firmware will pick some *bad rates*.
      The most hurtful scene will be in *noisy environment*, such as office or
      public area with many APs and users.
      The latency would be high and the overall throughput would be only half
      or less.
      
      Tested in 2.4G in office area, with this patch the throughput increased
      from such as "1x Mbps -> 4x Mbps".
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      a24bad74
    • S
      rtw88: fix subscript above array bounds compiler warning · 8a03447d
      Stanislaw Gruszka 提交于
      My compiler complains about:
      
      drivers/net/wireless/realtek/rtw88/phy.c: In function ‘rtw_phy_rf_power_2_rssi’:
      drivers/net/wireless/realtek/rtw88/phy.c:430:26: warning: array subscript is above array bounds [-Warray-bounds]
        linear = db_invert_table[i][j];
      
      According to comment power_db should be in range 1 ~ 96 .
      To fix add check for boundaries before access the array.
      Signed-off-by: NStanislaw Gruszka <sgruszka@redhat.com>
      Acked-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      8a03447d
  20. 02 5月, 2019 1 次提交
    • G
      rtw88: phy: mark expected switch fall-throughs · aa8eaaaa
      Gustavo A. R. Silva 提交于
      In preparation to enabling -Wimplicit-fallthrough, mark switch
      cases where we are expecting to fall through.
      
      This patch fixes the following warnings:
      
      drivers/net/wireless/realtek/rtw88/phy.c: In function ‘rtw_get_channel_group’:
      ./include/linux/compiler.h:77:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
       # define unlikely(x) __builtin_expect(!!(x), 0)
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      ./include/asm-generic/bug.h:125:2: note: in expansion of macro ‘unlikely’
        unlikely(__ret_warn_on);     \
        ^~~~~~~~
      drivers/net/wireless/realtek/rtw88/phy.c:907:3: note: in expansion of macro ‘WARN_ON’
         WARN_ON(1);
         ^~~~~~~
      drivers/net/wireless/realtek/rtw88/phy.c:908:2: note: here
        case 1:
        ^~~~
      In file included from ./include/linux/bcd.h:5,
                       from drivers/net/wireless/realtek/rtw88/phy.c:5:
      drivers/net/wireless/realtek/rtw88/phy.c: In function ‘phy_get_2g_tx_power_index’:
      ./include/linux/compiler.h:77:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
       # define unlikely(x) __builtin_expect(!!(x), 0)
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      ./include/asm-generic/bug.h:125:2: note: in expansion of macro ‘unlikely’
        unlikely(__ret_warn_on);     \
        ^~~~~~~~
      drivers/net/wireless/realtek/rtw88/phy.c:1021:3: note: in expansion of macro ‘WARN_ON’
         WARN_ON(1);
         ^~~~~~~
      drivers/net/wireless/realtek/rtw88/phy.c:1022:2: note: here
        case RTW_CHANNEL_WIDTH_20:
        ^~~~
      
      Warning level 3 was used: -Wimplicit-fallthrough=3
      
      This patch is part of the ongoing efforts to enable
      -Wimplicit-fallthrough.
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      aa8eaaaa