staging: rtlwifi: delete the staging driver
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 May 2019 08:15:42 +0000 (10:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 May 2019 08:15:42 +0000 (10:15 +0200)
A "real" driver for this hardware is now in the wireless-drivers-next
tree, to be merged in the next major kernel release, so this staging
driver can now be deleted as it is not needed anymore.

Note, 2 .h files remain for this driver, as they are referenced in a
separate staging driver.  That mess will be cleaned up in a follow-on
patch.

Cc: Ping-Ke Shih <pkshih@realtek.com>
Cc: Tzu-En Huang <tehuang@realtek.com>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
181 files changed:
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/rtlwifi/Kconfig [deleted file]
drivers/staging/rtlwifi/Makefile [deleted file]
drivers/staging/rtlwifi/TODO [deleted file]
drivers/staging/rtlwifi/base.c [deleted file]
drivers/staging/rtlwifi/base.h [deleted file]
drivers/staging/rtlwifi/btcoexist/Makefile [deleted file]
drivers/staging/rtlwifi/btcoexist/halbt_precomp.h [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.h [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.c [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822b2ant.h [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.c [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtc8822bwifionly.h [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c [deleted file]
drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.h [deleted file]
drivers/staging/rtlwifi/btcoexist/rtl_btc.c [deleted file]
drivers/staging/rtlwifi/btcoexist/rtl_btc.h [deleted file]
drivers/staging/rtlwifi/cam.c [deleted file]
drivers/staging/rtlwifi/cam.h [deleted file]
drivers/staging/rtlwifi/core.c [deleted file]
drivers/staging/rtlwifi/core.h [deleted file]
drivers/staging/rtlwifi/debug.c [deleted file]
drivers/staging/rtlwifi/debug.h [deleted file]
drivers/staging/rtlwifi/efuse.c [deleted file]
drivers/staging/rtlwifi/efuse.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_2_platform.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_cfg.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_88xx_cfg.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_pcie.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_sdio.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx_usb.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_api.c [deleted file]
drivers/staging/rtlwifi/halmac/halmac_api.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_bit2.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_bit_8822b.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_fw_info.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_fw_offload_c2h_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_fw_offload_h2c_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_h2c_extra_info_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_intf_phy_cmd.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_original_c2h_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_original_h2c_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_pwr_seq_cmd.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_reg2.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_reg_8822b.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_rx_bd_chip.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_rx_bd_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_rx_desc_chip.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_rx_desc_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_sdio_reg.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_tx_bd_chip.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_tx_bd_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_tx_desc_chip.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_tx_desc_nic.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_type.h [deleted file]
drivers/staging/rtlwifi/halmac/halmac_usb_reg.h [deleted file]
drivers/staging/rtlwifi/halmac/rtl_halmac.c [deleted file]
drivers/staging/rtlwifi/halmac/rtl_halmac.h [deleted file]
drivers/staging/rtlwifi/pci.c [deleted file]
drivers/staging/rtlwifi/pci.h [deleted file]
drivers/staging/rtlwifi/phydm/halphyrf_ce.c [deleted file]
drivers/staging/rtlwifi/phydm/halphyrf_ce.h [deleted file]
drivers/staging/rtlwifi/phydm/mp_precomp.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_acs.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_acs.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_adaptivity.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_adaptivity.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_adc_sampling.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_antdiv.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_antdiv.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_beamforming.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_ccx.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_ccx.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_cfotracking.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_cfotracking.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_debug.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_debug.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dfs.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dig.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dig.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dynamic_rx_path.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dynamicbbpowersaving.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_dynamictxpower.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_features.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_hwconfig.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_hwconfig.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_interface.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_interface.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_iqk.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_kfree.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_kfree.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_noisemonitor.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_noisemonitor.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_powertracking_ce.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_pre_define.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_precomp.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_psd.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_psd.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_rainfo.c [deleted file]
drivers/staging/rtlwifi/phydm/phydm_rainfo.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_regdefine11ac.h [deleted file]
drivers/staging/rtlwifi/phydm/phydm_types.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_hal_api8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_iqk_8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_regconfig8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/phydm_rtl8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl8822b/version_rtl8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/rtl_phydm.c [deleted file]
drivers/staging/rtlwifi/phydm/rtl_phydm.h [deleted file]
drivers/staging/rtlwifi/phydm/txbf/halcomtxbf.h [deleted file]
drivers/staging/rtlwifi/phydm/txbf/haltxbf8822b.h [deleted file]
drivers/staging/rtlwifi/phydm/txbf/haltxbfinterface.h [deleted file]
drivers/staging/rtlwifi/phydm/txbf/haltxbfjaguar.h [deleted file]
drivers/staging/rtlwifi/phydm/txbf/phydm_hal_txbf_api.h [deleted file]
drivers/staging/rtlwifi/ps.c [deleted file]
drivers/staging/rtlwifi/ps.h [deleted file]
drivers/staging/rtlwifi/pwrseqcmd.h [deleted file]
drivers/staging/rtlwifi/rc.c [deleted file]
drivers/staging/rtlwifi/rc.h [deleted file]
drivers/staging/rtlwifi/regd.c [deleted file]
drivers/staging/rtlwifi/regd.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/Makefile [deleted file]
drivers/staging/rtlwifi/rtl8822be/def.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/fw.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/fw.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/hw.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/hw.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/led.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/led.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/phy.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/phy.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/reg.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/sw.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/sw.h [deleted file]
drivers/staging/rtlwifi/rtl8822be/trx.c [deleted file]
drivers/staging/rtlwifi/rtl8822be/trx.h [deleted file]
drivers/staging/rtlwifi/stats.c [deleted file]
drivers/staging/rtlwifi/stats.h [deleted file]
drivers/staging/rtlwifi/wifi.h [deleted file]

index 82f1699..36805d5 100644 (file)
@@ -40,8 +40,6 @@ source "drivers/staging/rtl8712/Kconfig"
 
 source "drivers/staging/rtl8188eu/Kconfig"
 
-source "drivers/staging/rtlwifi/Kconfig"
-
 source "drivers/staging/rts5208/Kconfig"
 
 source "drivers/staging/octeon/Kconfig"
index 0640bd6..7da52e8 100644 (file)
@@ -10,7 +10,6 @@ obj-$(CONFIG_RTL8192E)                += rtl8192e/
 obj-$(CONFIG_RTL8723BS)                += rtl8723bs/
 obj-$(CONFIG_R8712U)           += rtl8712/
 obj-$(CONFIG_R8188EU)          += rtl8188eu/
-obj-$(CONFIG_R8822BE)          += rtlwifi/
 obj-$(CONFIG_RTS5208)          += rts5208/
 obj-$(CONFIG_NETLOGIC_XLR_NET) += netlogic/
 obj-$(CONFIG_OCTEON_ETHERNET)  += octeon/
diff --git a/drivers/staging/rtlwifi/Kconfig b/drivers/staging/rtlwifi/Kconfig
deleted file mode 100644 (file)
index f874373..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config R8822BE
-       tristate "Realtek RTL8822BE Wireless Network Adapter"
-       depends on PCI && MAC80211 && m
-       select FW_LOADER
-       help
-       This is the staging driver for Realtek RTL8822BE 802.11ac PCIe
-       wireless network adapters.
-
-config RTLWIFI_DEBUG_ST
-       bool
-       depends on R8822BE
-       default y
diff --git a/drivers/staging/rtlwifi/Makefile b/drivers/staging/rtlwifi/Makefile
deleted file mode 100644 (file)
index b223692..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_R8822BE)          += r8822be.o
-
-r8822be-objs   :=              \
-               base.o          \
-               cam.o           \
-               core.o          \
-               debug.o         \
-               efuse.o         \
-               ps.o            \
-               rc.o            \
-               regd.o          \
-               stats.o         \
-               pci.o           \
-               rtl8822be/fw.o  \
-               rtl8822be/hw.o  \
-               rtl8822be/led.o \
-               rtl8822be/phy.o \
-               rtl8822be/sw.o  \
-               rtl8822be/trx.o \
-               btcoexist/halbtc8822b2ant.o     \
-               btcoexist/halbtc8822b1ant.o     \
-               btcoexist/halbtc8822bwifionly.o \
-               btcoexist/halbtcoutsrc.o        \
-               btcoexist/rtl_btc.o             \
-               halmac/halmac_api.o     \
-               halmac/halmac_88xx/halmac_api_88xx_usb.o        \
-               halmac/halmac_88xx/halmac_api_88xx_sdio.o       \
-               halmac/halmac_88xx/halmac_api_88xx.o    \
-               halmac/halmac_88xx/halmac_api_88xx_pcie.o       \
-               halmac/halmac_88xx/halmac_func_88xx.o   \
-               halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_pcie.o \
-               halmac/halmac_88xx/halmac_8822b/halmac_func_8822b.o     \
-               halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_sdio.o \
-               halmac/halmac_88xx/halmac_8822b/halmac_api_8822b.o      \
-               halmac/halmac_88xx/halmac_8822b/halmac_8822b_phy.o      \
-               halmac/halmac_88xx/halmac_8822b/halmac_8822b_pwr_seq.o  \
-               halmac/halmac_88xx/halmac_8822b/halmac_api_8822b_usb.o  \
-               halmac/rtl_halmac.o                                     \
-               phydm/phydm_debug.o     \
-               phydm/phydm_antdiv.o\
-               phydm/phydm_interface.o\
-               phydm/phydm_hwconfig.o\
-               phydm/phydm.o\
-               phydm/halphyrf_ce.o\
-               phydm/phydm_edcaturbocheck.o\
-               phydm/phydm_dig.o\
-               phydm/phydm_rainfo.o\
-               phydm/phydm_dynamicbbpowersaving.o\
-               phydm/phydm_powertracking_ce.o\
-               phydm/phydm_dynamictxpower.o\
-               phydm/phydm_adaptivity.o\
-               phydm/phydm_cfotracking.o\
-               phydm/phydm_noisemonitor.o\
-               phydm/phydm_acs.o\
-               phydm/phydm_psd.o\
-               phydm/phydm_adc_sampling.o\
-               phydm/phydm_kfree.o\
-               phydm/phydm_ccx.o               \
-               phydm/rtl8822b/halhwimg8822b_bb.o\
-               phydm/rtl8822b/halhwimg8822b_mac.o\
-               phydm/rtl8822b/halhwimg8822b_rf.o\
-               phydm/rtl8822b/halphyrf_8822b.o\
-               phydm/rtl8822b/phydm_hal_api8822b.o\
-               phydm/rtl8822b/phydm_iqk_8822b.o\
-               phydm/rtl8822b/phydm_regconfig8822b.o\
-               phydm/rtl8822b/phydm_rtl8822b.o \
-               phydm/rtl_phydm.o
-
-
-obj-$(CONFIG_R8822BE)                  += rtl8822be/
diff --git a/drivers/staging/rtlwifi/TODO b/drivers/staging/rtlwifi/TODO
deleted file mode 100644 (file)
index 4a084f2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-TODO:
-- find and remove code blocks guarded by never set CONFIG_FOO defines
-- convert any remaining unusual variable types
-- find codes that can use %pM and %Nph formatting
-- checkpatch.pl fixes - most of the remaining ones are lines too long. Many
-  of them will require refactoring
-- merge Realtek's bugfixes and new features into the driver
-- address any reviewers comments
-
-Please send any patches to Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
-and Larry Finger <Larry.Finger@lwfinger.net>.
diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
deleted file mode 100644 (file)
index b8b89e4..0000000
+++ /dev/null
@@ -1,2805 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/******************************************************************************
- *
- * Copyright(c) 2009-2012  Realtek Corporation.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- *
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- *****************************************************************************/
-
-#include "wifi.h"
-#include "rc.h"
-#include "base.h"
-#include "efuse.h"
-#include "cam.h"
-#include "ps.h"
-#include "regd.h"
-#include "pci.h"
-#include <linux/ip.h>
-#include <linux/module.h>
-#include <linux/udp.h>
-
-/*
- *NOTICE!!!: This file will be very big, we should
- *keep it clear under following roles:
- *
- *This file include following parts, so, if you add new
- *functions into this file, please check which part it
- *should includes. or check if you should add new part
- *for this file:
- *
- *1) mac80211 init functions
- *2) tx information functions
- *3) functions called by core.c
- *4) wq & timer callback functions
- *5) frame process functions
- *6) IOT functions
- *7) sysfs functions
- *8) vif functions
- *9) ...
- */
-
-/*********************************************************
- *
- * mac80211 init functions
- *
- *********************************************************/
-static struct ieee80211_channel rtl_channeltable_2g[] = {
-       {.center_freq = 2412, .hw_value = 1,},
-       {.center_freq = 2417, .hw_value = 2,},
-       {.center_freq = 2422, .hw_value = 3,},
-       {.center_freq = 2427, .hw_value = 4,},
-       {.center_freq = 2432, .hw_value = 5,},
-       {.center_freq = 2437, .hw_value = 6,},
-       {.center_freq = 2442, .hw_value = 7,},
-       {.center_freq = 2447, .hw_value = 8,},
-       {.center_freq = 2452, .hw_value = 9,},
-       {.center_freq = 2457, .hw_value = 10,},
-       {.center_freq = 2462, .hw_value = 11,},
-       {.center_freq = 2467, .hw_value = 12,},
-       {.center_freq = 2472, .hw_value = 13,},
-       {.center_freq = 2484, .hw_value = 14,},
-};
-
-static struct ieee80211_channel rtl_channeltable_5g[] = {
-       {.center_freq = 5180, .hw_value = 36,},
-       {.center_freq = 5200, .hw_value = 40,},
-       {.center_freq = 5220, .hw_value = 44,},
-       {.center_freq = 5240, .hw_value = 48,},
-       {.center_freq = 5260, .hw_value = 52,},
-       {.center_freq = 5280, .hw_value = 56,},
-       {.center_freq = 5300, .hw_value = 60,},
-       {.center_freq = 5320, .hw_value = 64,},
-       {.center_freq = 5500, .hw_value = 100,},
-       {.center_freq = 5520, .hw_value = 104,},
-       {.center_freq = 5540, .hw_value = 108,},
-       {.center_freq = 5560, .hw_value = 112,},
-       {.center_freq = 5580, .hw_value = 116,},
-       {.center_freq = 5600, .hw_value = 120,},
-       {.center_freq = 5620, .hw_value = 124,},
-       {.center_freq = 5640, .hw_value = 128,},
-       {.center_freq = 5660, .hw_value = 132,},
-       {.center_freq = 5680, .hw_value = 136,},
-       {.center_freq = 5700, .hw_value = 140,},
-       {.center_freq = 5745, .hw_value = 149,},
-       {.center_freq = 5765, .hw_value = 153,},
-       {.center_freq = 5785, .hw_value = 157,},
-       {.center_freq = 5805, .hw_value = 161,},
-       {.center_freq = 5825, .hw_value = 165,},
-};
-
-static struct ieee80211_rate rtl_ratetable_2g[] = {
-       {.bitrate = 10, .hw_value = 0x00,},
-       {.bitrate = 20, .hw_value = 0x01,},
-       {.bitrate = 55, .hw_value = 0x02,},
-       {.bitrate = 110, .hw_value = 0x03,},
-       {.bitrate = 60, .hw_value = 0x04,},
-       {.bitrate = 90, .hw_value = 0x05,},
-       {.bitrate = 120, .hw_value = 0x06,},
-       {.bitrate = 180, .hw_value = 0x07,},
-       {.bitrate = 240, .hw_value = 0x08,},
-       {.bitrate = 360, .hw_value = 0x09,},
-       {.bitrate = 480, .hw_value = 0x0a,},
-       {.bitrate = 540, .hw_value = 0x0b,},
-};
-
-static struct ieee80211_rate rtl_ratetable_5g[] = {
-       {.bitrate = 60, .hw_value = 0x04,},
-       {.bitrate = 90, .hw_value = 0x05,},
-       {.bitrate = 120, .hw_value = 0x06,},
-       {.bitrate = 180, .hw_value = 0x07,},
-       {.bitrate = 240, .hw_value = 0x08,},
-       {.bitrate = 360, .hw_value = 0x09,},
-       {.bitrate = 480, .hw_value = 0x0a,},
-       {.bitrate = 540, .hw_value = 0x0b,},
-};
-
-static const struct ieee80211_supported_band rtl_band_2ghz = {
-       .band = NL80211_BAND_2GHZ,
-
-       .channels = rtl_channeltable_2g,
-       .n_channels = ARRAY_SIZE(rtl_channeltable_2g),
-
-       .bitrates = rtl_ratetable_2g,
-       .n_bitrates = ARRAY_SIZE(rtl_ratetable_2g),
-
-       .ht_cap = {0},
-};
-
-static struct ieee80211_supported_band rtl_band_5ghz = {
-       .band = NL80211_BAND_5GHZ,
-
-       .channels = rtl_channeltable_5g,
-       .n_channels = ARRAY_SIZE(rtl_channeltable_5g),
-
-       .bitrates = rtl_ratetable_5g,
-       .n_bitrates = ARRAY_SIZE(rtl_ratetable_5g),
-
-       .ht_cap = {0},
-};
-
-static const u8 tid_to_ac[] = {
-       2, /* IEEE80211_AC_BE */
-       3, /* IEEE80211_AC_BK */
-       3, /* IEEE80211_AC_BK */
-       2, /* IEEE80211_AC_BE */
-       1, /* IEEE80211_AC_VI */
-       1, /* IEEE80211_AC_VI */
-       0, /* IEEE80211_AC_VO */
-       0, /* IEEE80211_AC_VO */
-};
-
-u8 rtl_tid_to_ac(u8 tid)
-{
-       return tid_to_ac[tid];
-}
-
-static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
-                                 struct ieee80211_sta_ht_cap *ht_cap)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_phy *rtlphy = &rtlpriv->phy;
-
-       ht_cap->ht_supported = true;
-       ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-           IEEE80211_HT_CAP_SGI_40 |
-           IEEE80211_HT_CAP_SGI_20 |
-           IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU;
-
-       if (rtlpriv->rtlhal.disable_amsdu_8k)
-               ht_cap->cap &= ~IEEE80211_HT_CAP_MAX_AMSDU;
-
-       /*
-        *Maximum length of AMPDU that the STA can receive.
-        *Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
-        */
-       ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
-
-       /*Minimum MPDU start spacing , */
-       ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_16;
-
-       ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
-
-       /*hw->wiphy->bands[NL80211_BAND_2GHZ]
-        *base on ant_num
-        *rx_mask: RX mask
-        *if rx_ant = 1 rx_mask[0]= 0xff;==>MCS0-MCS7
-        *if rx_ant = 2 rx_mask[1]= 0xff;==>MCS8-MCS15
-        *if rx_ant >= 3 rx_mask[2]= 0xff;
-        *if BW_40 rx_mask[4]= 0x01;
-        *highest supported RX rate
-        */
-       if (rtlpriv->dm.supp_phymode_switch) {
-               pr_info("Support phy mode switch\n");
-
-               ht_cap->mcs.rx_mask[0] = 0xFF;
-               ht_cap->mcs.rx_mask[1] = 0xFF;
-               ht_cap->mcs.rx_mask[4] = 0x01;
-
-               ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
-       } else {
-               if (get_rf_type(rtlphy) == RF_1T2R ||
-                   get_rf_type(rtlphy) == RF_2T2R) {
-                       RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-                                "1T2R or 2T2R\n");
-                       ht_cap->mcs.rx_mask[0] = 0xFF;
-                       ht_cap->mcs.rx_mask[1] = 0xFF;
-                       ht_cap->mcs.rx_mask[4] = 0x01;
-
-                       ht_cap->mcs.rx_highest =
-                                cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
-               } else if (get_rf_type(rtlphy) == RF_1T1R) {
-                       RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T1R\n");
-
-                       ht_cap->mcs.rx_mask[0] = 0xFF;
-                       ht_cap->mcs.rx_mask[1] = 0x00;
-                       ht_cap->mcs.rx_mask[4] = 0x01;
-
-                       ht_cap->mcs.rx_highest =
-                                cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7);
-               }
-       }
-}
-
-static void _rtl_init_hw_vht_capab(struct ieee80211_hw *hw,
-                                  struct ieee80211_sta_vht_cap *vht_cap)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
-
-       if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE ||
-           rtlhal->hw_type == HARDWARE_TYPE_RTL8822BE) {
-               u16 mcs_map;
-
-               vht_cap->vht_supported = true;
-               vht_cap->cap =
-                       IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
-                       IEEE80211_VHT_CAP_SHORT_GI_80 |
-                       IEEE80211_VHT_CAP_TXSTBC |
-                       IEEE80211_VHT_CAP_RXSTBC_1 |
-                       IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
-                       IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
-                       IEEE80211_VHT_CAP_HTC_VHT |
-                       IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
-                       IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN |
-                       IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN |
-                       0;
-
-               mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 |
-                       IEEE80211_VHT_MCS_SUPPORT_0_9 << 2 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 14;
-
-               vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
-               vht_cap->vht_mcs.rx_highest =
-                       cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9);
-               vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
-               vht_cap->vht_mcs.tx_highest =
-                       cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9);
-       } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
-               u16 mcs_map;
-
-               vht_cap->vht_supported = true;
-               vht_cap->cap =
-                       IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
-                       IEEE80211_VHT_CAP_SHORT_GI_80 |
-                       IEEE80211_VHT_CAP_TXSTBC |
-                       IEEE80211_VHT_CAP_RXSTBC_1 |
-                       IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
-                       IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
-                       IEEE80211_VHT_CAP_HTC_VHT |
-                       IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
-                       IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN |
-                       IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN |
-                       0;
-
-               mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 2 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 |
-                       IEEE80211_VHT_MCS_NOT_SUPPORTED << 14;
-
-               vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
-               vht_cap->vht_mcs.rx_highest =
-                       cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9);
-               vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
-               vht_cap->vht_mcs.tx_highest =
-                       cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9);
-       }
-}
-
-static void _rtl_init_mac80211(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
-       struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
-       struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
-       struct ieee80211_supported_band *sband;
-
-       if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY &&
-           rtlhal->bandset == BAND_ON_BOTH) {
-               /* 1: 2.4 G bands */
-               /* <1> use  mac->bands as mem for hw->wiphy->bands */
-               sband = &rtlmac->bands[NL80211_BAND_2GHZ];
-
-               /* <2> set hw->wiphy->bands[NL80211_BAND_2GHZ]
-                * to default value(1T1R)
-                */
-               memcpy(&rtlmac->bands[NL80211_BAND_2GHZ], &rtl_band_2ghz,
-                      sizeof(struct ieee80211_supported_band));
-
-               /* <3> init ht cap base on ant_num */
-               _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
-
-               /* <4> set mac->sband to wiphy->sband */
-               hw->wiphy->bands[NL80211_BAND_2GHZ] = sband;
-
-               /* 2: 5 G bands */
-               /* <1> use  mac->bands as mem for hw->wiphy->bands */
-               sband = &rtlmac->bands[NL80211_BAND_5GHZ];
-
-               /* <2> set hw->wiphy->bands[NL80211_BAND_5GHZ]
-                * to default value(1T1R)
-                */
-               memcpy(&rtlmac->bands[NL80211_BAND_5GHZ], &rtl_band_5ghz,
-                      sizeof(struct ieee80211_supported_band));
-
-               /* <3> init ht cap base on ant_num */
-               _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
-
-               _rtl_init_hw_vht_capab(hw, &sband->vht_cap);
-               /* <4> set mac->sband to wiphy->sband */
-               hw->wiphy->bands[NL80211_BAND_5GHZ] = sband;
-       } else {
-               if (rtlhal->current_bandtype == BAND_ON_2_4G) {
-                       /* <1> use  mac->bands as mem for hw->wiphy->bands */
-                       sband = &rtlmac->bands[NL80211_BAND_2GHZ];
-
-                       /* <2> set hw->wiphy->bands[NL80211_BAND_2GHZ]
-                        * to default value(1T1R)
-                        */
-                       memcpy(&rtlmac->bands[NL80211_BAND_2GHZ],
-                              &rtl_band_2ghz,
-                              sizeof(struct ieee80211_supported_band));
-
-                       /* <3> init ht cap base on ant_num */
-                       _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
-
-                       /* <4> set mac->sband to wiphy->sband */
-                       hw->wiphy->bands[NL80211_BAND_2GHZ] = sband;
-               } else if (rtlhal->current_bandtype == BAND_ON_5G) {
-                       /* <1> use  mac->bands as mem for hw->wiphy->bands */
-                       sband = &rtlmac->bands[NL80211_BAND_5GHZ];
-
-                       /* <2> set hw->wiphy->bands[NL80211_BAND_5GHZ]
-                        * to default value(1T1R)
-                        */
-                       memcpy(&rtlmac->bands[NL80211_BAND_5GHZ],
-                              &rtl_band_5ghz,
-                              sizeof(struct ieee80211_supported_band));
-
-                       /* <3> init ht cap base on ant_num */
-                       _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
-
-                       _rtl_init_hw_vht_capab(hw, &sband->vht_cap);
-                       /* <4> set mac->sband to wiphy->sband */
-                       hw->wiphy->bands[NL80211_BAND_5GHZ] = sband;
-               } else {
-                       pr_err("Err BAND %d\n",
-                              rtlhal->current_bandtype);
-               }
-       }
-       /* <5> set hw caps */
-       ieee80211_hw_set(hw, SIGNAL_DBM);
-       ieee80211_hw_set(hw, RX_INCLUDES_FCS);
-       ieee80211_hw_set(hw, AMPDU_AGGREGATION);
-       ieee80211_hw_set(hw, CONNECTION_MONITOR);
-       ieee80211_hw_set(hw, MFP_CAPABLE);
-       ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
-       ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
-       ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
-       ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
-
-       /* swlps or hwlps has been set in diff chip in init_sw_vars */
-       if (rtlpriv->psc.swctrl_lps) {
-               ieee80211_hw_set(hw, SUPPORTS_PS);
-               ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
-       }
-       if (rtlpriv->psc.fwctrl_lps) {
-               ieee80211_hw_set(hw, SUPPORTS_PS);
-               ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
-       }
-       hw->wiphy->interface_modes =
-           BIT(NL80211_IFTYPE_AP) |
-           BIT(NL80211_IFTYPE_STATION) |
-           BIT(NL80211_IFTYPE_ADHOC) |
-           BIT(NL80211_IFTYPE_MESH_POINT) |
-           BIT(NL80211_IFTYPE_P2P_CLIENT) |
-           BIT(NL80211_IFTYPE_P2P_GO);
-       hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
-
-       hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
-
-       hw->wiphy->rts_threshold = 2347;
-
-       hw->queues = AC_MAX;
-       hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
-
-       /* TODO: Correct this value for our hw */
-       hw->max_listen_interval = MAX_LISTEN_INTERVAL;
-       hw->max_rate_tries = MAX_RATE_TRIES;
-       /* hw->max_rates = 1; */
-       hw->sta_data_size = sizeof(struct rtl_sta_info);
-
-/* wowlan is not supported by kernel if CONFIG_PM is not defined */
-#ifdef CONFIG_PM
-       if (rtlpriv->psc.wo_wlan_mode) {
-               if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_MAGIC_PACKET)
-                       rtlpriv->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT;
-               if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_PATTERN_MATCH) {
-                       rtlpriv->wowlan.n_patterns =
-                               MAX_SUPPORT_WOL_PATTERN_NUM;
-                       rtlpriv->wowlan.pattern_min_len = MIN_WOL_PATTERN_SIZE;
-                       rtlpriv->wowlan.pattern_max_len = MAX_WOL_PATTERN_SIZE;
-               }
-               hw->wiphy->wowlan = &rtlpriv->wowlan;
-       }
-#endif
-
-       /* <6> mac address */
-       if (is_valid_ether_addr(rtlefuse->dev_addr)) {
-               SET_IEEE80211_PERM_ADDR(hw, rtlefuse->dev_addr);
-       } else {
-               u8 rtlmac1[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 };
-
-               get_random_bytes((rtlmac1 + (ETH_ALEN - 1)), 1);
-               SET_IEEE80211_PERM_ADDR(hw, rtlmac1);
-       }
-}
-
-static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-       /* <1> timer */
-       timer_setup(&rtlpriv->works.watchdog_timer,
-                   rtl_watch_dog_timer_callback, 0);
-       timer_setup(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
-                   rtl_easy_concurrent_retrytimer_callback, 0);
-       /* <2> work queue */
-       rtlpriv->works.hw = hw;
-       rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
-       INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
-                         (void *)rtl_watchdog_wq_callback);
-       INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
-                         (void *)rtl_ips_nic_off_wq_callback);
-       INIT_DELAYED_WORK(&rtlpriv->works.ps_work,
-                         (void *)rtl_swlps_wq_callback);
-       INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq,
-                         (void *)rtl_swlps_rfon_wq_callback);
-       INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq,
-                         (void *)rtl_fwevt_wq_callback);
-       INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq,
-                         (void *)rtl_c2hcmd_wq_callback);
-}
-
-void rtl_deinit_deferred_work(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-       del_timer_sync(&rtlpriv->works.watchdog_timer);
-
-       cancel_delayed_work(&rtlpriv->works.watchdog_wq);
-       cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
-       cancel_delayed_work(&rtlpriv->works.ps_work);
-       cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
-       cancel_delayed_work(&rtlpriv->works.fwevt_wq);
-       cancel_delayed_work(&rtlpriv->works.c2hcmd_wq);
-}
-
-void rtl_init_rfkill(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-       bool radio_state;
-       bool blocked;
-       u8 valid = 0;
-
-       /*set init state to on */
-       rtlpriv->rfkill.rfkill_state = true;
-       wiphy_rfkill_set_hw_state(hw->wiphy, 0);
-
-       radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
-
-       if (valid) {
-               pr_info("rtlwifi: wireless switch is %s\n",
-                       rtlpriv->rfkill.rfkill_state ? "on" : "off");
-
-               rtlpriv->rfkill.rfkill_state = radio_state;
-
-               blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
-               wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
-       }
-
-       wiphy_rfkill_start_polling(hw->wiphy);
-}
-
-void rtl_deinit_rfkill(struct ieee80211_hw *hw)
-{
-       wiphy_rfkill_stop_polling(hw->wiphy);
-}
-
-int rtl_init_core(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
-
-       /* <1> init mac80211 */
-       _rtl_init_mac80211(hw);
-       rtlmac->hw = hw;
-
-       /* <2> rate control register */
-       hw->rate_control_algorithm = "rtl_rc";
-
-       /*
-        * <3> init CRDA must come after init
-        * mac80211 hw  in _rtl_init_mac80211.
-        */
-       if (rtl_regd_init(hw, rtl_reg_notifier)) {
-               pr_err("REGD init failed\n");
-               return 1;
-       }
-
-       /* <4> locks */
-       mutex_init(&rtlpriv->locks.conf_mutex);
-       mutex_init(&rtlpriv->locks.ips_mutex);
-       mutex_init(&rtlpriv->locks.lps_mutex);
-       spin_lock_init(&rtlpriv->locks.irq_th_lock);
-       spin_lock_init(&rtlpriv->locks.h2c_lock);
-       spin_lock_init(&rtlpriv->locks.rf_ps_lock);
-       spin_lock_init(&rtlpriv->locks.rf_lock);
-       spin_lock_init(&rtlpriv->locks.waitq_lock);
-       spin_lock_init(&rtlpriv->locks.entry_list_lock);
-       spin_lock_init(&rtlpriv->locks.c2hcmd_lock);
-       spin_lock_init(&rtlpriv->locks.scan_list_lock);
-       spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock);
-       spin_lock_init(&rtlpriv->locks.fw_ps_lock);
-       spin_lock_init(&rtlpriv->locks.iqk_lock);
-       /* <5> init list */
-       INIT_LIST_HEAD(&rtlpriv->entry_list);
-       INIT_LIST_HEAD(&rtlpriv->c2hcmd_list);
-       INIT_LIST_HEAD(&rtlpriv->scan_list.list);
-
-       rtlmac->link_state = MAC80211_NOLINK;
-
-       /* <6> init deferred work */
-       _rtl_init_deferred_work(hw);
-
-       return 0;
-}
-
-static void rtl_free_entries_from_scan_list(struct ieee80211_hw *hw);
-
-void rtl_deinit_core(struct ieee80211_hw *hw)
-{
-       rtl_c2hcmd_launcher(hw, 0);
-       rtl_free_entries_from_scan_list(hw);
-}
-
-void rtl_init_rx_config(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-
-       rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)&mac->rx_conf);
-}
-
-/*********************************************************
- *
- * tx information functions
- *
- *********************************************************/
-static void _rtl_qurey_shortpreamble_mode(struct ieee80211_hw *hw,
-                                         struct rtl_tcb_desc *tcb_desc,
-                                         struct ieee80211_tx_info *info)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       u8 rate_flag = info->control.rates[0].flags;
-
-       tcb_desc->use_shortpreamble = false;
-
-       /* 1M can only use Long Preamble. 11B spec */
-       if (tcb_desc->hw_rate == rtlpriv->cfg->maps[RTL_RC_CCK_RATE1M])
-               return;
-       else if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
-               tcb_desc->use_shortpreamble = true;
-}
-
-static void _rtl_query_shortgi(struct ieee80211_hw *hw,
-                              struct ieee80211_sta *sta,
-                              struct rtl_tcb_desc *tcb_desc,
-                              struct ieee80211_tx_info *info)
-{
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       u8 rate_flag = info->control.rates[0].flags;
-       u8 sgi_40 = 0, sgi_20 = 0, bw_40 = 0;
-       u8 sgi_80 = 0, bw_80 = 0;
-
-       tcb_desc->use_shortgi = false;
-
-       if (!sta)
-               return;
-
-       sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
-       sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
-       sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80;
-
-       if (!sta->ht_cap.ht_supported && !sta->vht_cap.vht_supported)
-               return;
-
-       if (!sgi_40 && !sgi_20)
-               return;
-
-       if (mac->opmode == NL80211_IFTYPE_STATION) {
-               bw_40 = mac->bw_40;
-               bw_80 = mac->bw_80;
-       } else if (mac->opmode == NL80211_IFTYPE_AP ||
-                mac->opmode == NL80211_IFTYPE_ADHOC ||
-                mac->opmode == NL80211_IFTYPE_MESH_POINT) {
-               bw_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
-               bw_80 = sta->vht_cap.vht_supported;
-       }
-
-       if (bw_80) {
-               if (sgi_80)
-                       tcb_desc->use_shortgi = true;
-               else
-                       tcb_desc->use_shortgi = false;
-       } else {
-               if (bw_40 && sgi_40)
-                       tcb_desc->use_shortgi = true;
-               else if (!bw_40 && sgi_20)
-                       tcb_desc->use_shortgi = true;
-       }
-
-       if (!(rate_flag & IEEE80211_TX_RC_SHORT_GI))
-               tcb_desc->use_shortgi = false;
-}
-
-static void _rtl_query_protection_mode(struct ieee80211_hw *hw,
-                                      struct rtl_tcb_desc *tcb_desc,
-                                      struct ieee80211_tx_info *info)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       u8 rate_flag = info->control.rates[0].flags;
-
-       /* Common Settings */
-       tcb_desc->rts_stbc = false;
-       tcb_desc->cts_enable = false;
-       tcb_desc->rts_sc = 0;
-       tcb_desc->rts_bw = false;
-       tcb_desc->rts_use_shortpreamble = false;
-       tcb_desc->rts_use_shortgi = false;
-
-       if (rate_flag & IEEE80211_TX_RC_USE_CTS_PROTECT) {
-               /* Use CTS-to-SELF in protection mode. */
-               tcb_desc->rts_enable = true;
-               tcb_desc->cts_enable = true;
-               tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M];
-       } else if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
-               /* Use RTS-CTS in protection mode. */
-               tcb_desc->rts_enable = true;
-               tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M];
-       }
-}
-
-u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw, u8 rate_index,
-                           enum wireless_mode wirelessmode)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_phy *rtlphy = &rtlpriv->phy;
-       u8 ret = 0;
-
-       switch (rate_index) {
-       case RATR_INX_WIRELESS_NGB:
-               if (rtlphy->rf_type == RF_1T1R)
-                       ret = RATEID_IDX_BGN_40M_1SS;
-               else
-                       ret = RATEID_IDX_BGN_40M_2SS;
-               break;
-       case RATR_INX_WIRELESS_N:
-       case RATR_INX_WIRELESS_NG:
-               if (rtlphy->rf_type == RF_1T1R)
-                       ret = RATEID_IDX_GN_N1SS;
-               else
-                       ret = RATEID_IDX_GN_N2SS;
-               break;
-       case RATR_INX_WIRELESS_NB:
-               if (rtlphy->rf_type == RF_1T1R)
-                       ret = RATEID_IDX_BGN_20M_1SS_BN;
-               else
-                       ret = RATEID_IDX_BGN_20M_2SS_BN;
-               break;
-       case RATR_INX_WIRELESS_GB:
-               ret = RATEID_IDX_BG;
-               break;
-       case RATR_INX_WIRELESS_G:
-               ret = RATEID_IDX_G;
-               break;
-       case RATR_INX_WIRELESS_B:
-               ret = RATEID_IDX_B;
-               break;
-       case RATR_INX_WIRELESS_MC:
-               if (wirelessmode == WIRELESS_MODE_B ||
-                   wirelessmode == WIRELESS_MODE_G ||
-                   wirelessmode == WIRELESS_MODE_N_24G ||
-                   wirelessmode == WIRELESS_MODE_AC_24G)
-                       ret = RATEID_IDX_BG;
-               else
-                       ret = RATEID_IDX_G;
-               break;
-       case RATR_INX_WIRELESS_AC_5N:
-               if (rtlphy->rf_type == RF_1T1R)
-                       ret = RATEID_IDX_VHT_1SS;
-               else
-                       ret = RATEID_IDX_VHT_2SS;
-               break;
-       case RATR_INX_WIRELESS_AC_24N:
-               if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_80) {
-                       if (rtlphy->rf_type == RF_1T1R)
-                               ret = RATEID_IDX_VHT_1SS;
-                       else
-                               ret = RATEID_IDX_VHT_2SS;
-               } else {
-                       if (rtlphy->rf_type == RF_1T1R)
-                               ret = RATEID_IDX_MIX1;
-                       else
-                               ret = RATEID_IDX_MIX2;
-               }
-               break;
-       default:
-               ret = RATEID_IDX_BGN_40M_2SS;
-               break;
-       }
-       return ret;
-}
-
-static inline u8 _rtl_rate_id(struct ieee80211_hw *hw,
-                             struct rtl_sta_info *sta_entry,
-                             int rate_index)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-       if (rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) {
-               int wireless_mode = sta_entry ?
-                       sta_entry->wireless_mode : WIRELESS_MODE_G;
-
-               return rtl_mrate_idx_to_arfr_id(hw, rate_index, wireless_mode);
-       } else {
-               return rate_index;
-       }
-}
-
-static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
-                                  struct ieee80211_sta *sta,
-                                  struct rtl_tcb_desc *tcb_desc)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       struct rtl_sta_info *sta_entry = NULL;
-       u8 ratr_index = _rtl_rate_id(hw, sta_entry, RATR_INX_WIRELESS_MC);
-
-       if (sta) {
-               sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-               ratr_index = sta_entry->ratr_index;
-       }
-       if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) {
-               if (mac->opmode == NL80211_IFTYPE_STATION) {
-                       tcb_desc->ratr_index = 0;
-               } else if (mac->opmode == NL80211_IFTYPE_ADHOC ||
-                               mac->opmode == NL80211_IFTYPE_MESH_POINT) {
-                       if (tcb_desc->multicast || tcb_desc->broadcast) {
-                               tcb_desc->hw_rate =
-                                   rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M];
-                               tcb_desc->use_driver_rate = 1;
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_MC);
-                       } else {
-                               tcb_desc->ratr_index = ratr_index;
-                       }
-               } else if (mac->opmode == NL80211_IFTYPE_AP) {
-                       tcb_desc->ratr_index = ratr_index;
-               }
-       }
-
-       if (rtlpriv->dm.useramask) {
-               tcb_desc->ratr_index = ratr_index;
-               /* TODO we will differentiate adhoc and station future  */
-               if (mac->opmode == NL80211_IFTYPE_STATION ||
-                   mac->opmode == NL80211_IFTYPE_MESH_POINT) {
-                       tcb_desc->mac_id = 0;
-
-                       if (sta &&
-                           (rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID))
-                               ;       /* use sta_entry->ratr_index */
-                       else if (mac->mode == WIRELESS_MODE_AC_5G)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_AC_5N);
-                       else if (mac->mode == WIRELESS_MODE_AC_24G)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_AC_24N);
-                       else if (mac->mode == WIRELESS_MODE_N_24G)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_NGB);
-                       else if (mac->mode == WIRELESS_MODE_N_5G)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_NG);
-                       else if (mac->mode & WIRELESS_MODE_G)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_GB);
-                       else if (mac->mode & WIRELESS_MODE_B)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_B);
-                       else if (mac->mode & WIRELESS_MODE_A)
-                               tcb_desc->ratr_index =
-                                       _rtl_rate_id(hw, sta_entry,
-                                                    RATR_INX_WIRELESS_G);
-
-               } else if (mac->opmode == NL80211_IFTYPE_AP ||
-                       mac->opmode == NL80211_IFTYPE_ADHOC) {
-                       if (sta) {
-                               if (sta->aid > 0)
-                                       tcb_desc->mac_id = sta->aid + 1;
-                               else
-                                       tcb_desc->mac_id = 1;
-                       } else {
-                               tcb_desc->mac_id = 0;
-                       }
-               }
-       }
-}
-
-static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw,
-                                     struct ieee80211_sta *sta,
-                                     struct rtl_tcb_desc *tcb_desc)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-
-       tcb_desc->packet_bw = false;
-       if (!sta)
-               return;
-       if (mac->opmode == NL80211_IFTYPE_AP ||
-           mac->opmode == NL80211_IFTYPE_ADHOC ||
-           mac->opmode == NL80211_IFTYPE_MESH_POINT) {
-               if (!(sta->ht_cap.ht_supported) ||
-                   !(sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
-                       return;
-       } else if (mac->opmode == NL80211_IFTYPE_STATION) {
-               if (!mac->bw_40 || !(sta->ht_cap.ht_supported))
-                       return;
-       }
-       if (tcb_desc->multicast || tcb_desc->broadcast)
-               return;
-
-       /*use legency rate, shall use 20MHz */
-       if (tcb_desc->hw_rate <= rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M])
-               return;
-
-       tcb_desc->packet_bw = HT_CHANNEL_WIDTH_20_40;
-
-       if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE ||
-           rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8821AE ||
-           (rtlpriv->cfg->spec_ver & RTL_SPEC_SUPPORT_VHT)) {
-               if (mac->opmode == NL80211_IFTYPE_AP ||
-                   mac->opmode == NL80211_IFTYPE_ADHOC ||
-                   mac->opmode == NL80211_IFTYPE_MESH_POINT) {
-                       if (!(sta->vht_cap.vht_supported))
-                               return;
-               } else if (mac->opmode == NL80211_IFTYPE_STATION) {
-                       if (!mac->bw_80 ||
-                           !(sta->vht_cap.vht_supported))
-                               return;
-               }
-               if (tcb_desc->hw_rate <=
-                       rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15])
-                       return;
-               tcb_desc->packet_bw = HT_CHANNEL_WIDTH_80;
-       }
-}
-
-static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw,
-                                     struct ieee80211_sta *sta)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_phy *rtlphy = &rtlpriv->phy;
-       u8 hw_rate;
-       u16 tx_mcs_map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
-
-       if ((get_rf_type(rtlphy) == RF_2T2R) &&
-           (tx_mcs_map & 0x000c) != 0x000c) {
-               if ((tx_mcs_map & 0x000c) >> 2 ==
-                       IEEE80211_VHT_MCS_SUPPORT_0_7)
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7];
-               else if ((tx_mcs_map  & 0x000c) >> 2 ==
-                       IEEE80211_VHT_MCS_SUPPORT_0_8)
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS8];
-               else
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
-       } else {
-               if ((tx_mcs_map  & 0x0003) ==
-                       IEEE80211_VHT_MCS_SUPPORT_0_7)
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS7];
-               else if ((tx_mcs_map  & 0x0003) ==
-                       IEEE80211_VHT_MCS_SUPPORT_0_8)
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS8];
-               else
-                       hw_rate =
-                       rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
-       }
-
-       return hw_rate;
-}
-
-static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
-                                 struct ieee80211_sta *sta)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_phy *rtlphy = &rtlpriv->phy;
-       u8 hw_rate;
-
-       if (get_rf_type(rtlphy) == RF_2T2R &&
-           sta->ht_cap.mcs.rx_mask[1] != 0)
-               hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15];
-       else
-               hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7];
-
-       return hw_rate;
-}
-
-/* mac80211's rate_idx is like this:
- *
- * 2.4G band:rx_status->band == NL80211_BAND_2GHZ
- *
- * B/G rate:
- * (rx_status->flag & RX_FLAG_HT) = 0,
- * DESC_RATE1M-->DESC_RATE54M ==> idx is 0-->11,
- *
- * N rate:
- * (rx_status->flag & RX_FLAG_HT) = 1,
- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
- *
- * 5G band:rx_status->band == NL80211_BAND_5GHZ
- * A rate:
- * (rx_status->flag & RX_FLAG_HT) = 0,
- * DESC_RATE6M-->DESC_RATE54M ==> idx is 0-->7,
- *
- * N rate:
- * (rx_status->flag & RX_FLAG_HT) = 1,
- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
- *
- * VHT rates:
- * DESC_RATEVHT1SS_MCS0-->DESC_RATEVHT1SS_MCS9 ==> idx is 0-->9
- * DESC_RATEVHT2SS_MCS0-->DESC_RATEVHT2SS_MCS9 ==> idx is 0-->9
- */
-int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, bool isvht,
-                        u8 desc_rate)
-{
-       int rate_idx;
-
-       if (isvht) {
-               switch (desc_rate) {
-               case DESC_RATEVHT1SS_MCS0:
-                       rate_idx = 0;
-                       break;
-               case DESC_RATEVHT1SS_MCS1:
-                       rate_idx = 1;
-                       break;
-               case DESC_RATEVHT1SS_MCS2:
-                       rate_idx = 2;
-                       break;
-               case DESC_RATEVHT1SS_MCS3:
-                       rate_idx = 3;
-                       break;
-               case DESC_RATEVHT1SS_MCS4:
-                       rate_idx = 4;
-                       break;
-               case DESC_RATEVHT1SS_MCS5:
-                       rate_idx = 5;
-                       break;
-               case DESC_RATEVHT1SS_MCS6:
-                       rate_idx = 6;
-                       break;
-               case DESC_RATEVHT1SS_MCS7:
-                       rate_idx = 7;
-                       break;
-               case DESC_RATEVHT1SS_MCS8:
-                       rate_idx = 8;
-                       break;
-               case DESC_RATEVHT1SS_MCS9:
-                       rate_idx = 9;
-                       break;
-               case DESC_RATEVHT2SS_MCS0:
-                       rate_idx = 0;
-                       break;
-               case DESC_RATEVHT2SS_MCS1:
-                       rate_idx = 1;
-                       break;
-               case DESC_RATEVHT2SS_MCS2:
-                       rate_idx = 2;
-                       break;
-               case DESC_RATEVHT2SS_MCS3:
-                       rate_idx = 3;
-                       break;
-               case DESC_RATEVHT2SS_MCS4:
-                       rate_idx = 4;
-                       break;
-               case DESC_RATEVHT2SS_MCS5:
-                       rate_idx = 5;
-                       break;
-               case DESC_RATEVHT2SS_MCS6:
-                       rate_idx = 6;
-                       break;
-               case DESC_RATEVHT2SS_MCS7:
-                       rate_idx = 7;
-                       break;
-               case DESC_RATEVHT2SS_MCS8:
-                       rate_idx = 8;
-                       break;
-               case DESC_RATEVHT2SS_MCS9:
-                       rate_idx = 9;
-                       break;
-               default:
-                       rate_idx = 0;
-                       break;
-               }
-               return rate_idx;
-       }
-       if (!isht) {
-               if (hw->conf.chandef.chan->band == NL80211_BAND_2GHZ) {
-                       switch (desc_rate) {
-                       case DESC_RATE1M:
-                               rate_idx = 0;
-                               break;
-                       case DESC_RATE2M:
-                               rate_idx = 1;
-                               break;
-                       case DESC_RATE5_5M:
-                               rate_idx = 2;
-                               break;
-                       case DESC_RATE11M:
-                               rate_idx = 3;
-                               break;
-                       case DESC_RATE6M:
-                               rate_idx = 4;
-                               break;
-                       case DESC_RATE9M:
-                               rate_idx = 5;
-                               break;
-                       case DESC_RATE12M:
-                               rate_idx = 6;
-                               break;
-                       case DESC_RATE18M:
-                               rate_idx = 7;
-                               break;
-                       case DESC_RATE24M:
-                               rate_idx = 8;
-                               break;
-                       case DESC_RATE36M:
-                               rate_idx = 9;
-                               break;
-                       case DESC_RATE48M:
-                               rate_idx = 10;
-                               break;
-                       case DESC_RATE54M:
-                               rate_idx = 11;
-                               break;
-                       default:
-                               rate_idx = 0;
-                               break;
-                       }
-               } else {
-                       switch (desc_rate) {
-                       case DESC_RATE6M:
-                               rate_idx = 0;
-                               break;
-                       case DESC_RATE9M:
-                               rate_idx = 1;
-                               break;
-                       case DESC_RATE12M:
-                               rate_idx = 2;
-                               break;
-                       case DESC_RATE18M:
-                               rate_idx = 3;
-                               break;
-                       case DESC_RATE24M:
-                               rate_idx = 4;
-                               break;
-                       case DESC_RATE36M:
-                               rate_idx = 5;
-                               break;
-                       case DESC_RATE48M:
-                               rate_idx = 6;
-                               break;
-                       case DESC_RATE54M:
-                               rate_idx = 7;
-                               break;
-                       default:
-                               rate_idx = 0;
-                               break;
-                       }
-               }
-       } else {
-               switch (desc_rate) {
-               case DESC_RATEMCS0:
-                       rate_idx = 0;
-                       break;
-               case DESC_RATEMCS1:
-                       rate_idx = 1;
-                       break;
-               case DESC_RATEMCS2:
-                       rate_idx = 2;
-                       break;
-               case DESC_RATEMCS3:
-                       rate_idx = 3;
-                       break;
-               case DESC_RATEMCS4:
-                       rate_idx = 4;
-                       break;
-               case DESC_RATEMCS5:
-                       rate_idx = 5;
-                       break;
-               case DESC_RATEMCS6:
-                       rate_idx = 6;
-                       break;
-               case DESC_RATEMCS7:
-                       rate_idx = 7;
-                       break;
-               case DESC_RATEMCS8:
-                       rate_idx = 8;
-                       break;
-               case DESC_RATEMCS9:
-                       rate_idx = 9;
-                       break;
-               case DESC_RATEMCS10:
-                       rate_idx = 10;
-                       break;
-               case DESC_RATEMCS11:
-                       rate_idx = 11;
-                       break;
-               case DESC_RATEMCS12:
-                       rate_idx = 12;
-                       break;
-               case DESC_RATEMCS13:
-                       rate_idx = 13;
-                       break;
-               case DESC_RATEMCS14:
-                       rate_idx = 14;
-                       break;
-               case DESC_RATEMCS15:
-                       rate_idx = 15;
-                       break;
-               default:
-                       rate_idx = 0;
-                       break;
-               }
-       }
-       return rate_idx;
-}
-
-static u8 _rtl_get_tx_hw_rate(struct ieee80211_hw *hw,
-                             struct ieee80211_tx_info *info)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct ieee80211_tx_rate *r = &info->status.rates[0];
-       struct ieee80211_rate *txrate;
-       u8 hw_value = 0x0;
-
-       if (r->flags & IEEE80211_TX_RC_MCS) {
-               /* HT MCS0-15 */
-               hw_value = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15] - 15 +
-                          r->idx;
-       } else if (r->flags & IEEE80211_TX_RC_VHT_MCS) {
-               /* VHT MCS0-9, NSS */
-               if (ieee80211_rate_get_vht_nss(r) == 2)
-                       hw_value = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
-               else
-                       hw_value = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
-
-               hw_value = hw_value - 9 + ieee80211_rate_get_vht_mcs(r);
-       } else {
-               /* legacy */
-               txrate = ieee80211_get_tx_rate(hw, info);
-
-               if (txrate)
-                       hw_value = txrate->hw_value;
-       }
-
-       /* check 5G band */
-       if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G &&
-           hw_value < rtlpriv->cfg->maps[RTL_RC_OFDM_RATE6M])
-               hw_value = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE6M];
-
-       return hw_value;
-}
-
-void rtl_get_tcb_desc(struct ieee80211_hw *hw,
-                     struct ieee80211_tx_info *info,
-                     struct ieee80211_sta *sta,
-                     struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
-       struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
-       struct rtl_sta_info *sta_entry =
-               (sta ? (struct rtl_sta_info *)sta->drv_priv : NULL);
-
-       __le16 fc = rtl_get_fc(skb);
-
-       tcb_desc->hw_rate = _rtl_get_tx_hw_rate(hw, info);
-
-       if (rtl_is_tx_report_skb(hw, skb))
-               tcb_desc->use_spe_rpt = 1;
-
-       if (!ieee80211_is_data(fc)) {
-               tcb_desc->use_driver_rate = true;
-               tcb_desc->ratr_index = _rtl_rate_id(hw, sta_entry,
-                                                   RATR_INX_WIRELESS_MC);
-               tcb_desc->disable_ratefallback = 1;
-               tcb_desc->mac_id = 0;
-               tcb_desc->packet_bw = false;
-
-               return;
-       }
-
-       /*
-        * We set data rate INX 0
-        * in rtl_rc.c if skb is special data or
-        * mgt which need low data rate.
-        */
-
-       /*
-        * So tcb_desc->hw_rate is just used for
-        * special data and mgt frames
-        */
-       if (info->control.rates[0].idx == 0 || ieee80211_is_nullfunc(fc)) {
-               tcb_desc->use_driver_rate = true;
-               tcb_desc->ratr_index = _rtl_rate_id(hw, sta_entry,
-                                                   RATR_INX_WIRELESS_MC);
-
-               tcb_desc->disable_ratefallback = 1;
-       } else if (sta && sta->vht_cap.vht_supported) {
-               /*
-                * Because hw will never use hw_rate
-                * when tcb_desc->use_driver_rate = false
-                * so we never set highest N rate here,
-                * and N rate will all be controlled by FW
-                * when tcb_desc->use_driver_rate = false
-                */
-               tcb_desc->hw_rate = _rtl_get_vht_highest_n_rate(hw, sta);
-       } else if (sta && sta->ht_cap.ht_supported) {
-               tcb_desc->hw_rate = _rtl_get_highest_n_rate(hw, sta);
-       } else {
-               enum rtl_var_map var = RTL_RC_OFDM_RATE54M;
-
-               if (rtlmac->mode == WIRELESS_MODE_B)
-                       var = RTL_RC_CCK_RATE11M;
-
-               tcb_desc->hw_rate = rtlpriv->cfg->maps[var];
-       }
-
-       if (is_multicast_ether_addr(hdr->addr1))
-               tcb_desc->multicast = 1;
-       else if (is_broadcast_ether_addr(hdr->addr1))
-               tcb_desc->broadcast = 1;
-
-       _rtl_txrate_selectmode(hw, sta, tcb_desc);
-       _rtl_query_bandwidth_mode(hw, sta, tcb_desc);
-       _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info);
-       _rtl_query_shortgi(hw, sta, tcb_desc, info);
-       _rtl_query_protection_mode(hw, tcb_desc, info);
-}
-
-bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       __le16 fc = rtl_get_fc(skb);
-
-       if (rtlpriv->dm.supp_phymode_switch &&
-           mac->link_state < MAC80211_LINKED &&
-           (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) {
-               if (rtlpriv->cfg->ops->chk_switch_dmdp)
-                       rtlpriv->cfg->ops->chk_switch_dmdp(hw);
-       }
-       if (ieee80211_is_auth(fc)) {
-               RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
-
-               mac->link_state = MAC80211_LINKING;
-               /* Dul mac */
-               rtlpriv->phy.need_iqk = true;
-       }
-       return true;
-}
-
-struct sk_buff *rtl_make_del_ba(struct ieee80211_hw *hw, u8 *sa,
-                               u8 *bssid, u16 tid);
-
-static void process_agg_start(struct ieee80211_hw *hw,
-                             struct ieee80211_hdr *hdr, u16 tid)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct ieee80211_rx_status rx_status = { 0 };
-       struct sk_buff *skb_delba = NULL;
-
-       skb_delba = rtl_make_del_ba(hw, hdr->addr2, hdr->addr3, tid);
-       if (skb_delba) {
-               rx_status.freq = hw->conf.chandef.chan->center_freq;
-               rx_status.band = hw->conf.chandef.chan->band;
-               rx_status.flag |= RX_FLAG_DECRYPTED;
-               rx_status.flag |= RX_FLAG_MACTIME_START;
-               rx_status.rate_idx = 0;
-               rx_status.signal = 50 + 10;
-               memcpy(IEEE80211_SKB_RXCB(skb_delba),
-                      &rx_status, sizeof(rx_status));
-               RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG,
-                             "fake del\n",
-                             skb_delba->data,
-                             skb_delba->len);
-               ieee80211_rx_irqsafe(hw, skb_delba);
-       }
-}
-
-bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
-{
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       __le16 fc = rtl_get_fc(skb);
-       u8 *act = (u8 *)(((u8 *)skb->data + MAC80211_3ADDR_LEN));
-       u8 category;
-
-       if (!ieee80211_is_action(fc))
-               return true;
-
-       category = *act;
-       act++;
-       switch (category) {
-       case ACT_CAT_BA:
-               switch (*act) {
-               case ACT_ADDBAREQ:
-                       if (mac->act_scanning)
-                               return false;
-
-                       RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
-                                "%s ACT_ADDBAREQ From :%pM\n",
-                                is_tx ? "Tx" : "Rx", hdr->addr2);
-                       RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "req\n",
-                                     skb->data, skb->len);
-                       if (!is_tx) {
-                               struct ieee80211_sta *sta = NULL;
-                               struct rtl_sta_info *sta_entry = NULL;
-                               struct rtl_tid_data *tid_data;
-                               struct ieee80211_mgmt *mgmt = (void *)skb->data;
-                               u16 capab = 0, tid = 0;
-
-                               rcu_read_lock();
-                               sta = rtl_find_sta(hw, hdr->addr3);
-                               if (!sta) {
-                                       RT_TRACE(rtlpriv, COMP_SEND | COMP_RECV,
-                                                DBG_DMESG, "sta is NULL\n");
-                                       rcu_read_unlock();
-                                       return true;
-                               }
-
-                               sta_entry =
-                                       (struct rtl_sta_info *)sta->drv_priv;
-                               if (!sta_entry) {
-                                       rcu_read_unlock();
-                                       return true;
-                               }
-                               capab =
-                                 le16_to_cpu(mgmt->u.action.u.addba_req.capab);
-                               tid = (capab &
-                                      IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
-                               if (tid >= MAX_TID_COUNT) {
-                                       rcu_read_unlock();
-                                       return true;
-                               }
-                               tid_data = &sta_entry->tids[tid];
-                               if (tid_data->agg.rx_agg_state ==
-                                   RTL_RX_AGG_START)
-                                       process_agg_start(hw, hdr, tid);
-                               rcu_read_unlock();
-                       }
-                       break;
-               case ACT_ADDBARSP:
-                       RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
-                                "%s ACT_ADDBARSP From :%pM\n",
-                                 is_tx ? "Tx" : "Rx", hdr->addr2);
-                       break;
-               case ACT_DELBA:
-                       RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
-                                "ACT_ADDBADEL From :%pM\n", hdr->addr2);
-                       break;
-               }
-               break;
-       default:
-               break;
-       }
-
-       return true;
-}
-
-static void setup_special_tx(struct rtl_priv *rtlpriv, struct rtl_ps_ctl *ppsc,
-                            int type)
-{
-       struct ieee80211_hw *hw = rtlpriv->hw;
-
-       rtlpriv->ra.is_special_data = true;
-       if (rtlpriv->cfg->ops->get_btc_status())
-               rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(rtlpriv,
-                                                                     type);
-       rtl_lps_leave(hw);
-       ppsc->last_delaylps_stamp_jiffies = jiffies;
-}
-
-static const u8 *rtl_skb_ether_type_ptr(struct ieee80211_hw *hw,
-                                       struct sk_buff *skb, bool is_enc)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       u8 mac_hdr_len = ieee80211_get_hdrlen_from_skb(skb);
-       u8 encrypt_header_len = 0;
-       u8 offset;
-
-       switch (rtlpriv->sec.pairwise_enc_algorithm) {
-       case WEP40_ENCRYPTION:
-       case WEP104_ENCRYPTION:
-               encrypt_header_len = 4;/*WEP_IV_LEN*/
-               break;
-       case TKIP_ENCRYPTION:
-               encrypt_header_len = 8;/*TKIP_IV_LEN*/
-               break;
-       case AESCCMP_ENCRYPTION:
-               encrypt_header_len = 8;/*CCMP_HDR_LEN;*/
-               break;
-       default:
-               break;
-       }
-
-       offset = mac_hdr_len + SNAP_SIZE;
-       if (is_enc)
-               offset += encrypt_header_len;
-
-       return skb->data + offset;
-}
-
-/*should call before software enc*/
-u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
-                      bool is_enc)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-       __le16 fc = rtl_get_fc(skb);
-       u16 ether_type;
-       const u8 *ether_type_ptr;
-       const struct iphdr *ip;
-
-       if (!ieee80211_is_data(fc))
-               goto end;
-
-       ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, is_enc);
-       ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
-
-       if (ether_type == ETH_P_IP) {
-               ip = (struct iphdr *)((u8 *)ether_type_ptr +
-                    PROTOC_TYPE_SIZE);
-               if (ip->protocol == IPPROTO_UDP) {
-                       struct udphdr *udp = (struct udphdr *)((u8 *)ip +
-                                                              (ip->ihl << 2));
-                       if (((((u8 *)udp)[1] == 68) &&
-                            (((u8 *)udp)[3] == 67)) ||
-                           ((((u8 *)udp)[1] == 67) &&
-                            (((u8 *)udp)[3] == 68))) {
-                               /* 68 : UDP BOOTP client
-                                * 67 : UDP BOOTP server
-                                */
-                               RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV),
-                                        DBG_DMESG, "dhcp %s !!\n",
-                                        (is_tx) ? "Tx" : "Rx");
-
-                               if (is_tx)
-                                       setup_special_tx(rtlpriv, ppsc,
-                                                        PACKET_DHCP);
-
-                               return true;
-                       }
-               }
-       } else if (ether_type == ETH_P_ARP) {
-               if (is_tx)
-                       setup_special_tx(rtlpriv, ppsc, PACKET_ARP);
-
-               return true;
-       } else if (ether_type == ETH_P_PAE) {
-               /* EAPOL is seen as in-4way */
-               rtlpriv->btcoexist.btc_info.in_4way = true;
-               rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
-               rtlpriv->btcoexist.btc_info.in_4way_ts = jiffies;
-
-               RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
-                        "802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx");
-
-               if (is_tx) {
-                       rtlpriv->ra.is_special_data = true;
-                       rtl_lps_leave(hw);
-                       ppsc->last_delaylps_stamp_jiffies = jiffies;
-
-                       setup_special_tx(rtlpriv, ppsc, PACKET_EAPOL);
-               }
-
-               return true;
-       } else if (ether_type == ETH_P_IPV6) {
-               /* TODO: Handle any IPv6 cases that need special handling.
-                * For now, always return false
-                */
-               goto end;
-       }
-
-end:
-       rtlpriv->ra.is_special_data = false;
-       return false;
-}
-
-bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-       u16 ether_type;
-       const u8 *ether_type_ptr;
-
-       ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, true);
-       ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
-
-       /* EAPOL */
-       if (ether_type == ETH_P_PAE)
-               return true;
-
-       return false;
-}
-
-static u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_tx_report *tx_report = &rtlpriv->tx_report;
-       u16 sn;
-
-       /*
-        * SW_DEFINE[11:8] are reserved (driver fills zeros)
-        * SW_DEFINE[7:2] are used by driver
-        * SW_DEFINE[1:0] are reserved for firmware (driver fills zeros)
-        */
-       sn = (atomic_inc_return(&tx_report->sn) & 0x003F) << 2;
-
-       tx_report->last_sent_sn = sn;
-       tx_report->last_sent_time = jiffies;
-
-       RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_DMESG,
-                "Send TX-Report sn=0x%X\n", sn);
-
-       return sn;
-}
-
-void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
-                      struct ieee80211_hw *hw)
-{
-       if (ptcb_desc->use_spe_rpt) {
-               u16 sn = rtl_get_tx_report_sn(hw);
-
-               SET_TX_DESC_SPE_RPT(pdesc, 1);
-               SET_TX_DESC_SW_DEFINE(pdesc, sn);
-       }
-}
-
-void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf, u8 c2h_cmd_len)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_tx_report *tx_report = &rtlpriv->tx_report;
-       u16 sn;
-       u8 st, retry;
-
-       if (rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_FW_C2H) {
-               sn = tmp_buf[6];
-               st = tmp_buf[7] & 0xC0;
-               retry = tmp_buf[8] & 0x3F;
-       } else {
-               sn = ((tmp_buf[7] & 0x0F) << 8) | tmp_buf[6];
-               st = tmp_buf[0] & 0xC0;
-               retry = tmp_buf[2] & 0x3F;
-       }
-
-       tx_report->last_recv_sn = sn;
-
-       RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_DMESG,
-                "Recv TX-Report st=0x%02X sn=0x%X retry=0x%X\n",
-                st, sn, retry);
-}
-
-bool rtl_check_tx_report_acked(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_tx_report *tx_report = &rtlpriv->tx_report;
-
-       if (tx_report->last_sent_sn == tx_report->last_recv_sn)
-               return true;
-
-       if (time_before(tx_report->last_sent_time + 3 * HZ, jiffies)) {
-               RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_WARNING,
-                        "Check TX-Report timeout!! s_sn=0x%X r_sn=0x%X\n",
-                        tx_report->last_sent_sn, tx_report->last_recv_sn);
-               return true;    /* 3 sec. (timeout) seen as acked */
-       }
-
-       return false;
-}
-
-void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       int i;
-
-       for (i = 0; i < wait_ms; i++) {
-               if (rtl_check_tx_report_acked(hw))
-                       break;
-               usleep_range(1000, 2000);
-               RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
-                        "Wait 1ms (%d/%d) to disable key.\n", i, wait_ms);
-       }
-}
-
-u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
-                          struct ieee80211_vif *vif,
-                          enum wireless_mode wirelessmode,
-                          struct ieee80211_tx_queue_params *param)
-{
-       u32 reg = 0;
-       u8 sifstime = 10;
-       u8 slottime = 20;
-
-       /* AIFS = AIFSN * slot time + SIFS */
-       switch (wirelessmode) {
-       case WIRELESS_MODE_A:
-       case WIRELESS_MODE_N_24G:
-       case WIRELESS_MODE_N_5G:
-       case WIRELESS_MODE_AC_5G:
-       case WIRELESS_MODE_AC_24G:
-               sifstime = 16;
-               slottime = 9;
-               break;
-       case WIRELESS_MODE_G:
-               slottime = (vif->bss_conf.use_short_slot ? 9 : 20);
-               break;
-       default:
-               break;
-       }
-
-       reg |= (param->txop & 0x7FF) << 16;
-       reg |= (fls(param->cw_max) & 0xF) << 12;
-       reg |= (fls(param->cw_min) & 0xF) << 8;
-       reg |= (param->aifs & 0x0F) * slottime + sifstime;
-
-       return reg;
-}
-
-/*********************************************************
- *
- * functions called by core.c
- *
- *********************************************************/
-int rtl_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                    struct ieee80211_sta *sta, u16 tid, u16 *ssn)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_tid_data *tid_data;
-       struct rtl_sta_info *sta_entry = NULL;
-
-       if (!sta)
-               return -EINVAL;
-
-       if (unlikely(tid >= MAX_TID_COUNT))
-               return -EINVAL;
-
-       sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-       if (!sta_entry)
-               return -ENXIO;
-       tid_data = &sta_entry->tids[tid];
-
-       RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG,
-                "on ra = %pM tid = %d seq:%d\n", sta->addr, tid,
-                tid_data->seq_number);
-
-       *ssn = tid_data->seq_number;
-       tid_data->agg.agg_state = RTL_AGG_START;
-
-       ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
-       return 0;
-}
-
-int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                   struct ieee80211_sta *sta, u16 tid)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_sta_info *sta_entry = NULL;
-
-       if (!sta)
-               return -EINVAL;
-
-       RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG,
-                "on ra = %pM tid = %d\n", sta->addr, tid);
-
-       if (unlikely(tid >= MAX_TID_COUNT))
-               return -EINVAL;
-
-       sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-       sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP;
-
-       ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
-       return 0;
-}
-
-int rtl_rx_agg_start(struct ieee80211_hw *hw,
-                    struct ieee80211_sta *sta, u16 tid)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_tid_data *tid_data;
-       struct rtl_sta_info *sta_entry = NULL;
-       u8 reject_agg;
-
-       if (!sta)
-               return -EINVAL;
-
-       if (unlikely(tid >= MAX_TID_COUNT))
-               return -EINVAL;
-
-       if (rtlpriv->cfg->ops->get_btc_status()) {
-               rtlpriv->btcoexist.btc_ops->btc_get_ampdu_cfg(rtlpriv,
-                                                             &reject_agg,
-                                                             NULL, NULL);
-               if (reject_agg)
-                       return -EINVAL;
-       }
-
-       sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-       if (!sta_entry)
-               return -ENXIO;
-       tid_data = &sta_entry->tids[tid];
-
-       RT_TRACE(rtlpriv, COMP_RECV, DBG_DMESG,
-                "on ra = %pM tid = %d seq:%d\n", sta->addr, tid,
-                tid_data->seq_number);
-
-       tid_data->agg.rx_agg_state = RTL_RX_AGG_START;
-       return 0;
-}
-
-int rtl_rx_agg_stop(struct ieee80211_hw *hw,
-                   struct ieee80211_sta *sta, u16 tid)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_sta_info *sta_entry = NULL;
-
-       if (!sta)
-               return -EINVAL;
-
-       RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG,
-                "on ra = %pM tid = %d\n", sta->addr, tid);
-
-       if (unlikely(tid >= MAX_TID_COUNT))
-               return -EINVAL;
-
-       sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-       sta_entry->tids[tid].agg.rx_agg_state = RTL_RX_AGG_STOP;
-
-       return 0;
-}
-
-int rtl_tx_agg_oper(struct ieee80211_hw *hw,
-                   struct ieee80211_sta *sta, u16 tid)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_sta_info *sta_entry = NULL;
-
-       if (!sta)
-               return -EINVAL;
-
-       RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG,
-                "on ra = %pM tid = %d\n", sta->addr, tid);
-
-       if (unlikely(tid >= MAX_TID_COUNT))
-               return -EINVAL;
-
-       sta_entry = (struct rtl_sta_info *)sta->drv_priv;
-       sta_entry->tids[tid].agg.agg_state = RTL_AGG_OPERATIONAL;
-
-       return 0;
-}
-
-void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv)
-{
-       struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
-       u8 reject_agg = 0, ctrl_agg_size = 0, agg_size = 0;
-
-       if (rtlpriv->cfg->ops->get_btc_status())
-               btc_ops->btc_get_ampdu_cfg(rtlpriv, &reject_agg,
-                                          &ctrl_agg_size, &agg_size);
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
-                "Set RX AMPDU: coex - reject=%d, ctrl_agg_size=%d, size=%d",
-                reject_agg, ctrl_agg_size, agg_size);
-
-       rtlpriv->hw->max_rx_aggregation_subframes =
-               (ctrl_agg_size ? agg_size : IEEE80211_MAX_AMPDU_BUF_HT);
-}
-
-/*********************************************************
- *
- * wq & timer callback functions
- *
- *********************************************************/
-/* this function is used for roaming */
-void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-
-       if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
-               return;
-
-       if (rtlpriv->mac80211.link_state < MAC80211_LINKED)
-               return;
-
-       /* check if this really is a beacon */
-       if (!ieee80211_is_beacon(hdr->frame_control) &&
-           !ieee80211_is_probe_resp(hdr->frame_control))
-               return;
-
-       /* min. beacon length + FCS_LEN */
-       if (skb->len <= 40 + FCS_LEN)
-               return;
-
-       /* and only beacons from the associated BSSID, please */
-       if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
-               return;
-
-       rtlpriv->link_info.bcn_rx_inperiod++;
-}
-
-static void rtl_free_entries_from_scan_list(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_bssid_entry *entry, *next;
-
-       list_for_each_entry_safe(entry, next, &rtlpriv->scan_list.list, list) {
-               list_del(&entry->list);
-               kfree(entry);
-               rtlpriv->scan_list.num--;
-       }
-}
-
-void rtl_scan_list_expire(struct ieee80211_hw *hw)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_bssid_entry *entry, *next;
-       unsigned long flags;
-
-       spin_lock_irqsave(&rtlpriv->locks.scan_list_lock, flags);
-
-       list_for_each_entry_safe(entry, next, &rtlpriv->scan_list.list, list) {
-               /* 180 seconds */
-               if (jiffies_to_msecs(jiffies - entry->age) < 180000)
-                       continue;
-
-               list_del(&entry->list);
-               rtlpriv->scan_list.num--;
-
-               RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
-                        "BSSID=%pM is expire in scan list (total=%d)\n",
-                        entry->bssid, rtlpriv->scan_list.num);
-               kfree(entry);
-       }
-
-       spin_unlock_irqrestore(&rtlpriv->locks.scan_list_lock, flags);
-
-       rtlpriv->btcoexist.btc_info.ap_num = rtlpriv->scan_list.num;
-}
-
-void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       unsigned long flags;
-
-       struct rtl_bssid_entry *entry;
-       bool entry_found = false;
-
-       /* check if it is scanning */
-       if (!mac->act_scanning)
-               return;
-
-       /* check if this really is a beacon */
-       if (!ieee80211_is_beacon(hdr->frame_control) &&
-           !ieee80211_is_probe_resp(hdr->frame_control))
-               return;
-
-       spin_lock_irqsave(&rtlpriv->locks.scan_list_lock, flags);
-
-       list_for_each_entry(entry, &rtlpriv->scan_list.list, list) {
-               if (memcmp(entry->bssid, hdr->addr3, ETH_ALEN) == 0) {
-                       list_del_init(&entry->list);
-                       entry_found = true;
-                       RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
-                                "Update BSSID=%pM to scan list (total=%d)\n",
-                                hdr->addr3, rtlpriv->scan_list.num);
-                       break;
-               }
-       }
-
-       if (!entry_found) {
-               entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
-
-               if (!entry)
-                       goto label_err;
-
-               memcpy(entry->bssid, hdr->addr3, ETH_ALEN);
-               rtlpriv->scan_list.num++;
-
-               RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
-                        "Add BSSID=%pM to scan list (total=%d)\n",
-                        hdr->addr3, rtlpriv->scan_list.num);
-       }
-
-       entry->age = jiffies;
-
-       list_add_tail(&entry->list, &rtlpriv->scan_list.list);
-
-label_err:
-       spin_unlock_irqrestore(&rtlpriv->locks.scan_list_lock, flags);
-}
-
-void rtl_watchdog_wq_callback(void *data)
-{
-       struct rtl_works *rtlworks = container_of_dwork_rtl(data,
-                                                           struct rtl_works,
-                                                           watchdog_wq);
-       struct ieee80211_hw *hw = rtlworks->hw;
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       bool busytraffic = false;
-       bool tx_busy_traffic = false;
-       bool rx_busy_traffic = false;
-       bool higher_busytraffic = false;
-       bool higher_busyrxtraffic = false;
-       u8 idx, tid;
-       u32 rx_cnt_inp4eriod = 0;
-       u32 tx_cnt_inp4eriod = 0;
-       u32 aver_rx_cnt_inperiod = 0;
-       u32 aver_tx_cnt_inperiod = 0;
-       u32 aver_tidtx_inperiod[MAX_TID_COUNT] = {0};
-       u32 tidtx_inp4eriod[MAX_TID_COUNT] = {0};
-
-       if (is_hal_stop(rtlhal))
-               return;
-
-       /* <1> Determine if action frame is allowed */
-       if (mac->link_state > MAC80211_NOLINK) {
-               if (mac->cnt_after_linked < 20)
-                       mac->cnt_after_linked++;
-       } else {
-               mac->cnt_after_linked = 0;
-       }
-
-       /* <2> to check if traffic busy, if
-        * busytraffic we don't change channel
-        */
-       if (mac->link_state >= MAC80211_LINKED) {
-               /* (1) get aver_rx_cnt_inperiod & aver_tx_cnt_inperiod */
-               for (idx = 0; idx <= 2; idx++) {
-                       rtlpriv->link_info.num_rx_in4period[idx] =
-                           rtlpriv->link_info.num_rx_in4period[idx + 1];
-                       rtlpriv->link_info.num_tx_in4period[idx] =
-                           rtlpriv->link_info.num_tx_in4period[idx + 1];
-               }
-               rtlpriv->link_info.num_rx_in4period[3] =
-                   rtlpriv->link_info.num_rx_inperiod;
-               rtlpriv->link_info.num_tx_in4period[3] =
-                   rtlpriv->link_info.num_tx_inperiod;
-               for (idx = 0; idx <= 3; idx++) {
-                       rx_cnt_inp4eriod +=
-                           rtlpriv->link_info.num_rx_in4period[idx];
-                       tx_cnt_inp4eriod +=
-                           rtlpriv->link_info.num_tx_in4period[idx];
-               }
-               aver_rx_cnt_inperiod = rx_cnt_inp4eriod / 4;
-               aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4;
-
-               /* (2) check traffic busy */
-               if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100) {
-                       busytraffic = true;
-                       if (aver_rx_cnt_inperiod > aver_tx_cnt_inperiod)
-                               rx_busy_traffic = true;
-                       else
-                               tx_busy_traffic = false;
-               }
-
-               /* Higher Tx/Rx data. */
-               if (aver_rx_cnt_inperiod > 4000 ||
-                   aver_tx_cnt_inperiod > 4000) {
-                       higher_busytraffic = true;
-
-                       /* Extremely high Rx data. */
-                       if (aver_rx_cnt_inperiod > 5000)
-                               higher_busyrxtraffic = true;
-               }
-
-               /* check every tid's tx traffic */
-               for (tid = 0; tid <= 7; tid++) {
-                       for (idx = 0; idx <= 2; idx++)
-                               rtlpriv->link_info.tidtx_in4period[tid][idx] =
-                                       rtlpriv->link_info.tidtx_in4period[tid]
-                                       [idx + 1];
-                       rtlpriv->link_info.tidtx_in4period[tid][3] =
-                               rtlpriv->link_info.tidtx_inperiod[tid];
-
-                       for (idx = 0; idx <= 3; idx++)
-                               tidtx_inp4eriod[tid] +=
-                                  rtlpriv->link_info.tidtx_in4period[tid][idx];
-                       aver_tidtx_inperiod[tid] = tidtx_inp4eriod[tid] / 4;
-                       if (aver_tidtx_inperiod[tid] > 5000)
-                               rtlpriv->link_info.higher_busytxtraffic[tid] =
-                                                                       true;
-                       else
-                               rtlpriv->link_info.higher_busytxtraffic[tid] =
-                                                                       false;
-               }
-
-               /* PS is controlled by coex. */
-               if (rtlpriv->cfg->ops->get_btc_status() &&
-                   rtlpriv->btcoexist.btc_ops->btc_is_bt_ctrl_lps(rtlpriv))
-                       goto label_lps_done;
-
-               if (rtlpriv->link_info.num_rx_inperiod +
-                     rtlpriv->link_info.num_tx_inperiod > 8 ||
-                   rtlpriv->link_info.num_rx_inperiod > 2)
-                       rtl_lps_leave(hw);
-               else
-                       rtl_lps_enter(hw);
-
-label_lps_done:
-               ;
-       }
-
-       rtlpriv->link_info.num_rx_inperiod = 0;
-       rtlpriv->link_info.num_tx_inperiod = 0;
-       for (tid = 0; tid <= 7; tid++)
-               rtlpriv->link_info.tidtx_inperiod[tid] = 0;
-
-       rtlpriv->link_info.busytraffic = busytraffic;
-       rtlpriv->link_info.higher_busytraffic = higher_busytraffic;
-       rtlpriv->link_info.rx_busy_traffic = rx_busy_traffic;
-       rtlpriv->link_info.tx_busy_traffic = tx_busy_traffic;
-       rtlpriv->link_info.higher_busyrxtraffic = higher_busyrxtraffic;
-
-       rtlpriv->stats.txbytesunicast_inperiod =
-               rtlpriv->stats.txbytesunicast -
-               rtlpriv->stats.txbytesunicast_last;
-       rtlpriv->stats.rxbytesunicast_inperiod =
-               rtlpriv->stats.rxbytesunicast -
-               rtlpriv->stats.rxbytesunicast_last;
-       rtlpriv->stats.txbytesunicast_last = rtlpriv->stats.txbytesunicast;
-       rtlpriv->stats.rxbytesunicast_last = rtlpriv->stats.rxbytesunicast;
-
-       rtlpriv->stats.txbytesunicast_inperiod_tp =
-               (u32)(rtlpriv->stats.txbytesunicast_inperiod * 8 / 2 /
-               1024 / 1024);
-       rtlpriv->stats.rxbytesunicast_inperiod_tp =
-               (u32)(rtlpriv->stats.rxbytesunicast_inperiod * 8 / 2 /
-               1024 / 1024);
-
-       /* <3> DM */
-       if (!rtlpriv->cfg->mod_params->disable_watchdog)
-               rtlpriv->cfg->ops->dm_watchdog(hw);
-
-       /* <4> roaming */
-       if (mac->link_state == MAC80211_LINKED &&
-           mac->opmode == NL80211_IFTYPE_STATION) {
-               if ((rtlpriv->link_info.bcn_rx_inperiod +
-                   rtlpriv->link_info.num_rx_inperiod) == 0) {
-                       rtlpriv->link_info.roam_times++;
-                       RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
-                                "AP off for %d s\n",
-                               (rtlpriv->link_info.roam_times * 2));
-
-                       /* if we can't recv beacon for 10s,
-                        * we should reconnect this AP
-                        */
-                       if (rtlpriv->link_info.roam_times >= 5) {
-                               pr_err("AP off, try to reconnect now\n");
-                               rtlpriv->link_info.roam_times = 0;
-                               ieee80211_connection_loss(rtlpriv->mac80211.vif);
-                       }
-               } else {
-                       rtlpriv->link_info.roam_times = 0;
-               }
-       }
-
-       if (rtlpriv->cfg->ops->get_btc_status())
-               rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
-
-       if (rtlpriv->btcoexist.btc_info.in_4way) {
-               if (time_after(jiffies, rtlpriv->btcoexist.btc_info.in_4way_ts +
-                              msecs_to_jiffies(IN_4WAY_TIMEOUT_TIME)))
-                       rtlpriv->btcoexist.btc_info.in_4way = false;
-       }
-
-       rtlpriv->link_info.bcn_rx_inperiod = 0;
-
-       /* <6> scan list */
-       rtl_scan_list_expire(hw);
-}
-
-void rtl_watch_dog_timer_callback(struct timer_list *t)
-{
-       struct rtl_priv *rtlpriv = from_timer(rtlpriv, t, works.watchdog_timer);
-
-       queue_delayed_work(rtlpriv->works.rtl_wq,
-                          &rtlpriv->works.watchdog_wq, 0);
-
-       mod_timer(&rtlpriv->works.watchdog_timer,
-                 jiffies + MSECS(RTL_WATCH_DOG_TIME));
-}
-
-void rtl_fwevt_wq_callback(void *data)
-{
-       struct rtl_works *rtlworks =
-               container_of_dwork_rtl(data, struct rtl_works, fwevt_wq);
-       struct ieee80211_hw *hw = rtlworks->hw;
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-       rtlpriv->cfg->ops->c2h_command_handle(hw);
-}
-
-void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       unsigned long flags;
-       struct rtl_c2hcmd *c2hcmd;
-
-       c2hcmd = kmalloc(sizeof(*c2hcmd),
-                        in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-
-       if (!c2hcmd)
-               goto label_err;
-
-       c2hcmd->val = kmalloc(len,
-                             in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-
-       if (!c2hcmd->val)
-               goto label_err2;
-
-       /* fill data */
-       c2hcmd->tag = tag;
-       c2hcmd->len = len;
-       memcpy(c2hcmd->val, val, len);
-
-       /* enqueue */
-       spin_lock_irqsave(&rtlpriv->locks.c2hcmd_lock, flags);
-
-       list_add_tail(&c2hcmd->list, &rtlpriv->c2hcmd_list);
-
-       spin_unlock_irqrestore(&rtlpriv->locks.c2hcmd_lock, flags);
-
-       /* wake up wq */
-       queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.c2hcmd_wq, 0);
-
-       return;
-
-label_err2:
-       kfree(c2hcmd);
-
-label_err:
-       RT_TRACE(rtlpriv, COMP_CMD, DBG_WARNING,
-                "C2H cmd enqueue fail.\n");
-}
-
-void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       unsigned long flags;
-       struct rtl_c2hcmd *c2hcmd;
-       int i;
-
-       for (i = 0; i < 200; i++) {
-               /* dequeue a task */
-               spin_lock_irqsave(&rtlpriv->locks.c2hcmd_lock, flags);
-
-               c2hcmd = list_first_entry_or_null(&rtlpriv->c2hcmd_list,
-                                                 struct rtl_c2hcmd, list);
-
-               if (c2hcmd)
-                       list_del(&c2hcmd->list);
-
-               spin_unlock_irqrestore(&rtlpriv->locks.c2hcmd_lock, flags);
-
-               /* do it */
-               if (!c2hcmd)
-                       break;
-
-               if (rtlpriv->cfg->ops->c2h_content_parsing && exec)
-                       rtlpriv->cfg->ops->c2h_content_parsing(hw,
-                                       c2hcmd->tag, c2hcmd->len, c2hcmd->val);
-
-               /* free */
-               kfree(c2hcmd->val);
-
-               kfree(c2hcmd);
-       }
-}
-
-void rtl_c2hcmd_wq_callback(void *data)
-{
-       struct rtl_works *rtlworks = container_of_dwork_rtl(data,
-                                                           struct rtl_works,
-                                                           c2hcmd_wq);
-       struct ieee80211_hw *hw = rtlworks->hw;
-
-       rtl_c2hcmd_launcher(hw, 1);
-}
-
-void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t)
-{
-       struct rtl_priv *rtlpriv =
-               from_timer(rtlpriv, t, works.dualmac_easyconcurrent_retrytimer);
-       struct ieee80211_hw *hw = rtlpriv->hw;
-       struct rtl_priv *buddy_priv = rtlpriv->buddy_priv;
-
-       if (!buddy_priv)
-               return;
-
-       rtlpriv->cfg->ops->dualmac_easy_concurrent(hw);
-}
-
-/*********************************************************
- *
- * frame process functions
- *
- *********************************************************/
-u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie)
-{
-       struct ieee80211_mgmt *mgmt = (void *)data;
-       u8 *pos, *end;
-
-       pos = (u8 *)mgmt->u.beacon.variable;
-       end = data + len;
-       while (pos < end) {
-               if (pos + 2 + pos[1] > end)
-                       return NULL;
-
-               if (pos[0] == ie)
-                       return pos;
-
-               pos += 2 + pos[1];
-       }
-       return NULL;
-}
-
-/* when we use 2 rx ants we send IEEE80211_SMPS_OFF */
-/* when we use 1 rx ant we send IEEE80211_SMPS_STATIC */
-static struct sk_buff *rtl_make_smps_action(struct ieee80211_hw *hw,
-                                           enum ieee80211_smps_mode smps,
-                                           u8 *da, u8 *bssid)
-{
-       struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
-       struct sk_buff *skb;
-       struct ieee80211_mgmt *action_frame;
-
-       /* 27 = header + category + action + smps mode */
-       skb = dev_alloc_skb(27 + hw->extra_tx_headroom);
-       if (!skb)
-               return NULL;
-
-       skb_reserve(skb, hw->extra_tx_headroom);
-       action_frame = skb_put_zero(skb, 27);
-       memcpy(action_frame->da, da, ETH_ALEN);
-       memcpy(action_frame->sa, rtlefuse->dev_addr, ETH_ALEN);
-       memcpy(action_frame->bssid, bssid, ETH_ALEN);
-       action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-                                                 IEEE80211_STYPE_ACTION);
-       action_frame->u.action.category = WLAN_CATEGORY_HT;
-       action_frame->u.action.u.ht_smps.action = WLAN_HT_ACTION_SMPS;
-       switch (smps) {
-       case IEEE80211_SMPS_AUTOMATIC:/* 0 */
-       case IEEE80211_SMPS_NUM_MODES:/* 4 */
-               WARN_ON(1);
-       /* fall through */
-       case IEEE80211_SMPS_OFF:/* 1 */ /*MIMO_PS_NOLIMIT*/
-               action_frame->u.action.u.ht_smps.smps_control =
-                               WLAN_HT_SMPS_CONTROL_DISABLED;/* 0 */
-               break;
-       case IEEE80211_SMPS_STATIC:/* 2 */ /*MIMO_PS_STATIC*/
-               action_frame->u.action.u.ht_smps.smps_control =
-                               WLAN_HT_SMPS_CONTROL_STATIC;/* 1 */
-               break;
-       case IEEE80211_SMPS_DYNAMIC:/* 3 */ /*MIMO_PS_DYNAMIC*/
-               action_frame->u.action.u.ht_smps.smps_control =
-                               WLAN_HT_SMPS_CONTROL_DYNAMIC;/* 3 */
-               break;
-       }
-
-       return skb;
-}
-
-int rtl_send_smps_action(struct ieee80211_hw *hw,
-                        struct ieee80211_sta *sta,
-                        enum ieee80211_smps_mode smps)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
-       struct sk_buff *skb = NULL;
-       struct rtl_tcb_desc tcb_desc;
-       u8 bssid[ETH_ALEN] = {0};
-
-       memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
-
-       if (rtlpriv->mac80211.act_scanning)
-               goto err_free;
-
-       if (!sta)
-               goto err_free;
-
-       if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
-               goto err_free;
-
-       if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
-               goto err_free;
-
-       if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP)
-               memcpy(bssid, rtlpriv->efuse.dev_addr, ETH_ALEN);
-       else
-               memcpy(bssid, rtlpriv->mac80211.bssid, ETH_ALEN);
-
-       skb = rtl_make_smps_action(hw, smps, sta->addr, bssid);
-       /* this is a type = mgmt * stype = action frame */
-       if (skb) {
-               struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-               struct rtl_sta_info *sta_entry =
-                       (struct rtl_sta_info *)sta->drv_priv;
-               sta_entry->mimo_ps = smps;
-               /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0, true); */
-
-               info->control.rates[0].idx = 0;
-               info->band = hw->conf.chandef.chan->band;
-               rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc);
-       }
-       return 1;
-
-err_free:
-       return 0;
-}
-
-void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       enum io_type iotype;
-
-       if (!is_hal_stop(rtlhal)) {
-               switch (operation) {
-               case SCAN_OPT_BACKUP:
-                       iotype = IO_CMD_PAUSE_DM_BY_SCAN;
-                       rtlpriv->cfg->ops->set_hw_reg(hw,
-                                                     HW_VAR_IO_CMD,
-                                                     (u8 *)&iotype);
-                       break;
-               case SCAN_OPT_RESTORE:
-                       iotype = IO_CMD_RESUME_DM_BY_SCAN;
-                       rtlpriv->cfg->ops->set_hw_reg(hw,
-                                                     HW_VAR_IO_CMD,
-                                                     (u8 *)&iotype);
-                       break;
-               default:
-                       pr_err("Unknown Scan Backup operation.\n");
-                       break;
-               }
-       }
-}
-
-/* because mac80211 have issues when can receive del ba
- * so here we just make a fake del_ba if we receive a ba_req
- * but rx_agg was opened to let mac80211 release some ba
- * related resources, so please this del_ba for tx
- */
-struct sk_buff *rtl_make_del_ba(struct ieee80211_hw *hw,
-                               u8 *sa, u8 *bssid, u16 tid)
-{
-       struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
-       struct sk_buff *skb;
-       struct ieee80211_mgmt *action_frame;
-       u16 params;
-
-       /* 27 = header + category + action + smps mode */
-       skb = dev_alloc_skb(34 + hw->extra_tx_headroom);
-       if (!skb)
-               return NULL;
-
-       skb_reserve(skb, hw->extra_tx_headroom);
-       action_frame = skb_put_zero(skb, 34);
-       memcpy(action_frame->sa, sa, ETH_ALEN);
-       memcpy(action_frame->da, rtlefuse->dev_addr, ETH_ALEN);
-       memcpy(action_frame->bssid, bssid, ETH_ALEN);
-       action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-                                                 IEEE80211_STYPE_ACTION);
-       action_frame->u.action.category = WLAN_CATEGORY_BACK;
-       action_frame->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
-       params = BIT(11);               /* bit 11 initiator */
-       params |= (u16)(tid << 12);     /* bit 15:12 TID number */
-
-       action_frame->u.action.u.delba.params = cpu_to_le16(params);
-       action_frame->u.action.u.delba.reason_code =
-               cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT);
-
-       return skb;
-}
-
-bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data, unsigned int len)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       struct rtl_phy *rtlphy = &rtlpriv->phy;
-       struct ieee80211_hdr *hdr = data;
-       struct ieee80211_ht_cap *ht_cap_ie;
-       struct ieee80211_ht_operation *ht_oper_ie = NULL;
-       struct rtl_beacon_keys bcn_key = {};
-       struct rtl_beacon_keys *cur_bcn_key;
-       u8 *ht_cap;
-       u8 *ht_oper;
-       u8 *ds_param;
-
-       if (mac->opmode != NL80211_IFTYPE_STATION)
-               return false;
-
-       /* check if this really is a beacon*/
-       if (!ieee80211_is_beacon(hdr->frame_control))
-               return false;
-
-       /* min. beacon length + FCS_LEN */
-       if (len <= 40 + FCS_LEN)
-               return false;
-
-       cur_bcn_key = &mac->cur_beacon_keys;
-
-       if (rtlpriv->mac80211.link_state == MAC80211_NOLINK) {
-               if (cur_bcn_key->valid) {
-                       cur_bcn_key->valid = false;
-                       RT_TRACE(rtlpriv, COMP_BEACON, DBG_LOUD,
-                                "Reset cur_beacon_keys.valid to false!\n");
-               }
-               return false;
-       }
-
-       /* and only beacons from the associated BSSID, please */
-       if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
-               return false;
-
-       /***** Parsing DS Param IE ******/
-       ds_param = rtl_find_ie(data, len - FCS_LEN, WLAN_EID_DS_PARAMS);
-
-       if (ds_param && !(ds_param[1] < sizeof(*ds_param)))
-               bcn_key.bcn_channel = ds_param[2];
-       else
-               ds_param = NULL;
-
-       /***** Parsing HT Cap. IE ******/
-       ht_cap = rtl_find_ie(data, len - FCS_LEN, WLAN_EID_HT_CAPABILITY);
-
-       if (ht_cap && !(ht_cap[1] < sizeof(*ht_cap))) {
-               ht_cap_ie = (struct ieee80211_ht_cap *)&ht_cap[2];
-               bcn_key.ht_cap_info = ht_cap_ie->cap_info;
-       } else  {
-               ht_cap = NULL;
-       }
-
-       /***** Parsing HT Info. IE ******/
-       ht_oper = rtl_find_ie(data, len - FCS_LEN, WLAN_EID_HT_OPERATION);
-
-       if (ht_oper && !(ht_oper[1] < sizeof(*ht_oper)))
-               ht_oper_ie = (struct ieee80211_ht_operation *)&ht_oper[2];
-       else
-               ht_oper = NULL;
-
-       /* update bcn_key */
-
-       if (!ds_param && ht_oper && ht_oper_ie)
-               bcn_key.bcn_channel = ht_oper_ie->primary_chan;
-
-       if (ht_oper && ht_oper_ie)
-               bcn_key.ht_info_infos_0_sco = ht_oper_ie->ht_param & 0x03;
-
-       bcn_key.valid = true;
-
-       /* update cur_beacon_keys or compare beacon key */
-       if (rtlpriv->mac80211.link_state != MAC80211_LINKED &&
-           rtlpriv->mac80211.link_state != MAC80211_LINKED_SCANNING)
-               return true;
-
-       if (!cur_bcn_key->valid) {
-               /* update cur_beacon_keys */
-               memcpy(cur_bcn_key, &bcn_key, sizeof(bcn_key));
-               cur_bcn_key->valid = true;
-
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_LOUD,
-                        "Beacon key update!ch=%d, ht_cap_info=0x%x, sco=0x%x\n",
-                        cur_bcn_key->bcn_channel,
-                        cur_bcn_key->ht_cap_info,
-                        cur_bcn_key->ht_info_infos_0_sco);
-               return true;
-       }
-
-       /* compare beacon key */
-       if (!memcmp(cur_bcn_key, &bcn_key, sizeof(bcn_key))) {
-               /* same beacon key */
-               mac->new_beacon_cnt = 0;
-               goto chk_exit;
-       }
-
-       if (cur_bcn_key->bcn_channel == bcn_key.bcn_channel &&
-           cur_bcn_key->ht_cap_info == bcn_key.ht_cap_info) {
-               /* Beacon HT info IE, secondary channel offset check */
-               /* 40M -> 20M */
-               if (cur_bcn_key->ht_info_infos_0_sco >
-                   bcn_key.ht_info_infos_0_sco) {
-                       /* Not a new beacon */
-                       RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                                "Beacon BW change! sco:0x%x -> 0x%x\n",
-                                cur_bcn_key->ht_info_infos_0_sco,
-                                bcn_key.ht_info_infos_0_sco);
-
-                       cur_bcn_key->ht_info_infos_0_sco =
-                                       bcn_key.ht_info_infos_0_sco;
-               } else {
-                       /* 20M -> 40M */
-                       if (rtlphy->max_ht_chan_bw >= HT_CHANNEL_WIDTH_20_40) {
-                               /* Not a new beacon */
-                               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                                        "Beacon BW change! sco:0x%x -> 0x%x\n",
-                                        cur_bcn_key->ht_info_infos_0_sco,
-                                        bcn_key.ht_info_infos_0_sco);
-
-                               cur_bcn_key->ht_info_infos_0_sco =
-                                       bcn_key.ht_info_infos_0_sco;
-                       } else {
-                               mac->new_beacon_cnt++;
-                       }
-               }
-       } else {
-               mac->new_beacon_cnt++;
-       }
-
-       if (mac->new_beacon_cnt == 1) {
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                        "Get new beacon.\n");
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                        "Cur : ch=%d, ht_cap=0x%x, sco=0x%x\n",
-                        cur_bcn_key->bcn_channel,
-                        cur_bcn_key->ht_cap_info,
-                        cur_bcn_key->ht_info_infos_0_sco);
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                        "New RX : ch=%d, ht_cap=0x%x, sco=0x%x\n",
-                        bcn_key.bcn_channel,
-                        bcn_key.ht_cap_info,
-                        bcn_key.ht_info_infos_0_sco);
-
-       } else if (mac->new_beacon_cnt > 1) {
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                        "new beacon cnt: %d\n",
-                        mac->new_beacon_cnt);
-       }
-
-       if (mac->new_beacon_cnt > 3) {
-               ieee80211_connection_loss(rtlpriv->mac80211.vif);
-               RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
-                        "new beacon cnt >3, disconnect !\n");
-       }
-
-chk_exit:
-
-       return true;
-}
-
-/*********************************************************
- *
- * IOT functions
- *
- *********************************************************/
-static bool rtl_chk_vendor_ouisub(struct ieee80211_hw *hw,
-                                 struct octet_string vendor_ie)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       bool matched = false;
-       static u8 athcap_1[] = { 0x00, 0x03, 0x7F };
-       static u8 athcap_2[] = { 0x00, 0x13, 0x74 };
-       static u8 broadcap_1[] = { 0x00, 0x10, 0x18 };
-       static u8 broadcap_2[] = { 0x00, 0x0a, 0xf7 };
-       static u8 broadcap_3[] = { 0x00, 0x05, 0xb5 };
-       static u8 racap[] = { 0x00, 0x0c, 0x43 };
-       static u8 ciscocap[] = { 0x00, 0x40, 0x96 };
-       static u8 marvcap[] = { 0x00, 0x50, 0x43 };
-
-       if (memcmp(vendor_ie.octet, athcap_1, 3) == 0 ||
-           memcmp(vendor_ie.octet, athcap_2, 3) == 0) {
-               rtlpriv->mac80211.vendor = PEER_ATH;
-               matched = true;
-       } else if (memcmp(vendor_ie.octet, broadcap_1, 3) == 0 ||
-                  memcmp(vendor_ie.octet, broadcap_2, 3) == 0 ||
-                  memcmp(vendor_ie.octet, broadcap_3, 3) == 0) {
-               rtlpriv->mac80211.vendor = PEER_BROAD;
-               matched = true;
-       } else if (memcmp(vendor_ie.octet, racap, 3) == 0) {
-               rtlpriv->mac80211.vendor = PEER_RAL;
-               matched = true;
-       } else if (memcmp(vendor_ie.octet, ciscocap, 3) == 0) {
-               rtlpriv->mac80211.vendor = PEER_CISCO;
-               matched = true;
-       } else if (memcmp(vendor_ie.octet, marvcap, 3) == 0) {
-               rtlpriv->mac80211.vendor = PEER_MARV;
-               matched = true;
-       }
-
-       return matched;
-}
-
-static bool rtl_find_221_ie(struct ieee80211_hw *hw, u8 *data,
-                           unsigned int len)
-{
-       struct ieee80211_mgmt *mgmt = (void *)data;
-       struct octet_string vendor_ie;
-       u8 *pos, *end;
-
-       pos = (u8 *)mgmt->u.beacon.variable;
-       end = data + len;
-       while (pos < end) {
-               if (pos[0] == 221) {
-                       vendor_ie.length = pos[1];
-                       vendor_ie.octet = &pos[2];
-                       if (rtl_chk_vendor_ouisub(hw, vendor_ie))
-                               return true;
-               }
-
-               if (pos + 2 + pos[1] > end)
-                       return false;
-
-               pos += 2 + pos[1];
-       }
-       return false;
-}
-
-void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len)
-{
-       struct rtl_priv *rtlpriv = rtl_priv(hw);
-       struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
-       struct ieee80211_hdr *hdr = (void *)data;
-       u32 vendor = PEER_UNKNOWN;
-
-       static u8 ap3_1[3] = { 0x00, 0x14, 0xbf };
-       static u8 ap3_2[3] = { 0x00, 0x1a, 0x70 };
-       static u8 ap3_3[3] = { 0x00, 0x1d, 0x7e };
-       static u8 ap4_1[3] = { 0x00, 0x90, 0xcc };
-       static u8 ap4_2[3] = { 0x00, 0x0e, 0x2e };
-       static u8 ap4_3[3] = { 0x00, 0x18, 0x02 };
-       static u8 ap4_4[3] = { 0x00, 0x17, 0x3f };
-       static u8 ap4_5[3] = { 0x00, 0x1c, 0xdf };
-       static u8 ap5_1[3] = { 0x00, 0x1c, 0xf0 };
-       static u8 ap5_2[3] = { 0x00, 0x21, 0x91 };
-       static u8 ap5_3[3] = { 0x00, 0x24, 0x01 };
-       static u8 ap5_4[3] = { 0x00, 0x15, 0xe9 };
-       static u8 ap5_5[3] = { 0x00, 0x17, 0x9A };
-       static u8 ap5_6[3] = { 0x00, 0x18, 0xE7 };
-       static u8 ap6_1[3] = { 0x00, 0x17, 0x94 };
-       static u8 ap7_1[3] = { 0x00, 0x14, 0xa4 };
-
-       if (mac->opmode != NL80211_IFTYPE_STATION)
-               return;
-
-       if (mac->link_state == MAC80211_NOLINK) {
-               mac->vendor = PEER_UNKNOWN;
-               return;
-       }
-
-       if (mac->cnt_after_linked > 2)
-               return;
-
-       /* check if this really is a beacon */
-       if (!ieee80211_is_beacon(hdr->frame_control))
-               return;
-
-       /* min. beacon length + FCS_LEN */
-       if (len <= 40 + FCS_LEN)
-               return;
-
-       /* and only beacons from the associated BSSID, please */
-       if (!ether_addr_equal_64bits(hdr->addr3, rtlpriv->mac80211.bssid))
-               return;
-
-       if (rtl_find_221_ie(hw, data, len))
-               vendor = mac->vendor;
-
-       if ((memcmp(mac->bssid, ap5_1, 3) == 0) ||
-           (memcmp(mac->bssid, ap5_2, 3) == 0) ||
-           (memcmp(mac->bssid, ap5_3, 3) == 0) ||
-           (memcmp(mac->bssid, ap5_4, 3) == 0) ||
-           (memcmp(mac->bssid, ap5_5, 3) == 0) ||
-           (memcmp(mac->bssid, ap5_6, 3) == 0) ||
-           vendor == PEER_ATH) {
-               vendor = PEER_ATH;
-               RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ath find\n");
-       } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) ||
-               (memcmp(mac->bssid, ap4_5, 3) == 0) ||
-               (memcmp(mac->bssid, ap4_1, 3) == 0) ||
-               (memcmp(mac->bssid, ap4_2, 3) == 0) ||
-               (memcmp(mac->bssid, ap4_3, 3) == 0) ||
-               vendor == PEER_RAL) {
-               RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ral find\n");
-               vendor = PEER_RAL;
-       } else if (memcmp(mac->bssid, ap6_1, 3) == 0 ||
-               vendor == PEER_CISCO) {
-               vendor = PEER_CISCO;
-               RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>cisco find\n");
-       } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) ||
-               (memcmp(mac->bssid, ap3_2, 3) == 0) ||
-               (memcmp(mac->bssid, ap3_3, 3) == 0) ||
-               vendor == PEER_BROAD) {
-               RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>broad find\n");
-               vendor = PEER_BROAD;
-       } else if (memcmp(mac->bssid, ap7_1, 3) == 0 ||
-               vendor == PEER_MARV) {
-               vendor = PEER_MARV;
-               RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>marv find\n");
-       }
-
-       mac->vendor = vendor;
-}
-
-MODULE_AUTHOR("lizhaoming      <chaoming_li@realsil.com.cn>");
-MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
-MODULE_AUTHOR("Larry Finger    <Larry.FInger@lwfinger.net>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
-
-struct rtl_global_var rtl_global_var = {};
-
-int rtl_core_module_init(void)
-{
-       if (rtl_rate_control_register())
-               pr_err("rtl: Unable to register rtl_rc, use default RC !!\n");
-
-       /* add debugfs */
-       rtl_debugfs_add_topdir();
-
-       /* init some global vars */
-       INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
-       spin_lock_init(&rtl_global_var.glb_list_lock);
-
-       return 0;
-}
-
-void rtl_core_module_exit(void)
-{
-       /*RC*/
-       rtl_rate_control_unregister();
-
-       /* remove debugfs */
-       rtl_debugfs_remove_topdir();
-}
diff --git a/drivers/staging/rtlwifi/base.h b/drivers/staging/rtlwifi/base.h
deleted file mode 100644 (file)
index 591f433..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- *
- * Copyright(c) 2009-2012  Realtek Corporation.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- *
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- *****************************************************************************/
-
-#ifndef __RTL_BASE_H__
-#define __RTL_BASE_H__
-
-enum ap_peer {
-       PEER_UNKNOWN = 0,
-       PEER_RTL = 1,
-       PEER_RTL_92SE = 2,
-       PEER_BROAD = 3,
-       PEER_RAL = 4,
-       PEER_ATH = 5,
-       PEER_CISCO = 6,
-       PEER_MARV = 7,
-       PEER_AIRGO = 9,
-       PEER_MAX = 10,
-};
-
-#define RTL_DUMMY_OFFSET       0
-#define RTL_DUMMY_UNIT         8
-#define RTL_TX_DUMMY_SIZE      (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT)
-#define RTL_TX_DESC_SIZE       32
-#define RTL_TX_HEADER_SIZE     (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE)
-
-#define MAX_BIT_RATE_40MHZ_MCS15       300     /* Mbps */
-#define MAX_BIT_RATE_40MHZ_MCS7                150     /* Mbps */
-
-#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9  867     /* Mbps */
-#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7  650     /* Mbps */
-#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9   780     /* Mbps */
-#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7   585     /* Mbps */
-
-#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9  434     /* Mbps */
-#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7  325     /* Mbps */
-#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9   390     /* Mbps */
-#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7   293     /* Mbps */
-
-#define FRAME_OFFSET_FRAME_CONTROL     0
-#define FRAME_OFFSET_DURATION          2
-#define FRAME_OFFSET_ADDRESS1          4
-#define FRAME_OFFSET_ADDRESS2          10
-#define FRAME_OFFSET_ADDRESS3          16
-#define FRAME_OFFSET_SEQUENCE          22
-#define FRAME_OFFSET_ADDRESS4          24
-#define MAX_LISTEN_INTERVAL            10
-#define MAX_RATE_TRIES                 4
-
-#define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)                \
-       WRITEEF2BYTE(_hdr, _val)
-#define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val)     \
-       WRITEEF1BYTE(_hdr, _val)
-#define SET_80211_HDR_PWR_MGNT(_hdr, _val)             \
-       SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val)
-#define SET_80211_HDR_TO_DS(_hdr, _val)                        \
-       SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val)
-
-#define SET_80211_PS_POLL_AID(_hdr, _val)              \
-       (*(u16 *)((u8 *)(_hdr) + 2) = _val)
-#define SET_80211_PS_POLL_BSSID(_hdr, _val)            \
-       ether_addr_copy(((u8 *)(_hdr)) + 4, (u8 *)(_val))
-#define SET_80211_PS_POLL_TA(_hdr, _val)               \
-       ether_addr_copy(((u8 *)(_hdr)) + 10, (u8 *)(_val))
-
-#define SET_80211_HDR_DURATION(_hdr, _val)     \
-       (*(u16 *)((u8 *)(_hdr) + FRAME_OFFSET_DURATION) = le16_to_cpu(_val))
-#define SET_80211_HDR_ADDRESS1(_hdr, _val)     \
-       CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS1, (u8 *)(_val))
-#define SET_80211_HDR_ADDRESS2(_hdr, _val)     \
-       CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS2, (u8 *)(_val))
-#define SET_80211_HDR_ADDRESS3(_hdr, _val)     \
-       CP_MACADDR((u8 *)(_hdr) + FRAME_OFFSET_ADDRESS3, (u8 *)(_val))
-#define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val)  \
-       WRITEEF2BYTE((u8 *)(_hdr) + FRAME_OFFSET_SEQUENCE, _val)
-
-#define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val)     \
-       WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val)
-#define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \
-       WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val)
-#define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \
-       WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val)
-#define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr)           \
-       READEF2BYTE(((u8 *)(__phdr)) + 34)
-#define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
-       WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val)
-#define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
-       SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \
-       (GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val))))
-
-#define SET_TX_DESC_SPE_RPT(__pdesc, __val)                    \
-       SET_BITS_TO_LE_4BYTE((__pdesc) + 8, 19, 1, __val)
-#define SET_TX_DESC_SW_DEFINE(__pdesc, __val)  \
-       SET_BITS_TO_LE_4BYTE((__pdesc) + 24, 0, 12, __val)
-
-int rtl_init_core(struct ieee80211_hw *hw);
-void rtl_deinit_core(struct ieee80211_hw *hw);
-void rtl_init_rx_config(struct ieee80211_hw *hw);
-void rtl_init_rfkill(struct ieee80211_hw *hw);
-void rtl_deinit_rfkill(struct ieee80211_hw *hw);
-
-void rtl_watch_dog_timer_callback(struct timer_list *t);
-void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
-
-bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
-int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
-                        bool isvht, u8 desc_rate);
-bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
-u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx,
-                      bool is_enc);
-
-bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb);
-void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
-                      struct ieee80211_hw *hw);
-void rtl_tx_report_handler(struct ieee80211_hw *hw, u8 *tmp_buf,
-                          u8 c2h_cmd_len);
-bool rtl_check_tx_report_acked(struct ieee80211_hw *hw);
-void rtl_wait_tx_report_acked(struct ieee80211_hw *hw, u32 wait_ms);
-u32 rtl_get_hal_edca_param(struct ieee80211_hw *hw,
-                          struct ieee80211_vif *vif,
-                          enum wireless_mode wirelessmode,
-                          struct ieee80211_tx_queue_params *param);
-
-void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
-void rtl_collect_scan_list(struct ieee80211_hw *hw, struct sk_buff *skb);
-void rtl_scan_list_expire(struct ieee80211_hw *hw);
-int rtl_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                    struct ieee80211_sta *sta, u16 tid, u16 *ssn);
-int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                   struct ieee80211_sta *sta, u16 tid);
-int rtl_tx_agg_oper(struct ieee80211_hw *hw,
-                   struct ieee80211_sta *sta, u16 tid);
-int rtl_rx_agg_start(struct ieee80211_hw *hw,
-                    struct ieee80211_sta *sta, u16 tid);
-int rtl_rx_agg_stop(struct ieee80211_hw *hw,
-                   struct ieee80211_sta *sta, u16 tid);
-void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv);
-void rtl_watchdog_wq_callback(void *data);
-void rtl_fwevt_wq_callback(void *data);
-void rtl_c2hcmd_wq_callback(void *data);
-void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
-void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val);
-
-u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw,
-                           u8 rate_index,
-                           enum wireless_mode wirelessmode);
-void rtl_get_tcb_desc(struct ieee80211_hw *hw,
-                     struct ieee80211_tx_info *info,
-                     struct ieee80211_sta *sta,
-                     struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc);
-
-int rtl_send_smps_action(struct ieee80211_hw *hw,
-                        struct ieee80211_sta *sta,
-                        enum ieee80211_smps_mode smps);
-u8 *rtl_find_ie(u8 *data, unsigned int len, u8 ie);
-void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
-u8 rtl_tid_to_ac(u8 tid);
-void rtl_easy_concurrent_retrytimer_callback(struct timer_list *t);
-extern struct rtl_global_var rtl_global_var;
-void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
-bool rtl_check_beacon_key(struct ieee80211_hw *hw, void *data,
-                         unsigned int len);
-int rtl_core_module_init(void);
-void rtl_core_module_exit(void);
-#endif
diff --git a/drivers/staging/rtlwifi/btcoexist/Makefile b/drivers/staging/rtlwifi/btcoexist/Makefile
deleted file mode 100644 (file)
index dda3779..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-btcoexist-objs :=                              \
-                       halbtc8822b1ant.o       \
-                       halbtc8822b2ant.o       \
-                       halbtc8822bwifionly.o   \
-                       halbtcoutsrc.o          \
-                       rtl_btc.o
-
-obj-$(CONFIG_RTLBTCOEXIST) += btcoexist.o
diff --git a/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h b/drivers/staging/rtlwifi/btcoexist/halbt_precomp.h
deleted file mode 100644 (file)
index 90d0f24..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-
-#ifndef        __HALBT_PRECOMP_H__
-#define __HALBT_PRECOMP_H__
-/*************************************************************
- * include files
- *************************************************************/
-#include "../wifi.h"
-#include "../efuse.h"
-#include "../base.h"
-#include "../regd.h"
-#include "../cam.h"
-#include "../ps.h"
-#include "../pci.h"
-
-#include "halbtcoutsrc.h"
-
-/* Interface type */
-#define RT_PCI_INTERFACE       1
-#define RT_USB_INTERFACE       2
-#define RT_SDIO_INTERFACE      3
-#define DEV_BUS_TYPE           RT_PCI_INTERFACE
-
-#include "halbtc8822b1ant.h"
-#include "halbtc8822b2ant.h"
-#include "halbtc8822bwifionly.h"
-
-#define GETDEFAULTADAPTER(padapter)    padapter
-
-#define BIT0   0x00000001
-#define BIT1   0x00000002
-#define BIT2   0x00000004
-#define BIT3   0x00000008
-#define BIT4   0x00000010
-#define BIT5   0x00000020
-#define BIT6   0x00000040
-#define BIT7   0x00000080
-#define BIT8   0x00000100
-#define BIT9   0x00000200
-#define BIT10  0x00000400
-#define BIT11  0x00000800
-#define BIT12  0x00001000
-#define BIT13  0x00002000
-#define BIT14  0x00004000
-#define BIT15  0x00008000
-#define BIT16  0x00010000
-#define BIT17  0x00020000
-#define BIT18  0x00040000
-#define BIT19  0x00080000
-#define BIT20  0x00100000
-#define BIT21  0x00200000
-#define BIT22  0x00400000
-#define BIT23  0x00800000
-#define BIT24  0x01000000
-#define BIT25  0x02000000
-#define BIT26  0x04000000
-#define BIT27  0x08000000
-#define BIT28  0x10000000
-#define BIT29  0x20000000
-#define BIT30  0x40000000
-#define BIT31  0x80000000
-
-#endif /* __HALBT_PRECOMP_H__ */
diff --git a/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c b/drivers/staging/rtlwifi/btcoexist/halbtc8822b1ant.c
deleted file mode 100644 (file)
index 32c7974..0000000
+++ /dev/null
@@ -1,5233 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/******************************************************************************
- *
- * Copyright(c) 2016  Realtek Corporation.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- *
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- *****************************************************************************/
-/* ************************************************************
- * Description:
- *
- * This file is for RTL8822B Co-exist mechanism
- *
- * History
- * 2012/11/15 Cosa first check in.
- *
- * *************************************************************/
-
-/* ************************************************************
- * include files
- * *************************************************************/
-/*only for rf4ce*/
-#include "halbt_precomp.h"
-
-/* ************************************************************
- * Global variables, these are static variables
- * *************************************************************/
-static struct coex_dm_8822b_1ant glcoex_dm_8822b_1ant;
-static struct coex_dm_8822b_1ant *coex_dm = &glcoex_dm_8822b_1ant;
-static struct coex_sta_8822b_1ant glcoex_sta_8822b_1ant;
-static struct coex_sta_8822b_1ant *coex_sta = &glcoex_sta_8822b_1ant;
-static struct psdscan_sta_8822b_1ant gl_psd_scan_8822b_1ant;
-static struct psdscan_sta_8822b_1ant *psd_scan = &gl_psd_scan_8822b_1ant;
-static struct rfe_type_8822b_1ant gl_rfe_type_8822b_1ant;
-static struct rfe_type_8822b_1ant *rfe_type = &gl_rfe_type_8822b_1ant;
-
-static const char *const glbt_info_src_8822b_1ant[] = {
-       "BT Info[wifi fw]", "BT Info[bt rsp]", "BT Info[bt auto report]",
-};
-
-static u32 glcoex_ver_date_8822b_1ant = 20170327;
-static u32 glcoex_ver_8822b_1ant = 0x44;
-static u32 glcoex_ver_btdesired_8822b_1ant = 0x42;
-
-/* ************************************************************
- * local function proto type if needed
- * ************************************************************
- * ************************************************************
- * local function start with halbtc8822b1ant_
- * *************************************************************/
-
-static u8 halbtc8822b1ant_wifi_rssi_state(struct btc_coexist *btcoexist,
-                                         u8 index, u8 level_num,
-                                         u8 rssi_thresh, u8 rssi_thresh1)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       s32 wifi_rssi = 0;
-       u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
-
-       btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
-
-       if (level_num == 2) {
-               if ((coex_sta->pre_wifi_rssi_state[index] ==
-                    BTC_RSSI_STATE_LOW) ||
-                   (coex_sta->pre_wifi_rssi_state[index] ==
-                    BTC_RSSI_STATE_STAY_LOW)) {
-                       if (wifi_rssi >=
-                           (rssi_thresh + BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
-                               wifi_rssi_state = BTC_RSSI_STATE_HIGH;
-                       else
-                               wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
-               } else {
-                       if (wifi_rssi < rssi_thresh)
-                               wifi_rssi_state = BTC_RSSI_STATE_LOW;
-                       else
-                               wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
-               }
-       } else if (level_num == 3) {
-               if (rssi_thresh > rssi_thresh1) {
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], wifi RSSI thresh error!!\n");
-                       return coex_sta->pre_wifi_rssi_state[index];
-               }
-
-               if ((coex_sta->pre_wifi_rssi_state[index] ==
-                    BTC_RSSI_STATE_LOW) ||
-                   (coex_sta->pre_wifi_rssi_state[index] ==
-                    BTC_RSSI_STATE_STAY_LOW)) {
-                       if (wifi_rssi >=
-                           (rssi_thresh + BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
-                               wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
-                       else
-                               wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
-               } else if ((coex_sta->pre_wifi_rssi_state[index] ==
-                           BTC_RSSI_STATE_MEDIUM) ||
-                          (coex_sta->pre_wifi_rssi_state[index] ==
-                           BTC_RSSI_STATE_STAY_MEDIUM)) {
-                       if (wifi_rssi >= (rssi_thresh1 +
-                                         BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
-                               wifi_rssi_state = BTC_RSSI_STATE_HIGH;
-                       else if (wifi_rssi < rssi_thresh)
-                               wifi_rssi_state = BTC_RSSI_STATE_LOW;
-                       else
-                               wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
-               } else {
-                       if (wifi_rssi < rssi_thresh1)
-                               wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
-                       else
-                               wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
-               }
-       }
-
-       coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
-
-       return wifi_rssi_state;
-}
-
-static void halbtc8822b1ant_update_ra_mask(struct btc_coexist *btcoexist,
-                                          bool force_exec, u32 dis_rate_mask)
-{
-       coex_dm->cur_ra_mask = dis_rate_mask;
-
-       if (force_exec || (coex_dm->pre_ra_mask != coex_dm->cur_ra_mask))
-               btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_RAMASK,
-                                  &coex_dm->cur_ra_mask);
-       coex_dm->pre_ra_mask = coex_dm->cur_ra_mask;
-}
-
-static void
-halbtc8822b1ant_auto_rate_fallback_retry(struct btc_coexist *btcoexist,
-                                        bool force_exec, u8 type)
-{
-       bool wifi_under_b_mode = false;
-
-       coex_dm->cur_arfr_type = type;
-
-       if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) {
-               switch (coex_dm->cur_arfr_type) {
-               case 0: /* normal mode */
-                       btcoexist->btc_write_4byte(btcoexist, 0x430,
-                                                  coex_dm->backup_arfr_cnt1);
-                       btcoexist->btc_write_4byte(btcoexist, 0x434,
-                                                  coex_dm->backup_arfr_cnt2);
-                       break;
-               case 1:
-                       btcoexist->btc_get(btcoexist,
-                                          BTC_GET_BL_WIFI_UNDER_B_MODE,
-                                          &wifi_under_b_mode);
-                       if (wifi_under_b_mode) {
-                               btcoexist->btc_write_4byte(btcoexist, 0x430,
-                                                          0x0);
-                               btcoexist->btc_write_4byte(btcoexist, 0x434,
-                                                          0x01010101);
-                       } else {
-                               btcoexist->btc_write_4byte(btcoexist, 0x430,
-                                                          0x0);
-                               btcoexist->btc_write_4byte(btcoexist, 0x434,
-                                                          0x04030201);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       coex_dm->pre_arfr_type = coex_dm->cur_arfr_type;
-}
-
-static void halbtc8822b1ant_retry_limit(struct btc_coexist *btcoexist,
-                                       bool force_exec, u8 type)
-{
-       coex_dm->cur_retry_limit_type = type;
-
-       if (force_exec ||
-           (coex_dm->pre_retry_limit_type != coex_dm->cur_retry_limit_type)) {
-               switch (coex_dm->cur_retry_limit_type) {
-               case 0: /* normal mode */
-                       btcoexist->btc_write_2byte(btcoexist, 0x42a,
-                                                  coex_dm->backup_retry_limit);
-                       break;
-               case 1: /* retry limit=8 */
-                       btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type;
-}
-
-static void halbtc8822b1ant_ampdu_max_time(struct btc_coexist *btcoexist,
-                                          bool force_exec, u8 type)
-{
-       coex_dm->cur_ampdu_time_type = type;
-
-       if (force_exec ||
-           (coex_dm->pre_ampdu_time_type != coex_dm->cur_ampdu_time_type)) {
-               switch (coex_dm->cur_ampdu_time_type) {
-               case 0: /* normal mode */
-                       btcoexist->btc_write_1byte(
-                               btcoexist, 0x456,
-                               coex_dm->backup_ampdu_max_time);
-                       break;
-               case 1: /* AMPDU timw = 0x38 * 32us */
-                       btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type;
-}
-
-static void halbtc8822b1ant_limited_tx(struct btc_coexist *btcoexist,
-                                      bool force_exec, u8 ra_mask_type,
-                                      u8 arfr_type, u8 retry_limit_type,
-                                      u8 ampdu_time_type)
-{
-       switch (ra_mask_type) {
-       case 0: /* normal mode */
-               halbtc8822b1ant_update_ra_mask(btcoexist, force_exec, 0x0);
-               break;
-       case 1: /* disable cck 1/2 */
-               halbtc8822b1ant_update_ra_mask(btcoexist, force_exec,
-                                              0x00000003);
-               break;
-       case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
-               halbtc8822b1ant_update_ra_mask(btcoexist, force_exec,
-                                              0x0001f1f7);
-               break;
-       default:
-               break;
-       }
-
-       halbtc8822b1ant_auto_rate_fallback_retry(btcoexist, force_exec,
-                                                arfr_type);
-       halbtc8822b1ant_retry_limit(btcoexist, force_exec, retry_limit_type);
-       halbtc8822b1ant_ampdu_max_time(btcoexist, force_exec, ampdu_time_type);
-}
-
-/*
- * rx agg size setting :
- * 1:      true / don't care / don't care
- * max: false / false / don't care
- * 7:     false / true / 7
- */
-
-static void halbtc8822b1ant_limited_rx(struct btc_coexist *btcoexist,
-                                      bool force_exec, bool rej_ap_agg_pkt,
-                                      bool bt_ctrl_agg_buf_size,
-                                      u8 agg_buf_size)
-{
-       bool reject_rx_agg = rej_ap_agg_pkt;
-       bool bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
-       u8 rx_agg_size = agg_buf_size;
-
-       /* ============================================ */
-       /*      Rx Aggregation related setting */
-       /* ============================================ */
-       btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
-                          &reject_rx_agg);
-       /* decide BT control aggregation buf size or not */
-       btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
-                          &bt_ctrl_rx_agg_size);
-       /* aggregation buf size, only work when BT control Rx aggregation size*/
-       btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
-       /* real update aggregation setting */
-       btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
-}
-
-static void halbtc8822b1ant_query_bt_info(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       u8 h2c_parameter[1] = {0};
-
-       if (coex_sta->bt_disabled) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], No query BT info because BT is disabled!\n");
-               return;
-       }
-
-       h2c_parameter[0] |= BIT(0); /* trigger */
-
-       btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], WL query BT info!!\n");
-}
-
-static void halbtc8822b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
-       u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
-       static u8 num_of_bt_counter_chk, cnt_slave, cnt_autoslot_hang;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-
-       reg_hp_txrx = 0x770;
-       reg_lp_txrx = 0x774;
-
-       u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
-       reg_hp_tx = u32tmp & MASKLWORD;
-       reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
-
-       u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
-       reg_lp_tx = u32tmp & MASKLWORD;
-       reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
-
-       coex_sta->high_priority_tx = reg_hp_tx;
-       coex_sta->high_priority_rx = reg_hp_rx;
-       coex_sta->low_priority_tx = reg_lp_tx;
-       coex_sta->low_priority_rx = reg_lp_rx;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",
-                reg_hp_rx, reg_hp_tx, reg_lp_rx, reg_lp_tx);
-
-       /* reset counter */
-       btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
-
-       if ((coex_sta->low_priority_tx > 1150) &&
-           (!coex_sta->c2h_bt_inquiry_page))
-               coex_sta->pop_event_cnt++;
-
-       if ((coex_sta->low_priority_rx >= 1150) &&
-           (coex_sta->low_priority_rx >= coex_sta->low_priority_tx) &&
-           (!coex_sta->under_ips) && (!coex_sta->c2h_bt_inquiry_page) &&
-           (coex_sta->bt_link_exist)) {
-               if (cnt_slave >= 3) {
-                       bt_link_info->slave_role = true;
-                       cnt_slave = 3;
-               } else {
-                       cnt_slave++;
-               }
-       } else {
-               if (cnt_slave == 0) {
-                       bt_link_info->slave_role = false;
-                       cnt_slave = 0;
-               } else {
-                       cnt_slave--;
-               }
-       }
-
-       if (coex_sta->is_tdma_btautoslot) {
-               if ((coex_sta->low_priority_tx >= 1300) &&
-                   (coex_sta->low_priority_rx <= 150)) {
-                       if (cnt_autoslot_hang >= 2) {
-                               coex_sta->is_tdma_btautoslot_hang = true;
-                               cnt_autoslot_hang = 2;
-                       } else {
-                               cnt_autoslot_hang++;
-                       }
-               } else {
-                       if (cnt_autoslot_hang == 0) {
-                               coex_sta->is_tdma_btautoslot_hang = false;
-                               cnt_autoslot_hang = 0;
-                       } else {
-                               cnt_autoslot_hang--;
-                       }
-               }
-       }
-
-       if (bt_link_info->hid_only) {
-               if (coex_sta->low_priority_rx > 50)
-                       coex_sta->is_hid_low_pri_tx_overhead = true;
-               else
-                       coex_sta->is_hid_low_pri_tx_overhead = false;
-       }
-
-       if ((coex_sta->high_priority_tx == 0) &&
-           (coex_sta->high_priority_rx == 0) &&
-           (coex_sta->low_priority_tx == 0) &&
-           (coex_sta->low_priority_rx == 0)) {
-               num_of_bt_counter_chk++;
-
-               if (num_of_bt_counter_chk >= 3) {
-                       halbtc8822b1ant_query_bt_info(btcoexist);
-                       num_of_bt_counter_chk = 0;
-               }
-       }
-}
-
-static void halbtc8822b1ant_monitor_wifi_ctr(struct btc_coexist *btcoexist)
-{
-       s32 wifi_rssi = 0;
-       bool wifi_busy = false, wifi_under_b_mode = false, wifi_scan = false;
-       static u8 cck_lock_counter, wl_noisy_count0, wl_noisy_count1 = 3,
-                                                    wl_noisy_count2;
-       u32 total_cnt, cck_cnt;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-       btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE,
-                          &wifi_under_b_mode);
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &wifi_scan);
-
-       coex_sta->crc_ok_cck = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_OK_CCK");
-       coex_sta->crc_ok_11g = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_OK_LEGACY");
-       coex_sta->crc_ok_11n = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_OK_HT");
-       coex_sta->crc_ok_11n_vht = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_OK_VHT");
-
-       coex_sta->crc_err_cck = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_ERROR_CCK");
-       coex_sta->crc_err_11g = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_ERROR_LEGACY");
-       coex_sta->crc_err_11n = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_ERROR_HT");
-       coex_sta->crc_err_11n_vht = btcoexist->btc_phydm_query_phy_counter(
-               btcoexist, "PHYDM_INFO_CRC32_ERROR_VHT");
-
-       cck_cnt = coex_sta->crc_ok_cck + coex_sta->crc_err_cck;
-
-       if (cck_cnt > 250) {
-               if (wl_noisy_count2 < 3)
-                       wl_noisy_count2++;
-
-               if (wl_noisy_count2 == 3) {
-                       wl_noisy_count0 = 0;
-                       wl_noisy_count1 = 0;
-               }
-
-       } else if (cck_cnt < 50) {
-               if (wl_noisy_count0 < 3)
-                       wl_noisy_count0++;
-
-               if (wl_noisy_count0 == 3) {
-                       wl_noisy_count1 = 0;
-                       wl_noisy_count2 = 0;
-               }
-
-       } else {
-               if (wl_noisy_count1 < 3)
-                       wl_noisy_count1++;
-
-               if (wl_noisy_count1 == 3) {
-                       wl_noisy_count0 = 0;
-                       wl_noisy_count2 = 0;
-               }
-       }
-
-       if (wl_noisy_count2 == 3)
-               coex_sta->wl_noisy_level = 2;
-       else if (wl_noisy_count1 == 3)
-               coex_sta->wl_noisy_level = 1;
-       else
-               coex_sta->wl_noisy_level = 0;
-
-       if ((wifi_busy) && (wifi_rssi >= 30) && (!wifi_under_b_mode)) {
-               total_cnt = coex_sta->crc_ok_cck + coex_sta->crc_ok_11g +
-                           coex_sta->crc_ok_11n + coex_sta->crc_ok_11n_vht;
-
-               if ((coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_ACL_BUSY) ||
-                   (coex_dm->bt_status ==
-                    BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY) ||
-                   (coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_SCO_BUSY)) {
-                       if (coex_sta->crc_ok_cck >
-                           (total_cnt - coex_sta->crc_ok_cck)) {
-                               if (cck_lock_counter < 3)
-                                       cck_lock_counter++;
-                       } else {
-                               if (cck_lock_counter > 0)
-                                       cck_lock_counter--;
-                       }
-
-               } else {
-                       if (cck_lock_counter > 0)
-                               cck_lock_counter--;
-               }
-       } else {
-               if (cck_lock_counter > 0)
-                       cck_lock_counter--;
-       }
-
-       if (!coex_sta->pre_ccklock) {
-               if (cck_lock_counter >= 3)
-                       coex_sta->cck_lock = true;
-               else
-                       coex_sta->cck_lock = false;
-       } else {
-               if (cck_lock_counter == 0)
-                       coex_sta->cck_lock = false;
-               else
-                       coex_sta->cck_lock = true;
-       }
-
-       if (coex_sta->cck_lock)
-               coex_sta->cck_ever_lock = true;
-
-       coex_sta->pre_ccklock = coex_sta->cck_lock;
-}
-
-static bool
-halbtc8822b1ant_is_wifi_status_changed(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       static bool pre_wifi_busy, pre_under_4way, pre_bt_hs_on,
-               pre_rf4ce_enabled, pre_bt_off, pre_bt_slave,
-               pre_hid_low_pri_tx_overhead, pre_wifi_under_lps,
-               pre_bt_setup_link;
-       static u8 pre_hid_busy_num, pre_wl_noisy_level;
-       bool wifi_busy = false, under_4way = false, bt_hs_on = false,
-            rf4ce_enabled = false;
-       bool wifi_connected = false;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
-                          &wifi_connected);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
-                          &under_4way);
-
-       if (coex_sta->bt_disabled != pre_bt_off) {
-               pre_bt_off = coex_sta->bt_disabled;
-
-               if (coex_sta->bt_disabled)
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], BT is disabled !!\n");
-               else
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], BT is enabled !!\n");
-
-               coex_sta->bt_coex_supported_feature = 0;
-               coex_sta->bt_coex_supported_version = 0;
-               return true;
-       }
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_RF4CE_CONNECTED,
-                          &rf4ce_enabled);
-
-       if (rf4ce_enabled != pre_rf4ce_enabled) {
-               pre_rf4ce_enabled = rf4ce_enabled;
-
-               if (rf4ce_enabled)
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], rf4ce is enabled !!\n");
-               else
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], rf4ce is disabled !!\n");
-
-               return true;
-       }
-
-       if (wifi_connected) {
-               if (wifi_busy != pre_wifi_busy) {
-                       pre_wifi_busy = wifi_busy;
-                       return true;
-               }
-               if (under_4way != pre_under_4way) {
-                       pre_under_4way = under_4way;
-                       return true;
-               }
-               if (bt_hs_on != pre_bt_hs_on) {
-                       pre_bt_hs_on = bt_hs_on;
-                       return true;
-               }
-               if (coex_sta->wl_noisy_level != pre_wl_noisy_level) {
-                       pre_wl_noisy_level = coex_sta->wl_noisy_level;
-                       return true;
-               }
-               if (coex_sta->under_lps != pre_wifi_under_lps) {
-                       pre_wifi_under_lps = coex_sta->under_lps;
-                       if (coex_sta->under_lps)
-                               return true;
-               }
-       }
-
-       if (!coex_sta->bt_disabled) {
-               if (coex_sta->hid_busy_num != pre_hid_busy_num) {
-                       pre_hid_busy_num = coex_sta->hid_busy_num;
-                       return true;
-               }
-
-               if (bt_link_info->slave_role != pre_bt_slave) {
-                       pre_bt_slave = bt_link_info->slave_role;
-                       return true;
-               }
-
-               if (pre_hid_low_pri_tx_overhead !=
-                   coex_sta->is_hid_low_pri_tx_overhead) {
-                       pre_hid_low_pri_tx_overhead =
-                               coex_sta->is_hid_low_pri_tx_overhead;
-                       return true;
-               }
-
-               if (pre_bt_setup_link != coex_sta->is_setup_link) {
-                       pre_bt_setup_link = coex_sta->is_setup_link;
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-static void halbtc8822b1ant_update_bt_link_info(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool bt_hs_on = false;
-       bool bt_busy = false;
-
-       coex_sta->num_of_profile = 0;
-
-       /* set link exist status */
-       if (!(coex_sta->bt_info & BT_INFO_8822B_1ANT_B_CONNECTION)) {
-               coex_sta->bt_link_exist = false;
-               coex_sta->pan_exist = false;
-               coex_sta->a2dp_exist = false;
-               coex_sta->hid_exist = false;
-               coex_sta->sco_exist = false;
-       } else { /* connection exists */
-               coex_sta->bt_link_exist = true;
-               if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_FTP) {
-                       coex_sta->pan_exist = true;
-                       coex_sta->num_of_profile++;
-               } else {
-                       coex_sta->pan_exist = false;
-               }
-
-               if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_A2DP) {
-                       coex_sta->a2dp_exist = true;
-                       coex_sta->num_of_profile++;
-               } else {
-                       coex_sta->a2dp_exist = false;
-               }
-
-               if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_HID) {
-                       coex_sta->hid_exist = true;
-                       coex_sta->num_of_profile++;
-               } else {
-                       coex_sta->hid_exist = false;
-               }
-
-               if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_SCO_ESCO) {
-                       coex_sta->sco_exist = true;
-                       coex_sta->num_of_profile++;
-               } else {
-                       coex_sta->sco_exist = false;
-               }
-       }
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
-       bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
-       bt_link_info->sco_exist = coex_sta->sco_exist;
-       bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
-       bt_link_info->pan_exist = coex_sta->pan_exist;
-       bt_link_info->hid_exist = coex_sta->hid_exist;
-       bt_link_info->acl_busy = coex_sta->acl_busy;
-
-       /* work around for HS mode. */
-       if (bt_hs_on) {
-               bt_link_info->pan_exist = true;
-               bt_link_info->bt_link_exist = true;
-       }
-
-       /* check if Sco only */
-       if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
-           !bt_link_info->pan_exist && !bt_link_info->hid_exist)
-               bt_link_info->sco_only = true;
-       else
-               bt_link_info->sco_only = false;
-
-       /* check if A2dp only */
-       if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist &&
-           !bt_link_info->pan_exist && !bt_link_info->hid_exist)
-               bt_link_info->a2dp_only = true;
-       else
-               bt_link_info->a2dp_only = false;
-
-       /* check if Pan only */
-       if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
-           bt_link_info->pan_exist && !bt_link_info->hid_exist)
-               bt_link_info->pan_only = true;
-       else
-               bt_link_info->pan_only = false;
-
-       /* check if Hid only */
-       if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
-           !bt_link_info->pan_exist && bt_link_info->hid_exist)
-               bt_link_info->hid_only = true;
-       else
-               bt_link_info->hid_only = false;
-
-       if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_INQ_PAGE) {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_INQ_PAGE;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT Inq/page!!!\n");
-       } else if (!(coex_sta->bt_info & BT_INFO_8822B_1ANT_B_CONNECTION)) {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
-       } else if (coex_sta->bt_info == BT_INFO_8822B_1ANT_B_CONNECTION) {
-               /* connection exists but no busy */
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
-       } else if (((coex_sta->bt_info & BT_INFO_8822B_1ANT_B_SCO_ESCO) ||
-                   (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_SCO_BUSY)) &&
-                  (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_ACL_BUSY)) {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT ACL SCO busy!!!\n");
-       } else if ((coex_sta->bt_info & BT_INFO_8822B_1ANT_B_SCO_ESCO) ||
-                  (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_SCO_BUSY)) {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_SCO_BUSY;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
-       } else if (coex_sta->bt_info & BT_INFO_8822B_1ANT_B_ACL_BUSY) {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_ACL_BUSY;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
-       } else {
-               coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_MAX;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
-       }
-
-       if ((coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_ACL_BUSY) ||
-           (coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_SCO_BUSY) ||
-           (coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY))
-               bt_busy = true;
-       else
-               bt_busy = false;
-
-       btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-}
-
-static void halbtc8822b1ant_update_wifi_ch_info(struct btc_coexist *btcoexist,
-                                               u8 type)
-{
-       u8 h2c_parameter[3] = {0};
-       u32 wifi_bw;
-       u8 wifi_central_chnl;
-
-       /* only 2.4G we need to inform bt the chnl mask */
-       btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
-                          &wifi_central_chnl);
-       if ((type == BTC_MEDIA_CONNECT) && (wifi_central_chnl <= 14)) {
-               /* enable BT AFH skip WL channel for 8822b
-                * because BT Rx LO interference
-                */
-               h2c_parameter[0] = 0x1;
-               h2c_parameter[1] = wifi_central_chnl;
-
-               btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
-               if (wifi_bw == BTC_WIFI_BW_HT40)
-                       h2c_parameter[2] = 0x30;
-               else
-                       h2c_parameter[2] = 0x20;
-       }
-
-       coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
-       coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
-       coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
-
-       btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
-}
-
-static u8 halbtc8822b1ant_action_algorithm(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool bt_hs_on = false;
-       u8 algorithm = BT_8822B_1ANT_COEX_ALGO_UNDEFINED;
-       u8 num_of_diff_profile = 0;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
-       if (!bt_link_info->bt_link_exist) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], No BT link exists!!!\n");
-               return algorithm;
-       }
-
-       if (bt_link_info->sco_exist)
-               num_of_diff_profile++;
-       if (bt_link_info->hid_exist)
-               num_of_diff_profile++;
-       if (bt_link_info->pan_exist)
-               num_of_diff_profile++;
-       if (bt_link_info->a2dp_exist)
-               num_of_diff_profile++;
-
-       if (num_of_diff_profile == 1) {
-               if (bt_link_info->sco_exist) {
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], BT Profile = SCO only\n");
-                       algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
-               } else {
-                       if (bt_link_info->hid_exist) {
-                               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                        "[BTCoex], BT Profile = HID only\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
-                       } else if (bt_link_info->a2dp_exist) {
-                               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                        "[BTCoex], BT Profile = A2DP only\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_A2DP;
-                       } else if (bt_link_info->pan_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = PAN(HS) only\n");
-                                       algorithm =
-                                               BT_8822B_1ANT_COEX_ALGO_PANHS;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = PAN(EDR) only\n");
-                                       algorithm =
-                                               BT_8822B_1ANT_COEX_ALGO_PANEDR;
-                               }
-                       }
-               }
-       } else if (num_of_diff_profile == 2) {
-               if (bt_link_info->sco_exist) {
-                       if (bt_link_info->hid_exist) {
-                               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                        "[BTCoex], BT Profile = SCO + HID\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
-                       } else if (bt_link_info->a2dp_exist) {
-                               RT_TRACE(
-                                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                       "[BTCoex], BT Profile = SCO + A2DP ==> SCO\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
-                       } else if (bt_link_info->pan_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + PAN(HS)\n");
-                                       algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + PAN(EDR)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
-                               }
-                       }
-               } else {
-                       if (bt_link_info->hid_exist &&
-                           bt_link_info->a2dp_exist) {
-                               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                        "[BTCoex], BT Profile = HID + A2DP\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
-                       } else if (bt_link_info->hid_exist &&
-                                  bt_link_info->pan_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = HID + PAN(HS)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = HID + PAN(EDR)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
-                               }
-                       } else if (bt_link_info->pan_exist &&
-                                  bt_link_info->a2dp_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = A2DP + PAN(HS)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_A2DP_PANHS;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = A2DP + PAN(EDR)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_A2DP;
-                               }
-                       }
-               }
-       } else if (num_of_diff_profile == 3) {
-               if (bt_link_info->sco_exist) {
-                       if (bt_link_info->hid_exist &&
-                           bt_link_info->a2dp_exist) {
-                               RT_TRACE(
-                                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                       "[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n");
-                               algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
-                       } else if (bt_link_info->hid_exist &&
-                                  bt_link_info->pan_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + HID + PAN(HS)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
-                               }
-                       } else if (bt_link_info->pan_exist &&
-                                  bt_link_info->a2dp_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n");
-                                       algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
-                               }
-                       }
-               } else {
-                       if (bt_link_info->hid_exist &&
-                           bt_link_info->pan_exist &&
-                           bt_link_info->a2dp_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n");
-                                       algorithm =
-                                       BT_8822B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
-                               }
-                       }
-               }
-       } else if (num_of_diff_profile >= 3) {
-               if (bt_link_info->sco_exist) {
-                       if (bt_link_info->hid_exist &&
-                           bt_link_info->pan_exist &&
-                           bt_link_info->a2dp_exist) {
-                               if (bt_hs_on) {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n");
-
-                               } else {
-                                       RT_TRACE(
-                                               rtlpriv, COMP_BT_COEXIST,
-                                               DBG_LOUD,
-                                               "[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
-                                       algorithm =
-                                           BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
-                               }
-                       }
-               }
-       }
-
-       return algorithm;
-}
-
-static void halbtc8822b1ant_low_penalty_ra(struct btc_coexist *btcoexist,
-                                          bool force_exec, bool low_penalty_ra)
-{
-       coex_dm->cur_low_penalty_ra = low_penalty_ra;
-
-       if (!force_exec) {
-               if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
-                       return;
-       }
-
-       if (low_penalty_ra)
-               btcoexist->btc_phydm_modify_ra_pcr_threshold(btcoexist, 0, 25);
-       else
-               btcoexist->btc_phydm_modify_ra_pcr_threshold(btcoexist, 0, 0);
-
-       coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
-}
-
-static void halbtc8822b1ant_write_score_board(struct btc_coexist *btcoexist,
-                                             u16 bitpos, bool state)
-{
-       static u16 originalval = 0x8002;
-
-       if (state)
-               originalval = originalval | bitpos;
-       else
-               originalval = originalval & (~bitpos);
-
-       btcoexist->btc_write_2byte(btcoexist, 0xaa, originalval);
-}
-
-static void halbtc8822b1ant_read_score_board(struct btc_coexist *btcoexist,
-                                            u16 *score_board_val)
-{
-       *score_board_val =
-               (btcoexist->btc_read_2byte(btcoexist, 0xaa)) & 0x7fff;
-}
-
-static void halbtc8822b1ant_post_state_to_bt(struct btc_coexist *btcoexist,
-                                            u16 type, bool state)
-{
-       halbtc8822b1ant_write_score_board(btcoexist, (u16)type, state);
-}
-
-static void
-halbtc8822b1ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       static u32 bt_disable_cnt;
-       bool bt_active = true, bt_disabled = false, wifi_under_5g = false;
-       u16 u16tmp;
-
-       /* This function check if bt is disabled */
-
-       /* Read BT on/off status from scoreboard[1],
-        * enable this only if BT patch support this feature
-        */
-       halbtc8822b1ant_read_score_board(btcoexist, &u16tmp);
-
-       bt_active = u16tmp & BIT(1);
-
-       if (bt_active) {
-               bt_disable_cnt = 0;
-               bt_disabled = false;
-               btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
-                                  &bt_disabled);
-       } else {
-               bt_disable_cnt++;
-               if (bt_disable_cnt >= 2) {
-                       bt_disabled = true;
-                       bt_disable_cnt = 2;
-               }
-
-               btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
-                                  &bt_disabled);
-       }
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
-
-       if ((wifi_under_5g) || (bt_disabled))
-               halbtc8822b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, false);
-       else
-               halbtc8822b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, true);
-
-       if (coex_sta->bt_disabled != bt_disabled) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], BT is from %s to %s!!\n",
-                        (coex_sta->bt_disabled ? "disabled" : "enabled"),
-                        (bt_disabled ? "disabled" : "enabled"));
-               coex_sta->bt_disabled = bt_disabled;
-       }
-}
-
-static void halbtc8822b1ant_enable_gnt_to_gpio(struct btc_coexist *btcoexist,
-                                              bool isenable)
-{
-       static u8 bit_val[5] = {0, 0, 0, 0, 0};
-       static bool state;
-
-       if (!btcoexist->dbg_mode_1ant)
-               return;
-
-       if (state == isenable)
-               return;
-
-       state = isenable;
-
-       if (isenable) {
-               /* enable GNT_WL, GNT_BT to GPIO for debug */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x8, 0x1);
-
-               /* store original value */
-               bit_val[0] =
-                       (btcoexist->btc_read_1byte(btcoexist, 0x66) & BIT(4)) >>
-                       4; /*0x66[4] */
-               bit_val[1] = (btcoexist->btc_read_1byte(btcoexist, 0x67) &
-                             BIT(0)); /*0x66[8] */
-               bit_val[2] =
-                       (btcoexist->btc_read_1byte(btcoexist, 0x42) & BIT(3)) >>
-                       3; /*0x40[19] */
-               bit_val[3] =
-                       (btcoexist->btc_read_1byte(btcoexist, 0x65) & BIT(7)) >>
-                       7; /*0x64[15] */
-               bit_val[4] =
-                       (btcoexist->btc_read_1byte(btcoexist, 0x72) & BIT(2)) >>
-                       2; /*0x70[18] */
-
-               /*  switch GPIO Mux */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x66, BIT(4),
-                                                  0x0); /*0x66[4] = 0 */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, BIT(0),
-                                                  0x0); /*0x66[8] = 0 */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x42, BIT(3),
-                                                  0x0); /*0x40[19] = 0 */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x65, BIT(7),
-                                                  0x0); /*0x64[15] = 0 */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x72, BIT(2),
-                                                  0x0); /*0x70[18] = 0 */
-
-       } else {
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x8, 0x0);
-
-               /*  Restore original value  */
-               /*  switch GPIO Mux */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x66, BIT(4),
-                                                  bit_val[0]); /*0x66[4] = 0 */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, BIT(0),
-                                                  bit_val[1]); /*0x66[8] = 0 */
-               btcoexist->btc_write_1byte_bitmask(
-                       btcoexist, 0x42, BIT(3), bit_val[2]); /*0x40[19] = 0 */
-               btcoexist->btc_write_1byte_bitmask(
-                       btcoexist, 0x65, BIT(7), bit_val[3]); /*0x64[15] = 0 */
-               btcoexist->btc_write_1byte_bitmask(
-                       btcoexist, 0x72, BIT(2), bit_val[4]); /*0x70[18] = 0 */
-       }
-}
-
-static u32
-halbtc8822b1ant_ltecoex_indirect_read_reg(struct btc_coexist *btcoexist,
-                                         u16 reg_addr)
-{
-       u32 delay_count = 0;
-
-       /* wait for ready bit before access 0x1700 */
-       while (1) {
-               if ((btcoexist->btc_read_1byte(btcoexist, 0x1703) & BIT(5)) ==
-                   0) {
-                       mdelay(50);
-                       delay_count++;
-                       if (delay_count >= 10) {
-                               delay_count = 0;
-                               break;
-                       }
-               } else {
-                       break;
-               }
-       }
-
-       btcoexist->btc_write_4byte(btcoexist, 0x1700, 0x800F0000 | reg_addr);
-
-       return btcoexist->btc_read_4byte(btcoexist, 0x1708); /* get read data */
-}
-
-static void
-halbtc8822b1ant_ltecoex_indirect_write_reg(struct btc_coexist *btcoexist,
-                                          u16 reg_addr, u32 bit_mask,
-                                          u32 reg_value)
-{
-       u32 val, i = 0, bitpos = 0, delay_count = 0;
-
-       if (bit_mask == 0x0)
-               return;
-
-       if (bit_mask == 0xffffffff) {
-               /* wait for ready bit before access 0x1700/0x1704 */
-               while (1) {
-                       if ((btcoexist->btc_read_1byte(btcoexist, 0x1703) &
-                            BIT(5)) == 0) {
-                               mdelay(50);
-                               delay_count++;
-                               if (delay_count >= 10) {
-                                       delay_count = 0;
-                                       break;
-                               }
-                       } else {
-                               break;
-                       }
-               }
-
-               btcoexist->btc_write_4byte(btcoexist, 0x1704,
-                                          reg_value); /* put write data */
-
-               btcoexist->btc_write_4byte(btcoexist, 0x1700,
-                                          0xc00F0000 | reg_addr);
-       } else {
-               for (i = 0; i <= 31; i++) {
-                       if (((bit_mask >> i) & 0x1) == 0x1) {
-                               bitpos = i;
-                               break;
-                       }
-               }
-
-               /* read back register value before write */
-               val = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
-                                                               reg_addr);
-               val = (val & (~bit_mask)) | (reg_value << bitpos);
-
-               /* wait for ready bit before access 0x1700/0x1704 */
-               while (1) {
-                       if ((btcoexist->btc_read_1byte(btcoexist, 0x1703) &
-                            BIT(5)) == 0) {
-                               mdelay(50);
-                               delay_count++;
-                               if (delay_count >= 10) {
-                                       delay_count = 0;
-                                       break;
-                               }
-                       } else {
-                               break;
-                       }
-               }
-
-               btcoexist->btc_write_4byte(btcoexist, 0x1704,
-                                          val); /* put write data */
-
-               btcoexist->btc_write_4byte(btcoexist, 0x1700,
-                                          0xc00F0000 | reg_addr);
-       }
-}
-
-static void halbtc8822b1ant_ltecoex_enable(struct btc_coexist *btcoexist,
-                                          bool enable)
-{
-       u8 val;
-
-       val = (enable) ? 1 : 0;
-       /* 0x38[7] */
-       halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist, 0x38, 0x80, val);
-}
-
-static void
-halbtc8822b1ant_ltecoex_pathcontrol_owner(struct btc_coexist *btcoexist,
-                                         bool wifi_control)
-{
-       u8 val;
-
-       val = (wifi_control) ? 1 : 0;
-       /* 0x70[26] */
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x4, val);
-}
-
-static void halbtc8822b1ant_ltecoex_set_gnt_bt(struct btc_coexist *btcoexist,
-                                              u8 control_block,
-                                              bool sw_control, u8 state)
-{
-       u32 val = 0, bit_mask;
-
-       state = state & 0x1;
-       /*LTE indirect 0x38=0xccxx (sw : gnt_wl=1,sw gnt_bt=1)
-        *0x38=0xddxx (sw : gnt_bt=1 , sw gnt_wl=0)
-        *0x38=0x55xx(hw pta :gnt_wl /gnt_bt )
-        */
-       val = (sw_control) ? ((state << 1) | 0x1) : 0;
-
-       switch (control_block) {
-       case BT_8822B_1ANT_GNT_BLOCK_RFC_BB:
-       default:
-               bit_mask = 0xc000;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[15:14] */
-               bit_mask = 0x0c00;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[11:10] */
-               break;
-       case BT_8822B_1ANT_GNT_BLOCK_RFC:
-               bit_mask = 0xc000;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[15:14] */
-               break;
-       case BT_8822B_1ANT_GNT_BLOCK_BB:
-               bit_mask = 0x0c00;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[11:10] */
-               break;
-       }
-}
-
-static void halbtc8822b1ant_ltecoex_set_gnt_wl(struct btc_coexist *btcoexist,
-                                              u8 control_block,
-                                              bool sw_control, u8 state)
-{
-       u32 val = 0, bit_mask;
-       /*LTE indirect 0x38=0xccxx (sw : gnt_wl=1,sw gnt_bt=1)
-        *0x38=0xddxx (sw : gnt_bt=1 , sw gnt_wl=0)
-        *0x38=0x55xx(hw pta :gnt_wl /gnt_bt )
-        */
-
-       state = state & 0x1;
-       val = (sw_control) ? ((state << 1) | 0x1) : 0;
-
-       switch (control_block) {
-       case BT_8822B_1ANT_GNT_BLOCK_RFC_BB:
-       default:
-               bit_mask = 0x3000;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[13:12] */
-               bit_mask = 0x0300;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[9:8] */
-               break;
-       case BT_8822B_1ANT_GNT_BLOCK_RFC:
-               bit_mask = 0x3000;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[13:12] */
-               break;
-       case BT_8822B_1ANT_GNT_BLOCK_BB:
-               bit_mask = 0x0300;
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, 0x38, bit_mask, val); /* 0x38[9:8] */
-               break;
-       }
-}
-
-static void
-halbtc8822b1ant_ltecoex_set_coex_table(struct btc_coexist *btcoexist,
-                                      u8 table_type, u16 table_content)
-{
-       u16 reg_addr = 0x0000;
-
-       switch (table_type) {
-       case BT_8822B_1ANT_CTT_WL_VS_LTE:
-               reg_addr = 0xa0;
-               break;
-       case BT_8822B_1ANT_CTT_BT_VS_LTE:
-               reg_addr = 0xa4;
-               break;
-       }
-
-       if (reg_addr != 0x0000)
-               halbtc8822b1ant_ltecoex_indirect_write_reg(
-                       btcoexist, reg_addr, 0xffff,
-                       table_content); /* 0xa0[15:0] or 0xa4[15:0] */
-}
-
-static void halbtc8822b1ant_set_wltoggle_coex_table(
-       struct btc_coexist *btcoexist, bool force_exec, u8 interval,
-       u8 val0x6c4_b0, u8 val0x6c4_b1, u8 val0x6c4_b2, u8 val0x6c4_b3)
-{
-       static u8 pre_h2c_parameter[6] = {0};
-       u8 cur_h2c_parameter[6] = {0};
-       u8 i, match_cnt = 0;
-
-       cur_h2c_parameter[0] = 0x7; /* op_code, 0x7= wlan toggle slot*/
-
-       cur_h2c_parameter[1] = interval;
-       cur_h2c_parameter[2] = val0x6c4_b0;
-       cur_h2c_parameter[3] = val0x6c4_b1;
-       cur_h2c_parameter[4] = val0x6c4_b2;
-       cur_h2c_parameter[5] = val0x6c4_b3;
-
-       if (!force_exec) {
-               for (i = 1; i <= 5; i++) {
-                       if (cur_h2c_parameter[i] != pre_h2c_parameter[i])
-                               break;
-
-                       match_cnt++;
-               }
-
-               if (match_cnt == 5)
-                       return;
-       }
-
-       for (i = 1; i <= 5; i++)
-               pre_h2c_parameter[i] = cur_h2c_parameter[i];
-
-       btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, cur_h2c_parameter);
-}
-
-static void halbtc8822b1ant_set_coex_table(struct btc_coexist *btcoexist,
-                                          u32 val0x6c0, u32 val0x6c4,
-                                          u32 val0x6c8, u8 val0x6cc)
-{
-       btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
-
-       btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
-
-       btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
-
-       btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
-}
-
-static void halbtc8822b1ant_coex_table(struct btc_coexist *btcoexist,
-                                      bool force_exec, u32 val0x6c0,
-                                      u32 val0x6c4, u32 val0x6c8, u8 val0x6cc)
-{
-       coex_dm->cur_val0x6c0 = val0x6c0;
-       coex_dm->cur_val0x6c4 = val0x6c4;
-       coex_dm->cur_val0x6c8 = val0x6c8;
-       coex_dm->cur_val0x6cc = val0x6cc;
-
-       if (!force_exec) {
-               if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
-                   (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
-                   (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
-                   (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
-                       return;
-       }
-       halbtc8822b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, val0x6c8,
-                                      val0x6cc);
-
-       coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
-       coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
-       coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
-       coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
-}
-
-static void halbtc8822b1ant_coex_table_with_type(struct btc_coexist *btcoexist,
-                                                bool force_exec, u8 type)
-{
-       u32 break_table;
-       u8 select_table;
-
-       coex_sta->coex_table_type = type;
-
-       if (coex_sta->concurrent_rx_mode_on) {
-               break_table = 0xf0ffffff; /* set WL hi-pri can break BT */
-               select_table = 0x3; /* set Tx response = Hi-Pri
-                                    * (ex: Transmitting ACK,BA,CTS)
-                                    */
-       } else {
-               break_table = 0xffffff;
-               select_table = 0x3;
-       }
-
-       switch (type) {
-       case 0:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0x55555555, break_table,
-                                          select_table);
-               break;
-       case 1:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0x5a5a5a5a, break_table,
-                                          select_table);
-               break;
-       case 2:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaa5a5a5a,
-                                          0xaa5a5a5a, break_table,
-                                          select_table);
-               break;
-       case 3:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0xaa5a5a5a, break_table,
-                                          select_table);
-               break;
-       case 4:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaa555555,
-                                          0xaa5a5a5a, break_table,
-                                          select_table);
-               break;
-       case 5:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
-                                          0x5a5a5a5a, break_table,
-                                          select_table);
-               break;
-       case 6:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0xaaaaaaaa, break_table,
-                                          select_table);
-               break;
-       case 7:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa,
-                                          0xaaaaaaaa, break_table,
-                                          select_table);
-               break;
-       case 8:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xffffffff,
-                                          0xffffffff, break_table,
-                                          select_table);
-               break;
-       case 9:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x5a5a5555,
-                                          0xaaaa5a5a, break_table,
-                                          select_table);
-               break;
-       case 10:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaaaa5aaa,
-                                          0xaaaa5aaa, break_table,
-                                          select_table);
-               break;
-       case 11:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaaaaa5aa,
-                                          0xaaaaaaaa, break_table,
-                                          select_table);
-               break;
-       case 12:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaaaaa5aa,
-                                          0xaaaaa5aa, break_table,
-                                          select_table);
-               break;
-       case 13:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0xaaaa5a5a, break_table,
-                                          select_table);
-               break;
-       case 14:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x5a5a555a,
-                                          0xaaaa5a5a, break_table,
-                                          select_table);
-               break;
-       case 15:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0xaaaa55aa, break_table,
-                                          select_table);
-               break;
-       case 16:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x5a5a555a,
-                                          0x5a5a555a, break_table,
-                                          select_table);
-               break;
-       case 17:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xaaaa55aa,
-                                          0xaaaa55aa, break_table,
-                                          select_table);
-               break;
-       case 18:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0x5aaa5a5a, break_table,
-                                          select_table);
-               break;
-       case 19:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0xa5555555,
-                                          0xaaaa5aaa, break_table,
-                                          select_table);
-               break;
-       case 20:
-               halbtc8822b1ant_coex_table(btcoexist, force_exec, 0x55555555,
-                                          0xaaaa5aaa, break_table,
-                                          select_table);
-               break;
-       default:
-               break;
-       }
-}
-
-static void
-halbtc8822b1ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist,
-                                      bool enable)
-{
-       u8 h2c_parameter[1] = {0};
-
-       if (enable)
-               h2c_parameter[0] |= BIT(0); /* function enable */
-
-       btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
-}
-
-static void halbtc8822b1ant_ignore_wlan_act(struct btc_coexist *btcoexist,
-                                           bool force_exec, bool enable)
-{
-       coex_dm->cur_ignore_wlan_act = enable;
-
-       if (!force_exec) {
-               if (coex_dm->pre_ignore_wlan_act ==
-                   coex_dm->cur_ignore_wlan_act) {
-                       coex_dm->pre_ignore_wlan_act =
-                               coex_dm->cur_ignore_wlan_act;
-                       return;
-               }
-       }
-
-       halbtc8822b1ant_set_fw_ignore_wlan_act(btcoexist, enable);
-
-       coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
-}
-
-static void halbtc8822b1ant_set_lps_rpwm(struct btc_coexist *btcoexist,
-                                        u8 lps_val, u8 rpwm_val)
-{
-       u8 lps = lps_val;
-       u8 rpwm = rpwm_val;
-
-       btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps);
-       btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
-}
-
-static void halbtc8822b1ant_lps_rpwm(struct btc_coexist *btcoexist,
-                                    bool force_exec, u8 lps_val, u8 rpwm_val)
-{
-       coex_dm->cur_lps = lps_val;
-       coex_dm->cur_rpwm = rpwm_val;
-
-       if (!force_exec) {
-               if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
-                   (coex_dm->pre_rpwm == coex_dm->cur_rpwm))
-                       return;
-       }
-       halbtc8822b1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val);
-
-       coex_dm->pre_lps = coex_dm->cur_lps;
-       coex_dm->pre_rpwm = coex_dm->cur_rpwm;
-}
-
-static void halbtc8822b1ant_ps_tdma_check_for_power_save_state(
-       struct btc_coexist *btcoexist, bool new_ps_state)
-{
-       u8 lps_mode = 0x0;
-       u8 h2c_parameter[5] = {0x8, 0, 0, 0, 0};
-
-       btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
-
-       if (lps_mode) { /* already under LPS state */
-               if (new_ps_state) {
-                       /* keep state under LPS, do nothing. */
-               } else {
-                       /* will leave LPS state, turn off psTdma first */
-
-                       btcoexist->btc_fill_h2c(btcoexist, 0x60, 5,
-                                               h2c_parameter);
-               }
-       } else { /* NO PS state */
-               if (new_ps_state) {
-                       /* will enter LPS state, turn off psTdma first */
-
-                       btcoexist->btc_fill_h2c(btcoexist, 0x60, 5,
-                                               h2c_parameter);
-               } else {
-                       /* keep state under NO PS state, do nothing. */
-               }
-       }
-}
-
-static bool halbtc8822b1ant_power_save_state(struct btc_coexist *btcoexist,
-                                            u8 ps_type, u8 lps_val,
-                                            u8 rpwm_val)
-{
-       bool low_pwr_disable = false, result = true;
-
-       switch (ps_type) {
-       case BTC_PS_WIFI_NATIVE:
-               /* recover to original 32k low power setting */
-               coex_sta->force_lps_ctrl = false;
-               low_pwr_disable = false;
-               btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
-                                  &low_pwr_disable);
-               btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
-               break;
-       case BTC_PS_LPS_ON:
-
-               coex_sta->force_lps_ctrl = true;
-               halbtc8822b1ant_ps_tdma_check_for_power_save_state(btcoexist,
-                                                                  true);
-               halbtc8822b1ant_lps_rpwm(btcoexist, NORMAL_EXEC, lps_val,
-                                        rpwm_val);
-               /* when coex force to enter LPS, do not enter 32k low power. */
-               low_pwr_disable = true;
-               btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
-                                  &low_pwr_disable);
-               /* power save must executed before psTdma. */
-               btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
-
-               break;
-       case BTC_PS_LPS_OFF:
-
-               coex_sta->force_lps_ctrl = true;
-               halbtc8822b1ant_ps_tdma_check_for_power_save_state(btcoexist,
-                                                                  false);
-               result = btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS,
-                                           NULL);
-
-               break;
-       default:
-               break;
-       }
-
-       return result;
-}
-
-static void halbtc8822b1ant_set_fw_pstdma(struct btc_coexist *btcoexist,
-                                         u8 byte1, u8 byte2, u8 byte3,
-                                         u8 byte4, u8 byte5)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       u8 h2c_parameter[5] = {0};
-       u8 real_byte1 = byte1, real_byte5 = byte5;
-       bool ap_enable = false, result = false;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-
-       if (byte5 & BIT(2))
-               coex_sta->is_tdma_btautoslot = true;
-       else
-               coex_sta->is_tdma_btautoslot = false;
-
-       /* release bt-auto slot for auto-slot hang is detected!! */
-       if (coex_sta->is_tdma_btautoslot)
-               if ((coex_sta->is_tdma_btautoslot_hang) ||
-                   (bt_link_info->slave_role))
-                       byte5 = byte5 & 0xfb;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
-                          &ap_enable);
-
-       if ((ap_enable) && (byte1 & BIT(4) && !(byte1 & BIT(5)))) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], %s == FW for 1Ant AP mode\n", __func__);
-
-               real_byte1 &= ~BIT(4);
-               real_byte1 |= BIT(5);
-
-               real_byte5 |= BIT(5);
-               real_byte5 &= ~BIT(6);
-
-               halbtc8822b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
-                                                0x0, 0x0);
-
-       } else if (byte1 & BIT(4) && !(byte1 & BIT(5))) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], %s == Force LPS (byte1 = 0x%x)\n",
-                        __func__, byte1);
-               if (!halbtc8822b1ant_power_save_state(btcoexist, BTC_PS_LPS_OFF,
-                                                     0x50, 0x4))
-                       result = true;
-       } else {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], %s == native power save (byte1 = 0x%x)\n",
-                        __func__, byte1);
-               halbtc8822b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
-                                                0x0, 0x0);
-       }
-
-       coex_sta->is_set_ps_state_fail = result;
-
-       if (!coex_sta->is_set_ps_state_fail) {
-               h2c_parameter[0] = real_byte1;
-               h2c_parameter[1] = byte2;
-               h2c_parameter[2] = byte3;
-               h2c_parameter[3] = byte4;
-               h2c_parameter[4] = real_byte5;
-
-               coex_dm->ps_tdma_para[0] = real_byte1;
-               coex_dm->ps_tdma_para[1] = byte2;
-               coex_dm->ps_tdma_para[2] = byte3;
-               coex_dm->ps_tdma_para[3] = byte4;
-               coex_dm->ps_tdma_para[4] = real_byte5;
-
-               btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
-
-       } else {
-               coex_sta->cnt_set_ps_state_fail++;
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], %s == Force Leave LPS Fail (cnt = %d)\n",
-                        __func__, coex_sta->cnt_set_ps_state_fail);
-       }
-}
-
-static void halbtc8822b1ant_ps_tdma(struct btc_coexist *btcoexist,
-                                   bool force_exec, bool turn_on, u8 type)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool wifi_busy = false;
-       static u8 ps_tdma_byte4_modify, pre_ps_tdma_byte4_modify;
-       static bool pre_wifi_busy;
-
-       coex_dm->cur_ps_tdma_on = turn_on;
-       coex_dm->cur_ps_tdma = type;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
-       if (wifi_busy != pre_wifi_busy) {
-               force_exec = true;
-               pre_wifi_busy = wifi_busy;
-       }
-
-       /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */
-       if (bt_link_info->slave_role)
-               ps_tdma_byte4_modify = 0x1;
-       else
-               ps_tdma_byte4_modify = 0x0;
-
-       if (pre_ps_tdma_byte4_modify != ps_tdma_byte4_modify) {
-               force_exec = true;
-               pre_ps_tdma_byte4_modify = ps_tdma_byte4_modify;
-       }
-
-       if (!force_exec) {
-               if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
-                   (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) {
-                       RT_TRACE(
-                               rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                               "[BTCoex], Skip TDMA because no change TDMA(%s, %d)\n",
-                               (coex_dm->cur_ps_tdma_on ? "on" : "off"),
-                               coex_dm->cur_ps_tdma);
-                       return;
-               }
-       }
-
-       if (coex_dm->cur_ps_tdma_on) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], ********** TDMA(on, %d) **********\n",
-                        coex_dm->cur_ps_tdma);
-
-               btcoexist->btc_write_1byte_bitmask(
-                       btcoexist, 0x550, 0x8, 0x1); /* enable TBTT nterrupt */
-       } else {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], ********** TDMA(off, %d) **********\n",
-                        coex_dm->cur_ps_tdma);
-       }
-
-       if (turn_on) {
-               /* enable TBTT nterrupt */
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x550, 0x8, 0x1);
-
-               switch (type) {
-               default:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x35,
-                                                     0x03, 0x11, 0x11);
-                       break;
-               case 1:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x3a,
-                                                     0x03, 0x11, 0x10);
-                       break;
-               case 3:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x30,
-                                                     0x03, 0x10, 0x50);
-                       break;
-               case 4:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x21,
-                                                     0x03, 0x10, 0x50);
-                       break;
-               case 5:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x15,
-                                                     0x3, 0x11, 0x11);
-                       break;
-               case 6:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x20,
-                                                     0x3, 0x11, 0x10);
-                       break;
-               case 7:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x10, 0x03, 0x10,
-                               0x54 | ps_tdma_byte4_modify);
-                       break;
-               case 8:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x10, 0x03, 0x10,
-                               0x14 | ps_tdma_byte4_modify);
-                       break;
-               case 11:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x61, 0x25, 0x03, 0x11,
-                               0x10 | ps_tdma_byte4_modify);
-                       break;
-               case 12:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x30, 0x03, 0x10,
-                               0x50 | ps_tdma_byte4_modify);
-                       break;
-               case 13:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x10, 0x07, 0x10,
-                               0x54 | ps_tdma_byte4_modify);
-                       break;
-               case 14:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x15, 0x03, 0x10,
-                               0x50 | ps_tdma_byte4_modify);
-                       break;
-               case 15:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x20, 0x03, 0x10,
-                               0x10 | ps_tdma_byte4_modify);
-                       break;
-               case 17:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x61, 0x10, 0x03, 0x11,
-                               0x14 | ps_tdma_byte4_modify);
-                       break;
-               case 18:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x10, 0x03, 0x10,
-                               0x50 | ps_tdma_byte4_modify);
-                       break;
-
-               case 20:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x30,
-                                                     0x03, 0x11, 0x10);
-                       break;
-               case 22:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x25,
-                                                     0x03, 0x11, 0x10);
-                       break;
-               case 27:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x10,
-                                                     0x03, 0x11, 0x15);
-                       break;
-               case 32:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x35,
-                                                     0x3, 0x11, 0x11);
-                       break;
-               case 33:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x35,
-                                                     0x03, 0x11, 0x10);
-                       break;
-               case 41:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x45,
-                                                     0x3, 0x11, 0x11);
-                       break;
-               case 42:
-                       halbtc8822b1ant_set_fw_pstdma(
-                               btcoexist, 0x51, 0x1e, 0x3, 0x10,
-                               0x14 | ps_tdma_byte4_modify);
-                       break;
-               case 43:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x45,
-                                                     0x3, 0x10, 0x14);
-                       break;
-               case 44:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x25,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 45:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x29,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 46:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x1a,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 47:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x32,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 48:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x29,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 49:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x55, 0x10,
-                                                     0x3, 0x10, 0x54);
-                       break;
-               case 50:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x51, 0x4a,
-                                                     0x3, 0x10, 0x10);
-                       break;
-               case 51:
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x61, 0x35,
-                                                     0x3, 0x10, 0x11);
-                       break;
-               }
-       } else {
-               switch (type) {
-               case 0:
-               default: /* Software control, Antenna at BT side */
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0,
-                                                     0x0, 0x0);
-                       break;
-               case 8: /* PTA Control */
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x8, 0x0, 0x0,
-                                                     0x0, 0x0);
-                       break;
-               case 9: /* Software control, Antenna at WiFi side */
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0,
-                                                     0x0, 0x0);
-                       break;
-               case 10: /* under 5G , 0x778=1*/
-                       halbtc8822b1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0,
-                                                     0x0, 0x0);
-
-                       break;
-               }
-       }
-
-       if (!coex_sta->is_set_ps_state_fail) {
-               /* update pre state */
-               coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
-               coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
-       }
-}
-
-static void halbtc8822b1ant_sw_mechanism(struct btc_coexist *btcoexist,
-                                        bool low_penalty_ra)
-{
-       halbtc8822b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
-}
-
-/* rf4 type by efuse, and for ant at main aux inverse use,
- * because is 2x2, and control types are the same, does not need
- */
-
-static void halbtc8822b1ant_set_rfe_type(struct btc_coexist *btcoexist)
-{
-       struct btc_board_info *board_info = &btcoexist->board_info;
-
-       /* Ext switch buffer mux */
-       btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
-
-       /* the following setup should be got from Efuse in the future */
-       rfe_type->rfe_module_type = board_info->rfe_type;
-
-       rfe_type->ext_ant_switch_ctrl_polarity = 0;
-
-       switch (rfe_type->rfe_module_type) {
-       case 0:
-       default:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 1:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 2:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 3:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 4:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 5:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 6:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       case 7:
-               rfe_type->ext_ant_switch_exist = true;
-               rfe_type->ext_ant_switch_type =
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
-               break;
-       }
-}
-
-/*anttenna control by bb mac bt antdiv pta to write 0x4c 0xcb4,0xcbd*/
-
-static void halbtc8822b1ant_set_ext_ant_switch(struct btc_coexist *btcoexist,
-                                              bool force_exec, u8 ctrl_type,
-                                              u8 pos_type)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       bool switch_polatiry_inverse = false;
-       u8 regval_0xcbd = 0, regval_0x64;
-       u32 u32tmp1 = 0, u32tmp2 = 0, u32tmp3 = 0;
-
-       /* Ext switch buffer mux */
-       btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
-
-       if (!rfe_type->ext_ant_switch_exist)
-               return;
-
-       coex_dm->cur_ext_ant_switch_status = (ctrl_type << 8) + pos_type;
-
-       if (!force_exec) {
-               if (coex_dm->pre_ext_ant_switch_status ==
-                   coex_dm->cur_ext_ant_switch_status)
-                       return;
-       }
-
-       coex_dm->pre_ext_ant_switch_status = coex_dm->cur_ext_ant_switch_status;
-
-       /* swap control polarity if use different switch control polarity*/
-       /* Normal switch polarity for SPDT,
-        * 0xcbd[1:0] = 2b'01 => Ant to BTG,
-        * 0xcbd[1:0] = 2b'10 => Ant to WLG
-        */
-       switch_polatiry_inverse = rfe_type->ext_ant_switch_ctrl_polarity == 1;
-
-       switch (pos_type) {
-       default:
-       case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_BT:
-       case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE:
-
-               break;
-       case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLG:
-               break;
-       case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLA:
-               break;
-       }
-
-       if (rfe_type->ext_ant_switch_type ==
-           BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT) {
-               switch (ctrl_type) {
-               default:
-               case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW:
-                       /*  0x4c[23] = 0 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
-                                                          0x80, 0x0);
-                       /* 0x4c[24] = 1 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f,
-                                                          0x01, 0x1);
-                       /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin*/
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb4,
-                                                          0xff, 0x77);
-
-                       /* 0xcbd[1:0] = 2b'01 for no switch_polatiry_inverse,
-                        * ANTSWB =1, ANTSW =0
-                        */
-                       regval_0xcbd = (!switch_polatiry_inverse ? 0x1 : 0x2);
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
-                                                          0x3, regval_0xcbd);
-
-                       break;
-               case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_PTA:
-                       /* 0x4c[23] = 0 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
-                                                          0x80, 0x0);
-                       /* 0x4c[24] = 1 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f,
-                                                          0x01, 0x1);
-                       /* PTA,  DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb4,
-                                                          0xff, 0x66);
-
-                       /* 0xcbd[1:0] = 2b'10 for no switch_polatiry_inverse,
-                        * ANTSWB =1, ANTSW =0  @ GNT_BT=1
-                        */
-                       regval_0xcbd = (!switch_polatiry_inverse ? 0x2 : 0x1);
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
-                                                          0x3, regval_0xcbd);
-
-                       break;
-               case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_ANTDIV:
-                       /* 0x4c[23] = 0 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
-                                                          0x80, 0x0);
-                       /* 0x4c[24] = 1 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f,
-                                                          0x01, 0x1);
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb4,
-                                                          0xff, 0x88);
-
-                       /* no regval_0xcbd setup required, because
-                        * antenna switch control value by antenna diversity
-                        */
-
-                       break;
-               case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_MAC:
-                       /*  0x4c[23] = 1 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
-                                                          0x80, 0x1);
-
-                       /* 0x64[0] = 1b'0 for no switch_polatiry_inverse,
-                        * DPDT_SEL_N =1, DPDT_SEL_P =0
-                        */
-                       regval_0x64 = (!switch_polatiry_inverse ? 0x0 : 0x1);
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64, 0x1,
-                                                          regval_0x64);
-                       break;
-               case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BT:
-                       /* 0x4c[23] = 0 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
-                                                          0x80, 0x0);
-                       /* 0x4c[24] = 0 */
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f,
-                                                          0x01, 0x0);
-
-                       /* no setup required, because antenna switch control
-                        * value by BT vendor 0xac[1:0]
-                        */
-                       break;
-               }
-       }
-
-       u32tmp1 = btcoexist->btc_read_4byte(btcoexist, 0xcbc);
-       u32tmp2 = btcoexist->btc_read_4byte(btcoexist, 0x4c);
-       u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0x64) & 0xff;
-
-       RT_TRACE(
-               rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-               "[BTCoex], ********** (After Ext Ant switch setup) 0xcbc = 0x%08x, 0x4c = 0x%08x, 0x64= 0x%02x**********\n",
-               u32tmp1, u32tmp2, u32tmp3);
-}
-
-/* set gnt_wl gnt_bt control by sw high low, or
- * hwpta while in power on, ini, wlan off, wlan only, wl2g non-currrent,
- * wl2g current, wl5g
- */
-
-static void halbtc8822b1ant_set_ant_path(struct btc_coexist *btcoexist,
-                                        u8 ant_pos_type, bool force_exec,
-                                        u8 phase)
-
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       u8 u8tmp = 0;
-       u32 u32tmp1 = 0;
-       u32 u32tmp2 = 0, u32tmp3 = 0;
-
-       u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x38);
-
-       /* To avoid indirect access fail  */
-       if (((u32tmp1 & 0xf000) >> 12) != ((u32tmp1 & 0x0f00) >> 8)) {
-               force_exec = true;
-               coex_sta->gnt_error_cnt++;
-
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex],(Before Ant Setup) 0x38= 0x%x\n", u32tmp1);
-       }
-
-       /* Ext switch buffer mux */
-       btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
-
-       coex_dm->cur_ant_pos_type = (ant_pos_type << 8) + phase;
-
-       if (!force_exec) {
-               if (coex_dm->cur_ant_pos_type == coex_dm->pre_ant_pos_type)
-                       return;
-       }
-
-       coex_dm->pre_ant_pos_type = coex_dm->cur_ant_pos_type;
-
-       if (btcoexist->dbg_mode_1ant) {
-               u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
-                                                                   0x38);
-               u32tmp2 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
-                                                                   0x54);
-               u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
-
-               u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x73);
-
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (Before Ant Setup) 0xcb4 = 0x%x, 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n",
-                       u32tmp3, u8tmp, u32tmp1, u32tmp2);
-       }
-
-       switch (phase) {
-       case BT_8822B_1ANT_PHASE_COEX_INIT:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_COEX_INIT) **********\n");
-
-               /* Disable LTE Coex Function in WiFi side
-                * (this should be on if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
-
-               /* GNT_WL_LTE always = 1
-                * (this should be config if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_set_coex_table(
-                       btcoexist, BT_8822B_1ANT_CTT_WL_VS_LTE, 0xffff);
-
-               /* GNT_BT_LTE always = 1
-                * (this should be config if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_set_coex_table(
-                       btcoexist, BT_8822B_1ANT_CTT_BT_VS_LTE, 0xffff);
-
-               /* set GNT_BT to SW high */
-               halbtc8822b1ant_ltecoex_set_gnt_bt(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
-
-               /* set GNT_WL to SW low */
-               halbtc8822b1ant_ltecoex_set_gnt_wl(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
-
-               /* set Path control owner to WL at initial step */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_WLSIDE);
-
-               coex_sta->run_time_state = false;
-
-               /* Ext switch buffer mux */
-               btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
-
-               if (ant_pos_type == BTC_ANT_PATH_AUTO)
-                       ant_pos_type = BTC_ANT_PATH_BT;
-
-               break;
-       case BT_8822B_1ANT_PHASE_WLANONLY_INIT:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_WLANONLY_INIT) **********\n");
-
-               /* Disable LTE Coex Function in WiFi side
-                * (this should be on if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
-
-               /* GNT_WL_LTE always = 1
-                * (this should be config if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_set_coex_table(
-                       btcoexist, BT_8822B_1ANT_CTT_WL_VS_LTE, 0xffff);
-
-               /* GNT_BT_LTE always = 1
-                * (this should be config if LTE coex is required)
-                */
-               halbtc8822b1ant_ltecoex_set_coex_table(
-                       btcoexist, BT_8822B_1ANT_CTT_BT_VS_LTE, 0xffff);
-
-               /* set GNT_BT to SW Low */
-               halbtc8822b1ant_ltecoex_set_gnt_bt(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
-
-               /* Set GNT_WL to SW high */
-               halbtc8822b1ant_ltecoex_set_gnt_wl(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
-
-               /* set Path control owner to WL at initial step */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_WLSIDE);
-
-               coex_sta->run_time_state = false;
-
-               /* Ext switch buffer mux */
-               btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
-
-               if (ant_pos_type == BTC_ANT_PATH_AUTO)
-                       ant_pos_type = BTC_ANT_PATH_WIFI;
-
-               break;
-       case BT_8822B_1ANT_PHASE_WLAN_OFF:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_WLAN_OFF) **********\n");
-
-               /* Disable LTE Coex Function in WiFi side */
-               halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
-
-               /* set Path control owner to BT */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_BTSIDE);
-
-               /* Set Ext Ant Switch to BT control at wifi off step */
-               halbtc8822b1ant_set_ext_ant_switch(
-                       btcoexist, FORCE_EXEC,
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BT,
-                       BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE);
-
-               coex_sta->run_time_state = false;
-
-               break;
-       case BT_8822B_1ANT_PHASE_2G_RUNTIME:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_2G_RUNTIME) **********\n");
-
-               /* set GNT_BT to PTA */
-               halbtc8822b1ant_ltecoex_set_gnt_bt(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_PTA,
-                       BT_8822B_1ANT_SIG_STA_SET_BY_HW);
-
-               /* Set GNT_WL to PTA */
-               halbtc8822b1ant_ltecoex_set_gnt_wl(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_PTA,
-                       BT_8822B_1ANT_SIG_STA_SET_BY_HW);
-
-               /* set Path control owner to WL at runtime step */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_WLSIDE);
-
-               coex_sta->run_time_state = true;
-
-               if (ant_pos_type == BTC_ANT_PATH_AUTO)
-                       ant_pos_type = BTC_ANT_PATH_PTA;
-
-               break;
-       case BT_8822B_1ANT_PHASE_5G_RUNTIME:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_5G_RUNTIME) **********\n");
-
-               /* set GNT_BT to SW Hi */
-               halbtc8822b1ant_ltecoex_set_gnt_bt(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
-
-               /* Set GNT_WL to SW Hi */
-               halbtc8822b1ant_ltecoex_set_gnt_wl(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
-
-               /* set Path control owner to WL at runtime step */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_WLSIDE);
-
-               coex_sta->run_time_state = true;
-
-               if (ant_pos_type == BTC_ANT_PATH_AUTO)
-                       ant_pos_type = BTC_ANT_PATH_WIFI5G;
-
-               break;
-       case BT_8822B_1ANT_PHASE_BTMPMODE:
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_BTMPMODE) **********\n");
-
-               /* Disable LTE Coex Function in WiFi side */
-               halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
-
-               /* set GNT_BT to SW Hi */
-               halbtc8822b1ant_ltecoex_set_gnt_bt(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
-
-               /* Set GNT_WL to SW Lo */
-               halbtc8822b1ant_ltecoex_set_gnt_wl(
-                       btcoexist, BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
-                       BT_8822B_1ANT_GNT_CTRL_BY_SW,
-                       BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
-
-               /* set Path control owner to WL */
-               halbtc8822b1ant_ltecoex_pathcontrol_owner(
-                       btcoexist, BT_8822B_1ANT_PCO_WLSIDE);
-
-               coex_sta->run_time_state = false;
-
-               /* Set Ext Ant Switch to BT side at BT MP mode */
-               if (ant_pos_type == BTC_ANT_PATH_AUTO)
-                       ant_pos_type = BTC_ANT_PATH_BT;
-
-               break;
-       }
-
-       if (phase != BT_8822B_1ANT_PHASE_WLAN_OFF) {
-               switch (ant_pos_type) {
-               case BTC_ANT_PATH_WIFI:
-                       halbtc8822b1ant_set_ext_ant_switch(
-                               btcoexist, force_exec,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLG);
-                       break;
-               case BTC_ANT_PATH_WIFI5G:
-                       halbtc8822b1ant_set_ext_ant_switch(
-                               btcoexist, force_exec,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLA);
-                       break;
-               case BTC_ANT_PATH_BT:
-                       halbtc8822b1ant_set_ext_ant_switch(
-                               btcoexist, force_exec,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_TO_BT);
-                       break;
-               default:
-               case BTC_ANT_PATH_PTA:
-                       halbtc8822b1ant_set_ext_ant_switch(
-                               btcoexist, force_exec,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_PTA,
-                               BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE);
-                       break;
-               }
-       }
-
-       if (btcoexist->dbg_mode_1ant) {
-               u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
-                                                                   0x38);
-               u32tmp2 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
-                                                                   0x54);
-               u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
-
-               u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x73);
-
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (After Ant Setup) 0xcb4 = 0x%x, 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n",
-                       u32tmp3, u8tmp, u32tmp1, u32tmp2);
-       }
-}
-
-static bool halbtc8822b1ant_is_common_action(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       bool common = false, wifi_connected = false, wifi_busy = false;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
-                          &wifi_connected);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
-       if (!wifi_connected &&
-           coex_dm->bt_status == BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n");
-
-               /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
-
-               common = true;
-       } else if (wifi_connected &&
-                  (coex_dm->bt_status ==
-                   BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE)) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], Wifi connected + BT non connected-idle!!\n");
-
-               /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
-
-               common = true;
-       } else if (!wifi_connected && (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE ==
-                                      coex_dm->bt_status)) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], Wifi non connected-idle + BT connected-idle!!\n");
-
-               /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
-
-               common = true;
-       } else if (wifi_connected && (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE ==
-                                     coex_dm->bt_status)) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], Wifi connected + BT connected-idle!!\n");
-
-               /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
-
-               common = true;
-       } else if (!wifi_connected && (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE !=
-                                      coex_dm->bt_status)) {
-               RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                        "[BTCoex], Wifi non connected-idle + BT Busy!!\n");
-
-               /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
-
-               common = true;
-       } else {
-               if (wifi_busy) {
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
-               } else {
-                       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                                "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
-               }
-
-               common = false;
-       }
-
-       return common;
-}
-
-static void halbtc8822b1ant_action_wifi_under5g(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], under 5g start\n");
-       /* for test : s3 bt disappear , fail rate 1/600*/
-       /*set sw gnt wl bt  high*/
-       halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, FORCE_EXEC,
-                                    BT_8822B_1ANT_PHASE_5G_RUNTIME);
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-       btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd, 0x3, 1);
-}
-
-static void halbtc8822b1ant_action_wifi_only(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       bool wifi_under_5g = false, rf4ce_enabled = false;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
-       if (wifi_under_5g) {
-               halbtc8822b1ant_action_wifi_under5g(btcoexist);
-
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (wlan only -- under 5g ) **********\n");
-               return;
-       }
-
-       if (rf4ce_enabled) {
-               btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 50);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
-               return;
-       }
-       halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
-       halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
-
-       halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, FORCE_EXEC,
-                                    BT_8822B_1ANT_PHASE_2G_RUNTIME);
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], ********** (wlan only -- under 2g ) **********\n");
-}
-
-static void
-halbtc8822b1ant_action_wifi_native_lps(struct btc_coexist *btcoexist)
-{
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-}
-
-/* *********************************************
- *
- *     Non-Software Coex Mechanism start
- *
- * **********************************************/
-
-static void halbtc8822b1ant_action_bt_whck_test(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex],action_bt_whck_test\n");
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-
-       halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, NORMAL_EXEC,
-                                    BT_8822B_1ANT_PHASE_2G_RUNTIME);
-
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-static void
-halbtc8822b1ant_action_wifi_multi_port(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex],action_wifi_multi_port\n");
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-
-       halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, NORMAL_EXEC,
-                                    BT_8822B_1ANT_PHASE_2G_RUNTIME);
-
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-static void halbtc8822b1ant_action_hs(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, "[BTCoex], action_hs\n");
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
-
-       halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, NORMAL_EXEC,
-                                    BT_8822B_1ANT_PHASE_2G_RUNTIME);
-
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
-}
-
-static void halbtc8822b1ant_action_bt_relink(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], run bt multi link function\n");
-
-       if (coex_sta->is_bt_multi_link)
-               return;
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], run bt_re-link function\n");
-
-       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-       halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-/*"""bt inquiry"""" + wifi any + bt any*/
-
-static void halbtc8822b1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool wifi_connected = false, ap_enable = false, wifi_busy = false,
-            bt_busy = false, rf4ce_enabled = false;
-
-       bool wifi_scan = false, link = false, roam = false;
-
-       RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                "[BTCoex], ********** (bt inquiry) **********\n");
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
-                          &ap_enable);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
-                          &wifi_connected);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-       btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &wifi_scan);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
-       RT_TRACE(
-               rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-               "[BTCoex], ********** scan = %d,  link =%d, roam = %d**********\n",
-               wifi_scan, link, roam);
-
-       if ((link) || (roam) || (coex_sta->wifi_is_high_pri_task)) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (bt inquiry wifi  connect or scan ) **********\n");
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
-
-       } else if ((wifi_scan) && (coex_sta->bt_create_connection)) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
-
-       } else if ((!wifi_connected) && (!wifi_scan)) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (bt inquiry wifi non connect) **********\n");
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-
-       } else if ((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
-       } else if (bt_link_info->a2dp_exist) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
-       } else if (wifi_scan) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
-       } else if (wifi_busy) {
-               /* for BT inquiry/page fail after S4 resume */
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
-               /*aaaa->55aa for bt connect while wl busy*/
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
-                                                    15);
-               if (rf4ce_enabled) {
-                       btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e,
-                                                          0x8, 0x1);
-
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               50);
-
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 0);
-               }
-       } else {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "[BTCoex], ********** (bt inquiry wifi connect) **********\n");
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
-
-               halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO,
-                                            NORMAL_EXEC,
-                                            BT_8822B_1ANT_PHASE_2G_RUNTIME);
-
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
-       }
-}
-
-static void
-halbtc8822b1ant_action_bt_sco_hid_only_busy(struct btc_coexist *btcoexist)
-{
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool wifi_connected = false, wifi_busy = false;
-       u32 wifi_bw = 1;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
-                          &wifi_connected);
-
-       btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
-       if (bt_link_info->sco_exist) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
-       } else {
-               if (coex_sta->is_hid_low_pri_tx_overhead) {
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 6);
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               18);
-               } else if (wifi_bw == 0) { /* if 11bg mode */
-
-                       if (coex_sta->is_bt_multi_link) {
-                               halbtc8822b1ant_coex_table_with_type(
-                                       btcoexist, NORMAL_EXEC, 11);
-                               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-                                                       true, 11);
-                       } else {
-                               halbtc8822b1ant_coex_table_with_type(
-                                       btcoexist, NORMAL_EXEC, 6);
-                               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
-                                                       true, 11);
-                       }
-               } else {
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 6);
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               11);
-               }
-       }
-}
-
-static void
-halbtc8822b1ant_action_wifi_connected_bt_acl_busy(struct btc_coexist *btcoexist)
-{
-       struct rtl_priv *rtlpriv = btcoexist->adapter;
-       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-       bool wifi_busy = false, wifi_turbo = false;
-       u32 wifi_bw = 1;
-
-       btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
-       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-       btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
-                          &coex_sta->scan_ap_num);
-       RT_TRACE(
-               rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-               "############# [BTCoex],  scan_ap_num = %d, wl_noisy_level = %d\n",
-               coex_sta->scan_ap_num, coex_sta->wl_noisy_level);
-
-       if ((wifi_busy) && (coex_sta->wl_noisy_level == 0))
-               wifi_turbo = true;
-
-       if ((coex_sta->bt_relink_downcount != 0) &&
-           (!bt_link_info->pan_exist) && (wifi_busy)) {
-               RT_TRACE(
-                       rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
-                       "############# [BTCoex],  BT Re-Link + A2DP + WL busy\n");
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-
-       } else if ((bt_link_info->a2dp_exist) && (coex_sta->is_bt_a2dp_sink)) {
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 12);
-               halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
-       } else if (bt_link_info->a2dp_only) { /* A2DP            */
-
-               halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 7);
-
-               if (wifi_turbo)
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 19);
-               else
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 4);
-       } else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) ||
-                  (bt_link_info->hid_exist && bt_link_info->a2dp_exist &&
-                   bt_link_info->pan_exist)) {
-               /* A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) */
-
-               if (wifi_busy)
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               13);
-               else
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               14);
-
-               if (bt_link_info->hid_exist)
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 1);
-               else if (wifi_turbo)
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 19);
-               else
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 4);
-       } else if (bt_link_info->hid_exist &&
-                  bt_link_info->a2dp_exist) { /* HID+A2DP */
-
-               if (wifi_bw == 0) { /* if 11bg mode */
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 1);
-                       halbtc8822b1ant_set_wltoggle_coex_table(
-                               btcoexist, NORMAL_EXEC, 1, 0xaa, 0x5a, 0xaa,
-                               0xaa);
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               49);
-               } else {
-                       halbtc8822b1ant_coex_table_with_type(btcoexist,
-                                                            NORMAL_EXEC, 1);
-                       halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC,
-                                                  false, true, 8);
-                       halbtc8822b1ant_set_wltoggle_coex_table(
-                               btcoexist, NORMAL_EXEC, 1, 0xaa, 0x5a, 0xaa,
-                               0xaa);
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-                                               49);
-               }
-               /* PAN(OPP,FTP), HID+PAN(OPP,FTP) */
-
-       } else if ((bt_link_info->pan_only) ||
-                  (bt_link_info->hid_exist && bt_link_info->pan_exist)) {
-               if (!wifi_busy)
-                       halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
-