Skip to content

Commit 5b20557

Browse files
haogrootnbd168
authored andcommitted
wifi: mt76: connac: adjust phy capabilities based on band constraints
Adjust HE and EHT phy capabilities based on the band constraints. For 2g band, we shall not enable the capabilities above 40MHz. Signed-off-by: Howard Hsu <[email protected]> Signed-off-by: Shayne Chen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent 5c2a25a commit 5b20557

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)
405405
mutex_unlock(&dev->mutex);
406406
}
407407

408-
void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss);
408+
void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss, enum nl80211_band band);
409409
int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc,
410410
int ring_base, void *wed, u32 flags);
411411

drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
#define HE_PREP(f, m, v) le16_encode_bits(le32_get_bits(v, MT_CRXV_HE_##m),\
1010
IEEE80211_RADIOTAP_HE_##f)
1111

12-
void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss)
12+
void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss, enum nl80211_band band)
1313
{
1414
static const u8 ppet16_ppet8_ru3_ru0[] = { 0x1c, 0xc7, 0x71 };
15-
u8 i, ppet_bits, ppet_size, ru_bit_mask = 0x7; /* HE80 */
15+
u8 i, ppet_bits, ppet_size, ru_bit_mask = 0xf;
16+
17+
if (band == NL80211_BAND_2GHZ)
18+
ru_bit_mask = 0x3;
1619

1720
he_ppet[0] = FIELD_PREP(IEEE80211_PPE_THRES_NSS_MASK, nss - 1) |
1821
FIELD_PREP(IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
11261126
memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
11271127
if (he_cap_elem->phy_cap_info[6] &
11281128
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
1129-
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
1129+
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
11301130
} else {
11311131
he_cap_elem->phy_cap_info[9] |=
11321132
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mt7921_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
147147
memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
148148
if (he_cap_elem->phy_cap_info[6] &
149149
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
150-
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
150+
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
151151
} else {
152152
he_cap_elem->phy_cap_info[9] |=
153153
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
130130

131131
if (he_cap_elem->phy_cap_info[6] &
132132
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
133-
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
133+
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
134134
} else {
135135
he_cap_elem->phy_cap_info[9] |=
136136
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,

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

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,12 @@ void mt7996_set_stream_vht_txbf_caps(struct mt7996_phy *phy)
10801080

10811081
static void
10821082
mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
1083-
struct ieee80211_sta_he_cap *he_cap, int vif)
1083+
struct ieee80211_sta_he_cap *he_cap, int vif,
1084+
enum nl80211_band band)
10841085
{
10851086
struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
10861087
int sts = hweight16(phy->mt76->chainmask);
1088+
bool non_2g = band != NL80211_BAND_2GHZ;
10871089
u8 c;
10881090

10891091
#ifdef CONFIG_MAC80211_MESH
@@ -1113,10 +1115,10 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
11131115

11141116
if (is_mt7996(phy->mt76->dev))
11151117
c |= IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 |
1116-
IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4;
1118+
(IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 * non_2g);
11171119
else
11181120
c |= IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 |
1119-
IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5;
1121+
(IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 * non_2g);
11201122

11211123
elem->phy_cap_info[4] |= c;
11221124

@@ -1142,8 +1144,9 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
11421144

11431145
c = FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK,
11441146
sts - 1) |
1145-
FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK,
1146-
sts - 1);
1147+
(FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK,
1148+
sts - 1) * non_2g);
1149+
11471150
elem->phy_cap_info[5] |= c;
11481151

11491152
if (vif != NL80211_IFTYPE_AP)
@@ -1155,8 +1158,10 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
11551158
IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB;
11561159
elem->phy_cap_info[6] |= c;
11571160

1158-
c = IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ |
1159-
IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ;
1161+
c = 0;
1162+
if (non_2g)
1163+
c |= IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ |
1164+
IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ;
11601165
elem->phy_cap_info[7] |= c;
11611166
}
11621167

@@ -1262,12 +1267,12 @@ mt7996_init_he_caps(struct mt7996_phy *phy, enum nl80211_band band,
12621267
he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map);
12631268
he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map);
12641269

1265-
mt7996_set_stream_he_txbf_caps(phy, he_cap, iftype);
1270+
mt7996_set_stream_he_txbf_caps(phy, he_cap, iftype, band);
12661271

12671272
memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
12681273
if (he_cap_elem->phy_cap_info[6] &
12691274
IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
1270-
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
1275+
mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
12711276
} else {
12721277
he_cap_elem->phy_cap_info[9] |=
12731278
u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
@@ -1326,13 +1331,20 @@ mt7996_init_eht_caps(struct mt7996_phy *phy, enum nl80211_band band,
13261331

13271332
eht_cap_elem->phy_cap_info[1] =
13281333
u8_encode_bits(u8_get_bits(val, GENMASK(2, 1)),
1329-
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK) |
1330-
u8_encode_bits(val,
1331-
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK);
1334+
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK);
13321335

13331336
eht_cap_elem->phy_cap_info[2] =
1334-
u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK) |
1335-
u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK);
1337+
u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK);
1338+
1339+
if (band != NL80211_BAND_2GHZ) {
1340+
eht_cap_elem->phy_cap_info[1] |=
1341+
u8_encode_bits(val,
1342+
IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK);
1343+
1344+
eht_cap_elem->phy_cap_info[2] |=
1345+
u8_encode_bits(sts - 1,
1346+
IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK);
1347+
}
13361348

13371349
if (band == NL80211_BAND_6GHZ) {
13381350
eht_cap_elem->phy_cap_info[0] |=
@@ -1393,8 +1405,13 @@ mt7996_init_eht_caps(struct mt7996_phy *phy, enum nl80211_band band,
13931405

13941406
eht_cap_elem->phy_cap_info[7] =
13951407
IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ |
1408+
IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ;
1409+
1410+
if (band == NL80211_BAND_2GHZ)
1411+
return;
1412+
1413+
eht_cap_elem->phy_cap_info[7] |=
13961414
IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ |
1397-
IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
13981415
IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ;
13991416

14001417
if (band != NL80211_BAND_6GHZ)

0 commit comments

Comments
 (0)