socsvn commit: r257398 - in soc2013/ccqin/head/sys: conf net80211

ccqin at FreeBSD.org ccqin at FreeBSD.org
Mon Sep 16 08:08:52 UTC 2013


Author: ccqin
Date: Mon Sep 16 08:08:52 2013
New Revision: 257398
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257398

Log:
  Update ieee80211_sample and complete ieee80211_ratectl_none templete.
  * rename ieee80211_rc_sample* to ieee80211_sample*. this seems more harmonious.
  * modify ieee80211_sample to let it use the latest net80211-ratectl features.
  * fix some errors in ieee80211_sample.
  * complete the ieee80211_ratectl_none templete with new added net80211-ratectl
    functions.
  

Added:
  soc2013/ccqin/head/sys/net80211/ieee80211_sample.c
     - copied, changed from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c
  soc2013/ccqin/head/sys/net80211/ieee80211_sample.h
     - copied, changed from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h
  soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h
     - copied unchanged from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h
Deleted:
  soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c
  soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h
  soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h
Modified:
  soc2013/ccqin/head/sys/conf/files
  soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
  soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c

Modified: soc2013/ccqin/head/sys/conf/files
==============================================================================
--- soc2013/ccqin/head/sys/conf/files	Mon Sep 16 06:25:54 2013	(r257397)
+++ soc2013/ccqin/head/sys/conf/files	Mon Sep 16 08:08:52 2013	(r257398)
@@ -3100,6 +3100,7 @@
 net80211/ieee80211_ratectl_none.c optional wlan
 net80211/ieee80211_regdomain.c	optional wlan
 net80211/ieee80211_rssadapt.c	optional wlan wlan_rssadapt
+net80211/ieee80211_sample.c	optional wlan | wlan_sample
 net80211/ieee80211_scan.c	optional wlan
 net80211/ieee80211_scan_sta.c	optional wlan
 net80211/ieee80211_sta.c	optional wlan

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Mon Sep 16 06:25:54 2013	(r257397)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Mon Sep 16 08:08:52 2013	(r257398)
@@ -57,13 +57,10 @@
 #define is_enough(amn)		\
 	((amn)->amn_txcnt > 10)
 
-static void	amrr_setinterval(const struct ieee80211vap *, int);
 static void	amrr_init(struct ieee80211vap *, uint32_t);
 static void	amrr_deinit(struct ieee80211vap *);
 static void	amrr_node_init(struct ieee80211_node *);
 static void	amrr_node_deinit(struct ieee80211_node *);
-static int	amrr_update(struct ieee80211_amrr *,
-    			struct ieee80211_amrr_node *, struct ieee80211_node *);
 static int	amrr_rate(struct ieee80211_node *, void *, uint32_t);
 static void	amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *);
 static void	amrr_tx_complete(const struct ieee80211vap *,
@@ -71,6 +68,7 @@
 static void	amrr_tx_update(const struct ieee80211vap *,
 			const struct ieee80211_node *, void *, void *, void *);
 static void	amrr_stats(const struct ieee80211vap *);
+static void	amrr_setinterval(const struct ieee80211vap *, int);
 static void	amrr_sysctlattach(struct ieee80211vap *,
 			struct sysctl_ctx_list *, struct sysctl_oid *);
 

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c	Mon Sep 16 06:25:54 2013	(r257397)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c	Mon Sep 16 08:08:52 2013	(r257398)
@@ -112,6 +112,11 @@
 }
 
 static void
+none_rates(struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info)
+{
+}
+
+static void
 none_tx_complete(const struct ieee80211vap *vap,
     const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info)
 {
@@ -128,6 +133,16 @@
 {
 }
 
+static void
+none_stats(const struct ieee80211vap *vap)
+{
+	struct ieee80211_rc_stat * irs = IEEE80211_RATECTL_STAT(vap);
+	printf("tx count: %d (ok count: %d, fail count: %d)\n"
+			"retry count: %d (short retry: %d, long retry: %d)\n",
+			irs->irs_txcnt, irs->irs_txcnt - irs->irs_failcnt, irs->irs_failcnt,
+			irs->irs_retrycnt, irs->irs_shortretry, irs->irs_longretry);
+	/* ... */
+}
 /* number of references from net80211 layer */
 static	int nrefs = 0;
 
@@ -140,9 +155,11 @@
 	.ir_node_init	= none_node_init,
 	.ir_node_deinit	= none_node_deinit,
 	.ir_rate	= none_rate,
+	.ir_rates	= none_rates,
 	.ir_tx_complete	= none_tx_complete,
 	.ir_tx_update	= none_tx_update,
 	.ir_setinterval	= none_setinterval,
+	.ir_stats	= none_stats,
 };
 IEEE80211_RATECTL_MODULE(ratectl_none, 1);
 IEEE80211_RATECTL_ALG(none, IEEE80211_RATECTL_NONE, none);

Copied and modified: soc2013/ccqin/head/sys/net80211/ieee80211_sample.c (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c)
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c	Mon Sep  2 08:00:12 2013	(r256825, copy source)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_sample.c	Mon Sep 16 08:08:52 2013	(r257398)
@@ -38,6 +38,7 @@
 
 #include <net/if.h>
 #include <net/if_media.h>
+#include <net/ethernet.h>
 
 #ifdef INET
 #include <netinet/in.h>
@@ -47,21 +48,26 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ht.h>
 #include <net80211/ieee80211_ratectl.h>
-#include <net80211/ieee80211_rc_sample.h>
-#include <net80211/ieee80211_rc_sample_txsched.h>
+#include <net80211/ieee80211_sample.h>
+#include <net80211/ieee80211_sample_txsched.h>
 
 static void	sample_init(struct ieee80211vap *, uint32_t);
 static void	sample_deinit(struct ieee80211vap *);
 static void	sample_node_init(struct ieee80211_node *);
 static void	sample_node_deinit(struct ieee80211_node *);
 static int	sample_rate(struct ieee80211_node *, void *, uint32_t);
+static void	sample_rates(struct ieee80211_node *, struct ieee80211_rc_info *);
 static void	sample_tx_complete(const struct ieee80211vap *,
-    			const struct ieee80211_node *, int, 
-			void *, void *);
+    			const struct ieee80211_node *, struct ieee80211_rc_info *);
 static void	sample_tx_update(const struct ieee80211vap *vap,
 			const struct ieee80211_node *, void *, void *, void *);
+static void	sample_stats(const struct ieee80211vap *);
 static void	sample_setinterval(const struct ieee80211vap *, int);
 
+static void	sample_sysctlattach(struct ieee80211vap *,
+			struct sysctl_ctx_list *, struct sysctl_oid *);
+static void	sample_update_static_rix(struct ieee80211_node *);
+
 /* number of references from net80211 layer */
 static	int nrefs = 0;
 
@@ -78,6 +84,7 @@
 	.ir_tx_complete	= sample_tx_complete,
 	.ir_tx_update	= sample_tx_update,
 	.ir_setinterval	= sample_setinterval,
+	.ir_stats	= sample_stats,
 };
 IEEE80211_RATECTL_MODULE(sample, 1);
 IEEE80211_RATECTL_ALG(sample, IEEE80211_RATECTL_SAMPLE, sample);
@@ -136,10 +143,12 @@
 #define	RATE(_ix)	(ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
 #define	DOT11RATE(_ix)	(rt->info[(_ix)].dot11Rate & IEEE80211_RATE_VAL)
 #define	MCS(_ix)	(ni->ni_htrates.rs_rates[_ix] | IEEE80211_RATE_MCS)
+	
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211_sample *sample = vap->iv_rs;
 	struct ieee80211_sample_node *san = NULL;
-	const struct ieee80211_rate_table *rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan);
+
+	const struct ieee80211_rate_table *rt = NULL;
 	enum ieee80211_phymode curmode = ieee80211_chan2mode(vap->iv_ic->ic_curchan);
 	int x, y, rix;
 
@@ -156,6 +165,7 @@
 	
 	san->san_sample = sample;
 
+	rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan);
 	KASSERT(rt != NULL, ("no rate table, mode %u", curmode));
 
 	san->sched = mrr_schedules[curmode];
@@ -177,9 +187,6 @@
 			rix = rt->rateCodeToIndex[MCS(x)];
 			if (rix == 0xff)
 				continue;
-			/* skip rates marked broken by hal */
-			if (!rt->info[rix].valid)
-				continue;
 			KASSERT(rix < SAMPLE_MAXRATES,
 			    ("mcs %u has rix %d", MCS(x), rix));
 			san->ratemask |= (uint64_t) 1<<rix;
@@ -191,9 +198,6 @@
 		rix = rt->rateCodeToIndex[RATE(x)];
 		if (rix == 0xff)
 			continue;
-		/* skip rates marked broken by hal */
-		if (!rt->info[rix].valid)
-			continue;
 		KASSERT(rix < SAMPLE_MAXRATES,
 		    ("rate %u has rix %d", RATE(x), rix));
 		san->ratemask |= (uint64_t) 1<<rix;
@@ -248,7 +252,7 @@
 }
 
 static int
-dot11rate(const ieee80211_rate_table *rt, int rix)
+dot11rate(const struct ieee80211_rate_table *rt, int rix)
 {
 	if (rix < 0)
 		return -1;
@@ -257,7 +261,7 @@
 }
 
 static const char *
-dot11rate_label(const ieee80211_rate_table *rt, int rix)
+dot11rate_label(const struct ieee80211_rate_table *rt, int rix)
 {
 	if (rix < 0)
 		return "";
@@ -354,8 +358,8 @@
  * Pick a good "random" bit-rate to sample other than the current one.
  */
 static __inline int
-pick_sample_rate(const struct ieee80211_node *ni, const ieee80211_rate_table *rt, 
-	int size_bin)
+pick_sample_rate(const struct ieee80211_node *ni, 
+		const struct ieee80211_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)
@@ -624,7 +628,7 @@
 		sample->sample_rate/100)) {
 		rix = pick_sample_rate(ni, rt, size_bin);
 		IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL,
-		     &ni, "att %d sample_tt %d size %u sample rate %d %s current rate %d %s",
+		     ni, "att %d sample_tt %d size %u sample rate %d %s current rate %d %s",
 		     average_tx_time,
 		     san->sample_tt[size_bin],
 		     bin_to_size(size_bin),
@@ -650,13 +654,13 @@
 		} else if (san->packets_sent[size_bin] < 20) {
 			/* let the bit-rate switch quickly during the first few packets */
 			IEEE80211_NOTE(vap,
-			    IEEE80211_MSG_RATECTL, &ni,
+			    IEEE80211_MSG_RATECTL, ni,
 			    "%s: switching quickly..", __func__);
 			change_rates = 1;
 		} else if (ticks - sample->sample_min_switch > san->ticks_since_switch[size_bin]) {
 			/* min_switch seconds have gone by */
 			IEEE80211_NOTE(vap,
-			    IEEE80211_MSG_RATECTL, &ni,
+			    IEEE80211_MSG_RATECTL, ni,
 			    "%s: min_switch %d > ticks_since_switch %d..",
 			    __func__, ticks - sample->sample_min_switch, san->ticks_since_switch[size_bin]);
 			change_rates = 1;
@@ -664,7 +668,7 @@
 		    (2*average_tx_time < san->stats[size_bin][san->current_rix[size_bin]].average_tx_time)) {
 			/* the current bit-rate is twice as slow as the best one */
 			IEEE80211_NOTE(vap,
-			    IEEE80211_MSG_RATECTL, &ni,
+			    IEEE80211_MSG_RATECTL, ni,
 			    "%s: 2x att (= %d) < cur_rix att %d",
 			    __func__,
 			    2 * average_tx_time, san->stats[size_bin][san->current_rix[size_bin]].average_tx_time);
@@ -686,7 +690,7 @@
 			if ((MCS(best_rix) > MCS(cur_rix)) &&
 			    (average_tx_time * 8) <= (cur_att * 10)) {
 				IEEE80211_NOTE(vap,
-				    IEEE80211_MSG_RATECTL, &ni,
+				    IEEE80211_MSG_RATECTL, ni,
 				    "%s: HT: best_rix 0x%d > cur_rix 0x%x, average_tx_time %d, cur_att %d",
 				    __func__,
 				    MCS(best_rix), MCS(cur_rix), average_tx_time, cur_att);
@@ -700,7 +704,7 @@
 			if (best_rix != san->current_rix[size_bin]) {
 				IEEE80211_NOTE(vap,
 				    IEEE80211_MSG_RATECTL,
-				    &ni,
+				    ni,
 "%s: size %d switch rate %d (%d/%d) -> %d (%d/%d) after %d packets mrr %d",
 				    __func__,
 				    bin_to_size(size_bin),
@@ -794,7 +798,7 @@
 	const int size_bin = size_to_bin(frame_size);
 	const int size = bin_to_size(size_bin);
 
-	int is_ht40 = ieee80211_ratectl_hascap_cw40(vap, ni);
+	int is_ht40 = ieee80211_ratectl_hascap_cw40(ni);
 	int tt, tries_so_far;
 	int pct;
 
@@ -827,7 +831,7 @@
 			MIN(tries3 + tries_so_far, tries) - tries_so_far - 1, is_ht40);
 	}
 
-	if (san->stats[size_bin][rix0].total_packets < sample->sanple_smoothing_minpackets) {
+	if (san->stats[size_bin][rix0].total_packets < sample->sample_smoothing_minpackets) {
 		/* just average the first few packets */
 		int avg_tx = san->stats[size_bin][rix0].average_tx_time;
 		int packets = san->stats[size_bin][rix0].total_packets;
@@ -835,8 +839,8 @@
 	} else {
 		/* use a ewma */
 		san->stats[size_bin][rix0].average_tx_time = 
-			((san->stats[size_bin][rix0].average_tx_time * sample->sanple_smoothing_rate) + 
-			 (tt * (100 - sample->sanple_smoothing_rate))) / 100;
+			((san->stats[size_bin][rix0].average_tx_time * sample->sample_smoothing_rate) + 
+			 (tt * (100 - sample->sample_smoothing_rate))) / 100;
 	}
 	
 	/*
@@ -863,7 +867,7 @@
 	pct = ((nframes - nbad) * 1000) / nframes;
 
 	if (san->stats[size_bin][rix0].total_packets <
-	    sample->sanple_smoothing_minpackets) {
+	    sample->sample_smoothing_minpackets) {
 		/* just average the first few packets */
 		int a_pct = (san->stats[size_bin][rix0].packets_acked * 1000) /
 		    (san->stats[size_bin][rix0].total_packets);
@@ -871,8 +875,8 @@
 	} else {
 		/* use a ewma */
 		san->stats[size_bin][rix0].ewma_pct =
-			((san->stats[size_bin][rix0].ewma_pct * sample->sanple_smoothing_rate) +
-			 (pct * (100 - sample->sanple_smoothing_rate))) / 100;
+			((san->stats[size_bin][rix0].ewma_pct * sample->sample_smoothing_rate) +
+			 (pct * (100 - sample->sample_smoothing_rate))) / 100;
 	}
 
 	if (rix0 == san->current_sample_rix[size_bin]) {
@@ -883,25 +887,22 @@
 
 static void
 sample_tx_complete(const struct ieee80211vap *vap,
-    const struct ieee80211_node *ni, int ok,
-    void *arg1, void *arg2)
+    const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info)
 {
 	struct ieee80211_sample_node *san = ni->ni_rctls;
-	const struct ieee80211_rate_table *rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan);
-
-	/* XXX need to change arg2 to pointer of ieee80211_rc_info */
-	struct ieee80211_rc_info *rc_info = (struct ieee80211_rc_info*)arg2;
-
+	const struct ieee80211_rate_table *rt = NULL;
+	struct ieee80211_rc_series *rc = NULL;
 	int final_rix, short_tries, long_tries;
 	int nframes, nbad;
 	int frame_size, mrr;
 
+	rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan);
+	rc = rc_info->iri_rc;	
 	/* update per vap statistics */
 	ieee80211_ratectl_update_stat(vap, rc_info);
 
 	final_rix = rt->rateCodeToIndex[rc_info->iri_txrate];
 	short_tries = rc_info->iri_shortretry;
-	/* XXX why plus 1 here? */
 	long_tries = rc_info->iri_longretry + 1;
 
 	nframes = rc_info->iri_txcnt;
@@ -911,6 +912,7 @@
 	mrr = 0;
 
 	if (nframes == 0) {
+		/* XXX need some msg out */
 		return;
 	}
 
@@ -944,7 +946,6 @@
 
 	} else {
 		int finalTSIdx = rc_info->iri_finaltsi;
-		int i;
 
 		/*
 		 * NB: series > 0 are not penalized for failure
@@ -1008,18 +1009,11 @@
 static void
 sample_setinterval(const struct ieee80211vap *vap, int msecs)
 {
-	struct ieee80211_sample *sample = vap->iv_rs;
-	int t;
-
-	if (msecs < 100)
-		msecs = 100;
-	t = msecs_to_ticks(msecs);
 	/* ieee80211_sample doesn't have the sample_interval field by now */
-	// sample->sample_interval = (t < 1) ? 1 : t;
 }
 
 static void
-sample_stats(void *arg, struct ieee80211_node *ni)
+sample_stats_node(void *arg, struct ieee80211_node *ni)
 {
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211_sample_node *san = ni->ni_rctls;
@@ -1071,20 +1065,16 @@
 		}
 	}
 }
-
-static int
-sample_sysctl_stats(SYSCTL_HANDLER_ARGS)
+static void
+sample_stats(const struct ieee80211vap *vap)
 {
-	struct ieee80211vap *vap = arg1;
 	struct ieee80211com *ic = vap->iv_ifp->if_l2com;
-	int error, v;
-
-	v = 0;
-	error = sysctl_handle_int(oidp, &v, 0, req);
-	if (error || !req->newptr)
-		return error;
-	ieee80211_iterate_nodes(&ic->ic_sta, sample_stats, NULL);
-	return 0;
+	struct ieee80211_rc_stat * irs = IEEE80211_RATECTL_STAT(vap);
+	printf("tx count: %d (ok count: %d, fail count: %d)\n"
+			"retry count: %d (short retry: %d, long retry: %d)\n",
+			irs->irs_txcnt, irs->irs_txcnt - irs->irs_failcnt, irs->irs_failcnt,
+			irs->irs_retrycnt, irs->irs_shortretry, irs->irs_longretry);
+	ieee80211_iterate_nodes(&ic->ic_sta, sample_stats_node, NULL);
 }
 
 static int
@@ -1134,8 +1124,4 @@
 	    "sample_rate", CTLTYPE_INT | CTLFLAG_RW, vap, 0,
 	    sample_sysctl_sample_rate, "I",
 	    "sample: percent air time devoted to sampling new rates (%%)");
-	/* XXX max_successive_failures, stale_failure_timeout, min_switch */
-	SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
-	    "sample_stats", CTLTYPE_INT | CTLFLAG_RW, vap, 0,
-	    sample_sysctl_stats, "I", "sample: print statistics");
 }

Copied and modified: soc2013/ccqin/head/sys/net80211/ieee80211_sample.h (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h)
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h	Mon Sep  2 08:00:12 2013	(r256825, copy source)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_sample.h	Mon Sep 16 08:08:52 2013	(r257398)
@@ -143,25 +143,28 @@
 	return NUM_PACKET_SIZE_BINS-1;
 }
 
-static uint32_t sample_pkt_txtime(const struct ieee80211_rate_table *rt,
+static uint32_t sample_pkt_tx_time(const struct ieee80211_rate_table *rt,
 	uint32_t frameLen, uint16_t rateix, int isht40, int isShortPreamble)
 {
-	uint8_t rc;
-    int numStreams;
+	uint8_t rate = rt->info[rateix].dot11Rate;
+	uint32_t tx_time = 0;
 
-    rc = rt->info[rateix].rateCode;
-
-    /* Legacy rate? Return the old way */
-    if (! IS_HT_RATE(rc))
-    	return ieee80211_compute_duration(rt, frameLen, rateix, isShortPreamble);
-
-    /* 11n frame - extract out the number of spatial streams */
-    numStreams = HT_RC_2_STREAMS(rc);
-    KASSERT(numStreams > 0 && numStreams <= 4,
-        ("number of spatial streams needs to be 1..3: MCS rate 0x%x!",
-        rateix));
+	if (rt->info[rateix].phy == IEEE80211_T_HT) {
+    	int numStreams;
+    	/* 11n frame - extract out the number of spatial streams */
+    	rate |= IEEE80211_RATE_MCS;
+		numStreams = HT_RC_2_STREAMS(rate);
+    	KASSERT(numStreams > 0 && numStreams <= 4,
+    	    ("number of spatial streams needs to be 1..3: MCS rate 0x%x!",
+    	    rateix));
+    	tx_time = ieee80211_compute_duration_ht(frameLen, rate, numStreams, isht40, isShortPreamble);
+	} else {
+    	/* Legacy rate? Return the old way */
+    	rate &= IEEE80211_RATE_VAL;
+    	tx_time = ieee80211_compute_duration(rt, frameLen, rate, isShortPreamble);
+	}
 
-    return ieee80211_compute_duration_ht(frameLen, rc, numStreams, isht40, isShortPreamble);
+	return tx_time;
 }
 
 #define WIFI_CW_MIN 31
@@ -183,9 +186,9 @@
 	int rts, cts;
 	int tt, x, cw, cix;
 
-	int tt = 0;
-	int x = 0;
-	int cw = WIFI_CW_MIN;
+	tt = 0;
+	x = 0;
+	cw = WIFI_CW_MIN;
 
 	KASSERT(rt != NULL, ("no rate table, mode %u", curmode));
 
@@ -194,7 +197,7 @@
 		       rix, rt->rateCount, curmode);
 		return 0;
 	}
-	cix = rt->info[rix].controlRate;
+	cix = rt->info[rix].ctlRateIndex;
 	/* 
 	 * XXX getting mac/phy level timings should be fixed for turbo
 	 * rates, and there is probably a way to get this from the
@@ -242,7 +245,7 @@
     	if (0xff == protrix)
     		protrix = 0;
 
-		cix = rt->info[protrix].controlRate;
+		cix = rt->info[protrix].ctlRateIndex;
 	}
 
 	if (0 /*length > ic->ic_rtsthreshold */) {
@@ -250,7 +253,6 @@
 	}
 
 	if (rts || cts) {
-		int ctsrate;
 		int ctsduration = 0;
 
 		/* NB: this is intentionally not a runtime check */
@@ -258,12 +260,11 @@
 		    ("bogus cix %d, max %u, mode %u\n", cix, rt->rateCount,
 		     curmode));
 
-		ctsrate = rt->info[cix].rateCode | rt->info[cix].shortPreamble;
 		if (rts)		/* SIFS + CTS */
 			ctsduration += rt->info[cix].spAckDuration;
 
 		/* XXX assumes short preamble */
-		ctsduration += sample_pkt_txtime(rt, length, rix, is_ht40, 0);
+		ctsduration += sample_pkt_tx_time(rt, length, rix, is_ht40, 0);
 
 		if (cts)	/* SIFS + ACK */
 			ctsduration += rt->info[cix].spAckDuration;
@@ -273,7 +274,7 @@
 	tt += t_difs;
 
 	/* XXX assumes short preamble */
-	tt += (long_retries+1)*sample_pkt_txtime(rt, length, rix, is_ht40, 0);
+	tt += (long_retries+1)*sample_pkt_tx_time(rt, length, rix, is_ht40, 0);
 
 	tt += (long_retries+1)*(t_sifs + rt->info[rix].spAckDuration);
 

Copied: soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h	Mon Sep 16 08:08:52 2013	(r257398, copy of r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h)
@@ -0,0 +1,241 @@
+/* $FreeBSD: head/sys/dev/ath/ath_rate/sample/tx_schedules.h 240384 2012-08-15 07:50:42Z adrian $*/
+
+/*-
+ * Copyright (c) 2005 John Bicket
+ * Copyright (c) 2013 Chenchong Qin <ccqin at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+#ifndef	_NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_
+#define	_NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_
+
+#include <sys/cdefs.h>
+
+#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 NA1(_r) \
+	(((_r) == 6.5)  ? 8 : (((_r) == 13)  ?  9 : (((_r) == 19.5)? 10 : \
+	(((_r) == 26)  ? 11 : (((_r) == 39)  ? 12 : (((_r) == 52)  ? 13 : \
+	(((_r) == 58.5)? 14 : (((_r) == 65)  ? 15 : 0))))))))
+#define NA2(_r) \
+	(((_r) == 13) ? 16 : (((_r) == 26) ? 17 : (((_r) == 39) ? 18 : \
+	(((_r) == 52) ? 19 : (((_r) == 78) ? 20 : (((_r) == 104)? 21 : \
+	(((_r) == 117)? 22 : (((_r) == 130)? 23 : 0))))))))
+#define NA3(_r) \
+	(((_r) == 19.5)  ? 24 : (((_r) == 39) ? 25 : (((_r) == 58.5)  ? 26 : \
+	(((_r) == 78)  ? 27 : (((_r) == 117) ? 28 : (((_r) == 156) ? 29 : \
+	(((_r) == 175.5) ? 30 : (((_r) == 195)? 31 : 0))))))))
+static const struct txschedule series_11na[] = {
+	{ 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 */
+
+	/* 1 stream rates */
+
+	{ 3,NA1( 6.5), 3,NA1( 6.5), 0,NA1( 6.5), 0,NA1(6.5) },  /* 6.5Mb/s */
+	{ 4,NA1(  13), 3,NA1( 6.5), 4,NA1( 6.5), 0,NA1(6.5) },  /*  13Mb/s */
+	{ 4,NA1(19.5), 3,NA1( 6.5), 4,NA1( 6.5), 0,NA1(6.5) },  /*19.5Mb/s */
+	{ 4,NA1(  26), 3,NA1(19.5), 4,NA1( 6.5), 2,NA1(6.5) },  /*  26Mb/s */
+	{ 4,NA1(  39), 3,NA1(  26), 4,NA1(19.5), 2,NA1(6.5) },  /*  39Mb/s */
+	{ 4,NA1(  52), 3,NA1(  39), 4,NA1(  26), 2,NA1(6.5) },  /*  52Mb/s */
+	{ 4,NA1(58.5), 3,NA1(  52), 4,NA1(  39), 2,NA1( 13) },  /*58.5Mb/s */
+	{ 4,NA1(  65), 3,NA1(58.5), 4,NA1(  52), 2,NA1( 13) },  /*  65Mb/s */
+
+	/* 2 stream rates */
+
+	{ 3,NA2(  13), 3,NA2(  13), 0,NA2(  13), 0,NA2( 13) },  /*  13Mb/s */
+	{ 4,NA2(  26), 3,NA2(  13), 4,NA2(  13), 0,NA2( 13) },  /*  26Mb/s */
+	{ 4,NA2(  39), 3,NA2(  26), 4,NA2(  13), 2,NA2( 13) },  /*  39Mb/s */
+	{ 4,NA2(  52), 3,NA2(  39), 4,NA2(  26), 2,NA2( 13) },  /*  52Mb/s */
+	{ 4,NA2(  78), 3,NA2(  52), 4,NA2(  39), 2,NA2( 13) },  /*  78Mb/s */
+	{ 4,NA2( 104), 3,NA2(  78), 4,NA2(  52), 2,NA2( 13) },  /* 104Mb/s */
+	{ 4,NA2( 117), 3,NA2( 104), 4,NA2(  78), 2,NA2( 26) },  /* 117Mb/s */
+	{ 4,NA2( 130), 3,NA2( 117), 4,NA2( 104), 2,NA2( 26) },   /* 130Mb/s */
+
+	/* 3 stream rates */
+
+	{ 3,NA3(19.5), 3,NA3(19.5), 0,NA3(19.5), 0,NA3(19.5) },  /*  19Mb/s */
+	{ 3,NA3(  39), 3,NA3(19.5), 0,NA3(19.5), 0,NA3(19.5) },  /*  39Mb/s */
+	{ 3,NA3(58.5), 3,NA3(  39), 0,NA3(19.5), 0,NA3(19.5) },  /*  58Mb/s */
+	{ 3,NA3(  78), 3,NA3(58.5), 0,NA3(  39), 0,NA3(19.5) },  /*  78Mb/s */
+	{ 3,NA3( 117), 3,NA3(  78), 0,NA3(58.5), 0,NA3(19.5) },  /* 117Mb/s */
+	{ 3,NA3( 156), 3,NA3( 117), 0,NA3(  78), 0,NA3(19.5) },  /*  156Mb/s */
+	{ 3,NA3(175.5), 3,NA3( 156), 0,NA3( 117), 0,NA3(  39) },  /*  175Mb/s */
+	{ 3,NA3( 195), 3,NA3( 195), 0,NA3( 156), 0,NA3(58.5) },  /* 195Mb/s */
+};
+#undef A
+#undef NA3
+#undef NA2
+#undef NA1
+
+#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 */
+};
+
+#define NG1(_r) \
+	(((_r) == 6.5) ? 12 : (((_r) == 13) ? 13 : (((_r) == 19.5)? 14 : \
+	(((_r) == 26)  ? 15 : (((_r) == 39) ? 16 : (((_r) == 52)  ? 17 : \
+	(((_r) == 58.5)? 18 : (((_r) == 65) ? 19 : 0))))))))
+#define NG2(_r) \
+	(((_r) == 13)  ? 20 : (((_r) == 26) ? 21 : (((_r) == 39)  ? 22 : \
+	(((_r) == 52)  ? 23 : (((_r) == 78) ? 24 : (((_r) == 104) ? 25 : \
+	(((_r) == 117) ? 26 : (((_r) == 130)? 27 : 0))))))))
+#define NG3(_r) \
+	(((_r) == 19.5)  ? 28 : (((_r) == 39) ? 29 : (((_r) == 58.5)  ? 30 : \
+	(((_r) == 78)  ? 31 : (((_r) == 117) ? 32 : (((_r) == 156) ? 33 : \
+	(((_r) == 175.5) ? 34 : (((_r) == 195)? 35 : 0))))))))
+
+static const struct txschedule series_11ng[] = {
+	{ 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 */
+
+	/* 1 stream rates */
+
+	{ 3,NG1( 6.5), 3,NG1( 6.5), 0,NG1( 6.5), 0,NG1(6.5) },  /* 6.5Mb/s */
+	{ 4,NG1(  13), 3,NG1( 6.5), 4,NG1( 6.5), 0,NG1(6.5) },  /*  13Mb/s */
+	{ 4,NG1(19.5), 3,NG1( 6.5), 4,NG1( 6.5), 0,NG1(6.5) },  /*19.5Mb/s */
+	{ 4,NG1(  26), 3,NG1(19.5), 4,NG1( 6.5), 2,NG1(6.5) },  /*  26Mb/s */
+	{ 4,NG1(  39), 3,NG1(  26), 4,NG1(19.5), 2,NG1(6.5) },  /*  39Mb/s */
+	{ 4,NG1(  52), 3,NG1(  39), 4,NG1(  26), 2,NG1(6.5) },  /*  52Mb/s */
+	{ 4,NG1(58.5), 3,NG1(  52), 4,NG1(  39), 2,NG1( 13) },  /*58.5Mb/s */
+	{ 4,NG1(  65), 3,NG1(58.5), 4,NG1(  52), 2,NG1( 13) },  /*  65Mb/s */
+
+	/* 2 stream rates */
+
+	{ 3,NG2(  13), 3,NG2(  13), 0,NG2(  13), 0,NG2( 13) },  /*  13Mb/s */
+	{ 4,NG2(  26), 3,NG2(  13), 4,NG2(  13), 0,NG2( 13) },  /*  26Mb/s */
+	{ 4,NG2(  39), 3,NG2(  26), 4,NG2(  13), 2,NG2( 13) },  /*  39Mb/s */
+	{ 4,NG2(  52), 3,NG2(  39), 4,NG2(  26), 2,NG2( 13) },  /*  52Mb/s */
+	{ 4,NG2(  78), 3,NG2(  52), 4,NG2(  39), 2,NG2( 13) },  /*  78Mb/s */
+	{ 4,NG2( 104), 3,NG2(  78), 4,NG2(  52), 2,NG2( 13) },  /* 104Mb/s */
+	{ 4,NG2( 117), 3,NG2( 104), 4,NG2(  78), 2,NG2( 26) },  /* 117Mb/s */
+	{ 4,NG2( 130), 3,NG2( 117), 4,NG2( 104), 2,NG2( 26) },  /* 130Mb/s */
+
+	/* 3 stream rates */
+
+	{ 3,NG3(19.5), 3,NG3(19.5), 0,NG3(19.5), 0,NG3(19.5) },  /*  19Mb/s */
+	{ 3,NG3(  39), 3,NG3(19.5), 0,NG3(19.5), 0,NG3(19.5) },  /*  39Mb/s */
+	{ 3,NG3(58.5), 3,NG3(  39), 0,NG3(19.5), 0,NG3(19.5) },  /*  58Mb/s */
+	{ 3,NG3(  78), 3,NG3(58.5), 0,NG3(  39), 0,NG3(19.5) },  /*  78Mb/s */
+	{ 3,NG3( 117), 3,NG3(  78), 0,NG3(58.5), 0,NG3(19.5) },  /* 117Mb/s */
+	{ 3,NG3( 156), 3,NG3( 117), 0,NG3(  78), 0,NG3(19.5) },  /*  156Mb/s */
+	{ 3,NG3(175.5), 3,NG3( 156), 0,NG3( 117), 0,NG3(  39) },  /*  175Mb/s */
+	{ 3,NG3( 195), 3,NG3( 195), 0,NG3( 156), 0,NG3(58.5) },  /* 195Mb/s */
+
+};
+#undef G
+#undef NG3
+#undef NG2
+#undef NG1
+
+#define H(_r) \
+    (((_r) == 3)   ? 0 : (((_r) == 4.5) ? 1 : (((_r) == 6)  ? 2 : \
+    (((_r) == 9)   ? 3 : (((_r) == 12)  ? 4 : (((_r) == 18) ? 5 : \
+    (((_r) == 24)  ? 6 : (((_r) == 27)  ? 7 : 0))))))))
+static const struct txschedule series_half[] = {
+	{ 3,H( 3), 3,H(  3), 0,H(  3), 0,H( 3) },	/*   3Mb/s */
+	{ 4,H(4.5),3,H(  3), 4,H(  3), 0,H( 3) },	/* 4.5Mb/s */
+	{ 4,H( 6), 3,H(  3), 4,H(  3), 0,H( 3) },	/*   6Mb/s */
+	{ 4,H( 9), 3,H(  6), 4,H(  3), 2,H( 3) },	/*   9Mb/s */
+	{ 4,H(12), 3,H(  9), 4,H(  6), 2,H( 3) },	/*  12Mb/s */
+	{ 4,H(18), 3,H( 12), 4,H(  9), 2,H( 3) },	/*  18Mb/s */
+	{ 4,H(24), 3,H( 18), 4,H( 12), 2,H( 6) },	/*  24Mb/s */
+	{ 4,H(27), 3,H( 24), 4,H( 18), 2,H(12) }	/*  27Mb/s */
+};
+#undef H
+
+#ifdef Q
+#undef Q
+#endif
+#define Q(_r) \
+    (((_r) == 1.5) ? 0 : (((_r) ==2.25) ? 1 : (((_r) == 3)  ? 2 : \
+    (((_r) == 4.5) ? 3 : (((_r) ==  6)  ? 4 : (((_r) == 9)  ? 5 : \
+    (((_r) == 12)  ? 6 : (((_r) == 13.5)? 7 : 0))))))))
+static const struct txschedule series_quarter[] = {
+	{ 3,Q( 1.5),3,Q(1.5), 0,Q(1.5), 0,Q(1.5) },	/* 1.5Mb/s */
+	{ 4,Q(2.25),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) },	/*2.25Mb/s */
+	{ 4,Q(   3),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) },	/*   3Mb/s */
+	{ 4,Q( 4.5),3,Q(  3), 4,Q(1.5), 2,Q(1.5) },	/* 4.5Mb/s */
+	{ 4,Q(   6),3,Q(4.5), 4,Q(  3), 2,Q(1.5) },	/*   6Mb/s */
+	{ 4,Q(   9),3,Q(  6), 4,Q(4.5), 2,Q(1.5) },	/*   9Mb/s */
+	{ 4,Q(  12),3,Q(  9), 4,Q(  6), 2,Q(  3) },	/*  12Mb/s */
+	{ 4,Q(13.5),3,Q( 12), 4,Q(  9), 2,Q(  6) }	/*13.5Mb/s */
+};
+#undef Q
+
+#endif /* _NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_ */


More information about the svn-soc-all mailing list