socsvn commit: r255969 - soc2013/ccqin/head/sys/net80211

ccqin at FreeBSD.org ccqin at FreeBSD.org
Thu Aug 15 09:07:05 UTC 2013


Author: ccqin
Date: Thu Aug 15 09:07:05 2013
New Revision: 255969
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255969

Log:
  Some error fixed and come functions added.
  * fix the error refering rateCode of ieee80211_rate_table.
  * add ieee80211_ratectl_[node_is11n|get_rateset] to the ratectl api.
    rc algos all need these functions.
  * change the naming conversion of IEEE80211_RATECTL_FLAG_*.

Modified:
  soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
  soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c
  soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h
  soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Thu Aug 15 08:21:00 2013	(r255968)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Thu Aug 15 09:07:05 2013	(r255969)
@@ -130,7 +130,7 @@
 }
 
 static int
-amrr_node_is_11n(struct ieee80211_node *ni)
+ieee80211_ratectl_node_is11n(struct ieee80211_node *ni)
 {
 
 	if (ni->ni_chan == NULL)
@@ -169,23 +169,13 @@
 	amn->amn_txcnt = amn->amn_retrycnt = 0;
 	amn->amn_success_threshold = amrr->amrr_min_success_threshold;
 
-	/* 11n or not? Pick the right rateset */
-	if (amrr_node_is_11n(ni)) {
-		/* XXX ew */
-		IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
-		    "%s: 11n node", __func__);
-		rs = (struct ieee80211_rateset *) &ni->ni_htrates;
-	} else {
-		IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
-		    "%s: non-11n node", __func__);
-		rs = &ni->ni_rates;
-	}
+	rs = ieee80211_ratectl_get_rateset(ni);
 
 	/* Initial rate - lowest */
 	rate = rs->rs_rates[0];
 
 	/* XXX clear the basic rate flag if it's not 11n */
-	if (! amrr_node_is_11n(ni))
+	if (! ieee80211_ratectl_node_is11n(ni))
 		rate &= IEEE80211_RATE_VAL;
 
 	/* pick initial rate from the rateset - HT or otherwise */
@@ -193,7 +183,7 @@
 	    amn->amn_rix--) {
 		/* legacy - anything < 36mbit, stop searching */
 		/* 11n - stop at MCS4 / MCS12 / MCS28 */
-		if (amrr_node_is_11n(ni) &&
+		if (ieee80211_ratectl_node_is11n(ni) &&
 		    (rs->rs_rates[amn->amn_rix] & 0x7) < 4)
 			break;
 		else if ((rs->rs_rates[amn->amn_rix] & IEEE80211_RATE_VAL) <= 72)
@@ -202,7 +192,7 @@
 	}
 
 	/* if the rate is an 11n rate, ensure the MCS bit is set */
-	if (amrr_node_is_11n(ni))
+	if (ieee80211_ratectl_node_is11n(ni))
 		rate |= IEEE80211_RATE_MCS;
 
 	/* Assign initial rate from the rateset */
@@ -230,13 +220,8 @@
 
 	KASSERT(is_enough(amn), ("txcnt %d", amn->amn_txcnt));
 
-	/* 11n or not? Pick the right rateset */
-	if (amrr_node_is_11n(ni)) {
-		/* XXX ew */
-		rs = (struct ieee80211_rateset *) &ni->ni_htrates;
-	} else {
-		rs = &ni->ni_rates;
-	}
+	rs = ieee80211_ratectl_get_rateset(ni);
+
 
 	IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
 	    "AMRR: current rate %d, txcnt=%d, retrycnt=%d",
@@ -308,13 +293,7 @@
 	const struct ieee80211_rateset *rs = NULL;
 	int rix;
 
-	/* 11n or not? Pick the right rateset */
-	if (amrr_node_is_11n(ni)) {
-		/* XXX ew */
-		rs = (struct ieee80211_rateset *) &ni->ni_htrates;
-	} else {
-		rs = &ni->ni_rates;
-	}
+	rs = ieee80211_ratectl_get_rateset(ni);
 
 	if (is_enough(amn) && (ticks - amn->amn_ticks) > amrr->amrr_interval) {
 		rix = amrr_update(amrr, amn, ni);
@@ -322,7 +301,7 @@
 			/* update public rate */
 			ni->ni_txrate = rs->rs_rates[rix];
 			/* XXX strip basic rate flag from txrate, if non-11n */
-			if (amrr_node_is_11n(ni))
+			if (ieee80211_ratectl_node_is11n(ni))
 				ni->ni_txrate |= IEEE80211_RATE_MCS;
 			else
 				ni->ni_txrate &= IEEE80211_RATE_VAL;

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Thu Aug 15 08:21:00 2013	(r255968)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Thu Aug 15 09:07:05 2013	(r255969)
@@ -123,13 +123,15 @@
 ieee80211_ratectl_complete_rcflags(struct ieee80211_node *ni,
 		struct ieee80211_rc_info *rc_info)
 {
+	const struct ieee80211_rate_table * rt = NULL;
 	const struct ieee80211com *ic = ni->ni_ic;
-	const struct ieee80211_rate_table * rt = ic->ic_rt;
 	struct ieee80211_rc_series *rc = rc_info->ri_rc;
 	int shortPreamble = rc_info->ri_shortPreamble;
 	uint8_t rate;
 	int i;
 
+	rt = ieee80211_get_ratetable(ni->ni_ic->ic_curchan);
+
 	/* Make sure that rate control code doesn't mess it up.
 	 * If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 
 	 */
@@ -138,9 +140,9 @@
 	{
 		for (i = 1; i < IEEE80211_RATECTL_NUM; i++)
 		{
-			if (rc[0].flags & IEEE80211_RATECTL_RTSCTS_FLAG)
+			if (rc[0].flags & IEEE80211_RATECTL_FLAG_RTSCTS)
 				rc[i].tries = 0;
-			rc[i].flags &= ~IEEE80211_RATECTL_RTSCTS_FLAG; 
+			rc[i].flags &= ~IEEE80211_RATECTL_FLAG_RTSCTS; 
 		}
 	}
 
@@ -149,13 +151,18 @@
 		if (rc[i].tries == 0)
 			continue;
 
-		rate = rt->info[rc[i].rix].rateCode;
+		rate = rt->info[rc[i].rix].dot11Rate;
 
 		/*
 		 * Only enable short preamble for legacy rates
 		 */
+
+		/* XXX how we get the non_ht ratecode here? */
+
+		#if 0
 		if ((! IS_HT_RATE(rate)) && shortPreamble)
 			rate |= rt->info[rc[i].rix].shortPreamble;
+		#endif
 
 		/*
 		 * Save this, used by the TX and completion code
@@ -164,7 +171,7 @@
 
 		/* Only enable shortgi, 2040, dual-stream if HT is set */
 		if (IS_HT_RATE(rate)) {
-			rc[i].flags |= IEEE80211_RATECTL_HT_FLAG;
+			rc[i].flags |= IEEE80211_RATECTL_FLAG_HT;
 
 			/*
 			 * XXX TODO: LDPC
@@ -174,9 +181,9 @@
 			 * Dual / Triple stream rate?
 			 */
 			if (HT_RC_2_STREAMS(rate) == 2)
-				rc[i].flags |= IEEE80211_RATECTL_DS_FLAG;
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_DS;
 			else if (HT_RC_2_STREAMS(rate) == 3)
-				rc[i].flags |= IEEE80211_RATECTL_TS_FLAG;
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_TS;
 		}
 
 		/*
@@ -190,16 +197,16 @@
 		 * Calculate the maximum 4ms frame length based
 		 * on the MCS rate, SGI and channel width flags.
 		 */
-		if ((rc[i].flags & IEEE80211_RATECTL_HT_FLAG) &&
+		if ((rc[i].flags & IEEE80211_RATECTL_FLAG_HT) &&
 		    (HT_RC_2_MCS(rate) < 32)) {
 			int j;
-			if (rc[i].flags & IEEE80211_RATECTL_CW40_FLAG) {
-				if (rc[i].flags & IEEE80211_RATECTL_SGI_FLAG)
+			if (rc[i].flags & IEEE80211_RATECTL_FLAG_CW40) {
+				if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI)
 					j = MCS_HT40_SGI;
 				else
 					j = MCS_HT40;
 			} else {
-				if (rc[i].flags & IEEE80211_RATECTL_SGI_FLAG)
+				if (rc[i].flags & IEEE80211_RATECTL_FLAG_SGI)
 					j = MCS_HT20_SGI;
 				else
 					j = MCS_HT20;

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Thu Aug 15 08:21:00 2013	(r255968)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Thu Aug 15 09:07:05 2013	(r255969)
@@ -37,13 +37,6 @@
 	IEEE80211_RATECTL_MAX
 };
 
-enum {
-	MCS_HT20,
-	MCS_HT20_SGI,
-	MCS_HT40,
-	MCS_HT40_SGI,
-};
-
 #define	IEEE80211_RATECTL_TX_SUCCESS	1
 #define	IEEE80211_RATECTL_TX_FAILURE	0
 
@@ -52,35 +45,30 @@
 
 #define	IEEE80211_RATECTL_NUM		4
 
-#define	IEEE80211_RATECTL_DS_FLAG		0x01	/* dual-stream rate */
-#define	IEEE80211_RATECTL_CW40_FLAG		0x02	/* use HT40 */
-#define	IEEE80211_RATECTL_SGI_FLAG		0x04	/* use short-GI */
-#define	IEEE80211_RATECTL_HT_FLAG		0x08	/* use HT */
-#define	IEEE80211_RATECTL_RTSCTS_FLAG	0x10	/* enable RTS/CTS protection */
-#define	IEEE80211_RATECTL_STBC_FLAG		0x20	/* enable STBC */
-#define	IEEE80211_RATECTL_TS_FLAG		0x40	/* triple-stream rate */
+#define	IEEE80211_RATECTL_FLAG_DS		0x01	/* dual-stream rate */
+#define	IEEE80211_RATECTL_FLAG_CW40		0x02	/* use HT40 */
+#define	IEEE80211_RATECTL_FLAG_SGI		0x04	/* use short-GI */
+#define	IEEE80211_RATECTL_FLAG_HT		0x08	/* use HT */
+#define	IEEE80211_RATECTL_FLAG_RTSCTS	0x10	/* enable RTS/CTS protection */
+#define	IEEE80211_RATECTL_FLAG_STBC		0x20	/* enable STBC */
+#define	IEEE80211_RATECTL_FLAG_TS		0x40	/* triple-stream rate */
 
 /* Hardware CAPs offered to rate control algo */
 #define	IEEE80211_RATECTL_CAP_MRR			0x01	/* support MRR */
 #define	IEEE80211_RATECTL_CAP_MRRPROT		0x02	/* support MRR + protect */
 #define	IEEE80211_RATECTL_CAP_MULTXCHAIN	0x04	/* has more than 1 txchain */
 
-#define IEEE80211_RATECTL_NODE(_ni) \
-	((struct ieee80211_ratectl_node *)((_ni)->ni_rctls))
-
-#define	IEEE80211_RATECTL_HASCAP_MRR(_ni) \
-	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MRR)
-#define	IEEE80211_RATECTL_HASCAP_MRRPROT(_ni) \
-	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MRRPROT)
-#define	IEEE80211_RATECTL_HASCAP_MULTXCHAIN(_ni) \
-	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MULTXCHAIN)
-
 #define IS_VAP_HT(vap)	((vap)->iv_htcaps & IEEE80211_HTC_HT)
-
 #define IS_HT_RATE(_rate)   ((_rate) & 0x80)
 #define HT_RC_2_MCS(_rc)    ((_rc) & 0x7f)
 #define HT_RC_2_STREAMS(_rc)    ((((_rc) & 0x78) >> 3) + 1)
 
+enum {
+	MCS_HT20,
+	MCS_HT20_SGI,
+	MCS_HT40,
+	MCS_HT40_SGI,
+};
 
 extern int max_4ms_framelen[4][32];
 
@@ -135,6 +123,16 @@
 	uint32_t irn_capabilities;		/* hardware capabilities offered to rc */
 };
 
+#define IEEE80211_RATECTL_NODE(_ni) \
+	((struct ieee80211_ratectl_node *)((_ni)->ni_rctls))
+
+#define	IEEE80211_RATECTL_HASCAP_MRR(_ni) \
+	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MRR)
+#define	IEEE80211_RATECTL_HASCAP_MRRPROT(_ni) \
+	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MRRPROT)
+#define	IEEE80211_RATECTL_HASCAP_MULTXCHAIN(_ni) \
+	(IEEE80211_RATECTL_NODE(_ni)->irn_capabilities & IEEE80211_RATECTL_CAP_MULTXCHAIN)
+
 void	ieee80211_ratectl_register(int, const struct ieee80211_ratectl *);
 void	ieee80211_ratectl_unregister(int);
 void	ieee80211_ratectl_init(struct ieee80211vap *);
@@ -243,4 +241,22 @@
 			    IEEE80211_RATECTL_HASCAP_MULTXCHAIN(ni);
 }
 
+static int __inline
+ieee80211_ratectl_node_is11n(const struct ieee80211_node *ni)
+{
+	if (ni->ni_chan == NULL)
+		return (0);
+	if (ni->ni_chan == IEEE80211_CHAN_ANYC)
+		return (0);
+	return (IEEE80211_IS_CHAN_HT(ni->ni_chan));
+}
+
+static const struct ieee80211_rateset * __inline
+ieee80211_ratectl_get_rateset(const struct ieee80211_node *ni)
+{
+	return ieee80211_ratectl_node_is11n(ni) ? 
+				(struct ieee80211_rateset *) &ni->ni_htrates :
+				&ni->ni_rates;
+}
+
 #endif

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c	Thu Aug 15 08:21:00 2013	(r255968)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c	Thu Aug 15 09:07:05 2013	(r255969)
@@ -111,18 +111,6 @@
 	free(vap->iv_rs, M_80211_RATECTL);
 }
 
-// XXX should be shared by ratectl algos
-static int
-sample_node_is_11n(struct ieee80211_node *ni)
-{
-
-	if (ni->ni_chan == NULL)
-		return (0);
-	if (ni->ni_chan == IEEE80211_CHAN_ANYC)
-		return (0);
-	return (IEEE80211_IS_CHAN_HT(ni->ni_chan));
-}
-
 static const struct txschedule *mrr_schedules[IEEE80211_MODE_MAX+2] = {
 	NULL,		/* IEEE80211_MODE_AUTO */
 	series_11a,	/* IEEE80211_MODE_11A */
@@ -591,24 +579,6 @@
 #undef MCS
 }
 
-static const struct ieee80211_rateset *
-sample_get_rateset(const struct ieee80211_node *ni)
-{
-	const struct ieee80211_rateset *rs = NULL;
-	/* 11n or not? Pick the right rateset */
-	if (sample_node_is_11n(ni)) {
-		/* XXX ew */
-		IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
-		    "%s: 11n node", __func__);
-		rs = (struct ieee80211_rateset *) &ni->ni_htrates;
-	} else {
-		IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
-		    "%s: non-11n node", __func__);
-		rs = &ni->ni_rates;
-	}
-	return rs;
-}
-
 static int
 sample_rate(struct ieee80211_node *ni, void *arg __unused, uint32_t iarg __unused)
 {


More information about the svn-soc-all mailing list