Skip to content

Commit df94b37

Browse files
ecsvgregkh
authored andcommitted
ath11k: Fix ETSI regd with weather radar overlap
[ Upstream commit 086c921 ] Some ETSI countries have a small overlap in the wireless-regdb with an ETSI channel (5590-5650). A good example is Australia: country AU: DFS-ETSI (2400 - 2483.5 @ 40), (36) (5150 - 5250 @ 80), (23), NO-OUTDOOR, AUTO-BW (5250 - 5350 @ 80), (20), NO-OUTDOOR, AUTO-BW, DFS (5470 - 5600 @ 80), (27), DFS (5650 - 5730 @ 80), (27), DFS (5730 - 5850 @ 80), (36) (57000 - 66000 @ 2160), (43), NO-OUTDOOR If the firmware (or the BDF) is shipped with these rules then there is only a 10 MHz overlap with the weather radar: * below: 5470 - 5590 * weather radar: 5590 - 5600 * above: (none for the rule "5470 - 5600 @ 80") There are several wrong assumption in the ath11k code: * there is always a valid range below the weather radar (actually: there could be no range below the weather radar range OR range could be smaller than 20 MHz) * intersected range in the weather radar range is valid (actually: the range could be smaller than 20 MHz) * range above weather radar is either empty or valid (actually: the range could be smaller than 20 MHz) These wrong assumption will lead in this example to a rule (5590 - 5600 @ 20), (N/A, 27), (600000 ms), DFS, AUTO-BW which is invalid according to is_valid_reg_rule() because the freq_diff is only 10 MHz but the max_bandwidth is set to 20 MHz. Which results in a rejection like: WARNING: at backports-20210222_001-4.4.60-b157d2276/net/wireless/reg.c:3984 [...] Call trace: [<ffffffbffc3d2e50>] reg_get_max_bandwidth+0x300/0x3a8 [cfg80211] [<ffffffbffc3d3d0c>] regulatory_set_wiphy_regd_sync+0x3c/0x98 [cfg80211] [<ffffffbffc651598>] ath11k_regd_update+0x1a8/0x210 [ath11k] [<ffffffbffc652108>] ath11k_regd_update_work+0x18/0x20 [ath11k] [<ffffffc0000a93e0>] process_one_work+0x1f8/0x340 [<ffffffc0000a9784>] worker_thread+0x25c/0x448 [<ffffffc0000aedc8>] kthread+0xd0/0xd8 [<ffffffc000085550>] ret_from_fork+0x10/0x40 ath11k c000000.wifi: failed to perform regd update : -22 Invalid regulatory domain detected To avoid this, the algorithm has to be changed slightly. Instead of splitting a rule which overlaps with the weather radar range into 3 pieces and accepting the first two parts blindly, it must actually be checked for each piece whether it is a valid range. And only if it is valid, add it to the output array. When these checks are in place, the processed rules for AU would end up as country AU: DFS-ETSI (2400 - 2483 @ 40), (N/A, 36), (N/A) (5150 - 5250 @ 80), (6, 23), (N/A), NO-OUTDOOR, AUTO-BW (5250 - 5350 @ 80), (6, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW (5470 - 5590 @ 80), (6, 27), (0 ms), DFS, AUTO-BW (5650 - 5730 @ 80), (6, 27), (0 ms), DFS, AUTO-BW (5730 - 5850 @ 80), (6, 36), (N/A), AUTO-BW and will be accepted by the wireless regulatory code. Fixes: d5c6515 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20211112153116.1214421-1-sven@narfation.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ffc9019 commit df94b37

1 file changed

Lines changed: 56 additions & 47 deletions

File tree

  • drivers/net/wireless/ath/ath11k

‎drivers/net/wireless/ath/ath11k/reg.c‎

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,20 @@ ath11k_reg_adjust_bw(u16 start_freq, u16 end_freq, u16 max_bw)
456456
{
457457
u16 bw;
458458

459+
if (end_freq <= start_freq)
460+
return 0;
461+
459462
bw = end_freq - start_freq;
460463
bw = min_t(u16, bw, max_bw);
461464

462465
if (bw >= 80 && bw < 160)
463466
bw = 80;
464467
else if (bw >= 40 && bw < 80)
465468
bw = 40;
466-
else if (bw < 40)
469+
else if (bw >= 20 && bw < 40)
467470
bw = 20;
471+
else
472+
bw = 0;
468473

469474
return bw;
470475
}
@@ -488,73 +493,77 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
488493
struct cur_reg_rule *reg_rule,
489494
u8 *rule_idx, u32 flags, u16 max_bw)
490495
{
496+
u32 start_freq;
491497
u32 end_freq;
492498
u16 bw;
493499
u8 i;
494500

495501
i = *rule_idx;
496502

503+
/* there might be situations when even the input rule must be dropped */
504+
i--;
505+
506+
/* frequencies below weather radar */
497507
bw = ath11k_reg_adjust_bw(reg_rule->start_freq,
498508
ETSI_WEATHER_RADAR_BAND_LOW, max_bw);
509+
if (bw > 0) {
510+
i++;
499511

500-
ath11k_reg_update_rule(regd->reg_rules + i, reg_rule->start_freq,
501-
ETSI_WEATHER_RADAR_BAND_LOW, bw,
502-
reg_rule->ant_gain, reg_rule->reg_power,
503-
flags);
512+
ath11k_reg_update_rule(regd->reg_rules + i,
513+
reg_rule->start_freq,
514+
ETSI_WEATHER_RADAR_BAND_LOW, bw,
515+
reg_rule->ant_gain, reg_rule->reg_power,
516+
flags);
504517

505-
ath11k_dbg(ab, ATH11K_DBG_REG,
506-
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
507-
i + 1, reg_rule->start_freq, ETSI_WEATHER_RADAR_BAND_LOW,
508-
bw, reg_rule->ant_gain, reg_rule->reg_power,
509-
regd->reg_rules[i].dfs_cac_ms,
510-
flags);
511-
512-
if (reg_rule->end_freq > ETSI_WEATHER_RADAR_BAND_HIGH)
513-
end_freq = ETSI_WEATHER_RADAR_BAND_HIGH;
514-
else
515-
end_freq = reg_rule->end_freq;
518+
ath11k_dbg(ab, ATH11K_DBG_REG,
519+
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
520+
i + 1, reg_rule->start_freq,
521+
ETSI_WEATHER_RADAR_BAND_LOW, bw, reg_rule->ant_gain,
522+
reg_rule->reg_power, regd->reg_rules[i].dfs_cac_ms,
523+
flags);
524+
}
516525

517-
bw = ath11k_reg_adjust_bw(ETSI_WEATHER_RADAR_BAND_LOW, end_freq,
518-
max_bw);
526+
/* weather radar frequencies */
527+
start_freq = max_t(u32, reg_rule->start_freq,
528+
ETSI_WEATHER_RADAR_BAND_LOW);
529+
end_freq = min_t(u32, reg_rule->end_freq, ETSI_WEATHER_RADAR_BAND_HIGH);
519530

520-
i++;
531+
bw = ath11k_reg_adjust_bw(start_freq, end_freq, max_bw);
532+
if (bw > 0) {
533+
i++;
521534

522-
ath11k_reg_update_rule(regd->reg_rules + i,
523-
ETSI_WEATHER_RADAR_BAND_LOW, end_freq, bw,
524-
reg_rule->ant_gain, reg_rule->reg_power,
525-
flags);
535+
ath11k_reg_update_rule(regd->reg_rules + i, start_freq,
536+
end_freq, bw, reg_rule->ant_gain,
537+
reg_rule->reg_power, flags);
526538

527-
regd->reg_rules[i].dfs_cac_ms = ETSI_WEATHER_RADAR_BAND_CAC_TIMEOUT;
539+
regd->reg_rules[i].dfs_cac_ms = ETSI_WEATHER_RADAR_BAND_CAC_TIMEOUT;
528540

529-
ath11k_dbg(ab, ATH11K_DBG_REG,
530-
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
531-
i + 1, ETSI_WEATHER_RADAR_BAND_LOW, end_freq,
532-
bw, reg_rule->ant_gain, reg_rule->reg_power,
533-
regd->reg_rules[i].dfs_cac_ms,
534-
flags);
535-
536-
if (end_freq == reg_rule->end_freq) {
537-
regd->n_reg_rules--;
538-
*rule_idx = i;
539-
return;
541+
ath11k_dbg(ab, ATH11K_DBG_REG,
542+
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
543+
i + 1, start_freq, end_freq, bw,
544+
reg_rule->ant_gain, reg_rule->reg_power,
545+
regd->reg_rules[i].dfs_cac_ms, flags);
540546
}
541547

548+
/* frequencies above weather radar */
542549
bw = ath11k_reg_adjust_bw(ETSI_WEATHER_RADAR_BAND_HIGH,
543550
reg_rule->end_freq, max_bw);
551+
if (bw > 0) {
552+
i++;
544553

545-
i++;
546-
547-
ath11k_reg_update_rule(regd->reg_rules + i, ETSI_WEATHER_RADAR_BAND_HIGH,
548-
reg_rule->end_freq, bw,
549-
reg_rule->ant_gain, reg_rule->reg_power,
550-
flags);
554+
ath11k_reg_update_rule(regd->reg_rules + i,
555+
ETSI_WEATHER_RADAR_BAND_HIGH,
556+
reg_rule->end_freq, bw,
557+
reg_rule->ant_gain, reg_rule->reg_power,
558+
flags);
551559

552-
ath11k_dbg(ab, ATH11K_DBG_REG,
553-
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
554-
i + 1, ETSI_WEATHER_RADAR_BAND_HIGH, reg_rule->end_freq,
555-
bw, reg_rule->ant_gain, reg_rule->reg_power,
556-
regd->reg_rules[i].dfs_cac_ms,
557-
flags);
560+
ath11k_dbg(ab, ATH11K_DBG_REG,
561+
"\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
562+
i + 1, ETSI_WEATHER_RADAR_BAND_HIGH,
563+
reg_rule->end_freq, bw, reg_rule->ant_gain,
564+
reg_rule->reg_power, regd->reg_rules[i].dfs_cac_ms,
565+
flags);
566+
}
558567

559568
*rule_idx = i;
560569
}

0 commit comments

Comments
 (0)