socsvn commit: r256824 - in soc2013/ccqin/head/sys: dev/ath net80211 sys

ccqin at FreeBSD.org ccqin at FreeBSD.org
Mon Sep 2 07:43:31 UTC 2013


Author: ccqin
Date: Mon Sep  2 07:43:31 2013
New Revision: 256824
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256824

Log:
  teach ieee80211_amrr to return multiple rates and modify ath to use net80211_ratectl.
  * add amrr_rates to teach ieee80211_amrr of multiple rate.
  * change ieee80211_ratectl_complete(), drop stats, arg1, arg2, add
    ieee80211_rc_info *. adapt amrr_tx_complete correspondingly.
  * update ieee80211_ratectl_hascap_* functions to make it more reasonable.
  * modify ieee80211_ratectl_complete_rcflags() to let it work properly. we just
    care about rc flags here. ratecode is left for drivers to fill.
  * add a 48 bytes buf to mbuf(m_hdr) to record rc state.
  * modify ath to make it use net80211_ratectl api.

Modified:
  soc2013/ccqin/head/sys/dev/ath/if_ath.c
  soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c
  soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c
  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/sys/mbuf.h

Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c
==============================================================================
--- soc2013/ccqin/head/sys/dev/ath/if_ath.c	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/dev/ath/if_ath.c	Mon Sep  2 07:43:31 2013	(r256824)
@@ -1380,6 +1380,15 @@
 	}
 	ATH_UNLOCK(sc);
 
+	uint32_t caps = 0;
+	if (sc->sc_mrretry)
+		caps |= IEEE80211_RATECTL_CAP_MRR;
+	if (sc->sc_mrrprot)
+		caps |= IEEE80211_RATECTL_CAP_MRRPROT;
+	if (sc->sc_txchainmask > 1)
+		caps |= IEEE80211_RATECTL_CAP_MULTXCHAIN;
+
+	ieee80211_ratectl_init(vap, caps);
 	/* complete setup */
 	ieee80211_vap_attach(vap, ath_media_change, ieee80211_media_status);
 	return vap;
@@ -1414,6 +1423,7 @@
 		ath_stoprecv(sc, 1);		/* stop recv side */
 	}
 
+	ieee80211_ratectl_deinit(vap);
 	ieee80211_vap_detach(vap);
 
 	/*
@@ -4072,6 +4082,13 @@
 			     bf->bf_state.bfs_rc, ts,
 			    bf->bf_state.bfs_pktlen, 1,
 			    (ts->ts_status == 0 ? 0 : 1));
+
+			struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+			ieee80211_ratectl_rc_info_set(rc_info,
+					1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen,
+					ts->ts_shortretry, ts->ts_longretry,
+					ts->ts_finaltsi, ts->ts_rate);
+			ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info);
 		}
 		ath_tx_default_comp(sc, bf, 0);
 	} else

Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c
==============================================================================
--- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c	Mon Sep  2 07:43:31 2013	(r256824)
@@ -1395,7 +1395,7 @@
 
 	/* Get rid of any previous state */
 	bzero(bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc));
-
+#if 0
 	ATH_NODE_LOCK(ATH_NODE(bf->bf_node));
 	ath_rate_findrate(sc, ATH_NODE(bf->bf_node), bf->bf_state.bfs_shpream,
 	    bf->bf_state.bfs_pktlen, &rix, &try0, &rate);
@@ -1409,6 +1409,20 @@
 		ath_rate_getxtxrates(sc, ATH_NODE(bf->bf_node), rix,
 		    bf->bf_state.bfs_rc);
 	ATH_NODE_UNLOCK(ATH_NODE(bf->bf_node));
+#endif
+	/* net80211 ratectl */
+	struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+	struct ieee80211_rc_series *rc = rc_info->iri_rc;
+	struct ieee80211_node *ni = bf->bf_node;
+	bzero(rc_info, sizeof(rc_info));
+	if (bf->bf_state.bfs_shpream)
+		rc_info->iri_flags |= IEEE80211_RATECTL_INFO_SP;
+
+	ieee80211_ratectl_rates(ni, rc_info);
+
+	rix = rc[0].rix;
+	try0 = rc[0].tries;
+	rate = ni->ni_txrate;
 
 	sc->sc_txrix = rix;	/* for LED blinking */
 	sc->sc_lastdatarix = rix;	/* for fast frames */
@@ -4108,10 +4122,19 @@
 	 * during a hw queue drain and the frame wanted an ACK.
 	 */
 	if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
+	{
 		ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
 		    ts, bf->bf_state.bfs_pktlen,
 		    1, (ts->ts_status == 0) ? 0 : 1);
 
+		struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+		ieee80211_ratectl_rc_info_set(rc_info,
+				1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen,
+				ts->ts_shortretry, ts->ts_longretry,
+				ts->ts_finaltsi, ts->ts_rate);
+		ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info);
+	}
+
 	ath_tx_default_comp(sc, bf, fail);
 }
 
@@ -4490,6 +4513,13 @@
 	    bf_first->bf_state.bfs_pktlen,
 	    bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes);
 
+	struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+	ieee80211_ratectl_rc_info_set(rc_info,
+			bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes,
+			bf->bf_state.bfs_pktlen,
+			ts->ts_shortretry, ts->ts_longretry,
+			ts->ts_finaltsi, ts->ts_rate);
+	ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info);
 	ATH_TX_LOCK(sc);
 	tap = ath_tx_get_tx_tid(an, tid->tid);
 	sc->sc_stats.ast_tx_aggr_failall++;
@@ -4873,9 +4903,18 @@
 	 * control code.
 	 */
 	if (fail == 0)
+	{	
 		ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes,
 		    nbad);
 
+		struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+		ieee80211_ratectl_rc_info_set(rc_info,
+				nframes, nbad, pktlen,
+				ts->ts_shortretry, ts->ts_longretry,
+				ts->ts_finaltsi, ts->ts_rate);
+		ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info);
+	}
+
 	/*
 	 * send bar if we dropped any frames
 	 */
@@ -4962,11 +5001,19 @@
 	 * Do it outside of the TXQ lock.
 	 */
 	if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
+	{	
 		ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
 		    &bf->bf_status.ds_txstat,
 		    bf->bf_state.bfs_pktlen,
 		    1, (ts.ts_status == 0) ? 0 : 1);
 
+		struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+		ieee80211_ratectl_rc_info_set(rc_info,
+				1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen,
+				ts->ts_shortretry, ts->ts_longretry,
+				ts->ts_finaltsi, ts->ts_rate);
+		ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info);
+	}
 	/*
 	 * This is called early so atid->hwq_depth can be tracked.
 	 * This unfortunately means that it's released and regrabbed

Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c
==============================================================================
--- soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx_ht.c	Mon Sep  2 07:43:31 2013	(r256824)
@@ -221,13 +221,34 @@
 void
 ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf)
 {
-	struct ieee80211_node *ni = bf->bf_node;
-	struct ieee80211com *ic = ni->ni_ic;
+	// struct ieee80211_node *ni = bf->bf_node;
+	// struct ieee80211com *ic = ni->ni_ic;
 	const HAL_RATE_TABLE *rt = sc->sc_currates;
-	struct ath_rc_series *rc = bf->bf_state.bfs_rc;
+	struct ath_rc_series *ath_rc = bf->bf_state.bfs_rc;
+	struct ieee80211_rc_info *rc_info = IEEE80211_RATECTL_INFO(bf->bf_m);
+	struct ieee80211_rc_series *rc = rc_info->iri_rc;
 	uint8_t rate;
 	int i;
 
+	for (i = 0; i < IEEE80211_RATECTL_NUM; i++) {
+		if (rc[i].tries == 0)
+			continue;
+
+		rate = rt->info[rc[i].rix].rateCode;
+		if (rc[i].flags & IEEE80211_RATECTL_FLAG_SP)
+			rate |= rt->info[rc[i].rix].shortPreamble;
+
+		rc[i].ratecode = rate;
+
+		ath_rc[i].rix = rc[i].rix;
+		ath_rc[i].tries = rc[i].tries;
+		ath_rc[i].flags = rc[i].flags;
+		ath_rc[i].ratecode = rc[i].ratecode;
+		ath_rc[i].tx_power_cap = rc[i].tx_power_cap;
+		ath_rc[i].max4msframelen = rc[i].max4msframelen;
+	}
+
+#if 0
 	for (i = 0; i < ATH_RC_NUM; i++) {
 		rc[i].flags = 0;
 		if (rc[i].tries == 0)
@@ -325,6 +346,7 @@
 		    "%s: i=%d, rate=0x%x, flags=0x%x, max4ms=%d\n",
 		    __func__, i, rate, rc[i].flags, rc[i].max4msframelen);
 	}
+#endif
 }
 
 /*

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Mon Sep  2 07:43:31 2013	(r256824)
@@ -65,9 +65,9 @@
 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 int	amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *);
 static void	amrr_tx_complete(const struct ieee80211vap *,
-    			const struct ieee80211_node *, int, 
-			void *, void *);
+    			const struct ieee80211_node *, struct ieee80211_rc_info *);
 static void	amrr_tx_update(const struct ieee80211vap *vap,
 			const struct ieee80211_node *, void *, void *, void *);
 static void	amrr_sysctlattach(struct ieee80211vap *,
@@ -85,6 +85,7 @@
 	.ir_node_init	= amrr_node_init,
 	.ir_node_deinit	= amrr_node_deinit,
 	.ir_rate	= amrr_rate,
+	.ir_rates	= amrr_rates,
 	.ir_tx_complete	= amrr_tx_complete,
 	.ir_tx_update	= amrr_tx_update,
 	.ir_setinterval	= amrr_setinterval,
@@ -303,6 +304,69 @@
 	return rix;
 }
 
+static void
+amrr_rates(struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info)
+{
+#define	RATE(_ix)	(rs->rs_rates[(_ix)] & IEEE80211_RATE_VAL)
+#define	MCS(_ix)	(rs->rs_rates[(_ix)] | IEEE80211_RATE_MCS)
+
+	struct ieee80211_amrr_node *amn = ni->ni_rctls;
+	struct ieee80211_amrr *amrr = amn->amn_amrr;
+	struct ieee80211_rc_series *rc = rc_info->iri_rc;
+	const struct ieee80211_rateset *rs = NULL;
+	const struct ieee80211_rate_table *rt = NULL;
+	int rix, code;
+
+	rs = ieee80211_ratectl_get_rateset(ni);
+	rt = ieee80211_get_ratetable(ni->ni_ic->ic_curchan);
+
+	rix = amrr_rate(ni, NULL, 0);
+
+	rc[0].flags = rc[1].flags = rc[2].flags = rc[3].flags = 0;
+
+	if (rs->rs_nrates > 0) {
+		code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix);
+		rc[0].rix = rt->rateCodeToIndex[code];
+
+		if (IEEE80211_RATECTL_HASCAP_MRR(ni->ni_vap)) {
+			rc[0].tries = 1;
+			rc[1].tries = 1;
+			rc[2].tries = 1;
+			rc[3].tries = 1;
+			if (--rix >= 0) {
+				code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix);
+				rc[1].rix = rt->rateCodeToIndex[code];
+			} else {
+				rc[1].rix = 0;
+			}
+			if (--rix >= 0) {
+				code = ieee80211_ratectl_node_is11n(ni)? MCS(rix) : RATE(rix);
+				rc[2].rix = rt->rateCodeToIndex[code];
+			} else {
+				rc[2].rix = 0;
+			}
+			if (rix > 0) {
+				/* NB: only do this if we didn't already do it above */
+				code = ieee80211_ratectl_node_is11n(ni)? MCS(0) : RATE(0);
+				rc[3].rix = rt->rateCodeToIndex[code];
+			} else {
+				rc[3].rix = 0;
+			}
+		} else {
+			rc[0].tries = IEEE80211_RATECTL_TXMAXTRY;
+
+			rc[1].tries = 0;
+			rc[2].tries = 0;
+			rc[3].tries = 0;
+			rc[1].rix = 0;
+			rc[2].rix = 0;
+			rc[3].rix = 0;
+		}
+	}
+#undef RATE
+#undef MCS
+}
+
 /*
  * Update statistics with tx complete status.  Ok is non-zero
  * if the packet is known to be ACK'd.  Retries has the number
@@ -310,22 +374,16 @@
  */
 static void
 amrr_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_amrr_node *amn = ni->ni_rctls;
-	int retries = *(int *)arg1;
-
-	/* XXX need to change arg2 to pointer of ieee80211_rc_info */
-	struct ieee80211_rc_info *rc_info = (struct ieee80211_rc_info*)arg2;
 
 	/* update per vap statistics */
 	ieee80211_ratectl_update_stat(vap, rc_info);
 
-	amn->amn_txcnt++;
-	if (ok)
-		amn->amn_success++;
-	amn->amn_retrycnt += retries;
+	amn->amn_txcnt += rc_info->iri_txcnt;
+	amn->amn_success += (rc_info->iri_txcnt - rc_info->failcnt);
+	amn->amn_retrycnt += rc_info->retrycnt;
 }
 
 /*

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Mon Sep  2 07:43:31 2013	(r256824)
@@ -131,9 +131,8 @@
 		struct ieee80211_rc_info *rc_info)
 {
 	struct ieee80211vap *vap = ni->ni_vap;
-	const struct ieee80211_rate_table * rt = NULL;
 	struct ieee80211_rc_series *rc = rc_info->iri_rc;
-	/* int shortPreamble = rc_info->ri_shortPreamble; */
+	const struct ieee80211_rate_table * rt = NULL;
 	uint8_t rate;
 	int i;
 
@@ -160,30 +159,27 @@
 
 		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
+		/* Only enable dual-stream, shortgi, 2040 if HT is set */
 
-		/*
-		 * Save this, used by the TX and completion code
-		 */
-		rc[i].ratecode = rate;
-
-		/* Only enable shortgi, 2040, dual-stream if HT is set */
 		if (IS_HT_RATE(rate)) {
 			rc[i].flags |= IEEE80211_RATECTL_FLAG_HT;
 
+			if (ieee80211_ratectl_hascap_cw40(vap, ni))
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_CW40;
+
+			if (ieee80211_ratectl_hascap_shortgi(vap, ni))
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_SGI;
 			/*
-			 * XXX TODO: LDPC
+			 * If we have STBC TX enabled and the receiver
+			 * can receive (at least) 1 stream STBC, AND it's
+			 * MCS 0-7, AND we have at least two chains enabled,
+			 * enable STBC.
 			 */
-
+			if (ieee80211_ratectl_hascap_stbc(vap, ni) &&
+				(rate & IEEE80211_RATE_VAL) < 8 &&
+				HT_RC_2_STREAMS(rate) == 1)
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_STBC;
+			
 			/*
 			 * Dual / Triple stream rate?
 			 */
@@ -191,6 +187,35 @@
 				rc[i].flags |= IEEE80211_RATECTL_FLAG_DS;
 			else if (HT_RC_2_STREAMS(rate) == 3)
 				rc[i].flags |= IEEE80211_RATECTL_FLAG_TS;
+
+			/*
+			 * Calculate the maximum 4ms frame length based
+			 * on the MCS rate, SGI and channel width flags.
+			 */
+			if (HT_RC_2_MCS(rate) < 32) {
+				int j;
+				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_FLAG_SGI)
+						j = MCS_HT20_SGI;
+					else
+						j = MCS_HT20;
+				}
+				rc[i].max4msframelen =
+				    max_4ms_framelen[j][HT_RC_2_MCS(rate)];
+			}
+		} else {
+			rc[i].max4msframelen = 0;
+
+			/*
+			 * Only enable short preamble for legacy rates
+			 */
+			if (rc_info->iri_flags & IEEE80211_RATECTL_INFO_SP)
+				rc[i].flags |= IEEE80211_RATECTL_FLAG_SP;
 		}
 
 		/*
@@ -200,28 +225,6 @@
 		 */
 		rc[i].tx_power_cap = ieee80211_get_node_txpower(ni);
 		
-		/*
-		 * Calculate the maximum 4ms frame length based
-		 * on the MCS rate, SGI and channel width flags.
-		 */
-		if ((rc[i].flags & IEEE80211_RATECTL_FLAG_HT) &&
-		    (HT_RC_2_MCS(rate) < 32)) {
-			int j;
-			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_FLAG_SGI)
-					j = MCS_HT20_SGI;
-				else
-					j = MCS_HT20;
-			}
-			rc[i].max4msframelen =
-			    max_4ms_framelen[j][HT_RC_2_MCS(rate)];
-		} else
-			rc[i].max4msframelen = 0;
 	}
 }
 

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Mon Sep  2 07:43:31 2013	(r256824)
@@ -44,6 +44,7 @@
 #define	IEEE80211_RATECTL_FALSE		0
 
 #define	IEEE80211_RATECTL_NUM		4
+#define	IEEE80211_RATECTL_TXMAXTRY	11
 
 #define	IEEE80211_RATECTL_FLAG_DS		0x01	/* dual-stream rate */
 #define	IEEE80211_RATECTL_FLAG_CW40		0x02	/* use HT40 */
@@ -52,6 +53,7 @@
 #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 */
+#define	IEEE80211_RATECTL_FLAG_SP		0x80	/* short preamble */
 
 /* Hardware CAPs offered to rate control algo */
 #define	IEEE80211_RATECTL_CAP_MRR			0x01	/* support MRR */
@@ -76,23 +78,28 @@
 
 struct ieee80211_rc_info {
 	struct ieee80211_rc_series iri_rc[IEEE80211_RATECTL_NUM];
-	int iri_framelen;
-	int iri_shortPreamble;
+	uint32_t iri_framelen;
+	uint16_t iri_flags;		/* for now, just records short preamble */
 
 	/* TX info */
-	int iri_success;	/* TX success or not */
-	int iri_okcnt;		/* TX ok with or without retry */
-	int iri_failcnt;	/* TX retry-fail count */
-	int iri_txcnt;		/* TX count */
-	int iri_retrycnt;	/* TX retry count */
-	int iri_shortretry;
-	int iri_longretry;
-	int iri_finaltsi;
-	int iri_txrate;		/* hw tx rate */
+	uint8_t iri_txcnt;		/* TX count */
+	uint8_t iri_okcnt;		/* TX ok with or without retry */
+	uint8_t iri_failcnt;	/* TX retry-fail count */
+	uint8_t iri_retrycnt;	/* TX retry count */
+	uint8_t iri_shortretry;
+	uint8_t iri_longretry;
+	uint8_t iri_finaltsi;
+	uint8_t iri_txrate;		/* hw tx rate */
 };
 
-/* net80211 ratectl statistics. 
- * per vap ratectl seeting must start with this common state
+/* ieee80211_rc_info flags */
+#define	IEEE80211_RATECTL_INFO_SP		0x01	/* short preamble */
+
+#define IEEE80211_RATECTL_INFO(_m) ((struct ieee80211_rc_info *)(_m)->m_ccb)
+
+/*
+ * net80211 ratectl statistics. 
+ * per vap ratectl seeting must start with this common state.
  */
 struct ieee80211_rc_stat {
 	uint32_t irs_capabilities;		/* hardware capabilities offered to rc */
@@ -126,8 +133,7 @@
 	int	(*ir_rate)(struct ieee80211_node *, void *, uint32_t);
 	void	(*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_info *);
 	void	(*ir_tx_complete)(const struct ieee80211vap *,
-	    			  const struct ieee80211_node *, int,
-	    			  void *, void *);
+	    			  const struct ieee80211_node *, struct ieee80211_rc_info *);
 	void	(*ir_tx_update)(const struct ieee80211vap *,
 	    			const struct ieee80211_node *,
 	    			void *, void *, void *);
@@ -184,9 +190,9 @@
 
 static void __inline
 ieee80211_ratectl_tx_complete(const struct ieee80211vap *vap,
-    const struct ieee80211_node *ni, int status, void *arg1, void *arg2)
+    const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info)
 {
-	vap->iv_rate->ir_tx_complete(vap, ni, status, arg1, arg2);
+	vap->iv_rate->ir_tx_complete(vap, ni, rc_info);
 }
 
 static void __inline
@@ -207,39 +213,40 @@
 }
 
 static int __inline
-ieee80211_ratectl_hascap_cw40(const struct ieee80211vap *vap,
-		const struct ieee80211_node *ni)
+ieee80211_ratectl_hascap_cw40(const struct ieee80211_node *ni)
 {
-	return IS_VAP_HT(vap) && (ni->ni_chw == 40);
+	return ni->ni_chw == 40;
 }
 
 static int __inline
-ieee80211_ratectl_hascap_shortgi(const struct ieee80211vap *vap,
-		const struct ieee80211_node *ni)
+ieee80211_ratectl_hascap_shortgi(const struct ieee80211_node *ni)
 {
-	if (IS_VAP_HT(vap))
-	{
-		if (ni->ni_chw == 40 &&
-				vap->iv_htcaps & IEEE80211_HTCAP_SHORTGI40 &&
-				ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40)
-			return IEEE80211_RATECTL_TRUE;
-
-		if (ni->ni_chw == 20 &&
-				vap->iv_htcaps & IEEE80211_HTCAP_SHORTGI20 &&
-				ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20)
-			return IEEE80211_RATECTL_TRUE;
-	}
+	struct ieee80211com *ic = ni->ni_ic;
+
+	if (ni->ni_chw == 40 &&
+		ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40 &&
+		ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40)
+		return IEEE80211_RATECTL_TRUE;
+
+	if (ni->ni_chw == 20 &&
+		ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20 &&
+		ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20)
+		return IEEE80211_RATECTL_TRUE;
+
 	return IEEE80211_RATECTL_FALSE;
 }
 
-
 static int __inline
-ieee80211_ratectl_hascap_stbc(const struct ieee80211vap *vap,
-		const struct ieee80211_node *ni)
+ieee80211_ratectl_hascap_stbc(const struct ieee80211_node *ni)
 {
-   return IS_VAP_HT(vap) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) &&
-			    (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM) &&
-			    IEEE80211_RATECTL_HASCAP_MULTXCHAIN(vap);
+	struct ieee80211com *ic = ni->ni_ic;
+
+	if (ic->ic_htcaps & IEEE80211_HTCAP_TXSTBC &&
+		ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM &&
+		IEEE80211_RATECTL_HASCAP_MULTXCHAIN(ni->ni_vap))
+		return IEEE80211_RATECTL_TRUE;
+	
+	return IEEE80211_RATECTL_FALSE;
 }
 
 static int __inline
@@ -272,4 +279,21 @@
 	irs->irs_longretry += rc_info->iri_longretry;
 }
 
+static void __inline
+ieee80211_ratectl_rc_info_set(struct ieee80211_rc_info *rc_info,
+		uint8_t txcnt, uint8_t failcnt, uint32_t framelen,
+		uint8_t shortretry, uint8_t longretry,
+		uint8_t finaltsi, uint8_t txrate)
+{
+	rc_info->iri_txcnt = txcnt;
+	rc_info->iri_failcnt = failcnt;
+	rc_info->iri_okcnt = txcnt - failcnt;
+	rc_info->iri_framelen = framelen;
+	rc_info->iri_shortretry = shortretry;
+	rc_info->iri_longretry = longretry;
+	rc_info->iri_retrycnt = shortretry + longretry;
+	rc_info->iri_finaltsi = finaltsi;
+	rc_info->iri_txrate = txrate;
+}
+
 #endif

Modified: soc2013/ccqin/head/sys/sys/mbuf.h
==============================================================================
--- soc2013/ccqin/head/sys/sys/mbuf.h	Mon Sep  2 06:41:54 2013	(r256823)
+++ soc2013/ccqin/head/sys/sys/mbuf.h	Mon Sep  2 07:43:31 2013	(r256824)
@@ -95,6 +95,7 @@
 	caddr_t		 mh_data;	/* location of data */
 	int		 mh_len;	/* amount of data in this mbuf */
 	int		 mh_flags;	/* flags; see below */
+	uint8_t		 mh_ccb[48];	/* common control block */
 	short		 mh_type;	/* type of data in this mbuf */
 	uint8_t          pad[M_HDR_PAD];/* word align                  */
 };
@@ -173,6 +174,7 @@
 #define	m_type		m_hdr.mh_type
 #define	m_flags		m_hdr.mh_flags
 #define	m_nextpkt	m_hdr.mh_nextpkt
+#define	m_ccb		m_hdr.mh_ccb
 #define	m_act		m_nextpkt
 #define	m_pkthdr	M_dat.MH.MH_pkthdr
 #define	m_ext		M_dat.MH.MH_dat.MH_ext


More information about the svn-soc-all mailing list