Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Aug 2008 16:52:20 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 148630 for review
Message-ID:  <200808271652.m7RGqKD9020691@repoman.freebsd.org>

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

Change 148630 by sam@sam_ebb on 2008/08/27 16:51:26

	Add current transmit parameters for fixed rate handling so
	drivers don't duplicate this.  These are setup according to
	the role of the node--the bss node for ap and adhoc modes
	need to use parameters that are the least common denomimator
	of all nodes in the bss; otherwise we are setting up params
	for a station joining a bss and we select those according to
	the capabilities of the station.
	
	This stuff needs more work as we do extra work due to having
	setup in common code paths shared by nodes using both roles.

Affected files ...

.. //depot/projects/vap/sys/net80211/ieee80211_node.c#42 edit
.. //depot/projects/vap/sys/net80211/ieee80211_node.h#21 edit

Differences ...

==== //depot/projects/vap/sys/net80211/ieee80211_node.c#42 (text+ko) ====

@@ -202,6 +202,29 @@
 }
 
 /*
+ * Fix tx parameters for a node according to ``association state''.
+ */
+static void
+node_setuptxparms(struct ieee80211_node *ni)
+{
+	struct ieee80211vap *vap = ni->ni_vap;
+
+	if (ni->ni_flags & IEEE80211_NODE_HT) {
+		if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan))
+			ni->ni_txparms = &vap->iv_txparms[IEEE80211_MODE_11NA];
+		else
+			ni->ni_txparms = &vap->iv_txparms[IEEE80211_MODE_11NG];
+	} else {				/* legacy rate handling */
+		if (IEEE80211_IS_CHAN_A(ni->ni_chan))
+			ni->ni_txparms = &vap->iv_txparms[IEEE80211_MODE_11A];
+		else if (ni->ni_flags & IEEE80211_NODE_ERP)
+			ni->ni_txparms = &vap->iv_txparms[IEEE80211_MODE_11G];
+		else
+			ni->ni_txparms = &vap->iv_txparms[IEEE80211_MODE_11B];
+	}
+}
+
+/*
  * Set/change the channel.  The rate set is also updated as
  * to insure a consistent view by drivers.
  * XXX should be private but hostap needs it to deal with CSA
@@ -211,10 +234,13 @@
 	struct ieee80211_channel *chan)
 {
 	struct ieee80211com *ic = ni->ni_ic;
+	struct ieee80211vap *vap = ni->ni_vap;
+	enum ieee80211_phymode mode;
 
 	KASSERT(chan != IEEE80211_CHAN_ANYC, ("no channel"));
 
 	ni->ni_chan = chan;
+	mode = ieee80211_chan2mode(chan);
 	if (IEEE80211_IS_CHAN_HT(chan)) {
 		/*
 		 * XXX Gotta be careful here; the rate set returned by
@@ -224,7 +250,22 @@
 		 * HT rate set in ni_htrates.
 		 */
 		ni->ni_htrates = *ieee80211_get_suphtrates(ic, chan);
+		/*
+		 * Setup bss tx parameters based on operating mode.  We
+		 * use legacy rates when operating in a mixed HT+non-HT bss
+		 * and non-ERP rates in 11g for mixed ERP+non-ERP bss.
+		 */
+		if (mode == IEEE80211_MODE_11NA &&
+		    (vap->iv_flags_ext & IEEE80211_FEXT_PUREN) == 0)
+			mode = IEEE80211_MODE_11A;
+		else if (mode == IEEE80211_MODE_11NG &&
+		    (vap->iv_flags_ext & IEEE80211_FEXT_PUREN) == 0)
+			mode = IEEE80211_MODE_11G;
+		if (mode == IEEE80211_MODE_11G &&
+		    (vap->iv_flags & IEEE80211_F_PUREG) == 0)
+			mode = IEEE80211_MODE_11B;
 	}
+	ni->ni_txparms = &vap->iv_txparms[mode];
 	ni->ni_rates = *ieee80211_get_suprates(ic, chan);
 }
 
@@ -541,8 +582,8 @@
 
 /*
  * Check if the current channel needs to change based on whether
- * any vap's are using HT20/HT40.  This is used sync the state of
- * ic_curchan after a channel width change on a running vap.
+ * any vap's are using HT20/HT40.  This is used to sync the state
+ * of ic_curchan after a channel width change on a running vap.
  */
 void
 ieee80211_sync_curchan(struct ieee80211com *ic)
@@ -965,6 +1006,7 @@
 	ni->ni_chan = IEEE80211_CHAN_ANYC;
 	ni->ni_authmode = IEEE80211_AUTH_OPEN;
 	ni->ni_txpower = ic->ic_txpowlimit;	/* max power */
+	ni->ni_txparms = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
 	ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, IEEE80211_KEYIX_NONE);
 	ni->ni_avgrssi = IEEE80211_RSSI_DUMMY_MARKER;
 	ni->ni_inact_reload = nt->nt_inact_init;
@@ -999,6 +1041,8 @@
 
 	ni = ic->ic_node_alloc(vap, macaddr);
 	if (ni != NULL) {
+		struct ieee80211_node *bss = vap->iv_bss;
+
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
 			"%s %p<%s>\n", __func__, ni, ether_sprintf(macaddr));
 
@@ -1007,12 +1051,13 @@
 		ni->ni_vap = vap;
 
 		IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);
-		IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid);
+		IEEE80211_ADDR_COPY(ni->ni_bssid, bss->ni_bssid);
 		ieee80211_node_initref(ni);		/* mark referenced */
 		/* NB: required by ieee80211_fix_rate */
-		ieee80211_node_set_chan(ni, vap->iv_bss->ni_chan);
+		ieee80211_node_set_chan(ni, bss->ni_chan);
 		ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey,
 			IEEE80211_KEYIX_NONE);
+		ni->ni_txpower = bss->ni_txpower;
 		/* XXX optimize away */
 		IEEE80211_NODE_SAVEQ_INIT(ni, "unknown");
 		IEEE80211_NODE_WDSQ_INIT(ni, "unknown");
@@ -1032,13 +1077,13 @@
 
 	ni = ieee80211_alloc_node(&ic->ic_sta, vap, macaddr);
 	if (ni != NULL) {
+		struct ieee80211_node *bss = vap->iv_bss;
 		/*
 		 * Inherit from iv_bss.
 		 */
-		ni->ni_authmode = vap->iv_bss->ni_authmode;
-		ni->ni_vlan = vap->iv_bss->ni_vlan;	/* XXX?? */
-		IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid);
-		ieee80211_node_set_chan(ni, vap->iv_bss->ni_chan);
+		copy_bss(ni, bss);
+		IEEE80211_ADDR_COPY(ni->ni_bssid, bss->ni_bssid);
+		ieee80211_node_set_chan(ni, bss->ni_chan);
 	}
 	return ni;
 }
@@ -1065,8 +1110,7 @@
 		/*
 		 * Inherit any manually configured settings.
 		 */
-		ni->ni_authmode = vap->iv_bss->ni_authmode;
-		ni->ni_vlan = vap->iv_bss->ni_vlan;
+		copy_bss(ni, vap->iv_bss);
 		ieee80211_node_set_chan(ni, chan);
 		/* NB: propagate ssid so available to WPA supplicant */
 		ni->ni_esslen = vap->iv_des_ssid[0].len;
@@ -1238,6 +1282,7 @@
 			if (vap->iv_flags & IEEE80211_F_FF)
 				ni->ni_flags |= IEEE80211_NODE_FF;
 		}
+		node_setuptxparms(ni);
 		if (ic->ic_newassoc != NULL)
 			ic->ic_newassoc(ni, 1);
 		/* XXX not right for 802.1x/WPA */
@@ -1295,6 +1340,7 @@
 		struct ieee80211com *ic = vap->iv_ic;
 
 		ieee80211_init_neighbor(ni, wh, sp);
+		node_setuptxparms(ni);
 		if (ic->ic_newassoc != NULL)
 			ic->ic_newassoc(ni, 1);
 		/* XXX not right for 802.1x/WPA */
@@ -2235,6 +2281,7 @@
 		", turbo" : ""
 	);
 
+	node_setuptxparms(ni);
 	/* give driver a chance to setup state like ni_txrate */
 	if (ic->ic_newassoc != NULL)
 		ic->ic_newassoc(ni, newassoc);

==== //depot/projects/vap/sys/net80211/ieee80211_node.h#21 (text+ko) ====

@@ -126,6 +126,7 @@
 	uint16_t		ni_ath_defkeyix;/* Atheros def key index */
 	uint16_t		ni_associd;	/* assoc response */
 	uint16_t		ni_txpower;	/* current transmit power */
+	const struct ieee80211_txparam *ni_txparms;
 	uint16_t		ni_vlan;	/* vlan tag */
 	uint32_t		ni_jointime;	/* time of join (secs) */
 	uint32_t		*ni_challenge;	/* shared-key challenge */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808271652.m7RGqKD9020691>