Skip to content

Commit 50ac15a

Browse files
LorenzoBianconinbd168
authored andcommitted
mt76: mt7921: add 6GHz support
Unlock 6GHz band if supported by the device. Configure HE 6G capabilities. Tested-by: Deren Wu <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent edf9dab commit 50ac15a

File tree

4 files changed

+64
-16
lines changed

4 files changed

+64
-16
lines changed

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,14 @@ mt7921_get_status_freq_info(struct mt7921_dev *dev, struct mt76_phy *mphy,
355355
return;
356356
}
357357

358-
status->band = chfreq <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
358+
if (chfreq > 180) {
359+
status->band = NL80211_BAND_6GHZ;
360+
chfreq = (chfreq - 181) * 4 + 1;
361+
} else if (chfreq > 14) {
362+
status->band = NL80211_BAND_5GHZ;
363+
} else {
364+
status->band = NL80211_BAND_2GHZ;
365+
}
359366
status->freq = ieee80211_channel_to_frequency(chfreq, status->band);
360367
}
361368

@@ -441,10 +448,17 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
441448

442449
mt7921_get_status_freq_info(dev, mphy, status, chfreq);
443450

444-
if (status->band == NL80211_BAND_5GHZ)
451+
switch (status->band) {
452+
case NL80211_BAND_5GHZ:
445453
sband = &mphy->sband_5g.sband;
446-
else
454+
break;
455+
case NL80211_BAND_6GHZ:
456+
sband = &mphy->sband_6g.sband;
457+
break;
458+
default:
447459
sband = &mphy->sband_2g.sband;
460+
break;
461+
}
448462

449463
if (!sband->channels)
450464
return -EINVAL;
@@ -994,7 +1008,7 @@ mt7921_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
9941008
u16 fc, tid;
9951009
u32 val;
9961010

997-
if (!sta || !sta->ht_cap.ht_supported)
1011+
if (!sta || !(sta->ht_cap.ht_supported || sta->he_cap.has_he))
9981012
return;
9991013

10001014
tid = FIELD_GET(MT_TXD1_TID, le32_to_cpu(txwi[1]));
@@ -1392,17 +1406,12 @@ void mt7921_mac_set_timing(struct mt7921_phy *phy)
13921406
FIELD_PREP(MT_TIMEOUT_VAL_CCA, 48);
13931407
u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) |
13941408
FIELD_PREP(MT_TIMEOUT_VAL_CCA, 28);
1395-
int sifs, offset;
1396-
bool is_5ghz = phy->mt76->chandef.chan->band == NL80211_BAND_5GHZ;
1409+
bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ;
1410+
int sifs = is_2ghz ? 10 : 16, offset;
13971411

13981412
if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
13991413
return;
14001414

1401-
if (is_5ghz)
1402-
sifs = 16;
1403-
else
1404-
sifs = 10;
1405-
14061415
mt76_set(dev, MT_ARB_SCR(0),
14071416
MT_ARB_SCR_TX_DISABLE | MT_ARB_SCR_RX_DISABLE);
14081417
udelay(1);
@@ -1419,7 +1428,7 @@ void mt7921_mac_set_timing(struct mt7921_phy *phy)
14191428
FIELD_PREP(MT_IFS_SIFS, sifs) |
14201429
FIELD_PREP(MT_IFS_SLOT, phy->slottime));
14211430

1422-
if (phy->slottime < 20 || is_5ghz)
1431+
if (phy->slottime < 20 || !is_2ghz)
14231432
val = MT7921_CFEND_RATE_DEFAULT;
14241433
else
14251434
val = MT7921_CFEND_RATE_11B;

drivers/net/wireless/mediatek/mt76/mt7921/main.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
7272
if (band == NL80211_BAND_2GHZ)
7373
he_cap_elem->phy_cap_info[0] =
7474
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G;
75-
else if (band == NL80211_BAND_5GHZ)
75+
else
7676
he_cap_elem->phy_cap_info[0] =
7777
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G;
7878

@@ -93,7 +93,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
9393
if (band == NL80211_BAND_2GHZ)
9494
he_cap_elem->phy_cap_info[0] |=
9595
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G;
96-
else if (band == NL80211_BAND_5GHZ)
96+
else
9797
he_cap_elem->phy_cap_info[0] |=
9898
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G;
9999

@@ -142,6 +142,32 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
142142
he_cap_elem->phy_cap_info[9] |=
143143
IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_16US;
144144
}
145+
146+
if (band == NL80211_BAND_6GHZ) {
147+
struct ieee80211_supported_band *sband =
148+
&phy->mt76->sband_5g.sband;
149+
struct ieee80211_sta_vht_cap *vht_cap = &sband->vht_cap;
150+
struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap;
151+
u32 exp;
152+
u16 cap;
153+
154+
cap = u16_encode_bits(ht_cap->ampdu_density,
155+
IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START);
156+
exp = u32_get_bits(vht_cap->cap,
157+
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
158+
cap |= u16_encode_bits(exp,
159+
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
160+
exp = u32_get_bits(vht_cap->cap,
161+
IEEE80211_VHT_CAP_MAX_MPDU_MASK);
162+
cap |= u16_encode_bits(exp,
163+
IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN);
164+
if (vht_cap->cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN)
165+
cap |= IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS;
166+
if (vht_cap->cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN)
167+
cap |= IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS;
168+
169+
data->he_6ghz_capa.capa = cpu_to_le16(cap);
170+
}
145171
idx++;
146172
}
147173

@@ -170,6 +196,15 @@ void mt7921_set_stream_he_caps(struct mt7921_phy *phy)
170196
band = &phy->mt76->sband_5g.sband;
171197
band->iftype_data = data;
172198
band->n_iftype_data = n;
199+
200+
if (phy->mt76->cap.has_6ghz) {
201+
data = phy->iftype[NL80211_BAND_6GHZ];
202+
n = mt7921_init_he_caps(phy, NL80211_BAND_6GHZ, data);
203+
204+
band = &phy->mt76->sband_6g.sband;
205+
band->iftype_data = data;
206+
band->n_iftype_data = n;
207+
}
173208
}
174209
}
175210

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,13 @@ int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd)
10281028
.tx_streams_num = hweight8(phy->mt76->antenna_mask),
10291029
.rx_streams = phy->mt76->antenna_mask,
10301030
.band_idx = phy != &dev->phy,
1031-
.channel_band = chandef->chan->band,
10321031
};
10331032

1033+
if (chandef->chan->band == NL80211_BAND_6GHZ)
1034+
req.channel_band = 2;
1035+
else
1036+
req.channel_band = chandef->chan->band;
1037+
10341038
if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
10351039
req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
10361040
else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct mt7921_phy {
112112
struct mt76_phy *mt76;
113113
struct mt7921_dev *dev;
114114

115-
struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];
115+
struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
116116

117117
u32 rxfilter;
118118
u64 omac_mask;

0 commit comments

Comments
 (0)