Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/net80211 Add and use mbuf context accessors



details:   https://anonhg.NetBSD.org/src-all/rev/fbf6607fe5c2
branches:  trunk
changeset: 949679:fbf6607fe5c2
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Thu Dec 10 18:07:58 2020 +0100

description:
Add and use mbuf context accessors

diffstat:

 sys/net80211/ieee80211_ageq.c   |  22 ++++------------------
 sys/net80211/ieee80211_hwmp.c   |   7 +------
 sys/net80211/ieee80211_mesh.c   |   6 +-----
 sys/net80211/ieee80211_netbsd.h |  10 ++++++++++
 sys/net80211/ieee80211_output.c |  12 ++----------
 sys/net80211/ieee80211_power.c  |   7 ++-----
 sys/net80211/ieee80211_superg.c |  11 +++++++----
 sys/net80211/ieee80211_wds.c    |  13 ++-----------
 8 files changed, 29 insertions(+), 59 deletions(-)

diffs (211 lines):

diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_ageq.c
--- a/sys/net80211/ieee80211_ageq.c     Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_ageq.c     Thu Dec 10 18:07:58 2020 +0100
@@ -96,14 +96,11 @@
 static void
 ageq_mfree(struct mbuf *m)
 {
-#ifdef __FreeBSD__             
        if (m->m_flags & M_ENCAP) {
-               struct ieee80211_node *ni = (void *) m->m_pkthdr.rcvif;
+               struct ieee80211_node *ni = IEEE80211_MBUF_GETNODE(m,
+                   struct ieee80211_node *);
                ieee80211_free_node(ni);
        }
-#elif __NetBSD__
-       /* NNN how does one free the rcvif??? */
-#endif
 
        m->m_nextpkt = NULL;
        m_freem(m);
@@ -227,22 +224,11 @@
        prev = &aq->aq_head;
        phead = &head;
        while ((m = *prev) != NULL) {
-#ifdef __FreeBSD__             
-               if (match != NULL && m->m_pkthdr.rcvif != (void *) match) {
+               if (match != NULL &&
+                   IEEE80211_MBUF_GETNODE(m, void*) != (void *) match) {
                        prev = &m->m_nextpkt;
                        continue;
                }
-#elif __NetBSD__
-               int s;
-               struct ifnet *ifp = m_get_rcvif(m,&s);
-               if ((void *)match != (void *)ifp) {
-                       prev = &m->m_nextpkt;
-                       m_put_rcvif(ifp,&s);
-                       continue;
-               }
-               m_put_rcvif(ifp,&s);
-                       
-#endif
                /*
                 * Adjust q length.
                 */
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_hwmp.c
--- a/sys/net80211/ieee80211_hwmp.c     Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_hwmp.c     Thu Dec 10 18:07:58 2020 +0100
@@ -2041,13 +2041,8 @@
                        IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest,
                            "%s", "queue frame until path found");
                        KASSERT((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#ifdef __FreeBSD__
-                       m->m_pkthdr.rcvif = (void *)(uintptr_t)
-                           ieee80211_mac_hash(ic, dest);
-#elif __NetBSD__
-                       m_set_rcvif(m,  (void *)(uintptr_t)
+                       IEEE80211_MBUF_SETNODE(m, (uintptr_t)
                            ieee80211_mac_hash(ic, dest));
-#endif                       
                        /* XXX age chosen randomly */
                        ieee80211_ageq_append(&ic->ic_stageq, m,
                            IEEE80211_INACT_WAIT);
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_mesh.c
--- a/sys/net80211/ieee80211_mesh.c     Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_mesh.c     Thu Dec 10 18:07:58 2020 +0100
@@ -1264,11 +1264,7 @@
 
        /* XXX do we know m_nextpkt is NULL? */
        KASSERT((mcopy->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#if __FreeBSD__
-       mcopy->m_pkthdr.rcvif = (void *) ni;
-#elif __NetBSD__
-       m_set_rcvif(mcopy,(void *)ni);
-#endif
+       IEEE80211_MBUF_SETNODE(mcopy, ni);
 
        /*
         * XXX this bypasses all of the VAP TX handling; it passes frames
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_netbsd.h
--- a/sys/net80211/ieee80211_netbsd.h   Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_netbsd.h   Thu Dec 10 18:07:58 2020 +0100
@@ -611,6 +611,16 @@
 #define        M_WME_GETAC(m)  ((m)->m_pkthdr.ether_vtag)
 
 /*
+ * Store a node pointer in the mbuf context
+ *
+ * FreeBSD version: 
+ *     (M)->m_pkthdr.rcvif = (void *)(N);
+ *     (T)(M)->m_pkthdr.rcvif
+ */
+#define IEEE80211_MBUF_SETNODE(M, N)   M_SETCTX(M, N)
+#define        IEEE80211_MBUF_GETNODE(M, T)    M_GETCTX(M, T)
+
+/*
  * Mbufs on the power save queue are tagged with an age and
  * timed out.  We reuse the hardware checksum field in the
  * mbuf packet header to store this data.
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c   Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_output.c   Thu Dec 10 18:07:58 2020 +0100
@@ -194,11 +194,7 @@
         * interface it (might have been) received on.
         */
        KASSERT((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#if __FreeBSD__
-       m->m_pkthdr.rcvif = (void *)ni;
-#elif __NetBSD__
-       m_set_rcvif(m, (void *)ni);
-#endif
+       IEEE80211_MBUF_SETNODE(m, ni);
        mcast = (m->m_flags & (M_MCAST | M_BCAST)) ? 1: 0;
 
        BPF_MTAP(ifp, m);               /* 802.3 tx */
@@ -603,11 +599,7 @@
         * it would if it were going via the normal path.
         */
        KASSERT((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#if __FreeBSD__
-       m->m_pkthdr.rcvif = (void *)ni;
-#elif __NetBSD__
-       m_set_rcvif(m, (void*)ni);
-#endif
+       IEEE80211_MBUF_SETNODE(m, ni);
 
        /*
         * Attempt to add bpf transmit parameters.
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_power.c
--- a/sys/net80211/ieee80211_power.c    Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_power.c    Thu Dec 10 18:07:58 2020 +0100
@@ -187,11 +187,8 @@
 psq_mfree(struct mbuf *m)
 {
        if (m->m_flags & M_ENCAP) {
-#ifdef __FreeBSD__
-               struct ieee80211_node *ni = (void *) m->m_pkthdr.rcvif;
-#elif __NetBSD__
-               struct ieee80211_node *ni = (void *) m_get_rcvif_NOMPSAFE(m);
-#endif
+               struct ieee80211_node *ni = IEEE80211_MBUF_GETNODE(m,
+                   struct ieee80211_node *);
                ieee80211_free_node(ni);
        }
        m->m_nextpkt = NULL;
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_superg.c
--- a/sys/net80211/ieee80211_superg.c   Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_superg.c   Thu Dec 10 18:07:58 2020 +0100
@@ -637,7 +637,8 @@
                next = m->m_nextpkt;
                m->m_nextpkt = NULL;
 
-               ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
+               ni = (struct ieee80211_node *) IEEE80211_MBUF_GETNODE(m,
+                   struct ieee80211_node *);
                vap = ni->ni_vap;
 
                IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni,
@@ -671,7 +672,8 @@
                int tid = WME_AC_TO_TID(M_WME_GETAC(m));
 
                /* clear staging ref to frame */
-               ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
+               ni = (struct ieee80211_node *) IEEE80211_MBUF_GETNODE(m,
+                   struct ieee80211_node *);
                KASSERT(ni->ni_tx_superg[tid] == m, ("staging queue empty"));
                ni->ni_tx_superg[tid] = NULL;
 
@@ -886,8 +888,9 @@
                 * Release the node reference; we only need
                 * the one already in mstaged.
                 */
-               KASSERT(mstaged->m_pkthdr.rcvif == (void *)ni,
-                   ("rcvif %p ni %p", mstaged->m_pkthdr.rcvif, ni));
+               KASSERTMSG(
+                   IEEE80211_MBUF_GETNODE(mstaged, void*) == (void *)ni,
+                   "rcvif %p ni %p", mstaged->m_pkthdr.rcvif, ni);
                ieee80211_free_node(ni);
 
                m->m_nextpkt = NULL;
diff -r 6c8346a410a7 -r fbf6607fe5c2 sys/net80211/ieee80211_wds.c
--- a/sys/net80211/ieee80211_wds.c      Thu Dec 10 17:35:39 2020 +0100
+++ b/sys/net80211/ieee80211_wds.c      Thu Dec 10 18:07:58 2020 +0100
@@ -321,11 +321,7 @@
                }
                mcopy->m_flags |= M_MCAST;
                KASSERT((mcopy->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#ifdef __FreeBSD__             
-               mcopy->m_pkthdr.rcvif = (void *) ni;
-#elif __NetBSD__
-               m_set_rcvif(mcopy, (void *)ni);
-#endif
+               IEEE80211_MBUF_SETNODE(mcopy, ni);
 
                err = ieee80211_parent_xmitpkt(ic, mcopy);
                IEEE80211_TX_UNLOCK(ic);
@@ -359,13 +355,8 @@
         * XXX per/vap beacon interval?
         */
        KASSERT((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
-#ifdef __FreeBSD__
-       m->m_pkthdr.rcvif = (void *)(uintptr_t)
-           ieee80211_mac_hash(ic, ni->ni_macaddr);
-#elif __NetBSD__
-       m_set_rcvif(m, (void *)(uintptr_t)
+       IEEE80211_MBUF_SETNODE(m, (uintptr_t)
            ieee80211_mac_hash(ic, ni->ni_macaddr));
-#endif
        (void) ieee80211_ageq_append(&ic->ic_stageq, m,
            ((ni->ni_intval * ic->ic_lintval) << 2) / 1024);
        ieee80211_notify_wds_discover(ni);



Home | Main Index | Thread Index | Old Index