Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2011 14:02:57 +0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        freebsd-wireless@freebsd.org
Subject:   ath_rate_sample: only sample/try HT rates for HT nodes
Message-ID:  <BANLkTi=53kfqj3HLWa%2BKWEHn3rWCm7ML6Q@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi,

The initial sample rate 11n code that I merged in from Rui didn't
properly disable the non-HT rates when sampling and choosing a rate
for a HT node.

This meant that time was spent trying to sample non-11n rates.

This patch disables this behaviour whilst leaving the non-11n rates in
the 11na/11ng TX schedules. Since the management rate in an 11na
network is a legacy rate (6mbit, not MCS0) then there will be
instances of legacy TXing occuring. If the legacy rates are simply
removed from the TX schedule, the sample rate module logs a complaint.
I'd rather this not happen.

This seems to work in legacy and non-legacy modes but I admit I
haven't given it much testing yet in 11bg and 11a modes. I'd
appreciate some testing and feedback.

Thanks!


Adrian

[-- Attachment #2 --]
Index: sample.c
===================================================================
--- sample.c	(revision 221947)
+++ sample.c	(working copy)
@@ -161,9 +161,10 @@
  * or -1 if all the average_tx_times are 0.
  */
 static __inline int
-pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt,
+pick_best_rate(struct ath_node *an, const HAL_RATE_TABLE *rt,
     int size_bin, int require_acked_before)
 {
+	struct sample_node *sn = ATH_NODE_SAMPLE(an);
         int best_rate_rix, best_rate_tt;
 	uint32_t mask;
 	int rix, tt;
@@ -174,6 +175,12 @@
 		if ((mask & 1) == 0)		/* not a supported rate */
 			continue;
 
+		/* Don't pick a non-HT rate for a HT node */
+		if ((an->an_node.ni_flags & IEEE80211_NODE_HT) &&
+		    (rt->info[rix].phy != IEEE80211_T_HT)) {
+			continue;
+		}
+
 		tt = sn->stats[size_bin][rix].average_tx_time;
 		if (tt <= 0 ||
 		    (require_acked_before &&
@@ -196,11 +203,12 @@
  * Pick a good "random" bit-rate to sample other than the current one.
  */
 static __inline int
-pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn,
+pick_sample_rate(struct sample_softc *ssc , struct ath_node *an,
     const HAL_RATE_TABLE *rt, int size_bin)
 {
 #define	DOT11RATE(ix)	(rt->info[ix].dot11Rate & IEEE80211_RATE_VAL)
 #define	MCS(ix)		(rt->info[ix].dot11Rate | IEEE80211_RATE_MCS)
+	struct sample_node *sn = ATH_NODE_SAMPLE(an);
 	int current_rix, rix;
 	unsigned current_tt;
 	uint32_t mask;
@@ -208,6 +216,7 @@
 	current_rix = sn->current_rix[size_bin];
 	if (current_rix < 0) {
 		/* no successes yet, send at the lowest bit-rate */
+		/* XXX should return MCS0 if HT */
 		return 0;
 	}
 
@@ -223,6 +232,13 @@
 			continue;
 		}
 
+		/* if the node is HT and the rate isn't HT, don't bother sample */
+		if ((an->an_node.ni_flags & IEEE80211_NODE_HT) &&
+		    (rt->info[rix].phy != IEEE80211_T_HT)) {
+			mask &= ~(1<<rix);
+			goto nextrate;
+		}
+
 		/* this bit-rate is always worse than the current one */
 		if (sn->stats[size_bin][rix].perfect_tx_time > current_tt) {
 			mask &= ~(1<<rix);
@@ -236,11 +252,12 @@
 			goto nextrate;
 		}
 
-		/* 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;
-		}
+		/* don't sample more than 2 rates higher for rates > 11M for non-HT rates */
+		if (! (an->an_node.ni_flags & IEEE80211_NODE_HT))
+			if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) {
+				mask &= ~(1<<rix);
+				goto nextrate;
+			}
 
 		sn->last_sample_rix[size_bin] = rix;
 		return rix;
@@ -327,7 +344,7 @@
 	/* XXX TODO: this doesn't know about 11gn vs 11g protection; teach it */
 	mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT);
 
-	best_rix = pick_best_rate(sn, rt, size_bin, !mrr);
+	best_rix = pick_best_rate(an, rt, size_bin, !mrr);
 	if (best_rix >= 0) {
 		average_tx_time = sn->stats[size_bin][best_rix].average_tx_time;
 	} else {
@@ -338,7 +355,7 @@
 	 * rates to sample_rate% of the total transmission time.
 	 */
 	if (sn->sample_tt[size_bin] < average_tx_time * (sn->packets_since_sample[size_bin]*ssc->sample_rate/100)) {
-		rix = pick_sample_rate(ssc, sn, rt, size_bin);
+		rix = pick_sample_rate(ssc, an, rt, size_bin);
 		IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL,
 		     &an->an_node, "size %u sample rate %d current rate %d",
 		     bin_to_size(size_bin), RATE(rix),

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTi=53kfqj3HLWa%2BKWEHn3rWCm7ML6Q>