add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / mac80211 / patches / 303-ath9k-add-DFS-support-for-extension-channel.patch
1 From: Zefir Kurtisi <zefir.kurtisi@neratec.com>
2 Date: Tue, 10 Mar 2015 17:49:30 +0100
3 Subject: [PATCH] ath9k: add DFS support for extension channel
4
5 In HT40 modes, pulse events on primary and extension
6 channel are processed individually. If valid, a pulse
7 event will be fed into the detector
8 * for primary frequency, or
9 * for extension frequency (+/-20MHz based on HT40-mode)
10 * or both
11
12 With that, a 40MHz radar will result in two individual
13 radar events.
14
15 Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
16 ---
17
18 --- a/drivers/net/wireless/ath/ath9k/dfs.c
19 +++ b/drivers/net/wireless/ath/ath9k/dfs.c
20 @@ -126,8 +126,19 @@ ath9k_postprocess_radar_event(struct ath
21         DFS_STAT_INC(sc, pulses_detected);
22         return true;
23  }
24 -#undef PRI_CH_RADAR_FOUND
25 -#undef EXT_CH_RADAR_FOUND
26 +
27 +static void
28 +ath9k_dfs_process_radar_pulse(struct ath_softc *sc, struct pulse_event *pe)
29 +{
30 +       struct dfs_pattern_detector *pd = sc->dfs_detector;
31 +       DFS_STAT_INC(sc, pulses_processed);
32 +       if (pd == NULL)
33 +               return;
34 +       if (!pd->add_pulse(pd, pe))
35 +               return;
36 +       DFS_STAT_INC(sc, radar_detected);
37 +       ieee80211_radar_detected(sc->hw);
38 +}
39  
40  /*
41   * DFS: check PHY-error for radar pulse and feed the detector
42 @@ -176,18 +187,21 @@ void ath9k_dfs_process_phyerr(struct ath
43         ard.pulse_length_pri = vdata_end[-3];
44         pe.freq = ah->curchan->channel;
45         pe.ts = mactime;
46 -       if (ath9k_postprocess_radar_event(sc, &ard, &pe)) {
47 -               struct dfs_pattern_detector *pd = sc->dfs_detector;
48 -               ath_dbg(common, DFS,
49 -                       "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, "
50 -                       "width=%d, rssi=%d, delta_ts=%llu\n",
51 -                       pe.freq, pe.ts, pe.width, pe.rssi,
52 -                       pe.ts - sc->dfs_prev_pulse_ts);
53 -               sc->dfs_prev_pulse_ts = pe.ts;
54 -               DFS_STAT_INC(sc, pulses_processed);
55 -               if (pd != NULL && pd->add_pulse(pd, &pe)) {
56 -                       DFS_STAT_INC(sc, radar_detected);
57 -                       ieee80211_radar_detected(sc->hw);
58 -               }
59 +       if (!ath9k_postprocess_radar_event(sc, &ard, &pe))
60 +               return;
61 +
62 +       ath_dbg(common, DFS,
63 +               "ath9k_dfs_process_phyerr: type=%d, freq=%d, ts=%llu, "
64 +               "width=%d, rssi=%d, delta_ts=%llu\n",
65 +               ard.pulse_bw_info, pe.freq, pe.ts, pe.width, pe.rssi,
66 +               pe.ts - sc->dfs_prev_pulse_ts);
67 +       sc->dfs_prev_pulse_ts = pe.ts;
68 +       if (ard.pulse_bw_info & PRI_CH_RADAR_FOUND)
69 +               ath9k_dfs_process_radar_pulse(sc, &pe);
70 +       if (ard.pulse_bw_info & EXT_CH_RADAR_FOUND) {
71 +               pe.freq += IS_CHAN_HT40PLUS(ah->curchan) ? 20 : -20;
72 +               ath9k_dfs_process_radar_pulse(sc, &pe);
73         }
74  }
75 +#undef PRI_CH_RADAR_FOUND
76 +#undef EXT_CH_RADAR_FOUND