20
20
.max_power = 30, \
21
21
}
22
22
23
+ #define CHAN6G (_idx , _freq ) { \
24
+ .band = NL80211_BAND_6GHZ, \
25
+ .center_freq = (_freq), \
26
+ .hw_value = (_idx), \
27
+ .max_power = 30, \
28
+ }
29
+
23
30
static const struct ieee80211_channel mt76_channels_2ghz [] = {
24
31
CHAN2G (1 , 2412 ),
25
32
CHAN2G (2 , 2417 ),
@@ -70,6 +77,72 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
70
77
CHAN5G (173 , 5865 ),
71
78
};
72
79
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
+
73
146
static const struct ieee80211_tpt_blink mt76_tpt_blink [] = {
74
147
{ .throughput = 0 * 1024 , .blink_time = 334 },
75
148
{ .throughput = 1 * 1024 , .blink_time = 260 },
@@ -194,13 +267,16 @@ void mt76_set_stream_caps(struct mt76_phy *phy, bool vht)
194
267
mt76_init_stream_cap (phy , & phy -> sband_2g .sband , false);
195
268
if (phy -> cap .has_5ghz )
196
269
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 );
197
272
}
198
273
EXPORT_SYMBOL_GPL (mt76_set_stream_caps );
199
274
200
275
static int
201
276
mt76_init_sband (struct mt76_phy * phy , struct mt76_sband * msband ,
202
277
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 )
204
280
{
205
281
struct ieee80211_supported_band * sband = & msband -> sband ;
206
282
struct ieee80211_sta_vht_cap * vht_cap ;
@@ -224,6 +300,9 @@ mt76_init_sband(struct mt76_phy *phy, struct mt76_sband *msband,
224
300
sband -> bitrates = rates ;
225
301
sband -> n_bitrates = n_rates ;
226
302
303
+ if (!ht )
304
+ return 0 ;
305
+
227
306
ht_cap = & sband -> ht_cap ;
228
307
ht_cap -> ht_supported = true;
229
308
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,
260
339
261
340
return mt76_init_sband (phy , & phy -> sband_2g , mt76_channels_2ghz ,
262
341
ARRAY_SIZE (mt76_channels_2ghz ), rates ,
263
- n_rates , false);
342
+ n_rates , true, false);
264
343
}
265
344
266
345
static int
@@ -271,7 +350,18 @@ mt76_init_sband_5g(struct mt76_phy *phy, struct ieee80211_rate *rates,
271
350
272
351
return mt76_init_sband (phy , & phy -> sband_5g , mt76_channels_5ghz ,
273
352
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);
275
365
}
276
366
277
367
static void
@@ -396,9 +486,16 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
396
486
return ret ;
397
487
}
398
488
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
+
399
495
wiphy_read_of_freq_limits (phy -> hw -> wiphy );
400
496
mt76_check_sband (phy , & phy -> sband_2g , NL80211_BAND_2GHZ );
401
497
mt76_check_sband (phy , & phy -> sband_5g , NL80211_BAND_5GHZ );
498
+ mt76_check_sband (phy , & phy -> sband_6g , NL80211_BAND_6GHZ );
402
499
403
500
ret = ieee80211_register_hw (phy -> hw );
404
501
if (ret )
@@ -506,9 +603,16 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
506
603
return ret ;
507
604
}
508
605
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
+
509
612
wiphy_read_of_freq_limits (hw -> wiphy );
510
613
mt76_check_sband (& dev -> phy , & phy -> sband_2g , NL80211_BAND_2GHZ );
511
614
mt76_check_sband (& dev -> phy , & phy -> sband_5g , NL80211_BAND_5GHZ );
615
+ mt76_check_sband (& dev -> phy , & phy -> sband_6g , NL80211_BAND_6GHZ );
512
616
513
617
if (IS_ENABLED (CONFIG_MT76_LEDS )) {
514
618
ret = mt76_led_init (dev );
@@ -653,6 +757,8 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c)
653
757
654
758
if (c -> band == NL80211_BAND_2GHZ )
655
759
msband = & phy -> sband_2g ;
760
+ else if (c -> band == NL80211_BAND_6GHZ )
761
+ msband = & phy -> sband_6g ;
656
762
else
657
763
msband = & phy -> sband_5g ;
658
764
@@ -728,10 +834,16 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
728
834
if (idx == 0 && dev -> drv -> update_survey )
729
835
mt76_update_survey (phy );
730
836
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 ;
734
844
sband = & phy -> sband_5g ;
845
+ } else {
846
+ sband = & phy -> sband_2g ;
735
847
}
736
848
737
849
if (idx >= sband -> sband .n_channels ) {
@@ -1286,7 +1398,7 @@ int mt76_get_rate(struct mt76_dev *dev,
1286
1398
int i , offset = 0 , len = sband -> n_bitrates ;
1287
1399
1288
1400
if (cck ) {
1289
- if (sband == & dev -> phy .sband_5g .sband )
1401
+ if (sband != & dev -> phy .sband_2g .sband )
1290
1402
return 0 ;
1291
1403
1292
1404
idx &= ~BIT (2 ); /* short preamble */
@@ -1358,7 +1470,7 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
1358
1470
int offset = 0 ;
1359
1471
struct ieee80211_rate * rate ;
1360
1472
1361
- if (phy -> chandef .chan -> band == NL80211_BAND_5GHZ )
1473
+ if (phy -> chandef .chan -> band != NL80211_BAND_2GHZ )
1362
1474
offset = 4 ;
1363
1475
1364
1476
/* pick the lowest rate for hidden nodes */
0 commit comments