Skip to content

Commit edf9dab

Browse files
LorenzoBianconinbd168
authored andcommitted
mt76: add 6GHz support
Introduce 6GHz channel list in mt76 module. This is a preliminary patch to unlock 6GHz band for mt7921 devices. Tested-by: Deren Wu <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent bebd368 commit edf9dab

File tree

1 file changed

+120
-8
lines changed

1 file changed

+120
-8
lines changed

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

Lines changed: 120 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
.max_power = 30, \
2121
}
2222

23+
#define CHAN6G(_idx, _freq) { \
24+
.band = NL80211_BAND_6GHZ, \
25+
.center_freq = (_freq), \
26+
.hw_value = (_idx), \
27+
.max_power = 30, \
28+
}
29+
2330
static const struct ieee80211_channel mt76_channels_2ghz[] = {
2431
CHAN2G(1, 2412),
2532
CHAN2G(2, 2417),
@@ -70,6 +77,72 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
7077
CHAN5G(173, 5865),
7178
};
7279

80+
static const struct ieee80211_channel mt76_channels_6ghz[] = {
81+
/* UNII-5 */
82+
CHAN6G(1, 5955),
83+
CHAN6G(5, 5975),
84+
CHAN6G(9, 5995),
85+
CHAN6G(13, 6015),
86+
CHAN6G(17, 6035),
87+
CHAN6G(21, 6055),
88+
CHAN6G(25, 6075),
89+
CHAN6G(29, 6095),
90+
CHAN6G(33, 6115),
91+
CHAN6G(37, 6135),
92+
CHAN6G(41, 6155),
93+
CHAN6G(45, 6175),
94+
CHAN6G(49, 6195),
95+
CHAN6G(53, 6215),
96+
CHAN6G(57, 6235),
97+
CHAN6G(61, 6255),
98+
CHAN6G(65, 6275),
99+
CHAN6G(69, 6295),
100+
CHAN6G(73, 6315),
101+
CHAN6G(77, 6335),
102+
CHAN6G(81, 6355),
103+
CHAN6G(85, 6375),
104+
CHAN6G(89, 6395),
105+
CHAN6G(93, 6415),
106+
/* UNII-6 */
107+
CHAN6G(97, 6435),
108+
CHAN6G(101, 6455),
109+
CHAN6G(105, 6475),
110+
CHAN6G(109, 6495),
111+
CHAN6G(113, 6515),
112+
CHAN6G(117, 6535),
113+
/* UNII-7 */
114+
CHAN6G(121, 6555),
115+
CHAN6G(125, 6575),
116+
CHAN6G(129, 6595),
117+
CHAN6G(133, 6615),
118+
CHAN6G(137, 6635),
119+
CHAN6G(141, 6655),
120+
CHAN6G(145, 6675),
121+
CHAN6G(149, 6695),
122+
CHAN6G(153, 6715),
123+
CHAN6G(157, 6735),
124+
CHAN6G(161, 6755),
125+
CHAN6G(165, 6775),
126+
CHAN6G(169, 6795),
127+
CHAN6G(173, 6815),
128+
CHAN6G(177, 6835),
129+
CHAN6G(181, 6855),
130+
CHAN6G(185, 6875),
131+
/* UNII-8 */
132+
CHAN6G(189, 6895),
133+
CHAN6G(193, 6915),
134+
CHAN6G(197, 6935),
135+
CHAN6G(201, 6955),
136+
CHAN6G(205, 6975),
137+
CHAN6G(209, 6995),
138+
CHAN6G(213, 7015),
139+
CHAN6G(217, 7035),
140+
CHAN6G(221, 7055),
141+
CHAN6G(225, 7075),
142+
CHAN6G(229, 7095),
143+
CHAN6G(233, 7115),
144+
};
145+
73146
static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
74147
{ .throughput = 0 * 1024, .blink_time = 334 },
75148
{ .throughput = 1 * 1024, .blink_time = 260 },
@@ -194,13 +267,16 @@ void mt76_set_stream_caps(struct mt76_phy *phy, bool vht)
194267
mt76_init_stream_cap(phy, &phy->sband_2g.sband, false);
195268
if (phy->cap.has_5ghz)
196269
mt76_init_stream_cap(phy, &phy->sband_5g.sband, vht);
270+
if (phy->cap.has_6ghz)
271+
mt76_init_stream_cap(phy, &phy->sband_6g.sband, vht);
197272
}
198273
EXPORT_SYMBOL_GPL(mt76_set_stream_caps);
199274

200275
static int
201276
mt76_init_sband(struct mt76_phy *phy, struct mt76_sband *msband,
202277
const struct ieee80211_channel *chan, int n_chan,
203-
struct ieee80211_rate *rates, int n_rates, bool vht)
278+
struct ieee80211_rate *rates, int n_rates,
279+
bool ht, bool vht)
204280
{
205281
struct ieee80211_supported_band *sband = &msband->sband;
206282
struct ieee80211_sta_vht_cap *vht_cap;
@@ -224,6 +300,9 @@ mt76_init_sband(struct mt76_phy *phy, struct mt76_sband *msband,
224300
sband->bitrates = rates;
225301
sband->n_bitrates = n_rates;
226302

303+
if (!ht)
304+
return 0;
305+
227306
ht_cap = &sband->ht_cap;
228307
ht_cap->ht_supported = true;
229308
ht_cap->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
@@ -260,7 +339,7 @@ mt76_init_sband_2g(struct mt76_phy *phy, struct ieee80211_rate *rates,
260339

261340
return mt76_init_sband(phy, &phy->sband_2g, mt76_channels_2ghz,
262341
ARRAY_SIZE(mt76_channels_2ghz), rates,
263-
n_rates, false);
342+
n_rates, true, false);
264343
}
265344

266345
static int
@@ -271,7 +350,18 @@ mt76_init_sband_5g(struct mt76_phy *phy, struct ieee80211_rate *rates,
271350

272351
return mt76_init_sband(phy, &phy->sband_5g, mt76_channels_5ghz,
273352
ARRAY_SIZE(mt76_channels_5ghz), rates,
274-
n_rates, vht);
353+
n_rates, true, vht);
354+
}
355+
356+
static int
357+
mt76_init_sband_6g(struct mt76_phy *phy, struct ieee80211_rate *rates,
358+
int n_rates)
359+
{
360+
phy->hw->wiphy->bands[NL80211_BAND_6GHZ] = &phy->sband_6g.sband;
361+
362+
return mt76_init_sband(phy, &phy->sband_6g, mt76_channels_6ghz,
363+
ARRAY_SIZE(mt76_channels_6ghz), rates,
364+
n_rates, false, false);
275365
}
276366

277367
static void
@@ -396,9 +486,16 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
396486
return ret;
397487
}
398488

489+
if (phy->cap.has_6ghz) {
490+
ret = mt76_init_sband_6g(phy, rates + 4, n_rates - 4);
491+
if (ret)
492+
return ret;
493+
}
494+
399495
wiphy_read_of_freq_limits(phy->hw->wiphy);
400496
mt76_check_sband(phy, &phy->sband_2g, NL80211_BAND_2GHZ);
401497
mt76_check_sband(phy, &phy->sband_5g, NL80211_BAND_5GHZ);
498+
mt76_check_sband(phy, &phy->sband_6g, NL80211_BAND_6GHZ);
402499

403500
ret = ieee80211_register_hw(phy->hw);
404501
if (ret)
@@ -506,9 +603,16 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
506603
return ret;
507604
}
508605

606+
if (phy->cap.has_6ghz) {
607+
ret = mt76_init_sband_6g(phy, rates + 4, n_rates - 4);
608+
if (ret)
609+
return ret;
610+
}
611+
509612
wiphy_read_of_freq_limits(hw->wiphy);
510613
mt76_check_sband(&dev->phy, &phy->sband_2g, NL80211_BAND_2GHZ);
511614
mt76_check_sband(&dev->phy, &phy->sband_5g, NL80211_BAND_5GHZ);
615+
mt76_check_sband(&dev->phy, &phy->sband_6g, NL80211_BAND_6GHZ);
512616

513617
if (IS_ENABLED(CONFIG_MT76_LEDS)) {
514618
ret = mt76_led_init(dev);
@@ -653,6 +757,8 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
653757

654758
if (c->band == NL80211_BAND_2GHZ)
655759
msband = &phy->sband_2g;
760+
else if (c->band == NL80211_BAND_6GHZ)
761+
msband = &phy->sband_6g;
656762
else
657763
msband = &phy->sband_5g;
658764

@@ -728,10 +834,16 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
728834
if (idx == 0 && dev->drv->update_survey)
729835
mt76_update_survey(phy);
730836

731-
sband = &phy->sband_2g;
732-
if (idx >= sband->sband.n_channels) {
733-
idx -= sband->sband.n_channels;
837+
if (idx >= phy->sband_2g.sband.n_channels +
838+
phy->sband_5g.sband.n_channels) {
839+
idx -= (phy->sband_2g.sband.n_channels +
840+
phy->sband_5g.sband.n_channels);
841+
sband = &phy->sband_6g;
842+
} else if (idx >= phy->sband_2g.sband.n_channels) {
843+
idx -= phy->sband_2g.sband.n_channels;
734844
sband = &phy->sband_5g;
845+
} else {
846+
sband = &phy->sband_2g;
735847
}
736848

737849
if (idx >= sband->sband.n_channels) {
@@ -1286,7 +1398,7 @@ int mt76_get_rate(struct mt76_dev *dev,
12861398
int i, offset = 0, len = sband->n_bitrates;
12871399

12881400
if (cck) {
1289-
if (sband == &dev->phy.sband_5g.sband)
1401+
if (sband != &dev->phy.sband_2g.sband)
12901402
return 0;
12911403

12921404
idx &= ~BIT(2); /* short preamble */
@@ -1358,7 +1470,7 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
13581470
int offset = 0;
13591471
struct ieee80211_rate *rate;
13601472

1361-
if (phy->chandef.chan->band == NL80211_BAND_5GHZ)
1473+
if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
13621474
offset = 4;
13631475

13641476
/* pick the lowest rate for hidden nodes */

0 commit comments

Comments
 (0)