Source-Changes-HG archive

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

[src/trunk]: src/sys Use M_GETCTX and M_SETCTX instead of open-coding rcvif



details:   https://anonhg.NetBSD.org/src/rev/c561e71f86f3
branches:  trunk
changeset: 345278:c561e71f86f3
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon May 16 09:53:59 2016 +0000

description:
Use M_GETCTX and M_SETCTX instead of open-coding rcvif

No functional change.

diffstat:

 sys/altq/altq_rio.c             |  21 ++++-----------------
 sys/dev/ic/rtw.c                |  10 +++++-----
 sys/net80211/ieee80211_netbsd.c |   8 ++++----
 sys/net80211/ieee80211_output.c |  14 +++++++-------
 4 files changed, 20 insertions(+), 33 deletions(-)

diffs (175 lines):

diff -r 3357c97bd764 -r c561e71f86f3 sys/altq/altq_rio.c
--- a/sys/altq/altq_rio.c       Mon May 16 08:00:25 2016 +0000
+++ b/sys/altq/altq_rio.c       Mon May 16 09:53:59 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: altq_rio.c,v 1.22 2016/04/20 08:58:48 knakahara Exp $  */
+/*     $NetBSD: altq_rio.c,v 1.23 2016/05/16 09:53:59 ozaki-r Exp $    */
 /*     $KAME: altq_rio.c,v 1.19 2005/04/13 03:44:25 suz Exp $  */
 
 /*
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.22 2016/04/20 08:58:48 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rio.c,v 1.23 2016/05/16 09:53:59 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -326,19 +326,6 @@
 }
 #endif
 
-#if 1
-/*
- * kludge: when a packet is dequeued, we need to know its drop precedence
- * in order to keep the queue length of each drop precedence.
- * use m_pkthdr.rcvif to pass this info.
- */
-#define        RIOM_SET_PRECINDEX(m, idx)      \
-       do { (m)->m_pkthdr.rcvif = (struct ifnet *)((long)(idx)); } while (0)
-#define        RIOM_GET_PRECINDEX(m)   \
-       ({ long idx; idx = (long)((m)->m_pkthdr.rcvif); \
-       (m)->m_pkthdr.rcvif = NULL; idx; })
-#endif
-
 int
 rio_addq(rio_t *rp, class_queue_t *q, struct mbuf *m,
     struct altq_pktattr *pktattr)
@@ -436,7 +423,7 @@
                rp->rio_precstate[i].qlen++;
 
        /* save drop precedence index in mbuf hdr */
-       RIOM_SET_PRECINDEX(m, dpindex);
+       M_SETCTX(m, (intptr_t)dpindex);
 
        if (rp->rio_flags & RIOF_CLEARDSCP)
                dsfield &= ~DSCP_MASK;
@@ -461,7 +448,7 @@
        if ((m = _getq(q)) == NULL)
                return NULL;
 
-       dpindex = RIOM_GET_PRECINDEX(m);
+       dpindex = M_GETCTX(m, intptr_t);
        for (i = dpindex; i < RIO_NDROPPREC; i++) {
                if (--rp->rio_precstate[i].qlen == 0) {
                        if (rp->rio_precstate[i].idle == 0) {
diff -r 3357c97bd764 -r c561e71f86f3 sys/dev/ic/rtw.c
--- a/sys/dev/ic/rtw.c  Mon May 16 08:00:25 2016 +0000
+++ b/sys/dev/ic/rtw.c  Mon May 16 09:53:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtw.c,v 1.121 2014/02/25 18:30:09 pooka Exp $ */
+/* $NetBSD: rtw.c,v 1.122 2016/05/16 09:53:59 ozaki-r Exp $ */
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 David Young.  All rights
  * reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.121 2014/02/25 18:30:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.122 2016/05/16 09:53:59 ozaki-r Exp $");
 
 
 #include <sys/param.h>
@@ -1902,7 +1902,7 @@
                            "could not allocate beacon\n");
                        return;
                }
-               m->m_pkthdr.rcvif = (void *)ieee80211_ref_node(ic->ic_bss);
+               M_SETCTX(m, ieee80211_ref_node(ic->ic_bss));
                IF_ENQUEUE(&sc->sc_beaconq, m);
                rtw_start(&sc->sc_if);
        }
@@ -3062,8 +3062,8 @@
                return NULL;
        }
        IF_DEQUEUE(ifq, m);
-       *nip = (struct ieee80211_node *)m->m_pkthdr.rcvif;
-       m->m_pkthdr.rcvif = NULL;
+       *nip = M_GETCTX(m, struct ieee80211_node *);
+       M_SETCTX(m, NULL);
        KASSERT(*nip != NULL);
        return m;
 }
diff -r 3357c97bd764 -r c561e71f86f3 sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c   Mon May 16 08:00:25 2016 +0000
+++ b/sys/net80211/ieee80211_netbsd.c   Mon May 16 09:53:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.26 2014/04/07 00:07:40 pooka Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.27 2016/05/16 09:53:59 ozaki-r Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -30,7 +30,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.26 2014/04/07 00:07:40 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.27 2016/05/16 09:53:59 ozaki-r Exp $");
 #endif
 
 /*
@@ -515,10 +515,10 @@
                if (m == NULL)
                        break;
 
-               ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
+               ni = M_GETCTX(m, struct ieee80211_node *);
                KASSERT(ni != NULL);
                ieee80211_free_node(ni);
-               m->m_pkthdr.rcvif = NULL;
+               M_SETCTX(m, NULL);
 
                m_freem(m);
        }
diff -r 3357c97bd764 -r c561e71f86f3 sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c   Mon May 16 08:00:25 2016 +0000
+++ b/sys/net80211/ieee80211_output.c   Mon May 16 09:53:59 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_output.c,v 1.53 2015/08/24 22:21:26 pooka Exp $      */
+/*     $NetBSD: ieee80211_output.c,v 1.54 2016/05/16 09:53:59 ozaki-r Exp $    */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.53 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.54 2016/05/16 09:53:59 ozaki-r Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -185,9 +185,9 @@
        if (m == NULL)
                return ENOMEM;
 #ifdef __FreeBSD__
-       KASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
+       KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
 #endif
-       m->m_pkthdr.rcvif = (void *)ni;
+       M_SETCTX(m, ni);
 
        wh = mtod(m, struct ieee80211_frame *);
        ieee80211_send_setup(ic, ni, wh, 
@@ -247,7 +247,7 @@
                ieee80211_unref_node(&ni);
                return ENOMEM;
        }
-       m->m_pkthdr.rcvif = (void *) ni;
+       M_SETCTX(m, ni);
 
        wh = mtod(m, struct ieee80211_frame *);
        ieee80211_send_setup(ic, ni, wh,
@@ -1344,8 +1344,8 @@
        M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT);
        if (m == NULL)
                return ENOMEM;
-       IASSERT(m->m_pkthdr.rcvif == NULL, ("rcvif not null"));
-       m->m_pkthdr.rcvif = (void *)ni;
+       KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
+       M_SETCTX(m, ni);
 
        wh = mtod(m, struct ieee80211_frame *);
        ieee80211_send_setup(ic, ni, wh,



Home | Main Index | Thread Index | Old Index