summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2007-03-11 22:37:32 +0000
committersam <sam@FreeBSD.org>2007-03-11 22:37:32 +0000
commit35a6c17cb8cd2d9c814d2cff98b00a26fae9b9e6 (patch)
tree7601409f400bd2d60403c79b2eb23f78587868c2
parentc77fb6f45fa6f27fca46baa53d66769e9246d705 (diff)
downloadFreeBSD-src-35a6c17cb8cd2d9c814d2cff98b00a26fae9b9e6.zip
FreeBSD-src-35a6c17cb8cd2d9c814d2cff98b00a26fae9b9e6.tar.gz
change ic_modecaps to a bit vector and use setbit, et. al.
-rw-r--r--sys/dev/if_ndis/if_ndis.c35
-rw-r--r--sys/dev/iwi/if_iwi.c8
-rw-r--r--sys/net80211/ieee80211.c28
-rw-r--r--sys/net80211/ieee80211_ioctl.c2
-rw-r--r--sys/net80211/ieee80211_var.h2
5 files changed, 35 insertions, 40 deletions
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 52c0f6a..efa4e41 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -687,7 +687,7 @@ ndis_attach(dev)
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_caps = IEEE80211_C_IBSS;
ic->ic_state = IEEE80211_S_ASSOC;
- ic->ic_modecaps = (1<<IEEE80211_MODE_AUTO);
+ setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
len = 0;
r = ndis_get_info(sc, OID_802_11_NETWORK_TYPES_SUPPORTED,
NULL, &len);
@@ -705,13 +705,13 @@ ndis_attach(dev)
switch (ntl->ntl_type[i]) {
case NDIS_80211_NETTYPE_11FH:
case NDIS_80211_NETTYPE_11DS:
- ic->ic_modecaps |= (1<<IEEE80211_MODE_11B);
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11B);
break;
case NDIS_80211_NETTYPE_11OFDM5:
- ic->ic_modecaps |= (1<<IEEE80211_MODE_11A);
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11A);
break;
case NDIS_80211_NETTYPE_11OFDM24:
- ic->ic_modecaps |= (1<<IEEE80211_MODE_11G);
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11G);
break;
default:
break;
@@ -750,11 +750,11 @@ nonettypes:
ic->ic_sup_rates[x].rs_nrates++
ic->ic_curmode = IEEE80211_MODE_AUTO;
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11A))
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11A))
ic->ic_sup_rates[IEEE80211_MODE_11A].rs_nrates = 0;
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11B))
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11B))
ic->ic_sup_rates[IEEE80211_MODE_11B].rs_nrates = 0;
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11G))
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11G))
ic->ic_sup_rates[IEEE80211_MODE_11G].rs_nrates = 0;
for (i = 0; i < len; i++) {
switch (rates[i] & IEEE80211_RATE_VAL) {
@@ -763,11 +763,10 @@ nonettypes:
case 11:
case 10:
case 22:
- if (!(ic->ic_modecaps &
- (1<<IEEE80211_MODE_11B))) {
+ if (isclr(ic->ic_modecaps, IEEE80211_MODE_11B)) {
/* Lazy-init 802.11b. */
- ic->ic_modecaps |=
- (1<<IEEE80211_MODE_11B);
+ setbit(ic->ic_modecaps,
+ IEEE80211_MODE_11B);
ic->ic_sup_rates[IEEE80211_MODE_11B].
rs_nrates = 0;
}
@@ -775,11 +774,11 @@ nonettypes:
INCRATE(IEEE80211_MODE_11B);
break;
default:
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11A)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11A)) {
SETRATE(IEEE80211_MODE_11A, rates[i]);
INCRATE(IEEE80211_MODE_11A);
}
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11G)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11G)) {
SETRATE(IEEE80211_MODE_11G, rates[i]);
INCRATE(IEEE80211_MODE_11G);
}
@@ -794,7 +793,7 @@ nonettypes:
* just cheat here. Just how in the heck do
* we detect turbo modes, though?
*/
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11B)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11B)) {
TESTSETRATE(IEEE80211_MODE_11B,
IEEE80211_RATE_BASIC|2);
TESTSETRATE(IEEE80211_MODE_11B,
@@ -804,13 +803,13 @@ nonettypes:
TESTSETRATE(IEEE80211_MODE_11B,
IEEE80211_RATE_BASIC|22);
}
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11G)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11G)) {
TESTSETRATE(IEEE80211_MODE_11G, 47);
TESTSETRATE(IEEE80211_MODE_11G, 72);
TESTSETRATE(IEEE80211_MODE_11G, 96);
TESTSETRATE(IEEE80211_MODE_11G, 108);
}
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11A)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11A)) {
TESTSETRATE(IEEE80211_MODE_11A, 47);
TESTSETRATE(IEEE80211_MODE_11A, 72);
TESTSETRATE(IEEE80211_MODE_11A, 96);
@@ -2629,7 +2628,7 @@ ndis_getstate_80211(sc)
device_printf (sc->ndis_dev, "get link speed failed: %d\n",
rval);
- if (ic->ic_modecaps & (1<<IEEE80211_MODE_11B)) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11B)) {
ic->ic_bss->ni_rates = ic->ic_sup_rates[IEEE80211_MODE_11B];
for (i = 0; i < ic->ic_bss->ni_rates.rs_nrates; i++) {
if ((ic->ic_bss->ni_rates.rs_rates[i] &
@@ -2639,7 +2638,7 @@ ndis_getstate_80211(sc)
}
if (i == ic->ic_bss->ni_rates.rs_nrates &&
- ic->ic_modecaps & (1<<IEEE80211_MODE_11G)) {
+ isset(ic->ic_modecaps, IEEE80211_MODE_11G)) {
ic->ic_bss->ni_rates = ic->ic_sup_rates[IEEE80211_MODE_11G];
for (i = 0; i < ic->ic_bss->ni_rates.rs_nrates; i++) {
if ((ic->ic_bss->ni_rates.rs_rates[i] &
diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c
index f504d80..e27cac7 100644
--- a/sys/dev/iwi/if_iwi.c
+++ b/sys/dev/iwi/if_iwi.c
@@ -2707,8 +2707,6 @@ set_scan_type(struct iwi_scan_ext *scan, int ix, int scan_type)
static int
iwi_scan(struct iwi_softc *sc)
{
-#define IEEE80211_MODE_5GHZ (1<<IEEE80211_MODE_11A)
-#define IEEE80211_MODE_2GHZ ((1<<IEEE80211_MODE_11B)|1<<IEEE80211_MODE_11G)
struct ieee80211com *ic = &sc->sc_ic;
const struct ieee80211_channel *c;
struct iwi_scan_ext scan;
@@ -2743,7 +2741,7 @@ iwi_scan(struct iwi_softc *sc)
scan_type = IWI_SCAN_TYPE_BROADCAST;
ix = 0;
- if (ic->ic_modecaps & IEEE80211_MODE_5GHZ) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11A)) {
start = ix;
for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
c = &ic->ic_channels[i];
@@ -2767,7 +2765,7 @@ iwi_scan(struct iwi_softc *sc)
ix++;
}
}
- if (ic->ic_modecaps & IEEE80211_MODE_2GHZ) {
+ if (isset(ic->ic_modecaps, IEEE80211_MODE_11B)) {
start = ix;
for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
c = &ic->ic_channels[i];
@@ -2795,8 +2793,6 @@ iwi_scan(struct iwi_softc *sc)
sc->sc_ifp->if_timer = 1;
sc->flags |= IWI_FLAG_SCANNING;
return iwi_cmd(sc, IWI_CMD_SCAN_EXT, &scan, sizeof scan);
-#undef IEEE80211_MODE_5GHZ
-#undef IEEE80211_MODE_2GHZ
}
static void
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index bcef214..c96465c 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -144,7 +144,7 @@ static void
ieee80211_chan_init(struct ieee80211com *ic)
{
#define DEFAULTRATES(m, def) do { \
- if ((ic->ic_modecaps & (1<<m)) && ic->ic_sup_rates[m].rs_nrates == 0) \
+ if (isset(ic->ic_modecaps, m) && ic->ic_sup_rates[m].rs_nrates == 0) \
ic->ic_sup_rates[m] = def; \
} while (0)
struct ifnet *ifp = ic->ic_ifp;
@@ -152,7 +152,7 @@ ieee80211_chan_init(struct ieee80211com *ic)
int i;
memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));
- ic->ic_modecaps = 1<<IEEE80211_MODE_AUTO;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
c = &ic->ic_channels[i];
if (c->ic_flags) {
@@ -171,17 +171,17 @@ ieee80211_chan_init(struct ieee80211com *ic)
* Identify mode capabilities.
*/
if (IEEE80211_IS_CHAN_A(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_11A;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11A);
if (IEEE80211_IS_CHAN_B(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_11B;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11B);
if (IEEE80211_IS_CHAN_ANYG(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_11G;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_11G);
if (IEEE80211_IS_CHAN_FHSS(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_FH;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_FH);
if (IEEE80211_IS_CHAN_T(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_TURBO_A;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_A);
if (IEEE80211_IS_CHAN_108G(c))
- ic->ic_modecaps |= 1<<IEEE80211_MODE_TURBO_G;
+ setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_G);
if (ic->ic_curchan == NULL) {
/* arbitrarily pick the first channel */
ic->ic_curchan = &ic->ic_channels[i];
@@ -447,7 +447,7 @@ ieee80211_media_init(struct ieee80211com *ic,
IFM_IEEE80211_11A | IFM_IEEE80211_TURBO,
IFM_IEEE80211_11G | IFM_IEEE80211_TURBO,
};
- if ((ic->ic_modecaps & (1<<mode)) == 0)
+ if (isclr(ic->ic_modecaps, mode))
continue;
mopt = mopts[mode];
ADD(ic, IFM_AUTO, mopt); /* e.g. 11a auto */
@@ -537,7 +537,7 @@ ieee80211_announce(struct ieee80211com *ic)
struct ieee80211_rateset *rs;
for (mode = IEEE80211_MODE_11A; mode < IEEE80211_MODE_MAX; mode++) {
- if ((ic->ic_modecaps & (1<<mode)) == 0)
+ if (isclr(ic->ic_modecaps, mode))
continue;
if_printf(ifp, "%s rates: ", ieee80211_phymode_name[mode]);
rs = &ic->ic_sup_rates[mode];
@@ -650,7 +650,7 @@ ieee80211_media_change(struct ifnet *ifp)
/*
* Validate requested mode is available.
*/
- if ((ic->ic_modecaps & (1<<newphymode)) == 0)
+ if (isclr(ic->ic_modecaps, newphymode))
return EINVAL;
/*
@@ -673,7 +673,7 @@ ieee80211_media_change(struct ifnet *ifp)
*/
for (j = IEEE80211_MODE_11A;
j < IEEE80211_MODE_MAX; j++) {
- if ((ic->ic_modecaps & (1<<j)) == 0)
+ if (isclr(ic->ic_modecaps, j))
continue;
i = findrate(ic, j, newrate);
if (i != -1) {
@@ -714,7 +714,7 @@ ieee80211_media_change(struct ifnet *ifp)
if (newopmode == IEEE80211_M_HOSTAP &&
newphymode == IEEE80211_MODE_AUTO) {
for (j = IEEE80211_MODE_11A; j < IEEE80211_MODE_MAX; j++)
- if (ic->ic_modecaps & (1<<j)) {
+ if (isset(ic->ic_modecaps, j)) {
newphymode = j;
break;
}
@@ -894,7 +894,7 @@ ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode)
int i;
/* validate new mode */
- if ((ic->ic_modecaps & (1<<mode)) == 0) {
+ if (isclr(ic->ic_modecaps, mode)) {
IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
"%s: mode %u not supported (caps 0x%x)\n",
__func__, mode, ic->ic_modecaps);
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index 1f19ff5..0499bcb 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -595,7 +595,7 @@ ieee80211_cfgset(struct ieee80211com *ic, u_long cmd, caddr_t data)
*/
for (j = IEEE80211_MODE_11A;
j < IEEE80211_MODE_MAX; j++) {
- if ((ic->ic_modecaps & (1<<j)) == 0)
+ if (isclr(ic->ic_modecaps, j))
continue;
i = findrate(ic, j, rate);
if (i != -1) {
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 1ebd6ef..ea15e5e 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -117,7 +117,7 @@ struct ieee80211com {
u_int32_t ic_flags; /* state flags */
u_int32_t ic_flags_ext; /* extended state flags */
u_int32_t ic_caps; /* capabilities */
- u_int16_t ic_modecaps; /* set of mode capabilities */
+ u_int8_t ic_modecaps[2]; /* set of mode capabilities */
u_int16_t ic_curmode; /* current mode */
enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */
enum ieee80211_opmode ic_opmode; /* operation mode */
OpenPOWER on IntegriCloud