From owner-p4-projects@FreeBSD.ORG Wed Apr 2 16:09:59 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 563AF106566B; Wed, 2 Apr 2008 16:09:59 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0ABA61065672 for ; Wed, 2 Apr 2008 16:09:59 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id EAC768FC26 for ; Wed, 2 Apr 2008 16:09:58 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m32G9wqh016922 for ; Wed, 2 Apr 2008 16:09:58 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m32G9wtE016920 for perforce@freebsd.org; Wed, 2 Apr 2008 16:09:58 GMT (envelope-from sam@freebsd.org) Date: Wed, 2 Apr 2008 16:09:58 GMT Message-Id: <200804021609.m32G9wtE016920@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 139219 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Apr 2008 16:10:00 -0000 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<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<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 *,