Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/dev/usb Merge Nat's changes



details:   https://anonhg.NetBSD.org/src-all/rev/d56a2bbee861
branches:  trunk
changeset: 951013:d56a2bbee861
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Thu Jul 09 19:25:25 2020 +0200

description:
Merge Nat's changes

diffstat:

 sys/dev/pci/if_iwn.c   |  124 ++++++++++++++++++++++++------------------------
 sys/dev/usb/if_urtwn.c |  104 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 160 insertions(+), 68 deletions(-)

diffs (truncated from 907 to 300 lines):

diff -r 726457105d6d -r d56a2bbee861 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c      Thu Jul 09 19:12:43 2020 +0200
+++ b/sys/dev/pci/if_iwn.c      Thu Jul 09 19:25:25 2020 +0200
@@ -221,7 +221,7 @@
 #ifdef notyet
 static void    iwn5000_reset_sched(struct iwn_softc *, int, int);
 #endif
-static int     iwn_tx(struct iwn_softc *, struct mbuf *,
+static int     iwn_tx(struct ieee80211vap *, struct mbuf *,
                    struct ieee80211_node *, int);
 static void    iwn_start(struct ifnet *);
 static void    iwn_watchdog(struct ifnet *);
@@ -648,6 +648,10 @@
 
        ic->ic_txstream = sc->ntxchains;
        ic->ic_rxstream = sc->nrxchains;
+       if (ic->ic_rxstream > 2)
+               ic->ic_rxstream = 2;
+       if (ic->ic_txstream > 2)
+               ic->ic_txstream = 2;
 
        ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 
@@ -757,9 +761,7 @@
 static int
 iwn_reset(struct ieee80211vap *vap, u_long arg)
 {
-       struct ifnet *ifp = vap->iv_ifp;
-       struct iwn_softc *sc = ifp->if_softc;
-       struct ieee80211com *ic = &sc->sc_ic;
+       struct ieee80211com *ic = vap->iv_ic;
 
        if (ic->ic_opmode != IEEE80211_M_MONITOR)
                return ENETRESET;
@@ -807,6 +809,10 @@
        
        ieee80211_scan_done(vap);
 
+       IEEE80211_LOCK(ic);
+       ieee80211_cancel_scan(vap);
+       IEEE80211_UNLOCK(ic);
+
        if (vap->iv_state == IEEE80211_S_RUN) {
                /* Set link LED to ON status if we are associated */
                iwn_set_led(sc, IWN_LED_LINK, 0, 1);
@@ -846,6 +852,8 @@
        struct ieee80211com *ic = vap->iv_ic;
        int error;
 
+       ss->ss_flags |= IEEE80211_SCAN_ONCE;
+
        error = iwn_scan(ic, ss);
        if (error != 0) {
                IEEE80211_LOCK(ic);
@@ -2148,7 +2156,7 @@
 {
        struct ieee80211com *ic = vap->iv_ic;
        struct iwn_softc *sc = ic->ic_softc;
-       //struct ifnet *ifp = vap->iv_ifp;
+       struct ifnet *ifp = vap->iv_ifp;
        int error;
 
        enum ieee80211_state ostate = vap->iv_state;
@@ -2156,7 +2164,9 @@
        callout_stop(&sc->scan_to);
        callout_stop(&sc->calib_to);
 
+#ifdef IEEE80211_DEBUG
        vap->iv_debug = ieee80211_debug;
+#endif
        switch (nstate) {
        case IEEE80211_S_SCAN:
 #if 0
@@ -2237,11 +2247,11 @@
                sc->sc_flags &= ~IWN_FLAG_SCANNING;
                sc->calib.state = IWN_CALIB_STATE_INIT;
                break;
-#if 0
                /*
                 * Purge the xmit queue so we don't have old frames
                 * during a new association attempt.
                 */
+               iwn_stop(ifp, 0);
                error = iwn_init(ifp);
                if (error)
                        return error;
@@ -2249,7 +2259,6 @@
                ifp->if_flags &= ~IFF_OACTIVE;
                iwn_start(ifp);
                break;
-#endif
        }
 
        error = (*sc->sc_newstate)(vap, nstate, arg);
@@ -2503,7 +2512,7 @@
                }
                /* push the frame up to the 802.11 stack */
                /* NNN Convert rssi to -10 to 110 ? for 802.11 layer */
-               ieee80211_input(ni, m, rssi, 0);
+               ieee80211_input(ni, m, rssi + 116, 0);
 
                /* Node is no longer needed. */
                ieee80211_free_node(ni);
@@ -2511,10 +2520,8 @@
        } else {
 
                /* No node found ... process differently. */
-               (void) ieee80211_input_all(ic, m, rssi, 0);
-       }
-
-       m_free(m);
+               (void) ieee80211_input_all(ic, m, rssi + 116, 0);
+       }
        splx(s);
 }
 
@@ -3255,10 +3262,10 @@
        KASSERT(sc != NULL);
        KASSERT(m != NULL);
 
-#if 0
        if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
                return 0;
 
+#if 0
        if (vap->iv_state != IEEE80211_S_RUN)
                return ENXIO;
 #endif
@@ -3269,7 +3276,14 @@
                        return EIO;
        }
        eh = mtod(m, struct ether_header *);
+
 #if 0
+       if ((m = ieee80211_encap(vap, ni, m)) == NULL) {
+               ieee80211_free_node(ni);
+               if_statinc(ifp, if_oerrors);
+               return ENOMEM;
+       }
+
        /* classify mbuf so we can find which tx ring to use */
        if (ieee80211_classify(ni, m) != 0) {
                m_freem(m);
@@ -3285,16 +3299,7 @@
 
         bpf_mtap3(vap->iv_rawbpf, m, BPF_D_OUT);
 
-#if 0
-       if ((m = ieee80211_encap(vap, ni, m)) == NULL) {
-               ieee80211_free_node(ni);
-               if_statinc(ifp, if_oerrors);
-               return ENOMEM;
-       }
-#endif
-
-
-       if (iwn_tx(sc, m, ni, ac) != 0) {
+       if (iwn_tx(vap, m, ni, ac) != 0) {
                ieee80211_free_node(ni);
                if_statinc(ifp, if_oerrors);
                        return ENXIO;
@@ -3312,10 +3317,10 @@
 }
 
 static int
-iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+iwn_tx(struct ieee80211vap *vap, struct mbuf *m, struct ieee80211_node *ni, int ac)
+{
+       struct ieee80211com *ic = vap->iv_ic;
+       struct iwn_softc *sc = ic->ic_softc;
        //struct iwn_node *wn = (void *)ni;
        struct iwn_tx_ring *ring;
        struct iwn_tx_desc *desc;
@@ -3375,24 +3380,6 @@
                ridx = wn->ridx[ni->ni_txrate];
        rinfo = &iwn_rates[ridx];
 
-       /* Encrypt the frame if need be. */
-       /*
-        * XXX For now, NetBSD swaps the encryption and bpf sections
-        * in order to match old code and other drivers. Tests with
-        * tcpdump indicates that the order is irrelevant, however,
-        * as bpf produces unencrypted data for both ordering choices.
-        */
-       if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
-               k = ieee80211_crypto_encap(ni, m);
-               if (k == NULL) {
-                       m_freem(m);
-                       return ENOBUFS;
-               }
-               /* Packet header may have moved, reset our local pointer. */
-               wh = mtod(m, struct ieee80211_frame *);
-       }
-       totlen = m->m_pkthdr.len;
-
        if (sc->sc_drvbpf != NULL) {
                struct iwn_tx_radiotap_header *tap = &sc->sc_txtap;
 
@@ -3407,6 +3394,18 @@
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m, BPF_D_OUT);
        }
 
+       /* Encrypt the frame if need be. */
+       if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
+               k = ieee80211_crypto_encap(ni, m);
+               if (k == NULL) {
+                       m_freem(m);
+                       return ENOBUFS;
+               }
+               /* Packet header may have moved, reset our local pointer. */
+               wh = mtod(m, struct ieee80211_frame *);
+       }
+       totlen = m->m_pkthdr.len;
+
        /* Prepare TX firmware command. */
        cmd = &ring->cmd[ring->cur];
        cmd->code = IWN_CMD_TX_DATA;
@@ -3655,6 +3654,14 @@
                        if_statinc(ifp, if_oerrors);
                        continue;
                }
+
+#if 0
+               if ((m = ieee80211_encap(vap, ni, m)) == NULL) {
+                       ieee80211_free_node(ni);
+                       if_statinc(ifp, if_oerrors);
+                       continue;
+               }
+
                /* classify mbuf so we can find which tx ring to use */
                if (ieee80211_classify(ni, m) != 0) {
                        m_freem(m);
@@ -3662,6 +3669,7 @@
                        if_statinc(ifp, if_oerrors);
                        continue;
                }
+#endif
 
                /* No QoS encapsulation for EAPOL frames. */
                ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ?
@@ -3669,19 +3677,13 @@
 
                if (sc->sc_beacon_wait == 0)
                        bpf_mtap(ifp, m, BPF_D_OUT);
-
-               if ((m = ieee80211_encap(vap, ni, m)) == NULL) {
-                       ieee80211_free_node(ni);
-                       if_statinc(ifp, if_oerrors);
-                       continue;
-               }
 sendit:
                if (sc->sc_beacon_wait)
                        continue;
 
                //bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
 
-               if (iwn_tx(sc, m, ni, ac) != 0) {
+               if (iwn_tx(vap, m, ni, ac) != 0) {
                        ieee80211_free_node(ni);
                        if_statinc(ifp, if_oerrors);
                        continue;
@@ -3768,7 +3770,7 @@
                error = 0;
                if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
                    (IFF_UP | IFF_RUNNING)) {
-//                     iwn_stop(ifp, 0);
+                       iwn_stop(ifp, 0);
                        iwn_init(ifp);
                }
                error = 0;
@@ -6884,11 +6886,6 @@
        ifp->if_flags &= ~IFF_OACTIVE;
        ifp->if_flags |= IFF_RUNNING;
 
-       if (ic->ic_opmode == IEEE80211_M_MONITOR)
-               ieee80211_new_state(vap, IEEE80211_S_RUN, -1);
-       else if (vap->iv_roaming != IEEE80211_ROAMING_MANUAL)
-               ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
-
        iwn_init_channels(ic);
        ieee80211_chan_init(ic);
        ieee80211_media_status(ifp, &imr);
@@ -6899,7 +6896,12 @@
        sc->sc_flags |= IWN_FLAG_HW_INITED;
 out:
        mutex_exit(&sc->sc_mtx);
-       ieee80211_init(ifp);
+
+       if (ic->ic_opmode == IEEE80211_M_MONITOR)
+               ieee80211_new_state(vap, IEEE80211_S_RUN, -1);
+       else if (vap->iv_roaming != IEEE80211_ROAMING_MANUAL)
+               ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
+
        return 0;
 
 fail:  mutex_exit(&sc->sc_mtx);
@@ -6920,13 +6922,13 @@



Home | Main Index | Thread Index | Old Index