Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move IEEE 802.11 MAC management functions from awi drive...
details: https://anonhg.NetBSD.org/src/rev/983f79828fa4
branches: trunk
changeset: 515172:983f79828fa4
user: onoe <onoe%NetBSD.org@localhost>
date: Tue Sep 18 09:09:57 2001 +0000
description:
Move IEEE 802.11 MAC management functions from awi driver to
if_ieee80211subr.c, which can be shared between any IEEE 802.11
drivers.
However, most of current working IEEE 802.11b wireless LAN cards
have rich firmware and we cannot have a control to management frames
for such cards.
IBSS creation is now supported for the awi driver.
diffstat:
sys/conf/files | 5 +-
sys/dev/ic/awi.c | 3238 ++++++++++++++-------------------------
sys/dev/ic/awi_wep.c | 521 ------
sys/dev/ic/awi_wicfg.c | 657 --------
sys/dev/ic/awireg.h | 108 +-
sys/dev/ic/awivar.h | 189 +-
sys/dev/pcmcia/if_awi_pcmcia.c | 45 +-
sys/net/if_ieee80211.h | 189 ++-
sys/net/if_ieee80211subr.c | 2192 +++++++++++++++++++++++++++
9 files changed, 3690 insertions(+), 3454 deletions(-)
diffs (truncated from 7863 to 300 lines):
diff -r a23a9a53e8b9 -r 983f79828fa4 sys/conf/files
--- a/sys/conf/files Tue Sep 18 08:38:28 2001 +0000
+++ b/sys/conf/files Tue Sep 18 09:09:57 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.462 2001/09/16 07:33:31 manu Exp $
+# $NetBSD: files,v 1.463 2001/09/18 09:09:57 onoe Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -328,8 +328,6 @@
# AMD 79c930-based 802.11 cards
device awi: arp, wlan, ifnet
file dev/ic/awi.c awi
-file dev/ic/awi_wep.c awi
-file dev/ic/awi_wicfg.c awi
file dev/ic/am79c930.c awi
# Lucent & Intersil WaveLan IEEE (802.11)
@@ -984,6 +982,7 @@
file net/if_gre.c gre needs-count
file net/if_hippisubr.c hippi needs-flag
file net/if_ieee1394subr.c ieee1394
+file net/if_ieee80211subr.c wlan
file net/if_loop.c loop needs-count
file net/if_media.c
file net/if_ppp.c ppp needs-count
diff -r a23a9a53e8b9 -r 983f79828fa4 sys/dev/ic/awi.c
--- a/sys/dev/ic/awi.c Tue Sep 18 08:38:28 2001 +0000
+++ b/sys/dev/ic/awi.c Tue Sep 18 09:09:57 2001 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: awi.c,v 1.36 2001/07/26 22:55:14 wiz Exp $ */
+/* $NetBSD: awi.c,v 1.37 2001/09/18 09:09:58 onoe Exp $ */
/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -85,14 +85,7 @@
*/
#include "opt_inet.h"
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
-#define NBPFILTER 1
-#elif defined(__FreeBSD__) && __FreeBSD__ >= 3
-#include "bpf.h"
-#define NBPFILTER NBPF
-#else
#include "bpfilter.h"
-#endif
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,19 +96,11 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/errno.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
-#include <sys/bus.h>
-#else
#include <sys/device.h>
-#endif
#include <net/if.h>
#include <net/if_dl.h>
-#ifdef __FreeBSD__
-#include <net/ethernet.h>
-#else
#include <net/if_ether.h>
-#endif
#include <net/if_media.h>
#include <net/if_llc.h>
#include <net/if_ieee80211.h>
@@ -136,234 +121,182 @@
#include <machine/cpu.h>
#include <machine/bus.h>
-#ifdef __NetBSD__
#include <machine/intr.h>
-#endif
-#ifdef __FreeBSD__
-#include <machine/clock.h>
-#endif
-#ifdef __NetBSD__
#include <dev/ic/am79c930reg.h>
#include <dev/ic/am79c930var.h>
#include <dev/ic/awireg.h>
#include <dev/ic/awivar.h>
-#endif
-#ifdef __FreeBSD__
-#include <dev/awi/am79c930reg.h>
-#include <dev/awi/am79c930var.h>
-#include <dev/awi/awireg.h>
-#include <dev/awi/awivar.h>
-#endif
+
+static int awi_init(struct ifnet *);
+static void awi_stop(struct ifnet *, int);
+static void awi_start(struct ifnet *);
+static void awi_watchdog(struct ifnet *);
+static int awi_ioctl(struct ifnet *, u_long, caddr_t);
+static int awi_media_change(struct ifnet *);
+static void awi_media_status(struct ifnet *, struct ifmediareq *);
+static int awi_mode_init(struct awi_softc *);
+static int awi_media_rate2opt(struct awi_softc *, int);
+static int awi_media_opt2rate(struct awi_softc *, int);
+static void awi_rx_int(struct awi_softc *);
+static void awi_tx_int(struct awi_softc *);
+static struct mbuf *awi_devget(struct awi_softc *, u_int32_t, u_int16_t);
+static int awi_hw_init(struct awi_softc *);
+static int awi_init_mibs(struct awi_softc *);
+static int awi_chan_check(void *, u_char *);
+static int awi_mib(struct awi_softc *, u_int8_t, u_int8_t, int);
+static int awi_cmd(struct awi_softc *, u_int8_t, int);
+static int awi_cmd_wait(struct awi_softc *);
+static void awi_cmd_done(struct awi_softc *);
+static int awi_next_txd(struct awi_softc *, int, u_int32_t *, u_int32_t *);
+static int awi_lock(struct awi_softc *);
+static void awi_unlock(struct awi_softc *);
+static int awi_intr_lock(struct awi_softc *);
+static void awi_intr_unlock(struct awi_softc *);
+static int awi_newstate(void *, enum ieee80211_state);
+static struct mbuf *awi_ether_encap(struct awi_softc *, struct mbuf *);
+static struct mbuf *awi_ether_modcap(struct awi_softc *, struct mbuf *);
-static int awi_ioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data));
-#ifdef IFM_IEEE80211
-static int awi_media_rate2opt __P((struct awi_softc *sc, int rate));
-static int awi_media_opt2rate __P((struct awi_softc *sc, int opt));
-static int awi_media_change __P((struct ifnet *ifp));
-static void awi_media_status __P((struct ifnet *ifp, struct ifmediareq *imr));
-#endif
-static void awi_watchdog __P((struct ifnet *ifp));
-static void awi_start __P((struct ifnet *ifp));
-static void awi_txint __P((struct awi_softc *sc));
-static struct mbuf * awi_fix_txhdr __P((struct awi_softc *sc, struct mbuf *m0));
-static struct mbuf * awi_fix_rxhdr __P((struct awi_softc *sc, struct mbuf *m0));
-static void awi_input __P((struct awi_softc *sc, struct mbuf *m, u_int32_t rxts, u_int8_t rssi));
-static void awi_rxint __P((struct awi_softc *sc));
-static struct mbuf * awi_devget __P((struct awi_softc *sc, u_int32_t off, u_int16_t len));
-static int awi_init_hw __P((struct awi_softc *sc));
-static int awi_init_mibs __P((struct awi_softc *sc));
-static int awi_init_txrx __P((struct awi_softc *sc));
-static void awi_stop_txrx __P((struct awi_softc *sc));
-static int awi_start_scan __P((struct awi_softc *sc));
-static int awi_next_scan __P((struct awi_softc *sc));
-static void awi_stop_scan __P((struct awi_softc *sc));
-static void awi_recv_beacon __P((struct awi_softc *sc, struct mbuf *m0, u_int32_t rxts, u_int8_t rssi));
-static int awi_set_ss __P((struct awi_softc *sc));
-static void awi_try_sync __P((struct awi_softc *sc));
-static void awi_sync_done __P((struct awi_softc *sc));
-static void awi_send_deauth __P((struct awi_softc *sc));
-static void awi_send_auth __P((struct awi_softc *sc, int seq));
-static void awi_recv_auth __P((struct awi_softc *sc, struct mbuf *m0));
-static void awi_send_asreq __P((struct awi_softc *sc, int reassoc));
-static void awi_recv_asresp __P((struct awi_softc *sc, struct mbuf *m0));
-static int awi_mib __P((struct awi_softc *sc, u_int8_t cmd, u_int8_t mib));
-static int awi_cmd_scan __P((struct awi_softc *sc));
-static int awi_cmd __P((struct awi_softc *sc, u_int8_t cmd));
-static void awi_cmd_done __P((struct awi_softc *sc));
-static int awi_next_txd __P((struct awi_softc *sc, int len, u_int32_t *framep, u_int32_t*ntxdp));
-static int awi_lock __P((struct awi_softc *sc));
-static void awi_unlock __P((struct awi_softc *sc));
-static int awi_intr_lock __P((struct awi_softc *sc));
-static void awi_intr_unlock __P((struct awi_softc *sc));
-static int awi_cmd_wait __P((struct awi_softc *sc));
-static void awi_print_essid __P((u_int8_t *essid));
+/* unalligned little endian access */
+#define LE_READ_2(p) \
+ ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))
+#define LE_READ_4(p) \
+ ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \
+ (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
+#define LE_WRITE_2(p, v) \
+ ((((u_int8_t *)(p))[0] = (((u_int32_t)(v) ) & 0xff)), \
+ (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
+#define LE_WRITE_4(p, v) \
+ ((((u_int8_t *)(p))[0] = (((u_int32_t)(v) ) & 0xff)), \
+ (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \
+ (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \
+ (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
+
+struct awi_chanset awi_chanset[] = {
+ /* PHY type domain min max def */
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_JP, 6, 17, 6 },
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_ES, 0, 26, 1 },
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_FR, 0, 32, 1 },
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_US, 0, 77, 1 },
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_CA, 0, 77, 1 },
+ { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_EU, 0, 77, 1 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_JP, 14, 14, 14 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_ES, 10, 11, 10 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_FR, 10, 13, 10 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_US, 1, 11, 3 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_CA, 1, 11, 3 },
+ { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_EU, 1, 13, 3 },
+ { 0, 0 }
+};
#ifdef AWI_DEBUG
-static void awi_dump_pkt __P((struct awi_softc *sc, struct mbuf *m, int rssi));
-int awi_verbose = 0;
-int awi_dump = 0;
-#define AWI_DUMP_MASK(fc0) (1 << (((fc0) & IEEE80211_FC0_SUBTYPE_MASK) >> 4))
-int awi_dump_mask = AWI_DUMP_MASK(IEEE80211_FC0_SUBTYPE_BEACON);
-int awi_dump_hdr = 0;
-int awi_dump_len = 28;
-#endif
+int awi_debug;
-#if NBPFILTER > 0
-#define AWI_BPF_NORM 0
-#define AWI_BPF_RAW 1
-#ifdef __FreeBSD__
-#define AWI_BPF_MTAP(sc, m, raw) do { \
- if ((sc)->sc_ifp->if_bpf && (sc)->sc_rawbpf == (raw)) \
- bpf_mtap((sc)->sc_ifp, (m)); \
-} while (0);
-#else
-#define AWI_BPF_MTAP(sc, m, raw) do { \
- if ((sc)->sc_ifp->if_bpf && (sc)->sc_rawbpf == (raw)) \
- bpf_mtap((sc)->sc_ifp->if_bpf, (m)); \
-} while (0);
-#endif
+#define DPRINTF(X) if (awi_debug) printf X
+#define DPRINTF2(X) if (awi_debug > 1) printf X
#else
-#define AWI_BPF_MTAP(sc, m, raw)
-#endif
-
-#ifndef llc_snap
-#define llc_snap llc_un.type_snap
-#endif
-
-#ifdef __FreeBSD__
-#if __FreeBSD__ >= 4
-devclass_t awi_devclass;
-#endif
-
-/* NetBSD compatible functions */
-static char * ether_sprintf __P((u_int8_t *));
-
-static char *
-ether_sprintf(enaddr)
- u_int8_t *enaddr;
-{
- static char strbuf[18];
-
- sprintf(strbuf, "%6D", enaddr, ":");
- return strbuf;
-}
+#define DPRINTF(X)
+#define DPRINTF2(X)
#endif
int
-awi_attach(sc)
- struct awi_softc *sc;
+awi_attach(struct awi_softc *sc)
{
- struct ifnet *ifp = sc->sc_ifp;
- int s;
- int error;
-#ifdef IFM_IEEE80211
- int i;
- u_int8_t *phy_rates;
+ struct ieee80211com *ic = &sc->sc_ic;
+ struct ifnet *ifp = &ic->ic_if;
+ int s, i, error, nrate;
int mword;
struct ifmediareq imr;
-#endif
s = splnet();
- /*
- * Even if we can sleep in initialization state,
- * all other processes (e.g. ifconfig) have to wait for
- * completion of attaching interface.
- */
sc->sc_busy = 1;
- sc->sc_status = AWI_ST_INIT;
- TAILQ_INIT(&sc->sc_scan);
- error = awi_init_hw(sc);
- if (error) {
+ ic->ic_state = IEEE80211_S_INIT;
+ sc->sc_substate = AWI_ST_NONE;
+ if ((error = awi_hw_init(sc)) != 0) {
sc->sc_invalid = 1;
splx(s);
return error;
}
error = awi_init_mibs(sc);
- splx(s);
- if (error) {
+ if (error != 0) {
sc->sc_invalid = 1;
+ splx(s);
return error;
Home |
Main Index |
Thread Index |
Old Index