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

ccqin at FreeBSD.org ccqin at FreeBSD.org
Thu Aug 15 08:00:02 UTC 2013


Author: ccqin
Date: Thu Aug 15 08:00:01 2013
New Revision: 255966
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255966

Log:
  Fix some errors and move the ir_capabilities to irn_capabilities in per node rc state.
  * some minor errors fixed.
  * add struct ieee80211_ratectl_node. this is the common state that all per node rc
    state, i.e. ieee80211_[amrr|sample]_node, should contains it as the first field.
  * move ir_capabilities to irn_capabilities in ieee80211_ratectl_node. ieee80211_ratectl
    is readonly, so ir_capabilities can't be set. And, the capabilities is not a part of
    rc algo. It seems that it should be put in the per node rc state. Interface of
    ieee80211_ratectl_node_init() and its callers are updated. References to ir_capabilities
    are also adapted.
  

Modified:
  soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
  soc2013/ccqin/head/sys/net80211/ieee80211_amrr.h
  soc2013/ccqin/head/sys/net80211/ieee80211_node.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
  soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h
  soc2013/ccqin/head/sys/net80211/ieee80211_sta.c

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c	Thu Aug 15 08:00:01 2013	(r255966)
@@ -47,8 +47,8 @@
 
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ht.h>
-#include <net80211/ieee80211_amrr.h>
 #include <net80211/ieee80211_ratectl.h>
+#include <net80211/ieee80211_amrr.h>
 
 #define is_success(amn)	\
 	((amn)->amn_retrycnt < (amn)->amn_txcnt / 10)
@@ -60,7 +60,7 @@
 static void	amrr_setinterval(const struct ieee80211vap *, int);
 static void	amrr_init(struct ieee80211vap *);
 static void	amrr_deinit(struct ieee80211vap *);
-static void	amrr_node_init(struct ieee80211_node *);
+static void	amrr_node_init(struct ieee80211_node *, uint32_t);
 static void	amrr_node_deinit(struct ieee80211_node *);
 static int	amrr_update(struct ieee80211_amrr *,
     			struct ieee80211_amrr_node *, struct ieee80211_node *);
@@ -141,7 +141,7 @@
 }
 
 static void
-amrr_node_init(struct ieee80211_node *ni)
+amrr_node_init(struct ieee80211_node *ni, uint32_t capabilities)
 {
 	const struct ieee80211_rateset *rs = NULL;
 	struct ieee80211vap *vap = ni->ni_vap;
@@ -159,6 +159,10 @@
 		}
 	} else
 		amn = ni->ni_rctls;
+
+	struct ieee80211_ratectl_node *irn = IEEE80211_RATECTL_NODE(ni);
+	irn->irn_capabilities = capabilities;
+	
 	amn->amn_amrr = amrr;
 	amn->amn_success = 0;
 	amn->amn_recovery = 0;

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.h
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.h	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.h	Thu Aug 15 08:00:01 2013	(r255966)
@@ -20,6 +20,7 @@
 #ifndef _NET80211_IEEE80211_AMRR_H_
 #define _NET80211_IEEE80211_AMRR_H_
 
+#include <net80211/ieee80211_ratectl.h>
 /*-
  * Naive implementation of the Adaptive Multi Rate Retry algorithm:
  *
@@ -47,6 +48,7 @@
  * Rate control state for a given node.
  */
 struct ieee80211_amrr_node {
+	struct ieee80211_ratectl_node amn_node;
 	struct ieee80211_amrr *amn_amrr;/* backpointer */
 	int	amn_rix;		/* current rate index */
 	int	amn_ticks;		/* time of last update */

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_node.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_node.c	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_node.c	Thu Aug 15 08:00:01 2013	(r255966)
@@ -846,7 +846,8 @@
 	/* XXX QoS? Difficult given that WME config is specific to a master */
 
 	ieee80211_node_setuptxparms(ni);
-	ieee80211_ratectl_node_init(ni);
+	/* XXX TODO fill the cap field */
+	ieee80211_ratectl_node_init(ni, 0);
 
 	return ieee80211_sta_join1(ieee80211_ref_node(ni));
 }
@@ -1188,7 +1189,8 @@
 	IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni,
 	    "%s: inact_reload %u", __func__, ni->ni_inact_reload);
 
-	ieee80211_ratectl_node_init(ni);
+	/* XXX TODO fill the cap field */
+	ieee80211_ratectl_node_init(ni, 0);
 
 	return ni;
 }
@@ -1228,7 +1230,8 @@
 		/* XXX optimize away */
 		ieee80211_psq_init(&ni->ni_psq, "unknown");
 
-		ieee80211_ratectl_node_init(ni);
+		/* XXX TODO fill the cap field */
+		ieee80211_ratectl_node_init(ni, 0);
 	} else {
 		/* XXX msg */
 		vap->iv_stats.is_rx_nodealloc++;
@@ -1457,7 +1460,8 @@
 #endif
 		}
 		ieee80211_node_setuptxparms(ni);
-		ieee80211_ratectl_node_init(ni);
+		/* XXX TODO fill the cap field */
+		ieee80211_ratectl_node_init(ni, 0);
 		if (ic->ic_newassoc != NULL)
 			ic->ic_newassoc(ni, 1);
 		/* XXX not right for 802.1x/WPA */
@@ -1531,7 +1535,8 @@
 		ieee80211_setup_basic_htrates(ni,
 		    ni->ni_ies.htinfo_ie);
 		ieee80211_node_setuptxparms(ni);
-		ieee80211_ratectl_node_init(ni);
+		/* XXX TODO fill the cap field */
+		ieee80211_ratectl_node_init(ni, 0);
 	}
 }
 
@@ -1558,7 +1563,8 @@
 		if (ieee80211_iserp_rateset(&ni->ni_rates))
 			ni->ni_flags |= IEEE80211_NODE_ERP;
 		ieee80211_node_setuptxparms(ni);
-		ieee80211_ratectl_node_init(ni);
+		/* XXX TODO fill the cap field */
+		ieee80211_ratectl_node_init(ni, 0);
 		if (ic->ic_newassoc != NULL)
 			ic->ic_newassoc(ni, 1);
 		/* XXX not right for 802.1x/WPA */
@@ -2528,7 +2534,8 @@
 	);
 
 	ieee80211_node_setuptxparms(ni);
-	ieee80211_ratectl_node_init(ni);
+	/* XXX TODO fill the cap field */
+	ieee80211_ratectl_node_init(ni, 0);
 	/* give driver a chance to setup state like ni_txrate */
 	if (ic->ic_newassoc != NULL)
 		ic->ic_newassoc(ni, newassoc);

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.c	Thu Aug 15 08:00:01 2013	(r255966)
@@ -94,11 +94,10 @@
 }
 
 void
-ieee80211_ratectl_init(struct ieee80211vap *vap, uint32_t capabilities)
+ieee80211_ratectl_init(struct ieee80211vap *vap)
 {
 	if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE])
 		ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR);
-	vap->iv_rate.ir_capabilities = capabilities;
 	vap->iv_rate->ir_init(vap);
 }
 
@@ -121,11 +120,10 @@
 }
 
 void
-ieee80211_ratectl_complete_rcflags(const struct ieee80211_node *ni,
+ieee80211_ratectl_complete_rcflags(struct ieee80211_node *ni,
 		struct ieee80211_rc_info *rc_info)
 {
 	const struct ieee80211com *ic = ni->ni_ic;
-	const struct ieee80211vap *vap = ni->ni_vap;
 	const struct ieee80211_rate_table * rt = ic->ic_rt;
 	struct ieee80211_rc_series *rc = rc_info->ri_rc;
 	int shortPreamble = rc_info->ri_shortPreamble;
@@ -136,7 +134,7 @@
 	 * If enable rts/cts and is pre-802.11n, blank tries 1, 2, 3 
 	 */
 
-	if (! (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRRPROT))
+	if (! IEEE80211_RATECTL_HASCAP_MRRPROT(ni))
 	{
 		for (i = 1; i < IEEE80211_RATECTL_NUM; i++)
 		{

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h	Thu Aug 15 08:00:01 2013	(r255966)
@@ -60,11 +60,21 @@
 #define	IEEE80211_RATECTL_STBC_FLAG		0x20	/* enable STBC */
 #define	IEEE80211_RATECTL_TS_FLAG		0x40	/* triple-stream rate */
 
-/* Hardware CAPs chip offered to rate control code */
+/* 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)
@@ -83,7 +93,7 @@
 	uint16_t max4msframelen;
 };
 
-/*  */
+/* net80211 rate control infomation */
 struct ieee80211_rc_info {
 	struct ieee80211_rc_series ri_rc[IEEE80211_RATECTL_NUM];
 	int ri_framelen;
@@ -103,13 +113,11 @@
 
 struct ieee80211_ratectl {
 	const char *ir_name;
-	uint32_t ir_capabilities;		/* hardware capabilities offered to rc */
-
 	int	(*ir_attach)(const struct ieee80211vap *);
 	void	(*ir_detach)(const struct ieee80211vap *);
 	void	(*ir_init)(struct ieee80211vap *);
 	void	(*ir_deinit)(struct ieee80211vap *);
-	void	(*ir_node_init)(struct ieee80211_node *);
+	void	(*ir_node_init)(struct ieee80211_node *, uint32_t);
 	void	(*ir_node_deinit)(struct ieee80211_node *);
 	int	(*ir_rate)(struct ieee80211_node *, void *, uint32_t);
 	void	(*ir_rates)(struct ieee80211_node *, struct ieee80211_rc_info *);
@@ -122,12 +130,17 @@
 	void	(*ir_setinterval)(const struct ieee80211vap *, int);
 };
 
+/* per ratectl node must start with this common state */
+struct ieee80211_ratectl_node {
+	uint32_t irn_capabilities;		/* hardware capabilities offered to rc */
+};
+
 void	ieee80211_ratectl_register(int, const struct ieee80211_ratectl *);
 void	ieee80211_ratectl_unregister(int);
-void	ieee80211_ratectl_init(struct ieee80211vap *, uint32_t);
+void	ieee80211_ratectl_init(struct ieee80211vap *);
 void	ieee80211_ratectl_set(struct ieee80211vap *, int);
-void	ieee80211_ratectl_complete_rcflags(const struct ieee80211_node *, 
-		struct ieee80211_rc_info*)
+void	ieee80211_ratectl_complete_rcflags(struct ieee80211_node *, 
+		struct ieee80211_rc_info*);
 
 MALLOC_DECLARE(M_80211_RATECTL);
 
@@ -138,11 +151,11 @@
 }
 
 static void __inline
-ieee80211_ratectl_node_init(struct ieee80211_node *ni)
+ieee80211_ratectl_node_init(struct ieee80211_node *ni, uint32_t capabilities)
 {
 	const struct ieee80211vap *vap = ni->ni_vap;
 
-	vap->iv_rate->ir_node_init(ni);
+	vap->iv_rate->ir_node_init(ni, capabilities);
 }
 
 static void __inline
@@ -205,18 +218,19 @@
 ieee80211_ratectl_hascap_shortgi(const struct ieee80211vap *vap,
 		const struct ieee80211_node *ni)
 {
-	if (! IS_VAP_HT(vap))
-		return IEEE80211_RATECTL_FALSE;
-
-	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;
+	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;
+	}
+	return IEEE80211_RATECTL_FALSE;
 }
 
 
@@ -226,7 +240,7 @@
 {
    return IS_VAP_HT(vap) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) &&
 			    (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC_1STREAM) &&
-			    (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MULTXCHAIN);
+			    IEEE80211_RATECTL_HASCAP_MULTXCHAIN(ni);
 }
 
 #endif

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c	Thu Aug 15 08:00:01 2013	(r255966)
@@ -1,6 +1,7 @@
 /* $FreeBSD: head/sys/dev/ath/ath_rate/sample/sample.c 248573 2013-02-27 04:33:06Z adrian $*/
 
 /*-
+ * Copyright (c) 2005 John Bicket
  * Copyright (c) 2013 Chenchong Qin <ccqin at FreeBSD.org>
  * All rights reserved.
  *
@@ -138,7 +139,7 @@
 };
 
 static void
-sample_node_init(struct ieee80211_node *ni)
+sample_node_init(struct ieee80211_node *ni, uint32_t capabilities)
 {
 #define	RATE(_ix)	(ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
 #define	DOT11RATE(_ix)	(rt->info[(_ix)].dot11Rate & IEEE80211_RATE_VAL)
@@ -160,6 +161,10 @@
 		}
 	} else
 		san = ni->ni_rctls;
+
+	struct ieee80211_ratectl_node *irn = IEEE80211_RATECTL_NODE(ni);
+	irn->irn_capabilities = capabilities;
+	
 	san->san_sample = sample;
 
 	KASSERT(rt != NULL, ("no rate table, mode %u", curmode));
@@ -628,9 +633,9 @@
 		goto done;
 	}
 
-	if (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRR)
+	if (IEEE80211_RATECTL_HASCAP_MRR(ni))
 		mrr = 1;
-	if (!(vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRRPROT))
+	if (! IEEE80211_RATECTL_HASCAP_MRRPROT(ni))
 		mrr = 0;
 
 	best_rix = pick_best_rate(ni, rt, size_bin, !mrr);
@@ -942,12 +947,12 @@
 		return;
 	}
 	
-	if (vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRR)
+	if (IEEE80211_RATECTL_HASCAP_MRR(ni))
 		mrr = 1;
 	/* XXX check HT protmode too */
-	if (mrr && !(vap->iv_rate->ir_capabilities & IEEE80211_RATECTL_CAP_MRRPROT))
+	if (mrr && !IEEE80211_RATECTL_HASCAP_MRRPROT(ni))
 		mrr = 0;
-
+	
 	if (!mrr || rc_info->ri_finaltsi == 0) {
 		if (!IS_RATE_DEFINED(san, final_rix)) {
 			return;

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h	Thu Aug 15 08:00:01 2013	(r255966)
@@ -1,6 +1,7 @@
 /* $FreeBSD: head/sys/dev/ath/ath_rate/sample/sample.h 240382 2012-08-15 07:10:10Z adrian $*/
 
 /*-
+ * Copyright (c) 2005 John Bicket
  * Copyright (c) 2013 Chenchong Qin <ccqin at FreeBSD.org>
  * All rights reserved.
  *
@@ -39,6 +40,8 @@
 #ifndef _NET80211_IEEE80211_RATECTL_SAMPLE_H_
 #define _NET80211_IEEE80211_RATECTL_SAMPLE_H_
 
+#include <net80211/ieee80211_ratectl.h>
+
 /*
  * for now, we track performance for three different packet
  * size buckets
@@ -82,6 +85,7 @@
  */
 /* XXX change naming conversion? */
 struct ieee80211_sample_node {
+	struct ieee80211_ratectl_node san_node;	/* common state */
 	struct ieee80211_sample *san_sample;/* backpointer */
 	int static_rix;			/* rate index of fixed tx rate */
 	uint64_t ratemask;		/* bit mask of valid rate indices */

Modified: soc2013/ccqin/head/sys/net80211/ieee80211_sta.c
==============================================================================
--- soc2013/ccqin/head/sys/net80211/ieee80211_sta.c	Thu Aug 15 07:54:31 2013	(r255965)
+++ soc2013/ccqin/head/sys/net80211/ieee80211_sta.c	Thu Aug 15 08:00:01 2013	(r255966)
@@ -1636,7 +1636,8 @@
 			     IEEE80211_F_JOIN | IEEE80211_F_DOBRS);
 			ieee80211_setup_basic_htrates(ni, htinfo);
 			ieee80211_node_setuptxparms(ni);
-			ieee80211_ratectl_node_init(ni);
+			/* XXX TODO fill the cap field */
+			ieee80211_ratectl_node_init(ni, 0);
 		} else {
 #ifdef IEEE80211_SUPPORT_SUPERG
 			if (IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_ATH))


More information about the svn-soc-all mailing list