diff options
author | sam <sam@FreeBSD.org> | 2004-12-08 17:36:51 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2004-12-08 17:36:51 +0000 |
commit | db6535c8766930b500333ae4fc743c5da7814928 (patch) | |
tree | 456a8adcebe60aa5acdc41fc83efd45d43311043 /sys/dev/awi | |
parent | 0c82ed616510db58f8cd9df461314ab8010dbd72 (diff) | |
download | FreeBSD-src-db6535c8766930b500333ae4fc743c5da7814928.zip FreeBSD-src-db6535c8766930b500333ae4fc743c5da7814928.tar.gz |
Update for net80211 changes.
Diffstat (limited to 'sys/dev/awi')
-rw-r--r-- | sys/dev/awi/awi.c | 166 | ||||
-rw-r--r-- | sys/dev/awi/awivar.h | 2 |
2 files changed, 89 insertions, 79 deletions
diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c index 105b7a7..f025039 100644 --- a/sys/dev/awi/awi.c +++ b/sys/dev/awi/awi.c @@ -258,7 +258,7 @@ int awi_attach(struct awi_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; + struct ifnet *ifp = &sc->sc_if; int s, i, error, nrate; int mword; enum ieee80211_phymode mode; @@ -300,6 +300,7 @@ awi_attach(struct awi_softc *sc) device_get_unit(sc->sc_dev)); #endif + ic->ic_ifp = ifp; ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_IBSS | IEEE80211_C_HOSTAP; if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { ic->ic_phytype = IEEE80211_T_FH; @@ -322,7 +323,7 @@ awi_attach(struct awi_softc *sc) #ifdef __NetBSD__ if_attach(ifp); #endif - ieee80211_ifattach(ifp); + ieee80211_ifattach(ic); sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = awi_newstate; @@ -333,7 +334,7 @@ awi_attach(struct awi_softc *sc) sc->sc_send_mgmt = ic->ic_send_mgmt; ic->ic_send_mgmt = awi_send_mgmt; - ieee80211_media_init(ifp, awi_media_change, awi_media_status); + ieee80211_media_init(ic, awi_media_change, awi_media_status); /* Melco compatibility mode. */ #define ADD(s, o) ifmedia_add(&ic->ic_media, \ @@ -363,13 +364,15 @@ awi_attach(struct awi_softc *sc) /* ready to accept ioctl */ awi_unlock(sc); + ieee80211_announce(ic); + return 0; } int awi_detach(struct awi_softc *sc) { - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; int s; if (!sc->sc_attached) @@ -384,7 +387,7 @@ awi_detach(struct awi_softc *sc) (void)tsleep(sc, PWAIT, "awidet", 1); } sc->sc_attached = 0; - ieee80211_ifdetach(ifp); + ieee80211_ifdetach(&sc->sc_ic); #ifdef __NetBSD__ if_detach(ifp); shutdownhook_disestablish(sc->sc_sdhook); @@ -399,7 +402,7 @@ int awi_activate(struct device *self, enum devact act) { struct awi_softc *sc = (struct awi_softc *)self; - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; int s, error = 0; s = splnet(); @@ -420,7 +423,7 @@ void awi_power(int why, void *arg) { struct awi_softc *sc = arg; - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; int s; int ocansleep; @@ -453,7 +456,7 @@ void awi_shutdown(void *arg) { struct awi_softc *sc = arg; - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; if (sc->sc_attached) awi_stop(ifp, 1); @@ -524,7 +527,7 @@ awi_intr(void *arg) if (status & AWI_INT_SCAN_CMPLT) { if (sc->sc_ic.ic_state == IEEE80211_S_SCAN && sc->sc_substate == AWI_ST_NONE) - ieee80211_next_scan(&sc->sc_ic.ic_if); + ieee80211_next_scan(&sc->sc_ic); } } sc->sc_cansleep = ocansleep; @@ -539,7 +542,7 @@ awi_init0(void *arg) { struct awi_softc *sc = arg; - (void)awi_init(&sc->sc_ic.ic_if); + (void)awi_init(&sc->sc_if); } #endif @@ -660,7 +663,7 @@ awi_init(struct ifnet *ifp) ni->ni_intval = ic->ic_lintval; ni->ni_rssi = 0; ni->ni_rstamp = 0; - memset(ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); + memset(&ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2mode(ic, ni->ni_chan)]; IEEE80211_ADDR_COPY(ni->ni_macaddr, ic->ic_myaddr); @@ -678,7 +681,7 @@ awi_init(struct ifnet *ifp) memset(ni->ni_bssid, 0, IEEE80211_ADDR_LEN); ni->ni_esslen = 0; } - if (ic->ic_flags & IEEE80211_F_WEPON) + if (ic->ic_flags & IEEE80211_F_PRIVACY) ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY; if (ic->ic_opmode != IEEE80211_M_AHDEMO) ic->ic_flags |= IEEE80211_F_SIBSS; @@ -743,6 +746,7 @@ awi_start(struct ifnet *ifp) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni; struct ieee80211_frame *wh; + struct ether_header *eh; struct mbuf *m, *m0; int len, dowep; u_int32_t txd, frame, ntxd; @@ -755,6 +759,7 @@ awi_start(struct ifnet *ifp) txd = sc->sc_txnext; IF_POLL(&ic->ic_mgtq, m0); dowep = 0; + ni = NULL; if (m0 != NULL) { len = m0->m_pkthdr.len; if (awi_next_txd(sc, len, &frame, &ntxd)) { @@ -762,6 +767,8 @@ awi_start(struct ifnet *ifp) break; } IF_DEQUEUE(&ic->ic_mgtq, m0); + ni = (struct ieee80211_node *) m0->m_pkthdr.rcvif; + m0->m_pkthdr.rcvif = NULL; } else { if (ic->ic_state != IEEE80211_S_RUN) break; @@ -776,7 +783,8 @@ awi_start(struct ifnet *ifp) if (!(ifp->if_flags & IFF_LINK0) && !sc->sc_adhoc_ap) len += sizeof(struct llc) - sizeof(struct ether_header); - if (ic->ic_flags & IEEE80211_F_WEPON) { + if (ic->ic_flags & IEEE80211_F_PRIVACY) { + /* XXX other crypto */ dowep = 1; len += IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; @@ -786,21 +794,31 @@ awi_start(struct ifnet *ifp) break; } IFQ_DEQUEUE(&ifp->if_snd, m0); - ifp->if_opackets++; #if NBPFILTER > 0 if (ifp->if_bpf) bpf_mtap(ifp->if_bpf, m0); #endif if ((ifp->if_flags & IFF_LINK0) || sc->sc_adhoc_ap) m0 = awi_ether_encap(sc, m0); - else - m0 = ieee80211_encap(ifp, m0, &ni); - if (m0 == NULL) { - ifp->if_oerrors++; - continue; + else { + if (m0->m_len < sizeof(struct ether_header) && + ((m0 = m_pullup(m0, sizeof(struct ether_header)))) == NULL) { + ifp->if_oerrors++; + continue; + } + eh = mtod(m0, struct ether_header *); + ni = ieee80211_find_txnode(ic, eh->ether_dhost); + if (ni == NULL) + goto bad; + if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && + (m0->m_flags & M_PWR_SAV) == 0) { + ieee80211_pwrsave(ic, ni, m0); + continue; + } + m0 = ieee80211_encap(ic, m0, ni); } - if (ni != NULL && ni != ic->ic_bss) - ieee80211_free_node(ic, ni); + if (m0 == NULL) + goto bad; wh = mtod(m0, struct ieee80211_frame *); if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && (ic->ic_opmode == IEEE80211_M_HOSTAP || @@ -809,27 +827,38 @@ awi_start(struct ifnet *ifp) (ifp->if_flags & IFF_LINK0) == 0 && (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA && ni == NULL) { - m_freem(m0); + bad: + if (m0 != NULL) + m_freem(m0); ifp->if_oerrors++; + if (ni != NULL) + ieee80211_free_node(ni); continue; } + ifp->if_opackets++; } #if NBPFILTER > 0 if (ic->ic_rawbpf) bpf_mtap(ic->ic_rawbpf, m0); #endif if (dowep) { - if ((m0 = ieee80211_wep_crypt(ifp, m0, 1)) == NULL) { - ifp->if_oerrors++; + struct ieee80211_key *k; + + k = ieee80211_crypto_encap(ic, ni, m0); + if (k == NULL) { + if (ni != NULL) + ieee80211_free_node(ni); continue; } } #ifdef DIAGNOSTIC if (m0->m_pkthdr.len != len) { - printf("%s: length %d should be %d\n", - ic->ic_if.if_xname, m0->m_pkthdr.len, len); + if_printf(ifp, "length %d should be %d\n", + m0->m_pkthdr.len, len); m_freem(m0); ifp->if_oerrors++; + if (ni != NULL) + ieee80211_free_node(ni); continue; } #endif @@ -900,7 +929,7 @@ awi_watchdog(struct ifnet *ifp) ifp->if_timer = 1; } /* TODO: rate control */ - ieee80211_watchdog(ifp); + ieee80211_watchdog(&sc->sc_ic); out: sc->sc_cansleep = ocansleep; } @@ -954,7 +983,7 @@ awi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } break; default: - error = ieee80211_ioctl(ifp, cmd, data); + error = ieee80211_ioctl(&sc->sc_ic, cmd, data); if (error == ENETRESET) { if (sc->sc_enabled) error = awi_init(ifp); @@ -1095,7 +1124,7 @@ awi_media_status(struct ifnet *ifp, struct ifmediareq *imr) static int awi_mode_init(struct awi_softc *sc) { - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; int n, error; #ifdef __FreeBSD__ struct ifmultiaddr *ifma; @@ -1150,7 +1179,7 @@ awi_mode_init(struct awi_softc *sc) ifp->if_flags |= IFF_ALLMULTI; #endif sc->sc_mib_mgt.Wep_Required = - (sc->sc_ic.ic_flags & IEEE80211_F_WEPON) ? AWI_WEP_ON : AWI_WEP_OFF; + (sc->sc_ic.ic_flags & IEEE80211_F_PRIVACY) ? AWI_WEP_ON : AWI_WEP_OFF; if ((error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_LOCAL, AWI_WAIT)) || (error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_ADDR, AWI_WAIT)) || @@ -1167,8 +1196,7 @@ static void awi_rx_int(struct awi_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = &ic->ic_if; - struct ieee80211_frame *wh; + struct ifnet *ifp = &sc->sc_if; struct ieee80211_node *ni; u_int8_t state, rate, rssi; u_int16_t len; @@ -1213,36 +1241,16 @@ awi_rx_int(struct awi_softc *sc) sc->sc_adhoc_ap) m = awi_ether_modcap(sc, m); else - m = m_pullup(m, sizeof(*wh)); + m = m_pullup(m, + sizeof(struct ieee80211_frame_min)); if (m == NULL) { ifp->if_ierrors++; goto rx_next; } - wh = mtod(m, struct ieee80211_frame *); -#ifdef __NetBSD__ - ni = ieee80211_find_rxnode(ic, wh); -#else - if (ic->ic_opmode != IEEE80211_M_STA) { - ni = ieee80211_find_node(ic, - wh->i_addr2); - if (ni == NULL) - ni = ieee80211_ref_node( - ic->ic_bss); - } else - ni = ieee80211_ref_node(ic->ic_bss); -#endif - ieee80211_input(ifp, m, ni, rssi, rstamp); - /* - * The frame may have caused the - * node to be marked for reclamation - * (e.g. in response to a DEAUTH - * message) so use free_node here - * instead of unref_node. - */ - if (ni == ic->ic_bss) - ieee80211_unref_node(&ni); - else - ieee80211_free_node(ic, ni); + ni = ieee80211_find_rxnode(ic, + mtod(m, struct ieee80211_frame_min *)); + ieee80211_input(ic, m, ni, rssi, rstamp); + ieee80211_free_node(ni); } else sc->sc_rxpend = m; rx_next: @@ -1265,7 +1273,7 @@ awi_rx_int(struct awi_softc *sc) static void awi_tx_int(struct awi_softc *sc) { - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; u_int8_t flags; while (sc->sc_txdone != sc->sc_txnext) { @@ -1287,7 +1295,7 @@ awi_tx_int(struct awi_softc *sc) static struct mbuf * awi_devget(struct awi_softc *sc, u_int32_t off, u_int16_t len) { - struct ifnet *ifp = &sc->sc_ic.ic_if; + struct ifnet *ifp = &sc->sc_if; struct mbuf *m; struct mbuf *top, **mp; u_int tlen; @@ -1388,7 +1396,7 @@ awi_hw_init(struct awi_softc *sc) return ENXIO; if (i >= AWI_SELFTEST_TIMEOUT*hz/1000) { printf("%s: failed to complete selftest (timeout)\n", - sc->sc_ic.ic_if.if_xname); + sc->sc_if.if_xname); return ENXIO; } status = awi_read_1(sc, AWI_SELFTEST); @@ -1404,7 +1412,7 @@ awi_hw_init(struct awi_softc *sc) } if (status != AWI_SELFTEST_PASSED) { printf("%s: failed to complete selftest (code %x)\n", - sc->sc_ic.ic_if.if_xname, status); + sc->sc_if.if_xname, status); return ENXIO; } @@ -1412,7 +1420,7 @@ awi_hw_init(struct awi_softc *sc) awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN); if (memcmp(sc->sc_banner, "PCnetMobile:", 12) != 0) { printf("%s: failed to complete selftest (bad banner)\n", - sc->sc_ic.ic_if.if_xname); + sc->sc_if.if_xname); for (i = 0; i < AWI_BANNER_LEN; i++) printf("%s%02x", i ? ":" : "\t", sc->sc_banner[i]); printf("\n"); @@ -1437,7 +1445,7 @@ awi_hw_init(struct awi_softc *sc) error = awi_cmd(sc, AWI_CMD_NOP, AWI_WAIT); if (error) { printf("%s: failed to complete selftest", - sc->sc_ic.ic_if.if_xname); + sc->sc_if.if_xname); if (error == ENXIO) printf(" (no hardware)\n"); else if (error != EWOULDBLOCK) @@ -1475,7 +1483,7 @@ awi_init_mibs(struct awi_softc *sc) (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_MGT, AWI_WAIT)) || (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_PHY, AWI_WAIT))) { printf("%s: failed to get default mib value (error %d)\n", - ic->ic_if.if_xname, error); + sc->sc_if.if_xname, error); return error; } @@ -1483,7 +1491,7 @@ awi_init_mibs(struct awi_softc *sc) for (cs = awi_chanset; ; cs++) { if (cs->cs_type == 0) { printf("%s: failed to set available channel\n", - ic->ic_if.if_xname); + sc->sc_if.if_xname); return ENXIO; } if (cs->cs_type == sc->sc_mib_phy.IEEE_PHY_Type && @@ -1663,7 +1671,7 @@ awi_cmd(struct awi_softc *sc, u_int8_t cmd, int wflag) return EINVAL; default: printf("%s: command %d failed %x\n", - sc->sc_ic.ic_if.if_xname, cmd, status); + sc->sc_if.if_xname, cmd, status); return ENXIO; } return 0; @@ -1680,7 +1688,7 @@ awi_cmd_wait(struct awi_softc *sc) return ENXIO; if (awi_read_1(sc, AWI_CMD) != sc->sc_cmd_inprog) { printf("%s: failed to access hardware\n", - sc->sc_ic.ic_if.if_xname); + sc->sc_if.if_xname); sc->sc_invalid = 1; return ENXIO; } @@ -1725,7 +1733,7 @@ awi_cmd_done(struct awi_softc *sc) if (status != AWI_STAT_OK) { printf("%s: command %d failed %x\n", - sc->sc_ic.ic_if.if_xname, cmd, status); + sc->sc_if.if_xname, cmd, status); sc->sc_substate = AWI_ST_NONE; return; } @@ -1840,7 +1848,7 @@ awi_intr_lock(struct awi_softc *sc) } if (status != 0) { printf("%s: failed to lock interrupt\n", - sc->sc_ic.ic_if.if_xname); + sc->sc_if.if_xname); return ENXIO; } return 0; @@ -1856,9 +1864,9 @@ awi_intr_unlock(struct awi_softc *sc) static int awi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) { - struct awi_softc *sc = ic->ic_softc; + struct ifnet *ifp = ic->ic_ifp; + struct awi_softc *sc = ifp->if_softc; struct ieee80211_node *ni; - struct ifnet *ifp = &ic->ic_if; int error; u_int8_t newmode; enum ieee80211_state ostate; @@ -1929,7 +1937,7 @@ awi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) case IEEE80211_S_AUTH: case IEEE80211_S_ASSOC: case IEEE80211_S_INIT: - ieee80211_begin_scan(ifp); + ieee80211_begin_scan(ic, 0); break; case IEEE80211_S_SCAN: /* scan next */ @@ -2044,14 +2052,14 @@ awi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) awi_write_2(sc, AWI_CA_SYNC_DWELL, 0); } if (ic->ic_flags & IEEE80211_F_SIBSS) { - memset(ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); + memset(&ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); ni->ni_rstamp = 0; awi_write_1(sc, AWI_CA_SYNC_STARTBSS, 1); } else awi_write_1(sc, AWI_CA_SYNC_STARTBSS, 0); awi_write_2(sc, AWI_CA_SYNC_MBZ, 0); awi_write_bytes(sc, AWI_CA_SYNC_TIMESTAMP, - ni->ni_tstamp, 8); + ni->ni_tstamp.data, 8); awi_write_4(sc, AWI_CA_SYNC_REFTIME, ni->ni_rstamp); sc->sc_cur_chan = ieee80211_chan2ieee(ic, ni->ni_chan); if ((error = awi_cmd(sc, AWI_CMD_SYNC, AWI_NOWAIT)) @@ -2101,7 +2109,7 @@ awi_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0, struct ieee80211_node *ni, int subtype, int rssi, u_int32_t rstamp) { - struct awi_softc *sc = ic->ic_softc; + struct awi_softc *sc = ic->ic_ifp->if_softc; /* probe request is handled by hardware */ if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_REQ) @@ -2113,7 +2121,7 @@ static int awi_send_mgmt(struct ieee80211com *ic, struct ieee80211_node *ni, int type, int arg) { - struct awi_softc *sc = ic->ic_softc; + struct awi_softc *sc = ic->ic_ifp->if_softc; /* probe request is handled by hardware */ if (type == IEEE80211_FC0_SUBTYPE_PROBE_REQ) @@ -2142,8 +2150,8 @@ awi_ether_encap(struct awi_softc *sc, struct mbuf *m) wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_DATA; *(u_int16_t *)wh->i_dur = 0; *(u_int16_t *)wh->i_seq = - htole16(ni->ni_txseq << IEEE80211_SEQ_SEQ_SHIFT); - ni->ni_txseq++; + htole16(ni->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT); + ni->ni_txseqs[0]++; if (ic->ic_opmode == IEEE80211_M_IBSS || ic->ic_opmode == IEEE80211_M_AHDEMO) { wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h index b9f24e4..64da83d 100644 --- a/sys/dev/awi/awivar.h +++ b/sys/dev/awi/awivar.h @@ -78,6 +78,8 @@ struct awi_softc { struct device sc_dev; #endif #ifdef __FreeBSD__ + struct arpcom sc_arp; +#define sc_if sc_arp.ac_if device_t sc_dev; #endif struct am79c930_softc sc_chip; |