Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Feb 2012 06:04:44 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232170 - head/sys/dev/ath/ath_rate/sample
Message-ID:  <201202260604.q1Q64i9e051065@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Feb 26 06:04:44 2012
New Revision: 232170
URL: http://svn.freebsd.org/changeset/base/232170

Log:
  Add in some debugging code to check whether the current rate table has
  been bait-and-switched from the rate control code.
  
  This will avoid the panic that I saw and will avoid sending invalid rates
  (eg 11a/11g OFDM rates when in 11b, on 11b-only NICs (AR5211)) where the
  rate table is not "big".
  
  It also will point out situations where this occurs for the 11n NICs
  which will have sufficiently large rate tables that "invalid rix" doesn't
  occur.
  
  I'll try to follow this up with a commit that adds a current operating mode
  check. The "rix" is only relevant to the current operating mode and rate
  table.
  
  PR:	kern/165475

Modified:
  head/sys/dev/ath/ath_rate/sample/sample.c
  head/sys/dev/ath/ath_rate/sample/sample.h

Modified: head/sys/dev/ath/ath_rate/sample/sample.c
==============================================================================
--- head/sys/dev/ath/ath_rate/sample/sample.c	Sun Feb 26 02:24:40 2012	(r232169)
+++ head/sys/dev/ath/ath_rate/sample/sample.c	Sun Feb 26 06:04:44 2012	(r232170)
@@ -495,6 +495,14 @@ ath_rate_findrate(struct ath_softc *sc, 
 
 	ath_rate_update_static_rix(sc, &an->an_node);
 
+	if (sn->currates != sc->sc_currates) {
+		device_printf(sc->sc_dev, "%s: currates != sc_currates!\n",
+		    __func__);
+		rix = 0;
+		*try0 = ATH_TXMAXTRY;
+		goto done;
+	}
+
 	if (sn->static_rix != -1) {
 		rix = sn->static_rix;
 		*try0 = ATH_TXMAXTRY;
@@ -621,6 +629,20 @@ ath_rate_findrate(struct ath_softc *sc, 
 	}
 	*try0 = mrr ? sn->sched[rix].t0 : ATH_TXMAXTRY;
 done:
+
+	/*
+	 * This bug totally sucks and should be fixed.
+	 *
+	 * For now though, let's not panic, so we can start to figure
+	 * out how to better reproduce it.
+	 */
+	if (rix < 0 || rix >= rt->rateCount) {
+		printf("%s: ERROR: rix %d out of bounds (rateCount=%d)\n",
+		    __func__,
+		    rix,
+		    rt->rateCount);
+		    rix = 0;	/* XXX just default for now */
+	}
 	KASSERT(rix >= 0 && rix < rt->rateCount, ("rix is %d", rix));
 
 	*rix0 = rix;
@@ -1073,6 +1095,8 @@ ath_rate_ctl_reset(struct ath_softc *sc,
         sn->static_rix = -1;
 	ath_rate_update_static_rix(sc, ni);
 
+	sn->currates = sc->sc_currates;
+
 	/*
 	 * Construct a bitmask of usable rates.  This has all
 	 * negotiated rates minus those marked by the hal as

Modified: head/sys/dev/ath/ath_rate/sample/sample.h
==============================================================================
--- head/sys/dev/ath/ath_rate/sample/sample.h	Sun Feb 26 02:24:40 2012	(r232169)
+++ head/sys/dev/ath/ath_rate/sample/sample.h	Sun Feb 26 06:04:44 2012	(r232170)
@@ -86,6 +86,8 @@ struct sample_node {
 	uint32_t ratemask;		/* bit mask of valid rate indices */
 	const struct txschedule *sched;	/* tx schedule table */
 
+	const HAL_RATE_TABLE *currates;
+
 	struct rate_stats stats[NUM_PACKET_SIZE_BINS][SAMPLE_MAXRATES];
 	int last_sample_rix[NUM_PACKET_SIZE_BINS];
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202260604.q1Q64i9e051065>