diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2008-08-27 09:05:05 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2008-08-27 09:05:05 +0000 |
commit | ae8d786435a0cd5b546644a9f5e3592c26c022e5 (patch) | |
tree | 3e8cc621792a9e7e11267f6eb127006e3f4e5810 /sys/dev/usb | |
parent | 667d3188711dacb1f8a406d01c9c42412ed0c710 (diff) |
introduce new IEEE80211_STA_ONLY kernel option that can be set to
remove IBSS and HostAP support from net80211 and 802.11 drivers.
it can be used to shrink RAMDISK kernels for instance (like what
was done for wi(4)).
it also has the benefit of highlighting what is specific to IBSS
and HostAP modes in the code.
the cost is that we now have two code paths to maintain.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_ral.c | 33 | ||||
-rw-r--r-- | sys/dev/usb/if_rum.c | 21 | ||||
-rw-r--r-- | sys/dev/usb/if_zyd.c | 4 |
3 files changed, 48 insertions, 10 deletions
diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 5e7a8c3400d..0adacf6c1bd 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.106 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: if_ral.c,v 1.107 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -127,8 +127,10 @@ uint16_t ural_txtime(int, int, uint32_t); uint8_t ural_plcp_signal(int); void ural_setup_tx_desc(struct ural_softc *, struct ural_tx_desc *, uint32_t, int, int); +#ifndef IEEE80211_STA_ONLY int ural_tx_bcn(struct ural_softc *, struct mbuf *, struct ieee80211_node *); +#endif int ural_tx_data(struct ural_softc *, struct mbuf *, struct ieee80211_node *); void ural_start(struct ifnet *); @@ -295,9 +297,11 @@ ural_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAp mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -552,7 +556,6 @@ ural_task(void *arg) struct ieee80211com *ic = &sc->sc_ic; enum ieee80211_state ostate; struct ieee80211_node *ni; - struct mbuf *m; ostate = ic->ic_state; @@ -592,9 +595,10 @@ ural_task(void *arg) ural_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) { - m = ieee80211_beacon_alloc(ic, ni); + struct mbuf *m = ieee80211_beacon_alloc(ic, ni); if (m == NULL) { printf("%s: could not allocate beacon\n", sc->sc_dev.dv_xname); @@ -611,6 +615,7 @@ ural_task(void *arg) /* beacon is no longer needed */ m_freem(m); } +#endif /* make tx led blink on tx (controlled by ASIC) */ ural_write(sc, RAL_MAC_CSR20, 1); @@ -978,6 +983,7 @@ ural_setup_tx_desc(struct ural_softc *sc, struct ural_tx_desc *desc, #define RAL_TX_TIMEOUT 5000 +#ifndef IEEE80211_STA_ONLY int ural_tx_bcn(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { @@ -1027,6 +1033,7 @@ ural_tx_bcn(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) return error; } +#endif int ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) @@ -1157,11 +1164,13 @@ ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) ic->ic_flags) + RAL_SIFS; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp in probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RAL_TX_TIMESTAMP; +#endif } #if NBPFILTER > 0 @@ -1661,8 +1670,16 @@ ural_enable_tsf_sync(struct ural_softc *sc) tmp = (16 * ic->ic_bss->ni_intval) << 4; ural_write(sc, RAL_TXRX_CSR18, tmp); - logcwmin = (ic->ic_opmode == IEEE80211_M_IBSS) ? 2 : 0; - preload = (ic->ic_opmode == IEEE80211_M_IBSS) ? 320 : 6; +#ifndef IEEE80211_STA_ONLY + if (ic->ic_opmode == IEEE80211_M_IBSS) { + logcwmin = 2; + preload = 320; + } else +#endif + { + logcwmin = 0; + preload = 6; + } tmp = logcwmin << 12 | preload; ural_write(sc, RAL_TXRX_CSR20, tmp); @@ -1670,8 +1687,10 @@ ural_enable_tsf_sync(struct ural_softc *sc) tmp = RAL_ENABLE_TSF | RAL_ENABLE_TBCN; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RAL_ENABLE_TSF_SYNC(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RAL_ENABLE_TSF_SYNC(2) | RAL_ENABLE_BEACON_GENERATOR; +#endif ural_write(sc, RAL_TXRX_CSR19, tmp); DPRINTF(("enabling TSF synchronization\n")); @@ -2041,7 +2060,9 @@ ural_init(struct ifnet *ifp) tmp = RAL_DROP_PHY_ERROR | RAL_DROP_CRC_ERROR; if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RAL_DROP_CTL | RAL_DROP_VERSION_ERROR; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RAL_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RAL_DROP_NOT_TO_ME; diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 758fe814af8..df53a86dad1 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.77 2008/08/19 02:34:04 deraadt Exp $ */ +/* $OpenBSD: if_rum.c,v 1.78 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -183,7 +183,9 @@ int rum_bbp_init(struct rum_softc *); int rum_init(struct ifnet *); void rum_stop(struct ifnet *, int); int rum_load_microcode(struct rum_softc *, const u_char *, size_t); +#ifndef IEEE80211_STA_ONLY int rum_prepare_beacon(struct rum_softc *); +#endif void rum_newassoc(struct ieee80211com *, struct ieee80211_node *, int); void rum_amrr_start(struct rum_softc *, struct ieee80211_node *); @@ -359,9 +361,11 @@ rum_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAp mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -683,9 +687,11 @@ rum_task(void *arg) rum_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) rum_prepare_beacon(sc); +#endif if (ic->ic_opmode != IEEE80211_M_MONITOR) rum_enable_tsf_sync(sc); @@ -1173,11 +1179,13 @@ rum_tx_data(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) ic->ic_flags) + sc->sifs; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp in probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RT2573_TX_TIMESTAMP; +#endif } #if NBPFILTER > 0 @@ -1745,6 +1753,7 @@ rum_enable_tsf_sync(struct rum_softc *sc) struct ieee80211com *ic = &sc->sc_ic; uint32_t tmp; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA) { /* * Change default 16ms TBTT adjustment to 8ms. @@ -1752,6 +1761,7 @@ rum_enable_tsf_sync(struct rum_softc *sc) */ rum_write(sc, RT2573_TXRX_CSR10, 1 << 12 | 8); } +#endif tmp = rum_read(sc, RT2573_TXRX_CSR9) & 0xff000000; @@ -1761,9 +1771,10 @@ rum_enable_tsf_sync(struct rum_softc *sc) tmp |= RT2573_TSF_TICKING | RT2573_ENABLE_TBTT; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RT2573_TSF_MODE(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RT2573_TSF_MODE(2) | RT2573_GENERATE_BEACON; - +#endif rum_write(sc, RT2573_TXRX_CSR9, tmp); } @@ -2064,7 +2075,9 @@ rum_init(struct ifnet *ifp) if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RT2573_DROP_CTL | RT2573_DROP_VER_ERROR | RT2573_DROP_ACKCTS; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RT2573_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RT2573_DROP_NOT_TO_ME; @@ -2147,6 +2160,7 @@ rum_load_microcode(struct rum_softc *sc, const u_char *ucode, size_t size) return error; } +#ifndef IEEE80211_STA_ONLY int rum_prepare_beacon(struct rum_softc *sc) { @@ -2179,6 +2193,7 @@ rum_prepare_beacon(struct rum_softc *sc) return 0; } +#endif void rum_newassoc(struct ieee80211com *ic, struct ieee80211_node *ni, int isnew) diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index b509739439f..a19985d687f 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.69 2008/07/21 18:43:19 damien Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.70 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -1734,10 +1734,12 @@ zyd_set_rxfilter(struct zyd_softc *sc) case IEEE80211_M_STA: rxfilter = ZYD_FILTER_BSS; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_HOSTAP: rxfilter = ZYD_FILTER_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: rxfilter = ZYD_FILTER_MONITOR; break; |