Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Oct 2008 23:49:27 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 152134 for review
Message-ID:  <200810282349.m9SNnR4V099475@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=152134

Change 152134 by sam@sam_ebb on 2008/10/28 23:49:03

	be more intelligent selecting tx schedules

Affected files ...

.. //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#18 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.h#9 edit

Differences ...

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

@@ -254,7 +254,6 @@
 	}
 
 	mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT);
-	*try0 = mrr ? 2 : ATH_TXMAXTRY;
 
 	best_rix = pick_best_rate(sn, rt, size_bin, !mrr);
 	if (best_rix >= 0) {
@@ -333,6 +332,7 @@
 		rix = sn->current_rix[size_bin];
 		sn->packets_since_switch[size_bin]++;
 	}
+	*try0 = mrr ? sn->sched[rix].t0 : ATH_TXMAXTRY;
 done:
 	KASSERT(rix >= 0 && rix < rt->rateCount, ("rix is %d", rix));
 
@@ -343,28 +343,64 @@
 #undef RATE
 }
 
+#define A(_r) \
+    (((_r) == 6)   ? 0 : (((_r) == 9)   ? 1 : (((_r) == 12)  ? 2 : \
+    (((_r) == 18)  ? 3 : (((_r) == 24)  ? 4 : (((_r) == 36)  ? 5 : \
+    (((_r) == 48)  ? 6 : (((_r) == 54)  ? 7 : 0))))))))
+static const struct txschedule series_11a[] = {
+	{ 3,A( 6), 3,A(  6), 0,A(  6), 0,A( 6) },	/*   6Mb/s */
+	{ 4,A( 9), 3,A(  6), 4,A(  6), 0,A( 6) },	/*   9Mb/s */
+	{ 4,A(12), 3,A(  6), 4,A(  6), 0,A( 6) },	/*  12Mb/s */
+	{ 4,A(18), 3,A( 12), 4,A(  6), 2,A( 6) },	/*  18Mb/s */
+	{ 4,A(24), 3,A( 18), 4,A( 12), 2,A( 6) },	/*  24Mb/s */
+	{ 4,A(36), 3,A( 24), 4,A( 18), 2,A( 6) },	/*  36Mb/s */
+	{ 4,A(48), 3,A( 36), 4,A( 24), 2,A(12) },	/*  48Mb/s */
+	{ 4,A(54), 3,A( 48), 4,A( 36), 2,A(24) }	/*  54Mb/s */
+};
+
+#define G(_r) \
+    (((_r) == 1)   ? 0 : (((_r) == 2)   ? 1 : (((_r) == 5.5) ? 2 : \
+    (((_r) == 11)  ? 3 : (((_r) == 6)   ? 4 : (((_r) == 9)   ? 5 : \
+    (((_r) == 12)  ? 6 : (((_r) == 18)  ? 7 : (((_r) == 24)  ? 8 : \
+    (((_r) == 36)  ? 9 : (((_r) == 48)  ? 10 : (((_r) == 54)  ? 11 : 0))))))))))))
+static const struct txschedule series_11g[] = {
+	{ 3,G( 1), 3,G(  1), 0,G(  1), 0,G( 1) },	/*   1Mb/s */
+	{ 4,G( 2), 3,G(  1), 4,G(  1), 0,G( 1) },	/*   2Mb/s */
+	{ 4,G(5.5),3,G(  2), 4,G(  1), 2,G( 1) },	/* 5.5Mb/s */
+	{ 4,G(11), 3,G(5.5), 4,G(  2), 2,G( 1) },	/*  11Mb/s */
+	{ 4,G( 6), 3,G(5.5), 4,G(  2), 2,G( 1) },	/*   6Mb/s */
+	{ 4,G( 9), 3,G(  6), 4,G(5.5), 2,G( 1) },	/*   9Mb/s */
+	{ 4,G(12), 3,G( 11), 4,G(5.5), 2,G( 1) },	/*  12Mb/s */
+	{ 4,G(18), 3,G( 12), 4,G( 11), 2,G( 1) },	/*  18Mb/s */
+	{ 4,G(24), 3,G( 18), 4,G( 12), 2,G( 1) },	/*  24Mb/s */
+	{ 4,G(36), 3,G( 24), 4,G( 18), 2,G( 1) },	/*  36Mb/s */
+	{ 4,G(48), 3,G( 36), 4,G( 24), 2,G( 1) },	/*  48Mb/s */
+	{ 4,G(54), 3,G( 48), 4,G( 36), 2,G( 1) }	/*  54Mb/s */
+};
+
 void
 ath_rate_setupxtxdesc(struct ath_softc *sc, struct ath_node *an,
 		      struct ath_desc *ds, int shortPreamble, u_int8_t rix)
 {
 	struct sample_node *sn = ATH_NODE_SAMPLE(an);
+	const struct txschedule *sched = &sn->sched[rix];
 	const HAL_RATE_TABLE *rt = sc->sc_currates;
-	const int size_bin = 0;		/*XXX*/
-	uint8_t rix1, s1code, rix2, s2code;
+	uint8_t rix1, s1code, rix2, s2code, rix3, s3code;
 
-	rix1 = sn->current_rix[size_bin]; /* retry at the current bit-rate */
-	if (!sn->stats[size_bin][rix1].packets_acked)
-		rix1 = rt->info[rix].controlRate;  /* next lowest basic rate */
+	/* XXX precalculate short preamble tables */
+	rix1 = sched->r1;
 	s1code = rt->info[rix1].rateCode
 	       | (shortPreamble ? rt->info[rix1].shortPreamble : 0);
-	rix2 = rt->info[rix1].controlRate;
+	rix2 = sched->r2;
 	s2code = rt->info[rix2].rateCode
 	       | (shortPreamble ? rt->info[rix2].shortPreamble : 0);
-	ath_hal_setupxtxdesc(sc->sc_ah, ds
-			     , s1code, 3	        /* series 1 */
-			     , s2code, 3		/* series 2 */
-			     , 0, 0	                /* series 3 */
-			     );
+	rix3 = sched->r3;
+	s3code = rt->info[rix3].rateCode
+	       | (shortPreamble ? rt->info[rix3].shortPreamble : 0);
+	ath_hal_setupxtxdesc(sc->sc_ah, ds,
+	    s1code, sched->t1,		/* series 1 */
+	    s2code, sched->t2,		/* series 2 */
+	    s3code, sched->t3);		/* series 3 */
 }
 
 static void
@@ -637,6 +673,19 @@
 		ath_rate_ctl_reset(sc, &an->an_node);
 }
 
+static const struct txschedule *mrr_schedules[IEEE80211_MODE_MAX] = {
+	NULL,		/* IEEE80211_MODE_AUTO */
+	series_11a,	/* IEEE80211_MODE_11A */
+	series_11g,	/* IEEE80211_MODE_11B */
+	series_11g,	/* IEEE80211_MODE_11G */
+	NULL,		/* IEEE80211_MODE_FH */
+	series_11a,	/* IEEE80211_MODE_TURBO_A */
+	series_11g,	/* IEEE80211_MODE_TURBO_G */
+	series_11a,	/* IEEE80211_MODE_STURBO_A */
+	series_11a,	/* IEEE80211_MODE_11NA */
+	series_11g,	/* IEEE80211_MODE_11NG */
+};
+
 /*
  * Initialize the tables for a node.
  */
@@ -653,6 +702,13 @@
 	uint32_t mask;
 
 	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
+
+	KASSERT(sc->sc_curmode < IEEE80211_MODE_MAX,
+	    ("curmode %u", sc->sc_curmode));
+	sn->sched = mrr_schedules[sc->sc_curmode];
+	KASSERT(sn->sched != NULL,
+	    ("no mrr schedule for mode %u", sc->sc_curmode));
+
         sn->static_rix = -1;
 	if (tp != NULL && tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
 		/*

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

@@ -60,6 +60,13 @@
 	int last_tx;
 };
 
+struct txschedule {
+	uint8_t	t0, r0;		/* series 0: tries, rate code */
+	uint8_t	t1, r1;		/* series 1: tries, rate code */
+	uint8_t	t2, r2;		/* series 2: tries, rate code */
+	uint8_t	t3, r3;		/* series 3: tries, rate code */
+};
+
 /*
  * for now, we track performance for three different packet
  * size buckets
@@ -71,6 +78,7 @@
 	int static_rix;			/* rate index of fixed tx rate */
 #define	SAMPLE_MAXRATES	32		/* NB: corresponds to hal info[32] */
 	uint32_t ratemask;		/* bit mask of valid rate indices */
+	const struct txschedule *sched;	/* tx schedule table */
 
 	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?200810282349.m9SNnR4V099475>