Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Apr 2008 16:09:58 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 139219 for review
Message-ID:  <200804021609.m32G9wtE016920@repoman.freebsd.org>

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

Change 139219 by sam@sam_ebb on 2008/04/02 16:09:12

	switch to regulat bitops and allocate 32 bits; using bit
	vector stuff seems like overkill

Affected files ...

.. //depot/projects/vap/sys/dev/ath/if_ath.c#56 edit
.. //depot/projects/vap/sys/dev/if_ndis/if_ndis.c#10 edit
.. //depot/projects/vap/sys/dev/mwl/if_mwl.c#3 edit
.. //depot/projects/vap/sys/dev/wi/if_wi.c#22 edit
.. //depot/projects/vap/sys/net80211/ieee80211.c#33 edit
.. //depot/projects/vap/sys/net80211/ieee80211_crypto.c#12 edit
.. //depot/projects/vap/sys/net80211/ieee80211_crypto.h#12 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ddb.c#10 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#50 edit
.. //depot/projects/vap/sys/net80211/ieee80211_var.h#36 edit

Differences ...

==== //depot/projects/vap/sys/dev/ath/if_ath.c#56 (text+ko) ====

@@ -524,22 +524,22 @@
 	 * Query the hal to figure out h/w crypto support.
 	 */
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_WEP))
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB))
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_AES_OCB);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_OCB;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM))
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_AES_CCM);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_CCM;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_CKIP))
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_CKIP);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_CKIP;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_TKIP)) {
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIP);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIP;
 		/*
 		 * Check if h/w does the MIC and/or whether the
 		 * separate key cache entries are required to
 		 * handle both tx+rx MIC keys.
 		 */
 		if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC))
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIPMIC);
+			ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC;
 		/*
 		 * If the h/w supports storing tx+rx MIC keys
 		 * in one cache slot automatically enable use.

==== //depot/projects/vap/sys/dev/if_ndis/if_ndis.c#10 (text+ko) ====

@@ -872,22 +872,22 @@
 		arg = NDIS_80211_WEPSTAT_ENC3ENABLED;
 		r = ndis_set_info(sc, OID_802_11_ENCRYPTION_STATUS, &arg, &i);
 		if (r == 0) {
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIP);
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_AES_CCM);
+			ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP
+					  |  IEEE80211_CRYPTO_TKIP
+					  |  IEEE80211_CRYPTO_AES_CCM;
 			goto got_crypto;
 		}
 		arg = NDIS_80211_WEPSTAT_ENC2ENABLED;
 		r = ndis_set_info(sc, OID_802_11_ENCRYPTION_STATUS, &arg, &i);
 		if (r == 0) {
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIP);
+			ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP
+					  |  IEEE80211_CRYPTO_TKIP;
 			goto got_crypto;
 		}
 		arg = NDIS_80211_WEPSTAT_ENC1ENABLED;
 		r = ndis_set_info(sc, OID_802_11_ENCRYPTION_STATUS, &arg, &i);
 		if (r == 0)
-			setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
+			ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP;
 got_crypto:
 		i = sizeof(arg);
 		r = ndis_get_info(sc, OID_802_11_POWER_MODE, &arg, &i);
@@ -2063,19 +2063,19 @@
 	len = sizeof(arg);
 
 	if (cipher == WPA_CSE_WEP40 || WPA_CSE_WEP104) {
-		if (!isset(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP))
+		if (!(ic->ic_cryptocaps & IEEE80211_CRYPTO_WEP))
 			return(ENOTSUP);
 		arg = NDIS_80211_WEPSTAT_ENC1ENABLED;
 	}
 
 	if (cipher == WPA_CSE_TKIP) {
-		if (!isset(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIP))
+		if (!(ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP))
 			return(ENOTSUP);
 		arg = NDIS_80211_WEPSTAT_ENC2ENABLED;
 	}
 
 	if (cipher == WPA_CSE_CCMP) {
-		if (!isset(ic->ic_cryptocaps, IEEE80211_CIPHER_AES_CCM))
+		if (!(ic->ic_cryptocaps & IEEE80211_CRYPTO_AES_CCM))
 			return(ENOTSUP);
 		arg = NDIS_80211_WEPSTAT_ENC3ENABLED;
 	}

==== //depot/projects/vap/sys/dev/mwl/if_mwl.c#3 (text+ko) ====

@@ -468,11 +468,11 @@
 	 * Mark h/w crypto support.
 	 * XXX no way to query h/w support.
 	 */
-	setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
-	setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_AES_CCM);
-	setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIP);
-	setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_TKIPMIC);
-
+	ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP
+			  |  IEEE80211_CRYPTO_AES_CCM
+			  |  IEEE80211_CRYPTO_TKIP
+			  |  IEEE80211_CRYPTO_TKIPMIC
+			  ;
 	/*
 	 * Transmit requires space in the packet for a special
 	 * format transmit record and optional padding between

==== //depot/projects/vap/sys/dev/wi/if_wi.c#22 (text+ko) ====

@@ -407,7 +407,7 @@
 	buflen = sizeof(val);
 	if (wi_read_rid(sc, WI_RID_WEP_AVAIL, &val, &buflen) == 0 &&
 	    val != htole16(0))
-		setbit(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP);
+		ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP;
 
 	/* Find supported rates. */
 	buflen = sizeof(ratebuf);
@@ -826,7 +826,7 @@
 		    ieee80211_chan2ieee(ic, bss->ni_chan));
 
 		/* Configure WEP. */
-		if (isset(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP))
+		if (ic->ic_cryptocaps & IEEE80211_CRYPTO_WEP)
 			wi_write_wep(sc, vap);
 		else
 			sc->sc_encryption = 0;
@@ -916,7 +916,7 @@
 		wi_write_val(sc, WI_RID_PROMISC, 0);
 
 		/* Configure WEP. */
-		if (isset(ic->ic_cryptocaps, IEEE80211_CIPHER_WEP))
+		if (ic->ic_cryptocaps & IEEE80211_CRYPTO_WEP)
 			wi_write_wep(sc, vap);
 		else
 			sc->sc_encryption = 0;

==== //depot/projects/vap/sys/net80211/ieee80211.c#33 (text+ko) ====

@@ -324,13 +324,7 @@
 	vap->iv_flags_ext = ic->ic_flags_ext;
 	vap->iv_flags_ven = ic->ic_flags_ven;
 	vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE;
-	vap->iv_cryptocaps[0] = ic->ic_cryptocaps[0];
-#if IEEE80211_CIPHER_MAX > 8
-	vap->iv_cryptocaps[1] = ic->ic_cryptocaps[1];
-#endif
-#if IEEE80211_CIPHER_MAX > 16
-#error	"too many crypto capability bits"
-#endif
+	vap->iv_cryptocaps = ic->ic_cryptocaps;
 	vap->iv_htcaps = ic->ic_htcaps;
 	vap->iv_opmode = opmode;
 	switch (opmode) {

==== //depot/projects/vap/sys/net80211/ieee80211_crypto.c#12 (text+ko) ====

@@ -309,7 +309,7 @@
 	 * If the hardware does not support the cipher then
 	 * fallback to a host-based implementation.
 	 */
-	if (!isset(vap->iv_cryptocaps, cipher)) {
+	if ((vap->iv_cryptocaps & (1<<cipher)) == 0) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
 		    "%s: no h/w support for cipher %s, falling back to s/w\n",
 		    __func__, cip->ic_name);
@@ -321,7 +321,7 @@
 	 * the cipher modules honor it.
 	 */
 	if (cipher == IEEE80211_CIPHER_TKIP &&
-	    !isset(vap->iv_cryptocaps, IEEE80211_CIPHER_TKIPMIC)) {
+	    (vap->iv_cryptocaps & IEEE80211_CRYPTO_TKIPMIC) == 0) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
 		    "%s: no h/w support for TKIP MIC, falling back to s/w\n",
 		    __func__);

==== //depot/projects/vap/sys/net80211/ieee80211_crypto.h#12 (text+ko) ====

@@ -94,6 +94,8 @@
 #define	IEEE80211_KEY_COMMON 		/* common flags passed in by apps */\
 	(IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
 
+#define	IEEE80211_KEYIX_NONE	((ieee80211_keyix) -1)
+
 /*
  * NB: these values are ordered carefully; there are lots of
  * of implications in any reordering.  Beware that 4 is used
@@ -111,7 +113,13 @@
 
 #define	IEEE80211_CIPHER_MAX		(IEEE80211_CIPHER_NONE+1)
 
-#define	IEEE80211_KEYIX_NONE	((ieee80211_keyix) -1)
+/* capability bits in ic_cryptocaps/iv_cryptocaps */
+#define	IEEE80211_CRYPTO_WEP		(1<<IEEE80211_CIPHER_WEP)
+#define	IEEE80211_CRYPTO_TKIP		(1<<IEEE80211_CIPHER_TKIP)
+#define	IEEE80211_CRYPTO_AES_OCB	(1<<IEEE80211_CIPHER_AES_OCB)
+#define	IEEE80211_CRYPTO_AES_CCM	(1<<IEEE80211_CIPHER_AES_CCM)
+#define	IEEE80211_CRYPTO_TKIPMIC	(1<<IEEE80211_CIPHER_TKIPMIC)
+#define	IEEE80211_CRYPTO_CKIP		(1<<IEEE80211_CIPHER_CKIP)
 
 #if defined(__KERNEL__) || defined(_KERNEL)
 

==== //depot/projects/vap/sys/net80211/ieee80211_ddb.c#10 (text+ko) ====

@@ -331,7 +331,7 @@
 	db_printf("\tflags_ven=%b\n", vap->iv_flags_ven, IEEE80211_FVEN_BITS);
 	db_printf("\tcaps=%b\n", vap->iv_caps, IEEE80211_C_BITS);
 	db_printf("\tcryptocaps=%b\n",
-	    vap->iv_cryptocaps[0], IEEE80211_C_CRYPTO_BITS);
+	    vap->iv_cryptocaps, IEEE80211_C_CRYPTO_BITS);
 	db_printf("\thtcaps=%b\n", vap->iv_htcaps, IEEE80211_C_HTCAP_BITS);
 
 	_db_show_stats(&vap->iv_stats);
@@ -490,7 +490,7 @@
 	db_printf("\tflags_ven=%b\n", ic->ic_flags_ven, IEEE80211_FVEN_BITS);
 	db_printf("\tcaps=%b\n", ic->ic_caps, IEEE80211_C_BITS);
 	db_printf("\tcryptocaps=%b\n",
-	    ic->ic_cryptocaps[0], IEEE80211_C_CRYPTO_BITS);
+	    ic->ic_cryptocaps, IEEE80211_C_CRYPTO_BITS);
 	db_printf("\thtcaps=%b\n", ic->ic_htcaps, IEEE80211_HTCAP_BITS);
 
 #if 0

==== //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#50 (text+ko) ====

@@ -701,13 +701,7 @@
 	if (dc == NULL)
 		return ENOMEM;
 	dc->dc_drivercaps = ic->ic_caps;
-#if IEEE80211_CIPHER_MAX <= 8
-	dc->dc_cryptocaps = ic->ic_cryptocaps[0];
-#elif IEEE80211_CIPHER_MAX <= 16
-	dc->dc_cryptocaps = (ic->ic_cryptocaps[0]<<8) | ic->ic_cryptocaps[1];
-#else
-#error	"too many crypto capability bits"
-#endif
+	dc->dc_cryptocaps = ic->ic_cryptocaps;
 	dc->dc_htcaps = ic->ic_htcaps;
 	ci = &dc->dc_chaninfo;
 	ic->ic_getradiocaps(ic, &ci->ic_nchans, ci->ic_chans);

==== //depot/projects/vap/sys/net80211/ieee80211_var.h#36 (text+ko) ====

@@ -122,7 +122,7 @@
 	uint32_t		ic_flags_ven;	/* vendor state flags */
 	uint32_t		ic_caps;	/* capabilities */
 	uint32_t		ic_htcaps;	/* HT capabilities */
-	uint8_t			ic_cryptocaps[1];/* crypto capabilities */
+	uint32_t		ic_cryptocaps;	/* crypto capabilities */
 	uint8_t			ic_modecaps[2];	/* set of mode capabilities */
 	uint8_t			ic_promisc;	/* vap's needing promisc mode */
 	uint8_t			ic_allmulti;	/* vap's needing all multicast*/
@@ -293,7 +293,7 @@
 	uint32_t		iv_flags_ven;	/* vendor state flags */
 	uint32_t		iv_caps;	/* capabilities */
 	uint32_t		iv_htcaps;	/* HT capabilities */
-	uint8_t			iv_cryptocaps[1];/* crypto capabilities */
+	uint32_t		iv_cryptocaps;	/* crypto capabilities */
 	enum ieee80211_opmode	iv_opmode;	/* operation mode */
 	enum ieee80211_state	iv_state;	/* state machine state */
 	void			(*iv_newstate_cb)(struct ieee80211vap *,



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