Commit 56dc389f authored by Zefir Kurtisi's avatar Zefir Kurtisi Committed by John W. Linville

ath9k: update to DFS pattern detector interface

Follow updates in DFS pattern detector interface:
a) use given pulse event structure
b) adapt to boolean return value of add_pulse()
Signed-off-by: default avatarZefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 8e92d3f2
...@@ -21,17 +21,6 @@ ...@@ -21,17 +21,6 @@
#include "dfs.h" #include "dfs.h"
#include "dfs_debug.h" #include "dfs_debug.h"
/*
* TODO: move into or synchronize this with generic header
* as soon as IF is defined
*/
struct dfs_radar_pulse {
u16 freq;
u64 ts;
u32 width;
u8 rssi;
};
/* internal struct to pass radar data */ /* internal struct to pass radar data */
struct ath_radar_data { struct ath_radar_data {
u8 pulse_bw_info; u8 pulse_bw_info;
...@@ -60,44 +49,44 @@ static u32 dur_to_usecs(struct ath_hw *ah, u32 dur) ...@@ -60,44 +49,44 @@ static u32 dur_to_usecs(struct ath_hw *ah, u32 dur)
#define EXT_CH_RADAR_FOUND 0x02 #define EXT_CH_RADAR_FOUND 0x02
static bool static bool
ath9k_postprocess_radar_event(struct ath_softc *sc, ath9k_postprocess_radar_event(struct ath_softc *sc,
struct ath_radar_data *are, struct ath_radar_data *ard,
struct dfs_radar_pulse *drp) struct pulse_event *pe)
{ {
u8 rssi; u8 rssi;
u16 dur; u16 dur;
ath_dbg(ath9k_hw_common(sc->sc_ah), DFS, ath_dbg(ath9k_hw_common(sc->sc_ah), DFS,
"pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n", "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n",
are->pulse_bw_info, ard->pulse_bw_info,
are->pulse_length_pri, are->rssi, ard->pulse_length_pri, ard->rssi,
are->pulse_length_ext, are->ext_rssi); ard->pulse_length_ext, ard->ext_rssi);
/* /*
* Only the last 2 bits of the BW info are relevant, they indicate * Only the last 2 bits of the BW info are relevant, they indicate
* which channel the radar was detected in. * which channel the radar was detected in.
*/ */
are->pulse_bw_info &= 0x03; ard->pulse_bw_info &= 0x03;
switch (are->pulse_bw_info) { switch (ard->pulse_bw_info) {
case PRI_CH_RADAR_FOUND: case PRI_CH_RADAR_FOUND:
/* radar in ctrl channel */ /* radar in ctrl channel */
dur = are->pulse_length_pri; dur = ard->pulse_length_pri;
DFS_STAT_INC(sc, pri_phy_errors); DFS_STAT_INC(sc, pri_phy_errors);
/* /*
* cannot use ctrl channel RSSI * cannot use ctrl channel RSSI
* if extension channel is stronger * if extension channel is stronger
*/ */
rssi = (are->ext_rssi >= (are->rssi + 3)) ? 0 : are->rssi; rssi = (ard->ext_rssi >= (ard->rssi + 3)) ? 0 : ard->rssi;
break; break;
case EXT_CH_RADAR_FOUND: case EXT_CH_RADAR_FOUND:
/* radar in extension channel */ /* radar in extension channel */
dur = are->pulse_length_ext; dur = ard->pulse_length_ext;
DFS_STAT_INC(sc, ext_phy_errors); DFS_STAT_INC(sc, ext_phy_errors);
/* /*
* cannot use extension channel RSSI * cannot use extension channel RSSI
* if control channel is stronger * if control channel is stronger
*/ */
rssi = (are->rssi >= (are->ext_rssi + 12)) ? 0 : are->ext_rssi; rssi = (ard->rssi >= (ard->ext_rssi + 12)) ? 0 : ard->ext_rssi;
break; break;
case (PRI_CH_RADAR_FOUND | EXT_CH_RADAR_FOUND): case (PRI_CH_RADAR_FOUND | EXT_CH_RADAR_FOUND):
/* /*
...@@ -107,14 +96,14 @@ ath9k_postprocess_radar_event(struct ath_softc *sc, ...@@ -107,14 +96,14 @@ ath9k_postprocess_radar_event(struct ath_softc *sc,
* Radiated testing, when pulse is on DC, different pri and * Radiated testing, when pulse is on DC, different pri and
* ext durations are reported, so take the larger of the two * ext durations are reported, so take the larger of the two
*/ */
if (are->pulse_length_ext >= are->pulse_length_pri) if (ard->pulse_length_ext >= ard->pulse_length_pri)
dur = are->pulse_length_ext; dur = ard->pulse_length_ext;
else else
dur = are->pulse_length_pri; dur = ard->pulse_length_pri;
DFS_STAT_INC(sc, dc_phy_errors); DFS_STAT_INC(sc, dc_phy_errors);
/* when both are present use stronger one */ /* when both are present use stronger one */
rssi = (are->rssi < are->ext_rssi) ? are->ext_rssi : are->rssi; rssi = (ard->rssi < ard->ext_rssi) ? ard->ext_rssi : ard->rssi;
break; break;
default: default:
/* /*
...@@ -137,8 +126,8 @@ ath9k_postprocess_radar_event(struct ath_softc *sc, ...@@ -137,8 +126,8 @@ ath9k_postprocess_radar_event(struct ath_softc *sc,
*/ */
/* convert duration to usecs */ /* convert duration to usecs */
drp->width = dur_to_usecs(sc->sc_ah, dur); pe->width = dur_to_usecs(sc->sc_ah, dur);
drp->rssi = rssi; pe->rssi = rssi;
DFS_STAT_INC(sc, pulses_detected); DFS_STAT_INC(sc, pulses_detected);
return true; return true;
...@@ -155,12 +144,12 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, ...@@ -155,12 +144,12 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data,
struct ath_radar_data ard; struct ath_radar_data ard;
u16 datalen; u16 datalen;
char *vdata_end; char *vdata_end;
struct dfs_radar_pulse drp; struct pulse_event pe;
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
if ((!(rs->rs_phyerr != ATH9K_PHYERR_RADAR)) && if ((rs->rs_phyerr != ATH9K_PHYERR_RADAR) &&
(!(rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT))) { (rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT)) {
ath_dbg(common, DFS, ath_dbg(common, DFS,
"Error: rs_phyer=0x%x not a radar error\n", "Error: rs_phyer=0x%x not a radar error\n",
rs->rs_phyerr); rs->rs_phyerr);
...@@ -189,27 +178,20 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, ...@@ -189,27 +178,20 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data,
ard.pulse_bw_info = vdata_end[-1]; ard.pulse_bw_info = vdata_end[-1];
ard.pulse_length_ext = vdata_end[-2]; ard.pulse_length_ext = vdata_end[-2];
ard.pulse_length_pri = vdata_end[-3]; ard.pulse_length_pri = vdata_end[-3];
pe.freq = ah->curchan->channel;
ath_dbg(common, DFS, pe.ts = mactime;
"bw_info=%d, length_pri=%d, length_ext=%d, " if (ath9k_postprocess_radar_event(sc, &ard, &pe)) {
"rssi_pri=%d, rssi_ext=%d\n", struct dfs_pattern_detector *pd = sc->dfs_detector;
ard.pulse_bw_info, ard.pulse_length_pri, ard.pulse_length_ext,
ard.rssi, ard.ext_rssi);
drp.freq = ah->curchan->channel;
drp.ts = mactime;
if (ath9k_postprocess_radar_event(sc, &ard, &drp)) {
static u64 last_ts; static u64 last_ts;
ath_dbg(common, DFS, ath_dbg(common, DFS,
"ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, "
"width=%d, rssi=%d, delta_ts=%llu\n", "width=%d, rssi=%d, delta_ts=%llu\n",
drp.freq, drp.ts, drp.width, drp.rssi, drp.ts-last_ts); pe.freq, pe.ts, pe.width, pe.rssi, pe.ts-last_ts);
last_ts = drp.ts; last_ts = pe.ts;
/* if (pd != NULL && pd->add_pulse(pd, &pe)) {
* TODO: forward pulse to pattern detector /*
* * TODO: forward radar event to DFS management layer
* ieee80211_add_radar_pulse(drp.freq, drp.ts, */
* drp.width, drp.rssi); }
*/
} }
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#ifndef ATH9K_DFS_H #ifndef ATH9K_DFS_H
#define ATH9K_DFS_H #define ATH9K_DFS_H
#include "dfs_pattern_detector.h"
#if defined(CONFIG_ATH9K_DFS_CERTIFIED) #if defined(CONFIG_ATH9K_DFS_CERTIFIED)
/** /**
...@@ -31,13 +32,14 @@ ...@@ -31,13 +32,14 @@
* *
* The radar information provided as raw payload data is validated and * The radar information provided as raw payload data is validated and
* filtered for false pulses. Events passing all tests are forwarded to * filtered for false pulses. Events passing all tests are forwarded to
* the upper layer for pattern detection. * the DFS detector for pattern detection.
*/ */
void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data,
struct ath_rx_status *rs, u64 mactime); struct ath_rx_status *rs, u64 mactime);
#else #else
static inline void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, static inline void
struct ath_rx_status *rs, u64 mactime) { } ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data,
struct ath_rx_status *rs, u64 mactime) { }
#endif #endif
#endif /* ATH9K_DFS_H */ #endif /* ATH9K_DFS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment