Skip to content

Commit 551e1ef

Browse files
LorenzoBianconiKalle Valo
authored andcommitted
mt76: add mt76_init_stream_cap routine
Add mt76_init_stream_cap utility routine to set ht/vht sta capabilities related to number of streams currently used by the device (it will be used by mac80211 set_antenna callback) Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 24114a5 commit 551e1ef

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

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

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,43 @@ static int mt76_led_init(struct mt76_dev *dev)
119119
return devm_led_classdev_register(dev->dev, &dev->led_cdev);
120120
}
121121

122+
static void mt76_init_stream_cap(struct mt76_dev *dev,
123+
struct ieee80211_supported_band *sband,
124+
bool vht)
125+
{
126+
struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap;
127+
int i, nstream = __sw_hweight8(dev->antenna_mask);
128+
struct ieee80211_sta_vht_cap *vht_cap;
129+
u16 mcs_map = 0;
130+
131+
if (nstream > 1)
132+
ht_cap->cap |= IEEE80211_HT_CAP_TX_STBC;
133+
else
134+
ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC;
135+
136+
for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
137+
ht_cap->mcs.rx_mask[i] = i < nstream ? 0xff : 0;
138+
139+
if (!vht)
140+
return;
141+
142+
vht_cap = &sband->vht_cap;
143+
if (nstream > 1)
144+
vht_cap->cap |= IEEE80211_VHT_CAP_TXSTBC;
145+
else
146+
vht_cap->cap &= ~IEEE80211_VHT_CAP_TXSTBC;
147+
148+
for (i = 0; i < 8; i++) {
149+
if (i < nstream)
150+
mcs_map |= (IEEE80211_VHT_MCS_SUPPORT_0_9 << (i * 2));
151+
else
152+
mcs_map |=
153+
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (i * 2));
154+
}
155+
vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
156+
vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
157+
}
158+
122159
static int
123160
mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
124161
const struct ieee80211_channel *chan, int n_chan,
@@ -128,7 +165,6 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
128165
struct ieee80211_sta_ht_cap *ht_cap;
129166
struct ieee80211_sta_vht_cap *vht_cap;
130167
void *chanlist;
131-
u16 mcs_map;
132168
int size;
133169

134170
size = n_chan * sizeof(*chan);
@@ -153,34 +189,20 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
153189
IEEE80211_HT_CAP_GRN_FLD |
154190
IEEE80211_HT_CAP_SGI_20 |
155191
IEEE80211_HT_CAP_SGI_40 |
156-
IEEE80211_HT_CAP_TX_STBC |
157192
(1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
158193

159-
ht_cap->mcs.rx_mask[0] = 0xff;
160-
ht_cap->mcs.rx_mask[1] = 0xff;
161194
ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
162195
ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
163196
ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_4;
164197

198+
mt76_init_stream_cap(dev, sband, vht);
199+
165200
if (!vht)
166201
return 0;
167202

168203
vht_cap = &sband->vht_cap;
169204
vht_cap->vht_supported = true;
170-
171-
mcs_map = (IEEE80211_VHT_MCS_SUPPORT_0_9 << (0 * 2)) |
172-
(IEEE80211_VHT_MCS_SUPPORT_0_9 << (1 * 2)) |
173-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (2 * 2)) |
174-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (3 * 2)) |
175-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (4 * 2)) |
176-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (5 * 2)) |
177-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (6 * 2)) |
178-
(IEEE80211_VHT_MCS_NOT_SUPPORTED << (7 * 2));
179-
180-
vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
181-
vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
182205
vht_cap->cap |= IEEE80211_VHT_CAP_RXLDPC |
183-
IEEE80211_VHT_CAP_TXSTBC |
184206
IEEE80211_VHT_CAP_RXSTBC_1 |
185207
IEEE80211_VHT_CAP_SHORT_GI_80;
186208

0 commit comments

Comments
 (0)