From owner-freebsd-wireless@FreeBSD.ORG Tue Mar 4 08:09:32 2014 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8F754E56 for ; Tue, 4 Mar 2014 08:09:32 +0000 (UTC) Received: from mail-qc0-x232.google.com (mail-qc0-x232.google.com [IPv6:2607:f8b0:400d:c01::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4F473F48 for ; Tue, 4 Mar 2014 08:09:32 +0000 (UTC) Received: by mail-qc0-f178.google.com with SMTP id i8so5110508qcq.9 for ; Tue, 04 Mar 2014 00:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=bg8SLwcKG5C+6Ay88gF9ROC+8ahylC9RIC7ED7ahUZY=; b=N/TrcBAOTC8GDsuBlfnCzhlnLyvy7cb2+I0qX/0k9z4df0Hp5NueJy78o/EArgRi4y rr/0EPzY1vxtcNm257rykToRSB3Fh3uc5tqOvzvYGFrYl8Fwe8TCYZBbw8ql1YXzvAvV 5Len3wKeeGA61jPnTrrUuGj/7+iEKaGHSsybDZ5cKSaXOj3fdNF3n0Dij3EK9WN+9u+O q7SbK8fZPy2cq0HHMzBHj/nG4eo8bOUJFoEHcDdVQ7AI4dJLW1q4252HZRIkCdyz1yhR H01owCvpuq1/VR2nlQHiUZ9sY0+J2A/DpvzbG3LltenxDnDBaC6mU1t9mn32ookfMDIz mOlA== MIME-Version: 1.0 X-Received: by 10.224.136.195 with SMTP id s3mr8140547qat.95.1393920571492; Tue, 04 Mar 2014 00:09:31 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.16.10 with HTTP; Tue, 4 Mar 2014 00:09:31 -0800 (PST) In-Reply-To: <201403040801.s2481uAc088743@svn.freebsd.org> References: <201403040801.s2481uAc088743@svn.freebsd.org> Date: Tue, 4 Mar 2014 00:09:31 -0800 X-Google-Sender-Auth: W67A3AqXoPQeyj9jnbuEVsztzIg Message-ID: Subject: Fwd: svn commit: r262729 - head/sys/dev/iwn From: Adrian Chadd To: "freebsd-wireless@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2014 08:09:32 -0000 If you have a Centrino 100, 2200, 2230, then please update to the latest -HEAD. This may fix some calibration issues. -a ---------- Forwarded message ---------- From: Adrian Chadd Date: 4 March 2014 00:01 Subject: svn commit: r262729 - head/sys/dev/iwn To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Author: adrian Date: Tue Mar 4 08:01:56 2014 New Revision: 262729 URL: http://svnweb.freebsd.org/changeset/base/262729 Log: Handle the newer-style bluetooth message format from the (at least) Centrino 2230 firmware. This fixes the general statistics block to be actually valid. I've verified this by contrasting the output of iwnstats before and after the change. The general block is now correct. Tested: * Intel 5100 (old format stats message) * Intel 2230 (new format stats message) Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Tue Mar 4 06:55:54 2014 (r262728) +++ head/sys/dev/iwn/if_iwn.c Tue Mar 4 08:01:56 2014 (r262729) @@ -685,6 +685,13 @@ iwn_attach(device_t dev) goto fail; } +#if 0 + device_printf(sc->sc_dev, "%s: rx_stats=%d, rx_stats_bt=%d\n", + __func__, + sizeof(struct iwn_stats), + sizeof(struct iwn_stats_bt)); +#endif + if (bootverbose) ieee80211_announce(ic); DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); @@ -3143,11 +3150,62 @@ iwn5000_rx_calib_results(struct iwn_soft static void iwn_stats_update(struct iwn_softc *sc, struct iwn_calib_state *calib, - struct iwn_stats *stats) + struct iwn_stats *stats, int len) { + struct iwn_stats_bt *stats_bt; + struct iwn_stats *lstats; + + /* + * First - check whether the length is the bluetooth or normal. + * + * If it's normal - just copy it and bump out. + * Otherwise we have to convert things. + */ + + if (len == sizeof(struct iwn_stats) + 4) { + memcpy(&sc->last_stat, stats, sizeof(struct iwn_stats)); + sc->last_stat_valid = 1; + return; + } - /* XXX lock assert */ - memcpy(&sc->last_stat, stats, sizeof(struct iwn_stats)); + /* + * If it's not the bluetooth size - log, then just copy. + */ + if (len != sizeof(struct iwn_stats_bt) + 4) { + DPRINTF(sc, IWN_DEBUG_STATS, + "%s: size of rx statistics (%d) not an expected size!\n", + __func__, + len); + memcpy(&sc->last_stat, stats, sizeof(struct iwn_stats)); + sc->last_stat_valid = 1; + return; + } + + /* + * Ok. Time to copy. + */ + stats_bt = (struct iwn_stats_bt *) stats; + lstats = &sc->last_stat; + + /* flags */ + lstats->flags = stats_bt->flags; + /* rx_bt */ + memcpy(&lstats->rx.ofdm, &stats_bt->rx_bt.ofdm, + sizeof(struct iwn_rx_phy_stats)); + memcpy(&lstats->rx.cck, &stats_bt->rx_bt.cck, + sizeof(struct iwn_rx_phy_stats)); + memcpy(&lstats->rx.general, &stats_bt->rx_bt.general_bt.common, + sizeof(struct iwn_rx_general_stats)); + memcpy(&lstats->rx.ht, &stats_bt->rx_bt.ht, + sizeof(struct iwn_rx_ht_phy_stats)); + /* tx */ + memcpy(&lstats->tx, &stats_bt->tx, + sizeof(struct iwn_tx_stats)); + /* general */ + memcpy(&lstats->general, &stats_bt->general, + sizeof(struct iwn_general_stats)); + + /* XXX TODO: Squirrel away the extra bluetooth stats somewhere */ sc->last_stat_valid = 1; } @@ -3165,6 +3223,7 @@ iwn_rx_statistics(struct iwn_softc *sc, 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__); @@ -3179,15 +3238,26 @@ iwn_rx_statistics(struct iwn_softc *sc, bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD); - DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: received statistics, cmd %d\n", - __func__, desc->type); + 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; /* Reset TX power calibration timeout. */ - /* Collect/track general statistics for reporting */ - iwn_stats_update(sc, calib, stats); + /* + * 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. + */ + iwn_stats_update(sc, calib, stats, le16toh(desc->len)); + + /* + * And now, let's take a reference of it to use! + */ + lstats = &sc->last_stat; /* Test if temperature has changed. */ - if (stats->general.temp != sc->rawtemp) { + if (lstats->general.temp != sc->rawtemp) { /* Convert "raw" temperature to degC. */ sc->rawtemp = stats->general.temp; temp = ops->get_temperature(sc); @@ -3202,25 +3272,25 @@ iwn_rx_statistics(struct iwn_softc *sc, if (desc->type != IWN_BEACON_STATISTICS) return; /* Reply to a statistics request. */ - sc->noise = iwn_get_noise(&stats->rx.general); + sc->noise = iwn_get_noise(&lstats->rx.general); DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: noise %d\n", __func__, sc->noise); /* Test that RSSI and noise are present in stats report. */ - if (le32toh(stats->rx.general.flags) != 1) { + 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, &stats->rx.general); + iwn_collect_noise(sc, &lstats->rx.general); else if (calib->state == IWN_CALIB_STATE_RUN) { - iwn_tune_sensitivity(sc, &stats->rx); + iwn_tune_sensitivity(sc, &lstats->rx); /* * XXX TODO: Only run the RX recovery if we're associated! */ - iwn_check_rx_recovery(sc, stats); - iwn_save_stats_counters(sc, stats); + iwn_check_rx_recovery(sc, lstats); + iwn_save_stats_counters(sc, lstats); } DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__);