Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Partially fix. Now it comes up, associates with ...



details:   https://anonhg.NetBSD.org/src/rev/5be697bcaf99
branches:  trunk
changeset: 583333:5be697bcaf99
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 30 21:15:51 2005 +0000

description:
Partially fix. Now it comes up, associates with wep, but something is wrong
with tcp since it crashes in wep encryption when I cvs update.

diffstat:

 sys/dev/pci/if_iwi.c    |  266 ++++++++++++++++++++++++++++++-----------------
 sys/dev/pci/if_iwireg.h |   24 ++-
 sys/dev/pci/if_iwivar.h |    8 +-
 3 files changed, 187 insertions(+), 111 deletions(-)

diffs (truncated from 705 to 300 lines):

diff -r b5b4f92d75d4 -r 5be697bcaf99 sys/dev/pci/if_iwi.c
--- a/sys/dev/pci/if_iwi.c      Sat Jul 30 17:37:11 2005 +0000
+++ b/sys/dev/pci/if_iwi.c      Sat Jul 30 21:15:51 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwi.c,v 1.11 2005/07/07 00:43:01 dyoung Exp $  */
+/*     $NetBSD: if_iwi.c,v 1.12 2005/07/30 21:15:51 christos Exp $  */
 
 /*-
  * Copyright (c) 2004, 2005
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.11 2005/07/07 00:43:01 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.12 2005/07/30 21:15:51 christos Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2915ABG driver
@@ -123,7 +123,6 @@
 static int iwi_auth_and_assoc(struct iwi_softc *);
 static int iwi_init(struct ifnet *);
 static void iwi_stop(struct ifnet *, int);
-static int iwi_key_alloc(struct ieee80211com *, const struct ieee80211_key *);
 
 static __inline u_int8_t MEM_READ_1(struct iwi_softc *sc, u_int32_t addr)
 {
@@ -249,12 +248,12 @@
 
        ic->ic_ifp = ifp;
        ic->ic_phytype = IEEE80211_T_OFDM;
-       ic->ic_opmode = IEEE80211_M_STA;
-       ic->ic_state = IEEE80211_S_INIT;
+       ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
+       ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */
 
        /* set device capabilities */
-       ic->ic_caps = IEEE80211_C_IBSS | IEEE80211_C_PMGT | IEEE80211_C_WEP |
-           IEEE80211_C_TXPMGT | IEEE80211_C_SHPREAMBLE | IEEE80211_C_MONITOR;
+       ic->ic_caps = IEEE80211_C_WPA | IEEE80211_C_PMGT | IEEE80211_C_TXPMGT |
+           IEEE80211_C_SHPREAMBLE | IEEE80211_C_MONITOR;
 
        /* read MAC address from EEPROM */
        val = iwi_read_prom_word(sc, IWI_EEPROM_MAC + 0);
@@ -280,7 +279,7 @@
                            ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ);
                        ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A;
                }
-               for (i = 149; i <= 161; i += 4) {
+               for (i = 149; i <= 165; i += 4) {
                        ic->ic_channels[i].ic_freq =
                            ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ);
                        ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A;
@@ -300,12 +299,6 @@
                    IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
        }
 
-       /* default to authmode OPEN */
-       sc->authmode = IEEE80211_AUTH_OPEN;
-
-       /* IBSS channel undefined for now */
-       ic->ic_ibss_chan = &ic->ic_channels[0];
-
        ifp->if_softc = sc;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        ifp->if_init = iwi_init;
@@ -321,7 +314,6 @@
        /* override state transition machine */
        sc->sc_newstate = ic->ic_newstate;
        ic->ic_newstate = iwi_newstate;
-       ic->ic_crypto.cs_key_alloc = iwi_key_alloc;
        ieee80211_media_init(ic, iwi_media_change, iwi_media_status);
 
 #if NBPFILTER > 0
@@ -336,6 +328,13 @@
        sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
        sc->sc_txtap.wt_ihdr.it_present = htole32(IWI_TX_RADIOTAP_PRESENT);
 #endif
+       /*
+        * Add a few sysctl knobs.
+        * XXX: Not yet.
+        */
+       sc->dwelltime = 100;
+       sc->bluetooth = 1;
+       sc->antenna = 0;
 }
 
 static int
@@ -557,15 +556,6 @@
 }
 
 static int
-iwi_key_alloc(struct ieee80211com *ic, const struct ieee80211_key *k)
-{
-       if (k >= &ic->ic_nw_keys[0] && k < &ic->ic_nw_keys[IEEE80211_WEP_NKID])
-               return k - ic->ic_nw_keys;
-
-       return IEEE80211_KEYIX_NONE;
-}
-
-static int
 iwi_media_change(struct ifnet *ifp)
 {
        int error;
@@ -646,6 +636,12 @@
 
        switch (nstate) {
        case IEEE80211_S_SCAN:
+               if (sc->flags & IWI_FLAG_SCANNING)
+                       break;
+
+               ieee80211_node_table_reset(&ic->ic_scan);
+               ic->ic_flags |= IEEE80211_F_SCAN | IEEE80211_F_ASCAN;
+               sc->flags |= IWI_FLAG_SCANNING;
                iwi_scan(sc);
                break;
 
@@ -658,10 +654,16 @@
                        ieee80211_new_state(ic, IEEE80211_S_AUTH, -1);
                else if (ic->ic_opmode == IEEE80211_M_MONITOR)
                        iwi_set_chan(sc, ic->ic_ibss_chan);
+
+               return (*sc->sc_newstate)(ic, nstate,
+                   IEEE80211_FC0_SUBTYPE_ASSOC_RESP);
                break;
 
        case IEEE80211_S_ASSOC:
+               break;
+
        case IEEE80211_S_INIT:
+               sc->flags &= ~IWI_FLAG_SCANNING;
                break;
        }
 
@@ -767,9 +769,9 @@
     struct iwi_frame *frame)
 {
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ifnet *ifp = &sc->sc_if;
+       struct ifnet *ifp = ic->ic_ifp;
        struct mbuf *m;
-       struct ieee80211_frame_min *wh;
+       struct ieee80211_frame *wh;
        struct ieee80211_node *ni;
        int error;
 
@@ -780,7 +782,7 @@
            sizeof (struct iwi_frame) + le16toh(frame->len),
            BUS_DMASYNC_POSTREAD);
 
-       if (le16toh(frame->len) < sizeof (struct ieee80211_frame_min) ||
+       if (le16toh(frame->len) < sizeof (struct ieee80211_frame) ||
            le16toh(frame->len) > MCLBYTES) {
                aprint_error("%s: bad frame length\n", sc->sc_dev.dv_xname);
        }
@@ -795,24 +797,32 @@
 
        m_adj(m, sizeof (struct iwi_hdr) + sizeof (struct iwi_frame));
 
-       wh = mtod(m, struct ieee80211_frame_min *);
+       if (ic->ic_state == IEEE80211_S_SCAN)
+               iwi_fix_channel(ic, m);
 
 #if NBPFILTER > 0
        if (sc->sc_drvbpf != NULL) {
                struct iwi_rx_radiotap_header *tap = &sc->sc_rxtap;
+               tap->wr_flags = 0;
+               tap->wr_rate = frame->rate;
+               tap->wr_chan_freq =
+                   htole16(ic->ic_channels[frame->chan].ic_freq);
+               tap->wr_chan_flags =
+                   htole16(ic->ic_channels[frame->chan].ic_flags);
+               tap->wr_antsignal = frame->signal;
+               tap->wr_antenna = frame->antenna;
 
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m);
        }
 #endif
 
-       if (ic->ic_state == IEEE80211_S_SCAN)
-               iwi_fix_channel(ic, m);
-
-       ni = ieee80211_find_rxnode(ic, wh);
+       wh = mtod(m, struct ieee80211_frame *);
+       ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
 
        /* Send the frame to the upper layer */
-       ieee80211_input(ic, m, ni, IWI_RSSIDBM2RAW(frame->rssi_dbm), 0);
+       ieee80211_input(ic, m, ni, frame->rssi_dbm, 0);
 
+       /* node is no longer needed */
        ieee80211_free_node(ni);
 
        MGETHDR(buf->m, M_DONTWAIT, MT_DATA);
@@ -872,9 +882,10 @@
                    scan->status));
 
                /* monitor mode uses scan to set the channel ... */
-               if (ic->ic_opmode != IEEE80211_M_MONITOR)
+               if (ic->ic_opmode != IEEE80211_M_MONITOR) {
+                       sc->flags &= ~IWI_FLAG_SCANNING;
                        ieee80211_end_scan(ic);
-               else
+               } else
                        iwi_set_chan(sc, ic->ic_ibss_chan);
                break;
 
@@ -885,6 +896,7 @@
 
                switch (auth->state) {
                case IWI_AUTHENTICATED:
+                       ieee80211_node_authorize(ic, ic->ic_bss);
                        ieee80211_new_state(ic, IEEE80211_S_ASSOC, -1);
                        break;
 
@@ -904,12 +916,16 @@
                    assoc->status));
 
                switch (assoc->state) {
+               case IWI_AUTHENTICATED:
+                       /* re-association, do nothing */
+                       break;
+
                case IWI_ASSOCIATED:
                        ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
                        break;
 
                case IWI_DEASSOCIATED:
-                       ieee80211_begin_scan(ic, 0);
+                       ieee80211_begin_scan(ic, 1);
                        break;
 
                default:
@@ -992,6 +1008,7 @@
                buf->ni = NULL;
 
                sc->tx_queued--;
+               ifp->if_opackets++;
 
                /* kill watchdog timer */
                sc->sc_tx_timer = 0;
@@ -1082,19 +1099,29 @@
 {
        struct iwi_softc *sc = ifp->if_softc;
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211_frame *wh;
+       struct ieee80211_frame wh;
+       struct ieee80211_key *k;
        struct iwi_tx_buf *buf;
        struct iwi_tx_desc *desc;
        struct mbuf *mnew;
        int error, i;
 
+       (void)memcpy(&wh, mtod(m0, struct ieee80211_frame *), sizeof(wh));
+       if (wh.i_fc[1] & IEEE80211_FC1_WEP) {
+               k = ieee80211_crypto_encap(ic, ni, m0);
+               if (k == NULL) {
+                       m_freem(m0);
+                       return ENOBUFS;
+               }
+       }
+
 #if NBPFILTER > 0
        if (sc->sc_drvbpf != NULL) {
                struct iwi_tx_radiotap_header *tap = &sc->sc_txtap;
 
                tap->wt_flags = 0;
-               tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
-               tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
+               tap->wt_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
+               tap->wt_chan_flags = htole16(ic->ic_ibss_chan->ic_flags);
 
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0);
        }
@@ -1103,8 +1130,6 @@
        buf = &sc->tx_buf[sc->tx_cur];
        desc = &sc->tx_desc[sc->tx_cur];
 
-       wh = mtod(m0, struct ieee80211_frame *);
-
        /* trim IEEE802.11 header */
        m_adj(m0, sizeof (struct ieee80211_frame));
 
@@ -1154,23 +1179,22 @@
        desc->hdr.flags = IWI_HDR_FLAG_IRQ;
        desc->cmd = IWI_DATA_CMD_TX;
        desc->len = htole16(m0->m_pkthdr.len);
+       (void)memcpy(&desc->wh, &wh, sizeof (struct ieee80211_frame));
        desc->flags = 0;
-       if (ic->ic_opmode == IEEE80211_M_IBSS) {
-               if (!IEEE80211_IS_MULTICAST(wh->i_addr1))
-                       desc->flags |= IWI_DATA_FLAG_NEED_ACK;
-       } else if (!IEEE80211_IS_MULTICAST(wh->i_addr3))
+       if (!IEEE80211_IS_MULTICAST(wh.i_addr1))
                desc->flags |= IWI_DATA_FLAG_NEED_ACK;
 
+#if 0
        if (ic->ic_flags & IEEE80211_F_PRIVACY) {
-               wh->i_fc[1] |= IEEE80211_FC1_WEP;
-               desc->wep_txkey = ic->ic_def_txkey;
+               wh.i_fc[1] |= IEEE80211_FC1_WEP;



Home | Main Index | Thread Index | Old Index