Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/dev/pci Fill in more of raw xmit.



details:   https://anonhg.NetBSD.org/src-all/rev/ffffdcc249a1
branches:  trunk
changeset: 933673:ffffdcc249a1
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Thu May 21 01:10:08 2020 +1000

description:
Fill in more of raw xmit.

XXX Someone please review the errors returned for appropriateness.

diffstat:

 sys/dev/pci/if_iwn.c |  51 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 41 insertions(+), 10 deletions(-)

diffs (76 lines):

diff -r 0da16f7b57ff -r ffffdcc249a1 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c      Tue May 19 23:52:35 2020 +1000
+++ b/sys/dev/pci/if_iwn.c      Thu May 21 01:10:08 2020 +1000
@@ -3224,8 +3224,9 @@
        struct ieee80211vap *vap = ni->ni_vap;
        struct ieee80211com *ic = ni->ni_ic;
        struct iwn_softc *sc = ic->ic_softc;
+       struct ifnet *ifp = vap->iv_ifp;
        struct ether_header *eh;
-       int ac, error;
+       int ac;
 
        DPRINTFN(DBG_FN, ("%s: %s\n",device_xname(sc->sc_dev), __func__));
 
@@ -3234,22 +3235,52 @@
        KASSERT(sc != NULL);
        KASSERT(m != NULL);
 
-
+       if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+               return 0;
+
+       if (vap->iv_state != IEEE80211_S_RUN)
+               return ENXIO;
+
+       if (m->m_len < sizeof (*eh) &&
+           (m = m_pullup(m, sizeof (*eh))) == NULL) {
+               if_statinc(ifp, if_oerrors);
+                       return EIO;
+       }
        eh = mtod(m, struct ether_header *);
+       /* classify mbuf so we can find which tx ring to use */
+       if (ieee80211_classify(ni, m) != 0) {
+               m_freem(m);
+               ieee80211_free_node(ni);
+               if_statinc(ifp, if_oerrors);
+                       return ENOBUFS;
+       }
+
+       /* No QoS encapsulation for EAPOL frames. */
        ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ?
            M_WME_GETAC(m) : WME_AC_BE;
+
         bpf_mtap3(vap->iv_rawbpf, m, BPF_D_OUT);
 
-       error = iwn_tx(sc, m, ni, ac);
-       if (error != 0) {
-                if_statinc(vap->iv_ifp, if_oerrors);
-       } else {
-               sc->sc_tx_timer = 5;
-               vap->iv_ifp->if_timer = 1;
-       }
+       if ((m = ieee80211_encap(vap, ni, m)) == NULL) {
+               ieee80211_free_node(ni);
+               if_statinc(ifp, if_oerrors);
+               return ENOMEM;
+       }
+
+
+       if (iwn_tx(sc, m, ni, ac) != 0) {
+               ieee80211_free_node(ni);
+               if_statinc(ifp, if_oerrors);
+                       return ENXIO;
+       }
+
+       sc->sc_tx_timer = 5;
+       ifp->if_timer = 1;
+
        m_freem(m);
        ieee80211_free_node(ni);
-       return error;
+
+       return 0;
 }
 
 static int



Home | Main Index | Thread Index | Old Index