PERFORCE change 137845 for review

Sam Leffler sam at FreeBSD.org
Sun Mar 16 17:39:36 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137845

Change 137845 by sam at sam_ebb on 2008/03/16 17:39:06

	simplify ieee80211_plcp2rate; it's not use doesn't warrant
	the extra code to validate the plcp parameter

Affected files ...

.. //depot/projects/vap/sys/net80211/ieee80211_phy.c#5 edit

Differences ...

==== //depot/projects/vap/sys/net80211/ieee80211_phy.c#5 (text+ko) ====

@@ -300,27 +300,19 @@
 }
 
 /*
- * Covert PLCP signal/rate field to 802.11 rate (.5Mbits/s)
+ * Convert PLCP signal/rate field to 802.11 rate (.5Mbits/s)
+ *
+ * Note we do no parameter checking; this routine is mainly
+ * used to derive an 802.11 rate for constructing radiotap
+ * header data for rx frames.
+ *
+ * XXX might be a candidate for inline
  */
 uint8_t
 ieee80211_plcp2rate(uint8_t plcp, int ofdm)
 {
-	if (!ofdm) {
-		switch (plcp) {
-		/* IEEE Std 802.11b-1999 page 15, subclause 18.2.3.3 */
-		case 0x0a:
-		case 0x14:
-		case 0x37:
-		case 0x6e:
-		/* IEEE Std 802.11g-2003 page 19, subclause 19.3.2.1 */
-		case 0xdc:
-			return plcp / 5;
-		}
-	} else {
-#define _OFDM_PLCP2RATE_MAX	16
-
-		/* IEEE Std 802.11a-1999 page 14, subclause 17.3.4.1 */
-		static const uint8_t ofdm_plcp2rate[_OFDM_PLCP2RATE_MAX] = {
+	if (ofdm) {
+		static const uint8_t ofdm_plcp2rate[16] = {
 			[0xb]	= 12,
 			[0xf]	= 18,
 			[0xa]	= 24,
@@ -330,12 +322,17 @@
 			[0x8]	= 96,
 			[0xc]	= 108
 		};
-		if (plcp < _OFDM_PLCP2RATE_MAX)
-			return ofdm_plcp2rate[plcp];
-
-#undef _OFDM_PLCP2RATE_MAX
+		return ofdm_plcp2rate[plcp & 0xf];
+	} else {
+		static const uint8_t cck_plcp2rate[16] = {
+			[0xa]	= 2,	/* 0x0a */
+			[0x4]	= 4,	/* 0x14 */
+			[0x7]	= 11,	/* 0x37 */
+			[0xe]	= 22,	/* 0x6e */
+			[0xc]	= 44,	/* 0xdc , actually PBCC */
+		};
+		return cck_plcp2rate[plcp & 0xf];
 	}
-	return 0;
 }
 
 /*


More information about the p4-projects mailing list