| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 |
/* Copyright(c) 2018-2019 Realtek Corporation. |
| 3 |
*/ |
| 4 |
|
| 5 |
#ifndef __RTW_BF_H_ |
| 6 |
#define __RTW_BF_H_ |
| 7 |
|
| 8 |
#define REG_TXBF_CTRL 0x042C |
| 9 |
#define REG_RRSR 0x0440 |
| 10 |
#define REG_NDPA_OPT_CTRL 0x045F |
| 11 |
|
| 12 |
#define REG_ASSOCIATED_BFMER0_INFO 0x06E4 |
| 13 |
#define REG_ASSOCIATED_BFMER1_INFO 0x06EC |
| 14 |
#define REG_TX_CSI_RPT_PARAM_BW20 0x06F4 |
| 15 |
#define REG_SND_PTCL_CTRL 0x0718 |
| 16 |
#define BIT_DIS_CHK_VHTSIGB_CRC BIT(6) |
| 17 |
#define BIT_DIS_CHK_VHTSIGA_CRC BIT(5) |
| 18 |
#define BIT_MASK_BEAMFORM (GENMASK(4, 0) | BIT(7)) |
| 19 |
#define REG_MU_TX_CTL 0x14C0 |
| 20 |
#define REG_MU_STA_GID_VLD 0x14C4 |
| 21 |
#define REG_MU_STA_USER_POS_INFO 0x14C8 |
| 22 |
#define REG_CSI_RRSR 0x1678 |
| 23 |
#define REG_WMAC_MU_BF_OPTION 0x167C |
| 24 |
#define REG_WMAC_MU_BF_CTL 0x1680 |
| 25 |
|
| 26 |
#define BIT_WMAC_USE_NDPARATE BIT(30) |
| 27 |
#define BIT_WMAC_TXMU_ACKPOLICY_EN BIT(6) |
| 28 |
#define BIT_USE_NDPA_PARAMETER BIT(30) |
| 29 |
#define BIT_MU_P1_WAIT_STATE_EN BIT(16) |
| 30 |
#define BIT_EN_MU_MIMO BIT(7) |
| 31 |
|
| 32 |
#define R_MU_RL 0xf |
| 33 |
#define BIT_SHIFT_R_MU_RL 12 |
| 34 |
#define BIT_SHIFT_WMAC_TXMU_ACKPOLICY 4 |
| 35 |
#define BIT_SHIFT_CSI_RATE 24 |
| 36 |
#define BIT_CSI_FORCE_RATE BIT(15) |
| 37 |
|
| 38 |
#define BIT_MASK_R_MU_RL (R_MU_RL << BIT_SHIFT_R_MU_RL) |
| 39 |
#define BIT_MASK_R_MU_TABLE_VALID 0x3f |
| 40 |
#define BIT_MASK_CSI_RATE_VAL 0x3F |
| 41 |
#define BIT_MASK_CSI_RATE (BIT_MASK_CSI_RATE_VAL << BIT_SHIFT_CSI_RATE) |
| 42 |
|
| 43 |
#define BIT_RXFLTMAP0_ACTIONNOACK BIT(14) |
| 44 |
#define BIT_RXFLTMAP1_BF (BIT(4) | BIT(5)) |
| 45 |
#define BIT_RXFLTMAP1_BF_REPORT_POLL BIT(4) |
| 46 |
#define BIT_RXFLTMAP4_BF_REPORT_POLL BIT(4) |
| 47 |
|
| 48 |
#define RTW_NDP_RX_STANDBY_TIME 0x70 |
| 49 |
#define RTW_SND_CTRL_REMOVE 0x98 |
| 50 |
#define RTW_SND_CTRL_SOUNDING 0x9B |
| 51 |
|
| 52 |
enum csi_rsc { |
| 53 |
CSI_RSC_PRIMARY_20M_BW = 0, |
| 54 |
CSI_RSC_FOLLOW_RX_PACKET_BW = 1, |
| 55 |
CSI_RSC_DUPLICATE_MODE = 2, |
| 56 |
}; |
| 57 |
|
| 58 |
enum csi_seg_len { |
| 59 |
HAL_CSI_SEG_4K = 0, |
| 60 |
HAL_CSI_SEG_8K = 1, |
| 61 |
HAL_CSI_SEG_11K = 2, |
| 62 |
}; |
| 63 |
|
| 64 |
struct cfg_mumimo_para { |
| 65 |
u8 sounding_sts[6]; |
| 66 |
u16 grouping_bitmap; |
| 67 |
u8 mu_tx_en; |
| 68 |
u32 given_gid_tab[2]; |
| 69 |
u32 given_user_pos[4]; |
| 70 |
}; |
| 71 |
|
| 72 |
struct mu_bfer_init_para { |
| 73 |
u16 paid; |
| 74 |
u16 csi_para; |
| 75 |
u16 my_aid; |
| 76 |
enum csi_seg_len csi_length_sel; |
| 77 |
u8 bfer_address[ETH_ALEN]; |
| 78 |
}; |
| 79 |
|
| 80 |
void rtw_bf_disassoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, |
| 81 |
struct ieee80211_bss_conf *bss_conf); |
| 82 |
void rtw_bf_assoc(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, |
| 83 |
struct ieee80211_bss_conf *bss_conf); |
| 84 |
void rtw_bf_init_bfer_entry_mu(struct rtw_dev *rtwdev, |
| 85 |
struct mu_bfer_init_para *param); |
| 86 |
void rtw_bf_cfg_sounding(struct rtw_dev *rtwdev, struct rtw_vif *vif, |
| 87 |
enum rtw_trx_desc_rate rate); |
| 88 |
void rtw_bf_cfg_mu_bfee(struct rtw_dev *rtwdev, struct cfg_mumimo_para *param); |
| 89 |
void rtw_bf_del_bfer_entry_mu(struct rtw_dev *rtwdev); |
| 90 |
void rtw_bf_del_sounding(struct rtw_dev *rtwdev); |
| 91 |
void rtw_bf_enable_bfee_su(struct rtw_dev *rtwdev, struct rtw_vif *vif, |
| 92 |
struct rtw_bfee *bfee); |
| 93 |
void rtw_bf_enable_bfee_mu(struct rtw_dev *rtwdev, struct rtw_vif *vif, |
| 94 |
struct rtw_bfee *bfee); |
| 95 |
void rtw_bf_remove_bfee_su(struct rtw_dev *rtwdev, struct rtw_bfee *bfee); |
| 96 |
void rtw_bf_remove_bfee_mu(struct rtw_dev *rtwdev, struct rtw_bfee *bfee); |
| 97 |
void rtw_bf_set_gid_table(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, |
| 98 |
struct ieee80211_bss_conf *conf); |
| 99 |
void rtw_bf_phy_init(struct rtw_dev *rtwdev); |
| 100 |
void rtw_bf_cfg_csi_rate(struct rtw_dev *rtwdev, u8 rssi, u8 cur_rate, |
| 101 |
u8 fixrate_en, u8 *new_rate); |
| 102 |
static inline void rtw_chip_config_bfee(struct rtw_dev *rtwdev, struct rtw_vif *vif, |
| 103 |
struct rtw_bfee *bfee, bool enable) |
| 104 |
{ |
| 105 |
if (rtwdev->chip->ops->config_bfee) |
| 106 |
rtwdev->chip->ops->config_bfee(rtwdev, vif, bfee, enable); |
| 107 |
} |
| 108 |
|
| 109 |
static inline void rtw_chip_set_gid_table(struct rtw_dev *rtwdev, |
| 110 |
struct ieee80211_vif *vif, |
| 111 |
struct ieee80211_bss_conf *conf) |
| 112 |
{ |
| 113 |
if (rtwdev->chip->ops->set_gid_table) |
| 114 |
rtwdev->chip->ops->set_gid_table(rtwdev, vif, conf); |
| 115 |
} |
| 116 |
|
| 117 |
static inline void rtw_chip_cfg_csi_rate(struct rtw_dev *rtwdev, u8 rssi, u8 cur_rate, |
| 118 |
u8 fixrate_en, u8 *new_rate) |
| 119 |
{ |
| 120 |
if (rtwdev->chip->ops->cfg_csi_rate) |
| 121 |
rtwdev->chip->ops->cfg_csi_rate(rtwdev, rssi, cur_rate, |
| 122 |
fixrate_en, new_rate); |
| 123 |
} |
| 124 |
#endif |