Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 May 2005 04:36:01 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 76729 for review
Message-ID:  <200505090436.j494a1pI026777@repoman.freebsd.org>

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

Change 76729 by sam@sam_ebb on 2005/05/09 04:35:25

	order channel list so selection gives priority to preferred channels
	(needs more work)

Affected files ...

.. //depot/projects/vap/sys/net80211/ieee80211_scan_ap.c#2 edit

Differences ...

==== //depot/projects/vap/sys/net80211/ieee80211_scan_ap.c#2 (text+ko) ====

@@ -112,10 +112,10 @@
 	return 0;
 }
 
-static int
+static struct ieee80211_channel *
 find11gchannel(struct ieee80211com *ic, int i, int freq)
 {
-	const struct ieee80211_channel *c;
+	struct ieee80211_channel *c;
 	int j;
 
 	/*
@@ -126,72 +126,169 @@
 	for (j = i+1; j < ic->ic_nchans; j++) {
 		c = &ic->ic_channels[j];
 		if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
-			return 1;
+			return c;
 	}
 	for (j = 0; j < i; j++) {
 		c = &ic->ic_channels[j];
 		if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
-			return 1;
+			return c;
+	}
+	return NULL;
+}
+
+static void
+add_channels(struct ieee80211com *ic,
+	struct ieee80211_scan_state *ss,
+	enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
+{
+#define	N(a)	(sizeof(a) / sizeof(a[0]))
+	static const u_int chanflags[] = {
+		IEEE80211_CHAN_B,	/* IEEE80211_MODE_AUTO */
+		IEEE80211_CHAN_A,	/* IEEE80211_MODE_11A */
+		IEEE80211_CHAN_B,	/* IEEE80211_MODE_11B */
+		IEEE80211_CHAN_PUREG,	/* IEEE80211_MODE_11G */
+		IEEE80211_CHAN_FHSS,	/* IEEE80211_MODE_FH */
+		IEEE80211_CHAN_108A,	/* IEEE80211_MODE_TURBO_A */
+		IEEE80211_CHAN_108G,	/* IEEE80211_MODE_TURBO_G */
+	};
+	struct ieee80211_channel *c, *cg;
+	u_int modeflags;
+	int i;
+
+	KASSERT(mode < N(chanflags), ("Unexpected mode %u", mode));
+	modeflags = chanflags[mode];
+	for (i = 0; i < nfreq; i++) {
+		c = ieee80211_find_channel(ic, freq[i], modeflags);
+		if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
+			continue;
+		if (mode == IEEE80211_MODE_AUTO) {
+			/*
+			 * XXX special-case 11b/g channels so we select
+			 *     the g channel if both are present.
+			 */
+			if (IEEE80211_IS_CHAN_B(c) &&
+			    (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
+				c = cg;
+		}
+		if (ss->ss_last >= IEEE80211_SCAN_MAX)
+			break;
+		ss->ss_chans[ss->ss_last++] = c;
 	}
-	return 0;
+#undef N
 }
 
+static const u_int16_t rcl1[] =		/* 8 FCC channel: 52, 56, 60, 64, 36, 40, 44, 48 */
+{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
+static const u_int16_t rcl2[] =		/* 4 MKK channels: 34, 38, 42, 46 */
+{ 5170, 5190, 5210, 5230 };
+static const u_int16_t rcl3[] =		/* 2.4Ghz ch: 1,6,11,7,13 */
+{ 2412, 2437, 2462, 2442, 2472 };
+static const u_int16_t rcl4[] =		/* 5 FCC channel: 149, 153, 161, 165 */
+{ 5745, 5765, 5785, 5805, 5825 };
+static const u_int16_t rcl7[] =		/* 11 ETSI channel: 100,104,108,112,116,120,124,128,132,136,140 */
+{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
+static const u_int16_t rcl8[] =		/* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
+{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
+static const u_int16_t rcl9[] =		/* 2.4Ghz ch: 14 */
+{ 2484 };
+static const u_int16_t rcl10[] =	/* Added Korean channels 2312-2372 */
+{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
+static const u_int16_t rcl11[] =	/* Added Japan channels in 4.9/5.0 spectrum */
+{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
+#ifdef ATH_TURBO_SCAN
+static const u_int16_t rcl5[] =		/* 3 turbo channels */
+{ 5210, 5250, 5290 };
+static const u_int16_t rcl6[] =		/* 2 turbo channels */
+{ 5760, 5800 };
+static const u_int16_t rcl6x[] =	/* 4 FCC3 turbo channels */
+{ 5540, 5580, 5620, 5660 };
+static const u_int16_t rcl12[] =	/* 2.4Ghz Turbo channel 6 */
+{ 2437 };
+#endif /* ATH_TURBO_SCAN */
+
+static const struct {
+	u_int16_t	mode;
+	u_int16_t	count;
+	const u_int16_t	*list;
+} scanTable[] = {
+#define	X(a)	.count = sizeof(a)/sizeof(a[0]), .list = a
+	{ IEEE80211_MODE_11B,   	X(rcl3) },
+	{ IEEE80211_MODE_11A,   	X(rcl1) },
+	{ IEEE80211_MODE_11A,   	X(rcl2) },
+	{ IEEE80211_MODE_11B,   	X(rcl8) },
+	{ IEEE80211_MODE_11B,   	X(rcl9) },
+	{ IEEE80211_MODE_11A,   	X(rcl4) },
+#ifdef ATH_TURBO_SCAN
+	{ IEEE80211_MODE_TURBO_A,	X(rcl5) },
+	{ IEEE80211_MODE_TURBO_A,	X(rcl6) },
+	{ IEEE80211_MODE_TURBO_A,	X(rcl6x) },
+#endif /* ATH_TURBO_SCAN */
+	{ IEEE80211_MODE_11A,		X(rcl7) },
+	{ IEEE80211_MODE_11B,		X(rcl10) },
+	{ IEEE80211_MODE_11A,		X(rcl11) },
+#ifdef ATH_TURBO_SCAN
+	{ IEEE80211_MODE_TURBO_G,	X(rcl12) },
+#endif /* ATH_TURBO_SCAN */
+#undef X
+};
+
 /*
  * Start an ap scan.
  */
 static int
 ap_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
 {
+#define	N(a)	(sizeof(a) / sizeof(a[0]))
 	struct ieee80211com *ic = vap->iv_ic;
-	struct ieee80211_channel *c;
+	enum ieee80211_phymode mode;
 	int i;
 
 	ss->ss_last = 0;
-	if (vap->iv_des_mode == IEEE80211_MODE_AUTO) {
-		for (i = 0; i < ic->ic_nchans; i++) {
-			c = &ic->ic_channels[i];
-			if (IEEE80211_IS_CHAN_TURBO(c)) {
-#ifdef IEEE80211_F_XR
-				/* XR is not supported on turbo channels */
-				if (vap->iv_flags & IEEE80211_F_XR)
-					continue;
-#endif
-				/* dynamic channels are scanned in base mode */
-				if (!IEEE80211_IS_CHAN_ST(c))
-					continue;
-			} else {
+	/*
+	 * Use the table of ordered channels to construct the list
+	 * of channels for scanning.  Any channels in the ordered
+	 * list not in the master list will be discarded.
+	 * XXX add channels not listed in fixed tables
+	 */
+	for (i = 0; i < N(scanTable); i++) {
+		mode = scanTable[i].mode;
+		if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
+			/*
+			 * If a desired mode was specified, scan only 
+			 * channels that satisfy that constraint.
+			 */
+			if (vap->iv_des_mode != mode) {
 				/*
-				 * Use any 11g channel instead of 11b one.
+				 * The scan table marks 2.4Ghz channels as b
+				 * so if the desired mode is 11g, then use
+				 * the 11b channel list but upgrade the mode.
 				 */
-				if (IEEE80211_IS_CHAN_B(c) &&
-				    find11gchannel(ic, i, c->ic_freq))
+				if (vap->iv_des_mode != IEEE80211_MODE_11G ||
+				    mode != IEEE80211_MODE_11B)
 					continue;
+				mode = IEEE80211_MODE_11G;	/* upgrade */
 			}
-			if (ss->ss_last >= IEEE80211_SCAN_MAX)
-				break;
-			ss->ss_chans[ss->ss_last++] = c;
+		} else {
+			/*
+			 * This lets ieee80211_scan_add_channels
+			 * upgrade an 11b channel to 11g if available.
+			 */
+			if (mode == IEEE80211_MODE_11B)
+				mode = IEEE80211_MODE_AUTO;
 		}
-	} else {
-		static const u_int chanflags[] = {
-			0,			/* IEEE80211_MODE_AUTO */
-			IEEE80211_CHAN_A,	/* IEEE80211_MODE_11A */
-			IEEE80211_CHAN_B,	/* IEEE80211_MODE_11B */
-			IEEE80211_CHAN_PUREG,	/* IEEE80211_MODE_11G */
-			IEEE80211_CHAN_FHSS,	/* IEEE80211_MODE_FH */
-			IEEE80211_CHAN_108A,	/* IEEE80211_MODE_TURBO_A */
-			IEEE80211_CHAN_108G,	/* IEEE80211_MODE_TURBO_G */
-		};
-		u_int modeflags;
-
-		modeflags = chanflags[vap->iv_des_mode];
-		for (i = 0; i < ic->ic_nchans; i++) {
-			c = &ic->ic_channels[i];
-			if ((c->ic_flags & modeflags) != modeflags)
-				continue;
-			if (ss->ss_last >= IEEE80211_SCAN_MAX)
-				break;
-			ss->ss_chans[ss->ss_last++] = c;
-		}
+#ifdef IEEE80211_F_XR
+		/* XR does not operate on turbo channels */
+		if ((vap->iv_flags & IEEE80211_F_XR) &&
+		    (mode == IEEE80211_MODE_TURBO_A ||
+		     mode == IEEE80211_MODE_TURBO_G))
+			continue;
+#endif
+		/*
+		 * Add the list of the channels; any that are not
+		 * in the master channel list will be discarded.
+		 */
+		add_channels(ic, ss, mode,
+			scanTable[i].list, scanTable[i].count);
 	}
 	ss->ss_next = 0;
 	/* XXX tunables */
@@ -210,6 +307,7 @@
 #endif /* IEEE80211_DEBUG */
 
 	return ap_restart(ss, vap);
+#undef N
 }
 
 /*



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