Skip to content

Commit b4d093e

Browse files
MeiChia Chiunbd168
authored andcommitted
mt76: mt7915: add 6 GHz support
Basic 6 GHz support is added to mt76. Modification includes: 1. Add 6 GHz E2P definition 2. Register 6 GHz HE cap 3. Refactor existing code of adding a STA This adds support for Wi-Fi 6E on MT7986/MT7916. Detailed link: https://www.mediatek.com/products/mediatek-filogic-830 Detailed link: https://www.mediatek.com/products/products/broadband-wifi/mediatek-filogic-630 Reviewed-by: Ryder Lee <[email protected]> Signed-off-by: Shayne Chen <[email protected]> Signed-off-by: Peter Chiu <[email protected]> Signed-off-by: Money Wang <[email protected]> Signed-off-by: MeiChia Chiu <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent 37b5e57 commit b4d093e

File tree

7 files changed

+88
-14
lines changed

7 files changed

+88
-14
lines changed

drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,24 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
135135

136136
val = eeprom[MT_EE_WIFI_CONF + phy->band_idx];
137137
val = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val);
138-
if (val == MT_EE_BAND_SEL_DEFAULT &&
139-
(!is_mt7915(&dev->mt76) || dev->dbdc_support))
140-
val = phy->band_idx ? MT_EE_BAND_SEL_5GHZ : MT_EE_BAND_SEL_2GHZ;
138+
139+
if (!is_mt7915(&dev->mt76)) {
140+
switch (val) {
141+
case MT_EE_V2_BAND_SEL_5GHZ:
142+
phy->mt76->cap.has_5ghz = true;
143+
return;
144+
case MT_EE_V2_BAND_SEL_6GHZ:
145+
phy->mt76->cap.has_6ghz = true;
146+
return;
147+
case MT_EE_V2_BAND_SEL_5GHZ_6GHZ:
148+
phy->mt76->cap.has_5ghz = true;
149+
phy->mt76->cap.has_6ghz = true;
150+
return;
151+
default:
152+
phy->mt76->cap.has_2ghz = true;
153+
return;
154+
}
155+
}
141156

142157
switch (val) {
143158
case MT_EE_BAND_SEL_5GHZ:

drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ enum mt7915_eeprom_band {
7676
MT_EE_BAND_SEL_DUAL,
7777
};
7878

79+
enum {
80+
MT_EE_V2_BAND_SEL_2GHZ,
81+
MT_EE_V2_BAND_SEL_5GHZ,
82+
MT_EE_V2_BAND_SEL_6GHZ,
83+
MT_EE_V2_BAND_SEL_5GHZ_6GHZ,
84+
};
85+
7986
enum mt7915_sku_rate_group {
8087
SKU_CCK,
8188
SKU_OFDM,

drivers/net/wireless/mediatek/mt76/mt7915/init.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
872872
if (band == NL80211_BAND_2GHZ)
873873
he_cap_elem->phy_cap_info[0] =
874874
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G;
875-
else if (band == NL80211_BAND_5GHZ)
875+
else
876876
he_cap_elem->phy_cap_info[0] =
877877
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
878878
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
@@ -911,7 +911,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
911911
if (band == NL80211_BAND_2GHZ)
912912
he_cap_elem->phy_cap_info[0] |=
913913
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G;
914-
else if (band == NL80211_BAND_5GHZ)
914+
else
915915
he_cap_elem->phy_cap_info[0] |=
916916
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G;
917917

@@ -961,6 +961,21 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
961961
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
962962
IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK);
963963
}
964+
965+
if (band == NL80211_BAND_6GHZ) {
966+
u16 cap = IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS |
967+
IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS;
968+
969+
cap |= u16_encode_bits(IEEE80211_HT_MPDU_DENSITY_8,
970+
IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START) |
971+
u16_encode_bits(IEEE80211_VHT_MAX_AMPDU_1024K,
972+
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) |
973+
u16_encode_bits(IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454,
974+
IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN);
975+
976+
data[idx].he_6ghz_capa.capa = cpu_to_le16(cap);
977+
}
978+
964979
idx++;
965980
}
966981

@@ -990,6 +1005,15 @@ void mt7915_set_stream_he_caps(struct mt7915_phy *phy)
9901005
band->iftype_data = data;
9911006
band->n_iftype_data = n;
9921007
}
1008+
1009+
if (phy->mt76->cap.has_6ghz) {
1010+
data = phy->iftype[NL80211_BAND_6GHZ];
1011+
n = mt7915_init_he_caps(phy, NL80211_BAND_6GHZ, data);
1012+
1013+
band = &phy->mt76->sband_6g.sband;
1014+
band->iftype_data = data;
1015+
band->n_iftype_data = n;
1016+
}
9931017
}
9941018

9951019
static void mt7915_unregister_ext_phy(struct mt7915_dev *dev)

drivers/net/wireless/mediatek/mt76/mt7915/mac.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
638638
status->band = mphy->chandef.chan->band;
639639
if (status->band == NL80211_BAND_5GHZ)
640640
sband = &mphy->sband_5g.sband;
641+
else if (status->band == NL80211_BAND_6GHZ)
642+
sband = &mphy->sband_6g.sband;
641643
else
642644
sband = &mphy->sband_2g.sband;
643645

@@ -1351,7 +1353,7 @@ mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
13511353
u16 fc, tid;
13521354
u32 val;
13531355

1354-
if (!sta || !sta->ht_cap.ht_supported)
1356+
if (!sta || !(sta->ht_cap.ht_supported || sta->he_cap.has_he))
13551357
return;
13561358

13571359
tid = FIELD_GET(MT_TXD1_TID, le32_to_cpu(txwi[1]));
@@ -1559,6 +1561,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
15591561

15601562
if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
15611563
sband = &mphy->sband_5g.sband;
1564+
else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ)
1565+
sband = &mphy->sband_6g.sband;
15621566
else
15631567
sband = &mphy->sband_2g.sband;
15641568

@@ -1804,7 +1808,7 @@ void mt7915_mac_set_timing(struct mt7915_phy *phy)
18041808
u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) |
18051809
FIELD_PREP(MT_TIMEOUT_VAL_CCA, 28);
18061810
int offset;
1807-
bool is_5ghz = phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ;
1811+
bool a_band = !(phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ);
18081812

18091813
if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
18101814
return;
@@ -1824,15 +1828,15 @@ void mt7915_mac_set_timing(struct mt7915_phy *phy)
18241828
mt76_wr(dev, MT_TMAC_CDTR(phy->band_idx), cck + reg_offset);
18251829
mt76_wr(dev, MT_TMAC_ODTR(phy->band_idx), ofdm + reg_offset);
18261830
mt76_wr(dev, MT_TMAC_ICR0(phy->band_idx),
1827-
FIELD_PREP(MT_IFS_EIFS_OFDM, is_5ghz ? 84 : 78) |
1831+
FIELD_PREP(MT_IFS_EIFS_OFDM, a_band ? 84 : 78) |
18281832
FIELD_PREP(MT_IFS_RIFS, 2) |
18291833
FIELD_PREP(MT_IFS_SIFS, 10) |
18301834
FIELD_PREP(MT_IFS_SLOT, phy->slottime));
18311835

18321836
mt76_wr(dev, MT_TMAC_ICR1(phy->band_idx),
18331837
FIELD_PREP(MT_IFS_EIFS_CCK, 314));
18341838

1835-
if (phy->slottime < 20 || is_5ghz)
1839+
if (phy->slottime < 20 || a_band)
18361840
val = MT7915_CFEND_RATE_DEFAULT;
18371841
else
18381842
val = MT7915_CFEND_RATE_11B;

drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,9 @@ mt7915_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
987987
struct sta_rec_ht *ht;
988988
struct tlv *tlv;
989989

990+
if (!sta->ht_cap.ht_supported)
991+
return;
992+
990993
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));
991994

992995
ht = (struct sta_rec_ht *)tlv;
@@ -1267,6 +1270,9 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb,
12671270
};
12681271
bool ebf;
12691272

1273+
if (!(sta->ht_cap.ht_supported || sta->he_cap.has_he))
1274+
return;
1275+
12701276
ebf = mt7915_is_ebf_supported(phy, vif, sta, false);
12711277
if (!ebf && !dev->ibf)
12721278
return;
@@ -1327,6 +1333,9 @@ mt7915_mcu_sta_bfee_tlv(struct mt7915_dev *dev, struct sk_buff *skb,
13271333
struct tlv *tlv;
13281334
u8 nrow = 0;
13291335

1336+
if (!(sta->vht_cap.vht_supported || sta->he_cap.has_he))
1337+
return;
1338+
13301339
if (!mt7915_is_ebf_supported(phy, vif, sta, true))
13311340
return;
13321341

@@ -1621,6 +1630,10 @@ mt7915_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7915_dev *dev,
16211630
if (sta->he_cap.has_he) {
16221631
ra->supp_mode |= MODE_HE;
16231632
cap |= STA_CAP_HE;
1633+
1634+
if (sta->he_6ghz_capa.capa)
1635+
ra->af = le16_get_bits(sta->he_6ghz_capa.capa,
1636+
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
16241637
}
16251638

16261639
ra->sta_cap = cpu_to_le32(cap);
@@ -1643,7 +1656,7 @@ int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,
16431656
* once dev->rc_work changes the settings driver should also
16441657
* update sta_rec_he here.
16451658
*/
1646-
if (sta->he_cap.has_he && changed)
1659+
if (changed)
16471660
mt7915_mcu_sta_he_tlv(skb, sta, vif);
16481661

16491662
/* sta_rec_ra accommodates BW, NSS and only MCS range format
@@ -1712,7 +1725,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
17121725
goto out;
17131726

17141727
/* tag order is in accordance with firmware dependency. */
1715-
if (sta && sta->ht_cap.ht_supported) {
1728+
if (sta) {
17161729
/* starec bfer */
17171730
mt7915_mcu_sta_bfer_tlv(dev, skb, vif, sta);
17181731
/* starec ht */
@@ -1729,7 +1742,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
17291742
return ret;
17301743
}
17311744

1732-
if (sta && sta->ht_cap.ht_supported) {
1745+
if (sta) {
17331746
/* starec amsdu */
17341747
mt7915_mcu_sta_amsdu_tlv(dev, skb, vif, sta);
17351748
/* starec he */
@@ -2772,6 +2785,11 @@ int mt7915_mcu_rdd_background_enable(struct mt7915_phy *phy,
27722785

27732786
int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
27742787
{
2788+
static const u8 ch_band[] = {
2789+
[NL80211_BAND_2GHZ] = 0,
2790+
[NL80211_BAND_5GHZ] = 1,
2791+
[NL80211_BAND_6GHZ] = 2,
2792+
};
27752793
struct mt7915_dev *dev = phy->dev;
27762794
struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
27772795
int freq1 = chandef->center_freq1;
@@ -2799,7 +2817,7 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
27992817
.tx_streams_num = hweight8(phy->mt76->antenna_mask),
28002818
.rx_streams = phy->mt76->antenna_mask,
28012819
.band_idx = phy->band_idx,
2802-
.channel_band = chandef->chan->band,
2820+
.channel_band = ch_band[chandef->chan->band],
28032821
};
28042822

28052823
#ifdef CONFIG_NL80211_TESTMODE
@@ -3461,6 +3479,8 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
34613479
case MT_PHY_TYPE_OFDM:
34623480
if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
34633481
sband = &mphy->sband_5g.sband;
3482+
else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ)
3483+
sband = &mphy->sband_6g.sband;
34643484
else
34653485
sband = &mphy->sband_2g.sband;
34663486

drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct mt7915_phy {
227227
struct mt76_phy *mt76;
228228
struct mt7915_dev *dev;
229229

230-
struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];
230+
struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
231231

232232
struct ieee80211_vif *monitor_vif;
233233

drivers/net/wireless/mediatek/mt76/mt7915/testmode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time)
271271
case MT76_TM_TX_MODE_OFDM:
272272
if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
273273
sband = &mphy->sband_5g.sband;
274+
else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ)
275+
sband = &mphy->sband_6g.sband;
274276
else
275277
sband = &mphy->sband_2g.sband;
276278

@@ -572,6 +574,8 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
572574

573575
if (chandef->chan->band == NL80211_BAND_5GHZ)
574576
sband = &phy->mt76->sband_5g.sband;
577+
else if (chandef->chan->band == NL80211_BAND_6GHZ)
578+
sband = &phy->mt76->sband_6g.sband;
575579
else
576580
sband = &phy->mt76->sband_2g.sband;
577581

0 commit comments

Comments
 (0)