Commit 248ac948 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: mt7915: simplify peer's TxBF capability check

This is a preliminary patch for implicit beamforming support.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 06e0bbe1
...@@ -66,9 +66,6 @@ struct mt7915_fw_region { ...@@ -66,9 +66,6 @@ struct mt7915_fw_region {
#define MCU_PATCH_ADDRESS 0x200000 #define MCU_PATCH_ADDRESS 0x200000
#define MT_STA_BFER BIT(0)
#define MT_STA_BFEE BIT(1)
#define FW_FEATURE_SET_ENCRYPT BIT(0) #define FW_FEATURE_SET_ENCRYPT BIT(0)
#define FW_FEATURE_SET_KEY_IDX GENMASK(2, 1) #define FW_FEATURE_SET_KEY_IDX GENMASK(2, 1)
#define FW_FEATURE_OVERRIDE_ADDR BIT(5) #define FW_FEATURE_OVERRIDE_ADDR BIT(5)
...@@ -1944,20 +1941,26 @@ mt7915_mcu_sta_bfee_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, ...@@ -1944,20 +1941,26 @@ mt7915_mcu_sta_bfee_tlv(struct sk_buff *skb, struct ieee80211_sta *sta,
} }
/* reply with identity matrix to avoid 2x2 BF negative gain */ /* reply with identity matrix to avoid 2x2 BF negative gain */
if (nr == 1 && tx_ant == 2) bfee->fb_identity_matrix = !!(nr == 1 && tx_ant == 2);
bfee->fb_identity_matrix = true;
} }
static u8 static int
mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta) struct ieee80211_sta *sta, bool enable)
{ {
u8 type = 0; struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
struct mt7915_phy *phy;
struct sk_buff *skb;
int r, len;
bool ebfee = 0, ebf = 0;
if (vif->type != NL80211_IFTYPE_STATION && if (vif->type != NL80211_IFTYPE_STATION &&
vif->type != NL80211_IFTYPE_AP) vif->type != NL80211_IFTYPE_AP)
return 0; return 0;
phy = mvif->band_idx ? mt7915_ext_phy(dev) : &dev->phy;
if (sta->he_cap.has_he) { if (sta->he_cap.has_he) {
struct ieee80211_he_cap_elem *pe; struct ieee80211_he_cap_elem *pe;
const struct ieee80211_he_cap_elem *ve; const struct ieee80211_he_cap_elem *ve;
...@@ -1967,15 +1970,12 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, ...@@ -1967,15 +1970,12 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif,
vc = mt7915_get_he_phy_cap(phy, vif); vc = mt7915_get_he_phy_cap(phy, vif);
ve = &vc->he_cap_elem; ve = &vc->he_cap_elem;
if ((HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]) || ebfee = !!((HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]) ||
HE_PHY(CAP4_MU_BEAMFORMER, pe->phy_cap_info[4])) && HE_PHY(CAP4_MU_BEAMFORMER, pe->phy_cap_info[4])) &&
HE_PHY(CAP4_SU_BEAMFORMEE, ve->phy_cap_info[4])) HE_PHY(CAP4_SU_BEAMFORMEE, ve->phy_cap_info[4]));
type |= MT_STA_BFEE; ebf = !!((HE_PHY(CAP3_SU_BEAMFORMER, ve->phy_cap_info[3]) ||
HE_PHY(CAP4_MU_BEAMFORMER, ve->phy_cap_info[4])) &&
if ((HE_PHY(CAP3_SU_BEAMFORMER, ve->phy_cap_info[3]) || HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]));
HE_PHY(CAP4_MU_BEAMFORMER, ve->phy_cap_info[4])) &&
HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]))
type |= MT_STA_BFER;
} else if (sta->vht_cap.vht_supported) { } else if (sta->vht_cap.vht_supported) {
struct ieee80211_sta_vht_cap *pc; struct ieee80211_sta_vht_cap *pc;
struct ieee80211_sta_vht_cap *vc; struct ieee80211_sta_vht_cap *vc;
...@@ -1988,37 +1988,14 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif, ...@@ -1988,37 +1988,14 @@ mt7915_mcu_sta_txbf_type(struct mt7915_phy *phy, struct ieee80211_vif *vif,
ce = IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | ce = IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
if ((pc->cap & cr) && (vc->cap & ce)) ebfee = !!((pc->cap & cr) && (vc->cap & ce));
type |= MT_STA_BFEE; ebf = !!((vc->cap & cr) && (pc->cap & ce));
if ((vc->cap & cr) && (pc->cap & ce))
type |= MT_STA_BFER;
} else if (sta->ht_cap.ht_supported) {
/* TODO: iBF */
} }
return type;
}
static int
mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta, bool enable)
{
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
struct mt7915_phy *phy;
struct sk_buff *skb;
int r, len;
u8 type;
phy = mvif->band_idx ? mt7915_ext_phy(dev) : &dev->phy;
type = mt7915_mcu_sta_txbf_type(phy, vif, sta);
/* must keep each tag independent */ /* must keep each tag independent */
/* starec bf */ /* starec bf */
if (type & MT_STA_BFER) { if (ebf) {
len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bf); len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bf);
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len);
...@@ -2034,7 +2011,7 @@ mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif, ...@@ -2034,7 +2011,7 @@ mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif,
} }
/* starec bfee */ /* starec bfee */
if (type & MT_STA_BFEE) { if (ebfee) {
len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bfee); len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_bfee);
skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len);
......
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