aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2016-09-18 05:07:18 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2016-09-18 05:07:18 +0000
commit4083793433f434e68ab3393ddee1d0bf785d9be6 (patch)
tree1d8452997d82a2bdfca222f42b04c8938f6fdf3e
parent9cd2207265c15ad1e39f6be9fbdb85041f4df577 (diff)
Notes
-rw-r--r--sys/dev/iwm/if_iwm.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index 2316cdfcf486b..7024a22b630ef 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -312,7 +312,8 @@ static int iwm_mvm_get_signal_strength(struct iwm_softc *,
static void iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *,
struct iwm_rx_packet *,
struct iwm_rx_data *);
-static int iwm_get_noise(const struct iwm_mvm_statistics_rx_non_phy *);
+static int iwm_get_noise(struct iwm_softc *sc,
+ const struct iwm_mvm_statistics_rx_non_phy *);
static void iwm_mvm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_rx_data *);
static int iwm_mvm_rx_tx_cmd_single(struct iwm_softc *,
@@ -2871,21 +2872,34 @@ iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *sc,
* Retrieve the average noise (in dBm) among receivers.
*/
static int
-iwm_get_noise(const struct iwm_mvm_statistics_rx_non_phy *stats)
+iwm_get_noise(struct iwm_softc *sc,
+ const struct iwm_mvm_statistics_rx_non_phy *stats)
{
int i, total, nbant, noise;
total = nbant = noise = 0;
for (i = 0; i < 3; i++) {
noise = le32toh(stats->beacon_silence_rssi[i]) & 0xff;
+ IWM_DPRINTF(sc, IWM_DEBUG_RECV, "%s: i=%d, noise=%d\n",
+ __func__,
+ i,
+ noise);
+
if (noise) {
total += noise;
nbant++;
}
}
+ IWM_DPRINTF(sc, IWM_DEBUG_RECV, "%s: nbant=%d, total=%d\n",
+ __func__, nbant, total);
+#if 0
/* There should be at least one antenna but check anyway. */
return (nbant == 0) ? -127 : (total / nbant) - 107;
+#else
+ /* For now, just hard-code it to -96 to be safe */
+ return (-96);
+#endif
}
/*
@@ -2940,8 +2954,15 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc,
} else {
rssi = iwm_mvm_calc_rssi(sc, phy_info);
}
- rssi = (0 - IWM_MIN_DBM) + rssi; /* normalize */
- rssi = MIN(rssi, sc->sc_max_rssi); /* clip to max. 100% */
+
+ /* Note: RSSI is absolute (ie a -ve value) */
+ if (rssi < IWM_MIN_DBM)
+ rssi = IWM_MIN_DBM;
+ else if (rssi > IWM_MAX_DBM)
+ rssi = IWM_MAX_DBM;
+
+ /* Map it to relative value */
+ rssi = rssi - sc->sc_noise;
/* replenish ring for the buffer we're going to feed to the sharks */
if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0) {
@@ -2950,6 +2971,9 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc,
return;
}
+ IWM_DPRINTF(sc, IWM_DEBUG_RECV,
+ "%s: rssi=%d, noise=%d\n", __func__, rssi, sc->sc_noise);
+
ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
IWM_DPRINTF(sc, IWM_DEBUG_RECV,
@@ -2970,7 +2994,9 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc,
} else {
rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, IEEE80211_CHAN_5GHZ);
}
- rxs.rssi = rssi - sc->sc_noise;
+
+ /* rssi is in 1/2db units */
+ rxs.rssi = rssi * 2;
rxs.nf = sc->sc_noise;
if (ieee80211_radiotap_active_vap(vap)) {
@@ -5172,7 +5198,7 @@ iwm_notif_intr(struct iwm_softc *sc)
struct iwm_notif_statistics *stats;
SYNC_RESP_STRUCT(stats, pkt);
memcpy(&sc->sc_stats, stats, sizeof(sc->sc_stats));
- sc->sc_noise = iwm_get_noise(&stats->rx.general);
+ sc->sc_noise = iwm_get_noise(sc, &stats->rx.general);
break; }
case IWM_NVM_ACCESS_CMD:
@@ -5823,8 +5849,12 @@ iwm_attach(device_t dev)
sc->sc_phyctxt[i].channel = NULL;
}
+ /* Default noise floor */
+ sc->sc_noise = -96;
+
/* Max RSSI */
sc->sc_max_rssi = IWM_MAX_DBM - IWM_MIN_DBM;
+
sc->sc_preinit_hook.ich_func = iwm_preinit;
sc->sc_preinit_hook.ich_arg = sc;
if (config_intrhook_establish(&sc->sc_preinit_hook) != 0) {