PERFORCE change 153311 for review

Sam Leffler sam at FreeBSD.org
Fri Nov 21 14:58:45 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=153311

Change 153311 by sam at sam_ebb on 2008/11/21 22:58:40

	Unbreak sample rate selection:
	o use the old algorithm of cycling through all possible rates
	  instead of just checking from the last sample rate to the end
	  of the rate table; this broke upshifting once the highest possible
	  rate was tried as we walked off the end of the table and so
	  never tried sampling again (which meant there were not enough
	  samples to cause the sampled rate to be selected as best)
	o remove the hack to never sample past 12M when operating at 11M;
	  aside from being a very dubious heuristic it means it's impossible
	  to upshift once you land on 11M (not sure what John's intent was
	  here but I can think of no reason to ever do this so it goes)

Affected files ...

.. //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#22 edit

Differences ...

==== //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#22 (text+ko) ====

@@ -187,7 +187,7 @@
 static __inline int
 pick_sample_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, int size_bin)
 {
-#define	RATE(ix)	(rt->info[ix].dot11Rate & IEEE80211_RATE_VAL)
+#define	DOT11RATE(ix)	(rt->info[ix].dot11Rate & IEEE80211_RATE_VAL)
 	int current_rix, rix;
 	unsigned current_tt;
 	uint32_t mask;
@@ -197,39 +197,43 @@
 		/* no successes yet, send at the lowest bit-rate */
 		return 0;
 	}
-	
+
 	current_tt = sn->stats[size_bin][current_rix].average_tx_time;
-	
+
 	rix = sn->last_sample_rix[size_bin]+1;	/* next sample rate */
-	mask = sn->ratemask >> rix;		/* clear all rates below */
-	for (; mask != 0; mask >>= 1, rix++) {
-		if ((mask & 1) == 0)		/* not a supported rate */
+	mask = sn->ratemask &~ (1<<current_rix);/* don't sample current rate */
+	while (mask != 0) {
+		if ((mask & (1<<rix)) == 0) {	/* not a supported rate */
+	nextrate:
+			if (++rix >= rt->rateCount)
+				rix = 0;
 			continue;
+		}
 
 		/* this bit-rate is always worse than the current one */
-		if (sn->stats[size_bin][rix].perfect_tx_time > current_tt) 
-			continue;
+		if (sn->stats[size_bin][rix].perfect_tx_time > current_tt) {
+			mask &= ~(1<<rix);
+			goto nextrate;
+		}
 
 		/* rarely sample bit-rates that fail a lot */
-		if (ticks - sn->stats[size_bin][rix].last_tx < ((hz * STALE_FAILURE_TIMEOUT_MS)/1000) &&
-		    sn->stats[size_bin][rix].successive_failures > 3)
-			continue;
+		if (sn->stats[size_bin][rix].successive_failures > 3 &&
+		    ticks - sn->stats[size_bin][rix].last_tx < ((hz * STALE_FAILURE_TIMEOUT_MS)/1000)) {
+			mask &= ~(1<<rix);
+			goto nextrate;
+		}
 
-		/* don't sample more than 2 indexes higher 
-		 * for rates higher than 11 megabits
-		 */
-		if (RATE(rix) > 2*11 && rix > current_rix + 2)
-			continue;
+		/* don't sample more than 2 rates higher for rates > 11M */
+		if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) {
+			mask &= ~(1<<rix);
+			goto nextrate;
+		}
 
-		/* if we're using 11 megabits, only sample up to 12 megabits */
-		if (RATE(current_rix) == 2*11 && rix > current_rix + 1) 
-			continue;
-
 		sn->last_sample_rix[size_bin] = rix;
 		return rix;
 	}
 	return current_rix;
-#undef RATE
+#undef DOT11RATE
 }
 
 void


More information about the p4-projects mailing list