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 Modify function for ipw_transmit and raw_x...



details:   https://anonhg.NetBSD.org/src-all/rev/fe8f606e913e
branches:  trunk
changeset: 369363:fe8f606e913e
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Mon Mar 07 17:01:45 2022 +1100

description:
Modify function for ipw_transmit and raw_xmit.

diffstat:

 sys/dev/pci/if_ipw.c |  69 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 44 insertions(+), 25 deletions(-)

diffs (147 lines):

diff -r 76dd09d1ff93 -r fe8f606e913e sys/dev/pci/if_ipw.c
--- a/sys/dev/pci/if_ipw.c      Sat Mar 05 19:50:41 2022 +0100
+++ b/sys/dev/pci/if_ipw.c      Mon Mar 07 17:01:45 2022 +1100
@@ -112,8 +112,9 @@
 static int     ipw_intr(void *);
 static void    ipw_softintr(void *);
 static int     ipw_cmd(struct ipw_softc *, uint32_t, void *, uint32_t);
-static int     ipw_tx_start(struct ifnet *, struct mbuf *,
-                   struct ieee80211_node *);
+static int     ipw_transmit(struct ieee80211com *, struct mbuf *);
+static int     ipw_raw_xmit(struct ieee80211node *, struct mbuf *,
+                   const struct ieee80211_bpf_params *);
 static void    ipw_start(struct ifnet *);
 static void    ipw_watchdog(struct ifnet *);
 static int     ipw_get_table1(struct ipw_softc *, uint32_t *);
@@ -333,6 +334,8 @@
        ic->ic_vap_delete = ipw_vap_delete;
        ic->ic_getradiocaps = ipw_get_radiocaps;
        ic->ic_parent = ipw_parent;
+       ic->ic_transmit = ipw_transmit;
+       ic->ic_raw_xmit = ipw_raw_xmit;
 
        ieee80211_media_init(ic, ipw_media_change, ipw_media_status);
 
@@ -1451,10 +1454,27 @@
 }
 
 static int
-ipw_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni)
+ipw_transmit(struct ieee80211com *ic, struct mbuf *m)
 {
-       struct ipw_softc *sc = ifp->if_softc;
-       struct ieee80211com *ic = &sc->sc_ic;
+       struct ipw_softc *sc = ic->ic_softc;
+       int s;
+ 
+       s = splnet();
+       IF_ENQUEUE(&sc->sc_sendq, m);
+       splx(s);
+   
+       if (!(sc->sc_flags & IPW_FLAG_TX_RUNNING))
+               ipw_start(sc);
+    
+       return 0;
+}
+
+static int
+ipw_raw_xmit(struct ieee80211node *ni, struct mbuf *m0,
+           const struct ieee80211_bpf_params *bpfp);
+{
+       struct ieee80211com *ic = ni->ni_ic;
+       struct ipw_softc *sc = ic->ic_softc;
        struct ieee80211_frame *wh;
        struct ipw_soft_bd *sbd;
        struct ipw_soft_hdr *shdr;
@@ -1465,8 +1485,8 @@
 
        wh = mtod(m0, struct ieee80211_frame *);
 
-       if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
-               k = ieee80211_crypto_encap(ic, ni, m0);
+       if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
+               k = ieee80211_crypto_encap(ni, m0);
                if (k == NULL) {
                        m_freem(m0);
                        return ENOBUFS;
@@ -1476,12 +1496,6 @@
                wh = mtod(m0, struct ieee80211_frame *);
        }
 
-       if (sc->sc_drvbpf != NULL) {
-               struct ipw_tx_radiotap_header *tap = &sc->sc_txtap;
-
-               bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0, BPF_D_OUT);
-       }
-
        shdr = TAILQ_FIRST(&sc->sc_free_shdr);
        sbuf = TAILQ_FIRST(&sc->sc_free_sbuf);
        KASSERT(shdr != NULL && sbuf != NULL);
@@ -1614,25 +1628,30 @@
 }
 
 static void
-ipw_start(struct ifnet *ifp)
+ipw_start(struct ipw_softc *sc)
 {
-       struct ipw_softc *sc = ifp->if_softc;
        struct ieee80211com *ic = &sc->sc_ic;
+       struct ieee80211vap *vap;
        struct mbuf *m0;
        struct ether_header *eh;
        struct ieee80211_node *ni;
 
-       if (ic->ic_state != IEEE80211_S_RUN)
+       if (sc->sc_flags & IPW_FLAG_TX_RUNNING)
                return;
 
        for (;;) {
-               IF_DEQUEUE(&ifp->if_snd, m0);
+               /* Encapsulate and send data frames. */
+               IFQ_DEQUEUE(&sc->sc_sendq, m0);
                if (m0 == NULL)
                        break;
 
+               ni = M_GETCTX(m0, struct ieee80211_node *);
+               M_CLEARCTX(m0);
+               vap = ni->ni_vap;
+
                if (sc->txfree < 1 + IPW_MAX_NSEG) {
-                       IF_PREPEND(&ifp->if_snd, m0);
-                       ifp->if_flags |= IFF_OACTIVE;
+                       IF_PREPEND(&sc->sc_sendq, m0);
+                       vap->iv_flags |= IFF_OACTIVE;
                        break;
                }
 
@@ -1641,13 +1660,12 @@
                        continue;
 
                eh = mtod(m0, struct ether_header *);
-               ni = ieee80211_find_txnode(ic, eh->ether_dhost);
                if (ni == NULL) {
                        m_freem(m0);
                        continue;
                }
 
-               bpf_mtap(ifp, m0, BPF_D_OUT);
+               bpf_mtap(vap->iv_ifp, m0, BPF_D_OUT);
 
                m0 = ieee80211_encap(ic, m0, ni);
                if (m0 == NULL) {
@@ -1657,10 +1675,11 @@
 
                bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
 
-               if (ipw_tx_start(ifp, m0, ni) != 0) {
-                       ieee80211_free_node(ni);
-                       if_statinc(ifp, if_oerrors);
-                       break;
+               if (ipw_raw_xmit(ni, m0, NULL) != 0) {
+                       ieee80211_tx_complete(ni, m0, 1);
+                       if (vap != NULL)
+                               if_statinc(vap->iv_ifp, if_oerrors);
+                       continue;
                }
 
                /* start watchdog timer */



Home | Main Index | Thread Index | Old Index