Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Switch wi(4) to the new 802.11 layer.



details:   https://anonhg.NetBSD.org/src/rev/10efc2b0ddc2
branches:  trunk
changeset: 553255:10efc2b0ddc2
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Mon Oct 13 08:07:21 2003 +0000

description:
Switch wi(4) to the new 802.11 layer.

diffstat:

 sys/arch/macppc/dev/if_wi_obio.c |    7 +-
 sys/dev/ic/wi.c                  |  188 ++++++++++++++++++++++++--------------
 sys/dev/ic/wivar.h               |    5 +-
 sys/dev/pci/if_wi_pci.c          |    8 +-
 sys/dev/pcmcia/if_wi_pcmcia.c    |    8 +-
 5 files changed, 138 insertions(+), 78 deletions(-)

diffs (truncated from 667 to 300 lines):

diff -r 2766191bbc1e -r 10efc2b0ddc2 sys/arch/macppc/dev/if_wi_obio.c
--- a/sys/arch/macppc/dev/if_wi_obio.c  Mon Oct 13 08:02:02 2003 +0000
+++ b/sys/arch/macppc/dev/if_wi_obio.c  Mon Oct 13 08:07:21 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wi_obio.c,v 1.6 2003/07/15 02:43:29 lukem Exp $     */
+/*     $NetBSD: if_wi_obio.c,v 1.7 2003/10/13 08:07:21 dyoung Exp $    */
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wi_obio.c,v 1.6 2003/07/15 02:43:29 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wi_obio.c,v 1.7 2003/10/13 08:07:21 dyoung Exp $");
 
 #include "opt_inet.h"
 
@@ -41,7 +41,8 @@
 #include <net/if.h>
 #include <net/if_ether.h>
 #include <net/if_media.h>
-#include <net/if_ieee80211.h>
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_compat.h>
 #endif
 
 #include <machine/autoconf.h>
diff -r 2766191bbc1e -r 10efc2b0ddc2 sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c   Mon Oct 13 08:02:02 2003 +0000
+++ b/sys/dev/ic/wi.c   Mon Oct 13 08:07:21 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wi.c,v 1.132 2003/07/06 20:01:17 dyoung Exp $  */
+/*     $NetBSD: wi.c,v 1.133 2003/10/13 08:07:21 dyoung Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.132 2003/07/06 20:01:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.133 2003/10/13 08:07:21 dyoung Exp $");
 
 #define WI_HERMES_AUTOINC_WAR  /* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR    /* Work around stats counter bug. */
@@ -92,7 +92,10 @@
 #include <net/if_llc.h>
 #include <net/if_media.h>
 #include <net/if_ether.h>
-#include <net/if_ieee80211.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_compat.h>
+#include <net80211/ieee80211_ioctl.h>
 
 #if NBPFILTER > 0
 #include <net/bpf.h>
@@ -136,7 +139,7 @@
 static int  wi_read_rid(struct wi_softc *, int, void *, int *);
 static int  wi_write_rid(struct wi_softc *, int, void *, int);
 
-static int  wi_newstate(void *, enum ieee80211_state);
+static int  wi_newstate(struct ieee80211com *, enum ieee80211_state, int);
 static int  wi_set_tim(struct ieee80211com *, int, int);
 
 static int  wi_scan_ap(struct wi_softc *, u_int16_t, u_int16_t);
@@ -207,7 +210,7 @@
 {
        struct ieee80211com *ic = &sc->sc_ic;
        struct ifnet *ifp = &ic->ic_if;
-       int i, nrate, buflen;
+       int chan, i, nrate, buflen;
        u_int16_t val;
        u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
        static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
@@ -256,10 +259,8 @@
 
        ic->ic_phytype = IEEE80211_T_DS;
        ic->ic_opmode = IEEE80211_M_STA;
-       ic->ic_flags = IEEE80211_F_HASPMGT | IEEE80211_F_HASAHDEMO;
+       ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_AHDEMO;
        ic->ic_state = IEEE80211_S_INIT;
-       ic->ic_newstate = wi_newstate;
-       ic->ic_set_tim = wi_set_tim;
        ic->ic_max_aid = WI_MAX_AID;
 
        /* Find available channel */
@@ -267,8 +268,12 @@
        if (wi_read_rid(sc, WI_RID_CHANNEL_LIST, &val, &buflen) != 0)
                val = htole16(0x1fff);  /* assume 1-11 */
        for (i = 0; i < 16; i++) {
+               chan = i + 1;
                if (isset((u_int8_t*)&val, i))
-                       setbit(ic->ic_chan_avail, i + 1);
+                       setbit(ic->ic_chan_avail, chan);
+               ic->ic_channels[chan].ic_freq =
+                   ieee80211_ieee2mhz(chan, IEEE80211_CHAN_2GHZ);
+               ic->ic_channels[chan].ic_flags = IEEE80211_CHAN_B;
        }
 
        if (sc->sc_firmware_type == WI_LUCENT) {
@@ -290,15 +295,18 @@
        /* Find default IBSS channel */
        buflen = sizeof(val);
        if (wi_read_rid(sc, WI_RID_OWN_CHNL, &val, &buflen) == 0)
-               ic->ic_ibss_chan = le16toh(val);
+               chan = le16toh(val);
        else {
                /* use lowest available channel */
-               for (i = 0; i < 16; i++) {
-                       if (isset(ic->ic_chan_avail, i))
+               for (chan = 0; chan < 16; chan++) {
+                       if (isset(ic->ic_chan_avail, chan))
                                break;
                }
-               ic->ic_ibss_chan = i;
        }
+       if (!isset(ic->ic_chan_avail, chan))
+               panic("%s: no available channel\n", sc->sc_dev.dv_xname);
+
+       ic->ic_ibss_chan = &ic->ic_channels[chan];
 
        /*
         * Set flags based on firmware version.
@@ -315,8 +323,8 @@
                if (sc->sc_sta_firmware_ver >= 60000)
                        sc->sc_flags |= WI_FLAGS_HAS_MOR;
                if (sc->sc_sta_firmware_ver >= 60006) {
-                       ic->ic_flags |= IEEE80211_F_HASIBSS;
-                       ic->ic_flags |= IEEE80211_F_HASMONITOR;
+                       ic->ic_caps |= IEEE80211_C_IBSS;
+                       ic->ic_caps |= IEEE80211_C_MONITOR;
                }
                sc->sc_ibss_port = 1;
                break;
@@ -329,9 +337,9 @@
                        sc->sc_flags |= WI_FLAGS_HAS_DBMADJUST;
                if (sc->sc_sta_firmware_ver >= 800) {
                        if (sc->sc_sta_firmware_ver != 10402)
-                               ic->ic_flags |= IEEE80211_F_HASHOSTAP;
-                       ic->ic_flags |= IEEE80211_F_HASIBSS;
-                       ic->ic_flags |= IEEE80211_F_HASMONITOR;
+                               ic->ic_caps |= IEEE80211_C_HOSTAP;
+                       ic->ic_caps |= IEEE80211_C_IBSS;
+                       ic->ic_caps |= IEEE80211_C_MONITOR;
                }
                sc->sc_ibss_port = 0;
                break;
@@ -339,7 +347,7 @@
        case WI_SYMBOL:
                sc->sc_flags |= WI_FLAGS_HAS_DIVERSITY;
                if (sc->sc_sta_firmware_ver >= 20000)
-                       ic->ic_flags |= IEEE80211_F_HASIBSS;
+                       ic->ic_caps |= IEEE80211_C_IBSS;
                sc->sc_ibss_port = 4;
                break;
        }
@@ -350,7 +358,7 @@
        buflen = sizeof(val);
        if (wi_read_rid(sc, WI_RID_WEP_AVAIL, &val, &buflen) == 0 &&
            val != htole16(0))
-               ic->ic_flags |= IEEE80211_F_HASWEP;
+               ic->ic_caps |= IEEE80211_C_WEP;
 
        /* Find supported rates. */
        buflen = sizeof(ratebuf);
@@ -358,7 +366,9 @@
                nrate = le16toh(*(u_int16_t *)ratebuf);
                if (nrate > IEEE80211_RATE_SIZE)
                        nrate = IEEE80211_RATE_SIZE;
-               memcpy(ic->ic_sup_rates, ratebuf + 2, nrate);
+               memcpy(ic->ic_sup_rates[IEEE80211_MODE_11B].rs_rates,
+                   ratebuf + 2, nrate);
+               ic->ic_sup_rates[IEEE80211_MODE_11B].rs_nrates = nrate;
        }
        buflen = sizeof(val);
 
@@ -375,8 +385,11 @@
        if_attach(ifp);
        ieee80211_ifattach(ifp);
 
-       ic->ic_media.ifm_status = wi_media_status;
-       ic->ic_media.ifm_change = wi_media_change;
+       sc->sc_newstate = ic->ic_newstate;
+       ic->ic_newstate = wi_newstate;
+       ic->ic_set_tim = wi_set_tim;
+
+       ieee80211_media_init(ifp, wi_media_change, wi_media_status);
 
        /* Attach is successful. */
        sc->sc_attached = 1;
@@ -584,7 +597,8 @@
        wi_write_val(sc, WI_RID_MAX_SLEEP, ic->ic_lintval);
        wi_write_ssid(sc, WI_RID_DESIRED_SSID, ic->ic_des_essid,
            ic->ic_des_esslen);
-       wi_write_val(sc, WI_RID_OWN_CHNL, ic->ic_ibss_chan);
+       wi_write_val(sc, WI_RID_OWN_CHNL,
+           ieee80211_chan2ieee(ic, ic->ic_ibss_chan));
        wi_write_ssid(sc, WI_RID_OWN_SSID, ic->ic_des_essid, ic->ic_des_esslen);
        IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(ifp->if_sadl));
        wi_write_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, IEEE80211_ADDR_LEN);
@@ -631,7 +645,7 @@
        }
 
        /* Configure WEP. */
-       if (ic->ic_flags & IEEE80211_F_HASWEP)
+       if (ic->ic_caps & IEEE80211_C_WEP)
                wi_write_wep(sc);
 
        /* Set multicast filter. */
@@ -660,10 +674,12 @@
        wi_cmd(sc, WI_CMD_ENABLE | sc->sc_portnum, 0, 0, 0);
        ifp->if_flags |= IFF_RUNNING;
        ifp->if_flags &= ~IFF_OACTIVE;
+       ic->ic_state = IEEE80211_S_INIT;
+
        if (ic->ic_opmode == IEEE80211_M_AHDEMO ||
            ic->ic_opmode == IEEE80211_M_MONITOR ||
            ic->ic_opmode == IEEE80211_M_HOSTAP)
-               wi_newstate(sc, IEEE80211_S_RUN);
+               ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 
        /* Enable interrupts */
        CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
@@ -678,12 +694,13 @@
 
        if (ic->ic_opmode == IEEE80211_M_STA &&
            ((ic->ic_flags & IEEE80211_F_DESBSSID) ||
-           ic->ic_des_chan != IEEE80211_CHAN_ANY)) {
+           ic->ic_des_chan != IEEE80211_CHAN_ANYC)) {
                memset(&join, 0, sizeof(join));
                if (ic->ic_flags & IEEE80211_F_DESBSSID)
                        IEEE80211_ADDR_COPY(&join.wi_bssid, ic->ic_des_bssid);
-               if (ic->ic_des_chan != IEEE80211_CHAN_ANY)
-                       join.wi_chan = htole16(ic->ic_des_chan);
+               if (ic->ic_des_chan != IEEE80211_CHAN_ANYC)
+                       join.wi_chan =
+                           htole16(ieee80211_chan2ieee(ic, ic->ic_des_chan));
                /* Lucent firmware does not support the JOIN RID. */
                if (sc->sc_firmware_type != WI_LUCENT)
                        wi_write_rid(sc, WI_RID_JOIN_REQ, &join, sizeof(join));
@@ -702,6 +719,7 @@
 wi_stop(struct ifnet *ifp, int disable)
 {
        struct wi_softc *sc = ifp->if_softc;
+       struct ieee80211com *ic = &sc->sc_ic;
        int s;
 
        if (!sc->sc_enabled)
@@ -711,7 +729,7 @@
 
        DPRINTF(("wi_stop: disable %d\n", disable));
 
-       ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+       ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
        if (!sc->sc_invalid) {
                CSR_WRITE_2(sc, WI_INT_EN, 0);
                wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
@@ -752,6 +770,7 @@
        memset(&frmhdr, 0, sizeof(frmhdr));
        cur = sc->sc_txnext;
        for (;;) {
+               ni = ic->ic_bss;
                if (!IF_IS_EMPTY(&ic->ic_mgtq)) {
                        if (sc->sc_txd[cur].d_len != 0) {
                                ifp->if_flags |= IFF_OACTIVE;
@@ -762,6 +781,7 @@
                            (caddr_t)&frmhdr.wi_ehdr);
                        frmhdr.wi_ehdr.ether_type = 0;
                         wh = mtod(m0, struct ieee80211_frame *);
+                       /* TBD set ni = m0->m_pkthdr.rcvif */ 
                } else if (!IF_IS_EMPTY(&ic->ic_pwrsaveq)) {
                        struct llc *llc;
 
@@ -787,12 +807,15 @@
                        m_copydata(m0, 4, ETHER_ADDR_LEN * 2,
                            (caddr_t)&frmhdr.wi_ehdr);
                        frmhdr.wi_ehdr.ether_type = llc->llc_snap.ether_type;
+                       /* TBD set ni = m0->m_pkthdr.rcvif */ 
                } else {
-                       if (ic->ic_state != IEEE80211_S_RUN)
+                       if (ic->ic_state != IEEE80211_S_RUN) {
                                break;
+                       }
                        IFQ_POLL(&ifp->if_snd, m0);
-                       if (m0 == NULL)
+                       if (m0 == NULL) {
                                break;
+                       }
                        if (sc->sc_txd[cur].d_len != 0) {
                                ifp->if_flags |= IFF_OACTIVE;
                                break;
@@ -806,7 +829,7 @@
                                bpf_mtap(ifp->if_bpf, m0);
 #endif
 
-                       if ((m0 = ieee80211_encap(ifp, m0)) == NULL) {
+                       if ((m0 = ieee80211_encap(ifp, m0, &ni)) == NULL) {
                                ifp->if_oerrors++;



Home | Main Index | Thread Index | Old Index