blob: 5514339af9cd9f27ea9d14089aa2c2d531800d50 [file] [log] [blame]
developer711759c2022-09-21 18:38:10 +08001From e93433a00ee18a27cfb9ef6a9cd0df6c28f96cb7 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Wed, 21 Sep 2022 13:25:26 +0800
4Subject: [PATCH] mt76: mt7915: set chainmask to 3 for mt7916
5
6Use chainmask to represent the number of TRx path and set it to 3 for mt7916.
7Use antenna_mask to represent the TRx streams.
8
9Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
10---
11 mt7915/init.c | 11 ++++++-----
12 mt7915/main.c | 6 +++++-
13 mt7915/mcu.c | 2 +-
14 3 files changed, 12 insertions(+), 7 deletions(-)
15
16diff --git a/mt7915/init.c b/mt7915/init.c
17index 489f6e77..8474c11f 100644
18--- a/mt7915/init.c
19+++ b/mt7915/init.c
20@@ -730,11 +730,12 @@ void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy)
21 }
22
23 static void
24-mt7915_set_stream_he_txbf_caps(struct mt7915_dev *dev,
25- struct ieee80211_sta_he_cap *he_cap,
26- int vif, int nss)
27+mt7915_set_stream_he_txbf_caps(struct mt7915_phy *phy,
28+ struct ieee80211_sta_he_cap *he_cap, int vif)
29 {
30+ struct mt7915_dev *dev = phy->dev;
31 struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
32+ int nss = hweight8(phy->mt76->chainmask);
33 u8 c, nss_160;
34
35 /* Can do 1/2 of NSS streams in 160Mhz mode for mt7915 */
36@@ -839,7 +840,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
37 struct ieee80211_sband_iftype_data *data)
38 {
39 struct mt7915_dev *dev = phy->dev;
40- int i, idx = 0, nss = hweight8(phy->mt76->chainmask);
41+ int i, idx = 0, nss = hweight8(phy->mt76->antenna_mask);
42 u16 mcs_map = 0;
43 u16 mcs_map_160 = 0;
44 u8 nss_160;
45@@ -972,7 +973,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
46 he_mcs->rx_mcs_80p80 = cpu_to_le16(mcs_map_160);
47 he_mcs->tx_mcs_80p80 = cpu_to_le16(mcs_map_160);
48
49- mt7915_set_stream_he_txbf_caps(dev, he_cap, i, nss);
50+ mt7915_set_stream_he_txbf_caps(phy, he_cap, i);
51
52 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
53 if (he_cap_elem->phy_cap_info[6] &
54diff --git a/mt7915/main.c b/mt7915/main.c
55index edd678ce..fc5319da 100644
56--- a/mt7915/main.c
57+++ b/mt7915/main.c
58@@ -952,6 +952,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
59 struct mt7915_dev *dev = mt7915_hw_dev(hw);
60 struct mt7915_phy *phy = mt7915_hw_phy(hw);
61 int max_nss = hweight8(hw->wiphy->available_antennas_tx);
62+ int tx_nss = hweight8(tx_ant), rx_nss = hweight8(rx_ant);
63 bool ext_phy = phy != &dev->phy;
64
65 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
66@@ -964,7 +965,10 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
67 if (ext_phy)
68 tx_ant <<= dev->chainshift;
69
70- phy->mt76->chainmask = tx_ant;
71+ if (is_mt7916(&dev->mt76) && tx_nss == max_nss && rx_nss == max_nss)
72+ phy->mt76->chainmask = 0x7;
73+ else
74+ phy->mt76->chainmask = tx_ant;
75
76 mt76_set_stream_caps(phy->mt76, true);
77 mt7915_set_stream_vht_txbf_caps(phy);
78diff --git a/mt7915/mcu.c b/mt7915/mcu.c
79index 19a33120..f11ca25d 100644
80--- a/mt7915/mcu.c
81+++ b/mt7915/mcu.c
82@@ -485,7 +485,7 @@ static void
83 mt7915_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
84 struct mt7915_phy *phy)
85 {
86- int max_nss = hweight8(phy->mt76->chainmask);
87+ int max_nss = hweight8(phy->mt76->antenna_mask);
88 struct bss_info_ra *ra;
89 struct tlv *tlv;
90
91--
922.18.0
93