/* * DFS: check PHY-error for radar pulse and feed the detector */ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, struct ath_rx_status *rs, u64 mactime) { struct ath_radar_data ard; u16 datalen; char *vdata_end; struct pulse_event pe; struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); DFS_STAT_INC(sc, pulses_total); if ((rs->rs_phyerr != ATH9K_PHYERR_RADAR) && (rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT)) { ath_dbg(common, DFS, "Error: rs_phyer=0x%x not a radar error\n", rs->rs_phyerr); DFS_STAT_INC(sc, pulses_no_dfs); return; } datalen = rs->rs_datalen; if (datalen == 0) { DFS_STAT_INC(sc, datalen_discards); return; } ard.rssi = rs->rs_rssi_ctl[0]; ard.ext_rssi = rs->rs_rssi_ext[0]; /* * hardware stores this as 8 bit signed value. * we will cap it at 0 if it is a negative number */ if (ard.rssi & 0x80) ard.rssi = 0; if (ard.ext_rssi & 0x80) ard.ext_rssi = 0; vdata_end = (char *)data + datalen; ard.pulse_bw_info = vdata_end[-1]; ard.pulse_length_ext = vdata_end[-2]; ard.pulse_length_pri = vdata_end[-3]; pe.freq = ah->curchan->channel; pe.ts = mactime; if (ath9k_postprocess_radar_event(sc, &ard, &pe)) { struct dfs_pattern_detector *pd = sc->dfs_detector; static u64 last_ts; ath_dbg(common, DFS, "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " "width=%d, rssi=%d, delta_ts=%llu\n", pe.freq, pe.ts, pe.width, pe.rssi, pe.ts-last_ts); last_ts = pe.ts; DFS_STAT_INC(sc, pulses_processed); if (pd != NULL && pd->add_pulse(pd, &pe)) { DFS_STAT_INC(sc, radar_detected); ieee80211_radar_detected(sc->hw); } } }
/* * DFS: check PHY-error for radar pulse and feed the detector */ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, struct ath_rx_status *rs, u64 mactime) { struct ath_radar_data ard; u16 datalen; char *vdata_end; struct dfs_radar_pulse drp; struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); if ((!(rs->rs_phyerr != ATH9K_PHYERR_RADAR)) && (!(rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT))) { ath_dbg(common, ATH_DBG_DFS, "Error: rs_phyer=0x%x not a radar error\n", rs->rs_phyerr); return; } datalen = rs->rs_datalen; if (datalen == 0) { DFS_STAT_INC(sc, datalen_discards); return; } ard.rssi = rs->rs_rssi_ctl0; ard.ext_rssi = rs->rs_rssi_ext0; /* * hardware stores this as 8 bit signed value. * we will cap it at 0 if it is a negative number */ if (ard.rssi & 0x80) ard.rssi = 0; if (ard.ext_rssi & 0x80) ard.ext_rssi = 0; vdata_end = (char *)data + datalen; ard.pulse_bw_info = vdata_end[-1]; ard.pulse_length_ext = vdata_end[-2]; ard.pulse_length_pri = vdata_end[-3]; ath_dbg(common, ATH_DBG_DFS, "bw_info=%d, length_pri=%d, length_ext=%d, " "rssi_pri=%d, rssi_ext=%d\n", 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; ath_dbg(common, ATH_DBG_DFS, "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " "width=%d, rssi=%d, delta_ts=%llu\n", drp.freq, drp.ts, drp.width, drp.rssi, drp.ts-last_ts); last_ts = drp.ts; /* * TODO: forward pulse to pattern detector * * ieee80211_add_radar_pulse(drp.freq, drp.ts, * drp.width, drp.rssi); */ } }