Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/net80211 Use our own abstractions and fix output s...



details:   https://anonhg.NetBSD.org/src-all/rev/21a3ccdf4ccc
branches:  trunk
changeset: 947490:21a3ccdf4ccc
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Mon Dec 14 15:56:13 2020 +0100

description:
Use our own abstractions and fix output statistics.

diffstat:

 sys/net80211/ieee80211_netbsd.c |  23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r 568e29012da4 -r 21a3ccdf4ccc sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c   Mon Dec 14 15:31:03 2020 +0100
+++ b/sys/net80211/ieee80211_netbsd.c   Mon Dec 14 15:56:13 2020 +0100
@@ -621,7 +621,7 @@
                if (m == NULL)
                        break;
 
-               ni = (struct ieee80211_node *)m_get_rcvif_NOMPSAFE(m);
+               ni = IEEE80211_MBUF_GETNODE(m, struct ieee80211_node *);
                KASSERTMSG(ni != NULL, "frame w/o node");
                ieee80211_free_node(ni);
                ieee80211_free_mbuf(m);
@@ -637,7 +637,7 @@
        IFQ_LOCK(ifq);
        mprev = &ifq->ifq_head;
        while ((m = *mprev) != NULL) {
-               ni = (struct ieee80211_node *)m_get_rcvif_NOMPSAFE(m);
+               ni = IEEE80211_MBUF_GETNODE(m, struct ieee80211_node *);
                if (ni != NULL && ni->ni_vap == vap) {
                        *mprev = m->m_nextpkt;          /* remove from list */
                        ifq->ifq_len--;
@@ -905,7 +905,14 @@
 int
 ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m)
 {
+       struct ieee80211_node *ni;
+       struct ifnet *ifp;
+       size_t pktlen = m->m_pkthdr.len;
        int error;
+       bool mcast = (m->m_flags & M_MCAST) != 0;
+
+       ni = IEEE80211_MBUF_GETNODE(m, struct ieee80211_node *);
+       ifp = ni->ni_vap->iv_ifp;
 
        /*
         * Assert the IC TX lock is held - this enforces the
@@ -914,14 +921,16 @@
        IEEE80211_TX_LOCK_ASSERT(ic);
        error = ic->ic_transmit(ic, m);
        if (error) {
-               struct ieee80211_node *ni;
-
-               ni = (struct ieee80211_node *)m_get_rcvif_NOMPSAFE(m);
-
                /* XXX number of fragments */
-               if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
+               if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                ieee80211_free_node(ni);
                ieee80211_free_mbuf(m);
+       } else {
+               net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+               if_statadd_ref(nsr, if_obytes, pktlen);
+               if (mcast)
+                       if_statinc_ref(nsr, if_omcasts);
+               IF_STAT_PUTREF(ni->ni_vap->iv_ifp);
        }
        return (error);
 }



Home | Main Index | Thread Index | Old Index