FreeBSD/sys/dev/iwn/if_iwn.c
/*
 * Process an RX_STATISTICS or BEACON_STATISTICS firmware notification.
 * The latter is sent by the firmware after each received beacon.
 */
Process an RX_STATISTICS or BEACON_STATISTICS firmware notification.
The latter is sent by the firmware after each received beacon.
Process an RX_STATISTICS or BEACON_STATISTICS firmware notification . The latter is sent by the firmware after each received beacon .
static void
iwn_rx_statistics(struct iwn_softc *sc, struct iwn_rx_desc *desc,
    struct iwn_rx_data *data)
{
	struct iwn_ops *ops = &sc->ops;
	struct ieee80211com *ic = &sc->sc_ic;
	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
	struct iwn_calib_state *calib = &sc->calib;
	struct iwn_stats *stats = (struct iwn_stats *)(desc + 1);
	struct iwn_stats *lstats;
	int temp;
	DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__);
	if (vap->iv_state != IEEE80211_S_RUN ||
	    (ic->ic_flags & IEEE80211_F_SCAN)){
		DPRINTF(sc, IWN_DEBUG_TRACE, "->%s received during calib\n",
	    __func__);
		return;
	}
	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
	DPRINTF(sc, IWN_DEBUG_CALIBRATE | IWN_DEBUG_STATS,
	    "%s: received statistics, cmd %d, len %d\n",
	    __func__, desc->type, le16toh(desc->len));
	sc->calib_cnt = 0;	
	iwn_stats_update(sc, calib, stats, le16toh(desc->len));
	lstats = &sc->last_stat;
	if (lstats->general.temp != sc->rawtemp) {
		sc->rawtemp = stats->general.temp;
		temp = ops->get_temperature(sc);
		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d\n",
		    __func__, temp);
		if (sc->hw_type == IWN_HW_REV_TYPE_4965)
			iwn4965_power_calibration(sc, temp);
	}
	if (desc->type != IWN_BEACON_STATISTICS)
		return;	
	sc->noise = iwn_get_noise(&lstats->rx.general);
	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: noise %d\n", __func__, sc->noise);
	if (le32toh(lstats->rx.general.flags) != 1) {
		DPRINTF(sc, IWN_DEBUG_ANY, "%s\n",
		    "received statistics without RSSI");
		return;
	}
	if (calib->state == IWN_CALIB_STATE_ASSOC)
		iwn_collect_noise(sc, &lstats->rx.general);
	else if (calib->state == IWN_CALIB_STATE_RUN) {
		iwn_tune_sensitivity(sc, &lstats->rx);
		iwn_check_rx_recovery(sc, lstats);
		iwn_save_stats_counters(sc, lstats);
	}
	DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__);
}
static void iwn_rx_statistics ( struct iwn_softc * sc , struct iwn_rx_desc * desc , struct iwn_rx_data * data ) { struct iwn_ops * ops = & sc -> ops ; struct ieee80211com * ic = & sc -> sc_ic ; struct ieee80211vap * vap = TAILQ_FIRST ( & ic -> ic_vaps ) ; struct iwn_calib_state * calib = & sc -> calib ; struct iwn_stats * stats = ( struct iwn_stats * ) ( desc + 1 ) ; struct iwn_stats * lstats ; int temp ; DPRINTF ( sc , IWN_DEBUG_TRACE , " \n " , __func__ ) ; if ( vap -> iv_state != IEEE80211_S_RUN || ( ic -> ic_flags & IEEE80211_F_SCAN ) ) { DPRINTF ( sc , IWN_DEBUG_TRACE , " \n " , __func__ ) ; return ; } bus_dmamap_sync ( sc -> rxq . data_dmat , data -> map , BUS_DMASYNC_POSTREAD ) ; DPRINTF ( sc , IWN_DEBUG_CALIBRATE | IWN_DEBUG_STATS , " \n " , __func__ , desc -> type , le16toh ( desc -> len ) ) ; sc -> calib_cnt = 0 ; iwn_stats_update ( sc , calib , stats , le16toh ( desc -> len ) ) ; lstats = & sc -> last_stat ; if ( lstats -> general . temp != sc -> rawtemp ) { sc -> rawtemp = stats -> general . temp ; temp = ops -> get_temperature ( sc ) ; DPRINTF ( sc , IWN_DEBUG_CALIBRATE , " \n " , __func__ , temp ) ; if ( sc -> hw_type == IWN_HW_REV_TYPE_4965 ) iwn4965_power_calibration ( sc , temp ) ; } if ( desc -> type != IWN_BEACON_STATISTICS ) return ; sc -> noise = iwn_get_noise ( & lstats -> rx . general ) ; DPRINTF ( sc , IWN_DEBUG_CALIBRATE , " \n " , __func__ , sc -> noise ) ; if ( le32toh ( lstats -> rx . general . flags ) != 1 ) { DPRINTF ( sc , IWN_DEBUG_ANY , " \n " , " " ) ; return ; } if ( calib -> state == IWN_CALIB_STATE_ASSOC ) iwn_collect_noise ( sc , & lstats -> rx . general ) ; else if ( calib -> state == IWN_CALIB_STATE_RUN ) { iwn_tune_sensitivity ( sc , & lstats -> rx ) ; iwn_check_rx_recovery ( sc , lstats ) ; iwn_save_stats_counters ( sc , lstats ) ; } DPRINTF ( sc , IWN_DEBUG_TRACE , " \n " , __func__ ) ; }
Process an RX_STATISTICS or BEACON_STATISTICS firmware notification.
Process an RX_STATISTICS or BEACON_STATISTICS firmware notification .
/* Ignore statistics received during a scan. */ /* Reset TX power calibration timeout. */ /*
	 * Collect/track general statistics for reporting.
	 *
	 * This takes care of ensuring that the bluetooth sized message
	 * will be correctly converted to the legacy sized message.
	 */ /*
	 * And now, let's take a reference of it to use!
	 */ /* Test if temperature has changed. */ /* Convert "raw" temperature to degC. */ /* Update TX power if need be (4965AGN only). */ /* Reply to a statistics request. */ /* Test that RSSI and noise are present in stats report. */ /*
		 * XXX TODO: Only run the RX recovery if we're associated!
		 */