Commit 89029a85 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: mt7915: add Tx beamformer support

Enable TxBF modules and trigger sounding process to support Tx beamformer.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Tested-by: Evelyn Tsai <evelyn.tsai@mediatek.com
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b0efe6dd
...@@ -57,6 +57,25 @@ static void mt7915_mac_init(struct mt7915_dev *dev) ...@@ -57,6 +57,25 @@ static void mt7915_mac_init(struct mt7915_dev *dev)
mt7915_mcu_set_rts_thresh(&dev->phy, 0x92b); mt7915_mcu_set_rts_thresh(&dev->phy, 0x92b);
} }
static int mt7915_txbf_init(struct mt7915_dev *dev)
{
int ret;
/*
* TODO: DBDC & check whether iBF phase calibration data has
* been stored in eeprom offset 0x651~0x7b8, then write down
* 0x1111 into 0x651 and 0x651 to trigger iBF.
*/
/* trigger sounding packets */
ret = mt7915_mcu_set_txbf_sounding(dev);
if (ret)
return ret;
/* enable iBF & eBF */
return mt7915_mcu_set_txbf_type(dev);
}
static void static void
mt7915_init_txpower_band(struct mt7915_dev *dev, mt7915_init_txpower_band(struct mt7915_dev *dev,
struct ieee80211_supported_band *sband) struct ieee80211_supported_band *sband)
...@@ -97,6 +116,7 @@ static void mt7915_init_work(struct work_struct *work) ...@@ -97,6 +116,7 @@ static void mt7915_init_work(struct work_struct *work)
mt7915_mcu_set_eeprom(dev); mt7915_mcu_set_eeprom(dev);
mt7915_mac_init(dev); mt7915_mac_init(dev);
mt7915_init_txpower(dev); mt7915_init_txpower(dev);
mt7915_txbf_init(dev);
} }
static int mt7915_init_hardware(struct mt7915_dev *dev) static int mt7915_init_hardware(struct mt7915_dev *dev)
......
...@@ -485,7 +485,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -485,7 +485,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
int idx; int ret, idx;
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA - 1); idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA - 1);
if (idx < 0) if (idx < 0)
...@@ -504,9 +504,11 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -504,9 +504,11 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7915_mac_wtbl_update(dev, idx, mt7915_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR); MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
mt7915_mcu_add_sta(dev, vif, sta, true); ret = mt7915_mcu_add_sta(dev, vif, sta, true);
if (ret)
return ret;
return 0; return mt7915_mcu_add_sta_adv(dev, vif, sta, true);
} }
void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
...@@ -515,6 +517,7 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -515,6 +517,7 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
mt7915_mcu_add_sta_adv(dev, vif, sta, false);
mt7915_mcu_add_sta(dev, vif, sta, false); mt7915_mcu_add_sta(dev, vif, sta, false);
mt7915_mac_wtbl_update(dev, msta->wcid.idx, mt7915_mac_wtbl_update(dev, msta->wcid.idx,
......
...@@ -194,6 +194,7 @@ enum { ...@@ -194,6 +194,7 @@ enum {
MCU_EXT_CMD_PM_STATE_CTRL = 0x07, MCU_EXT_CMD_PM_STATE_CTRL = 0x07,
MCU_EXT_CMD_CHANNEL_SWITCH = 0x08, MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,
MCU_EXT_CMD_FW_LOG_2_HOST = 0x13, MCU_EXT_CMD_FW_LOG_2_HOST = 0x13,
MCU_EXT_CMD_TXBF_ACTION = 0x1e,
MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21, MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21,
MCU_EXT_CMD_STA_REC_UPDATE = 0x25, MCU_EXT_CMD_STA_REC_UPDATE = 0x25,
MCU_EXT_CMD_BSS_INFO_UPDATE = 0x26, MCU_EXT_CMD_BSS_INFO_UPDATE = 0x26,
...@@ -571,18 +572,6 @@ struct wtbl_ba { ...@@ -571,18 +572,6 @@ struct wtbl_ba {
u8 rsv1[4]; u8 rsv1[4];
} __packed; } __packed;
struct wtbl_bf {
__le16 tag;
__le16 len;
u8 ibf;
u8 ebf;
u8 ibf_vht;
u8 ebf_vht;
u8 gid;
u8 pfmu_idx;
u8 rsv[2];
} __packed;
struct wtbl_smps { struct wtbl_smps {
__le16 tag; __le16 tag;
__le16 len; __le16 len;
...@@ -590,13 +579,6 @@ struct wtbl_smps { ...@@ -590,13 +579,6 @@ struct wtbl_smps {
u8 rsv[3]; u8 rsv[3];
} __packed; } __packed;
struct wtbl_spe {
__le16 tag;
__le16 len;
u8 spe_idx;
u8 rsv[3];
} __packed;
enum { enum {
WTBL_GENERIC, WTBL_GENERIC,
WTBL_RX, WTBL_RX,
...@@ -834,6 +816,55 @@ struct sta_rec_ra_fixed { ...@@ -834,6 +816,55 @@ struct sta_rec_ra_fixed {
#define RATE_CFG_LDPC GENMASK(23, 20) #define RATE_CFG_LDPC GENMASK(23, 20)
#define RATE_CFG_PHY_TYPE GENMASK(27, 24) #define RATE_CFG_PHY_TYPE GENMASK(27, 24)
struct sta_rec_bf {
__le16 tag;
__le16 len;
__le16 pfmu; /* 0xffff: no access right for PFMU */
bool su_mu; /* 0: SU, 1: MU */
u8 bf_cap; /* 0: iBF, 1: eBF */
u8 sounding_phy; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT */
u8 ndpa_rate;
u8 ndp_rate;
u8 rept_poll_rate;
u8 tx_mode; /* 0: legacy, 1: OFDM, 2: HT, 4: VHT ... */
u8 nc;
u8 nr;
u8 bw; /* 0: 20M, 1: 40M, 2: 80M, 3: 160M */
u8 mem_total;
u8 mem_20m;
struct {
u8 row;
u8 col: 6, row_msb: 2;
} mem[4];
__le16 smart_ant;
u8 se_idx;
u8 auto_sounding; /* b7: low traffic indicator
* b6: Stop sounding for this entry
* b5 ~ b0: postpone sounding
*/
u8 ibf_timeout;
u8 ibf_dbw;
u8 ibf_ncol;
u8 ibf_nrow;
u8 nr_bw160;
u8 nc_bw160;
u8 ru_start_idx;
u8 ru_end_idx;
bool trigger_su;
bool trigger_mu;
bool ng16_su;
bool ng16_mu;
bool codebook42_su;
bool codebook75_mu;
u8 he_ltf;
u8 rsv[2];
} __packed;
enum { enum {
STA_REC_BASIC, STA_REC_BASIC,
STA_REC_RA, STA_REC_RA,
...@@ -890,15 +921,18 @@ enum { ...@@ -890,15 +921,18 @@ enum {
THERMAL_SENSOR_TASK_CTRL, THERMAL_SENSOR_TASK_CTRL,
}; };
enum {
MT_EBF = BIT(0), /* explicit beamforming */
MT_IBF = BIT(1) /* implicit beamforming */
};
#define MT7915_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \ #define MT7915_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \
sizeof(struct wtbl_generic) + \ sizeof(struct wtbl_generic) + \
sizeof(struct wtbl_rx) + \ sizeof(struct wtbl_rx) + \
sizeof(struct wtbl_ht) + \ sizeof(struct wtbl_ht) + \
sizeof(struct wtbl_vht) + \ sizeof(struct wtbl_vht) + \
sizeof(struct wtbl_ba) + \ sizeof(struct wtbl_ba) + \
sizeof(struct wtbl_bf) + \ sizeof(struct wtbl_smps))
sizeof(struct wtbl_smps) + \
sizeof(struct wtbl_spe))
#define MT7915_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ #define MT7915_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
sizeof(struct sta_rec_basic) + \ sizeof(struct sta_rec_basic) + \
......
...@@ -286,6 +286,8 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, ...@@ -286,6 +286,8 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,
struct ieee80211_vif *vif, int enable); struct ieee80211_vif *vif, int enable);
int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool enable); struct ieee80211_sta *sta, bool enable);
int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool enable);
int mt7915_mcu_add_tx_ba(struct mt7915_dev *dev, int mt7915_mcu_add_tx_ba(struct mt7915_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool add); bool add);
...@@ -315,6 +317,8 @@ int mt7915_mcu_set_rts_thresh(struct mt7915_phy *phy, u32 val); ...@@ -315,6 +317,8 @@ int mt7915_mcu_set_rts_thresh(struct mt7915_phy *phy, u32 val);
int mt7915_mcu_set_pm(struct mt7915_dev *dev, int band, int enter); int mt7915_mcu_set_pm(struct mt7915_dev *dev, int band, int enter);
int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable); int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable);
int mt7915_mcu_set_sku(struct mt7915_phy *phy); int mt7915_mcu_set_sku(struct mt7915_phy *phy);
int mt7915_mcu_set_txbf_type(struct mt7915_dev *dev);
int mt7915_mcu_set_txbf_sounding(struct mt7915_dev *dev);
int mt7915_mcu_set_fcc5_lpn(struct mt7915_dev *dev, int val); int mt7915_mcu_set_fcc5_lpn(struct mt7915_dev *dev, int val);
int mt7915_mcu_set_pulse_th(struct mt7915_dev *dev, int mt7915_mcu_set_pulse_th(struct mt7915_dev *dev,
const struct mt7915_dfs_pulse *pulse); const struct mt7915_dfs_pulse *pulse);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment